@rightkit/release 0.2.20 → 0.2.22

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.
@@ -0,0 +1,76 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtempSync, readFileSync, writeFileSync, mkdirSync, existsSync, rmSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import { spawnSync } from "node:child_process";
6
+ import test from "node:test";
7
+
8
+ import { verifyStandaloneClones } from "./standalone-clone-verify.mjs";
9
+
10
+ function run(command, args, cwd) {
11
+ const result = spawnSync(command, args, { cwd, encoding: "utf8", windowsHide: true });
12
+ assert.equal(result.status, 0, `${command} ${args.join(" ")}\n${result.stderr}`);
13
+ }
14
+
15
+ test("standalone verifier clones, installs, doctors from a nested app root, and removes only its own temp tree", async (t) => {
16
+ const fixtureRoot = mkdtempSync(path.join(tmpdir(), "rightkit-standalone-fixture-"));
17
+ t.after(() => rmSync(fixtureRoot, { recursive: true, force: true }));
18
+ const source = path.join(fixtureRoot, "source");
19
+ const outsideSentinel = path.join(fixtureRoot, "keep.txt");
20
+ mkdirSync(path.join(source, "apps", "desktop"), { recursive: true });
21
+ writeFileSync(outsideSentinel, "keep", "utf8");
22
+ writeFileSync(path.join(source, "apps", "desktop", "package.json"), JSON.stringify({
23
+ name: "standalone-fixture",
24
+ private: true,
25
+ packageManager: "pnpm@11.12.0",
26
+ scripts: { "release:doctor": "node doctor.mjs" },
27
+ }), "utf8");
28
+ writeFileSync(path.join(source, "apps", "desktop", "pnpm-lock.yaml"), "lockfileVersion: '9.0'\nsettings:\n autoInstallPeers: true\n excludeLinksFromLockfile: false\nimporters:\n .: {}\n", "utf8");
29
+ writeFileSync(path.join(source, "apps", "desktop", "doctor.mjs"), "process.stdout.write('fixture doctor passed\\n')\n", "utf8");
30
+ run("git", ["init", "-q"], source);
31
+ run("git", ["config", "user.email", "fixture@example.test"], source);
32
+ run("git", ["config", "user.name", "Fixture"], source);
33
+ run("git", ["add", "."], source);
34
+ run("git", ["commit", "-qm", "fixture"], source);
35
+
36
+ const evidencePath = path.join(fixtureRoot, "evidence.json");
37
+ const result = await verifyStandaloneClones({
38
+ apps: [{ key: "fixture", remote: source, appDir: "apps/desktop" }],
39
+ evidencePath,
40
+ tempParent: fixtureRoot,
41
+ });
42
+
43
+ assert.equal(result.apps[0].install.status, 0);
44
+ assert.equal(result.apps[0].doctor.status, 0);
45
+ assert.match(result.apps[0].doctor.stdout, /fixture doctor passed/);
46
+ assert.equal(existsSync(result.workRoot), false, "generated clone tree must be removed");
47
+ assert.equal(readFileSync(outsideSentinel, "utf8"), "keep", "cleanup must not escape the generated tree");
48
+ assert.deepEqual(JSON.parse(readFileSync(evidencePath, "utf8")).apps.map(({ key }) => key), ["fixture"]);
49
+ });
50
+
51
+ test("release package exposes the local standalone verification lane", () => {
52
+ const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8"));
53
+ assert.equal(pkg.scripts["verify:standalone"], "node standalone-clone-verify.mjs");
54
+ });
55
+
56
+ test("standalone verifier rejects a package root that escapes its clone", async (t) => {
57
+ const fixtureRoot = mkdtempSync(path.join(tmpdir(), "rightkit-standalone-escape-"));
58
+ t.after(() => rmSync(fixtureRoot, { recursive: true, force: true }));
59
+ const source = path.join(fixtureRoot, "source");
60
+ mkdirSync(source, { recursive: true });
61
+ writeFileSync(path.join(source, "README.md"), "fixture", "utf8");
62
+ run("git", ["init", "-q"], source);
63
+ run("git", ["config", "user.email", "fixture@example.test"], source);
64
+ run("git", ["config", "user.name", "Fixture"], source);
65
+ run("git", ["add", "."], source);
66
+ run("git", ["commit", "-qm", "fixture"], source);
67
+
68
+ await assert.rejects(
69
+ verifyStandaloneClones({
70
+ apps: [{ key: "fixture", remote: source, appDir: ".." }],
71
+ evidencePath: path.join(fixtureRoot, "evidence.json"),
72
+ tempParent: fixtureRoot,
73
+ }),
74
+ /package root escapes its clone/,
75
+ );
76
+ });