MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / smokeTestPackage

Function smokeTestPackage

scripts/smoke-test-packed.ts:109–212  ·  view source on GitHub ↗
(
  pkgDir: string,
  tarballs: Tarballs,
  failures: SmokeFailure[],
)

Source from the content-addressed store, hash-verified

107type Tarballs = ReadonlyMap<string, string>;
108
109const smokeTestPackage = async (
110 pkgDir: string,
111 tarballs: Tarballs,
112 failures: SmokeFailure[],
113): Promise<void> => {
114 const pkg = await readPackageJson(pkgDir);
115 const tarballPath = tarballs.get(pkg.name);
116 if (!tarballPath) {
117 failures.push({ pkg: pkg.name, subpath: "", reason: "no tarball produced" });
118 return;
119 }
120
121 const tmp = await mkdtemp(join(tmpdir(), "executor-smoke-"));
122 try {
123 // npm `overrides` forces transitive `@executor-js/*` deps to resolve
124 // to their local tarball instead of whatever's published on npm.
125 // Without this, a plugin built against an unreleased symbol in
126 // `@executor-js/sdk` would silently install the published `sdk`
127 // and fail at import — a real bug, but not the bundle bug we're
128 // here to catch.
129 const overrides: Record<string, string> = {};
130 for (const [name, path] of tarballs) {
131 overrides[name] = `file:${path}`;
132 }
133 const fixture = {
134 name: "executor-smoke-fixture",
135 version: "0.0.0",
136 private: true,
137 type: "module",
138 dependencies: { [pkg.name]: `file:${tarballPath}` },
139 overrides,
140 };
141 await writeFile(join(tmp, "package.json"), `${JSON.stringify(fixture, null, 2)}\n`);
142
143 const install = await $`npm install --no-audit --no-fund --legacy-peer-deps`
144 .cwd(tmp)
145 .quiet()
146 .nothrow();
147 if (install.exitCode !== 0) {
148 failures.push({
149 pkg: pkg.name,
150 subpath: "<install>",
151 reason: install.stderr.toString().trim().split("\n").slice(-3).join("\n"),
152 });
153 return;
154 }
155
156 // Read the installed manifest — that's the real published view
157 // (publishConfig.exports applied, workspace specifiers resolved).
158 const installedPkg = await readPackageJson(join(tmp, "node_modules", ...pkg.name.split("/")));
159 const subpaths = subpathsToTest(installedPkg);
160 if (subpaths.length === 0) {
161 failures.push({
162 pkg: pkg.name,
163 subpath: "",
164 reason: "no exports declared in published manifest",
165 });
166 return;

Callers 1

mainFunction · 0.85

Calls 8

readPackageJsonFunction · 0.85
subpathsToTestFunction · 0.85
importSpecifierFunction · 0.85
firstMeaningfulLineFunction · 0.85
pushMethod · 0.80
toStringMethod · 0.80
logMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected