@theholocron/cli 5.0.0-alpha.342 → 5.0.0-alpha.344
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 +4 -5
- package/dist/cli.mjs +101 -392
- package/dist/cli.mjs.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -812,11 +812,10 @@ the local override exists to exempt.
|
|
|
812
812
|
`notifications channel add`, `notifications link`,
|
|
813
813
|
`notifications sync-roles`, `doctor ci`, `doctor credentials`, `doctor dns`, `doctor environments`, `doctor monitoring`, `doctor notifications`, `doctor project`, `doctor repo`, `doctor secrets`, `doctor tokens`, `doctor variables`
|
|
814
814
|
`notifications sync-roles`, `project reconcile`, `doctor ci`, `doctor credentials`, `doctor dns`, `doctor environments`, `doctor monitoring`, `doctor notifications`, `doctor repo`, `doctor secrets`, `doctor tokens`, `doctor variables`
|
|
815
|
-
- `src/commands/
|
|
816
|
-
renderer and `declaredVsActual` helper
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
(`COMMAND_REGISTRY`, each entry's `positionals`/`options`), `run-menu-entries`
|
|
815
|
+
- `src/commands/deep-checks/` — `DEEP_CHECKS`, the registry every `doctor <capability>` is
|
|
816
|
+
listed in; the shared row renderer and `declaredVsActual` helper are in `@theholocron/kyber/ui`
|
|
817
|
+
- `src/interactive-menu/` — the interactive fallback's Holocron data: `command-catalog`
|
|
818
|
+
(`COMMAND_REGISTRY`, built with kyber's `createCommandRegistry`; each entry's `positionals`/`options`), `run-menu-entries`
|
|
820
819
|
and `probe-menu-entries` (menu entries built at run time), and `menu.ts`,
|
|
821
820
|
kyber's `createMenu` bound to the `holocron` bin and `HOLOCRON_` env prefix.
|
|
822
821
|
The engine itself (the picker, argv and secret env, the dry-run preview, the spawn)
|
package/dist/cli.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import {
|
|
3
|
+
import { copyFileSync, existsSync, fstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
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
7
|
import { ProviderApiError, ProviderApiError as ProviderApiError$1, createRestClient, onRetry } from "@theholocron/http-client";
|
|
8
8
|
import { addGlobalOptions, groupMenu, tokenContext } from "@theholocron/kyber/flags";
|
|
9
9
|
import { checkForUpdates } from "@theholocron/kyber/notifier";
|
|
10
|
-
import { NonInteractiveError, commandFailureMessage, createProgress, createRetryNotice, describeError, logReason, openPath, pad, sanitizeDetail, setProgressListener, statusRow, stripControl, style,
|
|
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
11
|
import { LOG_LEVELS } from "@theholocron/observability/core";
|
|
12
12
|
import yargs from "yargs";
|
|
13
13
|
import { hideBin } from "yargs/helpers";
|
|
@@ -19,16 +19,16 @@ import { bumpCatalogPins, discoverWorkspacePackages, parseCatalogs, readPackageJ
|
|
|
19
19
|
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
20
20
|
import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
21
21
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
22
|
-
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, hasCredentials, isGitIgnored, readDotenvFile, setCredentials,
|
|
22
|
+
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver, createKeyring, dotenvLine, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
23
23
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
24
24
|
import { pathToFileURL } from "node:url";
|
|
25
|
-
import { DRY_RUN_NOOP_EXIT_CODE, createMenu } from "@theholocron/kyber/menu";
|
|
25
|
+
import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
|
|
26
26
|
import { promptForPositionals } from "@theholocron/kyber/prompts";
|
|
27
27
|
import { Separator, checkbox, confirm, input, select } from "@inquirer/prompts";
|
|
28
28
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
29
29
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
30
30
|
import { findRootSync, isWorkspaceRoot, walkFilesSync } from "@theholocron/fs-utils";
|
|
31
|
-
import { serveHandler } from "@theholocron/dagobah";
|
|
31
|
+
import { serveHandler, superviseProcesses } from "@theholocron/dagobah";
|
|
32
32
|
import { access, copyFile, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
33
33
|
import { createHash, createHmac, randomBytes, randomUUID } from "node:crypto";
|
|
34
34
|
import { createServer } from "node:http";
|
|
@@ -1449,53 +1449,6 @@ async function tryLoadHint(importer, packageName) {
|
|
|
1449
1449
|
function tokenContext$1(rawTokens) {
|
|
1450
1450
|
return tokenContext(rawTokens, reportError);
|
|
1451
1451
|
}
|
|
1452
|
-
// src/commands/doctor-checks/declared-vs-actual.ts
|
|
1453
|
-
/**
|
|
1454
|
-
* Compares what the config declares with what exists, both as maps by key, and returns one problem line per
|
|
1455
|
-
* difference: a declared key that is missing, a key found but not declared, a key whose values disagree.
|
|
1456
|
-
* An empty list means they match. A deep check is then a list of these comparisons, not a renderer of its own.
|
|
1457
|
-
*/
|
|
1458
|
-
function declaredVsActual(declared, actual, options) {
|
|
1459
|
-
const equal = options.equal ?? ((a, b) => a === b);
|
|
1460
|
-
const show = options.show ?? ((value) => String(value));
|
|
1461
|
-
const problems = [];
|
|
1462
|
-
for (const [key, want] of declared) {
|
|
1463
|
-
if (!actual.has(key)) {
|
|
1464
|
-
problems.push(`missing ${options.noun} ${key}`);
|
|
1465
|
-
continue;
|
|
1466
|
-
}
|
|
1467
|
-
const found = actual.get(key);
|
|
1468
|
-
if (!equal(want, found)) problems.push(`${options.noun} ${key}: declared ${show(want)}, found ${show(found)}`);
|
|
1469
|
-
}
|
|
1470
|
-
if (options.flagExtra !== false) {
|
|
1471
|
-
for (const key of actual.keys()) if (!declared.has(key)) problems.push(`unexpected ${options.noun} ${key}`);
|
|
1472
|
-
}
|
|
1473
|
-
return problems;
|
|
1474
|
-
}
|
|
1475
|
-
// src/commands/doctor-checks/print-check-rows.ts
|
|
1476
|
-
/** One row per step, titles padded to the widest, each problem on its own indented line. */
|
|
1477
|
-
function printCheckRows(rows, print) {
|
|
1478
|
-
const width = Math.max(0, ...rows.map((row) => row.title.length));
|
|
1479
|
-
for (const row of rows) {
|
|
1480
|
-
print(statusRow(row.status, [row.title.padEnd(width), row.detail]));
|
|
1481
|
-
for (const problem of row.problems) print(` - ${problem}`);
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
// src/commands/doctor-checks/print-check-summary.ts
|
|
1485
|
-
/** A blank line, then the closing `N ok, N fail, N skipped`. */
|
|
1486
|
-
function printCheckSummary(summary, print) {
|
|
1487
|
-
print("");
|
|
1488
|
-
print(style.header(`${summary.ok} ok, ${summary.fail} fail, ${summary.skip} skipped`));
|
|
1489
|
-
}
|
|
1490
|
-
// src/commands/doctor-checks/summarise-checks.ts
|
|
1491
|
-
/** How many rows ended each way. */
|
|
1492
|
-
function summariseChecks(rows) {
|
|
1493
|
-
return {
|
|
1494
|
-
ok: rows.filter((r) => r.status === "ok").length,
|
|
1495
|
-
fail: rows.filter((r) => r.status === "fail").length,
|
|
1496
|
-
skip: rows.filter((r) => r.status === "skip").length
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
1452
|
const DAY_MS = 864e5;
|
|
1500
1453
|
/**
|
|
1501
1454
|
* How long a token has left, as `expires in 12 days`, and whether that is inside the warning window.
|
|
@@ -1619,56 +1572,6 @@ const doctorTokensCommand = {
|
|
|
1619
1572
|
})).status === "fail") process.exitCode = 1;
|
|
1620
1573
|
}
|
|
1621
1574
|
};
|
|
1622
|
-
// src/commands/finish-credentials-file/finish-credentials-file.ts
|
|
1623
|
-
/** Signals that end the wait for the import, with the exit status each is conventionally reported as. */
|
|
1624
|
-
const INTERRUPTS = [
|
|
1625
|
-
["SIGINT", 130],
|
|
1626
|
-
["SIGTERM", 143],
|
|
1627
|
-
["SIGHUP", 129]
|
|
1628
|
-
];
|
|
1629
|
-
/**
|
|
1630
|
-
* Once the lines are in the private file, says what to do with it and, on a terminal, deletes it when the import is
|
|
1631
|
-
* done. Returns whether the file is gone (or was left on purpose): `false` means plaintext secrets are still on disk.
|
|
1632
|
-
*/
|
|
1633
|
-
async function finishCredentialsFile(input) {
|
|
1634
|
-
const { path, identity, print } = input;
|
|
1635
|
-
print(`wrote ${path} (readable only by you)`);
|
|
1636
|
-
print(input.importHint);
|
|
1637
|
-
if (input.keep || !input.interactive) {
|
|
1638
|
-
closeSync(identity.fd);
|
|
1639
|
-
print(`it holds ${input.holds} in plain text: delete it when you are done: ${path}`);
|
|
1640
|
-
return true;
|
|
1641
|
-
}
|
|
1642
|
-
const cleanup = () => {
|
|
1643
|
-
try {
|
|
1644
|
-
const outcome = (input.shred ?? shredFile)(path, identity);
|
|
1645
|
-
if (outcome === "deleted") print(`deleted ${path}`);
|
|
1646
|
-
else if (outcome === "missing") print(`${path} was already gone`);
|
|
1647
|
-
else print(`left ${path} alone: it is no longer the file this command wrote`);
|
|
1648
|
-
return true;
|
|
1649
|
-
} catch (err) {
|
|
1650
|
-
print(`could not delete ${path}: ${errorMessage(err)}`);
|
|
1651
|
-
print(`it holds ${input.holds} in plain text: delete it yourself: ${path}`);
|
|
1652
|
-
return false;
|
|
1653
|
-
}
|
|
1654
|
-
};
|
|
1655
|
-
const handlers = INTERRUPTS.map(([signal, code]) => {
|
|
1656
|
-
const handler = () => {
|
|
1657
|
-
cleanup();
|
|
1658
|
-
process.exit(code);
|
|
1659
|
-
};
|
|
1660
|
-
process.once(signal, handler);
|
|
1661
|
-
return [signal, handler];
|
|
1662
|
-
});
|
|
1663
|
-
let cleaned;
|
|
1664
|
-
try {
|
|
1665
|
-
await (input.waitForImport ?? waitForEnter)("press Enter when the import is done and the file will be deleted: ");
|
|
1666
|
-
} finally {
|
|
1667
|
-
for (const [signal, handler] of handlers) process.off(signal, handler);
|
|
1668
|
-
cleaned = cleanup();
|
|
1669
|
-
}
|
|
1670
|
-
return cleaned;
|
|
1671
|
-
}
|
|
1672
1575
|
// src/commands/auth-export/auth-export.ts
|
|
1673
1576
|
/**
|
|
1674
1577
|
* `holocron auth export` — print the tokens a configured plugin takes as `NAME=value` lines, to move them into a
|
|
@@ -2018,8 +1921,6 @@ const authExportEntry = {
|
|
|
2018
1921
|
positionals: [],
|
|
2019
1922
|
supportsDryRun: false
|
|
2020
1923
|
};
|
|
2021
|
-
// src/interactive-menu/command-registry/validators.ts
|
|
2022
|
-
const numeric = (value) => /^\d+$/.test(value) ? true : "enter a number";
|
|
2023
1924
|
// src/commands/cleanup-preview/cleanup-preview.entry.ts
|
|
2024
1925
|
const cleanupPreviewEntry = {
|
|
2025
1926
|
name: "deploy cleanup-preview",
|
|
@@ -2451,7 +2352,7 @@ const PUBLISH_OTP_OPTION = {
|
|
|
2451
2352
|
required: Boolean(env$6.get("HOLOCRON_NPM_ENFORCE_2FA")),
|
|
2452
2353
|
message: "One-time password (2FA), if npm requires it for this publish:"
|
|
2453
2354
|
};
|
|
2454
|
-
// src/interactive-menu/command-
|
|
2355
|
+
// src/interactive-menu/command-catalog/command-catalog.ts
|
|
2455
2356
|
/**
|
|
2456
2357
|
* The full command surface for the interactive menu. Each entry lives next to the command it describes
|
|
2457
2358
|
* (`commands/<name>/<name>.entry.ts`) and is listed here in menu order; this module does not introspect yargs at runtime.
|
|
@@ -2462,7 +2363,7 @@ const PUBLISH_OTP_OPTION = {
|
|
|
2462
2363
|
* `run lint commit-msg <file>` stays excluded entirely: it's invoked exclusively from `.husky/commit-msg "$1"`, never
|
|
2463
2364
|
* typed by a human.
|
|
2464
2365
|
*/
|
|
2465
|
-
const
|
|
2366
|
+
const registry = createCommandRegistry([
|
|
2466
2367
|
cloneEntry,
|
|
2467
2368
|
doctorEntry,
|
|
2468
2369
|
doctorAllEntry,
|
|
@@ -2771,13 +2672,11 @@ const COMMAND_REGISTRY = [
|
|
|
2771
2672
|
projectCloseEntry,
|
|
2772
2673
|
projectSetupEntry,
|
|
2773
2674
|
projectReconcileEntry
|
|
2774
|
-
];
|
|
2775
|
-
/**
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
return entry;
|
|
2780
|
-
}
|
|
2675
|
+
], "interactive-menu");
|
|
2676
|
+
/** Every Holocron command, in menu order: what {@link launchMenu} lists and what a leaf handler's prompt reads. */
|
|
2677
|
+
const COMMAND_REGISTRY = registry.entries;
|
|
2678
|
+
/** Look up a command's menu entry by its full name — for Layer 3 call sites in `cli.ts`. */
|
|
2679
|
+
const getEntry = registry.getEntry;
|
|
2781
2680
|
// src/interactive-menu/menu.ts
|
|
2782
2681
|
/**
|
|
2783
2682
|
* Kyber's menu engine bound to `holocron`: secret options travel as `HOLOCRON_<OPTION>` env vars and the
|
|
@@ -4045,76 +3944,6 @@ function resolveDevOptions(flags, config, self = [process.execPath, process.argv
|
|
|
4045
3944
|
command
|
|
4046
3945
|
};
|
|
4047
3946
|
}
|
|
4048
|
-
// src/commands/run-dev-processes/run-dev-processes.ts
|
|
4049
|
-
/**
|
|
4050
|
-
* Runs the application and the tunnel's connector side by side in the foreground, with their output on the terminal,
|
|
4051
|
-
* and stops the other when either ends. Ctrl-C and a termination signal go to both and are not a failure. A process
|
|
4052
|
-
* that cannot be started stops the other and rejects, saying which program it was.
|
|
4053
|
-
*/
|
|
4054
|
-
function runDevProcesses(input) {
|
|
4055
|
-
return new Promise((resolve, reject) => {
|
|
4056
|
-
const spawnImpl = input.spawn ?? spawn;
|
|
4057
|
-
const start = (p) => spawnImpl(p.command, p.args, {
|
|
4058
|
-
stdio: "inherit",
|
|
4059
|
-
env: {
|
|
4060
|
-
...process.env,
|
|
4061
|
-
...p.env
|
|
4062
|
-
}
|
|
4063
|
-
});
|
|
4064
|
-
const children = {
|
|
4065
|
-
app: start(input.app),
|
|
4066
|
-
connector: start(input.connector)
|
|
4067
|
-
};
|
|
4068
|
-
const names = ["app", "connector"];
|
|
4069
|
-
let endedFirst;
|
|
4070
|
-
let status = 0;
|
|
4071
|
-
let interrupted = false;
|
|
4072
|
-
let done = false;
|
|
4073
|
-
const ended = /* @__PURE__ */ new Set();
|
|
4074
|
-
const signals = ["SIGINT", "SIGTERM"].map((signal) => {
|
|
4075
|
-
const handler = () => {
|
|
4076
|
-
interrupted = true;
|
|
4077
|
-
for (const child of Object.values(children)) child.kill(signal);
|
|
4078
|
-
};
|
|
4079
|
-
process.on(signal, handler);
|
|
4080
|
-
return [signal, handler];
|
|
4081
|
-
});
|
|
4082
|
-
const cleanUp = () => {
|
|
4083
|
-
for (const [signal, handler] of signals) process.off(signal, handler);
|
|
4084
|
-
};
|
|
4085
|
-
const stopAll = () => {
|
|
4086
|
-
for (const child of Object.values(children)) child.kill("SIGTERM");
|
|
4087
|
-
};
|
|
4088
|
-
for (const name of names) {
|
|
4089
|
-
const other = name === "app" ? "connector" : "app";
|
|
4090
|
-
children[name].once("error", (err) => {
|
|
4091
|
-
if (done) return;
|
|
4092
|
-
done = true;
|
|
4093
|
-
cleanUp();
|
|
4094
|
-
stopAll();
|
|
4095
|
-
const program = input[name].command;
|
|
4096
|
-
reject(/* @__PURE__ */ new Error(err.code === "ENOENT" ? `${program} is not installed or not on the PATH` : `could not start ${program}: ${err.message}`));
|
|
4097
|
-
});
|
|
4098
|
-
children[name].once("exit", (code) => {
|
|
4099
|
-
ended.add(name);
|
|
4100
|
-
if (endedFirst === void 0) {
|
|
4101
|
-
endedFirst = name;
|
|
4102
|
-
status = code ?? 1;
|
|
4103
|
-
children[other].kill("SIGTERM");
|
|
4104
|
-
}
|
|
4105
|
-
if (ended.size === names.length && !done) {
|
|
4106
|
-
done = true;
|
|
4107
|
-
cleanUp();
|
|
4108
|
-
resolve({
|
|
4109
|
-
exitCode: interrupted ? 0 : status,
|
|
4110
|
-
endedFirst,
|
|
4111
|
-
interrupted
|
|
4112
|
-
});
|
|
4113
|
-
}
|
|
4114
|
-
});
|
|
4115
|
-
}
|
|
4116
|
-
});
|
|
4117
|
-
}
|
|
4118
3947
|
// src/commands/run-cloudflared/run-cloudflared.ts
|
|
4119
3948
|
/**
|
|
4120
3949
|
* Runs `cloudflared tunnel run` in the foreground and resolves with its exit status. The tunnel's token goes to the
|
|
@@ -4313,6 +4142,13 @@ const tunnelUpCommand = {
|
|
|
4313
4142
|
}
|
|
4314
4143
|
};
|
|
4315
4144
|
// src/commands/dev/dev.ts
|
|
4145
|
+
/**
|
|
4146
|
+
* `holocron dev` — run an application locally behind its development tunnel, in one command.
|
|
4147
|
+
*
|
|
4148
|
+
* The vault environment's variables are read in memory and handed to the application's process, never written to
|
|
4149
|
+
* disk or printed (only how many there are). The tunnel and its DNS record are set up the way `holocron tunnel up`
|
|
4150
|
+
* does, and the tunnel's connector runs beside the application; Ctrl-C stops both.
|
|
4151
|
+
*/
|
|
4316
4152
|
const COMMAND$6 = "dev";
|
|
4317
4153
|
/** The environment the application is told it runs in, which its logger tags every line with. */
|
|
4318
4154
|
const APP_ENVIRONMENT = "development";
|
|
@@ -4394,8 +4230,8 @@ async function runDev(input) {
|
|
|
4394
4230
|
print(`running ${shown} and cloudflared (Ctrl-C stops both): ${tunnel.url} to localhost:${input.port}`);
|
|
4395
4231
|
let exitCode;
|
|
4396
4232
|
try {
|
|
4397
|
-
({exitCode} = await (input.runProcesses ??
|
|
4398
|
-
|
|
4233
|
+
({exitCode} = await (input.runProcesses ?? superviseProcesses)({
|
|
4234
|
+
primary: {
|
|
4399
4235
|
command: program,
|
|
4400
4236
|
args,
|
|
4401
4237
|
env: {
|
|
@@ -4404,7 +4240,7 @@ async function runDev(input) {
|
|
|
4404
4240
|
PORT: String(input.port)
|
|
4405
4241
|
}
|
|
4406
4242
|
},
|
|
4407
|
-
|
|
4243
|
+
companion: {
|
|
4408
4244
|
command: "cloudflared",
|
|
4409
4245
|
args: [
|
|
4410
4246
|
"tunnel",
|
|
@@ -8338,9 +8174,6 @@ const BUILTIN_TEMPLATES = {
|
|
|
8338
8174
|
"2 · Next",
|
|
8339
8175
|
"3 · Process"
|
|
8340
8176
|
]
|
|
8341
|
-
}, {
|
|
8342
|
-
name: "Milestone",
|
|
8343
|
-
type: "text"
|
|
8344
8177
|
}],
|
|
8345
8178
|
views: [
|
|
8346
8179
|
{
|
|
@@ -9296,8 +9129,9 @@ function repoChecks(config, repoRoot) {
|
|
|
9296
9129
|
const declared = /* @__PURE__ */ new Map();
|
|
9297
9130
|
if (config.description) declared.set("description", config.description);
|
|
9298
9131
|
if (config.homepage) declared.set("homepage", config.homepage);
|
|
9132
|
+
const actual = /* @__PURE__ */ new Map([["description", info.description ?? ""], ["homepage", info.homepage ?? ""]]);
|
|
9299
9133
|
return {
|
|
9300
|
-
problems: declaredVsActual(declared,
|
|
9134
|
+
problems: declaredVsActual(declared, actual, {
|
|
9301
9135
|
noun: "repository field",
|
|
9302
9136
|
flagExtra: false,
|
|
9303
9137
|
show: quote
|
|
@@ -9314,8 +9148,9 @@ function repoChecks(config, repoRoot) {
|
|
|
9314
9148
|
const info = await source.getRepoInfo();
|
|
9315
9149
|
const declared = new Map(Object.entries(preset ? BALANCED_REPO_SETTINGS : {}));
|
|
9316
9150
|
if (repo?.defaultBranch) declared.set("default_branch", repo.defaultBranch);
|
|
9151
|
+
const actual = new Map(Object.entries(info.settings));
|
|
9317
9152
|
return {
|
|
9318
|
-
problems: declaredVsActual(declared,
|
|
9153
|
+
problems: declaredVsActual(declared, actual, {
|
|
9319
9154
|
noun: "repository setting",
|
|
9320
9155
|
flagExtra: false,
|
|
9321
9156
|
show: quote
|
|
@@ -15862,7 +15697,7 @@ function hooksEnabled(input) {
|
|
|
15862
15697
|
return config.repo?.protection === "strict";
|
|
15863
15698
|
}
|
|
15864
15699
|
// src/commands/repo-files/generate-config-files.ts
|
|
15865
|
-
const { workflowHeader: workflowHeader$
|
|
15700
|
+
const { workflowHeader: workflowHeader$1 } = createHeader({
|
|
15866
15701
|
source: "cli/cli/src/commands/repo-files/generate-config-files.ts",
|
|
15867
15702
|
tool: "holocron repo setup"
|
|
15868
15703
|
});
|
|
@@ -15887,7 +15722,7 @@ async function generateConfigFiles(input) {
|
|
|
15887
15722
|
const taskNames = (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name);
|
|
15888
15723
|
const entries = [];
|
|
15889
15724
|
if (taskNames.includes("bookkeeping")) entries.push(file(".github/labeler.yml", createLabeler()));
|
|
15890
|
-
if (config.repo?.protection !== "none") entries.push(file(".github/dependabot.yml", createDependabot({ ignore: ownCatalogPackages(input.repoRoot) })), file(".github/dco.yml", `${workflowHeader$
|
|
15725
|
+
if (config.repo?.protection !== "none") entries.push(file(".github/dependabot.yml", createDependabot({ ignore: ownCatalogPackages(input.repoRoot) })), file(".github/dco.yml", `${workflowHeader$1()}${dco_default}`));
|
|
15891
15726
|
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)));
|
|
15892
15727
|
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"));
|
|
15893
15728
|
else for (const hook of [".husky/pre-push", ".husky/pre-commit"]) entries.push({
|
|
@@ -15920,203 +15755,6 @@ async function generateConfigFiles(input) {
|
|
|
15920
15755
|
}
|
|
15921
15756
|
return entries;
|
|
15922
15757
|
}
|
|
15923
|
-
// src/commands/workflow-source-marker/workflow-source-marker.ts
|
|
15924
|
-
/** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
|
|
15925
|
-
const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
|
|
15926
|
-
/** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
|
|
15927
|
-
function sanitizeForDisplay(value) {
|
|
15928
|
-
return value.replace(/[\x00-\x1f\x7f]/g, "");
|
|
15929
|
-
}
|
|
15930
|
-
/**
|
|
15931
|
-
* Repo-root-relative path of the PACKAGE a workflow-writing command run is
|
|
15932
|
-
* scoped to — the directory holding the discovered `holocron.config.*`
|
|
15933
|
-
* (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
|
|
15934
|
-
* up to find the config from any subdirectory ("every command is usable
|
|
15935
|
-
* from any subdirectory of a repo, not only its exact root"), so a `--cwd`
|
|
15936
|
-
* one level too deep would otherwise stamp a different marker than a later
|
|
15937
|
-
* run from the package's own root and misfire the collision check this
|
|
15938
|
-
* feeds (holocron#1026).
|
|
15939
|
-
*
|
|
15940
|
-
* "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
|
|
15941
|
-
* to forward slashes so the same package produces the same marker on
|
|
15942
|
-
* Windows and POSIX. Throws if the result contains a line break — a path
|
|
15943
|
-
* containing one could otherwise break out of the `# Source package: `
|
|
15944
|
-
* comment line and inject arbitrary workflow YAML when the generated
|
|
15945
|
-
* content is later written. Not reachable through this CLI's own flows
|
|
15946
|
-
* (no code path writes a config file whose directory name contains a line
|
|
15947
|
-
* break), but cheap to reject outright rather than trust the filesystem.
|
|
15948
|
-
*/
|
|
15949
|
-
function resolvePkgRelPath(gitRoot, configFilepath) {
|
|
15950
|
-
let root;
|
|
15951
|
-
try {
|
|
15952
|
-
root = realpathSync(gitRoot);
|
|
15953
|
-
} catch {
|
|
15954
|
-
root = gitRoot;
|
|
15955
|
-
}
|
|
15956
|
-
let configDir;
|
|
15957
|
-
try {
|
|
15958
|
-
configDir = realpathSync(dirname(configFilepath));
|
|
15959
|
-
} catch {
|
|
15960
|
-
configDir = dirname(configFilepath);
|
|
15961
|
-
}
|
|
15962
|
-
const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
|
|
15963
|
-
if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
|
|
15964
|
-
return pkgRelPath;
|
|
15965
|
-
}
|
|
15966
|
-
/**
|
|
15967
|
-
* Two different monorepo packages opting into the same generic task name
|
|
15968
|
-
* (e.g. both `apps/sentinel` and some future `apps/other` configuring
|
|
15969
|
-
* `delivery.previewDeploy`) would otherwise overwrite each other's
|
|
15970
|
-
* `.github/workflows/<task>.yml` on whichever package's write ran last —
|
|
15971
|
-
* only one package's behavior would ever actually run in CI, with no
|
|
15972
|
-
* signal that the other's was silently dropped (holocron#1026).
|
|
15973
|
-
*
|
|
15974
|
-
* Shared by both `holocron repo sync` (reads the file straight off local
|
|
15975
|
-
* disk) and `holocron repo setup` (reads it through the loaded `Source`
|
|
15976
|
-
* capability, which happens to be local disk too for the github plugin
|
|
15977
|
-
* today, but the interface doesn't promise that for every provider —
|
|
15978
|
-
* holocron#1068). The marker-parsing and error message are identical
|
|
15979
|
-
* either way; `readExisting` is how the two callers differ.
|
|
15980
|
-
*
|
|
15981
|
-
* A file with no marker at all predates this check (or was written before
|
|
15982
|
-
* #1026) and is never flagged — only a marker that's present AND disagrees
|
|
15983
|
-
* with the current run's own package is a real collision. `readExisting`
|
|
15984
|
-
* returning `null` means "nothing there," not "unreadable" — a caller
|
|
15985
|
-
* whose underlying read can fail for reasons other than "doesn't exist"
|
|
15986
|
-
* (e.g. local fs EISDIR) is expected to let that error propagate out of
|
|
15987
|
-
* `readExisting` itself rather than mapping it to `null`.
|
|
15988
|
-
*/
|
|
15989
|
-
async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
|
|
15990
|
-
const existing = await readExisting();
|
|
15991
|
-
if (existing === null) return;
|
|
15992
|
-
const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
|
|
15993
|
-
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.`);
|
|
15994
|
-
}
|
|
15995
|
-
// src/commands/repo-files/generate-project-workflow-files.ts
|
|
15996
|
-
/** Where the scheduled reconcile workflow is written. */
|
|
15997
|
-
const PROJECT_RECONCILE_WORKFLOW = ".github/workflows/platform.projectReconcile.yml";
|
|
15998
|
-
/**
|
|
15999
|
-
* The workflow's own name. `platform.notifications.yml` lists it under `workflow_run`, so a run that fails on the
|
|
16000
|
-
* default branch posts to #alerts with the gatekeepers ping.
|
|
16001
|
-
*/
|
|
16002
|
-
const PROJECT_RECONCILE_NAME = "Project reconcile";
|
|
16003
|
-
/** The Actions secrets that hold the GitHub App's id and private key the run mints its installation token from. */
|
|
16004
|
-
const PROJECT_APP_SECRETS = {
|
|
16005
|
-
id: "SENTINEL_APP_ID",
|
|
16006
|
-
privateKey: "SENTINEL_APP_PRIVATE_KEY"
|
|
16007
|
-
};
|
|
16008
|
-
const { workflowHeader: workflowHeader$1 } = createHeader({
|
|
16009
|
-
source: "cli/cli/src/commands/repo-files/generate-project-workflow-files.ts",
|
|
16010
|
-
tool: "holocron repo sync"
|
|
16011
|
-
});
|
|
16012
|
-
/**
|
|
16013
|
-
* The workflow as YAML. Its nesting is written with tabs here, one tab for each two spaces of the file, and turned into spaces
|
|
16014
|
-
* when it is rendered: a source line that starts with spaces fails the editorconfig check, and the autofix that answers
|
|
16015
|
-
* it rewrites the YAML into tabs, which YAML does not allow.
|
|
16016
|
-
*/
|
|
16017
|
-
function workflow(owner) {
|
|
16018
|
-
return `name: ${PROJECT_RECONCILE_NAME}
|
|
16019
|
-
|
|
16020
|
-
on: # yamllint disable-line rule:truthy
|
|
16021
|
-
schedule:
|
|
16022
|
-
- cron: "23 * * * *"
|
|
16023
|
-
workflow_dispatch:
|
|
16024
|
-
inputs:
|
|
16025
|
-
dry_run:
|
|
16026
|
-
description: "Only say what would change; set no status"
|
|
16027
|
-
type: boolean
|
|
16028
|
-
default: false
|
|
16029
|
-
|
|
16030
|
-
permissions:
|
|
16031
|
-
contents: read
|
|
16032
|
-
|
|
16033
|
-
# One run at a time: two could set the same item twice.
|
|
16034
|
-
concurrency:
|
|
16035
|
-
group: project-reconcile
|
|
16036
|
-
cancel-in-progress: false
|
|
16037
|
-
|
|
16038
|
-
jobs:
|
|
16039
|
-
reconcile:
|
|
16040
|
-
name: Reconcile and check the boards
|
|
16041
|
-
runs-on: ubuntu-latest
|
|
16042
|
-
timeout-minutes: 15
|
|
16043
|
-
steps:
|
|
16044
|
-
# \`GITHUB_TOKEN\` cannot write an organization project, so the run uses the GitHub App's installation token.
|
|
16045
|
-
# The App needs the organization Projects permission (read and write), which setup cannot grant: a person does.
|
|
16046
|
-
- name: Generate GitHub App token
|
|
16047
|
-
id: app-token
|
|
16048
|
-
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
|
|
16049
|
-
with:
|
|
16050
|
-
app-id: \${{ secrets.${PROJECT_APP_SECRETS.id} }}
|
|
16051
|
-
private-key: \${{ secrets.${PROJECT_APP_SECRETS.privateKey} }}
|
|
16052
|
-
owner: ${owner}
|
|
16053
|
-
permission-organization-projects: write
|
|
16054
|
-
permission-issues: read
|
|
16055
|
-
permission-pull-requests: read
|
|
16056
|
-
|
|
16057
|
-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
16058
|
-
name: Checkout repository
|
|
16059
|
-
|
|
16060
|
-
- uses: theholocron/.github/.github/actions/setup@main
|
|
16061
|
-
name: Setup
|
|
16062
|
-
|
|
16063
|
-
- uses: theholocron/.github/.github/actions/holocron@main
|
|
16064
|
-
name: Reconcile the boards
|
|
16065
|
-
id: reconcile
|
|
16066
|
-
with:
|
|
16067
|
-
command: project reconcile
|
|
16068
|
-
args: >-
|
|
16069
|
-
\${{ inputs.dry_run && '--dry-run' || '' }}
|
|
16070
|
-
--token github=\${{ steps.app-token.outputs.token }}
|
|
16071
|
-
|
|
16072
|
-
- name: List what changed
|
|
16073
|
-
if: \${{ !cancelled() && steps.reconcile.outputs.log-file != '' }}
|
|
16074
|
-
env:
|
|
16075
|
-
LOG_FILE: \${{ steps.reconcile.outputs.log-file }}
|
|
16076
|
-
run: |
|
|
16077
|
-
{
|
|
16078
|
-
echo "### Project reconcile"
|
|
16079
|
-
echo '\`\`\`'
|
|
16080
|
-
cat "$LOG_FILE"
|
|
16081
|
-
echo '\`\`\`'
|
|
16082
|
-
} >> "$GITHUB_STEP_SUMMARY"
|
|
16083
|
-
|
|
16084
|
-
# What reconcile cannot fix: an item with no status, a board that differs from its template, a rule that is off, a
|
|
16085
|
-
# missing App permission. A failure here fails the run, and the run's failure reaches #alerts.
|
|
16086
|
-
- uses: theholocron/.github/.github/actions/holocron@main
|
|
16087
|
-
name: Check the boards
|
|
16088
|
-
if: \${{ !cancelled() }}
|
|
16089
|
-
with:
|
|
16090
|
-
command: doctor project
|
|
16091
|
-
args: >-
|
|
16092
|
-
--token github=\${{ steps.app-token.outputs.token }}
|
|
16093
|
-
`.replaceAll(" ", " ");
|
|
16094
|
-
}
|
|
16095
|
-
/**
|
|
16096
|
-
* The scheduled workflow that keeps the declared boards true (spec `command-project`, "Keeping a board true"): hourly
|
|
16097
|
-
* and on demand it runs `holocron project reconcile`, then `holocron doctor project`, with a token minted from the
|
|
16098
|
-
* GitHub App. Written only when `providers.projects` declares boards, and for the owner the boards belong to, so a repo
|
|
16099
|
-
* without boards gets no file. A generated file, so `probe generated check` compares it with the committed copy.
|
|
16100
|
-
*/
|
|
16101
|
-
function generateProjectWorkflowFiles(input) {
|
|
16102
|
-
const config = input.loaded.resolved;
|
|
16103
|
-
const entry = config.providers.projects;
|
|
16104
|
-
const tuple = entry?.cardinality === "single" ? entry.tuple : entry?.tuples[0];
|
|
16105
|
-
if (!tuple) return [];
|
|
16106
|
-
const resolved = resolveProjectOptions(tuple.options, config.org ?? "");
|
|
16107
|
-
if (!resolved.ok || resolved.options.boards.length === 0 || resolved.options.owner === "") return [];
|
|
16108
|
-
const pkgRelPath = resolvePkgRelPath(findRootSync(input.repoRoot, ".git", {
|
|
16109
|
-
fallback: "start",
|
|
16110
|
-
realpath: true
|
|
16111
|
-
}), input.loaded.filepath);
|
|
16112
|
-
return [{
|
|
16113
|
-
kind: "file",
|
|
16114
|
-
path: PROJECT_RECONCILE_WORKFLOW,
|
|
16115
|
-
content: `${workflowHeader$1()}# Source package: ${pkgRelPath}\n\n${workflow(resolved.options.owner)}`,
|
|
16116
|
-
step: "write workflow project reconcile",
|
|
16117
|
-
syncStep: "sync workflow project reconcile"
|
|
16118
|
-
}];
|
|
16119
|
-
}
|
|
16120
15758
|
// src/commands/repo-files/generate-turbo-files.ts
|
|
16121
15759
|
/**
|
|
16122
15760
|
* `turbo.json`, and the two edits that go with it: `turbo.json` alone is inert unless the root is a workspace member
|
|
@@ -16226,7 +15864,7 @@ function withAutoPreviewDeployPaths(tasks, gitRoot) {
|
|
|
16226
15864
|
}
|
|
16227
15865
|
// src/commands/thin-caller-file/thin-caller-file.ts
|
|
16228
15866
|
const { workflowHeader } = createHeader({
|
|
16229
|
-
source: "cli/astromech/src/thin-callers.ts",
|
|
15867
|
+
source: "cli/astromech/src/generators/github-action-thin-callers/github-action-thin-callers.ts",
|
|
16230
15868
|
tool: "holocron repo sync"
|
|
16231
15869
|
});
|
|
16232
15870
|
/**
|
|
@@ -16237,6 +15875,78 @@ const { workflowHeader } = createHeader({
|
|
|
16237
15875
|
function thinCallerFile(pkgRelPath, content) {
|
|
16238
15876
|
return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
|
|
16239
15877
|
}
|
|
15878
|
+
// src/commands/workflow-source-marker/workflow-source-marker.ts
|
|
15879
|
+
/** `# Source package: <path>` line at the head of a generated thin-caller workflow — see {@link resolvePkgRelPath}. */
|
|
15880
|
+
const SOURCE_PACKAGE_MARKER = /^# Source package: (.+)$/m;
|
|
15881
|
+
/** Strip control characters (including ANSI escapes) before a value reaches a printed error message. */
|
|
15882
|
+
function sanitizeForDisplay(value) {
|
|
15883
|
+
return value.replace(/[\x00-\x1f\x7f]/g, "");
|
|
15884
|
+
}
|
|
15885
|
+
/**
|
|
15886
|
+
* Repo-root-relative path of the PACKAGE a workflow-writing command run is
|
|
15887
|
+
* scoped to — the directory holding the discovered `holocron.config.*`
|
|
15888
|
+
* (`configFilepath`), not necessarily `--cwd` itself. `loadConfig()` walks
|
|
15889
|
+
* up to find the config from any subdirectory ("every command is usable
|
|
15890
|
+
* from any subdirectory of a repo, not only its exact root"), so a `--cwd`
|
|
15891
|
+
* one level too deep would otherwise stamp a different marker than a later
|
|
15892
|
+
* run from the package's own root and misfire the collision check this
|
|
15893
|
+
* feeds (holocron#1026).
|
|
15894
|
+
*
|
|
15895
|
+
* "." for a root invocation, "apps/sentinel" for a subpackage. Normalized
|
|
15896
|
+
* to forward slashes so the same package produces the same marker on
|
|
15897
|
+
* Windows and POSIX. Throws if the result contains a line break — a path
|
|
15898
|
+
* containing one could otherwise break out of the `# Source package: `
|
|
15899
|
+
* comment line and inject arbitrary workflow YAML when the generated
|
|
15900
|
+
* content is later written. Not reachable through this CLI's own flows
|
|
15901
|
+
* (no code path writes a config file whose directory name contains a line
|
|
15902
|
+
* break), but cheap to reject outright rather than trust the filesystem.
|
|
15903
|
+
*/
|
|
15904
|
+
function resolvePkgRelPath(gitRoot, configFilepath) {
|
|
15905
|
+
let root;
|
|
15906
|
+
try {
|
|
15907
|
+
root = realpathSync(gitRoot);
|
|
15908
|
+
} catch {
|
|
15909
|
+
root = gitRoot;
|
|
15910
|
+
}
|
|
15911
|
+
let configDir;
|
|
15912
|
+
try {
|
|
15913
|
+
configDir = realpathSync(dirname(configFilepath));
|
|
15914
|
+
} catch {
|
|
15915
|
+
configDir = dirname(configFilepath);
|
|
15916
|
+
}
|
|
15917
|
+
const pkgRelPath = (relative(root, configDir) || ".").split(sep).join("/");
|
|
15918
|
+
if (/[\r\n]/.test(pkgRelPath)) throw new Error(`refusing to use a package path containing a line break: ${JSON.stringify(pkgRelPath)}`);
|
|
15919
|
+
return pkgRelPath;
|
|
15920
|
+
}
|
|
15921
|
+
/**
|
|
15922
|
+
* Two different monorepo packages opting into the same generic task name
|
|
15923
|
+
* (e.g. both `apps/sentinel` and some future `apps/other` configuring
|
|
15924
|
+
* `delivery.previewDeploy`) would otherwise overwrite each other's
|
|
15925
|
+
* `.github/workflows/<task>.yml` on whichever package's write ran last —
|
|
15926
|
+
* only one package's behavior would ever actually run in CI, with no
|
|
15927
|
+
* signal that the other's was silently dropped (holocron#1026).
|
|
15928
|
+
*
|
|
15929
|
+
* Shared by both `holocron repo sync` (reads the file straight off local
|
|
15930
|
+
* disk) and `holocron repo setup` (reads it through the loaded `Source`
|
|
15931
|
+
* capability, which happens to be local disk too for the github plugin
|
|
15932
|
+
* today, but the interface doesn't promise that for every provider —
|
|
15933
|
+
* holocron#1068). The marker-parsing and error message are identical
|
|
15934
|
+
* either way; `readExisting` is how the two callers differ.
|
|
15935
|
+
*
|
|
15936
|
+
* A file with no marker at all predates this check (or was written before
|
|
15937
|
+
* #1026) and is never flagged — only a marker that's present AND disagrees
|
|
15938
|
+
* with the current run's own package is a real collision. `readExisting`
|
|
15939
|
+
* returning `null` means "nothing there," not "unreadable" — a caller
|
|
15940
|
+
* whose underlying read can fail for reasons other than "doesn't exist"
|
|
15941
|
+
* (e.g. local fs EISDIR) is expected to let that error propagate out of
|
|
15942
|
+
* `readExisting` itself rather than mapping it to `null`.
|
|
15943
|
+
*/
|
|
15944
|
+
async function assertNoPackageCollision(taskName, pkgRelPath, filename, readExisting) {
|
|
15945
|
+
const existing = await readExisting();
|
|
15946
|
+
if (existing === null) return;
|
|
15947
|
+
const previousPkg = SOURCE_PACKAGE_MARKER.exec(existing)?.[1];
|
|
15948
|
+
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.`);
|
|
15949
|
+
}
|
|
16240
15950
|
// src/commands/repo-files/generate-workflow-files.ts
|
|
16241
15951
|
/**
|
|
16242
15952
|
* The thin-caller workflow for each task in the manifest, in the manifest's order. A task with no template is a
|
|
@@ -16356,7 +16066,6 @@ function generateWorkflowFiles(input) {
|
|
|
16356
16066
|
async function generateRepoFiles(input) {
|
|
16357
16067
|
return [
|
|
16358
16068
|
...generateWorkflowFiles(input),
|
|
16359
|
-
...generateProjectWorkflowFiles(input),
|
|
16360
16069
|
...await generateConfigFiles(input),
|
|
16361
16070
|
...await generateAgentFiles(input),
|
|
16362
16071
|
...await generateTurboFiles(input)
|