@capxul/cli 4.20.0-beta.24 → 4.20.0-beta.27
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.
- package/README.md +313 -262
- package/dist/browser/signer.js +154 -112
- package/dist/browser/signer.js.map +1 -1
- package/dist/{entry-DVob5Y9P.mjs → entry-GLdITgH4.mjs} +8902 -8630
- package/dist/entry-GLdITgH4.mjs.map +1 -0
- package/dist/{fast-BqLZA9eV.mjs → fast-BQEiHMyp.mjs} +3 -3
- package/dist/fast-BQEiHMyp.mjs.map +1 -0
- package/dist/main.mjs +2 -2
- package/dist/{where-view-CPYOxIxM.mjs → where-view-Csv4lEES.mjs} +23 -15
- package/dist/{where-view-CPYOxIxM.mjs.map → where-view-Csv4lEES.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/entry-DVob5Y9P.mjs.map +0 -1
- package/dist/fast-BqLZA9eV.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as cliHome, d as
|
|
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";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
//#region src/commands/whoami/fast.ts
|
|
@@ -40,7 +40,7 @@ const fastWhoami = (args, env, stdoutTty) => {
|
|
|
40
40
|
origin: choice.origin,
|
|
41
41
|
envSource: choice.source,
|
|
42
42
|
saved,
|
|
43
|
-
|
|
43
|
+
explicitOrg: explicitOrganization(flagValue(args, "org"), env.CAPXUL_ORG)
|
|
44
44
|
});
|
|
45
45
|
if (args.includes("--json")) return `${JSON.stringify({
|
|
46
46
|
version: 1,
|
|
@@ -54,4 +54,4 @@ const fastWhoami = (args, env, stdoutTty) => {
|
|
|
54
54
|
//#endregion
|
|
55
55
|
export { fastWhoami };
|
|
56
56
|
|
|
57
|
-
//# sourceMappingURL=fast-
|
|
57
|
+
//# sourceMappingURL=fast-BQEiHMyp.mjs.map
|
|
@@ -0,0 +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"}
|
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-
|
|
6
|
+
const whoami = args[0] === "whoami" ? (await import("./fast-BQEiHMyp.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-
|
|
11
|
+
import("./entry-GLdITgH4.mjs")
|
|
12
12
|
]);
|
|
13
13
|
NodeRuntime.runMain(runCli({
|
|
14
14
|
nodeVersion: versions.node,
|
|
@@ -2545,15 +2545,14 @@ const parseWhere = (content) => {
|
|
|
2545
2545
|
};
|
|
2546
2546
|
/** The CLI home folder, from the same variables the runtime configuration reads. */
|
|
2547
2547
|
const cliHome = (env, join) => env.CAPXUL_CLI_HOME ?? (env.XDG_CONFIG_HOME === void 0 ? env.HOME === void 0 ? void 0 : join(env.HOME, ".config", "capxul", "cli") : join(env.XDG_CONFIG_HOME, "capxul", "cli"));
|
|
2548
|
-
/**
|
|
2549
|
-
const
|
|
2548
|
+
/** Every value of a `--name value` or `--name=value` flag, before any `--`. */
|
|
2549
|
+
const flagValues = (args, name) => {
|
|
2550
2550
|
const end = args.indexOf("--");
|
|
2551
2551
|
const flags = end < 0 ? args : args.slice(0, end);
|
|
2552
|
-
|
|
2553
|
-
for (const [index, arg] of flags.entries()) if (arg.startsWith(`--${name}=`)) value = arg.slice(name.length + 3);
|
|
2554
|
-
else if (arg === `--${name}`) value = flags[index + 1];
|
|
2555
|
-
return value;
|
|
2552
|
+
return flags.flatMap((arg, index) => arg.startsWith(`--${name}=`) ? [arg.slice(name.length + 3)] : arg === `--${name}` && flags[index + 1] !== void 0 ? [flags[index + 1]] : []);
|
|
2556
2553
|
};
|
|
2554
|
+
/** The last value of one flag, as the parser reads it. */
|
|
2555
|
+
const flagValue = (args, name) => flagValues(args, name).at(-1);
|
|
2557
2556
|
const isLoopback = (hostname) => hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
2558
2557
|
/** What an origin points at: bundled staging, the local DevNet, another loopback backend, or custom. */
|
|
2559
2558
|
const environmentOf = (origin) => {
|
|
@@ -2592,9 +2591,17 @@ const chooseEnvironment = (input) => {
|
|
|
2592
2591
|
};
|
|
2593
2592
|
/** The network's name, from the chain Capxul data names. */
|
|
2594
2593
|
const networkName = (chainId) => chainId === null || chainId === void 0 ? null : networkForChain(chainId)?.name ?? `Chain ${chainId}`;
|
|
2595
|
-
/**
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2594
|
+
/** The Organization `--org`, else `CAPXUL_ORG`, names for one command. */
|
|
2595
|
+
const explicitOrganization = (flag, variable) => flag !== void 0 ? {
|
|
2596
|
+
value: flag,
|
|
2597
|
+
source: "flag"
|
|
2598
|
+
} : variable === void 0 || variable === "" ? void 0 : {
|
|
2599
|
+
value: variable,
|
|
2600
|
+
source: "env"
|
|
2601
|
+
};
|
|
2602
|
+
/** Who you act as: `--org` or `CAPXUL_ORG`, else the saved Organization, else yourself. */
|
|
2603
|
+
const actorOf = (saved, explicit) => {
|
|
2604
|
+
if (explicit === void 0) {
|
|
2598
2605
|
const org = saved.org;
|
|
2599
2606
|
if (org === null || org === void 0) return { actingAs: {
|
|
2600
2607
|
kind: "personal",
|
|
@@ -2609,15 +2616,16 @@ const actorOf = (saved, orgFlag) => {
|
|
|
2609
2616
|
}
|
|
2610
2617
|
};
|
|
2611
2618
|
}
|
|
2612
|
-
const
|
|
2619
|
+
const wanted = explicit.value.replace(/^@/u, "").toLowerCase();
|
|
2620
|
+
const known = saved.org?.handle.toLowerCase() === wanted || saved.org?.id === explicit.value ? saved.org : void 0;
|
|
2613
2621
|
return {
|
|
2614
2622
|
known,
|
|
2615
2623
|
actingAs: {
|
|
2616
2624
|
kind: "organization",
|
|
2617
|
-
handle:
|
|
2625
|
+
handle: known?.handle ?? explicit.value,
|
|
2618
2626
|
name: known?.name ?? null,
|
|
2619
2627
|
id: known?.id ?? null,
|
|
2620
|
-
source:
|
|
2628
|
+
source: explicit.source
|
|
2621
2629
|
}
|
|
2622
2630
|
};
|
|
2623
2631
|
};
|
|
@@ -2625,7 +2633,7 @@ const actorOf = (saved, orgFlag) => {
|
|
|
2625
2633
|
const describeWhere = (input) => {
|
|
2626
2634
|
const saved = input.saved.origins?.[input.origin] ?? {};
|
|
2627
2635
|
const user = saved.email === void 0 ? null : { email: saved.email };
|
|
2628
|
-
const { known, actingAs: actor } = actorOf(saved, input.
|
|
2636
|
+
const { known, actingAs: actor } = actorOf(saved, input.explicitOrg);
|
|
2629
2637
|
const actingAs = actor.kind === "personal" ? actor : {
|
|
2630
2638
|
kind: actor.kind,
|
|
2631
2639
|
handle: actor.handle,
|
|
@@ -2685,6 +2693,6 @@ const whoamiLines = (where, style) => {
|
|
|
2685
2693
|
];
|
|
2686
2694
|
};
|
|
2687
2695
|
//#endregion
|
|
2688
|
-
export {
|
|
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 };
|
|
2689
2697
|
|
|
2690
|
-
//# sourceMappingURL=where-view-
|
|
2698
|
+
//# sourceMappingURL=where-view-Csv4lEES.mjs.map
|