@theholocron/kyber 5.0.0-alpha.348 → 5.0.0-alpha.349
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 +1 -1
- package/dist/config.d.mts +16 -2
- package/dist/config.mjs +17 -4
- package/dist/notifier.mjs +1 -1
- package/dist/secrets.mjs +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Published, so a second CLI can import it. `@theholocron/cli` is its first consum
|
|
|
19
19
|
| `/menu` | The interactive menu of a CLI, driven by data: `launchMenu(entries, argv, { bin, envPrefix })` shows a searchable, nested picker over a list of `MenuEntry`, asks for the positionals and options the command needs, then spawns the CLI again with the answers. A command that supports `--dry-run` is previewed first and then confirmed (`--skip-dry-run` opts out); a preview that reports `DRY_RUN_NOOP_EXIT_CODE` skips the question. Secret options never reach argv: they travel as `<envPrefix>_<OPTION>` env vars, and a preview child gets `dryRunPreviewEnvVar(envPrefix)`. `createMenu({ bin, envPrefix })` binds it once (returning `launchMenu(entries, argv, options?)` and `dryRunPreviewEnvVar`). `createCommandRegistry(entries, label?)` declares the commands once and returns `{ entries, getEntry(name) }` (a repeated name throws), and `numeric` is a ready `validate` for a number prompt. Also `menuItems`, `buildChildArgv`, `forwardedFlags`, `secretEnv`, `shouldPreviewDryRun`. |
|
|
20
20
|
| `/testing` | A test harness for a CLI: `createCliRunner` runs a built binary in a fresh directory with an environment built from nothing, `runCommand` runs one yargs command module through a real parse, `ensureBuilt` is a Vitest global setup that builds only when `dist` is missing or stale, and `hermeticCreateRequire` resolves modules only from one directory. |
|
|
21
21
|
| `/observability` | The logging and telemetry wiring of a CLI: `createCliLogger({ envPrefix, resolveAxiom? })` returns a memoized root logger (`buildCliLogger`, `getLogger`, `reportError`, `getRunId`, `resolveLogLevel`) whose level comes from `--log` / `--verbose` / `--quiet`, then `<PREFIX>_LOG_LEVEL`, then the config file, and is quiet on a terminal unless asked; `createCliTelemetry({ envPrefix, dsn, posthogKey, posthogHost })` returns Sentry error reporting and PostHog analytics behind `<PREFIX>_TELEMETRY=false`. `@theholocron/observability` is an optional peer. |
|
|
22
|
-
| `/config` | A `<name>.config.{ts,js,mjs,cjs,json}` for a new CLI: `createConfigSystem({ name, derive?, resolve, merge })` returns `defineConfig`, `loadConfig` (walks up to `.git`) and `compose()` (dedupe by `id`, all unmet `requires` in one `ConfigError`, per-key merge). Strategies: `lastWins`, `shallowMerge`, `union`, `mergeByKey`. `@theholocron/datapad` is an optional peer.
|
|
22
|
+
| `/config` | A `<name>.config.{ts,js,mjs,cjs,json}` for a new CLI: `createConfigSystem({ name, areas?, place?, derive?, resolve, merge })` returns `defineConfig`, `loadConfig` (walks up to `.git`) and `compose()` (dedupe by `id`, all unmet `requires` in one `ConfigError`, per-key merge). Strategies: `lastWins`, `shallowMerge`, `union`, `mergeByKey`. `@theholocron/datapad` is an optional peer. |
|
|
23
23
|
| `/plugins` | A plugin system for a new CLI: `createPluginSystem({ packagePrefix, providers, communityPrefix?, configFile?, pluginOptions?, preload? })` returns a `PluginLoader` class and `resolvePackage`. `load()` imports each configured provider's package (from the working directory first, importer injectable), calls its `createPlugin(options)` and fills a registry typed by your capability map: `get(key)` is one implementation for a `single` capability and an array for a `many` one. A package may export a capability config (`{ provider, options? }`) whose preset options sit under the project's. A failing provider is recorded in `loadFailures()` and `get` rethrows its error; `load()` never throws for one. Also `assertPluginsResolvable`, `isModuleNotFound`, `resolvePluginPackage`, `defaultImporter` and `LoaderError`. |
|
|
24
24
|
| `/flags` | The options every command of a tool takes: `addGlobalOptions(parser, { describe?, cwd? })` declares `--dry-run`, a repeatable `--token` and `--cwd` once on the root; `tokenContext(values, report)` parses the `--token` values and reports a bad one without a stack trace; `groupMenu(parent, open)` is the hidden default command that makes a bare group (`tool repo`) do something useful; `InferArgs` types a command's handler arguments from its builder. |
|
|
25
25
|
| `/checks` | `runCheckAgainstUrl(input, opts?)` runs an HTTP check with assertions (`status_code`, `response_time`, `body`, `header`) over `fetch` and returns `{ passed, failures, requestError? }`, with no monitoring vendor involved; `connectionProbe({ provider, url?, token, verify })` is a probe that tells a network problem from a credential problem (and `describeNetworkError` words a network failure). |
|
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigFileError, Loaded } from "@theholocron/datapad";
|
|
1
|
+
import { ConfigDirArea, ConfigFileError, Loaded } from "@theholocron/datapad";
|
|
2
2
|
/** How the values several fragments give one key combine. */
|
|
3
3
|
interface Strategy<V> {
|
|
4
4
|
/** The value to start from. A strategy without one leaves the key out of the result until a fragment sets it. */
|
|
@@ -27,6 +27,19 @@ export declare class ConfigError extends Error {
|
|
|
27
27
|
interface ConfigSystemOptions<Raw, Resolved, Composed> {
|
|
28
28
|
/** The CLI's name; its config file is `<name>.config.{ts,js,mjs,cjs,json}`. */
|
|
29
29
|
name: string;
|
|
30
|
+
/**
|
|
31
|
+
* The closed list of area names to read from the `.<name>/` directory beside the config (`.holocron/` for a CLI
|
|
32
|
+
* named `holocron`): `["notifications", "repo"]` reads `.holocron/notifications.{ts,js,mjs,cjs,json}` and
|
|
33
|
+
* `.holocron/repo.*`. Needs `place` to do anything with them. Files not on the list are never read.
|
|
34
|
+
*/
|
|
35
|
+
areas?: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* Put the loaded areas into the config, called after the config file is loaded and before `derive`, only when
|
|
38
|
+
* `areas` is set. `areas` holds one entry per area that has a file (none when the directory is missing), and `raw`
|
|
39
|
+
* is the config as loaded. Return the config with the areas placed; throw `ConfigError` when an area clashes with
|
|
40
|
+
* what the config already says (for example, a value set inline and in a file).
|
|
41
|
+
*/
|
|
42
|
+
place?: (areas: ConfigDirArea[], raw: Raw) => Raw | Promise<Raw>;
|
|
30
43
|
/** Fill in defaults on the loaded config (from `package.json`, git, other files) before it is resolved. */
|
|
31
44
|
derive?: (found: Loaded<Raw>) => Raw | Promise<Raw>;
|
|
32
45
|
/** Check the config and turn it into the shape the CLI works with; throw `ConfigError` when it is invalid. */
|
|
@@ -55,7 +68,8 @@ interface ConfigSystem<Raw, Resolved, Fragment extends ConfigFragment, Composed>
|
|
|
55
68
|
}
|
|
56
69
|
/**
|
|
57
70
|
* Build the config system of a new CLI: a `<name>.config.{ts,js,mjs,cjs,json}` file, a typing helper for it, a loader
|
|
58
|
-
* that walks up to the repo root, and a `compose()` that merges reusable fragments.
|
|
71
|
+
* that walks up to the repo root, and a `compose()` that merges reusable fragments. With `areas` and `place`, it also
|
|
72
|
+
* reads the files of a `.<name>/` directory beside the config and hands them to `place` before `derive`.
|
|
59
73
|
*
|
|
60
74
|
* @example
|
|
61
75
|
* const { defineConfig, loadConfig, compose } = createConfigSystem<Raw, Resolved, Fragment, Composed>({
|
package/dist/config.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { ConfigFileError, ConfigFileError as ConfigFileError$1, loadConfigDir, loadConfigFile } from "@theholocron/datapad";
|
|
2
3
|
// src/config/config-error/config-error.ts
|
|
3
4
|
/**
|
|
4
5
|
* Thrown when a config is invalid, or when `compose()` is given fragments whose `requires` are not met. A caller that
|
|
@@ -38,7 +39,8 @@ function composeFragments(strategies, args) {
|
|
|
38
39
|
// src/config/create-config-system/create-config-system.ts
|
|
39
40
|
/**
|
|
40
41
|
* Build the config system of a new CLI: a `<name>.config.{ts,js,mjs,cjs,json}` file, a typing helper for it, a loader
|
|
41
|
-
* that walks up to the repo root, and a `compose()` that merges reusable fragments.
|
|
42
|
+
* that walks up to the repo root, and a `compose()` that merges reusable fragments. With `areas` and `place`, it also
|
|
43
|
+
* reads the files of a `.<name>/` directory beside the config and hands them to `place` before `derive`.
|
|
42
44
|
*
|
|
43
45
|
* @example
|
|
44
46
|
* const { defineConfig, loadConfig, compose } = createConfigSystem<Raw, Resolved, Fragment, Composed>({
|
|
@@ -48,16 +50,27 @@ function composeFragments(strategies, args) {
|
|
|
48
50
|
* });
|
|
49
51
|
*/
|
|
50
52
|
function createConfigSystem(options) {
|
|
51
|
-
const { name, derive, resolve, merge } = options;
|
|
53
|
+
const { name, areas, place, derive, resolve, merge } = options;
|
|
52
54
|
return {
|
|
53
55
|
defineConfig: (config) => config,
|
|
54
56
|
async loadConfig(cwd) {
|
|
55
|
-
|
|
57
|
+
let found = await loadConfigFile({
|
|
56
58
|
cwd,
|
|
57
59
|
name,
|
|
58
60
|
walkUp: true
|
|
59
61
|
});
|
|
60
62
|
if (!found) throw new ConfigFileError$1(`no ${name}.config.{ts,js,mjs,cjs,json} found in ${cwd}. Create one — see the README for the schema.`);
|
|
63
|
+
if (areas && place) {
|
|
64
|
+
const placed = await loadConfigDir({
|
|
65
|
+
cwd: dirname(found.filepath),
|
|
66
|
+
dir: `.${name}`,
|
|
67
|
+
areas
|
|
68
|
+
});
|
|
69
|
+
found = {
|
|
70
|
+
...found,
|
|
71
|
+
config: await place(placed, found.config)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
61
74
|
const raw = derive ? await derive(found) : found.config;
|
|
62
75
|
return {
|
|
63
76
|
resolved: resolve(raw),
|
package/dist/notifier.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
1
2
|
import chalk from "chalk";
|
|
2
3
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
4
|
// src/notifier/update-notifier/update-notifier.ts
|
|
5
5
|
const CACHE_FILE = "update-check.json";
|
|
6
6
|
const CACHE_TTL_MS = 864e5;
|
package/dist/secrets.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { n as parseTokenArgs, t as TokenParseError } from "./token-args-BgrCq_kK
|
|
|
2
2
|
import { t as describeError } from "./describe-error-y4wLzFzj.mjs";
|
|
3
3
|
import { t as waitForEnter } from "./wait-for-enter-BeC-qTm3.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
|
+
import { basename, dirname, join } from "node:path";
|
|
5
6
|
import { execFileSync } from "node:child_process";
|
|
6
7
|
import { closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, renameSync, unlinkSync, writeSync } from "node:fs";
|
|
7
|
-
import { basename, dirname, join } from "node:path";
|
|
8
8
|
import { randomBytes } from "node:crypto";
|
|
9
9
|
import { parse } from "dotenv";
|
|
10
10
|
// src/secrets/auth-error/auth-error.ts
|
package/dist/testing.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { dirname, join, sep } from "node:path";
|
|
1
2
|
import { execFileSync, spawn } from "node:child_process";
|
|
2
3
|
import { existsSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
3
|
-
import { dirname, join, sep } from "node:path";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/kyber",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.349",
|
|
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,11 +105,11 @@
|
|
|
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.
|
|
108
|
+
"@theholocron/datapad": "5.0.0-alpha.349",
|
|
109
|
+
"@theholocron/observability": "0.7.0-alpha.1",
|
|
109
110
|
"@theholocron/eslint-config": "^8.9.0-alpha.8",
|
|
110
111
|
"@theholocron/tsdown-config": "^8.9.0-alpha.8",
|
|
111
112
|
"@theholocron/tsconfig": "^8.9.0-alpha.8",
|
|
112
|
-
"@theholocron/observability": "0.7.0-alpha.1",
|
|
113
113
|
"@theholocron/vitest-config": "^8.9.0-alpha.8"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
@@ -121,8 +121,8 @@
|
|
|
121
121
|
"dotenv": "^17.0.0",
|
|
122
122
|
"ora": "^9.0.0",
|
|
123
123
|
"yargs": "^18.0.0",
|
|
124
|
-
"@theholocron/
|
|
125
|
-
"@theholocron/
|
|
124
|
+
"@theholocron/observability": "^0.7.0-alpha.1",
|
|
125
|
+
"@theholocron/datapad": "^5.0.0-alpha.349"
|
|
126
126
|
},
|
|
127
127
|
"peerDependenciesMeta": {
|
|
128
128
|
"@inquirer/prompts": {
|