@theholocron/cli 5.1.1 → 5.1.3
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 -74
- 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,24 +19866,40 @@ 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
|
-
*
|
|
19879
|
-
* a folder.
|
|
19870
|
+
* the `# Source package:` marker `generated check` reads, and the workflow itself. Its source is
|
|
19871
|
+
* `ci/workflows/<suite>/<leaf>.yml` (or `ci/workflows/<id>.yml`), the id with each colon a folder.
|
|
19880
19872
|
*/
|
|
19881
19873
|
function hostedReusableFile(id, content) {
|
|
19882
19874
|
const { workflowHeader } = createHeader({
|
|
19883
19875
|
source: `ci/workflows/${id.replaceAll(":", "/")}.yml`,
|
|
19884
19876
|
tool: "holocron sync"
|
|
19885
19877
|
});
|
|
19886
|
-
return `${workflowHeader()}# Source package: .\n\n${
|
|
19878
|
+
return `${workflowHeader()}# Source package: .\n\n${content}`;
|
|
19879
|
+
}
|
|
19880
|
+
// src/commands/required-checks-for/required-checks-for.ts
|
|
19881
|
+
/**
|
|
19882
|
+
* The status checks a `strict` ruleset requires for the repo at `repoRoot`, as `holocron setup` writes them and
|
|
19883
|
+
* `holocron doctor repo` compares them. A list the repo writes down (`repo.requiredChecks`) is the whole list.
|
|
19884
|
+
* Otherwise it comes from the task manifest. Only the repo that serves the reusables has the `ci` aggregate (polling for
|
|
19885
|
+
* every check costs GitHub quota, so no other repo gets one): there the list is `ci / Required checks` and `DCO`, unless
|
|
19886
|
+
* `ci.aggregate` is `none`. Every other repo lists `DCO`, each `{ required: true }` task's check and
|
|
19887
|
+
* `extraRequiredChecks` one by one.
|
|
19888
|
+
*
|
|
19889
|
+
* @param statusContexts - The coverage statuses a `coverage` provider reports, when the repo declares one.
|
|
19890
|
+
*/
|
|
19891
|
+
function requiredChecksFor(config, repoRoot, statusContexts) {
|
|
19892
|
+
const declared = declaredRequiredChecks(config.repo);
|
|
19893
|
+
if (declared !== void 0) return declared;
|
|
19894
|
+
const tasksConfig = { tasks: config.tasks };
|
|
19895
|
+
if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
|
|
19896
|
+
if (config.ci) tasksConfig.ci = config.ci;
|
|
19897
|
+
return createAstromech({
|
|
19898
|
+
cwd: repoRoot,
|
|
19899
|
+
config: tasksConfig,
|
|
19900
|
+
logger: getLogger(),
|
|
19901
|
+
...statusContexts ? { statusContexts } : {}
|
|
19902
|
+
}).requiredChecks(hostsReusables(repoRoot));
|
|
19887
19903
|
}
|
|
19888
19904
|
// src/commands/setup/derived-properties/derived-properties.ts
|
|
19889
19905
|
/**
|
|
@@ -20397,7 +20413,7 @@ function repoChecks(config, repoRoot, statusContexts) {
|
|
|
20397
20413
|
checked: 1
|
|
20398
20414
|
};
|
|
20399
20415
|
const detail = await source.getRulesetDetail(found.id);
|
|
20400
|
-
const required = preset === "strict" ?
|
|
20416
|
+
const required = preset === "strict" ? requiredChecksFor(config, repoRoot, statusContexts) : [];
|
|
20401
20417
|
const rules = [
|
|
20402
20418
|
"deletion",
|
|
20403
20419
|
"non_fast_forward",
|
|
@@ -20437,7 +20453,7 @@ function repoChecks(config, repoRoot, statusContexts) {
|
|
|
20437
20453
|
checked: 1
|
|
20438
20454
|
};
|
|
20439
20455
|
const detail = await source.getRulesetDetail(found.id);
|
|
20440
|
-
const required = preset === "strict" ?
|
|
20456
|
+
const required = preset === "strict" ? requiredChecksFor(config, repoRoot, statusContexts) : [];
|
|
20441
20457
|
const rules = [
|
|
20442
20458
|
"deletion",
|
|
20443
20459
|
"non_fast_forward",
|
|
@@ -20466,7 +20482,7 @@ function repoChecks(config, repoRoot, statusContexts) {
|
|
|
20466
20482
|
title: "ci / Required checks is pinned to the declared app",
|
|
20467
20483
|
needs: "getRulesetDetail",
|
|
20468
20484
|
async run(source) {
|
|
20469
|
-
const plan = aggregatePin(config.ci,
|
|
20485
|
+
const plan = aggregatePin(config.ci, requiredChecksFor(config, repoRoot, statusContexts));
|
|
20470
20486
|
if (plan.problem) return {
|
|
20471
20487
|
problems: [plan.problem],
|
|
20472
20488
|
checked: 1
|
|
@@ -20531,20 +20547,6 @@ function declaredProperties(config) {
|
|
|
20531
20547
|
if (manual.uses_external_packages !== void 0) out.set("uses_external_packages", String(manual.uses_external_packages));
|
|
20532
20548
|
return out;
|
|
20533
20549
|
}
|
|
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
20550
|
// src/commands/doctor-repo/doctor-repo.ts
|
|
20549
20551
|
/**
|
|
20550
20552
|
* `holocron doctor repo` — do the repository settings `setup` writes match the config?
|
|
@@ -25614,11 +25616,12 @@ function thinCallerFile(pkgRelPath, content) {
|
|
|
25614
25616
|
* skipped entry, and a task with `ci: false` has no file. Nothing here is remote: astromech renders every file from the
|
|
25615
25617
|
* manifest (the linter set, deploy paths, deploy and preview), and a bad manifest throws.
|
|
25616
25618
|
*
|
|
25617
|
-
*
|
|
25618
|
-
*
|
|
25619
|
-
*
|
|
25620
|
-
*
|
|
25621
|
-
*
|
|
25619
|
+
* Every config's callers are named for their task id, in the workflow, the job and the file (`test-unit.yml`, the id
|
|
25620
|
+
* with its colon a hyphen), and call the reusables in `theholocron/holocron` at `ci-v1` (`CI_HOME`). The repo that serves
|
|
25621
|
+
* the reusables (it has the `@theholocron/ci` package) calls them by path, `./.github/workflows/<flat name>.yml`, so a
|
|
25622
|
+
* PR that edits one runs it; its callers get the `ci.` prefix (`ci.test-unit.yml`) so they do not clash with the
|
|
25623
|
+
* reusables beside them, and its root config also writes the reusables. The root config of any repo writes the `ci`
|
|
25624
|
+
* aggregate caller.
|
|
25622
25625
|
*/
|
|
25623
25626
|
function generateWorkflowFiles(input) {
|
|
25624
25627
|
const config = input.loaded.resolved;
|
|
@@ -25645,19 +25648,17 @@ function generateWorkflowFiles(input) {
|
|
|
25645
25648
|
});
|
|
25646
25649
|
const files = astromech.thinCallers();
|
|
25647
25650
|
const hosting = hostsReusables(gitRoot);
|
|
25648
|
-
const legacy = !hosting && legacyGate();
|
|
25649
25651
|
const entries = [];
|
|
25650
25652
|
const wanted = tasks.flatMap((entry) => {
|
|
25651
25653
|
const name = typeof entry === "string" ? entry : entry.name;
|
|
25652
25654
|
const ids = resolveTaskName(name);
|
|
25653
25655
|
if (ids.length > 0 && ids.every(({ id }) => TASKS[id]?.workflow === false)) return [];
|
|
25654
|
-
return
|
|
25655
|
-
entry,
|
|
25656
|
+
return workflowKeys(name).map((key) => ({
|
|
25656
25657
|
name,
|
|
25657
25658
|
key
|
|
25658
25659
|
}));
|
|
25659
25660
|
});
|
|
25660
|
-
for (const {
|
|
25661
|
+
for (const { name, key } of wanted) {
|
|
25661
25662
|
const isCombinedContentOnly = key === "deploy-docs" || key === "deploy-components";
|
|
25662
25663
|
if (!KNOWN_WORKFLOWS.has(key) && !isCombinedContentOnly) {
|
|
25663
25664
|
entries.push({
|
|
@@ -25668,12 +25669,10 @@ function generateWorkflowFiles(input) {
|
|
|
25668
25669
|
});
|
|
25669
25670
|
continue;
|
|
25670
25671
|
}
|
|
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)" : "";
|
|
25672
|
+
const content = files.get(`${key}.yml`);
|
|
25673
|
+
if (content === void 0) continue;
|
|
25674
|
+
const filename = hosting ? `ci.${workflowFile(key)}` : workflowFile(key);
|
|
25675
|
+
const preview = content.includes("workflows/preview.yml@") ? " (with preview)" : "";
|
|
25677
25676
|
entries.push({
|
|
25678
25677
|
kind: "file",
|
|
25679
25678
|
path: `.github/workflows/${filename}`,
|
|
@@ -25702,21 +25701,21 @@ function generateWorkflowFiles(input) {
|
|
|
25702
25701
|
}
|
|
25703
25702
|
});
|
|
25704
25703
|
}
|
|
25705
|
-
|
|
25706
|
-
|
|
25707
|
-
|
|
25708
|
-
|
|
25709
|
-
|
|
25710
|
-
|
|
25711
|
-
|
|
25712
|
-
|
|
25713
|
-
|
|
25714
|
-
|
|
25715
|
-
|
|
25716
|
-
|
|
25717
|
-
|
|
25718
|
-
}
|
|
25719
|
-
}
|
|
25704
|
+
}
|
|
25705
|
+
if (hosting && pkgRelPath === ".") for (const [id, content] of hostedReusableWorkflows()) {
|
|
25706
|
+
if (id === "ci" && astromech.aggregatePoster() !== "actions") continue;
|
|
25707
|
+
const filename = workflowFile(id);
|
|
25708
|
+
entries.push({
|
|
25709
|
+
kind: "file",
|
|
25710
|
+
path: `.github/workflows/${filename}`,
|
|
25711
|
+
content: hostedReusableFile(id, content),
|
|
25712
|
+
step: `write reusable workflow ${id}`,
|
|
25713
|
+
syncStep: `sync reusable workflow ${id}`,
|
|
25714
|
+
workflow: {
|
|
25715
|
+
task: id,
|
|
25716
|
+
filename
|
|
25717
|
+
}
|
|
25718
|
+
});
|
|
25720
25719
|
}
|
|
25721
25720
|
return entries;
|
|
25722
25721
|
}
|
|
@@ -26918,15 +26917,7 @@ async function runSetup(input) {
|
|
|
26918
26917
|
});
|
|
26919
26918
|
}));
|
|
26920
26919
|
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)) : [];
|
|
26920
|
+
const requiredChecks = effectivePreset === "strict" ? requiredChecksFor(config, input.context.repoRoot, statusContexts) : [];
|
|
26930
26921
|
const pinPlan = aggregatePin(config.ci, requiredChecks);
|
|
26931
26922
|
const protectedBranches = repo?.protectedBranches ?? [];
|
|
26932
26923
|
steps.push(await upsertBranchProtection(source, dryRun, requiredChecks, pinPlan.pins, protectedBranches));
|