From b8d0c9982dcc856fd2b1c7dbef3353877652a92b Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 16 May 2020 18:07:11 +0300 Subject: [PATCH] refactor: use lockfile version constant --- packages/audit/package.json | 1 + packages/audit/test/index.ts | 3 +- .../filter-lockfile/test/filterByImporters.ts | 20 +++---- .../test/filterByImportersAndEngine.ts | 5 +- packages/lockfile-file/test/read.ts | 8 +-- .../test/linkRecursive.ts | 10 ++-- packages/pnpm/test/monorepo/index.ts | 8 +-- packages/prune-lockfile/test/index.ts | 54 +++++++++---------- packages/supi/test/install/aliases.ts | 6 +-- packages/supi/test/install/local.ts | 9 ++-- packages/supi/test/install/misc.ts | 6 +-- .../supi/test/install/multipleImporters.ts | 6 +-- packages/supi/test/lockfile.ts | 24 ++++----- packages/supi/test/uninstall.ts | 4 +- pnpm-lock.yaml | 8 +++ 15 files changed, 91 insertions(+), 81 deletions(-) diff --git a/packages/audit/package.json b/packages/audit/package.json index 654fa11706..7b25652e29 100644 --- a/packages/audit/package.json +++ b/packages/audit/package.json @@ -31,6 +31,7 @@ "homepage": "https://github.com/pnpm/pnpm/blob/master/packages/audit#readme", "devDependencies": { "@pnpm/audit": "link:", + "@pnpm/constants": "^3.0.0", "@pnpm/lockfile-file": "workspace:3.0.9-alpha.1", "nock": "12.0.3" }, diff --git a/packages/audit/test/index.ts b/packages/audit/test/index.ts index b4363fc60a..a6b3b5db29 100644 --- a/packages/audit/test/index.ts +++ b/packages/audit/test/index.ts @@ -1,5 +1,6 @@ import audit from '@pnpm/audit' import lockfileToAuditTree from '@pnpm/audit/lib/lockfileToAuditTree' +import { LOCKFILE_VERSION } from '@pnpm/constants' import PnpmError from '@pnpm/error' import nock = require('nock') import test = require('tape') @@ -16,7 +17,7 @@ test('lockfileToAuditTree()', (t) => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/bar/1.0.0': { resolution: { diff --git a/packages/filter-lockfile/test/filterByImporters.ts b/packages/filter-lockfile/test/filterByImporters.ts index 7b20697495..ea30e77a6c 100644 --- a/packages/filter-lockfile/test/filterByImporters.ts +++ b/packages/filter-lockfile/test/filterByImporters.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { filterLockfileByImporters } from '@pnpm/filter-lockfile' import test = require('tape') @@ -31,7 +31,7 @@ test('filterByImporters(): only prod dependencies of one importer', (t) => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dev-dep/1.0.0': { dev: true, @@ -96,7 +96,7 @@ test('filterByImporters(): only prod dependencies of one importer', (t) => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/prod-dep-dep/1.0.0': { resolution: { integrity: '' }, @@ -134,7 +134,7 @@ test('filterByImporters(): fail on missing packages when failOnMissingDependenci specifiers: {}, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/prod-dep/1.0.0': { dependencies: { @@ -184,7 +184,7 @@ test('filterByImporters(): do not fail on missing packages when failOnMissingDep specifiers: {}, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/prod-dep/1.0.0': { dependencies: { @@ -227,7 +227,7 @@ test('filterByImporters(): do not fail on missing packages when failOnMissingDep specifiers: {}, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/prod-dep/1.0.0': { dependencies: { @@ -270,7 +270,7 @@ test('filterByImporters(): do not include skipped packages', (t) => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dev-dep/1.0.0': { dev: true, @@ -339,7 +339,7 @@ test('filterByImporters(): do not include skipped packages', (t) => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dev-dep/1.0.0': { dev: true, @@ -383,7 +383,7 @@ test('filterByImporters(): exclude orphan packages', (t) => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/orphan/1.0.0': { resolution: { integrity: '' }, @@ -440,7 +440,7 @@ test('filterByImporters(): exclude orphan packages', (t) => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/prod-dep-dep/1.0.0': { resolution: { integrity: '' }, diff --git a/packages/filter-lockfile/test/filterByImportersAndEngine.ts b/packages/filter-lockfile/test/filterByImportersAndEngine.ts index a2ccb74de8..41e33952c2 100644 --- a/packages/filter-lockfile/test/filterByImportersAndEngine.ts +++ b/packages/filter-lockfile/test/filterByImportersAndEngine.ts @@ -1,3 +1,4 @@ +import { LOCKFILE_VERSION } from '@pnpm/constants' import { filterLockfileByImportersAndEngine } from '@pnpm/filter-lockfile' import test = require('tape') @@ -33,7 +34,7 @@ test('filterByImportersAndEngine(): skip packages that are not installable', (t) }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/bar/1.0.0': { resolution: { integrity: '' }, @@ -128,7 +129,7 @@ test('filterByImportersAndEngine(): skip packages that are not installable', (t) }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/bar/1.0.0': { resolution: { integrity: '' }, diff --git a/packages/lockfile-file/test/read.ts b/packages/lockfile-file/test/read.ts index f41ce53c4c..d9ba3ffa9b 100644 --- a/packages/lockfile-file/test/read.ts +++ b/packages/lockfile-file/test/read.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { existsWantedLockfile, readCurrentLockfile, @@ -190,7 +190,7 @@ test('writeLockfiles()', async t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dependencies: { @@ -234,7 +234,7 @@ test('writeLockfiles() when no specifiers but dependencies present', async t => specifiers: {}, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, } await writeLockfiles({ currentLockfile: wantedLockfile, @@ -262,7 +262,7 @@ test('write does not use yaml anchors/aliases', async t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: yaml` /react-dnd/2.5.4/react@15.6.1: dependencies: diff --git a/packages/plugin-commands-installation/test/linkRecursive.ts b/packages/plugin-commands-installation/test/linkRecursive.ts index 8b742fe5cd..c4ffeb6096 100644 --- a/packages/plugin-commands-installation/test/linkRecursive.ts +++ b/packages/plugin-commands-installation/test/linkRecursive.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { readProjects } from '@pnpm/filter-workspace-packages' import { install, link, unlink } from '@pnpm/plugin-commands-installation' import { preparePackages } from '@pnpm/prepare' @@ -59,13 +59,13 @@ test('recursive linking/unlinking', async (t) => { { const project1Lockfile = await projects['project-1'].readLockfile() - t.equal(project1Lockfile.lockfileVersion, 5.1, `project-1 has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) + t.equal(project1Lockfile.lockfileVersion, LOCKFILE_VERSION, `project-1 has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) t.equal(project1Lockfile.devDependencies['is-positive'], '1.0.0') t.ok(project1Lockfile.packages['/is-positive/1.0.0']) } const isPositiveLockfile = await projects['is-positive'].readLockfile() - t.equal(isPositiveLockfile.lockfileVersion, 5.1, `is-positive has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) + t.equal(isPositiveLockfile.lockfileVersion, LOCKFILE_VERSION, `is-positive has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) t.end() }) @@ -122,13 +122,13 @@ test('recursive unlink specific package', async (t) => { { const project1Lockfile = await projects['project-1'].readLockfile() - t.equal(project1Lockfile.lockfileVersion, 5.1, `project-1 has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) + t.equal(project1Lockfile.lockfileVersion, LOCKFILE_VERSION, `project-1 has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) t.equal(project1Lockfile.devDependencies['is-positive'], '1.0.0') t.ok(project1Lockfile.packages['/is-positive/1.0.0']) } const isPositiveLockfile = await projects['is-positive'].readLockfile() - t.equal(isPositiveLockfile.lockfileVersion, 5.1, `is-positive has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) + t.equal(isPositiveLockfile.lockfileVersion, LOCKFILE_VERSION, `is-positive has correct lockfileVersion specified in ${WANTED_LOCKFILE}`) t.end() }) diff --git a/packages/pnpm/test/monorepo/index.ts b/packages/pnpm/test/monorepo/index.ts index cd12c77d9b..656fca6728 100644 --- a/packages/pnpm/test/monorepo/index.ts +++ b/packages/pnpm/test/monorepo/index.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import findWorkspacePackages from '@pnpm/find-workspace-packages' import { Lockfile } from '@pnpm/lockfile-types' import { read as readModulesManifest } from '@pnpm/modules-yaml' @@ -708,7 +708,7 @@ test('shared-workspace-lockfile: create shared lockfile format when installation const lockfile = await readYamlFile(WANTED_LOCKFILE) t.ok(lockfile['importers'] && lockfile['importers']['.'], `correct ${WANTED_LOCKFILE} format`) - t.equal(lockfile['lockfileVersion'], 5.1, `correct ${WANTED_LOCKFILE} version`) + t.equal(lockfile['lockfileVersion'], LOCKFILE_VERSION, `correct ${WANTED_LOCKFILE} version`) }) // covers https://github.com/pnpm/pnpm/issues/1451 @@ -765,7 +765,7 @@ test("shared-workspace-lockfile: don't install dependencies in projects that are }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -860,7 +860,7 @@ test('shared-workspace-lockfile: install dependencies in projects that are relat }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dev: false, diff --git a/packages/prune-lockfile/test/index.ts b/packages/prune-lockfile/test/index.ts index 4ea562595f..0cca6e91a4 100644 --- a/packages/prune-lockfile/test/index.ts +++ b/packages/prune-lockfile/test/index.ts @@ -1,5 +1,5 @@ /// -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { pruneLockfile, pruneSharedLockfile, @@ -25,7 +25,7 @@ test('remove one redundant package', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -58,7 +58,7 @@ test('remove one redundant package', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -84,7 +84,7 @@ test('remove redundant linked package', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: {}, }, { name: 'foo', @@ -97,7 +97,7 @@ test('remove redundant linked package', t => { specifiers: {}, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, }) t.end() @@ -117,7 +117,7 @@ test('keep all', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dependencies: { @@ -162,7 +162,7 @@ test('keep all', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dependencies: { @@ -209,7 +209,7 @@ test('optional dependency should have optional = true', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/foo-child/1.0.0': { optional: true, @@ -280,7 +280,7 @@ test('optional dependency should have optional = true', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/foo-child/1.0.0': { dev: false, @@ -343,7 +343,7 @@ test('optional dependency should not have optional = true if used not only as op }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -382,7 +382,7 @@ test('optional dependency should not have optional = true if used not only as op }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -421,7 +421,7 @@ test('dev dependency should have dev = true', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { resolution: { @@ -460,7 +460,7 @@ test('dev dependency should have dev = true', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: true, @@ -496,7 +496,7 @@ test('dev dependency should not have dev = true if it is used not only as dev', }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { resolution: { @@ -538,7 +538,7 @@ test('dev dependency should not have dev = true if it is used not only as dev', }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { resolution: { @@ -572,7 +572,7 @@ test('the dev field should be updated to dev = false if it is not a dev dependen }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/a/1.0.0': { resolution: { @@ -598,7 +598,7 @@ test('the dev field should be updated to dev = false if it is not a dev dependen }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/a/1.0.0': { dev: false, @@ -855,7 +855,7 @@ test('remove dependencies that are not in the package', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/fsevents/1.0.0': { resolution: { @@ -882,7 +882,7 @@ test('remove dependencies that are not in the package', t => { specifiers: {}, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, }) t.end() @@ -900,7 +900,7 @@ test(`ignore dependencies that are in package.json but are not in ${WANTED_LOCKF }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -928,7 +928,7 @@ test(`ignore dependencies that are in package.json but are not in ${WANTED_LOCKF }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -1009,7 +1009,7 @@ test('keep linked package even if it is not in package.json', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dev: false, @@ -1037,7 +1037,7 @@ test('keep linked package even if it is not in package.json', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dev: false, @@ -1071,7 +1071,7 @@ test("prune: don't remove package used by another importer", t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dev: false, @@ -1116,7 +1116,7 @@ test("prune: don't remove package used by another importer", t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dev: false, @@ -1148,7 +1148,7 @@ test('pruneSharedLockfile: remove one redundant package', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, @@ -1174,7 +1174,7 @@ test('pruneSharedLockfile: remove one redundant package', t => { }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-positive/1.0.0': { dev: false, diff --git a/packages/supi/test/install/aliases.ts b/packages/supi/test/install/aliases.ts index b14fe20d62..ee635dd8f9 100644 --- a/packages/supi/test/install/aliases.ts +++ b/packages/supi/test/install/aliases.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { prepareEmpty } from '@pnpm/prepare' import { getIntegrity } from '@pnpm/registry-mock' import { addDependenciesToPackage } from 'supi' @@ -24,7 +24,7 @@ test('installing aliased dependency', async (t: tape.Test) => { negative: '/is-negative/1.0.0', positive: '/is-positive/3.1.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dev: false, @@ -78,7 +78,7 @@ test('a dependency has an aliased subdependency', async (t: tape.Test) => { dependencies: { 'pkg-with-1-aliased-dep': '100.0.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dep-of-pkg-with-1-dep/100.1.0': { dev: false, diff --git a/packages/supi/test/install/local.ts b/packages/supi/test/install/local.ts index a68d6e6c68..f1ea0575eb 100644 --- a/packages/supi/test/install/local.ts +++ b/packages/supi/test/install/local.ts @@ -1,9 +1,8 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { prepareEmpty } from '@pnpm/prepare' import { addDistTag } from '@pnpm/registry-mock' import { copyFixture, pathToLocalPkg } from '@pnpm/test-fixtures' import rimraf = require('@zkochan/rimraf') -import { copy } from 'fs-extra' import fs = require('mz/fs') import normalizePath = require('normalize-path') import path = require('path') @@ -47,7 +46,7 @@ test('local file', async (t: tape.Test) => { dependencies: { 'local-pkg': 'link:../local-pkg', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, specifiers: expectedSpecs, }) }) @@ -71,7 +70,7 @@ test('local file via link:', async (t: tape.Test) => { dependencies: { 'local-pkg': 'link:../local-pkg', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, specifiers: expectedSpecs, }) }) @@ -97,7 +96,7 @@ test('local file with symlinked node_modules', async (t: tape.Test) => { dependencies: { 'local-pkg': 'link:../local-pkg', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, specifiers: expectedSpecs, }) }) diff --git a/packages/supi/test/install/misc.ts b/packages/supi/test/install/misc.ts index 077da9ae52..bd6caca0f8 100644 --- a/packages/supi/test/install/misc.ts +++ b/packages/supi/test/install/misc.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { PackageManifestLog, ProgressLog, @@ -931,7 +931,7 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall dependencies: { foobarqar: '1.0.1', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/bar/100.0.0': { dev: false, @@ -1027,7 +1027,7 @@ test('subdep symlinks are updated if the lockfile has new subdep versions specif dependencies: { 'parent-of-pkg-with-1-dep': '1.0.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dep-of-pkg-with-1-dep/100.1.0': { dev: false, diff --git a/packages/supi/test/install/multipleImporters.ts b/packages/supi/test/install/multipleImporters.ts index 78646018b0..b4040316c5 100644 --- a/packages/supi/test/install/multipleImporters.ts +++ b/packages/supi/test/install/multipleImporters.ts @@ -1,5 +1,5 @@ import assertProject from '@pnpm/assert-project' -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { readCurrentLockfile } from '@pnpm/lockfile-file' import { prepareEmpty, preparePackages } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' @@ -490,7 +490,7 @@ test('partial installation in a monorepo does not remove dependencies of other w }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dep-of-pkg-with-1-dep/100.0.0': { dev: false, @@ -583,7 +583,7 @@ test('partial installation in a monorepo does not remove dependencies of other w }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dep-of-pkg-with-1-dep/100.0.0': { dev: false, diff --git a/packages/supi/test/lockfile.ts b/packages/supi/test/lockfile.ts index ef8f70a3b3..520ebacc56 100644 --- a/packages/supi/test/lockfile.ts +++ b/packages/supi/test/lockfile.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { RootLog } from '@pnpm/core-loggers' import PnpmError from '@pnpm/error' import { Lockfile, TarballResolution } from '@pnpm/lockfile-file' @@ -51,7 +51,7 @@ test('lockfile has correct format', async (t: tape.Test) => { const lockfile = await project.readLockfile() const id = '/pkg-with-1-dep/100.0.0' - t.equal(lockfile.lockfileVersion, 5.1, 'correct lockfile version') + t.equal(lockfile.lockfileVersion, LOCKFILE_VERSION, 'correct lockfile version') t.ok(lockfile.specifiers, 'has specifiers field') t.ok(lockfile.dependencies, 'has dependencies field') @@ -98,7 +98,7 @@ test('lockfile with scoped package', async (t: tape.Test) => { dependencies: { '@types/semver': '5.3.31', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/@types/semver/5.3.31': { resolution: { @@ -125,7 +125,7 @@ test('fail when shasum from lockfile does not match with the actual one', async dependencies: { 'is-negative': '2.1.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/2.1.0': { resolution: { @@ -186,7 +186,7 @@ test('lockfile removed when no deps in package.json', async (t: tape.Test) => { dependencies: { 'is-negative': '2.1.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/2.1.0': { resolution: { @@ -213,7 +213,7 @@ test('lockfile is fixed when it does not match package.json', async (t: tape.Tes 'is-negative': '2.1.0', 'is-positive': '3.1.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/@types/semver/5.3.31': { resolution: { @@ -271,7 +271,7 @@ test(`doing named installation when ${WANTED_LOCKFILE} exists already`, async (t 'is-negative': '2.1.0', 'is-positive': '3.1.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/@types/semver/5.3.31': { resolution: { @@ -492,7 +492,7 @@ test('scoped module from different registry', async (t: tape.Test) => { '@zkochan/foo': '1.0.0', 'is-positive': '3.1.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/@foo/has-dep-from-same-scope/1.0.0': { dependencies: { @@ -694,7 +694,7 @@ test('lockfile is ignored when lockfile = false', async (t: tape.Test) => { dependencies: { 'is-negative': '2.1.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/2.1.0': { resolution: { @@ -801,7 +801,7 @@ test('packages installed via tarball URL from the default registry are normalize 'is-positive': 'registry.npmjs.org/is-positive/-/is-positive-1.0.0', 'pkg-with-tarball-dep-from-registry': '1.0.0', }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/dep-of-pkg-with-1-dep/100.0.0': { dev: false, @@ -862,7 +862,7 @@ test('lockfile file has correct format when lockfile directory does not equal th const lockfile: Lockfile = await readYamlFile(WANTED_LOCKFILE) const id = '/pkg-with-1-dep/100.0.0' - t.equal(lockfile.lockfileVersion, 5.1, 'correct lockfile version') + t.equal(lockfile.lockfileVersion, LOCKFILE_VERSION, 'correct lockfile version') t.ok(lockfile.importers) t.ok(lockfile.importers.project) @@ -963,7 +963,7 @@ test(`doing named installation when shared ${WANTED_LOCKFILE} exists already`, a }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/2.1.0': { resolution: { diff --git a/packages/supi/test/uninstall.ts b/packages/supi/test/uninstall.ts index e9a310465f..65649bd543 100644 --- a/packages/supi/test/uninstall.ts +++ b/packages/supi/test/uninstall.ts @@ -1,4 +1,4 @@ -import { WANTED_LOCKFILE } from '@pnpm/constants' +import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { PackageManifestLog, RootLog, @@ -343,7 +343,7 @@ test('uninstalling a dependency from package that uses shared lockfile', async ( }, }, }, - lockfileVersion: 5.1, + lockfileVersion: LOCKFILE_VERSION, packages: { '/is-negative/1.0.0': { dev: false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18d19eea06..073a256eb4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,10 +50,12 @@ importers: '@pnpm/types': 'link:../types' devDependencies: '@pnpm/audit': 'link:' + '@pnpm/constants': 3.0.0 '@pnpm/lockfile-file': 'link:../lockfile-file' nock: 12.0.3 specifiers: '@pnpm/audit': 'link:' + '@pnpm/constants': ^3.0.0 '@pnpm/error': 'workspace:1.2.0' '@pnpm/fetch': 'workspace:1.0.3' '@pnpm/lockfile-file': 'workspace:3.0.9-alpha.1' @@ -3410,6 +3412,12 @@ packages: node: '>=10' resolution: integrity: sha512-GTsO3rA0vKVx9w3IrB6rrxFfhguAqJxSl0Bg0DG/GxlzKYEe9YlSBImZgR/UxTrSDQICodpCJ/lYC1Vo4+K3eA== + /@pnpm/constants/3.0.0: + dev: true + engines: + node: '>=10' + resolution: + integrity: sha512-N+FCVHl3V8vlqeCH3k2qVoVrxGCmgWMYKjgG2yfS69lJlW2PNXpQ408gP00gctOCllFEFOmlHoRnrICVJ57ENw== /@pnpm/file-reporter/0.1.0: dependencies: graceful-fs: 4.2.1