@theholocron/cli 5.1.1 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +65 -73
- package/dist/cli.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { hideBin } from "yargs/helpers";
|
|
|
15
15
|
import { appendFileSync, closeSync, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
16
16
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
17
17
|
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, createPrivateFile, deferCredentials, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
18
|
-
import { AGGREGATE_CHECK, AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, aggregatePoster, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths,
|
|
18
|
+
import { AGGREGATE_CHECK, AGGREGATE_CHECK_NAME, AGGREGATE_SHADOW_CHECK_NAME, DEFAULT_ORG, DOCUMENTATION_FLAG, DOT_GITHUB_REPO, HOLOCRON_REPO, KNOWN_TASKS, KNOWN_WORKFLOWS, LEGACY_NAMES, PNPM_BUILTIN_COMMANDS, PRERELEASE_CHANNEL, RELEASE_BRANCHES, RESERVED_SCRIPT_NAMES, SUITES, TASKS, aggregateChecks, aggregatePoster, checkPackageScripts, checkReleaseLines, codecovFlagNames, createAstromech, createCommitMsg, createDependabot, createDevmoji, createEditorconfig, createEditorconfigChecker, createHeader, createLabeler, createPreCommit, createPrePush, createPrepareCommitMsg, createYamlignore, createYamllint, defaultListDirs, defaultPaths, defaultReadJson, deployOnRelease, describeTasks, extractPreviewConfig, formatJson, frozenReusablePaths, hostedReusableWorkflows, isDeprecated, isTask, localize, mergeScripts, packageLocation, postAggregate, readWorkspacePackages, recordDeploys, requiredChecks, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
|
|
19
19
|
import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
|
|
20
20
|
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
21
21
|
import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
@@ -14273,11 +14273,11 @@ const SAYS = {
|
|
|
14273
14273
|
};
|
|
14274
14274
|
/**
|
|
14275
14275
|
* The `home` row: where the callers point. All at `theholocron/.github` is the frozen, legacy-named home; all at holocron
|
|
14276
|
-
* `ci-v1` (or at this repo's own reusables, in the repo that
|
|
14277
|
-
* fail, since the names and the checks they post then follow two vocabularies.
|
|
14278
|
-
*
|
|
14276
|
+
* `ci-v1` (or at this repo's own reusables, in the repo that serves them) is the flat one. Callers split between homes
|
|
14277
|
+
* fail, since the names and the checks they post then follow two vocabularies. The generator writes only flat names
|
|
14278
|
+
* now, so a legacy home is one the next `sync` moves.
|
|
14279
14279
|
*/
|
|
14280
|
-
function homeRow(callers
|
|
14280
|
+
function homeRow(callers) {
|
|
14281
14281
|
const id = "home";
|
|
14282
14282
|
const title = "callers point at one home";
|
|
14283
14283
|
const homes = /* @__PURE__ */ new Map();
|
|
@@ -14303,7 +14303,7 @@ function homeRow(callers, gateShut) {
|
|
|
14303
14303
|
};
|
|
14304
14304
|
}
|
|
14305
14305
|
const [home] = [...homes.keys()];
|
|
14306
|
-
const gate = home === "legacy" ?
|
|
14306
|
+
const gate = home === "legacy" ? "; sync writes flat names" : "";
|
|
14307
14307
|
return {
|
|
14308
14308
|
id,
|
|
14309
14309
|
title,
|
|
@@ -14547,7 +14547,7 @@ async function runDoctorCi(input) {
|
|
|
14547
14547
|
tasksRow(tasks.map((entry) => typeof entry === "string" ? entry : entry.name)),
|
|
14548
14548
|
callersRow(callers),
|
|
14549
14549
|
aggregateRow(callers, aggregateChecks(tasksConfig).expected, aggregatePoster(tasksConfig)),
|
|
14550
|
-
homeRow(callers
|
|
14550
|
+
homeRow(callers),
|
|
14551
14551
|
...input.shadow ? await shadowRows(input) : []
|
|
14552
14552
|
];
|
|
14553
14553
|
printCheckRows(rows, print);
|
|
@@ -19866,16 +19866,9 @@ function hostsReusables(gitRoot) {
|
|
|
19866
19866
|
}
|
|
19867
19867
|
}
|
|
19868
19868
|
/**
|
|
19869
|
-
* The composite actions the hosting repo's own copy of a reusable runs from its checkout, not from the frozen copy in
|
|
19870
|
-
* `theholocron/.github` that the shared text names. The upload loop is here so a retry added to it takes effect on the
|
|
19871
|
-
* PR that adds it; the frozen copy never changes again. Other actions join once `CI_HOME` moves to `ci-v1` and the
|
|
19872
|
-
* rest of the hosted files are run from this repo.
|
|
19873
|
-
*/
|
|
19874
|
-
const LOCAL_ACTIONS = ["codecov-upload"];
|
|
19875
|
-
/**
|
|
19876
19869
|
* The text of a reusable workflow written to the hosting repo's own `.github/workflows`: the AUTO-GENERATED header,
|
|
19877
|
-
* the `# Source package:` marker `generated check` reads, and the workflow itself
|
|
19878
|
-
*
|
|
19870
|
+
* the `# Source package:` marker `generated check` reads, and the workflow itself (its local actions are already
|
|
19871
|
+
* called by path, `hostedActionRefs()`). Its source is `ci/workflows/<suite>/<leaf>.yml` (or `ci/workflows/<id>.yml`), the id with each colon
|
|
19879
19872
|
* a folder.
|
|
19880
19873
|
*/
|
|
19881
19874
|
function hostedReusableFile(id, content) {
|
|
@@ -19883,7 +19876,31 @@ function hostedReusableFile(id, content) {
|
|
|
19883
19876
|
source: `ci/workflows/${id.replaceAll(":", "/")}.yml`,
|
|
19884
19877
|
tool: "holocron sync"
|
|
19885
19878
|
});
|
|
19886
|
-
return `${workflowHeader()}# Source package: .\n\n${
|
|
19879
|
+
return `${workflowHeader()}# Source package: .\n\n${content}`;
|
|
19880
|
+
}
|
|
19881
|
+
// src/commands/required-checks-for/required-checks-for.ts
|
|
19882
|
+
/**
|
|
19883
|
+
* The status checks a `strict` ruleset requires for the repo at `repoRoot`, as `holocron setup` writes them and
|
|
19884
|
+
* `holocron doctor repo` compares them. A list the repo writes down (`repo.requiredChecks`) is the whole list.
|
|
19885
|
+
* Otherwise it comes from the task manifest. Only the repo that serves the reusables has the `ci` aggregate (polling for
|
|
19886
|
+
* every check costs GitHub quota, so no other repo gets one): there the list is `ci / Required checks` and `DCO`, unless
|
|
19887
|
+
* `ci.aggregate` is `none`. Every other repo lists `DCO`, each `{ required: true }` task's check and
|
|
19888
|
+
* `extraRequiredChecks` one by one.
|
|
19889
|
+
*
|
|
19890
|
+
* @param statusContexts - The coverage statuses a `coverage` provider reports, when the repo declares one.
|
|
19891
|
+
*/
|
|
19892
|
+
function requiredChecksFor(config, repoRoot, statusContexts) {
|
|
19893
|
+
const declared = declaredRequiredChecks(config.repo);
|
|
19894
|
+
if (declared !== void 0) return declared;
|
|
19895
|
+
const tasksConfig = { tasks: config.tasks };
|
|
19896
|
+
if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
|
|
19897
|
+
if (config.ci) tasksConfig.ci = config.ci;
|
|
19898
|
+
return createAstromech({
|
|
19899
|
+
cwd: repoRoot,
|
|
19900
|
+
config: tasksConfig,
|
|
19901
|
+
logger: getLogger(),
|
|
19902
|
+
...statusContexts ? { statusContexts } : {}
|
|
19903
|
+
}).requiredChecks(hostsReusables(repoRoot));
|
|
19887
19904
|
}
|
|
19888
19905
|
// src/commands/setup/derived-properties/derived-properties.ts
|
|
19889
19906
|
/**
|
|
@@ -20397,7 +20414,7 @@ function repoChecks(config, repoRoot, statusContexts) {
|
|
|
20397
20414
|
checked: 1
|
|
20398
20415
|
};
|
|
20399
20416
|
const detail = await source.getRulesetDetail(found.id);
|
|
20400
|
-
const required = preset === "strict" ?
|
|
20417
|
+
const required = preset === "strict" ? requiredChecksFor(config, repoRoot, statusContexts) : [];
|
|
20401
20418
|
const rules = [
|
|
20402
20419
|
"deletion",
|
|
20403
20420
|
"non_fast_forward",
|
|
@@ -20437,7 +20454,7 @@ function repoChecks(config, repoRoot, statusContexts) {
|
|
|
20437
20454
|
checked: 1
|
|
20438
20455
|
};
|
|
20439
20456
|
const detail = await source.getRulesetDetail(found.id);
|
|
20440
|
-
const required = preset === "strict" ?
|
|
20457
|
+
const required = preset === "strict" ? requiredChecksFor(config, repoRoot, statusContexts) : [];
|
|
20441
20458
|
const rules = [
|
|
20442
20459
|
"deletion",
|
|
20443
20460
|
"non_fast_forward",
|
|
@@ -20466,7 +20483,7 @@ function repoChecks(config, repoRoot, statusContexts) {
|
|
|
20466
20483
|
title: "ci / Required checks is pinned to the declared app",
|
|
20467
20484
|
needs: "getRulesetDetail",
|
|
20468
20485
|
async run(source) {
|
|
20469
|
-
const plan = aggregatePin(config.ci,
|
|
20486
|
+
const plan = aggregatePin(config.ci, requiredChecksFor(config, repoRoot, statusContexts));
|
|
20470
20487
|
if (plan.problem) return {
|
|
20471
20488
|
problems: [plan.problem],
|
|
20472
20489
|
checked: 1
|
|
@@ -20531,20 +20548,6 @@ function declaredProperties(config) {
|
|
|
20531
20548
|
if (manual.uses_external_packages !== void 0) out.set("uses_external_packages", String(manual.uses_external_packages));
|
|
20532
20549
|
return out;
|
|
20533
20550
|
}
|
|
20534
|
-
/** The status checks a `strict` ruleset requires, derived from the task manifest exactly as `setup` does. */
|
|
20535
|
-
function strictChecks(config, repoRoot, statusContexts) {
|
|
20536
|
-
const declared = declaredRequiredChecks(config.repo);
|
|
20537
|
-
if (declared !== void 0) return declared;
|
|
20538
|
-
const tasksConfig = { tasks: config.tasks };
|
|
20539
|
-
if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
|
|
20540
|
-
if (config.ci) tasksConfig.ci = config.ci;
|
|
20541
|
-
return createAstromech({
|
|
20542
|
-
cwd: repoRoot,
|
|
20543
|
-
config: tasksConfig,
|
|
20544
|
-
logger: getLogger(),
|
|
20545
|
-
...statusContexts ? { statusContexts } : {}
|
|
20546
|
-
}).requiredChecks(hostsReusables(repoRoot));
|
|
20547
|
-
}
|
|
20548
20551
|
// src/commands/doctor-repo/doctor-repo.ts
|
|
20549
20552
|
/**
|
|
20550
20553
|
* `holocron doctor repo` — do the repository settings `setup` writes match the config?
|
|
@@ -25614,11 +25617,12 @@ function thinCallerFile(pkgRelPath, content) {
|
|
|
25614
25617
|
* skipped entry, and a task with `ci: false` has no file. Nothing here is remote: astromech renders every file from the
|
|
25615
25618
|
* manifest (the linter set, deploy paths, deploy and preview), and a bad manifest throws.
|
|
25616
25619
|
*
|
|
25617
|
-
*
|
|
25618
|
-
*
|
|
25619
|
-
*
|
|
25620
|
-
*
|
|
25621
|
-
*
|
|
25620
|
+
* Every config's callers are named for their task id, in the workflow, the job and the file (`test-unit.yml`, the id
|
|
25621
|
+
* with its colon a hyphen), and call the reusables in `theholocron/holocron` at `ci-v1` (`CI_HOME`). The repo that serves
|
|
25622
|
+
* the reusables (it has the `@theholocron/ci` package) calls them by path, `./.github/workflows/<flat name>.yml`, so a
|
|
25623
|
+
* PR that edits one runs it; its callers get the `ci.` prefix (`ci.test-unit.yml`) so they do not clash with the
|
|
25624
|
+
* reusables beside them, and its root config also writes the reusables. The root config of any repo writes the `ci`
|
|
25625
|
+
* aggregate caller.
|
|
25622
25626
|
*/
|
|
25623
25627
|
function generateWorkflowFiles(input) {
|
|
25624
25628
|
const config = input.loaded.resolved;
|
|
@@ -25645,19 +25649,17 @@ function generateWorkflowFiles(input) {
|
|
|
25645
25649
|
});
|
|
25646
25650
|
const files = astromech.thinCallers();
|
|
25647
25651
|
const hosting = hostsReusables(gitRoot);
|
|
25648
|
-
const legacy = !hosting && legacyGate();
|
|
25649
25652
|
const entries = [];
|
|
25650
25653
|
const wanted = tasks.flatMap((entry) => {
|
|
25651
25654
|
const name = typeof entry === "string" ? entry : entry.name;
|
|
25652
25655
|
const ids = resolveTaskName(name);
|
|
25653
25656
|
if (ids.length > 0 && ids.every(({ id }) => TASKS[id]?.workflow === false)) return [];
|
|
25654
|
-
return
|
|
25655
|
-
entry,
|
|
25657
|
+
return workflowKeys(name).map((key) => ({
|
|
25656
25658
|
name,
|
|
25657
25659
|
key
|
|
25658
25660
|
}));
|
|
25659
25661
|
});
|
|
25660
|
-
for (const {
|
|
25662
|
+
for (const { name, key } of wanted) {
|
|
25661
25663
|
const isCombinedContentOnly = key === "deploy-docs" || key === "deploy-components";
|
|
25662
25664
|
if (!KNOWN_WORKFLOWS.has(key) && !isCombinedContentOnly) {
|
|
25663
25665
|
entries.push({
|
|
@@ -25668,12 +25670,10 @@ function generateWorkflowFiles(input) {
|
|
|
25668
25670
|
});
|
|
25669
25671
|
continue;
|
|
25670
25672
|
}
|
|
25671
|
-
|
|
25672
|
-
if (
|
|
25673
|
-
|
|
25674
|
-
const
|
|
25675
|
-
const filename = hosting ? `ci.${workflowFile(key)}` : legacy ? legacyCallerFile(key) : workflowFile(key);
|
|
25676
|
-
const preview = content.includes("workflows/preview.yml@main") ? " (with preview)" : "";
|
|
25673
|
+
const content = files.get(`${key}.yml`);
|
|
25674
|
+
if (content === void 0) continue;
|
|
25675
|
+
const filename = hosting ? `ci.${workflowFile(key)}` : workflowFile(key);
|
|
25676
|
+
const preview = content.includes("workflows/preview.yml@") ? " (with preview)" : "";
|
|
25677
25677
|
entries.push({
|
|
25678
25678
|
kind: "file",
|
|
25679
25679
|
path: `.github/workflows/${filename}`,
|
|
@@ -25702,21 +25702,21 @@ function generateWorkflowFiles(input) {
|
|
|
25702
25702
|
}
|
|
25703
25703
|
});
|
|
25704
25704
|
}
|
|
25705
|
-
|
|
25706
|
-
|
|
25707
|
-
|
|
25708
|
-
|
|
25709
|
-
|
|
25710
|
-
|
|
25711
|
-
|
|
25712
|
-
|
|
25713
|
-
|
|
25714
|
-
|
|
25715
|
-
|
|
25716
|
-
|
|
25717
|
-
|
|
25718
|
-
}
|
|
25719
|
-
}
|
|
25705
|
+
}
|
|
25706
|
+
if (hosting && pkgRelPath === ".") for (const [id, content] of hostedReusableWorkflows()) {
|
|
25707
|
+
if (id === "ci" && astromech.aggregatePoster() !== "actions") continue;
|
|
25708
|
+
const filename = workflowFile(id);
|
|
25709
|
+
entries.push({
|
|
25710
|
+
kind: "file",
|
|
25711
|
+
path: `.github/workflows/${filename}`,
|
|
25712
|
+
content: hostedReusableFile(id, content),
|
|
25713
|
+
step: `write reusable workflow ${id}`,
|
|
25714
|
+
syncStep: `sync reusable workflow ${id}`,
|
|
25715
|
+
workflow: {
|
|
25716
|
+
task: id,
|
|
25717
|
+
filename
|
|
25718
|
+
}
|
|
25719
|
+
});
|
|
25720
25720
|
}
|
|
25721
25721
|
return entries;
|
|
25722
25722
|
}
|
|
@@ -26918,15 +26918,7 @@ async function runSetup(input) {
|
|
|
26918
26918
|
});
|
|
26919
26919
|
}));
|
|
26920
26920
|
print(formatStep(steps[steps.length - 1]));
|
|
26921
|
-
const
|
|
26922
|
-
if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
|
|
26923
|
-
if (config.ci) tasksConfig.ci = config.ci;
|
|
26924
|
-
const requiredChecks = effectivePreset === "strict" ? declaredRequiredChecks(config.repo) ?? createAstromech({
|
|
26925
|
-
cwd: input.context.repoRoot,
|
|
26926
|
-
config: tasksConfig,
|
|
26927
|
-
logger,
|
|
26928
|
-
...statusContexts ? { statusContexts } : {}
|
|
26929
|
-
}).requiredChecks(hostsReusables(input.context.repoRoot)) : [];
|
|
26921
|
+
const requiredChecks = effectivePreset === "strict" ? requiredChecksFor(config, input.context.repoRoot, statusContexts) : [];
|
|
26930
26922
|
const pinPlan = aggregatePin(config.ci, requiredChecks);
|
|
26931
26923
|
const protectedBranches = repo?.protectedBranches ?? [];
|
|
26932
26924
|
steps.push(await upsertBranchProtection(source, dryRun, requiredChecks, pinPlan.pins, protectedBranches));
|