@fluojs/cli 1.1.0 → 3.0.0
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.
- package/README.ko.md +183 -22
- package/README.md +186 -22
- package/dist/cli.d.ts +5 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +128 -35
- package/dist/commands/diagnostics.d.ts +35 -0
- package/dist/commands/diagnostics.d.ts.map +1 -1
- package/dist/commands/diagnostics.js +60 -0
- package/dist/commands/generate.d.ts +1 -49
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +1 -214
- package/dist/commands/inspect.d.ts +5 -7
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +85 -65
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +27 -15
- package/dist/commands/migration-transform-tokens.d.ts +15 -0
- package/dist/commands/migration-transform-tokens.d.ts.map +1 -0
- package/dist/commands/migration-transform-tokens.js +41 -0
- package/dist/commands/new.d.ts +0 -6
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +42 -96
- package/dist/commands/output-path-safety.d.ts +14 -0
- package/dist/commands/output-path-safety.d.ts.map +1 -0
- package/dist/commands/output-path-safety.js +34 -0
- package/dist/commands/scripts.d.ts +1 -1
- package/dist/commands/scripts.d.ts.map +1 -1
- package/dist/commands/scripts.js +13 -7
- package/dist/commands/typegen-artifact.d.ts +54 -0
- package/dist/commands/typegen-artifact.d.ts.map +1 -0
- package/dist/commands/typegen-artifact.js +117 -0
- package/dist/commands/typegen-generation-child.d.ts +2 -0
- package/dist/commands/typegen-generation-child.d.ts.map +1 -0
- package/dist/commands/typegen-generation-child.js +59 -0
- package/dist/commands/typegen-generation-process.d.ts +46 -0
- package/dist/commands/typegen-generation-process.d.ts.map +1 -0
- package/dist/commands/typegen-generation-process.js +131 -0
- package/dist/commands/typegen-generation-protocol.d.ts +16 -0
- package/dist/commands/typegen-generation-protocol.d.ts.map +1 -0
- package/dist/commands/typegen-generation-protocol.js +35 -0
- package/dist/commands/typegen-isolated-source.d.ts +10 -0
- package/dist/commands/typegen-isolated-source.d.ts.map +1 -0
- package/dist/commands/typegen-isolated-source.js +75 -0
- package/dist/commands/typegen-options.d.ts +20 -0
- package/dist/commands/typegen-options.d.ts.map +1 -0
- package/dist/commands/typegen-options.js +71 -0
- package/dist/commands/typegen-source.d.ts +59 -0
- package/dist/commands/typegen-source.d.ts.map +1 -0
- package/dist/commands/typegen-source.js +183 -0
- package/dist/commands/typegen-watch.d.ts +46 -0
- package/dist/commands/typegen-watch.d.ts.map +1 -0
- package/dist/commands/typegen-watch.js +212 -0
- package/dist/commands/typegen.d.ts +29 -0
- package/dist/commands/typegen.d.ts.map +1 -0
- package/dist/commands/typegen.js +119 -0
- package/dist/dev-runner/node-restart-runner.d.ts +6 -0
- package/dist/dev-runner/node-restart-runner.d.ts.map +1 -1
- package/dist/dev-runner/node-restart-runner.js +64 -13
- package/dist/fixtures/inspect-react-app.module.d.ts +4 -0
- package/dist/fixtures/inspect-react-app.module.d.ts.map +1 -0
- package/dist/fixtures/inspect-react-app.module.js +32 -0
- package/dist/fixtures/typegen-react-app.module.d.ts +4 -0
- package/dist/fixtures/typegen-react-app.module.d.ts.map +1 -0
- package/dist/fixtures/typegen-react-app.module.js +33 -0
- package/dist/generate-command.d.ts +50 -0
- package/dist/generate-command.d.ts.map +1 -0
- package/dist/generate-command.js +214 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/new/install.js +1 -1
- package/dist/new/package-spec-resolver.d.ts.map +1 -1
- package/dist/new/package-spec-resolver.js +50 -59
- package/dist/new/prompt.d.ts +1 -0
- package/dist/new/prompt.d.ts.map +1 -1
- package/dist/new/prompt.js +40 -12
- package/dist/new/published-internal-dependencies.d.ts +20 -0
- package/dist/new/published-internal-dependencies.d.ts.map +1 -0
- package/dist/new/published-internal-dependencies.js +20 -0
- package/dist/new/react-vite-ssr-scaffold.d.ts +19 -0
- package/dist/new/react-vite-ssr-scaffold.d.ts.map +1 -0
- package/dist/new/react-vite-ssr-scaffold.js +108 -0
- package/dist/new/resolver.d.ts +2 -2
- package/dist/new/resolver.d.ts.map +1 -1
- package/dist/new/resolver.js +5 -1
- package/dist/new/scaffold.d.ts.map +1 -1
- package/dist/new/scaffold.js +177 -54
- package/dist/new/starter-profiles.d.ts +8 -4
- package/dist/new/starter-profiles.d.ts.map +1 -1
- package/dist/new/starter-profiles.js +52 -18
- package/dist/new/templates/react-vite-ssr/README.md.ejs +74 -0
- package/dist/new/templates/react-vite-ssr/playwright.config.ts.ejs +26 -0
- package/dist/new/templates/react-vite-ssr/src/app.test.ts.ejs +82 -0
- package/dist/new/templates/react-vite-ssr/src/app.ts.ejs +91 -0
- package/dist/new/templates/react-vite-ssr/src/entry-client.tsx.ejs +29 -0
- package/dist/new/templates/react-vite-ssr/src/entry-server.tsx.ejs +52 -0
- package/dist/new/templates/react-vite-ssr/src/load-manifest.test.ts.ejs +55 -0
- package/dist/new/templates/react-vite-ssr/src/load-manifest.ts.ejs +53 -0
- package/dist/new/templates/react-vite-ssr/src/main.ts.ejs +18 -0
- package/dist/new/templates/react-vite-ssr/src/page.tsx.ejs +43 -0
- package/dist/new/templates/react-vite-ssr/src/react-app.test.tsx.ejs +67 -0
- package/dist/new/templates/react-vite-ssr/src/react-app.tsx.ejs +46 -0
- package/dist/new/templates/react-vite-ssr/src/styles.css.ejs +25 -0
- package/dist/new/templates/react-vite-ssr/src/styles.d.ts.ejs +1 -0
- package/dist/new/templates/react-vite-ssr/tests/production-hydration.spec.ts.ejs +54 -0
- package/dist/new/templates/react-vite-ssr/tsconfig.json.ejs +16 -0
- package/dist/new/templates/react-vite-ssr/vite.client.config.ts.ejs +24 -0
- package/dist/new/templates/react-vite-ssr/vite.server.config.ts.ejs +17 -0
- package/dist/new/templates/react-vite-ssr/vitest.config.ts.ejs +10 -0
- package/dist/new/types.d.ts +4 -2
- package/dist/new/types.d.ts.map +1 -1
- package/dist/public-generate.d.ts +2 -0
- package/dist/public-generate.d.ts.map +1 -0
- package/dist/public-generate.js +1 -0
- package/dist/public-inspect.d.ts +13 -0
- package/dist/public-inspect.d.ts.map +1 -0
- package/dist/public-inspect.js +16 -0
- package/dist/public-new.d.ts +13 -0
- package/dist/public-new.d.ts.map +1 -0
- package/dist/public-new.js +16 -0
- package/dist/public-typegen.d.ts +14 -0
- package/dist/public-typegen.d.ts.map +1 -0
- package/dist/public-typegen.js +17 -0
- package/dist/run-cli.d.ts +2 -1
- package/dist/run-cli.d.ts.map +1 -1
- package/dist/studio/sidecar.d.ts.map +1 -1
- package/dist/studio/sidecar.js +106 -14
- package/dist/transforms/nestjs-migrate.d.ts +4 -1
- package/dist/transforms/nestjs-migrate.d.ts.map +1 -1
- package/dist/transforms/nestjs-migrate.js +625 -65
- package/dist/typegen-contract.d.ts +10 -0
- package/dist/typegen-contract.d.ts.map +1 -0
- package/dist/typegen-contract.js +9 -0
- package/dist/usage.d.ts +19 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +178 -0
- package/package.json +19 -10
package/dist/cli.js
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
import { existsSync,
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { diagnosticsUsage, runAnalyzeCommand, runDoctorCommand, runInfoCommand } from './commands/diagnostics.js';
|
|
5
|
-
import { runGenerateCommand } from './commands/generate.js';
|
|
6
|
-
import { inspectUsage, runInspectCommand } from './commands/inspect.js';
|
|
7
|
-
import { migrateUsage, runMigrateCommand } from './commands/migrate.js';
|
|
8
|
-
import { newUsage, runNewCommand } from './commands/new.js';
|
|
9
|
-
import { addUsage, runAddCommand, runUpgradeCommand, upgradeUsage } from './commands/package-workflow.js';
|
|
10
|
-
import { runScriptCommand, scriptUsage } from './commands/scripts.js';
|
|
11
|
-
import { runNodeRestartRunner } from './dev-runner/node-restart-runner.js';
|
|
12
|
-
import { builtInGeneratorCollection, generatorManifest, generatorOptionSchemas, resolveGeneratorKind } from './generators/manifest.js';
|
|
13
4
|
import { renderAliasList, renderHelpTable } from './help.js';
|
|
14
5
|
import { removeUpdateCheckFlags, runCliUpdateCheck } from './update-check.js';
|
|
6
|
+
import { inspectUsage, newUsage, typegenUsage } from './usage.js';
|
|
15
7
|
|
|
16
8
|
/**
|
|
17
9
|
* Runtime dependency overrides for embedding the CLI in tests or higher-level tooling.
|
|
18
10
|
*/
|
|
19
11
|
|
|
20
|
-
const GENERATE_KIND_HELP = [...generatorManifest.map(entry => ({
|
|
21
|
-
aliases: [...entry.aliases],
|
|
22
|
-
description: entry.description,
|
|
23
|
-
kind: entry.kind,
|
|
24
|
-
schematic: entry.schematic,
|
|
25
|
-
wiring: entry.wiringBehavior === 'auto-registered' ? 'auto' : 'manual'
|
|
26
|
-
}))];
|
|
27
|
-
const GENERATE_OPTION_HELP = [...generatorOptionSchemas.map(option => ({
|
|
28
|
-
aliases: [...option.aliases],
|
|
29
|
-
description: option.description,
|
|
30
|
-
option: option.name
|
|
31
|
-
}))];
|
|
32
12
|
const TOP_LEVEL_COMMAND_HELP = [{
|
|
33
13
|
aliases: ['create'],
|
|
34
14
|
command: 'new',
|
|
@@ -69,6 +49,10 @@ const TOP_LEVEL_COMMAND_HELP = [{
|
|
|
69
49
|
aliases: [],
|
|
70
50
|
command: 'inspect',
|
|
71
51
|
description: 'Inspect runtime platform snapshot/diagnostics and emit timing optionally.'
|
|
52
|
+
}, {
|
|
53
|
+
aliases: [],
|
|
54
|
+
command: 'typegen',
|
|
55
|
+
description: 'Generate, check, or watch path-only React page route types.'
|
|
72
56
|
}, {
|
|
73
57
|
aliases: [],
|
|
74
58
|
command: 'migrate',
|
|
@@ -113,7 +97,10 @@ function parseDevRunnerInvocation(argv) {
|
|
|
113
97
|
runtime
|
|
114
98
|
};
|
|
115
99
|
}
|
|
116
|
-
function normalizeGeneratorKind(value) {
|
|
100
|
+
async function normalizeGeneratorKind(value) {
|
|
101
|
+
const {
|
|
102
|
+
resolveGeneratorKind
|
|
103
|
+
} = await import('./generators/manifest.js');
|
|
117
104
|
return resolveGeneratorKind(value);
|
|
118
105
|
}
|
|
119
106
|
function isHelpFlag(value) {
|
|
@@ -136,8 +123,25 @@ function readCliVersion() {
|
|
|
136
123
|
}
|
|
137
124
|
return manifest.version;
|
|
138
125
|
}
|
|
139
|
-
function generateUsage() {
|
|
140
|
-
|
|
126
|
+
async function generateUsage() {
|
|
127
|
+
const {
|
|
128
|
+
builtInGeneratorCollection,
|
|
129
|
+
generatorManifest,
|
|
130
|
+
generatorOptionSchemas
|
|
131
|
+
} = await import('./generators/manifest.js');
|
|
132
|
+
const generateKindHelp = generatorManifest.map(entry => ({
|
|
133
|
+
aliases: [...entry.aliases],
|
|
134
|
+
description: entry.description,
|
|
135
|
+
kind: entry.kind,
|
|
136
|
+
schematic: entry.schematic,
|
|
137
|
+
wiring: entry.wiringBehavior === 'auto-registered' ? 'auto' : 'manual'
|
|
138
|
+
}));
|
|
139
|
+
const generateOptionHelp = generatorOptionSchemas.map(option => ({
|
|
140
|
+
aliases: [...option.aliases],
|
|
141
|
+
description: option.description,
|
|
142
|
+
option: option.name
|
|
143
|
+
}));
|
|
144
|
+
return ['Usage: fluo generate|g <kind> <name> [options]', ' fluo generate|g request-dto|req <feature> <name> [options]', ' fluo generate|g e2e <name> [options]', '', 'Schematics', renderHelpTable(generateKindHelp, [{
|
|
141
145
|
header: 'Schematic',
|
|
142
146
|
render: entry => entry.schematic
|
|
143
147
|
}, {
|
|
@@ -149,7 +153,7 @@ function generateUsage() {
|
|
|
149
153
|
}, {
|
|
150
154
|
header: 'Description',
|
|
151
155
|
render: entry => entry.description
|
|
152
|
-
}]), '', ' auto = class is auto-registered in the domain module (created if absent)', ' manual = files only; you must wire the generated class into a module yourself', '', 'Collections', ` ${builtInGeneratorCollection.id} (${builtInGeneratorCollection.source})`, ' External or app-local generator collections are intentionally deferred; no packages or config files are loaded by generate.', '', 'Options', renderHelpTable(
|
|
156
|
+
}]), '', ' auto = class is auto-registered in the domain module (created if absent)', ' manual = files only; you must wire the generated class into a module yourself', '', 'Collections', ` ${builtInGeneratorCollection.id} (${builtInGeneratorCollection.source})`, ' External or app-local generator collections are intentionally deferred; no packages or config files are loaded by generate.', '', 'Options', renderHelpTable(generateOptionHelp, [{
|
|
153
157
|
header: 'Option',
|
|
154
158
|
render: entry => entry.option
|
|
155
159
|
}, {
|
|
@@ -190,14 +194,14 @@ function resolveDefaultTargetDirectory(startDirectory) {
|
|
|
190
194
|
}
|
|
191
195
|
return resolvedStartDirectory;
|
|
192
196
|
}
|
|
193
|
-
function parseGenerateArgs(argv) {
|
|
197
|
+
async function parseGenerateArgs(argv) {
|
|
194
198
|
const [command, rawKind, firstName, ...optionArgs] = argv;
|
|
195
|
-
const kind = normalizeGeneratorKind(rawKind);
|
|
199
|
+
const kind = await normalizeGeneratorKind(rawKind);
|
|
196
200
|
if (!(command === 'g' || command === 'generate')) {
|
|
197
201
|
throw new Error(usage());
|
|
198
202
|
}
|
|
199
203
|
if (!kind || !firstName) {
|
|
200
|
-
throw new Error(generateUsage());
|
|
204
|
+
throw new Error(await generateUsage());
|
|
201
205
|
}
|
|
202
206
|
if (firstName.startsWith('-')) {
|
|
203
207
|
throw new Error(`Invalid resource name "${firstName}": names cannot start with "-".`);
|
|
@@ -279,7 +283,7 @@ function parseGenerateArgs(argv) {
|
|
|
279
283
|
targetDirectory
|
|
280
284
|
};
|
|
281
285
|
}
|
|
282
|
-
function parseCommand(argv) {
|
|
286
|
+
async function parseCommand(argv) {
|
|
283
287
|
const [command] = argv;
|
|
284
288
|
if (command === 'analyze') {
|
|
285
289
|
return {
|
|
@@ -335,10 +339,16 @@ function parseCommand(argv) {
|
|
|
335
339
|
command: 'inspect'
|
|
336
340
|
};
|
|
337
341
|
}
|
|
342
|
+
if (command === 'typegen') {
|
|
343
|
+
return {
|
|
344
|
+
argv: argv.slice(1),
|
|
345
|
+
command: 'typegen'
|
|
346
|
+
};
|
|
347
|
+
}
|
|
338
348
|
return {
|
|
339
349
|
argv,
|
|
340
350
|
command: 'generate',
|
|
341
|
-
parsed: parseGenerateArgs(argv)
|
|
351
|
+
parsed: await parseGenerateArgs(argv)
|
|
342
352
|
};
|
|
343
353
|
}
|
|
344
354
|
|
|
@@ -362,7 +372,7 @@ function parseCommand(argv) {
|
|
|
362
372
|
*
|
|
363
373
|
* @param argv Argument vector to execute. Defaults to the current process arguments without the node/bin prefix.
|
|
364
374
|
* @param runtime Optional runtime overrides shared by the top-level dispatcher and delegated commands.
|
|
365
|
-
* @returns `0` when the command completes successfully, otherwise
|
|
375
|
+
* @returns `0` when the command completes successfully, otherwise the delegated command exit code.
|
|
366
376
|
*/
|
|
367
377
|
export async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
368
378
|
const cwd = runtime.cwd ? resolve(runtime.cwd) : process.cwd();
|
|
@@ -378,6 +388,9 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
|
378
388
|
try {
|
|
379
389
|
if (commandArgv[0] === NODE_DEV_RUNNER_COMMAND || commandArgv[0] === DEV_RUNNER_COMMAND) {
|
|
380
390
|
const runnerInvocation = parseDevRunnerInvocation(commandArgv);
|
|
391
|
+
const {
|
|
392
|
+
runNodeRestartRunner
|
|
393
|
+
} = await import('./dev-runner/node-restart-runner.js');
|
|
381
394
|
return runNodeRestartRunner({
|
|
382
395
|
appArgs: runnerInvocation.appArgs,
|
|
383
396
|
env,
|
|
@@ -417,30 +430,48 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
|
417
430
|
return 0;
|
|
418
431
|
}
|
|
419
432
|
if (topic === 'g' || topic === 'generate') {
|
|
420
|
-
stdout.write(`${generateUsage()}\n`);
|
|
433
|
+
stdout.write(`${await generateUsage()}\n`);
|
|
421
434
|
return 0;
|
|
422
435
|
}
|
|
423
436
|
if (topic === 'doctor' || topic === 'info') {
|
|
437
|
+
const {
|
|
438
|
+
diagnosticsUsage
|
|
439
|
+
} = await import('./commands/diagnostics.js');
|
|
424
440
|
stdout.write(`${diagnosticsUsage(topic)}\n`);
|
|
425
441
|
return 0;
|
|
426
442
|
}
|
|
427
443
|
if (topic === 'analyze') {
|
|
444
|
+
const {
|
|
445
|
+
diagnosticsUsage
|
|
446
|
+
} = await import('./commands/diagnostics.js');
|
|
428
447
|
stdout.write(`${diagnosticsUsage('analyze')}\n`);
|
|
429
448
|
return 0;
|
|
430
449
|
}
|
|
431
450
|
if (topic === 'build' || topic === 'dev' || topic === 'start') {
|
|
451
|
+
const {
|
|
452
|
+
scriptUsage
|
|
453
|
+
} = await import('./commands/scripts.js');
|
|
432
454
|
stdout.write(`${scriptUsage(topic)}\n`);
|
|
433
455
|
return 0;
|
|
434
456
|
}
|
|
435
457
|
if (topic === 'add') {
|
|
458
|
+
const {
|
|
459
|
+
addUsage
|
|
460
|
+
} = await import('./commands/package-workflow.js');
|
|
436
461
|
stdout.write(`${addUsage()}\n`);
|
|
437
462
|
return 0;
|
|
438
463
|
}
|
|
439
464
|
if (topic === 'upgrade') {
|
|
465
|
+
const {
|
|
466
|
+
upgradeUsage
|
|
467
|
+
} = await import('./commands/package-workflow.js');
|
|
440
468
|
stdout.write(`${upgradeUsage()}\n`);
|
|
441
469
|
return 0;
|
|
442
470
|
}
|
|
443
471
|
if (topic === 'migrate') {
|
|
472
|
+
const {
|
|
473
|
+
migrateUsage
|
|
474
|
+
} = await import('./commands/migrate.js');
|
|
444
475
|
stdout.write(`${migrateUsage()}\n`);
|
|
445
476
|
return 0;
|
|
446
477
|
}
|
|
@@ -448,6 +479,10 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
|
448
479
|
stdout.write(`${inspectUsage()}\n`);
|
|
449
480
|
return 0;
|
|
450
481
|
}
|
|
482
|
+
if (topic === 'typegen') {
|
|
483
|
+
stdout.write(`${typegenUsage()}\n`);
|
|
484
|
+
return 0;
|
|
485
|
+
}
|
|
451
486
|
stdout.write(`${usage()}\n`);
|
|
452
487
|
return 0;
|
|
453
488
|
}
|
|
@@ -456,30 +491,48 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
|
456
491
|
return 0;
|
|
457
492
|
}
|
|
458
493
|
if ((commandArgv[0] === 'g' || commandArgv[0] === 'generate') && commandArgv.slice(1).some(isHelpFlag)) {
|
|
459
|
-
stdout.write(`${generateUsage()}\n`);
|
|
494
|
+
stdout.write(`${await generateUsage()}\n`);
|
|
460
495
|
return 0;
|
|
461
496
|
}
|
|
462
497
|
if ((commandArgv[0] === 'doctor' || commandArgv[0] === 'info') && commandArgv.slice(1).some(isHelpFlag)) {
|
|
498
|
+
const {
|
|
499
|
+
diagnosticsUsage
|
|
500
|
+
} = await import('./commands/diagnostics.js');
|
|
463
501
|
stdout.write(`${diagnosticsUsage(commandArgv[0])}\n`);
|
|
464
502
|
return 0;
|
|
465
503
|
}
|
|
466
504
|
if (commandArgv[0] === 'analyze' && commandArgv.slice(1).some(isHelpFlag)) {
|
|
505
|
+
const {
|
|
506
|
+
diagnosticsUsage
|
|
507
|
+
} = await import('./commands/diagnostics.js');
|
|
467
508
|
stdout.write(`${diagnosticsUsage('analyze')}\n`);
|
|
468
509
|
return 0;
|
|
469
510
|
}
|
|
470
511
|
if ((commandArgv[0] === 'build' || commandArgv[0] === 'dev' || commandArgv[0] === 'start') && commandArgv.slice(1).some(isHelpFlag)) {
|
|
512
|
+
const {
|
|
513
|
+
scriptUsage
|
|
514
|
+
} = await import('./commands/scripts.js');
|
|
471
515
|
stdout.write(`${scriptUsage(commandArgv[0])}\n`);
|
|
472
516
|
return 0;
|
|
473
517
|
}
|
|
474
518
|
if (commandArgv[0] === 'add' && commandArgv.slice(1).some(isHelpFlag)) {
|
|
519
|
+
const {
|
|
520
|
+
addUsage
|
|
521
|
+
} = await import('./commands/package-workflow.js');
|
|
475
522
|
stdout.write(`${addUsage()}\n`);
|
|
476
523
|
return 0;
|
|
477
524
|
}
|
|
478
525
|
if (commandArgv[0] === 'upgrade' && commandArgv.slice(1).some(isHelpFlag)) {
|
|
526
|
+
const {
|
|
527
|
+
upgradeUsage
|
|
528
|
+
} = await import('./commands/package-workflow.js');
|
|
479
529
|
stdout.write(`${upgradeUsage()}\n`);
|
|
480
530
|
return 0;
|
|
481
531
|
}
|
|
482
532
|
if (commandArgv[0] === 'migrate' && commandArgv.slice(1).some(isHelpFlag)) {
|
|
533
|
+
const {
|
|
534
|
+
migrateUsage
|
|
535
|
+
} = await import('./commands/migrate.js');
|
|
483
536
|
stdout.write(`${migrateUsage()}\n`);
|
|
484
537
|
return 0;
|
|
485
538
|
}
|
|
@@ -487,38 +540,78 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
|
|
|
487
540
|
stdout.write(`${inspectUsage()}\n`);
|
|
488
541
|
return 0;
|
|
489
542
|
}
|
|
490
|
-
|
|
543
|
+
if (commandArgv[0] === 'typegen' && commandArgv.slice(1).some(isHelpFlag)) {
|
|
544
|
+
stdout.write(`${typegenUsage()}\n`);
|
|
545
|
+
return 0;
|
|
546
|
+
}
|
|
547
|
+
const parsedCommand = await parseCommand(commandArgv);
|
|
491
548
|
if (parsedCommand.command === 'analyze') {
|
|
549
|
+
const {
|
|
550
|
+
runAnalyzeCommand
|
|
551
|
+
} = await import('./commands/diagnostics.js');
|
|
492
552
|
return runAnalyzeCommand(parsedCommand.argv, commandRuntime);
|
|
493
553
|
}
|
|
494
554
|
if (parsedCommand.command === 'add') {
|
|
555
|
+
const {
|
|
556
|
+
runAddCommand
|
|
557
|
+
} = await import('./commands/package-workflow.js');
|
|
495
558
|
return runAddCommand(parsedCommand.argv, commandRuntime);
|
|
496
559
|
}
|
|
497
560
|
if (parsedCommand.command === 'doctor') {
|
|
561
|
+
const {
|
|
562
|
+
runDoctorCommand
|
|
563
|
+
} = await import('./commands/diagnostics.js');
|
|
498
564
|
return runDoctorCommand(parsedCommand.argv, commandRuntime);
|
|
499
565
|
}
|
|
500
566
|
if (parsedCommand.command === 'info') {
|
|
567
|
+
const {
|
|
568
|
+
runInfoCommand
|
|
569
|
+
} = await import('./commands/diagnostics.js');
|
|
501
570
|
return runInfoCommand(parsedCommand.argv, commandRuntime);
|
|
502
571
|
}
|
|
503
572
|
if (parsedCommand.command === 'build' || parsedCommand.command === 'dev' || parsedCommand.command === 'start') {
|
|
573
|
+
const {
|
|
574
|
+
runScriptCommand
|
|
575
|
+
} = await import('./commands/scripts.js');
|
|
504
576
|
return await runScriptCommand(parsedCommand.command, parsedCommand.argv, commandRuntime);
|
|
505
577
|
}
|
|
506
578
|
if (parsedCommand.command === 'upgrade') {
|
|
579
|
+
const {
|
|
580
|
+
runUpgradeCommand
|
|
581
|
+
} = await import('./commands/package-workflow.js');
|
|
507
582
|
return runUpgradeCommand(parsedCommand.argv, commandRuntime);
|
|
508
583
|
}
|
|
509
584
|
if (parsedCommand.command === 'new') {
|
|
585
|
+
const {
|
|
586
|
+
runNewCommand
|
|
587
|
+
} = await import('./commands/new.js');
|
|
510
588
|
return runNewCommand(parsedCommand.argv, commandRuntime);
|
|
511
589
|
}
|
|
512
590
|
if (parsedCommand.command === 'migrate') {
|
|
591
|
+
const {
|
|
592
|
+
runMigrateCommand
|
|
593
|
+
} = await import('./commands/migrate.js');
|
|
513
594
|
return runMigrateCommand(parsedCommand.argv, commandRuntime);
|
|
514
595
|
}
|
|
515
596
|
if (parsedCommand.command === 'inspect') {
|
|
597
|
+
const {
|
|
598
|
+
runInspectCommand
|
|
599
|
+
} = await import('./commands/inspect.js');
|
|
516
600
|
return runInspectCommand(parsedCommand.argv, commandRuntime);
|
|
517
601
|
}
|
|
602
|
+
if (parsedCommand.command === 'typegen') {
|
|
603
|
+
const {
|
|
604
|
+
runTypegenCommand
|
|
605
|
+
} = await import('./commands/typegen.js');
|
|
606
|
+
return runTypegenCommand(parsedCommand.argv, commandRuntime);
|
|
607
|
+
}
|
|
518
608
|
if (parsedCommand.command !== 'generate') {
|
|
519
609
|
throw new Error(usage());
|
|
520
610
|
}
|
|
521
611
|
const targetDirectory = resolve(cwd, parsedCommand.parsed.targetDirectory ?? resolveDefaultTargetDirectory(cwd));
|
|
612
|
+
const {
|
|
613
|
+
runGenerateCommand
|
|
614
|
+
} = await import('./commands/generate.js');
|
|
522
615
|
const result = runGenerateCommand(parsedCommand.parsed.kind, parsedCommand.parsed.name, targetDirectory, parsedCommand.parsed.options);
|
|
523
616
|
if (parsedCommand.parsed.options.dryRun) {
|
|
524
617
|
stdout.write('Dry run: no files were written.\n');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApplicationLogger } from '@fluojs/runtime';
|
|
1
2
|
type CliStream = {
|
|
2
3
|
write(message: string): unknown;
|
|
3
4
|
};
|
|
@@ -7,9 +8,43 @@ type DiagnosticRuntimeOptions = {
|
|
|
7
8
|
fetchDistTags?: (packageName: string) => Promise<Record<string, string> | undefined>;
|
|
8
9
|
stdout?: CliStream;
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Creates the runtime logger used when a CLI command reserves stdout for an artifact.
|
|
13
|
+
*
|
|
14
|
+
* @param stderr Stream that receives human-readable runtime diagnostics.
|
|
15
|
+
* @returns A logger that preserves the default runtime diagnostic format on stderr.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createCliDiagnosticsLogger(stderr: CliStream): ApplicationLogger;
|
|
18
|
+
/**
|
|
19
|
+
* Returns usage text for a diagnostics command.
|
|
20
|
+
*
|
|
21
|
+
* @param command Diagnostics command whose usage text is requested.
|
|
22
|
+
* @returns Usage text for the selected command.
|
|
23
|
+
*/
|
|
10
24
|
export declare function diagnosticsUsage(command?: 'analyze' | 'doctor' | 'info'): string;
|
|
25
|
+
/**
|
|
26
|
+
* Runs the doctor diagnostics command.
|
|
27
|
+
*
|
|
28
|
+
* @param argv Command arguments after `doctor`.
|
|
29
|
+
* @param runtime Runtime overrides for diagnostics output and lookup.
|
|
30
|
+
* @returns Process-style exit code from the command.
|
|
31
|
+
*/
|
|
11
32
|
export declare function runDoctorCommand(argv: string[], runtime?: DiagnosticRuntimeOptions): Promise<number>;
|
|
33
|
+
/**
|
|
34
|
+
* Runs the info diagnostics command.
|
|
35
|
+
*
|
|
36
|
+
* @param argv Command arguments after `info`.
|
|
37
|
+
* @param runtime Runtime overrides for diagnostics output and lookup.
|
|
38
|
+
* @returns Process-style exit code from the command.
|
|
39
|
+
*/
|
|
12
40
|
export declare function runInfoCommand(argv: string[], runtime?: DiagnosticRuntimeOptions): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Runs the analyze diagnostics command.
|
|
43
|
+
*
|
|
44
|
+
* @param argv Command arguments after `analyze`.
|
|
45
|
+
* @param runtime Runtime overrides for diagnostics output and lookup.
|
|
46
|
+
* @returns Process-style exit code from the command.
|
|
47
|
+
*/
|
|
13
48
|
export declare function runAnalyzeCommand(argv: string[], runtime?: DiagnosticRuntimeOptions): Promise<number>;
|
|
14
49
|
export {};
|
|
15
50
|
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/commands/diagnostics.ts"],"names":[],"mappings":"AAKA,KAAK,SAAS,GAAG;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;IACrF,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/commands/diagnostics.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,KAAK,SAAS,GAAG;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC;IACrF,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAQF;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,CAsB/E;AAiHD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,SAAS,GAAG,QAAQ,GAAG,MAAiB,GAAG,MAAM,CAoB1F;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAgC9G;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5G;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAsB/G"}
|
|
@@ -5,6 +5,35 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
const DEFAULT_PACKAGE_NAME = '@fluojs/cli';
|
|
6
6
|
const DEFAULT_REGISTRY_TIMEOUT_MS = 5_000;
|
|
7
7
|
const EMPTY_ENV = {};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates the runtime logger used when a CLI command reserves stdout for an artifact.
|
|
11
|
+
*
|
|
12
|
+
* @param stderr Stream that receives human-readable runtime diagnostics.
|
|
13
|
+
* @returns A logger that preserves the default runtime diagnostic format on stderr.
|
|
14
|
+
*/
|
|
15
|
+
export function createCliDiagnosticsLogger(stderr) {
|
|
16
|
+
const write = (level, message, context = 'fluo') => {
|
|
17
|
+
stderr.write(`[fluo] ${level} [${context}] ${message}\n`);
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
debug(message, context = 'fluo') {
|
|
21
|
+
write('DEBUG', message, context);
|
|
22
|
+
},
|
|
23
|
+
error(message, error, context = 'fluo') {
|
|
24
|
+
write('ERROR', message, context);
|
|
25
|
+
if (error) {
|
|
26
|
+
stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
log(message, context = 'fluo') {
|
|
30
|
+
write('LOG', message, context);
|
|
31
|
+
},
|
|
32
|
+
warn(message, context = 'fluo') {
|
|
33
|
+
write('WARN', message, context);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
8
37
|
function isRecord(value) {
|
|
9
38
|
return typeof value === 'object' && value !== null;
|
|
10
39
|
}
|
|
@@ -100,12 +129,27 @@ function listScripts(manifest) {
|
|
|
100
129
|
}
|
|
101
130
|
return Object.keys(scripts).sort();
|
|
102
131
|
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns usage text for a diagnostics command.
|
|
135
|
+
*
|
|
136
|
+
* @param command Diagnostics command whose usage text is requested.
|
|
137
|
+
* @returns Usage text for the selected command.
|
|
138
|
+
*/
|
|
103
139
|
export function diagnosticsUsage(command = 'doctor') {
|
|
104
140
|
if (command === 'analyze') {
|
|
105
141
|
return ['Usage: fluo analyze [options]', '', 'Summarize the current project and point to deeper inspect/report diagnostics.', '', 'Options', ' --help Show help for the analyze command.'].join('\n');
|
|
106
142
|
}
|
|
107
143
|
return [`Usage: fluo ${command} [options]`, '', 'Print CLI, registry, update-cache, runtime, and project diagnostics.', '', 'Options', ` --help Show help for the ${command} command.`].join('\n');
|
|
108
144
|
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Runs the doctor diagnostics command.
|
|
148
|
+
*
|
|
149
|
+
* @param argv Command arguments after `doctor`.
|
|
150
|
+
* @param runtime Runtime overrides for diagnostics output and lookup.
|
|
151
|
+
* @returns Process-style exit code from the command.
|
|
152
|
+
*/
|
|
109
153
|
export async function runDoctorCommand(argv, runtime = {}) {
|
|
110
154
|
if (argv.includes('--help') || argv.includes('-h')) {
|
|
111
155
|
(runtime.stdout ?? process.stdout).write(`${diagnosticsUsage('doctor')}\n`);
|
|
@@ -135,6 +179,14 @@ export async function runDoctorCommand(argv, runtime = {}) {
|
|
|
135
179
|
stdout.write(` Project scripts: ${scripts.length > 0 ? scripts.join(', ') : 'none'}\n`);
|
|
136
180
|
return 0;
|
|
137
181
|
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Runs the info diagnostics command.
|
|
185
|
+
*
|
|
186
|
+
* @param argv Command arguments after `info`.
|
|
187
|
+
* @param runtime Runtime overrides for diagnostics output and lookup.
|
|
188
|
+
* @returns Process-style exit code from the command.
|
|
189
|
+
*/
|
|
138
190
|
export async function runInfoCommand(argv, runtime = {}) {
|
|
139
191
|
if (argv.includes('--help') || argv.includes('-h')) {
|
|
140
192
|
(runtime.stdout ?? process.stdout).write(`${diagnosticsUsage('info')}\n`);
|
|
@@ -142,6 +194,14 @@ export async function runInfoCommand(argv, runtime = {}) {
|
|
|
142
194
|
}
|
|
143
195
|
return runDoctorCommand(argv, runtime);
|
|
144
196
|
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Runs the analyze diagnostics command.
|
|
200
|
+
*
|
|
201
|
+
* @param argv Command arguments after `analyze`.
|
|
202
|
+
* @param runtime Runtime overrides for diagnostics output and lookup.
|
|
203
|
+
* @returns Process-style exit code from the command.
|
|
204
|
+
*/
|
|
145
205
|
export async function runAnalyzeCommand(argv, runtime = {}) {
|
|
146
206
|
if (argv.includes('--help') || argv.includes('-h')) {
|
|
147
207
|
(runtime.stdout ?? process.stdout).write(`${diagnosticsUsage('analyze')}\n`);
|
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import type { GeneratorManifestEntry } from '../generators/manifest.js';
|
|
3
|
-
/** Describes how one generated artifact would interact with the workspace. */
|
|
4
|
-
export type GeneratePlanAction = 'create' | 'module-create' | 'module-unchanged' | 'module-update' | 'overwrite' | 'skip' | 'unchanged';
|
|
5
|
-
/** One path-level action reported by generate dry-run previews and structured results. */
|
|
6
|
-
export type GeneratePlanEntry = {
|
|
7
|
-
/** Planned action for this path. */
|
|
8
|
-
action: GeneratePlanAction;
|
|
9
|
-
/** Absolute path affected by the plan entry. */
|
|
10
|
-
path: string;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Structured result returned by {@link runGenerateCommand} for tooling-friendly automation.
|
|
14
|
-
*
|
|
15
|
-
* `generatedFiles` only includes files whose on-disk content changed during the command.
|
|
16
|
-
* `moduleRegistered` reports whether the target schematic participates in automatic module wiring,
|
|
17
|
-
* even when the target module file was already up to date.
|
|
18
|
-
*/
|
|
19
|
-
export type GenerateResult = {
|
|
20
|
-
generatedFiles: string[];
|
|
21
|
-
moduleRegistered: boolean;
|
|
22
|
-
modulePath: string | undefined;
|
|
23
|
-
nextStepHint: string;
|
|
24
|
-
plannedFiles: GeneratePlanEntry[];
|
|
25
|
-
wiringBehavior: GeneratorManifestEntry['wiringBehavior'];
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Generates one CLI schematic into a source directory and returns structured wiring metadata.
|
|
29
|
-
*
|
|
30
|
-
* The command keeps generation idempotent where possible: unchanged files are not rewritten, and
|
|
31
|
-
* auto-registered schematics reuse an existing module file when it already contains the required import
|
|
32
|
-
* and registration entry.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* const result = runGenerateCommand('service', 'Post', './src');
|
|
37
|
-
*
|
|
38
|
-
* console.log(result.wiringBehavior);
|
|
39
|
-
* console.log(result.nextStepHint);
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @param kind Generator kind to execute.
|
|
43
|
-
* @param name Resource name supplied by the caller before normalization.
|
|
44
|
-
* @param baseDirectory Source directory that should receive the generated domain folder.
|
|
45
|
-
* @param options Optional generation flags that control overwrites, request DTO feature placement, and sibling-aware templates.
|
|
46
|
-
* @returns Structured file and wiring metadata for the completed generation run.
|
|
47
|
-
* @throws {Error} When the resource name is invalid, the generator kind is unknown, or the target module source cannot be updated safely.
|
|
48
|
-
*/
|
|
49
|
-
export declare function runGenerateCommand(kind: GeneratorKind, name: string, baseDirectory: string, options?: GenerateOptions): GenerateResult;
|
|
1
|
+
export { type GeneratePlanAction, type GeneratePlanEntry, type GenerateResult, runGenerateCommand } from '../generate-command.js';
|
|
50
2
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|