@theholocron/cli 5.0.0-alpha.367 → 5.0.0-alpha.368

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/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
4
4
  import { homedir, tmpdir } from "node:os";
5
5
  import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
- import { createEnvLookup, firstEnv, withEnvPrefix } from "@theholocron/env-utils/lookup";
6
+ import { PREFIX, createEnvLookup, firstEnv, holocronEnv } from "@theholocron/env-utils/lookup";
7
7
  import { ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient, onRetry } from "@theholocron/http-client";
8
8
  import { addGlobalOptions, groupMenu, tokenContext } from "@theholocron/kyber/flags";
9
9
  import { checkForUpdates } from "@theholocron/kyber/notifier";
@@ -803,15 +803,12 @@ function commandsInContext(context) {
803
803
  * traces, errors, structured context that routes to Axiom. It runs in
804
804
  * parallel to `print` (user-facing UX output) and does not replace it.
805
805
  */
806
- const env$9 = createEnvLookup();
807
- /** The one definition of the CLI's variable prefix: `HOLOCRON_<NAME>` is tried before the bare `<NAME>`. */
808
- const PREFIX$1 = "HOLOCRON";
809
- const holocronEnv$1 = withEnvPrefix(env$9, PREFIX$1);
806
+ const env$10 = createEnvLookup();
807
+ const holocron = holocronEnv();
810
808
  /**
811
809
  * The CLI's Axiom dataset (`holocron`; each service has its own): the process environment (`HOLOCRON_AXIOM_DATASET`, then the unprefixed `AXIOM_DATASET`,
812
810
  * through the prefix lookup), then the repo's `log.axiom.dataset`, then the credential chain, which is asked for the
813
- * same pair of names. `resolveValue` takes a plain list of names, so the pair is built from {@link PREFIX} instead of
814
- * adding a prefix option to kyber for one caller.
811
+ * same pair of names through `resolveValue`'s `prefix` option.
815
812
  *
816
813
  * A service's environments ship to the same dataset and are told apart by the `env` field on each line (ADR-0019). The
817
814
  * config dataset is only a per-repo override, so a `global`-context command (`clone`, `auth set`, `upgrade node`, ...,
@@ -819,7 +816,7 @@ const holocronEnv$1 = withEnvPrefix(env$9, PREFIX$1);
819
816
  * lines go.
820
817
  */
821
818
  function resolveCliDataset(opts, isGlobal) {
822
- return holocronEnv$1.get("AXIOM_DATASET") ?? (isGlobal ? void 0 : opts.configAxiomDataset) ?? resolveValue$2([`${PREFIX$1}_AXIOM_DATASET`, "AXIOM_DATASET"]);
819
+ return holocron.get("AXIOM_DATASET") ?? (isGlobal ? void 0 : opts.configAxiomDataset) ?? resolveValue$2(["AXIOM_DATASET"], void 0, { prefix: PREFIX });
823
820
  }
824
821
  /**
825
822
  * Resolve Axiom credentials for the CLI.
@@ -834,15 +831,15 @@ function resolveCliAxiom(opts, ctx) {
834
831
  if (fromEnv) return fromEnv;
835
832
  const dataset = resolveCliDataset(opts, contextForCommand(ctx.command ?? "") === "global");
836
833
  if (!dataset) return void 0;
837
- const org = opts.org ?? env$9.get(`${PREFIX$1}_ORG`);
838
- const token = holocronEnv$1.get("AXIOM_TOKEN") || (org ? keyring.get(`axiom.${org}`) : null) || keyring.get("axiom");
834
+ const org = opts.org ?? env$10.get(`${PREFIX}_ORG`);
835
+ const token = holocron.get("AXIOM_TOKEN") || (org ? keyring.get(`axiom.${org}`) : null) || keyring.get("axiom");
839
836
  return token ? {
840
837
  dataset,
841
838
  token
842
839
  } : void 0;
843
840
  }
844
841
  const logger = createCliLogger({
845
- envPrefix: PREFIX$1,
842
+ envPrefix: PREFIX,
846
843
  resolveAxiom: resolveCliAxiom
847
844
  });
848
845
  /**
@@ -860,7 +857,7 @@ const getRunId = logger.getRunId;
860
857
  logger.resetCliLogger;
861
858
  logger.resolveLogLevel;
862
859
  // src/observability/resolve-telemetry/resolve-telemetry.ts
863
- const holocronEnv = withEnvPrefix(createEnvLookup(), "HOLOCRON");
860
+ const env$9 = holocronEnv();
864
861
  /**
865
862
  * Holocron-specific credential resolution for the telemetry sinks — the env
866
863
  * chain plus Holocron's own shipped fallbacks. This is **CLI policy**, not part
@@ -884,15 +881,15 @@ const FALLBACK_POSTHOG_PROJECT_TOKEN = "phc_AC4vFCvYzwnzmG7Vg5nEc3PZKZztoPyfKp4L
884
881
  const DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
885
882
  /** Resolve the Sentry DSN. `""` → error telemetry disabled. */
886
883
  function resolveDsn() {
887
- return holocronEnv.get("SENTRY_DSN") ?? FALLBACK_DSN;
884
+ return env$9.get("SENTRY_DSN") ?? FALLBACK_DSN;
888
885
  }
889
886
  /** Resolve the PostHog project key. `""` → usage analytics disabled. */
890
887
  function resolvePostHogKey() {
891
- return holocronEnv.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
888
+ return env$9.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
892
889
  }
893
890
  /** Resolve the PostHog ingest host. */
894
891
  function resolvePostHogHost() {
895
- return holocronEnv.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
892
+ return env$9.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
896
893
  }
897
894
  // src/observability/telemetry/telemetry.ts
898
895
  /**
@@ -906,7 +903,7 @@ function resolvePostHogHost() {
906
903
  * `NO_HOLOCRON_TELEMETRY`); see ADR-0007 / ADR-0008.
907
904
  */
908
905
  const telemetry = createCliTelemetry({
909
- envPrefix: "HOLOCRON",
906
+ envPrefix: PREFIX,
910
907
  dsn: resolveDsn,
911
908
  posthogKey: resolvePostHogKey,
912
909
  posthogHost: resolvePostHogHost,
@@ -1158,7 +1155,7 @@ const defaultImporter = (pkg) => createDefaultImporter()(pkg);
1158
1155
  * pulling FROM it would just re-store the same value.
1159
1156
  */
1160
1157
  function resolveAuthSetToken(input) {
1161
- const e = withEnvPrefix(createEnvLookup(input.env), "HOLOCRON");
1158
+ const e = holocronEnv(input.env);
1162
1159
  return input.positional || e.get(`${input.provider.toUpperCase()}_TOKEN`) || null;
1163
1160
  }
1164
1161
  /**
@@ -2700,7 +2697,7 @@ const getEntry = registry.getEntry;
2700
2697
  */
2701
2698
  const menu = createMenu({
2702
2699
  bin: "holocron",
2703
- envPrefix: "HOLOCRON"
2700
+ envPrefix: PREFIX
2704
2701
  });
2705
2702
  const launchMenu = menu.launchMenu;
2706
2703
  /** The env var a Holocron dry-run preview child gets (`HOLOCRON_DRY_RUN_PREVIEW`). */
@@ -4365,7 +4362,7 @@ const CALLER_IDS = [
4365
4362
  "ci"
4366
4363
  ];
4367
4364
  /** The `ci.` a hosting repo puts before its callers' file names (`ci.yml` is the reusable itself, not a prefixed caller). */
4368
- const PREFIX = "ci.";
4365
+ const PREFIX$1 = "ci.";
4369
4366
  /**
4370
4367
  * What is wrong with the names of the generated callers, one line each. A caller is named for its task id in three
4371
4368
  * places: the file (`workflowFile(id)`, `ci.` first in the repo that hosts the reusables), the workflow `name:` and each
@@ -4376,7 +4373,7 @@ const PREFIX = "ci.";
4376
4373
  function callerProblems(callers) {
4377
4374
  return callers.flatMap(({ file, name, jobs }) => {
4378
4375
  const base = file.replace(/\.yml$/, "");
4379
- const prefix = base.startsWith(PREFIX) ? PREFIX : "";
4376
+ const prefix = base.startsWith(PREFIX$1) ? PREFIX$1 : "";
4380
4377
  const stem = base.slice(prefix.length);
4381
4378
  if (Object.hasOwn(LEGACY_NAMES, stem)) return [`${file}: an old caller name; the flat name is ${workflowKeys(stem).map((id) => `${prefix}${workflowFile(id)}`).join(", ")}`];
4382
4379
  const id = CALLER_IDS.find((candidate) => workflowFile(candidate).replace(/\.yml$/, "") === stem);
@@ -19185,7 +19182,7 @@ async function runSetup(input) {
19185
19182
  const logs = loader.get("logs");
19186
19183
  print(style.step("logs"));
19187
19184
  if (logs.ensureDataset) {
19188
- const dataset = withEnvPrefix(createEnvLookup(), "HOLOCRON").get("AXIOM_DATASET");
19185
+ const dataset = holocronEnv().get("AXIOM_DATASET");
19189
19186
  if (dataset) steps.push(await runStep("logs", `ensureDataset ${dataset}`, dryRun, async () => {
19190
19187
  const result = await logs.ensureDataset(dataset);
19191
19188
  return `${dataset} ${result.alreadyExists ? "exists" : "created"}`;