@w6w/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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +110 -0
  3. package/dist/bin/w6w.d.ts +22 -0
  4. package/dist/bin/w6w.d.ts.map +1 -0
  5. package/dist/bin/w6w.js +58 -0
  6. package/dist/bin/w6w.js.map +1 -0
  7. package/dist/mod.d.ts +131 -0
  8. package/dist/mod.d.ts.map +1 -0
  9. package/dist/mod.js +257 -0
  10. package/dist/mod.js.map +1 -0
  11. package/dist/src/args.d.ts +79 -0
  12. package/dist/src/args.d.ts.map +1 -0
  13. package/dist/src/args.js +130 -0
  14. package/dist/src/args.js.map +1 -0
  15. package/dist/src/client.d.ts +90 -0
  16. package/dist/src/client.d.ts.map +1 -0
  17. package/dist/src/client.js +172 -0
  18. package/dist/src/client.js.map +1 -0
  19. package/dist/src/commands/connections.d.ts +13 -0
  20. package/dist/src/commands/connections.d.ts.map +1 -0
  21. package/dist/src/commands/connections.js +30 -0
  22. package/dist/src/commands/connections.js.map +1 -0
  23. package/dist/src/commands/documents.d.ts +34 -0
  24. package/dist/src/commands/documents.d.ts.map +1 -0
  25. package/dist/src/commands/documents.js +179 -0
  26. package/dist/src/commands/documents.js.map +1 -0
  27. package/dist/src/commands/index.d.ts +27 -0
  28. package/dist/src/commands/index.d.ts.map +1 -0
  29. package/dist/src/commands/index.js +39 -0
  30. package/dist/src/commands/index.js.map +1 -0
  31. package/dist/src/commands/me.d.ts +29 -0
  32. package/dist/src/commands/me.d.ts.map +1 -0
  33. package/dist/src/commands/me.js +52 -0
  34. package/dist/src/commands/me.js.map +1 -0
  35. package/dist/src/commands/run.d.ts +24 -0
  36. package/dist/src/commands/run.d.ts.map +1 -0
  37. package/dist/src/commands/run.js +78 -0
  38. package/dist/src/commands/run.js.map +1 -0
  39. package/dist/src/commands/shared.d.ts +117 -0
  40. package/dist/src/commands/shared.d.ts.map +1 -0
  41. package/dist/src/commands/shared.js +152 -0
  42. package/dist/src/commands/shared.js.map +1 -0
  43. package/dist/src/commands/vars.d.ts +59 -0
  44. package/dist/src/commands/vars.d.ts.map +1 -0
  45. package/dist/src/commands/vars.js +216 -0
  46. package/dist/src/commands/vars.js.map +1 -0
  47. package/dist/src/commands/workflows.d.ts +13 -0
  48. package/dist/src/commands/workflows.d.ts.map +1 -0
  49. package/dist/src/commands/workflows.js +75 -0
  50. package/dist/src/commands/workflows.js.map +1 -0
  51. package/dist/src/exit.d.ts +51 -0
  52. package/dist/src/exit.d.ts.map +1 -0
  53. package/dist/src/exit.js +94 -0
  54. package/dist/src/exit.js.map +1 -0
  55. package/dist/src/help.d.ts +48 -0
  56. package/dist/src/help.d.ts.map +1 -0
  57. package/dist/src/help.generated.d.ts +88 -0
  58. package/dist/src/help.generated.d.ts.map +1 -0
  59. package/dist/src/help.generated.js +988 -0
  60. package/dist/src/help.generated.js.map +1 -0
  61. package/dist/src/help.js +128 -0
  62. package/dist/src/help.js.map +1 -0
  63. package/dist/src/output.d.ts +84 -0
  64. package/dist/src/output.d.ts.map +1 -0
  65. package/dist/src/output.js +94 -0
  66. package/dist/src/output.js.map +1 -0
  67. package/dist/src/runtime.d.ts +37 -0
  68. package/dist/src/runtime.d.ts.map +1 -0
  69. package/dist/src/runtime.js +57 -0
  70. package/dist/src/runtime.js.map +1 -0
  71. package/package.json +42 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 w6w-io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # @w6w/cli
2
+
3
+ The `w6w` command-line client for the [w6w](https://w6w.dev) workflow platform.
4
+
5
+ It is a **thin** client, built on [`@w6w/sdk`](https://www.npmjs.com/package/@w6w/sdk): transport,
6
+ auth, output formatting and exit codes. No business logic, no client-side polling, no hidden
7
+ retries. Everything it can do, the HTTP API can do — the CLI just makes it typeable.
8
+
9
+ - **License:** MIT (see [LICENSE](./LICENSE)).
10
+ - **Version:** `0.1.0`.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -g @w6w/cli
16
+ w6w --help
17
+ ```
18
+
19
+ `@w6w/cli`, `@w6w/sdk` and the Python `w6w` package share one version number and are released
20
+ together. A given version means the same set of operations in every language.
21
+
22
+ ## Configuration
23
+
24
+ Two environment variables:
25
+
26
+ | Variable | Meaning | Required |
27
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- |
28
+ | `W6W_BASE_URL` | The **origin** of your w6w server, e.g. `https://api.example.com`. The API's base path is appended for you — do not include it. | Yes |
29
+ | `W6W_TOKEN` | Your API token, sent as `Authorization: Bearer <token>` on every request. | Yes |
30
+
31
+ Both have a flag equivalent, and **a flag always wins over the environment**: `--base-url <url>` and
32
+ `--token <token>`.
33
+
34
+ ```bash
35
+ export W6W_BASE_URL=https://api.example.com
36
+ export W6W_TOKEN=…
37
+ w6w workflows list
38
+ ```
39
+
40
+ `--help` and `--version` deliberately need neither. They resolve with no token configured and no
41
+ server reachable, which is exactly when people need them most.
42
+
43
+ ## Help
44
+
45
+ Help resolves at three levels, and `-h` is an alias for `--help` at all of them:
46
+
47
+ ```bash
48
+ w6w --help # what w6w is, the global flags, the command groups
49
+ w6w documents --help # the commands in a group
50
+ w6w documents create --help # arguments, flags, examples
51
+ w6w help documents create # the same thing, spelled the other way
52
+ ```
53
+
54
+ Help is **generated** from the machine-readable surface contract all three w6w wrappers implement,
55
+ so the CLI cannot document an operation it does not have, or omit one it does. A bare `w6w` prints
56
+ the root help and exits `0`.
57
+
58
+ ## Exit codes
59
+
60
+ | Code | Meaning |
61
+ | ---- | ------------------------------------------------------------------------ |
62
+ | `0` | Success — including help, and including a _queued_ or _running_ workflow |
63
+ | `1` | Usage error — unknown command, missing argument, bad flag |
64
+ | `2` | API error — 4xx/5xx from the server, including auth failure |
65
+ | `3` | Run failure — `--wait` returned a run with status `failed` |
66
+
67
+ Code `3` exists so `w6w workflows run --wait` is usable in CI without parsing stdout. Keeping it
68
+ distinct from `2` matters: a failed workflow and an unreachable API demand opposite responses, and a
69
+ script that cannot tell them apart will retry the wrong one.
70
+
71
+ ## The surface
72
+
73
+ What commands exist is not decided in this repo. It is defined by the shared machine-readable
74
+ contract `endpoints.json`, which sits beside this repo alongside its two sibling wrapper repos and
75
+ which each wrapper's conformance test reads directly — the same file, never a vendored copy. A
76
+ command missing from a wrapper is a failing test, not a preference.
77
+
78
+ Some operations are marked `planned` in that contract: they are implemented and unit-tested here,
79
+ but the corresponding server route is not live yet, so calling them against a server today returns
80
+ `404`. Their help says so. The marker records **server** readiness, not CLI completeness.
81
+
82
+ ## Versioning
83
+
84
+ The version is a shared fact across all three wrappers, so a release may go out for this package
85
+ even when nothing in it changed — a divergent version is far more expensive than an empty release.
86
+
87
+ Below `1.0.0`, **breaking changes may land in a minor bump.** That grace ends at `1.0.0`; do not
88
+ plan around it.
89
+
90
+ ## Development
91
+
92
+ The gates are Deno tasks. They need no network and no server:
93
+
94
+ ```bash
95
+ deno task gen:help # regenerate src/help.generated.ts from the shared contract
96
+ deno task check # typecheck mod.ts, bin/, scripts/, src/ and tests/
97
+ deno task lint
98
+ deno task fmt:check
99
+ deno task test # every test runs in-process, against no server
100
+ deno task cov # test with coverage, then report it
101
+ ```
102
+
103
+ `src/help.generated.ts` is generated — never edit it by hand. `deno task test` compares it
104
+ byte-for-byte against a fresh render, so a contract change that was not regenerated fails the suite
105
+ instead of shipping stale help.
106
+
107
+ Runtime access — argv, environment, exit — lives in exactly one module, `src/runtime.ts`. Everything
108
+ else uses Web-standard globals only, which is what lets the same source run under Deno during
109
+ development and under Node once published. The npm `dist/` build (`npm run build`, i.e.
110
+ `tsc -p tsconfig.build.json`) runs in CI only.
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env -S deno run -A
2
+ /**
3
+ * The `w6w` binary.
4
+ *
5
+ * The only module that touches the real command line and the real process exit,
6
+ * and it does both through `src/runtime.ts` — so the entire CLI above it stays a
7
+ * pure function of `(argv, io, options)` and can be tested in-process.
8
+ *
9
+ * Its job is wiring, and only wiring: read the host's arguments and environment,
10
+ * decide whether stdout is a terminal, hand the command registry to `main()`, and
11
+ * exit with the code it returns. Nothing here decides anything a test cannot.
12
+ *
13
+ * Under Deno this file runs directly — `deno run -A bin/w6w.ts …`, or through the
14
+ * shebang above. For npm it is compiled to `dist/bin/w6w.js`, which is what
15
+ * `package.json`'s `bin` entry points at.
16
+ *
17
+ * Help and `--version` need no permissions beyond writing to stdout, which is why
18
+ * `deno run --allow-read --allow-env bin/w6w.ts --help` works with no token set
19
+ * and no server reachable: nothing on those paths constructs a client.
20
+ */
21
+ export {};
22
+ //# sourceMappingURL=w6w.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"w6w.d.ts","sourceRoot":"","sources":["../../bin/w6w.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG"}
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The `w6w` binary.
4
+ *
5
+ * The only module that touches the real command line and the real process exit,
6
+ * and it does both through `src/runtime.ts` — so the entire CLI above it stays a
7
+ * pure function of `(argv, io, options)` and can be tested in-process.
8
+ *
9
+ * Its job is wiring, and only wiring: read the host's arguments and environment,
10
+ * decide whether stdout is a terminal, hand the command registry to `main()`, and
11
+ * exit with the code it returns. Nothing here decides anything a test cannot.
12
+ *
13
+ * Under Deno this file runs directly — `deno run -A bin/w6w.ts …`, or through the
14
+ * shebang above. For npm it is compiled to `dist/bin/w6w.js`, which is what
15
+ * `package.json`'s `bin` entry points at.
16
+ *
17
+ * Help and `--version` need no permissions beyond writing to stdout, which is why
18
+ * `deno run --allow-read --allow-env bin/w6w.ts --help` works with no token set
19
+ * and no server reachable: nothing on those paths constructs a client.
20
+ */
21
+ import { main } from "../mod.js";
22
+ import { COMMANDS } from "../src/commands/index.js";
23
+ import { systemRuntime } from "../src/runtime.js";
24
+ /**
25
+ * The commands this build can run.
26
+ *
27
+ * The registry is assembled in `src/commands/index.ts`, one group at a time, and
28
+ * this file only hands it over: the entry point owns the wiring and nothing
29
+ * else. A command in the help tree with no entry in that registry answers with a
30
+ * usage error saying it is not available in this build, which is a better answer
31
+ * than a silent success.
32
+ */
33
+ const commands = COMMANDS;
34
+ /**
35
+ * Whether stdout is a terminal — the third of the three ways colour turns itself
36
+ * off (the other two being `--no-color` and `NO_COLOR`).
37
+ *
38
+ * A capability probe rather than a runtime assumption, the same shape
39
+ * `src/runtime.ts` uses, so this file compiles for the npm build (where no Deno
40
+ * types exist) and runs unchanged under Deno, Node and Bun. Anything it cannot
41
+ * establish counts as "not a terminal": a pipe is the case where colour actively
42
+ * corrupts the output, so it is the safe default to assume.
43
+ */
44
+ function stdoutIsTerminal() {
45
+ const host = globalThis;
46
+ const deno = host.Deno?.stdout;
47
+ if (deno?.isTerminal)
48
+ return deno.isTerminal();
49
+ return host.process?.stdout?.isTTY === true;
50
+ }
51
+ const runtime = systemRuntime();
52
+ const code = await main(runtime.args, runtime, {
53
+ env: runtime.env,
54
+ isTty: stdoutIsTerminal(),
55
+ commands,
56
+ });
57
+ runtime.exit(code);
58
+ //# sourceMappingURL=w6w.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"w6w.js","sourceRoot":"","sources":["../../bin/w6w.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAoB,QAAQ,CAAC;AAE3C;;;;;;;;;GASG;AACH,SAAS,gBAAgB;IACvB,MAAM,IAAI,GAAG,UAGZ,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,IAAI,IAAI,EAAE,UAAU;QAAE,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC/C,OAAO,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,IAAI,CAAC;AAC9C,CAAC;AAED,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;AAChC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE;IAC7C,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,KAAK,EAAE,gBAAgB,EAAE;IACzB,QAAQ;CACT,CAAC,CAAC;AACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
package/dist/mod.d.ts ADDED
@@ -0,0 +1,131 @@
1
+ /**
2
+ * `@w6w/cli` — the package barrel and the CLI's programmatic entry point.
3
+ *
4
+ * {@linkcode main} is the whole command line, minus the host: it is handed an
5
+ * argument vector and somewhere to write, and it returns an exit code. It never
6
+ * reads the real command line and never ends the process — `bin/w6w.ts` does
7
+ * both, through `src/runtime.ts`. That split is what lets the entire surface,
8
+ * exit codes included, be exercised in-process by the test suite, against an
9
+ * injected environment and an injected transport, with no live server anywhere.
10
+ *
11
+ * {@linkcode runCli} is its synchronous half: help, `--version` and usage
12
+ * errors, which by contract resolve with no token configured and no server
13
+ * reachable. Running a command needs the API and therefore needs `await`, so it
14
+ * lives on `main` alone.
15
+ *
16
+ * The exit codes are the shared surface contract's, generated into
17
+ * `src/help.generated.ts` rather than restated here:
18
+ *
19
+ * | code | meaning |
20
+ * |---|---|
21
+ * | 0 | success, including help and a queued/running workflow |
22
+ * | 1 | usage error |
23
+ * | 2 | API error (4xx/5xx, including auth failure) |
24
+ * | 3 | run failure (`--wait` returned status `failed`) |
25
+ *
26
+ * @module
27
+ */
28
+ import type { Invocation } from "./src/args.ts";
29
+ import type { EnvReader } from "./src/client.ts";
30
+ import type { Output } from "./src/output.ts";
31
+ import type { HelpCommand } from "./src/help.generated.ts";
32
+ import type { CliIo } from "./src/runtime.ts";
33
+ import type { FetchLike, W6wClient } from "@w6w/sdk";
34
+ export { parse } from "./src/args.ts";
35
+ export type { FlagSpec, GlobalOptions, Invocation, ParseOptions, ParseResult } from "./src/args.ts";
36
+ export { createClient, ENV_BASE_URL, ENV_TOKEN, envValue, NO_ENV } from "./src/client.ts";
37
+ export type { ClientOptions, EnvReader } from "./src/client.ts";
38
+ export { createOutput, ENV_NO_COLOR, useColor } from "./src/output.ts";
39
+ export type { Output, OutputOptions, Styles } from "./src/output.ts";
40
+ export { EXIT_API_ERROR, EXIT_RUN_FAILURE, EXIT_SUCCESS, EXIT_USAGE, exitCodeFor, } from "./src/exit.ts";
41
+ export { renderCommandHelp, renderGroupHelp, renderHelp, renderRootHelp, resolve, } from "./src/help.ts";
42
+ export type { Resolution } from "./src/help.ts";
43
+ export { systemRuntime } from "./src/runtime.ts";
44
+ export type { CliIo, CliRuntime } from "./src/runtime.ts";
45
+ export { COMMAND_PATHS, EXIT_CODES, GLOBAL_FLAGS, HELP_TREE } from "./src/help.generated.ts";
46
+ export type { HelpCommand, HelpExitCode, HelpGlobalFlag, HelpGroup, HelpParam, HelpTree, } from "./src/help.generated.ts";
47
+ /**
48
+ * The published version of this package.
49
+ *
50
+ * The same string as `deno.json`'s and `package.json`'s `version` and the shared
51
+ * `VERSION` file beside this repo — the single version all three w6w wrappers
52
+ * publish under. `tests/help_test.ts` fails if any of those disagree, so it cannot
53
+ * drift silently. `--version` prints exactly this.
54
+ *
55
+ * The explicit `: string` annotation is required, not decorative: JSR publishes
56
+ * this file as TypeScript source and rejects inferred public types.
57
+ */
58
+ export declare const VERSION: string;
59
+ /**
60
+ * What a command handler is handed: the invocation, somewhere to write, and a
61
+ * way to reach the API.
62
+ *
63
+ * The client is a **function**, not a field, and that is the point: it is
64
+ * constructed on first call and never before, so a command that answers without
65
+ * the API — and every help path — needs no token and no reachable server.
66
+ * Calling it twice returns the same client.
67
+ */
68
+ export interface CommandContext {
69
+ /** The command this invocation resolved to, straight out of the help tree. */
70
+ readonly command: HelpCommand;
71
+ /** The parsed command line: positional arguments, global flags, command flags. */
72
+ readonly invocation: Invocation;
73
+ /** The renderer. Every byte a command writes goes through it. */
74
+ readonly out: Output;
75
+ /**
76
+ * The API client, built on first use from the global flags and the
77
+ * environment.
78
+ *
79
+ * @throws {ConfigError} When the base URL or token is missing or unusable.
80
+ */
81
+ client(): W6wClient;
82
+ }
83
+ /**
84
+ * One command's implementation.
85
+ *
86
+ * Return nothing for the ordinary success case; return a code only where the
87
+ * exit-code contract has something to say that "it worked" does not — which is
88
+ * `--wait` on a run that failed. Get it from {@linkcode exitCodeFor}; never
89
+ * write the number.
90
+ *
91
+ * A handler does not catch its own API errors: {@linkcode main} maps a thrown
92
+ * error to an exit code and reports it on stderr, once, for every command.
93
+ */
94
+ export type CommandHandler = (context: CommandContext) => number | void | Promise<number | void>;
95
+ /**
96
+ * The registry the dispatcher walks, keyed by canonical command path —
97
+ * `"me"`, `"documents list"`. Aliases resolve to the canonical path before the
98
+ * lookup, so `w6w info` finds `"me"`.
99
+ */
100
+ export type CommandRegistry = Record<string, CommandHandler>;
101
+ /** Everything the CLI needs from its host, all of it injectable. */
102
+ export interface CliOptions {
103
+ /** The environment seam. Defaults to an empty environment. */
104
+ env?: EnvReader;
105
+ /** Transport override, handed to the SDK. The test suite's seam. */
106
+ fetch?: FetchLike;
107
+ /** Whether stdout is a terminal, for the colour decision. Defaults to `false`. */
108
+ isTty?: boolean;
109
+ /** The commands that are wired up. Defaults to none. */
110
+ commands?: CommandRegistry;
111
+ }
112
+ /**
113
+ * Runs a command line and returns its exit code. The whole CLI.
114
+ *
115
+ * @param argv - The argument vector, with the runtime's own prefix already dropped.
116
+ * @param io - Where to write. Nothing else is written anywhere.
117
+ * @param options - The environment, the transport, the terminal, the commands.
118
+ * @returns The exit code, one of the four the contract declares.
119
+ */
120
+ export declare function main(argv: string[], io: CliIo, options?: CliOptions): Promise<number>;
121
+ /**
122
+ * The synchronous half of the command line: help, `--version`, and usage errors.
123
+ *
124
+ * Kept because those are exactly the paths that must work with **no token
125
+ * configured and no server reachable**, and a function that cannot reach the API
126
+ * is the strongest possible statement of that. A runnable command is not run
127
+ * here — running one is asynchronous by nature — and comes back as a usage error
128
+ * pointing at its help. Use {@linkcode main}, which is what the binary calls.
129
+ */
130
+ export declare function runCli(argv: string[], io: CliIo): number;
131
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAY,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAU9C,OAAO,KAAK,EAAE,WAAW,EAAE,MA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;AACH,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,iEAAiE;IACjE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,MAAM,IAAI,SAAS,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAEjG;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAE7D,oEAAoE;AACpE,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,oEAAoE;IACpE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kFAAkF;IAClF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAgMD;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAI/F;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CASxD"}
package/dist/mod.js ADDED
@@ -0,0 +1,257 @@
1
+ /**
2
+ * `@w6w/cli` — the package barrel and the CLI's programmatic entry point.
3
+ *
4
+ * {@linkcode main} is the whole command line, minus the host: it is handed an
5
+ * argument vector and somewhere to write, and it returns an exit code. It never
6
+ * reads the real command line and never ends the process — `bin/w6w.ts` does
7
+ * both, through `src/runtime.ts`. That split is what lets the entire surface,
8
+ * exit codes included, be exercised in-process by the test suite, against an
9
+ * injected environment and an injected transport, with no live server anywhere.
10
+ *
11
+ * {@linkcode runCli} is its synchronous half: help, `--version` and usage
12
+ * errors, which by contract resolve with no token configured and no server
13
+ * reachable. Running a command needs the API and therefore needs `await`, so it
14
+ * lives on `main` alone.
15
+ *
16
+ * The exit codes are the shared surface contract's, generated into
17
+ * `src/help.generated.ts` rather than restated here:
18
+ *
19
+ * | code | meaning |
20
+ * |---|---|
21
+ * | 0 | success, including help and a queued/running workflow |
22
+ * | 1 | usage error |
23
+ * | 2 | API error (4xx/5xx, including auth failure) |
24
+ * | 3 | run failure (`--wait` returned status `failed`) |
25
+ *
26
+ * @module
27
+ */
28
+ import { GLOBAL_FLAG_SPECS, parse } from "./src/args.js";
29
+ import { createClient, NO_ENV } from "./src/client.js";
30
+ import { createOutput } from "./src/output.js";
31
+ import { EXIT_SUCCESS, EXIT_USAGE, exitCodeFor } from "./src/exit.js";
32
+ import { renderCommandHelp, renderGroupHelp, renderHelp, renderRootHelp, resolve, } from "./src/help.js";
33
+ import { HELP_TREE } from "./src/help.generated.js";
34
+ export { parse } from "./src/args.js";
35
+ export { createClient, ENV_BASE_URL, ENV_TOKEN, envValue, NO_ENV } from "./src/client.js";
36
+ export { createOutput, ENV_NO_COLOR, useColor } from "./src/output.js";
37
+ export { EXIT_API_ERROR, EXIT_RUN_FAILURE, EXIT_SUCCESS, EXIT_USAGE, exitCodeFor, } from "./src/exit.js";
38
+ export { renderCommandHelp, renderGroupHelp, renderHelp, renderRootHelp, resolve, } from "./src/help.js";
39
+ export { systemRuntime } from "./src/runtime.js";
40
+ // The four exit codes are re-exported from `src/exit.ts` above, alongside the
41
+ // mapping that produces them — one import for anything to do with an exit code.
42
+ export { COMMAND_PATHS, EXIT_CODES, GLOBAL_FLAGS, HELP_TREE } from "./src/help.generated.js";
43
+ /**
44
+ * The published version of this package.
45
+ *
46
+ * The same string as `deno.json`'s and `package.json`'s `version` and the shared
47
+ * `VERSION` file beside this repo — the single version all three w6w wrappers
48
+ * publish under. `tests/help_test.ts` fails if any of those disagree, so it cannot
49
+ * drift silently. `--version` prints exactly this.
50
+ *
51
+ * The explicit `: string` annotation is required, not decorative: JSR publishes
52
+ * this file as TypeScript source and rejects inferred public types.
53
+ */
54
+ export const VERSION = "0.1.0";
55
+ /** `w6w help <command>` is accepted as an alias for `w6w <command> --help`. */
56
+ const HELP_COMMAND = "help";
57
+ /**
58
+ * The flags a command declares for itself, lifted out of the generated help
59
+ * tree so the parser and the help text cannot disagree about them.
60
+ *
61
+ * The flag's spelling is the first token of its help display (`--var
62
+ * <key=value>` → `--var`, which is not always its contract parameter name), and
63
+ * a display with nothing after that token is a boolean. Flags that shadow a
64
+ * global one are dropped: `--json` is already parsed for every command.
65
+ */
66
+ function commandFlagSpecs(command) {
67
+ const globals = new Set(GLOBAL_FLAG_SPECS.map((spec) => spec.name));
68
+ const specs = [];
69
+ for (const param of command.params) {
70
+ if (param.kind !== "flag")
71
+ continue;
72
+ const [name, ...rest] = param.display.split(" ");
73
+ if (globals.has(name))
74
+ continue;
75
+ specs.push({ name, alias: null, type: rest.length > 0 ? "string" : "boolean" });
76
+ }
77
+ return specs;
78
+ }
79
+ /**
80
+ * Parses an argument vector, giving a resolved command's own flags a second
81
+ * chance.
82
+ *
83
+ * The first pass knows only the global flags, because which command's flags
84
+ * apply is not known until the command path has been read out of the same
85
+ * argument vector. So `w6w documents list --project p_1` fails that pass on an
86
+ * unknown flag — and the failure still carries the command the user was aiming
87
+ * at, which is exactly what is needed to re-parse with that command's flags
88
+ * added.
89
+ *
90
+ * **When the second pass fails too, its message is the one reported**, not the
91
+ * first pass's. The second pass ran with strictly more flags known, so it got
92
+ * further and its complaint is about the flag that is actually wrong; the first
93
+ * pass's complaint is about the first flag it had not been told about yet, which
94
+ * by then is usually a perfectly valid one. Reporting the first message names
95
+ * the wrong flag: `w6w vars create g --type string --value hello --project p`
96
+ * would answer `unknown flag: --type` — a flag that command declares and
97
+ * requires — sending the user to fix the one thing that was right.
98
+ */
99
+ function parseInvocation(argv) {
100
+ const first = parse(argv);
101
+ if (first.ok)
102
+ return first;
103
+ const resolution = resolve(first.command);
104
+ if (resolution.kind !== "command")
105
+ return first;
106
+ const specs = commandFlagSpecs(resolution.command);
107
+ if (specs.length === 0)
108
+ return first;
109
+ return parse(argv, { flags: specs });
110
+ }
111
+ /**
112
+ * Answers everything that can be answered without the API, and reports
113
+ * everything else as a command to run.
114
+ *
115
+ * Help and `--version` are answered here, before anything else: they must
116
+ * resolve with **no token configured and no server reachable**, so nothing on
117
+ * those paths constructs a client or performs I/O beyond writing to `io`.
118
+ */
119
+ function route(argv, io) {
120
+ const done = (code) => ({ kind: "done", code });
121
+ const result = parseInvocation(argv);
122
+ if (!result.ok) {
123
+ io.stderr(`${HELP_TREE.binary}: ${result.message}`);
124
+ io.stderr("");
125
+ io.stderr(renderHelp(resolve(result.command)));
126
+ return done(EXIT_USAGE);
127
+ }
128
+ const { command, positionals, globals } = result.invocation;
129
+ // `w6w help <command>` — the same three levels, reached by the other spelling.
130
+ if (command[0] === HELP_COMMAND) {
131
+ const target = [...command.slice(1), ...positionals];
132
+ const resolution = resolve(target);
133
+ if (resolution.kind === "unknown") {
134
+ io.stderr(`${HELP_TREE.binary}: unknown command: ${target.join(" ")}`);
135
+ io.stderr("");
136
+ io.stderr(renderHelp(resolution));
137
+ return done(EXIT_USAGE);
138
+ }
139
+ io.stdout(renderHelp(resolution));
140
+ return done(EXIT_SUCCESS);
141
+ }
142
+ if (globals.version) {
143
+ io.stdout(VERSION);
144
+ return done(EXIT_SUCCESS);
145
+ }
146
+ const resolution = resolve(command);
147
+ switch (resolution.kind) {
148
+ // A bare `w6w` prints root help and exits 0 — not an error, not a usage stub.
149
+ case "root":
150
+ io.stdout(renderRootHelp());
151
+ return done(EXIT_SUCCESS);
152
+ case "unknown":
153
+ io.stderr(`${HELP_TREE.binary}: unknown command: ${command.join(" ")}`);
154
+ io.stderr("");
155
+ io.stderr(renderHelp(resolution));
156
+ return done(EXIT_USAGE);
157
+ // A group is never runnable. With --help that is a question, answered on
158
+ // stdout; without it, it is an incomplete command, answered on stderr.
159
+ case "group":
160
+ if (globals.help) {
161
+ io.stdout(renderGroupHelp(resolution.group));
162
+ return done(EXIT_SUCCESS);
163
+ }
164
+ io.stderr(`${HELP_TREE.binary}: \`${resolution.group.name}\` needs a subcommand`);
165
+ io.stderr("");
166
+ io.stderr(renderGroupHelp(resolution.group));
167
+ return done(EXIT_USAGE);
168
+ case "command":
169
+ if (globals.help) {
170
+ io.stdout(renderCommandHelp(resolution.command));
171
+ return done(EXIT_SUCCESS);
172
+ }
173
+ return { kind: "run", command: resolution.command, invocation: result.invocation };
174
+ }
175
+ }
176
+ /**
177
+ * Runs one command and turns whatever happens into an exit code.
178
+ *
179
+ * Every command's error handling is here rather than in the command: an error
180
+ * is reported once, on stderr, and mapped once, through `src/exit.ts`. A
181
+ * handler that wants a code other than success returns it; a handler that
182
+ * throws gets the mapping for what it threw.
183
+ */
184
+ async function dispatch(routed, io, options) {
185
+ const { globals } = routed.invocation;
186
+ const out = createOutput(io, {
187
+ json: globals.json,
188
+ noColor: globals.noColor,
189
+ isTty: options.isTty,
190
+ env: options.env,
191
+ });
192
+ const key = routed.command.path.join(" ");
193
+ const handler = options.commands?.[key];
194
+ if (!handler) {
195
+ out.error(`\`${key}\` is not available in this build. ` +
196
+ `Try \`${HELP_TREE.binary} ${key} --help\`.`);
197
+ return EXIT_USAGE;
198
+ }
199
+ // Built on demand and remembered: a command that never asks for the API never
200
+ // needs a token, and one that asks twice gets one client, not two.
201
+ let client = null;
202
+ const context = {
203
+ command: routed.command,
204
+ invocation: routed.invocation,
205
+ out,
206
+ client: () => {
207
+ if (client === null) {
208
+ client = createClient(globals, options.env ?? NO_ENV, { fetch: options.fetch });
209
+ }
210
+ return client;
211
+ },
212
+ };
213
+ try {
214
+ return (await handler(context)) ?? EXIT_SUCCESS;
215
+ }
216
+ catch (error) {
217
+ // Normalised at the boundary rather than inside the mapping: `throw "boom"`
218
+ // is legal JavaScript, and a mapping asked to classify a bare string has no
219
+ // way to tell it from a returned payload — which would make a crash exit 0.
220
+ const failure = error instanceof Error ? error : new Error(String(error));
221
+ out.error(failure.message);
222
+ return exitCodeFor(failure);
223
+ }
224
+ }
225
+ /**
226
+ * Runs a command line and returns its exit code. The whole CLI.
227
+ *
228
+ * @param argv - The argument vector, with the runtime's own prefix already dropped.
229
+ * @param io - Where to write. Nothing else is written anywhere.
230
+ * @param options - The environment, the transport, the terminal, the commands.
231
+ * @returns The exit code, one of the four the contract declares.
232
+ */
233
+ export async function main(argv, io, options = {}) {
234
+ const routed = route(argv, io);
235
+ if (routed.kind === "done")
236
+ return routed.code;
237
+ return await dispatch(routed, io, options);
238
+ }
239
+ /**
240
+ * The synchronous half of the command line: help, `--version`, and usage errors.
241
+ *
242
+ * Kept because those are exactly the paths that must work with **no token
243
+ * configured and no server reachable**, and a function that cannot reach the API
244
+ * is the strongest possible statement of that. A runnable command is not run
245
+ * here — running one is asynchronous by nature — and comes back as a usage error
246
+ * pointing at its help. Use {@linkcode main}, which is what the binary calls.
247
+ */
248
+ export function runCli(argv, io) {
249
+ const routed = route(argv, io);
250
+ if (routed.kind === "done")
251
+ return routed.code;
252
+ const path = routed.command.path.join(" ");
253
+ io.stderr(`${HELP_TREE.binary}: \`${path}\` needs the API, which this entry point does not reach. ` +
254
+ `Try \`${HELP_TREE.binary} ${path} --help\`.`);
255
+ return EXIT_USAGE;
256
+ }
257
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO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