Files
PaperClipAI/packages/paperclip-runner/scripts/lib/installed-package-pack.mjs
T
DottaandPaperclip e2b89b6302 Integrate pinned Cursor ACP runtime and explicit public setup
Consolidate Cursor v10 onto current controller behavior, retain admission gates, and prepare native interaction and cleanup qualification. Add the public provisioner and ordinary provider-pack assets.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-03 13:33:15 -05:00

31 lines
1.3 KiB
JavaScript

import { cp, mkdtemp, readFile, rm } from "node:fs/promises";
import { join, resolve } from "node:path";
/** Keep npm's installed-tree traversal out of non-bundled package packing.
* Copy manifests and pack rules unchanged; npm still selects the tarball files.
* Bundled packages need their dependency tree, so keep their existing pack path.
*/
export async function withInstalledPackagePackInput(packageRoot, scratchRoot, pack) {
const manifest = JSON.parse(await readFile(resolve(packageRoot, "package.json"), "utf8"));
const hasBundle = [manifest.bundleDependencies, manifest.bundledDependencies].some(
value => value !== undefined && value !== false && !(Array.isArray(value) && value.length === 0),
);
if (hasBundle) return pack(packageRoot, false);
const stage = await mkdtemp(join(scratchRoot, "pack-input-"));
try {
const input = join(stage, "package");
// node_modules is excluded by npm for non-bundled packages. Preserve every
// other entry, including ignore rules and links, without dereferencing it.
await cp(packageRoot, input, {
recursive: true,
dereference: false,
verbatimSymlinks: true,
filter: source => resolve(source) !== resolve(packageRoot, "node_modules"),
});
return await pack(input, true);
} finally {
await rm(stage, { recursive: true, force: true });
}
}