@theholocron/cli 5.0.0-alpha.521 → 5.0.0-alpha.523
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 +1 -1
- package/dist/cli.mjs +84 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-system-S97oWF6b.mjs → config-system-DKPW6MTH.mjs} +2 -0
- package/dist/{index-D4i2IB5D.d.mts → index-DPV85Hrf.d.mts} +11 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plugin/capabilities.d.mts +1 -1
- package/dist/presets.d.mts +1 -1
- package/dist/presets.mjs +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -682,7 +682,7 @@ commands and the config are provider-neutral; Discord is the first provider.
|
|
|
682
682
|
| `holocron doctor workers` | Do the Workers and deployment projects the config declares exist, route and deploy healthily? Declared Workers are the relay Worker of a notifications layout that feeds an error tracker and the reverse proxy of a wiki with a custom domain. Rows per Worker: `<name> Worker is deployed and routed` (the script exists with a route for its host), `has its bindings` (by name, a value is never read) and `latest deployment is healthy` (the newest deployment serves all traffic). Rows per deployment project (the preview project, else one named like the repo): `<project> project exists`, `has its custom domain` (when one is declared) and `latest deployment is healthy` (the newest production deployment is ready; one that errored fails, one still building is information). Reads through the optional `Workers.inspectScript` / `latestDeployment` / `proxyScriptName` and `Deployment.listProjects` / `listDomains` / `latestDeployment`; never deploys or prints a token. A missing token, a 401 or 403, or a provider that cannot read it is a skip. Read-only |
|
|
683
683
|
| `holocron doctor environments` | Do the deployment environments exist? The ones `setup` creates (`staging`, `production`, when an `environments` provider is configured) plus every environment `repo.secrets.environments` names. One row. A missing one fails; an extra one is never a problem; no provider with some named is a skip |
|
|
684
684
|
| `holocron doctor project [--post [channel]]` | Does each board `providers.projects.boards` declares exist and match its template? One row per board, status list, field, view and automation rule; the board's extras and the items `reconcile project` would fix (no status, closed but not done, open blocker but not blocked, blocked without a blocker) are `info` rows, never a failure. A template file that does not read fails, naming the file. Read-only; `--post` shares the failing rows through the `notifications` bot. |
|
|
685
|
-
| `holocron doctor repo` | Do the repository settings `setup` writes match the config? One row per group the config declares: description and homepage, default branch and merge settings, topics, custom properties, team access, branch protection; labels and security settings are always checked, plus a `repo-area-labels` row when `repo.labels.areas` is declared (a declared area with no `area:<name>` label fails; an undeclared `area:` label is an `info` note). Read-only. Reads through optional `Source` methods (`getRepoInfo`, `getProperties`, `listLabels`, `listTeamAccess`, `getRulesetDetail`, `getSecurity`); a group that cannot be read is a skip, not a failure
|
|
685
|
+
| `holocron doctor repo` | Do the repository settings `setup` writes match the config? One row per group the config declares: description and homepage, default branch and merge settings, topics, custom properties, team access, branch protection (and, for `strict`, a `repo-ci-pin` row comparing the App `ci / Required checks` is pinned to with the opt-in `ci.pin`; skipped, saying the option is off, when unset); labels and security settings are always checked, plus a `repo-area-labels` row when `repo.labels.areas` is declared (a declared area with no `area:<name>` label fails; an undeclared `area:` label is an `info` note). Read-only. Reads through optional `Source` methods (`getRepoInfo`, `getProperties`, `listLabels`, `listTeamAccess`, `getRulesetDetail`, `getSecurity`); a group that cannot be read is a skip, not a failure |
|
|
686
686
|
| `holocron doctor dns` | Do the DNS records the config makes setup write exist, pointing where they should? The preview domain's apex and wildcard CNAMEs (Cloudflare), the docs site a wiki provider asks for, and the relay Worker's proxied placeholder; one row per zone. A missing record, another target or a missing proxy fails; an extra record never does. A record `ensureCustomDomain()` returns is not checked, because asking for it creates the domain |
|
|
687
687
|
| `holocron doctor monitoring` | Do the checks the `monitoring` provider declares exist in its account, matched by name, with the URL, method and (when stated) frequency, locations, tags (a declared tag the check lacks fails; an extra one does not), activated, should-fail, body and assertions the config sets? One row. A check in the account that is not declared is never a problem. A provider that cannot list its checks, could not load or has no token is a skip |
|
|
688
688
|
| `holocron doctor secrets [--env <list>] [--only-secrets \| --only-variables] [--strict] [--name <name>] [--verify] [--shared [--allow NAME]...]` | Prints a matrix of every secret and variable by place (1Password Environments, GitHub, deployments; names only, cells `ok`, `n/a`, `MISSING`, `extra`, `?`) and checks the declared ones. `MISSING` fails; `extra` is info (`--strict` fails; `doctor.manualSecrets` is left out); `--name` explains one name and exits 0 (this and `extra` replace `doctor variable-owners`). `--shared` compares the layers named by `--env` (two or more of `local`, `dev`, `ci`, `prod`; all four by default) for a secret that holds the same value in two of them: it reads each Environment in memory, compares the concealed entries by a salted hash made fresh per run, and prints names only, one row per pair of layers (`info`, shown as skipped; `--strict` fails), plus `info` rows for `ci` variables missing from or different in `dev`; `doctor.sharedVariables` and `--allow` leave out names shared on purpose (the old `doctor secrets`). `--verify` also asks each vendor whether the tokens the plugins take are still accepted (online; fails a rejected token or one with 7 days or fewer left; the old `doctor tokens`). It also checks `repo.variables` (the old `doctor variables`). Do the secrets the config says must exist (`repo.secrets`, plus the notification layout's webhook and role secrets and the Chromatic token) exist? One row for the repository, the organization and each environment, each only when something is expected there. Names only; an undeclared secret is never a problem. `--env` takes a comma-separated or repeated list of `local`, `dev`, `ci`, `test`, `prod` and checks only those (`ci` the GitHub secrets, `prod` the deploy destinations; `local`, `dev` and `test` are a skipped row that says why). A scope that cannot be read is a skip |
|
package/dist/cli.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { appendFileSync, closeSync, copyFileSync, existsSync, fstatSync, lstatSy
|
|
|
14
14
|
import { DRY_RUN_NOOP_EXIT_CODE, createCommandRegistry, createMenu, numeric } from "@theholocron/kyber/menu";
|
|
15
15
|
import { Entry, findCredentials } from "@napi-rs/keyring";
|
|
16
16
|
import { AuthError, DOTENV_FILE, copyToClipboard, createFeatureResolver as createFeatureResolver$1, createKeyring, createPrivateFile, dotenvLine, findCredential, finishCredentialsFile, hasCredentials, isGitIgnored, readDotenvFile, resolveValue as resolveValue$1, resolveValue as resolveValue$2, setCredentials, writeCredentialsFile } from "@theholocron/kyber/secrets";
|
|
17
|
-
import { 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, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, postAggregate, readWorkspacePackages, recordDeploys, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
|
|
17
|
+
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, generateThinCallerContent, hostedReusableWorkflows, isDeprecated, isTask, legacyCaller, legacyCallerFile, legacyGate, legacyWorkflowKey, localize, localizeActions, mergeScripts, packageLocation, postAggregate, readWorkspacePackages, recordDeploys, resolveTaskName, reusableTemplates, scriptName, stampDeprecated, wedgeFix, workflowFile, workflowKey, workflowKeys, workspacePackages as workspacePackages$1 } from "@theholocron/astromech";
|
|
18
18
|
import { loadTasksConfig, releaseGroups } from "@theholocron/astromech/config";
|
|
19
19
|
import { createCliLogger, createCliTelemetry } from "@theholocron/kyber/observability";
|
|
20
20
|
import { resolveAxiomFromEnv } from "@theholocron/observability/logger";
|
|
@@ -3158,6 +3158,8 @@ function resolveConfig(raw) {
|
|
|
3158
3158
|
if (docsCoverage !== void 0 && !DOCS_COVERAGE_MODES.includes(docsCoverage)) throw new ConfigError(`\`repoValidation.docsCoverage\` must be one of ${DOCS_COVERAGE_MODES.map((m) => `"${m}"`).join(", ")}, got ${JSON.stringify(docsCoverage)}`);
|
|
3159
3159
|
const aggregate = raw.ci?.aggregate;
|
|
3160
3160
|
if (aggregate !== void 0 && !CI_AGGREGATE_POSTERS.includes(aggregate)) throw new ConfigError(`\`ci.aggregate\` must be one of ${CI_AGGREGATE_POSTERS.map((m) => `"${m}"`).join(", ")}, got ${JSON.stringify(aggregate)}`);
|
|
3161
|
+
const pin = raw.ci?.pin;
|
|
3162
|
+
if (pin !== void 0 && (typeof pin !== "object" || pin === null || !Number.isSafeInteger(pin.integrationId) || pin.integrationId <= 0)) throw new ConfigError(`\`ci.pin.integrationId\` must be a positive integer (the GitHub App's id), got ${JSON.stringify(pin)}`);
|
|
3161
3163
|
if (raw.credentials !== void 0) {
|
|
3162
3164
|
const environment = raw.credentials.environment;
|
|
3163
3165
|
if (typeof environment !== "string" || environment.trim() === "") throw new ConfigError("`credentials.environment` must be the name of an environment, got an empty value");
|
|
@@ -16346,6 +16348,21 @@ async function issueTypesRow(declared, issues, whyNoIssues) {
|
|
|
16346
16348
|
problems: []
|
|
16347
16349
|
};
|
|
16348
16350
|
}
|
|
16351
|
+
// src/commands/aggregate-pin/aggregate-pin.ts
|
|
16352
|
+
/**
|
|
16353
|
+
* Reads `ci.pin` against the repo's derived required checks. Off (no pin, `problem` unset) when the option is not set;
|
|
16354
|
+
* only the `ci / Required checks` context is ever pinned, never the other required checks. When the option is set but
|
|
16355
|
+
* that context is not required (a repo on the legacy gate, or a preset that requires nothing), nothing is pinned and
|
|
16356
|
+
* `problem` says why, so neither `setup` nor `doctor repo` pretends the pin is in place.
|
|
16357
|
+
*/
|
|
16358
|
+
function aggregatePin(ci, requiredChecks) {
|
|
16359
|
+
if (ci?.pin === void 0) return { pins: {} };
|
|
16360
|
+
if (!requiredChecks.includes(AGGREGATE_CHECK)) return {
|
|
16361
|
+
pins: {},
|
|
16362
|
+
problem: `ci.pin is set but ${AGGREGATE_CHECK} is not a required check of this repo`
|
|
16363
|
+
};
|
|
16364
|
+
return { pins: { [AGGREGATE_CHECK]: ci.pin.integrationId } };
|
|
16365
|
+
}
|
|
16349
16366
|
// src/commands/repo-files/hosted-reusables.ts
|
|
16350
16367
|
/** The name of the private package that holds the reusable workflows and composite actions. */
|
|
16351
16368
|
const CI_PACKAGE = "@theholocron/ci";
|
|
@@ -16400,7 +16417,11 @@ function buildClassicProtectionPayload(requiredChecks = []) {
|
|
|
16400
16417
|
allow_deletions: false
|
|
16401
16418
|
};
|
|
16402
16419
|
}
|
|
16403
|
-
|
|
16420
|
+
/**
|
|
16421
|
+
* The ruleset `setup` writes. `pins` maps a required context to the integration id of the one GitHub App whose check
|
|
16422
|
+
* may satisfy it (written as `integration_id` on that entry); a context with no entry may be satisfied by any app.
|
|
16423
|
+
*/
|
|
16424
|
+
function buildRulesetPayload(requiredChecks = [], pins = {}) {
|
|
16404
16425
|
const rules = [
|
|
16405
16426
|
{ type: "deletion" },
|
|
16406
16427
|
{ type: "non_fast_forward" },
|
|
@@ -16419,7 +16440,10 @@ function buildRulesetPayload(requiredChecks = []) {
|
|
|
16419
16440
|
if (requiredChecks.length > 0) rules.push({
|
|
16420
16441
|
type: "required_status_checks",
|
|
16421
16442
|
parameters: {
|
|
16422
|
-
required_status_checks: requiredChecks.map((context) =>
|
|
16443
|
+
required_status_checks: requiredChecks.map((context) => pins[context] === void 0 ? { context } : {
|
|
16444
|
+
context,
|
|
16445
|
+
integration_id: pins[context]
|
|
16446
|
+
}),
|
|
16423
16447
|
strict_required_status_checks_policy: false
|
|
16424
16448
|
}
|
|
16425
16449
|
});
|
|
@@ -16439,7 +16463,7 @@ function buildRulesetPayload(requiredChecks = []) {
|
|
|
16439
16463
|
rules
|
|
16440
16464
|
};
|
|
16441
16465
|
}
|
|
16442
|
-
async function upsertBranchProtection(source, dryRun, requiredChecks) {
|
|
16466
|
+
async function upsertBranchProtection(source, dryRun, requiredChecks, pins = {}) {
|
|
16443
16467
|
const step = `upsert ruleset ${RULESET_NAME}`;
|
|
16444
16468
|
if (dryRun) return {
|
|
16445
16469
|
capability: "source",
|
|
@@ -16449,7 +16473,7 @@ async function upsertBranchProtection(source, dryRun, requiredChecks) {
|
|
|
16449
16473
|
try {
|
|
16450
16474
|
const found = (await source.listRulesets()).find((r) => r.name === RULESET_NAME);
|
|
16451
16475
|
if (found) {
|
|
16452
|
-
await source.updateRuleset(found.id, buildRulesetPayload(requiredChecks));
|
|
16476
|
+
await source.updateRuleset(found.id, buildRulesetPayload(requiredChecks, pins));
|
|
16453
16477
|
return {
|
|
16454
16478
|
capability: "source",
|
|
16455
16479
|
step,
|
|
@@ -16457,7 +16481,7 @@ async function upsertBranchProtection(source, dryRun, requiredChecks) {
|
|
|
16457
16481
|
message: "updated"
|
|
16458
16482
|
};
|
|
16459
16483
|
}
|
|
16460
|
-
await source.createRuleset(buildRulesetPayload(requiredChecks));
|
|
16484
|
+
await source.createRuleset(buildRulesetPayload(requiredChecks, pins));
|
|
16461
16485
|
return {
|
|
16462
16486
|
capability: "source",
|
|
16463
16487
|
step,
|
|
@@ -16707,6 +16731,22 @@ const BALANCED_REPO_SETTINGS = {
|
|
|
16707
16731
|
has_projects: true,
|
|
16708
16732
|
has_wiki: false
|
|
16709
16733
|
};
|
|
16734
|
+
// src/commands/doctor-repo/pinned-sources.ts
|
|
16735
|
+
/**
|
|
16736
|
+
* Compares the app each required context is pinned to with the declared pins: one line per declared pin the ruleset
|
|
16737
|
+
* lacks or sets to another app, and one per pin the ruleset holds that nothing declares (the option was turned off or
|
|
16738
|
+
* the id changed). Empty when they match. Ids are the integration ids of GitHub Apps, never credentials.
|
|
16739
|
+
*/
|
|
16740
|
+
function comparePinnedSources(declared, found) {
|
|
16741
|
+
const problems = [];
|
|
16742
|
+
for (const [context, id] of Object.entries(declared)) {
|
|
16743
|
+
const actual = found[context];
|
|
16744
|
+
if (actual === void 0) problems.push(`${context} is not pinned (declared app ${id}; any app may satisfy it)`);
|
|
16745
|
+
else if (actual !== id) problems.push(`${context} is pinned to app ${actual}, declared app ${id}`);
|
|
16746
|
+
}
|
|
16747
|
+
for (const [context, id] of Object.entries(found)) if (declared[context] === void 0) problems.push(`${context} is pinned to app ${id} but ci.pin does not declare it`);
|
|
16748
|
+
return problems;
|
|
16749
|
+
}
|
|
16710
16750
|
// src/commands/doctor-repo/required-contexts.ts
|
|
16711
16751
|
/**
|
|
16712
16752
|
* Compares the ruleset's required status-check contexts with the ones `requiredChecks()` (from
|
|
@@ -16934,6 +16974,33 @@ function repoChecks(config, repoRoot, statusContexts) {
|
|
|
16934
16974
|
};
|
|
16935
16975
|
}
|
|
16936
16976
|
});
|
|
16977
|
+
if (preset === "strict") checks.push({
|
|
16978
|
+
id: "repo-ci-pin",
|
|
16979
|
+
title: "ci / Required checks is pinned to the declared app",
|
|
16980
|
+
needs: "getRulesetDetail",
|
|
16981
|
+
async run(source) {
|
|
16982
|
+
const plan = aggregatePin(config.ci, strictChecks(config, repoRoot, statusContexts));
|
|
16983
|
+
if (plan.problem) return {
|
|
16984
|
+
problems: [plan.problem],
|
|
16985
|
+
checked: 1
|
|
16986
|
+
};
|
|
16987
|
+
let rulesets;
|
|
16988
|
+
try {
|
|
16989
|
+
rulesets = await source.listRulesets();
|
|
16990
|
+
} catch (err) {
|
|
16991
|
+
if (err instanceof ProviderApiError && err.status === 403) return { skip: "rulesets are not available on this plan" };
|
|
16992
|
+
throw err;
|
|
16993
|
+
}
|
|
16994
|
+
const found = rulesets.find((r) => r.name === RULESET_NAME);
|
|
16995
|
+
if (!found) return { skip: `no ruleset ${RULESET_NAME} (see repo-protection)` };
|
|
16996
|
+
const actual = (await source.getRulesetDetail(found.id)).requiredCheckSources ?? {};
|
|
16997
|
+
if (Object.keys(plan.pins).length === 0 && Object.keys(actual).length === 0) return { skip: "not pinned: ci.pin is off, so any app may satisfy ci / Required checks" };
|
|
16998
|
+
return {
|
|
16999
|
+
problems: comparePinnedSources(plan.pins, actual),
|
|
17000
|
+
checked: Math.max(Object.keys(plan.pins).length, 1)
|
|
17001
|
+
};
|
|
17002
|
+
}
|
|
17003
|
+
});
|
|
16937
17004
|
checks.push({
|
|
16938
17005
|
id: "repo-security",
|
|
16939
17006
|
title: "security settings match",
|
|
@@ -23182,8 +23249,18 @@ async function runSetup(input) {
|
|
|
23182
23249
|
logger,
|
|
23183
23250
|
...statusContexts ? { statusContexts } : {}
|
|
23184
23251
|
}).requiredChecks(hostsReusables(input.context.repoRoot)) : [];
|
|
23185
|
-
|
|
23252
|
+
const pinPlan = aggregatePin(config.ci, requiredChecks);
|
|
23253
|
+
steps.push(await upsertBranchProtection(source, dryRun, requiredChecks, pinPlan.pins));
|
|
23186
23254
|
print(formatStep(steps[steps.length - 1]));
|
|
23255
|
+
if (pinPlan.problem) {
|
|
23256
|
+
steps.push({
|
|
23257
|
+
capability: "source",
|
|
23258
|
+
step: "pin ci / Required checks",
|
|
23259
|
+
status: "skip",
|
|
23260
|
+
message: pinPlan.problem
|
|
23261
|
+
});
|
|
23262
|
+
print(formatStep(steps[steps.length - 1]));
|
|
23263
|
+
}
|
|
23187
23264
|
}
|
|
23188
23265
|
}
|
|
23189
23266
|
if (loader.has("source")) {
|