@venn-lang/cli 0.1.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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +284 -0
  3. package/dist/bin/venn.mjs +16 -0
  4. package/dist/cli.mjs +56378 -0
  5. package/dist/index.d.mts +98 -0
  6. package/dist/index.d.mts.map +1 -0
  7. package/dist/index.mjs +916 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +67 -0
  10. package/src/bin/venn.ts +14 -0
  11. package/src/cli.ts +299 -0
  12. package/src/commands/build.ts +97 -0
  13. package/src/commands/check.ts +143 -0
  14. package/src/commands/deps.ts +228 -0
  15. package/src/commands/fmt.ts +55 -0
  16. package/src/commands/index.ts +2 -0
  17. package/src/commands/inside-workspace.ts +20 -0
  18. package/src/commands/list.ts +53 -0
  19. package/src/commands/new.ts +66 -0
  20. package/src/commands/run.ts +149 -0
  21. package/src/commands/script.ts +127 -0
  22. package/src/commands/upgrade.ts +86 -0
  23. package/src/commands/verify-plugin.ts +35 -0
  24. package/src/index.ts +7 -0
  25. package/src/manifest/index.ts +2 -0
  26. package/src/manifest/load-env.ts +70 -0
  27. package/src/manifest/load-manifest.ts +42 -0
  28. package/src/project/command-targets.ts +53 -0
  29. package/src/project/index.ts +9 -0
  30. package/src/project/resolve-targets.ts +70 -0
  31. package/src/project/select-packages.ts +37 -0
  32. package/src/project/targets-or-exit.ts +28 -0
  33. package/src/reporters/colors.ts +17 -0
  34. package/src/reporters/dot-sink.ts +18 -0
  35. package/src/reporters/error-line.ts +14 -0
  36. package/src/reporters/index.ts +9 -0
  37. package/src/reporters/junit-sink.ts +39 -0
  38. package/src/reporters/ndjson-stdout.ts +13 -0
  39. package/src/reporters/pick-reporter.ts +28 -0
  40. package/src/reporters/pretty/diff-lines.ts +53 -0
  41. package/src/reporters/pretty/index.ts +1 -0
  42. package/src/reporters/pretty/pretty-reporter.ts +122 -0
  43. package/src/reporters/pretty/pretty.types.ts +29 -0
  44. package/src/reporters/pretty/render.ts +88 -0
  45. package/src/reporters/problem-reporter.ts +13 -0
  46. package/src/reporters/problem-sink.ts +20 -0
  47. package/src/reporters/reporter.types.ts +21 -0
  48. package/src/run/collect-files.ts +43 -0
  49. package/src/run/ending.types.ts +17 -0
  50. package/src/run/exit-code.ts +15 -0
  51. package/src/run/node-io.ts +27 -0
  52. package/src/run/npm-loader.ts +41 -0
  53. package/src/run/package-types.ts +66 -0
  54. package/src/run/run-file.ts +106 -0
  55. package/src/run/should-leave.ts +11 -0
  56. package/src/run/step-titles.ts +61 -0
  57. package/src/shutdown/create-leave.ts +42 -0
  58. package/src/shutdown/create-shutdown.ts +34 -0
  59. package/src/shutdown/index.ts +7 -0
  60. package/src/shutdown/install-exit-hook.ts +21 -0
  61. package/src/shutdown/install-fault-hooks.ts +30 -0
  62. package/src/shutdown/install-hooks.ts +36 -0
  63. package/src/shutdown/install-signal-hooks.ts +26 -0
  64. package/src/shutdown/shutdown.types.ts +20 -0
  65. package/src/title/index.ts +2 -0
  66. package/src/title/program-title.ts +15 -0
  67. package/src/title/set-program-title.ts +15 -0
  68. package/src/upgrade/index.ts +6 -0
  69. package/src/upgrade/install-site.ts +70 -0
  70. package/src/upgrade/latest-version.ts +50 -0
  71. package/src/upgrade/upgrade-command.ts +32 -0
  72. package/src/upgrade/upgrade-plan.ts +36 -0
  73. package/src/upgrade/upgrade.types.ts +17 -0
  74. package/src/upgrade/version.ts +21 -0
@@ -0,0 +1,98 @@
1
+ import { HttpClient, HttpServer } from "@venn-lang/http";
2
+ import { Console, Host } from "@venn-lang/contracts";
3
+ import { CleanupSink, EventSink, ModuleIo, NpmModules, RunFilter, RunResult } from "@venn-lang/runtime";
4
+ import { Problem } from "@venn-lang/core";
5
+ //#region src/commands/run.d.ts
6
+ /** Everything `venn run` accepts. */
7
+ interface RunOptions {
8
+ file: string;
9
+ reporter?: string;
10
+ tags?: string;
11
+ flow?: string;
12
+ step?: string;
13
+ env?: string;
14
+ bail?: boolean;
15
+ }
16
+ /**
17
+ * `venn test <file|directory>`: run every matching flow, then report.
18
+ *
19
+ * @param options - The file or directory, the reporter, and the filters.
20
+ * @returns The exit code: whatever a flow's `exit` named, else 0 when nothing
21
+ * failed, else 1. Also 1 when the path holds no `.vn` file.
22
+ */
23
+ declare function runCommand(options: RunOptions): Promise<number>;
24
+ //#endregion
25
+ //#region src/commands/verify-plugin.d.ts
26
+ /**
27
+ * `venn verify-plugin <path>`: import a plugin module, print what it declares,
28
+ * and check its shape.
29
+ *
30
+ * @param args - `path` is the module to import, relative to the working
31
+ * directory or absolute.
32
+ * @returns 0 when the plugin names itself and a namespace, 1 when it does not.
33
+ * @throws Error when the module exports nothing that looks like a plugin.
34
+ */
35
+ declare function verifyPluginCommand(args: {
36
+ path: string;
37
+ }): Promise<number>;
38
+ //#endregion
39
+ //#region src/reporters/ndjson-stdout.d.ts
40
+ /**
41
+ * An event sink that writes each envelope to stdout as one line of NDJSON: the
42
+ * stream a script or a CI job parses.
43
+ */
44
+ declare function createStdoutSink(): EventSink;
45
+ //#endregion
46
+ //#region src/reporters/problem-reporter.d.ts
47
+ /**
48
+ * Print compile-time problems to stderr, one code and title per problem with
49
+ * its source location beneath. The terminal surface of the §16 model.
50
+ */
51
+ declare function reportProblems(problems: readonly Problem[]): void;
52
+ //#endregion
53
+ //#region src/run/run-file.d.ts
54
+ /** What one `.vn` file amounted to. */
55
+ interface RunFileOutcome {
56
+ /** Everything refused or reported. Empty when the file ran clean. */
57
+ problems: Problem[];
58
+ /** Absent when nothing ran: the parse or the imports stopped it first. */
59
+ result?: RunResult;
60
+ }
61
+ /** The source to run, the implementations behind its ports, and how to run it. */
62
+ interface RunFileArgs {
63
+ source: string;
64
+ uri: string;
65
+ host: Host;
66
+ sink: EventSink;
67
+ httpClient: HttpClient;
68
+ /** Injected when the caller needs to close the servers itself, as `venn run` does. */
69
+ httpServer?: HttpServer;
70
+ console?: Console;
71
+ filter?: RunFilter;
72
+ bail?: boolean;
73
+ env?: Record<string, unknown>;
74
+ io?: ModuleIo;
75
+ /** How an installed package is loaded, when the host can load one. */
76
+ npm?: NpmModules;
77
+ /** Where the program registers what it opened, so the host can close it. */
78
+ cleanup?: CleanupSink;
79
+ /** "test" runs the flows; "script" executes the file top to bottom. */
80
+ mode?: "test" | "script";
81
+ }
82
+ /**
83
+ * Parse and run a `.vn` source with the full stdlib loaded.
84
+ *
85
+ * The HttpClient, HttpServer and Console ports take injected implementations
86
+ * (real in the CLI, fakes in tests); every other port takes the binding
87
+ * `@venn-lang/stdlib` supplies.
88
+ *
89
+ * @param args - The source and its uri, the host and the ports, and how to run
90
+ * it: the filter, the mode, the environment, the module and package loaders.
91
+ * @returns The problems and, when anything ran, the run's result. A failing
92
+ * flow is a `Problem` here, not an exception.
93
+ * @throws Whatever an action or a loaded module let escape the runner.
94
+ */
95
+ declare function runFile(args: RunFileArgs): Promise<RunFileOutcome>;
96
+ //#endregion
97
+ export { type RunFileOutcome, createStdoutSink, reportProblems, runCommand, runFile, verifyPluginCommand };
98
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/commands/run.ts","../src/commands/verify-plugin.ts","../src/reporters/ndjson-stdout.ts","../src/reporters/problem-reporter.ts","../src/run/run-file.ts"],"mappings":";;;;;;UAiBiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;iBAkBoB,WAAW,SAAS,aAAa;;;;;;;;;;;;iBC7BjC,oBAAoB;EAAQ;IAAiB;;;;;;;iBCPnD,oBAAoB;;;;;;;iBCApB,eAAe,mBAAmB;;;;UCYjC;;EAEf,UAAU;;EAEV,SAAS;;;UAIM;EACf;EACA;EACA,MAAM;EACN,MAAM;EACN,YAAY;;EAEZ,aAAa;EACb,UAAU;EACV,SAAS;EACT;EACA,MAAM;EACN,KAAK;;EAEL,MAAM;;EAEN,UAAU;;EAEV;;;;;;;;;;;;;;;iBAgBoB,QAAQ,MAAM,cAAc,QAAQ"}