Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,19 @@ gember supports the following config files:

A gember config file must export a gember config object, or a sync/async function that returns a gember config object:

```js
```ts
// gember.config.js

export default {};
import { defineConfig } from "@bertdeblock/gember";

// An object:
export default defineConfig({});

// or:
export default () => ({});
// A function that returns an object:
export default defineConfig(() => ({}));

// or:
export default async () => ({});
// An async function that returns an object:
export default defineConfig(async () => ({}));
```

### Configuration Signature
Expand All @@ -145,8 +148,6 @@ export type Config = {
copy?: boolean;
// Log the generated component to the console, instead of writing it to disk:
log?: boolean;
// The component's name:
name?: string;
// Generate a nested colocated component, e.g. `foo/bar/index.gts`:
nested?: boolean;
// Generate a component at a custom path, e.g. `--path=src/-private`:
Expand All @@ -159,8 +160,6 @@ export type Config = {
copy?: boolean;
// Log the generated component-test to the console, instead of writing it to disk:
log?: boolean;
// The component-test's name:
name?: string;
// Generate a component-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.gts` component-test, instead of a `.gjs` component-test:
Expand All @@ -173,8 +172,6 @@ export type Config = {
copy?: boolean;
// Log the generated helper to the console, instead of writing it to disk:
log?: boolean;
// The helper's name:
name?: string;
// Generate a helper at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` helper, instead of a `.js` helper:
Expand All @@ -185,8 +182,6 @@ export type Config = {
copy?: boolean;
// Log the generated helper-test to the console, instead of writing it to disk:
log?: boolean;
// The helper-test's name:
name?: string;
// Generate a helper-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.gts` helper-test, instead of a `.gjs` helper-test:
Expand All @@ -199,8 +194,6 @@ export type Config = {
copy?: boolean;
// Log the generated modifier to the console, instead of writing it to disk:
log?: boolean;
// The modifier's name:
name?: string;
// Generate a modifier at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` modifier, instead of a `.js` modifier:
Expand All @@ -211,8 +204,6 @@ export type Config = {
copy?: boolean;
// Log the generated modifier-test to the console, instead of writing it to disk:
log?: boolean;
// The modifier-test's name:
name?: string;
// Generate a modifier-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.gts` modifier-test, instead of a `.gjs` modifier-test:
Expand All @@ -223,8 +214,6 @@ export type Config = {
copy?: boolean;
// Log the generated service to the console, instead of writing it to disk:
log?: boolean;
// The service's name:
name?: string;
// Generate a service at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` service, instead of a `.js` service:
Expand All @@ -235,8 +224,6 @@ export type Config = {
copy?: boolean;
// Log the generated service-test to the console, instead of writing it to disk:
log?: boolean;
// The service-test's name:
name?: string;
// Generate a service-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` service-test, instead of a `.js` service-test:
Expand All @@ -247,8 +234,6 @@ export type Config = {
copy?: boolean;
// Log the generated acceptance-test to the console, instead of writing it to disk:
log?: boolean;
// The acceptance-test's name:
name?: string;
// Generate a acceptance-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` acceptance-test, instead of a `.js` acceptance-test:
Expand Down
6 changes: 5 additions & 1 deletion dev/generators-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ for (const generator of generators) {
generatorsType += `${generator.name.includes("-") ? `"${generator.name}"` : generator.name}?: {\n`;

for (const arg of generator.args) {
if (arg.type === "positional") {
continue;
}

generatorsType += ` // ${arg.description}:\n`;
generatorsType += ` ${arg.name}?: ${arg.type === "positional" ? "string" : arg.type};\n`;
generatorsType += ` ${arg.name}?: ${arg.type};\n`;
}

generatorsType += `};\n`;
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"license": "MIT",
"author": "Bert De Block",
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"bin": {
"gember": "bin/gember.js"
},
Expand All @@ -24,7 +30,7 @@
"lint:format:fix": "prettier . --cache --write",
"lint:js": "eslint . --cache",
"lint:types": "tsc --noEmit",
"prepack": "tsc --project tsconfig.json",
"prepack": "pnpm build",
"start": "pnpm build --watch",
"test": "vitest",
"test:coverage": "pnpm build && vitest run --coverage"
Expand Down
20 changes: 2 additions & 18 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export type Config = {
copy?: boolean;
// Log the generated component to the console, instead of writing it to disk:
log?: boolean;
// The component's name:
name?: string;
// Generate a nested colocated component, e.g. `foo/bar/index.gts`:
nested?: boolean;
// Generate a component at a custom path, e.g. `--path=src/-private`:
Expand All @@ -26,8 +24,6 @@ export type Config = {
copy?: boolean;
// Log the generated component-test to the console, instead of writing it to disk:
log?: boolean;
// The component-test's name:
name?: string;
// Generate a component-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.gts` component-test, instead of a `.gjs` component-test:
Expand All @@ -40,8 +36,6 @@ export type Config = {
copy?: boolean;
// Log the generated helper to the console, instead of writing it to disk:
log?: boolean;
// The helper's name:
name?: string;
// Generate a helper at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` helper, instead of a `.js` helper:
Expand All @@ -52,8 +46,6 @@ export type Config = {
copy?: boolean;
// Log the generated helper-test to the console, instead of writing it to disk:
log?: boolean;
// The helper-test's name:
name?: string;
// Generate a helper-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.gts` helper-test, instead of a `.gjs` helper-test:
Expand All @@ -66,8 +58,6 @@ export type Config = {
copy?: boolean;
// Log the generated modifier to the console, instead of writing it to disk:
log?: boolean;
// The modifier's name:
name?: string;
// Generate a modifier at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` modifier, instead of a `.js` modifier:
Expand All @@ -78,8 +68,6 @@ export type Config = {
copy?: boolean;
// Log the generated modifier-test to the console, instead of writing it to disk:
log?: boolean;
// The modifier-test's name:
name?: string;
// Generate a modifier-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.gts` modifier-test, instead of a `.gjs` modifier-test:
Expand All @@ -90,8 +78,6 @@ export type Config = {
copy?: boolean;
// Log the generated service to the console, instead of writing it to disk:
log?: boolean;
// The service's name:
name?: string;
// Generate a service at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` service, instead of a `.js` service:
Expand All @@ -102,8 +88,6 @@ export type Config = {
copy?: boolean;
// Log the generated service-test to the console, instead of writing it to disk:
log?: boolean;
// The service-test's name:
name?: string;
// Generate a service-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` service-test, instead of a `.js` service-test:
Expand All @@ -114,8 +98,6 @@ export type Config = {
copy?: boolean;
// Log the generated acceptance-test to the console, instead of writing it to disk:
log?: boolean;
// The acceptance-test's name:
name?: string;
// Generate a acceptance-test at a custom path, e.g. `--path=src/-private`:
path?: string;
// Generate a `.ts` acceptance-test, instead of a `.js` acceptance-test:
Expand All @@ -136,6 +118,8 @@ export type Config = {
typescript?: boolean;
};

export type ConfigFactory = Config | (() => Config) | (() => Promise<Config>);

const CONFIG_FILES: string[] = [
"gember.config.js",
"gember.config.cjs",
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ConfigFactory } from "./config.js";

export function defineConfig(config: ConfigFactory): ConfigFactory {
return config;
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"declaration": true,
"forceConsistentCasingInFileNames": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
Expand Down