Skip to content

Preserve pnpm lockfile version when pruning #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isolate-package",
"version": "1.19.0",
"version": "1.20.0-0",
"description": "Isolate a monorepo package with its shared dependencies to form a self-contained directory, compatible with Firebase deploy",
"author": "Thijs Koerselman",
"license": "MIT",
Expand Down
14 changes: 9 additions & 5 deletions src/lib/lockfile/helpers/generate-pnpm-lockfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function generatePnpmLockfile({
* versions after 9, because we might get lucky. If it does change, things
* would break either way.
*/
const useVersion9 = majorVersion >= 9;
const useReadVersion9 = majorVersion >= 9;

const { includeDevDependencies, includePatchedDependencies } = useConfig();
const log = useLogger();
Expand All @@ -51,7 +51,7 @@ export async function generatePnpmLockfile({
try {
const isRush = isRushWorkspace(workspaceRootDir);

const lockfile = useVersion9
const lockfile = useReadVersion9
? await readWantedLockfile_v9(
isRush
? path.join(workspaceRootDir, "common/config/rush")
Expand All @@ -71,7 +71,11 @@ export async function generatePnpmLockfile({

assert(lockfile, `No input lockfile found at ${workspaceRootDir}`);

const targetImporterId = useVersion9
const [lockfileMajorVersion] = String(lockfile.lockfileVersion).split(".");

const useLockfileVersion9 = lockfileMajorVersion >= "9";

const targetImporterId = useLockfileVersion9
? getLockfileImporterId_v9(workspaceRootDir, targetPackageDir)
: getLockfileImporterId_v8(workspaceRootDir, targetPackageDir);

Expand Down Expand Up @@ -141,7 +145,7 @@ export async function generatePnpmLockfile({

log.debug("Pruning the lockfile");

const prunedLockfile = useVersion9
const prunedLockfile = useLockfileVersion9
? await pruneLockfile_v9(lockfile, targetPackageManifest, ".")
: await pruneLockfile_v8(lockfile, targetPackageManifest, ".");

Expand All @@ -160,7 +164,7 @@ export async function generatePnpmLockfile({
? lockfile.patchedDependencies
: undefined;

useVersion9
useLockfileVersion9
? await writeWantedLockfile_v9(isolateDir, {
...prunedLockfile,
patchedDependencies,
Expand Down