Skip to content

Commit 0dd3958

Browse files
committed
Fix generators type
1 parent 93c4475 commit 0dd3958

File tree

3 files changed

+247
-74
lines changed

3 files changed

+247
-74
lines changed

README.md

Lines changed: 115 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -137,43 +137,121 @@ export default async () => ({});
137137

138138
```ts
139139
export type Config = {
140-
generators?: {
141-
component?: {
142-
classBased?: boolean;
143-
nested?: boolean;
144-
path?: string;
145-
typescript?: boolean;
146-
};
147-
"component-test"?: {
148-
path?: string;
149-
typescript?: boolean;
150-
};
151-
helper?: {
152-
classBased?: boolean;
153-
path?: string;
154-
typescript?: boolean;
155-
};
156-
"helper-test"?: {
157-
path?: string;
158-
typescript?: boolean;
159-
};
160-
modifier?: {
161-
classBased?: boolean;
162-
path?: string;
163-
typescript?: boolean;
164-
};
165-
"modifier-test"?: {
166-
path?: string;
167-
typescript?: boolean;
168-
};
169-
service?: {
170-
path?: string;
171-
typescript?: boolean;
172-
};
173-
"service-test"?: {
174-
path?: string;
175-
typescript?: boolean;
176-
};
140+
component?: {
141+
// Generate a `class-based` component, instead of a `template-only` component:
142+
classBased?: boolean;
143+
// Copy the generated component to the clipboard, instead of writing it to disk:
144+
copy?: boolean;
145+
// Log the generated component to the console, instead of writing it to disk:
146+
log?: boolean;
147+
// The component's name:
148+
name?: string;
149+
// Generate a nested colocated component, e.g. `foo/bar/index.gts`:
150+
nested?: boolean;
151+
// Generate a component at a custom path, e.g. `--path=src/-private`:
152+
path?: string;
153+
// Generate a `.gts` component, instead of a `.gjs` component:
154+
typescript?: boolean;
155+
};
156+
"component-test"?: {
157+
// Copy the generated component-test to the clipboard, instead of writing it to disk:
158+
copy?: boolean;
159+
// Log the generated component-test to the console, instead of writing it to disk:
160+
log?: boolean;
161+
// The component-test's name:
162+
name?: string;
163+
// Generate a component-test at a custom path, e.g. `--path=src/-private`:
164+
path?: string;
165+
// Generate a `.gts` component-test, instead of a `.gjs` component-test:
166+
typescript?: boolean;
167+
};
168+
helper?: {
169+
// Generate a `class-based` helper, instead of a `function-based` helper:
170+
classBased?: boolean;
171+
// Copy the generated helper to the clipboard, instead of writing it to disk:
172+
copy?: boolean;
173+
// Log the generated helper to the console, instead of writing it to disk:
174+
log?: boolean;
175+
// The helper's name:
176+
name?: string;
177+
// Generate a helper at a custom path, e.g. `--path=src/-private`:
178+
path?: string;
179+
// Generate a `.ts` helper, instead of a `.js` helper:
180+
typescript?: boolean;
181+
};
182+
"helper-test"?: {
183+
// Copy the generated helper-test to the clipboard, instead of writing it to disk:
184+
copy?: boolean;
185+
// Log the generated helper-test to the console, instead of writing it to disk:
186+
log?: boolean;
187+
// The helper-test's name:
188+
name?: string;
189+
// Generate a helper-test at a custom path, e.g. `--path=src/-private`:
190+
path?: string;
191+
// Generate a `.gts` helper-test, instead of a `.gjs` helper-test:
192+
typescript?: boolean;
193+
};
194+
modifier?: {
195+
// Generate a `class-based` modifier, instead of a `function-based` modifier:
196+
classBased?: boolean;
197+
// Copy the generated modifier to the clipboard, instead of writing it to disk:
198+
copy?: boolean;
199+
// Log the generated modifier to the console, instead of writing it to disk:
200+
log?: boolean;
201+
// The modifier's name:
202+
name?: string;
203+
// Generate a modifier at a custom path, e.g. `--path=src/-private`:
204+
path?: string;
205+
// Generate a `.ts` modifier, instead of a `.js` modifier:
206+
typescript?: boolean;
207+
};
208+
"modifier-test"?: {
209+
// Copy the generated modifier-test to the clipboard, instead of writing it to disk:
210+
copy?: boolean;
211+
// Log the generated modifier-test to the console, instead of writing it to disk:
212+
log?: boolean;
213+
// The modifier-test's name:
214+
name?: string;
215+
// Generate a modifier-test at a custom path, e.g. `--path=src/-private`:
216+
path?: string;
217+
// Generate a `.gts` modifier-test, instead of a `.gjs` modifier-test:
218+
typescript?: boolean;
219+
};
220+
service?: {
221+
// Copy the generated service to the clipboard, instead of writing it to disk:
222+
copy?: boolean;
223+
// Log the generated service to the console, instead of writing it to disk:
224+
log?: boolean;
225+
// The service's name:
226+
name?: string;
227+
// Generate a service at a custom path, e.g. `--path=src/-private`:
228+
path?: string;
229+
// Generate a `.ts` service, instead of a `.js` service:
230+
typescript?: boolean;
231+
};
232+
"service-test"?: {
233+
// Copy the generated service-test to the clipboard, instead of writing it to disk:
234+
copy?: boolean;
235+
// Log the generated service-test to the console, instead of writing it to disk:
236+
log?: boolean;
237+
// The service-test's name:
238+
name?: string;
239+
// Generate a service-test at a custom path, e.g. `--path=src/-private`:
240+
path?: string;
241+
// Generate a `.ts` service-test, instead of a `.js` service-test:
242+
typescript?: boolean;
243+
};
244+
"acceptance-test"?: {
245+
// Copy the generated acceptance-test to the clipboard, instead of writing it to disk:
246+
copy?: boolean;
247+
// Log the generated acceptance-test to the console, instead of writing it to disk:
248+
log?: boolean;
249+
// The acceptance-test's name:
250+
name?: string;
251+
// Generate a acceptance-test at a custom path, e.g. `--path=src/-private`:
252+
path?: string;
253+
// Generate a `.ts` acceptance-test, instead of a `.js` acceptance-test:
254+
typescript?: boolean;
177255
};
178256

179257
hooks?: {

dev/generators-type.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// eslint-disable-next-line n/no-missing-import
2+
import { generators } from "../dist/generators.js";
3+
4+
let generatorsType = "";
5+
6+
for (const generator of generators) {
7+
generatorsType += `${generator.name.includes("-") ? `"${generator.name}"` : generator.name}?: {\n`;
8+
9+
for (const arg of generator.args) {
10+
generatorsType += ` // ${arg.description}:\n`;
11+
generatorsType += ` ${arg.name}?: ${arg.type === "positional" ? "string" : arg.type};\n`;
12+
}
13+
14+
generatorsType += `};\n`;
15+
}
16+
17+
console.log(generatorsType);

src/config.ts

Lines changed: 115 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,121 @@ import { GemberError } from "./errors.js";
44
import type { GeneratorFile } from "./types.js";
55

66
export type Config = {
7-
generators?: {
8-
component?: {
9-
classBased?: boolean;
10-
nested?: boolean;
11-
path?: string;
12-
typescript?: boolean;
13-
};
14-
"component-test"?: {
15-
path?: string;
16-
typescript?: boolean;
17-
};
18-
helper?: {
19-
classBased?: boolean;
20-
path?: string;
21-
typescript?: boolean;
22-
};
23-
"helper-test"?: {
24-
path?: string;
25-
typescript?: boolean;
26-
};
27-
modifier?: {
28-
classBased?: boolean;
29-
path?: string;
30-
typescript?: boolean;
31-
};
32-
"modifier-test"?: {
33-
path?: string;
34-
typescript?: boolean;
35-
};
36-
service?: {
37-
path?: string;
38-
typescript?: boolean;
39-
};
40-
"service-test"?: {
41-
path?: string;
42-
typescript?: boolean;
43-
};
7+
component?: {
8+
// Generate a `class-based` component, instead of a `template-only` component:
9+
classBased?: boolean;
10+
// Copy the generated component to the clipboard, instead of writing it to disk:
11+
copy?: boolean;
12+
// Log the generated component to the console, instead of writing it to disk:
13+
log?: boolean;
14+
// The component's name:
15+
name?: string;
16+
// Generate a nested colocated component, e.g. `foo/bar/index.gts`:
17+
nested?: boolean;
18+
// Generate a component at a custom path, e.g. `--path=src/-private`:
19+
path?: string;
20+
// Generate a `.gts` component, instead of a `.gjs` component:
21+
typescript?: boolean;
22+
};
23+
"component-test"?: {
24+
// Copy the generated component-test to the clipboard, instead of writing it to disk:
25+
copy?: boolean;
26+
// Log the generated component-test to the console, instead of writing it to disk:
27+
log?: boolean;
28+
// The component-test's name:
29+
name?: string;
30+
// Generate a component-test at a custom path, e.g. `--path=src/-private`:
31+
path?: string;
32+
// Generate a `.gts` component-test, instead of a `.gjs` component-test:
33+
typescript?: boolean;
34+
};
35+
helper?: {
36+
// Generate a `class-based` helper, instead of a `function-based` helper:
37+
classBased?: boolean;
38+
// Copy the generated helper to the clipboard, instead of writing it to disk:
39+
copy?: boolean;
40+
// Log the generated helper to the console, instead of writing it to disk:
41+
log?: boolean;
42+
// The helper's name:
43+
name?: string;
44+
// Generate a helper at a custom path, e.g. `--path=src/-private`:
45+
path?: string;
46+
// Generate a `.ts` helper, instead of a `.js` helper:
47+
typescript?: boolean;
48+
};
49+
"helper-test"?: {
50+
// Copy the generated helper-test to the clipboard, instead of writing it to disk:
51+
copy?: boolean;
52+
// Log the generated helper-test to the console, instead of writing it to disk:
53+
log?: boolean;
54+
// The helper-test's name:
55+
name?: string;
56+
// Generate a helper-test at a custom path, e.g. `--path=src/-private`:
57+
path?: string;
58+
// Generate a `.gts` helper-test, instead of a `.gjs` helper-test:
59+
typescript?: boolean;
60+
};
61+
modifier?: {
62+
// Generate a `class-based` modifier, instead of a `function-based` modifier:
63+
classBased?: boolean;
64+
// Copy the generated modifier to the clipboard, instead of writing it to disk:
65+
copy?: boolean;
66+
// Log the generated modifier to the console, instead of writing it to disk:
67+
log?: boolean;
68+
// The modifier's name:
69+
name?: string;
70+
// Generate a modifier at a custom path, e.g. `--path=src/-private`:
71+
path?: string;
72+
// Generate a `.ts` modifier, instead of a `.js` modifier:
73+
typescript?: boolean;
74+
};
75+
"modifier-test"?: {
76+
// Copy the generated modifier-test to the clipboard, instead of writing it to disk:
77+
copy?: boolean;
78+
// Log the generated modifier-test to the console, instead of writing it to disk:
79+
log?: boolean;
80+
// The modifier-test's name:
81+
name?: string;
82+
// Generate a modifier-test at a custom path, e.g. `--path=src/-private`:
83+
path?: string;
84+
// Generate a `.gts` modifier-test, instead of a `.gjs` modifier-test:
85+
typescript?: boolean;
86+
};
87+
service?: {
88+
// Copy the generated service to the clipboard, instead of writing it to disk:
89+
copy?: boolean;
90+
// Log the generated service to the console, instead of writing it to disk:
91+
log?: boolean;
92+
// The service's name:
93+
name?: string;
94+
// Generate a service at a custom path, e.g. `--path=src/-private`:
95+
path?: string;
96+
// Generate a `.ts` service, instead of a `.js` service:
97+
typescript?: boolean;
98+
};
99+
"service-test"?: {
100+
// Copy the generated service-test to the clipboard, instead of writing it to disk:
101+
copy?: boolean;
102+
// Log the generated service-test to the console, instead of writing it to disk:
103+
log?: boolean;
104+
// The service-test's name:
105+
name?: string;
106+
// Generate a service-test at a custom path, e.g. `--path=src/-private`:
107+
path?: string;
108+
// Generate a `.ts` service-test, instead of a `.js` service-test:
109+
typescript?: boolean;
110+
};
111+
"acceptance-test"?: {
112+
// Copy the generated acceptance-test to the clipboard, instead of writing it to disk:
113+
copy?: boolean;
114+
// Log the generated acceptance-test to the console, instead of writing it to disk:
115+
log?: boolean;
116+
// The acceptance-test's name:
117+
name?: string;
118+
// Generate a acceptance-test at a custom path, e.g. `--path=src/-private`:
119+
path?: string;
120+
// Generate a `.ts` acceptance-test, instead of a `.js` acceptance-test:
121+
typescript?: boolean;
44122
};
45123

46124
hooks?: {

0 commit comments

Comments
 (0)