@theholocron/astromech 5.0.0-alpha.253 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +46 -2
  2. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -631,6 +631,49 @@ const WORKFLOW_CHECK_CONTEXTS = {
631
631
  "delivery.bundleSize": "Audit the Bundle Size / Upload bundle stats to Codecov"
632
632
  };
633
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
+ /**
634
677
  * Generate the thin caller content for a workflow, optionally injecting or
635
678
  * merging `with:` overrides into the jobs block.
636
679
  *
@@ -644,8 +687,9 @@ const WORKFLOW_CHECK_CONTEXTS = {
644
687
  * base template is returned unchanged.
645
688
  */
646
689
  function generateThinCallerContent(name, withOverrides, additionalPaths, logger, comments) {
647
- const base = WORKFLOW_TEMPLATES[name];
648
- if (!base) return "";
690
+ const template = WORKFLOW_TEMPLATES[name];
691
+ if (!template) return "";
692
+ const base = withCacheMode(template);
649
693
  if (name === "delivery.publish" && withOverrides && "groups" in withOverrides) {
650
694
  const { groups, ungrouped, ...shared } = withOverrides;
651
695
  return groupedPublishCaller(base, groups, shared, ungrouped);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/astromech",
3
- "version": "5.0.0-alpha.253",
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/datapad": "5.0.0-alpha.253",
54
- "@theholocron/pkg-utils": "^1.16.1-alpha.1",
53
+ "@theholocron/datapad": "5.0.0-alpha.254",
54
+ "@theholocron/fs-utils": "^1.16.1-alpha.1",
55
55
  "@theholocron/json-utils": "^1.16.1-alpha.1",
56
- "@theholocron/fs-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",
@@ -72,9 +72,9 @@
72
72
  "typescript": "^5.9.3",
73
73
  "vitest": "^5.0.5",
74
74
  "@theholocron/rollup-plugin-transform-template": "^8.9.0-alpha.3",
75
- "@theholocron/tsconfig": "^8.9.0-alpha.3",
76
75
  "@theholocron/tsdown-config": "^8.9.0-alpha.3",
77
- "@theholocron/vitest-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",