@theholocron/cli 5.0.0-alpha.151 → 5.0.0-alpha.152

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
@@ -10,7 +10,7 @@ import { LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, redactObject } from "@the
10
10
  import yargs from "yargs";
11
11
  import { hideBin } from "yargs/helpers";
12
12
  import { AuthError, ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient } from "@theholocron/http-client";
13
- import { createEnvLookup } from "@theholocron/env-utils";
13
+ import { createEnvLookup, firstEnv, withEnvPrefix } from "@theholocron/env-utils";
14
14
  import { Entry, findCredentials } from "@napi-rs/keyring";
15
15
  import { pathToFileURL } from "node:url";
16
16
  import { errorMessage } from "@theholocron/misc-utils";
@@ -37,6 +37,13 @@ import search from "@inquirer/search";
37
37
  /** Singleton env for simple global lookups throughout the CLI. */
38
38
  const env = createEnvLookup();
39
39
  /**
40
+ * `get("KEY")` tries `HOLOCRON_KEY` first, then `KEY`. Use it for settings that
41
+ * have both a Holocron-namespaced override and a vendor-native name; do not use
42
+ * it for `HOLOCRON_*` variables that have no bare fallback (`HOLOCRON_ORG`,
43
+ * `HOLOCRON_LOG_LEVEL`, …), where the bare name would be wrong.
44
+ */
45
+ const holocronEnv = withEnvPrefix(env, "HOLOCRON");
46
+ /**
40
47
  * Create an injectable env for commands that accept a fake env in tests.
41
48
  * Pass `input.env` when available, falls back to `process.env`.
42
49
  */
@@ -450,10 +457,10 @@ function resolveCliAxiom(opts) {
450
457
  const fromEnv = resolveAxiomFromEnv();
451
458
  if (fromEnv) return fromEnv;
452
459
  }
453
- const dataset = isGlobal ? GLOBAL_AXIOM_DATASET : env.get("HOLOCRON_AXIOM_DATASET") || env.get("AXIOM_DATASET") || opts.configAxiomDataset;
460
+ const dataset = isGlobal ? GLOBAL_AXIOM_DATASET : holocronEnv.get("AXIOM_DATASET") ?? opts.configAxiomDataset;
454
461
  if (!dataset) return void 0;
455
462
  const org = opts.org ?? env.get("HOLOCRON_ORG");
456
- const token = env.get("HOLOCRON_AXIOM_TOKEN") || env.get("AXIOM_TOKEN") || (org ? getToken(`axiom.${org}`) : null) || getToken("axiom");
463
+ const token = holocronEnv.get("AXIOM_TOKEN") || (org ? getToken(`axiom.${org}`) : null) || getToken("axiom");
457
464
  return token ? {
458
465
  dataset,
459
466
  token
@@ -813,10 +820,8 @@ const defaultImporter = async (pkg) => {
813
820
  * pulling FROM it would just re-store the same value.
814
821
  */
815
822
  function resolveAuthSetToken(input) {
816
- const e = makeEnv(input.env);
817
- const upper = input.provider.toUpperCase();
818
- const holocronKey = `HOLOCRON_${upper}_TOKEN`;
819
- return input.positional || e.get(holocronKey) || e.get(`${upper}_TOKEN`) || null;
823
+ const e = withEnvPrefix(makeEnv(input.env), "HOLOCRON");
824
+ return input.positional || e.get(`${input.provider.toUpperCase()}_TOKEN`) || null;
820
825
  }
821
826
  async function runAuthSet(input) {
822
827
  const print = input.print ?? ((l) => console.log(l));
@@ -6561,7 +6566,11 @@ async function runSyncReadme(input) {
6561
6566
  //#endregion
6562
6567
  //#region src/commands/sync-wiki.ts
6563
6568
  function resolveToken(input) {
6564
- return input.token ?? input.context.cliToken ?? process.env.HOLOCRON_READ_TOKEN ?? process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN;
6569
+ return input.token ?? input.context.cliToken ?? firstEnv(env, [
6570
+ "HOLOCRON_READ_TOKEN",
6571
+ "GH_TOKEN",
6572
+ "GITHUB_TOKEN"
6573
+ ]);
6565
6574
  }
6566
6575
  function deriveBasepath(domain, repoName) {
6567
6576
  if (domain) {
@@ -7384,15 +7393,15 @@ const FALLBACK_POSTHOG_PROJECT_TOKEN = "phc_AC4vFCvYzwnzmG7Vg5nEc3PZKZztoPyfKp4L
7384
7393
  const DEFAULT_POSTHOG_HOST = "https://us.i.posthog.com";
7385
7394
  /** Resolve the Sentry DSN. `""` → error telemetry disabled. */
7386
7395
  function resolveDsn() {
7387
- return env.get("HOLOCRON_SENTRY_DSN") ?? env.get("SENTRY_DSN") ?? FALLBACK_DSN;
7396
+ return holocronEnv.get("SENTRY_DSN") ?? FALLBACK_DSN;
7388
7397
  }
7389
7398
  /** Resolve the PostHog project key. `""` → usage analytics disabled. */
7390
7399
  function resolvePostHogKey() {
7391
- return env.get("HOLOCRON_POSTHOG_PROJECT_TOKEN") ?? env.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
7400
+ return holocronEnv.get("POSTHOG_PROJECT_TOKEN") ?? FALLBACK_POSTHOG_PROJECT_TOKEN;
7392
7401
  }
7393
7402
  /** Resolve the PostHog ingest host. */
7394
7403
  function resolvePostHogHost() {
7395
- return env.get("HOLOCRON_POSTHOG_HOST") ?? env.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
7404
+ return holocronEnv.get("POSTHOG_HOST") ?? DEFAULT_POSTHOG_HOST;
7396
7405
  }
7397
7406
  //#endregion
7398
7407
  //#region src/telemetry.ts