@fluojs/cli 2.0.1 → 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.
Files changed (118) hide show
  1. package/README.ko.md +169 -21
  2. package/README.md +172 -21
  3. package/dist/cli.d.ts +5 -4
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +127 -35
  6. package/dist/commands/diagnostics.d.ts +35 -0
  7. package/dist/commands/diagnostics.d.ts.map +1 -1
  8. package/dist/commands/diagnostics.js +60 -0
  9. package/dist/commands/inspect.d.ts +5 -1
  10. package/dist/commands/inspect.d.ts.map +1 -1
  11. package/dist/commands/inspect.js +84 -17
  12. package/dist/commands/migrate.d.ts.map +1 -1
  13. package/dist/commands/migrate.js +27 -15
  14. package/dist/commands/migration-transform-tokens.d.ts +15 -0
  15. package/dist/commands/migration-transform-tokens.d.ts.map +1 -0
  16. package/dist/commands/migration-transform-tokens.js +41 -0
  17. package/dist/commands/new.d.ts.map +1 -1
  18. package/dist/commands/new.js +29 -9
  19. package/dist/commands/output-path-safety.d.ts +14 -0
  20. package/dist/commands/output-path-safety.d.ts.map +1 -0
  21. package/dist/commands/output-path-safety.js +34 -0
  22. package/dist/commands/scripts.js +2 -2
  23. package/dist/commands/typegen-artifact.d.ts +54 -0
  24. package/dist/commands/typegen-artifact.d.ts.map +1 -0
  25. package/dist/commands/typegen-artifact.js +117 -0
  26. package/dist/commands/typegen-generation-child.d.ts +2 -0
  27. package/dist/commands/typegen-generation-child.d.ts.map +1 -0
  28. package/dist/commands/typegen-generation-child.js +59 -0
  29. package/dist/commands/typegen-generation-process.d.ts +46 -0
  30. package/dist/commands/typegen-generation-process.d.ts.map +1 -0
  31. package/dist/commands/typegen-generation-process.js +131 -0
  32. package/dist/commands/typegen-generation-protocol.d.ts +16 -0
  33. package/dist/commands/typegen-generation-protocol.d.ts.map +1 -0
  34. package/dist/commands/typegen-generation-protocol.js +35 -0
  35. package/dist/commands/typegen-isolated-source.d.ts +10 -0
  36. package/dist/commands/typegen-isolated-source.d.ts.map +1 -0
  37. package/dist/commands/typegen-isolated-source.js +75 -0
  38. package/dist/commands/typegen-options.d.ts +20 -0
  39. package/dist/commands/typegen-options.d.ts.map +1 -0
  40. package/dist/commands/typegen-options.js +71 -0
  41. package/dist/commands/typegen-source.d.ts +59 -0
  42. package/dist/commands/typegen-source.d.ts.map +1 -0
  43. package/dist/commands/typegen-source.js +183 -0
  44. package/dist/commands/typegen-watch.d.ts +46 -0
  45. package/dist/commands/typegen-watch.d.ts.map +1 -0
  46. package/dist/commands/typegen-watch.js +212 -0
  47. package/dist/commands/typegen.d.ts +29 -0
  48. package/dist/commands/typegen.d.ts.map +1 -0
  49. package/dist/commands/typegen.js +119 -0
  50. package/dist/dev-runner/node-restart-runner.d.ts.map +1 -1
  51. package/dist/dev-runner/node-restart-runner.js +54 -7
  52. package/dist/fixtures/inspect-react-app.module.d.ts +4 -0
  53. package/dist/fixtures/inspect-react-app.module.d.ts.map +1 -0
  54. package/dist/fixtures/inspect-react-app.module.js +32 -0
  55. package/dist/fixtures/typegen-react-app.module.d.ts +4 -0
  56. package/dist/fixtures/typegen-react-app.module.d.ts.map +1 -0
  57. package/dist/fixtures/typegen-react-app.module.js +33 -0
  58. package/dist/index.d.ts +6 -5
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +3 -2
  61. package/dist/new/install.js +1 -1
  62. package/dist/new/package-spec-resolver.d.ts.map +1 -1
  63. package/dist/new/package-spec-resolver.js +50 -59
  64. package/dist/new/prompt.d.ts +1 -0
  65. package/dist/new/prompt.d.ts.map +1 -1
  66. package/dist/new/prompt.js +40 -12
  67. package/dist/new/published-internal-dependencies.d.ts +20 -0
  68. package/dist/new/published-internal-dependencies.d.ts.map +1 -0
  69. package/dist/new/published-internal-dependencies.js +20 -0
  70. package/dist/new/react-vite-ssr-scaffold.d.ts +19 -0
  71. package/dist/new/react-vite-ssr-scaffold.d.ts.map +1 -0
  72. package/dist/new/react-vite-ssr-scaffold.js +108 -0
  73. package/dist/new/resolver.d.ts +2 -2
  74. package/dist/new/resolver.d.ts.map +1 -1
  75. package/dist/new/resolver.js +5 -1
  76. package/dist/new/scaffold.d.ts.map +1 -1
  77. package/dist/new/scaffold.js +62 -31
  78. package/dist/new/starter-profiles.d.ts +8 -4
  79. package/dist/new/starter-profiles.d.ts.map +1 -1
  80. package/dist/new/starter-profiles.js +52 -18
  81. package/dist/new/templates/react-vite-ssr/README.md.ejs +74 -0
  82. package/dist/new/templates/react-vite-ssr/playwright.config.ts.ejs +26 -0
  83. package/dist/new/templates/react-vite-ssr/src/app.test.ts.ejs +82 -0
  84. package/dist/new/templates/react-vite-ssr/src/app.ts.ejs +91 -0
  85. package/dist/new/templates/react-vite-ssr/src/entry-client.tsx.ejs +29 -0
  86. package/dist/new/templates/react-vite-ssr/src/entry-server.tsx.ejs +52 -0
  87. package/dist/new/templates/react-vite-ssr/src/load-manifest.test.ts.ejs +55 -0
  88. package/dist/new/templates/react-vite-ssr/src/load-manifest.ts.ejs +53 -0
  89. package/dist/new/templates/react-vite-ssr/src/main.ts.ejs +18 -0
  90. package/dist/new/templates/react-vite-ssr/src/page.tsx.ejs +43 -0
  91. package/dist/new/templates/react-vite-ssr/src/react-app.test.tsx.ejs +67 -0
  92. package/dist/new/templates/react-vite-ssr/src/react-app.tsx.ejs +46 -0
  93. package/dist/new/templates/react-vite-ssr/src/styles.css.ejs +25 -0
  94. package/dist/new/templates/react-vite-ssr/src/styles.d.ts.ejs +1 -0
  95. package/dist/new/templates/react-vite-ssr/tests/production-hydration.spec.ts.ejs +54 -0
  96. package/dist/new/templates/react-vite-ssr/tsconfig.json.ejs +16 -0
  97. package/dist/new/templates/react-vite-ssr/vite.client.config.ts.ejs +24 -0
  98. package/dist/new/templates/react-vite-ssr/vite.server.config.ts.ejs +17 -0
  99. package/dist/new/templates/react-vite-ssr/vitest.config.ts.ejs +10 -0
  100. package/dist/new/types.d.ts +4 -0
  101. package/dist/new/types.d.ts.map +1 -1
  102. package/dist/public-typegen.d.ts +14 -0
  103. package/dist/public-typegen.d.ts.map +1 -0
  104. package/dist/public-typegen.js +17 -0
  105. package/dist/run-cli.d.ts +2 -1
  106. package/dist/run-cli.d.ts.map +1 -1
  107. package/dist/studio/sidecar.d.ts.map +1 -1
  108. package/dist/studio/sidecar.js +35 -9
  109. package/dist/transforms/nestjs-migrate.d.ts +4 -1
  110. package/dist/transforms/nestjs-migrate.d.ts.map +1 -1
  111. package/dist/transforms/nestjs-migrate.js +625 -65
  112. package/dist/typegen-contract.d.ts +10 -0
  113. package/dist/typegen-contract.d.ts.map +1 -0
  114. package/dist/typegen-contract.js +9 -0
  115. package/dist/usage.d.ts +6 -0
  116. package/dist/usage.d.ts.map +1 -1
  117. package/dist/usage.js +47 -0
  118. package/package.json +19 -10
package/dist/cli.js CHANGED
@@ -1,35 +1,14 @@
1
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 { runInspectCommand } from './commands/inspect.js';
7
- import { migrateUsage, runMigrateCommand } from './commands/migrate.js';
8
- import { 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';
15
- import { inspectUsage, newUsage } from './usage.js';
6
+ import { inspectUsage, newUsage, typegenUsage } from './usage.js';
16
7
 
17
8
  /**
18
9
  * Runtime dependency overrides for embedding the CLI in tests or higher-level tooling.
19
10
  */
20
11
 
21
- const GENERATE_KIND_HELP = [...generatorManifest.map(entry => ({
22
- aliases: [...entry.aliases],
23
- description: entry.description,
24
- kind: entry.kind,
25
- schematic: entry.schematic,
26
- wiring: entry.wiringBehavior === 'auto-registered' ? 'auto' : 'manual'
27
- }))];
28
- const GENERATE_OPTION_HELP = [...generatorOptionSchemas.map(option => ({
29
- aliases: [...option.aliases],
30
- description: option.description,
31
- option: option.name
32
- }))];
33
12
  const TOP_LEVEL_COMMAND_HELP = [{
34
13
  aliases: ['create'],
35
14
  command: 'new',
@@ -70,6 +49,10 @@ const TOP_LEVEL_COMMAND_HELP = [{
70
49
  aliases: [],
71
50
  command: 'inspect',
72
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.'
73
56
  }, {
74
57
  aliases: [],
75
58
  command: 'migrate',
@@ -114,7 +97,10 @@ function parseDevRunnerInvocation(argv) {
114
97
  runtime
115
98
  };
116
99
  }
117
- function normalizeGeneratorKind(value) {
100
+ async function normalizeGeneratorKind(value) {
101
+ const {
102
+ resolveGeneratorKind
103
+ } = await import('./generators/manifest.js');
118
104
  return resolveGeneratorKind(value);
119
105
  }
120
106
  function isHelpFlag(value) {
@@ -137,8 +123,25 @@ function readCliVersion() {
137
123
  }
138
124
  return manifest.version;
139
125
  }
140
- function generateUsage() {
141
- 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(GENERATE_KIND_HELP, [{
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, [{
142
145
  header: 'Schematic',
143
146
  render: entry => entry.schematic
144
147
  }, {
@@ -150,7 +153,7 @@ function generateUsage() {
150
153
  }, {
151
154
  header: 'Description',
152
155
  render: entry => entry.description
153
- }]), '', ' 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(GENERATE_OPTION_HELP, [{
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, [{
154
157
  header: 'Option',
155
158
  render: entry => entry.option
156
159
  }, {
@@ -191,14 +194,14 @@ function resolveDefaultTargetDirectory(startDirectory) {
191
194
  }
192
195
  return resolvedStartDirectory;
193
196
  }
194
- function parseGenerateArgs(argv) {
197
+ async function parseGenerateArgs(argv) {
195
198
  const [command, rawKind, firstName, ...optionArgs] = argv;
196
- const kind = normalizeGeneratorKind(rawKind);
199
+ const kind = await normalizeGeneratorKind(rawKind);
197
200
  if (!(command === 'g' || command === 'generate')) {
198
201
  throw new Error(usage());
199
202
  }
200
203
  if (!kind || !firstName) {
201
- throw new Error(generateUsage());
204
+ throw new Error(await generateUsage());
202
205
  }
203
206
  if (firstName.startsWith('-')) {
204
207
  throw new Error(`Invalid resource name "${firstName}": names cannot start with "-".`);
@@ -280,7 +283,7 @@ function parseGenerateArgs(argv) {
280
283
  targetDirectory
281
284
  };
282
285
  }
283
- function parseCommand(argv) {
286
+ async function parseCommand(argv) {
284
287
  const [command] = argv;
285
288
  if (command === 'analyze') {
286
289
  return {
@@ -336,10 +339,16 @@ function parseCommand(argv) {
336
339
  command: 'inspect'
337
340
  };
338
341
  }
342
+ if (command === 'typegen') {
343
+ return {
344
+ argv: argv.slice(1),
345
+ command: 'typegen'
346
+ };
347
+ }
339
348
  return {
340
349
  argv,
341
350
  command: 'generate',
342
- parsed: parseGenerateArgs(argv)
351
+ parsed: await parseGenerateArgs(argv)
343
352
  };
344
353
  }
345
354
 
@@ -363,7 +372,7 @@ function parseCommand(argv) {
363
372
  *
364
373
  * @param argv Argument vector to execute. Defaults to the current process arguments without the node/bin prefix.
365
374
  * @param runtime Optional runtime overrides shared by the top-level dispatcher and delegated commands.
366
- * @returns `0` when the command completes successfully, otherwise `1` after writing the error message to `stderr`.
375
+ * @returns `0` when the command completes successfully, otherwise the delegated command exit code.
367
376
  */
368
377
  export async function runCli(argv = process.argv.slice(2), runtime = {}) {
369
378
  const cwd = runtime.cwd ? resolve(runtime.cwd) : process.cwd();
@@ -379,6 +388,9 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
379
388
  try {
380
389
  if (commandArgv[0] === NODE_DEV_RUNNER_COMMAND || commandArgv[0] === DEV_RUNNER_COMMAND) {
381
390
  const runnerInvocation = parseDevRunnerInvocation(commandArgv);
391
+ const {
392
+ runNodeRestartRunner
393
+ } = await import('./dev-runner/node-restart-runner.js');
382
394
  return runNodeRestartRunner({
383
395
  appArgs: runnerInvocation.appArgs,
384
396
  env,
@@ -418,30 +430,48 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
418
430
  return 0;
419
431
  }
420
432
  if (topic === 'g' || topic === 'generate') {
421
- stdout.write(`${generateUsage()}\n`);
433
+ stdout.write(`${await generateUsage()}\n`);
422
434
  return 0;
423
435
  }
424
436
  if (topic === 'doctor' || topic === 'info') {
437
+ const {
438
+ diagnosticsUsage
439
+ } = await import('./commands/diagnostics.js');
425
440
  stdout.write(`${diagnosticsUsage(topic)}\n`);
426
441
  return 0;
427
442
  }
428
443
  if (topic === 'analyze') {
444
+ const {
445
+ diagnosticsUsage
446
+ } = await import('./commands/diagnostics.js');
429
447
  stdout.write(`${diagnosticsUsage('analyze')}\n`);
430
448
  return 0;
431
449
  }
432
450
  if (topic === 'build' || topic === 'dev' || topic === 'start') {
451
+ const {
452
+ scriptUsage
453
+ } = await import('./commands/scripts.js');
433
454
  stdout.write(`${scriptUsage(topic)}\n`);
434
455
  return 0;
435
456
  }
436
457
  if (topic === 'add') {
458
+ const {
459
+ addUsage
460
+ } = await import('./commands/package-workflow.js');
437
461
  stdout.write(`${addUsage()}\n`);
438
462
  return 0;
439
463
  }
440
464
  if (topic === 'upgrade') {
465
+ const {
466
+ upgradeUsage
467
+ } = await import('./commands/package-workflow.js');
441
468
  stdout.write(`${upgradeUsage()}\n`);
442
469
  return 0;
443
470
  }
444
471
  if (topic === 'migrate') {
472
+ const {
473
+ migrateUsage
474
+ } = await import('./commands/migrate.js');
445
475
  stdout.write(`${migrateUsage()}\n`);
446
476
  return 0;
447
477
  }
@@ -449,6 +479,10 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
449
479
  stdout.write(`${inspectUsage()}\n`);
450
480
  return 0;
451
481
  }
482
+ if (topic === 'typegen') {
483
+ stdout.write(`${typegenUsage()}\n`);
484
+ return 0;
485
+ }
452
486
  stdout.write(`${usage()}\n`);
453
487
  return 0;
454
488
  }
@@ -457,30 +491,48 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
457
491
  return 0;
458
492
  }
459
493
  if ((commandArgv[0] === 'g' || commandArgv[0] === 'generate') && commandArgv.slice(1).some(isHelpFlag)) {
460
- stdout.write(`${generateUsage()}\n`);
494
+ stdout.write(`${await generateUsage()}\n`);
461
495
  return 0;
462
496
  }
463
497
  if ((commandArgv[0] === 'doctor' || commandArgv[0] === 'info') && commandArgv.slice(1).some(isHelpFlag)) {
498
+ const {
499
+ diagnosticsUsage
500
+ } = await import('./commands/diagnostics.js');
464
501
  stdout.write(`${diagnosticsUsage(commandArgv[0])}\n`);
465
502
  return 0;
466
503
  }
467
504
  if (commandArgv[0] === 'analyze' && commandArgv.slice(1).some(isHelpFlag)) {
505
+ const {
506
+ diagnosticsUsage
507
+ } = await import('./commands/diagnostics.js');
468
508
  stdout.write(`${diagnosticsUsage('analyze')}\n`);
469
509
  return 0;
470
510
  }
471
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');
472
515
  stdout.write(`${scriptUsage(commandArgv[0])}\n`);
473
516
  return 0;
474
517
  }
475
518
  if (commandArgv[0] === 'add' && commandArgv.slice(1).some(isHelpFlag)) {
519
+ const {
520
+ addUsage
521
+ } = await import('./commands/package-workflow.js');
476
522
  stdout.write(`${addUsage()}\n`);
477
523
  return 0;
478
524
  }
479
525
  if (commandArgv[0] === 'upgrade' && commandArgv.slice(1).some(isHelpFlag)) {
526
+ const {
527
+ upgradeUsage
528
+ } = await import('./commands/package-workflow.js');
480
529
  stdout.write(`${upgradeUsage()}\n`);
481
530
  return 0;
482
531
  }
483
532
  if (commandArgv[0] === 'migrate' && commandArgv.slice(1).some(isHelpFlag)) {
533
+ const {
534
+ migrateUsage
535
+ } = await import('./commands/migrate.js');
484
536
  stdout.write(`${migrateUsage()}\n`);
485
537
  return 0;
486
538
  }
@@ -488,38 +540,78 @@ export async function runCli(argv = process.argv.slice(2), runtime = {}) {
488
540
  stdout.write(`${inspectUsage()}\n`);
489
541
  return 0;
490
542
  }
491
- const parsedCommand = parseCommand(commandArgv);
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);
492
548
  if (parsedCommand.command === 'analyze') {
549
+ const {
550
+ runAnalyzeCommand
551
+ } = await import('./commands/diagnostics.js');
493
552
  return runAnalyzeCommand(parsedCommand.argv, commandRuntime);
494
553
  }
495
554
  if (parsedCommand.command === 'add') {
555
+ const {
556
+ runAddCommand
557
+ } = await import('./commands/package-workflow.js');
496
558
  return runAddCommand(parsedCommand.argv, commandRuntime);
497
559
  }
498
560
  if (parsedCommand.command === 'doctor') {
561
+ const {
562
+ runDoctorCommand
563
+ } = await import('./commands/diagnostics.js');
499
564
  return runDoctorCommand(parsedCommand.argv, commandRuntime);
500
565
  }
501
566
  if (parsedCommand.command === 'info') {
567
+ const {
568
+ runInfoCommand
569
+ } = await import('./commands/diagnostics.js');
502
570
  return runInfoCommand(parsedCommand.argv, commandRuntime);
503
571
  }
504
572
  if (parsedCommand.command === 'build' || parsedCommand.command === 'dev' || parsedCommand.command === 'start') {
573
+ const {
574
+ runScriptCommand
575
+ } = await import('./commands/scripts.js');
505
576
  return await runScriptCommand(parsedCommand.command, parsedCommand.argv, commandRuntime);
506
577
  }
507
578
  if (parsedCommand.command === 'upgrade') {
579
+ const {
580
+ runUpgradeCommand
581
+ } = await import('./commands/package-workflow.js');
508
582
  return runUpgradeCommand(parsedCommand.argv, commandRuntime);
509
583
  }
510
584
  if (parsedCommand.command === 'new') {
585
+ const {
586
+ runNewCommand
587
+ } = await import('./commands/new.js');
511
588
  return runNewCommand(parsedCommand.argv, commandRuntime);
512
589
  }
513
590
  if (parsedCommand.command === 'migrate') {
591
+ const {
592
+ runMigrateCommand
593
+ } = await import('./commands/migrate.js');
514
594
  return runMigrateCommand(parsedCommand.argv, commandRuntime);
515
595
  }
516
596
  if (parsedCommand.command === 'inspect') {
597
+ const {
598
+ runInspectCommand
599
+ } = await import('./commands/inspect.js');
517
600
  return runInspectCommand(parsedCommand.argv, commandRuntime);
518
601
  }
602
+ if (parsedCommand.command === 'typegen') {
603
+ const {
604
+ runTypegenCommand
605
+ } = await import('./commands/typegen.js');
606
+ return runTypegenCommand(parsedCommand.argv, commandRuntime);
607
+ }
519
608
  if (parsedCommand.command !== 'generate') {
520
609
  throw new Error(usage());
521
610
  }
522
611
  const targetDirectory = resolve(cwd, parsedCommand.parsed.targetDirectory ?? resolveDefaultTargetDirectory(cwd));
612
+ const {
613
+ runGenerateCommand
614
+ } = await import('./commands/generate.js');
523
615
  const result = runGenerateCommand(parsedCommand.parsed.kind, parsedCommand.parsed.name, targetDirectory, parsedCommand.parsed.options);
524
616
  if (parsedCommand.parsed.options.dryRun) {
525
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;AAuHF,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,SAAS,GAAG,QAAQ,GAAG,MAAiB,GAAG,MAAM,CAoB1F;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAgC9G;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5G;AAED,wBAAsB,iBAAiB,CA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Path } 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,4 +1,4 @@
1
- import { type PlatformShellSnapshot } from '@fluojs/runtime';
1
+ import type { PlatformShellSnapshot } from '@fluojs/runtime';
2
2
  type CliStream = {
3
3
  write(message: string): unknown;
4
4
  };
@@ -11,6 +11,8 @@ type ReadableStream = {
11
11
  };
12
12
  type StudioMermaidRenderer = (snapshot: PlatformShellSnapshot) => string;
13
13
  type StudioMermaidRendererLoader = (cwd: string) => Promise<StudioMermaidRenderer | undefined>;
14
+ type RuntimeInspectionModule = Pick<typeof import('@fluojs/runtime'), 'createRuntimeInspectionSnapshot' | 'FluoFactory' | 'PLATFORM_SHELL'>;
15
+ type RuntimeInspectionModuleLoader = (cwd: string) => Promise<RuntimeInspectionModule | undefined>;
14
16
  /**
15
17
  * Runtime options for the inspect command when used programmatically.
16
18
  */
@@ -21,6 +23,8 @@ export interface InspectCommandRuntimeOptions {
21
23
  cwd?: string;
22
24
  /** Force or disable interactive prompts for optional Studio guidance. */
23
25
  interactive?: boolean;
26
+ /** Optional test/editor hook for resolving the runtime inspection dependency. */
27
+ loadRuntimeInspectionModule?: RuntimeInspectionModuleLoader;
24
28
  /** Optional test/editor hook for resolving Studio's Mermaid renderer. */
25
29
  loadStudioMermaidRenderer?: StudioMermaidRendererLoader;
26
30
  /** Custom prompt implementation used only when Studio is missing for Mermaid output. */
@@ -1 +1 @@
1
- {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AAMA,OAAO,EAOL,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAMzB,KAAK,SAAS,GAAG;IACf,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,qBAAqB,GAAG,CAAC,QAAQ,EAAE,qBAAqB,KAAK,MAAM,CAAC;AAEzE,KAAK,2BAA2B,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,yEAAyE;IACz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