@theholocron/astromech 5.0.0-alpha.252 → 5.0.0-alpha.254

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.
@@ -1,4 +1,4 @@
1
- import { n as TaskEntry, r as TasksConfig, t as TaskConfigItem } from "../schema.type-B28guVbH.mjs";
1
+ import { n as TaskEntry, r as TasksConfig, t as TaskConfigItem } from "../schema.type-CHShKm-U.mjs";
2
2
  import { Loaded } from "@theholocron/datapad";
3
3
  /**
4
4
  * The `tasks` config shape — the single manifest of what a repo runs.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { r as TasksConfig } from "./schema.type-B28guVbH.mjs";
1
+ import { r as TasksConfig } from "./schema.type-CHShKm-U.mjs";
2
2
  import { ListWorkspacePackagesOptions, WorkspacePackageEntry } from "@theholocron/pkg-utils";
3
3
  interface WorkspacePackage$1 {
4
4
  slug: string;
@@ -250,6 +250,8 @@ interface RunTaskInput extends RunDeps {
250
250
  required?: boolean;
251
251
  /** `turbo --filter=<pkg>` passthrough (monorepo). Ignored when the repo has no `turbo.json`. */
252
252
  filter?: string;
253
+ /** The task entry's `jobs` switches: a sub-job set to `false` (by key or alias) is not run. */
254
+ jobSwitches?: Record<string, boolean>;
253
255
  }
254
256
  interface RunTaskReport {
255
257
  status: "ok" | "fail" | "skip" | "dry-run" | "unknown";
@@ -613,6 +615,11 @@ interface JobDef {
613
615
  * jobs) lives in `WORKFLOW_CHECK_CONTEXTS`.
614
616
  */
615
617
  checkContext: string;
618
+ /**
619
+ * The name a repo's config uses to switch this job off (`jobs: { packageRegistry: false }`),
620
+ * where the job's own key is vague or fixed by the reusable workflow. The key itself works too.
621
+ */
622
+ alias?: string;
616
623
  }
617
624
  interface TaskDef {
618
625
  /**
package/dist/index.mjs CHANGED
@@ -456,9 +456,15 @@ function parseGroups(groups) {
456
456
  * - A push releases every group; a manual run can pick one (and dry-run it) with the
457
457
  * `group` input. A job's `if:` cannot see `matrix`, so the choice is made in `plan`.
458
458
  * - `ungrouped` also releases everything that is in **no** group, together and under the
459
- * repo's plain tags, as the single release did before; it runs first. It takes the same
460
- * per-release inputs as a group (`true` for none). A repo with groups and packages in no
461
- * group needs it, or those packages would stop releasing.
459
+ * repo's plain tags, as the single release did before; it runs **last**, from the branch's
460
+ * current tip (`from-branch-tip`), once every group has released. Packages in no group
461
+ * depend on the groups' packages through `workspace:` ranges, which are rewritten to
462
+ * concrete versions at publish time, so the groups must be on npm first; list `groups` in
463
+ * dependency order (a group before the groups that depend on it). It is skipped if a group
464
+ * failed, so a failed dependency does not leave a package published against a version
465
+ * that is not on npm. It takes the same per-release inputs as a group (`true` for none).
466
+ * A repo with groups and packages in no group needs it, or those packages would stop
467
+ * releasing.
462
468
  * - `shared` entries (and the template's own `dry-run`) go to every release; the
463
469
  * per-group inputs come from the matrix entry.
464
470
  */
@@ -499,18 +505,22 @@ function groupedPublishCaller(base, groups, shared, ungrouped = false) {
499
505
  const ungroupedJob = ungroupedInputs ? [
500
506
  " release:",
501
507
  " name: Release",
502
- " if: ${{ inputs.group == '' || inputs.group == 'all' || inputs.group == 'ungrouped' }}",
508
+ " # last: the packages in no group depend on the groups' packages, which must be on npm first.",
509
+ " # Runs even if the groups were skipped (a manual run picked `ungrouped`), but not if one failed.",
510
+ " needs: [plan, release-groups]",
511
+ " if: >-",
512
+ " ${{ !cancelled() && needs.plan.result == 'success' && needs.release-groups.result != 'failure' &&",
513
+ " (inputs.group == '' || inputs.group == 'all' || inputs.group == 'ungrouped') }}",
503
514
  uses,
504
515
  " with:",
505
516
  ...templateWith,
517
+ " from-branch-tip: true",
506
518
  ...sharedWith,
507
519
  ...Object.entries(ungroupedInputs).map(([key, value]) => ` ${key}: ${yamlScalar(value)}`),
508
- " secrets: inherit",
509
- ""
520
+ " secrets: inherit"
510
521
  ] : [];
511
522
  return [
512
523
  `${head}jobs:`,
513
- ...ungroupedJob,
514
524
  " plan:",
515
525
  " name: Plan",
516
526
  " runs-on: ubuntu-latest",
@@ -534,10 +544,9 @@ function groupedPublishCaller(base, groups, shared, ungrouped = false) {
534
544
  ` ${ungroupedInputs ? "release-groups" : "release"}:`,
535
545
  " name: Release ${{ matrix.group }}",
536
546
  ...ungroupedInputs ? [
537
- " # after the ungrouped release, which pushes its own commit first; still run if it failed or was skipped.",
538
547
  " # Choosing `ungrouped` by hand leaves the plan empty, and a matrix with no entries fails the run.",
539
- " needs: [plan, release]",
540
- " if: ${{ !cancelled() && needs.plan.result == 'success' && needs.plan.outputs.groups != '[]' }}"
548
+ " needs: plan",
549
+ " if: ${{ needs.plan.outputs.groups != '[]' }}"
541
550
  ] : [" needs: plan"],
542
551
  " strategy:",
543
552
  " fail-fast: false",
@@ -548,6 +557,7 @@ function groupedPublishCaller(base, groups, shared, ungrouped = false) {
548
557
  " with:",
549
558
  ...matrixWith,
550
559
  " secrets: inherit",
560
+ ...ungroupedJob.length > 0 ? ["", ...ungroupedJob] : [],
551
561
  ""
552
562
  ].join("\n");
553
563
  }
@@ -621,6 +631,49 @@ const WORKFLOW_CHECK_CONTEXTS = {
621
631
  "delivery.bundleSize": "Audit the Bundle Size / Upload bundle stats to Codecov"
622
632
  };
623
633
  /**
634
+ * Triggers actionlint treats as low-trust: their runs default to read-only
635
+ * cache access, so a reusable-workflow call must cap what the callee may ask
636
+ * for (`cache-call-unrestricted`).
637
+ */
638
+ const LOW_TRUST_TRIGGERS = /* @__PURE__ */ new Set([
639
+ "branch_protection_rule",
640
+ "check_run",
641
+ "check_suite",
642
+ "deployment",
643
+ "deployment_status",
644
+ "discussion",
645
+ "discussion_comment",
646
+ "fork",
647
+ "gollum",
648
+ "image_version",
649
+ "issue_comment",
650
+ "issues",
651
+ "label",
652
+ "milestone",
653
+ "public",
654
+ "pull_request_target",
655
+ "status",
656
+ "watch",
657
+ "workflow_run"
658
+ ]);
659
+ /** Top-level event names of a workflow's `on:` (scalar, flow list, or block mapping). */
660
+ function workflowTriggers(yaml) {
661
+ const onMatch = yaml.match(/^on:[^\S\n]*([^#\n]*)(?:#[^\n]*)?\n((?:[ \t]+[^\n]*\n|\n)*)/m);
662
+ if (!onMatch) return [];
663
+ const inline = onMatch[1].trim();
664
+ if (inline) return inline.replace(/[[\]{}]/g, "").split(",").map((t) => t.trim());
665
+ return [...onMatch[2].matchAll(/^ {2}([a-z_]+):/gm)].map((m) => m[1]);
666
+ }
667
+ /**
668
+ * Cap callee cache access on callers with a low-trust trigger: adds
669
+ * `cache-mode: read` to every reusable-workflow job. Without it the callee
670
+ * could request cache writes despite the trigger's read-only default.
671
+ */
672
+ function withCacheMode(yaml) {
673
+ if (!workflowTriggers(yaml).some((t) => LOW_TRUST_TRIGGERS.has(t))) return yaml;
674
+ return yaml.replace(/^( {4}uses: [^\n]+\n)(?! {4}cache-mode:)/gm, "$1 cache-mode: read\n");
675
+ }
676
+ /**
624
677
  * Generate the thin caller content for a workflow, optionally injecting or
625
678
  * merging `with:` overrides into the jobs block.
626
679
  *
@@ -634,8 +687,9 @@ const WORKFLOW_CHECK_CONTEXTS = {
634
687
  * base template is returned unchanged.
635
688
  */
636
689
  function generateThinCallerContent(name, withOverrides, additionalPaths, logger, comments) {
637
- const base = WORKFLOW_TEMPLATES[name];
638
- if (!base) return "";
690
+ const template = WORKFLOW_TEMPLATES[name];
691
+ if (!template) return "";
692
+ const base = withCacheMode(template);
639
693
  if (name === "delivery.publish" && withOverrides && "groups" in withOverrides) {
640
694
  const { groups, ungrouped, ...shared } = withOverrides;
641
695
  return groupedPublishCaller(base, groups, shared, ungrouped);
@@ -1005,7 +1059,11 @@ const TASKS = {
1005
1059
  "eslint.config.ts",
1006
1060
  "eslint.config.js",
1007
1061
  "eslint.config.mjs",
1008
- "eslint.config.cjs"
1062
+ "eslint.config.cjs",
1063
+ "$TURBO_ROOT$/eslint.config.ts",
1064
+ "$TURBO_ROOT$/eslint.config.js",
1065
+ "$TURBO_ROOT$/eslint.config.mjs",
1066
+ "$TURBO_ROOT$/eslint.config.cjs"
1009
1067
  ],
1010
1068
  outputs: [],
1011
1069
  dependsOn: ["^delivery.build"]
@@ -1056,6 +1114,7 @@ const TASKS = {
1056
1114
  "src/**",
1057
1115
  "package.json",
1058
1116
  "tsdown.config.ts",
1117
+ "$TURBO_ROOT$/tsdown.config.ts",
1059
1118
  "vite.config.ts",
1060
1119
  "rollup.config.ts",
1061
1120
  "tsconfig.json"
@@ -1097,14 +1156,16 @@ const TASKS = {
1097
1156
  tool: "node",
1098
1157
  args: ["scripts/validate-registry.mjs"]
1099
1158
  },
1100
- checkContext: "platform.repoValidation / Validate registry consistency"
1159
+ checkContext: "platform.repoValidation / Validate registry consistency",
1160
+ alias: "packageRegistry"
1101
1161
  },
1102
1162
  docsPresence: {
1103
1163
  local: {
1104
1164
  tool: "node",
1105
1165
  args: ["scripts/validate-docs-presence.mjs"]
1106
1166
  },
1107
- checkContext: "platform.repoValidation / Validate docs presence"
1167
+ checkContext: "platform.repoValidation / Validate docs presence",
1168
+ alias: "docsEnforcement"
1108
1169
  }
1109
1170
  }
1110
1171
  },
@@ -1891,6 +1952,11 @@ function makeRunOne(input) {
1891
1952
  };
1892
1953
  };
1893
1954
  }
1955
+ /** `false` when the repo's config switched this sub-job off, by its key or its alias. */
1956
+ function jobEnabled(name, jobDef, switches) {
1957
+ if (!switches) return true;
1958
+ return switches[name] !== false && (jobDef.alias === void 0 || switches[jobDef.alias] !== false);
1959
+ }
1894
1960
  function runTask(input) {
1895
1961
  const { print, logger, readFile, fileExists, listDir, task, cwd } = input;
1896
1962
  const def = TASKS[task];
@@ -1916,6 +1982,19 @@ function runTask(input) {
1916
1982
  };
1917
1983
  }
1918
1984
  const label = `${task} ${job}`;
1985
+ if (!jobEnabled(job, jobDef, input.jobSwitches)) {
1986
+ const message = `${label} is off in this repo's config (jobs.${jobDef.alias ?? job}: false)`;
1987
+ print(`· ${message}`);
1988
+ logger.debug({
1989
+ task,
1990
+ job,
1991
+ status: "skip"
1992
+ }, `run: ${label}`);
1993
+ return {
1994
+ status: "skip",
1995
+ message
1996
+ };
1997
+ }
1919
1998
  return runUnit(input, label, jobDef.local, makeRunOne({
1920
1999
  ...input,
1921
2000
  task: label
@@ -2055,6 +2134,10 @@ function runAllJobs(input, jobs, passthrough) {
2055
2134
  const reports = [];
2056
2135
  for (const [name, jobDef] of Object.entries(jobs)) {
2057
2136
  const label = `${task} ${name}`;
2137
+ if (!jobEnabled(name, jobDef, input.jobSwitches)) {
2138
+ print(`· ${jobDef.checkContext} — off in this repo's config (jobs.${jobDef.alias ?? name}: false)`);
2139
+ continue;
2140
+ }
2058
2141
  print(`▶ ${jobDef.checkContext}`);
2059
2142
  reports.push(runUnit(perJob, label, jobDef.local, makeRunOne({
2060
2143
  ...perJob,
@@ -2199,6 +2282,7 @@ function runCi(input) {
2199
2282
  listDir: input.listDir,
2200
2283
  lookPath: input.lookPath,
2201
2284
  task: entry.name,
2285
+ ...entry.jobs ? { jobSwitches: entry.jobs } : {},
2202
2286
  cwd: input.cwd,
2203
2287
  dryRun: input.dryRun ?? false,
2204
2288
  required: entry.required === true,
@@ -2638,6 +2722,11 @@ function matchNamespace(config, namespace) {
2638
2722
  * the rest, same as `runCi`'s own loop — so a single invocation surfaces
2639
2723
  * every problem in the namespace at once instead of stopping at the first.
2640
2724
  */
2725
+ /** The `jobs` switches of a task's entry, as a `runTask` input; nothing when it has none. */
2726
+ function jobSwitches(config, name) {
2727
+ const jobs = config.tasks.map(normalizeTaskEntry).find((e) => e.name === name)?.jobs;
2728
+ return jobs ? { jobSwitches: jobs } : {};
2729
+ }
2641
2730
  function runGroup(input) {
2642
2731
  const { print, namespace } = input;
2643
2732
  const names = matchNamespace(input.config, namespace);
@@ -2659,6 +2748,7 @@ function runGroup(input) {
2659
2748
  listDir: input.listDir,
2660
2749
  lookPath: input.lookPath,
2661
2750
  task: name,
2751
+ ...jobSwitches(input.config, name),
2662
2752
  cwd: input.cwd,
2663
2753
  dryRun: input.dryRun ?? false,
2664
2754
  ...input.filter ? { filter: input.filter } : {}
@@ -2692,6 +2782,11 @@ function createAstromech(options) {
2692
2782
  lookPath: options.lookPath ?? realLookPath
2693
2783
  };
2694
2784
  const items = () => (options.config?.tasks ?? []).map((i) => normalizeTaskEntry(i));
2785
+ /** The `jobs` switches of a task's entry in the manifest, as a `runTask` input; nothing when it has none. */
2786
+ const jobSwitchesFor = (task) => {
2787
+ const jobs = items().find((e) => e.name === task)?.jobs;
2788
+ return jobs ? { jobSwitches: jobs } : {};
2789
+ };
2695
2790
  /**
2696
2791
  * Task names this repo's manifest can actually run locally — shared by
2697
2792
  * {@link packageScripts} and by `holocron`'s own interactive task picker.
@@ -2729,7 +2824,8 @@ function createAstromech(options) {
2729
2824
  passthrough: opts.passthrough ?? [],
2730
2825
  dryRun: opts.dryRun ?? false,
2731
2826
  required: opts.required ?? false,
2732
- ...opts.filter ? { filter: opts.filter } : {}
2827
+ ...opts.filter ? { filter: opts.filter } : {},
2828
+ ...jobSwitchesFor(task)
2733
2829
  });
2734
2830
  },
2735
2831
  ci: (opts = {}) => runCi({
@@ -1,4 +1,4 @@
1
- import { r as TasksConfig } from "../schema.type-B28guVbH.mjs";
1
+ import { r as TasksConfig } from "../schema.type-CHShKm-U.mjs";
2
2
  import { defineConfig } from "@theholocron/semantic-release-config";
3
3
  /** Runs `git` with `args` in `cwd`, feeding it `input` on stdin, and returns stdout. */
4
4
  export type GitRun = (args: string[], input: string, cwd: string) => string;
@@ -20,6 +20,12 @@ interface TaskEntry {
20
20
  required?: boolean;
21
21
  /** Per-repo overrides on the same channel the reusable workflow reads. */
22
22
  with?: Record<string, unknown>;
23
+ /**
24
+ * Switch individual sub-jobs of a task off for this repo (`false`), by their registry key or alias:
25
+ * `{ name: "platform.repoValidation", jobs: { packageRegistry: false } }`. A job left out runs. The job's CI
26
+ * check still reports (green, "off in this repo's config"), so a required check never goes missing.
27
+ */
28
+ jobs?: Record<string, boolean>;
23
29
  /** Extra `on.push.paths` entries for the generated CI workflow. */
24
30
  paths?: string[];
25
31
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/astromech",
3
- "version": "5.0.0-alpha.252",
3
+ "version": "5.0.0-alpha.254",
4
4
  "description": "The Holocron task runner — one task manifest drives `holocron run`, `holocron run ci`, the CI workflows, package.json scripts, linters, and required checks.",
5
5
  "keywords": [
6
6
  "ci",
@@ -50,10 +50,10 @@
50
50
  "@commitlint/lint": "^21.2.3",
51
51
  "@commitlint/load": "^21.2.3",
52
52
  "@commitlint/types": "^21.2.3",
53
- "@theholocron/fs-utils": "^1.16.0",
54
- "@theholocron/json-utils": "^1.16.0",
55
- "@theholocron/pkg-utils": "^1.16.0",
56
- "@theholocron/datapad": "5.0.0-alpha.252"
53
+ "@theholocron/datapad": "5.0.0-alpha.254",
54
+ "@theholocron/fs-utils": "^1.16.1-alpha.1",
55
+ "@theholocron/json-utils": "^1.16.1-alpha.1",
56
+ "@theholocron/pkg-utils": "^1.16.1-alpha.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@commitlint/config-conventional": "^21.2.3",
@@ -61,11 +61,7 @@
61
61
  "@semantic-release/release-notes-generator": "^14.1.1",
62
62
  "@theholocron/commitlint-config": "^8.8.0",
63
63
  "@theholocron/eslint-config": "^8.8.2",
64
- "@theholocron/rollup-plugin-transform-template": "^8.8.2",
65
64
  "@theholocron/semantic-release-config": "^8.8.2",
66
- "@theholocron/tsconfig": "^8.8.2",
67
- "@theholocron/tsdown-config": "^8.8.2",
68
- "@theholocron/vitest-config": "^8.8.2",
69
65
  "@types/node": "^26",
70
66
  "@vitest/coverage-v8": "^5.0.5",
71
67
  "@vitest/eslint-plugin": "^1.6.27",
@@ -74,7 +70,11 @@
74
70
  "globals": "^17.11.0",
75
71
  "tsdown": "^0.23.3",
76
72
  "typescript": "^5.9.3",
77
- "vitest": "^5.0.5"
73
+ "vitest": "^5.0.5",
74
+ "@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.3",
75
+ "@theholocron/tsdown-config": "^8.9.0-alpha.3",
76
+ "@theholocron/vitest-config": "^8.9.0-alpha.3",
77
+ "@theholocron/tsconfig": "^8.9.0-alpha.3"
78
78
  },
79
79
  "peerDependencies": {
80
80
  "@semantic-release/commit-analyzer": "^13",