Skip to content

Commit

Permalink
fix(core): fix pruning of pnpm lockfiles with github packages (#13875)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Dec 19, 2022
1 parent fed3f90 commit 20c4782
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 19 additions & 3 deletions packages/nx/src/lock-file/lock-file.spec.ts
@@ -1,7 +1,19 @@
import { mapLockFileDataToPartialGraph } from './lock-file';
import { parseNpmLockFile, stringifyNpmLockFile } from './npm';
import { parsePnpmLockFile, stringifyPnpmLockFile } from './pnpm';
import { parseYarnLockFile, stringifyYarnLockFile } from './yarn';
import {
parseNpmLockFile,
pruneNpmLockFile,
stringifyNpmLockFile,
} from './npm';
import {
parsePnpmLockFile,
prunePnpmLockFile,
stringifyPnpmLockFile,
} from './pnpm';
import {
parseYarnLockFile,
pruneYarnLockFile,
stringifyYarnLockFile,
} from './yarn';
import {
npmLockFileV1WithAliases,
npmLockFileWithAliases,
Expand Down Expand Up @@ -247,6 +259,7 @@ describe('lock-file', () => {
);

const newPackage = createPackageJson('lib1', partialGraph, {});
const prunedLockFile = pruneYarnLockFile(lockFileData, newPackage);
expect(newPackage).toMatchInlineSnapshot(`
Object {
"dependencies": Object {
Expand Down Expand Up @@ -283,6 +296,7 @@ describe('lock-file', () => {
);

const newPackage = createPackageJson('lib1', partialGraph, {});
const prunedLockFile = pruneNpmLockFile(lockFileData, newPackage);
expect(newPackage).toMatchInlineSnapshot(`
Object {
"dependencies": Object {
Expand Down Expand Up @@ -317,6 +331,7 @@ describe('lock-file', () => {
);

const newPackage = createPackageJson('lib1', partialGraph, {});
const prunedLockFile = pruneYarnLockFile(lockFileData, newPackage);
expect(newPackage).toMatchInlineSnapshot(`
Object {
"dependencies": Object {
Expand Down Expand Up @@ -350,6 +365,7 @@ describe('lock-file', () => {
mapLockFileDataToPartialGraph(lockFileData, 'pnpm')
);
const newPackage = createPackageJson('lib1', partialGraph, {});
const prunedLockFile = prunePnpmLockFile(lockFileData, newPackage);
expect(newPackage).toMatchInlineSnapshot(`
Object {
"dependencies": Object {
Expand Down
4 changes: 3 additions & 1 deletion packages/nx/src/lock-file/pnpm.ts
Expand Up @@ -432,7 +432,9 @@ function pruneDependencies(
dependencies[packageName]
).find(([_, v]) => v.rootVersion);
result[packageName] = result[packageName] || {};
const metaKey = `/${packageName}/${value.version}`;
const metaKey = value.actualVersion
? value.version
: `/${packageName}/${value.version}`;
const meta = packageMeta.find((m) => m.key.startsWith(metaKey));

result[packageName][key] = Object.assign(value, {
Expand Down

1 comment on commit 20c4782

@vercel
Copy link

@vercel vercel bot commented on 20c4782 Dec 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.