@theholocron/cli 5.0.0-alpha.342 → 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 +2 -3
- package/dist/cli.mjs +92 -379
- package/dist/cli.mjs.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -812,9 +812,8 @@ 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
|
-
`doctor <capability>` is listed in
|
|
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`
|
|
818
817
|
- `src/interactive-menu/` — the interactive fallback's Holocron data: `command-registry`
|
|
819
818
|
(`COMMAND_REGISTRY`, each entry's `positionals`/`options`), `run-menu-entries`
|
|
820
819
|
and `probe-menu-entries` (menu entries built at run time), and `menu.ts`,
|
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,7 +19,7 @@ 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
25
|
import { DRY_RUN_NOOP_EXIT_CODE, createMenu } from "@theholocron/kyber/menu";
|
|
@@ -28,7 +28,7 @@ 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
|
|
@@ -4045,76 +3948,6 @@ function resolveDevOptions(flags, config, self = [process.execPath, process.argv
|
|
|
4045
3948
|
command
|
|
4046
3949
|
};
|
|
4047
3950
|
}
|
|
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
3951
|
// src/commands/run-cloudflared/run-cloudflared.ts
|
|
4119
3952
|
/**
|
|
4120
3953
|
* Runs `cloudflared tunnel run` in the foreground and resolves with its exit status. The tunnel's token goes to the
|
|
@@ -4313,6 +4146,13 @@ const tunnelUpCommand = {
|
|
|
4313
4146
|
}
|
|
4314
4147
|
};
|
|
4315
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
|
+
*/
|
|
4316
4156
|
const COMMAND$6 = "dev";
|
|
4317
4157
|
/** The environment the application is told it runs in, which its logger tags every line with. */
|
|
4318
4158
|
const APP_ENVIRONMENT = "development";
|
|
@@ -4394,8 +4234,8 @@ async function runDev(input) {
|
|
|
4394
4234
|
print(`running ${shown} and cloudflared (Ctrl-C stops both): ${tunnel.url} to localhost:${input.port}`);
|
|
4395
4235
|
let exitCode;
|
|
4396
4236
|
try {
|
|
4397
|
-
({exitCode} = await (input.runProcesses ??
|
|
4398
|
-
|
|
4237
|
+
({exitCode} = await (input.runProcesses ?? superviseProcesses)({
|
|
4238
|
+
primary: {
|
|
4399
4239
|
command: program,
|
|
4400
4240
|
args,
|
|
4401
4241
|
env: {
|
|
@@ -4404,7 +4244,7 @@ async function runDev(input) {
|
|
|
4404
4244
|
PORT: String(input.port)
|
|
4405
4245
|
}
|
|
4406
4246
|
},
|
|
4407
|
-
|
|
4247
|
+
companion: {
|
|
4408
4248
|
command: "cloudflared",
|
|
4409
4249
|
args: [
|
|
4410
4250
|
"tunnel",
|
|
@@ -8338,9 +8178,6 @@ const BUILTIN_TEMPLATES = {
|
|
|
8338
8178
|
"2 · Next",
|
|
8339
8179
|
"3 · Process"
|
|
8340
8180
|
]
|
|
8341
|
-
}, {
|
|
8342
|
-
name: "Milestone",
|
|
8343
|
-
type: "text"
|
|
8344
8181
|
}],
|
|
8345
8182
|
views: [
|
|
8346
8183
|
{
|
|
@@ -9296,8 +9133,9 @@ function repoChecks(config, repoRoot) {
|
|
|
9296
9133
|
const declared = /* @__PURE__ */ new Map();
|
|
9297
9134
|
if (config.description) declared.set("description", config.description);
|
|
9298
9135
|
if (config.homepage) declared.set("homepage", config.homepage);
|
|
9136
|
+
const actual = /* @__PURE__ */ new Map([["description", info.description ?? ""], ["homepage", info.homepage ?? ""]]);
|
|
9299
9137
|
return {
|
|
9300
|
-
problems: declaredVsActual(declared,
|
|
9138
|
+
problems: declaredVsActual(declared, actual, {
|
|
9301
9139
|
noun: "repository field",
|
|
9302
9140
|
flagExtra: false,
|
|
9303
9141
|
show: quote
|
|
@@ -9314,8 +9152,9 @@ function repoChecks(config, repoRoot) {
|
|
|
9314
9152
|
const info = await source.getRepoInfo();
|
|
9315
9153
|
const declared = new Map(Object.entries(preset ? BALANCED_REPO_SETTINGS : {}));
|
|
9316
9154
|
if (repo?.defaultBranch) declared.set("default_branch", repo.defaultBranch);
|
|
9155
|
+
const actual = new Map(Object.entries(info.settings));
|
|
9317
9156
|
return {
|
|
9318
|
-
problems: declaredVsActual(declared,
|
|
9157
|
+
problems: declaredVsActual(declared, actual, {
|
|
9319
9158
|
noun: "repository setting",
|
|
9320
9159
|
flagExtra: false,
|
|
9321
9160
|
show: quote
|
|
@@ -15862,7 +15701,7 @@ function hooksEnabled(input) {
|
|
|
15862
15701
|
return config.repo?.protection === "strict";
|
|
15863
15702
|
}
|
|
15864
15703
|
// src/commands/repo-files/generate-config-files.ts
|
|
15865
|
-
const { workflowHeader: workflowHeader$
|
|
15704
|
+
const { workflowHeader: workflowHeader$1 } = createHeader({
|
|
15866
15705
|
source: "cli/cli/src/commands/repo-files/generate-config-files.ts",
|
|
15867
15706
|
tool: "holocron repo setup"
|
|
15868
15707
|
});
|
|
@@ -15887,7 +15726,7 @@ async function generateConfigFiles(input) {
|
|
|
15887
15726
|
const taskNames = (config.tasks ?? []).map((e) => typeof e === "string" ? e : e.name);
|
|
15888
15727
|
const entries = [];
|
|
15889
15728
|
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$
|
|
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}`));
|
|
15891
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)));
|
|
15892
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"));
|
|
15893
15732
|
else for (const hook of [".husky/pre-push", ".husky/pre-commit"]) entries.push({
|
|
@@ -15920,203 +15759,6 @@ async function generateConfigFiles(input) {
|
|
|
15920
15759
|
}
|
|
15921
15760
|
return entries;
|
|
15922
15761
|
}
|
|
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
15762
|
// src/commands/repo-files/generate-turbo-files.ts
|
|
16121
15763
|
/**
|
|
16122
15764
|
* `turbo.json`, and the two edits that go with it: `turbo.json` alone is inert unless the root is a workspace member
|
|
@@ -16237,6 +15879,78 @@ const { workflowHeader } = createHeader({
|
|
|
16237
15879
|
function thinCallerFile(pkgRelPath, content) {
|
|
16238
15880
|
return `${workflowHeader()}# Source package: ${pkgRelPath}\n\n${content}`;
|
|
16239
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
|
+
}
|
|
16240
15954
|
// src/commands/repo-files/generate-workflow-files.ts
|
|
16241
15955
|
/**
|
|
16242
15956
|
* The thin-caller workflow for each task in the manifest, in the manifest's order. A task with no template is a
|
|
@@ -16356,7 +16070,6 @@ function generateWorkflowFiles(input) {
|
|
|
16356
16070
|
async function generateRepoFiles(input) {
|
|
16357
16071
|
return [
|
|
16358
16072
|
...generateWorkflowFiles(input),
|
|
16359
|
-
...generateProjectWorkflowFiles(input),
|
|
16360
16073
|
...await generateConfigFiles(input),
|
|
16361
16074
|
...await generateAgentFiles(input),
|
|
16362
16075
|
...await generateTurboFiles(input)
|