@rightkit/git 0.2.13 → 0.2.14

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 (3) hide show
  1. package/package.json +1 -1
  2. package/sync.mjs +20 -0
  3. package/sync.test.mjs +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightkit/git",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "Public-repo-only GitHub Actions workflow layer: templates, visibility gate, sync/drift/adopt/uninstall for right-git.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
package/sync.mjs CHANGED
@@ -12,6 +12,22 @@ import { renderTemplate, MANAGED_MARKER } from "./render.mjs";
12
12
  const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
13
13
  const TEMPLATES_DIR = path.join(packageRoot, "templates");
14
14
  const WORKFLOWS_SUBDIR = path.join(".github", "workflows");
15
+ const PUBLISHED_NPM_VERSION = /^\d+\.\d+\.\d+$/;
16
+
17
+ function releaseChainDependencyError(repoPath, manifest) {
18
+ if (!manifest.candidate?.releaseChain) return null;
19
+ let pkg;
20
+ try {
21
+ pkg = JSON.parse(fs.readFileSync(path.join(repoPath, "package.json"), "utf8"));
22
+ } catch {
23
+ return "release-candidate releaseChain requires a readable package.json with direct devDependency @rightkit/release";
24
+ }
25
+ const version = pkg.devDependencies?.["@rightkit/release"];
26
+ if (typeof version !== "string" || !PUBLISHED_NPM_VERSION.test(version)) {
27
+ return "release-candidate releaseChain requires direct devDependency @rightkit/release pinned to a published npm version";
28
+ }
29
+ return null;
30
+ }
15
31
 
16
32
  /** Render every lane declared in the manifest. Returns { lane, filename, content }[]. */
17
33
  export function renderLanes(manifest, repoPath) {
@@ -82,6 +98,10 @@ export async function planSync(repoPath, deps = {}, manifestOverride = null) {
82
98
  if (!loaded.ok) {
83
99
  return { ok: false, stage: "manifest", errors: loaded.errors, changes: [] };
84
100
  }
101
+ const dependencyError = releaseChainDependencyError(repoPath, loaded.manifest);
102
+ if (dependencyError) {
103
+ return { ok: false, stage: "dependency", errors: [dependencyError], changes: [] };
104
+ }
85
105
 
86
106
  const rendered = renderLanes(loaded.manifest, repoPath);
87
107
  const wantedFilenames = new Set(rendered.map((r) => r.filename));
package/sync.test.mjs CHANGED
@@ -54,6 +54,44 @@ test("sync reports manifest errors instead of writing files", async () => {
54
54
  assert.equal(result.stage, "manifest");
55
55
  });
56
56
 
57
+ test("sync rejects a Membrane-like release chain without root @rightkit/release", async () => {
58
+ const manifest = {
59
+ schemaVersion: 1,
60
+ lanes: ["ci", "release-candidate"],
61
+ matrix: { os: ["windows-2025", "macos-15"], node: ["22.23.2"] },
62
+ packageManager: "pnpm@11.24.0",
63
+ templateVersion: "1.5.0",
64
+ profile: "rust-hybrid",
65
+ gate: { path: "scripts/ci/run-ci.sh" },
66
+ candidate: {
67
+ buildScript: "release:candidate:build",
68
+ checkScript: "release:candidate:check",
69
+ artifactRoot: "membrane-release-candidate",
70
+ os: ["windows-2025", "macos-15"],
71
+ signWindows: true,
72
+ signMacos: true,
73
+ releaseChain: {
74
+ windowsFinalizeScript: "release:finalize:windows",
75
+ macosFinalizeScript: "release:finalize:macos",
76
+ installedQualificationScript: "release:qualify:installed",
77
+ publishScript: "release:publish:qualified",
78
+ qualificationRunnerVariable: "MEMBRANE_QUALIFICATION_RUNNER_LABEL",
79
+ },
80
+ },
81
+ };
82
+ const dir = makeTempRepo(manifest, { packageJson: { name: "membrane", devDependencies: { "@rightkit/git": "0.2.13" } } });
83
+ const missing = await syncCommand(dir, { deps: PUBLIC_DEPS });
84
+ assert.equal(missing.ok, false);
85
+ assert.equal(missing.stage, "dependency");
86
+ assert.match(missing.errors[0], /direct devDependency @rightkit\/release/);
87
+ assert.equal(fs.existsSync(path.join(dir, ".github", "workflows")), false);
88
+
89
+ fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify({ name: "membrane", devDependencies: { "@rightkit/git": "0.2.13", "@rightkit/release": "0.2.84" } }), "utf8");
90
+ const present = await syncCommand(dir, { deps: PUBLIC_DEPS });
91
+ assert.equal(present.ok, true);
92
+ assert.ok(fs.existsSync(path.join(dir, ".github", "workflows", "release-candidate.yml")));
93
+ });
94
+
57
95
  test("sync refuses an unmanaged same-name workflow", async () => {
58
96
  const dir = makeTempRepo(SAMPLE_MANIFEST);
59
97
  const target = path.join(dir, ".github", "workflows", "ci.yml");