packaging.test.ts 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. import { execFile } from "node:child_process";
  2. import { createHash } from "node:crypto";
  3. import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises";
  4. import { tmpdir } from "node:os";
  5. import { join } from "node:path";
  6. import { fileURLToPath } from "node:url";
  7. import { promisify } from "node:util";
  8. import { gunzipSync } from "node:zlib";
  9. import { afterEach, describe, expect, it } from "vitest";
  10. import { list as listTar } from "tar";
  11. import {
  12. collectBareModuleSpecifiers,
  13. isNodePtyRuntimePath,
  14. resolveProductionPackageClosure,
  15. stageRelease,
  16. } from "../src/packaging/stage.js";
  17. import {
  18. assertNodePtyNativeMatchesJs,
  19. isTargetSpecificPackage,
  20. } from "../src/packaging/stageDependencies.js";
  21. import { resolveHostTarCommand } from "../src/packaging/tarCommand.js";
  22. import { runPackagingCommand } from "../src/packaging/stageArchives.js";
  23. const execFileAsync = promisify(execFile);
  24. async function runTar(args: string[]): Promise<void> {
  25. await execFileAsync(resolveHostTarCommand(), args);
  26. }
  27. const temporaryDirs: string[] = [];
  28. const macIt = process.platform === "darwin" ? it : it.skip;
  29. describe("POSIX archive executable modes", () => {
  30. it.each([".", "zcode-server-linux-x64"])(
  31. "writes executable metadata without relying on host file modes (%s)",
  32. async (prefix) => {
  33. const cwd = await makeTempDir();
  34. const archivePath = join(await makeTempDir(), "release.tar.gz");
  35. const executables = [
  36. "bin/zcode",
  37. "runtime/node",
  38. "runtime/tools/bfs/bfs",
  39. "runtime/tools/ripgrep/rg",
  40. "runtime/tools/ugrep/ugrep",
  41. "runtime/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper",
  42. ];
  43. for (const path of [...executables, "runtime/server-cli.js", "runtime/tools/bfs/LICENSE"]) {
  44. const file = join(cwd, prefix, path);
  45. await mkdir(join(file, ".."), { recursive: true });
  46. // 模拟 Windows staging:NTFS 无 POSIX 执行位,归档必须按目标布局写入它。
  47. await writeFile(file, "fixture", { mode: 0o644 });
  48. }
  49. await runPackagingCommand("tar", ["-czf", archivePath, prefix], cwd);
  50. const modes = new Map<string, number>();
  51. await listTar({
  52. file: archivePath,
  53. onReadEntry: (entry) => {
  54. modes.set(entry.path.replace(/^\.\//u, ""), entry.mode ?? 0);
  55. },
  56. });
  57. const archiveName = (path: string) => (prefix === "." ? path : `${prefix}/${path}`);
  58. for (const path of executables) expect(modes.get(archiveName(path))! & 0o777).toBe(0o755);
  59. for (const path of ["runtime/server-cli.js", "runtime/tools/bfs/LICENSE"])
  60. expect(modes.get(archiveName(path))! & 0o111).toBe(0);
  61. },
  62. );
  63. });
  64. async function makeTempDir(): Promise<string> {
  65. const dir = await mkdtemp(join(tmpdir(), "zcode-server-stage-test-"));
  66. temporaryDirs.push(dir);
  67. return dir;
  68. }
  69. afterEach(async () => {
  70. await Promise.all(
  71. temporaryDirs.splice(0).map((dir) => rm(dir, { force: true, recursive: true })),
  72. );
  73. });
  74. interface FakePackageSpec {
  75. version?: string;
  76. dependencies?: Record<string, string>;
  77. optionalDependencies?: Record<string, string>;
  78. devDependencies?: Record<string, string>;
  79. files?: Record<string, string>;
  80. }
  81. async function writeFakePackage(
  82. nodeModulesDir: string,
  83. name: string,
  84. spec: FakePackageSpec = {},
  85. ): Promise<string> {
  86. const packageDir = join(nodeModulesDir, ...name.split("/"));
  87. await mkdir(packageDir, { recursive: true });
  88. await writeFile(
  89. join(packageDir, "package.json"),
  90. JSON.stringify({
  91. name,
  92. version: spec.version ?? "0.0.1",
  93. main: "./index.js",
  94. dependencies: spec.dependencies,
  95. optionalDependencies: spec.optionalDependencies,
  96. devDependencies: spec.devDependencies,
  97. }),
  98. "utf8",
  99. );
  100. await writeFile(join(packageDir, "index.js"), "module.exports = {};\n", "utf8");
  101. for (const [relativePath, contents] of Object.entries(spec.files ?? {})) {
  102. const filePath = join(packageDir, ...relativePath.split("/"));
  103. await mkdir(join(filePath, ".."), { recursive: true });
  104. await writeFile(filePath, contents, "utf8");
  105. }
  106. return packageDir;
  107. }
  108. describe("collectBareModuleSpecifiers", () => {
  109. it("extracts bare imports, dynamic imports and requires as package names", () => {
  110. const source = [
  111. 'import { Hono } from "hono";',
  112. 'import { serve } from "@hono/node-server";',
  113. 'const pty = await import("node-pty");',
  114. 'const utils = require("node-pty/lib/utils");',
  115. ].join("\n");
  116. const names = collectBareModuleSpecifiers(source);
  117. expect(names).toContain("hono");
  118. expect(names).toContain("@hono/node-server");
  119. expect(names).toContain("node-pty");
  120. });
  121. it("ignores node builtins and relative specifiers", () => {
  122. const source = [
  123. 'import { readFile } from "node:fs/promises";',
  124. 'import local from "./local.js";',
  125. 'import parent from "../parent.js";',
  126. ].join("\n");
  127. expect(collectBareModuleSpecifiers(source).size).toBe(0);
  128. });
  129. });
  130. describe("resolveProductionPackageClosure", () => {
  131. it("collects transitive production dependencies but not dev dependencies", async () => {
  132. const root = await makeTempDir();
  133. const nodeModulesDir = join(root, "node_modules");
  134. await writeFakePackage(nodeModulesDir, "pkg-a", {
  135. dependencies: { "pkg-b": "*" },
  136. devDependencies: { "pkg-dev": "*" },
  137. });
  138. await writeFakePackage(nodeModulesDir, "pkg-b", {
  139. dependencies: { "@scope/pkg-c": "*" },
  140. });
  141. await writeFakePackage(nodeModulesDir, "@scope/pkg-c");
  142. await writeFakePackage(nodeModulesDir, "pkg-dev");
  143. const closure = await resolveProductionPackageClosure(["pkg-a"], nodeModulesDir);
  144. expect([...closure.keys()].sort()).toEqual(["@scope/pkg-c", "pkg-a", "pkg-b"]);
  145. });
  146. it("skips missing optional dependencies and unknown entry packages", async () => {
  147. const root = await makeTempDir();
  148. const nodeModulesDir = join(root, "node_modules");
  149. await writeFakePackage(nodeModulesDir, "pkg-a", {
  150. optionalDependencies: { "pkg-missing-optional": "*" },
  151. });
  152. const closure = await resolveProductionPackageClosure(
  153. ["pkg-a", "pkg-not-installed"],
  154. nodeModulesDir,
  155. );
  156. expect([...closure.keys()]).toEqual(["pkg-a"]);
  157. });
  158. });
  159. describe("isNodePtyRuntimePath", () => {
  160. it("keeps runtime files and the target platform prebuild only", () => {
  161. expect(isNodePtyRuntimePath("package.json", "linux-x64")).toBe(true);
  162. expect(isNodePtyRuntimePath("lib/index.js", "linux-x64")).toBe(true);
  163. expect(isNodePtyRuntimePath("typings/node-pty.d.ts", "linux-x64")).toBe(true);
  164. expect(isNodePtyRuntimePath("prebuilds/linux-x64/pty.node", "linux-x64")).toBe(true);
  165. expect(isNodePtyRuntimePath("LICENSE", "linux-x64")).toBe(true);
  166. });
  167. it("drops host build outputs, sources and other platform prebuilds", () => {
  168. expect(isNodePtyRuntimePath("build/Release/pty.node", "linux-x64")).toBe(false);
  169. expect(isNodePtyRuntimePath("build/Debug/pty.node", "linux-x64")).toBe(false);
  170. expect(isNodePtyRuntimePath("prebuilds/darwin-arm64/pty.node", "linux-x64")).toBe(false);
  171. expect(isNodePtyRuntimePath("src/unix/pty.cc", "linux-x64")).toBe(false);
  172. expect(isNodePtyRuntimePath("deps/winpty/x.h", "linux-x64")).toBe(false);
  173. expect(isNodePtyRuntimePath("scripts/post-install.js", "linux-x64")).toBe(false);
  174. });
  175. });
  176. describe("assertNodePtyNativeMatchesJs", () => {
  177. it("rejects a native prebuild whose source version differs from the node-pty JS", () => {
  178. // 现场组合:官方 node-pty 1.1.0 JS + @lydell 1.2.0-beta.10 native。
  179. expect(() =>
  180. assertNodePtyNativeMatchesJs({
  181. target: "linux-x64",
  182. jsVersion: "1.1.0",
  183. nativeSource: "@lydell/node-pty-linux-x64",
  184. nativeVersion: "1.2.0-beta.10",
  185. }),
  186. ).toThrow(/node-pty JS 1\.1\.0 .*@lydell\/node-pty-linux-x64 1\.2\.0-beta\.10/);
  187. });
  188. it("accepts JS and native from the same version", () => {
  189. expect(() =>
  190. assertNodePtyNativeMatchesJs({
  191. target: "linux-x64",
  192. jsVersion: "1.2.0-beta.10",
  193. nativeSource: "@lydell/node-pty-linux-x64",
  194. nativeVersion: "1.2.0-beta.10",
  195. }),
  196. ).not.toThrow();
  197. });
  198. });
  199. describe("stageRelease", () => {
  200. async function makeStageFixture(): Promise<{
  201. distDir: string;
  202. workspaceNodeModulesDir: string;
  203. agentBundlePath: string;
  204. bundledSkillsDir: string;
  205. nodeBinaryPath: string;
  206. outputDir: string;
  207. notices: { thirdParty: string; node: string; nodeSource: string };
  208. }> {
  209. const root = await makeTempDir();
  210. const distDir = join(root, "dist");
  211. await mkdir(distDir, { recursive: true });
  212. await writeFile(
  213. join(distDir, "server-cli.js"),
  214. 'import "fake-dep";\nimport "node-pty";\n',
  215. "utf8",
  216. );
  217. await writeFile(join(distDir, "server-core.js"), 'import "node:fs";\n', "utf8");
  218. const workspaceNodeModulesDir = join(root, "node_modules");
  219. await writeFakePackage(workspaceNodeModulesDir, "fake-dep", {
  220. dependencies: { "fake-transitive": "*" },
  221. });
  222. await writeFakePackage(workspaceNodeModulesDir, "fake-transitive");
  223. await writeFakePackage(workspaceNodeModulesDir, "node-pty", {
  224. version: "1.1.0",
  225. files: {
  226. LICENSE: "node-pty license\n",
  227. "lib/index.js": "// official node-pty js\n",
  228. "typings/node-pty.d.ts": "export {};\n",
  229. "build/Release/pty.node": "host-binary",
  230. "prebuilds/darwin-arm64/pty.node": "darwin-binary",
  231. "prebuilds/darwin-arm64/spawn-helper": "darwin-helper",
  232. "prebuilds/win32-x64/pty.node": "windows-binary",
  233. },
  234. });
  235. // 平台包是同版本 node-pty 的 linux 子集:JS 与 native 同在一个包里。
  236. await writeFakePackage(workspaceNodeModulesDir, "@lydell/node-pty-linux-x64", {
  237. version: "1.2.0-beta.10",
  238. files: {
  239. LICENSE: "platform license\n",
  240. "lib/index.js": "// platform node-pty js\n",
  241. "prebuilds/linux-x64/pty.node": "linux-binary",
  242. },
  243. });
  244. const bundledSkillsDir = join(root, "bundled-skills");
  245. await mkdir(join(bundledSkillsDir, "skills/dynamic-workflows"), { recursive: true });
  246. await writeFile(join(bundledSkillsDir, "README.md"), "bundled skills");
  247. await writeFile(join(bundledSkillsDir, "scratch.txt"), "local only");
  248. for (const name of ["SKILL.md", "patterns.md", "examples.md"]) {
  249. await writeFile(join(bundledSkillsDir, "skills/dynamic-workflows", name), `fixture ${name}`);
  250. }
  251. const agentBundlePath = join(root, "zcode.cjs");
  252. await writeFile(agentBundlePath, "// fake agent bundle\n", "utf8");
  253. const nodeBinaryPath = join(root, "node-binary");
  254. await writeFile(nodeBinaryPath, "#!/bin/sh\nexit 0\n", "utf8");
  255. const outputDir = join(root, "out");
  256. const notices = {
  257. thirdParty: "Copyright npm\nComplete terms\n",
  258. node: "Copyright Node\nComplete runtime terms\n",
  259. nodeSource: '{"version":"22.16.0"}\n',
  260. };
  261. return {
  262. distDir,
  263. workspaceNodeModulesDir,
  264. agentBundlePath,
  265. bundledSkillsDir,
  266. nodeBinaryPath,
  267. outputDir,
  268. notices,
  269. };
  270. }
  271. async function writeFakeNativeTools(
  272. toolsDir: string,
  273. tools: Record<string, string>,
  274. ): Promise<void> {
  275. for (const [tool, binaryName] of Object.entries(tools)) {
  276. await mkdir(join(toolsDir, tool), { recursive: true });
  277. await writeFile(join(toolsDir, tool, binaryName), tool, "utf8");
  278. await writeFile(
  279. join(toolsDir, tool, "THIRD-PARTY-NOTICES.txt"),
  280. `Copyright ${tool}\nFull terms\n`,
  281. "utf8",
  282. );
  283. await writeFile(join(toolsDir, tool, "SOURCES.json"), JSON.stringify({ tool }), "utf8");
  284. }
  285. }
  286. it("assembles the release layout for a linux target", async () => {
  287. const fixture = await makeStageFixture();
  288. const staged = await stageRelease({
  289. target: "linux-x64",
  290. appVersion: "9.9.9-test",
  291. archive: false,
  292. ...fixture,
  293. });
  294. const releaseDir = staged.releaseDir;
  295. expect(releaseDir.endsWith("zcode-server-linux-x64")).toBe(true);
  296. expect(
  297. JSON.parse(await readFile(join(releaseDir, "runtime", "package.json"), "utf8")),
  298. ).toMatchObject({
  299. zcodeCredentialFormat: 2,
  300. });
  301. const launcher = await readFile(join(releaseDir, "bin", "zcode"), "utf8");
  302. expect(launcher).toContain('"$DIR/runtime/node"');
  303. expect(launcher).toContain('"$DIR/runtime/server-cli.js"');
  304. const launcherStat = await stat(join(releaseDir, "bin", "zcode"));
  305. // Bugfix: NTFS 不保留 POSIX exec 位(Windows 上 stat.mode 恒无 0o111 位),
  306. // 可执行性断言只在 POSIX 宿主上生效;Windows 宿主仍验证文件存在与内容。
  307. if (process.platform !== "win32") expect(launcherStat.mode & 0o111).not.toBe(0);
  308. const runtimePackageJson = JSON.parse(
  309. await readFile(join(releaseDir, "runtime", "package.json"), "utf8"),
  310. ) as { type?: string };
  311. expect(runtimePackageJson.type).toBe("module");
  312. for (const relativePath of [
  313. "runtime/server-cli.js",
  314. "runtime/server-core.js",
  315. "runtime/zcode.cjs",
  316. "runtime/node",
  317. "runtime/node_modules/fake-dep/package.json",
  318. "runtime/node_modules/fake-transitive/package.json",
  319. "runtime/node_modules/node-pty/lib/index.js",
  320. "runtime/node_modules/node-pty/LICENSE",
  321. "runtime/THIRD-PARTY-NOTICES.md",
  322. "runtime/LICENSE.node.txt",
  323. "runtime/NODE-SOURCES.json",
  324. "runtime/licenses/agent/THIRD-PARTY-NOTICES.md",
  325. "runtime/node_modules/node-pty/prebuilds/linux-x64/pty.node",
  326. ]) {
  327. await expect(stat(join(releaseDir, ...relativePath.split("/")))).resolves.toBeTruthy();
  328. }
  329. const nodeStat = await stat(join(releaseDir, "runtime", "node"));
  330. // Bugfix: 同上,NTFS 无 POSIX exec 位,可执行性断言只在 POSIX 宿主生效。
  331. if (process.platform !== "win32") expect(nodeStat.mode & 0o111).not.toBe(0);
  332. // 交叉打包安全性:宿主编译产物与非目标平台 prebuilds 不进入发行包。
  333. await expect(stat(join(releaseDir, "runtime/node_modules/node-pty/build"))).rejects.toThrow();
  334. await expect(
  335. stat(join(releaseDir, "runtime/node_modules/node-pty/prebuilds/darwin-arm64")),
  336. ).rejects.toThrow();
  337. // linux 平台 pty.node 由 @lydell 平台包补齐。
  338. const linuxPty = await readFile(
  339. join(releaseDir, "runtime/node_modules/node-pty/prebuilds/linux-x64/pty.node"),
  340. "utf8",
  341. );
  342. expect(linuxPty).toBe("linux-binary");
  343. // Bug 回归:旧 staging 只拷平台包的 pty.node(1.2.0-beta.10,resize 要 5 个参数),
  344. // JS 仍是官方 1.1.0(只传 3 个参数),远端终端 resize 必然失败。JS 必须与 native 同包同版本。
  345. const stagedNodePty = JSON.parse(
  346. await readFile(join(releaseDir, "runtime/node_modules/node-pty/package.json"), "utf8"),
  347. ) as { version: string };
  348. expect(stagedNodePty.version).toBe("1.2.0-beta.10");
  349. await expect(
  350. readFile(join(releaseDir, "runtime/node_modules/node-pty/lib/index.js"), "utf8"),
  351. ).resolves.toBe("// platform node-pty js\n");
  352. await expect(stat(join(releaseDir, "runtime/node_modules/node-pty/typings"))).rejects.toThrow();
  353. const manifest = JSON.parse(await readFile(join(releaseDir, "manifest.json"), "utf8")) as {
  354. product: string;
  355. target: string;
  356. appVersion: string;
  357. nodeVersion: string;
  358. entrypoints: { cli: string; core: string; agent: string };
  359. };
  360. expect(manifest.product).toBe("zcode-server");
  361. expect(manifest.target).toBe("linux-x64");
  362. expect(manifest.appVersion).toBe("9.9.9-test");
  363. expect(manifest.nodeVersion).toBe("22.16.0");
  364. expect(manifest.entrypoints).toEqual({
  365. cli: "runtime/server-cli.js",
  366. core: "runtime/server-core.js",
  367. agent: "runtime/zcode.cjs",
  368. });
  369. expect(staged.packagedDependencies).toEqual(["fake-dep", "fake-transitive", "node-pty"]);
  370. expect(staged.archivePath).toBeNull();
  371. });
  372. it("fails closed when the linux platform package cannot supply matching node-pty JS", async () => {
  373. const fixture = await makeStageFixture();
  374. // 只有 pty.node、没有 lib 的平台包无法提供同版本 JS;不能退回“官方 JS + 平台 native”混装。
  375. await rm(join(fixture.workspaceNodeModulesDir, "@lydell", "node-pty-linux-x64", "lib"), {
  376. recursive: true,
  377. force: true,
  378. });
  379. await expect(
  380. stageRelease({ target: "linux-x64", appVersion: "9.9.9-test", archive: false, ...fixture }),
  381. ).rejects.toThrow(/@lydell\/node-pty-linux-x64 does not ship node-pty JS/);
  382. });
  383. it("takes the whole linux platform package even when the workspace node-pty already has a linux native", async () => {
  384. const fixture = await makeStageFixture();
  385. // Bug 场景:同一 checkout 先做桌面 Linux 打包,beforePack 把平台包的 pty.node 回填进共享的
  386. // 官方 node-pty。旧逻辑看到 pty.node 已存在就跳过整包替换,产出官方 1.1.0 JS + 1.2.0-beta.10 native。
  387. const backfilledDir = join(
  388. fixture.workspaceNodeModulesDir,
  389. "node-pty",
  390. "prebuilds",
  391. "linux-x64",
  392. );
  393. await mkdir(backfilledDir, { recursive: true });
  394. await writeFile(join(backfilledDir, "pty.node"), "desktop-backfilled-binary", "utf8");
  395. const staged = await stageRelease({
  396. target: "linux-x64",
  397. appVersion: "9.9.9-test",
  398. archive: false,
  399. ...fixture,
  400. });
  401. const stagedNodePtyDir = join(staged.releaseDir, "runtime/node_modules/node-pty");
  402. const stagedNodePty = JSON.parse(
  403. await readFile(join(stagedNodePtyDir, "package.json"), "utf8"),
  404. ) as { version: string };
  405. expect(stagedNodePty.version).toBe("1.2.0-beta.10");
  406. await expect(readFile(join(stagedNodePtyDir, "lib/index.js"), "utf8")).resolves.toBe(
  407. "// platform node-pty js\n",
  408. );
  409. await expect(
  410. readFile(join(stagedNodePtyDir, "prebuilds/linux-x64/pty.node"), "utf8"),
  411. ).resolves.toBe("linux-binary");
  412. });
  413. it("keeps official darwin JS and prebuilds including spawn-helper for darwin targets", async () => {
  414. const fixture = await makeStageFixture();
  415. const staged = await stageRelease({
  416. target: "darwin-arm64",
  417. appVersion: "9.9.9-test",
  418. archive: false,
  419. ...fixture,
  420. });
  421. const prebuildDir = join(
  422. staged.releaseDir,
  423. "runtime/node_modules/node-pty/prebuilds/darwin-arm64",
  424. );
  425. await expect(stat(join(prebuildDir, "pty.node"))).resolves.toBeTruthy();
  426. // darwin 官方包自带同版本 prebuild,JS 保持官方包,不受 linux 平台包影响。
  427. await expect(
  428. readFile(join(staged.releaseDir, "runtime/node_modules/node-pty/lib/index.js"), "utf8"),
  429. ).resolves.toBe("// official node-pty js\n");
  430. const helperStat = await stat(join(prebuildDir, "spawn-helper"));
  431. // Bugfix: 同上,NTFS 无 POSIX exec 位,可执行性断言只在 POSIX 宿主生效。
  432. if (process.platform !== "win32") expect(helperStat.mode & 0o111).not.toBe(0);
  433. });
  434. it("stages a Windows target with a cmd launcher and zip archive", async () => {
  435. const fixture = await makeStageFixture();
  436. const toolsDir = join(await makeTempDir(), "tools");
  437. await writeFakeNativeTools(toolsDir, { ripgrep: "rg.exe", ugrep: "ugrep.exe" });
  438. // Job 宿主属于必需的 server-runtime;漏包时必须在发布前失败。
  439. await expect(
  440. stageRelease({
  441. target: "win32-x64",
  442. appVersion: "9.9.9-test",
  443. nativeToolsDir: toolsDir,
  444. ...fixture,
  445. }),
  446. ).rejects.toThrow(/runtime-host/);
  447. await mkdir(join(toolsDir, "runtime-host"), { recursive: true });
  448. await writeFile(join(toolsDir, "runtime-host/zcode-runtime-host.exe"), "fixture runtime host");
  449. const staged = await stageRelease({
  450. target: "win32-x64",
  451. appVersion: "9.9.9-test",
  452. nativeToolsDir: toolsDir,
  453. ...fixture,
  454. });
  455. await expect(
  456. readFile(
  457. join(staged.releaseDir, "runtime/tools/runtime-host/zcode-runtime-host.exe"),
  458. "utf8",
  459. ),
  460. ).resolves.toBe("fixture runtime host");
  461. const manifest = JSON.parse(await readFile(join(staged.releaseDir, "manifest.json"), "utf8"));
  462. expect(
  463. manifest.components.find((component: { id: string }) => component.id === "server-runtime")
  464. .paths,
  465. ).toContain("runtime/tools/runtime-host");
  466. expect(
  467. manifest.components.find(
  468. (component: { id: string }) => component.id === "native-search-tools",
  469. ).paths,
  470. ).not.toContain("runtime/tools");
  471. expect(staged.archivePath).toMatch(/\.zip$/u);
  472. expect(await readFile(join(staged.releaseDir, "bin", "zcode.cmd"), "utf8")).toContain(
  473. "node.exe",
  474. );
  475. await expect(stat(join(staged.releaseDir, "runtime", "node.exe"))).resolves.toBeTruthy();
  476. await expect(
  477. stat(join(staged.releaseDir, "runtime", "tools", "ripgrep", "rg.exe")),
  478. ).resolves.toBeTruthy();
  479. await expect(
  480. stat(join(staged.releaseDir, "runtime", "tools", "ugrep", "ugrep.exe")),
  481. ).resolves.toBeTruthy();
  482. await expect(
  483. stat(join(staged.releaseDir, "runtime", "tools", "ugrep", "THIRD-PARTY-NOTICES.txt")),
  484. ).resolves.toBeTruthy();
  485. await expect(stat(join(staged.releaseDir, "runtime", "tools", "bfs"))).rejects.toThrow();
  486. });
  487. it("每个可独立下载的组件归档都携带适用的第三方声明", async () => {
  488. const fixture = await makeStageFixture();
  489. const toolsDir = join(await makeTempDir(), "tools");
  490. await writeFakeNativeTools(toolsDir, { bfs: "bfs", ripgrep: "rg", ugrep: "ugrep" });
  491. const staged = await stageRelease({
  492. target: "linux-x64",
  493. appVersion: "9.9.9-test",
  494. nativeToolsDir: toolsDir,
  495. ...fixture,
  496. });
  497. const manifest = JSON.parse(
  498. await readFile(join(staged.releaseDir, "manifest.json"), "utf8"),
  499. ) as {
  500. components: Array<{ id: string; archivePath: string }>;
  501. };
  502. const expected: Record<string, string[]> = {
  503. "node-runtime": ["runtime/LICENSE.node.txt", "runtime/NODE-SOURCES.json"],
  504. "server-runtime": ["runtime/THIRD-PARTY-NOTICES.md", "runtime/node_modules/node-pty/LICENSE"],
  505. "agent-runtime": ["runtime/licenses/agent/THIRD-PARTY-NOTICES.md"],
  506. "native-search-tools": [
  507. "runtime/tools/ripgrep/THIRD-PARTY-NOTICES.txt",
  508. "runtime/tools/ugrep/SOURCES.json",
  509. ],
  510. };
  511. expect(manifest.components.map((component) => component.id).sort()).toEqual(
  512. Object.keys(expected).sort(),
  513. );
  514. const extractRoot = await makeTempDir();
  515. for (const component of manifest.components) {
  516. const extractDir = join(extractRoot, component.id);
  517. await mkdir(extractDir, { recursive: true });
  518. await runTar(["-xf", join(fixture.outputDir, component.archivePath), "-C", extractDir]);
  519. for (const member of expected[component.id] ?? []) {
  520. expect(await readFile(join(extractDir, member))).toEqual(
  521. await readFile(join(staged.releaseDir, member)),
  522. );
  523. }
  524. }
  525. });
  526. it.each([true, false])(
  527. "工具目录缺少声明或声明参数为空时拒绝组装发行包(componentArchives=%s)",
  528. async (componentArchives) => {
  529. const fixture = await makeStageFixture();
  530. const toolsDir = join(await makeTempDir(), "tools");
  531. await writeFakeNativeTools(toolsDir, { bfs: "bfs", ripgrep: "rg", ugrep: "ugrep" });
  532. await rm(join(toolsDir, "ripgrep", "THIRD-PARTY-NOTICES.txt"));
  533. await expect(
  534. stageRelease({
  535. target: "linux-x64",
  536. appVersion: "9.9.9-test",
  537. archive: false,
  538. nativeToolsDir: toolsDir,
  539. componentArchives,
  540. ...fixture,
  541. }),
  542. ).rejects.toThrow(/ENOENT/u);
  543. await expect(
  544. stageRelease({
  545. target: "linux-x64",
  546. appVersion: "9.9.9-test",
  547. archive: false,
  548. ...fixture,
  549. notices: { ...fixture.notices, node: " " },
  550. componentArchives,
  551. }),
  552. ).rejects.toThrow(/Missing distribution notice: node/u);
  553. },
  554. );
  555. macIt("omits macOS extended attributes from POSIX release archives", async () => {
  556. const fixture = await makeStageFixture();
  557. await execFileAsync("xattr", ["-w", "com.example.zcode", "value", fixture.nodeBinaryPath]);
  558. const staged = await stageRelease({
  559. target: "linux-x64",
  560. appVersion: "9.9.9-test",
  561. ...fixture,
  562. });
  563. const archive = gunzipSync(await readFile(staged.archivePath ?? ""));
  564. const tarText = archive.toString("latin1");
  565. expect(tarText).not.toContain("LIBARCHIVE.xattr");
  566. expect(tarText).not.toContain("SCHILY.xattr");
  567. });
  568. it("bundled workflow skills ship in the agent component and affect its hash", async () => {
  569. const fixture = await makeStageFixture();
  570. const officialPluginsDir = join(await makeTempDir(), "packages");
  571. await writeOfficialPluginFixture(officialPluginsDir, "zcode-guide-plugin");
  572. const options = {
  573. ...fixture,
  574. officialPluginsDir,
  575. target: "linux-x64" as const,
  576. appVersion: "test",
  577. archive: false,
  578. };
  579. const staged = await stageRelease(options);
  580. const manifest = JSON.parse(await readFile(join(staged.releaseDir, "manifest.json"), "utf8"));
  581. const component = manifest.components.find(
  582. (entry: { id: string }) => entry.id === "agent-runtime",
  583. );
  584. expect(component.paths).toContain("runtime/packages/bundled-skills");
  585. expect(manifest.plugins).not.toContain("bundled-skills");
  586. const archive = gunzipSync(
  587. await readFile(join(fixture.outputDir, component.archivePath)),
  588. ).toString("utf8");
  589. for (const name of ["SKILL.md", "patterns.md", "examples.md"]) {
  590. expect(
  591. await readFile(
  592. join(staged.releaseDir, "runtime/packages/bundled-skills/skills/dynamic-workflows", name),
  593. "utf8",
  594. ),
  595. ).toBe(`fixture ${name}`);
  596. expect(archive).toContain(`fixture ${name}`);
  597. }
  598. await writeFile(
  599. join(fixture.bundledSkillsDir, "skills/dynamic-workflows/examples.md"),
  600. "updated example",
  601. );
  602. const updated = await stageRelease(options);
  603. const next = JSON.parse(await readFile(join(updated.releaseDir, "manifest.json"), "utf8"));
  604. expect(
  605. next.components.find((entry: { id: string }) => entry.id === "agent-runtime").sha256,
  606. ).not.toBe(component.sha256);
  607. expect(
  608. next.components.find((entry: { id: string }) => entry.id === "official-plugins").sha256,
  609. ).toBe(
  610. manifest.components.find((entry: { id: string }) => entry.id === "official-plugins").sha256,
  611. );
  612. });
  613. it.each(["SKILL.md", "patterns.md", "examples.md", "entire-pack"])(
  614. "rejects missing bundled skill asset %s",
  615. async (missing) => {
  616. const fixture = await makeStageFixture();
  617. await rm(
  618. missing === "entire-pack"
  619. ? fixture.bundledSkillsDir
  620. : join(fixture.bundledSkillsDir, "skills/dynamic-workflows", missing),
  621. { recursive: true },
  622. );
  623. await expect(
  624. stageRelease({ ...fixture, target: "linux-x64", appVersion: "test", archive: false }),
  625. ).rejects.toThrow(/bundled skill/i);
  626. },
  627. );
  628. async function writeOfficialPluginFixture(
  629. officialPluginsDir: string,
  630. name: string,
  631. options: { mcpEntry?: string; withMcpEntryFile?: boolean; withManifest?: boolean } = {},
  632. ): Promise<void> {
  633. const pluginDir = join(officialPluginsDir, name);
  634. await mkdir(join(pluginDir, ".zcode-plugin"), { recursive: true });
  635. await writeFile(join(pluginDir, "README.md"), name, "utf8");
  636. // 真实官方插件的 package.json 都是 tracked 文件,是"该目录属于当前 checkout"的判据。
  637. await writeFile(
  638. join(pluginDir, "package.json"),
  639. JSON.stringify({ name: `@zcode/${name}`, private: true }),
  640. "utf8",
  641. );
  642. const manifest: Record<string, unknown> = {
  643. name: name.replace(/-plugin$/u, ""),
  644. version: "0.1.0",
  645. };
  646. if (options.mcpEntry) {
  647. manifest.mcpServers = {
  648. [name]: { command: "node", args: [`\${ZCODE_PLUGIN_ROOT}/${options.mcpEntry}`] },
  649. };
  650. if (options.withMcpEntryFile !== false) {
  651. const entryPath = join(pluginDir, ...options.mcpEntry.split("/"));
  652. await mkdir(join(entryPath, ".."), { recursive: true });
  653. await writeFile(entryPath, "// mcp server\n", "utf8");
  654. }
  655. }
  656. if (options.withManifest !== false) {
  657. await writeFile(
  658. join(pluginDir, ".zcode-plugin", "plugin.json"),
  659. JSON.stringify(manifest),
  660. "utf8",
  661. );
  662. }
  663. }
  664. it.each(["absent", "incomplete", "stale"])(
  665. "stages bundled skills from the agent source when the plugin cache is %s",
  666. async (cacheState) => {
  667. const fixture = await makeStageFixture();
  668. const officialPluginsDir = join(await makeTempDir(), "packages");
  669. await writeOfficialPluginFixture(officialPluginsDir, "zcode-guide-plugin");
  670. if (cacheState !== "absent") {
  671. const cachedPackDir = join(officialPluginsDir, "bundled-skills");
  672. await mkdir(join(cachedPackDir, "skills/dynamic-workflows"), { recursive: true });
  673. await writeFile(join(cachedPackDir, "README.md"), "old cached pack");
  674. const files =
  675. cacheState === "stale" ? ["SKILL.md", "patterns.md", "examples.md"] : ["SKILL.md"];
  676. for (const name of files) {
  677. await writeFile(
  678. join(cachedPackDir, "skills/dynamic-workflows", name),
  679. "old cached skill",
  680. );
  681. }
  682. }
  683. // 冲突整合时两条复制路径曾并存:插件缓存缺文件会拒绝有效技能包,旧缓存会覆盖 Agent 源。
  684. // 技能包只从 bundledSkillsDir 读取,并只由 agent-runtime 交付。
  685. const staged = await stageRelease({
  686. ...fixture,
  687. target: "linux-x64",
  688. appVersion: "test",
  689. archive: false,
  690. officialPluginsDir,
  691. });
  692. const stagedPackDir = join(staged.releaseDir, "runtime/packages/bundled-skills");
  693. expect(await readFile(join(stagedPackDir, "README.md"), "utf8")).toBe("bundled skills");
  694. for (const name of ["SKILL.md", "patterns.md", "examples.md"]) {
  695. expect(await readFile(join(stagedPackDir, "skills/dynamic-workflows", name), "utf8")).toBe(
  696. `fixture ${name}`,
  697. );
  698. }
  699. // 保留发布白名单:本地临时文件不能进入发行包或组件归档。
  700. await expect(stat(join(stagedPackDir, "scratch.txt"))).rejects.toThrow();
  701. const manifest = JSON.parse(
  702. await readFile(join(staged.releaseDir, "manifest.json"), "utf8"),
  703. ) as {
  704. plugins: string[];
  705. components: Array<{ id: string; paths: string[]; archivePath: string }>;
  706. };
  707. expect(manifest.plugins).toEqual(["zcode-guide"]);
  708. const agentComponent = manifest.components.find((entry) => entry.id === "agent-runtime")!;
  709. expect(agentComponent.paths).toContain("runtime/packages/bundled-skills");
  710. const agentExtractDir = await makeTempDir();
  711. await runTar([
  712. "-xf",
  713. join(fixture.outputDir, agentComponent.archivePath),
  714. "-C",
  715. agentExtractDir,
  716. ]);
  717. expect(
  718. await readFile(
  719. join(
  720. agentExtractDir,
  721. "runtime/packages/bundled-skills/skills/dynamic-workflows/SKILL.md",
  722. ),
  723. "utf8",
  724. ),
  725. ).toBe("fixture SKILL.md");
  726. await expect(
  727. stat(join(agentExtractDir, "runtime/packages/bundled-skills/scratch.txt")),
  728. ).rejects.toThrow();
  729. const pluginComponent = manifest.components.find((entry) => entry.id === "official-plugins")!;
  730. const pluginExtractDir = await makeTempDir();
  731. await runTar([
  732. "-xf",
  733. join(fixture.outputDir, pluginComponent.archivePath),
  734. "-C",
  735. pluginExtractDir,
  736. ]);
  737. await expect(
  738. stat(join(pluginExtractDir, "runtime/packages/zcode-guide-plugin")),
  739. ).resolves.toBeTruthy();
  740. await expect(
  741. stat(join(pluginExtractDir, "runtime/packages/bundled-skills")),
  742. ).rejects.toThrow();
  743. },
  744. );
  745. it("stages the official plugin set and excludes the on-demand superpowers package", async () => {
  746. const fixture = await makeStageFixture();
  747. const officialPluginsDir = join(await makeTempDir(), "packages");
  748. const pluginNames = [
  749. "android-emulator-plugin",
  750. "browser-use-plugin",
  751. "document-skills-plugin",
  752. "ios-simulator-plugin",
  753. "restore-legacy-sessions-plugin",
  754. "skill-creator-plugin",
  755. "zcode-guide-plugin",
  756. "superpowers-plugin",
  757. ];
  758. const mcpRuntimePlugins = new Set([
  759. "android-emulator-plugin",
  760. "browser-use-plugin",
  761. "ios-simulator-plugin",
  762. ]);
  763. for (const name of pluginNames) {
  764. await writeOfficialPluginFixture(
  765. officialPluginsDir,
  766. name,
  767. mcpRuntimePlugins.has(name) ? { mcpEntry: "dist/mcp/server.js" } : {},
  768. );
  769. }
  770. const staged = await stageRelease({
  771. target: "linux-x64",
  772. appVersion: "9.9.9-test",
  773. archive: false,
  774. officialPluginsDir,
  775. ...fixture,
  776. });
  777. for (const name of pluginNames.filter((name) => name !== "superpowers-plugin")) {
  778. await expect(
  779. stat(join(staged.releaseDir, "runtime/packages", name, "README.md")),
  780. ).resolves.toBeTruthy();
  781. }
  782. for (const name of mcpRuntimePlugins) {
  783. await expect(
  784. stat(join(staged.releaseDir, "runtime/packages", name, "dist/mcp/server.js")),
  785. ).resolves.toBeTruthy();
  786. }
  787. await expect(
  788. stat(join(staged.releaseDir, "runtime/packages/superpowers-plugin")),
  789. ).rejects.toThrow();
  790. const manifest = JSON.parse(
  791. await readFile(join(staged.releaseDir, "manifest.json"), "utf8"),
  792. ) as {
  793. plugins?: string[];
  794. components?: Array<{ id: string }>;
  795. };
  796. expect(manifest.plugins).toEqual([
  797. "android-emulator",
  798. "browser-use",
  799. "document-skills",
  800. "ios-simulator",
  801. "restore-legacy-sessions",
  802. "skill-creator",
  803. "zcode-guide",
  804. ]);
  805. expect(manifest.components?.some((component) => component.id === "official-plugins")).toBe(
  806. true,
  807. );
  808. });
  809. it.each([true, false])(
  810. "fails closed on a missing MCP entry with componentArchives=%s",
  811. async (componentArchives) => {
  812. // Bug 原因:插件 dist 被 gitignore,干净 CI 工作区里 android-emulator / ios-simulator 没有
  813. // dist/mcp/server.js;legacy prepare-prebuilds.mjs 曾构建并断言该文件,切到 stageRelease 后只剩
  814. // 整目录复制,archive 会静默带上只有 plugin.json 与 skills、缺 MCP 入口的插件。staging 必须以
  815. // plugin.json 的 mcpServers 声明为事实源 fail-closed。
  816. const fixture = await makeStageFixture();
  817. const officialPluginsDir = join(await makeTempDir(), "packages");
  818. await writeOfficialPluginFixture(officialPluginsDir, "android-emulator-plugin", {
  819. mcpEntry: "dist/mcp/server.js",
  820. withMcpEntryFile: false,
  821. });
  822. await writeOfficialPluginFixture(officialPluginsDir, "zcode-guide-plugin");
  823. await expect(
  824. stageRelease({
  825. target: "linux-x64",
  826. appVersion: "9.9.9-test",
  827. archive: false,
  828. officialPluginsDir,
  829. componentArchives,
  830. ...fixture,
  831. }),
  832. ).rejects.toThrow(/android-emulator-plugin[\s\S]*dist\/mcp\/server\.js/u);
  833. },
  834. );
  835. it("fails closed when a staged official plugin has no plugin manifest", async () => {
  836. const fixture = await makeStageFixture();
  837. const officialPluginsDir = join(await makeTempDir(), "packages");
  838. await writeOfficialPluginFixture(officialPluginsDir, "ios-simulator-plugin", {
  839. withManifest: false,
  840. });
  841. await expect(
  842. stageRelease({
  843. target: "linux-x64",
  844. appVersion: "9.9.9-test",
  845. archive: false,
  846. officialPluginsDir,
  847. ...fixture,
  848. }),
  849. ).rejects.toThrow(/ios-simulator-plugin[\s\S]*plugin\.json/u);
  850. });
  851. it("ignores orphaned *-plugin directories left behind by a previous checkout", async () => {
  852. // Bug 原因:CI 用 GIT_CLEAN_FLAGS "-e node_modules/" 跨 job 保留 node_modules,其它分支
  853. // (例如曾把 zcode-cua-plugin 改名为 computer-use-plugin 的分支)install 过的插件目录切回本
  854. // 分支后只剩 node_modules,tracked 文件全被 checkout 删掉。旧规则仅按 "-plugin" 后缀识别官方
  855. // 插件,会把这种僵尸目录当插件 stage,随后 fail-closed 校验读不到 plugin.json 而整段失败。
  856. const fixture = await makeStageFixture();
  857. const officialPluginsDir = join(await makeTempDir(), "packages");
  858. await writeOfficialPluginFixture(officialPluginsDir, "zcode-guide-plugin");
  859. const orphanDir = join(officialPluginsDir, "computer-use-plugin");
  860. await mkdir(join(orphanDir, "node_modules", "@zcode", "computer-use"), { recursive: true });
  861. await writeFile(
  862. join(orphanDir, "node_modules", "@zcode", "computer-use", "package.json"),
  863. "{}",
  864. "utf8",
  865. );
  866. const staged = await stageRelease({
  867. target: "linux-x64",
  868. appVersion: "9.9.9-test",
  869. archive: false,
  870. officialPluginsDir,
  871. ...fixture,
  872. });
  873. await expect(
  874. stat(join(staged.releaseDir, "runtime/packages/computer-use-plugin")),
  875. ).rejects.toThrow();
  876. const manifest = JSON.parse(
  877. await readFile(join(staged.releaseDir, "manifest.json"), "utf8"),
  878. ) as { plugins?: string[] };
  879. expect(manifest.plugins).toEqual(["zcode-guide"]);
  880. });
  881. it("removes stale component archives before restaging a target", async () => {
  882. const fixture = await makeStageFixture();
  883. const staleDir = join(fixture.outputDir, "components", "linux-x64");
  884. await mkdir(staleDir, { recursive: true });
  885. await writeFile(join(staleDir, "stale-component.tar.gz"), "stale", "utf8");
  886. await stageRelease({
  887. target: "linux-x64",
  888. appVersion: "9.9.9-test",
  889. archive: false,
  890. ...fixture,
  891. });
  892. await expect(stat(join(staleDir, "stale-component.tar.gz"))).rejects.toThrow();
  893. });
  894. it.each(["linux-x64", "linux-arm64"] as const)(
  895. "stages an installable full %s archive without standalone components",
  896. async (target) => {
  897. const fixture = await makeStageFixture();
  898. await writeFakePackage(fixture.workspaceNodeModulesDir, "@lydell/node-pty-linux-arm64", {
  899. version: "1.2.0-beta.10",
  900. files: {
  901. "lib/index.js": "// platform node-pty js\n",
  902. "prebuilds/linux-arm64/pty.node": "linux-arm64-binary",
  903. },
  904. });
  905. const options = { ...fixture, target, appVersion: "9.9.9-test" };
  906. const original = await stageRelease(options);
  907. expect(original.componentArchivePaths.length).toBeGreaterThan(0);
  908. const expected = JSON.parse(
  909. await readFile(join(original.releaseDir, "manifest.json"), "utf8"),
  910. );
  911. for (const component of expected.components) {
  912. expect(component.archivePath).toBeTruthy();
  913. delete component.archivePath;
  914. }
  915. const staged = await stageRelease({ ...options, componentArchives: false });
  916. expect(staged.componentArchivePaths).toEqual([]);
  917. await expect(stat(join(fixture.outputDir, "components", target))).rejects.toMatchObject({
  918. code: "ENOENT",
  919. });
  920. await expect(stat(join(fixture.outputDir, ".components"))).rejects.toMatchObject({
  921. code: "ENOENT",
  922. });
  923. const manifest = JSON.parse(await readFile(join(staged.releaseDir, "manifest.json"), "utf8"));
  924. expect(manifest).toEqual(expected);
  925. // 用真实整包 installer 验证没有组件 archivePath 仍可安装,且整包摘要校验仍会拒绝错误身份。
  926. const { ReleaseInstaller } = await import(
  927. fileURLToPath(new URL("../src/runtime/releaseInstaller.ts", import.meta.url))
  928. );
  929. const { resolveServerLayout } = await import(
  930. fileURLToPath(new URL("../src/runtime/paths.ts", import.meta.url))
  931. );
  932. const installer = new ReleaseInstaller(
  933. resolveServerLayout(join(await makeTempDir(), "server")),
  934. );
  935. const archivePath = staged.archivePath!;
  936. const archiveSha256 = createHash("sha256")
  937. .update(await readFile(archivePath))
  938. .digest("hex");
  939. await expect(
  940. installer.installArchive({ archivePath, target, archiveSha256: "0".repeat(64) }),
  941. ).rejects.toThrow(/checksum mismatch/);
  942. const installed = await installer.installArchive({ archivePath, target, archiveSha256 });
  943. expect(
  944. JSON.parse(await readFile(join(installed.releaseDir, "manifest.json"), "utf8")),
  945. ).toEqual(expected);
  946. expect(await readFile(join(installed.releaseDir, "runtime", "zcode.cjs"))).toEqual(
  947. await readFile(fixture.agentBundlePath),
  948. );
  949. },
  950. );
  951. });
  952. it("stages only the target OS keyring binary", () => {
  953. expect(isTargetSpecificPackage("@napi-rs/keyring-linux-x64-gnu", "linux-x64")).toBe(true);
  954. expect(isTargetSpecificPackage("@napi-rs/keyring-win32-x64-msvc", "linux-x64")).toBe(false);
  955. expect(isTargetSpecificPackage("@napi-rs/keyring-linux-arm64-gnu", "linux-x64")).toBe(false);
  956. });