@theholocron/cli 5.0.0-alpha.336 → 5.0.0-alpha.337
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 +427 -336
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +13 -35
- package/dist/index.mjs +138 -96
- package/package.json +7 -6
package/dist/index.d.mts
CHANGED
|
@@ -79,38 +79,25 @@ export declare function createFeatureResolver(config: FeatureResolverConfig): Fe
|
|
|
79
79
|
/**
|
|
80
80
|
* Keyring-backed bootstrap credential store.
|
|
81
81
|
*
|
|
82
|
-
* Every holocron plugin's bootstrap token (the one it needs before it
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* subcommands; consulted at position 4 in every plugin's auth
|
|
86
|
-
* precedence chain (after --token / HOLOCRON_<X>_TOKEN / <native>_TOKEN).
|
|
82
|
+
* Every holocron plugin's bootstrap token (the one it needs before it can talk to its vendor's API) can be stored in
|
|
83
|
+
* the OS keyring under a single reverse-DNS service scope. Managed via `holocron auth` subcommands; consulted at
|
|
84
|
+
* position 4 in every plugin's auth precedence chain (after --token / HOLOCRON_<X>_TOKEN / <native>_TOKEN).
|
|
87
85
|
*
|
|
88
|
-
*
|
|
86
|
+
* The keyring itself, with its best-effort failure model and its per-process cache, is `createKeyring` in
|
|
87
|
+
* `@theholocron/kyber/secrets`; this file only names the service and keeps the function names the CLI uses.
|
|
89
88
|
*
|
|
90
|
-
*
|
|
91
|
-
* supported credential store (some Linux CI images, sandboxed
|
|
92
|
-
* environments) will throw from the underlying library. Every export
|
|
93
|
-
* here catches and returns a null/empty result rather than propagating
|
|
94
|
-
* — the plugin's precedence chain then falls through to
|
|
95
|
-
* env-var-only paths, which is exactly how CI is meant to work.
|
|
89
|
+
* See `docs/wiki/specifications/tech-auth-bootstrap.spec.md` for the design rationale.
|
|
96
90
|
*/
|
|
97
91
|
/**
|
|
98
|
-
* Forget every token `getToken` has remembered, so the next read asks the keyring again.
|
|
99
|
-
*
|
|
100
|
-
* changed from outside the process.
|
|
92
|
+
* Forget every token `getToken` has remembered, so the next read asks the keyring again. For a test, or after the
|
|
93
|
+
* keyring was changed from outside the process.
|
|
101
94
|
*/
|
|
102
95
|
export declare function clearTokenCache(): void;
|
|
103
|
-
/**
|
|
104
|
-
* Store or overwrite a bootstrap token for a provider. Returns true on
|
|
105
|
-
* success, false when the underlying keyring is unsupported or errored.
|
|
106
|
-
*/
|
|
96
|
+
/** Store or overwrite a bootstrap token for a provider. Returns true on success, false when the keyring is unsupported or errored. */
|
|
107
97
|
export declare function setToken(provider: string, token: string): boolean;
|
|
108
98
|
/**
|
|
109
|
-
* Read the bootstrap token for a provider. Returns `null` for both
|
|
110
|
-
*
|
|
111
|
-
* same way (fall through to env-var precedence). The answer is
|
|
112
|
-
* remembered for the rest of the process, so the keyring is asked once
|
|
113
|
-
* per provider.
|
|
99
|
+
* Read the bootstrap token for a provider. Returns `null` for both "not stored" and "keyring unavailable", so callers
|
|
100
|
+
* fall through to env-var precedence. The answer is remembered for the rest of the process.
|
|
114
101
|
*/
|
|
115
102
|
export declare function getToken(provider: string): string | null;
|
|
116
103
|
/**
|
|
@@ -118,18 +105,9 @@ export declare function getToken(provider: string): string | null;
|
|
|
118
105
|
* cannot be reached alike; a caller that must tell an outage from an empty keyring asks this first.
|
|
119
106
|
*/
|
|
120
107
|
export declare function isKeyringAvailable(): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Delete a stored token. Returns true when a token was removed, false
|
|
123
|
-
* when there was nothing to delete or the keyring is unavailable.
|
|
124
|
-
* Distinguishing the two cases isn't worth the surface area — the
|
|
125
|
-
* command output makes the situation clear either way.
|
|
126
|
-
*/
|
|
108
|
+
/** Delete a stored token. Returns true when a token was removed, false when there was nothing to delete or the keyring is unavailable. */
|
|
127
109
|
export declare function deleteToken(provider: string): boolean;
|
|
128
|
-
/**
|
|
129
|
-
* List provider slugs with a stored token in this service scope.
|
|
130
|
-
* Uses the library's `findCredentials(service)` — supported on all
|
|
131
|
-
* platforms the underlying credential store supports.
|
|
132
|
-
*/
|
|
110
|
+
/** List the provider slugs that have a stored token under the holocron service scope. */
|
|
133
111
|
export declare function listStoredProviders(): string[];
|
|
134
112
|
/** One line a probe reports: `info` for a fact, `ok` / `fail` for a result, `heading` to title the rows that follow. */
|
|
135
113
|
interface ProbeRow {
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { CARDINALITY, ElevationRequiredError, MissingTokenError, ProviderApiError, REQUIRED_CAPABILITIES, WebhookVerificationError, isMulti } from "./plugin/capabilities.mjs";
|
|
2
2
|
import { a as resolveEntry, i as resolveConfig, n as ConfigError, o as resolvePluginPackage, r as credentialsEnvironment, t as compose } from "./compose-DU_NeIR0.mjs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
import { AuthError, createResolveToken as createResolveToken$1, createRestClient } from "@theholocron/http-client";
|
|
5
|
+
import { basename, dirname, join } from "node:path";
|
|
6
|
+
import "dotenv";
|
|
4
7
|
import { createEnvLookup, withEnvPrefix } from "@theholocron/env-utils/lookup";
|
|
5
8
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
6
9
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
7
|
-
import { basename, dirname, join } from "node:path";
|
|
8
10
|
import chalk from "chalk";
|
|
11
|
+
import "ora";
|
|
9
12
|
import { lookup } from "node:dns/promises";
|
|
10
13
|
import { readPackageJson } from "@theholocron/pkg-utils";
|
|
11
14
|
import { loadTasksConfig } from "@theholocron/astromech/config";
|
|
12
15
|
import { ConfigFileError, ConfigFileError as ConfigFileError$1, loadConfigFile } from "@theholocron/datapad";
|
|
13
16
|
import { readGitRemote } from "@theholocron/git-utils";
|
|
14
|
-
//
|
|
15
|
-
/** Singleton env for simple global lookups throughout the CLI. */
|
|
16
|
-
const env = createEnvLookup();
|
|
17
|
-
withEnvPrefix(env, "HOLOCRON");
|
|
18
|
-
/**
|
|
19
|
-
* Create an injectable env for commands that accept a fake env in tests.
|
|
20
|
-
* Pass `input.env` when available, falls back to `process.env`.
|
|
21
|
-
*/
|
|
22
|
-
function makeEnv(source) {
|
|
23
|
-
return createEnvLookup(source);
|
|
24
|
-
}
|
|
25
|
-
// src/auth/credential-store/credential-store.ts
|
|
17
|
+
// ../kyber/dist/secrets.mjs
|
|
26
18
|
/**
|
|
27
19
|
* The variables the `credentials` providers returned, kept for the life of the process.
|
|
28
20
|
*
|
|
@@ -45,114 +37,156 @@ function getCredential(...names) {
|
|
|
45
37
|
if (value) return value;
|
|
46
38
|
}
|
|
47
39
|
}
|
|
48
|
-
|
|
40
|
+
function loadBinding() {
|
|
41
|
+
try {
|
|
42
|
+
return createRequire(import.meta.url)("@napi-rs/keyring");
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
49
47
|
/**
|
|
50
|
-
*
|
|
48
|
+
* A tool's secrets in the OS keyring, under one service name.
|
|
51
49
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
50
|
+
* Keyring access is best-effort. Platforms without a supported credential store (some Linux CI images, sandboxed
|
|
51
|
+
* environments) throw from the underlying library, and `@napi-rs/keyring` is an optional peer that may not be installed
|
|
52
|
+
* at all. Every method catches that and answers `null`, `false` or an empty list rather than propagating, so a caller's
|
|
53
|
+
* chain (a flag, then the environment, then the keyring) falls through to the paths that do work, which is how CI is
|
|
54
|
+
* meant to run.
|
|
57
55
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* Failure model: keyring access is best-effort. Platforms without a
|
|
61
|
-
* supported credential store (some Linux CI images, sandboxed
|
|
62
|
-
* environments) will throw from the underlying library. Every export
|
|
63
|
-
* here catches and returns a null/empty result rather than propagating
|
|
64
|
-
* — the plugin's precedence chain then falls through to
|
|
65
|
-
* env-var-only paths, which is exactly how CI is meant to work.
|
|
56
|
+
* Reads are remembered in memory only, for the life of the process. A cache that outlived the process would mean writing
|
|
57
|
+
* secrets somewhere else, which is what the keyring is there to avoid.
|
|
66
58
|
*/
|
|
67
|
-
|
|
59
|
+
function createKeyring(options) {
|
|
60
|
+
const { service } = options;
|
|
61
|
+
const cache = /* @__PURE__ */ new Map();
|
|
62
|
+
let binding = options.binding;
|
|
63
|
+
const loaded = () => {
|
|
64
|
+
if (binding === void 0) binding = loadBinding();
|
|
65
|
+
return binding;
|
|
66
|
+
};
|
|
67
|
+
const entry = (account) => {
|
|
68
|
+
const b = loaded();
|
|
69
|
+
if (!b) throw new Error("no OS keyring available");
|
|
70
|
+
return new b.Entry(service, account);
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
get(account) {
|
|
74
|
+
if (cache.has(account)) return cache.get(account);
|
|
75
|
+
let secret;
|
|
76
|
+
try {
|
|
77
|
+
secret = entry(account).getPassword();
|
|
78
|
+
} catch {
|
|
79
|
+
secret = null;
|
|
80
|
+
}
|
|
81
|
+
cache.set(account, secret);
|
|
82
|
+
return secret;
|
|
83
|
+
},
|
|
84
|
+
set(account, secret) {
|
|
85
|
+
try {
|
|
86
|
+
entry(account).setPassword(secret);
|
|
87
|
+
cache.set(account, secret);
|
|
88
|
+
return true;
|
|
89
|
+
} catch {
|
|
90
|
+
cache.delete(account);
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
delete(account) {
|
|
95
|
+
try {
|
|
96
|
+
const removed = entry(account).deletePassword();
|
|
97
|
+
cache.set(account, null);
|
|
98
|
+
return removed;
|
|
99
|
+
} catch {
|
|
100
|
+
cache.delete(account);
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
list() {
|
|
105
|
+
try {
|
|
106
|
+
const b = loaded();
|
|
107
|
+
return b ? b.findCredentials(service).map((c) => c.account) : [];
|
|
108
|
+
} catch {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
isAvailable() {
|
|
113
|
+
try {
|
|
114
|
+
const b = loaded();
|
|
115
|
+
if (!b) return false;
|
|
116
|
+
b.findCredentials(service);
|
|
117
|
+
return true;
|
|
118
|
+
} catch {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
clearCache() {
|
|
123
|
+
cache.clear();
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// src/env/env.ts
|
|
128
|
+
/** Singleton env for simple global lookups throughout the CLI. */
|
|
129
|
+
const env = createEnvLookup();
|
|
130
|
+
withEnvPrefix(env, "HOLOCRON");
|
|
68
131
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
132
|
+
* Create an injectable env for commands that accept a fake env in tests.
|
|
133
|
+
* Pass `input.env` when available, falls back to `process.env`.
|
|
134
|
+
*/
|
|
135
|
+
function makeEnv(source) {
|
|
136
|
+
return createEnvLookup(source);
|
|
137
|
+
}
|
|
138
|
+
// src/auth/keyring/keyring.ts
|
|
139
|
+
/**
|
|
140
|
+
* Keyring-backed bootstrap credential store.
|
|
141
|
+
*
|
|
142
|
+
* Every holocron plugin's bootstrap token (the one it needs before it can talk to its vendor's API) can be stored in
|
|
143
|
+
* the OS keyring under a single reverse-DNS service scope. Managed via `holocron auth` subcommands; consulted at
|
|
144
|
+
* position 4 in every plugin's auth precedence chain (after --token / HOLOCRON_<X>_TOKEN / <native>_TOKEN).
|
|
72
145
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
146
|
+
* The keyring itself, with its best-effort failure model and its per-process cache, is `createKeyring` in
|
|
147
|
+
* `@theholocron/kyber/secrets`; this file only names the service and keeps the function names the CLI uses.
|
|
148
|
+
*
|
|
149
|
+
* See `docs/wiki/specifications/tech-auth-bootstrap.spec.md` for the design rationale.
|
|
75
150
|
*/
|
|
76
|
-
const
|
|
151
|
+
const keyring = createKeyring({
|
|
152
|
+
service: "com.theholocron.cli",
|
|
153
|
+
binding: {
|
|
154
|
+
Entry,
|
|
155
|
+
findCredentials
|
|
156
|
+
}
|
|
157
|
+
});
|
|
77
158
|
/**
|
|
78
|
-
* Forget every token `getToken` has remembered, so the next read asks the keyring again.
|
|
79
|
-
*
|
|
80
|
-
* changed from outside the process.
|
|
159
|
+
* Forget every token `getToken` has remembered, so the next read asks the keyring again. For a test, or after the
|
|
160
|
+
* keyring was changed from outside the process.
|
|
81
161
|
*/
|
|
82
162
|
function clearTokenCache() {
|
|
83
|
-
|
|
163
|
+
keyring.clearCache();
|
|
84
164
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Store or overwrite a bootstrap token for a provider. Returns true on
|
|
87
|
-
* success, false when the underlying keyring is unsupported or errored.
|
|
88
|
-
*/
|
|
165
|
+
/** Store or overwrite a bootstrap token for a provider. Returns true on success, false when the keyring is unsupported or errored. */
|
|
89
166
|
function setToken(provider, token) {
|
|
90
|
-
|
|
91
|
-
new Entry(SERVICE, provider).setPassword(token);
|
|
92
|
-
cache.set(provider, token);
|
|
93
|
-
return true;
|
|
94
|
-
} catch {
|
|
95
|
-
cache.delete(provider);
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
167
|
+
return keyring.set(provider, token);
|
|
98
168
|
}
|
|
99
169
|
/**
|
|
100
|
-
* Read the bootstrap token for a provider. Returns `null` for both
|
|
101
|
-
*
|
|
102
|
-
* same way (fall through to env-var precedence). The answer is
|
|
103
|
-
* remembered for the rest of the process, so the keyring is asked once
|
|
104
|
-
* per provider.
|
|
170
|
+
* Read the bootstrap token for a provider. Returns `null` for both "not stored" and "keyring unavailable", so callers
|
|
171
|
+
* fall through to env-var precedence. The answer is remembered for the rest of the process.
|
|
105
172
|
*/
|
|
106
173
|
function getToken(provider) {
|
|
107
|
-
|
|
108
|
-
let token;
|
|
109
|
-
try {
|
|
110
|
-
token = new Entry(SERVICE, provider).getPassword();
|
|
111
|
-
} catch {
|
|
112
|
-
token = null;
|
|
113
|
-
}
|
|
114
|
-
cache.set(provider, token);
|
|
115
|
-
return token;
|
|
174
|
+
return keyring.get(provider);
|
|
116
175
|
}
|
|
117
176
|
/**
|
|
118
177
|
* Whether the OS keyring can be used at all. `getToken` answers `null` for a missing entry and for a keyring that
|
|
119
178
|
* cannot be reached alike; a caller that must tell an outage from an empty keyring asks this first.
|
|
120
179
|
*/
|
|
121
180
|
function isKeyringAvailable() {
|
|
122
|
-
|
|
123
|
-
findCredentials(SERVICE);
|
|
124
|
-
return true;
|
|
125
|
-
} catch {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
181
|
+
return keyring.isAvailable();
|
|
128
182
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Delete a stored token. Returns true when a token was removed, false
|
|
131
|
-
* when there was nothing to delete or the keyring is unavailable.
|
|
132
|
-
* Distinguishing the two cases isn't worth the surface area — the
|
|
133
|
-
* command output makes the situation clear either way.
|
|
134
|
-
*/
|
|
183
|
+
/** Delete a stored token. Returns true when a token was removed, false when there was nothing to delete or the keyring is unavailable. */
|
|
135
184
|
function deleteToken(provider) {
|
|
136
|
-
|
|
137
|
-
const removed = new Entry(SERVICE, provider).deletePassword();
|
|
138
|
-
cache.set(provider, null);
|
|
139
|
-
return removed;
|
|
140
|
-
} catch {
|
|
141
|
-
cache.delete(provider);
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
185
|
+
return keyring.delete(provider);
|
|
144
186
|
}
|
|
145
|
-
/**
|
|
146
|
-
* List provider slugs with a stored token in this service scope.
|
|
147
|
-
* Uses the library's `findCredentials(service)` — supported on all
|
|
148
|
-
* platforms the underlying credential store supports.
|
|
149
|
-
*/
|
|
187
|
+
/** List the provider slugs that have a stored token under the holocron service scope. */
|
|
150
188
|
function listStoredProviders() {
|
|
151
|
-
|
|
152
|
-
return findCredentials(SERVICE).map((c) => c.account);
|
|
153
|
-
} catch {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
189
|
+
return keyring.list();
|
|
156
190
|
}
|
|
157
191
|
// src/auth/auth-resolver/auth-resolver.ts
|
|
158
192
|
/** Wraps `createResolveToken` from `@theholocron/http` and injects the
|
|
@@ -188,16 +222,24 @@ function createFeatureResolver(config) {
|
|
|
188
222
|
keyringKey: config.keyringKey
|
|
189
223
|
} });
|
|
190
224
|
}
|
|
191
|
-
//
|
|
225
|
+
// ../kyber/dist/ui.mjs
|
|
226
|
+
/** Formats a message with a status marker and colour: one helper per kind of line a command prints. */
|
|
192
227
|
const style = {
|
|
228
|
+
/** A green `✓` for something that worked. */
|
|
193
229
|
success: (msg) => `${chalk.green("✓")} ${msg}`,
|
|
230
|
+
/** A yellow `⚠` for something worth a second look. */
|
|
194
231
|
warn: (msg) => `${chalk.yellow("⚠")} ${msg}`,
|
|
232
|
+
/** A red `✗` for something that failed. */
|
|
195
233
|
fail: (msg) => `${chalk.red("✗")} ${msg}`,
|
|
234
|
+
/** A cyan `→` for a step being taken. */
|
|
196
235
|
step: (msg) => `${chalk.cyan("→")} ${msg}`,
|
|
197
236
|
/** A dim `·` marker for a row that's neither a pass nor a failure — loaded but inactive, or skipped. */
|
|
198
237
|
skip: (msg) => chalk.dim(`· ${msg}`),
|
|
238
|
+
/** Dimmed text for a suggestion or a next step. */
|
|
199
239
|
hint: (msg) => chalk.dim(msg),
|
|
240
|
+
/** Dimmed text for detail that should recede. */
|
|
200
241
|
dim: (msg) => chalk.dim(msg),
|
|
242
|
+
/** Bold text for a heading. */
|
|
201
243
|
header: (msg) => chalk.bold(msg)
|
|
202
244
|
};
|
|
203
245
|
// src/plugin/connection-probe/connection-probe.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/cli",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.337",
|
|
4
4
|
"description": "The Holocron CLI - a pluggable, capability-based orchestrator for spinning up and operating software projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"posthog-node": "^5.61.1",
|
|
55
55
|
"tsx": "4.23.15",
|
|
56
56
|
"yargs": "^18.1.0",
|
|
57
|
-
"@theholocron/astromech": "5.0.0-alpha.
|
|
58
|
-
"@theholocron/datapad": "5.0.0-alpha.336",
|
|
57
|
+
"@theholocron/astromech": "5.0.0-alpha.337",
|
|
59
58
|
"@theholocron/env-utils": "^1.17.0-alpha.1",
|
|
60
59
|
"@theholocron/fs-utils": "^1.17.0-alpha.1",
|
|
61
60
|
"@theholocron/git-utils": "^1.17.0-alpha.1",
|
|
62
|
-
"@theholocron/http-client": "^1.58.0-alpha.7",
|
|
63
61
|
"@theholocron/github-client": "^1.58.0-alpha.7",
|
|
64
|
-
"@theholocron/
|
|
62
|
+
"@theholocron/http-client": "^1.58.0-alpha.7",
|
|
65
63
|
"@theholocron/misc-utils": "^1.17.0-alpha.1",
|
|
64
|
+
"@theholocron/pkg-utils": "^1.17.0-alpha.1",
|
|
66
65
|
"@theholocron/observability": "^0.7.0-alpha.1",
|
|
67
|
-
"@theholocron/
|
|
66
|
+
"@theholocron/json-utils": "^1.17.0-alpha.1",
|
|
67
|
+
"@theholocron/datapad": "5.0.0-alpha.337"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/node": "^26",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"vitest": "^5.0.5",
|
|
80
80
|
"@theholocron/dagobah": "0.0.0",
|
|
81
81
|
"@theholocron/eslint-config": "^8.9.0-alpha.8",
|
|
82
|
+
"@theholocron/kyber": "^0.0.0",
|
|
82
83
|
"@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.8",
|
|
83
84
|
"@theholocron/tsconfig": "^8.9.0-alpha.8",
|
|
84
85
|
"@theholocron/vitest-config": "^8.9.0-alpha.8"
|