@theholocron/cli 5.0.0-alpha.336 → 5.0.0-alpha.338
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 +508 -1657
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +13 -35
- package/dist/index.mjs +85 -128
- package/package.json +5 -4
package/dist/cli.mjs
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { closeSync,
|
|
3
|
+
import { closeSync, copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { addGlobalOptions, groupMenu, tokenContext } from "@theholocron/kyber/flags";
|
|
4
5
|
import { LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, redactObject } from "@theholocron/observability/core";
|
|
5
6
|
import yargs from "yargs";
|
|
6
7
|
import { hideBin } from "yargs/helpers";
|
|
7
8
|
import { createLogger, isCI, parseLogLevel, resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
8
|
-
import { AuthError, ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient, onRetry } from "@theholocron/http-client";
|
|
9
|
+
import { AuthError, ProviderApiError, ProviderApiError as ProviderApiError$1, createResolveToken, createRestClient, onRetry } from "@theholocron/http-client";
|
|
10
|
+
import { DOTENV_FILE, createKeyring, getCredential, hasCredentials, readDotenvFile, setCredentials } from "@theholocron/kyber/secrets";
|
|
9
11
|
import { createEnvLookup, firstEnv, withEnvPrefix } from "@theholocron/env-utils/lookup";
|
|
10
12
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
13
|
+
import { createProgress, progressEnabled, withProgress } from "@theholocron/kyber/ui";
|
|
11
14
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
12
|
-
import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
13
|
-
import { parse } from "dotenv";
|
|
14
|
-
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
15
|
-
import chalk from "chalk";
|
|
16
|
-
import search from "@inquirer/search";
|
|
17
|
-
import ora from "ora";
|
|
18
|
-
import { Separator, checkbox, confirm, input, password, select } from "@inquirer/prompts";
|
|
19
|
-
import { createInterface } from "node:readline";
|
|
20
15
|
import { homedir, hostname, tmpdir, userInfo } from "node:os";
|
|
21
16
|
import { PostHogSink } from "@theholocron/observability/analytics";
|
|
22
17
|
import { SentrySink } from "@theholocron/observability/errors";
|
|
18
|
+
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
19
|
+
import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
23
20
|
import { KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, checkPackageScripts, createAlexignore, createAlexrc, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, frozenReusablePaths, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, mergeScripts, readWorkspacePackages, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, workflowFile, workflowKey, workflowKeys, workspacePackages } from "@theholocron/astromech";
|
|
24
21
|
import { loadTasksConfig } from "@theholocron/astromech/config";
|
|
22
|
+
import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
25
23
|
import { ConfigFileError, loadConfigFile } from "@theholocron/datapad";
|
|
26
24
|
import { readGitRemote, updateGitignore } from "@theholocron/git-utils";
|
|
27
25
|
import { bumpCatalogPins, discoverWorkspacePackages, parseCatalogs, readPackageJson, readPackageJsonSync, resolveWorkspaceGlobs } from "@theholocron/pkg-utils";
|
|
@@ -29,11 +27,38 @@ import { errorMessage } from "@theholocron/misc-utils";
|
|
|
29
27
|
import { pathToFileURL } from "node:url";
|
|
30
28
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
31
29
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
32
|
-
import {
|
|
30
|
+
import { serveHandler } from "@theholocron/dagobah";
|
|
33
31
|
import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
32
|
+
import { createServer } from "node:http";
|
|
34
33
|
import { ADR_DIR, ADR_STATUSES, CLOSED_STATUSES, SPEC_DIRS, SPEC_STATUSES, WITHDRAWN_STATE, assignSpecIds, checkSpecs, classifySpecPath, discussionBody, discussionIdLine, discussionPrLine, discussionTitle, evaluateDocsPresence, isAddedDocComment, isFeat, packageOf, parseFrontmatter, parseSkipDocs, reconcileSpecStatus, specSummary, specTitle, updateFrontmatter } from "@theholocron/astromech/repo-validation";
|
|
35
34
|
import { lintCommitMsgFile } from "@theholocron/astromech/lint";
|
|
36
35
|
import { createGitHubClient } from "@theholocron/github-client";
|
|
36
|
+
import { checkForUpdates } from "@theholocron/kyber/notifier";
|
|
37
|
+
// \0rolldown/runtime.js
|
|
38
|
+
var __defProp = Object.defineProperty;
|
|
39
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
40
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
41
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
42
|
+
var __exportAll = (all, no_symbols) => {
|
|
43
|
+
let target = {};
|
|
44
|
+
for (var name in all) __defProp(target, name, {
|
|
45
|
+
get: all[name],
|
|
46
|
+
enumerable: true
|
|
47
|
+
});
|
|
48
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
49
|
+
return target;
|
|
50
|
+
};
|
|
51
|
+
var __copyProps = (to, from, except, desc) => {
|
|
52
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
53
|
+
key = keys[i];
|
|
54
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
55
|
+
get: ((k) => from[k]).bind(null, key),
|
|
56
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return to;
|
|
60
|
+
};
|
|
61
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
37
62
|
// src/env/env.ts
|
|
38
63
|
/** Singleton env for simple global lookups throughout the CLI. */
|
|
39
64
|
const env = createEnvLookup();
|
|
@@ -51,139 +76,73 @@ const holocronEnv = withEnvPrefix(env, "HOLOCRON");
|
|
|
51
76
|
function makeEnv(source) {
|
|
52
77
|
return createEnvLookup(source);
|
|
53
78
|
}
|
|
54
|
-
// src/auth/credential-store/credential-store.ts
|
|
55
|
-
/**
|
|
56
|
-
* The variables the `credentials` providers returned, kept for the life of the process.
|
|
57
|
-
*
|
|
58
|
-
* The plugin loader reads each provider once (`setCredentials`), and the token resolvers look a token up here
|
|
59
|
-
* (`getCredential`) after the flag and the process environment and before the keyring. It is in memory only: the
|
|
60
|
-
* values were already in this process when the provider returned them, and nothing here writes them anywhere.
|
|
61
|
-
*
|
|
62
|
-
* A source is one provider's answer for one environment. They are kept in the order they were set, which is the
|
|
63
|
-
* order `holocron.config` lists the providers, and the first source that has a value wins.
|
|
64
|
-
*/
|
|
65
|
-
const sources = /* @__PURE__ */ new Map();
|
|
66
|
-
/** Remember `variables` as what the source `source` returned. Setting a source again replaces its variables. */
|
|
67
|
-
function setCredentials(source, variables) {
|
|
68
|
-
sources.set(source, variables);
|
|
69
|
-
}
|
|
70
|
-
/** Whether the source `source` has been read already, so a second loader in the same process does not read it again. */
|
|
71
|
-
function hasCredentials(source) {
|
|
72
|
-
return sources.has(source);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* The first non-empty value for any of `names`, from the first source that has one. Sources are tried in the order
|
|
76
|
-
* they were set; within a source the names are tried in the order given (the project's own variable name before the
|
|
77
|
-
* vendor's). `undefined` when no source has one.
|
|
78
|
-
*/
|
|
79
|
-
function getCredential(...names) {
|
|
80
|
-
for (const variables of sources.values()) for (const name of names) {
|
|
81
|
-
const value = variables[name];
|
|
82
|
-
if (value) return value;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
79
|
// src/auth/keyring/keyring.ts
|
|
86
80
|
/**
|
|
87
81
|
* Keyring-backed bootstrap credential store.
|
|
88
82
|
*
|
|
89
|
-
* Every holocron plugin's bootstrap token (the one it needs before it
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* subcommands; consulted at position 4 in every plugin's auth
|
|
93
|
-
* precedence chain (after --token / HOLOCRON_<X>_TOKEN / <native>_TOKEN).
|
|
94
|
-
*
|
|
95
|
-
* See `docs/wiki/specifications/tech-auth-bootstrap.spec.md` for the design rationale.
|
|
83
|
+
* Every holocron plugin's bootstrap token (the one it needs before it can talk to its vendor's API) can be stored in
|
|
84
|
+
* the OS keyring under a single reverse-DNS service scope. Managed via `holocron auth` subcommands; consulted at
|
|
85
|
+
* position 4 in every plugin's auth precedence chain (after --token / HOLOCRON_<X>_TOKEN / <native>_TOKEN).
|
|
96
86
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* environments) will throw from the underlying library. Every export
|
|
100
|
-
* here catches and returns a null/empty result rather than propagating
|
|
101
|
-
* — the plugin's precedence chain then falls through to
|
|
102
|
-
* env-var-only paths, which is exactly how CI is meant to work.
|
|
103
|
-
*/
|
|
104
|
-
const SERVICE = "com.theholocron.cli";
|
|
105
|
-
/**
|
|
106
|
-
* What `getToken` has already read, by provider, for the life of this process. A miss (`null`) is remembered too, so
|
|
107
|
-
* a token that is not stored, or a keyring that is unavailable, is asked about once, not on every lookup. The OS
|
|
108
|
-
* keyring can prompt on each read, and several resolvers ask for the same entry in one command.
|
|
87
|
+
* The keyring itself, with its best-effort failure model and its per-process cache, is `createKeyring` in
|
|
88
|
+
* `@theholocron/kyber/secrets`; this file only names the service and keeps the function names the CLI uses.
|
|
109
89
|
*
|
|
110
|
-
*
|
|
111
|
-
* what the keyring is there to avoid.
|
|
90
|
+
* See `docs/wiki/specifications/tech-auth-bootstrap.spec.md` for the design rationale.
|
|
112
91
|
*/
|
|
113
|
-
const
|
|
92
|
+
const keyring = createKeyring({
|
|
93
|
+
service: "com.theholocron.cli",
|
|
94
|
+
binding: {
|
|
95
|
+
Entry,
|
|
96
|
+
findCredentials
|
|
97
|
+
}
|
|
98
|
+
});
|
|
114
99
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
100
|
+
* Forget every token `getToken` has remembered, so the next read asks the keyring again. For a test, or after the
|
|
101
|
+
* keyring was changed from outside the process.
|
|
117
102
|
*/
|
|
103
|
+
function clearTokenCache() {
|
|
104
|
+
keyring.clearCache();
|
|
105
|
+
}
|
|
106
|
+
/** Store or overwrite a bootstrap token for a provider. Returns true on success, false when the keyring is unsupported or errored. */
|
|
118
107
|
function setToken(provider, token) {
|
|
119
|
-
|
|
120
|
-
new Entry(SERVICE, provider).setPassword(token);
|
|
121
|
-
cache.set(provider, token);
|
|
122
|
-
return true;
|
|
123
|
-
} catch {
|
|
124
|
-
cache.delete(provider);
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
108
|
+
return keyring.set(provider, token);
|
|
127
109
|
}
|
|
128
110
|
/**
|
|
129
|
-
* Read the bootstrap token for a provider. Returns `null` for both
|
|
130
|
-
*
|
|
131
|
-
* same way (fall through to env-var precedence). The answer is
|
|
132
|
-
* remembered for the rest of the process, so the keyring is asked once
|
|
133
|
-
* per provider.
|
|
111
|
+
* Read the bootstrap token for a provider. Returns `null` for both "not stored" and "keyring unavailable", so callers
|
|
112
|
+
* fall through to env-var precedence. The answer is remembered for the rest of the process.
|
|
134
113
|
*/
|
|
135
114
|
function getToken(provider) {
|
|
136
|
-
|
|
137
|
-
let token;
|
|
138
|
-
try {
|
|
139
|
-
token = new Entry(SERVICE, provider).getPassword();
|
|
140
|
-
} catch {
|
|
141
|
-
token = null;
|
|
142
|
-
}
|
|
143
|
-
cache.set(provider, token);
|
|
144
|
-
return token;
|
|
115
|
+
return keyring.get(provider);
|
|
145
116
|
}
|
|
146
117
|
/**
|
|
147
118
|
* Whether the OS keyring can be used at all. `getToken` answers `null` for a missing entry and for a keyring that
|
|
148
119
|
* cannot be reached alike; a caller that must tell an outage from an empty keyring asks this first.
|
|
149
120
|
*/
|
|
150
121
|
function isKeyringAvailable() {
|
|
151
|
-
|
|
152
|
-
findCredentials(SERVICE);
|
|
153
|
-
return true;
|
|
154
|
-
} catch {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
122
|
+
return keyring.isAvailable();
|
|
157
123
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Delete a stored token. Returns true when a token was removed, false
|
|
160
|
-
* when there was nothing to delete or the keyring is unavailable.
|
|
161
|
-
* Distinguishing the two cases isn't worth the surface area — the
|
|
162
|
-
* command output makes the situation clear either way.
|
|
163
|
-
*/
|
|
124
|
+
/** Delete a stored token. Returns true when a token was removed, false when there was nothing to delete or the keyring is unavailable. */
|
|
164
125
|
function deleteToken(provider) {
|
|
165
|
-
|
|
166
|
-
const removed = new Entry(SERVICE, provider).deletePassword();
|
|
167
|
-
cache.set(provider, null);
|
|
168
|
-
return removed;
|
|
169
|
-
} catch {
|
|
170
|
-
cache.delete(provider);
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
126
|
+
return keyring.delete(provider);
|
|
173
127
|
}
|
|
174
|
-
/**
|
|
175
|
-
* List provider slugs with a stored token in this service scope.
|
|
176
|
-
* Uses the library's `findCredentials(service)` — supported on all
|
|
177
|
-
* platforms the underlying credential store supports.
|
|
178
|
-
*/
|
|
128
|
+
/** List the provider slugs that have a stored token under the holocron service scope. */
|
|
179
129
|
function listStoredProviders() {
|
|
180
|
-
|
|
181
|
-
return findCredentials(SERVICE).map((c) => c.account);
|
|
182
|
-
} catch {
|
|
183
|
-
return [];
|
|
184
|
-
}
|
|
130
|
+
return keyring.list();
|
|
185
131
|
}
|
|
186
132
|
// src/auth/auth-resolver/auth-resolver.ts
|
|
133
|
+
/** Wraps `createResolveToken` from `@theholocron/http` and injects the
|
|
134
|
+
* system keyring so plugins stay at a one-liner call site. */
|
|
135
|
+
function createResolveToken$1(config) {
|
|
136
|
+
const storedOrKeyring = (provider) => getCredential(config.envName, config.vendorEnvName) ?? getToken(provider);
|
|
137
|
+
return Object.assign(createResolveToken({
|
|
138
|
+
...config,
|
|
139
|
+
getKeyringToken: storedOrKeyring
|
|
140
|
+
}), { token: {
|
|
141
|
+
envName: config.envName,
|
|
142
|
+
vendorEnvName: config.vendorEnvName,
|
|
143
|
+
keyringKey: config.keyringService
|
|
144
|
+
} });
|
|
145
|
+
}
|
|
187
146
|
/**
|
|
188
147
|
* Build a strict, single-feature token resolver.
|
|
189
148
|
*
|
|
@@ -204,241 +163,20 @@ function createFeatureResolver(config) {
|
|
|
204
163
|
keyringKey: config.keyringKey
|
|
205
164
|
} });
|
|
206
165
|
}
|
|
207
|
-
// src/auth/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
*
|
|
220
|
-
|
|
221
|
-
function createPrivateFile(path, text, write = writeSync) {
|
|
222
|
-
const fd = openSync(path, "wx", 384);
|
|
223
|
-
try {
|
|
224
|
-
write(fd, text);
|
|
225
|
-
fchmodSync(fd, 384);
|
|
226
|
-
const { dev, ino } = fstatSync(fd);
|
|
227
|
-
return {
|
|
228
|
-
dev,
|
|
229
|
-
ino,
|
|
230
|
-
fd
|
|
231
|
-
};
|
|
232
|
-
} catch (err) {
|
|
233
|
-
closeSync(fd);
|
|
234
|
-
try {
|
|
235
|
-
unlinkSync(path);
|
|
236
|
-
} catch {}
|
|
237
|
-
throw err;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
// src/auth/shred-file/shred-file.ts
|
|
241
|
-
/**
|
|
242
|
-
* Overwrite the file `identity` names with zeros, close it, and remove it from `path`, so the tokens it held are not
|
|
243
|
-
* left in a deleted-but-recoverable file.
|
|
244
|
-
*
|
|
245
|
-
* The overwrite goes through the descriptor held since the file was written, not through the path, so it zeroes that
|
|
246
|
-
* file wherever the path points now and never follows a symlink: a symlink or another file swapped in is not touched.
|
|
247
|
-
* The path itself is removed only if it is still that file (same device and inode, which the held descriptor keeps
|
|
248
|
-
* from being reused); otherwise it is left alone (`replaced`), so a file another process put there, or another
|
|
249
|
-
* export's file, survives. A path that is already gone is `missing`, not an error; any other failure to remove it
|
|
250
|
-
* throws, so the caller never reports a file as deleted while it is still there.
|
|
251
|
-
*
|
|
252
|
-
* The overwrite is best effort: a journaling or copy-on-write filesystem and an SSD may keep older blocks it does not
|
|
253
|
-
* reach, which is why the file is also kept private and short-lived. One that fails does not stop the removal.
|
|
254
|
-
* `remove` is how the path is deleted; it is a parameter so a test can look at the file just before it goes.
|
|
255
|
-
*/
|
|
256
|
-
function shredFile(path, identity, remove = unlinkSync) {
|
|
257
|
-
let missing = false;
|
|
258
|
-
let same = false;
|
|
259
|
-
try {
|
|
260
|
-
try {
|
|
261
|
-
const { size } = fstatSync(identity.fd);
|
|
262
|
-
writeSync(identity.fd, Buffer.alloc(size), 0, size, 0);
|
|
263
|
-
fsyncSync(identity.fd);
|
|
264
|
-
} catch {}
|
|
265
|
-
const stat = lstatSync(path);
|
|
266
|
-
same = stat.isFile() && stat.dev === identity.dev && stat.ino === identity.ino;
|
|
267
|
-
} catch (err) {
|
|
268
|
-
if (err.code !== "ENOENT") throw err;
|
|
269
|
-
missing = true;
|
|
270
|
-
} finally {
|
|
271
|
-
try {
|
|
272
|
-
closeSync(identity.fd);
|
|
273
|
-
} catch {}
|
|
274
|
-
}
|
|
275
|
-
if (missing) return "missing";
|
|
276
|
-
if (!same) return "replaced";
|
|
277
|
-
remove(path);
|
|
278
|
-
return "deleted";
|
|
279
|
-
}
|
|
280
|
-
// src/auth/credentials-file/credentials-file.ts
|
|
281
|
-
/**
|
|
282
|
-
* Write `text` to `path` as a file only its owner can read (mode `0600`), and return which file that is, with its
|
|
283
|
-
* descriptor still open, so cleanup can remove only it. Without `force` it will not replace a file that is already
|
|
284
|
-
* there. A write that fails removes the file it had just created, so a failed write never leaves plaintext tokens behind.
|
|
285
|
-
*
|
|
286
|
-
* With `force` the replacement is written to a temporary file beside `path` first and then renamed over it, which is
|
|
287
|
-
* atomic, so a replacement that cannot be written or swapped in leaves the old file exactly as it was. Only once the
|
|
288
|
-
* new file is in place is the old file's content overwritten with zeros through a descriptor opened on it before the
|
|
289
|
-
* swap, so the tokens of an earlier run are not left recoverable. A symlink at `path` is replaced, not followed.
|
|
290
|
-
*
|
|
291
|
-
* Windows does not honour these modes, so the caller does not use this there. `write` is how the text is written; it is
|
|
292
|
-
* a parameter so a test can make the write fail after the file exists.
|
|
293
|
-
*/
|
|
294
|
-
function writeCredentialsFile(path, text, force = false, write = writeSync) {
|
|
295
|
-
if (!force) return createPrivateFile(path, text, write);
|
|
296
|
-
const old = openExisting(path);
|
|
297
|
-
const temp = join(dirname(path), `${basename(path)}.${randomBytes(6).toString("hex")}.tmp`);
|
|
298
|
-
let fresh;
|
|
299
|
-
try {
|
|
300
|
-
fresh = createPrivateFile(temp, text, write);
|
|
301
|
-
try {
|
|
302
|
-
renameSync(temp, path);
|
|
303
|
-
} catch (err) {
|
|
304
|
-
closeSync(fresh.fd);
|
|
305
|
-
unlinkSync(temp);
|
|
306
|
-
throw err;
|
|
307
|
-
}
|
|
308
|
-
} catch (err) {
|
|
309
|
-
if (old) closeSync(old.fd);
|
|
310
|
-
throw err;
|
|
311
|
-
}
|
|
312
|
-
if (old) shredFile(path, old);
|
|
313
|
-
return fresh;
|
|
314
|
-
}
|
|
315
|
-
/** A descriptor for the regular file at `path`, opened without following a symlink, or `undefined` if there is none. */
|
|
316
|
-
function openExisting(path) {
|
|
317
|
-
let stat;
|
|
318
|
-
try {
|
|
319
|
-
stat = lstatSync(path);
|
|
320
|
-
} catch (err) {
|
|
321
|
-
if (err.code === "ENOENT") return void 0;
|
|
322
|
-
throw err;
|
|
323
|
-
}
|
|
324
|
-
if (!stat.isFile()) return void 0;
|
|
325
|
-
const fd = openSync(path, constants.O_WRONLY | constants.O_NOFOLLOW);
|
|
326
|
-
const { dev, ino } = fstatSync(fd);
|
|
327
|
-
return {
|
|
328
|
-
dev,
|
|
329
|
-
ino,
|
|
330
|
-
fd
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
// src/auth/dotenv-file/dotenv-file.ts
|
|
334
|
-
/** The name of the file, at the repo root, that holds a developer's own tokens. */
|
|
335
|
-
const DOTENV_FILE = ".env";
|
|
336
|
-
/**
|
|
337
|
-
* Read `<repoRoot>/.env` into a record, or `null` when the file is not there (or cannot be read).
|
|
338
|
-
*
|
|
339
|
-
* Only the repo root is looked at, never the directory the command happens to run in, so a `.env` in a checkout you
|
|
340
|
-
* cloned and ran the CLI from is not trusted. The file is optional: nothing asks for it, and a project that keeps its
|
|
341
|
-
* tokens in a `credentials` provider or the keyring does not need one.
|
|
342
|
-
*/
|
|
343
|
-
function readDotenvFile(repoRoot) {
|
|
344
|
-
try {
|
|
345
|
-
return parse(readFileSync(join(repoRoot, DOTENV_FILE)));
|
|
346
|
-
} catch {
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
// src/auth/dotenv-line/dotenv-line.ts
|
|
351
|
-
/** A value dotenv reads back as written without any quoting: no space, quote, `#`, backslash or line break. */
|
|
352
|
-
const PLAIN = /^[A-Za-z0-9_@%+=:,./-]*$/;
|
|
353
|
-
/** The quotes dotenv accepts around a value, in the order they are tried. Single quotes keep the value exactly as written. */
|
|
354
|
-
const QUOTES = [
|
|
355
|
-
"'",
|
|
356
|
-
"\"",
|
|
357
|
-
"`"
|
|
358
|
-
];
|
|
359
|
-
/**
|
|
360
|
-
* `NAME=value` in a form dotenv reads back as the same value, or `null` when there is none.
|
|
361
|
-
*
|
|
362
|
-
* dotenv has no escape for a quote or a backslash: a double-quoted value only turns `\n` and `\r` into line breaks, and
|
|
363
|
-
* leaves every other backslash, an escaped quote included, in the value. So nothing is escaped here. A plain value is
|
|
364
|
-
* written bare; any other is wrapped in the first of `'`, `"` and `` ` `` it does not contain; a value with a line
|
|
365
|
-
* break can only be double-quoted (with `\n` and `\r`) and so must not contain `"` or a backslash. A value that fits
|
|
366
|
-
* none of these is `null`, and the caller says so rather than exporting a different token.
|
|
367
|
-
*/
|
|
368
|
-
function dotenvLine(name, value) {
|
|
369
|
-
if (PLAIN.test(value)) return `${name}=${value}`;
|
|
370
|
-
if (/[\r\n]/.test(value)) {
|
|
371
|
-
if (value.includes("\"") || value.includes("\\")) return null;
|
|
372
|
-
return `${name}="${value.replace(/\r/g, "\\r").replace(/\n/g, "\\n")}"`;
|
|
373
|
-
}
|
|
374
|
-
const quote = QUOTES.find((q) => !value.includes(q));
|
|
375
|
-
return quote ? `${name}=${quote}${value}${quote}` : null;
|
|
376
|
-
}
|
|
377
|
-
// src/auth/git-ignored/git-ignored.ts
|
|
378
|
-
/**
|
|
379
|
-
* Ask git whether it ignores `path` (see {@link GitIgnoreState}). A caller that must not leave a file where it could be
|
|
380
|
-
* committed accepts only `ignored` and `no-repo`. Reads only; it changes nothing.
|
|
381
|
-
*/
|
|
382
|
-
function isGitIgnored(path) {
|
|
383
|
-
try {
|
|
384
|
-
execFileSync("git", [
|
|
385
|
-
"check-ignore",
|
|
386
|
-
"-q",
|
|
387
|
-
"--",
|
|
388
|
-
path
|
|
389
|
-
], {
|
|
390
|
-
cwd: dirname(path),
|
|
391
|
-
stdio: [
|
|
392
|
-
"ignore",
|
|
393
|
-
"ignore",
|
|
394
|
-
"pipe"
|
|
395
|
-
]
|
|
396
|
-
});
|
|
397
|
-
return "ignored";
|
|
398
|
-
} catch (err) {
|
|
399
|
-
const { status, code, stderr } = err;
|
|
400
|
-
if (code === "ENOENT") return "no-repo";
|
|
401
|
-
if (status === 1) return "tracked";
|
|
402
|
-
return status === 128 && /not a git repository/i.test(String(stderr)) ? "no-repo" : "unknown";
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
// src/auth/token-args/token-args.ts
|
|
406
|
-
var TokenParseError = class extends Error {
|
|
407
|
-
name = "TokenParseError";
|
|
408
|
-
};
|
|
409
|
-
/**
|
|
410
|
-
* Converts raw --token CLI values into a typed result.
|
|
411
|
-
*
|
|
412
|
-
* Bare form: --token ghp_xxx → { cliToken: "ghp_xxx" }
|
|
413
|
-
* Keyed form: --token github=ghp_xxx → { cliTokens: { github: "ghp_xxx" } }
|
|
414
|
-
* Mixed: --token github=ghp_xxx --token v_yyy
|
|
415
|
-
* → { cliToken: "v_yyy", cliTokens: { github: "ghp_xxx" } }
|
|
416
|
-
*
|
|
417
|
-
* Values may contain "=" (e.g. base64 strings) — only the first "=" is treated as a separator.
|
|
418
|
-
*/
|
|
419
|
-
function parseTokenArgs(tokens) {
|
|
420
|
-
if (tokens.length === 0) return {};
|
|
421
|
-
const cliTokens = {};
|
|
422
|
-
const bare = [];
|
|
423
|
-
for (const raw of tokens) {
|
|
424
|
-
const eqIdx = raw.indexOf("=");
|
|
425
|
-
if (eqIdx === -1) {
|
|
426
|
-
bare.push(raw);
|
|
427
|
-
continue;
|
|
428
|
-
}
|
|
429
|
-
const vendor = raw.slice(0, eqIdx);
|
|
430
|
-
const value = raw.slice(eqIdx + 1);
|
|
431
|
-
if (vendor.trim() === "") throw new TokenParseError(`invalid --token value "${raw}": vendor name must not be empty`);
|
|
432
|
-
if (/\s/.test(vendor)) throw new TokenParseError(`invalid --token value "${raw}": vendor name must not contain whitespace`);
|
|
433
|
-
if (value === "") throw new TokenParseError(`invalid --token value "${raw}": token value must not be empty`);
|
|
434
|
-
cliTokens[vendor] = value;
|
|
435
|
-
}
|
|
436
|
-
if (bare.length > 1) throw new TokenParseError(`only one bare --token value is allowed; got ${bare.length.toString()} — use vendor=value form for multiple tokens`);
|
|
437
|
-
const result = {};
|
|
438
|
-
if (bare.length === 1) result.cliToken = bare[0];
|
|
439
|
-
if (Object.keys(cliTokens).length > 0) result.cliTokens = cliTokens;
|
|
440
|
-
return result;
|
|
441
|
-
}
|
|
166
|
+
// src/auth/index.ts
|
|
167
|
+
var auth_exports = /* @__PURE__ */ __exportAll({
|
|
168
|
+
AuthError: () => AuthError,
|
|
169
|
+
clearTokenCache: () => clearTokenCache,
|
|
170
|
+
createFeatureResolver: () => createFeatureResolver,
|
|
171
|
+
createResolveToken: () => createResolveToken$1,
|
|
172
|
+
deleteToken: () => deleteToken,
|
|
173
|
+
getToken: () => getToken,
|
|
174
|
+
isKeyringAvailable: () => isKeyringAvailable,
|
|
175
|
+
listStoredProviders: () => listStoredProviders,
|
|
176
|
+
setToken: () => setToken
|
|
177
|
+
});
|
|
178
|
+
import * as import__theholocron_kyber_secrets from "@theholocron/kyber/secrets";
|
|
179
|
+
__reExport(auth_exports, import__theholocron_kyber_secrets);
|
|
442
180
|
// src/commands/contexts/contexts.ts
|
|
443
181
|
/**
|
|
444
182
|
* Command → context. Keys are the full command path as it lands in
|
|
@@ -528,651 +266,28 @@ function contextForCommand(name) {
|
|
|
528
266
|
function commandsInContext(context) {
|
|
529
267
|
return Object.entries(COMMAND_CONTEXTS).filter(([, c]) => c === context).map(([name]) => name);
|
|
530
268
|
}
|
|
531
|
-
// src/ui/non-interactive-error/non-interactive-error.ts
|
|
532
|
-
/**
|
|
533
|
-
* Raised when a prompt is needed but stdin isn't a TTY. A non-TTY run (CI, a
|
|
534
|
-
* script, a pipe) throws this instead of hanging on `@inquirer/prompts`, which
|
|
535
|
-
* otherwise throws its own `ExitPromptError` the moment stdin closes. `cli.ts`'s
|
|
536
|
-
* `USER_FACING_ERRORS` catch prints the message cleanly.
|
|
537
|
-
*/
|
|
538
|
-
var NonInteractiveError = class extends Error {
|
|
539
|
-
name = "NonInteractiveError";
|
|
540
|
-
};
|
|
541
|
-
// src/ui/json-view/json-view.ts
|
|
542
|
-
function isContainer(value) {
|
|
543
|
-
return typeof value === "object" && value !== null;
|
|
544
|
-
}
|
|
545
|
-
function childrenOf(value) {
|
|
546
|
-
return Array.isArray(value) ? value.map((v, i) => [String(i), v]) : Object.entries(value);
|
|
547
|
-
}
|
|
548
|
-
function scalar(value) {
|
|
549
|
-
if (typeof value === "string") return chalk.green(JSON.stringify(value));
|
|
550
|
-
if (typeof value === "number") return chalk.yellow(String(value));
|
|
551
|
-
if (typeof value === "boolean") return chalk.magenta(String(value));
|
|
552
|
-
return chalk.dim(String(value === void 0 ? null : value));
|
|
553
|
-
}
|
|
554
|
-
function summary(value) {
|
|
555
|
-
const n = childrenOf(value).length;
|
|
556
|
-
const unit = Array.isArray(value) ? n === 1 ? "item" : "items" : n === 1 ? "key" : "keys";
|
|
557
|
-
return chalk.dim(Array.isArray(value) ? `[… ${n} ${unit}]` : `{… ${n} ${unit}}`);
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Paths of every container deeper than `depth` levels are left out, so those
|
|
561
|
-
* render collapsed. `depth: 0` collapses the root; `Infinity` expands all.
|
|
562
|
-
*/
|
|
563
|
-
function expandToDepth(value, depth) {
|
|
564
|
-
const out = /* @__PURE__ */ new Set();
|
|
565
|
-
const walk = (v, path, level) => {
|
|
566
|
-
if (!isContainer(v) || level >= depth) return;
|
|
567
|
-
out.add(path);
|
|
568
|
-
for (const [k, child] of childrenOf(v)) walk(child, `${path}/${k}`, level + 1);
|
|
569
|
-
};
|
|
570
|
-
walk(value, "", 0);
|
|
571
|
-
return out;
|
|
572
|
-
}
|
|
573
|
-
/** Flatten `value` into the lines visible under `expanded`. Pure — no I/O. */
|
|
574
|
-
function renderTree(value, { expanded }) {
|
|
575
|
-
const lines = [];
|
|
576
|
-
const walk = (v, path, level, label, trailing) => {
|
|
577
|
-
const indent = " ".repeat(level);
|
|
578
|
-
const prefix = `${indent}${label}`;
|
|
579
|
-
if (!isContainer(v)) {
|
|
580
|
-
lines.push({
|
|
581
|
-
path,
|
|
582
|
-
text: `${prefix}${scalar(v)}${trailing}`,
|
|
583
|
-
foldable: false,
|
|
584
|
-
expanded: false,
|
|
585
|
-
level
|
|
586
|
-
});
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
const kids = childrenOf(v);
|
|
590
|
-
const [open, close] = Array.isArray(v) ? ["[", "]"] : ["{", "}"];
|
|
591
|
-
if (kids.length === 0) {
|
|
592
|
-
lines.push({
|
|
593
|
-
path,
|
|
594
|
-
text: `${prefix}${open}${close}${trailing}`,
|
|
595
|
-
foldable: false,
|
|
596
|
-
expanded: false,
|
|
597
|
-
level
|
|
598
|
-
});
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
if (!expanded.has(path)) {
|
|
602
|
-
lines.push({
|
|
603
|
-
path,
|
|
604
|
-
text: `${prefix}${summary(v)}${trailing}`,
|
|
605
|
-
foldable: true,
|
|
606
|
-
expanded: false,
|
|
607
|
-
level
|
|
608
|
-
});
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
lines.push({
|
|
612
|
-
path,
|
|
613
|
-
text: `${prefix}${open}`,
|
|
614
|
-
foldable: true,
|
|
615
|
-
expanded: true,
|
|
616
|
-
level
|
|
617
|
-
});
|
|
618
|
-
kids.forEach(([k, child], i) => {
|
|
619
|
-
const comma = i < kids.length - 1 ? "," : "";
|
|
620
|
-
const childLabel = Array.isArray(v) ? "" : `${chalk.cyan(JSON.stringify(k))}: `;
|
|
621
|
-
walk(child, `${path}/${k}`, level + 1, childLabel, comma);
|
|
622
|
-
});
|
|
623
|
-
lines.push({
|
|
624
|
-
path: `${path}#close`,
|
|
625
|
-
text: `${indent}${close}${trailing}`,
|
|
626
|
-
foldable: false,
|
|
627
|
-
expanded: false,
|
|
628
|
-
level
|
|
629
|
-
});
|
|
630
|
-
};
|
|
631
|
-
walk(value, "", 0, "", "");
|
|
632
|
-
return lines;
|
|
633
|
-
}
|
|
634
|
-
/** Pure key reducer: `(state, key) -> state`. `rows` is the viewport height. */
|
|
635
|
-
function reduceKey(state, key, value, rows) {
|
|
636
|
-
const lines = renderTree(value, { expanded: state.expanded });
|
|
637
|
-
const cur = lines[state.cursor];
|
|
638
|
-
let { cursor } = state;
|
|
639
|
-
const expanded = new Set(state.expanded);
|
|
640
|
-
switch (key) {
|
|
641
|
-
case "up":
|
|
642
|
-
cursor = Math.max(0, cursor - 1);
|
|
643
|
-
break;
|
|
644
|
-
case "down":
|
|
645
|
-
cursor = Math.min(lines.length - 1, cursor + 1);
|
|
646
|
-
break;
|
|
647
|
-
case "right":
|
|
648
|
-
if (cur?.foldable) expanded.add(cur.path);
|
|
649
|
-
break;
|
|
650
|
-
case "left":
|
|
651
|
-
if (cur?.foldable && cur.expanded) expanded.delete(cur.path);
|
|
652
|
-
else if (cur) {
|
|
653
|
-
const parent = lines.findLastIndex((l, i) => i < cursor && l.foldable && l.expanded && l.level < cur.level);
|
|
654
|
-
if (parent >= 0) cursor = parent;
|
|
655
|
-
}
|
|
656
|
-
break;
|
|
657
|
-
case "expandAll": return {
|
|
658
|
-
cursor,
|
|
659
|
-
top: state.top,
|
|
660
|
-
expanded: expandToDepth(value, Infinity)
|
|
661
|
-
};
|
|
662
|
-
case "collapseAll": return {
|
|
663
|
-
cursor: 0,
|
|
664
|
-
top: 0,
|
|
665
|
-
expanded: /* @__PURE__ */ new Set()
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
const count = renderTree(value, { expanded }).length;
|
|
669
|
-
cursor = Math.min(cursor, count - 1);
|
|
670
|
-
let top = state.top;
|
|
671
|
-
if (cursor < top) top = cursor;
|
|
672
|
-
if (cursor >= top + rows) top = cursor - rows + 1;
|
|
673
|
-
return {
|
|
674
|
-
cursor,
|
|
675
|
-
top: Math.max(0, top),
|
|
676
|
-
expanded
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
const KEYMAP = {
|
|
680
|
-
"\x1B[A": "up",
|
|
681
|
-
k: "up",
|
|
682
|
-
"\x1B[B": "down",
|
|
683
|
-
j: "down",
|
|
684
|
-
"\x1B[C": "right",
|
|
685
|
-
l: "right",
|
|
686
|
-
"\r": "right",
|
|
687
|
-
" ": "right",
|
|
688
|
-
"\x1B[D": "left",
|
|
689
|
-
h: "left",
|
|
690
|
-
E: "expandAll",
|
|
691
|
-
C: "collapseAll",
|
|
692
|
-
q: "quit",
|
|
693
|
-
"\x1B": "quit",
|
|
694
|
-
"": "quit"
|
|
695
|
-
};
|
|
696
|
-
function draw(out, value, state, rows) {
|
|
697
|
-
const lines = renderTree(value, { expanded: state.expanded });
|
|
698
|
-
const view = lines.slice(state.top, state.top + rows).map((l, i) => {
|
|
699
|
-
const row = `${l.foldable ? l.expanded ? "▾ " : "▸ " : " "}${l.text}`;
|
|
700
|
-
return state.top + i === state.cursor ? chalk.inverse(row) : row;
|
|
701
|
-
});
|
|
702
|
-
const footer = chalk.dim(`${state.cursor + 1}/${lines.length} ↑↓ move →/⏎ expand ← collapse E/C all q quit`);
|
|
703
|
-
out.write(`\u001b[H\u001b[J${view.join("\n")}\n${footer}`);
|
|
704
|
-
}
|
|
705
|
-
async function runInteractive(value, depth) {
|
|
706
|
-
const { stdin, stdout } = process;
|
|
707
|
-
if (!stdin.isTTY || !stdout.isTTY) throw new NonInteractiveError("--interactive needs a TTY on stdin and stdout.");
|
|
708
|
-
const rows = () => Math.max(3, (stdout.rows ?? 24) - 1);
|
|
709
|
-
let state = {
|
|
710
|
-
cursor: 0,
|
|
711
|
-
top: 0,
|
|
712
|
-
expanded: expandToDepth(value, depth)
|
|
713
|
-
};
|
|
714
|
-
const wasRaw = stdin.isRaw;
|
|
715
|
-
stdin.setRawMode(true);
|
|
716
|
-
stdin.resume();
|
|
717
|
-
stdout.write("\x1B[?1049h\x1B[?25l");
|
|
718
|
-
const redraw = () => draw(stdout, value, state, rows());
|
|
719
|
-
stdout.on("resize", redraw);
|
|
720
|
-
try {
|
|
721
|
-
redraw();
|
|
722
|
-
await new Promise((resolve) => {
|
|
723
|
-
const onData = (buf) => {
|
|
724
|
-
const key = KEYMAP[buf.toString()];
|
|
725
|
-
if (key === "quit") {
|
|
726
|
-
stdin.off("data", onData);
|
|
727
|
-
resolve();
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
if (key) {
|
|
731
|
-
state = reduceKey(state, key, value, rows());
|
|
732
|
-
redraw();
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
stdin.on("data", onData);
|
|
736
|
-
});
|
|
737
|
-
} finally {
|
|
738
|
-
stdout.off("resize", redraw);
|
|
739
|
-
stdout.write("\x1B[?25h\x1B[?1049l");
|
|
740
|
-
stdin.setRawMode(wasRaw);
|
|
741
|
-
stdin.pause();
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
/**
|
|
745
|
-
* Print `value` as JSON. Non-TTY stdout always gets plain, valid
|
|
746
|
-
* `JSON.stringify` output (so `| jq` and redirects keep working); a TTY gets a
|
|
747
|
-
* coloured tree, collapsed past `depth`. `interactive` opens a folding viewer (the default on a TTY).
|
|
748
|
-
*/
|
|
749
|
-
async function viewJson(value, options = {}) {
|
|
750
|
-
const depth = options.depth ?? Infinity;
|
|
751
|
-
if (options.interactive ?? (options.depth === void 0 && Boolean(process.stdin.isTTY && process.stdout.isTTY))) return runInteractive(value, options.depth ?? 1);
|
|
752
|
-
if (!process.stdout.isTTY) {
|
|
753
|
-
console.log(JSON.stringify(value, null, 2));
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
const lines = renderTree(value, { expanded: expandToDepth(value, depth) });
|
|
757
|
-
console.log(lines.map((l) => l.text).join("\n"));
|
|
758
|
-
}
|
|
759
|
-
// src/ui/menu/menu.ts
|
|
760
|
-
/**
|
|
761
|
-
* Searchable autocomplete over one menu level's `items`. `select()` would work too
|
|
762
|
-
* at these list sizes, but `search()` degrades gracefully as the surface grows and
|
|
763
|
-
* costs nothing when it doesn't. Resolves to the picked item's `value`.
|
|
764
|
-
*/
|
|
765
|
-
async function pickMenuItem(items, message = "What would you like to do?") {
|
|
766
|
-
return search({
|
|
767
|
-
message,
|
|
768
|
-
source: (term) => searchChoices(items, term)
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* `@inquirer/search`'s `source` callback, factored out as a plain function —
|
|
773
|
-
* unit-testable directly instead of only through a mocked `search()` call.
|
|
774
|
-
* Empty/undefined `term` (nothing typed yet) returns every item.
|
|
775
|
-
*/
|
|
776
|
-
function searchChoices(items, term) {
|
|
777
|
-
const needle = term?.toLowerCase();
|
|
778
|
-
const pool = !needle ? items : items.filter((i) => i.haystack.includes(needle));
|
|
779
|
-
const rank = (i) => {
|
|
780
|
-
if (!needle) return 0;
|
|
781
|
-
const name = i.name.toLowerCase();
|
|
782
|
-
return name.startsWith(needle) ? 0 : name.includes(needle) ? 1 : 2;
|
|
783
|
-
};
|
|
784
|
-
return [...pool].sort((a, b) => rank(a) - rank(b)).map((i) => ({
|
|
785
|
-
name: i.name,
|
|
786
|
-
value: i.value,
|
|
787
|
-
description: i.description,
|
|
788
|
-
short: i.name.replace(/ ›$/, "")
|
|
789
|
-
}));
|
|
790
|
-
}
|
|
791
|
-
// src/ui/open-path/open-path.ts
|
|
792
|
-
/** Platform-appropriate command to open a path in the OS's file browser. */
|
|
793
|
-
function openCommand(path) {
|
|
794
|
-
if (process.platform === "darwin") return {
|
|
795
|
-
cmd: "open",
|
|
796
|
-
args: [path]
|
|
797
|
-
};
|
|
798
|
-
if (process.platform === "win32") return {
|
|
799
|
-
cmd: "cmd",
|
|
800
|
-
args: [
|
|
801
|
-
"/c",
|
|
802
|
-
"start",
|
|
803
|
-
"",
|
|
804
|
-
path
|
|
805
|
-
]
|
|
806
|
-
};
|
|
807
|
-
return {
|
|
808
|
-
cmd: "xdg-open",
|
|
809
|
-
args: [path]
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Open `path` in the OS's default file browser (Finder / Explorer /
|
|
814
|
-
* whatever `xdg-open` resolves to on Linux). Fire-and-forget — detached so
|
|
815
|
-
* it outlives this process, and never throws when the opener binary isn't
|
|
816
|
-
* on PATH (e.g. no `xdg-open` in a minimal container).
|
|
817
|
-
*/
|
|
818
|
-
function openPath(path) {
|
|
819
|
-
const { cmd, args } = openCommand(path);
|
|
820
|
-
const child = spawn(cmd, args, {
|
|
821
|
-
stdio: "ignore",
|
|
822
|
-
detached: true
|
|
823
|
-
});
|
|
824
|
-
child.on("error", () => {});
|
|
825
|
-
child.unref();
|
|
826
|
-
}
|
|
827
269
|
// src/ui/progress/progress.ts
|
|
828
|
-
/**
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
/**
|
|
850
|
-
* Whether to draw a progress line: only when a person is watching a terminal (stdout and stderr both), not in CI, and not
|
|
851
|
-
* switched off. Everywhere else the output stays the plain line-per-step text that scripts and the docs rely on.
|
|
852
|
-
*/
|
|
853
|
-
function progressEnabled() {
|
|
854
|
-
return allowed && Boolean(process.stdout.isTTY) && Boolean(process.stderr.isTTY) && !process.env["CI"];
|
|
855
|
-
}
|
|
856
|
-
/**
|
|
857
|
-
* A spinner for one step at a time that a step can print through. Steps that only return a result use {@link
|
|
858
|
-
* withProgress}; a step that prints its own result line while it runs (`notifications setup`) prints through `print`.
|
|
859
|
-
*/
|
|
860
|
-
function createProgress(print, enabled = progressEnabled) {
|
|
861
|
-
let active;
|
|
862
|
-
return {
|
|
863
|
-
async run(label, fn) {
|
|
864
|
-
if (!enabled()) return fn();
|
|
865
|
-
const spinner = ora({
|
|
866
|
-
text: label,
|
|
867
|
-
stream: process.stderr,
|
|
868
|
-
discardStdin: false
|
|
869
|
-
}).start();
|
|
870
|
-
active = spinner;
|
|
871
|
-
const stopListening = onRetry((e) => {
|
|
872
|
-
spinner.text = `${label} (retrying ${e.vendor ?? "the request"}, attempt ${e.attempt} of ${e.of})`;
|
|
873
|
-
});
|
|
874
|
-
try {
|
|
875
|
-
return await fn();
|
|
876
|
-
} finally {
|
|
877
|
-
stopListening();
|
|
878
|
-
spinner.stop();
|
|
879
|
-
active = void 0;
|
|
880
|
-
}
|
|
881
|
-
},
|
|
882
|
-
print(line) {
|
|
883
|
-
const spinner = active;
|
|
884
|
-
if (!spinner) return print(line);
|
|
885
|
-
spinner.stop();
|
|
886
|
-
print(line);
|
|
887
|
-
spinner.start();
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
/** `fn` under a cleared-when-done spinner named `label`, on a terminal only. */
|
|
892
|
-
function withProgress(label, fn) {
|
|
893
|
-
return createProgress(() => {}).run(label, fn);
|
|
894
|
-
}
|
|
895
|
-
// src/ui/prompt-options/prompt-options.ts
|
|
896
|
-
/**
|
|
897
|
-
* A required option must not resolve to an empty answer — `optionArgv`/
|
|
898
|
-
* `secretEnv` (child-argv.ts) both drop an empty-string value entirely,
|
|
899
|
-
* which would silently invoke the child without a flag the caller asked
|
|
900
|
-
* for. Passed as `validate` so inquirer re-prompts instead of accepting it.
|
|
901
|
-
*/
|
|
902
|
-
const requireNonEmpty = (value) => value.trim().length > 0 || "required";
|
|
903
|
-
async function promptOne(option) {
|
|
904
|
-
if (option.secret || option.type === "password") return await password({
|
|
905
|
-
message: option.message,
|
|
906
|
-
...option.required ? { validate: requireNonEmpty } : {}
|
|
907
|
-
});
|
|
908
|
-
if (option.type === "confirm") return await confirm({
|
|
909
|
-
message: option.message,
|
|
910
|
-
default: option.default
|
|
911
|
-
});
|
|
912
|
-
if (option.type === "select") {
|
|
913
|
-
const choices = typeof option.choices === "function" ? option.choices() : option.choices ?? [];
|
|
914
|
-
return await select({
|
|
915
|
-
message: option.message,
|
|
916
|
-
choices: choices.map((c) => ({ value: c }))
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
|
-
if (option.arity && option.arity > 1) {
|
|
920
|
-
const values = [];
|
|
921
|
-
for (let n = 0; n < option.arity; n++) values.push(await input({
|
|
922
|
-
message: `${option.message} (${n + 1} of ${option.arity})`,
|
|
923
|
-
...option.required ? { validate: requireNonEmpty } : {}
|
|
924
|
-
}));
|
|
925
|
-
return values;
|
|
926
|
-
}
|
|
927
|
-
return await input({
|
|
928
|
-
message: option.message,
|
|
929
|
-
default: option.default,
|
|
930
|
-
...option.required ? { validate: requireNonEmpty } : {}
|
|
931
|
-
});
|
|
932
|
-
}
|
|
933
|
-
/**
|
|
934
|
-
* For each of `options` not already present in `argv`, resolves a value —
|
|
935
|
-
* `required` ones are always included, like required positionals, never
|
|
936
|
-
* behind a selector; everything else is offered through one `checkbox()`
|
|
937
|
-
* ("set any options?") and only the picked ones are then prompted in
|
|
938
|
-
* `options`' own declaration order. An empty list (or every optional one
|
|
939
|
-
* left unpicked) means zero prompts.
|
|
940
|
-
*
|
|
941
|
-
* A picked option (whether required or checkbox-picked) with
|
|
942
|
-
* `askLast: true` (holocron#1052 follow-up — a time-sensitive secret like
|
|
943
|
-
* an OTP, which should be typed as close as possible to when it's actually
|
|
944
|
-
* used, or one that's always needed for a specific operator's own account
|
|
945
|
-
* but not everyone's) isn't given a value here yet: it's returned in
|
|
946
|
-
* `deferred` instead, for the caller to resolve via
|
|
947
|
-
* `promptForDeferredOptions` right before the real (non-dry-run) spawn.
|
|
948
|
-
*
|
|
949
|
-
* `when`, evaluated against answers collected so far in that same
|
|
950
|
-
* declaration order, can skip a picked option entirely. Skipped this way,
|
|
951
|
-
* the option is simply absent from the result, exactly as if it had never
|
|
952
|
-
* been picked — acceptable for a minor, genuinely optional dependency, but
|
|
953
|
-
* prefer `OptionMode` (see `promptForOptions`) when the options have a
|
|
954
|
-
* real either/or relationship, so nothing contingent is shown at all.
|
|
955
|
-
*/
|
|
956
|
-
async function promptForFlatOptions(commandName, options, argv) {
|
|
957
|
-
if (options.length === 0) return {
|
|
958
|
-
answers: {},
|
|
959
|
-
deferred: []
|
|
960
|
-
};
|
|
961
|
-
const answers = {};
|
|
962
|
-
const deferred = [];
|
|
963
|
-
const needsPrompt = (option) => {
|
|
964
|
-
const existing = argv[option.key];
|
|
965
|
-
return existing === void 0 || existing === "";
|
|
966
|
-
};
|
|
967
|
-
const required = options.filter((o) => o.required);
|
|
968
|
-
const optional = options.filter((o) => !o.required);
|
|
969
|
-
if ((required.some(needsPrompt) || optional.some(needsPrompt)) && !process.stdin.isTTY) throw new NonInteractiveError(`\`${commandName}\` has options only settable interactively — pass them directly: holocron ${commandName} [options]`);
|
|
970
|
-
for (const option of required) {
|
|
971
|
-
if (!needsPrompt(option)) {
|
|
972
|
-
answers[option.key] = argv[option.key];
|
|
973
|
-
continue;
|
|
974
|
-
}
|
|
975
|
-
if (option.askLast) {
|
|
976
|
-
deferred.push(option);
|
|
977
|
-
continue;
|
|
978
|
-
}
|
|
979
|
-
answers[option.key] = await promptOne(option);
|
|
980
|
-
}
|
|
981
|
-
for (const option of optional) if (!needsPrompt(option)) answers[option.key] = argv[option.key];
|
|
982
|
-
const selectable = optional.filter(needsPrompt);
|
|
983
|
-
if (selectable.length === 0) return {
|
|
984
|
-
answers,
|
|
985
|
-
deferred
|
|
986
|
-
};
|
|
987
|
-
const picked = await checkbox({
|
|
988
|
-
message: "Set any options? (space to select, enter to skip)",
|
|
989
|
-
choices: selectable.map((o) => ({
|
|
990
|
-
name: o.message,
|
|
991
|
-
value: o.key
|
|
992
|
-
}))
|
|
993
|
-
});
|
|
994
|
-
if (picked.length === 0) return {
|
|
995
|
-
answers,
|
|
996
|
-
deferred
|
|
997
|
-
};
|
|
998
|
-
const pickedSet = new Set(picked);
|
|
999
|
-
for (const option of optional) {
|
|
1000
|
-
if (!pickedSet.has(option.key)) continue;
|
|
1001
|
-
if (option.when && !option.when(answers)) continue;
|
|
1002
|
-
if (option.askLast) {
|
|
1003
|
-
deferred.push(option);
|
|
1004
|
-
continue;
|
|
1005
|
-
}
|
|
1006
|
-
answers[option.key] = await promptOne(option);
|
|
1007
|
-
}
|
|
1008
|
-
return {
|
|
1009
|
-
answers,
|
|
1010
|
-
deferred
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* For a `modes`-based command (holocron#1052 follow-up): asks which
|
|
1015
|
-
* mutually exclusive workflow first ("What would you like to do?"), then
|
|
1016
|
-
* offers only that mode's own options, via the exact same
|
|
1017
|
-
* `promptForFlatOptions` flow. The picked mode's `flag`, if it has one, is
|
|
1018
|
-
* folded in as an already-resolved `confirm`-type option so
|
|
1019
|
-
* `buildChildArgv` renders it with no special-casing — it just sees
|
|
1020
|
-
* another boolean option whose answer happens to already be `true`.
|
|
1021
|
-
*/
|
|
1022
|
-
async function promptForModes(entry, modes, argv) {
|
|
1023
|
-
if (!process.stdin.isTTY) throw new NonInteractiveError(`\`${entry.name}\` has options only settable interactively — pass them directly: holocron ${entry.name} [options]`);
|
|
1024
|
-
const modeKey = await select({
|
|
1025
|
-
message: "What would you like to do?",
|
|
1026
|
-
choices: modes.map((m) => ({
|
|
1027
|
-
name: m.message,
|
|
1028
|
-
value: m.key,
|
|
1029
|
-
description: m.description
|
|
1030
|
-
}))
|
|
1031
|
-
});
|
|
1032
|
-
const mode = modes.find((m) => m.key === modeKey);
|
|
1033
|
-
const options = mode.options ?? [];
|
|
1034
|
-
const { answers, deferred } = await promptForFlatOptions(entry.name, options, argv);
|
|
1035
|
-
if (!mode.flag) return {
|
|
1036
|
-
options,
|
|
1037
|
-
answers,
|
|
1038
|
-
deferred
|
|
1039
|
-
};
|
|
1040
|
-
const flagOption = {
|
|
1041
|
-
key: `__mode_${mode.key}`,
|
|
1042
|
-
flag: mode.flag,
|
|
1043
|
-
type: "confirm",
|
|
1044
|
-
message: mode.message
|
|
1045
|
-
};
|
|
1046
|
-
return {
|
|
1047
|
-
options: [flagOption, ...options],
|
|
1048
|
-
answers: {
|
|
1049
|
-
[flagOption.key]: true,
|
|
1050
|
-
...answers
|
|
1051
|
-
},
|
|
1052
|
-
deferred
|
|
1053
|
-
};
|
|
1054
|
-
}
|
|
1055
|
-
/**
|
|
1056
|
-
* Resolves `entry`'s options into a {@link ResolvedOptions} ready for
|
|
1057
|
-
* `buildChildArgv`/`secretEnv` — delegating to {@link promptForModes} when
|
|
1058
|
-
* `entry.modes` is set, or treating `entry.options` as a flat list
|
|
1059
|
-
* otherwise. See `promptForFlatOptions` for the flat-list prompting
|
|
1060
|
-
* algorithm itself. `result.deferred` still needs
|
|
1061
|
-
* {@link promptForDeferredOptions} before the real spawn.
|
|
1062
|
-
*/
|
|
1063
|
-
async function promptForOptions(entry, argv) {
|
|
1064
|
-
if (entry.modes && entry.modes.length > 0) return promptForModes(entry, entry.modes, argv);
|
|
1065
|
-
const options = entry.options ?? [];
|
|
1066
|
-
const { answers, deferred } = await promptForFlatOptions(entry.name, options, argv);
|
|
1067
|
-
return {
|
|
1068
|
-
options,
|
|
1069
|
-
answers,
|
|
1070
|
-
deferred
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Collects a value for each of `deferred` — the `askLast: true` options
|
|
1075
|
-
* `promptForOptions` deliberately left unresolved. Call this as the very
|
|
1076
|
-
* last thing before the real (non-dry-run) spawn, never before: a dry-run
|
|
1077
|
-
* preview never reaches the real npm call these options exist for (an OTP
|
|
1078
|
-
* is never checked during `--dry-run`), and a time-sensitive code typed
|
|
1079
|
-
* any earlier — before a dry-run preview runs, before "proceed with the
|
|
1080
|
-
* real run?" waits on a human — risks going stale before it's actually
|
|
1081
|
-
* used. A no-op (no prompt at all) when `deferred` is empty.
|
|
1082
|
-
*/
|
|
1083
|
-
async function promptForDeferredOptions(deferred) {
|
|
1084
|
-
const answers = {};
|
|
1085
|
-
for (const option of deferred) answers[option.key] = await promptOne(option);
|
|
1086
|
-
return answers;
|
|
1087
|
-
}
|
|
1088
|
-
// src/ui/prompt-positionals/prompt-positionals.ts
|
|
1089
|
-
/**
|
|
1090
|
-
* For each of `entry.positionals` not already present in `argv`, prompts for
|
|
1091
|
-
* it (`input()` or `select()`, per the positional's `type`) and returns the
|
|
1092
|
-
* resolved values in positional order — ready to append to a spawned child's
|
|
1093
|
-
* argv, or to use directly in the current handler (Layer 3).
|
|
1094
|
-
*
|
|
1095
|
-
* Throws {@link NonInteractiveError} the first time it would need to prompt
|
|
1096
|
-
* on a non-TTY stdin, and again if a `select` positional's choices resolve
|
|
1097
|
-
* empty (nothing to pick from — e.g. `auth unset` with no stored tokens).
|
|
1098
|
-
*/
|
|
1099
|
-
async function promptForPositionals(entry, argv) {
|
|
1100
|
-
const out = [];
|
|
1101
|
-
for (const positional of entry.positionals) {
|
|
1102
|
-
const existing = argv[positional.key];
|
|
1103
|
-
if (existing !== void 0 && existing !== "") {
|
|
1104
|
-
out.push(String(existing));
|
|
1105
|
-
continue;
|
|
1106
|
-
}
|
|
1107
|
-
if (!process.stdin.isTTY) throw new NonInteractiveError(`\`${entry.name}\` needs "${positional.key}" — pass it directly: holocron ${entry.name} <${positional.cliArg ?? positional.key}>`);
|
|
1108
|
-
if (positional.type === "select") {
|
|
1109
|
-
const choices = typeof positional.choices === "function" ? positional.choices() : positional.choices ?? [];
|
|
1110
|
-
if (choices.length === 0) throw new NonInteractiveError(`\`${entry.name}\`: no ${positional.key} to choose from — nothing stored yet`);
|
|
1111
|
-
out.push(await select({
|
|
1112
|
-
message: positional.message,
|
|
1113
|
-
choices: choices.map((c) => ({ value: c }))
|
|
1114
|
-
}));
|
|
1115
|
-
} else out.push(await input({
|
|
1116
|
-
message: positional.message,
|
|
1117
|
-
...positional.validate ? { validate: positional.validate } : {}
|
|
1118
|
-
}));
|
|
1119
|
-
}
|
|
1120
|
-
return out;
|
|
1121
|
-
}
|
|
1122
|
-
// src/ui/style/style.ts
|
|
1123
|
-
const style = {
|
|
1124
|
-
success: (msg) => `${chalk.green("✓")} ${msg}`,
|
|
1125
|
-
warn: (msg) => `${chalk.yellow("⚠")} ${msg}`,
|
|
1126
|
-
fail: (msg) => `${chalk.red("✗")} ${msg}`,
|
|
1127
|
-
step: (msg) => `${chalk.cyan("→")} ${msg}`,
|
|
1128
|
-
/** A dim `·` marker for a row that's neither a pass nor a failure — loaded but inactive, or skipped. */
|
|
1129
|
-
skip: (msg) => chalk.dim(`· ${msg}`),
|
|
1130
|
-
hint: (msg) => chalk.dim(msg),
|
|
1131
|
-
dim: (msg) => chalk.dim(msg),
|
|
1132
|
-
header: (msg) => chalk.bold(msg)
|
|
1133
|
-
};
|
|
1134
|
-
// src/ui/status-row/status-row.ts
|
|
1135
|
-
/** Right-pads `s` to `width` with spaces — never truncates. */
|
|
1136
|
-
function pad(s, width) {
|
|
1137
|
-
return s.length >= width ? s : s + " ".repeat(width - s.length);
|
|
1138
|
-
}
|
|
1139
|
-
/**
|
|
1140
|
-
* One row of a status report: a 2-space indent, the status icon (✓ / ✗ / ·),
|
|
1141
|
-
* then `columns` joined with a two-space gap (blank columns dropped, so a
|
|
1142
|
-
* row that has nothing for its last column doesn't trail whitespace).
|
|
1143
|
-
* Column padding (`pad`) is the caller's job — `doctor` pads capability and
|
|
1144
|
-
* provider to a fixed width; `clone`'s repo names and paths don't, since
|
|
1145
|
-
* they vary too widely for fixed-width alignment to read cleanly.
|
|
1146
|
-
*
|
|
1147
|
-
* Shared by `doctor` (capability / provider / message) and `clone` (repo /
|
|
1148
|
-
* destination / reason) so every status table in the CLI reads the same way.
|
|
1149
|
-
*/
|
|
1150
|
-
function statusRow(status, columns) {
|
|
1151
|
-
const joined = columns.filter((c) => c.length > 0).join(" ");
|
|
1152
|
-
return ` ${status === "ok" ? style.success(joined) : status === "fail" ? style.fail(joined) : style.skip(joined)}`;
|
|
1153
|
-
}
|
|
1154
|
-
// src/ui/wait-for-enter/wait-for-enter.ts
|
|
1155
|
-
/**
|
|
1156
|
-
* Print `message` and wait until Enter is pressed, the input ends, or Ctrl-C is pressed, whichever comes first, and
|
|
1157
|
-
* return which: `enter`, or `closed` for the other two. It never hangs on a closed input. It reads from stdin and
|
|
1158
|
-
* writes to stderr, so a pipe on stdout is never touched; the caller checks there is a terminal to answer it. The
|
|
1159
|
-
* streams are parameters so a test can answer for the user.
|
|
1160
|
-
*/
|
|
1161
|
-
function waitForEnter(message, input = process.stdin, output = process.stderr) {
|
|
1162
|
-
return new Promise((resolve) => {
|
|
1163
|
-
const rl = createInterface({
|
|
1164
|
-
input,
|
|
1165
|
-
output
|
|
1166
|
-
});
|
|
1167
|
-
let answered = false;
|
|
1168
|
-
rl.on("close", () => resolve(answered ? "enter" : "closed"));
|
|
1169
|
-
rl.on("SIGINT", () => rl.close());
|
|
1170
|
-
rl.question(message, () => {
|
|
1171
|
-
answered = true;
|
|
1172
|
-
rl.close();
|
|
1173
|
-
});
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
270
|
+
/** Says on the spinner when a request is being sent again, so a slow step is not mistaken for a stuck one. */
|
|
271
|
+
const retryNotice = (label, setText) => onRetry((e) => {
|
|
272
|
+
setText(`${label} (retrying ${e.vendor ?? "the request"}, attempt ${e.attempt} of ${e.of})`);
|
|
273
|
+
});
|
|
274
|
+
/** {@link createSpinnerProgress} with the retry notice hooked in. */
|
|
275
|
+
function createProgress$1(print, enabled = progressEnabled) {
|
|
276
|
+
return createProgress(print, enabled, retryNotice);
|
|
277
|
+
}
|
|
278
|
+
/** `fn` under a cleared-when-done spinner named `label`, on a terminal only, with the retry notice hooked in. */
|
|
279
|
+
function withProgress$1(label, fn) {
|
|
280
|
+
return withProgress(label, fn, retryNotice);
|
|
281
|
+
}
|
|
282
|
+
// src/ui/index.ts
|
|
283
|
+
var ui_exports = /* @__PURE__ */ __exportAll({
|
|
284
|
+
createProgress: () => createProgress$1,
|
|
285
|
+
withProgress: () => withProgress$1
|
|
286
|
+
});
|
|
287
|
+
import * as import__theholocron_kyber_prompts from "@theholocron/kyber/prompts";
|
|
288
|
+
__reExport(ui_exports, import__theholocron_kyber_prompts);
|
|
289
|
+
import * as import__theholocron_kyber_ui from "@theholocron/kyber/ui";
|
|
290
|
+
__reExport(ui_exports, import__theholocron_kyber_ui);
|
|
1176
291
|
// src/observability/logger/logger.ts
|
|
1177
292
|
/**
|
|
1178
293
|
* Dataset for `global`-context commands (`clone`, `auth set`, `upgrade
|
|
@@ -1263,7 +378,7 @@ function resolveCliAxiom(opts) {
|
|
|
1263
378
|
*/
|
|
1264
379
|
function buildCliLogger(argv, opts = {}) {
|
|
1265
380
|
const { command, configLevel } = opts;
|
|
1266
|
-
allowProgress(!argv.quiet && !argv.log);
|
|
381
|
+
(0, ui_exports.allowProgress)(!argv.quiet && !argv.log);
|
|
1267
382
|
if (command) rootCommand = command;
|
|
1268
383
|
const level = resolveLogLevel(argv, configLevel);
|
|
1269
384
|
const consoleOutput = resolveConsoleOutput(argv);
|
|
@@ -1312,7 +427,7 @@ function getLogger() {
|
|
|
1312
427
|
* the per-step reason belongs in the structured log alone.
|
|
1313
428
|
*/
|
|
1314
429
|
function reportError(message, log = getLogger()) {
|
|
1315
|
-
console.error(style.fail(message));
|
|
430
|
+
console.error(ui_exports.style.fail(message));
|
|
1316
431
|
log.error(message);
|
|
1317
432
|
}
|
|
1318
433
|
/** The current root logger's correlation id, if a root has been built. */
|
|
@@ -2435,7 +1550,7 @@ function spawnChild(args, extraEnv) {
|
|
|
2435
1550
|
*/
|
|
2436
1551
|
async function resolveForRealSpawn(resolved) {
|
|
2437
1552
|
if (!resolved.deferred || resolved.deferred.length === 0) return resolved;
|
|
2438
|
-
const deferredAnswers = await promptForDeferredOptions(resolved.deferred);
|
|
1553
|
+
const deferredAnswers = await (0, ui_exports.promptForDeferredOptions)(resolved.deferred);
|
|
2439
1554
|
return {
|
|
2440
1555
|
...resolved,
|
|
2441
1556
|
answers: {
|
|
@@ -2479,7 +1594,7 @@ function shouldPreviewDryRun(entry, parentArgv) {
|
|
|
2479
1594
|
* left to make, since this one does mutate something.
|
|
2480
1595
|
*/
|
|
2481
1596
|
async function launchMenu(entries, parentArgv, pickMessage, nonInteractiveMessage = "Run `holocron --help` to see available commands.", startPath = []) {
|
|
2482
|
-
if (!process.stdin.isTTY) throw new NonInteractiveError(nonInteractiveMessage);
|
|
1597
|
+
if (!process.stdin.isTTY) throw new ui_exports.NonInteractiveError(nonInteractiveMessage);
|
|
2483
1598
|
const stack = [startPath];
|
|
2484
1599
|
let picked;
|
|
2485
1600
|
while (!picked) {
|
|
@@ -2491,13 +1606,14 @@ async function launchMenu(entries, parentArgv, pickMessage, nonInteractiveMessag
|
|
|
2491
1606
|
description: "Return to the previous menu",
|
|
2492
1607
|
haystack: "back"
|
|
2493
1608
|
});
|
|
2494
|
-
const
|
|
1609
|
+
const message = stack.length === 1 ? pickMessage : `${path.join(" ")} — choose a subcommand:`;
|
|
1610
|
+
const value = await (0, ui_exports.pickMenuItem)(items, message);
|
|
2495
1611
|
if (value === "back") stack.pop();
|
|
2496
1612
|
else if (value.startsWith("group:")) stack.push(value.slice(6).split(" "));
|
|
2497
1613
|
else picked = entries.find((e) => e.name === value);
|
|
2498
1614
|
}
|
|
2499
|
-
const positionals = await promptForPositionals(picked, {});
|
|
2500
|
-
const resolvedOptions = await promptForOptions(picked, {});
|
|
1615
|
+
const positionals = await (0, ui_exports.promptForPositionals)(picked, {});
|
|
1616
|
+
const resolvedOptions = await (0, ui_exports.promptForOptions)(picked, {});
|
|
2501
1617
|
const extraEnv = secretEnv(resolvedOptions);
|
|
2502
1618
|
if (shouldPreviewDryRun(picked, parentArgv)) {
|
|
2503
1619
|
const dryExit = await spawnChild(buildChildArgv(picked, positionals, resolvedOptions, parentArgv, true), {
|
|
@@ -2655,14 +1771,7 @@ async function launchGroupMenu(parent, argv) {
|
|
|
2655
1771
|
await launchMenu(COMMAND_REGISTRY, argv, `${parent} — choose a subcommand:`, `Run \`holocron ${parent} --help\` to see available ${parent} subcommands.`, parent.split(" "));
|
|
2656
1772
|
}
|
|
2657
1773
|
/** The hidden `$0` of a command group: bare `holocron <group>` opens the menu at that group. */
|
|
2658
|
-
const groupMenu = (parent) => (
|
|
2659
|
-
command: "$0",
|
|
2660
|
-
describe: false,
|
|
2661
|
-
builder: (y) => y,
|
|
2662
|
-
handler: async (argv) => {
|
|
2663
|
-
await launchGroupMenu(parent, argv);
|
|
2664
|
-
}
|
|
2665
|
-
});
|
|
1774
|
+
const groupMenu$1 = (parent) => groupMenu(parent, launchGroupMenu);
|
|
2666
1775
|
// src/cli-support/parse-scope/parse-scope.ts
|
|
2667
1776
|
/** `--scope` / `--github-secret-scope`: `repo`, `env=<name>` or `org=<name>`. */
|
|
2668
1777
|
function parseScope(s) {
|
|
@@ -2679,18 +1788,8 @@ function parseScope(s) {
|
|
|
2679
1788
|
}
|
|
2680
1789
|
// src/cli-support/token-context/token-context.ts
|
|
2681
1790
|
/** Parses --token values and returns the context spread, or null on parse error (exits with code 1). */
|
|
2682
|
-
function tokenContext(rawTokens) {
|
|
2683
|
-
|
|
2684
|
-
try {
|
|
2685
|
-
return parseTokenArgs(rawTokens);
|
|
2686
|
-
} catch (err) {
|
|
2687
|
-
if (err instanceof TokenParseError) {
|
|
2688
|
-
reportError(`--token: ${err.message}`);
|
|
2689
|
-
process.exitCode = 1;
|
|
2690
|
-
return null;
|
|
2691
|
-
}
|
|
2692
|
-
throw err;
|
|
2693
|
-
}
|
|
1791
|
+
function tokenContext$1(rawTokens) {
|
|
1792
|
+
return tokenContext(rawTokens, reportError);
|
|
2694
1793
|
}
|
|
2695
1794
|
// src/plugin/capabilities/capabilities.ts
|
|
2696
1795
|
/** How many providers each capability resolves to: one (`"single"`) or several active at once (`"many"`). */
|
|
@@ -3466,12 +2565,12 @@ async function runAuthSet(input) {
|
|
|
3466
2565
|
const isFeatureKey = provider.includes(".");
|
|
3467
2566
|
const packageName = isFeatureKey ? null : resolvePluginPackage(provider);
|
|
3468
2567
|
if (!token) {
|
|
3469
|
-
print(style.fail(`no token supplied for \`${keyringKey}\`.`));
|
|
3470
|
-
print(style.hint(` pass as positional arg: holocron auth set ${provider} <token>`));
|
|
2568
|
+
print(ui_exports.style.fail(`no token supplied for \`${keyringKey}\`.`));
|
|
2569
|
+
print(ui_exports.style.hint(` pass as positional arg: holocron auth set ${provider} <token>`));
|
|
3471
2570
|
if (!isFeatureKey) {
|
|
3472
|
-
print(style.hint(` or via env: HOLOCRON_${provider.toUpperCase()}_TOKEN / ${provider.toUpperCase()}_TOKEN`));
|
|
2571
|
+
print(ui_exports.style.hint(` or via env: HOLOCRON_${provider.toUpperCase()}_TOKEN / ${provider.toUpperCase()}_TOKEN`));
|
|
3473
2572
|
const hint = await tryLoadHint(importer, packageName);
|
|
3474
|
-
if (hint) print(style.hint(` hint: ${hint}`));
|
|
2573
|
+
if (hint) print(ui_exports.style.hint(` hint: ${hint}`));
|
|
3475
2574
|
}
|
|
3476
2575
|
logger.warn({
|
|
3477
2576
|
provider,
|
|
@@ -3491,8 +2590,8 @@ async function runAuthSet(input) {
|
|
|
3491
2590
|
if (typeof module.verifyToken === "function") {
|
|
3492
2591
|
const verified = await module.verifyToken(token);
|
|
3493
2592
|
if (!verified.ok) {
|
|
3494
|
-
print(style.fail(`token rejected by ${provider}: ${verified.message}`));
|
|
3495
|
-
if (module.AUTH_HINT) print(style.hint(` hint: ${module.AUTH_HINT}`));
|
|
2593
|
+
print(ui_exports.style.fail(`token rejected by ${provider}: ${verified.message}`));
|
|
2594
|
+
if (module.AUTH_HINT) print(ui_exports.style.hint(` hint: ${module.AUTH_HINT}`));
|
|
3496
2595
|
logger.warn({
|
|
3497
2596
|
provider,
|
|
3498
2597
|
keyringKey,
|
|
@@ -3505,14 +2604,14 @@ async function runAuthSet(input) {
|
|
|
3505
2604
|
};
|
|
3506
2605
|
}
|
|
3507
2606
|
subject = verified.subject;
|
|
3508
|
-
} else print(style.warn(`${provider} plugin has no verifyToken; storing without verification`));
|
|
2607
|
+
} else print(ui_exports.style.warn(`${provider} plugin has no verifyToken; storing without verification`));
|
|
3509
2608
|
} catch (err) {
|
|
3510
2609
|
const msg = errorMessage(err);
|
|
3511
|
-
print(style.warn(`cannot verify token — failed to load ${packageName}: ${msg}`));
|
|
3512
|
-
print(style.hint(` storing token anyway; run 'holocron auth check ${provider}' once the plugin is installed`));
|
|
2610
|
+
print(ui_exports.style.warn(`cannot verify token — failed to load ${packageName}: ${msg}`));
|
|
2611
|
+
print(ui_exports.style.hint(` storing token anyway; run 'holocron auth check ${provider}' once the plugin is installed`));
|
|
3513
2612
|
}
|
|
3514
2613
|
if (!setToken(keyringKey, token)) {
|
|
3515
|
-
print(style.fail(`keyring unavailable — token not stored. Use env vars instead.`));
|
|
2614
|
+
print(ui_exports.style.fail(`keyring unavailable — token not stored. Use env vars instead.`));
|
|
3516
2615
|
logger.warn({
|
|
3517
2616
|
provider,
|
|
3518
2617
|
keyringKey,
|
|
@@ -3523,11 +2622,11 @@ async function runAuthSet(input) {
|
|
|
3523
2622
|
message: "keyring unavailable"
|
|
3524
2623
|
};
|
|
3525
2624
|
}
|
|
3526
|
-
print(style.success(`stored ${keyringKey} token${subject ? ` (${subject})` : ""}`));
|
|
2625
|
+
print(ui_exports.style.success(`stored ${keyringKey} token${subject ? ` (${subject})` : ""}`));
|
|
3527
2626
|
if (input.credentials) {
|
|
3528
2627
|
const { provider: from, environment } = input.credentials;
|
|
3529
2628
|
const variable = credentialVariable(provider, keyringKey, listed);
|
|
3530
|
-
print(style.hint(` ${from} cannot be written to from the CLI: add ${variable} to its "${environment}" environment yourself, so the token follows you to other machines`));
|
|
2629
|
+
print(ui_exports.style.hint(` ${from} cannot be written to from the CLI: add ${variable} to its "${environment}" environment yourself, so the token follows you to other machines`));
|
|
3531
2630
|
}
|
|
3532
2631
|
logger.info({
|
|
3533
2632
|
provider,
|
|
@@ -3545,14 +2644,14 @@ function runAuthUnset(input) {
|
|
|
3545
2644
|
const print = input.print ?? ((l) => console.log(l));
|
|
3546
2645
|
const logger = input.logger ?? getLogger();
|
|
3547
2646
|
if (deleteToken(input.provider)) {
|
|
3548
|
-
print(style.success(`removed ${input.provider} token`));
|
|
2647
|
+
print(ui_exports.style.success(`removed ${input.provider} token`));
|
|
3549
2648
|
logger.info({
|
|
3550
2649
|
provider: input.provider,
|
|
3551
2650
|
status: "ok"
|
|
3552
2651
|
}, `auth unset: ${input.provider}`);
|
|
3553
2652
|
return { status: "ok" };
|
|
3554
2653
|
}
|
|
3555
|
-
print(style.dim(`no stored token for ${input.provider}`));
|
|
2654
|
+
print(ui_exports.style.dim(`no stored token for ${input.provider}`));
|
|
3556
2655
|
logger.info({
|
|
3557
2656
|
provider: input.provider,
|
|
3558
2657
|
status: "skip"
|
|
@@ -3570,7 +2669,7 @@ async function runAuthCheck(input) {
|
|
|
3570
2669
|
const keyringKey = input.org ? `${provider}.${input.org}` : provider;
|
|
3571
2670
|
const token = getToken(keyringKey);
|
|
3572
2671
|
if (!token) {
|
|
3573
|
-
print(style.dim(`no stored token for ${keyringKey}`));
|
|
2672
|
+
print(ui_exports.style.dim(`no stored token for ${keyringKey}`));
|
|
3574
2673
|
logger.info({
|
|
3575
2674
|
provider,
|
|
3576
2675
|
keyringKey,
|
|
@@ -3583,7 +2682,7 @@ async function runAuthCheck(input) {
|
|
|
3583
2682
|
};
|
|
3584
2683
|
}
|
|
3585
2684
|
if (provider.includes(".")) {
|
|
3586
|
-
print(style.success(`${keyringKey}: token stored (feature key — no plugin verification)`));
|
|
2685
|
+
print(ui_exports.style.success(`${keyringKey}: token stored (feature key — no plugin verification)`));
|
|
3587
2686
|
return {
|
|
3588
2687
|
status: "ok",
|
|
3589
2688
|
message: "stored"
|
|
@@ -3593,16 +2692,16 @@ async function runAuthCheck(input) {
|
|
|
3593
2692
|
try {
|
|
3594
2693
|
const module = await importer(packageName);
|
|
3595
2694
|
if (typeof module.verifyToken !== "function") {
|
|
3596
|
-
print(style.warn(`${keyringKey}: token stored (plugin has no verifyToken; can't confirm validity)`));
|
|
2695
|
+
print(ui_exports.style.warn(`${keyringKey}: token stored (plugin has no verifyToken; can't confirm validity)`));
|
|
3597
2696
|
return {
|
|
3598
2697
|
status: "ok",
|
|
3599
2698
|
message: "stored, unverified"
|
|
3600
2699
|
};
|
|
3601
2700
|
}
|
|
3602
2701
|
const verify = () => module.verifyToken(token);
|
|
3603
|
-
const verified = input.showSpinner !== false ? await withSpinner(`Verifying ${keyringKey} token…`, verify) : await verify();
|
|
2702
|
+
const verified = input.showSpinner !== false ? await (0, ui_exports.withSpinner)(`Verifying ${keyringKey} token…`, verify) : await verify();
|
|
3604
2703
|
if (verified.ok) {
|
|
3605
|
-
print(style.success(`${keyringKey}: ok — ${verified.subject}`));
|
|
2704
|
+
print(ui_exports.style.success(`${keyringKey}: ok — ${verified.subject}`));
|
|
3606
2705
|
logger.info({
|
|
3607
2706
|
provider,
|
|
3608
2707
|
keyringKey,
|
|
@@ -3615,8 +2714,8 @@ async function runAuthCheck(input) {
|
|
|
3615
2714
|
message: verified.subject
|
|
3616
2715
|
};
|
|
3617
2716
|
}
|
|
3618
|
-
print(style.fail(`${keyringKey}: rejected — ${verified.message}`));
|
|
3619
|
-
if (module.AUTH_HINT) print(style.hint(` hint: ${module.AUTH_HINT}`));
|
|
2717
|
+
print(ui_exports.style.fail(`${keyringKey}: rejected — ${verified.message}`));
|
|
2718
|
+
if (module.AUTH_HINT) print(ui_exports.style.hint(` hint: ${module.AUTH_HINT}`));
|
|
3620
2719
|
logger.warn({
|
|
3621
2720
|
provider,
|
|
3622
2721
|
keyringKey,
|
|
@@ -3631,7 +2730,7 @@ async function runAuthCheck(input) {
|
|
|
3631
2730
|
} catch (err) {
|
|
3632
2731
|
const msg = errorMessage(err);
|
|
3633
2732
|
if (isModuleNotFound(err)) {
|
|
3634
|
-
print(style.warn(`${keyringKey}: token present — verification skipped (plugin not available here)`));
|
|
2733
|
+
print(ui_exports.style.warn(`${keyringKey}: token present — verification skipped (plugin not available here)`));
|
|
3635
2734
|
logger.info({
|
|
3636
2735
|
provider,
|
|
3637
2736
|
keyringKey,
|
|
@@ -3643,7 +2742,7 @@ async function runAuthCheck(input) {
|
|
|
3643
2742
|
message: "stored, unverified (plugin not available)"
|
|
3644
2743
|
};
|
|
3645
2744
|
}
|
|
3646
|
-
print(style.fail(`${keyringKey}: cannot verify — ${msg}`));
|
|
2745
|
+
print(ui_exports.style.fail(`${keyringKey}: cannot verify — ${msg}`));
|
|
3647
2746
|
logger.warn({
|
|
3648
2747
|
provider,
|
|
3649
2748
|
keyringKey,
|
|
@@ -3662,8 +2761,8 @@ async function runAuthList(input = {}) {
|
|
|
3662
2761
|
const importer = input.importer ?? defaultImporter;
|
|
3663
2762
|
const providers = listStoredProviders();
|
|
3664
2763
|
if (providers.length === 0) {
|
|
3665
|
-
print(style.dim("no stored tokens."));
|
|
3666
|
-
print(style.hint("run: holocron auth set <provider> <token>"));
|
|
2764
|
+
print(ui_exports.style.dim("no stored tokens."));
|
|
2765
|
+
print(ui_exports.style.hint("run: holocron auth set <provider> <token>"));
|
|
3667
2766
|
logger.info({ providers: 0 }, "auth list: done");
|
|
3668
2767
|
return {
|
|
3669
2768
|
status: "ok",
|
|
@@ -3683,11 +2782,11 @@ async function runAuthList(input = {}) {
|
|
|
3683
2782
|
const label = `${provider}${check.message ? ` — ${check.message}` : ""}`;
|
|
3684
2783
|
if (check.status === "ok") {
|
|
3685
2784
|
ok += 1;
|
|
3686
|
-
print(` ${style.success(label)}`);
|
|
2785
|
+
print(` ${ui_exports.style.success(label)}`);
|
|
3687
2786
|
} else if (check.status === "fail") {
|
|
3688
2787
|
fail += 1;
|
|
3689
|
-
print(` ${style.fail(label)}`);
|
|
3690
|
-
} else print(` ${style.dim(`· ${label}`)}`);
|
|
2788
|
+
print(` ${ui_exports.style.fail(label)}`);
|
|
2789
|
+
} else print(` ${ui_exports.style.dim(`· ${label}`)}`);
|
|
3691
2790
|
}
|
|
3692
2791
|
logger.info({
|
|
3693
2792
|
providers: providers.length,
|
|
@@ -3731,7 +2830,7 @@ function declaredVsActual(declared, actual, options) {
|
|
|
3731
2830
|
function printCheckRows(rows, print) {
|
|
3732
2831
|
const width = Math.max(0, ...rows.map((row) => row.title.length));
|
|
3733
2832
|
for (const row of rows) {
|
|
3734
|
-
print(statusRow(row.status, [row.title.padEnd(width), row.detail]));
|
|
2833
|
+
print((0, ui_exports.statusRow)(row.status, [row.title.padEnd(width), row.detail]));
|
|
3735
2834
|
for (const problem of row.problems) print(` - ${problem}`);
|
|
3736
2835
|
}
|
|
3737
2836
|
}
|
|
@@ -3739,7 +2838,7 @@ function printCheckRows(rows, print) {
|
|
|
3739
2838
|
/** A blank line, then the closing `N ok, N fail, N skipped`. */
|
|
3740
2839
|
function printCheckSummary(summary, print) {
|
|
3741
2840
|
print("");
|
|
3742
|
-
print(style.header(`${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped`));
|
|
2841
|
+
print(ui_exports.style.header(`${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped`));
|
|
3743
2842
|
}
|
|
3744
2843
|
// src/commands/doctor-checks/summarise-checks.ts
|
|
3745
2844
|
/** How many rows ended each way. */
|
|
@@ -3859,7 +2958,7 @@ const doctorTokensCommand = {
|
|
|
3859
2958
|
command: "tokens",
|
|
3860
2959
|
describe: "Check that each token a configured plugin takes is set and still accepted (read-only; no token is printed)",
|
|
3861
2960
|
handler: async (argv) => {
|
|
3862
|
-
const tokens = tokenContext(argv.token);
|
|
2961
|
+
const tokens = tokenContext$1(argv.token);
|
|
3863
2962
|
if (!tokens) return;
|
|
3864
2963
|
const loaded = await loadConfig(argv.cwd);
|
|
3865
2964
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -3895,7 +2994,7 @@ async function finishCredentialsFile(input) {
|
|
|
3895
2994
|
}
|
|
3896
2995
|
const cleanup = () => {
|
|
3897
2996
|
try {
|
|
3898
|
-
const outcome = (input.shred ?? shredFile)(path, identity);
|
|
2997
|
+
const outcome = (input.shred ?? auth_exports.shredFile)(path, identity);
|
|
3899
2998
|
if (outcome === "deleted") print(`deleted ${path}`);
|
|
3900
2999
|
else if (outcome === "missing") print(`${path} was already gone`);
|
|
3901
3000
|
else print(`left ${path} alone: it is no longer the file this command wrote`);
|
|
@@ -3916,7 +3015,7 @@ async function finishCredentialsFile(input) {
|
|
|
3916
3015
|
});
|
|
3917
3016
|
let cleaned;
|
|
3918
3017
|
try {
|
|
3919
|
-
await (input.waitForImport ?? waitForEnter)("press Enter when the import is done and the file will be deleted: ");
|
|
3018
|
+
await (input.waitForImport ?? ui_exports.waitForEnter)("press Enter when the import is done and the file will be deleted: ");
|
|
3920
3019
|
} finally {
|
|
3921
3020
|
for (const [signal, handler] of handlers) process.off(signal, handler);
|
|
3922
3021
|
cleaned = cleanup();
|
|
@@ -4047,7 +3146,7 @@ async function runAuthExport(input) {
|
|
|
4047
3146
|
} else missing.push(name);
|
|
4048
3147
|
continue;
|
|
4049
3148
|
}
|
|
4050
|
-
const line = dotenvLine(written, value);
|
|
3149
|
+
const line = (0, auth_exports.dotenvLine)(written, value);
|
|
4051
3150
|
if (line === null) {
|
|
4052
3151
|
unsupported.push(written);
|
|
4053
3152
|
continue;
|
|
@@ -4061,7 +3160,7 @@ async function runAuthExport(input) {
|
|
|
4061
3160
|
}
|
|
4062
3161
|
const taken = new Set(entries.map((e) => e.name));
|
|
4063
3162
|
for (const [name, value] of literals) {
|
|
4064
|
-
const line = dotenvLine(name, value);
|
|
3163
|
+
const line = (0, auth_exports.dotenvLine)(name, value);
|
|
4065
3164
|
if (taken.has(name)) continue;
|
|
4066
3165
|
if (line === null) {
|
|
4067
3166
|
unsupported.push(name);
|
|
@@ -4096,7 +3195,7 @@ async function runAuthExport(input) {
|
|
|
4096
3195
|
if (target === "clipboard") {
|
|
4097
3196
|
try {
|
|
4098
3197
|
const pasted = input.only?.length && lines.length === 1 && exported.length === 1 ? values.get(exported[0]) : text;
|
|
4099
|
-
await (input.copy ?? copyToClipboard)(pasted);
|
|
3198
|
+
await (input.copy ?? auth_exports.copyToClipboard)(pasted);
|
|
4100
3199
|
} catch (err) {
|
|
4101
3200
|
return refuse("clipboard", `could not copy to the clipboard: ${errorMessage(err)}`, "write the private file instead: `holocron auth export --file`");
|
|
4102
3201
|
}
|
|
@@ -4104,10 +3203,10 @@ async function runAuthExport(input) {
|
|
|
4104
3203
|
} else if (target === "file") {
|
|
4105
3204
|
if ((input.platform ?? process.platform) === "win32") return refuse("windows", "cannot make the file private on Windows: its mode bits are not enforced, so other users may read it", "use `holocron auth export --copy`, or pipe the output to a tool");
|
|
4106
3205
|
file = resolve(dirname(input.loaded.filepath), input.file || DEFAULT_FILE$1);
|
|
4107
|
-
const git = (input.isIgnored ?? isGitIgnored)(file);
|
|
3206
|
+
const git = (input.isIgnored ?? auth_exports.isGitIgnored)(file);
|
|
4108
3207
|
if (git === "tracked" || git === "unknown") return refuse("not-ignored", git === "tracked" ? `refusing to write tokens to ${file}: git does not ignore it, so it could be committed` : `refusing to write tokens to ${file}: git could not say whether it ignores it`, "add it to .gitignore, or choose a path outside the repository with --file");
|
|
4109
3208
|
try {
|
|
4110
|
-
identity = (input.writeFile ?? writeCredentialsFile)(file, text, input.force === true);
|
|
3209
|
+
identity = (input.writeFile ?? auth_exports.writeCredentialsFile)(file, text, input.force === true);
|
|
4111
3210
|
} catch (err) {
|
|
4112
3211
|
return refuse("write", `could not write ${file}: ${errorMessage(err)}`, "an existing file is never overwritten: delete it, or pass --force to replace it");
|
|
4113
3212
|
}
|
|
@@ -4118,15 +3217,15 @@ async function runAuthExport(input) {
|
|
|
4118
3217
|
}
|
|
4119
3218
|
}
|
|
4120
3219
|
print(`exported ${exported.length} of ${tokens.size + literals.size + placeholders.length}:`);
|
|
4121
|
-
for (const name of exported) print(` ${style.success(name)}`);
|
|
4122
|
-
for (const name of blank) print(` ${style.dim("·")} ${name}${style.dim(" (written empty: fill it in)")}`);
|
|
4123
|
-
for (const name of missing) print(` ${style.dim("·")} ${name}${tokens.get(name)?.optional ? style.dim(" (optional)") : ""}`);
|
|
4124
|
-
for (const name of [...conflicts].sort(compare$1)) print(` ${style.fail(`${name} (listed by two plugins under different keyring entries, so not exported)`)}`);
|
|
4125
|
-
for (const name of unsupported) print(` ${style.fail(`${name} (a value dotenv cannot carry unchanged, so add it by hand)`)}`);
|
|
3220
|
+
for (const name of exported) print(` ${ui_exports.style.success(name)}`);
|
|
3221
|
+
for (const name of blank) print(` ${ui_exports.style.dim("·")} ${name}${ui_exports.style.dim(" (written empty: fill it in)")}`);
|
|
3222
|
+
for (const name of missing) print(` ${ui_exports.style.dim("·")} ${name}${tokens.get(name)?.optional ? ui_exports.style.dim(" (optional)") : ""}`);
|
|
3223
|
+
for (const name of [...conflicts].sort(compare$1)) print(` ${ui_exports.style.fail(`${name} (listed by two plugins under different keyring entries, so not exported)`)}`);
|
|
3224
|
+
for (const name of unsupported) print(` ${ui_exports.style.fail(`${name} (a value dotenv cannot carry unchanged, so add it by hand)`)}`);
|
|
4126
3225
|
if (unavailable.length > 0) {
|
|
4127
3226
|
print("");
|
|
4128
3227
|
print("could not load, so the tokens they take are not listed:");
|
|
4129
|
-
for (const pkg of [...unavailable].sort(compare$1)) print(` ${style.fail(`${pkg} (${reasons.get(pkg)})`)}`);
|
|
3228
|
+
for (const pkg of [...unavailable].sort(compare$1)) print(` ${ui_exports.style.fail(`${pkg} (${reasons.get(pkg)})`)}`);
|
|
4130
3229
|
}
|
|
4131
3230
|
if (destination === "clipboard" || destination === "file") print("");
|
|
4132
3231
|
if (destination === "clipboard") print("copied to the clipboard: paste it, then clear the clipboard");
|
|
@@ -4235,7 +3334,7 @@ const authCheckCommand = {
|
|
|
4235
3334
|
describe: "Re-verify a stored bootstrap token",
|
|
4236
3335
|
builder: authCheckArgs,
|
|
4237
3336
|
handler: async (argv) => {
|
|
4238
|
-
const [provider] = await promptForPositionals(getEntry("auth check"), argv);
|
|
3337
|
+
const [provider] = await (0, ui_exports.promptForPositionals)(getEntry("auth check"), argv);
|
|
4239
3338
|
if ((await runAuthCheck({
|
|
4240
3339
|
provider,
|
|
4241
3340
|
...argv.org ? { org: argv.org } : {}
|
|
@@ -4276,7 +3375,7 @@ const authSetCommand = {
|
|
|
4276
3375
|
describe: "Verify + store a bootstrap token for a provider",
|
|
4277
3376
|
builder: authSetArgs,
|
|
4278
3377
|
handler: async (argv) => {
|
|
4279
|
-
const [provider] = await promptForPositionals(getEntry("auth set"), argv);
|
|
3378
|
+
const [provider] = await (0, ui_exports.promptForPositionals)(getEntry("auth set"), argv);
|
|
4280
3379
|
const credentials = await credentialsOf(argv.cwd);
|
|
4281
3380
|
if ((await runAuthSet({
|
|
4282
3381
|
provider,
|
|
@@ -4294,7 +3393,7 @@ const authUnsetCommand = {
|
|
|
4294
3393
|
describe: "Remove a stored bootstrap token",
|
|
4295
3394
|
builder: authUnsetArgs,
|
|
4296
3395
|
handler: async (argv) => {
|
|
4297
|
-
const [provider] = await promptForPositionals(getEntry("auth unset"), argv);
|
|
3396
|
+
const [provider] = await (0, ui_exports.promptForPositionals)(getEntry("auth unset"), argv);
|
|
4298
3397
|
runAuthUnset({ provider });
|
|
4299
3398
|
}
|
|
4300
3399
|
};
|
|
@@ -4302,7 +3401,7 @@ const authUnsetCommand = {
|
|
|
4302
3401
|
const authCommand = {
|
|
4303
3402
|
command: "auth <subcommand>",
|
|
4304
3403
|
describe: "Manage bootstrap credentials in the OS keyring",
|
|
4305
|
-
builder: (y) => y.command(authSetCommand).command(authUnsetCommand).command(authCheckCommand).command(authListCommand).command(authExportCommand).command(groupMenu("auth")),
|
|
3404
|
+
builder: (y) => y.command(authSetCommand).command(authUnsetCommand).command(authCheckCommand).command(authListCommand).command(authExportCommand).command(groupMenu$1("auth")),
|
|
4306
3405
|
handler: () => {}
|
|
4307
3406
|
};
|
|
4308
3407
|
// src/commands/clone/clone.args.ts
|
|
@@ -4388,7 +3487,7 @@ async function runClone(input) {
|
|
|
4388
3487
|
});
|
|
4389
3488
|
print("");
|
|
4390
3489
|
if (!existsSync(targetDir)) {
|
|
4391
|
-
if (dryRun) print(style.dim(` would create ${targetDir}`));
|
|
3490
|
+
if (dryRun) print(ui_exports.style.dim(` would create ${targetDir}`));
|
|
4392
3491
|
else mkdirSync(targetDir, { recursive: true });
|
|
4393
3492
|
}
|
|
4394
3493
|
let repos;
|
|
@@ -4417,7 +3516,7 @@ async function runClone(input) {
|
|
|
4417
3516
|
toClone: repos.length - alreadyCloned
|
|
4418
3517
|
};
|
|
4419
3518
|
if (!await input.confirmWholeOrg(scope)) {
|
|
4420
|
-
print(style.dim(" aborted — nothing cloned"));
|
|
3519
|
+
print(ui_exports.style.dim(" aborted — nothing cloned"));
|
|
4421
3520
|
logger.info({
|
|
4422
3521
|
org: input.org,
|
|
4423
3522
|
...scope
|
|
@@ -4437,7 +3536,7 @@ async function runClone(input) {
|
|
|
4437
3536
|
for (const repo of repos) {
|
|
4438
3537
|
const dest = join(targetDir, repoDirName(repo));
|
|
4439
3538
|
if (existsSync(dest)) {
|
|
4440
|
-
print(statusRow("skip", [
|
|
3539
|
+
print((0, ui_exports.statusRow)("skip", [
|
|
4441
3540
|
repo.full_name,
|
|
4442
3541
|
dest,
|
|
4443
3542
|
"already exists"
|
|
@@ -4446,14 +3545,14 @@ async function runClone(input) {
|
|
|
4446
3545
|
continue;
|
|
4447
3546
|
}
|
|
4448
3547
|
if (dryRun) {
|
|
4449
|
-
print(style.dim(` would clone ${repo.full_name} → ${dest}`));
|
|
3548
|
+
print(ui_exports.style.dim(` would clone ${repo.full_name} → ${dest}`));
|
|
4450
3549
|
cloned++;
|
|
4451
3550
|
continue;
|
|
4452
3551
|
}
|
|
4453
|
-
print(style.step(` clone ${repo.full_name} → ${dest}`));
|
|
3552
|
+
print(ui_exports.style.step(` clone ${repo.full_name} → ${dest}`));
|
|
4454
3553
|
const { clone_url } = repo;
|
|
4455
3554
|
if (!clone_url.startsWith("https://github.com/")) {
|
|
4456
|
-
print(statusRow("fail", [
|
|
3555
|
+
print((0, ui_exports.statusRow)("fail", [
|
|
4457
3556
|
repo.full_name,
|
|
4458
3557
|
dest,
|
|
4459
3558
|
`unexpected clone URL: ${clone_url}`
|
|
@@ -4465,7 +3564,7 @@ async function runClone(input) {
|
|
|
4465
3564
|
try {
|
|
4466
3565
|
encodedToken = encodeTokenForGitHttpAuth(input.token);
|
|
4467
3566
|
} catch (err) {
|
|
4468
|
-
print(statusRow("fail", [
|
|
3567
|
+
print((0, ui_exports.statusRow)("fail", [
|
|
4469
3568
|
repo.full_name,
|
|
4470
3569
|
dest,
|
|
4471
3570
|
`invalid token format: ${errorMessage(err)}`
|
|
@@ -4479,16 +3578,16 @@ async function runClone(input) {
|
|
|
4479
3578
|
`https://x-access-token:${encodedToken}@github.com/${clone_url.slice(19)}`,
|
|
4480
3579
|
dest
|
|
4481
3580
|
], { cwd: targetDir }).status !== 0) {
|
|
4482
|
-
print(statusRow("fail", [repo.full_name, dest]));
|
|
3581
|
+
print((0, ui_exports.statusRow)("fail", [repo.full_name, dest]));
|
|
4483
3582
|
failed++;
|
|
4484
3583
|
} else {
|
|
4485
|
-
print(statusRow("ok", [repo.full_name, dest]));
|
|
3584
|
+
print((0, ui_exports.statusRow)("ok", [repo.full_name, dest]));
|
|
4486
3585
|
cloned++;
|
|
4487
3586
|
}
|
|
4488
3587
|
}
|
|
4489
3588
|
const summary = `${cloned} cloned, ${failed} failed, ${skipped} skipped`;
|
|
4490
3589
|
print("");
|
|
4491
|
-
print(dryRun ? style.dim(` dry-run: ${summary}`) : failed > 0 ? style.fail(` ${summary}`) : style.success(` ${summary}`));
|
|
3590
|
+
print(dryRun ? ui_exports.style.dim(` dry-run: ${summary}`) : failed > 0 ? ui_exports.style.fail(` ${summary}`) : ui_exports.style.success(` ${summary}`));
|
|
4492
3591
|
const status = dryRun ? "dry-run" : failed > 0 ? "fail" : "ok";
|
|
4493
3592
|
logger[failed > 0 ? "warn" : "info"]({
|
|
4494
3593
|
org: input.org,
|
|
@@ -4519,7 +3618,7 @@ const cloneCommand = {
|
|
|
4519
3618
|
describe: "Clone a single repo (org/repo) or every repo in an org (org)",
|
|
4520
3619
|
builder: cloneArgs,
|
|
4521
3620
|
handler: async (argv) => {
|
|
4522
|
-
const tokens = tokenContext(argv.token);
|
|
3621
|
+
const tokens = tokenContext$1(argv.token);
|
|
4523
3622
|
if (!tokens) return;
|
|
4524
3623
|
let token;
|
|
4525
3624
|
try {
|
|
@@ -4529,7 +3628,7 @@ const cloneCommand = {
|
|
|
4529
3628
|
process.exitCode = 1;
|
|
4530
3629
|
return;
|
|
4531
3630
|
}
|
|
4532
|
-
const [targetInput] = await promptForPositionals(getEntry("clone"), argv);
|
|
3631
|
+
const [targetInput] = await (0, ui_exports.promptForPositionals)(getEntry("clone"), argv);
|
|
4533
3632
|
const { org, repo } = parseCloneTarget(targetInput);
|
|
4534
3633
|
const report = await runClone({
|
|
4535
3634
|
org,
|
|
@@ -4538,7 +3637,7 @@ const cloneCommand = {
|
|
|
4538
3637
|
dryRun: argv.dryRun,
|
|
4539
3638
|
...argv.dir ? { dir: argv.dir } : {},
|
|
4540
3639
|
...!repo ? { confirmWholeOrg: async ({ total, alreadyCloned, toClone }) => {
|
|
4541
|
-
if (!process.stdin.isTTY) throw new NonInteractiveError(`clone: cloning every repo in "${org}" needs interactive confirmation — run this from a terminal, or pass a specific org/repo instead`);
|
|
3640
|
+
if (!process.stdin.isTTY) throw new ui_exports.NonInteractiveError(`clone: cloning every repo in "${org}" needs interactive confirmation — run this from a terminal, or pass a specific org/repo instead`);
|
|
4542
3641
|
if (toClone === 0) return true;
|
|
4543
3642
|
return confirm({
|
|
4544
3643
|
message: `${org} has ${total} repos — ${alreadyCloned} already cloned locally, ${toClone} new. Clone them all?`,
|
|
@@ -4551,7 +3650,7 @@ const cloneCommand = {
|
|
|
4551
3650
|
if (await confirm({
|
|
4552
3651
|
message: `Open ${openTarget}?`,
|
|
4553
3652
|
default: false
|
|
4554
|
-
})) openPath(openTarget);
|
|
3653
|
+
})) (0, ui_exports.openPath)(openTarget);
|
|
4555
3654
|
}
|
|
4556
3655
|
});
|
|
4557
3656
|
if (report.status === "fail") {
|
|
@@ -4574,7 +3673,8 @@ const configShowCommand = {
|
|
|
4574
3673
|
describe: "Print the resolved holocron config",
|
|
4575
3674
|
builder: configShowArgs,
|
|
4576
3675
|
handler: async (argv) => {
|
|
4577
|
-
|
|
3676
|
+
const loaded = await loadConfig(argv.cwd);
|
|
3677
|
+
await (0, ui_exports.viewJson)(loaded.resolved, {
|
|
4578
3678
|
depth: argv.depth,
|
|
4579
3679
|
interactive: argv.interactive
|
|
4580
3680
|
});
|
|
@@ -4594,9 +3694,9 @@ const cleanupPreviewArgs = (y) => y.positional("pr", {
|
|
|
4594
3694
|
});
|
|
4595
3695
|
// src/commands/cleanup-preview/cleanup-preview.ts
|
|
4596
3696
|
function prStateLabel(pr) {
|
|
4597
|
-
if (pr.merged) return style.success("merged");
|
|
4598
|
-
if (pr.state === "closed") return style.dim("closed (not merged)");
|
|
4599
|
-
return style.warn("open");
|
|
3697
|
+
if (pr.merged) return ui_exports.style.success("merged");
|
|
3698
|
+
if (pr.state === "closed") return ui_exports.style.dim("closed (not merged)");
|
|
3699
|
+
return ui_exports.style.warn("open");
|
|
4600
3700
|
}
|
|
4601
3701
|
async function runCleanupPreview(input) {
|
|
4602
3702
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -4621,10 +3721,10 @@ async function runCleanupPreview(input) {
|
|
|
4621
3721
|
}
|
|
4622
3722
|
const branch = `${(input.repo ?? input.loaded.resolved.repo?.name ?? "").split("/").pop()}-pr-${pr.number}`;
|
|
4623
3723
|
print("");
|
|
4624
|
-
print(`${style.header(`PR #${pr.number}`)} — ${pr.title}`);
|
|
4625
|
-
print(` Status : ${prStateLabel(pr)} | Branch : ${style.dim(pr.branch)}`);
|
|
4626
|
-
print(` URL : ${style.dim(pr.url)}`);
|
|
4627
|
-
print(` CF alias : ${style.dim(branch)}`);
|
|
3724
|
+
print(`${ui_exports.style.header(`PR #${pr.number}`)} — ${pr.title}`);
|
|
3725
|
+
print(` Status : ${prStateLabel(pr)} | Branch : ${ui_exports.style.dim(pr.branch)}`);
|
|
3726
|
+
print(` URL : ${ui_exports.style.dim(pr.url)}`);
|
|
3727
|
+
print(` CF alias : ${ui_exports.style.dim(branch)}`);
|
|
4628
3728
|
print("");
|
|
4629
3729
|
if (!loader.has("deployment")) throw new Error("deployment capability is not configured — add a deployment provider to holocron.config.json");
|
|
4630
3730
|
const deploy = loader.get("deployment");
|
|
@@ -4637,7 +3737,7 @@ async function runCleanupPreview(input) {
|
|
|
4637
3737
|
throw new Error(`Failed to list deployments: ${message}`, { cause: err });
|
|
4638
3738
|
}
|
|
4639
3739
|
if (deployments.length === 0) {
|
|
4640
|
-
print(style.dim(`No deployments found for branch ${branch}.`));
|
|
3740
|
+
print(ui_exports.style.dim(`No deployments found for branch ${branch}.`));
|
|
4641
3741
|
logger.info({
|
|
4642
3742
|
pr: pr.number,
|
|
4643
3743
|
branch,
|
|
@@ -4653,16 +3753,16 @@ async function runCleanupPreview(input) {
|
|
|
4653
3753
|
status: "none"
|
|
4654
3754
|
};
|
|
4655
3755
|
}
|
|
4656
|
-
print(`Found ${deployments.length} deployment${deployments.length === 1 ? "" : "s"} for ${style.dim(branch)}:`);
|
|
3756
|
+
print(`Found ${deployments.length} deployment${deployments.length === 1 ? "" : "s"} for ${ui_exports.style.dim(branch)}:`);
|
|
4657
3757
|
print("");
|
|
4658
3758
|
if (pr.state === "open") {
|
|
4659
|
-
print(style.warn(`PR #${pr.number} is still open. Deleting its preview deployments will break the live preview link.`));
|
|
4660
|
-
print(style.warn("Nothing is pre-selected — check the deployments you want to remove."));
|
|
3759
|
+
print(ui_exports.style.warn(`PR #${pr.number} is still open. Deleting its preview deployments will break the live preview link.`));
|
|
3760
|
+
print(ui_exports.style.warn("Nothing is pre-selected — check the deployments you want to remove."));
|
|
4661
3761
|
print("");
|
|
4662
3762
|
}
|
|
4663
3763
|
const choices = deployments.map((d) => {
|
|
4664
3764
|
return {
|
|
4665
|
-
name: `${d.id.includes(":") ? d.id.split(":").pop() : d.id} ${d.createdAt ? style.dim(d.createdAt.slice(0, 10)) : ""} ${style.dim(d.url)}`,
|
|
3765
|
+
name: `${d.id.includes(":") ? d.id.split(":").pop() : d.id} ${d.createdAt ? ui_exports.style.dim(d.createdAt.slice(0, 10)) : ""} ${ui_exports.style.dim(d.url)}`,
|
|
4666
3766
|
value: d.id,
|
|
4667
3767
|
checked: pr.state !== "open"
|
|
4668
3768
|
};
|
|
@@ -4674,7 +3774,7 @@ async function runCleanupPreview(input) {
|
|
|
4674
3774
|
choices
|
|
4675
3775
|
});
|
|
4676
3776
|
} catch {
|
|
4677
|
-
print(style.dim("Aborted."));
|
|
3777
|
+
print(ui_exports.style.dim("Aborted."));
|
|
4678
3778
|
return {
|
|
4679
3779
|
pr,
|
|
4680
3780
|
branch,
|
|
@@ -4684,7 +3784,7 @@ async function runCleanupPreview(input) {
|
|
|
4684
3784
|
};
|
|
4685
3785
|
}
|
|
4686
3786
|
if (selected.length === 0) {
|
|
4687
|
-
print(style.dim("Nothing selected — no deployments deleted."));
|
|
3787
|
+
print(ui_exports.style.dim("Nothing selected — no deployments deleted."));
|
|
4688
3788
|
return {
|
|
4689
3789
|
pr,
|
|
4690
3790
|
branch,
|
|
@@ -4696,7 +3796,7 @@ async function runCleanupPreview(input) {
|
|
|
4696
3796
|
print("");
|
|
4697
3797
|
try {
|
|
4698
3798
|
const count = await deploy.deletePreviewDeployments(input.project, selected);
|
|
4699
|
-
print(style.success(`Deleted ${count} deployment${count === 1 ? "" : "s"}.`));
|
|
3799
|
+
print(ui_exports.style.success(`Deleted ${count} deployment${count === 1 ? "" : "s"}.`));
|
|
4700
3800
|
logger.info({
|
|
4701
3801
|
pr: pr.number,
|
|
4702
3802
|
branch,
|
|
@@ -4713,7 +3813,7 @@ async function runCleanupPreview(input) {
|
|
|
4713
3813
|
};
|
|
4714
3814
|
} catch (err) {
|
|
4715
3815
|
const message = errorMessage(err);
|
|
4716
|
-
print(style.fail(message));
|
|
3816
|
+
print(ui_exports.style.fail(message));
|
|
4717
3817
|
logger.warn({
|
|
4718
3818
|
pr: pr.number,
|
|
4719
3819
|
branch,
|
|
@@ -4737,9 +3837,9 @@ const cleanupPreviewCommand = {
|
|
|
4737
3837
|
describe: "List and delete Cloudflare Pages preview deployments for a GitHub PR",
|
|
4738
3838
|
builder: cleanupPreviewArgs,
|
|
4739
3839
|
handler: async (argv) => {
|
|
4740
|
-
const tokens = tokenContext(argv.token);
|
|
3840
|
+
const tokens = tokenContext$1(argv.token);
|
|
4741
3841
|
if (!tokens) return;
|
|
4742
|
-
const [pr] = await promptForPositionals(getEntry("deploy cleanup-preview"), argv);
|
|
3842
|
+
const [pr] = await (0, ui_exports.promptForPositionals)(getEntry("deploy cleanup-preview"), argv);
|
|
4743
3843
|
const loaded = await loadConfig(argv.cwd);
|
|
4744
3844
|
applyResolvedConfig(argv, loaded.resolved);
|
|
4745
3845
|
if ((await runCleanupPreview({
|
|
@@ -5061,12 +4161,12 @@ async function runDeploy(input) {
|
|
|
5061
4161
|
projectId: input.projectId,
|
|
5062
4162
|
dryRun: dryRun || void 0
|
|
5063
4163
|
}, "deploy: start");
|
|
5064
|
-
print(style.header(`Holocron deploy — branch=${input.branch}${input.target ? `, target=${input.target}` : " (preview)"}${dryRun ? " (dry-run)" : ""}`));
|
|
4164
|
+
print(ui_exports.style.header(`Holocron deploy — branch=${input.branch}${input.target ? `, target=${input.target}` : " (preview)"}${dryRun ? " (dry-run)" : ""}`));
|
|
5065
4165
|
if (!loader.has("deployment")) throw new Error("deployment capability is not configured — add a `deployment` provider to holocron.config.json");
|
|
5066
4166
|
const deploy = loader.get("deployment");
|
|
5067
4167
|
if (dryRun) {
|
|
5068
4168
|
const message = `would: ${deploy.providerName}.triggerDeployment(projectId=${input.projectId}, branch=${input.branch}${input.target ? `, target=${input.target}` : ""})`;
|
|
5069
|
-
print(` ${style.dim(`… ${message}`)}`);
|
|
4169
|
+
print(` ${ui_exports.style.dim(`… ${message}`)}`);
|
|
5070
4170
|
return {
|
|
5071
4171
|
deployment: null,
|
|
5072
4172
|
status: "dry-run",
|
|
@@ -5074,7 +4174,7 @@ async function runDeploy(input) {
|
|
|
5074
4174
|
};
|
|
5075
4175
|
}
|
|
5076
4176
|
try {
|
|
5077
|
-
const triggered = await withSpinner(`Deploying ${input.branch}${input.target ? ` → ${input.target}` : ""}…`, () => deploy.triggerDeployment({
|
|
4177
|
+
const triggered = await (0, ui_exports.withSpinner)(`Deploying ${input.branch}${input.target ? ` → ${input.target}` : ""}…`, () => deploy.triggerDeployment({
|
|
5078
4178
|
projectId: input.projectId,
|
|
5079
4179
|
branch: input.branch,
|
|
5080
4180
|
...input.target ? { target: input.target } : {}
|
|
@@ -5084,10 +4184,10 @@ async function runDeploy(input) {
|
|
|
5084
4184
|
url: triggered.url,
|
|
5085
4185
|
id: triggered.id
|
|
5086
4186
|
}, "deploy: triggered");
|
|
5087
|
-
const record = TERMINAL_STATUSES.has(triggered.status) ? triggered : await withSpinner(`Waiting for ${withScheme(triggered.url)} to finish…`, () => waitForDeployment(deploy, triggered.id, input.wait));
|
|
4187
|
+
const record = TERMINAL_STATUSES.has(triggered.status) ? triggered : await (0, ui_exports.withSpinner)(`Waiting for ${withScheme(triggered.url)} to finish…`, () => waitForDeployment(deploy, triggered.id, input.wait));
|
|
5088
4188
|
if (record.status !== "ready") {
|
|
5089
4189
|
const message = terminalFailure(record);
|
|
5090
|
-
print(` ${style.fail(`${message} — ${withScheme(triggered.url)}`)}`);
|
|
4190
|
+
print(` ${ui_exports.style.fail(`${message} — ${withScheme(triggered.url)}`)}`);
|
|
5091
4191
|
logger.warn({
|
|
5092
4192
|
id: record.id,
|
|
5093
4193
|
status: record.status,
|
|
@@ -5099,7 +4199,7 @@ async function runDeploy(input) {
|
|
|
5099
4199
|
message
|
|
5100
4200
|
};
|
|
5101
4201
|
}
|
|
5102
|
-
print(` ${style.success(`${record.status} — ${withScheme(triggered.url)}`)}`);
|
|
4202
|
+
print(` ${ui_exports.style.success(`${record.status} — ${withScheme(triggered.url)}`)}`);
|
|
5103
4203
|
logger.info({
|
|
5104
4204
|
status: record.status,
|
|
5105
4205
|
url: triggered.url,
|
|
@@ -5111,7 +4211,7 @@ async function runDeploy(input) {
|
|
|
5111
4211
|
};
|
|
5112
4212
|
} catch (err) {
|
|
5113
4213
|
const message = errorMessage(err);
|
|
5114
|
-
print(` ${style.fail(message)}`);
|
|
4214
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
5115
4215
|
logger.warn({
|
|
5116
4216
|
branch: input.branch,
|
|
5117
4217
|
reason: message
|
|
@@ -5152,13 +4252,13 @@ async function runDeployFromFiles(input) {
|
|
|
5152
4252
|
projectId: input.projectId,
|
|
5153
4253
|
dryRun: dryRun || void 0
|
|
5154
4254
|
}, "deploy: start (files)");
|
|
5155
|
-
print(style.header(`Holocron deploy — files=${input.dir} (${fileCount} file${fileCount === 1 ? "" : "s"})${input.target ? `, target=${input.target}` : " (preview)"}${dryRun ? " (dry-run)" : ""}`));
|
|
4255
|
+
print(ui_exports.style.header(`Holocron deploy — files=${input.dir} (${fileCount} file${fileCount === 1 ? "" : "s"})${input.target ? `, target=${input.target}` : " (preview)"}${dryRun ? " (dry-run)" : ""}`));
|
|
5156
4256
|
if (!loader.has("deployment")) throw new Error("deployment capability is not configured — add a `deployment` provider to holocron.config.json");
|
|
5157
4257
|
const deploy = loader.get("deployment");
|
|
5158
4258
|
if (!deploy.deployFunction) throw new Error(`deployment provider "${deploy.providerName}" does not support deploying from files — deployFunction() is not implemented`);
|
|
5159
4259
|
if (dryRun) {
|
|
5160
4260
|
const message = `would: ${deploy.providerName}.deployFunction(projectId=${input.projectId}, files=${fileCount}${input.target ? `, target=${input.target}` : ""})`;
|
|
5161
|
-
print(` ${style.dim(`… ${message}`)}`);
|
|
4261
|
+
print(` ${ui_exports.style.dim(`… ${message}`)}`);
|
|
5162
4262
|
return {
|
|
5163
4263
|
deployment: null,
|
|
5164
4264
|
status: "dry-run",
|
|
@@ -5166,7 +4266,7 @@ async function runDeployFromFiles(input) {
|
|
|
5166
4266
|
};
|
|
5167
4267
|
}
|
|
5168
4268
|
try {
|
|
5169
|
-
const result = await withSpinner(`Deploying ${fileCount} file${fileCount === 1 ? "" : "s"} from ${input.dir}…`, () => deploy.deployFunction(input.projectId, {
|
|
4269
|
+
const result = await (0, ui_exports.withSpinner)(`Deploying ${fileCount} file${fileCount === 1 ? "" : "s"} from ${input.dir}…`, () => deploy.deployFunction(input.projectId, {
|
|
5170
4270
|
files,
|
|
5171
4271
|
...input.target ? { target: input.target } : {}
|
|
5172
4272
|
}));
|
|
@@ -5174,10 +4274,10 @@ async function runDeployFromFiles(input) {
|
|
|
5174
4274
|
url: result.url,
|
|
5175
4275
|
id: result.deploymentId
|
|
5176
4276
|
}, "deploy: triggered (files)");
|
|
5177
|
-
const record = await withSpinner(`Waiting for ${withScheme(result.url)} to finish…`, () => waitForDeployment(deploy, result.deploymentId, input.wait));
|
|
4277
|
+
const record = await (0, ui_exports.withSpinner)(`Waiting for ${withScheme(result.url)} to finish…`, () => waitForDeployment(deploy, result.deploymentId, input.wait));
|
|
5178
4278
|
if (record.status !== "ready") {
|
|
5179
4279
|
const message = terminalFailure(record);
|
|
5180
|
-
print(` ${style.fail(`${message} — ${withScheme(result.url)}`)}`);
|
|
4280
|
+
print(` ${ui_exports.style.fail(`${message} — ${withScheme(result.url)}`)}`);
|
|
5181
4281
|
logger.warn({
|
|
5182
4282
|
id: record.id,
|
|
5183
4283
|
status: record.status,
|
|
@@ -5189,7 +4289,7 @@ async function runDeployFromFiles(input) {
|
|
|
5189
4289
|
message
|
|
5190
4290
|
};
|
|
5191
4291
|
}
|
|
5192
|
-
print(` ${style.success(withScheme(result.url))}`);
|
|
4292
|
+
print(` ${ui_exports.style.success(withScheme(result.url))}`);
|
|
5193
4293
|
logger.info({
|
|
5194
4294
|
url: result.url,
|
|
5195
4295
|
id: result.deploymentId
|
|
@@ -5200,7 +4300,7 @@ async function runDeployFromFiles(input) {
|
|
|
5200
4300
|
};
|
|
5201
4301
|
} catch (err) {
|
|
5202
4302
|
const message = errorMessage(err);
|
|
5203
|
-
print(` ${style.fail(message)}`);
|
|
4303
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
5204
4304
|
logger.warn({
|
|
5205
4305
|
dir: input.dir,
|
|
5206
4306
|
reason: message
|
|
@@ -5223,7 +4323,7 @@ const deployCommand = {
|
|
|
5223
4323
|
process.exitCode = 1;
|
|
5224
4324
|
return;
|
|
5225
4325
|
}
|
|
5226
|
-
const tokens = tokenContext(argv.token);
|
|
4326
|
+
const tokens = tokenContext$1(argv.token);
|
|
5227
4327
|
if (!tokens) return;
|
|
5228
4328
|
const loaded = await loadConfig(argv.cwd);
|
|
5229
4329
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -5243,7 +4343,7 @@ const deployCommand = {
|
|
|
5243
4343
|
})).status === "fail") process.exitCode = 1;
|
|
5244
4344
|
return;
|
|
5245
4345
|
}
|
|
5246
|
-
const [branch] = await promptForPositionals(getEntry("deploy"), argv);
|
|
4346
|
+
const [branch] = await (0, ui_exports.promptForPositionals)(getEntry("deploy"), argv);
|
|
5247
4347
|
if ((await runDeploy({
|
|
5248
4348
|
loaded,
|
|
5249
4349
|
context,
|
|
@@ -5253,153 +4353,6 @@ const deployCommand = {
|
|
|
5253
4353
|
})).status === "fail") process.exitCode = 1;
|
|
5254
4354
|
}
|
|
5255
4355
|
};
|
|
5256
|
-
// ../dagobah/dist/index.mjs
|
|
5257
|
-
/**
|
|
5258
|
-
* Wrap an unquoted PEM block in double quotes. `op environment secret list --format=dotenv` prints a multi-line
|
|
5259
|
-
* value (a private key) unquoted, which `dotenv` reads as its first line only; quoted, it reads the whole block.
|
|
5260
|
-
* A PEM holds no quote or backslash, so nothing needs escaping.
|
|
5261
|
-
*/
|
|
5262
|
-
function quotePem(text) {
|
|
5263
|
-
return text.replace(/^([A-Za-z_][A-Za-z0-9_]*)=(-----BEGIN [^-]+-----[\s\S]*?-----END [^-]+-----)[ \t]*$/gm, "$1=\"$2\"");
|
|
5264
|
-
}
|
|
5265
|
-
/**
|
|
5266
|
-
* The environment a local app runs with: the variables already in the process, and what the 1Password
|
|
5267
|
-
* Environment `environment` holds for the rest (read with `op environment secret list`, the way the 1Password
|
|
5268
|
-
* plugin reads one, so Touch ID asks once). The process wins, so a variable exported for one run overrides the
|
|
5269
|
-
* Environment. The `required` ones must end up set; a message names the ones that are not, and never a
|
|
5270
|
-
* value. Nothing is written to disk.
|
|
5271
|
-
*/
|
|
5272
|
-
function loadDevEnv(input) {
|
|
5273
|
-
const REQUIRED = input.required;
|
|
5274
|
-
const env = input.env ?? process.env;
|
|
5275
|
-
const present = (name) => (env[name] ?? "") !== "";
|
|
5276
|
-
let merged = env;
|
|
5277
|
-
if (!REQUIRED.every(present)) {
|
|
5278
|
-
const result = (input.spawn ?? spawnSync)("op", [
|
|
5279
|
-
"environment",
|
|
5280
|
-
"secret",
|
|
5281
|
-
"list",
|
|
5282
|
-
input.environment,
|
|
5283
|
-
"--reveal",
|
|
5284
|
-
"--format=dotenv"
|
|
5285
|
-
], {
|
|
5286
|
-
encoding: "utf8",
|
|
5287
|
-
stdio: [
|
|
5288
|
-
"inherit",
|
|
5289
|
-
"pipe",
|
|
5290
|
-
"pipe"
|
|
5291
|
-
]
|
|
5292
|
-
});
|
|
5293
|
-
if (result.error || result.status !== 0) {
|
|
5294
|
-
const why = result.error?.message ?? result.stderr.trim().split("\n")[0];
|
|
5295
|
-
throw new Error(`could not read the 1Password Environment "${input.environment}": ${why || "op failed"}`);
|
|
5296
|
-
}
|
|
5297
|
-
merged = {
|
|
5298
|
-
...parse(quotePem(String(result.stdout))),
|
|
5299
|
-
...Object.fromEntries(Object.entries(env).filter(([, v]) => v !== void 0 && v !== ""))
|
|
5300
|
-
};
|
|
5301
|
-
}
|
|
5302
|
-
const missing = REQUIRED.filter((name) => (merged[name] ?? "") === "");
|
|
5303
|
-
if (missing.length > 0) throw new Error(`missing from the environment and from "${input.environment}": ${missing.join(", ")}`);
|
|
5304
|
-
return merged;
|
|
5305
|
-
}
|
|
5306
|
-
/**
|
|
5307
|
-
* One line saying where this run's structured logs go: they ship to Axiom when both variables are set. Names the
|
|
5308
|
-
* dataset (not a secret) and never the token, so a development run does not quietly write into production's dataset.
|
|
5309
|
-
*/
|
|
5310
|
-
function describeLogging(env, options) {
|
|
5311
|
-
const token = env[options.tokenVar];
|
|
5312
|
-
const dataset = env[options.datasetVar];
|
|
5313
|
-
return token && dataset ? `logs: shipped to Axiom, dataset "${dataset}"` : `logs: not shipped to Axiom (${options.tokenVar} and ${options.datasetVar} are not both set)`;
|
|
5314
|
-
}
|
|
5315
|
-
const LOOPBACK$1 = "127.0.0.1";
|
|
5316
|
-
/** GitHub caps a webhook payload at 25 MB; anything larger is not one. */
|
|
5317
|
-
const MAX_BODY = 27262976;
|
|
5318
|
-
/** The request body, or `undefined` when it is larger than a webhook can be. */
|
|
5319
|
-
async function readBody(req) {
|
|
5320
|
-
const chunks = [];
|
|
5321
|
-
let size = 0;
|
|
5322
|
-
for await (const chunk of req) {
|
|
5323
|
-
size += chunk.length;
|
|
5324
|
-
if (size > MAX_BODY) return void 0;
|
|
5325
|
-
chunks.push(chunk);
|
|
5326
|
-
}
|
|
5327
|
-
return Buffer.concat(chunks);
|
|
5328
|
-
}
|
|
5329
|
-
/**
|
|
5330
|
-
* Serves a `(Request, env) => Response` handler over HTTP on the loopback address, for a development instance behind
|
|
5331
|
-
* a tunnel: the same function the Vercel entry (e.g. Sentinel's `api/webhook.mjs`) calls, with the same web-standard `Request`. Only
|
|
5332
|
-
* the handler's own path is served. A request is logged as one line (method, path, status) and nothing else, so no
|
|
5333
|
-
* signature, token or payload reaches the terminal.
|
|
5334
|
-
*/
|
|
5335
|
-
async function startDevServer(input) {
|
|
5336
|
-
const path = input.path ?? "/api/webhook";
|
|
5337
|
-
const log = input.log ?? (() => {});
|
|
5338
|
-
const server = createServer(async (req, res) => {
|
|
5339
|
-
const method = req.method;
|
|
5340
|
-
const url = new URL(req.url, `http://${LOOPBACK$1}`);
|
|
5341
|
-
const reply = (status, body, headers = {}) => {
|
|
5342
|
-
log(`${method} ${url.pathname} ${status}`);
|
|
5343
|
-
res.writeHead(status, headers);
|
|
5344
|
-
res.end(body);
|
|
5345
|
-
};
|
|
5346
|
-
if (url.pathname !== path) return reply(404, "Not Found");
|
|
5347
|
-
const hasBody = method !== "GET" && method !== "HEAD";
|
|
5348
|
-
const body = hasBody ? await readBody(req) : void 0;
|
|
5349
|
-
if (hasBody && body === void 0) return reply(413, "Payload Too Large");
|
|
5350
|
-
const headers = new Headers();
|
|
5351
|
-
for (let i = 0; i < req.rawHeaders.length; i += 2) headers.append(req.rawHeaders[i], req.rawHeaders[i + 1]);
|
|
5352
|
-
try {
|
|
5353
|
-
const response = await input.handle(new Request(`http://${req.headers.host}${req.url}`, {
|
|
5354
|
-
method,
|
|
5355
|
-
headers,
|
|
5356
|
-
...body ? { body } : {}
|
|
5357
|
-
}), input.env);
|
|
5358
|
-
reply(response.status, Buffer.from(await response.arrayBuffer()), Object.fromEntries(response.headers));
|
|
5359
|
-
} catch {
|
|
5360
|
-
reply(500, "Internal Server Error");
|
|
5361
|
-
}
|
|
5362
|
-
});
|
|
5363
|
-
await new Promise((resolve) => server.listen(input.port, LOOPBACK$1, resolve));
|
|
5364
|
-
const { port } = server.address();
|
|
5365
|
-
return {
|
|
5366
|
-
url: `http://${LOOPBACK$1}:${port}${path}`,
|
|
5367
|
-
close: () => new Promise((resolve) => {
|
|
5368
|
-
server.close(() => resolve());
|
|
5369
|
-
server.closeAllConnections();
|
|
5370
|
-
})
|
|
5371
|
-
};
|
|
5372
|
-
}
|
|
5373
|
-
/**
|
|
5374
|
-
* Runs a web-standard handler locally: loads its environment, puts it in `process.env`, imports the handler, serves
|
|
5375
|
-
* it on the loopback address and says where it is listening and where its logs go. The server stops, and the process
|
|
5376
|
-
* exits, on SIGINT and SIGTERM.
|
|
5377
|
-
*
|
|
5378
|
-
* @returns The running server.
|
|
5379
|
-
*/
|
|
5380
|
-
async function serveHandler(input) {
|
|
5381
|
-
const log = input.log ?? ((line) => console.log(line));
|
|
5382
|
-
const settings = input.env ?? process.env;
|
|
5383
|
-
const env = loadDevEnv({
|
|
5384
|
-
environment: input.environment,
|
|
5385
|
-
required: input.required,
|
|
5386
|
-
env: settings,
|
|
5387
|
-
...input.spawn ? { spawn: input.spawn } : {}
|
|
5388
|
-
});
|
|
5389
|
-
Object.assign(process.env, env);
|
|
5390
|
-
const server = await startDevServer({
|
|
5391
|
-
handle: await input.handler(),
|
|
5392
|
-
env,
|
|
5393
|
-
port: input.port,
|
|
5394
|
-
...input.path ? { path: input.path } : {},
|
|
5395
|
-
log
|
|
5396
|
-
});
|
|
5397
|
-
log(`listening on ${server.url}, secrets from "${input.environment}"`);
|
|
5398
|
-
if (input.logging) log(describeLogging(env, input.logging));
|
|
5399
|
-
const stop = input.onSignal ?? ((close) => void close().then(() => process.exit(0)));
|
|
5400
|
-
for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => stop(server.close));
|
|
5401
|
-
return server;
|
|
5402
|
-
}
|
|
5403
4356
|
// src/commands/dev-serve/dev-serve.ts
|
|
5404
4357
|
/**
|
|
5405
4358
|
* `holocron dev serve` — the application `holocron dev` runs when `dev.serve` names a handler: it loads the handler
|
|
@@ -5661,13 +4614,13 @@ async function runTunnelUp(input) {
|
|
|
5661
4614
|
};
|
|
5662
4615
|
const row = (ok, label, detail) => {
|
|
5663
4616
|
summary[ok ? "ok" : "fail"] += 1;
|
|
5664
|
-
const text = `${label} ${style.dim(`(${detail})`)}`;
|
|
5665
|
-
print(` ${ok ? style.success(text) : style.fail(text)}`);
|
|
4617
|
+
const text = `${label} ${ui_exports.style.dim(`(${detail})`)}`;
|
|
4618
|
+
print(` ${ok ? ui_exports.style.success(text) : ui_exports.style.fail(text)}`);
|
|
5666
4619
|
};
|
|
5667
4620
|
const finish = (status, extra = {}) => {
|
|
5668
4621
|
print("");
|
|
5669
4622
|
const line = `${summary.ok} ok, ${summary.fail} failed`;
|
|
5670
|
-
print(summary.fail > 0 ? style.fail(line) : style.success(line));
|
|
4623
|
+
print(summary.fail > 0 ? ui_exports.style.fail(line) : ui_exports.style.success(line));
|
|
5671
4624
|
logger[status === "ok" ? "info" : "warn"]({
|
|
5672
4625
|
status,
|
|
5673
4626
|
...summary
|
|
@@ -5679,10 +4632,10 @@ async function runTunnelUp(input) {
|
|
|
5679
4632
|
};
|
|
5680
4633
|
};
|
|
5681
4634
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
5682
|
-
await withSpinner("Loading plugins…", () => loader.load());
|
|
4635
|
+
await (0, ui_exports.withSpinner)("Loading plugins…", () => loader.load());
|
|
5683
4636
|
assertPluginsResolvable(loader, COMMAND$3);
|
|
5684
4637
|
const dryRun = input.context.dryRun ?? false;
|
|
5685
|
-
print(style.header(`Holocron tunnel up — ${input.hostname}${dryRun ? " (dry-run)" : ""}`));
|
|
4638
|
+
print(ui_exports.style.header(`Holocron tunnel up — ${input.hostname}${dryRun ? " (dry-run)" : ""}`));
|
|
5686
4639
|
print("");
|
|
5687
4640
|
if (!loader.has("tunnels")) {
|
|
5688
4641
|
row(false, "tunnels", missing(loader, "tunnels", "needs a `tunnels` provider in holocron.config.ts (cloudflare)"));
|
|
@@ -5777,7 +4730,7 @@ const tunnelUpCommand = {
|
|
|
5777
4730
|
describe: "Make a named tunnel with a stable public hostname that reaches a local port",
|
|
5778
4731
|
builder: tunnelUpArgs,
|
|
5779
4732
|
handler: async (argv) => {
|
|
5780
|
-
const tokens = tokenContext(argv.token);
|
|
4733
|
+
const tokens = tokenContext$1(argv.token);
|
|
5781
4734
|
if (!tokens) return;
|
|
5782
4735
|
const loaded = await loadConfig(argv.cwd);
|
|
5783
4736
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -5809,13 +4762,13 @@ async function runDev(input) {
|
|
|
5809
4762
|
};
|
|
5810
4763
|
const row = (ok, label, detail) => {
|
|
5811
4764
|
summary[ok ? "ok" : "fail"] += 1;
|
|
5812
|
-
const text = `${label} ${style.dim(`(${detail})`)}`;
|
|
5813
|
-
print(` ${ok ? style.success(text) : style.fail(text)}`);
|
|
4765
|
+
const text = `${label} ${ui_exports.style.dim(`(${detail})`)}`;
|
|
4766
|
+
print(` ${ok ? ui_exports.style.success(text) : ui_exports.style.fail(text)}`);
|
|
5814
4767
|
};
|
|
5815
4768
|
const finish = (status, extra = {}) => {
|
|
5816
4769
|
print("");
|
|
5817
4770
|
const line = `${summary.ok} ok, ${summary.fail} failed`;
|
|
5818
|
-
print(summary.fail > 0 ? style.fail(line) : style.success(line));
|
|
4771
|
+
print(summary.fail > 0 ? ui_exports.style.fail(line) : ui_exports.style.success(line));
|
|
5819
4772
|
logger[status === "ok" ? "info" : "warn"]({
|
|
5820
4773
|
status,
|
|
5821
4774
|
...summary
|
|
@@ -5827,12 +4780,12 @@ async function runDev(input) {
|
|
|
5827
4780
|
};
|
|
5828
4781
|
};
|
|
5829
4782
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
5830
|
-
await withSpinner("Loading plugins…", () => loader.load());
|
|
4783
|
+
await (0, ui_exports.withSpinner)("Loading plugins…", () => loader.load());
|
|
5831
4784
|
assertPluginsResolvable(loader, COMMAND$2);
|
|
5832
4785
|
const dryRun = input.context.dryRun ?? false;
|
|
5833
4786
|
const [program, ...args] = input.command;
|
|
5834
4787
|
const shown = input.command.join(" ");
|
|
5835
|
-
print(style.header(`Holocron dev — ${input.hostname}${dryRun ? " (dry-run)" : ""}`));
|
|
4788
|
+
print(ui_exports.style.header(`Holocron dev — ${input.hostname}${dryRun ? " (dry-run)" : ""}`));
|
|
5836
4789
|
print("");
|
|
5837
4790
|
const vault = loader.has("vault") ? loader.get("vault") : void 0;
|
|
5838
4791
|
if (!vault?.readEnvironment) {
|
|
@@ -5924,7 +4877,7 @@ const devCommand = {
|
|
|
5924
4877
|
describe: "Run an application locally behind its development tunnel, with its secrets from the vault (command after --)",
|
|
5925
4878
|
builder: (y) => devArgs(y).command(devServeCommand),
|
|
5926
4879
|
handler: async (argv) => {
|
|
5927
|
-
const tokens = tokenContext(argv.token);
|
|
4880
|
+
const tokens = tokenContext$1(argv.token);
|
|
5928
4881
|
if (!tokens) return;
|
|
5929
4882
|
const loaded = await loadConfig(argv.cwd);
|
|
5930
4883
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -6341,7 +5294,7 @@ const doctorCredentialsCommand = {
|
|
|
6341
5294
|
command: "credentials",
|
|
6342
5295
|
describe: "Check that the credentials environment exists and holds the tokens the plugins take (read-only)",
|
|
6343
5296
|
handler: async (argv) => {
|
|
6344
|
-
const tokens = tokenContext(argv.token);
|
|
5297
|
+
const tokens = tokenContext$1(argv.token);
|
|
6345
5298
|
if (!tokens) return;
|
|
6346
5299
|
const loaded = await loadConfig(argv.cwd);
|
|
6347
5300
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -6469,7 +5422,7 @@ async function readCapped(res, maxBytes, tooBig) {
|
|
|
6469
5422
|
*/
|
|
6470
5423
|
/** Providers cap avatars well below this; it only keeps a wrong file from filling memory. */
|
|
6471
5424
|
const MAX_AVATAR_BYTES = 8388608;
|
|
6472
|
-
const FETCH_TIMEOUT_MS$
|
|
5425
|
+
const FETCH_TIMEOUT_MS$1 = 15e3;
|
|
6473
5426
|
const SIGNATURES = [
|
|
6474
5427
|
["image/png", [
|
|
6475
5428
|
137,
|
|
@@ -6529,7 +5482,7 @@ async function loadAvatar(source, baseDir = process.cwd(), fetchImpl = fetch) {
|
|
|
6529
5482
|
const base64 = /^data:[^;,]+;base64,(.*)$/is.exec(source)?.[1];
|
|
6530
5483
|
if (base64 === void 0) throw new Error("it is not a base64 data URI");
|
|
6531
5484
|
bytes = Buffer.from(base64, "base64");
|
|
6532
|
-
} else if (/^https:\/\//i.test(source)) bytes = await fetchAvatarBytes(source, fetchImpl, MAX_AVATAR_BYTES, FETCH_TIMEOUT_MS$
|
|
5485
|
+
} else if (/^https:\/\//i.test(source)) bytes = await fetchAvatarBytes(source, fetchImpl, MAX_AVATAR_BYTES, FETCH_TIMEOUT_MS$1, tooBig);
|
|
6533
5486
|
else {
|
|
6534
5487
|
const path = resolve(baseDir, source);
|
|
6535
5488
|
if ((await stat(path)).size > 8388608) throw tooBig();
|
|
@@ -6668,15 +5621,15 @@ async function provisionChannel(deps, spec) {
|
|
|
6668
5621
|
const relay = spec.feeds?.errors;
|
|
6669
5622
|
if (relay && !notifications.ensureWebhook) throw new Error(`\`${notifications.providerName}\` cannot create webhooks`);
|
|
6670
5623
|
if (dryRun) {
|
|
6671
|
-
print(` ${style.skip(`would ensure channel ${spec.name}${where}`)}`);
|
|
5624
|
+
print(` ${ui_exports.style.skip(`would ensure channel ${spec.name}${where}`)}`);
|
|
6672
5625
|
if (tally) tally.skip += webhookCfg ? 2 : 1;
|
|
6673
|
-
if (webhookCfg) print(` ${style.skip(`would ensure webhook ${webhookName} and store its URL in ${secretName}`)}`);
|
|
5626
|
+
if (webhookCfg) print(` ${ui_exports.style.skip(`would ensure webhook ${webhookName} and store its URL in ${secretName}`)}`);
|
|
6674
5627
|
if (feed) {
|
|
6675
|
-
print(` ${style.skip(`would ensure webhook ${feed.webhook} and alert channel ${feed.name} (monitoring)`)}`);
|
|
5628
|
+
print(` ${ui_exports.style.skip(`would ensure webhook ${feed.webhook} and alert channel ${feed.name} (monitoring)`)}`);
|
|
6676
5629
|
if (tally) tally.skip += 2;
|
|
6677
5630
|
}
|
|
6678
5631
|
if (relay) {
|
|
6679
|
-
print(` ${style.skip(`would ensure webhook ${relay.webhook} for the relay Worker (errors)`)}`);
|
|
5632
|
+
print(` ${ui_exports.style.skip(`would ensure webhook ${relay.webhook} for the relay Worker (errors)`)}`);
|
|
6680
5633
|
if (tally) tally.skip++;
|
|
6681
5634
|
}
|
|
6682
5635
|
return {
|
|
@@ -6696,7 +5649,7 @@ async function provisionChannel(deps, spec) {
|
|
|
6696
5649
|
const changed = channel.created || (channel.updated?.length ?? 0) > 0;
|
|
6697
5650
|
const verb = channel.created ? "created" : changed ? "updated" : "exists ";
|
|
6698
5651
|
const what = channel.updated?.length ? `: ${channel.updated.join(", ")}` : "";
|
|
6699
|
-
print(` ${(changed ? style.success : style.skip)(`${verb} channel ${spec.name}${where}${what}`)}`);
|
|
5652
|
+
print(` ${(changed ? ui_exports.style.success : ui_exports.style.skip)(`${verb} channel ${spec.name}${where}${what}`)}`);
|
|
6700
5653
|
if (tally) tally[changed ? "ok" : "skip"]++;
|
|
6701
5654
|
const outcome = {
|
|
6702
5655
|
name: spec.name,
|
|
@@ -6722,7 +5675,7 @@ async function provisionChannel(deps, spec) {
|
|
|
6722
5675
|
} catch (err) {
|
|
6723
5676
|
throw new Error(`webhook ${webhookName} was ${hook.created ? "created" : "found"} but storing its URL in ${secretName} failed (${describeProviderError(err)}) — delete the webhook in the provider and re-run to get a fresh URL`, { cause: err });
|
|
6724
5677
|
}
|
|
6725
|
-
print(` ${style.success(`${hook.created ? "created" : "found "} webhook ${webhookName}; URL stored in ${secretName}`)}`);
|
|
5678
|
+
print(` ${ui_exports.style.success(`${hook.created ? "created" : "found "} webhook ${webhookName}; URL stored in ${secretName}`)}`);
|
|
6726
5679
|
if (tally) tally.ok++;
|
|
6727
5680
|
outcome.webhook = {
|
|
6728
5681
|
name: webhookName,
|
|
@@ -6733,7 +5686,7 @@ async function provisionChannel(deps, spec) {
|
|
|
6733
5686
|
};
|
|
6734
5687
|
} else {
|
|
6735
5688
|
const note = `webhook ${webhookName} already exists and its URL cannot be read back — delete it in the provider and re-run, or set ${secretName} yourself`;
|
|
6736
|
-
print(` ${style.warn(note)}`);
|
|
5689
|
+
print(` ${ui_exports.style.warn(note)}`);
|
|
6737
5690
|
outcome.webhook = {
|
|
6738
5691
|
name: webhookName,
|
|
6739
5692
|
created: hook.created,
|
|
@@ -6744,7 +5697,7 @@ async function provisionChannel(deps, spec) {
|
|
|
6744
5697
|
};
|
|
6745
5698
|
}
|
|
6746
5699
|
if (avatarSet) {
|
|
6747
|
-
print(` ${style.success(`set avatar on webhook ${webhookName}`)}`);
|
|
5700
|
+
print(` ${ui_exports.style.success(`set avatar on webhook ${webhookName}`)}`);
|
|
6748
5701
|
if (tally) tally.ok++;
|
|
6749
5702
|
}
|
|
6750
5703
|
if (hook.avatarError) throw new Error(`webhook ${webhookName} is ready but setting its avatar failed (${hook.avatarError})`);
|
|
@@ -6766,7 +5719,7 @@ async function provisionRelayFeed(deps, spec, feed, outcome) {
|
|
|
6766
5719
|
...feed.avatar ? { avatar: feed.avatar } : {}
|
|
6767
5720
|
});
|
|
6768
5721
|
const avatarSet = hook.updated?.includes("avatar") ?? false;
|
|
6769
|
-
print(` ${(hook.created || avatarSet ? style.success : style.skip)(`${hook.created ? "created" : "found "} webhook ${feed.webhook} for the relay${avatarSet ? " (avatar set)" : ""}`)}`);
|
|
5722
|
+
print(` ${(hook.created || avatarSet ? ui_exports.style.success : ui_exports.style.skip)(`${hook.created ? "created" : "found "} webhook ${feed.webhook} for the relay${avatarSet ? " (avatar set)" : ""}`)}`);
|
|
6770
5723
|
if (tally) {
|
|
6771
5724
|
const done = Number(hook.created) + Number(avatarSet);
|
|
6772
5725
|
if (done > 0) tally.ok += done;
|
|
@@ -6795,7 +5748,7 @@ async function provisionFeed(deps, spec, feed, outcome) {
|
|
|
6795
5748
|
...feed.avatar ? { avatar: feed.avatar } : {}
|
|
6796
5749
|
});
|
|
6797
5750
|
const avatarSet = hook.updated?.includes("avatar") ?? false;
|
|
6798
|
-
print(` ${(hook.created || avatarSet ? style.success : style.skip)(`${hook.created ? "created" : "found "} webhook ${feed.webhook}${avatarSet ? " (avatar set)" : ""}`)}`);
|
|
5751
|
+
print(` ${(hook.created || avatarSet ? ui_exports.style.success : ui_exports.style.skip)(`${hook.created ? "created" : "found "} webhook ${feed.webhook}${avatarSet ? " (avatar set)" : ""}`)}`);
|
|
6799
5752
|
if (tally) {
|
|
6800
5753
|
const done = Number(hook.created) + Number(avatarSet);
|
|
6801
5754
|
if (done > 0) tally.ok += done;
|
|
@@ -6816,7 +5769,7 @@ async function provisionFeed(deps, spec, feed, outcome) {
|
|
|
6816
5769
|
const changed = result.created || result.updated.length > 0;
|
|
6817
5770
|
const verb = result.created ? "created" : changed ? "updated" : "exists ";
|
|
6818
5771
|
const what = result.updated.length > 0 ? `: ${result.updated.join(", ")}` : "";
|
|
6819
|
-
print(` ${(changed ? style.success : style.skip)(`${verb} alert channel ${feed.name} via webhook ${feed.webhook}${what} (${result.subscribed} checks)`)}`);
|
|
5772
|
+
print(` ${(changed ? ui_exports.style.success : ui_exports.style.skip)(`${verb} alert channel ${feed.name} via webhook ${feed.webhook}${what} (${result.subscribed} checks)`)}`);
|
|
6820
5773
|
if (tally) tally[changed ? "ok" : "skip"]++;
|
|
6821
5774
|
outcome.alertChannel = {
|
|
6822
5775
|
name: feed.name,
|
|
@@ -6872,7 +5825,7 @@ async function runNotificationsChannelAdd(input) {
|
|
|
6872
5825
|
}, `notifications channel add: ${input.name}`);
|
|
6873
5826
|
if (channel.webhook && !channel.webhook.stored && !dryRun) {
|
|
6874
5827
|
const message = channel.webhook.note;
|
|
6875
|
-
print(` ${style.fail(message)}`);
|
|
5828
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
6876
5829
|
return {
|
|
6877
5830
|
status: "fail",
|
|
6878
5831
|
channel,
|
|
@@ -6885,7 +5838,7 @@ async function runNotificationsChannelAdd(input) {
|
|
|
6885
5838
|
};
|
|
6886
5839
|
} catch (err) {
|
|
6887
5840
|
const message = describeProviderError(err);
|
|
6888
|
-
print(` ${style.fail(message)}`);
|
|
5841
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
6889
5842
|
logger.warn({
|
|
6890
5843
|
channel: input.name,
|
|
6891
5844
|
reason: logReason(err)
|
|
@@ -7219,7 +6172,7 @@ const doctorDnsCommand = {
|
|
|
7219
6172
|
command: "dns",
|
|
7220
6173
|
describe: "Check that the DNS records the config makes setup write exist and point where they should (read-only)",
|
|
7221
6174
|
handler: async (argv) => {
|
|
7222
|
-
const tokens = tokenContext(argv.token);
|
|
6175
|
+
const tokens = tokenContext$1(argv.token);
|
|
7223
6176
|
if (!tokens) return;
|
|
7224
6177
|
const loaded = await loadConfig(argv.cwd);
|
|
7225
6178
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -7295,7 +6248,7 @@ const doctorEnvironmentsCommand = {
|
|
|
7295
6248
|
command: "environments",
|
|
7296
6249
|
describe: "Check that the deployment environments the config relies on exist (read-only)",
|
|
7297
6250
|
handler: async (argv) => {
|
|
7298
|
-
const tokens = tokenContext(argv.token);
|
|
6251
|
+
const tokens = tokenContext$1(argv.token);
|
|
7299
6252
|
if (!tokens) return;
|
|
7300
6253
|
const loaded = await loadConfig(argv.cwd);
|
|
7301
6254
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -7451,7 +6404,7 @@ const doctorMonitoringCommand = {
|
|
|
7451
6404
|
command: "monitoring",
|
|
7452
6405
|
describe: "Check the monitoring checks the config declares against the ones the provider holds (read-only)",
|
|
7453
6406
|
handler: async (argv) => {
|
|
7454
|
-
const tokens = tokenContext(argv.token);
|
|
6407
|
+
const tokens = tokenContext$1(argv.token);
|
|
7455
6408
|
if (!tokens) return;
|
|
7456
6409
|
const loaded = await loadConfig(argv.cwd);
|
|
7457
6410
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -7683,7 +6636,7 @@ async function withElevation(run, deps) {
|
|
|
7683
6636
|
const { permission, grantUrl, revokeUrl, applied, keep } = err.elevation;
|
|
7684
6637
|
const name = err.elevation.label ?? permission;
|
|
7685
6638
|
if (await notifications.holdsPermission?.(permission).catch(() => false)) throw err;
|
|
7686
|
-
print(` ${style.skip(`${deps.label} needs ${name}${keep ? "" : " for this one edit"}`)}`);
|
|
6639
|
+
print(` ${ui_exports.style.skip(`${deps.label} needs ${name}${keep ? "" : " for this one edit"}`)}`);
|
|
7687
6640
|
print(` 1. approve it: ${grantUrl}`);
|
|
7688
6641
|
await pause(`Press Enter once ${name} is approved to try again`);
|
|
7689
6642
|
let result;
|
|
@@ -7701,10 +6654,10 @@ async function withElevation(run, deps) {
|
|
|
7701
6654
|
const holdsNow = await notifications.holdsPermission?.(permission).catch(() => void 0);
|
|
7702
6655
|
if (holdsNow === void 0) leftover = `could not check that ${permission} is gone; confirm it in ${notifications.providerName}'s role, then run \`holocron doctor notifications\``;
|
|
7703
6656
|
else if (holdsNow) leftover = `${notifications.providerName} still holds ${permission}; use the link above to take it away, then run \`holocron doctor notifications\` to check`;
|
|
7704
|
-
else print(` ${style.success(`${permission} is gone again`)}`);
|
|
6657
|
+
else print(` ${ui_exports.style.success(`${permission} is gone again`)}`);
|
|
7705
6658
|
}
|
|
7706
6659
|
if (failure !== void 0) {
|
|
7707
|
-
if (leftover) print(` ${style.fail(leftover)}`);
|
|
6660
|
+
if (leftover) print(` ${ui_exports.style.fail(leftover)}`);
|
|
7708
6661
|
throw failure;
|
|
7709
6662
|
}
|
|
7710
6663
|
return {
|
|
@@ -7900,7 +6853,7 @@ function serverLayoutProblem(layout) {
|
|
|
7900
6853
|
}
|
|
7901
6854
|
}
|
|
7902
6855
|
async function runNotificationsSetup(input$1) {
|
|
7903
|
-
const progress = createProgress(input$1.print ?? ((line) => console.log(line)));
|
|
6856
|
+
const progress = createProgress$1(input$1.print ?? ((line) => console.log(line)));
|
|
7904
6857
|
const print = progress.print;
|
|
7905
6858
|
const logger = input$1.logger ?? getLogger();
|
|
7906
6859
|
/* v8 ignore next -- the real loader is only built outside tests, which always inject one */
|
|
@@ -7916,9 +6869,9 @@ async function runNotificationsSetup(input$1) {
|
|
|
7916
6869
|
failures: []
|
|
7917
6870
|
};
|
|
7918
6871
|
const refuse = (message, reason = message) => {
|
|
7919
|
-
print(` ${style.fail(message)}`);
|
|
6872
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
7920
6873
|
print("");
|
|
7921
|
-
print(style.header("0 ok, 1 fail, 0 skipped"));
|
|
6874
|
+
print(ui_exports.style.header("0 ok, 1 fail, 0 skipped"));
|
|
7922
6875
|
logger.warn({ reason }, "notifications setup");
|
|
7923
6876
|
return {
|
|
7924
6877
|
...report,
|
|
@@ -7989,7 +6942,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
7989
6942
|
]) {
|
|
7990
6943
|
const key = JSON.stringify(sources);
|
|
7991
6944
|
if (sources.length > 0 && !avatars.has(key)) try {
|
|
7992
|
-
avatars.set(key, await loadFirstAvatar(sources, read, (source, reason, moreToTry) => print(` ${style.skip(`avatar ${describeAvatarSource(source)} could not be read (${reason})${moreToTry ? "; trying the next" : ""}`)}`)));
|
|
6945
|
+
avatars.set(key, await loadFirstAvatar(sources, read, (source, reason, moreToTry) => print(` ${ui_exports.style.skip(`avatar ${describeAvatarSource(source)} could not be read (${reason})${moreToTry ? "; trying the next" : ""}`)}`)));
|
|
7993
6946
|
} catch (err) {
|
|
7994
6947
|
return refuse(`webhook avatar ${errorMessage(err)}`);
|
|
7995
6948
|
}
|
|
@@ -8034,7 +6987,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
8034
6987
|
return true;
|
|
8035
6988
|
} catch (err) {
|
|
8036
6989
|
const message = describeProviderError(err);
|
|
8037
|
-
print(` ${style.fail(`${step}: ${message}`)}`);
|
|
6990
|
+
print(` ${ui_exports.style.fail(`${step}: ${message}`)}`);
|
|
8038
6991
|
report.failures.push({
|
|
8039
6992
|
step,
|
|
8040
6993
|
message
|
|
@@ -8042,11 +6995,11 @@ async function runNotificationsSetup(input$1) {
|
|
|
8042
6995
|
return false;
|
|
8043
6996
|
}
|
|
8044
6997
|
};
|
|
8045
|
-
if ((layout.roles ?? []).length > 0) print(`\n${style.header("Roles")}`);
|
|
6998
|
+
if ((layout.roles ?? []).length > 0) print(`\n${ui_exports.style.header("Roles")}`);
|
|
8046
6999
|
for (const role of layout.roles ?? []) await attempt(`role ${role.name}`, async () => {
|
|
8047
7000
|
if (!notifications.ensureRole) throw new Error(`\`${notifications.providerName}\` cannot manage roles`);
|
|
8048
7001
|
if (dryRun) {
|
|
8049
|
-
print(` ${style.skip(`would ensure role ${role.name}${role.secret ? ` and store its id in ${role.secret}` : ""}`)}`);
|
|
7002
|
+
print(` ${ui_exports.style.skip(`would ensure role ${role.name}${role.secret ? ` and store its id in ${role.secret}` : ""}`)}`);
|
|
8050
7003
|
tally.skip++;
|
|
8051
7004
|
report.roles.push({
|
|
8052
7005
|
name: role.name,
|
|
@@ -8071,23 +7024,23 @@ async function runNotificationsSetup(input$1) {
|
|
|
8071
7024
|
report.roles.push(outcome);
|
|
8072
7025
|
const changed = result.created || (result.updated?.length ?? 0) > 0;
|
|
8073
7026
|
const verb = result.created ? "created" : changed ? "updated" : "exists ";
|
|
8074
|
-
print(` ${(changed ? style.success : style.skip)(`${verb} role ${role.name} (id ${result.id})${result.updated?.length ? `: ${result.updated.join(", ")}` : ""}`)}`);
|
|
7027
|
+
print(` ${(changed ? ui_exports.style.success : ui_exports.style.skip)(`${verb} role ${role.name} (id ${result.id})${result.updated?.length ? `: ${result.updated.join(", ")}` : ""}`)}`);
|
|
8075
7028
|
made(changed);
|
|
8076
7029
|
if (role.secret) {
|
|
8077
7030
|
await secrets.setSecret(scope, role.secret, result.id);
|
|
8078
7031
|
outcome.secret = role.secret;
|
|
8079
7032
|
outcome.stored = true;
|
|
8080
|
-
print(` ${style.success(`stored the id of ${role.name} in ${role.secret}`)}`);
|
|
7033
|
+
print(` ${ui_exports.style.success(`stored the id of ${role.name} in ${role.secret}`)}`);
|
|
8081
7034
|
tally.ok++;
|
|
8082
7035
|
}
|
|
8083
7036
|
});
|
|
8084
7037
|
for (const category of layout.categories ?? []) {
|
|
8085
|
-
print(`\n${style.header(category.name)}`);
|
|
7038
|
+
print(`\n${ui_exports.style.header(category.name)}`);
|
|
8086
7039
|
report.categories.push(category.name);
|
|
8087
7040
|
const categoryOk = await attempt(`category ${category.name}`, async () => {
|
|
8088
7041
|
if (!notifications.ensureCategory) return;
|
|
8089
7042
|
if (dryRun) {
|
|
8090
|
-
print(` ${style.skip(`would ensure category ${category.name}`)}`);
|
|
7043
|
+
print(` ${ui_exports.style.skip(`would ensure category ${category.name}`)}`);
|
|
8091
7044
|
tally.skip++;
|
|
8092
7045
|
return;
|
|
8093
7046
|
}
|
|
@@ -8095,12 +7048,12 @@ async function runNotificationsSetup(input$1) {
|
|
|
8095
7048
|
const changed = result.created || (result.updated?.length ?? 0) > 0;
|
|
8096
7049
|
const verb = result.created ? "created" : changed ? "updated" : "exists ";
|
|
8097
7050
|
const what = result.updated?.length ? `: ${result.updated.join(", ")}` : "";
|
|
8098
|
-
print(` ${(changed ? style.success : style.skip)(`${verb} category ${category.name}${what}`)}`);
|
|
7051
|
+
print(` ${(changed ? ui_exports.style.success : ui_exports.style.skip)(`${verb} category ${category.name}${what}`)}`);
|
|
8099
7052
|
made(changed);
|
|
8100
7053
|
});
|
|
8101
7054
|
const channels = category.channels ?? [];
|
|
8102
7055
|
if (!categoryOk && channels.length > 0) {
|
|
8103
|
-
print(` ${style.skip(`skipped ${channels.length} channel${channels.length === 1 ? "" : "s"}: the category failed`)}`);
|
|
7056
|
+
print(` ${ui_exports.style.skip(`skipped ${channels.length} channel${channels.length === 1 ? "" : "s"}: the category failed`)}`);
|
|
8104
7057
|
tally.skip += channels.length;
|
|
8105
7058
|
continue;
|
|
8106
7059
|
}
|
|
@@ -8148,14 +7101,14 @@ async function runNotificationsSetup(input$1) {
|
|
|
8148
7101
|
});
|
|
8149
7102
|
}
|
|
8150
7103
|
if (errors && workers && dns && wantsRelay(layout)) {
|
|
8151
|
-
print(`\n${style.header("Relay")}`);
|
|
7104
|
+
print(`\n${ui_exports.style.header("Relay")}`);
|
|
8152
7105
|
const tracker = layout.relay.errors;
|
|
8153
7106
|
let signingSecret;
|
|
8154
7107
|
if (tracker && errors.ensureRelay) await attempt(`${errors.providerName} alert relay`, async () => {
|
|
8155
7108
|
const integration = tracker.integration ?? "Comlink";
|
|
8156
7109
|
const rule = tracker.rule ?? "Errors to Discord (Comlink)";
|
|
8157
7110
|
if (dryRun) {
|
|
8158
|
-
print(` ${style.skip(`would ensure the ${errors.providerName} integration ${integration} and the alert rule ${rule} on ${tracker.projects.join(", ")}`)}`);
|
|
7111
|
+
print(` ${ui_exports.style.skip(`would ensure the ${errors.providerName} integration ${integration} and the alert rule ${rule} on ${tracker.projects.join(", ")}`)}`);
|
|
8159
7112
|
tally.skip += 2;
|
|
8160
7113
|
return;
|
|
8161
7114
|
}
|
|
@@ -8181,14 +7134,14 @@ async function runNotificationsSetup(input$1) {
|
|
|
8181
7134
|
const changed = outcome.created || outcome.updated.length > 0;
|
|
8182
7135
|
const verb = outcome.created ? "created" : changed ? "updated" : "exists ";
|
|
8183
7136
|
const detail = outcome.updated.length > 0 ? `: ${outcome.updated.join(", ")}` : "";
|
|
8184
|
-
print(` ${(changed ? style.success : style.skip)(`${verb} ${errors.providerName} ${what} ${name}${detail}`)}`);
|
|
7137
|
+
print(` ${(changed ? ui_exports.style.success : ui_exports.style.skip)(`${verb} ${errors.providerName} ${what} ${name}${detail}`)}`);
|
|
8185
7138
|
made(changed);
|
|
8186
7139
|
}
|
|
8187
|
-
if (!signingSecret) print(` ${style.warn(`${errors.providerName} did not give the integration's signing secret (it may only show it once, when the integration is made), so the Worker keeps the one it has. To set it: copy it from the integration's page, add it to Doppler as COMLINK_${errors.providerName.toUpperCase()}_SECRET and run holocron secrets sync`)}`);
|
|
7140
|
+
if (!signingSecret) print(` ${ui_exports.style.warn(`${errors.providerName} did not give the integration's signing secret (it may only show it once, when the integration is made), so the Worker keeps the one it has. To set it: copy it from the integration's page, add it to Doppler as COMLINK_${errors.providerName.toUpperCase()}_SECRET and run holocron secrets sync`)}`);
|
|
8188
7141
|
});
|
|
8189
7142
|
await attempt(`relay ${layout.relay.host}`, async () => {
|
|
8190
7143
|
if (dryRun) {
|
|
8191
|
-
print(` ${style.skip(`would deploy the relay Worker at ${layout.relay.host}`)}`);
|
|
7144
|
+
print(` ${ui_exports.style.skip(`would deploy the relay Worker at ${layout.relay.host}`)}`);
|
|
8192
7145
|
tally.skip++;
|
|
8193
7146
|
return;
|
|
8194
7147
|
}
|
|
@@ -8203,26 +7156,26 @@ async function runNotificationsSetup(input$1) {
|
|
|
8203
7156
|
dns,
|
|
8204
7157
|
...input$1.readRelayCode ? { readCode: input$1.readRelayCode } : {}
|
|
8205
7158
|
});
|
|
8206
|
-
print(` ${style.success(`deployed ${deployed.script} at ${deployed.host}`)}`);
|
|
7159
|
+
print(` ${ui_exports.style.success(`deployed ${deployed.script} at ${deployed.host}`)}`);
|
|
8207
7160
|
tally.ok++;
|
|
8208
7161
|
});
|
|
8209
7162
|
}
|
|
8210
7163
|
if (layout.server || layout.welcome || layout.onboarding || (layout.pinned?.length ?? 0) > 0 || layout.application || layout.everyone) {
|
|
8211
|
-
print(`\n${style.header("Server")}`);
|
|
7164
|
+
print(`\n${ui_exports.style.header("Server")}`);
|
|
8212
7165
|
const apply = async (label, declared, run) => {
|
|
8213
7166
|
if (!declared) return;
|
|
8214
7167
|
await attempt(label, async () => {
|
|
8215
7168
|
if (dryRun) {
|
|
8216
|
-
print(` ${style.skip(`would ensure ${label}`)}`);
|
|
7169
|
+
print(` ${ui_exports.style.skip(`would ensure ${label}`)}`);
|
|
8217
7170
|
tally.skip++;
|
|
8218
7171
|
return;
|
|
8219
7172
|
}
|
|
8220
7173
|
const result = await run();
|
|
8221
7174
|
const changed = result.updated.length > 0;
|
|
8222
|
-
print(` ${(changed ? style.success : style.skip)(`${changed ? "updated" : "exists "} ${label}${changed ? `: ${result.updated.join(", ")}` : ""}`)}`);
|
|
7175
|
+
print(` ${(changed ? ui_exports.style.success : ui_exports.style.skip)(`${changed ? "updated" : "exists "} ${label}${changed ? `: ${result.updated.join(", ")}` : ""}`)}`);
|
|
8223
7176
|
made(changed);
|
|
8224
7177
|
for (const todo of result.todo ?? []) {
|
|
8225
|
-
print(` ${style.fail(`${label}: ${todo}`)}`);
|
|
7178
|
+
print(` ${ui_exports.style.fail(`${label}: ${todo}`)}`);
|
|
8226
7179
|
report.failures.push({
|
|
8227
7180
|
step: label,
|
|
8228
7181
|
message: todo
|
|
@@ -8252,7 +7205,7 @@ async function runNotificationsSetup(input$1) {
|
|
|
8252
7205
|
if (report.failures.length > 0) report.status = "fail";
|
|
8253
7206
|
else if (dryRun) report.status = "dry-run";
|
|
8254
7207
|
print("");
|
|
8255
|
-
print(style.header(`${tally.ok} ok, ${report.failures.length} fail, ${tally.skip} skipped`));
|
|
7208
|
+
print(ui_exports.style.header(`${tally.ok} ok, ${report.failures.length} fail, ${tally.skip} skipped`));
|
|
8256
7209
|
logger.info({
|
|
8257
7210
|
provider: notifications.providerName,
|
|
8258
7211
|
channels: report.channels.length,
|
|
@@ -8529,7 +7482,7 @@ async function syncRoles(input) {
|
|
|
8529
7482
|
skipped: 0
|
|
8530
7483
|
};
|
|
8531
7484
|
for (const role of input.roles) {
|
|
8532
|
-
print(`\n${style.header(`${role.name} ← team ${role.team}`)}`);
|
|
7485
|
+
print(`\n${ui_exports.style.header(`${role.name} ← team ${role.team}`)}`);
|
|
8533
7486
|
const step = `role ${role.name}`;
|
|
8534
7487
|
let plan;
|
|
8535
7488
|
try {
|
|
@@ -8543,7 +7496,7 @@ async function syncRoles(input) {
|
|
|
8543
7496
|
});
|
|
8544
7497
|
} catch (err) {
|
|
8545
7498
|
const message = describeProviderError(err);
|
|
8546
|
-
print(` ${style.fail(`${step}: ${message}`)}`);
|
|
7499
|
+
print(` ${ui_exports.style.fail(`${step}: ${message}`)}`);
|
|
8547
7500
|
result.failures.push({
|
|
8548
7501
|
step,
|
|
8549
7502
|
message
|
|
@@ -8559,11 +7512,11 @@ async function syncRoles(input) {
|
|
|
8559
7512
|
};
|
|
8560
7513
|
result.roles.push(outcome);
|
|
8561
7514
|
result.skipped += plan.inSync;
|
|
8562
|
-
if (plan.inSync > 0) print(` ${style.skip(`${plan.inSync} already have it`)}`);
|
|
7515
|
+
if (plan.inSync > 0) print(` ${ui_exports.style.skip(`${plan.inSync} already have it`)}`);
|
|
8563
7516
|
const act = async (verb, who) => {
|
|
8564
7517
|
const label = `${verb === "add" ? "gave" : "took"} ${role.name} ${verb === "add" ? "to" : "from"} ${who.login} (${who.member})`;
|
|
8565
7518
|
if (dryRun || verb === "remove" && keep) {
|
|
8566
|
-
print(` ${style.skip(`would ${verb === "add" ? "give" : "take"} ${role.name} ${verb === "add" ? "to" : "from"} ${who.login} (${who.member})${keep && verb === "remove" ? " (kept: --keep)" : ""}`)}`);
|
|
7519
|
+
print(` ${ui_exports.style.skip(`would ${verb === "add" ? "give" : "take"} ${role.name} ${verb === "add" ? "to" : "from"} ${who.login} (${who.member})${keep && verb === "remove" ? " (kept: --keep)" : ""}`)}`);
|
|
8567
7520
|
result.skipped++;
|
|
8568
7521
|
return;
|
|
8569
7522
|
}
|
|
@@ -8571,11 +7524,11 @@ async function syncRoles(input) {
|
|
|
8571
7524
|
if (verb === "add") await notifications.addRoleMember(role.name, who.member);
|
|
8572
7525
|
else await notifications.removeRoleMember(role.name, who.member);
|
|
8573
7526
|
(verb === "add" ? outcome.added : outcome.removed).push(who.member);
|
|
8574
|
-
print(` ${style.success(label)}`);
|
|
7527
|
+
print(` ${ui_exports.style.success(label)}`);
|
|
8575
7528
|
result.ok++;
|
|
8576
7529
|
} catch (err) {
|
|
8577
7530
|
const message = describeProviderError(err);
|
|
8578
|
-
print(` ${style.fail(`${step}: ${verb} ${who.login}: ${message}`)}`);
|
|
7531
|
+
print(` ${ui_exports.style.fail(`${step}: ${verb} ${who.login}: ${message}`)}`);
|
|
8579
7532
|
result.failures.push({
|
|
8580
7533
|
step: `${step} ${verb} ${who.login}`,
|
|
8581
7534
|
message
|
|
@@ -8585,11 +7538,11 @@ async function syncRoles(input) {
|
|
|
8585
7538
|
for (const who of plan.add) await act("add", who);
|
|
8586
7539
|
for (const who of plan.remove) await act("remove", who);
|
|
8587
7540
|
for (const person of plan.unlinked) {
|
|
8588
|
-
print(` ${style.skip(`${person.login} is on the team but has not linked their account`)}`);
|
|
7541
|
+
print(` ${ui_exports.style.skip(`${person.login} is on the team but has not linked their account`)}`);
|
|
8589
7542
|
result.skipped++;
|
|
8590
7543
|
}
|
|
8591
7544
|
for (const holder of plan.unknownHolders) {
|
|
8592
|
-
print(` ${style.skip(`${holder.name ?? holder.member} holds ${role.name} but is not linked to anyone: left alone`)}`);
|
|
7545
|
+
print(` ${ui_exports.style.skip(`${holder.name ?? holder.member} holds ${role.name} but is not linked to anyone: left alone`)}`);
|
|
8593
7546
|
result.skipped++;
|
|
8594
7547
|
}
|
|
8595
7548
|
}
|
|
@@ -8645,9 +7598,9 @@ async function runNotificationsSyncRoles(input) {
|
|
|
8645
7598
|
failures: []
|
|
8646
7599
|
};
|
|
8647
7600
|
const refuse = (message, reason = message) => {
|
|
8648
|
-
print(` ${style.fail(message)}`);
|
|
7601
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
8649
7602
|
print("");
|
|
8650
|
-
print(style.header("0 ok, 1 fail, 0 skipped"));
|
|
7603
|
+
print(ui_exports.style.header("0 ok, 1 fail, 0 skipped"));
|
|
8651
7604
|
logger.warn({ reason }, "notifications sync-roles");
|
|
8652
7605
|
return {
|
|
8653
7606
|
...report,
|
|
@@ -8675,7 +7628,7 @@ async function runNotificationsSyncRoles(input) {
|
|
|
8675
7628
|
} catch (err) {
|
|
8676
7629
|
return refuse(describeProviderError(err), logReason(err));
|
|
8677
7630
|
}
|
|
8678
|
-
if (links.links.length === 0) print(` ${style.skip("no links yet: nobody can be given a role until they link their account")}`);
|
|
7631
|
+
if (links.links.length === 0) print(` ${ui_exports.style.skip("no links yet: nobody can be given a role until they link their account")}`);
|
|
8679
7632
|
const result = await syncRoles({
|
|
8680
7633
|
notifications,
|
|
8681
7634
|
source,
|
|
@@ -8694,7 +7647,7 @@ async function runNotificationsSyncRoles(input) {
|
|
|
8694
7647
|
if (report.failures.length > 0) report.status = "fail";
|
|
8695
7648
|
else if (dryRun) report.status = "dry-run";
|
|
8696
7649
|
print("");
|
|
8697
|
-
print(style.header(`${result.ok} ok, ${report.failures.length} fail, ${result.skipped} skipped`));
|
|
7650
|
+
print(ui_exports.style.header(`${result.ok} ok, ${report.failures.length} fail, ${result.skipped} skipped`));
|
|
8698
7651
|
logger.info({
|
|
8699
7652
|
provider: notifications.providerName,
|
|
8700
7653
|
roles: report.roles.length,
|
|
@@ -8746,9 +7699,9 @@ async function runNotificationsLink(input) {
|
|
|
8746
7699
|
assertPluginsResolvable(loader, "notifications link");
|
|
8747
7700
|
const dryRun = input.context.dryRun ?? false;
|
|
8748
7701
|
const refuse = (message, reason = message) => {
|
|
8749
|
-
print(` ${style.fail(message)}`);
|
|
7702
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
8750
7703
|
print("");
|
|
8751
|
-
print(style.header("0 ok, 1 fail, 0 skipped"));
|
|
7704
|
+
print(ui_exports.style.header("0 ok, 1 fail, 0 skipped"));
|
|
8752
7705
|
logger.warn({ reason }, "notifications link");
|
|
8753
7706
|
return {
|
|
8754
7707
|
status: "fail",
|
|
@@ -8780,21 +7733,21 @@ async function runNotificationsLink(input) {
|
|
|
8780
7733
|
/* v8 ignore next -- the real fetch is only used outside tests, which inject one */
|
|
8781
7734
|
...input.fetch ? { fetch: input.fetch } : {}
|
|
8782
7735
|
});
|
|
8783
|
-
print(` ${style.skip(`sign-in ${choice.kind === "hosted" ? "is hosted" : "runs on this machine"}: ${choice.reason}`)}`);
|
|
7736
|
+
print(` ${ui_exports.style.skip(`sign-in ${choice.kind === "hosted" ? "is hosted" : "runs on this machine"}: ${choice.reason}`)}`);
|
|
8784
7737
|
if (choice.kind === "hosted") {
|
|
8785
7738
|
print(` open ${`${choice.redirectUri.replace(/\/callback$/, "")}/start`} in a browser to link your account`);
|
|
8786
7739
|
print("");
|
|
8787
|
-
print(style.header("0 ok, 0 fail, 1 skipped"));
|
|
7740
|
+
print(ui_exports.style.header("0 ok, 0 fail, 1 skipped"));
|
|
8788
7741
|
return {
|
|
8789
7742
|
status: "ok",
|
|
8790
7743
|
via: "hosted"
|
|
8791
7744
|
};
|
|
8792
7745
|
}
|
|
8793
7746
|
if (dryRun) {
|
|
8794
|
-
print(` ${style.skip(`would sign in on ${choice.redirectUri} and write the link to ${location.repo}/${location.path}`)}`);
|
|
8795
|
-
print(` ${style.skip(`first, ${redirectInstruction(choice.redirectUri)}`)}`);
|
|
7747
|
+
print(` ${ui_exports.style.skip(`would sign in on ${choice.redirectUri} and write the link to ${location.repo}/${location.path}`)}`);
|
|
7748
|
+
print(` ${ui_exports.style.skip(`first, ${redirectInstruction(choice.redirectUri)}`)}`);
|
|
8796
7749
|
print("");
|
|
8797
|
-
print(style.header("0 ok, 0 fail, 1 skipped"));
|
|
7750
|
+
print(ui_exports.style.header("0 ok, 0 fail, 1 skipped"));
|
|
8798
7751
|
return {
|
|
8799
7752
|
status: "dry-run",
|
|
8800
7753
|
via: "local"
|
|
@@ -8821,7 +7774,7 @@ async function runNotificationsLink(input) {
|
|
|
8821
7774
|
const code = await wait({
|
|
8822
7775
|
port,
|
|
8823
7776
|
state,
|
|
8824
|
-
onListening: () => void open(url).catch(() => print(` ${style.skip("could not open a browser; use the link above")}`))
|
|
7777
|
+
onListening: () => void open(url).catch(() => print(` ${ui_exports.style.skip("could not open a browser; use the link above")}`))
|
|
8825
7778
|
});
|
|
8826
7779
|
const who = await signIn.complete({
|
|
8827
7780
|
redirectUri: choice.redirectUri,
|
|
@@ -8854,9 +7807,9 @@ async function runNotificationsLink(input) {
|
|
|
8854
7807
|
throw err;
|
|
8855
7808
|
}
|
|
8856
7809
|
}
|
|
8857
|
-
print(` ${style.success(`${outcome.changed ? "linked" : "already linked"} ${who.github.login} (github ${who.github.id}) to ${who.name ?? who.member} (${who.member})`)}`);
|
|
7810
|
+
print(` ${ui_exports.style.success(`${outcome.changed ? "linked" : "already linked"} ${who.github.login} (github ${who.github.id}) to ${who.name ?? who.member} (${who.member})`)}`);
|
|
8858
7811
|
print("");
|
|
8859
|
-
print(style.header(`${outcome.changed ? 1 : 0} ok, 0 fail, ${outcome.changed ? 0 : 1} skipped`));
|
|
7812
|
+
print(ui_exports.style.header(`${outcome.changed ? 1 : 0} ok, 0 fail, ${outcome.changed ? 0 : 1} skipped`));
|
|
8860
7813
|
logger.info({
|
|
8861
7814
|
provider: notifications.providerName,
|
|
8862
7815
|
changed: outcome.changed
|
|
@@ -9225,7 +8178,7 @@ async function runDoctorNotifications(input) {
|
|
|
9225
8178
|
return report;
|
|
9226
8179
|
};
|
|
9227
8180
|
const refuse = (message, reason = message) => {
|
|
9228
|
-
print(` ${style.fail(message)}`);
|
|
8181
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
9229
8182
|
printCheckSummary({
|
|
9230
8183
|
ok: 0,
|
|
9231
8184
|
fail: 1,
|
|
@@ -9709,7 +8662,7 @@ async function runDoctorNotifications(input) {
|
|
|
9709
8662
|
})), print);
|
|
9710
8663
|
if (deliveryNote) {
|
|
9711
8664
|
print("");
|
|
9712
|
-
print(` ${style.skip(`note: ${deliveryNote}`)}`);
|
|
8665
|
+
print(` ${ui_exports.style.skip(`note: ${deliveryNote}`)}`);
|
|
9713
8666
|
}
|
|
9714
8667
|
const summary = summarise();
|
|
9715
8668
|
printCheckSummary({
|
|
@@ -9717,7 +8670,7 @@ async function runDoctorNotifications(input) {
|
|
|
9717
8670
|
fail: summary.fail,
|
|
9718
8671
|
skip: summary.skip
|
|
9719
8672
|
}, print);
|
|
9720
|
-
if (input.post !== void 0) print(` ${style.skip(await postDoctorReport(notifications, input.post, {
|
|
8673
|
+
if (input.post !== void 0) print(` ${ui_exports.style.skip(await postDoctorReport(notifications, input.post, {
|
|
9721
8674
|
checks,
|
|
9722
8675
|
summary
|
|
9723
8676
|
}))}`);
|
|
@@ -9729,7 +8682,7 @@ const doctorNotificationsCommand = {
|
|
|
9729
8682
|
describe: "Check the layout against the server and the secrets store, step by step (a full run leaves one test post in the test channel; --built-only posts nothing unless --deliver)",
|
|
9730
8683
|
builder: doctorNotificationsArgs,
|
|
9731
8684
|
handler: async (argv) => {
|
|
9732
|
-
const tokens = tokenContext(argv.token);
|
|
8685
|
+
const tokens = tokenContext$1(argv.token);
|
|
9733
8686
|
if (!tokens) return;
|
|
9734
8687
|
const loaded = await loadConfig(argv.cwd);
|
|
9735
8688
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -10429,7 +9382,7 @@ const doctorRepoCommand = {
|
|
|
10429
9382
|
command: "repo",
|
|
10430
9383
|
describe: "Check the repository settings against the config (read-only): description, topics, labels, teams, protection, security",
|
|
10431
9384
|
handler: async (argv) => {
|
|
10432
|
-
const tokens = tokenContext(argv.token);
|
|
9385
|
+
const tokens = tokenContext$1(argv.token);
|
|
10433
9386
|
if (!tokens) return;
|
|
10434
9387
|
const loaded = await loadConfig(argv.cwd);
|
|
10435
9388
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -10683,7 +9636,7 @@ const doctorSecretsCommand = {
|
|
|
10683
9636
|
command: "secrets",
|
|
10684
9637
|
describe: "Check the secrets the config says must exist against the ones the provider holds (read-only, names only)",
|
|
10685
9638
|
handler: async (argv) => {
|
|
10686
|
-
const tokens = tokenContext(argv.token);
|
|
9639
|
+
const tokens = tokenContext$1(argv.token);
|
|
10687
9640
|
if (!tokens) return;
|
|
10688
9641
|
const loaded = await loadConfig(argv.cwd);
|
|
10689
9642
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -10975,7 +9928,7 @@ const DEEP_CHECKS = [
|
|
|
10975
9928
|
command: "variables",
|
|
10976
9929
|
describe: "Check the Actions variables the config declares against the ones the provider holds (read-only)",
|
|
10977
9930
|
handler: async (argv) => {
|
|
10978
|
-
const tokens = tokenContext(argv.token);
|
|
9931
|
+
const tokens = tokenContext$1(argv.token);
|
|
10979
9932
|
if (!tokens) return;
|
|
10980
9933
|
const loaded = await loadConfig(argv.cwd);
|
|
10981
9934
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -11122,12 +10075,12 @@ const doctorArgs = (y) => {
|
|
|
11122
10075
|
async function runDoctor(input) {
|
|
11123
10076
|
const print = input.print ?? ((line) => console.log(line));
|
|
11124
10077
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
11125
|
-
await withSpinner("Loading plugins…", () => loader.load());
|
|
10078
|
+
await (0, ui_exports.withSpinner)("Loading plugins…", () => loader.load());
|
|
11126
10079
|
assertPluginsResolvable(loader, "doctor");
|
|
11127
10080
|
const rows = [];
|
|
11128
10081
|
const config = input.loaded.resolved;
|
|
11129
10082
|
print("");
|
|
11130
|
-
print(style.dim(` config: ${input.loaded.filepath}`));
|
|
10083
|
+
print(ui_exports.style.dim(` config: ${input.loaded.filepath}`));
|
|
11131
10084
|
print("");
|
|
11132
10085
|
for (const failure of loader.loadFailures()) rows.push({
|
|
11133
10086
|
capability: failure.key,
|
|
@@ -11143,12 +10096,12 @@ async function runDoctor(input) {
|
|
|
11143
10096
|
const impls = loader.get(key);
|
|
11144
10097
|
for (const [idx, impl] of impls.entries()) {
|
|
11145
10098
|
const name = impl.providerName ?? providers[idx];
|
|
11146
|
-
rows.push(await withProgress(`Checking ${key} (${name})…`, () => smokeCheck(key, name, impl)));
|
|
10099
|
+
rows.push(await withProgress$1(`Checking ${key} (${name})…`, () => smokeCheck(key, name, impl)));
|
|
11147
10100
|
}
|
|
11148
10101
|
} else {
|
|
11149
10102
|
const impl = loader.get(key);
|
|
11150
10103
|
const provider = providers[0] ?? "?";
|
|
11151
|
-
const row = await withProgress(`Checking ${key} (${provider})…`, () => smokeCheck(key, provider, impl));
|
|
10104
|
+
const row = await withProgress$1(`Checking ${key} (${provider})…`, () => smokeCheck(key, provider, impl));
|
|
11152
10105
|
rows.push(row);
|
|
11153
10106
|
}
|
|
11154
10107
|
}
|
|
@@ -11160,7 +10113,7 @@ async function runDoctor(input) {
|
|
|
11160
10113
|
status: row.status,
|
|
11161
10114
|
detail: row.logMessage ?? row.message
|
|
11162
10115
|
}, `doctor: ${row.capability}`);
|
|
11163
|
-
print(statusRow(row.status, [`${pad(row.capability, 14)} via ${pad(row.provider, 14)}`, row.message]));
|
|
10116
|
+
print((0, ui_exports.statusRow)(row.status, [`${(0, ui_exports.pad)(row.capability, 14)} via ${(0, ui_exports.pad)(row.provider, 14)}`, row.message]));
|
|
11164
10117
|
}
|
|
11165
10118
|
const summary = rows.reduce((acc, r) => {
|
|
11166
10119
|
acc[r.status] += 1;
|
|
@@ -11172,7 +10125,7 @@ async function runDoctor(input) {
|
|
|
11172
10125
|
});
|
|
11173
10126
|
const summaryLine = `${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped`;
|
|
11174
10127
|
print("");
|
|
11175
|
-
print(style.header(summaryLine));
|
|
10128
|
+
print(ui_exports.style.header(summaryLine));
|
|
11176
10129
|
return {
|
|
11177
10130
|
rows,
|
|
11178
10131
|
summary
|
|
@@ -11308,7 +10261,7 @@ const doctorCommand = {
|
|
|
11308
10261
|
describe: "Load the config and run a smoke check against every provider",
|
|
11309
10262
|
builder: doctorArgs,
|
|
11310
10263
|
handler: async (argv) => {
|
|
11311
|
-
const tokens = tokenContext(argv.token);
|
|
10264
|
+
const tokens = tokenContext$1(argv.token);
|
|
11312
10265
|
if (!tokens) return;
|
|
11313
10266
|
const loaded = await loadConfig(argv.cwd);
|
|
11314
10267
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -11515,7 +10468,7 @@ async function runGithubAppCreate(input) {
|
|
|
11515
10468
|
return refuse("manifest", errorMessage(err));
|
|
11516
10469
|
}
|
|
11517
10470
|
const file = resolve(input.dir, input.file || DEFAULT_FILE);
|
|
11518
|
-
const git = (input.isIgnored ?? isGitIgnored)(file);
|
|
10471
|
+
const git = (input.isIgnored ?? auth_exports.isGitIgnored)(file);
|
|
11519
10472
|
if (git === "tracked" || git === "unknown") return refuse("not-ignored", git === "tracked" ? `refusing to write credentials to ${file}: git does not ignore it, so it could be committed` : `refusing to write credentials to ${file}: git could not say whether it ignores it`, "add it to .gitignore, or choose another path with --file");
|
|
11520
10473
|
if (!input.force && (input.exists ?? existsSync)(file)) return refuse("exists", `${file} is already there and is never overwritten`, "delete it, or pass --force to replace it");
|
|
11521
10474
|
const state = input.state ?? randomBytes(16).toString("hex");
|
|
@@ -11532,7 +10485,7 @@ async function runGithubAppCreate(input) {
|
|
|
11532
10485
|
let app;
|
|
11533
10486
|
try {
|
|
11534
10487
|
print(`opening ${server.url} — press "Create GitHub App" on GitHub (this page waits up to five minutes)`);
|
|
11535
|
-
(input.openUrl ?? openPath)(server.url);
|
|
10488
|
+
(input.openUrl ?? ui_exports.openPath)(server.url);
|
|
11536
10489
|
app = await (input.convert ?? convertAppManifest)(await server.code);
|
|
11537
10490
|
} catch (err) {
|
|
11538
10491
|
return refuse("create", `the App was not created: ${errorMessage(err)}`);
|
|
@@ -11543,12 +10496,12 @@ async function runGithubAppCreate(input) {
|
|
|
11543
10496
|
let identity;
|
|
11544
10497
|
try {
|
|
11545
10498
|
const lines = [
|
|
11546
|
-
dotenvLine("GITHUB_APP_ID", String(app.id)),
|
|
11547
|
-
dotenvLine("GITHUB_APP_PRIVATE_KEY", app.pem),
|
|
11548
|
-
dotenvLine(input.webhookSecretVar || DEFAULT_WEBHOOK_SECRET_VAR, app.webhookSecret)
|
|
10499
|
+
(0, auth_exports.dotenvLine)("GITHUB_APP_ID", String(app.id)),
|
|
10500
|
+
(0, auth_exports.dotenvLine)("GITHUB_APP_PRIVATE_KEY", app.pem),
|
|
10501
|
+
(0, auth_exports.dotenvLine)(input.webhookSecretVar || DEFAULT_WEBHOOK_SECRET_VAR, app.webhookSecret)
|
|
11549
10502
|
];
|
|
11550
10503
|
if (lines.includes(null)) throw new Error("a value cannot be written as a dotenv line");
|
|
11551
|
-
identity = (input.writeFile ?? writeCredentialsFile)(file, `${lines.join("\n")}\n`, input.force === true);
|
|
10504
|
+
identity = (input.writeFile ?? auth_exports.writeCredentialsFile)(file, `${lines.join("\n")}\n`, input.force === true);
|
|
11552
10505
|
} catch (err) {
|
|
11553
10506
|
logger.warn({
|
|
11554
10507
|
status: "fail",
|
|
@@ -11639,7 +10592,7 @@ const githubAppCreateCommand = {
|
|
|
11639
10592
|
const githubAppCommand = {
|
|
11640
10593
|
command: "github-app <subcommand>",
|
|
11641
10594
|
describe: "Create and manage GitHub Apps",
|
|
11642
|
-
builder: (y) => y.command(githubAppCreateCommand).command(groupMenu("github-app")),
|
|
10595
|
+
builder: (y) => y.command(githubAppCreateCommand).command(groupMenu$1("github-app")),
|
|
11643
10596
|
handler: () => {}
|
|
11644
10597
|
};
|
|
11645
10598
|
// src/commands/menu/menu.command.ts
|
|
@@ -11653,7 +10606,7 @@ const githubAppCommand = {
|
|
|
11653
10606
|
function printVersionHeaderOnce(version) {
|
|
11654
10607
|
const marker = join(tmpdir(), `.holocron-version-shown-${process.ppid}`);
|
|
11655
10608
|
if (existsSync(marker)) return;
|
|
11656
|
-
console.log(style.dim(`v${version}`));
|
|
10609
|
+
console.log(ui_exports.style.dim(`v${version}`));
|
|
11657
10610
|
writeFileSync(marker, "");
|
|
11658
10611
|
}
|
|
11659
10612
|
/** Bare `holocron` (hidden from --help): a menu of every command, with this repo's runnable tasks merged in. */
|
|
@@ -11864,9 +10817,9 @@ const monitoringCheckCommand = {
|
|
|
11864
10817
|
describe: "Run every configured `monitoring` check against a given URL instead of its own configured url",
|
|
11865
10818
|
builder: monitoringCheckArgs,
|
|
11866
10819
|
handler: async (argv) => {
|
|
11867
|
-
const tokens = tokenContext(argv.token);
|
|
10820
|
+
const tokens = tokenContext$1(argv.token);
|
|
11868
10821
|
if (!tokens) return;
|
|
11869
|
-
const [url] = await promptForPositionals(getEntry("monitoring check"), argv);
|
|
10822
|
+
const [url] = await (0, ui_exports.promptForPositionals)(getEntry("monitoring check"), argv);
|
|
11870
10823
|
const loaded = await loadConfig(argv.cwd);
|
|
11871
10824
|
applyResolvedConfig(argv, loaded.resolved);
|
|
11872
10825
|
const { headers } = await resolveVercelBypassHeaders({
|
|
@@ -11924,7 +10877,7 @@ const monitoringResolveChecksCommand = {
|
|
|
11924
10877
|
describe: "Load config/plugins and write the configured `monitoring` checks to a file as JSON — the untrusted half of the delivery.previewCheck split (holocron#1030/#1032)",
|
|
11925
10878
|
builder: monitoringResolveChecksArgs,
|
|
11926
10879
|
handler: async (argv) => {
|
|
11927
|
-
const tokens = tokenContext(argv.token);
|
|
10880
|
+
const tokens = tokenContext$1(argv.token);
|
|
11928
10881
|
if (!tokens) return;
|
|
11929
10882
|
const loaded = await loadConfig(argv.cwd);
|
|
11930
10883
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -11972,7 +10925,7 @@ const monitoringRunResolvedCommand = {
|
|
|
11972
10925
|
const monitoringCommand = {
|
|
11973
10926
|
command: "monitoring",
|
|
11974
10927
|
describe: "Run monitoring checks ad hoc, outside the configured provider",
|
|
11975
|
-
builder: (y) => y.command(monitoringCheckCommand).command(monitoringResolveChecksCommand).command(monitoringRunResolvedCommand).command(groupMenu("monitoring")),
|
|
10928
|
+
builder: (y) => y.command(monitoringCheckCommand).command(monitoringResolveChecksCommand).command(monitoringRunResolvedCommand).command(groupMenu$1("monitoring")),
|
|
11976
10929
|
handler: () => {}
|
|
11977
10930
|
};
|
|
11978
10931
|
// src/commands/plugin-create/template-inputs/template-inputs.ts
|
|
@@ -13045,7 +11998,7 @@ const pluginCreateCommand = {
|
|
|
13045
11998
|
builder: pluginCreateArgs,
|
|
13046
11999
|
handler: async (argv) => {
|
|
13047
12000
|
try {
|
|
13048
|
-
const [slug, vendor] = await promptForPositionals(getEntry("new plugin"), argv);
|
|
12001
|
+
const [slug, vendor] = await (0, ui_exports.promptForPositionals)(getEntry("new plugin"), argv);
|
|
13049
12002
|
const { capability, vendorEnv, baseUrl } = await resolvePluginCreateInputs({
|
|
13050
12003
|
capability: argv.capability,
|
|
13051
12004
|
vendorEnv: argv.vendorEnv,
|
|
@@ -13731,7 +12684,7 @@ const newRepoCommand = {
|
|
|
13731
12684
|
builder: newRepoArgs,
|
|
13732
12685
|
handler: async (argv) => {
|
|
13733
12686
|
try {
|
|
13734
|
-
const tokens = tokenContext(argv.token);
|
|
12687
|
+
const tokens = tokenContext$1(argv.token);
|
|
13735
12688
|
if (!tokens) return;
|
|
13736
12689
|
const adminToken = tokens.cliTokens?.["github"] ?? tokens.cliToken;
|
|
13737
12690
|
const answers = await askNewRepoAnswers(argv);
|
|
@@ -13784,7 +12737,7 @@ const newRepoCommand = {
|
|
|
13784
12737
|
const newCommand = {
|
|
13785
12738
|
command: "new",
|
|
13786
12739
|
describe: "Scaffold a new repo or plugin",
|
|
13787
|
-
builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(groupMenu("new")),
|
|
12740
|
+
builder: (y) => y.command(newRepoCommand).command(pluginCreateCommand).command(groupMenu$1("new")),
|
|
13788
12741
|
handler: () => {}
|
|
13789
12742
|
};
|
|
13790
12743
|
// src/commands/notifications-create-server/find-guild-id.ts
|
|
@@ -13937,9 +12890,9 @@ async function runNotificationsCreateServer(input) {
|
|
|
13937
12890
|
const dryRun = input.context.dryRun ?? false;
|
|
13938
12891
|
const sleep = input.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
13939
12892
|
const refuse = (message, reason = message) => {
|
|
13940
|
-
print(` ${style.fail(message)}`);
|
|
12893
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
13941
12894
|
print("");
|
|
13942
|
-
print(style.header("0 ok, 1 fail, 0 skipped"));
|
|
12895
|
+
print(ui_exports.style.header("0 ok, 1 fail, 0 skipped"));
|
|
13943
12896
|
logger.warn({ reason }, "notifications create-server");
|
|
13944
12897
|
return {
|
|
13945
12898
|
status: "fail",
|
|
@@ -13989,9 +12942,9 @@ async function runNotificationsCreateServer(input) {
|
|
|
13989
12942
|
`write its id into ${input.loaded.filepath}`
|
|
13990
12943
|
];
|
|
13991
12944
|
print("");
|
|
13992
|
-
for (const step of steps) print(` ${style.skip(step)}`);
|
|
12945
|
+
for (const step of steps) print(` ${ui_exports.style.skip(step)}`);
|
|
13993
12946
|
print("");
|
|
13994
|
-
print(style.header("0 ok, 0 fail, 1 skipped"));
|
|
12947
|
+
print(ui_exports.style.header("0 ok, 0 fail, 1 skipped"));
|
|
13995
12948
|
return { status: "dry-run" };
|
|
13996
12949
|
}
|
|
13997
12950
|
const lock = await lockConfig(input.loaded.filepath);
|
|
@@ -13999,7 +12952,7 @@ async function runNotificationsCreateServer(input) {
|
|
|
13999
12952
|
const report = { status: "ok" };
|
|
14000
12953
|
let ok = 0;
|
|
14001
12954
|
const step = (line) => {
|
|
14002
|
-
print(` ${style.success(line)}`);
|
|
12955
|
+
print(` ${ui_exports.style.success(line)}`);
|
|
14003
12956
|
ok++;
|
|
14004
12957
|
};
|
|
14005
12958
|
try {
|
|
@@ -14015,7 +12968,7 @@ async function runNotificationsCreateServer(input) {
|
|
|
14015
12968
|
const written = await writeGuildId(input.loaded.filepath, made.id);
|
|
14016
12969
|
report.configUpdated = written.written;
|
|
14017
12970
|
if (written.written) step(`wrote the server id into ${input.loaded.filepath}`);
|
|
14018
|
-
else print(` ${style.fail(`could not update the config: ${written.reason}. Set guildId to ${made.id} by hand.`)}`);
|
|
12971
|
+
else print(` ${ui_exports.style.fail(`could not update the config: ${written.reason}. Set guildId to ${made.id} by hand.`)}`);
|
|
14019
12972
|
} else if (notifications.serverOwner) {
|
|
14020
12973
|
const owner = await notifications.serverOwner();
|
|
14021
12974
|
if (!owner.isBot) return refuse("the server in the config is not owned by the bot, so there is nothing to hand over; check `guildId` names the server this run created");
|
|
@@ -14036,7 +12989,7 @@ async function runNotificationsCreateServer(input) {
|
|
|
14036
12989
|
step(`invite for member ${input.owner} (one use, valid for a day): ${invite}`);
|
|
14037
12990
|
const waitMs = input.waitMs ?? 9e5;
|
|
14038
12991
|
const pollMs = input.pollMs ?? 5e3;
|
|
14039
|
-
print(` ${style.skip(`waiting for member ${input.owner} to join (up to ${Math.round(waitMs / 6e4)} minutes)…`)}`);
|
|
12992
|
+
print(` ${ui_exports.style.skip(`waiting for member ${input.owner} to join (up to ${Math.round(waitMs / 6e4)} minutes)…`)}`);
|
|
14040
12993
|
let waited = 0;
|
|
14041
12994
|
while (!await notifications.hasMember(input.owner)) {
|
|
14042
12995
|
if (waited >= waitMs) return refuse(`member ${input.owner} did not join in time; the server is ready and still owned by the bot. Open the invite, then run \`holocron notifications create-server --resume --owner ${input.owner}\``);
|
|
@@ -14056,7 +13009,7 @@ async function runNotificationsCreateServer(input) {
|
|
|
14056
13009
|
await lock.release();
|
|
14057
13010
|
}
|
|
14058
13011
|
print("");
|
|
14059
|
-
print(style.header(`${ok} ok, 0 fail, 0 skipped`));
|
|
13012
|
+
print(ui_exports.style.header(`${ok} ok, 0 fail, 0 skipped`));
|
|
14060
13013
|
logger.info({ serverId: report.serverId }, "notifications create-server");
|
|
14061
13014
|
return report;
|
|
14062
13015
|
}
|
|
@@ -14086,7 +13039,7 @@ const notificationsCreateServerCommand = {
|
|
|
14086
13039
|
describe: "Create the server the layout describes, apply it, invite its owner and hand it over",
|
|
14087
13040
|
builder: notificationsCreateServerArgs,
|
|
14088
13041
|
handler: async (argv) => {
|
|
14089
|
-
const tokens = tokenContext(argv.token);
|
|
13042
|
+
const tokens = tokenContext$1(argv.token);
|
|
14090
13043
|
if (!tokens) return;
|
|
14091
13044
|
const loaded = await loadConfig(argv.cwd);
|
|
14092
13045
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -14117,7 +13070,7 @@ const notificationsLinkCommand = {
|
|
|
14117
13070
|
describe: "Link your server account to your GitHub account by signing in with the provider",
|
|
14118
13071
|
builder: notificationsLinkArgs,
|
|
14119
13072
|
handler: async (argv) => {
|
|
14120
|
-
const tokens = tokenContext(argv.token);
|
|
13073
|
+
const tokens = tokenContext$1(argv.token);
|
|
14121
13074
|
if (!tokens) return;
|
|
14122
13075
|
const loaded = await loadConfig(argv.cwd);
|
|
14123
13076
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -14147,7 +13100,7 @@ const notificationsSetupCommand = {
|
|
|
14147
13100
|
describe: "Apply the server layout a notifications provider declares in holocron.config.ts",
|
|
14148
13101
|
builder: notificationsSetupArgs,
|
|
14149
13102
|
handler: async (argv) => {
|
|
14150
|
-
const tokens = tokenContext(argv.token);
|
|
13103
|
+
const tokens = tokenContext$1(argv.token);
|
|
14151
13104
|
if (!tokens) return;
|
|
14152
13105
|
const loaded = await loadConfig(argv.cwd);
|
|
14153
13106
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -14179,7 +13132,7 @@ const notificationsSyncRolesCommand = {
|
|
|
14179
13132
|
describe: "Make who holds a server role match a team, through the links file",
|
|
14180
13133
|
builder: notificationsSyncRolesArgs,
|
|
14181
13134
|
handler: async (argv) => {
|
|
14182
|
-
const tokens = tokenContext(argv.token);
|
|
13135
|
+
const tokens = tokenContext$1(argv.token);
|
|
14183
13136
|
if (!tokens) return;
|
|
14184
13137
|
const loaded = await loadConfig(argv.cwd);
|
|
14185
13138
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -14229,9 +13182,9 @@ const notificationsChannelAddCommand = {
|
|
|
14229
13182
|
describe: "Create a channel, optionally with a webhook whose URL is stored as a secret",
|
|
14230
13183
|
builder: notificationsChannelAddArgs,
|
|
14231
13184
|
handler: async (argv) => {
|
|
14232
|
-
const tokens = tokenContext(argv.token);
|
|
13185
|
+
const tokens = tokenContext$1(argv.token);
|
|
14233
13186
|
if (!tokens) return;
|
|
14234
|
-
const [name] = await promptForPositionals(getEntry("notifications channel add"), argv);
|
|
13187
|
+
const [name] = await (0, ui_exports.promptForPositionals)(getEntry("notifications channel add"), argv);
|
|
14235
13188
|
const loaded = await loadConfig(argv.cwd);
|
|
14236
13189
|
applyResolvedConfig(argv, loaded.resolved);
|
|
14237
13190
|
if ((await runNotificationsChannelAdd({
|
|
@@ -14257,14 +13210,14 @@ const notificationsChannelAddCommand = {
|
|
|
14257
13210
|
const notificationsChannelCommand = {
|
|
14258
13211
|
command: "channel",
|
|
14259
13212
|
describe: "Manage notification channels",
|
|
14260
|
-
builder: (y) => y.command(notificationsChannelAddCommand).command(groupMenu("notifications channel")),
|
|
13213
|
+
builder: (y) => y.command(notificationsChannelAddCommand).command(groupMenu$1("notifications channel")),
|
|
14261
13214
|
handler: () => {}
|
|
14262
13215
|
};
|
|
14263
13216
|
// src/commands/notifications/notifications.command.ts
|
|
14264
13217
|
const notificationsCommand = {
|
|
14265
13218
|
command: "notifications",
|
|
14266
13219
|
describe: "Provision notification channels, webhooks and roles",
|
|
14267
|
-
builder: (y) => y.command(notificationsChannelCommand).command(notificationsSetupCommand).command(notificationsCreateServerCommand).command(notificationsLinkCommand).command(notificationsSyncRolesCommand).command(groupMenu("notifications")),
|
|
13220
|
+
builder: (y) => y.command(notificationsChannelCommand).command(notificationsSetupCommand).command(notificationsCreateServerCommand).command(notificationsLinkCommand).command(notificationsSyncRolesCommand).command(groupMenu$1("notifications")),
|
|
14268
13221
|
handler: () => {}
|
|
14269
13222
|
};
|
|
14270
13223
|
// src/commands/move-tag/move-tag.ts
|
|
@@ -14393,7 +13346,7 @@ const moveTagCommand = {
|
|
|
14393
13346
|
describe: "Move a version group's major tag (ci-v1) to its latest stable release (semantic-release publishCmd)",
|
|
14394
13347
|
builder: moveTagArgs,
|
|
14395
13348
|
handler: async (argv) => {
|
|
14396
|
-
const [group] = await promptForPositionals(getEntry("package move-tag"), argv);
|
|
13349
|
+
const [group] = await (0, ui_exports.promptForPositionals)(getEntry("package move-tag"), argv);
|
|
14397
13350
|
if ((await runMoveTag({
|
|
14398
13351
|
group,
|
|
14399
13352
|
cwd: argv.cwd,
|
|
@@ -14536,7 +13489,7 @@ const npmBumpVersionsCommand = {
|
|
|
14536
13489
|
describe: "Bump all non-private package versions in lockstep (semantic-release prepareCmd)",
|
|
14537
13490
|
builder: npmBumpVersionsArgs,
|
|
14538
13491
|
handler: async (argv) => {
|
|
14539
|
-
const [newVersion] = await promptForPositionals(getEntry("package bump-versions"), argv);
|
|
13492
|
+
const [newVersion] = await (0, ui_exports.promptForPositionals)(getEntry("package bump-versions"), argv);
|
|
14540
13493
|
if ((await runNpmBumpVersions({
|
|
14541
13494
|
version: newVersion,
|
|
14542
13495
|
cwd: argv.cwd,
|
|
@@ -14669,9 +13622,9 @@ async function filterNewPackages(entries, cwd, exec, print, nameWidth, dirWidth)
|
|
|
14669
13622
|
], { cwd });
|
|
14670
13623
|
const publishedVersion = view.exitCode === 0 ? view.stdout.trim() : "";
|
|
14671
13624
|
if (publishedVersion) {
|
|
14672
|
-
print(statusRow("skip", [
|
|
14673
|
-
pad(entry.name, nameWidth),
|
|
14674
|
-
pad(entry.dir, dirWidth),
|
|
13625
|
+
print((0, ui_exports.statusRow)("skip", [
|
|
13626
|
+
(0, ui_exports.pad)(entry.name, nameWidth),
|
|
13627
|
+
(0, ui_exports.pad)(entry.dir, dirWidth),
|
|
14675
13628
|
`already published (v${publishedVersion})`
|
|
14676
13629
|
]));
|
|
14677
13630
|
continue;
|
|
@@ -14799,7 +13752,7 @@ function workspaceFilterArgs(cwd, scope = {}) {
|
|
|
14799
13752
|
function printSummary(print, dryRun, publishedCount, failedCount, skippedCount) {
|
|
14800
13753
|
const summary = `${publishedCount} published, ${failedCount} failed, ${skippedCount} skipped`;
|
|
14801
13754
|
print("");
|
|
14802
|
-
print(dryRun ? style.dim(` dry-run: ${summary}`) : failedCount > 0 ? style.fail(` ${summary}`) : style.success(` ${summary}`));
|
|
13755
|
+
print(dryRun ? ui_exports.style.dim(` dry-run: ${summary}`) : failedCount > 0 ? ui_exports.style.fail(` ${summary}`) : ui_exports.style.success(` ${summary}`));
|
|
14803
13756
|
}
|
|
14804
13757
|
async function runPublish(input = {}) {
|
|
14805
13758
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -14816,7 +13769,7 @@ async function runPublish(input = {}) {
|
|
|
14816
13769
|
dryRun: dryRun || void 0
|
|
14817
13770
|
}, "publish --initial: start");
|
|
14818
13771
|
print("");
|
|
14819
|
-
print(style.dim(" → verifying npm auth (`npm whoami`)…"));
|
|
13772
|
+
print(ui_exports.style.dim(" → verifying npm auth (`npm whoami`)…"));
|
|
14820
13773
|
let whoami = await exec("npm", ["whoami"], { cwd });
|
|
14821
13774
|
if (whoami.exitCode !== 0) {
|
|
14822
13775
|
print(" not authenticated — running `npm login --auth-type=web`…");
|
|
@@ -14846,9 +13799,9 @@ async function runPublish(input = {}) {
|
|
|
14846
13799
|
}
|
|
14847
13800
|
}
|
|
14848
13801
|
const whoamiName = whoami.stdout.trim() || "<unknown>";
|
|
14849
|
-
print(style.dim(` ✓ authed as ${whoamiName}`));
|
|
13802
|
+
print(ui_exports.style.dim(` ✓ authed as ${whoamiName}`));
|
|
14850
13803
|
print("");
|
|
14851
|
-
if (otp) print(style.dim(` otp: <${otp.length} chars>`));
|
|
13804
|
+
if (otp) print(ui_exports.style.dim(` otp: <${otp.length} chars>`));
|
|
14852
13805
|
const discoveredEntries = input.packages ?? discoverPublicPackageEntries(cwd, scopeOf(input));
|
|
14853
13806
|
const nameWidth = Math.max(0, ...discoveredEntries.map((e) => e.name.length));
|
|
14854
13807
|
const dirWidth = Math.max(0, ...discoveredEntries.map((e) => e.dir.length));
|
|
@@ -14895,8 +13848,8 @@ async function runPublish(input = {}) {
|
|
|
14895
13848
|
];
|
|
14896
13849
|
if (dryRun) {
|
|
14897
13850
|
print("");
|
|
14898
|
-
for (const entry of newEntries) print(style.dim(` ${pad(entry.name, nameWidth)} ${pad(entry.dir, dirWidth)} would publish (v${entry.version})`));
|
|
14899
|
-
print(style.dim(` would run: pnpm ${redactOtp(publishArgs, otp).join(" ")}`));
|
|
13851
|
+
for (const entry of newEntries) print(ui_exports.style.dim(` ${(0, ui_exports.pad)(entry.name, nameWidth)} ${(0, ui_exports.pad)(entry.dir, dirWidth)} would publish (v${entry.version})`));
|
|
13852
|
+
print(ui_exports.style.dim(` would run: pnpm ${redactOtp(publishArgs, otp).join(" ")}`));
|
|
14900
13853
|
printSummary(print, dryRun, packageNames.length, 0, skippedCount);
|
|
14901
13854
|
printNextSteps(print, env, packageNames, identity);
|
|
14902
13855
|
logger.info({
|
|
@@ -14921,9 +13874,9 @@ async function runPublish(input = {}) {
|
|
|
14921
13874
|
print(" → hint: your npm account requires 2FA for writes. Re-run with `--otp <code>`:");
|
|
14922
13875
|
print(` pnpm exec tsx cli/cli/src/cli.ts package publish --initial --otp <6-digit-code>`);
|
|
14923
13876
|
}
|
|
14924
|
-
for (const entry of newEntries) print(statusRow("fail", [
|
|
14925
|
-
pad(entry.name, nameWidth),
|
|
14926
|
-
pad(entry.dir, dirWidth),
|
|
13877
|
+
for (const entry of newEntries) print((0, ui_exports.statusRow)("fail", [
|
|
13878
|
+
(0, ui_exports.pad)(entry.name, nameWidth),
|
|
13879
|
+
(0, ui_exports.pad)(entry.dir, dirWidth),
|
|
14927
13880
|
"publish failed"
|
|
14928
13881
|
]));
|
|
14929
13882
|
printSummary(print, dryRun, 0, packageNames.length, skippedCount);
|
|
@@ -14937,9 +13890,9 @@ async function runPublish(input = {}) {
|
|
|
14937
13890
|
packageNames
|
|
14938
13891
|
};
|
|
14939
13892
|
}
|
|
14940
|
-
for (const entry of newEntries) print(statusRow("ok", [
|
|
14941
|
-
pad(entry.name, nameWidth),
|
|
14942
|
-
pad(entry.dir, dirWidth),
|
|
13893
|
+
for (const entry of newEntries) print((0, ui_exports.statusRow)("ok", [
|
|
13894
|
+
(0, ui_exports.pad)(entry.name, nameWidth),
|
|
13895
|
+
(0, ui_exports.pad)(entry.dir, dirWidth),
|
|
14943
13896
|
`published (v${entry.version})`
|
|
14944
13897
|
]));
|
|
14945
13898
|
printSummary(print, dryRun, packageNames.length, 0, skippedCount);
|
|
@@ -15405,7 +14358,7 @@ const publishCommand = {
|
|
|
15405
14358
|
const packageCommand = {
|
|
15406
14359
|
command: "package",
|
|
15407
14360
|
describe: "Version and publish workspace packages",
|
|
15408
|
-
builder: (y) => y.command(npmBumpVersionsCommand).command(moveTagCommand).command(publishCommand).command(groupMenu("package")),
|
|
14361
|
+
builder: (y) => y.command(npmBumpVersionsCommand).command(moveTagCommand).command(publishCommand).command(groupMenu$1("package")),
|
|
15409
14362
|
handler: () => {}
|
|
15410
14363
|
};
|
|
15411
14364
|
// src/commands/probe/probe.args.ts
|
|
@@ -17166,7 +16119,7 @@ function listProbes(groups) {
|
|
|
17166
16119
|
const lines = [];
|
|
17167
16120
|
const width = Math.max(0, ...[...groups.values()].flatMap((g) => Object.keys(g).map((n) => n.length)));
|
|
17168
16121
|
for (const [provider, probes] of [...groups].sort(([a], [b]) => a.localeCompare(b))) {
|
|
17169
|
-
lines.push(style.header(provider));
|
|
16122
|
+
lines.push(ui_exports.style.header(provider));
|
|
17170
16123
|
for (const [name, probe] of Object.entries(probes).sort(([a], [b]) => a.localeCompare(b))) {
|
|
17171
16124
|
const mark = probe.writes ? " (changes things)" : "";
|
|
17172
16125
|
lines.push(` ${name.padEnd(width)} ${probe.summary}${mark}`);
|
|
@@ -17408,7 +16361,7 @@ const defaultInterrupt = (handler) => {
|
|
|
17408
16361
|
* failed or was interrupted.
|
|
17409
16362
|
*/
|
|
17410
16363
|
async function runProbe(input) {
|
|
17411
|
-
const progress = createProgress(input.print ?? ((line) => console.log(line)));
|
|
16364
|
+
const progress = createProgress$1(input.print ?? ((line) => console.log(line)));
|
|
17412
16365
|
const print = progress.print;
|
|
17413
16366
|
const secrets = new Set(input.secrets ?? []);
|
|
17414
16367
|
const scrub = createScrubber(secrets);
|
|
@@ -17420,11 +16373,11 @@ async function runProbe(input) {
|
|
|
17420
16373
|
...row.detail ? { detail: scrub(sanitizeDetail(row.detail)) } : {}
|
|
17421
16374
|
};
|
|
17422
16375
|
rows.push(clean);
|
|
17423
|
-
if (clean.status === "heading") print(`\n ${style.header(clean.label)}`);
|
|
17424
|
-
else print(statusRow(clean.status === "info" ? "skip" : clean.status, [clean.label, clean.detail ?? ""]));
|
|
16376
|
+
if (clean.status === "heading") print(`\n ${ui_exports.style.header(clean.label)}`);
|
|
16377
|
+
else print((0, ui_exports.statusRow)(clean.status === "info" ? "skip" : clean.status, [clean.label, clean.detail ?? ""]));
|
|
17425
16378
|
};
|
|
17426
16379
|
if (input.probe.writes && !input.dryRun && !input.yes) {
|
|
17427
|
-
if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`${input.name}\` changes things on ${input.provider} (${input.probe.summary}); pass --yes to run it without asking`);
|
|
16380
|
+
if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new ui_exports.NonInteractiveError(`\`${input.name}\` changes things on ${input.provider} (${input.probe.summary}); pass --yes to run it without asking`);
|
|
17428
16381
|
if (!await (input.confirm ?? ((message) => confirm({
|
|
17429
16382
|
message,
|
|
17430
16383
|
default: false
|
|
@@ -17804,7 +16757,7 @@ async function runProbeCommand(input) {
|
|
|
17804
16757
|
}
|
|
17805
16758
|
const probes = groups.get(input.provider);
|
|
17806
16759
|
if (!probes) {
|
|
17807
|
-
print(statusRow("fail", [`no probes for \`${input.provider}\``, `try: ${[...groups.keys()].sort().join(", ")}`]));
|
|
16760
|
+
print((0, ui_exports.statusRow)("fail", [`no probes for \`${input.provider}\``, `try: ${[...groups.keys()].sort().join(", ")}`]));
|
|
17808
16761
|
return { status: "fail" };
|
|
17809
16762
|
}
|
|
17810
16763
|
if (!input.probe) {
|
|
@@ -17813,7 +16766,7 @@ async function runProbeCommand(input) {
|
|
|
17813
16766
|
}
|
|
17814
16767
|
const probe = probes[input.probe];
|
|
17815
16768
|
if (!probe) {
|
|
17816
|
-
print(statusRow("fail", [`\`${input.provider}\` has no probe \`${input.probe}\``, `try: ${Object.keys(probes).sort().join(", ")}`]));
|
|
16769
|
+
print((0, ui_exports.statusRow)("fail", [`\`${input.provider}\` has no probe \`${input.probe}\``, `try: ${Object.keys(probes).sort().join(", ")}`]));
|
|
17817
16770
|
return { status: "fail" };
|
|
17818
16771
|
}
|
|
17819
16772
|
const tokens = [input.context.cliToken, ...Object.values(input.context.cliTokens ?? {})].filter((t) => typeof t === "string");
|
|
@@ -17839,7 +16792,7 @@ const probeCommand = {
|
|
|
17839
16792
|
describe: "Poke a live provider on purpose: inspect it, or run a proof that cleans up after itself",
|
|
17840
16793
|
builder: probeArgs,
|
|
17841
16794
|
handler: async (argv) => {
|
|
17842
|
-
const tokens = tokenContext(argv.token);
|
|
16795
|
+
const tokens = tokenContext$1(argv.token);
|
|
17843
16796
|
if (!tokens) return;
|
|
17844
16797
|
const loaded = await loadConfig(argv.cwd);
|
|
17845
16798
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -18315,7 +17268,7 @@ async function execStep(capability, step, dryRun, body, opts = {}) {
|
|
|
18315
17268
|
status: "dry-run"
|
|
18316
17269
|
};
|
|
18317
17270
|
try {
|
|
18318
|
-
const note = await withProgress(`${capability}: ${step}…`, body);
|
|
17271
|
+
const note = await withProgress$1(`${capability}: ${step}…`, body);
|
|
18319
17272
|
const result = {
|
|
18320
17273
|
capability,
|
|
18321
17274
|
step,
|
|
@@ -18358,12 +17311,12 @@ function classify403(err) {
|
|
|
18358
17311
|
}
|
|
18359
17312
|
function formatStep(step) {
|
|
18360
17313
|
const tag = step.reason === "permissions" ? " [permissions]" : step.reason === "plan" ? " [plan restriction]" : "";
|
|
18361
|
-
const detail = step.message ? style.dim(` (${step.message})`) : "";
|
|
17314
|
+
const detail = step.message ? ui_exports.style.dim(` (${step.message})`) : "";
|
|
18362
17315
|
const label = `${step.step}${tag}${detail}`;
|
|
18363
|
-
if (step.status === "ok") return ` ${style.success(label)}`;
|
|
18364
|
-
if (step.status === "fail") return ` ${style.fail(label)}`;
|
|
18365
|
-
if (step.status === "dry-run") return ` ${style.dim(`… ${label}`)}`;
|
|
18366
|
-
return ` ${style.dim(`· ${label}`)}`;
|
|
17316
|
+
if (step.status === "ok") return ` ${ui_exports.style.success(label)}`;
|
|
17317
|
+
if (step.status === "fail") return ` ${ui_exports.style.fail(label)}`;
|
|
17318
|
+
if (step.status === "dry-run") return ` ${ui_exports.style.dim(`… ${label}`)}`;
|
|
17319
|
+
return ` ${ui_exports.style.dim(`· ${label}`)}`;
|
|
18367
17320
|
}
|
|
18368
17321
|
// src/commands/setup/skills/skills.ts
|
|
18369
17322
|
async function fetchExternalSkill(entry) {
|
|
@@ -18563,7 +17516,7 @@ async function runSetup(input) {
|
|
|
18563
17516
|
const print = input.print ?? ((line) => console.log(line));
|
|
18564
17517
|
const logger = getLogger();
|
|
18565
17518
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
18566
|
-
await withSpinner("Loading plugins…", () => loader.load());
|
|
17519
|
+
await (0, ui_exports.withSpinner)("Loading plugins…", () => loader.load());
|
|
18567
17520
|
assertPluginsResolvable(loader, "repo setup");
|
|
18568
17521
|
const config = input.loaded.resolved;
|
|
18569
17522
|
const dryRun = input.context.dryRun ?? false;
|
|
@@ -18574,12 +17527,12 @@ async function runSetup(input) {
|
|
|
18574
17527
|
fallback: "start",
|
|
18575
17528
|
realpath: true
|
|
18576
17529
|
}), input.loaded.filepath);
|
|
18577
|
-
print(style.header(`Holocron setup — ${config.name}${dryRun ? " (dry-run)" : ""}`));
|
|
18578
|
-
print(style.dim(` config: ${input.loaded.filepath}`));
|
|
17530
|
+
print(ui_exports.style.header(`Holocron setup — ${config.name}${dryRun ? " (dry-run)" : ""}`));
|
|
17531
|
+
print(ui_exports.style.dim(` config: ${input.loaded.filepath}`));
|
|
18579
17532
|
print("");
|
|
18580
17533
|
if (loader.has("source")) {
|
|
18581
17534
|
const source = loader.get("source");
|
|
18582
|
-
print(style.step("source"));
|
|
17535
|
+
print(ui_exports.style.step("source"));
|
|
18583
17536
|
const SECURITY_SKIP_CODES = {
|
|
18584
17537
|
enableSecretScanning: [422],
|
|
18585
17538
|
enablePrivateVulnerabilityReporting: [404]
|
|
@@ -18623,7 +17576,7 @@ async function runSetup(input) {
|
|
|
18623
17576
|
}
|
|
18624
17577
|
if (loader.has("source")) {
|
|
18625
17578
|
const source = loader.get("source");
|
|
18626
|
-
if (config.tasks && config.tasks.length > 0) print(style.step("workflows"));
|
|
17579
|
+
if (config.tasks && config.tasks.length > 0) print(ui_exports.style.step("workflows"));
|
|
18627
17580
|
for (const entry of await generateRepoFiles({
|
|
18628
17581
|
loaded: input.loaded,
|
|
18629
17582
|
repoRoot: input.context.repoRoot,
|
|
@@ -18792,7 +17745,7 @@ async function runSetup(input) {
|
|
|
18792
17745
|
}
|
|
18793
17746
|
if (loader.has("environments")) {
|
|
18794
17747
|
const envs = loader.get("environments");
|
|
18795
|
-
print(style.step("environments"));
|
|
17748
|
+
print(ui_exports.style.step("environments"));
|
|
18796
17749
|
for (const envName of SETUP_ENVIRONMENTS) {
|
|
18797
17750
|
steps.push(await runStep("environments", `upsert ${envName}`, dryRun, async () => {
|
|
18798
17751
|
await envs.upsertEnvironment({ name: envName });
|
|
@@ -18812,7 +17765,7 @@ async function runSetup(input) {
|
|
|
18812
17765
|
} catch (err) {
|
|
18813
17766
|
if (!(err instanceof AuthError)) throw err;
|
|
18814
17767
|
}
|
|
18815
|
-
print(style.step("docs"));
|
|
17768
|
+
print(ui_exports.style.step("docs"));
|
|
18816
17769
|
if (!deployToken) {
|
|
18817
17770
|
steps.push({
|
|
18818
17771
|
capability: "source",
|
|
@@ -18834,7 +17787,7 @@ async function runSetup(input) {
|
|
|
18834
17787
|
}
|
|
18835
17788
|
if (loader.has("wiki")) {
|
|
18836
17789
|
const wiki = loader.get("wiki");
|
|
18837
|
-
print(style.step("wiki"));
|
|
17790
|
+
print(ui_exports.style.step("wiki"));
|
|
18838
17791
|
steps.push(await runStep("wiki", "provision wiki config", dryRun, async () => {
|
|
18839
17792
|
return await wiki.provision({ name: config.name });
|
|
18840
17793
|
}));
|
|
@@ -18862,7 +17815,7 @@ async function runSetup(input) {
|
|
|
18862
17815
|
}
|
|
18863
17816
|
if (loader.has("deployment")) {
|
|
18864
17817
|
const deploy = loader.get("deployment");
|
|
18865
|
-
print(style.step("deployment"));
|
|
17818
|
+
print(ui_exports.style.step("deployment"));
|
|
18866
17819
|
const previewCfg = previewConfigOf(config);
|
|
18867
17820
|
const ensureCustomDomain = async (projectId, hostname) => {
|
|
18868
17821
|
if (!deploy.ensureCustomDomain) return;
|
|
@@ -18922,7 +17875,7 @@ async function runSetup(input) {
|
|
|
18922
17875
|
}
|
|
18923
17876
|
if (loader.has("auth")) {
|
|
18924
17877
|
const auth = loader.get("auth");
|
|
18925
|
-
print(style.step("auth"));
|
|
17878
|
+
print(ui_exports.style.step("auth"));
|
|
18926
17879
|
if (auth.ensureWebhookApp) {
|
|
18927
17880
|
steps.push(await runStep("auth", "ensureWebhookApp", dryRun, async () => {
|
|
18928
17881
|
return `webhook ${(await auth.ensureWebhookApp()).alreadyExists ? "exists" : "created"}`;
|
|
@@ -18940,7 +17893,7 @@ async function runSetup(input) {
|
|
|
18940
17893
|
}
|
|
18941
17894
|
if (loader.has("vault")) {
|
|
18942
17895
|
const vault = loader.get("vault");
|
|
18943
|
-
print(style.step("vault"));
|
|
17896
|
+
print(ui_exports.style.step("vault"));
|
|
18944
17897
|
if (vault.ensureProject) {
|
|
18945
17898
|
steps.push(await runStep("vault", `ensureProject ${config.name}`, dryRun, async () => {
|
|
18946
17899
|
return `project ${(await vault.ensureProject(config.name)).alreadyExists ? "exists" : "created"}`;
|
|
@@ -18978,7 +17931,7 @@ async function runSetup(input) {
|
|
|
18978
17931
|
}
|
|
18979
17932
|
if (loader.has("errors")) {
|
|
18980
17933
|
const errors = loader.get("errors");
|
|
18981
|
-
print(style.step("errors"));
|
|
17934
|
+
print(ui_exports.style.step("errors"));
|
|
18982
17935
|
if (errors.ensureProject) {
|
|
18983
17936
|
let dsn;
|
|
18984
17937
|
steps.push(await runStep("errors", `ensureProject ${config.name}`, dryRun, async () => {
|
|
@@ -19001,7 +17954,7 @@ async function runSetup(input) {
|
|
|
19001
17954
|
}
|
|
19002
17955
|
if (loader.has("logs")) {
|
|
19003
17956
|
const logs = loader.get("logs");
|
|
19004
|
-
print(style.step("logs"));
|
|
17957
|
+
print(ui_exports.style.step("logs"));
|
|
19005
17958
|
if (logs.ensureDataset) for (const dataset of ["holocron-ci", "holocron-local"]) {
|
|
19006
17959
|
steps.push(await runStep("logs", `ensureDataset ${dataset}`, dryRun, async () => {
|
|
19007
17960
|
const result = await logs.ensureDataset(dataset);
|
|
@@ -19012,7 +17965,7 @@ async function runSetup(input) {
|
|
|
19012
17965
|
}
|
|
19013
17966
|
if (loader.has("monitoring")) {
|
|
19014
17967
|
const monitoring = loader.get("monitoring");
|
|
19015
|
-
print(style.step("monitoring"));
|
|
17968
|
+
print(ui_exports.style.step("monitoring"));
|
|
19016
17969
|
for (const checkInput of monitoring.checks) {
|
|
19017
17970
|
steps.push(await runStep("monitoring", `ensureCheck ${checkInput.name}`, dryRun, async () => {
|
|
19018
17971
|
const result = await monitoring.ensureCheck(checkInput);
|
|
@@ -19023,7 +17976,7 @@ async function runSetup(input) {
|
|
|
19023
17976
|
}
|
|
19024
17977
|
if (loader.has("tooling")) {
|
|
19025
17978
|
const tools = loader.get("tooling");
|
|
19026
|
-
print(style.step("tooling"));
|
|
17979
|
+
print(ui_exports.style.step("tooling"));
|
|
19027
17980
|
for (const tool of tools) {
|
|
19028
17981
|
steps.push(await runStep("tooling", `${tool.providerName}.sync`, dryRun, async () => {
|
|
19029
17982
|
await tool.sync();
|
|
@@ -19032,7 +17985,7 @@ async function runSetup(input) {
|
|
|
19032
17985
|
}
|
|
19033
17986
|
}
|
|
19034
17987
|
if (config.skills && config.skills.length > 0 && config.agent) {
|
|
19035
|
-
print(style.step("skills"));
|
|
17988
|
+
print(ui_exports.style.step("skills"));
|
|
19036
17989
|
if (!(config.agent in AGENT_SYMLINK_PATHS)) steps.push({
|
|
19037
17990
|
capability: "skills",
|
|
19038
17991
|
step: "install skills",
|
|
@@ -19049,14 +18002,14 @@ async function runSetup(input) {
|
|
|
19049
18002
|
print(formatStep(steps[steps.length - 1]));
|
|
19050
18003
|
}
|
|
19051
18004
|
if (config.agent) {
|
|
19052
|
-
print(style.step("prompts"));
|
|
18005
|
+
print(ui_exports.style.step("prompts"));
|
|
19053
18006
|
steps.push(await runStep("prompts", "install agent prompts", dryRun, async () => {
|
|
19054
18007
|
return await installAgentPrompts({ repoRoot: input.context.repoRoot });
|
|
19055
18008
|
}));
|
|
19056
18009
|
print(formatStep(steps[steps.length - 1]));
|
|
19057
18010
|
}
|
|
19058
18011
|
if (config.docs) {
|
|
19059
|
-
print(style.step("engineering"));
|
|
18012
|
+
print(ui_exports.style.step("engineering"));
|
|
19060
18013
|
steps.push(await runStep("engineering", "provision engineering structure", dryRun, async () => {
|
|
19061
18014
|
return await installEngineeringStructure({ repoRoot: input.context.repoRoot });
|
|
19062
18015
|
}));
|
|
@@ -19076,56 +18029,56 @@ async function runSetup(input) {
|
|
|
19076
18029
|
});
|
|
19077
18030
|
print("");
|
|
19078
18031
|
const summaryLine = ` ${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped${dryRun ? `, ${summary.dryRun} would-do` : ""}`;
|
|
19079
|
-
print(summary.fail > 0 ? style.fail(summaryLine.trim()) : style.success(summaryLine.trim()));
|
|
18032
|
+
print(summary.fail > 0 ? ui_exports.style.fail(summaryLine.trim()) : ui_exports.style.success(summaryLine.trim()));
|
|
19080
18033
|
const skippedSteps = steps.filter((s) => s.status === "skip");
|
|
19081
18034
|
if (skippedSteps.length > 0) {
|
|
19082
18035
|
print("");
|
|
19083
|
-
print(style.hint(" Skipped:"));
|
|
18036
|
+
print(ui_exports.style.hint(" Skipped:"));
|
|
19084
18037
|
for (const s of skippedSteps)
|
|
19085
18038
|
/* v8 ignore next -- all skip steps set message; empty fallback is defensive */
|
|
19086
|
-
print(style.hint(` · ${s.step}${s.message ? ` (${s.message})` : ""}`));
|
|
18039
|
+
print(ui_exports.style.hint(` · ${s.step}${s.message ? ` (${s.message})` : ""}`));
|
|
19087
18040
|
}
|
|
19088
18041
|
if (steps.some((s) => s.reason === "permissions")) {
|
|
19089
18042
|
print("");
|
|
19090
|
-
print(style.warn("Some steps failed with 403 (insufficient token permissions)."));
|
|
19091
|
-
print(style.hint(" Repo-scoped operations (rulesets, settings, workflows) require a"));
|
|
19092
|
-
print(style.hint(" fine-grained PAT passed via --token or HOLOCRON_ADMIN_TOKEN:"));
|
|
18043
|
+
print(ui_exports.style.warn("Some steps failed with 403 (insufficient token permissions)."));
|
|
18044
|
+
print(ui_exports.style.hint(" Repo-scoped operations (rulesets, settings, workflows) require a"));
|
|
18045
|
+
print(ui_exports.style.hint(" fine-grained PAT passed via --token or HOLOCRON_ADMIN_TOKEN:"));
|
|
19093
18046
|
print("");
|
|
19094
|
-
print(style.hint(" · Administration — read and write"));
|
|
19095
|
-
print(style.hint(" · Code scanning alerts — read and write"));
|
|
19096
|
-
print(style.hint(" · Contents — read and write"));
|
|
19097
|
-
print(style.hint(" · Custom properties — read and write"));
|
|
19098
|
-
print(style.hint(" · Environments — read and write"));
|
|
19099
|
-
print(style.hint(" · Issues — read and write (labels)"));
|
|
19100
|
-
print(style.hint(" · Secret scanning alerts — read and write"));
|
|
19101
|
-
print(style.hint(" · Secrets — read and write"));
|
|
19102
|
-
print(style.hint(" · Variables — read and write (Actions variables)"));
|
|
19103
|
-
print(style.hint(" · Workflows — read and write"));
|
|
19104
|
-
print(style.hint(" · Metadata — read (added automatically)"));
|
|
18047
|
+
print(ui_exports.style.hint(" · Administration — read and write"));
|
|
18048
|
+
print(ui_exports.style.hint(" · Code scanning alerts — read and write"));
|
|
18049
|
+
print(ui_exports.style.hint(" · Contents — read and write"));
|
|
18050
|
+
print(ui_exports.style.hint(" · Custom properties — read and write"));
|
|
18051
|
+
print(ui_exports.style.hint(" · Environments — read and write"));
|
|
18052
|
+
print(ui_exports.style.hint(" · Issues — read and write (labels)"));
|
|
18053
|
+
print(ui_exports.style.hint(" · Secret scanning alerts — read and write"));
|
|
18054
|
+
print(ui_exports.style.hint(" · Secrets — read and write"));
|
|
18055
|
+
print(ui_exports.style.hint(" · Variables — read and write (Actions variables)"));
|
|
18056
|
+
print(ui_exports.style.hint(" · Workflows — read and write"));
|
|
18057
|
+
print(ui_exports.style.hint(" · Metadata — read (added automatically)"));
|
|
19105
18058
|
print("");
|
|
19106
|
-
print(style.hint(" Org-scoped operations (teams, organization Actions variables) require"));
|
|
19107
|
-
print(style.hint(" HOLOCRON_ORG_TOKEN — a fine-grained PAT with resource owner set to the org:"));
|
|
18059
|
+
print(ui_exports.style.hint(" Org-scoped operations (teams, organization Actions variables) require"));
|
|
18060
|
+
print(ui_exports.style.hint(" HOLOCRON_ORG_TOKEN — a fine-grained PAT with resource owner set to the org:"));
|
|
19108
18061
|
print("");
|
|
19109
|
-
print(style.hint(" · Administration — read and write (repository permission)"));
|
|
19110
|
-
print(style.hint(" · Members — read (organization permission)"));
|
|
19111
|
-
print(style.hint(" · Variables — read and write (organization permission)"));
|
|
19112
|
-
print(style.hint(" · Metadata — read (repository permission, auto-included)"));
|
|
18062
|
+
print(ui_exports.style.hint(" · Administration — read and write (repository permission)"));
|
|
18063
|
+
print(ui_exports.style.hint(" · Members — read (organization permission)"));
|
|
18064
|
+
print(ui_exports.style.hint(" · Variables — read and write (organization permission)"));
|
|
18065
|
+
print(ui_exports.style.hint(" · Metadata — read (repository permission, auto-included)"));
|
|
19113
18066
|
print("");
|
|
19114
18067
|
if (steps.some((s) => s.reason === "permissions" && /GitHub Pages/.test(s.step))) {
|
|
19115
18068
|
print("");
|
|
19116
|
-
print(style.hint(" GitHub Pages uses HOLOCRON_DEPLOY_TOKEN (keyring key github.deploy):"));
|
|
18069
|
+
print(ui_exports.style.hint(" GitHub Pages uses HOLOCRON_DEPLOY_TOKEN (keyring key github.deploy):"));
|
|
19117
18070
|
print("");
|
|
19118
|
-
print(style.hint(" · Pages — read and write"));
|
|
19119
|
-
print(style.hint(" · Administration — read and write"));
|
|
19120
|
-
print(style.hint(" · Metadata — read (added automatically)"));
|
|
18071
|
+
print(ui_exports.style.hint(" · Pages — read and write"));
|
|
18072
|
+
print(ui_exports.style.hint(" · Administration — read and write"));
|
|
18073
|
+
print(ui_exports.style.hint(" · Metadata — read (added automatically)"));
|
|
19121
18074
|
}
|
|
19122
18075
|
print("");
|
|
19123
|
-
print(style.hint(" Create tokens at: https://github.com/settings/personal-access-tokens/new"));
|
|
19124
|
-
print(style.hint(" Store them: HOLOCRON_ADMIN_TOKEN / HOLOCRON_ORG_TOKEN / HOLOCRON_DEPLOY_TOKEN env vars,"));
|
|
19125
|
-
print(style.hint(" or keyring keys github.admin / github.org / github.deploy"));
|
|
19126
|
-
print(style.hint(" Then re-run: holocron repo setup"));
|
|
19127
|
-
print(style.hint(" (--token <pat> overrides every token, the org one included; use it only when one"));
|
|
19128
|
-
print(style.hint(" token covers everything.)"));
|
|
18076
|
+
print(ui_exports.style.hint(" Create tokens at: https://github.com/settings/personal-access-tokens/new"));
|
|
18077
|
+
print(ui_exports.style.hint(" Store them: HOLOCRON_ADMIN_TOKEN / HOLOCRON_ORG_TOKEN / HOLOCRON_DEPLOY_TOKEN env vars,"));
|
|
18078
|
+
print(ui_exports.style.hint(" or keyring keys github.admin / github.org / github.deploy"));
|
|
18079
|
+
print(ui_exports.style.hint(" Then re-run: holocron repo setup"));
|
|
18080
|
+
print(ui_exports.style.hint(" (--token <pat> overrides every token, the org one included; use it only when one"));
|
|
18081
|
+
print(ui_exports.style.hint(" token covers everything.)"));
|
|
19129
18082
|
}
|
|
19130
18083
|
return {
|
|
19131
18084
|
steps,
|
|
@@ -19171,7 +18124,7 @@ const setupCommand = {
|
|
|
19171
18124
|
describe: "Apply infra setup actions across every configured capability",
|
|
19172
18125
|
builder: setupArgs,
|
|
19173
18126
|
handler: async (argv) => {
|
|
19174
|
-
const tokens = tokenContext(argv.token);
|
|
18127
|
+
const tokens = tokenContext$1(argv.token);
|
|
19175
18128
|
if (!tokens) return;
|
|
19176
18129
|
const loaded = await loadConfig(argv.cwd);
|
|
19177
18130
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -19375,7 +18328,7 @@ const SKIP_LABEL = {
|
|
|
19375
18328
|
/** A row's label: the name, where it lives, when it was last committed to (local only) and its PR. */
|
|
19376
18329
|
function rowLabel(entry) {
|
|
19377
18330
|
const detail = [entry.date?.slice(0, 10), entry.pr === void 0 ? void 0 : `PR #${entry.pr}`].filter(Boolean);
|
|
19378
|
-
return `${entry.name} [${entry.locations.join(", ")}]${detail.length > 0 ? ` ${style.dim(detail.join(" "))}` : ""}`;
|
|
18331
|
+
return `${entry.name} [${entry.locations.join(", ")}]${detail.length > 0 ? ` ${ui_exports.style.dim(detail.join(" "))}` : ""}`;
|
|
19379
18332
|
}
|
|
19380
18333
|
/**
|
|
19381
18334
|
* Classifies the branches against the provider's pull requests, shows them grouped, and deletes the ones
|
|
@@ -19436,17 +18389,17 @@ async function runCleanupBranches(input) {
|
|
|
19436
18389
|
for (const group of GROUPS) {
|
|
19437
18390
|
const rows = entries.filter((e) => e.group === group);
|
|
19438
18391
|
const line = `${rows.length} ${GROUP_LABEL[group]}`;
|
|
19439
|
-
print(SAFE.includes(group) ? style.success(line) : style.warn(line));
|
|
18392
|
+
print(SAFE.includes(group) ? ui_exports.style.success(line) : ui_exports.style.warn(line));
|
|
19440
18393
|
for (const row of rows) print(` ${rowLabel(row)}`);
|
|
19441
18394
|
}
|
|
19442
18395
|
if (classification.skipped.length > 0) {
|
|
19443
|
-
print(style.dim(`${classification.skipped.length} skipped`));
|
|
19444
|
-
for (const { ref, reason } of classification.skipped) print(style.dim(` ${ref.name} [${ref.where}] ${SKIP_LABEL[reason]}`));
|
|
18396
|
+
print(ui_exports.style.dim(`${classification.skipped.length} skipped`));
|
|
18397
|
+
for (const { ref, reason } of classification.skipped) print(ui_exports.style.dim(` ${ref.name} [${ref.where}] ${SKIP_LABEL[reason]}`));
|
|
19445
18398
|
}
|
|
19446
18399
|
print("");
|
|
19447
18400
|
const safe = entries.filter((e) => SAFE.includes(e.group));
|
|
19448
18401
|
if (input.context.dryRun === true) {
|
|
19449
|
-
print(style.dim(`Dry run: ${safe.length} branches are proven merged. Nothing was deleted.`));
|
|
18402
|
+
print(ui_exports.style.dim(`Dry run: ${safe.length} branches are proven merged. Nothing was deleted.`));
|
|
19450
18403
|
logger.info({
|
|
19451
18404
|
proven: safe.length,
|
|
19452
18405
|
deleted: 0
|
|
@@ -19456,7 +18409,7 @@ async function runCleanupBranches(input) {
|
|
|
19456
18409
|
if (entries.length === 0) return report;
|
|
19457
18410
|
let chosen = safe;
|
|
19458
18411
|
if (input.yes !== true) {
|
|
19459
|
-
if (!process.stdin.isTTY) throw new NonInteractiveError("`repo cleanup branches` asks which branches to delete — run it in a terminal, or pass --yes to delete the proven-merged ones, or --dry-run to only list them");
|
|
18412
|
+
if (!process.stdin.isTTY) throw new ui_exports.NonInteractiveError("`repo cleanup branches` asks which branches to delete — run it in a terminal, or pass --yes to delete the proven-merged ones, or --dry-run to only list them");
|
|
19460
18413
|
if (!await confirm({
|
|
19461
18414
|
message: "Choose branches to delete?",
|
|
19462
18415
|
default: true
|
|
@@ -19489,7 +18442,7 @@ async function runCleanupBranches(input) {
|
|
|
19489
18442
|
message: errorMessage(err)
|
|
19490
18443
|
});
|
|
19491
18444
|
}
|
|
19492
|
-
for (const { name, where, message } of report.failed) print(style.fail(`${name} [${where}]: ${message}`));
|
|
18445
|
+
for (const { name, where, message } of report.failed) print(ui_exports.style.fail(`${name} [${where}]: ${message}`));
|
|
19493
18446
|
print(`Deleted ${report.deleted.length} of ${report.deleted.length + report.failed.length} branches.`);
|
|
19494
18447
|
if (report.failed.length > 0) report.status = "fail";
|
|
19495
18448
|
logger.info({
|
|
@@ -19518,7 +18471,7 @@ const repoCleanupBranchesCommand = {
|
|
|
19518
18471
|
describe: "List the branches whose pull request is merged and delete the ones you pick (local, remote or both)",
|
|
19519
18472
|
builder: repoCleanupBranchesArgs,
|
|
19520
18473
|
handler: async (argv) => {
|
|
19521
|
-
const tokens = tokenContext(argv.token);
|
|
18474
|
+
const tokens = tokenContext$1(argv.token);
|
|
19522
18475
|
if (!tokens) return;
|
|
19523
18476
|
const loaded = await loadConfig(argv.cwd);
|
|
19524
18477
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -19540,7 +18493,7 @@ const repoCleanupBranchesCommand = {
|
|
|
19540
18493
|
const repoCleanupCommand = {
|
|
19541
18494
|
command: "cleanup",
|
|
19542
18495
|
describe: "Clean up what a repo accumulates (merged branches)",
|
|
19543
|
-
builder: (y) => y.command(repoCleanupBranchesCommand).command(groupMenu("repo cleanup")),
|
|
18496
|
+
builder: (y) => y.command(repoCleanupBranchesCommand).command(groupMenu$1("repo cleanup")),
|
|
19544
18497
|
handler: () => {}
|
|
19545
18498
|
};
|
|
19546
18499
|
// src/commands/sync-readme/generate-readme.ts
|
|
@@ -19738,8 +18691,8 @@ async function runSyncReadme(input) {
|
|
|
19738
18691
|
const logger = input.logger ?? getLogger();
|
|
19739
18692
|
const { repoRoot, dryRun = false } = context;
|
|
19740
18693
|
const namespaces = loaded.resolved.env?.namespaces ?? [];
|
|
19741
|
-
print(style.header(`Syncing README installation block${dryRun ? " (dry-run)" : ""}…`));
|
|
19742
|
-
if (namespaces.length > 0) print(style.hint(` namespaces: ${namespaces.join(", ")}`));
|
|
18694
|
+
print(ui_exports.style.header(`Syncing README installation block${dryRun ? " (dry-run)" : ""}…`));
|
|
18695
|
+
if (namespaces.length > 0) print(ui_exports.style.hint(` namespaces: ${namespaces.join(", ")}`));
|
|
19743
18696
|
let pkg;
|
|
19744
18697
|
try {
|
|
19745
18698
|
const raw = await readFileFn(join(repoRoot, "package.json"), "utf8");
|
|
@@ -19771,7 +18724,7 @@ async function runSyncReadme(input) {
|
|
|
19771
18724
|
};
|
|
19772
18725
|
const text = await updateReadme(repoRoot, generateInstallBlock(pkg, homepage), markerSections, dryRun, readFileFn, writeFileFn);
|
|
19773
18726
|
if (text === null) {
|
|
19774
|
-
print(style.warn("README.md not found or has no writable location for installation block"));
|
|
18727
|
+
print(ui_exports.style.warn("README.md not found or has no writable location for installation block"));
|
|
19775
18728
|
logger.warn({
|
|
19776
18729
|
repoRoot,
|
|
19777
18730
|
reason: "README.md not found / no marker block"
|
|
@@ -19783,9 +18736,9 @@ async function runSyncReadme(input) {
|
|
|
19783
18736
|
};
|
|
19784
18737
|
}
|
|
19785
18738
|
if (description) await updateIndexMdxDescription(repoRoot, description, dryRun, readFileFn, writeFileFn);
|
|
19786
|
-
print(dryRun ? style.hint(" would update README.md") : style.success(" updated README.md"));
|
|
18739
|
+
print(dryRun ? ui_exports.style.hint(" would update README.md") : ui_exports.style.success(" updated README.md"));
|
|
19787
18740
|
const problems = readmeScriptProblems(text, scripts);
|
|
19788
|
-
for (const problem of problems) print(style.fail(` ${problem}`));
|
|
18741
|
+
for (const problem of problems) print(ui_exports.style.fail(` ${problem}`));
|
|
19789
18742
|
const status = dryRun ? "dry-run" : "ok";
|
|
19790
18743
|
logger.info({
|
|
19791
18744
|
repoRoot,
|
|
@@ -20615,7 +19568,7 @@ const repoSyncCommand = {
|
|
|
20615
19568
|
describe: "Sync state from config to the provider and local files (labels, properties, teams, topics, keywords, description, homepage, readme, workflows, scripts, wiki)",
|
|
20616
19569
|
builder: (y) => repoSyncArgs(y).command(syncReadmeCommand),
|
|
20617
19570
|
handler: async (argv) => {
|
|
20618
|
-
const tokens = tokenContext(argv.token);
|
|
19571
|
+
const tokens = tokenContext$1(argv.token);
|
|
20619
19572
|
if (!tokens) return;
|
|
20620
19573
|
const loaded = await loadConfig(argv.cwd);
|
|
20621
19574
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -20651,12 +19604,12 @@ const repoSyncCommand = {
|
|
|
20651
19604
|
*
|
|
20652
19605
|
* After running, `pnpm install && holocron run ci`.
|
|
20653
19606
|
*/
|
|
20654
|
-
const FETCH_TIMEOUT_MS
|
|
19607
|
+
const FETCH_TIMEOUT_MS = 4e3;
|
|
20655
19608
|
/** Resolve a package's `latest` dist-tag from the npm registry. */
|
|
20656
19609
|
const fetchLatestFromNpm = async (pkg) => {
|
|
20657
19610
|
try {
|
|
20658
19611
|
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(pkg)}`, {
|
|
20659
|
-
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS
|
|
19612
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
|
|
20660
19613
|
headers: { accept: "application/vnd.npm.install-v1+json" }
|
|
20661
19614
|
});
|
|
20662
19615
|
if (!res.ok) return null;
|
|
@@ -21043,7 +19996,7 @@ const upgradeNodeCommand = {
|
|
|
21043
19996
|
describe: "Scan the repo and update every Node.js version pin to a new major",
|
|
21044
19997
|
builder: upgradeNodeArgs,
|
|
21045
19998
|
handler: async (argv) => {
|
|
21046
|
-
const [to] = await promptForPositionals(getEntry("repo upgrade node"), argv);
|
|
19999
|
+
const [to] = await (0, ui_exports.promptForPositionals)(getEntry("repo upgrade node"), argv);
|
|
21047
20000
|
let extra = [];
|
|
21048
20001
|
try {
|
|
21049
20002
|
const raw = readFileSync(join(argv.cwd, "holocron.config.json"), "utf8");
|
|
@@ -21067,14 +20020,14 @@ const upgradeNodeCommand = {
|
|
|
21067
20020
|
const repoUpgradeCommand = {
|
|
21068
20021
|
command: "upgrade",
|
|
21069
20022
|
describe: "Upgrade toolchain version pins across the repo",
|
|
21070
|
-
builder: (y) => y.command(upgradeNodeCommand).command(upgradeDepsCommand).command(groupMenu("repo upgrade")),
|
|
20023
|
+
builder: (y) => y.command(upgradeNodeCommand).command(upgradeDepsCommand).command(groupMenu$1("repo upgrade")),
|
|
21071
20024
|
handler: () => {}
|
|
21072
20025
|
};
|
|
21073
20026
|
// src/commands/repo/repo.command.ts
|
|
21074
20027
|
const repoCommand = {
|
|
21075
20028
|
command: "repo",
|
|
21076
20029
|
describe: "Set up, sync, upgrade and clean up the current repo",
|
|
21077
|
-
builder: (y) => y.command(setupCommand).command(repoSyncCommand).command(repoUpgradeCommand).command(repoCleanupCommand).command(groupMenu("repo")),
|
|
20030
|
+
builder: (y) => y.command(setupCommand).command(repoSyncCommand).command(repoUpgradeCommand).command(repoCleanupCommand).command(groupMenu$1("repo")),
|
|
21078
20031
|
handler: () => {}
|
|
21079
20032
|
};
|
|
21080
20033
|
// src/commands/run/run.args.ts
|
|
@@ -21285,9 +20238,9 @@ const secretSetCommand = {
|
|
|
21285
20238
|
describe: "Set a single secret via the configured `secrets` capability",
|
|
21286
20239
|
builder: secretSetArgs,
|
|
21287
20240
|
handler: async (argv) => {
|
|
21288
|
-
const tokens = tokenContext(argv.token);
|
|
20241
|
+
const tokens = tokenContext$1(argv.token);
|
|
21289
20242
|
if (!tokens) return;
|
|
21290
|
-
const [name] = await promptForPositionals(getEntry("secrets set"), argv);
|
|
20243
|
+
const [name] = await (0, ui_exports.promptForPositionals)(getEntry("secrets set"), argv);
|
|
21291
20244
|
const scopeArg = argv.scope;
|
|
21292
20245
|
const scope = parseScope(scopeArg);
|
|
21293
20246
|
const loaded = await loadConfig(argv.cwd);
|
|
@@ -21433,7 +20386,7 @@ const secretsListCommand = {
|
|
|
21433
20386
|
describe: "List the names of the secrets at each scope (never the values)",
|
|
21434
20387
|
builder: secretsListArgs,
|
|
21435
20388
|
handler: async (argv) => {
|
|
21436
|
-
const tokens = tokenContext(argv.token);
|
|
20389
|
+
const tokens = tokenContext$1(argv.token);
|
|
21437
20390
|
if (!tokens) return;
|
|
21438
20391
|
const loaded = await loadConfig(argv.cwd);
|
|
21439
20392
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -21521,7 +20474,7 @@ async function runSecretsSync(input) {
|
|
|
21521
20474
|
const print = input.print ?? ((line) => console.log(line));
|
|
21522
20475
|
const logger = input.logger ?? getLogger();
|
|
21523
20476
|
const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
|
|
21524
|
-
await withSpinner("Loading plugins…", () => loader.load());
|
|
20477
|
+
await (0, ui_exports.withSpinner)("Loading plugins…", () => loader.load());
|
|
21525
20478
|
assertPluginsResolvable(loader, "secrets sync");
|
|
21526
20479
|
logger.info({
|
|
21527
20480
|
environment: input.environmentId,
|
|
@@ -21529,17 +20482,17 @@ async function runSecretsSync(input) {
|
|
|
21529
20482
|
}, "secrets sync: start");
|
|
21530
20483
|
const dryRun = input.context.dryRun ?? false;
|
|
21531
20484
|
const targets = input.targets ?? ["production", "preview"];
|
|
21532
|
-
print(style.header(`Holocron secrets sync — environment ${input.environmentId}${dryRun ? " (dry-run)" : ""}`));
|
|
21533
|
-
print(style.dim(` vault: ${vaultProviderName(loader)}`));
|
|
20485
|
+
print(ui_exports.style.header(`Holocron secrets sync — environment ${input.environmentId}${dryRun ? " (dry-run)" : ""}`));
|
|
20486
|
+
print(ui_exports.style.dim(` vault: ${vaultProviderName(loader)}`));
|
|
21534
20487
|
print("");
|
|
21535
20488
|
const vault = loader.get("vault");
|
|
21536
20489
|
if (!vault.readEnvironment) throw new Error(`vault provider (${vault.providerName}) does not implement readEnvironment — sync needs bulk env reads`);
|
|
21537
20490
|
let envVars;
|
|
21538
20491
|
try {
|
|
21539
|
-
envVars = await withSpinner(`Reading vault environment ${input.environmentId}…`, () => vault.readEnvironment(input.environmentId));
|
|
20492
|
+
envVars = await (0, ui_exports.withSpinner)(`Reading vault environment ${input.environmentId}…`, () => vault.readEnvironment(input.environmentId));
|
|
21540
20493
|
} catch (err) {
|
|
21541
20494
|
const message = describeProviderError(err);
|
|
21542
|
-
print(` ${style.fail(`could not read vault environment ${input.environmentId}: ${message}`)}`);
|
|
20495
|
+
print(` ${ui_exports.style.fail(`could not read vault environment ${input.environmentId}: ${message}`)}`);
|
|
21543
20496
|
logger.warn({
|
|
21544
20497
|
environment: input.environmentId,
|
|
21545
20498
|
reason: logReason(err)
|
|
@@ -21553,7 +20506,7 @@ async function runSecretsSync(input) {
|
|
|
21553
20506
|
}], logger, print, dryRun);
|
|
21554
20507
|
}
|
|
21555
20508
|
const keys = Object.keys(envVars).sort();
|
|
21556
|
-
print(style.step(`read ${keys.length} keys from vault`));
|
|
20509
|
+
print(ui_exports.style.step(`read ${keys.length} keys from vault`));
|
|
21557
20510
|
print("");
|
|
21558
20511
|
const rows = [];
|
|
21559
20512
|
if (loader.has("secrets")) {
|
|
@@ -21563,7 +20516,7 @@ async function runSecretsSync(input) {
|
|
|
21563
20516
|
...input.githubSecretKeys ? { keys: input.githubSecretKeys } : {}
|
|
21564
20517
|
}];
|
|
21565
20518
|
for (const route of routes) {
|
|
21566
|
-
print(style.step(routes.length > 1 ? `secrets (${scopeLabel(route.scope)})` : "secrets"));
|
|
20519
|
+
print(ui_exports.style.step(routes.length > 1 ? `secrets (${scopeLabel(route.scope)})` : "secrets"));
|
|
21567
20520
|
for (const key of route.keys ?? keys) {
|
|
21568
20521
|
rows.push(await pushRow(`secrets:${secrets.providerName}`, scopeLabel(route.scope), key, envVars, dryRun, async (value) => {
|
|
21569
20522
|
await secrets.setSecret(route.scope, key, value);
|
|
@@ -21575,7 +20528,7 @@ async function runSecretsSync(input) {
|
|
|
21575
20528
|
if (loader.has("deployment")) {
|
|
21576
20529
|
const deploy = loader.get("deployment");
|
|
21577
20530
|
if (!input.projectId) {
|
|
21578
|
-
print(style.step("deployment"));
|
|
20531
|
+
print(ui_exports.style.step("deployment"));
|
|
21579
20532
|
const row = {
|
|
21580
20533
|
destination: `deployment:${deploy.providerName}`,
|
|
21581
20534
|
scope: "no projectId",
|
|
@@ -21586,7 +20539,7 @@ async function runSecretsSync(input) {
|
|
|
21586
20539
|
rows.push(row);
|
|
21587
20540
|
print(formatRow(row));
|
|
21588
20541
|
} else for (const target of targets) {
|
|
21589
|
-
print(style.step(`deployment (target=${target})`));
|
|
20542
|
+
print(ui_exports.style.step(`deployment (target=${target})`));
|
|
21590
20543
|
for (const key of keys) {
|
|
21591
20544
|
rows.push(await pushRow(`deployment:${deploy.providerName}`, `target=${target}`, key, envVars, dryRun, async (value) => {
|
|
21592
20545
|
await deploy.setEnvVar(input.projectId, target, key, value);
|
|
@@ -21597,7 +20550,7 @@ async function runSecretsSync(input) {
|
|
|
21597
20550
|
}
|
|
21598
20551
|
if (input.workerScript) {
|
|
21599
20552
|
const script = input.workerScript;
|
|
21600
|
-
print(style.step(`workers (script=${script})`));
|
|
20553
|
+
print(ui_exports.style.step(`workers (script=${script})`));
|
|
21601
20554
|
const workers = loader.has("workers") ? loader.get("workers") : void 0;
|
|
21602
20555
|
if (!workers?.setSecret) {
|
|
21603
20556
|
const row = {
|
|
@@ -21645,7 +20598,7 @@ function summarise(rows, logger, print, dryRun) {
|
|
|
21645
20598
|
}, "secrets sync: done");
|
|
21646
20599
|
print("");
|
|
21647
20600
|
const summaryLine = `${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped${dryRun ? `, ${summary.dryRun} would-do` : ""}`;
|
|
21648
|
-
print(summary.fail > 0 ? style.fail(summaryLine) : style.success(summaryLine));
|
|
20601
|
+
print(summary.fail > 0 ? ui_exports.style.fail(summaryLine) : ui_exports.style.success(summaryLine));
|
|
21649
20602
|
return {
|
|
21650
20603
|
rows,
|
|
21651
20604
|
summary
|
|
@@ -21700,12 +20653,12 @@ async function runRow(destination, scope, key, dryRun, body) {
|
|
|
21700
20653
|
}
|
|
21701
20654
|
}
|
|
21702
20655
|
function formatRow(row) {
|
|
21703
|
-
const detail = row.message ? style.dim(` (${row.message})`) : "";
|
|
20656
|
+
const detail = row.message ? ui_exports.style.dim(` (${row.message})`) : "";
|
|
21704
20657
|
const label = `${row.key}${detail}`;
|
|
21705
|
-
if (row.status === "ok") return ` ${style.success(label)}`;
|
|
21706
|
-
if (row.status === "fail") return ` ${style.fail(label)}`;
|
|
21707
|
-
if (row.status === "dry-run") return ` ${style.dim(`… ${label}`)}`;
|
|
21708
|
-
return ` ${style.dim(`· ${label}`)}`;
|
|
20658
|
+
if (row.status === "ok") return ` ${ui_exports.style.success(label)}`;
|
|
20659
|
+
if (row.status === "fail") return ` ${ui_exports.style.fail(label)}`;
|
|
20660
|
+
if (row.status === "dry-run") return ` ${ui_exports.style.dim(`… ${label}`)}`;
|
|
20661
|
+
return ` ${ui_exports.style.dim(`· ${label}`)}`;
|
|
21709
20662
|
}
|
|
21710
20663
|
function scopeLabel(scope) {
|
|
21711
20664
|
if (scope.kind === "repo") return "scope=repo";
|
|
@@ -21744,10 +20697,10 @@ const secretsSyncCommand = {
|
|
|
21744
20697
|
describe: "Read a vault environment + fan KEY=VALUEs out to secrets + deployment env vars",
|
|
21745
20698
|
builder: secretsSyncArgs,
|
|
21746
20699
|
handler: async (argv) => {
|
|
21747
|
-
const tokens = tokenContext(argv.token);
|
|
20700
|
+
const tokens = tokenContext$1(argv.token);
|
|
21748
20701
|
if (!tokens) return;
|
|
21749
20702
|
const githubSecretScope = parseScope(argv.githubSecretScope);
|
|
21750
|
-
const [environmentId] = await promptForPositionals(getEntry("secrets sync"), argv);
|
|
20703
|
+
const [environmentId] = await (0, ui_exports.promptForPositionals)(getEntry("secrets sync"), argv);
|
|
21751
20704
|
const loaded = await loadConfig(argv.cwd);
|
|
21752
20705
|
applyResolvedConfig(argv, loaded.resolved);
|
|
21753
20706
|
const routes = argv.githubSecret?.length ? [] : secretRoutes(loaded.resolved.repo?.secrets?.sync, environmentId);
|
|
@@ -21773,7 +20726,7 @@ const secretsSyncCommand = {
|
|
|
21773
20726
|
const secretsCommand = {
|
|
21774
20727
|
command: "secrets",
|
|
21775
20728
|
describe: "List and set secrets, and sync vault environments",
|
|
21776
|
-
builder: (y) => y.command(secretSetCommand).command(secretsListCommand).command(secretsSyncCommand).command(groupMenu("secrets")),
|
|
20729
|
+
builder: (y) => y.command(secretSetCommand).command(secretsListCommand).command(secretsSyncCommand).command(groupMenu$1("secrets")),
|
|
21777
20730
|
handler: () => {}
|
|
21778
20731
|
};
|
|
21779
20732
|
// src/commands/skills/skills.args.ts
|
|
@@ -21930,7 +20883,7 @@ const skillsUpdate = {
|
|
|
21930
20883
|
const skillsCommand = {
|
|
21931
20884
|
command: "skills",
|
|
21932
20885
|
describe: "Manage agent skills from the @theholocron/skills registry",
|
|
21933
|
-
builder: (y) => y.command(skillsInstall).command(skillsRemove).command(skillsUpdate).command(groupMenu("skills")),
|
|
20886
|
+
builder: (y) => y.command(skillsInstall).command(skillsRemove).command(skillsUpdate).command(groupMenu$1("skills")),
|
|
21934
20887
|
handler: () => {}
|
|
21935
20888
|
};
|
|
21936
20889
|
// src/commands/specs-sync/forum-channel.ts
|
|
@@ -22240,9 +21193,9 @@ async function runSpecsSync(input) {
|
|
|
22240
21193
|
assertPluginsResolvable(loader, "specs sync");
|
|
22241
21194
|
const dryRun = input.context.dryRun ?? false;
|
|
22242
21195
|
const refuse = (message, reason = message) => {
|
|
22243
|
-
print(` ${style.fail(message)}`);
|
|
21196
|
+
print(` ${ui_exports.style.fail(message)}`);
|
|
22244
21197
|
print("");
|
|
22245
|
-
print(style.header("0 ok, 1 fail, 0 skipped"));
|
|
21198
|
+
print(ui_exports.style.header("0 ok, 1 fail, 0 skipped"));
|
|
22246
21199
|
logger.warn({ reason }, "specs sync");
|
|
22247
21200
|
return {
|
|
22248
21201
|
status: "fail",
|
|
@@ -22322,7 +21275,7 @@ async function runSpecsSync(input) {
|
|
|
22322
21275
|
let renamed = 0;
|
|
22323
21276
|
let linked = 0;
|
|
22324
21277
|
let rateLimited;
|
|
22325
|
-
print(`\n${style.header(`ADRs and specs → #${forum.channel}`)}`);
|
|
21278
|
+
print(`\n${ui_exports.style.header(`ADRs and specs → #${forum.channel}`)}`);
|
|
22326
21279
|
for (const doc of documents) {
|
|
22327
21280
|
let outcome;
|
|
22328
21281
|
try {
|
|
@@ -22352,13 +21305,13 @@ async function runSpecsSync(input) {
|
|
|
22352
21305
|
if (outcome.titleRenamed) renamed++;
|
|
22353
21306
|
if (outcome.idLineRewritten) linked++;
|
|
22354
21307
|
if (outcome.problem) {
|
|
22355
|
-
print(` ${style.fail(`${outcome.path}: ${outcome.problem}`)}`);
|
|
21308
|
+
print(` ${ui_exports.style.fail(`${outcome.path}: ${outcome.problem}`)}`);
|
|
22356
21309
|
failed++;
|
|
22357
21310
|
} else if (outcome.did.length === 0) {
|
|
22358
|
-
print(` ${style.skip(`${outcome.path}: in step`)}`);
|
|
21311
|
+
print(` ${ui_exports.style.skip(`${outcome.path}: in step`)}`);
|
|
22359
21312
|
skipped++;
|
|
22360
21313
|
} else {
|
|
22361
|
-
print(` ${(dryRun ? style.skip : style.success)(`${outcome.path}: ${outcome.did.join("; ")}`)}`);
|
|
21314
|
+
print(` ${(dryRun ? ui_exports.style.skip : ui_exports.style.success)(`${outcome.path}: ${outcome.did.join("; ")}`)}`);
|
|
22362
21315
|
if (dryRun) skipped++;
|
|
22363
21316
|
else ok++;
|
|
22364
21317
|
if (!dryRun && outcome.text !== doc.text) input.io.write(doc.path, outcome.text);
|
|
@@ -22366,15 +21319,15 @@ async function runSpecsSync(input) {
|
|
|
22366
21319
|
}
|
|
22367
21320
|
if (rateLimited) {
|
|
22368
21321
|
const after = rateLimited.retryAfter > 0 ? `; it asks for ${rateLimited.retryAfter} seconds` : "";
|
|
22369
|
-
print(` ${style.skip(`stopped: the provider is rate limiting${after}. ${rateLimited.left} document(s) are left for the next run`)}`);
|
|
21322
|
+
print(` ${ui_exports.style.skip(`stopped: the provider is rate limiting${after}. ${rateLimited.left} document(s) are left for the next run`)}`);
|
|
22370
21323
|
skipped += rateLimited.left;
|
|
22371
21324
|
}
|
|
22372
|
-
if (refreshOrigin) print(style.header(`${rewritten} PR line(s) ${dryRun ? "would be rewritten" : "rewritten"}`));
|
|
22373
|
-
if (refreshTitles) print(style.header(`${renamed} title(s) ${dryRun ? "would be renamed" : "renamed"}`));
|
|
22374
|
-
if (input.refresh || linking) print(style.header(`${linked} id line(s) ${dryRun ? "would be rewritten" : "rewritten"}`));
|
|
21325
|
+
if (refreshOrigin) print(ui_exports.style.header(`${rewritten} PR line(s) ${dryRun ? "would be rewritten" : "rewritten"}`));
|
|
21326
|
+
if (refreshTitles) print(ui_exports.style.header(`${renamed} title(s) ${dryRun ? "would be renamed" : "renamed"}`));
|
|
21327
|
+
if (input.refresh || linking) print(ui_exports.style.header(`${linked} id line(s) ${dryRun ? "would be rewritten" : "rewritten"}`));
|
|
22375
21328
|
const status = failed > 0 ? "fail" : dryRun ? "dry-run" : "ok";
|
|
22376
21329
|
print("");
|
|
22377
|
-
print(style.header(`${ok} ok, ${failed} fail, ${skipped} skipped`));
|
|
21330
|
+
print(ui_exports.style.header(`${ok} ok, ${failed} fail, ${skipped} skipped`));
|
|
22378
21331
|
logger.info({
|
|
22379
21332
|
provider: notifications.providerName,
|
|
22380
21333
|
channel: forum.channel,
|
|
@@ -22432,7 +21385,7 @@ const specsSyncCommand = {
|
|
|
22432
21385
|
describe: "Keep each ADR and spec in step with a post in a forum channel",
|
|
22433
21386
|
builder: specsSyncArgs,
|
|
22434
21387
|
handler: async (argv) => {
|
|
22435
|
-
const tokens = tokenContext(argv.token);
|
|
21388
|
+
const tokens = tokenContext$1(argv.token);
|
|
22436
21389
|
if (!tokens) return;
|
|
22437
21390
|
const loaded = await loadConfig(argv.cwd);
|
|
22438
21391
|
applyResolvedConfig(argv, loaded.resolved);
|
|
@@ -22461,7 +21414,7 @@ const specsSyncCommand = {
|
|
|
22461
21414
|
const specsCommand = {
|
|
22462
21415
|
command: "specs",
|
|
22463
21416
|
describe: "Keep the repo's ADRs and specs in step with their discussion",
|
|
22464
|
-
builder: (y) => y.command(specsSyncCommand).command(groupMenu("specs")),
|
|
21417
|
+
builder: (y) => y.command(specsSyncCommand).command(groupMenu$1("specs")),
|
|
22465
21418
|
handler: () => {}
|
|
22466
21419
|
};
|
|
22467
21420
|
// src/commands/sync-github/sync-github.ts
|
|
@@ -22769,7 +21722,7 @@ const syncGithubCommand = {
|
|
|
22769
21722
|
builder: syncGithubArgs,
|
|
22770
21723
|
handler: async (argv) => {
|
|
22771
21724
|
const outputDir = argv["output-dir"];
|
|
22772
|
-
const parsed = tokenContext(argv.token);
|
|
21725
|
+
const parsed = tokenContext$1(argv.token);
|
|
22773
21726
|
if (!parsed) return;
|
|
22774
21727
|
let token;
|
|
22775
21728
|
if (outputDir) token = "no-token-needed";
|
|
@@ -22795,156 +21748,54 @@ const syncGithubCommand = {
|
|
|
22795
21748
|
const syncCommand = {
|
|
22796
21749
|
command: "sync",
|
|
22797
21750
|
describe: "Sync generated files to other repos",
|
|
22798
|
-
builder: (y) => y.command(syncGithubCommand).command(groupMenu("sync")),
|
|
21751
|
+
builder: (y) => y.command(syncGithubCommand).command(groupMenu$1("sync")),
|
|
22799
21752
|
handler: () => {}
|
|
22800
21753
|
};
|
|
22801
21754
|
// src/commands/tunnel/tunnel.command.ts
|
|
22802
21755
|
const tunnelCommand = {
|
|
22803
21756
|
command: "tunnel <subcommand>",
|
|
22804
21757
|
describe: "Tunnels from a stable public hostname to this machine",
|
|
22805
|
-
builder: (y) => y.command(tunnelUpCommand).command(groupMenu("tunnel")),
|
|
21758
|
+
builder: (y) => y.command(tunnelUpCommand).command(groupMenu$1("tunnel")),
|
|
22806
21759
|
handler: () => {}
|
|
22807
21760
|
};
|
|
22808
21761
|
// src/update-notifier/update-notifier.ts
|
|
22809
21762
|
const PACKAGE_NAME = "@theholocron/cli";
|
|
22810
|
-
|
|
22811
|
-
|
|
22812
|
-
|
|
22813
|
-
|
|
22814
|
-
|
|
22815
|
-
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
|
|
22819
|
-
|
|
22820
|
-
|
|
22821
|
-
|
|
22822
|
-
return null;
|
|
22823
|
-
}
|
|
22824
|
-
}
|
|
22825
|
-
function writeCache(entry) {
|
|
22826
|
-
try {
|
|
22827
|
-
mkdirSync(getCacheDir(), { recursive: true });
|
|
22828
|
-
writeFileSync(getCachePath(), JSON.stringify(entry));
|
|
22829
|
-
} catch {}
|
|
22830
|
-
}
|
|
22831
|
-
async function fetchLatestVersion(channel) {
|
|
22832
|
-
try {
|
|
22833
|
-
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME)}`, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
22834
|
-
if (!res.ok) return null;
|
|
22835
|
-
const data = await res.json();
|
|
22836
|
-
return data["dist-tags"][channel] ?? data["dist-tags"]["latest"] ?? null;
|
|
22837
|
-
} catch {
|
|
22838
|
-
return null;
|
|
22839
|
-
}
|
|
22840
|
-
}
|
|
22841
|
-
function getChannel(version) {
|
|
22842
|
-
return /^[^-]+-([a-zA-Z]+)/.exec(version)?.[1] ?? "latest";
|
|
22843
|
-
}
|
|
22844
|
-
function isUpdateAvailable(current, latest) {
|
|
22845
|
-
const normalize = (v) => v.replace(/^v/, "");
|
|
22846
|
-
const c = normalize(current);
|
|
22847
|
-
const l = normalize(latest);
|
|
22848
|
-
if (c === l) return false;
|
|
22849
|
-
const splitPre = (v) => {
|
|
22850
|
-
const idx = v.indexOf("-");
|
|
22851
|
-
return idx === -1 ? [v, ""] : [v.slice(0, idx), v.slice(idx + 1)];
|
|
22852
|
-
};
|
|
22853
|
-
const [cRelease, cPre] = splitPre(c);
|
|
22854
|
-
const [lRelease, lPre] = splitPre(l);
|
|
22855
|
-
const parseRelease = (r) => r.split(".").map(Number);
|
|
22856
|
-
const cParts = parseRelease(cRelease);
|
|
22857
|
-
const lParts = parseRelease(lRelease);
|
|
22858
|
-
for (let i = 0; i < Math.max(cParts.length, lParts.length); i++) {
|
|
22859
|
-
const cv = cParts[i] ?? 0;
|
|
22860
|
-
const lv = lParts[i] ?? 0;
|
|
22861
|
-
if (lv > cv) return true;
|
|
22862
|
-
if (lv < cv) return false;
|
|
22863
|
-
}
|
|
22864
|
-
if (!lPre && cPre) return true;
|
|
22865
|
-
if (lPre && !cPre) return false;
|
|
22866
|
-
const cPreParts = cPre.split(".");
|
|
22867
|
-
const lPreParts = lPre.split(".");
|
|
22868
|
-
for (let i = 0; i < Math.max(cPreParts.length, lPreParts.length); i++) {
|
|
22869
|
-
const cv = cPreParts[i] ?? "";
|
|
22870
|
-
const lv = lPreParts[i] ?? "";
|
|
22871
|
-
const cvNum = Number(cv);
|
|
22872
|
-
const lvNum = Number(lv);
|
|
22873
|
-
if (!isNaN(cvNum) && !isNaN(lvNum)) {
|
|
22874
|
-
if (lvNum > cvNum) return true;
|
|
22875
|
-
if (lvNum < cvNum) return false;
|
|
22876
|
-
} else {
|
|
22877
|
-
if (lv > cv) return true;
|
|
22878
|
-
if (lv < cv) return false;
|
|
21763
|
+
/**
|
|
21764
|
+
* Looks for a newer `@theholocron/cli` and returns a function that prints the notice, or `null` when there is none. The
|
|
21765
|
+
* answer is kept in `HOLOCRON_CACHE_DIR`, `~/.cache/holocron` by default.
|
|
21766
|
+
*/
|
|
21767
|
+
function checkForUpdates$1(currentVersion) {
|
|
21768
|
+
return checkForUpdates({
|
|
21769
|
+
name: PACKAGE_NAME,
|
|
21770
|
+
currentVersion,
|
|
21771
|
+
cacheDir: env.get("HOLOCRON_CACHE_DIR") ?? join(homedir(), ".cache", "holocron"),
|
|
21772
|
+
env: {
|
|
21773
|
+
CI: env.get("CI"),
|
|
21774
|
+
NO_UPDATE_NOTIFIER: env.get("NO_UPDATE_NOTIFIER")
|
|
22879
21775
|
}
|
|
22880
|
-
}
|
|
22881
|
-
return false;
|
|
22882
|
-
}
|
|
22883
|
-
function formatNotice(current, latest) {
|
|
22884
|
-
const installCmd = `npm install -g ${PACKAGE_NAME}`;
|
|
22885
|
-
const raw1 = `Update available: ${current} → ${latest}`;
|
|
22886
|
-
const raw2 = `Run ${installCmd} to update`;
|
|
22887
|
-
const width = Math.max(raw1.length, raw2.length) + 4;
|
|
22888
|
-
const bar = chalk.yellow("─".repeat(width));
|
|
22889
|
-
const border = chalk.yellow("│");
|
|
22890
|
-
const pad = (raw, styled) => `${border} ${styled}${" ".repeat(width - 2 - raw.length)} ${border}`;
|
|
22891
|
-
return [
|
|
22892
|
-
"",
|
|
22893
|
-
chalk.yellow(`╭${bar}╮`),
|
|
22894
|
-
pad(raw1, `Update available: ${chalk.dim(current)} → ${chalk.green(latest)}`),
|
|
22895
|
-
pad(raw2, `Run ${chalk.cyan(installCmd)} to update`),
|
|
22896
|
-
chalk.yellow(`╰${bar}╯`),
|
|
22897
|
-
""
|
|
22898
|
-
].join("\n");
|
|
22899
|
-
}
|
|
22900
|
-
async function checkForUpdates(currentVersion) {
|
|
22901
|
-
if (env.get("CI") || env.get("NO_UPDATE_NOTIFIER")) return null;
|
|
22902
|
-
const channel = getChannel(currentVersion);
|
|
22903
|
-
const cache = readCache();
|
|
22904
|
-
const now = Date.now();
|
|
22905
|
-
let latestVersion = null;
|
|
22906
|
-
if (cache && now - cache.checkedAt < CACHE_TTL_MS) latestVersion = cache.latestVersion;
|
|
22907
|
-
else {
|
|
22908
|
-
latestVersion = await fetchLatestVersion(channel);
|
|
22909
|
-
if (latestVersion) writeCache({
|
|
22910
|
-
latestVersion,
|
|
22911
|
-
checkedAt: now
|
|
22912
|
-
});
|
|
22913
|
-
}
|
|
22914
|
-
if (!latestVersion || !isUpdateAvailable(currentVersion, latestVersion)) return null;
|
|
22915
|
-
return () => {
|
|
22916
|
-
process.stderr.write(formatNotice(currentVersion, latestVersion) + "\n");
|
|
22917
|
-
};
|
|
21776
|
+
});
|
|
22918
21777
|
}
|
|
22919
21778
|
// src/cli.ts
|
|
22920
21779
|
const { version: CLI_VERSION } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
22921
21780
|
/** Whether to print the correlation id at command end (`--debug` / `--verbose`). */
|
|
22922
21781
|
let printRunId = false;
|
|
22923
21782
|
init(CLI_VERSION);
|
|
22924
|
-
const updateCheckPromise = checkForUpdates(CLI_VERSION);
|
|
21783
|
+
const updateCheckPromise = checkForUpdates$1(CLI_VERSION);
|
|
22925
21784
|
let finishCommand = () => {};
|
|
22926
21785
|
/** Set by `.fail()` once it has printed an error, so the outer catch doesn't repeat it. */
|
|
22927
21786
|
let errorReported = false;
|
|
22928
21787
|
try {
|
|
22929
|
-
await yargs(hideBin(process.argv)).scriptName("").usage("holocron <command> [options]").version(CLI_VERSION).alias("version", "v").parserConfiguration({ "populate--": true })
|
|
22930
|
-
|
|
22931
|
-
|
|
22932
|
-
|
|
22933
|
-
}).option("skip-dry-run", {
|
|
21788
|
+
await addGlobalOptions(yargs(hideBin(process.argv)).scriptName("").usage("holocron <command> [options]").version(CLI_VERSION).alias("version", "v").parserConfiguration({ "populate--": true }), { describe: {
|
|
21789
|
+
dryRun: "Print what would be mutated without calling capability mutators. Commands branch on this; read-only commands ignore it.",
|
|
21790
|
+
token: "Vendor token override for plugins. Bare form: --token <value> (fallback for all plugins, single-plugin commands). Keyed form: --token vendor=value (targets a specific provider; repeat for each). Example: --token github=ghp_xxx --token vercel=v_yyy",
|
|
21791
|
+
cwd: "Directory to search for holocron.config.json"
|
|
21792
|
+
} }).option("skip-dry-run", {
|
|
22934
21793
|
type: "boolean",
|
|
22935
21794
|
default: false,
|
|
22936
21795
|
describe: "Interactive mode only: skip the automatic dry-run preview for a dry-run-capable command and run for real immediately."
|
|
22937
|
-
}).option("token", {
|
|
22938
|
-
type: "string",
|
|
22939
|
-
array: true,
|
|
22940
|
-
describe: "Vendor token override for plugins. Bare form: --token <value> (fallback for all plugins, single-plugin commands). Keyed form: --token vendor=value (targets a specific provider; repeat for each). Example: --token github=ghp_xxx --token vercel=v_yyy"
|
|
22941
21796
|
}).option("org", {
|
|
22942
21797
|
type: "string",
|
|
22943
21798
|
describe: "Active org name for namespaced keyring lookup. Overrides HOLOCRON_ORG env var and the `org` field in holocron.config.ts. Example: --org theholocron"
|
|
22944
|
-
}).option("cwd", {
|
|
22945
|
-
type: "string",
|
|
22946
|
-
default: process.cwd(),
|
|
22947
|
-
describe: "Directory to search for holocron.config.json"
|
|
22948
21799
|
}).option("verbose", {
|
|
22949
21800
|
type: "boolean",
|
|
22950
21801
|
default: false,
|