@theholocron/cli 5.0.0-alpha.341 → 5.0.0-alpha.343
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/cli.mjs +283 -774
- package/dist/cli.mjs.map +1 -1
- package/dist/{compose-BucaYv2k.mjs → config-system-Bq6510iF.mjs} +30 -8
- package/dist/{index-BfArEnkX.d.mts → config-system-uaeB3g1g.d.mts} +22 -3
- package/dist/index.d.mts +2 -22
- package/dist/index.mjs +1 -30
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +10 -10
package/dist/cli.mjs
CHANGED
|
@@ -1,131 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import {
|
|
4
|
-
import { homedir,
|
|
3
|
+
import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { homedir, tmpdir } from "node:os";
|
|
5
5
|
import path, { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { createEnvLookup, firstEnv, withEnvPrefix } from "@theholocron/env-utils/lookup";
|
|
7
|
+
import { ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient, onRetry } from "@theholocron/http-client";
|
|
7
8
|
import { addGlobalOptions, groupMenu, tokenContext } from "@theholocron/kyber/flags";
|
|
8
9
|
import { checkForUpdates } from "@theholocron/kyber/notifier";
|
|
9
|
-
import { NonInteractiveError,
|
|
10
|
-
import { LOG_LEVELS
|
|
10
|
+
import { NonInteractiveError, commandFailureMessage, createProgress, createRetryNotice, declaredVsActual, describeError, logReason, openPath, pad, printCheckRows, printCheckSummary, sanitizeDetail, setProgressListener, statusRow, stripControl, style, summariseChecks, viewJson, withProgress, withSpinner } from "@theholocron/kyber/ui";
|
|
11
|
+
import { LOG_LEVELS } from "@theholocron/observability/core";
|
|
11
12
|
import yargs from "yargs";
|
|
12
13
|
import { hideBin } from "yargs/helpers";
|
|
13
14
|
import { ConfigError, createConfigSystem, lastWins, mergeByKey, shallowMerge, union } from "@theholocron/kyber/config";
|
|
14
15
|
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";
|
|
15
|
-
import { ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient, onRetry } from "@theholocron/http-client";
|
|
16
16
|
import { loadTasksConfig } from "@theholocron/astromech/config";
|
|
17
17
|
import { readGitRemote, updateGitignore } from "@theholocron/git-utils";
|
|
18
18
|
import { bumpCatalogPins, discoverWorkspacePackages, parseCatalogs, readPackageJson, readPackageJsonSync, resolveWorkspaceGlobs } from "@theholocron/pkg-utils";
|
|
19
|
-
import {
|
|
19
|
+
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
20
|
+
import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
20
21
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
21
|
-
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, hasCredentials, isGitIgnored, readDotenvFile, setCredentials,
|
|
22
|
-
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
23
|
-
import { PostHogSink } from "@theholocron/observability/analytics";
|
|
24
|
-
import { SentrySink } from "@theholocron/observability/errors";
|
|
22
|
+
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
25
23
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
26
24
|
import { pathToFileURL } from "node:url";
|
|
27
|
-
import { DRY_RUN_NOOP_EXIT_CODE,
|
|
25
|
+
import { DRY_RUN_NOOP_EXIT_CODE, createMenu } from "@theholocron/kyber/menu";
|
|
28
26
|
import { promptForPositionals } from "@theholocron/kyber/prompts";
|
|
29
27
|
import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
30
28
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
31
29
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
32
30
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
33
|
-
import { serveHandler } from "@theholocron/dagobah";
|
|
31
|
+
import { serveHandler, superviseProcesses } from "@theholocron/dagobah";
|
|
34
32
|
import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
33
|
+
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
35
34
|
import { createServer } from "node:http";
|
|
36
35
|
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";
|
|
37
36
|
import { lintCommitMsgFile } from "@theholocron/astromech/lint";
|
|
38
37
|
import { createGitHubClient } from "@theholocron/github-client";
|
|
39
|
-
// src/config/compose/merge-sync/merge-sync.ts
|
|
40
|
-
/**
|
|
41
|
-
* Merge two lists of `repo.secrets.sync` entries. An entry is the same sync when its environment and scope match;
|
|
42
|
-
* the keys then add up, and an entry that names no keys (every key the vault holds) stays that way.
|
|
43
|
-
*/
|
|
44
|
-
function mergeSync(a, b) {
|
|
45
|
-
const merged = /* @__PURE__ */ new Map();
|
|
46
|
-
for (const entry of [...a ?? [], ...b ?? []]) {
|
|
47
|
-
const id = `${entry.environment}\0${entry.scope ?? "repo"}`;
|
|
48
|
-
const have = merged.get(id);
|
|
49
|
-
merged.set(id, have ? {
|
|
50
|
-
...have,
|
|
51
|
-
...have.keys && entry.keys ? { keys: [.../* @__PURE__ */ new Set([...have.keys, ...entry.keys])] } : { keys: void 0 }
|
|
52
|
-
} : { ...entry });
|
|
53
|
-
}
|
|
54
|
-
return [...merged.values()].map(({ keys, ...rest }) => keys ? {
|
|
55
|
-
...rest,
|
|
56
|
-
keys
|
|
57
|
-
} : rest);
|
|
58
|
-
}
|
|
59
|
-
// src/config/compose/merge-repo/merge-repo.ts
|
|
60
|
-
const names$1 = union();
|
|
61
|
-
const properties = shallowMerge();
|
|
62
|
-
const teamsByKey = mergeByKey((t) => typeof t === "string" ? t : t.slug);
|
|
63
|
-
/**
|
|
64
|
-
* Merge one capability's `repo` fragment onto what earlier ones gave. Scalars: last writer wins. `properties`: shallow
|
|
65
|
-
* merge. `variables`: merged per scope (`repo`, `org`). `secrets`: each name list is a union, and `sync` entries merge by
|
|
66
|
-
* environment and scope. `topics`: union. `teams`: merged by slug.
|
|
67
|
-
*/
|
|
68
|
-
function mergeRepo(prev, next) {
|
|
69
|
-
const { properties: nextProperties, topics, teams, variables, secrets, ...scalars } = next;
|
|
70
|
-
const repo = {
|
|
71
|
-
...prev,
|
|
72
|
-
...scalars
|
|
73
|
-
};
|
|
74
|
-
if (nextProperties) repo.properties = properties.merge(repo.properties ?? {}, nextProperties);
|
|
75
|
-
if (variables) repo.variables = {
|
|
76
|
-
...repo.variables,
|
|
77
|
-
...variables,
|
|
78
|
-
...repo.variables?.repo || variables.repo ? { repo: {
|
|
79
|
-
...repo.variables?.repo,
|
|
80
|
-
...variables.repo
|
|
81
|
-
} } : {},
|
|
82
|
-
...repo.variables?.org || variables.org ? { org: {
|
|
83
|
-
...repo.variables?.org,
|
|
84
|
-
...variables.org
|
|
85
|
-
} } : {}
|
|
86
|
-
};
|
|
87
|
-
if (secrets) {
|
|
88
|
-
const environments = { ...repo.secrets?.environments };
|
|
89
|
-
for (const [env, list] of Object.entries(secrets.environments ?? {})) environments[env] = names$1.merge(environments[env] ?? [], list);
|
|
90
|
-
repo.secrets = {
|
|
91
|
-
...repo.secrets?.repo || secrets.repo ? { repo: names$1.merge(repo.secrets?.repo ?? [], secrets.repo ?? []) } : {},
|
|
92
|
-
...repo.secrets?.org || secrets.org ? { org: names$1.merge(repo.secrets?.org ?? [], secrets.org ?? []) } : {},
|
|
93
|
-
...Object.keys(environments).length > 0 ? { environments } : {},
|
|
94
|
-
...repo.secrets?.sync || secrets.sync ? { sync: mergeSync(repo.secrets?.sync, secrets.sync) } : {}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
if (topics) repo.topics = names$1.merge(repo.topics ?? [], topics);
|
|
98
|
-
if (teams) repo.teams = teamsByKey.merge(repo.teams ?? [], teams);
|
|
99
|
-
return repo;
|
|
100
|
-
}
|
|
101
|
-
// src/config/compose/task-name/task-name.ts
|
|
102
|
-
/**
|
|
103
|
-
* The key a task entry merges under. A name that stands for exactly one flat id (the id itself, or an old dotted
|
|
104
|
-
* alias such as `verification.unitTests`) keys by that id, so the alias overrides the preset's entry instead of
|
|
105
|
-
* sitting next to it; a name that stands for several ids or none (a suite, an unknown name) keys by itself.
|
|
106
|
-
*/
|
|
107
|
-
function taskName(e) {
|
|
108
|
-
const name = typeof e === "string" ? e : e.name;
|
|
109
|
-
const resolved = resolveTaskName(name);
|
|
110
|
-
return resolved.length === 1 ? resolved[0].id : name;
|
|
111
|
-
}
|
|
112
|
-
// src/config/compose/merge-strategies/merge-strategies.ts
|
|
113
|
-
/**
|
|
114
|
-
* How `compose()` merges each key of the capabilities: tasks by name (an old dotted alias overrides the entry it names),
|
|
115
|
-
* providers shallowly, the non-task required checks as a union, `repo` by its own rules, the rest last writer wins.
|
|
116
|
-
*/
|
|
117
|
-
const mergeStrategies = {
|
|
118
|
-
tasks: mergeByKey(taskName),
|
|
119
|
-
providers: shallowMerge(),
|
|
120
|
-
extraRequiredChecks: union(),
|
|
121
|
-
repo: {
|
|
122
|
-
empty: {},
|
|
123
|
-
merge: mergeRepo
|
|
124
|
-
},
|
|
125
|
-
org: lastWins(),
|
|
126
|
-
domain: lastWins(),
|
|
127
|
-
docs: lastWins()
|
|
128
|
-
};
|
|
129
38
|
// src/plugin/capabilities/capabilities.ts
|
|
130
39
|
/** How many providers each capability resolves to: one (`"single"`) or several active at once (`"many"`). */
|
|
131
40
|
const CARDINALITY = {
|
|
@@ -357,6 +266,96 @@ function resolveConfig(raw) {
|
|
|
357
266
|
eslint: raw.eslint
|
|
358
267
|
};
|
|
359
268
|
}
|
|
269
|
+
// src/config/compose/merge-sync/merge-sync.ts
|
|
270
|
+
/**
|
|
271
|
+
* Merge two lists of `repo.secrets.sync` entries. An entry is the same sync when its environment and scope match;
|
|
272
|
+
* the keys then add up, and an entry that names no keys (every key the vault holds) stays that way.
|
|
273
|
+
*/
|
|
274
|
+
function mergeSync(a, b) {
|
|
275
|
+
const merged = /* @__PURE__ */ new Map();
|
|
276
|
+
for (const entry of [...a ?? [], ...b ?? []]) {
|
|
277
|
+
const id = `${entry.environment}\0${entry.scope ?? "repo"}`;
|
|
278
|
+
const have = merged.get(id);
|
|
279
|
+
merged.set(id, have ? {
|
|
280
|
+
...have,
|
|
281
|
+
...have.keys && entry.keys ? { keys: [.../* @__PURE__ */ new Set([...have.keys, ...entry.keys])] } : { keys: void 0 }
|
|
282
|
+
} : { ...entry });
|
|
283
|
+
}
|
|
284
|
+
return [...merged.values()].map(({ keys, ...rest }) => keys ? {
|
|
285
|
+
...rest,
|
|
286
|
+
keys
|
|
287
|
+
} : rest);
|
|
288
|
+
}
|
|
289
|
+
// src/config/compose/merge-repo/merge-repo.ts
|
|
290
|
+
const names$1 = union();
|
|
291
|
+
const properties = shallowMerge();
|
|
292
|
+
const teamsByKey = mergeByKey((t) => typeof t === "string" ? t : t.slug);
|
|
293
|
+
/**
|
|
294
|
+
* Merge one capability's `repo` fragment onto what earlier ones gave. Scalars: last writer wins. `properties`: shallow
|
|
295
|
+
* merge. `variables`: merged per scope (`repo`, `org`). `secrets`: each name list is a union, and `sync` entries merge by
|
|
296
|
+
* environment and scope. `topics`: union. `teams`: merged by slug.
|
|
297
|
+
*/
|
|
298
|
+
function mergeRepo(prev, next) {
|
|
299
|
+
const { properties: nextProperties, topics, teams, variables, secrets, ...scalars } = next;
|
|
300
|
+
const repo = {
|
|
301
|
+
...prev,
|
|
302
|
+
...scalars
|
|
303
|
+
};
|
|
304
|
+
if (nextProperties) repo.properties = properties.merge(repo.properties ?? {}, nextProperties);
|
|
305
|
+
if (variables) repo.variables = {
|
|
306
|
+
...repo.variables,
|
|
307
|
+
...variables,
|
|
308
|
+
...repo.variables?.repo || variables.repo ? { repo: {
|
|
309
|
+
...repo.variables?.repo,
|
|
310
|
+
...variables.repo
|
|
311
|
+
} } : {},
|
|
312
|
+
...repo.variables?.org || variables.org ? { org: {
|
|
313
|
+
...repo.variables?.org,
|
|
314
|
+
...variables.org
|
|
315
|
+
} } : {}
|
|
316
|
+
};
|
|
317
|
+
if (secrets) {
|
|
318
|
+
const environments = { ...repo.secrets?.environments };
|
|
319
|
+
for (const [env, list] of Object.entries(secrets.environments ?? {})) environments[env] = names$1.merge(environments[env] ?? [], list);
|
|
320
|
+
repo.secrets = {
|
|
321
|
+
...repo.secrets?.repo || secrets.repo ? { repo: names$1.merge(repo.secrets?.repo ?? [], secrets.repo ?? []) } : {},
|
|
322
|
+
...repo.secrets?.org || secrets.org ? { org: names$1.merge(repo.secrets?.org ?? [], secrets.org ?? []) } : {},
|
|
323
|
+
...Object.keys(environments).length > 0 ? { environments } : {},
|
|
324
|
+
...repo.secrets?.sync || secrets.sync ? { sync: mergeSync(repo.secrets?.sync, secrets.sync) } : {}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
if (topics) repo.topics = names$1.merge(repo.topics ?? [], topics);
|
|
328
|
+
if (teams) repo.teams = teamsByKey.merge(repo.teams ?? [], teams);
|
|
329
|
+
return repo;
|
|
330
|
+
}
|
|
331
|
+
// src/config/compose/task-name/task-name.ts
|
|
332
|
+
/**
|
|
333
|
+
* The key a task entry merges under. A name that stands for exactly one flat id (the id itself, or an old dotted
|
|
334
|
+
* alias such as `verification.unitTests`) keys by that id, so the alias overrides the preset's entry instead of
|
|
335
|
+
* sitting next to it; a name that stands for several ids or none (a suite, an unknown name) keys by itself.
|
|
336
|
+
*/
|
|
337
|
+
function taskName(e) {
|
|
338
|
+
const name = typeof e === "string" ? e : e.name;
|
|
339
|
+
const resolved = resolveTaskName(name);
|
|
340
|
+
return resolved.length === 1 ? resolved[0].id : name;
|
|
341
|
+
}
|
|
342
|
+
// src/config/compose/merge-strategies/merge-strategies.ts
|
|
343
|
+
/**
|
|
344
|
+
* How `compose()` merges each key of the capabilities: tasks by name (an old dotted alias overrides the entry it names),
|
|
345
|
+
* providers shallowly, the non-task required checks as a union, `repo` by its own rules, the rest last writer wins.
|
|
346
|
+
*/
|
|
347
|
+
const mergeStrategies = {
|
|
348
|
+
tasks: mergeByKey(taskName),
|
|
349
|
+
providers: shallowMerge(),
|
|
350
|
+
extraRequiredChecks: union(),
|
|
351
|
+
repo: {
|
|
352
|
+
empty: {},
|
|
353
|
+
merge: mergeRepo
|
|
354
|
+
},
|
|
355
|
+
org: lastWins(),
|
|
356
|
+
domain: lastWins(),
|
|
357
|
+
docs: lastWins()
|
|
358
|
+
};
|
|
360
359
|
// src/config/load-config/read-package-json-name/read-package-json-name.ts
|
|
361
360
|
/** The `name` of the `package.json` in `dir` without its scope, or `undefined`. */
|
|
362
361
|
async function readPackageJsonName(dir) {
|
|
@@ -387,25 +386,28 @@ async function deriveDefaults$1(found) {
|
|
|
387
386
|
if (manifest.extraRequiredChecks) result.extraRequiredChecks = [...result.extraRequiredChecks ?? [], ...manifest.extraRequiredChecks];
|
|
388
387
|
return result;
|
|
389
388
|
}
|
|
390
|
-
// src/config/system
|
|
391
|
-
/** Holocron's config system, built from kyber's factory; `loadConfig`, `compose` and `defineConfig` wrap its parts. */
|
|
392
|
-
const system = createConfigSystem({
|
|
393
|
-
name: "holocron",
|
|
394
|
-
derive: deriveDefaults$1,
|
|
395
|
-
resolve: resolveConfig,
|
|
396
|
-
merge: mergeStrategies
|
|
397
|
-
});
|
|
398
|
-
// src/config/load-config/load-config.ts
|
|
389
|
+
// src/config/config-system.ts
|
|
399
390
|
/**
|
|
400
|
-
*
|
|
391
|
+
* Holocron's config system: `defineConfig`, `loadConfig` and `compose`, all built from one
|
|
392
|
+
* `createConfigSystem` call.
|
|
401
393
|
*
|
|
402
394
|
* File discovery, the walk up to `.git`, module loading (typed configs via `tsx`) and the derive-then-resolve flow come
|
|
403
395
|
* from `@theholocron/kyber/config`. The holocron-specific parts are `deriveDefaults` (name, `repo.name`, the task
|
|
404
|
-
* manifest)
|
|
396
|
+
* manifest), `resolveConfig` and `mergeStrategies`.
|
|
397
|
+
*
|
|
398
|
+
* The three functions live together because each is only a method of the one system object; splitting them back into
|
|
399
|
+
* one file apiece would just be pass-through wrappers (an exception to the one-function-per-file rule).
|
|
405
400
|
*
|
|
406
401
|
* Probe order is TS-first (`.ts` → `.js` → `.mjs` → `.cjs` → `.json`) —
|
|
407
402
|
* see ADR-0010 / issue #75 / #81.
|
|
408
403
|
*/
|
|
404
|
+
const system = createConfigSystem({
|
|
405
|
+
name: "holocron",
|
|
406
|
+
derive: deriveDefaults$1,
|
|
407
|
+
resolve: resolveConfig,
|
|
408
|
+
merge: mergeStrategies
|
|
409
|
+
});
|
|
410
|
+
system.defineConfig;
|
|
409
411
|
/**
|
|
410
412
|
* Read + parse + resolve `holocron.config.*` starting from the given
|
|
411
413
|
* directory, walking up through ancestors to the nearest `.git` boundary
|
|
@@ -415,9 +417,8 @@ const system = createConfigSystem({
|
|
|
415
417
|
* Throws `ConfigFileError` when nothing is found or a file cannot
|
|
416
418
|
* be loaded, or `ConfigError` when the config fails schema checks.
|
|
417
419
|
*/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
420
|
+
const loadConfig = system.loadConfig;
|
|
421
|
+
system.compose;
|
|
421
422
|
// src/auth.ts
|
|
422
423
|
/**
|
|
423
424
|
* The CLI's credentials: the OS keyring every plugin's bootstrap token lives in, and the two token resolvers built on
|
|
@@ -560,8 +561,8 @@ function commandsInContext(context) {
|
|
|
560
561
|
* traces, errors, structured context that routes to Axiom. It runs in
|
|
561
562
|
* parallel to `print` (user-facing UX output) and does not replace it.
|
|
562
563
|
*/
|
|
563
|
-
const env$
|
|
564
|
-
const holocronEnv$1 = withEnvPrefix(env$
|
|
564
|
+
const env$8 = createEnvLookup();
|
|
565
|
+
const holocronEnv$1 = withEnvPrefix(env$8, "HOLOCRON");
|
|
565
566
|
/**
|
|
566
567
|
* Dataset for `global`-context commands (`clone`, `auth set`, `upgrade
|
|
567
568
|
* node`, …) — ADR-0012. These commands aren't "about" any repo, so their
|
|
@@ -573,44 +574,6 @@ const holocronEnv$1 = withEnvPrefix(env$9, "HOLOCRON");
|
|
|
573
574
|
*/
|
|
574
575
|
const GLOBAL_AXIOM_DATASET = "holocron-global";
|
|
575
576
|
/**
|
|
576
|
-
* Resolve the explicit level to hand to `createLogger`, in priority order:
|
|
577
|
-
*
|
|
578
|
-
* 1. `--log <level>` 2. `--verbose` → `"debug"` 3. `--quiet` → `"error"`
|
|
579
|
-
* 4. `HOLOCRON_LOG_LEVEL` env var
|
|
580
|
-
* 5. `holocron.config` `log.level` (`configLevel`)
|
|
581
|
-
*
|
|
582
|
-
* Returns `undefined` when nothing applies — `createLogger` then defaults
|
|
583
|
-
* to `"info"`. Resolving the full chain here (rather than passing
|
|
584
|
-
* `configLevel` straight through) keeps config below the env var.
|
|
585
|
-
*/
|
|
586
|
-
function resolveLogLevel(argv, configLevel) {
|
|
587
|
-
if (argv.log) return argv.log;
|
|
588
|
-
if (argv.verbose) return "debug";
|
|
589
|
-
if (argv.quiet) return "error";
|
|
590
|
-
return parseLogLevel(env$9.get("HOLOCRON_LOG_LEVEL")) ?? configLevel;
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Resolve whether human-visible console output (pretty or NDJSON) should run
|
|
594
|
-
* at all, independent of level — the `@theholocron/observability`
|
|
595
|
-
* `consoleOutput` override.
|
|
596
|
-
*
|
|
597
|
-
* Local/interactive runs are quiet by default: any raw structured logger
|
|
598
|
-
* output (colorized or not) stays off regardless of the resolved level,
|
|
599
|
-
* unless the user explicitly asked to see it via `--log <level>`,
|
|
600
|
-
* `--verbose`, or `--quiet`. CI is untouched either way — returning
|
|
601
|
-
* `undefined` there preserves `createLogger`'s own `ci`/`tty`
|
|
602
|
-
* auto-detection exactly, so CI's existing NDJSON-to-stdout behavior is
|
|
603
|
-
* unaffected by this flag.
|
|
604
|
-
*/
|
|
605
|
-
function resolveConsoleOutput(argv) {
|
|
606
|
-
if (argv.log || argv.verbose || argv.quiet) return true;
|
|
607
|
-
return isCI() ? void 0 : false;
|
|
608
|
-
}
|
|
609
|
-
let root;
|
|
610
|
-
let rootLevel;
|
|
611
|
-
let rootCommand;
|
|
612
|
-
let rootAxiomKey;
|
|
613
|
-
/**
|
|
614
577
|
* Resolve Axiom credentials for the CLI.
|
|
615
578
|
*
|
|
616
579
|
* A `global`-context command (ADR-0012) always resolves to
|
|
@@ -624,89 +587,39 @@ let rootAxiomKey;
|
|
|
624
587
|
* `HOLOCRON_AXIOM_DATASET` / `AXIOM_DATASET` or `log.axiom.dataset`.
|
|
625
588
|
* Returns `undefined` unless both a token and a dataset are found.
|
|
626
589
|
*/
|
|
627
|
-
function resolveCliAxiom(opts) {
|
|
628
|
-
const isGlobal = contextForCommand(
|
|
590
|
+
function resolveCliAxiom(opts, ctx) {
|
|
591
|
+
const isGlobal = contextForCommand(ctx.command ?? "") === "global";
|
|
629
592
|
if (!isGlobal) {
|
|
630
593
|
const fromEnv = resolveAxiomFromEnv();
|
|
631
594
|
if (fromEnv) return fromEnv;
|
|
632
595
|
}
|
|
633
596
|
const dataset = isGlobal ? GLOBAL_AXIOM_DATASET : holocronEnv$1.get("AXIOM_DATASET") ?? opts.configAxiomDataset;
|
|
634
597
|
if (!dataset) return void 0;
|
|
635
|
-
const org = opts.org ?? env$
|
|
598
|
+
const org = opts.org ?? env$8.get("HOLOCRON_ORG");
|
|
636
599
|
const token = holocronEnv$1.get("AXIOM_TOKEN") || (org ? keyring.get(`axiom.${org}`) : null) || keyring.get("axiom");
|
|
637
600
|
return token ? {
|
|
638
601
|
dataset,
|
|
639
602
|
token
|
|
640
603
|
} : void 0;
|
|
641
604
|
}
|
|
605
|
+
const logger = createCliLogger({
|
|
606
|
+
envPrefix: "HOLOCRON",
|
|
607
|
+
resolveAxiom: resolveCliAxiom
|
|
608
|
+
});
|
|
642
609
|
/**
|
|
643
|
-
* The process-wide root logger
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
* first pass could not have known — `log.level` (unless `--verbose` /
|
|
647
|
-
* `--quiet` already fixed it) or `log.axiom.dataset` + the resolved org
|
|
648
|
-
* for a keyring-backed Axiom transport. That rebuild generates a fresh
|
|
649
|
-
* `runId`, which is harmless: nothing logs between the middleware and the
|
|
650
|
-
* handler.
|
|
651
|
-
*/
|
|
652
|
-
function buildCliLogger(argv, opts = {}) {
|
|
653
|
-
const { command, configLevel } = opts;
|
|
654
|
-
allowProgress(!argv.quiet && !argv.log);
|
|
655
|
-
if (command) rootCommand = command;
|
|
656
|
-
const level = resolveLogLevel(argv, configLevel);
|
|
657
|
-
const consoleOutput = resolveConsoleOutput(argv);
|
|
658
|
-
const axiom = resolveCliAxiom(opts);
|
|
659
|
-
const axiomKey = axiom?.dataset;
|
|
660
|
-
const rebuildForConfig = configLevel !== void 0 && level !== rootLevel && !argv.verbose && !argv.quiet && !argv.log;
|
|
661
|
-
if (!root || rebuildForConfig || axiomKey !== void 0 && axiomKey !== rootAxiomKey) {
|
|
662
|
-
const built = createLogger({
|
|
663
|
-
...level ? { level } : {},
|
|
664
|
-
...axiom ? { axiom } : {},
|
|
665
|
-
...consoleOutput !== void 0 ? { consoleOutput } : {}
|
|
666
|
-
});
|
|
667
|
-
root = {
|
|
668
|
-
logger: rootCommand ? built.logger.child({ command: rootCommand }) : built.logger,
|
|
669
|
-
runId: built.runId
|
|
670
|
-
};
|
|
671
|
-
rootLevel = level;
|
|
672
|
-
rootAxiomKey = axiomKey;
|
|
673
|
-
}
|
|
674
|
-
return root;
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Lazily-memoized `Logger` for module-level call sites with no `argv` in
|
|
678
|
-
* scope — notably yargs' own `.fail()` handler, which fires on a
|
|
679
|
-
* pre-middleware validation failure (a missing required argument, an
|
|
680
|
-
* unknown command) and therefore runs before `buildCliLogger` has ever
|
|
681
|
-
* built the real root. Without an explicit `consoleOutput` here, that
|
|
682
|
-
* fallback would use `createLogger`'s bare auto-detection (pretty on any
|
|
683
|
-
* local TTY) and leak a structured block even though no flag asked for one
|
|
684
|
-
* — so it resolves the same "quiet unless CI" default `buildCliLogger`
|
|
685
|
-
* would, as if no flags were passed.
|
|
686
|
-
*/
|
|
687
|
-
function getLogger() {
|
|
688
|
-
return (root ??= createLogger({ consoleOutput: resolveConsoleOutput({}) })).logger;
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* Report a fatal, command-ending CLI error: always printed to the console
|
|
692
|
-
* (regardless of `consoleOutput` suppression) via `style.fail`, and also
|
|
693
|
-
* sent through the structured logger for Axiom/telemetry visibility.
|
|
694
|
-
*
|
|
695
|
-
* Use this when a handler is returning or exiting right here with nothing
|
|
696
|
-
* else for the user to see — a resolved `--token` failure, a yargs
|
|
697
|
-
* validation failure, a thrown domain error. Don't use it for a per-step
|
|
698
|
-
* warning inside a multi-step orchestrator that already prints its own
|
|
699
|
-
* `ok / fail / skip` summary — that summary is the user-facing signal;
|
|
700
|
-
* the per-step reason belongs in the structured log alone.
|
|
610
|
+
* The process-wide root logger, built once from `cli.ts`'s middleware and
|
|
611
|
+
* rebuilt at most once more when a handler supplies `holocron.config` context.
|
|
612
|
+
* See `createCliLogger` in `@theholocron/kyber/observability`.
|
|
701
613
|
*/
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
614
|
+
const buildCliLogger = logger.buildCliLogger;
|
|
615
|
+
/** Lazily-memoized `Logger` for call sites with no `argv` in scope (yargs' `.fail()`). */
|
|
616
|
+
const getLogger = logger.getLogger;
|
|
617
|
+
/** Report a fatal, command-ending CLI error: printed with `style.fail` and logged. */
|
|
618
|
+
const reportError = logger.reportError;
|
|
706
619
|
/** The current root logger's correlation id, if a root has been built. */
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
620
|
+
const getRunId = logger.getRunId;
|
|
621
|
+
logger.resetCliLogger;
|
|
622
|
+
logger.resolveLogLevel;
|
|
710
623
|
// src/observability/resolve-telemetry/resolve-telemetry.ts
|
|
711
624
|
const holocronEnv = withEnvPrefix(createEnvLookup(), "HOLOCRON");
|
|
712
625
|
/**
|
|
@@ -744,148 +657,37 @@ function resolvePostHogHost() {
|
|
|
744
657
|
}
|
|
745
658
|
// src/observability/telemetry/telemetry.ts
|
|
746
659
|
/**
|
|
747
|
-
* CLI self-telemetry
|
|
748
|
-
*
|
|
749
|
-
* This module holds *no* vendor SDK import. Each concern sits behind an
|
|
750
|
-
* interface from `@theholocron/observability` ({@link ErrorSink} /
|
|
751
|
-
* {@link AnalyticsSink}); the `SentrySink` / `PostHogSink` adapters there are
|
|
752
|
-
* the only `@sentry/node` / `posthog-node` call sites, and a `Noop*Sink` is
|
|
753
|
-
* installed when telemetry is off. Same seam the package's `Logger` uses for
|
|
754
|
-
* Pino.
|
|
755
|
-
*
|
|
756
|
-
* Activation is env-var + shipped-fallback, resolved here (`resolve-telemetry.ts`)
|
|
757
|
-
* and passed to the sink — the adapters read no environment. The single kill
|
|
758
|
-
* switch is `HOLOCRON_TELEMETRY=false` (legacy alias `NO_HOLOCRON_TELEMETRY`);
|
|
759
|
-
* see ADR-0007 / ADR-0008.
|
|
760
|
-
*/
|
|
761
|
-
const env$8 = createEnvLookup();
|
|
762
|
-
let errors = new NoopErrorSink();
|
|
763
|
-
let analytics = new NoopAnalyticsSink();
|
|
764
|
-
/**
|
|
765
|
-
* The shared opt-out. `HOLOCRON_TELEMETRY=false` (going-forward) or
|
|
766
|
-
* `NO_HOLOCRON_TELEMETRY` (any truthy value, back-compat) disables all sinks.
|
|
767
|
-
*/
|
|
768
|
-
function isEnabled() {
|
|
769
|
-
return env$8.get("HOLOCRON_TELEMETRY") !== "false" && !env$8.get("NO_HOLOCRON_TELEMETRY");
|
|
770
|
-
}
|
|
771
|
-
let commandStartedAt = 0;
|
|
772
|
-
let currentCommand = "unknown";
|
|
773
|
-
let lastErrorType;
|
|
774
|
-
let currentSpan;
|
|
775
|
-
/**
|
|
776
|
-
* Anonymous, stable per-machine id — `sha256(hostname + username)` truncated
|
|
777
|
-
* (ADR-0008). One-way: no raw hostname or username is ever transmitted.
|
|
778
|
-
*/
|
|
779
|
-
function machineId() {
|
|
780
|
-
try {
|
|
781
|
-
return createHash("sha256").update(`${hostname()} ${userInfo().username}`).digest("hex").slice(0, 32);
|
|
782
|
-
} catch {
|
|
783
|
-
return "unknown";
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
/** Properties every analytics event carries — pivot key to the Axiom trace. */
|
|
787
|
-
function baseProps() {
|
|
788
|
-
const runId = getRunId();
|
|
789
|
-
return {
|
|
790
|
-
command: currentCommand,
|
|
791
|
-
ci: Boolean(env$8.get("CI")),
|
|
792
|
-
...runId ? { runId } : {}
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
function init(version) {
|
|
796
|
-
const dsn = resolveDsn();
|
|
797
|
-
if (isEnabled() && dsn !== "") {
|
|
798
|
-
errors = new SentrySink();
|
|
799
|
-
errors.init({
|
|
800
|
-
dsn,
|
|
801
|
-
release: `holocron@${version}`,
|
|
802
|
-
environment: env$8.get("CI") ? "ci" : "local",
|
|
803
|
-
tags: {
|
|
804
|
-
os: process.platform,
|
|
805
|
-
node: process.version,
|
|
806
|
-
ci: String(Boolean(env$8.get("CI")))
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
const posthogKey = resolvePostHogKey();
|
|
811
|
-
if (isEnabled() && posthogKey !== "") {
|
|
812
|
-
analytics = new PostHogSink({
|
|
813
|
-
key: posthogKey,
|
|
814
|
-
host: resolvePostHogHost()
|
|
815
|
-
});
|
|
816
|
-
analytics.identify(machineId(), {
|
|
817
|
-
ci: Boolean(env$8.get("CI")),
|
|
818
|
-
os: process.platform,
|
|
819
|
-
node: process.version,
|
|
820
|
-
cli: version,
|
|
821
|
-
...env$8.get("HOLOCRON_ORG") ? { org: env$8.get("HOLOCRON_ORG") } : {}
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Apply the `telemetry` config block — the committed override layer, run once
|
|
827
|
-
* per command *after* config loads (so it lands after {@link init}). Env still
|
|
828
|
-
* wins: this only ever *narrows* what `init` turned on, never re-enables.
|
|
660
|
+
* CLI self-telemetry — errors (Sentry), usage analytics (PostHog).
|
|
829
661
|
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}
|
|
860
|
-
function startCommand(name) {
|
|
861
|
-
currentCommand = name;
|
|
862
|
-
commandStartedAt = Date.now();
|
|
863
|
-
lastErrorType = void 0;
|
|
864
|
-
currentSpan = errors.startSpan(name);
|
|
865
|
-
event("command_started", { dry_run: process.argv.includes("--dry-run") });
|
|
866
|
-
return (ok) => {
|
|
867
|
-
currentSpan?.setStatus(ok);
|
|
868
|
-
currentSpan?.end();
|
|
869
|
-
event(ok ? "command_completed" : "command_failed", {
|
|
870
|
-
status: ok ? "ok" : "fail",
|
|
871
|
-
duration_ms: Date.now() - commandStartedAt,
|
|
872
|
-
...ok || !lastErrorType ? {} : { error_type: lastErrorType }
|
|
873
|
-
});
|
|
874
|
-
};
|
|
875
|
-
}
|
|
876
|
-
function captureException(err) {
|
|
877
|
-
lastErrorType = err instanceof Error ? err.constructor.name : "Error";
|
|
878
|
-
errors.captureException(err);
|
|
879
|
-
}
|
|
880
|
-
function endSession() {
|
|
881
|
-
errors.endSession();
|
|
882
|
-
}
|
|
883
|
-
async function flush() {
|
|
884
|
-
await errors.flush();
|
|
885
|
-
await analytics.shutdown();
|
|
886
|
-
errors = new NoopErrorSink();
|
|
887
|
-
analytics = new NoopAnalyticsSink();
|
|
888
|
-
}
|
|
662
|
+
* The orchestration is `createCliTelemetry` in `@theholocron/kyber/observability`
|
|
663
|
+
* (no vendor SDK import here either: the sinks live in `@theholocron/observability`).
|
|
664
|
+
* This module binds it to Holocron's values: the `HOLOCRON` env prefix, the
|
|
665
|
+
* credentials resolved by `resolve-telemetry.ts`, and the logger's run id.
|
|
666
|
+
* The single kill switch is `HOLOCRON_TELEMETRY=false` (legacy alias
|
|
667
|
+
* `NO_HOLOCRON_TELEMETRY`); see ADR-0007 / ADR-0008.
|
|
668
|
+
*/
|
|
669
|
+
const telemetry = createCliTelemetry({
|
|
670
|
+
envPrefix: "HOLOCRON",
|
|
671
|
+
dsn: resolveDsn,
|
|
672
|
+
posthogKey: resolvePostHogKey,
|
|
673
|
+
posthogHost: resolvePostHogHost,
|
|
674
|
+
getRunId: () => getRunId()
|
|
675
|
+
});
|
|
676
|
+
/** Install the live sinks unless telemetry is opted out or a credential is empty. */
|
|
677
|
+
const init = telemetry.init;
|
|
678
|
+
/** Apply the `telemetry` config block; it only ever narrows what `init` turned on. */
|
|
679
|
+
const applyConfig = telemetry.applyConfig;
|
|
680
|
+
/** Capture a PostHog event, scrubbed of secrets. */
|
|
681
|
+
const event = telemetry.event;
|
|
682
|
+
/** Start a command span; call the returned function with the outcome. */
|
|
683
|
+
const startCommand = telemetry.startCommand;
|
|
684
|
+
/** Report an error to Sentry. */
|
|
685
|
+
const captureException = telemetry.captureException;
|
|
686
|
+
/** End the Sentry session. */
|
|
687
|
+
const endSession = telemetry.endSession;
|
|
688
|
+
/** Drain both sinks and return to the no-ops. */
|
|
689
|
+
const flush = telemetry.flush;
|
|
690
|
+
telemetry.resetTelemetry;
|
|
889
691
|
// src/commands/resolve-org/resolve-org.ts
|
|
890
692
|
const env$7 = createEnvLookup();
|
|
891
693
|
/**
|
|
@@ -1647,53 +1449,6 @@ async function tryLoadHint(importer, packageName) {
|
|
|
1647
1449
|
function tokenContext$1(rawTokens) {
|
|
1648
1450
|
return tokenContext(rawTokens, reportError);
|
|
1649
1451
|
}
|
|
1650
|
-
// src/commands/doctor-checks/declared-vs-actual.ts
|
|
1651
|
-
/**
|
|
1652
|
-
* Compares what the config declares with what exists, both as maps by key, and returns one problem line per
|
|
1653
|
-
* difference: a declared key that is missing, a key found but not declared, a key whose values disagree.
|
|
1654
|
-
* An empty list means they match. A deep check is then a list of these comparisons, not a renderer of its own.
|
|
1655
|
-
*/
|
|
1656
|
-
function declaredVsActual(declared, actual, options) {
|
|
1657
|
-
const equal = options.equal ?? ((a, b) => a === b);
|
|
1658
|
-
const show = options.show ?? ((value) => String(value));
|
|
1659
|
-
const problems = [];
|
|
1660
|
-
for (const [key, want] of declared) {
|
|
1661
|
-
if (!actual.has(key)) {
|
|
1662
|
-
problems.push(`missing ${options.noun} ${key}`);
|
|
1663
|
-
continue;
|
|
1664
|
-
}
|
|
1665
|
-
const found = actual.get(key);
|
|
1666
|
-
if (!equal(want, found)) problems.push(`${options.noun} ${key}: declared ${show(want)}, found ${show(found)}`);
|
|
1667
|
-
}
|
|
1668
|
-
if (options.flagExtra !== false) {
|
|
1669
|
-
for (const key of actual.keys()) if (!declared.has(key)) problems.push(`unexpected ${options.noun} ${key}`);
|
|
1670
|
-
}
|
|
1671
|
-
return problems;
|
|
1672
|
-
}
|
|
1673
|
-
// src/commands/doctor-checks/print-check-rows.ts
|
|
1674
|
-
/** One row per step, titles padded to the widest, each problem on its own indented line. */
|
|
1675
|
-
function printCheckRows(rows, print) {
|
|
1676
|
-
const width = Math.max(0, ...rows.map((row) => row.title.length));
|
|
1677
|
-
for (const row of rows) {
|
|
1678
|
-
print(statusRow(row.status, [row.title.padEnd(width), row.detail]));
|
|
1679
|
-
for (const problem of row.problems) print(` - ${problem}`);
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
// src/commands/doctor-checks/print-check-summary.ts
|
|
1683
|
-
/** A blank line, then the closing `N ok, N fail, N skipped`. */
|
|
1684
|
-
function printCheckSummary(summary, print) {
|
|
1685
|
-
print("");
|
|
1686
|
-
print(style.header(`${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped`));
|
|
1687
|
-
}
|
|
1688
|
-
// src/commands/doctor-checks/summarise-checks.ts
|
|
1689
|
-
/** How many rows ended each way. */
|
|
1690
|
-
function summariseChecks(rows) {
|
|
1691
|
-
return {
|
|
1692
|
-
ok: rows.filter((r) => r.status === "ok").length,
|
|
1693
|
-
fail: rows.filter((r) => r.status === "fail").length,
|
|
1694
|
-
skip: rows.filter((r) => r.status === "skip").length
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
1452
|
const DAY_MS = 864e5;
|
|
1698
1453
|
/**
|
|
1699
1454
|
* How long a token has left, as `expires in 12 days`, and whether that is inside the warning window.
|
|
@@ -1817,56 +1572,6 @@ const doctorTokensCommand = {
|
|
|
1817
1572
|
})).status === "fail") process.exitCode = 1;
|
|
1818
1573
|
}
|
|
1819
1574
|
};
|
|
1820
|
-
// src/commands/finish-credentials-file/finish-credentials-file.ts
|
|
1821
|
-
/** Signals that end the wait for the import, with the exit status each is conventionally reported as. */
|
|
1822
|
-
const INTERRUPTS = [
|
|
1823
|
-
["SIGINT", 130],
|
|
1824
|
-
["SIGTERM", 143],
|
|
1825
|
-
["SIGHUP", 129]
|
|
1826
|
-
];
|
|
1827
|
-
/**
|
|
1828
|
-
* Once the lines are in the private file, says what to do with it and, on a terminal, deletes it when the import is
|
|
1829
|
-
* done. Returns whether the file is gone (or was left on purpose): `false` means plaintext secrets are still on disk.
|
|
1830
|
-
*/
|
|
1831
|
-
async function finishCredentialsFile(input) {
|
|
1832
|
-
const { path, identity, print } = input;
|
|
1833
|
-
print(`wrote ${path} (readable only by you)`);
|
|
1834
|
-
print(input.importHint);
|
|
1835
|
-
if (input.keep || !input.interactive) {
|
|
1836
|
-
closeSync(identity.fd);
|
|
1837
|
-
print(`it holds ${input.holds} in plain text: delete it when you are done: ${path}`);
|
|
1838
|
-
return true;
|
|
1839
|
-
}
|
|
1840
|
-
const cleanup = () => {
|
|
1841
|
-
try {
|
|
1842
|
-
const outcome = (input.shred ?? shredFile)(path, identity);
|
|
1843
|
-
if (outcome === "deleted") print(`deleted ${path}`);
|
|
1844
|
-
else if (outcome === "missing") print(`${path} was already gone`);
|
|
1845
|
-
else print(`left ${path} alone: it is no longer the file this command wrote`);
|
|
1846
|
-
return true;
|
|
1847
|
-
} catch (err) {
|
|
1848
|
-
print(`could not delete ${path}: ${errorMessage(err)}`);
|
|
1849
|
-
print(`it holds ${input.holds} in plain text: delete it yourself: ${path}`);
|
|
1850
|
-
return false;
|
|
1851
|
-
}
|
|
1852
|
-
};
|
|
1853
|
-
const handlers = INTERRUPTS.map(([signal, code]) => {
|
|
1854
|
-
const handler = () => {
|
|
1855
|
-
cleanup();
|
|
1856
|
-
process.exit(code);
|
|
1857
|
-
};
|
|
1858
|
-
process.once(signal, handler);
|
|
1859
|
-
return [signal, handler];
|
|
1860
|
-
});
|
|
1861
|
-
let cleaned;
|
|
1862
|
-
try {
|
|
1863
|
-
await (input.waitForImport ?? waitForEnter)("press Enter when the import is done and the file will be deleted: ");
|
|
1864
|
-
} finally {
|
|
1865
|
-
for (const [signal, handler] of handlers) process.off(signal, handler);
|
|
1866
|
-
cleaned = cleanup();
|
|
1867
|
-
}
|
|
1868
|
-
return cleaned;
|
|
1869
|
-
}
|
|
1870
1575
|
// src/commands/auth-export/auth-export.ts
|
|
1871
1576
|
/**
|
|
1872
1577
|
* `holocron auth export` — print the tokens a configured plugin takes as `NAME=value` lines, to move them into a
|
|
@@ -2976,33 +2681,23 @@ function getEntry(name) {
|
|
|
2976
2681
|
if (!entry) throw new Error(`interactive-menu: no COMMAND_REGISTRY entry named "${name}"`);
|
|
2977
2682
|
return entry;
|
|
2978
2683
|
}
|
|
2979
|
-
// src/interactive-menu/
|
|
2980
|
-
/**
|
|
2981
|
-
* Set on a dry-run preview child's env so its handler knows this specific `--dry-run` came from the menu's
|
|
2982
|
-
* own preview-then-ask flow, not a direct `holocron <cmd> --dry-run` invocation (see kyber's
|
|
2983
|
-
* `dryRunPreviewEnvVar`). A handler that supports it uses this to decide whether to report
|
|
2984
|
-
* {@link DRY_RUN_NOOP_EXIT_CODE}.
|
|
2985
|
-
*/
|
|
2986
|
-
const DRY_RUN_PREVIEW_ENV_VAR = dryRunPreviewEnvVar("HOLOCRON");
|
|
2684
|
+
// src/interactive-menu/menu.ts
|
|
2987
2685
|
/**
|
|
2988
2686
|
* Kyber's menu engine bound to `holocron`: secret options travel as `HOLOCRON_<OPTION>` env vars and the
|
|
2989
|
-
* non-interactive hint names the `holocron` bin.
|
|
2687
|
+
* non-interactive hint names the `holocron` bin. Feed it {@link COMMAND_REGISTRY} (plus any dynamically-built
|
|
2688
|
+
* entries); see `docs/wiki/specifications/tool-interactive-cli-menu.spec.md`.
|
|
2990
2689
|
*
|
|
2991
|
-
*
|
|
2992
|
-
*
|
|
2993
|
-
*
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
...nonInteractiveMessage !== void 0 && { nonInteractiveMessage },
|
|
3003
|
-
...startPath !== void 0 && { startPath }
|
|
3004
|
-
});
|
|
3005
|
-
}
|
|
2690
|
+
* Set on a dry-run preview child's env, `dryRunPreviewEnvVar` tells its handler this `--dry-run` came from the menu's own
|
|
2691
|
+
* preview-then-ask flow, not a direct `holocron <cmd> --dry-run`; a handler that supports it uses that to decide
|
|
2692
|
+
* whether to report {@link DRY_RUN_NOOP_EXIT_CODE}.
|
|
2693
|
+
*/
|
|
2694
|
+
const menu = createMenu({
|
|
2695
|
+
bin: "holocron",
|
|
2696
|
+
envPrefix: "HOLOCRON"
|
|
2697
|
+
});
|
|
2698
|
+
const launchMenu = menu.launchMenu;
|
|
2699
|
+
/** The env var a Holocron dry-run preview child gets (`HOLOCRON_DRY_RUN_PREVIEW`). */
|
|
2700
|
+
const DRY_RUN_PREVIEW_ENV_VAR = menu.dryRunPreviewEnvVar;
|
|
3006
2701
|
// src/interactive-menu/probe-menu-entries/probe-menu-entries.ts
|
|
3007
2702
|
/**
|
|
3008
2703
|
* One menu entry per probe, grouped under its provider (`probe sentry integrations`), for the menu `holocron probe`
|
|
@@ -3129,7 +2824,11 @@ function buildRunMenuEntries(taskNames) {
|
|
|
3129
2824
|
// src/commands/group-menu/group-menu.ts
|
|
3130
2825
|
/** Layer 2: a bare group command (`holocron repo`, `holocron repo upgrade`, …) opens the menu at that level. */
|
|
3131
2826
|
async function launchGroupMenu(parent, argv) {
|
|
3132
|
-
await launchMenu
|
|
2827
|
+
await launchMenu(COMMAND_REGISTRY, argv, {
|
|
2828
|
+
pickMessage: `${parent} — choose a subcommand:`,
|
|
2829
|
+
nonInteractiveMessage: `Run \`holocron ${parent} --help\` to see available ${parent} subcommands.`,
|
|
2830
|
+
startPath: parent.split(" ")
|
|
2831
|
+
});
|
|
3133
2832
|
}
|
|
3134
2833
|
/** The hidden `$0` of a command group: bare `holocron <group>` opens the menu at that group. */
|
|
3135
2834
|
const groupMenu$1 = (parent) => groupMenu(parent, launchGroupMenu);
|
|
@@ -4249,76 +3948,6 @@ function resolveDevOptions(flags, config, self = [process.execPath, process.argv
|
|
|
4249
3948
|
command
|
|
4250
3949
|
};
|
|
4251
3950
|
}
|
|
4252
|
-
// src/commands/run-dev-processes/run-dev-processes.ts
|
|
4253
|
-
/**
|
|
4254
|
-
* Runs the application and the tunnel's connector side by side in the foreground, with their output on the terminal,
|
|
4255
|
-
* and stops the other when either ends. Ctrl-C and a termination signal go to both and are not a failure. A process
|
|
4256
|
-
* that cannot be started stops the other and rejects, saying which program it was.
|
|
4257
|
-
*/
|
|
4258
|
-
function runDevProcesses(input) {
|
|
4259
|
-
return new Promise((resolve, reject) => {
|
|
4260
|
-
const spawnImpl = input.spawn ?? spawn;
|
|
4261
|
-
const start = (p) => spawnImpl(p.command, p.args, {
|
|
4262
|
-
stdio: "inherit",
|
|
4263
|
-
env: {
|
|
4264
|
-
...process.env,
|
|
4265
|
-
...p.env
|
|
4266
|
-
}
|
|
4267
|
-
});
|
|
4268
|
-
const children = {
|
|
4269
|
-
app: start(input.app),
|
|
4270
|
-
connector: start(input.connector)
|
|
4271
|
-
};
|
|
4272
|
-
const names = ["app", "connector"];
|
|
4273
|
-
let endedFirst;
|
|
4274
|
-
let status = 0;
|
|
4275
|
-
let interrupted = false;
|
|
4276
|
-
let done = false;
|
|
4277
|
-
const ended = /* @__PURE__ */ new Set();
|
|
4278
|
-
const signals = ["SIGINT", "SIGTERM"].map((signal) => {
|
|
4279
|
-
const handler = () => {
|
|
4280
|
-
interrupted = true;
|
|
4281
|
-
for (const child of Object.values(children)) child.kill(signal);
|
|
4282
|
-
};
|
|
4283
|
-
process.on(signal, handler);
|
|
4284
|
-
return [signal, handler];
|
|
4285
|
-
});
|
|
4286
|
-
const cleanUp = () => {
|
|
4287
|
-
for (const [signal, handler] of signals) process.off(signal, handler);
|
|
4288
|
-
};
|
|
4289
|
-
const stopAll = () => {
|
|
4290
|
-
for (const child of Object.values(children)) child.kill("SIGTERM");
|
|
4291
|
-
};
|
|
4292
|
-
for (const name of names) {
|
|
4293
|
-
const other = name === "app" ? "connector" : "app";
|
|
4294
|
-
children[name].once("error", (err) => {
|
|
4295
|
-
if (done) return;
|
|
4296
|
-
done = true;
|
|
4297
|
-
cleanUp();
|
|
4298
|
-
stopAll();
|
|
4299
|
-
const program = input[name].command;
|
|
4300
|
-
reject(/* @__PURE__ */ new Error(err.code === "ENOENT" ? `${program} is not installed or not on the PATH` : `could not start ${program}: ${err.message}`));
|
|
4301
|
-
});
|
|
4302
|
-
children[name].once("exit", (code) => {
|
|
4303
|
-
ended.add(name);
|
|
4304
|
-
if (endedFirst === void 0) {
|
|
4305
|
-
endedFirst = name;
|
|
4306
|
-
status = code ?? 1;
|
|
4307
|
-
children[other].kill("SIGTERM");
|
|
4308
|
-
}
|
|
4309
|
-
if (ended.size === names.length && !done) {
|
|
4310
|
-
done = true;
|
|
4311
|
-
cleanUp();
|
|
4312
|
-
resolve({
|
|
4313
|
-
exitCode: interrupted ? 0 : status,
|
|
4314
|
-
endedFirst,
|
|
4315
|
-
interrupted
|
|
4316
|
-
});
|
|
4317
|
-
}
|
|
4318
|
-
});
|
|
4319
|
-
}
|
|
4320
|
-
});
|
|
4321
|
-
}
|
|
4322
3951
|
// src/commands/run-cloudflared/run-cloudflared.ts
|
|
4323
3952
|
/**
|
|
4324
3953
|
* Runs `cloudflared tunnel run` in the foreground and resolves with its exit status. The tunnel's token goes to the
|
|
@@ -4517,6 +4146,13 @@ const tunnelUpCommand = {
|
|
|
4517
4146
|
}
|
|
4518
4147
|
};
|
|
4519
4148
|
// src/commands/dev/dev.ts
|
|
4149
|
+
/**
|
|
4150
|
+
* `holocron dev` — run an application locally behind its development tunnel, in one command.
|
|
4151
|
+
*
|
|
4152
|
+
* The vault environment's variables are read in memory and handed to the application's process, never written to
|
|
4153
|
+
* disk or printed (only how many there are). The tunnel and its DNS record are set up the way `holocron tunnel up`
|
|
4154
|
+
* does, and the tunnel's connector runs beside the application; Ctrl-C stops both.
|
|
4155
|
+
*/
|
|
4520
4156
|
const COMMAND$6 = "dev";
|
|
4521
4157
|
/** The environment the application is told it runs in, which its logger tags every line with. */
|
|
4522
4158
|
const APP_ENVIRONMENT = "development";
|
|
@@ -4598,8 +4234,8 @@ async function runDev(input) {
|
|
|
4598
4234
|
print(`running ${shown} and cloudflared (Ctrl-C stops both): ${tunnel.url} to localhost:${input.port}`);
|
|
4599
4235
|
let exitCode;
|
|
4600
4236
|
try {
|
|
4601
|
-
({exitCode} = await (input.runProcesses ??
|
|
4602
|
-
|
|
4237
|
+
({exitCode} = await (input.runProcesses ?? superviseProcesses)({
|
|
4238
|
+
primary: {
|
|
4603
4239
|
command: program,
|
|
4604
4240
|
args,
|
|
4605
4241
|
env: {
|
|
@@ -4608,7 +4244,7 @@ async function runDev(input) {
|
|
|
4608
4244
|
PORT: String(input.port)
|
|
4609
4245
|
}
|
|
4610
4246
|
},
|
|
4611
|
-
|
|
4247
|
+
companion: {
|
|
4612
4248
|
command: "cloudflared",
|
|
4613
4249
|
args: [
|
|
4614
4250
|
"tunnel",
|
|
@@ -8542,9 +8178,6 @@ const BUILTIN_TEMPLATES = {
|
|
|
8542
8178
|
"2 · Next",
|
|
8543
8179
|
"3 · Process"
|
|
8544
8180
|
]
|
|
8545
|
-
}, {
|
|
8546
|
-
name: "Milestone",
|
|
8547
|
-
type: "text"
|
|
8548
8181
|
}],
|
|
8549
8182
|
views: [
|
|
8550
8183
|
{
|
|
@@ -9500,8 +9133,9 @@ function repoChecks(config, repoRoot) {
|
|
|
9500
9133
|
const declared = /* @__PURE__ */ new Map();
|
|
9501
9134
|
if (config.description) declared.set("description", config.description);
|
|
9502
9135
|
if (config.homepage) declared.set("homepage", config.homepage);
|
|
9136
|
+
const actual = /* @__PURE__ */ new Map([["description", info.description ?? ""], ["homepage", info.homepage ?? ""]]);
|
|
9503
9137
|
return {
|
|
9504
|
-
problems: declaredVsActual(declared,
|
|
9138
|
+
problems: declaredVsActual(declared, actual, {
|
|
9505
9139
|
noun: "repository field",
|
|
9506
9140
|
flagExtra: false,
|
|
9507
9141
|
show: quote
|
|
@@ -9518,8 +9152,9 @@ function repoChecks(config, repoRoot) {
|
|
|
9518
9152
|
const info = await source.getRepoInfo();
|
|
9519
9153
|
const declared = new Map(Object.entries(preset ? BALANCED_REPO_SETTINGS : {}));
|
|
9520
9154
|
if (repo?.defaultBranch) declared.set("default_branch", repo.defaultBranch);
|
|
9155
|
+
const actual = new Map(Object.entries(info.settings));
|
|
9521
9156
|
return {
|
|
9522
|
-
problems: declaredVsActual(declared,
|
|
9157
|
+
problems: declaredVsActual(declared, actual, {
|
|
9523
9158
|
noun: "repository setting",
|
|
9524
9159
|
flagExtra: false,
|
|
9525
9160
|
show: quote
|
|
@@ -11052,7 +10687,7 @@ const menuCommand = (version) => ({
|
|
|
11052
10687
|
handler: async (argv) => {
|
|
11053
10688
|
printVersionHeaderOnce(version);
|
|
11054
10689
|
const runEntries = buildRunMenuEntries(await listRunnableTasks(argv));
|
|
11055
|
-
await launchMenu
|
|
10690
|
+
await launchMenu([...COMMAND_REGISTRY, ...runEntries], argv);
|
|
11056
10691
|
}
|
|
11057
10692
|
});
|
|
11058
10693
|
// src/commands/monitoring-check/monitoring-check.ts
|
|
@@ -16066,7 +15701,7 @@ function hooksEnabled(input) {
|
|
|
16066
15701
|
return config.repo?.protection === "strict";
|
|
16067
15702
|
}
|
|
16068
15703
|
// src/commands/repo-files/generate-config-files.ts
|
|
16069
|
-
const { workflowHeader: workflowHeader$
|
|
15704
|
+
const { workflowHeader: workflowHeader$1 } = createHeader({
|
|
16070
15705
|
source: "cli/cli/src/commands/repo-files/generate-config-files.ts",
|
|
16071
15706
|
tool: "holocron repo setup"
|
|
16072
15707
|
});
|
|
@@ -16091,7 +15726,7 @@ async function generateConfigFiles(input) {
|
|
|
16091
15726
|
const taskNames = (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name);
|
|
16092
15727
|
const entries = [];
|
|
16093
15728
|
if (taskNames.includes("bookkeeping")) entries.push(file(".github/labeler.yml", createLabeler()));
|
|
16094
|
-
if (config.repo?.protection !== "none") entries.push(file(".github/dependabot.yml", createDependabot({ ignore: ownCatalogPackages(input.repoRoot) })), file(".github/dco.yml", `${workflowHeader$
|
|
15729
|
+
if (config.repo?.protection !== "none") entries.push(file(".github/dependabot.yml", createDependabot({ ignore: ownCatalogPackages(input.repoRoot) })), file(".github/dco.yml", `${workflowHeader$1()}${dco_default}`));
|
|
16095
15730
|
entries.push(file(".alexrc.json", createAlexrc()), file(".alexignore", createAlexignore()), file(".yamllint.yml", createYamllint()), file(".yamlignore", createYamlignore()), file(".editorconfig", createEditorconfig()), file(".editorconfig-checker.json", createEditorconfigChecker()), file("devmoji.config.cjs", createDevmoji()), file(".husky/prepare-commit-msg", createPrepareCommitMsg()), file(".husky/commit-msg", createCommitMsg(config.holocronScript)));
|
|
16096
15731
|
if (hooksEnabled(input)) entries.push(file(".husky/pre-push", createPrePush(config.holocronScript), "runs `holocron run ci` before push — bypass with `git push --no-verify`"), file(".husky/pre-commit", createPreCommit(), "runs GitLeaks (staged-only) + lint-staged before commit"));
|
|
16097
15732
|
else for (const hook of [".husky/pre-push", ".husky/pre-commit"]) entries.push({
|
|
@@ -16124,203 +15759,6 @@ async function generateConfigFiles(input) {
|
|
|
16124
15759
|
}
|
|
16125
15760
|
return entries;
|
|
16126
15761
|
}
|
|
16127
|
-
// src/commands/workflow-source-marker/workflow-source-marker.ts
|
|
16128
|
-
/** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
|
|
16129
|
-
const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
|
|
16130
|
-
/** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
|
|
16131
|
-
function sanitizeForDisplay(value) {
|
|
16132
|
-
return value.replace(/[\x00-\x1f\x7f]/g, "");
|
|
16133
|
-
}
|
|
16134
|
-
/**
|
|
16135
|
-
* Repo-root-relative path of the PACKAGE a workflow-writing command run is
|
|
16136
|
-
* scoped to — the directory holding the discovered `holocron.config.*`
|
|
16137
|
-
* (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
|
|
16138
|
-
* up to find the config from any subdirectory ("every command is usable
|
|
16139
|
-
* from any subdirectory of a repo, not only its exact root"), so a `--cwd`
|
|
16140
|
-
* one level too deep would otherwise stamp a different marker than a later
|
|
16141
|
-
* run from the package's own root and misfire the collision check this
|
|
16142
|
-
* feeds (holocron#1026).
|
|
16143
|
-
*
|
|
16144
|
-
* "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
|
|
16145
|
-
* to forward slashes so the same package produces the same marker on
|
|
16146
|
-
* Windows and POSIX. Throws if the result contains a line break — a path
|
|
16147
|
-
* containing one could otherwise break out of the `# Source package: `
|
|
16148
|
-
* comment line and inject arbitrary workflow YAML when the generated
|
|
16149
|
-
* content is later written. Not reachable through this CLI's own flows
|
|
16150
|
-
* (no code path writes a config file whose directory name contains a line
|
|
16151
|
-
* break), but cheap to reject outright rather than trust the filesystem.
|
|
16152
|
-
*/
|
|
16153
|
-
function resolvePkgRelPath(gitRoot, configFilepath) {
|
|
16154
|
-
let root;
|
|
16155
|
-
try {
|
|
16156
|
-
root = realpathSync(gitRoot);
|
|
16157
|
-
} catch {
|
|
16158
|
-
root = gitRoot;
|
|
16159
|
-
}
|
|
16160
|
-
let configDir;
|
|
16161
|
-
try {
|
|
16162
|
-
configDir = realpathSync(dirname(configFilepath));
|
|
16163
|
-
} catch {
|
|
16164
|
-
configDir = dirname(configFilepath);
|
|
16165
|
-
}
|
|
16166
|
-
const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
|
|
16167
|
-
if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
|
|
16168
|
-
return pkgRelPath;
|
|
16169
|
-
}
|
|
16170
|
-
/**
|
|
16171
|
-
* Two different monorepo packages opting into the same generic task name
|
|
16172
|
-
* (e.g. both `apps/sentinel` and some future `apps/other` configuring
|
|
16173
|
-
* `delivery.previewDeploy`) would otherwise overwrite each other's
|
|
16174
|
-
* `.github/workflows/<task>.yml` on whichever package's write ran last —
|
|
16175
|
-
* only one package's behavior would ever actually run in CI, with no
|
|
16176
|
-
* signal that the other's was silently dropped (holocron#1026).
|
|
16177
|
-
*
|
|
16178
|
-
* Shared by both `holocron repo sync` (reads the file straight off local
|
|
16179
|
-
* disk) and `holocron repo setup` (reads it through the loaded `Source`
|
|
16180
|
-
* capability, which happens to be local disk too for the github plugin
|
|
16181
|
-
* today, but the interface doesn't promise that for every provider —
|
|
16182
|
-
* holocron#1068). The marker-parsing and error message are identical
|
|
16183
|
-
* either way; `readExisting` is how the two callers differ.
|
|
16184
|
-
*
|
|
16185
|
-
* A file with no marker at all predates this check (or was written before
|
|
16186
|
-
* #1026) and is never flagged — only a marker that's present AND disagrees
|
|
16187
|
-
* with the current run's own package is a real collision. `readExisting`
|
|
16188
|
-
* returning `null` means "nothing there," not "unreadable" — a caller
|
|
16189
|
-
* whose underlying read can fail for reasons other than "doesn't exist"
|
|
16190
|
-
* (e.g. local fs EISDIR) is expected to let that error propagate out of
|
|
16191
|
-
* `readExisting` itself rather than mapping it to `null`.
|
|
16192
|
-
*/
|
|
16193
|
-
async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
|
|
16194
|
-
const existing = await readExisting();
|
|
16195
|
-
if (existing === null) return;
|
|
16196
|
-
const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
|
|
16197
|
-
if (previousPkg !== void 0 && previousPkg !== pkgRelPath) throw new Error(`task "${taskName}" would overwrite .github/workflows/${filename}, already generated for package "${sanitizeForDisplay(previousPkg)}" — the same task name can't be used by two different packages (holocron#1026). If "${sanitizeForDisplay(previousPkg)}" moved or was renamed to this path, delete .github/workflows/${filename} first and re-run this command; otherwise rename one or give it a different thin-caller filename.`);
|
|
16198
|
-
}
|
|
16199
|
-
// src/commands/repo-files/generate-project-workflow-files.ts
|
|
16200
|
-
/** Where the scheduled reconcile workflow is written. */
|
|
16201
|
-
const PROJECT_RECONCILE_WORKFLOW = ".github/workflows/platform.projectReconcile.yml";
|
|
16202
|
-
/**
|
|
16203
|
-
* The workflow's own name. `platform.notifications.yml` lists it under `workflow_run`, so a run that fails on the
|
|
16204
|
-
* default branch posts to #alerts with the gatekeepers ping.
|
|
16205
|
-
*/
|
|
16206
|
-
const PROJECT_RECONCILE_NAME = "Project reconcile";
|
|
16207
|
-
/** The Actions secrets that hold the GitHub App's id and private key the run mints its installation token from. */
|
|
16208
|
-
const PROJECT_APP_SECRETS = {
|
|
16209
|
-
id: "SENTINEL_APP_ID",
|
|
16210
|
-
privateKey: "SENTINEL_APP_PRIVATE_KEY"
|
|
16211
|
-
};
|
|
16212
|
-
const { workflowHeader: workflowHeader$1 } = createHeader({
|
|
16213
|
-
source: "cli/cli/src/commands/repo-files/generate-project-workflow-files.ts",
|
|
16214
|
-
tool: "holocron repo sync"
|
|
16215
|
-
});
|
|
16216
|
-
/**
|
|
16217
|
-
* The workflow as YAML. Its nesting is written with tabs here, one tab for each two spaces of the file, and turned into spaces
|
|
16218
|
-
* when it is rendered: a source line that starts with spaces fails the editorconfig check, and the autofix that answers
|
|
16219
|
-
* it rewrites the YAML into tabs, which YAML does not allow.
|
|
16220
|
-
*/
|
|
16221
|
-
function workflow(owner) {
|
|
16222
|
-
return `name: ${PROJECT_RECONCILE_NAME}
|
|
16223
|
-
|
|
16224
|
-
on: # yamllint disable-line rule:truthy
|
|
16225
|
-
schedule:
|
|
16226
|
-
- cron: "23 * * * *"
|
|
16227
|
-
workflow_dispatch:
|
|
16228
|
-
inputs:
|
|
16229
|
-
dry_run:
|
|
16230
|
-
description: "Only say what would change; set no status"
|
|
16231
|
-
type: boolean
|
|
16232
|
-
default: false
|
|
16233
|
-
|
|
16234
|
-
permissions:
|
|
16235
|
-
contents: read
|
|
16236
|
-
|
|
16237
|
-
# One run at a time: two could set the same item twice.
|
|
16238
|
-
concurrency:
|
|
16239
|
-
group: project-reconcile
|
|
16240
|
-
cancel-in-progress: false
|
|
16241
|
-
|
|
16242
|
-
jobs:
|
|
16243
|
-
reconcile:
|
|
16244
|
-
name: Reconcile and check the boards
|
|
16245
|
-
runs-on: ubuntu-latest
|
|
16246
|
-
timeout-minutes: 15
|
|
16247
|
-
steps:
|
|
16248
|
-
# \`GITHUB_TOKEN\` cannot write an organization project, so the run uses the GitHub App's installation token.
|
|
16249
|
-
# The App needs the organization Projects permission (read and write), which setup cannot grant: a person does.
|
|
16250
|
-
- name: Generate GitHub App token
|
|
16251
|
-
id: app-token
|
|
16252
|
-
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
|
|
16253
|
-
with:
|
|
16254
|
-
app-id: \${{ secrets.${PROJECT_APP_SECRETS.id} }}
|
|
16255
|
-
private-key: \${{ secrets.${PROJECT_APP_SECRETS.privateKey} }}
|
|
16256
|
-
owner: ${owner}
|
|
16257
|
-
permission-organization-projects: write
|
|
16258
|
-
permission-issues: read
|
|
16259
|
-
permission-pull-requests: read
|
|
16260
|
-
|
|
16261
|
-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
16262
|
-
name: Checkout repository
|
|
16263
|
-
|
|
16264
|
-
- uses: theholocron/.github/.github/actions/setup@main
|
|
16265
|
-
name: Setup
|
|
16266
|
-
|
|
16267
|
-
- uses: theholocron/.github/.github/actions/holocron@main
|
|
16268
|
-
name: Reconcile the boards
|
|
16269
|
-
id: reconcile
|
|
16270
|
-
with:
|
|
16271
|
-
command: project reconcile
|
|
16272
|
-
args: >-
|
|
16273
|
-
\${{ inputs.dry_run && '--dry-run' || '' }}
|
|
16274
|
-
--token github=\${{ steps.app-token.outputs.token }}
|
|
16275
|
-
|
|
16276
|
-
- name: List what changed
|
|
16277
|
-
if: \${{ !cancelled() && steps.reconcile.outputs.log-file != '' }}
|
|
16278
|
-
env:
|
|
16279
|
-
LOG_FILE: \${{ steps.reconcile.outputs.log-file }}
|
|
16280
|
-
run: |
|
|
16281
|
-
{
|
|
16282
|
-
echo "### Project reconcile"
|
|
16283
|
-
echo '\`\`\`'
|
|
16284
|
-
cat "$LOG_FILE"
|
|
16285
|
-
echo '\`\`\`'
|
|
16286
|
-
} >> "$GITHUB_STEP_SUMMARY"
|
|
16287
|
-
|
|
16288
|
-
# What reconcile cannot fix: an item with no status, a board that differs from its template, a rule that is off, a
|
|
16289
|
-
# missing App permission. A failure here fails the run, and the run's failure reaches #alerts.
|
|
16290
|
-
- uses: theholocron/.github/.github/actions/holocron@main
|
|
16291
|
-
name: Check the boards
|
|
16292
|
-
if: \${{ !cancelled() }}
|
|
16293
|
-
with:
|
|
16294
|
-
command: doctor project
|
|
16295
|
-
args: >-
|
|
16296
|
-
--token github=\${{ steps.app-token.outputs.token }}
|
|
16297
|
-
`.replaceAll(" ", " ");
|
|
16298
|
-
}
|
|
16299
|
-
/**
|
|
16300
|
-
* The scheduled workflow that keeps the declared boards true (spec `command-project`, "Keeping a board true"): hourly
|
|
16301
|
-
* and on demand it runs `holocron project reconcile`, then `holocron doctor project`, with a token minted from the
|
|
16302
|
-
* GitHub App. Written only when `providers.projects` declares boards, and for the owner the boards belong to, so a repo
|
|
16303
|
-
* without boards gets no file. A generated file, so `probe generated check` compares it with the committed copy.
|
|
16304
|
-
*/
|
|
16305
|
-
function generateProjectWorkflowFiles(input) {
|
|
16306
|
-
const config = input.loaded.resolved;
|
|
16307
|
-
const entry = config.providers.projects;
|
|
16308
|
-
const tuple = entry?.cardinality === "single" ? entry.tuple : entry?.tuples[0];
|
|
16309
|
-
if (!tuple) return [];
|
|
16310
|
-
const resolved = resolveProjectOptions(tuple.options, config.org ?? "");
|
|
16311
|
-
if (!resolved.ok || resolved.options.boards.length === 0 || resolved.options.owner === "") return [];
|
|
16312
|
-
const pkgRelPath = resolvePkgRelPath(findRootSync(input.repoRoot, ".git", {
|
|
16313
|
-
fallback: "start",
|
|
16314
|
-
realpath: true
|
|
16315
|
-
}), input.loaded.filepath);
|
|
16316
|
-
return [{
|
|
16317
|
-
kind: "file",
|
|
16318
|
-
path: PROJECT_RECONCILE_WORKFLOW,
|
|
16319
|
-
content: `${workflowHeader$1()}# Source package: ${pkgRelPath}\n\n${workflow(resolved.options.owner)}`,
|
|
16320
|
-
step: "write workflow project reconcile",
|
|
16321
|
-
syncStep: "sync workflow project reconcile"
|
|
16322
|
-
}];
|
|
16323
|
-
}
|
|
16324
15762
|
// src/commands/repo-files/generate-turbo-files.ts
|
|
16325
15763
|
/**
|
|
16326
15764
|
* `turbo.json`, and the two edits that go with it: `turbo.json` alone is inert unless the root is a workspace member
|
|
@@ -16441,6 +15879,78 @@ const { workflowHeader } = createHeader({
|
|
|
16441
15879
|
function thinCallerFile(pkgRelPath, content) {
|
|
16442
15880
|
return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
|
|
16443
15881
|
}
|
|
15882
|
+
// src/commands/workflow-source-marker/workflow-source-marker.ts
|
|
15883
|
+
/** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
|
|
15884
|
+
const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
|
|
15885
|
+
/** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
|
|
15886
|
+
function sanitizeForDisplay(value) {
|
|
15887
|
+
return value.replace(/[\x00-\x1f\x7f]/g, "");
|
|
15888
|
+
}
|
|
15889
|
+
/**
|
|
15890
|
+
* Repo-root-relative path of the PACKAGE a workflow-writing command run is
|
|
15891
|
+
* scoped to — the directory holding the discovered `holocron.config.*`
|
|
15892
|
+
* (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
|
|
15893
|
+
* up to find the config from any subdirectory ("every command is usable
|
|
15894
|
+
* from any subdirectory of a repo, not only its exact root"), so a `--cwd`
|
|
15895
|
+
* one level too deep would otherwise stamp a different marker than a later
|
|
15896
|
+
* run from the package's own root and misfire the collision check this
|
|
15897
|
+
* feeds (holocron#1026).
|
|
15898
|
+
*
|
|
15899
|
+
* "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
|
|
15900
|
+
* to forward slashes so the same package produces the same marker on
|
|
15901
|
+
* Windows and POSIX. Throws if the result contains a line break — a path
|
|
15902
|
+
* containing one could otherwise break out of the `# Source package: `
|
|
15903
|
+
* comment line and inject arbitrary workflow YAML when the generated
|
|
15904
|
+
* content is later written. Not reachable through this CLI's own flows
|
|
15905
|
+
* (no code path writes a config file whose directory name contains a line
|
|
15906
|
+
* break), but cheap to reject outright rather than trust the filesystem.
|
|
15907
|
+
*/
|
|
15908
|
+
function resolvePkgRelPath(gitRoot, configFilepath) {
|
|
15909
|
+
let root;
|
|
15910
|
+
try {
|
|
15911
|
+
root = realpathSync(gitRoot);
|
|
15912
|
+
} catch {
|
|
15913
|
+
root = gitRoot;
|
|
15914
|
+
}
|
|
15915
|
+
let configDir;
|
|
15916
|
+
try {
|
|
15917
|
+
configDir = realpathSync(dirname(configFilepath));
|
|
15918
|
+
} catch {
|
|
15919
|
+
configDir = dirname(configFilepath);
|
|
15920
|
+
}
|
|
15921
|
+
const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
|
|
15922
|
+
if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
|
|
15923
|
+
return pkgRelPath;
|
|
15924
|
+
}
|
|
15925
|
+
/**
|
|
15926
|
+
* Two different monorepo packages opting into the same generic task name
|
|
15927
|
+
* (e.g. both `apps/sentinel` and some future `apps/other` configuring
|
|
15928
|
+
* `delivery.previewDeploy`) would otherwise overwrite each other's
|
|
15929
|
+
* `.github/workflows/<task>.yml` on whichever package's write ran last —
|
|
15930
|
+
* only one package's behavior would ever actually run in CI, with no
|
|
15931
|
+
* signal that the other's was silently dropped (holocron#1026).
|
|
15932
|
+
*
|
|
15933
|
+
* Shared by both `holocron repo sync` (reads the file straight off local
|
|
15934
|
+
* disk) and `holocron repo setup` (reads it through the loaded `Source`
|
|
15935
|
+
* capability, which happens to be local disk too for the github plugin
|
|
15936
|
+
* today, but the interface doesn't promise that for every provider —
|
|
15937
|
+
* holocron#1068). The marker-parsing and error message are identical
|
|
15938
|
+
* either way; `readExisting` is how the two callers differ.
|
|
15939
|
+
*
|
|
15940
|
+
* A file with no marker at all predates this check (or was written before
|
|
15941
|
+
* #1026) and is never flagged — only a marker that's present AND disagrees
|
|
15942
|
+
* with the current run's own package is a real collision. `readExisting`
|
|
15943
|
+
* returning `null` means "nothing there," not "unreadable" — a caller
|
|
15944
|
+
* whose underlying read can fail for reasons other than "doesn't exist"
|
|
15945
|
+
* (e.g. local fs EISDIR) is expected to let that error propagate out of
|
|
15946
|
+
* `readExisting` itself rather than mapping it to `null`.
|
|
15947
|
+
*/
|
|
15948
|
+
async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
|
|
15949
|
+
const existing = await readExisting();
|
|
15950
|
+
if (existing === null) return;
|
|
15951
|
+
const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
|
|
15952
|
+
if (previousPkg !== void 0 && previousPkg !== pkgRelPath) throw new Error(`task "${taskName}" would overwrite .github/workflows/${filename}, already generated for package "${sanitizeForDisplay(previousPkg)}" — the same task name can't be used by two different packages (holocron#1026). If "${sanitizeForDisplay(previousPkg)}" moved or was renamed to this path, delete .github/workflows/${filename} first and re-run this command; otherwise rename one or give it a different thin-caller filename.`);
|
|
15953
|
+
}
|
|
16444
15954
|
// src/commands/repo-files/generate-workflow-files.ts
|
|
16445
15955
|
/**
|
|
16446
15956
|
* The thin-caller workflow for each task in the manifest, in the manifest's order. A task with no template is a
|
|
@@ -16560,7 +16070,6 @@ function generateWorkflowFiles(input) {
|
|
|
16560
16070
|
async function generateRepoFiles(input) {
|
|
16561
16071
|
return [
|
|
16562
16072
|
...generateWorkflowFiles(input),
|
|
16563
|
-
...generateProjectWorkflowFiles(input),
|
|
16564
16073
|
...await generateConfigFiles(input),
|
|
16565
16074
|
...await generateAgentFiles(input),
|
|
16566
16075
|
...await generateTurboFiles(input)
|
|
@@ -17371,7 +16880,11 @@ const probeCommand = {
|
|
|
17371
16880
|
...argv.lcov ? { lcov: argv.lcov } : {},
|
|
17372
16881
|
dryRun: argv.dryRun,
|
|
17373
16882
|
yes: argv.yes,
|
|
17374
|
-
...process.stdin.isTTY ? { pick: (groups) => launchMenu
|
|
16883
|
+
...process.stdin.isTTY ? { pick: (groups) => launchMenu(buildProbeMenuEntries(groups), argv, {
|
|
16884
|
+
pickMessage: "probe — choose a provider:",
|
|
16885
|
+
nonInteractiveMessage: "Run `holocron probe` to list the probes.",
|
|
16886
|
+
startPath: ["probe"]
|
|
16887
|
+
}) } : {}
|
|
17375
16888
|
})).status === "fail") process.exitCode = 1;
|
|
17376
16889
|
}
|
|
17377
16890
|
};
|
|
@@ -21396,7 +20909,8 @@ const runCommand = {
|
|
|
21396
20909
|
describe: "Run a task or a suite locally (`test`, `test unit`, `typecheck`, `lint`, `build`, `format`) — figures out turbo / the tool / the package manager. `run ci` runs every merge-gating check; `run lint commit-msg <file>` lints a commit message.",
|
|
21397
20910
|
builder: runArgs,
|
|
21398
20911
|
handler: async (argv) => {
|
|
21399
|
-
const
|
|
20912
|
+
const commandKey = argv.task === "ci" ? "run ci" : argv.task === "lint" && argv.job === "commit-msg" ? "run lint commit-msg" : "run";
|
|
20913
|
+
const { logger } = buildCliLogger(argv, { command: commandKey });
|
|
21400
20914
|
const args = argv.passthrough ?? [];
|
|
21401
20915
|
const passthrough = argv["--"] ?? [];
|
|
21402
20916
|
if (argv.task === "lint" && argv.job === "commit-msg") {
|
|
@@ -23084,11 +22598,6 @@ const tunnelCommand = {
|
|
|
23084
22598
|
builder: (y) => y.command(tunnelUpCommand).command(groupMenu$1("tunnel")),
|
|
23085
22599
|
handler: () => {}
|
|
23086
22600
|
};
|
|
23087
|
-
// src/retry-notice/retry-notice.ts
|
|
23088
|
-
/** Says on the spinner when a request is being sent again, so a slow step is not mistaken for a stuck one. */
|
|
23089
|
-
const retryNotice = (label, setText) => onRetry((e) => {
|
|
23090
|
-
setText(`${label} (retrying ${e.vendor ?? "the request"}, attempt ${e.attempt} of ${e.of})`);
|
|
23091
|
-
});
|
|
23092
22601
|
// src/cli.ts
|
|
23093
22602
|
const env = createEnvLookup();
|
|
23094
22603
|
const { name: CLI_PACKAGE_NAME, version: CLI_VERSION } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
@@ -23104,7 +22613,7 @@ const USER_FACING_ERRORS = /* @__PURE__ */ new Set([
|
|
|
23104
22613
|
/** Whether to print the correlation id at command end (`--debug` / `--verbose`). */
|
|
23105
22614
|
let printRunId = false;
|
|
23106
22615
|
init(CLI_VERSION);
|
|
23107
|
-
setProgressListener(
|
|
22616
|
+
setProgressListener(createRetryNotice(onRetry));
|
|
23108
22617
|
const updateCheckPromise = checkForUpdates({
|
|
23109
22618
|
name: CLI_PACKAGE_NAME,
|
|
23110
22619
|
currentVersion: CLI_VERSION,
|