@theholocron/cli 5.0.0-alpha.543 → 5.0.0-alpha.545

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 CHANGED
@@ -329,7 +329,7 @@ posts, instead of reporting pass/fail.
329
329
  `holocron setup` builds the branch-protection required-check list from the
330
330
  manifest, not a hand-maintained array:
331
331
 
332
- In the repo that holds the reusable workflows (holocron itself) the list is `ci / Required checks` and `DCO`. That is the aggregate
332
+ In the repo that holds the reusable workflows the list is `ci / Required checks` and `DCO` (holocron itself sets `ci.aggregate: none` and writes its list down, below). That is the aggregate
333
333
  check (`ci/workflows/ci.yml`, written by `setup` / `sync` as `.github/workflows/ci.ci.yml`): it waits on
334
334
  every `{ required: true }` task, the hand-written checks in `extraRequiredChecks` and the coverage statuses (the `coverage` provider's required ones, `Coverage.statusContexts()`; `codecov/*` by default when none is loaded), and its
335
335
  job summary lists each of them with a link, failing ones first. The DCO check (`validate:dco / Run Developer Certificate of Origin`, Sentinel's) stays its own required context. In any other
@@ -342,6 +342,12 @@ repo, which has no `ci` caller yet, the list is:
342
342
  in CI order, then
343
343
  - the top-level `extraRequiredChecks` (codecov gates, a bundle-build check, …).
344
344
 
345
+ Two settings change that. `ci: { aggregate: "none" }` drops the aggregate even in the repo that holds the reusables: no
346
+ `ci.ci.yml`, no `ci.yml` reusable, and the list above is the one that applies there. And `repo.requiredChecks`
347
+ (usually in `.holocron/repo.ts`) writes the list down: when it is set it is the whole list, `setup` writes exactly those
348
+ contexts and `doctor repo` compares the ruleset with them, so the DCO check and each task's context are entries like any
349
+ other. It must be a non-empty list of distinct, non-blank contexts, or the config does not load.
350
+
345
351
  ```ts
346
352
  export default defineConfig({
347
353
  tasks: [
package/dist/cli.mjs CHANGED
@@ -3017,6 +3017,24 @@ function validateRepoLabels(labels) {
3017
3017
  if (!Array.isArray(repos)) throw new ConfigError$1("`repo.labels.repos` is a list of `owner/name` repositories");
3018
3018
  for (const repo of repos) if (typeof repo !== "string" || !REPOSITORY.test(repo)) throw new ConfigError$1(`\`repo.labels.repos\` has ${JSON.stringify(repo)}, which is not an \`owner/name\` repository`);
3019
3019
  }
3020
+ // src/config/validate-required-checks/validate-required-checks.ts
3021
+ /**
3022
+ * Checks `repo.requiredChecks`, the list of status-check contexts a `strict` ruleset requires, when a repo writes it down
3023
+ * (`.holocron/repo.ts`) instead of leaving `holocron setup` to derive it from the tasks. Each entry is the context as GitHub
3024
+ * shows it (`test:unit / Run unit tests and collect coverage`), so a blank one, a non-string and a repeat are errors named
3025
+ * by position. An empty list is refused too: a ruleset that requires nothing is `protection: "none"`, not this.
3026
+ */
3027
+ function validateRequiredChecks(checks) {
3028
+ if (checks === void 0) return;
3029
+ if (!Array.isArray(checks) || checks.length === 0) throw new ConfigError$1("`repo.requiredChecks` is a non-empty list of status-check contexts");
3030
+ const seen = /* @__PURE__ */ new Set();
3031
+ checks.forEach((context, index) => {
3032
+ const at = `\`repo.requiredChecks[${index}]\``;
3033
+ if (typeof context !== "string" || context.trim() === "") throw new ConfigError$1(`${at} needs a status-check context, such as "typecheck / Run typecheck"`);
3034
+ if (seen.has(context)) throw new ConfigError$1(`${at}: "${context}" is listed twice`);
3035
+ seen.add(context);
3036
+ });
3037
+ }
3020
3038
  // src/credentials-environments/repo-slug/repo-slug.ts
3021
3039
  /**
3022
3040
  * The `<org>/<repo>` of the repository at `cwd`, from its `origin` remote. A remote that is missing or cannot be
@@ -3274,7 +3292,11 @@ const DOCS_COVERAGE_MODES = [
3274
3292
  "required"
3275
3293
  ];
3276
3294
  /** The values `ci.aggregate` accepts. */
3277
- const CI_AGGREGATE_POSTERS = ["actions", "sentinel"];
3295
+ const CI_AGGREGATE_POSTERS = [
3296
+ "actions",
3297
+ "sentinel",
3298
+ "none"
3299
+ ];
3278
3300
  /**
3279
3301
  * The environment a `credentials` provider reads: its own `environment` option when it has one, else the shared
3280
3302
  * `credentials.environment`, else `undefined`. The option lets each of several providers name its own (a 1Password
@@ -3314,6 +3336,7 @@ function resolveConfig(raw) {
3314
3336
  if (raw.ideas !== void 0) validateIdeas(raw.ideas);
3315
3337
  if (raw.issueTypes !== void 0) validateIssueTypes(raw.issueTypes);
3316
3338
  validateRepoLabels(raw.repo?.labels);
3339
+ validateRequiredChecks(raw.repo?.requiredChecks);
3317
3340
  validateVariablesSync(raw.repo?.variables);
3318
3341
  validateSecretsDeploy(raw.repo?.secrets);
3319
3342
  validateSecretsSync(raw.repo?.secrets);
@@ -11755,6 +11778,16 @@ const byId = (ids) => new Map(ids.map((id) => [id, id]));
11755
11778
  function aggregateRow(callers, derived, poster = "actions") {
11756
11779
  const id = "aggregate";
11757
11780
  const title = "ci aggregate lists the configured tasks";
11781
+ if (poster === "none") {
11782
+ const left = callers.find((caller) => caller.file === "ci.ci.yml" || caller.file === "ci.yml");
11783
+ return left === void 0 ? {
11784
+ id,
11785
+ title,
11786
+ status: "ok",
11787
+ detail: "there is no aggregate (ci.aggregate: none); the ruleset requires each check on its own",
11788
+ problems: []
11789
+ } : problemRow(id, title, [`${left.file} is still there, but ci.aggregate says there is no aggregate`], "");
11790
+ }
11758
11791
  if (poster === "sentinel") {
11759
11792
  const left = callers.find((caller) => caller.file === "ci.ci.yml" || caller.file === "ci.yml");
11760
11793
  return left === void 0 ? {
@@ -17121,6 +17154,17 @@ function aggregatePin(ci, requiredChecks) {
17121
17154
  };
17122
17155
  return { pins: { [AGGREGATE_CHECK]: ci.pin.integrationId } };
17123
17156
  }
17157
+ // src/commands/declared-required-checks/declared-required-checks.ts
17158
+ /**
17159
+ * The status-check contexts the repo writes down in `repo.requiredChecks` (`.holocron/repo.ts`), de-duplicated and in the
17160
+ * order given, or `undefined` when it leaves the list out and `holocron setup` derives it from the task manifest
17161
+ * (`astromech.requiredChecks()`). A declared list is the whole list: nothing is added to it (not the DCO check, not a
17162
+ * task's context), so what the ruleset requires is what the file says. `setup` writes it and `doctor repo` compares it.
17163
+ */
17164
+ function declaredRequiredChecks(repo) {
17165
+ const declared = repo?.requiredChecks;
17166
+ return declared === void 0 ? void 0 : [...new Set(declared)];
17167
+ }
17124
17168
  // src/commands/repo-files/hosted-reusables.ts
17125
17169
  /** The name of the private package that holds the reusable workflows and composite actions. */
17126
17170
  const CI_PACKAGE = "@theholocron/ci";
@@ -17804,8 +17848,11 @@ function declaredProperties(config) {
17804
17848
  }
17805
17849
  /** The status checks a `strict` ruleset requires, derived from the task manifest exactly as `setup` does. */
17806
17850
  function strictChecks(config, repoRoot, statusContexts) {
17851
+ const declared = declaredRequiredChecks(config.repo);
17852
+ if (declared !== void 0) return declared;
17807
17853
  const tasksConfig = { tasks: config.tasks };
17808
17854
  if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
17855
+ if (config.ci) tasksConfig.ci = config.ci;
17809
17856
  return createAstromech({
17810
17857
  cwd: repoRoot,
17811
17858
  config: tasksConfig,
@@ -22916,7 +22963,7 @@ function generateWorkflowFiles(input) {
22916
22963
  });
22917
22964
  }
22918
22965
  for (const [id, content] of hostedReusableWorkflows()) {
22919
- if (id === "ci" && astromech.aggregatePoster() === "sentinel") continue;
22966
+ if (id === "ci" && astromech.aggregatePoster() !== "actions") continue;
22920
22967
  const filename = workflowFile(id);
22921
22968
  entries.push({
22922
22969
  kind: "file",
@@ -24001,7 +24048,8 @@ async function runSetup(input) {
24001
24048
  print(formatStep(steps[steps.length - 1]));
24002
24049
  const tasksConfig = { tasks: config.tasks };
24003
24050
  if (config.extraRequiredChecks) tasksConfig.extraRequiredChecks = config.extraRequiredChecks;
24004
- const requiredChecks = effectivePreset === "strict" ? createAstromech({
24051
+ if (config.ci) tasksConfig.ci = config.ci;
24052
+ const requiredChecks = effectivePreset === "strict" ? declaredRequiredChecks(config.repo) ?? createAstromech({
24005
24053
  cwd: input.context.repoRoot,
24006
24054
  config: tasksConfig,
24007
24055
  logger,
@@ -34173,8 +34221,9 @@ async function runReconcileCi(input) {
34173
34221
  print(style.header(`Holocron reconcile ci${dryRun ? " (dry-run)" : ""}`));
34174
34222
  print("");
34175
34223
  if (input.maxAgeMinutes !== void 0 && !(input.maxAgeMinutes > 0)) return fail("max-age", "--max-age is a number of minutes above zero");
34176
- if (!input.shadow && aggregatePoster({ ci: input.loaded.resolved.ci }) === "actions") {
34177
- rows.push(row$5("ci.aggregate", "skip", `ci.aggregate is actions here, so the Actions job posts ${AGGREGATE_CHECK_NAME} and nothing is posted; --shadow repairs Sentinel's shadow check`));
34224
+ const poster = aggregatePoster({ ci: input.loaded.resolved.ci });
34225
+ if (!input.shadow && poster !== "sentinel") {
34226
+ rows.push(row$5("ci.aggregate", "skip", poster === "none" ? `ci.aggregate is none here, so there is no ${AGGREGATE_CHECK_NAME} to post; --shadow repairs Sentinel's shadow check` : `ci.aggregate is actions here, so the Actions job posts ${AGGREGATE_CHECK_NAME} and nothing is posted; --shadow repairs Sentinel's shadow check`));
34178
34227
  return finish();
34179
34228
  }
34180
34229
  const providers = input.loaded.resolved.providers;