From 39bc24af1d30e2098dc1d85a7fd5df488e67d22c Mon Sep 17 00:00:00 2001 From: Miroslav Jonas Date: Tue, 28 Mar 2023 14:33:09 +0200 Subject: [PATCH] fix(core): improve lockfile version stringification --- package.json | 2 +- packages/nx/src/lock-file/pnpm-parser.ts | 11 ++++++++--- yarn.lock | 18 +++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index f7c433d07bc0b9..e3dbf255c27239 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "@parcel/watcher": "2.0.4", "@phenomnomnominal/tsquery": "4.1.1", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7", - "@pnpm/lockfile-types": "^4.3.6", + "@pnpm/lockfile-types": "5.0.0", "@reduxjs/toolkit": "1.9.0", "@rollup/plugin-babel": "^5.3.0", "@rollup/plugin-commonjs": "^20.0.0", diff --git a/packages/nx/src/lock-file/pnpm-parser.ts b/packages/nx/src/lock-file/pnpm-parser.ts index d8b1030bc15668..d176bb18cc4237 100644 --- a/packages/nx/src/lock-file/pnpm-parser.ts +++ b/packages/nx/src/lock-file/pnpm-parser.ts @@ -1,6 +1,7 @@ import type { PackageSnapshot, Lockfile, + LockfileV6, ProjectSnapshot, PackageSnapshots, } from '@pnpm/lockfile-types'; @@ -157,10 +158,14 @@ export function stringifyPnpmLockfile( packageJson: NormalizedPackageJson ): string { const data = parseAndNormalizePnpmLockfile(rootLockFileContent); - const hasV5Separator = data.lockfileVersion.toString().startsWith('5'); + const lockfileVersion: string = + typeof data.lockfileVersion === 'number' + ? data.lockfileVersion.toFixed(1) + : data.lockfileVersion; + const hasV5Separator = lockfileVersion.startsWith('5'); - const output: Lockfile = { - lockfileVersion: data.lockfileVersion, + const output: Lockfile | LockfileV6 = { + lockfileVersion, importers: { '.': mapRootSnapshot( packageJson, diff --git a/yarn.lock b/yarn.lock index 2ef086ab2ce4dd..b87a3a422bdd9a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5737,17 +5737,17 @@ schema-utils "^3.0.0" source-map "^0.7.3" -"@pnpm/lockfile-types@^4.3.6": - version "4.3.6" - resolved "https://registry.yarnpkg.com/@pnpm/lockfile-types/-/lockfile-types-4.3.6.tgz#9d81aa3547a57af9e229572d4763e48268637a83" - integrity sha512-5vvdV3tEVOCzzeGv2FXK4590qPUVpZ+5gdqCawFuiNTJavx+4rmmY4aDUjdVXUcKGwqkIBPVKe/SNUBA3A2rtg== +"@pnpm/lockfile-types@5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@pnpm/lockfile-types/-/lockfile-types-5.0.0.tgz#e46944f1b27fedc5490d388b4195857e3aba282d" + integrity sha512-2M82hciNNIczVtWmQF3eSXPFVWvGWBvq+vssBkSIP0tZW/izYyvkUf2NN8ktNrB/w0jDCVEzujC6RXiRR9b1bg== dependencies: - "@pnpm/types" "8.10.0" + "@pnpm/types" "9.0.0" -"@pnpm/types@8.10.0": - version "8.10.0" - resolved "https://registry.yarnpkg.com/@pnpm/types/-/types-8.10.0.tgz#29ebd095bb0653e5eab8283799c9f59fb6cf216f" - integrity sha512-A4pcNNvFJdkMXArEjTCOIYNL2VxD4uBynWZ6cBIELXb5qJ0tUzwKsaSz4J953I0rQFqnsFpUYqaWIquI10W1sw== +"@pnpm/types@9.0.0": + version "9.0.0" + resolved "https://registry.yarnpkg.com/@pnpm/types/-/types-9.0.0.tgz#f6f403c60af2ee3fa6df4ceb3ee42aa0811ba577" + integrity sha512-+nNqpNvqb1u3WW/cHDo7tGjqJBWWe4GAHEdELrz4QMQwGAtG/1GF6NMc0cewdwgU2k67CI3JHGu4quZJnMEUJg== "@popperjs/core@^2.0.0": version "2.11.6"