@theholocron/kyber 5.0.0-alpha.362 → 5.0.0-alpha.364

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.
@@ -13,7 +13,7 @@ interface UpdateCheckOptions {
13
13
  currentVersion: string;
14
14
  /** The directory the answer is kept in, created when it is first written. One per tool. */
15
15
  cacheDir: string;
16
- /** The variables that switch the notice off (`CI`, `NO_UPDATE_NOTIFIER`). Default `process.env`. */
16
+ /** The variables that switch the notice off (`CI`, `NO_UPDATE_NOTIFIER`). Default the process environment. */
17
17
  env?: Record<string, string | undefined>;
18
18
  /** How the notice tells people to update. Default `npm install -g <name>`. */
19
19
  installCommand?: string;
package/dist/notifier.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { join } from "node:path";
2
2
  import chalk from "chalk";
3
+ import { createEnvLookup, isCI } from "@theholocron/env-utils/lookup";
3
4
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
4
5
  // src/notifier/update-notifier/update-notifier.ts
5
6
  const CACHE_FILE = "update-check.json";
@@ -98,8 +99,7 @@ function formatNotice(current, latest, installCmd) {
98
99
  */
99
100
  async function checkForUpdates(options) {
100
101
  const { name, currentVersion, cacheDir } = options;
101
- const env = options.env ?? process.env;
102
- if (env["CI"] || env["NO_UPDATE_NOTIFIER"]) return null;
102
+ if (isCI(options.env) || createEnvLookup(options.env).get("NO_UPDATE_NOTIFIER")) return null;
103
103
  const channel = getChannel(currentVersion);
104
104
  const cache = readCache(cacheDir);
105
105
  const now = Date.now();
@@ -1,6 +1,6 @@
1
1
  import { allowProgress, style } from "./ui.mjs";
2
- import { createLogger, isCI, parseLogLevel, resolveAxiomFromEnv } from "@theholocron/observability/logger";
3
2
  import { createEnvLookup } from "@theholocron/env-utils/lookup";
3
+ import { createLogger, isCI as isCI$1, parseLogLevel, resolveAxiomFromEnv } from "@theholocron/observability/logger";
4
4
  import { createHash } from "node:crypto";
5
5
  import { hostname, userInfo } from "node:os";
6
6
  import { PostHogSink } from "@theholocron/observability/analytics";
@@ -21,7 +21,7 @@ import { SentrySink } from "@theholocron/observability/errors";
21
21
  */
22
22
  function resolveConsoleOutput(argv) {
23
23
  if (argv.log || argv.verbose || argv.quiet) return true;
24
- return isCI() ? void 0 : false;
24
+ return isCI$1() ? void 0 : false;
25
25
  }
26
26
  // src/observability/resolve-log-level/resolve-log-level.ts
27
27
  const env$1 = createEnvLookup();
@@ -43,6 +43,17 @@ export declare function hasCredentials(source: string): boolean;
43
43
  * vendor's). `undefined` when no source has one.
44
44
  */
45
45
  export declare function getCredential(...names: string[]): string | undefined;
46
+ /** A value found in the store, with the source that had it and the name it was found under. */
47
+ export interface FoundCredential {
48
+ /** The value. A secret: callers must not print it. */
49
+ value: string;
50
+ /** The source that returned it, as it was given to {@link setCredentials} (for example `1password:Holocron`). */
51
+ source: string;
52
+ /** Which of the names asked for had it. */
53
+ name: string;
54
+ }
55
+ /** Like {@link getCredential}, but also says which source and which name the value came from, for a report. */
56
+ export declare function findCredential(...names: string[]): FoundCredential | undefined;
46
57
  /** Forget every source. For tests, and for a process that wants the next load to read the providers again. */
47
58
  export declare function clearCredentials(): void;
48
59
  /**
package/dist/secrets.mjs CHANGED
@@ -4,8 +4,8 @@ import { t as waitForEnter } from "./wait-for-enter-BeC-qTm3.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { basename, dirname, join } from "node:path";
6
6
  import { execFileSync } from "node:child_process";
7
- import { closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeSync } from "node:fs";
8
7
  import { createEnvLookup } from "@theholocron/env-utils/lookup";
8
+ import { closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeSync } from "node:fs";
9
9
  import { randomBytes } from "node:crypto";
10
10
  import { parse } from "dotenv";
11
11
  // src/secrets/auth-error/auth-error.ts
@@ -49,9 +49,17 @@ function hasCredentials(source) {
49
49
  * vendor's). `undefined` when no source has one.
50
50
  */
51
51
  function getCredential(...names) {
52
- for (const variables of sources.values()) for (const name of names) {
52
+ return findCredential(...names)?.value;
53
+ }
54
+ /** Like {@link getCredential}, but also says which source and which name the value came from, for a report. */
55
+ function findCredential(...names) {
56
+ for (const [source, variables] of sources) for (const name of names) {
53
57
  const value = variables[name];
54
- if (value) return value;
58
+ if (value) return {
59
+ value,
60
+ source,
61
+ name
62
+ };
55
63
  }
56
64
  }
57
65
  /** Forget every source. For tests, and for a process that wants the next load to read the providers again. */
@@ -469,4 +477,4 @@ function createResolveToken(config) {
469
477
  function resolveValue(names, env) {
470
478
  return firstEnv(env, ...names) ?? getCredential(...names);
471
479
  }
472
- export { AuthError, DOTENV_FILE, TokenParseError, clearCredentials, copyToClipboard, createFeatureResolver, createKeyring, createPrivateFile, createResolveToken, dotenvLine, finishCredentialsFile, getCredential, hasCredentials, isGitIgnored, parseTokenArgs, readDotenvFile, resolveValue, setCredentials, shredFile, writeCredentialsFile };
480
+ export { AuthError, DOTENV_FILE, TokenParseError, clearCredentials, copyToClipboard, createFeatureResolver, createKeyring, createPrivateFile, createResolveToken, dotenvLine, findCredential, finishCredentialsFile, getCredential, hasCredentials, isGitIgnored, parseTokenArgs, readDotenvFile, resolveValue, setCredentials, shredFile, writeCredentialsFile };
package/dist/testing.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { dirname, join, sep } from "node:path";
2
2
  import { execFileSync, spawn } from "node:child_process";
3
+ import { createEnvLookup } from "@theholocron/env-utils/lookup";
3
4
  import { existsSync, readdirSync, realpathSync, statSync } from "node:fs";
4
5
  import { tmpdir } from "node:os";
5
6
  import { fileURLToPath } from "node:url";
@@ -29,7 +30,7 @@ function createCliRunner(options) {
29
30
  "pipe"
30
31
  ],
31
32
  env: {
32
- PATH: process.env["PATH"] ?? "",
33
+ PATH: createEnvLookup().get("PATH") ?? "",
33
34
  HOME: dir,
34
35
  TMPDIR: dir,
35
36
  FORCE_COLOR: "0",
package/dist/ui.d.mts CHANGED
@@ -176,8 +176,10 @@ export declare function setProgressListener(listener: ProgressListener | undefin
176
176
  /**
177
177
  * Whether to draw a progress line: only when a person is watching a terminal (stdout and stderr both), not in CI, and not
178
178
  * switched off. Everywhere else the output stays the plain line-per-step text that scripts and the docs rely on.
179
+ *
180
+ * @param env - The environment to read `CI` from. Default the process environment; a test passes its own.
179
181
  */
180
- export declare function progressEnabled(): boolean;
182
+ export declare function progressEnabled(env?: Record<string, string | undefined>): boolean;
181
183
  /**
182
184
  * A spinner for one step at a time that a step can print through. Steps that only return a result use {@link
183
185
  * withProgress}; a step that prints its own result line while it runs prints through `print`. A `listen` hook, or else the
package/dist/ui.mjs CHANGED
@@ -3,6 +3,7 @@ import { t as NonInteractiveError } from "./non-interactive-error-Mm_Mn79M.mjs";
3
3
  import { t as waitForEnter } from "./wait-for-enter-BeC-qTm3.mjs";
4
4
  import { spawn } from "node:child_process";
5
5
  import chalk from "chalk";
6
+ import { isCI } from "@theholocron/env-utils/lookup";
6
7
  import ora from "ora";
7
8
  // src/ui/command-failure/command-failure.ts
8
9
  /**
@@ -389,9 +390,11 @@ function setProgressListener(listener) {
389
390
  /**
390
391
  * Whether to draw a progress line: only when a person is watching a terminal (stdout and stderr both), not in CI, and not
391
392
  * switched off. Everywhere else the output stays the plain line-per-step text that scripts and the docs rely on.
393
+ *
394
+ * @param env - The environment to read `CI` from. Default the process environment; a test passes its own.
392
395
  */
393
- function progressEnabled() {
394
- return allowed && Boolean(process.stdout.isTTY) && Boolean(process.stderr.isTTY) && !process.env["CI"];
396
+ function progressEnabled(env) {
397
+ return allowed && Boolean(process.stdout.isTTY) && Boolean(process.stderr.isTTY) && !isCI(env);
395
398
  }
396
399
  /**
397
400
  * A spinner for one step at a time that a step can print through. Steps that only return a result use {@link
@@ -399,7 +402,7 @@ function progressEnabled() {
399
402
  * one set with {@link setProgressListener}, can change the spinner's text while the step runs, for instance to say that
400
403
  * a request is being sent again.
401
404
  */
402
- function createProgress(print, enabled = progressEnabled, listen) {
405
+ function createProgress(print, enabled = () => progressEnabled(), listen) {
403
406
  let active;
404
407
  return {
405
408
  async run(label, fn) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/kyber",
3
- "version": "5.0.0-alpha.362",
3
+ "version": "5.0.0-alpha.364",
4
4
  "description": "The reusable parts of a command-line tool: terminal output, prompts, the interactive menu, the update notifier, safe handling of tokens, a test harness and the global flags.",
5
5
  "keywords": [
6
6
  "cli",
@@ -105,12 +105,12 @@
105
105
  "typescript": "^5.9.3",
106
106
  "vitest": "^5.0.5",
107
107
  "yargs": "^18.1.0",
108
- "@theholocron/datapad": "5.0.0-alpha.362",
109
- "@theholocron/tsconfig": "^8.9.0-alpha.9",
110
- "@theholocron/observability": "0.7.0-alpha.1",
111
- "@theholocron/tsdown-config": "^8.9.0-alpha.9",
112
- "@theholocron/eslint-config": "^8.9.0-alpha.9",
113
- "@theholocron/vitest-config": "^8.9.0-alpha.9"
108
+ "@theholocron/datapad": "5.0.0-alpha.364",
109
+ "@theholocron/eslint-config": "^8.9.0-alpha.11",
110
+ "@theholocron/tsconfig": "^8.9.0-alpha.11",
111
+ "@theholocron/observability": "0.7.0-alpha.2",
112
+ "@theholocron/vitest-config": "^8.9.0-alpha.11",
113
+ "@theholocron/tsdown-config": "^8.9.0-alpha.11"
114
114
  },
115
115
  "peerDependencies": {
116
116
  "@inquirer/prompts": "^8.0.0",
@@ -121,8 +121,8 @@
121
121
  "dotenv": "^17.0.0",
122
122
  "ora": "^9.0.0",
123
123
  "yargs": "^18.0.0",
124
- "@theholocron/datapad": "^5.0.0-alpha.362",
125
- "@theholocron/observability": "^0.7.0-alpha.1"
124
+ "@theholocron/datapad": "^5.0.0-alpha.364",
125
+ "@theholocron/observability": "^0.7.0-alpha.2"
126
126
  },
127
127
  "peerDependenciesMeta": {
128
128
  "@inquirer/prompts": {