@topogram/cli 0.3.62 → 0.3.64

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 (121) hide show
  1. package/package.json +1 -1
  2. package/src/adoption/plan.d.ts +6 -0
  3. package/src/adoption/reporting.d.ts +10 -0
  4. package/src/adoption/review-groups.d.ts +6 -0
  5. package/src/agent-brief.d.ts +3 -0
  6. package/src/agent-brief.js +495 -0
  7. package/src/agent-ops/query-builders.d.ts +26 -0
  8. package/src/archive/archive.d.ts +2 -0
  9. package/src/archive/compact.d.ts +1 -0
  10. package/src/archive/unarchive.d.ts +1 -0
  11. package/src/catalog.d.ts +10 -0
  12. package/src/catalog.js +62 -66
  13. package/src/cli/catalog-alias.d.ts +1 -0
  14. package/src/cli/command-parser.js +38 -0
  15. package/src/cli/command-parsers/core.js +102 -0
  16. package/src/cli/command-parsers/generator.js +39 -0
  17. package/src/cli/command-parsers/import.js +44 -0
  18. package/src/cli/command-parsers/legacy-workflow.js +21 -0
  19. package/src/cli/command-parsers/project.js +47 -0
  20. package/src/cli/command-parsers/sdlc.js +47 -0
  21. package/src/cli/command-parsers/shared.js +51 -0
  22. package/src/cli/command-parsers/template.js +48 -0
  23. package/src/cli/commands/agent.js +47 -0
  24. package/src/cli/commands/catalog.js +617 -0
  25. package/src/cli/commands/check.js +268 -0
  26. package/src/cli/commands/doctor.js +268 -0
  27. package/src/cli/commands/emit.js +149 -0
  28. package/src/cli/commands/generate.js +96 -0
  29. package/src/cli/commands/generator-policy.js +785 -0
  30. package/src/cli/commands/generator.js +443 -0
  31. package/src/cli/commands/import-runner.js +157 -0
  32. package/src/cli/commands/import.js +1734 -0
  33. package/src/cli/commands/inspect.js +55 -0
  34. package/src/cli/commands/new.js +94 -0
  35. package/src/cli/commands/package.js +815 -0
  36. package/src/cli/commands/query.js +1302 -0
  37. package/src/cli/commands/release-rollout.js +257 -0
  38. package/src/cli/commands/release-shared.js +528 -0
  39. package/src/cli/commands/release-status.js +429 -0
  40. package/src/cli/commands/release.js +107 -0
  41. package/src/cli/commands/sdlc.js +168 -0
  42. package/src/cli/commands/setup.js +76 -0
  43. package/src/cli/commands/source.js +291 -0
  44. package/src/cli/commands/template-runner.js +198 -0
  45. package/src/cli/commands/template.js +2145 -0
  46. package/src/cli/commands/trust.js +219 -0
  47. package/src/cli/commands/version.js +40 -0
  48. package/src/cli/commands/widget.js +168 -0
  49. package/src/cli/commands/workflow.js +63 -0
  50. package/src/cli/dispatcher.js +392 -0
  51. package/src/cli/help-dispatch.js +188 -0
  52. package/src/cli/help.js +296 -0
  53. package/src/cli/migration-guidance.js +59 -0
  54. package/src/cli/options.js +96 -0
  55. package/src/cli/output-safety.js +107 -0
  56. package/src/cli/path-normalization.js +29 -0
  57. package/src/cli.js +47 -11711
  58. package/src/example-implementation.d.ts +2 -0
  59. package/src/format.d.ts +1 -0
  60. package/src/generator/check.d.ts +1 -0
  61. package/src/generator/context/bundle.d.ts +1 -0
  62. package/src/generator/context/shared.d.ts +2 -0
  63. package/src/generator/native/parity-bundle.js +2 -1
  64. package/src/generator/surfaces/web/html-escape.js +22 -0
  65. package/src/generator/surfaces/web/react.js +10 -8
  66. package/src/generator/surfaces/web/sveltekit.js +7 -5
  67. package/src/generator/surfaces/web/vanilla.js +8 -4
  68. package/src/generator.d.ts +2 -0
  69. package/src/github-client.js +520 -0
  70. package/src/import/core/shared.js +20 -62
  71. package/src/import/extractors/api/flutter-dio.js +4 -8
  72. package/src/import/extractors/api/react-native-repository.js +4 -8
  73. package/src/import/index.d.ts +4 -0
  74. package/src/import/provenance.d.ts +4 -0
  75. package/src/new-project.js +100 -11
  76. package/src/npm-safety.js +79 -0
  77. package/src/parser.d.ts +1 -0
  78. package/src/path-helpers.d.ts +1 -0
  79. package/src/path-helpers.js +20 -0
  80. package/src/project-config.js +1 -0
  81. package/src/reconcile/docs.d.ts +8 -0
  82. package/src/reconcile/journeys.d.ts +1 -0
  83. package/src/resolver.d.ts +1 -0
  84. package/src/runtime-support.js +29 -0
  85. package/src/sdlc/adopt.d.ts +1 -0
  86. package/src/sdlc/check.d.ts +1 -0
  87. package/src/sdlc/explain.d.ts +1 -0
  88. package/src/sdlc/release.d.ts +1 -0
  89. package/src/sdlc/scaffold.d.ts +1 -0
  90. package/src/sdlc/transition.d.ts +1 -0
  91. package/src/text-helpers.d.ts +6 -0
  92. package/src/text-helpers.js +245 -0
  93. package/src/topogram-config.js +306 -0
  94. package/src/validator.d.ts +2 -0
  95. package/src/workflows/adoption/index.js +26 -0
  96. package/src/workflows/docs-generate.js +262 -0
  97. package/src/workflows/docs-scan.js +703 -0
  98. package/src/workflows/docs.js +15 -0
  99. package/src/workflows/import-app/api.js +799 -0
  100. package/src/workflows/import-app/db.js +538 -0
  101. package/src/workflows/import-app/index.js +30 -0
  102. package/src/workflows/import-app/shared.js +218 -0
  103. package/src/workflows/import-app/ui.js +443 -0
  104. package/src/workflows/import-app/workflow.js +159 -0
  105. package/src/workflows/reconcile/adoption-plan.js +742 -0
  106. package/src/workflows/reconcile/auth.js +692 -0
  107. package/src/workflows/reconcile/bundle-core.js +600 -0
  108. package/src/workflows/reconcile/bundle-shared.js +75 -0
  109. package/src/workflows/reconcile/candidate-model.js +477 -0
  110. package/src/workflows/reconcile/canonical-surface.js +264 -0
  111. package/src/workflows/reconcile/gap-report.js +333 -0
  112. package/src/workflows/reconcile/ids.js +6 -0
  113. package/src/workflows/reconcile/impacts.js +625 -0
  114. package/src/workflows/reconcile/index.js +7 -0
  115. package/src/workflows/reconcile/renderers.js +461 -0
  116. package/src/workflows/reconcile/summary.js +90 -0
  117. package/src/workflows/reconcile/workflow.js +309 -0
  118. package/src/workflows/shared.js +189 -0
  119. package/src/workflows/types.d.ts +93 -0
  120. package/src/workflows.d.ts +1 -0
  121. package/src/workflows.js +10 -7652
@@ -0,0 +1,96 @@
1
+ // @ts-check
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+
6
+ import { loadImplementationProvider } from "../../example-implementation.js";
7
+ import { stableStringify } from "../../format.js";
8
+ import { buildOutputFiles, generateWorkspace } from "../../generator.js";
9
+ import { parsePath } from "../../parser.js";
10
+ import {
11
+ formatProjectConfigErrors,
12
+ loadProjectConfig,
13
+ projectConfigOrDefault,
14
+ validateProjectConfig
15
+ } from "../../project-config.js";
16
+ import { resolveWorkspace } from "../../resolver.js";
17
+ import { formatValidationErrors } from "../../validator.js";
18
+ import {
19
+ assertProjectOutputAllowsWrite,
20
+ assertSafeGeneratedOutputDir,
21
+ GENERATED_OUTPUT_SENTINEL,
22
+ generatedOutputSentinel,
23
+ topogramInputPathForGeneration
24
+ } from "../output-safety.js";
25
+
26
+ /**
27
+ * @param {{
28
+ * inputPath: string,
29
+ * projectRoot: string,
30
+ * outDir?: string|null,
31
+ * profileId?: string|null
32
+ * }} options
33
+ * @returns {Promise<number>}
34
+ */
35
+ export async function runGenerateAppCommand(options) {
36
+ const ast = parsePath(options.inputPath);
37
+ const explicitProjectConfig = loadProjectConfig(options.projectRoot) || loadProjectConfig(options.inputPath);
38
+ const shouldLoadImplementation = Boolean(explicitProjectConfig?.config?.implementation);
39
+ const implementation = shouldLoadImplementation
40
+ ? await loadImplementationProvider(explicitProjectConfig?.configDir || options.projectRoot)
41
+ : null;
42
+ const resolvedForConfig = resolveWorkspace(ast);
43
+ if (!resolvedForConfig.ok) {
44
+ console.error(formatValidationErrors(resolvedForConfig.validation));
45
+ return 1;
46
+ }
47
+ const defaultProjectConfig = projectConfigOrDefault(options.projectRoot, resolvedForConfig.graph, implementation);
48
+ const projectConfigInfo = explicitProjectConfig || defaultProjectConfig;
49
+ if (!projectConfigInfo) {
50
+ console.error("Unable to resolve topogram.project.json or derive a default project config.");
51
+ return 1;
52
+ }
53
+ const projectConfigValidation = validateProjectConfig(projectConfigInfo.config, resolvedForConfig.graph, {
54
+ configDir: projectConfigInfo.configDir
55
+ });
56
+ if (!projectConfigValidation.ok) {
57
+ console.error(formatProjectConfigErrors(projectConfigValidation, projectConfigInfo?.configPath || "topogram.project.json"));
58
+ return 1;
59
+ }
60
+
61
+ const result = generateWorkspace(ast, {
62
+ target: "app-bundle",
63
+ profileId: options.profileId,
64
+ topogramInputPath: topogramInputPathForGeneration(options.inputPath),
65
+ implementation,
66
+ projectConfig: projectConfigInfo.config,
67
+ configDir: projectConfigInfo.configDir || options.projectRoot,
68
+ projectRoot: projectConfigInfo.configDir || options.projectRoot
69
+ });
70
+ if (!result.ok) {
71
+ console.error(formatValidationErrors(result.validation));
72
+ return 1;
73
+ }
74
+
75
+ const resolvedOutDir = path.resolve(options.outDir || "./app");
76
+ assertProjectOutputAllowsWrite(projectConfigInfo, resolvedOutDir);
77
+ assertSafeGeneratedOutputDir(resolvedOutDir, options.inputPath);
78
+ const outputFiles = buildOutputFiles(result, {});
79
+ outputFiles.unshift({
80
+ path: GENERATED_OUTPUT_SENTINEL,
81
+ contents: generatedOutputSentinel("app-bundle")
82
+ });
83
+ fs.rmSync(resolvedOutDir, { recursive: true, force: true });
84
+ fs.mkdirSync(resolvedOutDir, { recursive: true });
85
+
86
+ for (const file of outputFiles) {
87
+ const destination = path.join(resolvedOutDir, file.path);
88
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
89
+ const contents =
90
+ typeof file.contents === "string" ? file.contents : `${stableStringify(file.contents)}\n`;
91
+ fs.writeFileSync(destination, contents, "utf8");
92
+ }
93
+
94
+ console.log(`Wrote ${outputFiles.length} file(s) to ${resolvedOutDir}`);
95
+ return 0;
96
+ }