@lite-fsm/cli 0.1.0 → 0.1.1

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 (89) hide show
  1. package/README.md +130 -0
  2. package/dist/bin/lite-fsm.js +6714 -5
  3. package/package.json +6 -4
  4. package/dist/bin/lite-fsm.d.cts +0 -2
  5. package/dist/bin/lite-fsm.d.ts +0 -2
  6. package/dist/cli/context.d.cts +0 -21
  7. package/dist/cli/context.d.ts +0 -21
  8. package/dist/cli/context.js +0 -0
  9. package/dist/cli/create-program.d.cts +0 -6
  10. package/dist/cli/create-program.d.ts +0 -6
  11. package/dist/cli/create-program.js +0 -48
  12. package/dist/cli/diagnostics.d.cts +0 -15
  13. package/dist/cli/diagnostics.d.ts +0 -15
  14. package/dist/cli/diagnostics.js +0 -13
  15. package/dist/cli/node-fs.d.cts +0 -2
  16. package/dist/cli/node-fs.d.ts +0 -2
  17. package/dist/cli/node-fs.js +0 -33
  18. package/dist/cli/result.d.cts +0 -6
  19. package/dist/cli/result.d.ts +0 -6
  20. package/dist/cli/result.js +0 -8
  21. package/dist/export-graph/command.d.cts +0 -8
  22. package/dist/export-graph/command.d.ts +0 -8
  23. package/dist/export-graph/command.js +0 -30
  24. package/dist/export-graph/export-document.d.cts +0 -38
  25. package/dist/export-graph/export-document.d.ts +0 -38
  26. package/dist/export-graph/export-document.js +0 -35
  27. package/dist/export-graph/options.d.cts +0 -21
  28. package/dist/export-graph/options.d.ts +0 -21
  29. package/dist/export-graph/options.js +0 -40
  30. package/dist/export-graph/run-export-graph.d.cts +0 -10
  31. package/dist/export-graph/run-export-graph.d.ts +0 -10
  32. package/dist/export-graph/run-export-graph.js +0 -53
  33. package/dist/export-graph/source-bundle.d.cts +0 -12
  34. package/dist/export-graph/source-bundle.d.ts +0 -12
  35. package/dist/export-graph/source-bundle.js +0 -48
  36. package/dist/export-graph/write-output.d.cts +0 -10
  37. package/dist/export-graph/write-output.d.ts +0 -10
  38. package/dist/export-graph/write-output.js +0 -24
  39. package/dist/output/format-diagnostics.d.cts +0 -6
  40. package/dist/output/format-diagnostics.d.ts +0 -6
  41. package/dist/output/format-diagnostics.js +0 -33
  42. package/dist/output/stable-json.d.cts +0 -1
  43. package/dist/output/stable-json.d.ts +0 -1
  44. package/dist/output/stable-json.js +0 -72
  45. package/dist/project/build-project-graph.d.cts +0 -19
  46. package/dist/project/build-project-graph.d.ts +0 -19
  47. package/dist/project/build-project-graph.js +0 -64
  48. package/dist/project/create-project-host.d.cts +0 -4
  49. package/dist/project/create-project-host.d.ts +0 -4
  50. package/dist/project/create-project-host.js +0 -11
  51. package/dist/project/module-resolver.d.cts +0 -15
  52. package/dist/project/module-resolver.d.ts +0 -15
  53. package/dist/project/module-resolver.js +0 -111
  54. package/dist/project/source-cache.d.cts +0 -11
  55. package/dist/project/source-cache.d.ts +0 -11
  56. package/dist/project/source-cache.js +0 -55
  57. package/dist/project/tsconfig.d.cts +0 -15
  58. package/dist/project/tsconfig.d.ts +0 -15
  59. package/dist/project/tsconfig.js +0 -116
  60. package/dist/visualize/command.d.cts +0 -9
  61. package/dist/visualize/command.d.ts +0 -9
  62. package/dist/visualize/command.js +0 -35
  63. package/dist/visualize/http.d.cts +0 -11
  64. package/dist/visualize/http.d.ts +0 -11
  65. package/dist/visualize/http.js +0 -65
  66. package/dist/visualize/open-browser.d.cts +0 -22
  67. package/dist/visualize/open-browser.d.ts +0 -22
  68. package/dist/visualize/open-browser.js +0 -45
  69. package/dist/visualize/options.d.cts +0 -16
  70. package/dist/visualize/options.d.ts +0 -16
  71. package/dist/visualize/options.js +0 -51
  72. package/dist/visualize/routes.d.cts +0 -2
  73. package/dist/visualize/routes.d.ts +0 -2
  74. package/dist/visualize/routes.js +0 -24
  75. package/dist/visualize/run-visualize.d.cts +0 -32
  76. package/dist/visualize/run-visualize.d.ts +0 -32
  77. package/dist/visualize/run-visualize.js +0 -81
  78. package/dist/visualize/server.d.cts +0 -40
  79. package/dist/visualize/server.d.ts +0 -40
  80. package/dist/visualize/server.js +0 -90
  81. package/dist/visualize/session.d.cts +0 -34
  82. package/dist/visualize/session.d.ts +0 -34
  83. package/dist/visualize/session.js +0 -137
  84. package/dist/visualize/static-assets.d.cts +0 -17
  85. package/dist/visualize/static-assets.d.ts +0 -17
  86. package/dist/visualize/static-assets.js +0 -87
  87. package/dist/visualize/types.d.cts +0 -65
  88. package/dist/visualize/types.d.ts +0 -65
  89. package/dist/visualize/types.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lite-fsm/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Alpha CLI for lite-fsm project graph exports",
6
6
  "license": "MIT",
@@ -38,18 +38,20 @@
38
38
  "node": ">=20"
39
39
  },
40
40
  "dependencies": {
41
- "commander": "^14.0.3",
42
41
  "typescript": "^6.0.3",
43
- "@lite-fsm/graph": "0.1.0"
42
+ "@lite-fsm/graph": "0.1.1"
44
43
  },
45
44
  "devDependencies": {
46
45
  "@types/node": "^25.6.0",
47
46
  "@vitest/coverage-v8": "^4.1.4",
47
+ "commander": "^14.0.3",
48
+ "jiti": "^2.7.0",
48
49
  "tsup": "^8.5.1",
49
50
  "vitest": "^4.1.4"
50
51
  },
51
52
  "scripts": {
52
- "build": "pnpm --filter @lite-fsm/graph build && node scripts/build-visualizer.mjs && tsup --config tsup.config.ts && tsc -p tsconfig.build.json && node ../../scripts/dts-to-dcts.mjs dist && chmod +x dist/bin/lite-fsm.js && node scripts/copy-visualizer.mjs && node scripts/check-visualizer-artifact.mjs",
53
+ "build": "pnpm --filter @lite-fsm/graph build && node scripts/build-visualizer.mjs && tsup --config tsup.config.ts && chmod +x dist/bin/lite-fsm.js && node scripts/copy-visualizer.mjs && node scripts/check-dist.mjs",
54
+ "check-dist": "node scripts/check-dist.mjs",
53
55
  "check-types": "tsc --noEmit -p tsconfig.json",
54
56
  "test:unit": "vitest run --config vitest.config.ts",
55
57
  "test:coverage": "vitest run --coverage --config vitest.config.ts"
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,21 +0,0 @@
1
- import type { Writable } from "node:stream";
2
- export type CliFileSystem = {
3
- readFile(path: string): string;
4
- readFileBuffer?(path: string): Uint8Array;
5
- writeFile(path: string, contents: string): void;
6
- mkdir(path: string, options: {
7
- recursive: true;
8
- }): void;
9
- rename(from: string, to: string): void;
10
- unlink(path: string): void;
11
- fileExists(path: string): boolean;
12
- directoryExists(path: string): boolean;
13
- realpath?(path: string): string;
14
- };
15
- export type CliContext = {
16
- cwd: string;
17
- stdout: Writable;
18
- stderr: Writable;
19
- env: Readonly<Record<string, string | undefined>>;
20
- fs: CliFileSystem;
21
- };
@@ -1,21 +0,0 @@
1
- import type { Writable } from "node:stream";
2
- export type CliFileSystem = {
3
- readFile(path: string): string;
4
- readFileBuffer?(path: string): Uint8Array;
5
- writeFile(path: string, contents: string): void;
6
- mkdir(path: string, options: {
7
- recursive: true;
8
- }): void;
9
- rename(from: string, to: string): void;
10
- unlink(path: string): void;
11
- fileExists(path: string): boolean;
12
- directoryExists(path: string): boolean;
13
- realpath?(path: string): string;
14
- };
15
- export type CliContext = {
16
- cwd: string;
17
- stdout: Writable;
18
- stderr: Writable;
19
- env: Readonly<Record<string, string | undefined>>;
20
- fs: CliFileSystem;
21
- };
File without changes
@@ -1,6 +0,0 @@
1
- import type { CliContext } from "./context.js";
2
- import type { CommandResult } from "./result.js";
3
- export type CliProgram = {
4
- parse(argv: readonly string[]): Promise<CommandResult>;
5
- };
6
- export declare const createProgram: (context: CliContext) => CliProgram;
@@ -1,6 +0,0 @@
1
- import type { CliContext } from "./context.js";
2
- import type { CommandResult } from "./result.js";
3
- export type CliProgram = {
4
- parse(argv: readonly string[]): Promise<CommandResult>;
5
- };
6
- export declare const createProgram: (context: CliContext) => CliProgram;
@@ -1,48 +0,0 @@
1
- import { Command, CommanderError } from "commander";
2
- import { cliDiagnostic } from "./diagnostics.js";
3
- import { createCommandResult } from "./result.js";
4
- import { registerExportGraphCommand } from "../export-graph/command.js";
5
- import { formatDiagnostics } from "../output/format-diagnostics.js";
6
- import { registerVisualizeCommand } from "../visualize/command.js";
7
- const invalidOptionsResult = (context, message) => {
8
- const diagnostic = cliDiagnostic("LFC_INVALID_OPTIONS", "error", message);
9
- context.stderr.write(formatDiagnostics([diagnostic]));
10
- return createCommandResult([diagnostic]);
11
- };
12
- const isHelpDisplayed = (error) => {
13
- return error instanceof CommanderError && error.code === "commander.helpDisplayed";
14
- };
15
- const isCommanderError = (error) => {
16
- return error instanceof CommanderError;
17
- };
18
- const createProgram = (context) => {
19
- let commandResult = { exitCode: 0, diagnostics: [] };
20
- const program = new Command();
21
- program.name("lite-fsm").description("lite-fsm command line tools").exitOverride().configureOutput({
22
- writeOut: (value) => context.stdout.write(value),
23
- /* v8 ignore next -- commander calls this only for its own formatted stderr, which CLI suppresses in favor of CliDiagnostic output. */
24
- writeErr: () => void 0,
25
- outputError: () => void 0
26
- });
27
- registerExportGraphCommand(program, context, (result) => {
28
- commandResult = result;
29
- });
30
- registerVisualizeCommand(program, context, (result) => {
31
- commandResult = result;
32
- });
33
- return {
34
- async parse(argv) {
35
- commandResult = { exitCode: 0, diagnostics: [] };
36
- try {
37
- await program.parseAsync([...argv], { from: "node" });
38
- } catch (error) {
39
- if (isHelpDisplayed(error)) return { exitCode: 0, diagnostics: [] };
40
- return invalidOptionsResult(context, isCommanderError(error) ? error.message : String(error));
41
- }
42
- return commandResult;
43
- }
44
- };
45
- };
46
- export {
47
- createProgram
48
- };
@@ -1,15 +0,0 @@
1
- export type CliDiagnosticSeverity = "info" | "warning" | "error";
2
- export type CliDiagnosticCode = "LFC_INVALID_OPTIONS" | "LFC_TSCONFIG_NOT_FOUND" | "LFC_TSCONFIG_INVALID" | "LFC_GRAPH_PROJECT_FAILED" | "LFC_NO_MACHINES_EXPORTED" | "LFC_SOURCE_BUNDLE_FILE_UNREADABLE" | "LFC_VISUALIZER_STATIC_MISSING" | "LFC_VISUALIZER_PORT_UNAVAILABLE" | "LFC_VISUALIZER_SERVER_FAILED" | "LFC_VISUALIZER_OPEN_FAILED" | "LFC_WRITE_FAILED";
3
- export type CliDiagnostic = {
4
- code: CliDiagnosticCode;
5
- severity: CliDiagnosticSeverity;
6
- message: string;
7
- file?: string;
8
- loc?: {
9
- line: number;
10
- column: number;
11
- };
12
- hint?: string;
13
- };
14
- export declare const cliDiagnostic: (code: CliDiagnosticCode, severity: CliDiagnosticSeverity, message: string, details?: Omit<CliDiagnostic, "code" | "severity" | "message">) => CliDiagnostic;
15
- export declare const hasBlockingCliDiagnostics: (diagnostics: readonly CliDiagnostic[]) => boolean;
@@ -1,15 +0,0 @@
1
- export type CliDiagnosticSeverity = "info" | "warning" | "error";
2
- export type CliDiagnosticCode = "LFC_INVALID_OPTIONS" | "LFC_TSCONFIG_NOT_FOUND" | "LFC_TSCONFIG_INVALID" | "LFC_GRAPH_PROJECT_FAILED" | "LFC_NO_MACHINES_EXPORTED" | "LFC_SOURCE_BUNDLE_FILE_UNREADABLE" | "LFC_VISUALIZER_STATIC_MISSING" | "LFC_VISUALIZER_PORT_UNAVAILABLE" | "LFC_VISUALIZER_SERVER_FAILED" | "LFC_VISUALIZER_OPEN_FAILED" | "LFC_WRITE_FAILED";
3
- export type CliDiagnostic = {
4
- code: CliDiagnosticCode;
5
- severity: CliDiagnosticSeverity;
6
- message: string;
7
- file?: string;
8
- loc?: {
9
- line: number;
10
- column: number;
11
- };
12
- hint?: string;
13
- };
14
- export declare const cliDiagnostic: (code: CliDiagnosticCode, severity: CliDiagnosticSeverity, message: string, details?: Omit<CliDiagnostic, "code" | "severity" | "message">) => CliDiagnostic;
15
- export declare const hasBlockingCliDiagnostics: (diagnostics: readonly CliDiagnostic[]) => boolean;
@@ -1,13 +0,0 @@
1
- const cliDiagnostic = (code, severity, message, details = {}) => ({
2
- code,
3
- severity,
4
- message,
5
- ...details
6
- });
7
- const hasBlockingCliDiagnostics = (diagnostics) => {
8
- return diagnostics.some((diagnostic) => diagnostic.severity === "error");
9
- };
10
- export {
11
- cliDiagnostic,
12
- hasBlockingCliDiagnostics
13
- };
@@ -1,2 +0,0 @@
1
- import type { CliFileSystem } from "./context.js";
2
- export declare const createNodeFileSystem: () => CliFileSystem;
@@ -1,2 +0,0 @@
1
- import type { CliFileSystem } from "./context.js";
2
- export declare const createNodeFileSystem: () => CliFileSystem;
@@ -1,33 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
2
- const createNodeFileSystem = () => ({
3
- readFile(path) {
4
- return readFileSync(path, "utf8");
5
- },
6
- readFileBuffer(path) {
7
- return readFileSync(path);
8
- },
9
- writeFile(path, contents) {
10
- writeFileSync(path, contents, "utf8");
11
- },
12
- mkdir(path, options) {
13
- mkdirSync(path, options);
14
- },
15
- rename(from, to) {
16
- renameSync(from, to);
17
- },
18
- unlink(path) {
19
- unlinkSync(path);
20
- },
21
- fileExists(path) {
22
- return existsSync(path) && statSync(path).isFile();
23
- },
24
- directoryExists(path) {
25
- return existsSync(path) && statSync(path).isDirectory();
26
- },
27
- realpath(path) {
28
- return realpathSync(path);
29
- }
30
- });
31
- export {
32
- createNodeFileSystem
33
- };
@@ -1,6 +0,0 @@
1
- import type { CliDiagnostic } from "./diagnostics.js";
2
- export type CommandResult = {
3
- exitCode: 0 | 1;
4
- diagnostics: CliDiagnostic[];
5
- };
6
- export declare const createCommandResult: (diagnostics: readonly CliDiagnostic[]) => CommandResult;
@@ -1,6 +0,0 @@
1
- import type { CliDiagnostic } from "./diagnostics.js";
2
- export type CommandResult = {
3
- exitCode: 0 | 1;
4
- diagnostics: CliDiagnostic[];
5
- };
6
- export declare const createCommandResult: (diagnostics: readonly CliDiagnostic[]) => CommandResult;
@@ -1,8 +0,0 @@
1
- import { hasBlockingCliDiagnostics } from "./diagnostics.js";
2
- const createCommandResult = (diagnostics) => ({
3
- exitCode: hasBlockingCliDiagnostics(diagnostics) ? 1 : 0,
4
- diagnostics: [...diagnostics]
5
- });
6
- export {
7
- createCommandResult
8
- };
@@ -1,8 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { CommandResult } from "../cli/result.js";
4
- import { type RawExportGraphOptions } from "./options.js";
5
- type SetCommandResult = (result: CommandResult) => void;
6
- export declare const runExportGraphCommand: (context: CliContext, rawOptions: RawExportGraphOptions) => Promise<CommandResult>;
7
- export declare const registerExportGraphCommand: (program: Command, context: CliContext, setResult: SetCommandResult) => void;
8
- export {};
@@ -1,8 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { CommandResult } from "../cli/result.js";
4
- import { type RawExportGraphOptions } from "./options.js";
5
- type SetCommandResult = (result: CommandResult) => void;
6
- export declare const runExportGraphCommand: (context: CliContext, rawOptions: RawExportGraphOptions) => Promise<CommandResult>;
7
- export declare const registerExportGraphCommand: (program: Command, context: CliContext, setResult: SetCommandResult) => void;
8
- export {};
@@ -1,30 +0,0 @@
1
- import { createCommandResult } from "../cli/result.js";
2
- import { formatDiagnostics } from "../output/format-diagnostics.js";
3
- import { normalizeExportGraphOptions } from "./options.js";
4
- const writeDiagnostics = (context, diagnostics) => {
5
- const formatted = formatDiagnostics(diagnostics);
6
- if (formatted) context.stderr.write(formatted);
7
- };
8
- const runExportGraphCommand = async (context, rawOptions) => {
9
- const normalized = normalizeExportGraphOptions(rawOptions);
10
- if (!normalized.ok) {
11
- writeDiagnostics(context, normalized.diagnostics);
12
- return createCommandResult(normalized.diagnostics);
13
- }
14
- const { runExportGraph } = await import("./run-export-graph.js");
15
- const result = runExportGraph(context, normalized.options);
16
- writeDiagnostics(context, [...result.diagnostics, ...result.graphDiagnostics]);
17
- return {
18
- exitCode: result.exitCode,
19
- diagnostics: result.diagnostics
20
- };
21
- };
22
- const registerExportGraphCommand = (program, context, setResult) => {
23
- program.command("export-graph").description("Export a lite-fsm project graph document as JSON").option("--entry <path>", "entrypoint TypeScript file").option("--out <path>", "output JSON file").option("--tsconfig <path>", "explicit tsconfig for TypeScript module resolution").option("--include-source", "embed project source text in JSON export").action(async (options) => {
24
- setResult(await runExportGraphCommand(context, options));
25
- });
26
- };
27
- export {
28
- registerExportGraphCommand,
29
- runExportGraphCommand
30
- };
@@ -1,38 +0,0 @@
1
- import type { LiteFsmGraphDocument, LiteFsmGraphProjectFile, LiteFsmGraphProjectResult } from "@lite-fsm/graph";
2
- import type { CliDiagnostic } from "../cli/diagnostics.js";
3
- export declare const PROJECT_GRAPH_EXPORT_VERSION = "lite-fsm.project-graph-export/v1";
4
- export declare const CLI_PACKAGE_NAME = "@lite-fsm/cli";
5
- export declare const CLI_PACKAGE_VERSION = "0.1.0";
6
- export type LiteFsmProjectGraphExportDocument = {
7
- version: typeof PROJECT_GRAPH_EXPORT_VERSION;
8
- createdBy: {
9
- package: typeof CLI_PACKAGE_NAME;
10
- version: string;
11
- };
12
- entry: {
13
- path: string;
14
- tsconfigPath?: string;
15
- };
16
- graph: LiteFsmGraphDocument;
17
- files: readonly LiteFsmGraphProjectFile[];
18
- diagnostics: readonly CliDiagnostic[];
19
- sources?: LiteFsmProjectGraphSourceBundle;
20
- };
21
- export type LiteFsmProjectGraphSourceFile = {
22
- fileName: string;
23
- language: "ts";
24
- hash: string;
25
- text: string;
26
- };
27
- export type LiteFsmProjectGraphSourceBundle = {
28
- files: readonly LiteFsmProjectGraphSourceFile[];
29
- };
30
- export type CreateProjectGraphExportDocumentOptions = {
31
- entryPath: string;
32
- tsconfigPath?: string;
33
- graphResult: LiteFsmGraphProjectResult;
34
- diagnostics: readonly CliDiagnostic[];
35
- sources?: LiteFsmProjectGraphSourceBundle;
36
- };
37
- export declare const createProjectGraphExportDocument: ({ entryPath, tsconfigPath, graphResult, diagnostics, sources, }: CreateProjectGraphExportDocumentOptions) => LiteFsmProjectGraphExportDocument;
38
- export declare const stringifyProjectGraphExportDocument: (document: LiteFsmProjectGraphExportDocument) => string;
@@ -1,38 +0,0 @@
1
- import type { LiteFsmGraphDocument, LiteFsmGraphProjectFile, LiteFsmGraphProjectResult } from "@lite-fsm/graph";
2
- import type { CliDiagnostic } from "../cli/diagnostics.js";
3
- export declare const PROJECT_GRAPH_EXPORT_VERSION = "lite-fsm.project-graph-export/v1";
4
- export declare const CLI_PACKAGE_NAME = "@lite-fsm/cli";
5
- export declare const CLI_PACKAGE_VERSION = "0.1.0";
6
- export type LiteFsmProjectGraphExportDocument = {
7
- version: typeof PROJECT_GRAPH_EXPORT_VERSION;
8
- createdBy: {
9
- package: typeof CLI_PACKAGE_NAME;
10
- version: string;
11
- };
12
- entry: {
13
- path: string;
14
- tsconfigPath?: string;
15
- };
16
- graph: LiteFsmGraphDocument;
17
- files: readonly LiteFsmGraphProjectFile[];
18
- diagnostics: readonly CliDiagnostic[];
19
- sources?: LiteFsmProjectGraphSourceBundle;
20
- };
21
- export type LiteFsmProjectGraphSourceFile = {
22
- fileName: string;
23
- language: "ts";
24
- hash: string;
25
- text: string;
26
- };
27
- export type LiteFsmProjectGraphSourceBundle = {
28
- files: readonly LiteFsmProjectGraphSourceFile[];
29
- };
30
- export type CreateProjectGraphExportDocumentOptions = {
31
- entryPath: string;
32
- tsconfigPath?: string;
33
- graphResult: LiteFsmGraphProjectResult;
34
- diagnostics: readonly CliDiagnostic[];
35
- sources?: LiteFsmProjectGraphSourceBundle;
36
- };
37
- export declare const createProjectGraphExportDocument: ({ entryPath, tsconfigPath, graphResult, diagnostics, sources, }: CreateProjectGraphExportDocumentOptions) => LiteFsmProjectGraphExportDocument;
38
- export declare const stringifyProjectGraphExportDocument: (document: LiteFsmProjectGraphExportDocument) => string;
@@ -1,35 +0,0 @@
1
- import { stringifyStableJson } from "../output/stable-json.js";
2
- const PROJECT_GRAPH_EXPORT_VERSION = "lite-fsm.project-graph-export/v1";
3
- const CLI_PACKAGE_NAME = "@lite-fsm/cli";
4
- const CLI_PACKAGE_VERSION = "0.1.0";
5
- const createProjectGraphExportDocument = ({
6
- entryPath,
7
- tsconfigPath,
8
- graphResult,
9
- diagnostics,
10
- sources
11
- }) => ({
12
- version: PROJECT_GRAPH_EXPORT_VERSION,
13
- createdBy: {
14
- package: CLI_PACKAGE_NAME,
15
- version: CLI_PACKAGE_VERSION
16
- },
17
- entry: {
18
- path: entryPath,
19
- ...tsconfigPath ? { tsconfigPath } : {}
20
- },
21
- graph: graphResult.document,
22
- files: graphResult.files,
23
- diagnostics,
24
- ...sources ? { sources } : {}
25
- });
26
- const stringifyProjectGraphExportDocument = (document) => {
27
- return stringifyStableJson(document);
28
- };
29
- export {
30
- CLI_PACKAGE_NAME,
31
- CLI_PACKAGE_VERSION,
32
- PROJECT_GRAPH_EXPORT_VERSION,
33
- createProjectGraphExportDocument,
34
- stringifyProjectGraphExportDocument
35
- };
@@ -1,21 +0,0 @@
1
- import type { CliDiagnostic } from "../cli/diagnostics.js";
2
- export type ExportGraphOptions = {
3
- entry: string;
4
- out: string;
5
- tsconfig?: string;
6
- includeSource: boolean;
7
- };
8
- export type RawExportGraphOptions = {
9
- entry?: unknown;
10
- out?: unknown;
11
- tsconfig?: unknown;
12
- includeSource?: unknown;
13
- };
14
- export type NormalizeExportGraphOptionsResult = {
15
- ok: true;
16
- options: ExportGraphOptions;
17
- } | {
18
- ok: false;
19
- diagnostics: CliDiagnostic[];
20
- };
21
- export declare const normalizeExportGraphOptions: (rawOptions: RawExportGraphOptions) => NormalizeExportGraphOptionsResult;
@@ -1,21 +0,0 @@
1
- import type { CliDiagnostic } from "../cli/diagnostics.js";
2
- export type ExportGraphOptions = {
3
- entry: string;
4
- out: string;
5
- tsconfig?: string;
6
- includeSource: boolean;
7
- };
8
- export type RawExportGraphOptions = {
9
- entry?: unknown;
10
- out?: unknown;
11
- tsconfig?: unknown;
12
- includeSource?: unknown;
13
- };
14
- export type NormalizeExportGraphOptionsResult = {
15
- ok: true;
16
- options: ExportGraphOptions;
17
- } | {
18
- ok: false;
19
- diagnostics: CliDiagnostic[];
20
- };
21
- export declare const normalizeExportGraphOptions: (rawOptions: RawExportGraphOptions) => NormalizeExportGraphOptionsResult;
@@ -1,40 +0,0 @@
1
- import { cliDiagnostic } from "../cli/diagnostics.js";
2
- const stringOption = (value) => {
3
- return typeof value === "string" && value.trim() !== "" ? value : void 0;
4
- };
5
- const normalizeExportGraphOptions = (rawOptions) => {
6
- const entry = stringOption(rawOptions.entry);
7
- const out = stringOption(rawOptions.out);
8
- const tsconfig = stringOption(rawOptions.tsconfig);
9
- const includeSource = rawOptions.includeSource === true;
10
- const diagnostics = [];
11
- if (!entry) {
12
- diagnostics.push(
13
- cliDiagnostic("LFC_INVALID_OPTIONS", "error", "Option --entry is required.", {
14
- hint: "Pass --entry path/to/store/index.ts."
15
- })
16
- );
17
- }
18
- if (!out) {
19
- diagnostics.push(
20
- cliDiagnostic("LFC_INVALID_OPTIONS", "error", "Option --out is required.", {
21
- hint: "Pass --out lite-fsm.graph.json."
22
- })
23
- );
24
- } else if (out === "-") {
25
- diagnostics.push(cliDiagnostic("LFC_INVALID_OPTIONS", "error", "JSON stdout output is not supported. Pass a file path to --out."));
26
- }
27
- if (diagnostics.length > 0) return { ok: false, diagnostics };
28
- return {
29
- ok: true,
30
- options: {
31
- entry,
32
- out,
33
- includeSource,
34
- ...tsconfig ? { tsconfig } : {}
35
- }
36
- };
37
- };
38
- export {
39
- normalizeExportGraphOptions
40
- };
@@ -1,10 +0,0 @@
1
- import type { GraphDiagnostic } from "@lite-fsm/graph";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { CommandResult } from "../cli/result.js";
4
- import { type ProjectGraphBuildResult } from "../project/build-project-graph.js";
5
- import type { ExportGraphOptions } from "./options.js";
6
- export type ExportGraphRunResult = CommandResult & {
7
- graphDiagnostics: GraphDiagnostic[];
8
- };
9
- export declare const createExportGraphRunResult: (context: CliContext, options: ExportGraphOptions, buildResult: ProjectGraphBuildResult) => ExportGraphRunResult;
10
- export declare const runExportGraph: (context: CliContext, options: ExportGraphOptions) => ExportGraphRunResult;
@@ -1,10 +0,0 @@
1
- import type { GraphDiagnostic } from "@lite-fsm/graph";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { CommandResult } from "../cli/result.js";
4
- import { type ProjectGraphBuildResult } from "../project/build-project-graph.js";
5
- import type { ExportGraphOptions } from "./options.js";
6
- export type ExportGraphRunResult = CommandResult & {
7
- graphDiagnostics: GraphDiagnostic[];
8
- };
9
- export declare const createExportGraphRunResult: (context: CliContext, options: ExportGraphOptions, buildResult: ProjectGraphBuildResult) => ExportGraphRunResult;
10
- export declare const runExportGraph: (context: CliContext, options: ExportGraphOptions) => ExportGraphRunResult;
@@ -1,53 +0,0 @@
1
- import { cliDiagnostic, hasBlockingCliDiagnostics } from "../cli/diagnostics.js";
2
- import { buildProjectGraph } from "../project/build-project-graph.js";
3
- import { createProjectGraphExportDocument, stringifyProjectGraphExportDocument } from "./export-document.js";
4
- import { createProjectGraphSourceBundle } from "./source-bundle.js";
5
- import { writeOutput } from "./write-output.js";
6
- const graphHasBlockingDiagnostics = (diagnostics) => {
7
- return diagnostics.some((diagnostic) => diagnostic.severity === "error");
8
- };
9
- const hasExportedMachines = (graphResult) => {
10
- return graphResult.document.managers.some((manager) => manager.machineRefs.length > 0);
11
- };
12
- const result = (diagnostics, graphDiagnostics = []) => ({
13
- exitCode: hasBlockingCliDiagnostics(diagnostics) ? 1 : 0,
14
- diagnostics: [...diagnostics],
15
- graphDiagnostics: [...graphDiagnostics]
16
- });
17
- const createExportGraphRunResult = (context, options, buildResult) => {
18
- const graphDiagnostics = buildResult.graphResult?.diagnostics ?? [];
19
- const diagnostics = [...buildResult.diagnostics];
20
- if (buildResult.blocking) return result(diagnostics, graphDiagnostics);
21
- if (!buildResult.graphResult) {
22
- diagnostics.push(cliDiagnostic("LFC_GRAPH_PROJECT_FAILED", "error", "Project graph build did not return a graph result."));
23
- return result(diagnostics, graphDiagnostics);
24
- }
25
- if (graphHasBlockingDiagnostics(graphDiagnostics)) {
26
- diagnostics.push(cliDiagnostic("LFC_GRAPH_PROJECT_FAILED", "error", "Project graph compile finished with blocking diagnostics."));
27
- return result(diagnostics, graphDiagnostics);
28
- }
29
- if (!hasExportedMachines(buildResult.graphResult)) {
30
- diagnostics.push(cliDiagnostic("LFC_NO_MACHINES_EXPORTED", "error", "Project graph export has no manager machine refs."));
31
- return result(diagnostics, graphDiagnostics);
32
- }
33
- const sources = options.includeSource ? createProjectGraphSourceBundle(context, buildResult.project.projectRoot, buildResult.graphResult.files) : void 0;
34
- if (sources && !sources.ok) return result([...diagnostics, ...sources.diagnostics], graphDiagnostics);
35
- const document = createProjectGraphExportDocument({
36
- entryPath: buildResult.project.entryPath,
37
- tsconfigPath: buildResult.project.tsconfigPath,
38
- graphResult: buildResult.graphResult,
39
- diagnostics,
40
- ...sources ? { sources: sources.sources } : {}
41
- });
42
- const written = writeOutput(context, options.out, stringifyProjectGraphExportDocument(document));
43
- if (!written.ok) return result([...diagnostics, ...written.diagnostics], graphDiagnostics);
44
- return result(diagnostics, graphDiagnostics);
45
- };
46
- const runExportGraph = (context, options) => {
47
- const buildResult = buildProjectGraph(context, { entry: options.entry, tsconfig: options.tsconfig });
48
- return createExportGraphRunResult(context, options, buildResult);
49
- };
50
- export {
51
- createExportGraphRunResult,
52
- runExportGraph
53
- };
@@ -1,12 +0,0 @@
1
- import type { LiteFsmGraphProjectFile } from "@lite-fsm/graph";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { CliDiagnostic } from "../cli/diagnostics.js";
4
- import type { LiteFsmProjectGraphSourceBundle } from "./export-document.js";
5
- export type CreateProjectGraphSourceBundleResult = {
6
- ok: true;
7
- sources: LiteFsmProjectGraphSourceBundle;
8
- } | {
9
- ok: false;
10
- diagnostics: CliDiagnostic[];
11
- };
12
- export declare const createProjectGraphSourceBundle: (context: CliContext, projectRoot: string, files: readonly LiteFsmGraphProjectFile[]) => CreateProjectGraphSourceBundleResult;
@@ -1,12 +0,0 @@
1
- import type { LiteFsmGraphProjectFile } from "@lite-fsm/graph";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { CliDiagnostic } from "../cli/diagnostics.js";
4
- import type { LiteFsmProjectGraphSourceBundle } from "./export-document.js";
5
- export type CreateProjectGraphSourceBundleResult = {
6
- ok: true;
7
- sources: LiteFsmProjectGraphSourceBundle;
8
- } | {
9
- ok: false;
10
- diagnostics: CliDiagnostic[];
11
- };
12
- export declare const createProjectGraphSourceBundle: (context: CliContext, projectRoot: string, files: readonly LiteFsmGraphProjectFile[]) => CreateProjectGraphSourceBundleResult;