@theholocron/cli 5.0.0-alpha.355 → 5.0.0-alpha.356

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 CHANGED
@@ -788,7 +788,8 @@ export default defineConfig({
788
788
  Axiom shipping activates when a token (`HOLOCRON_AXIOM_TOKEN` / `AXIOM_TOKEN`
789
789
  → OS keyring `axiom.<org>` → `axiom`) **and** a dataset
790
790
  (`HOLOCRON_AXIOM_DATASET` / `AXIOM_DATASET` → `log.axiom.dataset` in
791
- `holocron.config`) both resolve; env vars win. The token is never read from a
791
+ `holocron.config` → the credential chain, where the 1Password-synced
792
+ `AXIOM_DATASET` lives) both resolve; env vars win. The token is never read from a
792
793
  config file.
793
794
 
794
795
  The dataset side of that resolution is **execution-context-aware** (ADR-0012):
package/dist/cli.mjs CHANGED
@@ -20,7 +20,7 @@ import { bumpCatalogPins, discoverWorkspacePackages, parseCatalogs, readPackageJ
20
20
  import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
21
21
  import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
22
22
  import { Entry, findCredentials } from "@napi-rs/keyring";
23
- import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
23
+ import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
24
24
  import { errorMessage } from "@theholocron/misc-utils";
25
25
  import { pathToFileURL } from "node:url";
26
26
  import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
@@ -758,8 +758,10 @@ function commandsInContext(context) {
758
758
  * traces, errors, structured context that routes to Axiom. It runs in
759
759
  * parallel to `print` (user-facing UX output) and does not replace it.
760
760
  */
761
- const env$8 = createEnvLookup();
762
- const holocronEnv$1 = withEnvPrefix(env$8, "HOLOCRON");
761
+ const env$9 = createEnvLookup();
762
+ /** The one definition of the CLI's variable prefix: `HOLOCRON_<NAME>` is tried before the bare `<NAME>`. */
763
+ const PREFIX$1 = "HOLOCRON";
764
+ const holocronEnv$1 = withEnvPrefix(env$9, PREFIX$1);
763
765
  /**
764
766
  * Dataset for `global`-context commands (`clone`, `auth set`, `upgrade
765
767
  * node`, …) — ADR-0012. These commands aren't "about" any repo, so their
@@ -771,6 +773,15 @@ const holocronEnv$1 = withEnvPrefix(env$8, "HOLOCRON");
771
773
  */
772
774
  const GLOBAL_AXIOM_DATASET = "holocron-global";
773
775
  /**
776
+ * The dataset of a non-global command: the process environment (`HOLOCRON_AXIOM_DATASET`, then the unprefixed
777
+ * `AXIOM_DATASET`, through the prefix lookup), then `log.axiom.dataset`, then the credential chain, which is asked for
778
+ * the same pair of names. `resolveValue` takes a plain list of names, so the pair is built from {@link PREFIX} instead of
779
+ * adding a prefix option to kyber for one caller.
780
+ */
781
+ function resolveCliDataset(opts) {
782
+ return holocronEnv$1.get("AXIOM_DATASET") ?? opts.configAxiomDataset ?? resolveValue$2([`${PREFIX$1}_AXIOM_DATASET`, "AXIOM_DATASET"]);
783
+ }
784
+ /**
774
785
  * Resolve Axiom credentials for the CLI.
775
786
  *
776
787
  * A `global`-context command (ADR-0012) always resolves to
@@ -780,8 +791,11 @@ const GLOBAL_AXIOM_DATASET = "holocron-global";
780
791
  * right answer. Everything else keeps the existing chain: env vars win
781
792
  * (same contract as `@theholocron/observability`'s `resolveAxiomFromEnv`),
782
793
  * falling back to the CLI-only bridge that pairs the OS-keyring token
783
- * (`axiom.<org>` then bare `axiom`) with a dataset from
784
- * `HOLOCRON_AXIOM_DATASET` / `AXIOM_DATASET` or `log.axiom.dataset`.
794
+ * (`axiom.<org>` then bare `axiom`) with a dataset from the process
795
+ * environment (`HOLOCRON_AXIOM_DATASET`, then `AXIOM_DATASET`), then
796
+ * `log.axiom.dataset`, then the credential chain (`resolveValue`, which finds the
797
+ * 1Password-synced `AXIOM_DATASET`). The config sits before the chain so a local
798
+ * run with no `.envrc` still ships to `holocron-local`, not to the CI dataset.
785
799
  * Returns `undefined` unless both a token and a dataset are found.
786
800
  */
787
801
  function resolveCliAxiom(opts, ctx) {
@@ -790,9 +804,9 @@ function resolveCliAxiom(opts, ctx) {
790
804
  const fromEnv = resolveAxiomFromEnv();
791
805
  if (fromEnv) return fromEnv;
792
806
  }
793
- const dataset = isGlobal ? GLOBAL_AXIOM_DATASET : holocronEnv$1.get("AXIOM_DATASET") ?? opts.configAxiomDataset;
807
+ const dataset = isGlobal ? GLOBAL_AXIOM_DATASET : resolveCliDataset(opts);
794
808
  if (!dataset) return void 0;
795
- const org = opts.org ?? env$8.get("HOLOCRON_ORG");
809
+ const org = opts.org ?? env$9.get(`${PREFIX$1}_ORG`);
796
810
  const token = holocronEnv$1.get("AXIOM_TOKEN") || (org ? keyring.get(`axiom.${org}`) : null) || keyring.get("axiom");
797
811
  return token ? {
798
812
  dataset,
@@ -800,7 +814,7 @@ function resolveCliAxiom(opts, ctx) {
800
814
  } : void 0;
801
815
  }
802
816
  const logger = createCliLogger({
803
- envPrefix: "HOLOCRON",
817
+ envPrefix: PREFIX$1,
804
818
  resolveAxiom: resolveCliAxiom
805
819
  });
806
820
  /**
@@ -886,7 +900,7 @@ const endSession = telemetry.endSession;
886
900
  const flush = telemetry.flush;
887
901
  telemetry.resetTelemetry;
888
902
  // src/commands/resolve-org/resolve-org.ts
889
- const env$7 = createEnvLookup();
903
+ const env$8 = createEnvLookup();
890
904
  /**
891
905
  * Resolves the active org in priority order:
892
906
  * 1. `--org` CLI flag
@@ -894,7 +908,7 @@ const env$7 = createEnvLookup();
894
908
  * 3. `org` from `holocron.config.ts`
895
909
  */
896
910
  function resolveOrg(argv, config) {
897
- return argv.org ?? env$7.get("HOLOCRON_ORG") ?? config.org;
911
+ return argv.org ?? env$8.get("HOLOCRON_ORG") ?? config.org;
898
912
  }
899
913
  // src/commands/apply-resolved-config/apply-resolved-config.ts
900
914
  /**
@@ -2272,7 +2286,7 @@ const projectReconcileEntry = {
2272
2286
  supportsDryRun: true
2273
2287
  };
2274
2288
  // src/commands/publish/publish.entry.ts
2275
- const env$6 = createEnvLookup();
2289
+ const env$7 = createEnvLookup();
2276
2290
  const PUBLISH_TAG_OPTION = {
2277
2291
  key: "tag",
2278
2292
  flag: "--tag",
@@ -2285,7 +2299,7 @@ const PUBLISH_OTP_OPTION = {
2285
2299
  type: "password",
2286
2300
  secret: true,
2287
2301
  askLast: true,
2288
- required: Boolean(env$6.get("HOLOCRON_NPM_ENFORCE_2FA")),
2302
+ required: Boolean(env$7.get("HOLOCRON_NPM_ENFORCE_2FA")),
2289
2303
  message: "One-time password (2FA), if npm requires it for this publish:"
2290
2304
  };
2291
2305
  // src/interactive-menu/command-catalog/command-catalog.ts
@@ -3047,7 +3061,7 @@ async function runClone(input) {
3047
3061
  };
3048
3062
  }
3049
3063
  // src/commands/clone/clone.command.ts
3050
- const env$5 = createEnvLookup();
3064
+ const env$6 = createEnvLookup();
3051
3065
  const resolveCloneToken = createFeatureResolver$1({
3052
3066
  envName: "HOLOCRON_READ_TOKEN",
3053
3067
  keyringKey: "github.read"
@@ -3085,7 +3099,7 @@ const cloneCommand = {
3085
3099
  } } : {},
3086
3100
  confirmOpen: async (openTarget, moreToCome) => {
3087
3101
  if (!process.stdin.isTTY) return;
3088
- if (moreToCome && env$5.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") return;
3102
+ if (moreToCome && env$6.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") return;
3089
3103
  if (await confirm({
3090
3104
  message: `Open ${openTarget}?`,
3091
3105
  default: false
@@ -3095,7 +3109,7 @@ const cloneCommand = {
3095
3109
  if (report.status === "fail") {
3096
3110
  if (report.message) reportError(`clone: ${report.message}`);
3097
3111
  process.exitCode = 1;
3098
- } else if (report.status === "dry-run" && report.cloned === 0 && env$5.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") process.exitCode = DRY_RUN_NOOP_EXIT_CODE;
3112
+ } else if (report.status === "dry-run" && report.cloned === 0 && env$6.get(DRY_RUN_PREVIEW_ENV_VAR) === "1") process.exitCode = DRY_RUN_NOOP_EXIT_CODE;
3099
3113
  }
3100
3114
  };
3101
3115
  // src/commands/config-show/config-show.args.ts
@@ -3826,6 +3840,7 @@ async function runDevServe(input) {
3826
3840
  });
3827
3841
  }
3828
3842
  // src/commands/dev-serve/dev-serve.command.ts
3843
+ const env$5 = createEnvLookup();
3829
3844
  const devServeCommand = {
3830
3845
  command: "serve",
3831
3846
  describe: "Serve the handler `dev.serve` names on PORT: the application `holocron dev` runs when it is configured, not usually run by hand",
@@ -3841,7 +3856,7 @@ const devServeCommand = {
3841
3856
  cwd: argv.cwd,
3842
3857
  environment: dev.environment ?? "",
3843
3858
  serve: dev.serve,
3844
- port: Number(process.env["PORT"] ?? dev.port ?? 3e3)
3859
+ port: Number(env$5.get("PORT") ?? dev.port ?? 3e3)
3845
3860
  });
3846
3861
  } catch (err) {
3847
3862
  reportError(`dev serve: ${errorMessage(err)}`);
@@ -10727,6 +10742,36 @@ async function runMonitoringRunResolved(input) {
10727
10742
  ...input.runCheck ? { runCheck: input.runCheck } : {}
10728
10743
  });
10729
10744
  }
10745
+ // src/commands/resolve-vercel-credentials/resolve-vercel-credentials.ts
10746
+ /** The `teamId` of the first configured `vercel` provider (the loader fills it from `.holocron/org.ts`), if any. */
10747
+ function configuredTeamId(resolved) {
10748
+ for (const entry of Object.values(resolved?.providers ?? {})) {
10749
+ const tuples = entry.cardinality === "single" ? [entry.tuple] : entry.tuples;
10750
+ for (const tuple of tuples) {
10751
+ const teamId = tuple.provider === "vercel" ? tuple.options["teamId"] : void 0;
10752
+ if (typeof teamId === "string" && teamId !== "") return teamId;
10753
+ }
10754
+ }
10755
+ }
10756
+ /**
10757
+ * Reads the Vercel token, team id and Deployment Protection bypass secret through the credential chain
10758
+ * (`resolveValue`: the environment, then the `credentials` providers) instead of `process.env`. The environment's
10759
+ * `VERCEL_TEAM_ID` wins over the configured provider's `teamId`, so the override CI passes keeps working. A value that
10760
+ * is not set is left out, so the result spreads straight into the input of `resolveVercelBypassHeaders`.
10761
+ *
10762
+ * @param resolved - The loaded config, when the command has one. `monitoring run-resolved` loads none.
10763
+ * @param env - The environment to read. Default `process.env`; a test passes its own.
10764
+ */
10765
+ function resolveVercelCredentials(resolved, env) {
10766
+ const vercelToken = resolveValue(["VERCEL_TOKEN"], env);
10767
+ const vercelTeamId = resolveValue(["VERCEL_TEAM_ID"], env) ?? configuredTeamId(resolved);
10768
+ const bypassSecret = resolveValue(["VERCEL_PROTECTION_BYPASS_SECRET"], env);
10769
+ return {
10770
+ ...vercelToken ? { vercelToken } : {},
10771
+ ...vercelTeamId ? { vercelTeamId } : {},
10772
+ ...bypassSecret ? { bypassSecret } : {}
10773
+ };
10774
+ }
10730
10775
  // src/commands/monitoring-check/monitoring-check.args.ts
10731
10776
  const monitoringCheckArgs = (y) => y.positional("url", {
10732
10777
  type: "string",
@@ -10749,9 +10794,7 @@ const monitoringCheckCommand = {
10749
10794
  const { headers } = await resolveVercelBypassHeaders({
10750
10795
  url,
10751
10796
  ...argv.vercelProject ? { vercelProject: argv.vercelProject } : {},
10752
- ...process.env["VERCEL_TOKEN"] ? { vercelToken: process.env["VERCEL_TOKEN"] } : {},
10753
- ...process.env["VERCEL_TEAM_ID"] ? { vercelTeamId: process.env["VERCEL_TEAM_ID"] } : {},
10754
- ...process.env["VERCEL_PROTECTION_BYPASS_SECRET"] ? { bypassSecret: process.env["VERCEL_PROTECTION_BYPASS_SECRET"] } : {}
10797
+ ...resolveVercelCredentials(loaded.resolved)
10755
10798
  });
10756
10799
  if ((await runMonitoringCheck({
10757
10800
  loaded,
@@ -10839,9 +10882,7 @@ const monitoringRunResolvedCommand = {
10839
10882
  checks: JSON.parse(readFileSync(argv.checksFile, "utf8")),
10840
10883
  url: argv.url,
10841
10884
  ...argv.vercelProject ? { vercelProject: argv.vercelProject } : {},
10842
- ...process.env["VERCEL_TOKEN"] ? { vercelToken: process.env["VERCEL_TOKEN"] } : {},
10843
- ...process.env["VERCEL_TEAM_ID"] ? { vercelTeamId: process.env["VERCEL_TEAM_ID"] } : {},
10844
- ...process.env["VERCEL_PROTECTION_BYPASS_SECRET"] ? { bypassSecret: process.env["VERCEL_PROTECTION_BYPASS_SECRET"] } : {}
10885
+ ...resolveVercelCredentials()
10845
10886
  })).status === "fail") process.exitCode = 1;
10846
10887
  }
10847
10888
  };
@@ -15274,7 +15315,7 @@ function runTypedoc(repoRoot) {
15274
15315
  function realDiff(repoRoot) {
15275
15316
  /* v8 ignore start -- runs the real git; the probe is tested with an injected diff */
15276
15317
  return () => {
15277
- const base = process.env["BASE_SHA"] || "origin/alpha";
15318
+ const base = createEnvLookup().get("BASE_SHA") ?? "origin/alpha";
15278
15319
  return execFileSync("git", [
15279
15320
  "diff",
15280
15321
  "-U0",
@@ -20664,7 +20705,7 @@ async function runSecretSet(input) {
20664
20705
  const dryRun = input.context.dryRun ?? false;
20665
20706
  const scope = input.scope ?? { kind: "repo" };
20666
20707
  if (!loader.has("secrets")) throw new Error("`secrets` capability is not configured — add a `secrets` provider to holocron.config.json");
20667
- const value = await resolveValue(input);
20708
+ const value = await resolveValue$1(input);
20668
20709
  if (!value) throw new Error(`no value for secret \`${input.name}\` — pass it positionally, via --from-stdin, --from-env <NAME>, or set $${input.name} in the environment`);
20669
20710
  print(`Holocron secret set — ${input.name} (${describeScope$1(scope)})${dryRun ? " (dry-run)" : ""}`);
20670
20711
  if (dryRun) {
@@ -20708,7 +20749,7 @@ async function runSecretSet(input) {
20708
20749
  };
20709
20750
  }
20710
20751
  }
20711
- async function resolveValue(input) {
20752
+ async function resolveValue$1(input) {
20712
20753
  if (input.value) return input.value;
20713
20754
  if (input.fromStdin) return (await (input.readStdin ?? defaultReadStdin)()).replace(/\r?\n$/, "");
20714
20755
  if (input.fromEnv) return env$1.get(input.fromEnv);