@capxul/cli 4.20.0-beta.27 → 4.20.0-beta.28

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.
@@ -1,4 +1,4 @@
1
- import { c as cliHome, d as explicitOrganization, f as flagValue, h as parseWhere, l as describeWhere, n as styleFor, r as whoamiLines, s as chooseEnvironment } from "./where-view-Csv4lEES.mjs";
1
+ import { c as cliHome, d as explicitOrganization, f as flagValue, h as parseWhere, l as describeWhere, n as styleFor, r as whoamiLines, s as chooseEnvironment } from "./where-view-BJmsAHQb.mjs";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  //#region src/commands/whoami/fast.ts
@@ -54,4 +54,4 @@ const fastWhoami = (args, env, stdoutTty) => {
54
54
  //#endregion
55
55
  export { fastWhoami };
56
56
 
57
- //# sourceMappingURL=fast-BQEiHMyp.mjs.map
57
+ //# sourceMappingURL=fast-B1MSUn2P.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fast-BQEiHMyp.mjs","names":[],"sources":["../src/commands/whoami/fast.ts"],"sourcesContent":["// `capxul whoami` without the Effect runtime. Loading the full CLI costs about\n// 0.4 s before any command runs; this path reads two small local files and\n// prints, so it answers in well under 0.3 s. It handles only the plain forms\n// (`--json`, `--org <handle>`, `--env <name>`); anything else returns\n// undefined and the full CLI parses, validates and answers instead. It makes\n// no network call and records no telemetry.\n\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n chooseEnvironment,\n cliHome,\n describeWhere,\n explicitOrganization,\n flagValue,\n parseWhere,\n} from \"#runtime/where\";\nimport { styleFor, whoamiLines } from \"#runtime/where-view\";\n\ntype Environment = Readonly<Record<string, string | undefined>>;\n\nconst plainForm = (args: readonly string[]) => {\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n if (arg === \"--json\" || /^--(org|env)=./u.test(arg)) continue;\n if ((arg === \"--org\" || arg === \"--env\") && args[index + 1]?.startsWith(\"-\") === false) {\n index += 1;\n continue;\n }\n return false;\n }\n return true;\n};\n\nconst readText = (file: string) => {\n try {\n return readFileSync(file, \"utf8\");\n } catch {\n return null;\n }\n};\n\n/** The text to print for `whoami <args>`, or undefined when the full CLI must answer. */\nexport const fastWhoami = (\n args: readonly string[],\n env: Environment,\n stdoutTty: boolean,\n): string | undefined => {\n if (!plainForm(args)) return undefined;\n const home = cliHome(env, join);\n if (home === undefined) return undefined;\n const saved = parseWhere(readText(join(home, \"context.json\")));\n const bootstrapUrl = env.CAPXUL_BOOTSTRAP_URL;\n if (bootstrapUrl !== undefined && bootstrapUrl !== \"\" && !URL.canParse(bootstrapUrl))\n return undefined;\n const choice = chooseEnvironment({\n flag: flagValue(args, \"env\"),\n variable: env.CAPXUL_ENV,\n bootstrapUrl:\n bootstrapUrl === undefined || bootstrapUrl === \"\" ? undefined : new URL(bootstrapUrl).origin,\n saved: saved.env,\n });\n if (\"refusal\" in choice) return undefined;\n const where = describeWhere({\n origin: choice.origin,\n envSource: choice.source,\n saved,\n explicitOrg: explicitOrganization(flagValue(args, \"org\"), env.CAPXUL_ORG),\n });\n if (args.includes(\"--json\"))\n return `${JSON.stringify(\n {\n version: 1,\n command: \"whoami\",\n invocationId: globalThis.crypto.randomUUID(),\n outcome: \"succeeded\",\n data: where,\n },\n null,\n stdoutTty ? 2 : undefined,\n )}\\n`;\n return `${whoamiLines(where, styleFor(stdoutTty, env)).join(\"\\n\")}\\n`;\n};\n"],"mappings":";;;;AAqBA,MAAM,aAAa,SAA4B;CAC7C,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,MAAM,MAAM,KAAK;EACjB,IAAI,QAAQ,YAAY,kBAAkB,KAAK,GAAG,GAAG;EACrD,KAAK,QAAQ,WAAW,QAAQ,YAAY,KAAK,QAAQ,EAAE,EAAE,WAAW,GAAG,MAAM,OAAO;GACtF,SAAS;GACT;EACF;EACA,OAAO;CACT;CACA,OAAO;AACT;AAEA,MAAM,YAAY,SAAiB;CACjC,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,MAAa,cACX,MACA,KACA,cACuB;CACvB,IAAI,CAAC,UAAU,IAAI,GAAG,OAAO,KAAA;CAC7B,MAAM,OAAO,QAAQ,KAAK,IAAI;CAC9B,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,MAAM,QAAQ,WAAW,SAAS,KAAK,MAAM,cAAc,CAAC,CAAC;CAC7D,MAAM,eAAe,IAAI;CACzB,IAAI,iBAAiB,KAAA,KAAa,iBAAiB,MAAM,CAAC,IAAI,SAAS,YAAY,GACjF,OAAO,KAAA;CACT,MAAM,SAAS,kBAAkB;EAC/B,MAAM,UAAU,MAAM,KAAK;EAC3B,UAAU,IAAI;EACd,cACE,iBAAiB,KAAA,KAAa,iBAAiB,KAAK,KAAA,IAAY,IAAI,IAAI,YAAY,CAAC,CAAC;EACxF,OAAO,MAAM;CACf,CAAC;CACD,IAAI,aAAa,QAAQ,OAAO,KAAA;CAChC,MAAM,QAAQ,cAAc;EAC1B,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB;EACA,aAAa,qBAAqB,UAAU,MAAM,KAAK,GAAG,IAAI,UAAU;CAC1E,CAAC;CACD,IAAI,KAAK,SAAS,QAAQ,GACxB,OAAO,GAAG,KAAK,UACb;EACE,SAAS;EACT,SAAS;EACT,cAAc,WAAW,OAAO,WAAW;EAC3C,SAAS;EACT,MAAM;CACR,GACA,MACA,YAAY,IAAI,KAAA,CAClB,EAAE;CACJ,OAAO,GAAG,YAAY,OAAO,SAAS,WAAW,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;AACpE"}
1
+ {"version":3,"file":"fast-B1MSUn2P.mjs","names":[],"sources":["../src/commands/whoami/fast.ts"],"sourcesContent":["// `capxul whoami` without the Effect runtime. Loading the full CLI costs about\n// 0.4 s before any command runs; this path reads two small local files and\n// prints, so it answers in well under 0.3 s. It handles only the plain forms\n// (`--json`, `--org <handle>`, `--env <name>`); anything else returns\n// undefined and the full CLI parses, validates and answers instead. It makes\n// no network call and records no telemetry.\n\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n chooseEnvironment,\n cliHome,\n describeWhere,\n explicitOrganization,\n flagValue,\n parseWhere,\n} from \"#runtime/where\";\nimport { styleFor, whoamiLines } from \"#runtime/where-view\";\n\ntype Environment = Readonly<Record<string, string | undefined>>;\n\nconst plainForm = (args: readonly string[]) => {\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index]!;\n if (arg === \"--json\" || /^--(org|env)=./u.test(arg)) continue;\n if ((arg === \"--org\" || arg === \"--env\") && args[index + 1]?.startsWith(\"-\") === false) {\n index += 1;\n continue;\n }\n return false;\n }\n return true;\n};\n\nconst readText = (file: string) => {\n try {\n return readFileSync(file, \"utf8\");\n } catch {\n return null;\n }\n};\n\n/** The text to print for `whoami <args>`, or undefined when the full CLI must answer. */\nexport const fastWhoami = (\n args: readonly string[],\n env: Environment,\n stdoutTty: boolean,\n): string | undefined => {\n if (!plainForm(args)) return undefined;\n const home = cliHome(env, join);\n if (home === undefined) return undefined;\n const saved = parseWhere(readText(join(home, \"context.json\")));\n const bootstrapUrl = env.CAPXUL_BOOTSTRAP_URL;\n if (bootstrapUrl !== undefined && bootstrapUrl !== \"\" && !URL.canParse(bootstrapUrl))\n return undefined;\n const choice = chooseEnvironment({\n flag: flagValue(args, \"env\"),\n variable: env.CAPXUL_ENV,\n bootstrapUrl:\n bootstrapUrl === undefined || bootstrapUrl === \"\" ? undefined : new URL(bootstrapUrl).origin,\n saved: saved.env,\n });\n if (\"refusal\" in choice) return undefined;\n const where = describeWhere({\n origin: choice.origin,\n envSource: choice.source,\n saved,\n explicitOrg: explicitOrganization(flagValue(args, \"org\"), env.CAPXUL_ORG),\n });\n if (args.includes(\"--json\"))\n return `${JSON.stringify(\n {\n version: 1,\n command: \"whoami\",\n invocationId: globalThis.crypto.randomUUID(),\n outcome: \"succeeded\",\n data: where,\n },\n null,\n stdoutTty ? 2 : undefined,\n )}\\n`;\n return `${whoamiLines(where, styleFor(stdoutTty, env)).join(\"\\n\")}\\n`;\n};\n"],"mappings":";;;;AAqBA,MAAM,aAAa,SAA4B;CAC7C,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,MAAM,MAAM,KAAK;EACjB,IAAI,QAAQ,YAAY,kBAAkB,KAAK,GAAG,GAAG;EACrD,KAAK,QAAQ,WAAW,QAAQ,YAAY,KAAK,QAAQ,EAAE,EAAE,WAAW,GAAG,MAAM,OAAO;GACtF,SAAS;GACT;EACF;EACA,OAAO;CACT;CACA,OAAO;AACT;AAEA,MAAM,YAAY,SAAiB;CACjC,IAAI;EACF,OAAO,aAAa,MAAM,MAAM;CAClC,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,MAAa,cACX,MACA,KACA,cACuB;CACvB,IAAI,CAAC,UAAU,IAAI,GAAG,OAAO,KAAA;CAC7B,MAAM,OAAO,QAAQ,KAAK,IAAI;CAC9B,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,MAAM,QAAQ,WAAW,SAAS,KAAK,MAAM,cAAc,CAAC,CAAC;CAC7D,MAAM,eAAe,IAAI;CACzB,IAAI,iBAAiB,KAAA,KAAa,iBAAiB,MAAM,CAAC,IAAI,SAAS,YAAY,GACjF,OAAO,KAAA;CACT,MAAM,SAAS,kBAAkB;EAC/B,MAAM,UAAU,MAAM,KAAK;EAC3B,UAAU,IAAI;EACd,cACE,iBAAiB,KAAA,KAAa,iBAAiB,KAAK,KAAA,IAAY,IAAI,IAAI,YAAY,CAAC,CAAC;EACxF,OAAO,MAAM;CACf,CAAC;CACD,IAAI,aAAa,QAAQ,OAAO,KAAA;CAChC,MAAM,QAAQ,cAAc;EAC1B,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB;EACA,aAAa,qBAAqB,UAAU,MAAM,KAAK,GAAG,IAAI,UAAU;CAC1E,CAAC;CACD,IAAI,KAAK,SAAS,QAAQ,GACxB,OAAO,GAAG,KAAK,UACb;EACE,SAAS;EACT,SAAS;EACT,cAAc,WAAW,OAAO,WAAW;EAC3C,SAAS;EACT,MAAM;CACR,GACA,MACA,YAAY,IAAI,KAAA,CAClB,EAAE;CACJ,OAAO,GAAG,YAAY,OAAO,SAAS,WAAW,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;AACpE"}
package/dist/main.mjs CHANGED
@@ -3,12 +3,12 @@ import { argv, env, exit, platform, stderr, stdout, versions } from "node:proces
3
3
  import { fileURLToPath } from "node:url";
4
4
  //#region src/main.ts
5
5
  const args = argv.slice(2);
6
- const whoami = args[0] === "whoami" ? (await import("./fast-BQEiHMyp.mjs")).fastWhoami(args.slice(1), env, stdout.isTTY) : void 0;
6
+ const whoami = args[0] === "whoami" ? (await import("./fast-B1MSUn2P.mjs")).fastWhoami(args.slice(1), env, stdout.isTTY) : void 0;
7
7
  if (whoami === void 0) {
8
8
  const [{ Cause, Effect, Exit, Logger }, { NodeRuntime, NodeServices }, { runCli }] = await Promise.all([
9
9
  import("effect"),
10
10
  import("@effect/platform-node"),
11
- import("./entry-GLdITgH4.mjs")
11
+ import("./entry-DXu0dr0S.mjs")
12
12
  ]);
13
13
  NodeRuntime.runMain(runCli({
14
14
  nodeVersion: versions.node,
@@ -2553,6 +2553,15 @@ const flagValues = (args, name) => {
2553
2553
  };
2554
2554
  /** The last value of one flag, as the parser reads it. */
2555
2555
  const flagValue = (args, name) => flagValues(args, name).at(-1);
2556
+ /**
2557
+ * The `--org` and `--env` a person typed, for a suggested command line: every
2558
+ * command takes them, and without them the suggestion acts somewhere else or
2559
+ * refuses (`org payroll run`). A value that is not plain is not echoed.
2560
+ */
2561
+ const scopeArgs = (args) => ["org", "env"].flatMap((name) => {
2562
+ const value = flagValue(args, name);
2563
+ return value !== void 0 && /^[\w.@:+-]{1,64}$/u.test(value) ? [`--${name}`, value] : [];
2564
+ });
2556
2565
  const isLoopback = (hostname) => hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
2557
2566
  /** What an origin points at: bundled staging, the local DevNet, another loopback backend, or custom. */
2558
2567
  const environmentOf = (origin) => {
@@ -2693,6 +2702,6 @@ const whoamiLines = (where, style) => {
2693
2702
  ];
2694
2703
  };
2695
2704
  //#endregion
2696
- export { assertSize as A, pad as B, keccak256 as C, createCursor as D, toRlp as E, boolToHex as F, IntegerOutOfRangeError as G, trim as H, bytesToHex as I, InvalidBytesBooleanError as K, numberToHex as L, hexToNumber as M, hexToBytes as N, concat as O, toBytes as P, stringToHex as R, getAddress as S, format as T, size as U, padHex as V, isHex as W, readField as _, ENVIRONMENT_NAMES as a, isAddress as b, cliHome as c, explicitOrganization as d, flagValue as f, isRecord as g, parseWhere as h, DEVNET_ORIGIN as i, hexToBigInt as j, concatHex as k, describeWhere as l, networkName as m, styleFor as n, STAGING_ORIGIN as o, flagValues as p, BaseError as q, whoamiLines as r, chooseEnvironment as s, headerLine as t, environmentOf as u, slice as v, InvalidAddressError as w, checksumAddress as x, sliceBytes as y, toHex as z };
2705
+ export { concatHex as A, toHex as B, getAddress as C, toRlp as D, format as E, toBytes as F, isHex as G, padHex as H, boolToHex as I, BaseError as J, IntegerOutOfRangeError as K, bytesToHex as L, hexToBigInt as M, hexToNumber as N, createCursor as O, hexToBytes as P, numberToHex as R, checksumAddress as S, InvalidAddressError as T, trim as U, pad as V, size as W, isRecord as _, ENVIRONMENT_NAMES as a, sliceBytes as b, cliHome as c, explicitOrganization as d, flagValue as f, scopeArgs as g, parseWhere as h, DEVNET_ORIGIN as i, assertSize as j, concat as k, describeWhere as l, networkName as m, styleFor as n, STAGING_ORIGIN as o, flagValues as p, InvalidBytesBooleanError as q, whoamiLines as r, chooseEnvironment as s, headerLine as t, environmentOf as u, readField as v, keccak256 as w, isAddress as x, slice as y, stringToHex as z };
2697
2706
 
2698
- //# sourceMappingURL=where-view-Csv4lEES.mjs.map
2707
+ //# sourceMappingURL=where-view-BJmsAHQb.mjs.map