Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bertdeblock committed Mar 8, 2024
0 parents commit 5bccc34
Show file tree
Hide file tree
Showing 33 changed files with 4,592 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist/
/test/output/
14 changes: 14 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";

module.exports = {
env: { node: true },
extends: [
"eslint:recommended",
"plugin:n/recommended",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: { ecmaVersion: "latest" },
plugins: ["@typescript-eslint"],
root: true,
};
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
pull_request: {}
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wyvox/action-setup-pnpm@v3
- run: pnpm lint

test:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: wyvox/action-setup-pnpm@v3
- run: pnpm test:coverage
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/coverage/
/dist/
/node_modules/
/test/output/
/.eslintcache
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.scaffdog/documents/
/coverage/
/dist/
/test/output/
/CHANGELOG.md
/pnpm-lock.yaml
4 changes: 4 additions & 0 deletions .scaffdog/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
files: ["documents/*.md"],
tags: ["[[", "]]"],
};
30 changes: 30 additions & 0 deletions .scaffdog/documents/component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: "component"
root: "."
output: "**/*"
---

# [[inputs.name + (inputs.gts ? ".gts" : ".gjs")]]

```gts
[[name := pascal(inputs.name)-]]
import Component from "@glimmer/component";
[[if inputs.gts]]
export interface [[name]]Signature {
Args: {};
Blocks: {
default: [];
};
Element: null;
}
export default class [[name]]Component extends Component<[[name]]Signature> {
[[-else]]
export default class [[name]]Component extends Component {
[[-end]]
<template>
{{yield}}
</template>
}
```
14 changes: 14 additions & 0 deletions .scaffdog/documents/helper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: "helper"
root: "."
output: "**/*"
---

# [[inputs.name + (inputs.ts ? ".ts" : ".js")]]

```ts
export default function [[camel(inputs.name)]]Helper(positional /*, named*/) {
return positional;
}

```
14 changes: 14 additions & 0 deletions .scaffdog/documents/modifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: "modifier"
root: "."
output: "**/*"
---

# [[inputs.name + (inputs.ts ? ".ts" : ".js")]]

```ts
import { modifier } from "ember-modifier";

export default modifier(function foo(element /*, positional, named*/) {});

```
21 changes: 21 additions & 0 deletions .scaffdog/documents/service.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: "service"
root: "."
output: "**/*"
---

# [[inputs.name + (inputs.ts ? ".ts" : ".js")]]

```ts
[[name := pascal(inputs.name)-]]
import Service from "@ember/service";

export default class [[name]]Service extends Service {}
[[if inputs.ts]]
declare module "@ember/service" {
interface Registry {
"[[inputs.name]]": [[name]]Service;
}
}
[[end]]
```
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Bert De Block

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# @bertdeblock/gember

[![CI](https://github.com/bertdeblock/gember/workflows/CI/badge.svg)](https://github.com/bertdeblock/gember/actions?query=workflow%3ACI)
[![NPM Version](https://badge.fury.io/js/%40bertdeblock%2Fgember.svg)](https://badge.fury.io/js/%40bertdeblock%2Fgember)

Generate components, helpers, modifiers and services in v2 addons.

Uses [scaffdog](https://scaff.dog/) underneath.

## Installation

```shell
bun add -D @bertdeblock/gember
```

```shell
npm install -D @bertdeblock/gember
```

```shell
pnpm add -D @bertdeblock/gember
```

```shell
yarn add -D @bertdeblock/gember
```

## Usage

```shell
pnpm gember component foo
pnpm gember component foo --gts

pnpm gember helper foo
pnpm gember helper foo --ts

pnpm gember modifier foo
pnpm gember modifier foo --ts

pnpm gember service foo
pnpm gember service foo --ts
```

## Caveats

- Only supports `.gjs` (default) and `.gts` files for components at the moment
- Only supports generating files in a "classic" structure at the moment:
- `src/components/...`
- `src/helpers/...`
- `src/modifiers/...`
- `src/services/...`
4 changes: 4 additions & 0 deletions bin/gember.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

// eslint-disable-next-line n/no-missing-import
import "../dist/cli.js";
62 changes: 62 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@bertdeblock/gember",
"version": "0.0.0",
"description": "Generate components, helpers, modifiers and services in v2 addons.",
"repository": "https://github.com/bertdeblock/gember",
"license": "MIT",
"author": "Bert De Block",
"type": "module",
"bin": {
"gember": "bin/gember.js"
},
"files": [
"bin/",
"dist/",
"CHANGELOG.md"
],
"scripts": {
"build": "tsc --project tsconfig.json",
"lint": "concurrently --group --prefix-colors auto \"npm:lint:*(!fix)\"",
"lint:fix": "concurrently --group --prefix-colors auto \"npm:lint:*:fix\"",
"lint:format": "prettier . --cache --check",
"lint:format:fix": "prettier . --cache --write",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --noEmit",
"prepack": "tsc --project tsconfig.json",
"start": "pnpm build --watch",
"test": "vitest",
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"chalk": "^5.3.0",
"execa": "^8.0.1",
"fs-extra": "^11.2.0",
"scaffdog": "^3.0.0",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.20",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@vitest/coverage-v8": "^1.2.2",
"concurrently": "^8.2.2",
"eslint": "^8.56.0",
"eslint-plugin-n": "^16.6.2",
"prettier": "^3.2.5",
"recursive-copy": "^2.0.14",
"typescript": "^5.3.3",
"uuid": "^9.0.1",
"vitest": "^1.2.2"
},
"packageManager": "[email protected]",
"engines": {
"node": ">= 18"
},
"volta": {
"node": "18.19.1",
"pnpm": "8.15.4"
}
}
Loading

0 comments on commit 5bccc34

Please sign in to comment.