create-taserjs 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/addons/arktype/index.cjs.map +1 -1
  3. package/dist/cjs/addons/drizzle/index.cjs.map +1 -1
  4. package/dist/cjs/addons/kysely/index.cjs.map +1 -1
  5. package/dist/cjs/addons/pino/index.cjs.map +1 -1
  6. package/dist/cjs/addons/prisma/index.cjs +84 -24
  7. package/dist/cjs/addons/prisma/index.cjs.map +1 -1
  8. package/dist/cjs/addons/registry.cjs +1 -1
  9. package/dist/cjs/addons/registry.cjs.map +1 -1
  10. package/dist/cjs/addons/types.d.cts +1 -1
  11. package/dist/cjs/addons/valibot/index.cjs.map +1 -1
  12. package/dist/cjs/addons/validators.cjs.map +1 -1
  13. package/dist/cjs/addons/winston/index.cjs.map +1 -1
  14. package/dist/cjs/addons/zod/index.cjs.map +1 -1
  15. package/dist/cjs/cli.cjs +5 -0
  16. package/dist/cjs/cli.cjs.map +1 -1
  17. package/dist/cjs/commands/create.cjs +44 -11
  18. package/dist/cjs/commands/create.cjs.map +1 -1
  19. package/dist/cjs/commands/create.d.cts +1 -0
  20. package/dist/cjs/core/json-output.cjs.map +1 -1
  21. package/dist/cjs/core/package-manager.cjs.map +1 -1
  22. package/dist/cjs/core/package-manager.d.cts +1 -1
  23. package/dist/cjs/core/parse-options.cjs +7 -7
  24. package/dist/cjs/core/parse-options.cjs.map +1 -1
  25. package/dist/cjs/core/parse-options.d.cts +3 -3
  26. package/dist/cjs/core/project-config.cjs +1 -1
  27. package/dist/cjs/core/project-config.cjs.map +1 -1
  28. package/dist/cjs/core/resolve-packages.cjs +41 -7
  29. package/dist/cjs/core/resolve-packages.cjs.map +1 -1
  30. package/dist/cjs/core/resolve-packages.d.cts +2 -2
  31. package/dist/cjs/core/scaffold-engine.cjs +33 -6
  32. package/dist/cjs/core/scaffold-engine.cjs.map +1 -1
  33. package/dist/cjs/core/types.cjs +11 -3
  34. package/dist/cjs/core/types.cjs.map +1 -1
  35. package/dist/cjs/core/types.d.cts +8 -8
  36. package/dist/cjs/core/validate-project-name.cjs.map +1 -1
  37. package/dist/cjs/frameworks/index.cjs +138 -17
  38. package/dist/cjs/frameworks/index.cjs.map +1 -1
  39. package/dist/cjs/frameworks/index.d.cts +3 -3
  40. package/dist/cjs/scaffold.d.cts +1 -1
  41. package/dist/cjs/templates/base.cjs +6 -6
  42. package/dist/cjs/templates/base.cjs.map +1 -1
  43. package/dist/cjs/types.d.cts +1 -1
  44. package/dist/esm/addons/arktype/index.js.map +1 -1
  45. package/dist/esm/addons/drizzle/index.js.map +1 -1
  46. package/dist/esm/addons/kysely/index.js.map +1 -1
  47. package/dist/esm/addons/pino/index.js.map +1 -1
  48. package/dist/esm/addons/prisma/index.js +84 -24
  49. package/dist/esm/addons/prisma/index.js.map +1 -1
  50. package/dist/esm/addons/registry.js +2 -2
  51. package/dist/esm/addons/registry.js.map +1 -1
  52. package/dist/esm/addons/types.d.ts +1 -1
  53. package/dist/esm/addons/valibot/index.js.map +1 -1
  54. package/dist/esm/addons/validators.js.map +1 -1
  55. package/dist/esm/addons/winston/index.js.map +1 -1
  56. package/dist/esm/addons/zod/index.js.map +1 -1
  57. package/dist/esm/cli.js +5 -0
  58. package/dist/esm/cli.js.map +1 -1
  59. package/dist/esm/commands/create.d.ts +1 -0
  60. package/dist/esm/commands/create.js +46 -13
  61. package/dist/esm/commands/create.js.map +1 -1
  62. package/dist/esm/core/json-output.js.map +1 -1
  63. package/dist/esm/core/package-manager.d.ts +1 -1
  64. package/dist/esm/core/package-manager.js.map +1 -1
  65. package/dist/esm/core/parse-options.d.ts +3 -3
  66. package/dist/esm/core/parse-options.js +8 -8
  67. package/dist/esm/core/parse-options.js.map +1 -1
  68. package/dist/esm/core/project-config.js +1 -1
  69. package/dist/esm/core/project-config.js.map +1 -1
  70. package/dist/esm/core/resolve-packages.d.ts +2 -2
  71. package/dist/esm/core/resolve-packages.js +41 -7
  72. package/dist/esm/core/resolve-packages.js.map +1 -1
  73. package/dist/esm/core/scaffold-engine.js +34 -7
  74. package/dist/esm/core/scaffold-engine.js.map +1 -1
  75. package/dist/esm/core/types.d.ts +8 -8
  76. package/dist/esm/core/types.js +11 -3
  77. package/dist/esm/core/types.js.map +1 -1
  78. package/dist/esm/core/validate-project-name.js.map +1 -1
  79. package/dist/esm/frameworks/index.d.ts +3 -3
  80. package/dist/esm/frameworks/index.js +138 -17
  81. package/dist/esm/frameworks/index.js.map +1 -1
  82. package/dist/esm/scaffold.d.ts +1 -1
  83. package/dist/esm/templates/base.js +6 -6
  84. package/dist/esm/templates/base.js.map +1 -1
  85. package/dist/esm/types.d.ts +1 -1
  86. package/package.json +13 -13
  87. package/src/addons/arktype/index.ts +2 -2
  88. package/src/addons/drizzle/index.ts +53 -53
  89. package/src/addons/kysely/index.ts +42 -42
  90. package/src/addons/pino/index.ts +12 -12
  91. package/src/addons/prisma/index.ts +128 -55
  92. package/src/addons/registry.ts +37 -37
  93. package/src/addons/types.ts +14 -14
  94. package/src/addons/valibot/index.ts +2 -2
  95. package/src/addons/validators.ts +9 -9
  96. package/src/addons/winston/index.ts +12 -12
  97. package/src/addons/zod/index.ts +2 -2
  98. package/src/cli.ts +27 -26
  99. package/src/commands/create.ts +181 -152
  100. package/src/core/json-output.ts +4 -4
  101. package/src/core/package-manager.ts +38 -31
  102. package/src/core/parse-options.ts +50 -48
  103. package/src/core/project-config.ts +10 -14
  104. package/src/core/resolve-packages.ts +79 -41
  105. package/src/core/scaffold-engine.ts +106 -36
  106. package/src/core/types.ts +61 -36
  107. package/src/core/validate-project-name.ts +40 -40
  108. package/src/frameworks/index.ts +164 -29
  109. package/src/scaffold.ts +3 -3
  110. package/src/templates/base.ts +57 -51
  111. package/src/types.ts +5 -4
@@ -1,234 +1,258 @@
1
- import path from 'node:path'
1
+ import path from "node:path";
2
2
 
3
- import * as p from '@clack/prompts'
4
- import color from 'picocolors'
3
+ import * as p from "@clack/prompts";
4
+ import color from "picocolors";
5
5
 
6
- import { getCapabilitiesCatalog } from '../addons/registry.js'
7
- import { printCapabilitiesCatalog, printJsonError, printScaffoldResult } from '../core/json-output.js'
6
+ import { getCapabilitiesCatalog } from "../addons/registry.js";
7
+ import {
8
+ printCapabilitiesCatalog,
9
+ printJsonError,
10
+ printScaffoldResult,
11
+ } from "../core/json-output.js";
8
12
  import {
9
13
  parseDbFlag,
10
- parseFrameworkFlag,
11
14
  parseLoggerFlag,
15
+ parseTypeFlag,
12
16
  parseValidatorFlag,
13
17
  type ParsedCreateArgs,
14
18
  resolveScaffoldDefaults,
15
- } from '../core/parse-options.js'
16
- import { scaffoldProject } from '../core/scaffold-engine.js'
17
- import type { DbDriver, DbOdm, Framework, LoggerId, ScaffoldResult, ValidatorId } from '../core/types.js'
18
- import { DB_DRIVERS, DB_ODMS, FRAMEWORKS, LOGGERS, VALIDATORS } from '../core/types.js'
19
- import { validateProjectName } from '../core/validate-project-name.js'
20
- import { resolveUserAgent, runScript } from '../core/package-manager.js'
21
-
22
- function isFramework(value: unknown): value is Framework {
23
- return typeof value === 'string' && (FRAMEWORKS as readonly string[]).includes(value)
19
+ } from "../core/parse-options.js";
20
+ import { scaffoldProject } from "../core/scaffold-engine.js";
21
+ import type {
22
+ DbDriver,
23
+ DbOdm,
24
+ LoggerId,
25
+ ProjectType,
26
+ ScaffoldResult,
27
+ ValidatorId,
28
+ } from "../core/types.js";
29
+ import { DB_DRIVERS, DB_ODMS, LOGGERS, PROJECT_TYPES, VALIDATORS } from "../core/types.js";
30
+ import { validateProjectName } from "../core/validate-project-name.js";
31
+ import { resolveUserAgent, runScript } from "../core/package-manager.js";
32
+
33
+ function isProjectType(value: unknown): value is ProjectType {
34
+ return typeof value === "string" && (PROJECT_TYPES as readonly string[]).includes(value);
24
35
  }
25
36
 
26
37
  function isDbOdm(value: unknown): value is DbOdm {
27
- return typeof value === 'string' && (DB_ODMS as readonly string[]).includes(value)
38
+ return typeof value === "string" && (DB_ODMS as readonly string[]).includes(value);
28
39
  }
29
40
 
30
41
  function isDbDriver(value: unknown): value is DbDriver {
31
- return typeof value === 'string' && (DB_DRIVERS as readonly string[]).includes(value)
42
+ return typeof value === "string" && (DB_DRIVERS as readonly string[]).includes(value);
32
43
  }
33
44
 
34
45
  function isLoggerId(value: unknown): value is LoggerId {
35
- return typeof value === 'string' && (LOGGERS as readonly string[]).includes(value)
46
+ return typeof value === "string" && (LOGGERS as readonly string[]).includes(value);
36
47
  }
37
48
 
38
49
  function isValidatorId(value: unknown): value is ValidatorId {
39
- return typeof value === 'string' && (VALIDATORS as readonly string[]).includes(value)
50
+ return typeof value === "string" && (VALIDATORS as readonly string[]).includes(value);
40
51
  }
41
52
 
42
- async function promptInteractiveOptions(
43
- args: ParsedCreateArgs,
44
- ): Promise<ParsedCreateArgs> {
45
- const projectName = args.projectName
46
- ?? await p.text({
47
- message: 'Project name',
48
- placeholder: 'my-taser-app',
49
- defaultValue: 'my-taser-app',
53
+ async function promptInteractiveOptions(args: ParsedCreateArgs): Promise<ParsedCreateArgs> {
54
+ const projectName =
55
+ args.projectName ??
56
+ (await p.text({
57
+ message: "Project name",
58
+ placeholder: "my-taser-app",
59
+ defaultValue: "my-taser-app",
50
60
  validate(value) {
51
- return validateProjectName(value)
61
+ return validateProjectName(value);
52
62
  },
53
- })
63
+ }));
54
64
 
55
65
  if (p.isCancel(projectName)) {
56
- p.cancel('Scaffold cancelled.')
57
- process.exit(0)
66
+ p.cancel("Scaffold cancelled.");
67
+ process.exit(0);
58
68
  }
59
69
 
60
- const framework = args.framework
61
- ?? await p.select({
62
- message: 'Framework adapter',
70
+ const type =
71
+ args.type ??
72
+ (await p.select({
73
+ message: "Project type (runtime / framework)",
63
74
  options: [
64
- { value: 'node', label: 'Plain Node.js', hint: 'default' },
65
- { value: 'express', label: 'Express' },
66
- { value: 'hono', label: 'Hono' },
67
- { value: 'fastify', label: 'Fastify' },
75
+ { value: "node", label: "Node.js", hint: "default" },
76
+ { value: "express", label: "Express" },
77
+ { value: "fastify", label: "Fastify" },
78
+ { value: "hono", label: "Hono" },
79
+ { value: "bun", label: "Bun" },
80
+ { value: "deno", label: "Deno" },
81
+ { value: "aws-lambda", label: "AWS Lambda" },
82
+ { value: "cloudflare-workers", label: "Cloudflare Workers" },
83
+ { value: "netlify", label: "Netlify" },
84
+ { value: "vercel", label: "Vercel" },
85
+ { value: "azure-functions", label: "Azure Functions" },
86
+ { value: "google-cloud-run", label: "Google Cloud Run" },
68
87
  ],
69
- initialValue: 'node',
70
- })
88
+ initialValue: "node",
89
+ }));
71
90
 
72
- if (p.isCancel(framework) || !isFramework(framework)) {
73
- p.cancel('Scaffold cancelled.')
74
- process.exit(0)
91
+ if (p.isCancel(type) || !isProjectType(type)) {
92
+ p.cancel("Scaffold cancelled.");
93
+ process.exit(0);
75
94
  }
76
95
 
77
- const dbChoice = args.db
78
- ?? await p.select({
79
- message: 'Database',
96
+ const dbChoice =
97
+ args.db ??
98
+ (await p.select({
99
+ message: "Database",
80
100
  options: [
81
- { value: 'none', label: 'None', hint: 'default' },
82
- { value: 'drizzle', label: 'Drizzle' },
83
- { value: 'prisma', label: 'Prisma' },
84
- { value: 'kysely', label: 'Kysely' },
101
+ { value: "none", label: "None", hint: "default" },
102
+ { value: "drizzle", label: "Drizzle" },
103
+ { value: "prisma", label: "Prisma" },
104
+ { value: "kysely", label: "Kysely" },
85
105
  ],
86
- initialValue: 'none',
87
- })
106
+ initialValue: "none",
107
+ }));
88
108
 
89
109
  if (p.isCancel(dbChoice)) {
90
- p.cancel('Scaffold cancelled.')
91
- process.exit(0)
110
+ p.cancel("Scaffold cancelled.");
111
+ process.exit(0);
92
112
  }
93
113
 
94
- let db: DbOdm | undefined
95
- let driver: DbDriver | undefined
114
+ let db: DbOdm | undefined;
115
+ let driver: DbDriver | undefined;
96
116
 
97
- if (dbChoice !== 'none' && isDbOdm(dbChoice)) {
98
- db = dbChoice
99
- const driverChoice = args.driver
100
- ?? await p.select({
101
- message: 'Database driver',
117
+ if (dbChoice !== "none" && isDbOdm(dbChoice)) {
118
+ db = dbChoice;
119
+ const driverChoice =
120
+ args.driver ??
121
+ (await p.select({
122
+ message: "Database driver",
102
123
  options: [
103
- { value: 'sqlite', label: 'SQLite', hint: 'default' },
104
- { value: 'postgres', label: 'PostgreSQL' },
105
- { value: 'mysql', label: 'MySQL' },
124
+ { value: "sqlite", label: "SQLite", hint: "default" },
125
+ { value: "postgres", label: "PostgreSQL" },
126
+ { value: "mysql", label: "MySQL" },
106
127
  ],
107
- initialValue: 'sqlite',
108
- })
128
+ initialValue: "sqlite",
129
+ }));
109
130
 
110
131
  if (p.isCancel(driverChoice) || !isDbDriver(driverChoice)) {
111
- p.cancel('Scaffold cancelled.')
112
- process.exit(0)
132
+ p.cancel("Scaffold cancelled.");
133
+ process.exit(0);
113
134
  }
114
- driver = driverChoice
135
+ driver = driverChoice;
115
136
  }
116
137
 
117
- const loggerChoice = args.logger
118
- ?? await p.select({
119
- message: 'Logger',
138
+ const loggerChoice =
139
+ args.logger ??
140
+ (await p.select({
141
+ message: "Logger",
120
142
  options: [
121
- { value: 'none', label: 'None', hint: 'default' },
122
- { value: 'pino', label: 'Pino' },
123
- { value: 'winston', label: 'Winston' },
143
+ { value: "none", label: "None", hint: "default" },
144
+ { value: "pino", label: "Pino" },
145
+ { value: "winston", label: "Winston" },
124
146
  ],
125
- initialValue: 'none',
126
- })
147
+ initialValue: "none",
148
+ }));
127
149
 
128
150
  if (p.isCancel(loggerChoice)) {
129
- p.cancel('Scaffold cancelled.')
130
- process.exit(0)
151
+ p.cancel("Scaffold cancelled.");
152
+ process.exit(0);
131
153
  }
132
154
 
133
- const logger = loggerChoice === 'none' ? undefined : isLoggerId(loggerChoice) ? loggerChoice : undefined
155
+ const logger =
156
+ loggerChoice === "none" ? undefined : isLoggerId(loggerChoice) ? loggerChoice : undefined;
134
157
 
135
- const validatorChoice = args.validator
136
- ?? await p.select({
137
- message: 'Validator',
158
+ const validatorChoice =
159
+ args.validator ??
160
+ (await p.select({
161
+ message: "Validator",
138
162
  options: [
139
- { value: 'none', label: 'None', hint: 'default' },
140
- { value: 'zod', label: 'Zod' },
141
- { value: 'arktype', label: 'Arktype' },
142
- { value: 'valibot', label: 'Valibot' },
163
+ { value: "none", label: "None", hint: "default" },
164
+ { value: "zod", label: "Zod" },
165
+ { value: "arktype", label: "Arktype" },
166
+ { value: "valibot", label: "Valibot" },
143
167
  ],
144
- initialValue: 'none',
145
- })
168
+ initialValue: "none",
169
+ }));
146
170
 
147
171
  if (p.isCancel(validatorChoice)) {
148
- p.cancel('Scaffold cancelled.')
149
- process.exit(0)
172
+ p.cancel("Scaffold cancelled.");
173
+ process.exit(0);
150
174
  }
151
175
 
152
- const validator = validatorChoice === 'none' ? undefined : isValidatorId(validatorChoice) ? validatorChoice : undefined
176
+ const validator =
177
+ validatorChoice === "none"
178
+ ? undefined
179
+ : isValidatorId(validatorChoice)
180
+ ? validatorChoice
181
+ : undefined;
153
182
 
154
183
  return {
155
184
  projectName: String(projectName).trim(),
156
- framework,
185
+ type,
157
186
  yes: args.yes,
158
187
  noInstall: args.noInstall,
159
188
  json: args.json,
160
189
  ...(db ? { db, driver: driver! } : {}),
161
190
  ...(logger ? { logger } : {}),
162
191
  ...(validator ? { validator } : {}),
163
- }
192
+ };
164
193
  }
165
194
 
166
- export async function runCreateCommand(args: ParsedCreateArgs): Promise<ScaffoldResult | undefined> {
195
+ export async function runCreateCommand(
196
+ args: ParsedCreateArgs,
197
+ ): Promise<ScaffoldResult | undefined> {
167
198
  if (args.json && !args.projectName) {
168
- printCapabilitiesCatalog(getCapabilitiesCatalog())
169
- return undefined
199
+ printCapabilitiesCatalog(getCapabilitiesCatalog());
200
+ return undefined;
170
201
  }
171
202
 
172
- const cwd = process.cwd()
173
- const interactive = !args.yes
203
+ const cwd = process.cwd();
204
+ const interactive = !args.yes;
174
205
  const resolved = interactive
175
206
  ? await promptInteractiveOptions(args)
176
207
  : {
177
208
  ...args,
178
209
  projectName: args.projectName?.trim(),
179
- framework: args.framework ?? 'node',
180
- }
210
+ type: args.type ?? "node",
211
+ };
181
212
 
182
213
  if (!resolved.projectName) {
183
- const message = 'Project name is required'
214
+ const message = "Project name is required";
184
215
  if (args.json) {
185
- printJsonError(message)
186
- process.exit(1)
216
+ printJsonError(message);
217
+ process.exit(1);
187
218
  }
188
- throw new Error(message)
219
+ throw new Error(message);
189
220
  }
190
221
 
191
- const nameError = validateProjectName(resolved.projectName, cwd)
222
+ const nameError = validateProjectName(resolved.projectName, cwd);
192
223
  if (nameError) {
193
224
  if (args.json) {
194
- printJsonError(nameError)
195
- process.exit(1)
225
+ printJsonError(nameError);
226
+ process.exit(1);
196
227
  }
197
- throw new Error(nameError)
228
+ throw new Error(nameError);
198
229
  }
199
230
 
200
- const targetDir = path.resolve(cwd, resolved.projectName)
231
+ const targetDir = path.resolve(cwd, resolved.projectName);
201
232
  const scaffoldCtx = resolveScaffoldDefaults({
202
233
  ...resolved,
203
234
  projectName: resolved.projectName,
204
- })
205
- scaffoldCtx.targetDir = targetDir
235
+ });
236
+ scaffoldCtx.targetDir = targetDir;
206
237
 
207
238
  if (!args.json) {
208
- const spinner = p.spinner()
209
- spinner.start('Scaffolding project')
239
+ const spinner = p.spinner();
240
+ spinner.start("Scaffolding project");
210
241
  try {
211
242
  const result = await scaffoldProject({
212
243
  ...scaffoldCtx,
213
244
  targetDir,
214
245
  skipInstall: args.noInstall,
215
246
  agent: resolveUserAgent(),
216
- })
217
- spinner.stop('Project created')
218
- const cdPath = path.relative(cwd, targetDir) || '.'
219
- p.note(
220
- [
221
- `cd ${cdPath}`,
222
- runScript(resolveUserAgent(), 'dev'),
223
- ].join('\n'),
224
- 'Next steps',
225
- )
226
- p.outro(color.green('Done.'))
227
- return result
228
- }
229
- catch (error) {
230
- spinner.stop('Scaffold failed')
231
- throw error
247
+ });
248
+ spinner.stop("Project created");
249
+ const cdPath = path.relative(cwd, targetDir) || ".";
250
+ p.note([`cd ${cdPath}`, runScript(resolveUserAgent(), "dev")].join("\n"), "Next steps");
251
+ p.outro(color.green("Done."));
252
+ return result;
253
+ } catch (error) {
254
+ spinner.stop("Scaffold failed");
255
+ throw error;
232
256
  }
233
257
  }
234
258
 
@@ -237,47 +261,52 @@ export async function runCreateCommand(args: ParsedCreateArgs): Promise<Scaffold
237
261
  targetDir,
238
262
  skipInstall: args.noInstall,
239
263
  agent: resolveUserAgent(),
240
- })
241
- printScaffoldResult(result)
242
- return result
264
+ });
265
+ printScaffoldResult(result);
266
+ return result;
243
267
  }
244
268
 
245
- export function buildParsedArgsFromCli(values: {
246
- framework?: string
247
- db?: string
248
- logger?: string
249
- validator?: string
250
- y?: boolean
251
- noInstall?: boolean
252
- json?: boolean
253
- }, positionals: string[]): ParsedCreateArgs {
269
+ export function buildParsedArgsFromCli(
270
+ values: {
271
+ type?: string;
272
+ framework?: string;
273
+ db?: string;
274
+ logger?: string;
275
+ validator?: string;
276
+ y?: boolean;
277
+ noInstall?: boolean;
278
+ json?: boolean;
279
+ },
280
+ positionals: string[],
281
+ ): ParsedCreateArgs {
254
282
  const args: ParsedCreateArgs = {
255
283
  yes: values.y ?? false,
256
284
  noInstall: values.noInstall ?? false,
257
285
  json: values.json ?? false,
258
- }
286
+ };
259
287
 
260
288
  if (positionals[0]) {
261
- args.projectName = positionals[0]
289
+ args.projectName = positionals[0];
262
290
  }
263
291
 
264
- if (values.framework) {
265
- args.framework = parseFrameworkFlag(values.framework)
292
+ const typeFlag = values.type ?? values.framework;
293
+ if (typeFlag) {
294
+ args.type = parseTypeFlag(typeFlag);
266
295
  }
267
296
 
268
297
  if (values.db) {
269
- const parsed = parseDbFlag(values.db)
270
- args.db = parsed.db
271
- args.driver = parsed.driver
298
+ const parsed = parseDbFlag(values.db);
299
+ args.db = parsed.db;
300
+ args.driver = parsed.driver;
272
301
  }
273
302
 
274
303
  if (values.logger) {
275
- args.logger = parseLoggerFlag(values.logger)
304
+ args.logger = parseLoggerFlag(values.logger);
276
305
  }
277
306
 
278
307
  if (values.validator) {
279
- args.validator = parseValidatorFlag(values.validator)
308
+ args.validator = parseValidatorFlag(values.validator);
280
309
  }
281
310
 
282
- return args
311
+ return args;
283
312
  }
@@ -1,13 +1,13 @@
1
- import type { CapabilitiesCatalog, ScaffoldResult } from './types.js'
1
+ import type { CapabilitiesCatalog, ScaffoldResult } from "./types.js";
2
2
 
3
3
  export function printCapabilitiesCatalog(catalog: CapabilitiesCatalog): void {
4
- console.log(JSON.stringify(catalog, null, 2))
4
+ console.log(JSON.stringify(catalog, null, 2));
5
5
  }
6
6
 
7
7
  export function printScaffoldResult(result: ScaffoldResult): void {
8
- console.log(JSON.stringify(result, null, 2))
8
+ console.log(JSON.stringify(result, null, 2));
9
9
  }
10
10
 
11
11
  export function printJsonError(message: string): void {
12
- console.error(JSON.stringify({ error: message }))
12
+ console.error(JSON.stringify({ error: message }));
13
13
  }
@@ -1,65 +1,72 @@
1
- import { spawn } from 'node:child_process'
1
+ import { spawn } from "node:child_process";
2
2
 
3
- import type { Agent, ResolvedCommand } from 'package-manager-detector'
4
- import { resolveCommand } from 'package-manager-detector/commands'
5
- import { getUserAgent } from 'package-manager-detector/detect'
3
+ import type { Agent, ResolvedCommand } from "package-manager-detector";
4
+ import { resolveCommand } from "package-manager-detector/commands";
5
+ import { getUserAgent } from "package-manager-detector/detect";
6
6
 
7
7
  export function resolveUserAgent(): Agent {
8
- return getUserAgent() || 'npm'
8
+ return getUserAgent() || "npm";
9
9
  }
10
10
 
11
11
  function runCommand(command: string, args: string[], cwd: string): Promise<void> {
12
12
  return new Promise((resolve, reject) => {
13
13
  const child = spawn(command, args, {
14
14
  cwd,
15
- stdio: 'inherit',
15
+ stdio: "inherit",
16
16
  shell: false,
17
17
  env: process.env,
18
- })
19
- child.on('error', reject)
20
- child.on('close', (code) => {
18
+ });
19
+ child.on("error", reject);
20
+ child.on("close", (code) => {
21
21
  if (code === 0) {
22
- resolve()
23
- return
22
+ resolve();
23
+ return;
24
24
  }
25
- reject(new Error(`${command} ${args.join(' ')} exited with code ${code}`))
26
- })
27
- })
25
+ reject(new Error(`${command} ${args.join(" ")} exited with code ${code}`));
26
+ });
27
+ });
28
28
  }
29
29
 
30
- export function resolveInstallCommand(agent: Agent, packages: string[], dev: boolean): ResolvedCommand {
31
- const args = dev ? ['-D', ...packages] : packages
32
- const command = resolveCommand(agent, 'add', args)
33
- if (command) return command
30
+ export function resolveInstallCommand(
31
+ agent: Agent,
32
+ packages: string[],
33
+ dev: boolean,
34
+ ): ResolvedCommand {
35
+ const args = dev ? ["-D", ...packages] : packages;
36
+ const command = resolveCommand(agent, "add", args);
37
+ if (command) return command;
34
38
 
35
39
  return {
36
- command: 'npm',
37
- args: ['install', ...args],
38
- }
40
+ command: "npm",
41
+ args: ["install", ...args],
42
+ };
39
43
  }
40
44
 
41
45
  export async function installPackages(
42
46
  agent: Agent,
43
47
  cwd: string,
44
- { dependencies, devDependencies }: {
45
- dependencies: string[]
46
- devDependencies: string[]
48
+ {
49
+ dependencies,
50
+ devDependencies,
51
+ }: {
52
+ dependencies: string[];
53
+ devDependencies: string[];
47
54
  },
48
55
  ): Promise<void> {
49
56
  if (dependencies.length > 0) {
50
- const { command, args } = resolveInstallCommand(agent, dependencies, false)
51
- await runCommand(command, args, cwd)
57
+ const { command, args } = resolveInstallCommand(agent, dependencies, false);
58
+ await runCommand(command, args, cwd);
52
59
  }
53
60
  if (devDependencies.length > 0) {
54
- const { command, args } = resolveInstallCommand(agent, devDependencies, true)
55
- await runCommand(command, args, cwd)
61
+ const { command, args } = resolveInstallCommand(agent, devDependencies, true);
62
+ await runCommand(command, args, cwd);
56
63
  }
57
64
  }
58
65
 
59
66
  export function runScript(agent: Agent, script: string): string {
60
- const resolved = resolveCommand(agent, 'run', [script])
67
+ const resolved = resolveCommand(agent, "run", [script]);
61
68
  if (!resolved) {
62
- throw new Error(`Unable to resolve run command for ${agent}`)
69
+ throw new Error(`Unable to resolve run command for ${agent}`);
63
70
  }
64
- return `${resolved.command} ${resolved.args.join(' ')}`
71
+ return `${resolved.command} ${resolved.args.join(" ")}`;
65
72
  }