Skip to content

Commit 2c3fdf9

Browse files
committed
Support templateContent and templatePath options
1 parent 93c4475 commit 2c3fdf9

File tree

4 files changed

+330
-26
lines changed

4 files changed

+330
-26
lines changed

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,39 +139,155 @@ export default async () => ({});
139139
export type Config = {
140140
generators?: {
141141
component?: {
142+
// Generate a `class-based` component, instead of a `template-only` component:
142143
classBased?: boolean;
144+
// Copy the generated component to the clipboard, instead of writing it to disk:
145+
copy?: boolean;
146+
// Log the generated component to the console, instead of writing it to disk:
147+
log?: boolean;
148+
// The component's name:
149+
name?: string;
150+
// Generate a nested colocated component, e.g. `foo/bar/index.gts`:
143151
nested?: boolean;
152+
// Generate a component at a custom path, e.g. `--path=src/-private`:
144153
path?: string;
154+
// Custom template content:
155+
templateContent?: string;
156+
// Custom template path:
157+
templatePath?: string;
158+
// Generate a `.gts` component, instead of a `.gjs` component:
145159
typescript?: boolean;
146160
};
147161
"component-test"?: {
162+
// Copy the generated component-test to the clipboard, instead of writing it to disk:
163+
copy?: boolean;
164+
// Log the generated component-test to the console, instead of writing it to disk:
165+
log?: boolean;
166+
// The component-test's name:
167+
name?: string;
168+
// Generate a component-test at a custom path, e.g. `--path=src/-private`:
148169
path?: string;
170+
// Custom template content:
171+
templateContent?: string;
172+
// Custom template path:
173+
templatePath?: string;
174+
// Generate a `.gts` component-test, instead of a `.gjs` component-test:
149175
typescript?: boolean;
150176
};
151177
helper?: {
178+
// Generate a `class-based` helper, instead of a `function-based` helper:
152179
classBased?: boolean;
180+
// Copy the generated helper to the clipboard, instead of writing it to disk:
181+
copy?: boolean;
182+
// Log the generated helper to the console, instead of writing it to disk:
183+
log?: boolean;
184+
// The helper's name:
185+
name?: string;
186+
// Generate a helper at a custom path, e.g. `--path=src/-private`:
153187
path?: string;
188+
// Custom template content:
189+
templateContent?: string;
190+
// Custom template path:
191+
templatePath?: string;
192+
// Generate a `.ts` helper, instead of a `.js` helper:
154193
typescript?: boolean;
155194
};
156195
"helper-test"?: {
196+
// Copy the generated helper-test to the clipboard, instead of writing it to disk:
197+
copy?: boolean;
198+
// Log the generated helper-test to the console, instead of writing it to disk:
199+
log?: boolean;
200+
// The helper-test's name:
201+
name?: string;
202+
// Generate a helper-test at a custom path, e.g. `--path=src/-private`:
157203
path?: string;
204+
// Custom template content:
205+
templateContent?: string;
206+
// Custom template path:
207+
templatePath?: string;
208+
// Generate a `.gts` helper-test, instead of a `.gjs` helper-test:
158209
typescript?: boolean;
159210
};
160211
modifier?: {
212+
// Generate a `class-based` modifier, instead of a `function-based` modifier:
161213
classBased?: boolean;
214+
// Copy the generated modifier to the clipboard, instead of writing it to disk:
215+
copy?: boolean;
216+
// Log the generated modifier to the console, instead of writing it to disk:
217+
log?: boolean;
218+
// The modifier's name:
219+
name?: string;
220+
// Generate a modifier at a custom path, e.g. `--path=src/-private`:
162221
path?: string;
222+
// Custom template content:
223+
templateContent?: string;
224+
// Custom template path:
225+
templatePath?: string;
226+
// Generate a `.ts` modifier, instead of a `.js` modifier:
163227
typescript?: boolean;
164228
};
165229
"modifier-test"?: {
230+
// Copy the generated modifier-test to the clipboard, instead of writing it to disk:
231+
copy?: boolean;
232+
// Log the generated modifier-test to the console, instead of writing it to disk:
233+
log?: boolean;
234+
// The modifier-test's name:
235+
name?: string;
236+
// Generate a modifier-test at a custom path, e.g. `--path=src/-private`:
166237
path?: string;
238+
// Custom template content:
239+
templateContent?: string;
240+
// Custom template path:
241+
templatePath?: string;
242+
// Generate a `.gts` modifier-test, instead of a `.gjs` modifier-test:
167243
typescript?: boolean;
168244
};
169245
service?: {
246+
// Copy the generated service to the clipboard, instead of writing it to disk:
247+
copy?: boolean;
248+
// Log the generated service to the console, instead of writing it to disk:
249+
log?: boolean;
250+
// The service's name:
251+
name?: string;
252+
// Generate a service at a custom path, e.g. `--path=src/-private`:
170253
path?: string;
254+
// Custom template content:
255+
templateContent?: string;
256+
// Custom template path:
257+
templatePath?: string;
258+
// Generate a `.ts` service, instead of a `.js` service:
171259
typescript?: boolean;
172260
};
173261
"service-test"?: {
262+
// Copy the generated service-test to the clipboard, instead of writing it to disk:
263+
copy?: boolean;
264+
// Log the generated service-test to the console, instead of writing it to disk:
265+
log?: boolean;
266+
// The service-test's name:
267+
name?: string;
268+
// Generate a service-test at a custom path, e.g. `--path=src/-private`:
174269
path?: string;
270+
// Custom template content:
271+
templateContent?: string;
272+
// Custom template path:
273+
templatePath?: string;
274+
// Generate a `.ts` service-test, instead of a `.js` service-test:
275+
typescript?: boolean;
276+
};
277+
"acceptance-test"?: {
278+
// Copy the generated acceptance-test to the clipboard, instead of writing it to disk:
279+
copy?: boolean;
280+
// Log the generated acceptance-test to the console, instead of writing it to disk:
281+
log?: boolean;
282+
// The acceptance-test's name:
283+
name?: string;
284+
// Generate a acceptance-test at a custom path, e.g. `--path=src/-private`:
285+
path?: string;
286+
// Custom template content:
287+
templateContent?: string;
288+
// Custom template path:
289+
templatePath?: string;
290+
// Generate a `.ts` acceptance-test, instead of a `.js` acceptance-test:
175291
typescript?: boolean;
176292
};
177293
};

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: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,155 @@ import type { GeneratorFile } from "./types.js";
66
export type Config = {
77
generators?: {
88
component?: {
9+
// Generate a `class-based` component, instead of a `template-only` component:
910
classBased?: boolean;
11+
// Copy the generated component to the clipboard, instead of writing it to disk:
12+
copy?: boolean;
13+
// Log the generated component to the console, instead of writing it to disk:
14+
log?: boolean;
15+
// The component's name:
16+
name?: string;
17+
// Generate a nested colocated component, e.g. `foo/bar/index.gts`:
1018
nested?: boolean;
19+
// Generate a component at a custom path, e.g. `--path=src/-private`:
1120
path?: string;
21+
// Custom template content:
22+
templateContent?: string;
23+
// Custom template path:
24+
templatePath?: string;
25+
// Generate a `.gts` component, instead of a `.gjs` component:
1226
typescript?: boolean;
1327
};
1428
"component-test"?: {
29+
// Copy the generated component-test to the clipboard, instead of writing it to disk:
30+
copy?: boolean;
31+
// Log the generated component-test to the console, instead of writing it to disk:
32+
log?: boolean;
33+
// The component-test's name:
34+
name?: string;
35+
// Generate a component-test at a custom path, e.g. `--path=src/-private`:
1536
path?: string;
37+
// Custom template content:
38+
templateContent?: string;
39+
// Custom template path:
40+
templatePath?: string;
41+
// Generate a `.gts` component-test, instead of a `.gjs` component-test:
1642
typescript?: boolean;
1743
};
1844
helper?: {
45+
// Generate a `class-based` helper, instead of a `function-based` helper:
1946
classBased?: boolean;
47+
// Copy the generated helper to the clipboard, instead of writing it to disk:
48+
copy?: boolean;
49+
// Log the generated helper to the console, instead of writing it to disk:
50+
log?: boolean;
51+
// The helper's name:
52+
name?: string;
53+
// Generate a helper at a custom path, e.g. `--path=src/-private`:
2054
path?: string;
55+
// Custom template content:
56+
templateContent?: string;
57+
// Custom template path:
58+
templatePath?: string;
59+
// Generate a `.ts` helper, instead of a `.js` helper:
2160
typescript?: boolean;
2261
};
2362
"helper-test"?: {
63+
// Copy the generated helper-test to the clipboard, instead of writing it to disk:
64+
copy?: boolean;
65+
// Log the generated helper-test to the console, instead of writing it to disk:
66+
log?: boolean;
67+
// The helper-test's name:
68+
name?: string;
69+
// Generate a helper-test at a custom path, e.g. `--path=src/-private`:
2470
path?: string;
71+
// Custom template content:
72+
templateContent?: string;
73+
// Custom template path:
74+
templatePath?: string;
75+
// Generate a `.gts` helper-test, instead of a `.gjs` helper-test:
2576
typescript?: boolean;
2677
};
2778
modifier?: {
79+
// Generate a `class-based` modifier, instead of a `function-based` modifier:
2880
classBased?: boolean;
81+
// Copy the generated modifier to the clipboard, instead of writing it to disk:
82+
copy?: boolean;
83+
// Log the generated modifier to the console, instead of writing it to disk:
84+
log?: boolean;
85+
// The modifier's name:
86+
name?: string;
87+
// Generate a modifier at a custom path, e.g. `--path=src/-private`:
2988
path?: string;
89+
// Custom template content:
90+
templateContent?: string;
91+
// Custom template path:
92+
templatePath?: string;
93+
// Generate a `.ts` modifier, instead of a `.js` modifier:
3094
typescript?: boolean;
3195
};
3296
"modifier-test"?: {
97+
// Copy the generated modifier-test to the clipboard, instead of writing it to disk:
98+
copy?: boolean;
99+
// Log the generated modifier-test to the console, instead of writing it to disk:
100+
log?: boolean;
101+
// The modifier-test's name:
102+
name?: string;
103+
// Generate a modifier-test at a custom path, e.g. `--path=src/-private`:
33104
path?: string;
105+
// Custom template content:
106+
templateContent?: string;
107+
// Custom template path:
108+
templatePath?: string;
109+
// Generate a `.gts` modifier-test, instead of a `.gjs` modifier-test:
34110
typescript?: boolean;
35111
};
36112
service?: {
113+
// Copy the generated service to the clipboard, instead of writing it to disk:
114+
copy?: boolean;
115+
// Log the generated service to the console, instead of writing it to disk:
116+
log?: boolean;
117+
// The service's name:
118+
name?: string;
119+
// Generate a service at a custom path, e.g. `--path=src/-private`:
37120
path?: string;
121+
// Custom template content:
122+
templateContent?: string;
123+
// Custom template path:
124+
templatePath?: string;
125+
// Generate a `.ts` service, instead of a `.js` service:
38126
typescript?: boolean;
39127
};
40128
"service-test"?: {
129+
// Copy the generated service-test to the clipboard, instead of writing it to disk:
130+
copy?: boolean;
131+
// Log the generated service-test to the console, instead of writing it to disk:
132+
log?: boolean;
133+
// The service-test's name:
134+
name?: string;
135+
// Generate a service-test at a custom path, e.g. `--path=src/-private`:
41136
path?: string;
137+
// Custom template content:
138+
templateContent?: string;
139+
// Custom template path:
140+
templatePath?: string;
141+
// Generate a `.ts` service-test, instead of a `.js` service-test:
142+
typescript?: boolean;
143+
};
144+
"acceptance-test"?: {
145+
// Copy the generated acceptance-test to the clipboard, instead of writing it to disk:
146+
copy?: boolean;
147+
// Log the generated acceptance-test to the console, instead of writing it to disk:
148+
log?: boolean;
149+
// The acceptance-test's name:
150+
name?: string;
151+
// Generate a acceptance-test at a custom path, e.g. `--path=src/-private`:
152+
path?: string;
153+
// Custom template content:
154+
templateContent?: string;
155+
// Custom template path:
156+
templatePath?: string;
157+
// Generate a `.ts` acceptance-test, instead of a `.js` acceptance-test:
42158
typescript?: boolean;
43159
};
44160
};

0 commit comments

Comments
 (0)