test: all test packages should be from the @pnpm.e2e scope (#5211)

This commit is contained in:
Zoltan Kochan authored and GitHub committed 2022-08-19 05:05:34 +03:00
1 parent f4cc2d7b4c
commit cccaa0208f
129 files changed
+2301 -2233

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
es6-iterator: ^2.0.1
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
is-negative: ^2.1.0
@@ -31,8 +31,9 @@ packages:
dev: false
/is-negative/2.1.0:
resolution: {integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=}
resolution: {integrity: sha512-+iCKT4ZcvjRnjkHnQjZ8/qfciLLGD8BFKS0GNR5VjDU6jEiwh899R0GSMkaYcuTNd7fEKXb3Qib0webe6HczNw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: false
optional: true
+3 -2
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
is-negative: ^2.1.0
@@ -31,8 +31,9 @@ packages:
dev: false
/is-negative/2.1.0:
resolution: {integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=}
resolution: {integrity: sha512-+iCKT4ZcvjRnjkHnQjZ8/qfciLLGD8BFKS0GNR5VjDU6jEiwh899R0GSMkaYcuTNd7fEKXb3Qib0webe6HczNw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: false
optional: true
+3 -2
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
is-negative: ^2.1.0
@@ -31,8 +31,9 @@ packages:
dev: false
/is-negative/2.1.0:
resolution: {integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=}
resolution: {integrity: sha512-+iCKT4ZcvjRnjkHnQjZ8/qfciLLGD8BFKS0GNR5VjDU6jEiwh899R0GSMkaYcuTNd7fEKXb3Qib0webe6HczNw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: false
optional: true
+3 -2
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
is-negative: 1.0.0
@@ -55,8 +55,9 @@ packages:
dev: false
/is-negative/1.0.0:
resolution: {integrity: sha1-clmHeoPIAKwxkd17nZ+80PdS1P4=}
resolution: {integrity: sha512-1aKMsFUc7vYQGzt//8zhkjRWPoYkajY/I5MJEvrc0pDoHXrW7n5ri8DYxhy3rR+Dk0QFl7GjHHsZU1sppQrWtw==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: false
optional: true
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
is-negative: ^1.0.0
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
is-negative: ^1.0.0
+3 -3
View File
@@ -3,13 +3,13 @@
"version": "0.0.0",
"lockfileVersion": 1,
"dependencies": {
"dep-of-pkg-with-1-dep": {
"@pnpm.e2e/dep-of-pkg-with-1-dep": {
"version": "101.0.0"
},
"pkg-with-1-dep": {
"@pnpm.e2e/pkg-with-1-dep": {
"version": "100.0.0",
"dependencies": {
"dep-of-pkg-with-1-dep": {
"@pnpm.e2e/dep-of-pkg-with-1-dep": {
"version": "100.0.0"
}
}
@@ -2,7 +2,7 @@
"name": "has-npm-shrinkwrap-json",
"version": "0.0.0",
"dependencies": {
"dep-of-pkg-with-1-dep": "^101.0.0",
"pkg-with-1-dep": "*"
"@pnpm.e2e/dep-of-pkg-with-1-dep": "^101.0.0",
"@pnpm.e2e/pkg-with-1-dep": "*"
}
}
+28 -20
View File
@@ -1,23 +1,31 @@
dependencies:
deprecated: 1.0.0
is-negative: 1.0.0
devDependencies:
is-positive: 1.0.0
lockfileVersion: 5
packages:
/deprecated/1.0.0:
deprecated: This package is deprecated
dev: false
resolution:
integrity: sha512-IXOehroEnYcbv/C4Kam/SWp7doHhGuRU5PHwxkOsjPjMy+lZSICgMasAK74AkrulthvBxVvZqdDvjK63RfOY+w==
/is-negative/1.0.0:
resolution:
integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=
/is-positive/1.0.0:
dev: true
resolution:
integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=
lockfileVersion: 5.4
specifiers:
deprecated: 1.0.0
'@pnpm.e2e/deprecated': 1.0.0
is-negative: ^1.0.0
is-positive: ^1.0.0
dependencies:
'@pnpm.e2e/deprecated': 1.0.0
is-negative: 1.0.0
devDependencies:
is-positive: 1.0.0
packages:
/@pnpm.e2e/deprecated/1.0.0:
resolution: {integrity: sha512-oidipeQzM+eKHKOmDnruTG7wP+jySQAxskX54lMYTeaq1rBjC+G1u+l3TolCKShyyOz73mO2N9laBqyFB06t6A==}
deprecated: This package is deprecated. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
dev: false
/is-negative/1.0.0:
resolution: {integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=}
engines: {node: '>=0.10.0'}
dev: false
/is-positive/1.0.0:
resolution: {integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=}
engines: {node: '>=0.10.0'}
dev: true
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "wanted-shrinkwrap",
"version": "1.0.0",
"dependencies": {
"deprecated": "1.0.0",
"@pnpm.e2e/deprecated": "1.0.0",
"is-negative": "^2.1.0"
},
"devDependencies": {
+24 -16
View File
@@ -1,23 +1,31 @@
lockfileVersion: 5.4
specifiers:
'@pnpm.e2e/deprecated': 1.0.0
is-negative: ^2.1.0
is-positive: ^3.1.0
dependencies:
deprecated: 1.0.0
is-negative: 1.1.0
'@pnpm.e2e/deprecated': 1.0.0
is-negative: 2.1.0
devDependencies:
is-positive: 3.1.0
lockfileVersion: 5
packages:
/deprecated/1.0.0:
deprecated: This package is deprecated
/@pnpm.e2e/deprecated/1.0.0:
resolution: {integrity: sha512-oidipeQzM+eKHKOmDnruTG7wP+jySQAxskX54lMYTeaq1rBjC+G1u+l3TolCKShyyOz73mO2N9laBqyFB06t6A==}
deprecated: This package is deprecated. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
dev: false
resolution:
integrity: sha512-IXOehroEnYcbv/C4Kam/SWp7doHhGuRU5PHwxkOsjPjMy+lZSICgMasAK74AkrulthvBxVvZqdDvjK63RfOY+w==
/is-negative/1.1.0:
resolution:
integrity: sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=
/is-negative/2.1.0:
resolution: {integrity: sha512-+iCKT4ZcvjRnjkHnQjZ8/qfciLLGD8BFKS0GNR5VjDU6jEiwh899R0GSMkaYcuTNd7fEKXb3Qib0webe6HczNw==}
engines: {node: '>=0.10.0'}
dev: false
/is-positive/3.1.0:
resolution: {integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=}
engines: {node: '>=0.10.0'}
dev: true
resolution:
integrity: sha1-hX21hKG6XRyymAUn/DtsQ103sP0=
specifiers:
deprecated: 1.0.0
is-negative: ^1.1.0
is-positive: ^3.1.0
+3 -3
View File
@@ -3,13 +3,13 @@
"version": "0.0.0",
"lockfileVersion": 1,
"dependencies": {
"dep-of-pkg-with-1-dep": {
"@pnpm.e2e/dep-of-pkg-with-1-dep": {
"version": "101.0.0"
},
"pkg-with-1-dep": {
"@pnpm.e2e/pkg-with-1-dep": {
"version": "100.0.0",
"dependencies": {
"dep-of-pkg-with-1-dep": {
"@pnpm.e2e/dep-of-pkg-with-1-dep": {
"version": "100.0.0"
}
}
+2 -2
View File
@@ -2,8 +2,8 @@
"name": "has-package-lock-json",
"version": "0.0.0",
"dependencies": {
"dep-of-pkg-with-1-dep": "^101.0.0",
"pkg-with-1-dep": "*"
"@pnpm.e2e/dep-of-pkg-with-1-dep": "^101.0.0",
"@pnpm.e2e/pkg-with-1-dep": "*"
},
"scripts": {
"prepare": "exit 1"
+1
View File
@@ -0,0 +1 @@
registry=http://localhost:4873/
+2 -2
View File
@@ -2,7 +2,7 @@
"name": "has-yarn-lock",
"version": "0.0.0",
"dependencies": {
"dep-of-pkg-with-1-dep": "^101.0.0",
"pkg-with-1-dep": "*"
"@pnpm.e2e/dep-of-pkg-with-1-dep": "^100.0.0",
"@pnpm.e2e/pkg-with-1-dep": "*"
}
}
+9 -9
View File
@@ -2,14 +2,14 @@
# yarn lockfile v1
dep-of-pkg-with-1-dep@^1.0.0, dep-of-pkg-with-1-dep@^101.0.0:
version "1.1.0"
resolved "https://registry.nlark.com/dep-of-pkg-with-1-dep/download/dep-of-pkg-with-1-dep-1.1.0.tgz#67d3ac196cb08162e543b87b3b1829c76072c927"
integrity sha1-Z9OsGWywgWLlQ7h7Oxgpx2ByySc=
"@pnpm.e2e/dep-of-pkg-with-1-dep@^100.0.0":
version "100.0.0"
resolved "http://localhost:4873/@pnpm.e2e%2fdep-of-pkg-with-1-dep/-/dep-of-pkg-with-1-dep-100.0.0.tgz#a95f834b4a4d9661623a0cf2bd76acbc213192fc"
integrity sha512-KUmwlEiE3pzpmPCfrLkoOO7fmL4Tft+dcm6YQlUfOUJvHO73xlcKVoA/xOHP/ayUO8GiPlIqWRbKHrsxvXGE8g==
pkg-with-1-dep@*:
version "1.0.0"
resolved "https://registry.nlark.com/pkg-with-1-dep/download/pkg-with-1-dep-1.0.0.tgz#0d4ed129376f707bac0bf5f6a58410f663e27c80"
integrity sha1-DU7RKTdvcHusC/X2pYQQ9mPifIA=
"@pnpm.e2e/pkg-with-1-dep@*":
version "100.0.0"
resolved "http://localhost:4873/@pnpm.e2e%2fpkg-with-1-dep/-/pkg-with-1-dep-100.0.0.tgz#2845d276feb3153c4abc107728ddbe0f7ce75a45"
integrity sha512-tZBohBD7WeOtm0hBUQl0FlPvuTwyrdSn2V45P4jd2arjwKxM5YULEAtD1J42bKuEOJls4vS4/1v3lgS8qTfA2Q==
dependencies:
dep-of-pkg-with-1-dep "^1.0.0"
"@pnpm.e2e/dep-of-pkg-with-1-dep" "^100.0.0"
+1 -1
View File
@@ -1,5 +1,5 @@
{
"name": "hello-world-js-bin",
"name": "@pnpm.e2e/hello-world-js-bin",
"version": "1.0.0",
"description": "A package with a hello world js bin",
"bin": "./index.js",
+2 -2
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
positive: npm:is-positive@1.0.0
@@ -9,6 +9,6 @@ dependencies:
packages:
/is-positive/1.0.0:
resolution: {integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=}
resolution: {integrity: sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==}
engines: {node: '>=0.10.0'}
dev: false
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
general: link:../general
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
ajv: ^6.10.2
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
symlink-dir: 2.0.2
+1 -1
View File
@@ -39,7 +39,7 @@
"@commitlint/prompt-cli": "^17.0.3",
"@pnpm/eslint-config": "workspace:*",
"@pnpm/meta-updater": "0.0.6",
"@pnpm/registry-mock": "3.0.0-0",
"@pnpm/registry-mock": "3.0.0-2",
"@pnpm/tsconfig": "workspace:*",
"@types/jest": "^28.1.6",
"@types/node": "^14.18.23",
+1 -1
View File
@@ -77,7 +77,7 @@
"@pnpm/logger": "^4.0.0",
"@pnpm/package-store": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "3.0.0-0",
"@pnpm/registry-mock": "3.0.0-2",
"@pnpm/store-path": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@types/fs-extra": "^9.0.13",
@@ -11,12 +11,12 @@ import writeYamlFile from 'write-yaml-file'
import { testDefaults } from './utils'
test('installation breaks if the lockfile contains the wrong checksum', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({},
[
'pkg-with-1-dep@100.0.0',
'@pnpm.e2e/pkg-with-1-dep@100.0.0',
],
await testDefaults({ lockfileOnly: true })
)
@@ -24,7 +24,7 @@ test('installation breaks if the lockfile contains the wrong checksum', async ()
const corruptedLockfile = await project.readLockfile()
const correctLockfile = clone(corruptedLockfile)
// breaking the lockfile
corruptedLockfile.packages['/pkg-with-1-dep/100.0.0'].resolution['integrity'] = corruptedLockfile.packages['/dep-of-pkg-with-1-dep/100.0.0'].resolution['integrity']
corruptedLockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].resolution['integrity'] = corruptedLockfile.packages['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'].resolution['integrity']
await writeYamlFile(WANTED_LOCKFILE, corruptedLockfile, { lineWidth: 1000 })
await expect(mutateModules([
@@ -65,20 +65,20 @@ test('installation breaks if the lockfile contains the wrong checksum', async ()
})
test('installation breaks if the lockfile contains the wrong checksum and the store is clean', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({},
[
'pkg-with-1-dep@100.0.0',
'@pnpm.e2e/pkg-with-1-dep@100.0.0',
],
await testDefaults({ lockfileOnly: true })
)
const corruptedLockfile = await project.readLockfile()
const correctIntegrity = corruptedLockfile.packages['/pkg-with-1-dep/100.0.0'].resolution['integrity']
const correctIntegrity = corruptedLockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].resolution['integrity']
// breaking the lockfile
corruptedLockfile.packages['/pkg-with-1-dep/100.0.0'].resolution['integrity'] = 'sha512-pl8WtlGAnoIQ7gPxT187/YwhKRnsFBR4h0YY+v0FPQjT5WPuZbI9dPRaKWgKBFOqWHylJ8EyPy34V5u9YArfng=='
corruptedLockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].resolution['integrity'] = 'sha512-pl8WtlGAnoIQ7gPxT187/YwhKRnsFBR4h0YY+v0FPQjT5WPuZbI9dPRaKWgKBFOqWHylJ8EyPy34V5u9YArfng=='
await writeYamlFile(WANTED_LOCKFILE, corruptedLockfile, { lineWidth: 1000 })
await expect(
@@ -104,7 +104,7 @@ test('installation breaks if the lockfile contains the wrong checksum and the st
{
const lockfile = await project.readLockfile()
expect(lockfile.packages['/pkg-with-1-dep/100.0.0'].resolution['integrity']).toBe(correctIntegrity)
expect(lockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].resolution['integrity']).toBe(correctIntegrity)
}
// Breaking the lockfile again
@@ -130,6 +130,6 @@ test('installation breaks if the lockfile contains the wrong checksum and the st
}))
{
const lockfile = await project.readLockfile()
expect(lockfile.packages['/pkg-with-1-dep/100.0.0'].resolution['integrity']).toBe(correctIntegrity)
expect(lockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].resolution['integrity']).toBe(correctIntegrity)
}
})
+10 -10
View File
@@ -8,31 +8,31 @@ test('should fail to update when requests are cached', async () => {
const opts = await testDefaults()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], opts)
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], opts)
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(manifest, { ...opts, depth: 1, update: true })
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
})
test('should not cache when cache is not used', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ save: true }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ save: true }))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(manifest, await testDefaults({ depth: 1, update: true }))
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0')
})
@@ -26,8 +26,8 @@ test('a conflict is detected when the same peer is required with ranges that do
{
manifest: {
dependencies: {
'has-foo100-peer': '1.0.0',
'has-foo101-peer': '1.0.0',
'@pnpm.e2e/has-foo100-peer': '1.0.0',
'@pnpm.e2e/has-foo101-peer': '1.0.0',
},
},
rootDir: process.cwd(),
+21 -21
View File
@@ -83,23 +83,23 @@ test('overwriting existing files in node_modules', async () => {
test('preserve subdeps on update', async () => {
prepareEmpty()
await addDistTag({ package: 'foobarqar', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage(
{},
['foobarqar@1.0.0', 'bar@100.1.0'],
['@pnpm.e2e/foobarqar@1.0.0', '@pnpm.e2e/bar@100.1.0'],
await testDefaults({ nodeLinker: 'hoisted' })
)
await addDependenciesToPackage(
manifest,
['foobarqar@1.0.1'],
['@pnpm.e2e/foobarqar@1.0.1'],
await testDefaults({ nodeLinker: 'hoisted' })
)
expect(loadJsonFile<{ version: string }>('node_modules/bar/package.json').version).toBe('100.1.0')
expect(loadJsonFile<{ version: string }>('node_modules/foobarqar/package.json').version).toBe('1.0.1')
expect(loadJsonFile<{ version: string }>('node_modules/foobarqar/node_modules/bar/package.json').version).toBe('100.0.0')
expect(loadJsonFile<{ version: string }>('node_modules/@pnpm.e2e/bar/package.json').version).toBe('100.1.0')
expect(loadJsonFile<{ version: string }>('node_modules/@pnpm.e2e/foobarqar/package.json').version).toBe('1.0.1')
expect(loadJsonFile<{ version: string }>('node_modules/@pnpm.e2e/foobarqar/node_modules/@pnpm.e2e/bar/package.json').version).toBe('100.0.0')
})
test('adding a new dependency to one of the workspace projects', async () => {
@@ -113,7 +113,7 @@ test('adding a new dependency to one of the workspace projects', async () => {
version: '1.0.0',
dependencies: {
bar: '100.0.0',
'@pnpm.e2e/bar': '100.0.0',
},
},
mutation: 'install',
@@ -126,7 +126,7 @@ test('adding a new dependency to one of the workspace projects', async () => {
version: '1.0.0',
dependencies: {
foobarqar: '1.0.0',
'@pnpm.e2e/foobarqar': '1.0.0',
},
},
mutation: 'install',
@@ -139,41 +139,41 @@ test('adding a new dependency to one of the workspace projects', async () => {
await testDefaults({ nodeLinker: 'hoisted', prefix: path.resolve('project-1'), targetDependenciesField: 'devDependencies' })
)
expect(manifest.dependencies).toStrictEqual({ bar: '100.0.0' })
expect(manifest.dependencies).toStrictEqual({ '@pnpm.e2e/bar': '100.0.0' })
expect(manifest.devDependencies).toStrictEqual({ 'is-negative': '1.0.0' })
expect(loadJsonFile<{ version: string }>('node_modules/bar/package.json').version).toBe('100.0.0')
expect(loadJsonFile<{ version: string }>('node_modules/@pnpm.e2e/bar/package.json').version).toBe('100.0.0')
expect(loadJsonFile<{ version: string }>('node_modules/is-negative/package.json').version).toBe('1.0.0')
})
test('installing the same package with alias and no alias', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
prepareEmpty()
await addDependenciesToPackage(
{},
['pkg-with-1-aliased-dep@100.0.0', 'dep-of-pkg-with-1-dep@^100.0.0'],
['@pnpm.e2e/pkg-with-1-aliased-dep@100.0.0', '@pnpm.e2e/dep-of-pkg-with-1-dep@^100.0.0'],
await testDefaults({ nodeLinker: 'hoisted' })
)
expect(loadJsonFile<{ version: string }>('node_modules/pkg-with-1-aliased-dep/package.json').version).toBe('100.0.0')
expect(loadJsonFile<{ version: string }>('node_modules/dep-of-pkg-with-1-dep/package.json').version).toBe('100.0.0')
expect(loadJsonFile<{ version: string }>('node_modules/@pnpm.e2e/pkg-with-1-aliased-dep/package.json').version).toBe('100.0.0')
expect(loadJsonFile<{ version: string }>('node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep/package.json').version).toBe('100.0.0')
expect(loadJsonFile<{ version: string }>('node_modules/dep/package.json').version).toBe('100.0.0')
})
test('run pre/postinstall scripts. bin files should be linked in a hoisted node_modules', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example'],
['@pnpm.e2e/pre-and-postinstall-scripts-example'],
await testDefaults({ fastUnpack: false, nodeLinker: 'hoisted', targetDependenciesField: 'devDependencies' })
)
expect(fs.existsSync('node_modules/pre-and-postinstall-scripts-example/generated-by-prepare.js')).toBeFalsy()
expect(fs.existsSync('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeTruthy()
expect(fs.existsSync('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-prepare.js')).toBeFalsy()
expect(fs.existsSync('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeTruthy()
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
const generatedByPreinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall')
expect(typeof generatedByPreinstall).toBe('function')
const generatedByPostinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-postinstall')
const generatedByPostinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall')
expect(typeof generatedByPostinstall).toBe('function')
})
@@ -189,7 +189,7 @@ test('running install scripts in a workspace that has no root project', async ()
version: '1.0.0',
dependencies: {
'pre-and-postinstall-scripts-example': '1.0.0',
'@pnpm.e2e/pre-and-postinstall-scripts-example': '1.0.0',
},
},
mutation: 'install',
@@ -197,7 +197,7 @@ test('running install scripts in a workspace that has no root project', async ()
},
], await testDefaults({ fastUnpack: false, nodeLinker: 'hoisted' }))
expect(fs.existsSync('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeTruthy()
expect(fs.existsSync('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeTruthy()
})
test('hoistingLimits should prevent packages to be hoisted', async () => {
+14 -14
View File
@@ -50,47 +50,47 @@ test('aliased dependency w/o version spec, with custom tag config', async () =>
const tag = 'beta'
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: tag })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: tag })
await addDependenciesToPackage({}, ['foo@npm:dep-of-pkg-with-1-dep'], await testDefaults({ tag }))
await addDependenciesToPackage({}, ['foo@npm:@pnpm.e2e/dep-of-pkg-with-1-dep'], await testDefaults({ tag }))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
})
test('a dependency has an aliased subdependency', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const project = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-1-aliased-dep'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-aliased-dep'], await testDefaults({ fastUnpack: false }))
expect(project.requireModule('pkg-with-1-aliased-dep')().name).toEqual('dep-of-pkg-with-1-dep')
expect(project.requireModule('@pnpm.e2e/pkg-with-1-aliased-dep')().name).toEqual('@pnpm.e2e/dep-of-pkg-with-1-dep')
expect(await project.readLockfile()).toStrictEqual({
dependencies: {
'pkg-with-1-aliased-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-aliased-dep': '100.0.0',
},
lockfileVersion: LOCKFILE_VERSION,
packages: {
'/dep-of-pkg-with-1-dep/100.1.0': {
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0': {
dev: false,
resolution: {
integrity: getIntegrity('dep-of-pkg-with-1-dep', '100.1.0'),
integrity: getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0'),
},
},
'/pkg-with-1-aliased-dep/100.0.0': {
'/@pnpm.e2e/pkg-with-1-aliased-dep/100.0.0': {
dependencies: {
dep: '/dep-of-pkg-with-1-dep/100.1.0',
dep: '/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0',
},
dev: false,
resolution: {
integrity: getIntegrity('pkg-with-1-aliased-dep', '100.0.0'),
integrity: getIntegrity('@pnpm.e2e/pkg-with-1-aliased-dep', '100.0.0'),
},
},
},
specifiers: {
'pkg-with-1-aliased-dep': '^100.0.0',
'@pnpm.e2e/pkg-with-1-aliased-dep': '^100.0.0',
},
})
})
+12 -12
View File
@@ -20,13 +20,13 @@ test('a package that need authentication', async () => {
[`//localhost:${REGISTRY_MOCK_PORT}/:_authToken`]: data.token,
registry: `http://localhost:${REGISTRY_MOCK_PORT}/`,
}
const manifest = await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({}, {
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/needs-auth'], await testDefaults({}, {
authConfig,
}, {
authConfig,
}))
await project.has('needs-auth')
await project.has('@pnpm.e2e/needs-auth')
// should work when a lockfile is available
// and the registry in .npmrc is not the same as the one in lockfile
@@ -37,14 +37,14 @@ test('a package that need authentication', async () => {
[`//localhost:${REGISTRY_MOCK_PORT}/:_authToken`]: data.token,
registry: 'https://registry.npmjs.org/',
}
await addDependenciesToPackage(manifest, ['needs-auth'], await testDefaults({}, {
await addDependenciesToPackage(manifest, ['@pnpm.e2e/needs-auth'], await testDefaults({}, {
authConfig,
registry: 'https://registry.npmjs.org/',
}, {
authConfig,
}))
await project.has('needs-auth')
await project.has('@pnpm.e2e/needs-auth')
})
test('installing a package that need authentication, using password', async () => {
@@ -62,13 +62,13 @@ test('installing a package that need authentication, using password', async () =
[`//localhost:${REGISTRY_MOCK_PORT}/:username`]: 'foo',
registry: `http://localhost:${REGISTRY_MOCK_PORT}/`,
}
await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({}, {
await addDependenciesToPackage({}, ['@pnpm.e2e/needs-auth'], await testDefaults({}, {
authConfig,
}, {
authConfig,
}))
await project.has('needs-auth')
await project.has('@pnpm.e2e/needs-auth')
})
test('a package that need authentication, legacy way', async () => {
@@ -85,13 +85,13 @@ test('a package that need authentication, legacy way', async () => {
'always-auth': true,
registry: `http://localhost:${REGISTRY_MOCK_PORT}`,
}
await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({}, {
await addDependenciesToPackage({}, ['@pnpm.e2e/needs-auth'], await testDefaults({}, {
authConfig,
}, {
authConfig,
}))
await project.has('needs-auth')
await project.has('@pnpm.e2e/needs-auth')
})
test('a scoped package that need authentication specific to scope', async () => {
@@ -189,7 +189,7 @@ skipOnNode17('a package that need authentication reuses authorization tokens for
[`//127.0.0.1:${REGISTRY_MOCK_PORT}/:always-auth`]: true,
registry: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
}
await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({
await addDependenciesToPackage({}, ['@pnpm.e2e/needs-auth'], await testDefaults({
registries: {
default: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
},
@@ -200,7 +200,7 @@ skipOnNode17('a package that need authentication reuses authorization tokens for
authConfig,
}))
await project.has('needs-auth')
await project.has('@pnpm.e2e/needs-auth')
})
skipOnNode17('a package that need authentication reuses authorization tokens for tarball fetching when meta info is cached', async () => {
@@ -228,7 +228,7 @@ skipOnNode17('a package that need authentication reuses authorization tokens for
authConfig,
})
const manifest = await addDependenciesToPackage({}, ['needs-auth'], opts)
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/needs-auth'], opts)
await rimraf('node_modules')
await rimraf(path.join('..', '.registry'))
@@ -247,5 +247,5 @@ skipOnNode17('a package that need authentication reuses authorization tokens for
})
await install(manifest, opts)
await project.has('needs-auth')
await project.has('@pnpm.e2e/needs-auth')
})
+50 -45
View File
@@ -2,39 +2,40 @@ import { addDependenciesToPackage, install, mutateModules } from '@pnpm/core'
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import rimraf from '@zkochan/rimraf'
import { createPeersFolderSuffix } from 'dependency-path'
import { testDefaults } from '../utils'
test('auto install non-optional peer dependencies', async () => {
await addDistTag({ package: 'peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.0', distTag: 'latest' })
const project = prepareEmpty()
await addDependenciesToPackage({}, ['abc-optional-peers@1.0.0'], await testDefaults({ autoInstallPeers: true }))
await addDependenciesToPackage({}, ['@pnpm.e2e/abc-optional-peers@1.0.0'], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
'/abc-optional-peers/1.0.0_peer-a@1.0.0',
'/peer-a/1.0.0',
'/@pnpm.e2e/abc-optional-peers/1.0.0_@pnpm.e2e+peer-a@1.0.0',
'/@pnpm.e2e/peer-a/1.0.0',
])
await project.hasNot('peer-a')
await project.hasNot('@pnpm.e2e/peer-a')
})
test('auto install the common peer dependency', async () => {
await addDistTag({ package: 'peer-c', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.1', distTag: 'latest' })
const project = prepareEmpty()
await addDependenciesToPackage({}, ['wants-peer-c-1', 'wants-peer-c-1.0.0'], await testDefaults({ autoInstallPeers: true }))
await addDependenciesToPackage({}, ['@pnpm.e2e/wants-peer-c-1', '@pnpm.e2e/wants-peer-c-1.0.0'], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
'/peer-c/1.0.0',
'/wants-peer-c-1.0.0/1.0.0_peer-c@1.0.0',
'/wants-peer-c-1/1.0.0_peer-c@1.0.0',
'/@pnpm.e2e/peer-c/1.0.0',
'/@pnpm.e2e/wants-peer-c-1.0.0/1.0.0_@pnpm.e2e+peer-c@1.0.0',
'/@pnpm.e2e/wants-peer-c-1/1.0.0_@pnpm.e2e+peer-c@1.0.0',
])
})
test('do not auto install when there is no common peer dependency range intersection', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['wants-peer-c-1', 'wants-peer-c-2'], await testDefaults({ autoInstallPeers: true }))
await addDependenciesToPackage({}, ['@pnpm.e2e/wants-peer-c-1', '@pnpm.e2e/wants-peer-c-2'], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
'/wants-peer-c-1/1.0.0',
'/wants-peer-c-2/1.0.0',
'/@pnpm.e2e/wants-peer-c-1/1.0.0',
'/@pnpm.e2e/wants-peer-c-2/1.0.0',
])
})
@@ -60,22 +61,23 @@ test('don\'t fail on linked package, when peers are auto installed', async () =>
},
])
process.chdir('pkg')
const updatedManifest = await addDependenciesToPackage(pkgManifest, ['peer-b'], await testDefaults({ autoInstallPeers: true }))
expect(Object.keys(updatedManifest.dependencies ?? {})).toStrictEqual(['linked', 'peer-b'])
const updatedManifest = await addDependenciesToPackage(pkgManifest, ['@pnpm.e2e/peer-b'], await testDefaults({ autoInstallPeers: true }))
expect(Object.keys(updatedManifest.dependencies ?? {})).toStrictEqual(['linked', '@pnpm.e2e/peer-b'])
})
test('hoist a peer dependency in order to reuse it by other dependencies, when it satisfies them', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['@pnpm/xyz-parent-parent-parent-parent', '@pnpm/xyz-parent-parent-with-xyz'], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
const suffix = createPeersFolderSuffix([{ name: '@pnpm/x', version: '1.0.0' }, { name: '@pnpm/y', version: '1.0.0' }, { name: '@pnpm/z', version: '1.0.0' }])
expect(Object.keys(lockfile.packages)).toStrictEqual([
'/@pnpm/x/1.0.0',
'/@pnpm/xyz-parent-parent-parent-parent/1.0.0_e5suan7fvtov6fikg25btc2odi',
'/@pnpm/xyz-parent-parent-parent/1.0.0_e5suan7fvtov6fikg25btc2odi',
`/@pnpm/xyz-parent-parent-parent-parent/1.0.0${suffix}`,
`/@pnpm/xyz-parent-parent-parent/1.0.0${suffix}`,
'/@pnpm/xyz-parent-parent-with-xyz/1.0.0',
'/@pnpm/xyz-parent-parent/1.0.0_e5suan7fvtov6fikg25btc2odi',
'/@pnpm/xyz-parent/1.0.0_e5suan7fvtov6fikg25btc2odi',
'/@pnpm/xyz/1.0.0_e5suan7fvtov6fikg25btc2odi',
`/@pnpm/xyz-parent-parent/1.0.0${suffix}`,
`/@pnpm/xyz-parent/1.0.0${suffix}`,
`/@pnpm/xyz/1.0.0${suffix}`,
'/@pnpm/y/1.0.0',
'/@pnpm/z/1.0.0',
])
@@ -86,59 +88,62 @@ test('don\'t hoist a peer dependency when there is a root dependency by that nam
await addDependenciesToPackage({}, [
'@pnpm/xyz-parent-parent-parent-parent',
'@pnpm/xyz-parent-parent-with-xyz',
'@pnpm/x@npm:peer-a@1.0.0',
'@pnpm/x@npm:@pnpm.e2e/peer-a@1.0.0',
`http://localhost:${REGISTRY_MOCK_PORT}/@pnpm/y/-/y-2.0.0.tgz`,
], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
const suffix1 = createPeersFolderSuffix([{ name: '@pnpm/y', version: '2.0.0' }, { name: '@pnpm/z', version: '1.0.0' }, { name: '@pnpm.e2e/peer-a', version: '1.0.0' }])
const suffix2 = createPeersFolderSuffix([{ name: '@pnpm/x', version: '1.0.0' }, { name: '@pnpm/y', version: '1.0.0' }, { name: '@pnpm/z', version: '1.0.0' }])
expect(Object.keys(lockfile.packages).sort()).toStrictEqual([
'/@pnpm.e2e/peer-a/1.0.0',
'/@pnpm/x/1.0.0',
'/@pnpm/xyz-parent-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
`/@pnpm/xyz-parent-parent-parent-parent/1.0.0${suffix1}`,
`/@pnpm/xyz-parent-parent-parent/1.0.0${suffix1}`,
'/@pnpm/xyz-parent-parent-with-xyz/1.0.0',
'/@pnpm/xyz-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz-parent/1.0.0_e5suan7fvtov6fikg25btc2odi',
'/@pnpm/xyz/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz/1.0.0_e5suan7fvtov6fikg25btc2odi',
`/@pnpm/xyz-parent-parent/1.0.0${suffix1}`,
`/@pnpm/xyz-parent/1.0.0${suffix1}`,
`/@pnpm/xyz-parent/1.0.0${suffix2}`,
`/@pnpm/xyz/1.0.0${suffix1}`,
`/@pnpm/xyz/1.0.0${suffix2}`,
'/@pnpm/y/1.0.0',
'/@pnpm/y/2.0.0',
'/@pnpm/z/1.0.0',
'/peer-a/1.0.0',
])
].sort())
})
test('don\'t auto-install a peer dependency, when that dependency is in the root', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, [
'@pnpm/xyz-parent-parent-parent-parent',
'@pnpm/x@npm:peer-a@1.0.0',
'@pnpm/x@npm:@pnpm.e2e/peer-a@1.0.0',
`http://localhost:${REGISTRY_MOCK_PORT}/@pnpm/y/-/y-2.0.0.tgz`,
], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
'/@pnpm/xyz-parent-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz-parent-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz-parent-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz-parent/1.0.0_c3hmehglzcfufab5hu6m6d76li',
'/@pnpm/xyz/1.0.0_c3hmehglzcfufab5hu6m6d76li',
const suffix = createPeersFolderSuffix([{ name: '@pnpm/y', version: '2.0.0' }, { name: '@pnpm/z', version: '1.0.0' }, { name: '@pnpm.e2e/peer-a', version: '1.0.0' }])
expect(Object.keys(lockfile.packages).sort()).toStrictEqual([
`/@pnpm/xyz-parent-parent-parent-parent/1.0.0${suffix}`,
`/@pnpm/xyz-parent-parent-parent/1.0.0${suffix}`,
`/@pnpm/xyz-parent-parent/1.0.0${suffix}`,
`/@pnpm/xyz-parent/1.0.0${suffix}`,
`/@pnpm/xyz/1.0.0${suffix}`,
'/@pnpm/y/2.0.0',
'/@pnpm/z/1.0.0',
'/peer-a/1.0.0',
])
'/@pnpm.e2e/peer-a/1.0.0',
].sort())
})
test('don\'t install the same missing peer dependency twice', async () => {
await addDistTag({ package: '@pnpm/y', version: '2.0.0', distTag: 'latest' })
const project = prepareEmpty()
await addDependenciesToPackage({}, [
'has-has-y-peer-peer',
'@pnpm.e2e/has-has-y-peer-peer',
], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
expect(Object.keys(lockfile.packages).sort()).toStrictEqual([
'/@pnpm/y/1.0.0',
'/has-has-y-peer-peer/1.0.0_c7ewbmm644hn6ztbh6kbjiyhkq',
'/has-y-peer/1.0.0_@pnpm+y@1.0.0',
])
`/@pnpm.e2e/has-has-y-peer-peer/1.0.0${createPeersFolderSuffix([{ name: '@pnpm/y', version: '1.0.0' }, { name: '@pnpm.e2e/has-y-peer', version: '1.0.0' }])}`,
'/@pnpm.e2e/has-y-peer/1.0.0_@pnpm+y@1.0.0',
].sort())
})
test('automatically install root peer dependencies', async () => {
+48 -48
View File
@@ -6,140 +6,140 @@ import { testDefaults } from '../utils'
test('prefer version ranges specified for top dependencies', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(
{
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'pkg-with-1-dep': '*',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '*',
},
},
await testDefaults()
)
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
})
test('prefer version ranges specified for top dependencies, when doing named installation', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const manifest = await install(
{
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
},
await testDefaults()
)
await addDependenciesToPackage(manifest, ['pkg-with-1-dep'], await testDefaults())
await addDependenciesToPackage(manifest, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults())
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
})
test('prefer version ranges specified for top dependencies, even if they are aliased', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(
{
dependencies: {
foo: 'npm:dep-of-pkg-with-1-dep@100.0.0',
'pkg-with-1-dep': '*',
foo: 'npm:@pnpm.e2e/dep-of-pkg-with-1-dep@100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '*',
},
},
await testDefaults()
)
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
})
test('prefer version ranges specified for top dependencies, even if the subdependencies are aliased', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(
{
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'pkg-with-1-aliased-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-aliased-dep': '100.0.0',
},
},
await testDefaults()
)
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
})
test('ignore version of root dependency when it is incompatible with the indirect dependency\'s range', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await install(
{
dependencies: {
'dep-of-pkg-with-1-dep': '101.0.0',
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
await testDefaults()
)
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/101.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/101.0.0'])
})
test('prefer dist-tag specified for top dependency', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'stable' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'stable' })
await install(
{
dependencies: {
'dep-of-pkg-with-1-dep': 'stable',
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': 'stable',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
await testDefaults()
)
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
})
test('prefer version ranges passed in via opts.preferredVersions', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const project = prepareEmpty()
await install(
{
dependencies: {
'dep-of-pkg-with-1-dep': '^100.0.0',
'pkg-with-1-dep': '*',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '^100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '*',
},
},
await testDefaults(
{
preferredVersions: {
'dep-of-pkg-with-1-dep': {
'@pnpm.e2e/dep-of-pkg-with-1-dep': {
'100.0.0': 'version',
},
},
@@ -148,18 +148,18 @@ test('prefer version ranges passed in via opts.preferredVersions', async () => {
)
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
})
// Covers https://github.com/pnpm/pnpm/issues/1187
test('prefer version of package that also satisfies the range of the same package higher in the dependency graph', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
await addDependenciesToPackage(
{},
['has-foo-as-dep-and-subdep'],
['@pnpm.e2e/has-foo-as-dep-and-subdep'],
await testDefaults()
)
@@ -169,9 +169,9 @@ test('prefer version of package that also satisfies the range of the same packag
Object.keys(lockfile.packages)
).toStrictEqual(
[
'/foo/100.0.0',
'/has-foo-as-dep-and-subdep/1.0.0',
'/requires-any-foo/1.0.0',
'/@pnpm.e2e/foo/100.0.0',
'/@pnpm.e2e/has-foo-as-dep-and-subdep/1.0.0',
'/@pnpm.e2e/requires-any-foo/1.0.0',
]
)
})
@@ -179,15 +179,15 @@ test('prefer version of package that also satisfies the range of the same packag
test('dedupe subdependency when a newer version of the same package is installed', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['dep-of-pkg-with-1-dep@100.0.0', 'pkg-with-1-dep@100.0.0'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/dep-of-pkg-with-1-dep@100.0.0', '@pnpm.e2e/pkg-with-1-dep@100.0.0'], await testDefaults())
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDependenciesToPackage(manifest, ['dep-of-pkg-with-1-dep@100.1.0'], await testDefaults())
await addDependenciesToPackage(manifest, ['@pnpm.e2e/dep-of-pkg-with-1-dep@100.1.0'], await testDefaults())
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
})
@@ -3,52 +3,53 @@ import { prepareEmpty } from '@pnpm/prepare'
import { addDistTag } from '@pnpm/registry-mock'
import { addDependenciesToPackage } from '@pnpm/core'
import deepRequireCwd from 'deep-require-cwd'
import { createPeersFolderSuffix } from 'dependency-path'
import exists from 'path-exists'
import { testDefaults } from '../utils'
test('package with default peer dependency, when auto install peers is on', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const project = prepareEmpty()
await addDependenciesToPackage({}, ['has-default-peer'], await testDefaults({ autoInstallPeers: true }))
await addDependenciesToPackage({}, ['@pnpm.e2e/has-default-peer'], await testDefaults({ autoInstallPeers: true }))
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
})
test('don\'t install the default peer dependency when it may be resolved from parent packages', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['has-default-peer', 'dep-of-pkg-with-1-dep@101.0.0'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/has-default-peer', '@pnpm.e2e/dep-of-pkg-with-1-dep@101.0.0'], await testDefaults())
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
'/dep-of-pkg-with-1-dep/101.0.0',
'/has-default-peer/1.0.0_ptp3ffmxbab2qqs6nxppnituqi',
'/@pnpm.e2e/dep-of-pkg-with-1-dep/101.0.0',
`/@pnpm.e2e/has-default-peer/1.0.0${createPeersFolderSuffix([{ name: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '101.0.0' }])}`,
])
})
test('install the default peer dependency when it cannot be resolved from parent packages', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['has-default-peer'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/has-default-peer'], await testDefaults())
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual([
'/dep-of-pkg-with-1-dep/100.0.0',
'/has-default-peer/1.0.0',
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0',
'/@pnpm.e2e/has-default-peer/1.0.0',
])
})
test('package that resolves its own peer dependency', async () => {
await addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' })
const project = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-resolved-peer', 'peer-c@2.0.0'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-resolved-peer', '@pnpm.e2e/peer-c@2.0.0'], await testDefaults())
expect(deepRequireCwd(['pkg-with-resolved-peer', 'peer-c', './package.json']).version).toBe('2.0.0')
expect(deepRequireCwd(['@pnpm.e2e/pkg-with-resolved-peer', '@pnpm.e2e/peer-c', './package.json']).version).toBe('2.0.0')
expect(await exists(path.resolve('node_modules/.pnpm/pkg-with-resolved-peer@1.0.0_peer-c@2.0.0/node_modules/pkg-with-resolved-peer'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+pkg-with-resolved-peer@1.0.0_@pnpm.e2e+peer-c@2.0.0/node_modules/@pnpm.e2e/pkg-with-resolved-peer'))).toBeTruthy()
const lockfile = await project.readLockfile()
expect(lockfile.packages['/pkg-with-resolved-peer/1.0.0_peer-c@2.0.0']?.peerDependencies).toStrictEqual({ 'peer-c': '*' })
expect(lockfile.packages['/pkg-with-resolved-peer/1.0.0_peer-c@2.0.0'].dependencies).toHaveProperty(['peer-c'])
expect(lockfile.packages['/pkg-with-resolved-peer/1.0.0_peer-c@2.0.0'].optionalDependencies).toHaveProperty(['peer-b'])
expect(lockfile.packages['/@pnpm.e2e/pkg-with-resolved-peer/1.0.0_@pnpm.e2e+peer-c@2.0.0']?.peerDependencies).toStrictEqual({ '@pnpm.e2e/peer-c': '*' })
expect(lockfile.packages['/@pnpm.e2e/pkg-with-resolved-peer/1.0.0_@pnpm.e2e+peer-c@2.0.0'].dependencies).toHaveProperty(['@pnpm.e2e/peer-c'])
expect(lockfile.packages['/@pnpm.e2e/pkg-with-resolved-peer/1.0.0_@pnpm.e2e+peer-c@2.0.0'].optionalDependencies).toHaveProperty(['@pnpm.e2e/peer-b'])
})
+7 -7
View File
@@ -112,22 +112,22 @@ test('from a github repo with different name', async () => {
test('a subdependency is from a github repo with different name', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['has-aliased-git-dependency'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/has-aliased-git-dependency'], await testDefaults({ fastUnpack: false }))
const m = project.requireModule('has-aliased-git-dependency')
const m = project.requireModule('@pnpm.e2e/has-aliased-git-dependency')
expect(m).toEqual('Hi')
const lockfile = await project.readLockfile()
expect(lockfile.packages['/has-aliased-git-dependency/1.0.0'].dependencies).toStrictEqual({
'has-say-hi-peer': '1.0.0_hi@1.0.0',
expect(lockfile.packages['/@pnpm.e2e/has-aliased-git-dependency/1.0.0'].dependencies).toStrictEqual({
'@pnpm.e2e/has-say-hi-peer': '1.0.0_hi@1.0.0',
'say-hi': 'github.com/zkochan/hi/4cdebec76b7b9d1f6e219e06c42d92a6b8ea60cd',
})
await project.isExecutable('has-aliased-git-dependency/node_modules/.bin/hi')
await project.isExecutable('has-aliased-git-dependency/node_modules/.bin/szia')
await project.isExecutable('@pnpm.e2e/has-aliased-git-dependency/node_modules/.bin/hi')
await project.isExecutable('@pnpm.e2e/has-aliased-git-dependency/node_modules/.bin/szia')
expect(await exists(path.resolve('node_modules/.pnpm/has-say-hi-peer@1.0.0_hi@1.0.0/node_modules/has-say-hi-peer'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+has-say-hi-peer@1.0.0_hi@1.0.0/node_modules/@pnpm.e2e/has-say-hi-peer'))).toBeTruthy()
})
test('from a git repo', async () => {
+4 -4
View File
@@ -185,11 +185,11 @@ test(`prefer-frozen-lockfile+hoistPattern: should prefer headless installation w
const manifest = await install({
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
}, await testDefaults({ lockfileOnly: true }))
await project.hasNot('pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/pkg-with-1-dep')
const reporter = sinon.spy()
await install(manifest, await testDefaults({
@@ -204,8 +204,8 @@ test(`prefer-frozen-lockfile+hoistPattern: should prefer headless installation w
name: 'pnpm',
})).toBeTruthy()
await project.has('pkg-with-1-dep')
await project.has('.pnpm/node_modules/dep-of-pkg-with-1-dep')
await project.has('@pnpm.e2e/pkg-with-1-dep')
await project.has('.pnpm/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
})
test('prefer-frozen-lockfile: should prefer frozen-lockfile when package has linked dependency', async () => {
+57 -57
View File
@@ -207,36 +207,36 @@ test('hoistPattern=undefined throws exception when executed on node_modules inst
})
test('hoist by alias', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const project = prepareEmpty()
// pkg-with-1-aliased-dep aliases dep-of-pkg-with-1-dep as just "dep"
await addDependenciesToPackage({}, ['pkg-with-1-aliased-dep'], await testDefaults({ hoistPattern: '*' }))
// pkg-with-1-aliased-dep aliases @pnpm.e2e/dep-of-pkg-with-1-dep as just "dep"
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-aliased-dep'], await testDefaults({ hoistPattern: '*' }))
await project.has('pkg-with-1-aliased-dep')
await project.has('@pnpm.e2e/pkg-with-1-aliased-dep')
await project.has('.pnpm/node_modules/dep')
await project.hasNot('.pnpm/node_modules/dep-of-pkg-with-1-dep')
await project.hasNot('.pnpm/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
const modules = await project.readModulesManifest()
expect(modules).toBeTruthy()
expect(modules!.hoistedDependencies).toStrictEqual({ '/dep-of-pkg-with-1-dep/100.1.0': { dep: 'private' } })
expect(modules!.hoistedDependencies).toStrictEqual({ '/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0': { dep: 'private' } })
})
test('should remove aliased hoisted dependencies', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-aliased-dep'], await testDefaults({ hoistPattern: '*' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-aliased-dep'], await testDefaults({ hoistPattern: '*' }))
await mutateModules([
{
dependencyNames: ['pkg-with-1-aliased-dep'],
dependencyNames: ['@pnpm.e2e/pkg-with-1-aliased-dep'],
manifest,
mutation: 'uninstallSome',
rootDir: process.cwd(),
},
], await testDefaults({ hoistPattern: '*' }))
await project.hasNot('pkg-with-1-aliased-dep')
await project.hasNot('dep-of-pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/pkg-with-1-aliased-dep')
await project.hasNot('@pnpm.e2e/dep-of-pkg-with-1-dep')
try {
await resolveLinkTarget('./node_modules/dep')
throw new Error('should have failed')
@@ -252,7 +252,7 @@ test('should update .modules.yaml when pruning if we are flattening', async () =
await install({
dependencies: {
'pkg-with-1-aliased-dep': '*',
'@pnpm.e2e/pkg-with-1-aliased-dep': '*',
},
}, await testDefaults({ hoistPattern: '*' }))
@@ -297,17 +297,17 @@ test('should rehoist after pruning', async () => {
test('should hoist correctly peer dependencies', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['using-ajv'], await testDefaults({ hoistPattern: '*' }))
await addDependenciesToPackage({}, ['@pnpm.e2e/using-ajv'], await testDefaults({ hoistPattern: '*' }))
await project.has('.pnpm/node_modules/ajv-keywords')
})
test('should uninstall correctly peer dependencies', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['using-ajv'], await testDefaults({ hoistPattern: '*' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/using-ajv'], await testDefaults({ hoistPattern: '*' }))
await mutateModules([
{
dependencyNames: ['using-ajv'],
dependencyNames: ['@pnpm.e2e/using-ajv'],
manifest,
mutation: 'uninstallSome',
rootDir: process.cwd(),
@@ -323,14 +323,14 @@ test('hoist-pattern: hoist all dependencies to the virtual store node_modules',
name: 'root',
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
}
const workspacePackageManifest = {
name: 'package',
dependencies: {
foobar: '100.0.0',
'@pnpm.e2e/foobar': '100.0.0',
},
}
const projects = preparePackages([
@@ -360,53 +360,53 @@ test('hoist-pattern: hoist all dependencies to the virtual store node_modules',
]
await mutateModules(mutatedProjects, await testDefaults({ hoistPattern: '*' }))
await projects['root'].has('pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/dep-of-pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/foobar')
await projects['root'].has('.pnpm/node_modules/foo')
await projects['root'].has('.pnpm/node_modules/bar')
await projects['root'].hasNot('foobar')
await projects['root'].hasNot('foo')
await projects['root'].hasNot('bar')
await projects['root'].has('@pnpm.e2e/pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/foobar')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/foo')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/bar')
await projects['root'].hasNot('@pnpm.e2e/foobar')
await projects['root'].hasNot('@pnpm.e2e/foo')
await projects['root'].hasNot('@pnpm.e2e/bar')
await projects['package'].has('foobar')
await projects['package'].hasNot('foo')
await projects['package'].hasNot('bar')
await projects['package'].has('@pnpm.e2e/foobar')
await projects['package'].hasNot('@pnpm.e2e/foo')
await projects['package'].hasNot('@pnpm.e2e/bar')
await rimraf('node_modules')
await rimraf('package/node_modules')
await mutateModules(mutatedProjects, await testDefaults({ frozenLockfile: true, hoistPattern: '*' }))
await projects['root'].has('pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/dep-of-pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/foobar')
await projects['root'].has('.pnpm/node_modules/foo')
await projects['root'].has('.pnpm/node_modules/bar')
await projects['root'].hasNot('foobar')
await projects['root'].hasNot('foo')
await projects['root'].hasNot('bar')
await projects['root'].has('@pnpm.e2e/pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/foobar')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/foo')
await projects['root'].has('.pnpm/node_modules/@pnpm.e2e/bar')
await projects['root'].hasNot('@pnpm.e2e/foobar')
await projects['root'].hasNot('@pnpm.e2e/foo')
await projects['root'].hasNot('@pnpm.e2e/bar')
await projects['package'].has('foobar')
await projects['package'].hasNot('foo')
await projects['package'].hasNot('bar')
await projects['package'].has('@pnpm.e2e/foobar')
await projects['package'].hasNot('@pnpm.e2e/foo')
await projects['package'].hasNot('@pnpm.e2e/bar')
})
test('hoist when updating in one of the workspace projects', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const workspaceRootManifest = {
name: 'root',
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
}
const workspacePackageManifest = {
name: 'package',
dependencies: {
foo: '100.0.0',
'@pnpm.e2e/foo': '100.0.0',
},
}
preparePackages([
@@ -440,15 +440,15 @@ test('hoist when updating in one of the workspace projects', async () => {
{
const modulesManifest = await rootModules.readModulesManifest()
expect(modulesManifest?.hoistedDependencies).toStrictEqual({
'/dep-of-pkg-with-1-dep/100.0.0': { 'dep-of-pkg-with-1-dep': 'private' },
'/foo/100.0.0': { foo: 'private' },
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0': { '@pnpm.e2e/dep-of-pkg-with-1-dep': 'private' },
'/@pnpm.e2e/foo/100.0.0': { '@pnpm.e2e/foo': 'private' },
})
}
await mutateModules([
{
...mutatedProjects[0],
dependencySelectors: ['foo@100.1.0'],
dependencySelectors: ['@pnpm.e2e/foo@100.1.0'],
mutation: 'installSome',
},
], await testDefaults({ hoistPattern: '*', pruneLockfileImporters: false }))
@@ -459,26 +459,26 @@ test('hoist when updating in one of the workspace projects', async () => {
Object.keys(lockfile.packages)
).toStrictEqual(
[
'/dep-of-pkg-with-1-dep/100.0.0',
'/foo/100.0.0',
'/foo/100.1.0',
'/pkg-with-1-dep/100.0.0',
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0',
'/@pnpm.e2e/foo/100.0.0',
'/@pnpm.e2e/foo/100.1.0',
'/@pnpm.e2e/pkg-with-1-dep/100.0.0',
]
)
{
const modulesManifest = await rootModules.readModulesManifest()
expect(modulesManifest?.hoistedDependencies).toStrictEqual({
'/dep-of-pkg-with-1-dep/100.0.0': { 'dep-of-pkg-with-1-dep': 'private' },
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0': { '@pnpm.e2e/dep-of-pkg-with-1-dep': 'private' },
})
}
})
test('should recreate node_modules with hoisting', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ hoistPattern: undefined }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ hoistPattern: undefined }))
await project.hasNot('.pnpm/node_modules/dep-of-pkg-with-1-dep')
await project.hasNot('.pnpm/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
{
const modulesManifest = await project.readModulesManifest()
expect(modulesManifest?.hoistPattern).toBeFalsy()
@@ -494,8 +494,8 @@ test('should recreate node_modules with hoisting', async () => {
},
], await testDefaults({ hoistPattern: '*' }))
await project.has('pkg-with-1-dep')
await project.has('.pnpm/node_modules/dep-of-pkg-with-1-dep')
await project.has('@pnpm.e2e/pkg-with-1-dep')
await project.has('.pnpm/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
{
const modulesManifest = await project.readModulesManifest()
expect(modulesManifest?.hoistPattern).toBeTruthy()
@@ -512,13 +512,13 @@ test('hoisting should not create a broken symlink to a skipped optional dependen
'is-positive': '1.0.0',
},
optionalDependencies: {
'not-compatible-with-any-os': '*',
'@pnpm.e2e/not-compatible-with-any-os': '*',
},
}
await install(manifest, await testDefaults({ publicHoistPattern: '*' }))
await project.hasNot('dep-of-optional-pkg')
await project.hasNot('@pnpm.e2e/dep-of-optional-pkg')
expect(await rootModules.readCurrentLockfile()).toStrictEqual(await rootModules.readLockfile())
// Verifying the same with headless installation
@@ -526,14 +526,14 @@ test('hoisting should not create a broken symlink to a skipped optional dependen
await install(manifest, await testDefaults({ publicHoistPattern: '*' }))
await project.hasNot('dep-of-optional-pkg')
await project.hasNot('@pnpm.e2e/dep-of-optional-pkg')
expect(await rootModules.readCurrentLockfile()).toStrictEqual(await rootModules.readLockfile())
})
test('the hoisted packages should not override the bin files of the direct dependencies', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['hello-world-js-bin-parent'], await testDefaults({ fastUnpack: false, publicHoistPattern: '*' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/hello-world-js-bin-parent'], await testDefaults({ fastUnpack: false, publicHoistPattern: '*' }))
{
const cmd = await fs.promises.readFile('node_modules/.bin/hello-world-js-bin', 'utf-8')
+12 -12
View File
@@ -12,15 +12,15 @@ test('readPackage, afterAllResolved hooks', async () => {
const project = prepareEmpty()
// w/o the hook, 100.1.0 would be installed
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
function readPackageHook (manifest: PackageManifest) {
switch (manifest.name) {
case 'pkg-with-1-dep':
case '@pnpm.e2e/pkg-with-1-dep':
if (manifest.dependencies == null) {
throw new Error('pkg-with-1-dep expected to have a dependencies field')
throw new Error('@pnpm.e2e/pkg-with-1-dep expected to have a dependencies field')
}
manifest.dependencies['dep-of-pkg-with-1-dep'] = '100.0.0'
manifest.dependencies['@pnpm.e2e/dep-of-pkg-with-1-dep'] = '100.0.0'
break
}
return manifest
@@ -31,14 +31,14 @@ test('readPackage, afterAllResolved hooks', async () => {
return lockfile
})
await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({
hooks: {
afterAllResolved,
readPackage: readPackageHook,
},
}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
expect(afterAllResolved).toHaveBeenCalledTimes(1)
expect(afterAllResolved.mock.calls[0][0].lockfileVersion).toEqual(LOCKFILE_VERSION)
@@ -50,15 +50,15 @@ test('readPackage, afterAllResolved async hooks', async () => {
const project = prepareEmpty()
// w/o the hook, 100.1.0 would be installed
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
async function readPackageHook (manifest: PackageManifest) {
switch (manifest.name) {
case 'pkg-with-1-dep':
case '@pnpm.e2e/pkg-with-1-dep':
if (manifest.dependencies == null) {
throw new Error('pkg-with-1-dep expected to have a dependencies field')
throw new Error('@pnpm.e2e/pkg-with-1-dep expected to have a dependencies field')
}
manifest.dependencies['dep-of-pkg-with-1-dep'] = '100.0.0'
manifest.dependencies['@pnpm.e2e/dep-of-pkg-with-1-dep'] = '100.0.0'
break
}
return manifest
@@ -69,14 +69,14 @@ test('readPackage, afterAllResolved async hooks', async () => {
return lockfile
})
await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({
hooks: {
afterAllResolved,
readPackage: readPackageHook,
},
}))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
expect(afterAllResolved).toHaveBeenCalledTimes(1)
expect(afterAllResolved.mock.calls[0][0].lockfileVersion).toEqual(LOCKFILE_VERSION)
@@ -16,7 +16,7 @@ test('inject local packages', async () => {
'is-negative': '1.0.0',
},
devDependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
peerDependencies: {
'is-positive': '>=1.0.0',
@@ -112,7 +112,7 @@ test('inject local packages', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -180,7 +180,7 @@ test('inject local packages', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -233,7 +233,7 @@ test('inject local packages declared via file protocol', async () => {
'is-negative': '1.0.0',
},
devDependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
peerDependencies: {
'is-positive': '>=1.0.0',
@@ -329,7 +329,7 @@ test('inject local packages declared via file protocol', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -397,7 +397,7 @@ test('inject local packages declared via file protocol', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -451,7 +451,7 @@ test('inject local packages when the file protocol is used', async () => {
'is-negative': '1.0.0',
},
devDependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
peerDependencies: {
'is-positive': '>=1.0.0',
@@ -537,7 +537,7 @@ test('inject local packages when the file protocol is used', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -600,7 +600,7 @@ test('inject local packages when the file protocol is used', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -649,7 +649,7 @@ test('inject local packages and relink them after build', async () => {
'is-negative': '1.0.0',
},
devDependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
peerDependencies: {
'is-positive': '1.0.0',
@@ -715,7 +715,7 @@ test('inject local packages and relink them after build', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -759,7 +759,7 @@ test('inject local packages and relink them after build', async () => {
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -776,7 +776,7 @@ test('inject local packages and relink them after build (file protocol is used)'
'is-negative': '1.0.0',
},
devDependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
peerDependencies: {
'is-positive': '1.0.0',
@@ -821,7 +821,7 @@ test('inject local packages and relink them after build (file protocol is used)'
await mutateModules(importers, await testDefaults())
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -859,7 +859,7 @@ test('inject local packages and relink them after build (file protocol is used)'
}))
await projects['project-1'].has('is-negative')
await projects['project-1'].has('dep-of-pkg-with-1-dep')
await projects['project-1'].has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-1'].hasNot('is-positive')
await projects['project-2'].has('is-positive')
@@ -874,7 +874,7 @@ test('inject local packages when node-linker is hoisted', async () => {
version: '1.0.0',
dependencies: {
'is-negative': '1.0.0',
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
peerDependencies: {
'is-positive': '>=1.0.0',
@@ -885,7 +885,7 @@ test('inject local packages when node-linker is hoisted', async () => {
version: '1.0.0',
dependencies: {
'project-1': 'workspace:1.0.0',
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
},
devDependencies: {
'is-positive': '1.0.0',
@@ -973,11 +973,11 @@ test('inject local packages when node-linker is hoisted', async () => {
const rootModules = assertProject(process.cwd())
await rootModules.has('is-negative')
await rootModules.has('dep-of-pkg-with-1-dep')
await rootModules.has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await rootModules.has('is-positive')
await projects['project-2'].has('project-1')
await projects['project-2'].has('project-1/node_modules/dep-of-pkg-with-1-dep')
await projects['project-2'].has('project-1/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-3'].has('project-1')
await projects['project-3'].has('project-2')
@@ -1002,7 +1002,7 @@ test('inject local packages when node-linker is hoisted', async () => {
'is-positive': '>=1.0.0',
},
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
'is-negative': '1.0.0',
'is-positive': '1.0.0',
},
@@ -1017,7 +1017,7 @@ test('inject local packages when node-linker is hoisted', async () => {
name: 'project-2',
version: '1.0.0',
dependencies: {
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
'project-1': 'file:project-1_is-positive@2.0.0',
},
transitivePeerDependencies: ['is-positive'],
@@ -1037,7 +1037,7 @@ test('inject local packages when node-linker is hoisted and dependenciesMeta is
version: '1.0.0',
dependencies: {
'is-negative': '1.0.0',
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
peerDependencies: {
'is-positive': '>=1.0.0',
@@ -1048,7 +1048,7 @@ test('inject local packages when node-linker is hoisted and dependenciesMeta is
version: '1.0.0',
dependencies: {
'project-1': 'workspace:1.0.0',
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
},
devDependencies: {
'is-positive': '1.0.0',
@@ -1145,11 +1145,11 @@ test('inject local packages when node-linker is hoisted and dependenciesMeta is
const rootModules = assertProject(process.cwd())
await rootModules.has('is-negative')
await rootModules.has('dep-of-pkg-with-1-dep')
await rootModules.has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await rootModules.has('is-positive')
await projects['project-2'].has('project-1')
await projects['project-2'].has('project-1/node_modules/dep-of-pkg-with-1-dep')
await projects['project-2'].has('project-1/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep')
await projects['project-3'].has('project-1')
await projects['project-3'].has('project-2')
@@ -1174,7 +1174,7 @@ test('inject local packages when node-linker is hoisted and dependenciesMeta is
'is-positive': '>=1.0.0',
},
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
'is-negative': '1.0.0',
'is-positive': '1.0.0',
},
@@ -1189,7 +1189,7 @@ test('inject local packages when node-linker is hoisted and dependenciesMeta is
name: 'project-2',
version: '1.0.0',
dependencies: {
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
'project-1': 'file:project-1_is-positive@2.0.0',
},
transitivePeerDependencies: ['is-positive'],
@@ -7,52 +7,52 @@ test('fail if installed package does not support the current engine and engine-s
const project = prepareEmpty()
await expect(
addDependenciesToPackage({}, ['not-compatible-with-any-os'], await testDefaults({}, {}, {}, {
addDependenciesToPackage({}, ['@pnpm.e2e/not-compatible-with-any-os'], await testDefaults({}, {}, {}, {
engineStrict: true,
}))
).rejects.toThrow()
await project.hasNot('not-compatible-with-any-os')
await project.storeHasNot('not-compatible-with-any-os', '1.0.0')
await project.hasNot('@pnpm.e2e/not-compatible-with-any-os')
await project.storeHasNot('@pnpm.e2e/not-compatible-with-any-os', '1.0.0')
})
test('do not fail if installed package does not support the current engine and engine-strict = false', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['not-compatible-with-any-os'], await testDefaults({
await addDependenciesToPackage({}, ['@pnpm.e2e/not-compatible-with-any-os'], await testDefaults({
engineStrict: false,
}))
await project.has('not-compatible-with-any-os')
await project.storeHas('not-compatible-with-any-os', '1.0.0')
await project.has('@pnpm.e2e/not-compatible-with-any-os')
await project.storeHas('@pnpm.e2e/not-compatible-with-any-os', '1.0.0')
const lockfile = await project.readLockfile()
expect(lockfile.packages['/not-compatible-with-any-os/1.0.0'].os).toStrictEqual(['this-os-does-not-exist'])
expect(lockfile.packages['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'].os).toStrictEqual(['this-os-does-not-exist'])
})
test('do not fail if installed package requires the node version that was passed in and engine-strict = true', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['for-legacy-node'], await testDefaults({
await addDependenciesToPackage({}, ['@pnpm.e2e/for-legacy-node'], await testDefaults({
engineStrict: true,
nodeVersion: '0.10.0',
}))
await project.has('for-legacy-node')
await project.storeHas('for-legacy-node', '1.0.0')
await project.has('@pnpm.e2e/for-legacy-node')
await project.storeHas('@pnpm.e2e/for-legacy-node', '1.0.0')
const lockfile = await project.readLockfile()
expect(lockfile.packages['/for-legacy-node/1.0.0'].engines).toStrictEqual({ node: '0.10' })
expect(lockfile.packages['/@pnpm.e2e/for-legacy-node/1.0.0'].engines).toStrictEqual({ node: '0.10' })
})
test(`save cpu field to ${WANTED_LOCKFILE}`, async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['has-cpu-specified'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/has-cpu-specified'], await testDefaults())
const lockfile = await project.readLockfile()
expect(
lockfile.packages['/has-cpu-specified/1.0.0'].cpu
lockfile.packages['/@pnpm.e2e/has-cpu-specified/1.0.0'].cpu
).toStrictEqual(
['x64', 'ia32']
)
+84 -84
View File
@@ -20,18 +20,18 @@ const testOnNonWindows = isWindows() ? test.skip : test
test('run pre/postinstall scripts', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example'],
['@pnpm.e2e/pre-and-postinstall-scripts-example'],
await testDefaults({ fastUnpack: false, targetDependenciesField: 'devDependencies' })
)
{
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-prepare.js')).toBeFalsy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-prepare.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeTruthy()
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
const generatedByPreinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall')
expect(typeof generatedByPreinstall).toBe('function')
const generatedByPostinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-postinstall')
const generatedByPostinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall')
expect(typeof generatedByPostinstall).toBe('function')
}
@@ -43,21 +43,21 @@ test('run pre/postinstall scripts', async () => {
await install(manifest, await testDefaults({ fastUnpack: false, production: true }))
{
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
const generatedByPreinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall')
expect(typeof generatedByPreinstall).toBe('function')
const generatedByPostinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-postinstall')
const generatedByPostinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall')
expect(typeof generatedByPostinstall).toBe('function')
}
const lockfile = await project.readLockfile()
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild)
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild)
})
test('run pre/postinstall scripts, when PnP is used and no symlinks', async () => {
prepareEmpty()
await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example'],
['@pnpm.e2e/pre-and-postinstall-scripts-example'],
await testDefaults({
fastUnpack: false,
enablePnp: true,
@@ -66,7 +66,7 @@ test('run pre/postinstall scripts, when PnP is used and no symlinks', async () =
})
)
const pkgDir = 'node_modules/.pnpm/pre-and-postinstall-scripts-example@1.0.0/node_modules/pre-and-postinstall-scripts-example'
const pkgDir = 'node_modules/.pnpm/@pnpm.e2e+pre-and-postinstall-scripts-example@1.0.0/node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example'
expect(await exists(path.resolve(pkgDir, 'generated-by-prepare.js'))).toBeFalsy()
expect(await exists(path.resolve(pkgDir, 'generated-by-preinstall.js'))).toBeTruthy()
expect(await exists(path.resolve(pkgDir, 'generated-by-postinstall.js'))).toBeTruthy()
@@ -75,21 +75,21 @@ test('run pre/postinstall scripts, when PnP is used and no symlinks', async () =
test('testing that the bins are linked when the package with the bins was already in node_modules', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['hello-world-js-bin'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage(manifest, ['pre-and-postinstall-scripts-example'], await testDefaults({ fastUnpack: false, targetDependenciesField: 'devDependencies' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/hello-world-js-bin'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/pre-and-postinstall-scripts-example'], await testDefaults({ fastUnpack: false, targetDependenciesField: 'devDependencies' }))
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
const generatedByPreinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall')
expect(typeof generatedByPreinstall).toBe('function')
const generatedByPostinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-postinstall')
const generatedByPostinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall')
expect(typeof generatedByPostinstall).toBe('function')
})
test('run install scripts', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['install-script-example'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/install-script-example'], await testDefaults({ fastUnpack: false }))
const generatedByInstall = project.requireModule('install-script-example/generated-by-install')
const generatedByInstall = project.requireModule('@pnpm.e2e/install-script-example/generated-by-install')
expect(typeof generatedByInstall).toBe('function')
})
@@ -152,7 +152,7 @@ test('INIT_CWD is always set to lockfile directory', async () => {
manifest: {
dependencies: {
'json-append': '1.1.1',
'write-lifecycle-env': '1.0.0',
'@pnpm.e2e/write-lifecycle-env': '1.0.0',
},
scripts: {
install: 'node -e "process.stdout.write(process.env.INIT_CWD)" | json-append output.json',
@@ -165,7 +165,7 @@ test('INIT_CWD is always set to lockfile directory', async () => {
lockfileDir: rootDir,
}))
const childEnv = await loadJsonFile<{ INIT_CWD: string }>(path.join(rootDir, 'node_modules/write-lifecycle-env/env.json'))
const childEnv = await loadJsonFile<{ INIT_CWD: string }>(path.join(rootDir, 'node_modules/@pnpm.e2e/write-lifecycle-env/env.json'))
expect(childEnv.INIT_CWD).toBe(rootDir)
const output = await loadJsonFile(path.join(rootDir, 'output.json'))
@@ -178,17 +178,17 @@ test("reports child's output", async () => {
const reporter = sinon.spy()
await addDependenciesToPackage({}, ['count-to-10'], await testDefaults({ fastUnpack: false, reporter }))
await addDependenciesToPackage({}, ['@pnpm.e2e/count-to-10'], await testDefaults({ fastUnpack: false, reporter }))
expect(reporter.calledWithMatch({
depPath: '/count-to-10/1.0.0',
depPath: '/@pnpm.e2e/count-to-10/1.0.0',
level: 'debug',
name: 'pnpm:lifecycle',
script: 'node postinstall',
stage: 'postinstall',
} as LifecycleLog)).toBeTruthy()
expect(reporter.calledWithMatch({
depPath: '/count-to-10/1.0.0',
depPath: '/@pnpm.e2e/count-to-10/1.0.0',
level: 'debug',
line: '1',
name: 'pnpm:lifecycle',
@@ -196,7 +196,7 @@ test("reports child's output", async () => {
stdio: 'stdout',
} as LifecycleLog)).toBeTruthy()
expect(reporter.calledWithMatch({
depPath: '/count-to-10/1.0.0',
depPath: '/@pnpm.e2e/count-to-10/1.0.0',
level: 'debug',
line: '2',
name: 'pnpm:lifecycle',
@@ -204,7 +204,7 @@ test("reports child's output", async () => {
stdio: 'stdout',
} as LifecycleLog)).toBeTruthy()
expect(reporter.calledWithMatch({
depPath: '/count-to-10/1.0.0',
depPath: '/@pnpm.e2e/count-to-10/1.0.0',
level: 'debug',
line: '6',
name: 'pnpm:lifecycle',
@@ -212,7 +212,7 @@ test("reports child's output", async () => {
stdio: 'stderr',
} as LifecycleLog)).toBeTruthy()
expect(reporter.calledWithMatch({
depPath: '/count-to-10/1.0.0',
depPath: '/@pnpm.e2e/count-to-10/1.0.0',
exitCode: 0,
level: 'debug',
name: 'pnpm:lifecycle',
@@ -226,11 +226,11 @@ test("reports child's close event", async () => {
const reporter = sinon.spy()
await expect(
addDependenciesToPackage({}, ['failing-postinstall'], await testDefaults({ reporter }))
addDependenciesToPackage({}, ['@pnpm.e2e/failing-postinstall'], await testDefaults({ reporter }))
).rejects.toThrow()
expect(reporter.calledWithMatch({
depPath: '/failing-postinstall/1.0.0',
depPath: '/@pnpm.e2e/failing-postinstall/1.0.0',
exitCode: 1,
level: 'debug',
name: 'pnpm:lifecycle',
@@ -262,9 +262,9 @@ testOnNonWindows('lifecycle scripts have access to node-gyp', async () => {
test('run lifecycle scripts of dependent packages after running scripts of their deps', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['with-postinstall-a'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/with-postinstall-a'], await testDefaults({ fastUnpack: false }))
expect(+project.requireModule('.pnpm/with-postinstall-b@1.0.0/node_modules/with-postinstall-b/output.json')[0] < +project.requireModule('with-postinstall-a/output.json')[0]).toBeTruthy()
expect(+project.requireModule('.pnpm/@pnpm.e2e+with-postinstall-b@1.0.0/node_modules/@pnpm.e2e/with-postinstall-b/output.json')[0] < +project.requireModule('@pnpm.e2e/with-postinstall-a/output.json')[0]).toBeTruthy()
})
test('run prepare script for git-hosted dependencies', async () => {
@@ -290,7 +290,7 @@ test('run prepare script for git-hosted dependencies', async () => {
test('lifecycle scripts run before linking bins', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['generated-bins'], await testDefaults({ fastUnpack: false }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/generated-bins'], await testDefaults({ fastUnpack: false }))
await project.isExecutable('.bin/cmd1')
await project.isExecutable('.bin/cmd2')
@@ -316,7 +316,7 @@ test('lifecycle scripts run before linking bins', async () => {
test('hoisting does not fail on commands that will be created by lifecycle scripts on a later stage', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['has-generated-bins-as-dep'], await testDefaults({ fastUnpack: false, hoistPattern: '*' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-generated-bins-as-dep'], await testDefaults({ fastUnpack: false, hoistPattern: '*' }))
// await project.isExecutable('.pnpm/node_modules/.bin/cmd1')
// await project.isExecutable('.pnpm/node_modules/.bin/cmd2')
@@ -346,19 +346,19 @@ test('bins are linked even if lifecycle scripts are ignored', async () => {
const manifest = await addDependenciesToPackage(
{},
[
'pkg-with-peer-having-bin',
'peer-with-bin',
'pre-and-postinstall-scripts-example',
'@pnpm.e2e/pkg-with-peer-having-bin',
'@pnpm.e2e/peer-with-bin',
'@pnpm.e2e/pre-and-postinstall-scripts-example',
],
await testDefaults({ fastUnpack: false, ignoreScripts: true })
)
await project.isExecutable('.bin/peer-with-bin')
await project.isExecutable('pkg-with-peer-having-bin/node_modules/.bin/hello-world-js-bin')
await project.isExecutable('@pnpm.e2e/pkg-with-peer-having-bin/node_modules/.bin/hello-world-js-bin')
// Verifying that the scripts were ignored
expect(await exists('node_modules/pre-and-postinstall-scripts-example/package.json')).toBeTruthy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/package.json')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
await rimraf('node_modules')
@@ -375,11 +375,11 @@ test('bins are linked even if lifecycle scripts are ignored', async () => {
)
await project.isExecutable('.bin/peer-with-bin')
await project.isExecutable('pkg-with-peer-having-bin/node_modules/.bin/hello-world-js-bin')
await project.isExecutable('@pnpm.e2e/pkg-with-peer-having-bin/node_modules/.bin/hello-world-js-bin')
// Verifying that the scripts were ignored
expect(await exists('node_modules/pre-and-postinstall-scripts-example/package.json')).toBeTruthy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/package.json')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
})
test('dependency should not be added to current lockfile if it was not built successfully during headless install', async () => {
@@ -388,7 +388,7 @@ test('dependency should not be added to current lockfile if it was not built suc
const manifest = await addDependenciesToPackage(
{},
[
'package-that-cannot-be-installed@0.0.0',
'package-that-cannot-be-installed@0.0.0', // TODO: this package should be replaced
],
await testDefaults({
ignoreScripts: true,
@@ -418,37 +418,37 @@ test('scripts have access to unlisted bins when hoisting is used', async () => {
await addDependenciesToPackage(
{},
['pkg-that-calls-unlisted-dep-in-hooks'],
['@pnpm.e2e/pkg-that-calls-unlisted-dep-in-hooks'],
await testDefaults({ fastUnpack: false, hoistPattern: '*' })
)
expect(project.requireModule('pkg-that-calls-unlisted-dep-in-hooks/output.json')).toStrictEqual(['Hello world!'])
expect(project.requireModule('@pnpm.e2e/pkg-that-calls-unlisted-dep-in-hooks/output.json')).toStrictEqual(['Hello world!'])
})
test('selectively ignore scripts in some dependencies by neverBuiltDependencies', async () => {
const project = prepareEmpty()
const neverBuiltDependencies = ['pre-and-postinstall-scripts-example']
const neverBuiltDependencies = ['@pnpm.e2e/pre-and-postinstall-scripts-example']
const manifest = await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example', 'install-script-example'],
['@pnpm.e2e/pre-and-postinstall-scripts-example', '@pnpm.e2e/install-script-example'],
await testDefaults({ fastUnpack: false, neverBuiltDependencies })
)
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/install-script-example/generated-by-install.js')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/install-script-example/generated-by-install.js')).toBeTruthy()
const lockfile = await project.readLockfile()
expect(lockfile.neverBuiltDependencies).toStrictEqual(neverBuiltDependencies)
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/@pnpm.e2e/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
await rimraf('node_modules')
await install(manifest, await testDefaults({ fastUnpack: false, frozenLockfile: true, neverBuiltDependencies }))
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/install-script-example/generated-by-install.js')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/install-script-example/generated-by-install.js')).toBeTruthy()
})
test('throw an exception when both neverBuiltDependencies and onlyBuiltDependencies are used', async () => {
@@ -457,53 +457,53 @@ test('throw an exception when both neverBuiltDependencies and onlyBuiltDependenc
await expect(
addDependenciesToPackage(
{},
['pre-and-postinstall-scripts-example'],
await testDefaults({ onlyBuiltDependencies: ['foo'], neverBuiltDependencies: ['bar'] })
['@pnpm.e2e/pre-and-postinstall-scripts-example'],
await testDefaults({ onlyBuiltDependencies: ['@pnpm.e2e/foo'], neverBuiltDependencies: ['@pnpm.e2e/bar'] })
)
).rejects.toThrow(/Cannot have both/)
})
test('selectively allow scripts in some dependencies by onlyBuiltDependencies', async () => {
const project = prepareEmpty()
const onlyBuiltDependencies = ['install-script-example']
const onlyBuiltDependencies = ['@pnpm.e2e/install-script-example']
const manifest = await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example', 'install-script-example'],
['@pnpm.e2e/pre-and-postinstall-scripts-example', '@pnpm.e2e/install-script-example'],
await testDefaults({ fastUnpack: false, onlyBuiltDependencies })
)
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/install-script-example/generated-by-install.js')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/install-script-example/generated-by-install.js')).toBeTruthy()
const lockfile = await project.readLockfile()
expect(lockfile.onlyBuiltDependencies).toStrictEqual(onlyBuiltDependencies)
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBe(true)
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/@pnpm.e2e/install-script-example/1.0.0'].requiresBuild).toBe(true)
await rimraf('node_modules')
await install(manifest, await testDefaults({ fastUnpack: false, frozenLockfile: true, onlyBuiltDependencies }))
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/install-script-example/generated-by-install.js')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/install-script-example/generated-by-install.js')).toBeTruthy()
})
test('lockfile is updated if neverBuiltDependencies is changed', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example', 'install-script-example'],
['@pnpm.e2e/pre-and-postinstall-scripts-example', '@pnpm.e2e/install-script-example'],
await testDefaults({ fastUnpack: false })
)
{
const lockfile = await project.readLockfile()
expect(lockfile.neverBuiltDependencies).toBeFalsy()
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
}
const neverBuiltDependencies = ['pre-and-postinstall-scripts-example']
const neverBuiltDependencies = ['@pnpm.e2e/pre-and-postinstall-scripts-example']
await mutateModules([
{
buildIndex: 0,
@@ -516,23 +516,23 @@ test('lockfile is updated if neverBuiltDependencies is changed', async () => {
{
const lockfile = await project.readLockfile()
expect(lockfile.neverBuiltDependencies).toStrictEqual(neverBuiltDependencies)
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/@pnpm.e2e/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
}
})
test('lockfile is updated if onlyBuiltDependencies is changed', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example', 'install-script-example'],
['@pnpm.e2e/pre-and-postinstall-scripts-example', '@pnpm.e2e/install-script-example'],
await testDefaults({ fastUnpack: false })
)
{
const lockfile = await project.readLockfile()
expect(lockfile.onlyBuiltDependencies).toBeFalsy()
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/install-script-example/1.0.0'].requiresBuild).toBeTruthy()
}
const onlyBuiltDependencies: string[] = []
@@ -548,11 +548,11 @@ test('lockfile is updated if onlyBuiltDependencies is changed', async () => {
{
const lockfile = await project.readLockfile()
expect(lockfile.onlyBuiltDependencies).toStrictEqual(onlyBuiltDependencies)
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/@pnpm.e2e/install-script-example/1.0.0'].requiresBuild).toBe(undefined)
}
onlyBuiltDependencies.push('pre-and-postinstall-scripts-example')
onlyBuiltDependencies.push('@pnpm.e2e/pre-and-postinstall-scripts-example')
await mutateModules([
{
buildIndex: 0,
@@ -565,19 +565,19 @@ test('lockfile is updated if onlyBuiltDependencies is changed', async () => {
{
const lockfile = await project.readLockfile()
expect(lockfile.onlyBuiltDependencies).toStrictEqual(onlyBuiltDependencies)
expect(lockfile.packages['/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(true)
expect(lockfile.packages['/install-script-example/1.0.0'].requiresBuild).toBe(undefined)
expect(lockfile.packages['/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'].requiresBuild).toBe(true)
expect(lockfile.packages['/@pnpm.e2e/install-script-example/1.0.0'].requiresBuild).toBe(undefined)
}
})
test('lifecycle scripts have access to package\'s own binary by binary name', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({},
['runs-own-bin'],
['@pnpm.e2e/runs-own-bin'],
await testDefaults({ fastUnpack: false })
)
await project.isExecutable('.pnpm/runs-own-bin@1.0.0/node_modules/runs-own-bin/node_modules/.bin/runs-own-bin')
await project.isExecutable('.pnpm/@pnpm.e2e+runs-own-bin@1.0.0/node_modules/@pnpm.e2e/runs-own-bin/node_modules/.bin/runs-own-bin')
})
test('lifecycle scripts run after linking root dependencies', async () => {
@@ -586,7 +586,7 @@ test('lifecycle scripts run after linking root dependencies', async () => {
const manifest = {
dependencies: {
'is-positive': '1.0.0',
'postinstall-requires-is-positive': '1.0.0',
'@pnpm.e2e/postinstall-requires-is-positive': '1.0.0',
},
}
@@ -630,7 +630,7 @@ test('ignore-dep-scripts', async () => {
},
dependencies: {
'json-append': '1.1.1',
'pre-and-postinstall-scripts-example': '1.0.0',
'@pnpm.e2e/pre-and-postinstall-scripts-example': '1.0.0',
},
}
await install(manifest, await testDefaults({ fastUnpack: false, ignoreDepScripts: true }))
@@ -641,7 +641,7 @@ test('ignore-dep-scripts', async () => {
expect(output).toStrictEqual(['preinstall', 'install', 'postinstall'])
expect(await exists('test.txt')).toBeTruthy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
}
await rimraf('node_modules')
@@ -653,6 +653,6 @@ test('ignore-dep-scripts', async () => {
expect(output).toStrictEqual(['preinstall', 'install', 'postinstall'])
expect(await exists('test.txt')).toBeTruthy()
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js')).toBeFalsy()
}
})
+3 -3
View File
@@ -202,15 +202,15 @@ test('update tarball local package when its integrity changes', async () => {
// Covers https://github.com/pnpm/pnpm/issues/1878
test('do not update deps when installing in a project that has local tarball dep', async () => {
await addDistTag({ package: 'peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.0', distTag: 'latest' })
const project = prepareEmpty()
f.copy('tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz'))
const manifest = await addDependenciesToPackage({}, ['../tar.tgz', 'peer-a'], await testDefaults({ lockfileOnly: true }))
const manifest = await addDependenciesToPackage({}, ['../tar.tgz', '@pnpm.e2e/peer-a'], await testDefaults({ lockfileOnly: true }))
const initialLockfile = await project.readLockfile()
await addDistTag({ package: 'peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' })
await mutateModules([
{
+16 -16
View File
@@ -12,25 +12,25 @@ import sinon from 'sinon'
import { testDefaults } from '../utils'
test('install with lockfileOnly = true', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const project = prepareEmpty()
const opts = await testDefaults({ lockfileOnly: true, pinnedVersion: 'patch' as const })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep@100.0.0'], opts)
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep@100.0.0'], opts)
const { cafsHas } = assertStore(opts.storeDir)
await cafsHas('pkg-with-1-dep', '100.0.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep.json`))).toBeTruthy()
await cafsHas('dep-of-pkg-with-1-dep', '100.1.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/dep-of-pkg-with-1-dep.json`))).toBeTruthy()
await project.hasNot('pkg-with-1-dep')
await cafsHas('@pnpm.e2e/pkg-with-1-dep', '100.0.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-1-dep.json`))).toBeTruthy()
await cafsHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/dep-of-pkg-with-1-dep.json`))).toBeTruthy()
await project.hasNot('@pnpm.e2e/pkg-with-1-dep')
expect(manifest.dependencies!['pkg-with-1-dep']).toBeTruthy()
expect(manifest.dependencies!['@pnpm.e2e/pkg-with-1-dep']).toBeTruthy()
const lockfile = await project.readLockfile()
expect(lockfile.dependencies['pkg-with-1-dep']).toBeTruthy()
expect(lockfile.packages['/pkg-with-1-dep/100.0.0']).toBeTruthy()
expect(lockfile.specifiers['pkg-with-1-dep']).toBeTruthy()
expect(lockfile.dependencies['@pnpm.e2e/pkg-with-1-dep']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0']).toBeTruthy()
expect(lockfile.specifiers['@pnpm.e2e/pkg-with-1-dep']).toBeTruthy()
const currentLockfile = await project.readCurrentLockfile()
expect(currentLockfile).toBeFalsy()
@@ -38,11 +38,11 @@ test('install with lockfileOnly = true', async () => {
console.log(`doing repeat install when ${WANTED_LOCKFILE} is available already`)
await install(manifest, opts)
await cafsHas('pkg-with-1-dep', '100.0.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep.json`))).toBeTruthy()
await cafsHas('dep-of-pkg-with-1-dep', '100.1.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/dep-of-pkg-with-1-dep.json`))).toBeTruthy()
await project.hasNot('pkg-with-1-dep')
await cafsHas('@pnpm.e2e/pkg-with-1-dep', '100.0.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-1-dep.json`))).toBeTruthy()
await cafsHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0')
expect(await exists(path.join(opts.cacheDir, `metadata/localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/dep-of-pkg-with-1-dep.json`))).toBeTruthy()
await project.hasNot('@pnpm.e2e/pkg-with-1-dep')
expect(await project.readCurrentLockfile()).toBeFalsy()
})
+123 -122
View File
@@ -173,26 +173,26 @@ test('modules without version spec, with custom tag config', async () => {
const tag = 'beta'
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: tag })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: tag })
await addDependenciesToPackage({}, ['dep-of-pkg-with-1-dep'], await testDefaults({ tag }))
await addDependenciesToPackage({}, ['@pnpm.e2e/dep-of-pkg-with-1-dep'], await testDefaults({ tag }))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
})
test('modules without version spec but with a trailing @', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['dep-of-pkg-with-1-dep@'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/dep-of-pkg-with-1-dep@'], await testDefaults())
await project.has('dep-of-pkg-with-1-dep')
await project.has('@pnpm.e2e/dep-of-pkg-with-1-dep')
})
test('aliased modules without version spec but with a trailing @', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['foo@npm:dep-of-pkg-with-1-dep@'], await testDefaults())
await addDependenciesToPackage({}, ['foo@npm:@pnpm.e2e/dep-of-pkg-with-1-dep@'], await testDefaults())
await project.has('foo')
})
@@ -200,32 +200,32 @@ test('aliased modules without version spec but with a trailing @', async () => {
test('installing a package by specifying a specific dist-tag', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'beta' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'beta' })
await addDependenciesToPackage({}, ['dep-of-pkg-with-1-dep@beta'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/dep-of-pkg-with-1-dep@beta'], await testDefaults())
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
})
test('update a package when installing with a dist-tag', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'beta' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'beta' })
const manifest = await addDependenciesToPackage({}, ['dep-of-pkg-with-1-dep'], await testDefaults({ targetDependenciesField: 'devDependencies' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/dep-of-pkg-with-1-dep'], await testDefaults({ targetDependenciesField: 'devDependencies' }))
const reporter = sinon.spy()
await addDependenciesToPackage(manifest, ['dep-of-pkg-with-1-dep@beta'], await testDefaults({ targetDependenciesField: 'devDependencies', reporter }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/dep-of-pkg-with-1-dep@beta'], await testDefaults({ targetDependenciesField: 'devDependencies', reporter }))
expect(reporter.calledWithMatch({
level: 'debug',
name: 'pnpm:root',
removed: {
dependencyType: 'dev',
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.0.0',
},
} as RootLog)).toBeTruthy()
@@ -233,17 +233,17 @@ test('update a package when installing with a dist-tag', async () => {
expect(reporter.calledWithMatch({
added: {
dependencyType: 'dev',
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
level: 'debug',
name: 'pnpm:root',
} as RootLog)).toBeTruthy()
await project.has('dep-of-pkg-with-1-dep')
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
await project.has('@pnpm.e2e/dep-of-pkg-with-1-dep')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0')
expect(manifest.devDependencies!['dep-of-pkg-with-1-dep']).toBe('^100.1.0')
expect(manifest.devDependencies!['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('^100.1.0')
})
test('scoped modules with versions', async () => {
@@ -263,16 +263,16 @@ test('multiple scoped modules (@rstacruz/...)', async () => {
test('installing a beta version of a package', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['beta-version'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/beta-version'], await testDefaults())
expect(manifest.dependencies?.['beta-version']).toBe('1.0.0-beta.0')
expect(manifest.dependencies?.['@pnpm.e2e/beta-version']).toBe('1.0.0-beta.0')
})
test('nested scoped modules (test-pnpm-issue219 -> @zkochan/test-pnpm-issue219)', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['test-pnpm-issue219@1.0.2'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/test-pnpm-issue219@1.0.3'], await testDefaults({ fastUnpack: false }))
const m = project.requireModule('test-pnpm-issue219')
const m = project.requireModule('@pnpm.e2e/test-pnpm-issue219')
expect(m).toBe('test-pnpm-issue219,@zkochan/test-pnpm-issue219')
})
@@ -281,12 +281,12 @@ test('idempotency', async () => {
const reporter = sinon.spy()
const opts = await testDefaults({ reporter })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep@100.0.0'], opts)
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep@100.0.0'], opts)
expect(reporter.calledWithMatch({
added: {
dependencyType: 'prod',
name: 'pkg-with-1-dep',
name: '@pnpm.e2e/pkg-with-1-dep',
version: '100.0.0',
},
level: 'debug',
@@ -295,19 +295,19 @@ test('idempotency', async () => {
reporter.resetHistory()
await addDependenciesToPackage(manifest, ['pkg-with-1-dep@100.0.0'], opts)
await addDependenciesToPackage(manifest, ['@pnpm.e2e/pkg-with-1-dep@100.0.0'], opts)
expect(reporter.calledWithMatch({
added: {
dependencyType: 'prod',
name: 'pkg-with-1-dep',
name: '@pnpm.e2e/pkg-with-1-dep',
version: '100.0.0',
},
level: 'debug',
name: 'pnpm:root',
} as RootLog)).toBeFalsy()
await project.has('pkg-with-1-dep')
await project.has('@pnpm.e2e/pkg-with-1-dep')
})
test('reporting adding root package', async () => {
@@ -363,11 +363,11 @@ test('overwriting (is-positive@3.0.0 with is-positive@latest)', async () => {
test('keeping existing specs untouched when adding new dependency', async () => {
prepareEmpty()
await addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({ dependencies: { bar: '^100.0.0' } }, ['foo@100.1.0'], await testDefaults())
const manifest = await addDependenciesToPackage({ dependencies: { '@pnpm.e2e/bar': '^100.0.0' } }, ['@pnpm.e2e/foo@100.1.0'], await testDefaults())
expect(manifest.dependencies).toStrictEqual({ bar: '^100.0.0', foo: '100.1.0' })
expect(manifest.dependencies).toStrictEqual({ '@pnpm.e2e/bar': '^100.0.0', '@pnpm.e2e/foo': '100.1.0' })
})
test('forcing', async () => {
@@ -451,13 +451,13 @@ test.skip('relink package to project if the dependency is not linked from store'
test('circular deps', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['circular-deps-1-of-2'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/circular-deps-1-of-2'], await testDefaults({ fastUnpack: false }))
const m = project.requireModule('circular-deps-1-of-2/mirror')
const m = project.requireModule('@pnpm.e2e/circular-deps-1-of-2/mirror')
expect(m()).toEqual('circular-deps-1-of-2')
expect(m()).toEqual('@pnpm.e2e/circular-deps-1-of-2')
expect(await exists(path.join('node_modules', 'circular-deps-1-of-2', 'node_modules', 'circular-deps-2-of-2', 'node_modules', 'circular-deps-1-of-2'))).toBeFalsy()
expect(await exists(path.join('node_modules', '@pnpm.e2e/circular-deps-1-of-2', 'node_modules', '@pnpm.e2e/circular-deps-2-of-2', 'node_modules', '@pnpm.e2e/circular-deps-1-of-2'))).toBeFalsy()
})
test('concurrent circular deps', async () => {
@@ -501,41 +501,41 @@ test('big with dependencies and circular deps (babel-preset-2015)', async () =>
test('bundledDependencies (pkg-with-bundled-dependencies@1.0.0)', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-bundled-dependencies@1.0.0'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-bundled-dependencies@1.0.0'], await testDefaults({ fastUnpack: false }))
await project.isExecutable('pkg-with-bundled-dependencies/node_modules/.bin/hello-world-js-bin')
await project.isExecutable('@pnpm.e2e/pkg-with-bundled-dependencies/node_modules/.bin/hello-world-js-bin')
const lockfile = await project.readLockfile()
expect(
lockfile.packages['/pkg-with-bundled-dependencies/1.0.0'].bundledDependencies
lockfile.packages['/@pnpm.e2e/pkg-with-bundled-dependencies/1.0.0'].bundledDependencies
).toStrictEqual(
['hello-world-js-bin']
['@pnpm.e2e/hello-world-js-bin']
)
})
test('bundleDependencies (pkg-with-bundle-dependencies@1.0.0)', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-bundle-dependencies@1.0.0'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-bundle-dependencies@1.0.0'], await testDefaults({ fastUnpack: false }))
await project.isExecutable('pkg-with-bundle-dependencies/node_modules/.bin/hello-world-js-bin')
await project.isExecutable('@pnpm.e2e/pkg-with-bundle-dependencies/node_modules/.bin/hello-world-js-bin')
const lockfile = await project.readLockfile()
expect(
lockfile.packages['/pkg-with-bundle-dependencies/1.0.0'].bundledDependencies
lockfile.packages['/@pnpm.e2e/pkg-with-bundle-dependencies/1.0.0'].bundledDependencies
).toStrictEqual(
['hello-world-js-bin']
['@pnpm.e2e/hello-world-js-bin']
)
})
test('installing a package with bundleDependencies set to false (pkg-with-bundle-dependencies-false)', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-bundle-dependencies-false'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-bundle-dependencies-false'], await testDefaults({ fastUnpack: false }))
const lockfile = await project.readLockfile()
expect(
typeof lockfile.packages['/pkg-with-bundle-dependencies-false/1.0.0'].bundledDependencies
typeof lockfile.packages['/@pnpm.e2e/pkg-with-bundle-dependencies-false/1.0.0'].bundledDependencies
).toEqual('undefined')
})
@@ -556,7 +556,7 @@ test('compiled modules (ursa@0.9.1)', async () => {
test('bin specified in the directories property linked to .bin folder', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-directories-bin'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-directories-bin'], await testDefaults({ fastUnpack: false }))
await project.isExecutable('.bin/pkg-with-directories-bin')
})
@@ -565,7 +565,7 @@ test('bin specified in the directories property symlinked to .bin folder when pr
const project = prepareEmpty()
const opts = await testDefaults({ fastUnpack: false, preferSymlinkedExecutables: true })
await addDependenciesToPackage({}, ['pkg-with-directories-bin'], opts)
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-directories-bin'], opts)
await project.isExecutable('.bin/pkg-with-directories-bin')
@@ -589,17 +589,17 @@ testOnNonWindows('building native addons', async () => {
test('should update subdep on second install', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ save: true }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ save: true }))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
let lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const reporter = sinon.spy()
@@ -612,54 +612,54 @@ test('should update subdep on second install', async () => {
prefix: process.cwd(),
} as StatsLog)).toBeTruthy()
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0')
lockfile = await project.readLockfile()
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
expect(deepRequireCwd(['pkg-with-1-dep', 'dep-of-pkg-with-1-dep', './package.json']).version).toEqual('100.1.0')
expect(deepRequireCwd(['@pnpm.e2e/pkg-with-1-dep', '@pnpm.e2e/dep-of-pkg-with-1-dep', './package.json']).version).toEqual('100.1.0')
})
test('should not update subdep when depth is smaller than depth of package', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ save: true }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ save: true }))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
let lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await install(manifest, await testDefaults({ depth: 0, update: true }))
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
expect(deepRequireCwd(['pkg-with-1-dep', 'dep-of-pkg-with-1-dep', './package.json']).version).toEqual('100.0.0')
expect(deepRequireCwd(['@pnpm.e2e/pkg-with-1-dep', '@pnpm.e2e/dep-of-pkg-with-1-dep', './package.json']).version).toEqual('100.0.0')
})
test('should install dependency in second project', async () => {
const project1 = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ fastUnpack: false, save: true, store: '../store' }))
expect(project1.requireModule('pkg-with-1-dep')().name).toEqual('dep-of-pkg-with-1-dep')
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ fastUnpack: false, save: true, store: '../store' }))
expect(project1.requireModule('@pnpm.e2e/pkg-with-1-dep')().name).toEqual('@pnpm.e2e/dep-of-pkg-with-1-dep')
const project2 = prepareEmpty()
await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ fastUnpack: false, save: true, store: '../store' }))
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ fastUnpack: false, save: true, store: '../store' }))
expect(project2.requireModule('pkg-with-1-dep')().name).toEqual('dep-of-pkg-with-1-dep')
expect(project2.requireModule('@pnpm.e2e/pkg-with-1-dep')().name).toEqual('@pnpm.e2e/dep-of-pkg-with-1-dep')
})
test('should throw error when trying to install using a different store then the previous one', async () => {
@@ -715,27 +715,27 @@ test('lockfile locks npm dependencies', async () => {
const project = prepareEmpty()
const reporter = sinon.spy()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ save: true, reporter }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ save: true, reporter }))
expect(reporter.calledWithMatch({
level: 'debug',
name: 'pnpm:progress',
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
packageId: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-1-dep/100.0.0`,
requester: process.cwd(),
status: 'resolved',
} as ProgressLog)).toBeTruthy()
expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
packageId: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-1-dep/100.0.0`,
requester: process.cwd(),
status: 'fetched',
} as ProgressLog)).toBeTruthy()
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await rimraf('node_modules')
@@ -744,27 +744,28 @@ test('lockfile locks npm dependencies', async () => {
expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
packageId: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-1-dep/100.0.0`,
requester: process.cwd(),
status: 'resolved',
} as ProgressLog)).toBeTruthy()
expect(reporter.calledWithMatch({
level: 'debug',
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
packageId: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-1-dep/100.0.0`,
requester: process.cwd(),
status: 'found_in_store',
} as ProgressLog)).toBeTruthy()
const m = project.requireModule('.pnpm/pkg-with-1-dep@100.0.0/node_modules/dep-of-pkg-with-1-dep/package.json')
const m = project.requireModule('.pnpm/@pnpm.e2e+pkg-with-1-dep@100.0.0/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep/package.json')
expect(m.version).toEqual('100.0.0')
})
test('self-require should work', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['uses-pkg-with-self-usage'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/uses-pkg-with-self-usage'], await testDefaults({ fastUnpack: false }))
expect(project.requireModule('uses-pkg-with-self-usage')).toBeTruthy()
expect(project.requireModule('@pnpm.e2e/uses-pkg-with-self-usage')).toBeTruthy()
})
test('install on project with lockfile and no node_modules', async () => {
@@ -788,18 +789,18 @@ test('install a dependency with * range', async () => {
await install({
dependencies: {
'has-beta-only': '*',
'@pnpm.e2e/has-beta-only': '*',
},
}, await testDefaults({ reporter }))
await project.has('has-beta-only')
await project.has('@pnpm.e2e/has-beta-only')
expect(reporter.calledWithMatch({
level: 'debug',
name: 'pnpm:package-manifest',
updated: {
dependencies: {
'has-beta-only': '*',
'@pnpm.e2e/has-beta-only': '*',
},
} as ProjectManifest,
} as PackageManifestLog)).toBeTruthy()
@@ -837,9 +838,9 @@ test("don't fail on case insensitive filesystems when package has 2 files with s
const reporter = sinon.spy()
const opts = await testDefaults({ reporter })
await addDependenciesToPackage({}, ['with-same-file-in-different-cases'], opts)
await addDependenciesToPackage({}, ['@pnpm.e2e/with-same-file-in-different-cases'], opts)
await project.has('with-same-file-in-different-cases')
await project.has('@pnpm.e2e/with-same-file-in-different-cases')
})
// Covers https://github.com/pnpm/pnpm/issues/1134
@@ -902,14 +903,14 @@ test('reinstalls missing packages to node_modules during headless install', asyn
})
test('do not update deps when lockfile is present', async () => {
await addDistTag({ package: 'peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.0', distTag: 'latest' })
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['peer-a'], await testDefaults({ lockfileOnly: true }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/peer-a'], await testDefaults({ lockfileOnly: true }))
const initialLockfile = await project.readLockfile()
await addDistTag({ package: 'peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' })
await mutateModules([
{
@@ -933,7 +934,7 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall
buildIndex: 0,
manifest: {
dependencies: {
foobarqar: '1.0.0',
'@pnpm.e2e/foobarqar': '1.0.0',
},
},
mutation: 'install',
@@ -943,31 +944,31 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall
await writeYamlFile(path.resolve('pnpm-lock.yaml'), {
dependencies: {
foobarqar: '1.0.1',
'@pnpm.e2e/foobarqar': '1.0.1',
},
lockfileVersion: LOCKFILE_VERSION,
packages: {
'/bar/100.0.0': {
'/@pnpm.e2e/bar/100.0.0': {
dev: false,
resolution: {
integrity: getIntegrity('bar', '100.0.0'),
integrity: getIntegrity('@pnpm.e2e/bar', '100.0.0'),
},
},
'/foo/100.1.0': {
'/@pnpm.e2e/foo/100.1.0': {
dev: false,
resolution: {
integrity: getIntegrity('foo', '100.1.0'),
integrity: getIntegrity('@pnpm.e2e/foo', '100.1.0'),
},
},
'/foobarqar/1.0.1': {
'/@pnpm.e2e/foobarqar/1.0.1': {
dependencies: {
bar: '100.0.0',
foo: '100.1.0',
'@pnpm.e2e/bar': '100.0.0',
'@pnpm.e2e/foo': '100.1.0',
'is-positive': '3.1.0',
},
dev: false,
resolution: {
integrity: getIntegrity('foobarqar', '1.0.1'),
integrity: getIntegrity('@pnpm.e2e/foobarqar', '1.0.1'),
},
},
'/is-positive/3.1.0': {
@@ -981,7 +982,7 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall
},
},
specifiers: {
foobarqar: '1.0.1',
'@pnpm.e2e/foobarqar': '1.0.1',
},
}, { lineWidth: 1000 })
@@ -990,7 +991,7 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall
buildIndex: 0,
manifest: {
dependencies: {
foobarqar: '1.0.1',
'@pnpm.e2e/foobarqar': '1.0.1',
},
},
mutation: 'install',
@@ -999,19 +1000,19 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall
], await testDefaults({ preferFrozenLockfile: false }))
expect(
[...await fs.readdir(path.resolve('node_modules/.pnpm/foobarqar@1.0.1/node_modules'))]
[...await fs.readdir(path.resolve('node_modules/.pnpm/@pnpm.e2e+foobarqar@1.0.1/node_modules/@pnpm.e2e'))].sort()
).toStrictEqual(
[
'bar',
'foo',
'foobarqar',
'qar',
]
].sort()
)
})
test('subdep symlinks are updated if the lockfile has new subdep versions specified', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const project = prepareEmpty()
await mutateModules([
@@ -1019,7 +1020,7 @@ test('subdep symlinks are updated if the lockfile has new subdep versions specif
buildIndex: 0,
manifest: {
dependencies: {
'parent-of-pkg-with-1-dep': '1.0.0',
'@pnpm.e2e/parent-of-pkg-with-1-dep': '1.0.0',
},
},
mutation: 'install',
@@ -1033,45 +1034,45 @@ test('subdep symlinks are updated if the lockfile has new subdep versions specif
Object.keys(lockfile.packages)
).toStrictEqual(
[
'/dep-of-pkg-with-1-dep/100.0.0',
'/parent-of-pkg-with-1-dep/1.0.0',
'/pkg-with-1-dep/100.0.0',
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0',
'/@pnpm.e2e/parent-of-pkg-with-1-dep/1.0.0',
'/@pnpm.e2e/pkg-with-1-dep/100.0.0',
]
)
await writeYamlFile(path.resolve('pnpm-lock.yaml'), {
dependencies: {
'parent-of-pkg-with-1-dep': '1.0.0',
'@pnpm.e2e/parent-of-pkg-with-1-dep': '1.0.0',
},
lockfileVersion: LOCKFILE_VERSION,
packages: {
'/dep-of-pkg-with-1-dep/100.1.0': {
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0': {
dev: false,
resolution: {
integrity: getIntegrity('dep-of-pkg-with-1-dep', '100.1.0'),
integrity: getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0'),
},
},
'/parent-of-pkg-with-1-dep/1.0.0': {
'/@pnpm.e2e/parent-of-pkg-with-1-dep/1.0.0': {
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
dev: false,
resolution: {
integrity: getIntegrity('parent-of-pkg-with-1-dep', '1.0.0'),
integrity: getIntegrity('@pnpm.e2e/parent-of-pkg-with-1-dep', '1.0.0'),
},
},
'/pkg-with-1-dep/100.0.0': {
'/@pnpm.e2e/pkg-with-1-dep/100.0.0': {
dependencies: {
'dep-of-pkg-with-1-dep': '100.1.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.1.0',
},
dev: false,
resolution: {
integrity: getIntegrity('pkg-with-1-dep', '100.0.0'),
integrity: getIntegrity('@pnpm.e2e/pkg-with-1-dep', '100.0.0'),
},
},
},
specifiers: {
'parent-of-pkg-with-1-dep': '1.0.0',
'@pnpm.e2e/parent-of-pkg-with-1-dep': '1.0.0',
},
}, { lineWidth: 1000 })
@@ -1080,7 +1081,7 @@ test('subdep symlinks are updated if the lockfile has new subdep versions specif
buildIndex: 0,
manifest: {
dependencies: {
'parent-of-pkg-with-1-dep': '1.0.0',
'@pnpm.e2e/parent-of-pkg-with-1-dep': '1.0.0',
},
},
mutation: 'install',
@@ -1088,7 +1089,7 @@ test('subdep symlinks are updated if the lockfile has new subdep versions specif
},
], await testDefaults({ preferFrozenLockfile: false }))
expect(await exists(path.resolve('node_modules/.pnpm/pkg-with-1-dep@100.0.0/node_modules/dep-of-pkg-with-1-dep/package.json'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+pkg-with-1-dep@100.0.0/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep/package.json'))).toBeTruthy()
})
test('fail if none of the available resolvers support a version spec', async () => {
@@ -1312,9 +1313,9 @@ test('two dependencies have the same version and name. The only difference is th
test('installing a package with broken bin', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['broken-bin@1.0.0'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/broken-bin@1.0.0'], await testDefaults({ fastUnpack: false }))
await project.has('broken-bin')
await project.has('@pnpm.e2e/broken-bin')
})
test('a package should be able to be a dependency of itself', async () => {
+96 -93
View File
@@ -11,6 +11,7 @@ import {
mutateModules,
} from '@pnpm/core'
import rimraf from '@zkochan/rimraf'
import { createPeersFolderSuffix } from 'dependency-path'
import loadJsonFile from 'load-json-file'
import exists from 'path-exists'
import pick from 'ramda/src/pick'
@@ -120,7 +121,7 @@ test('install only the dependencies of the specified importer. The current lockf
version: '1.0.0',
dependencies: {
foobar: '100.0.0',
'@pnpm.e2e/foobar': '100.0.0',
},
},
mutation: 'install',
@@ -133,7 +134,7 @@ test('install only the dependencies of the specified importer. The current lockf
await mutateModules([
{
...importers[0],
dependencySelectors: ['pkg-with-1-dep'],
dependencySelectors: ['@pnpm.e2e/pkg-with-1-dep'],
mutation: 'installSome',
},
], await testDefaults({ hoistPattern: '*' }))
@@ -141,7 +142,7 @@ test('install only the dependencies of the specified importer. The current lockf
const rootModules = assertProject(process.cwd())
const currentLockfile = await rootModules.readCurrentLockfile()
expect(currentLockfile.importers).toHaveProperty(['project-3'])
expect(currentLockfile.packages).toHaveProperty(['/foobar/100.0.0'])
expect(currentLockfile.packages).toHaveProperty(['/@pnpm.e2e/foobar/100.0.0'])
})
test('some projects were removed from the workspace and the ones that are left depend on them', async () => {
@@ -473,26 +474,26 @@ test('headless install is used with an up-to-date lockfile when package referenc
test('headless install is used when packages are not linked from the workspace (unless workspace ranges are used)', async () => {
const foo = {
name: 'foo',
name: '@pnpm.e2e/foo',
version: '1.0.0',
dependencies: {
qar: 'workspace:*',
'@pnpm.e2e/qar': 'workspace:*',
},
}
const bar = {
name: 'bar',
name: '@pnpm.e2e/bar',
version: '1.0.0',
dependencies: {
qar: '100.0.0',
'@pnpm.e2e/qar': '100.0.0',
},
}
const qar = {
name: 'qar',
name: '@pnpm.e2e/qar',
version: '100.0.0',
}
preparePackages([foo, bar, qar])
preparePackages([{ location: 'foo', package: foo }, { location: 'bar', package: bar }, { location: 'qar', package: qar }])
const importers: MutatedProject[] = [
{
@@ -515,7 +516,7 @@ test('headless install is used when packages are not linked from the workspace (
},
]
const workspacePackages = {
qar: {
'@pnpm.e2e/qar': {
'100.0.0': {
dir: path.resolve('qar'),
manifest: qar,
@@ -585,7 +586,7 @@ test('current lockfile contains only installed dependencies when adding a new im
})
test('partial installation in a monorepo does not remove dependencies of other workspace projects', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
prepareEmpty()
await mutateModules([
@@ -603,7 +604,7 @@ test('partial installation in a monorepo does not remove dependencies of other w
buildIndex: 0,
manifest: {
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
mutation: 'install',
@@ -623,16 +624,16 @@ test('partial installation in a monorepo does not remove dependencies of other w
},
'project-2': {
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
specifiers: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
},
lockfileVersion: LOCKFILE_VERSION,
packages: {
'/dep-of-pkg-with-1-dep/100.0.0': {
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0': {
dev: false,
resolution: {
integrity: 'sha512-RWObNQIluSr56fVbOwD75Dt5CE2aiPReTMMUblYEMEqUI+iJw5ovTyO7LzUG/VJ4iVL2uUrbkQ6+rq4z4WOdDw==',
@@ -647,9 +648,9 @@ test('partial installation in a monorepo does not remove dependencies of other w
integrity: 'sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==',
},
},
'/pkg-with-1-dep/100.0.0': {
'/@pnpm.e2e/pkg-with-1-dep/100.0.0': {
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
dev: false,
resolution: {
@@ -673,12 +674,12 @@ test('partial installation in a monorepo does not remove dependencies of other w
], await testDefaults())
expect(await exists(path.resolve('node_modules/.pnpm/is-positive@2.0.0/node_modules/is-positive'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/pkg-with-1-dep@100.0.0/node_modules/pkg-with-1-dep'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/dep-of-pkg-with-1-dep@100.1.0/node_modules/dep-of-pkg-with-1-dep'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+pkg-with-1-dep@100.0.0/node_modules/@pnpm.e2e/pkg-with-1-dep'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+dep-of-pkg-with-1-dep@100.1.0/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep'))).toBeTruthy()
})
test('partial installation in a monorepo does not remove dependencies of other workspace projects when lockfile is frozen', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
prepareEmpty()
await mutateModules([
@@ -696,7 +697,7 @@ test('partial installation in a monorepo does not remove dependencies of other w
buildIndex: 0,
manifest: {
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
mutation: 'install',
@@ -716,16 +717,16 @@ test('partial installation in a monorepo does not remove dependencies of other w
},
'project-2': {
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
specifiers: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
},
lockfileVersion: LOCKFILE_VERSION,
packages: {
'/dep-of-pkg-with-1-dep/100.0.0': {
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0': {
dev: false,
resolution: {
integrity: 'sha512-RWObNQIluSr56fVbOwD75Dt5CE2aiPReTMMUblYEMEqUI+iJw5ovTyO7LzUG/VJ4iVL2uUrbkQ6+rq4z4WOdDw==',
@@ -740,9 +741,9 @@ test('partial installation in a monorepo does not remove dependencies of other w
integrity: 'sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==',
},
},
'/pkg-with-1-dep/100.0.0': {
'/@pnpm.e2e/pkg-with-1-dep/100.0.0': {
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
dev: false,
resolution: {
@@ -766,8 +767,8 @@ test('partial installation in a monorepo does not remove dependencies of other w
], await testDefaults({ frozenLockfile: true }))
expect(await exists(path.resolve('node_modules/.pnpm/is-positive@1.0.0/node_modules/is-positive'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/pkg-with-1-dep@100.0.0/node_modules/pkg-with-1-dep'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/dep-of-pkg-with-1-dep@100.1.0/node_modules/dep-of-pkg-with-1-dep'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+pkg-with-1-dep@100.0.0/node_modules/@pnpm.e2e/pkg-with-1-dep'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+dep-of-pkg-with-1-dep@100.1.0/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep'))).toBeTruthy()
})
test('adding a new dependency with the workspace: protocol', async () => {
@@ -1133,15 +1134,15 @@ test('remove dependencies of a project that was removed from the workspace (duri
})
test('do not resolve a subdependency from the workspace by default', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
preparePackages([
{
location: 'project',
package: { name: 'project' },
},
{
location: 'dep-of-pkg-with-1-dep',
package: { name: 'dep-of-pkg-with-1-dep' },
location: '@pnpm.e2e/dep-of-pkg-with-1-dep',
package: { name: '@pnpm.e2e/dep-of-pkg-with-1-dep' },
},
])
@@ -1153,7 +1154,7 @@ test('do not resolve a subdependency from the workspace by default', async () =>
version: '1.0.0',
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
mutation: 'install',
@@ -1162,19 +1163,19 @@ test('do not resolve a subdependency from the workspace by default', async () =>
{
buildIndex: 0,
manifest: {
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
mutation: 'install',
rootDir: path.resolve('dep-of-pkg-with-1-dep'),
rootDir: path.resolve('@pnpm.e2e/dep-of-pkg-with-1-dep'),
},
]
const workspacePackages = {
'dep-of-pkg-with-1-dep': {
'@pnpm.e2e/dep-of-pkg-with-1-dep': {
'100.1.0': {
dir: path.resolve('dep-of-pkg-with-1-dep'),
dir: path.resolve('@pnpm.e2e/dep-of-pkg-with-1-dep'),
manifest: {
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
},
@@ -1185,7 +1186,7 @@ test('do not resolve a subdependency from the workspace by default', async () =>
const project = assertProject(process.cwd())
const wantedLockfile = await project.readLockfile()
expect(wantedLockfile.packages['/pkg-with-1-dep/100.0.0'].dependencies?.['dep-of-pkg-with-1-dep']).toBe('100.1.0')
expect(wantedLockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].dependencies?.['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('100.1.0')
})
test('resolve a subdependency from the workspace', async () => {
@@ -1195,8 +1196,8 @@ test('resolve a subdependency from the workspace', async () => {
package: { name: 'project' },
},
{
location: 'dep-of-pkg-with-1-dep',
package: { name: 'dep-of-pkg-with-1-dep' },
location: '@pnpm.e2e/dep-of-pkg-with-1-dep',
package: { name: '@pnpm.e2e/dep-of-pkg-with-1-dep' },
},
])
@@ -1208,7 +1209,7 @@ test('resolve a subdependency from the workspace', async () => {
version: '1.0.0',
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
mutation: 'install',
@@ -1217,19 +1218,19 @@ test('resolve a subdependency from the workspace', async () => {
{
buildIndex: 0,
manifest: {
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
mutation: 'install',
rootDir: path.resolve('dep-of-pkg-with-1-dep'),
rootDir: path.resolve('@pnpm.e2e/dep-of-pkg-with-1-dep'),
},
]
const workspacePackages = {
'dep-of-pkg-with-1-dep': {
'@pnpm.e2e/dep-of-pkg-with-1-dep': {
'100.1.0': {
dir: path.resolve('dep-of-pkg-with-1-dep'),
dir: path.resolve('@pnpm.e2e/dep-of-pkg-with-1-dep'),
manifest: {
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
},
@@ -1240,7 +1241,7 @@ test('resolve a subdependency from the workspace', async () => {
const project = assertProject(process.cwd())
const wantedLockfile = await project.readLockfile()
expect(wantedLockfile.packages['/pkg-with-1-dep/100.0.0'].dependencies?.['dep-of-pkg-with-1-dep']).toBe('link:dep-of-pkg-with-1-dep')
expect(wantedLockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].dependencies?.['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('link:@pnpm.e2e/dep-of-pkg-with-1-dep')
await rimraf('node_modules')
@@ -1252,15 +1253,15 @@ test('resolve a subdependency from the workspace', async () => {
})
test('resolve a subdependency from the workspace and use it as a peer', async () => {
await addDistTag({ package: 'peer-c', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.1', distTag: 'latest' })
preparePackages([
{
location: 'project',
package: { name: 'project' },
},
{
location: 'peer-a',
package: { name: 'peer-a' },
location: '@pnpm.e2e/peer-a',
package: { name: '@pnpm.e2e/peer-a' },
},
])
@@ -1272,8 +1273,8 @@ test('resolve a subdependency from the workspace and use it as a peer', async ()
version: '1.0.0',
dependencies: {
'abc-grand-parent-with-c': '1.0.0',
'abc-parent-with-ab': '1.0.0',
'@pnpm.e2e/abc-grand-parent-with-c': '1.0.0',
'@pnpm.e2e/abc-parent-with-ab': '1.0.0',
},
},
mutation: 'install',
@@ -1282,19 +1283,19 @@ test('resolve a subdependency from the workspace and use it as a peer', async ()
{
buildIndex: 0,
manifest: {
name: 'peer-a',
name: '@pnpm.e2e/peer-a',
version: '1.0.1',
},
mutation: 'install',
rootDir: path.resolve('peer-a'),
rootDir: path.resolve('@pnpm.e2e/peer-a'),
},
]
const workspacePackages = {
'peer-a': {
'@pnpm.e2e/peer-a': {
'1.0.1': {
dir: path.resolve('peer-a'),
dir: path.resolve('@pnpm.e2e/peer-a'),
manifest: {
name: 'peer-a',
name: '@pnpm.e2e/peer-a',
version: '1.0.1',
},
},
@@ -1305,21 +1306,23 @@ test('resolve a subdependency from the workspace and use it as a peer', async ()
const project = assertProject(process.cwd())
const wantedLockfile = await project.readLockfile()
expect(Object.keys(wantedLockfile.packages)).toStrictEqual(
const suffix1 = createPeersFolderSuffix([{ name: '@pnpm.e2e/peer-a', version: '@pnpm.e2e+peer-a' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }])
const suffix2 = createPeersFolderSuffix([{ name: '@pnpm.e2e/peer-a', version: '@pnpm.e2e+peer-a' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.1' }])
expect(Object.keys(wantedLockfile.packages).sort()).toStrictEqual(
[
'/abc-grand-parent-with-c/1.0.0',
'/abc-parent-with-ab/1.0.0',
'/abc-parent-with-ab/1.0.0_peer-c@1.0.1',
'/abc/1.0.0_f7z7ngphs5rjimyr5x4q43qtai',
'/abc/1.0.0_peer-a@peer-a+peer-b@1.0.0',
'/dep-of-pkg-with-1-dep/100.0.0',
'/@pnpm.e2e/abc-grand-parent-with-c/1.0.0',
'/@pnpm.e2e/abc-parent-with-ab/1.0.0',
'/@pnpm.e2e/abc-parent-with-ab/1.0.0_@pnpm.e2e+peer-c@1.0.1',
`/@pnpm.e2e/abc/1.0.0${suffix1}`,
`/@pnpm.e2e/abc/1.0.0${suffix2}`,
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0',
'/is-positive/1.0.0',
'/peer-b/1.0.0',
'/peer-c/1.0.1',
]
'/@pnpm.e2e/peer-b/1.0.0',
'/@pnpm.e2e/peer-c/1.0.1',
].sort()
)
expect(wantedLockfile.packages['/abc-parent-with-ab/1.0.0'].dependencies?.['peer-a']).toBe('link:peer-a')
expect(wantedLockfile.packages['/abc/1.0.0_peer-a@peer-a+peer-b@1.0.0'].dependencies?.['peer-a']).toBe('link:peer-a')
expect(wantedLockfile.packages['/@pnpm.e2e/abc-parent-with-ab/1.0.0'].dependencies?.['@pnpm.e2e/peer-a']).toBe('link:@pnpm.e2e/peer-a')
expect(wantedLockfile.packages[`/@pnpm.e2e/abc/1.0.0${suffix1}`].dependencies?.['@pnpm.e2e/peer-a']).toBe('link:@pnpm.e2e/peer-a')
})
test('resolve a subdependency from the workspace, when it uses the workspace protocol', async () => {
@@ -1329,8 +1332,8 @@ test('resolve a subdependency from the workspace, when it uses the workspace pro
package: { name: 'project' },
},
{
location: 'dep-of-pkg-with-1-dep',
package: { name: 'dep-of-pkg-with-1-dep' },
location: '@pnpm.e2e/dep-of-pkg-with-1-dep',
package: { name: '@pnpm.e2e/dep-of-pkg-with-1-dep' },
},
])
@@ -1342,7 +1345,7 @@ test('resolve a subdependency from the workspace, when it uses the workspace pro
version: '1.0.0',
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
mutation: 'install',
@@ -1351,26 +1354,26 @@ test('resolve a subdependency from the workspace, when it uses the workspace pro
{
buildIndex: 0,
manifest: {
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
mutation: 'install',
rootDir: path.resolve('dep-of-pkg-with-1-dep'),
rootDir: path.resolve('@pnpm.e2e/dep-of-pkg-with-1-dep'),
},
]
const workspacePackages = {
'dep-of-pkg-with-1-dep': {
'@pnpm.e2e/dep-of-pkg-with-1-dep': {
'100.1.0': {
dir: path.resolve('dep-of-pkg-with-1-dep'),
dir: path.resolve('@pnpm.e2e/dep-of-pkg-with-1-dep'),
manifest: {
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
},
},
}
const overrides = {
'dep-of-pkg-with-1-dep': 'workspace:*',
'@pnpm.e2e/dep-of-pkg-with-1-dep': 'workspace:*',
}
await mutateModules(importers, await testDefaults({
linkWorkspacePackagesDepth: -1,
@@ -1381,7 +1384,7 @@ test('resolve a subdependency from the workspace, when it uses the workspace pro
const project = assertProject(process.cwd())
const wantedLockfile = await project.readLockfile()
expect(wantedLockfile.packages['/pkg-with-1-dep/100.0.0'].dependencies?.['dep-of-pkg-with-1-dep']).toBe('link:dep-of-pkg-with-1-dep')
expect(wantedLockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].dependencies?.['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('link:@pnpm.e2e/dep-of-pkg-with-1-dep')
await rimraf('node_modules')
@@ -1394,13 +1397,13 @@ test('resolve a subdependency from the workspace, when it uses the workspace pro
})
test('install the dependency that is already present in the workspace when adding a new direct dependency', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest1: ProjectManifest = {
name: 'project-1',
version: '1.0.0',
dependencies: {
'dep-of-pkg-with-1-dep': '^100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '^100.0.0',
},
}
const manifest2: ProjectManifest = { name: 'project-2' }
@@ -1432,13 +1435,13 @@ test('install the dependency that is already present in the workspace when addin
]
await mutateModules(importers, await testDefaults())
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await mutateModules([
importers[0],
{
...importers[1],
dependencySelectors: ['dep-of-pkg-with-1-dep'],
dependencySelectors: ['@pnpm.e2e/dep-of-pkg-with-1-dep'],
mutation: 'installSome',
},
], await testDefaults({
@@ -1456,23 +1459,23 @@ test('install the dependency that is already present in the workspace when addin
const rootModules = assertProject(process.cwd())
const currentLockfile = await rootModules.readCurrentLockfile()
expect(currentLockfile.importers['project-1'].specifiers?.['dep-of-pkg-with-1-dep']).toBe('^100.0.0')
expect(currentLockfile.importers['project-2'].specifiers?.['dep-of-pkg-with-1-dep']).toBe('^100.0.0')
expect(currentLockfile.importers['project-1'].specifiers?.['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('^100.0.0')
expect(currentLockfile.importers['project-2'].specifiers?.['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('^100.0.0')
expect(currentLockfile.importers['project-1'].dependencies?.['dep-of-pkg-with-1-dep']).toBe('100.0.0')
expect(currentLockfile.importers['project-2'].dependencies?.['dep-of-pkg-with-1-dep']).toBe('100.0.0')
expect(currentLockfile.importers['project-1'].dependencies?.['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('100.0.0')
expect(currentLockfile.importers['project-2'].dependencies?.['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('100.0.0')
})
test('do not update dependency that has the same name as a dependency in the workspace', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest1: ProjectManifest = {
name: 'project-1',
version: '1.0.0',
dependencies: {
'dep-of-pkg-with-1-dep': '^100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '^100.0.0',
},
}
const manifest2: ProjectManifest = { name: 'dep-of-pkg-with-1-dep', version: '100.1.0' }
const manifest2: ProjectManifest = { name: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0' }
preparePackages([
{
@@ -1506,7 +1509,7 @@ test('do not update dependency that has the same name as a dependency in the wor
manifest: manifest1,
},
},
'dep-of-pkg-with-1-dep': {
'@pnpm.e2e/dep-of-pkg-with-1-dep': {
'100.1.0': {
dir: path.resolve('project-2'),
manifest: manifest2,
@@ -1514,7 +1517,7 @@ test('do not update dependency that has the same name as a dependency in the wor
},
}
await mutateModules(importers, await testDefaults({ linkWorkspacePackagesDepth: -1, workspacePackages }))
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await mutateModules([
{
...importers[0],
@@ -1527,7 +1530,7 @@ test('do not update dependency that has the same name as a dependency in the wor
const rootModules = assertProject(process.cwd())
const currentLockfile = await rootModules.readCurrentLockfile()
expect(Object.keys(currentLockfile.packages)).toStrictEqual([
'/dep-of-pkg-with-1-dep/100.0.0',
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0',
'/is-negative/2.1.0',
])
})
+4 -4
View File
@@ -9,7 +9,7 @@ test('production install (with --production flag)', async () => {
await install({
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
'write-yaml': '1.0.0',
},
devDependencies: {
@@ -30,7 +30,7 @@ test('production install (with --production flag)', async () => {
expect(await exists(path.resolve('node_modules/.pnpm/@zkochan/foo@1.0.0'))).toBeFalsy()
expect(await exists(path.resolve('node_modules/.pnpm/js-yaml@3.14.0'))).toBeTruthy()
await project.has('pkg-with-1-dep')
await project.has('@pnpm.e2e/pkg-with-1-dep')
await project.has('write-yaml')
await project.hasNot('@zkochan/foo')
await project.hasNot('js-yaml')
@@ -41,7 +41,7 @@ test('production install with --no-optional', async () => {
await install({
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
'write-yaml': '1.0.0',
},
optionalDependencies: {
@@ -62,7 +62,7 @@ test('production install with --no-optional', async () => {
expect(await exists(path.resolve('node_modules/.pnpm/@zkochan/foo@1.0.0'))).toBeFalsy()
expect(await exists(path.resolve('node_modules/.pnpm/js-yaml@3.14.0'))).toBeTruthy()
await project.has('pkg-with-1-dep')
await project.has('@pnpm.e2e/pkg-with-1-dep')
await project.has('write-yaml')
await project.hasNot('@zkochan/foo')
await project.hasNot('js-yaml')
@@ -38,13 +38,13 @@ test('skip non-existing optional dependency', async () => {
'is-positive': '*',
},
optionalDependencies: {
'i-do-not-exist': '1000',
'@pnpm.e2e/i-do-not-exist': '1000',
},
}, await testDefaults({ reporter }))
expect(reporter.calledWithMatch({
package: {
name: 'i-do-not-exist',
name: '@pnpm.e2e/i-do-not-exist',
version: '1000',
},
parents: [],
@@ -64,22 +64,22 @@ test('skip optional dependency that does not support the current OS', async () =
let manifest = await install({
optionalDependencies: {
'not-compatible-with-any-os': '*',
'@pnpm.e2e/not-compatible-with-any-os': '*',
},
}, await testDefaults({ reporter }))
await project.hasNot('not-compatible-with-any-os')
await project.storeHas('not-compatible-with-any-os', '1.0.0')
expect(await exists(path.resolve('node_modules/.pnpm/dep-of-optional-pkg@1.0.0'))).toBeFalsy()
await project.hasNot('@pnpm.e2e/not-compatible-with-any-os')
await project.storeHas('@pnpm.e2e/not-compatible-with-any-os', '1.0.0')
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+dep-of-optional-pkg@1.0.0'))).toBeFalsy()
const lockfile = await project.readLockfile()
expect(lockfile.packages['/not-compatible-with-any-os/1.0.0']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/not-compatible-with-any-os/1.0.0']).toBeTruthy()
// optional dependencies always get requiresBuild: true
// this is to resolve https://github.com/pnpm/pnpm/issues/2038
expect(lockfile.packages['/not-compatible-with-any-os/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'].requiresBuild).toBeTruthy()
expect(lockfile.packages['/dep-of-optional-pkg/1.0.0']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/dep-of-optional-pkg/1.0.0']).toBeTruthy()
const currentLockfile = await project.readCurrentLockfile()
@@ -87,14 +87,14 @@ test('skip optional dependency that does not support the current OS', async () =
const modulesInfo = await readYamlFile<{skipped: string[]}>(path.join('node_modules', '.modules.yaml'))
expect(modulesInfo.skipped).toStrictEqual([
'/dep-of-optional-pkg/1.0.0',
'/not-compatible-with-any-os/1.0.0',
'/@pnpm.e2e/dep-of-optional-pkg/1.0.0',
'/@pnpm.e2e/not-compatible-with-any-os/1.0.0',
])
const logMatcher = sinon.match({
package: {
id: `localhost+${REGISTRY_MOCK_PORT}/not-compatible-with-any-os/1.0.0`,
name: 'not-compatible-with-any-os',
id: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/not-compatible-with-any-os/1.0.0`,
name: '@pnpm.e2e/not-compatible-with-any-os',
version: '1.0.0',
},
reason: 'unsupported_platform',
@@ -102,15 +102,15 @@ test('skip optional dependency that does not support the current OS', async () =
const reportedTimes = reporter.withArgs(logMatcher).callCount
expect(reportedTimes).toBe(1)
console.log('a previously skipped package is successfully installed')
// a previously skipped package is successfully installed
manifest = await addDependenciesToPackage(manifest, ['dep-of-optional-pkg'], await testDefaults())
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/dep-of-optional-pkg'], await testDefaults())
await project.has('dep-of-optional-pkg')
await project.has('@pnpm.e2e/dep-of-optional-pkg')
{
const modules = await project.readModulesManifest()
expect(modules?.skipped).toStrictEqual(['/not-compatible-with-any-os/1.0.0'])
expect(modules?.skipped).toStrictEqual(['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
}
await rimraf('node_modules')
@@ -127,12 +127,12 @@ test('skip optional dependency that does not support the current OS', async () =
await testDefaults({ frozenLockfile: true })
)
await project.hasNot('not-compatible-with-any-os')
await project.has('dep-of-optional-pkg')
await project.hasNot('@pnpm.e2e/not-compatible-with-any-os')
await project.has('@pnpm.e2e/dep-of-optional-pkg')
{
const modules = await project.readModulesManifest()
expect(modules?.skipped).toStrictEqual(['/not-compatible-with-any-os/1.0.0'])
expect(modules?.skipped).toStrictEqual(['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
}
})
@@ -142,17 +142,17 @@ test('skip optional dependency that does not support the current Node version',
await install({
optionalDependencies: {
'for-legacy-node': '*',
'@pnpm.e2e/for-legacy-node': '*',
},
}, await testDefaults({ reporter }))
await project.hasNot('for-legacy-node')
await project.storeHas('for-legacy-node', '1.0.0')
await project.hasNot('@pnpm.e2e/for-legacy-node')
await project.storeHas('@pnpm.e2e/for-legacy-node', '1.0.0')
const logMatcher = sinon.match({
package: {
id: `localhost+${REGISTRY_MOCK_PORT}/for-legacy-node/1.0.0`,
name: 'for-legacy-node',
id: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/for-legacy-node/1.0.0`,
name: '@pnpm.e2e/for-legacy-node',
version: '1.0.0',
},
reason: 'unsupported_engine',
@@ -167,7 +167,7 @@ test('skip optional dependency that does not support the current pnpm version',
await install({
optionalDependencies: {
'for-legacy-pnpm': '*',
'@pnpm.e2e/for-legacy-pnpm': '*',
},
}, await testDefaults({
reporter,
@@ -175,13 +175,13 @@ test('skip optional dependency that does not support the current pnpm version',
pnpmVersion: '4.0.0',
}))
await project.hasNot('for-legacy-pnpm')
await project.storeHas('for-legacy-pnpm', '1.0.0')
await project.hasNot('@pnpm.e2e/for-legacy-pnpm')
await project.storeHas('@pnpm.e2e/for-legacy-pnpm', '1.0.0')
const logMatcher = sinon.match({
package: {
id: `localhost+${REGISTRY_MOCK_PORT}/for-legacy-pnpm/1.0.0`,
name: 'for-legacy-pnpm',
id: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/for-legacy-pnpm/1.0.0`,
name: '@pnpm.e2e/for-legacy-pnpm',
version: '1.0.0',
},
reason: 'unsupported_engine',
@@ -195,12 +195,12 @@ test('don\'t skip optional dependency that does not support the current OS when
await install({
optionalDependencies: {
'not-compatible-with-any-os': '*',
'@pnpm.e2e/not-compatible-with-any-os': '*',
},
}, await testDefaults({}, {}, {}, { force: true }))
await project.has('not-compatible-with-any-os')
await project.storeHas('not-compatible-with-any-os', '1.0.0')
await project.has('@pnpm.e2e/not-compatible-with-any-os')
await project.storeHas('@pnpm.e2e/not-compatible-with-any-os', '1.0.0')
})
// Covers https://github.com/pnpm/pnpm/issues/2636
@@ -224,7 +224,7 @@ test('optional subdependency is not removed from current lockfile when new depen
version: '1.0.0',
dependencies: {
'pkg-with-optional': '1.0.0',
'@pnpm.e2e/pkg-with-optional': '1.0.0',
},
},
mutation: 'install',
@@ -246,10 +246,10 @@ test('optional subdependency is not removed from current lockfile when new depen
{
const modulesInfo = await readYamlFile<{ skipped: string[] }>(path.join('node_modules', '.modules.yaml'))
expect(modulesInfo.skipped).toStrictEqual(['/dep-of-optional-pkg/1.0.0', '/not-compatible-with-any-os/1.0.0'])
expect(modulesInfo.skipped).toStrictEqual(['/@pnpm.e2e/dep-of-optional-pkg/1.0.0', '/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
const currentLockfile = await readYamlFile<Lockfile>(path.resolve('node_modules/.pnpm/lock.yaml'))
expect(currentLockfile.packages).toHaveProperty(['/not-compatible-with-any-os/1.0.0'])
expect(currentLockfile.packages).toHaveProperty(['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
}
await mutateModules([
@@ -262,7 +262,7 @@ test('optional subdependency is not removed from current lockfile when new depen
{
const currentLockfile = await readYamlFile<Lockfile>(path.resolve('node_modules/.pnpm/lock.yaml'))
expect(currentLockfile.packages).toHaveProperty(['/not-compatible-with-any-os/1.0.0'])
expect(currentLockfile.packages).toHaveProperty(['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
}
})
@@ -270,20 +270,20 @@ test('optional subdependency is skipped', async () => {
const project = prepareEmpty()
const reporter = sinon.spy()
const manifest = await addDependenciesToPackage({}, ['pkg-with-optional', 'dep-of-optional-pkg'], await testDefaults({ reporter }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-optional', '@pnpm.e2e/dep-of-optional-pkg'], await testDefaults({ reporter }))
{
const modulesInfo = await readYamlFile<{ skipped: string[] }>(path.join('node_modules', '.modules.yaml'))
expect(modulesInfo.skipped).toStrictEqual(['/not-compatible-with-any-os/1.0.0'])
expect(modulesInfo.skipped).toStrictEqual(['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
}
expect(await exists('node_modules/.pnpm/pkg-with-optional@1.0.0')).toBeTruthy()
expect(await exists('node_modules/.pnpm/not-compatible-with-any-os@1.0.0')).toBeFalsy()
expect(await exists('node_modules/.pnpm/@pnpm.e2e+pkg-with-optional@1.0.0')).toBeTruthy()
expect(await exists('node_modules/.pnpm/@pnpm.e2e+not-compatible-with-any-os@1.0.0')).toBeFalsy()
const logMatcher = sinon.match({
package: {
id: `localhost+${REGISTRY_MOCK_PORT}/not-compatible-with-any-os/1.0.0`,
name: 'not-compatible-with-any-os',
id: `localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/not-compatible-with-any-os/1.0.0`,
name: '@pnpm.e2e/not-compatible-with-any-os',
version: '1.0.0',
},
reason: 'unsupported_platform',
@@ -291,7 +291,7 @@ test('optional subdependency is skipped', async () => {
const reportedTimes = reporter.withArgs(logMatcher).callCount
expect(reportedTimes).toBe(1)
console.log('recreate the lockfile with optional dependencies present')
// recreate the lockfile with optional dependencies present
expect(await exists('pnpm-lock.yaml')).toBeTruthy()
await rimraf('pnpm-lock.yaml')
@@ -311,9 +311,9 @@ test('optional subdependency is skipped', async () => {
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages).length).toBe(3)
expect(lockfile.packages).toHaveProperty(['/not-compatible-with-any-os/1.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
console.log('forced headless install should install non-compatible optional deps')
// forced headless install should install non-compatible optional deps
// TODO: move next case to @pnpm/headless tests
await mutateModules(
@@ -328,7 +328,7 @@ test('optional subdependency is skipped', async () => {
await testDefaults({ force: true, frozenLockfile: true })
)
expect(await exists('node_modules/.pnpm/not-compatible-with-any-os@1.0.0')).toBeTruthy()
expect(await exists('node_modules/.pnpm/@pnpm.e2e+not-compatible-with-any-os@1.0.0')).toBeTruthy()
{
const modulesInfo = await readYamlFile<{ skipped: string[] }>(path.join('node_modules', '.modules.yaml'))
@@ -341,15 +341,15 @@ test('optional subdependency of newly added optional dependency is skipped', asy
const project = prepareEmpty()
const reporter = sinon.spy()
await addDependenciesToPackage({}, ['pkg-with-optional'], await testDefaults({ reporter, targetDependenciesField: 'optionalDependencies' }))
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-optional'], await testDefaults({ reporter, targetDependenciesField: 'optionalDependencies' }))
const modulesInfo = await readYamlFile<{ skipped: string[] }>(path.join('node_modules', '.modules.yaml'))
expect(modulesInfo.skipped).toStrictEqual(['/dep-of-optional-pkg/1.0.0', '/not-compatible-with-any-os/1.0.0'])
expect(modulesInfo.skipped).toStrictEqual(['/@pnpm.e2e/dep-of-optional-pkg/1.0.0', '/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages).length).toBe(3)
expect(lockfile.packages).toHaveProperty(['/not-compatible-with-any-os/1.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'])
})
test('only that package is skipped which is an optional dependency only and not installable', async () => {
@@ -357,9 +357,9 @@ test('only that package is skipped which is an optional dependency only and not
const reporter = sinon.spy()
const manifest = await addDependenciesToPackage({}, [
'peer-c@1.0.0',
'has-optional-dep-with-peer',
'not-compatible-with-any-os-and-has-peer',
'@pnpm.e2e/peer-c@1.0.0',
'@pnpm.e2e/has-optional-dep-with-peer',
'@pnpm.e2e/not-compatible-with-any-os-and-has-peer',
], await testDefaults({ reporter }))
{
@@ -368,7 +368,7 @@ test('only that package is skipped which is an optional dependency only and not
}
const lockfile = await project.readLockfile()
expect(typeof lockfile.packages['/dep-of-optional-pkg/1.0.0'].optional).toBe('undefined')
expect(typeof lockfile.packages['/@pnpm.e2e/dep-of-optional-pkg/1.0.0'].optional).toBe('undefined')
await rimraf('node_modules')
@@ -398,7 +398,7 @@ test('not installing optional dependencies when optional is false', async () =>
await install(
{
dependencies: {
'pkg-with-good-optional': '*',
'@pnpm.e2e/pkg-with-good-optional': '*',
},
optionalDependencies: {
'is-positive': '1.0.0',
@@ -414,10 +414,10 @@ test('not installing optional dependencies when optional is false', async () =>
)
await project.hasNot('is-positive')
await project.has('pkg-with-good-optional')
await project.has('@pnpm.e2e/pkg-with-good-optional')
expect(deepRequireCwd(['pkg-with-good-optional', 'dep-of-pkg-with-1-dep', './package.json'])).toBeTruthy()
expect(deepRequireCwd.silent(['pkg-with-good-optional', 'is-positive', './package.json'])).toBeFalsy()
expect(deepRequireCwd(['@pnpm.e2e/pkg-with-good-optional', '@pnpm.e2e/dep-of-pkg-with-1-dep', './package.json'])).toBeTruthy()
expect(deepRequireCwd.silent(['@pnpm.e2e/pkg-with-good-optional', 'is-positive', './package.json'])).toBeFalsy()
})
test('optional dependency has bigger priority than regular dependency', async () => {
@@ -490,7 +490,7 @@ test('skip optional dependency that does not support the current OS, when doing
version: '1.0.0',
optionalDependencies: {
'not-compatible-with-any-os': '*',
'@pnpm.e2e/not-compatible-with-any-os': '*',
},
},
mutation: 'install',
@@ -503,7 +503,7 @@ test('skip optional dependency that does not support the current OS, when doing
version: '1.0.0',
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
mutation: 'install',
@@ -534,21 +534,21 @@ test('skip optional dependency that does not support the current OS, when doing
const modulesInfo = await readYamlFile<{skipped: string[]}>(path.join('node_modules', '.modules.yaml'))
expect(modulesInfo.skipped).toStrictEqual([
'/dep-of-optional-pkg/1.0.0',
'/not-compatible-with-any-os/1.0.0',
'/@pnpm.e2e/dep-of-optional-pkg/1.0.0',
'/@pnpm.e2e/not-compatible-with-any-os/1.0.0',
])
})
test('do not fail on unsupported dependency of optional dependency', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['not-compatible-with-not-compatible-dep@1.0.0'],
await addDependenciesToPackage({}, ['@pnpm.e2e/not-compatible-with-not-compatible-dep@1.0.0'],
await testDefaults({ targetDependenciesField: 'optionalDependencies' }, {}, {}, { engineStrict: true })
)
const lockfile = await project.readLockfile()
expect(lockfile.packages['/not-compatible-with-any-os/1.0.0'].optional).toBeTruthy()
expect(lockfile.packages['/dep-of-optional-pkg/1.0.0']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/not-compatible-with-any-os/1.0.0'].optional).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/dep-of-optional-pkg/1.0.0']).toBeTruthy()
})
test('fail on unsupported dependency of optional dependency', async () => {
@@ -556,7 +556,7 @@ test('fail on unsupported dependency of optional dependency', async () => {
await expect(
addDependenciesToPackage(
{},
['has-not-compatible-dep@1.0.0'],
['@pnpm.e2e/has-not-compatible-dep@1.0.0'],
await testDefaults({ targetDependenciesField: 'optionalDependencies' }, {}, {}, { engineStrict: true })
)
).rejects.toThrow()
+35 -35
View File
@@ -9,29 +9,29 @@ import {
test('versions are replaced with versions specified through overrides option', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
const overrides = {
'foobarqar>foo': 'npm:qar@100.0.0',
'bar@^100.0.0': '100.1.0',
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/foobarqar>@pnpm.e2e/foo': 'npm:@pnpm.e2e/qar@100.0.0',
'@pnpm.e2e/bar@^100.0.0': '100.1.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
}
const manifest = await addDependenciesToPackage({},
['pkg-with-1-dep@100.0.0', 'foobar@100.0.0', 'foobarqar@1.0.0'],
['@pnpm.e2e/pkg-with-1-dep@100.0.0', '@pnpm.e2e/foobar@100.0.0', '@pnpm.e2e/foobarqar@1.0.0'],
await testDefaults({ overrides })
)
{
const lockfile = await project.readLockfile()
expect(lockfile.packages['/foobarqar/1.0.0'].dependencies?.['foo']).toBe('/qar/100.0.0')
expect(lockfile.packages['/foobar/100.0.0'].dependencies?.['foo']).toBe('100.0.0')
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/101.0.0'])
expect(lockfile.packages).toHaveProperty(['/bar/100.1.0'])
expect(lockfile.packages['/@pnpm.e2e/foobarqar/1.0.0'].dependencies?.['@pnpm.e2e/foo']).toBe('/@pnpm.e2e/qar/100.0.0')
expect(lockfile.packages['/@pnpm.e2e/foobar/100.0.0'].dependencies?.['@pnpm.e2e/foo']).toBe('100.0.0')
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/101.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/bar/100.1.0'])
expect(lockfile.overrides).toStrictEqual({
'foobarqar>foo': 'npm:qar@100.0.0',
'bar@^100.0.0': '100.1.0',
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/foobarqar>@pnpm.e2e/foo': 'npm:@pnpm.e2e/qar@100.0.0',
'@pnpm.e2e/bar@^100.0.0': '100.1.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
})
const currentLockfile = await project.readCurrentLockfile()
expect(lockfile.overrides).toStrictEqual(currentLockfile.overrides)
@@ -47,9 +47,9 @@ test('versions are replaced with versions specified through overrides option', a
], { ...await testDefaults(), ignorePackageManifest: true, overrides })
// The lockfile is updated if the overrides are changed
overrides['bar@^100.0.0'] = '100.0.0'
overrides['@pnpm.e2e/bar@^100.0.0'] = '100.0.0'
// A direct dependency may be overriden as well
overrides['foobarqar'] = '1.0.1'
overrides['@pnpm.e2e/foobarqar'] = '1.0.1'
await mutateModules([
{
buildIndex: 0,
@@ -61,14 +61,14 @@ test('versions are replaced with versions specified through overrides option', a
{
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/101.0.0'])
expect(lockfile.packages).toHaveProperty(['/bar/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/foobarqar/1.0.1'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/101.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/bar/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/foobarqar/1.0.1'])
expect(lockfile.overrides).toStrictEqual({
foobarqar: '1.0.1',
'foobarqar>foo': 'npm:qar@100.0.0',
'bar@^100.0.0': '100.0.0',
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/foobarqar': '1.0.1',
'@pnpm.e2e/foobarqar>@pnpm.e2e/foo': 'npm:@pnpm.e2e/qar@100.0.0',
'@pnpm.e2e/bar@^100.0.0': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
})
const currentLockfile = await project.readCurrentLockfile()
expect(lockfile.overrides).toStrictEqual(currentLockfile.overrides)
@@ -86,16 +86,16 @@ test('versions are replaced with versions specified through overrides option', a
{
const lockfile = await project.readLockfile()
expect(lockfile.overrides).toStrictEqual({
foobarqar: '1.0.1',
'foobarqar>foo': 'npm:qar@100.0.0',
'bar@^100.0.0': '100.0.0',
'dep-of-pkg-with-1-dep': '101.0.0',
'@pnpm.e2e/foobarqar': '1.0.1',
'@pnpm.e2e/foobarqar>@pnpm.e2e/foo': 'npm:@pnpm.e2e/qar@100.0.0',
'@pnpm.e2e/bar@^100.0.0': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '101.0.0',
})
const currentLockfile = await project.readCurrentLockfile()
expect(lockfile.overrides).toStrictEqual(currentLockfile.overrides)
}
overrides['bar@^100.0.0'] = '100.0.1'
overrides['@pnpm.e2e/bar@^100.0.0'] = '100.0.1'
await expect(
mutateModules([
{
@@ -115,32 +115,32 @@ test('versions are replaced with versions specified through overrides option', a
test('when adding a new dependency that is present in the overrides, use the spec from the override', async () => {
prepareEmpty()
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
const overrides = {
bar: '100.1.0',
'@pnpm.e2e/bar': '100.1.0',
}
const manifest = await addDependenciesToPackage({},
['bar'],
['@pnpm.e2e/bar'],
await testDefaults({ overrides })
)
expect(manifest.dependencies?.bar).toBe(overrides.bar)
expect(manifest.dependencies?.['@pnpm.e2e/bar']).toBe(overrides['@pnpm.e2e/bar'])
})
test('explicitly specifying a version at install will ignore overrides', async () => {
prepareEmpty()
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
const overrides = {
bar: '100.1.0',
'@pnpm.e2e/bar': '100.1.0',
}
const EXACT_VERSION = '100.0.0'
const manifest = await addDependenciesToPackage({},
[`bar@${EXACT_VERSION}`],
[`@pnpm.e2e/bar@${EXACT_VERSION}`],
await testDefaults({ overrides })
)
expect(manifest.dependencies?.bar).toBe(EXACT_VERSION)
expect(manifest.dependencies?.['@pnpm.e2e/bar']).toBe(EXACT_VERSION)
})
+10 -10
View File
@@ -12,7 +12,7 @@ test('manifests are extended with fields specified by packageExtensions', async
const packageExtensions = {
'is-positive': {
dependencies: {
bar: '100.1.0',
'@pnpm.e2e/bar': '100.1.0',
},
},
}
@@ -24,11 +24,11 @@ test('manifests are extended with fields specified by packageExtensions', async
{
const lockfile = await project.readLockfile()
expect(lockfile.packages['/is-positive/1.0.0'].dependencies?.['bar']).toBe('100.1.0')
expect(lockfile.packages['/is-positive/1.0.0'].dependencies?.['@pnpm.e2e/bar']).toBe('100.1.0')
expect(lockfile.packageExtensionsChecksum).toStrictEqual(createObjectChecksum({
'is-positive': {
dependencies: {
bar: '100.1.0',
'@pnpm.e2e/bar': '100.1.0',
},
},
}))
@@ -37,7 +37,7 @@ test('manifests are extended with fields specified by packageExtensions', async
}
// The lockfile is updated if the overrides are changed
packageExtensions['is-positive'].dependencies!['foobar'] = '100.0.0'
packageExtensions['is-positive'].dependencies!['@pnpm.e2e/foobar'] = '100.0.0'
await mutateModules([
{
buildIndex: 0,
@@ -49,12 +49,12 @@ test('manifests are extended with fields specified by packageExtensions', async
{
const lockfile = await project.readLockfile()
expect(lockfile.packages['/is-positive/1.0.0'].dependencies?.['foobar']).toBe('100.0.0')
expect(lockfile.packages['/is-positive/1.0.0'].dependencies?.['@pnpm.e2e/foobar']).toBe('100.0.0')
expect(lockfile.packageExtensionsChecksum).toStrictEqual(createObjectChecksum({
'is-positive': {
dependencies: {
bar: '100.1.0',
foobar: '100.0.0',
'@pnpm.e2e/bar': '100.1.0',
'@pnpm.e2e/foobar': '100.0.0',
},
},
}))
@@ -76,8 +76,8 @@ test('manifests are extended with fields specified by packageExtensions', async
expect(lockfile.packageExtensionsChecksum).toStrictEqual(createObjectChecksum({
'is-positive': {
dependencies: {
bar: '100.1.0',
foobar: '100.0.0',
'@pnpm.e2e/bar': '100.1.0',
'@pnpm.e2e/foobar': '100.0.0',
},
},
}))
@@ -85,7 +85,7 @@ test('manifests are extended with fields specified by packageExtensions', async
expect(lockfile.packageExtensionsChecksum).toStrictEqual(currentLockfile.packageExtensionsChecksum)
}
packageExtensions['is-positive'].dependencies!['bar'] = '100.0.1'
packageExtensions['is-positive'].dependencies!['@pnpm.e2e/bar'] = '100.0.1'
await expect(
mutateModules([
{
+173 -170
View File
@@ -17,22 +17,23 @@ import rimraf from '@zkochan/rimraf'
import exists from 'path-exists'
import sinon from 'sinon'
import deepRequireCwd from 'deep-require-cwd'
import { createPeersFolderSuffix } from 'dependency-path'
import { testDefaults } from '../utils'
const f = fixtures(__dirname)
test("don't fail when peer dependency is fetched from GitHub", async () => {
prepareEmpty()
await addDependenciesToPackage({}, ['test-pnpm-peer-deps'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/test-pnpm-peer-deps'], await testDefaults())
})
test('peer dependency is grouped with dependency when peer is resolved not from a top dependency', async () => {
const project = prepareEmpty()
const opts = await testDefaults()
let manifest = await addDependenciesToPackage({}, ['using-ajv'], opts)
let manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/using-ajv'], opts)
expect(await exists(path.resolve('node_modules/.pnpm/ajv-keywords@1.5.0_ajv@4.10.4/node_modules/ajv'))).toBeTruthy()
expect(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version).toBe('4.10.4')
expect(deepRequireCwd(['@pnpm.e2e/using-ajv', 'ajv-keywords', 'ajv', './package.json']).version).toBe('4.10.4')
// testing that peers are reinstalled correctly using info from the lockfile
await rimraf('node_modules')
@@ -40,13 +41,13 @@ test('peer dependency is grouped with dependency when peer is resolved not from
manifest = await install(manifest, await testDefaults())
expect(await exists(path.resolve('node_modules/.pnpm/ajv-keywords@1.5.0_ajv@4.10.4/node_modules/ajv'))).toBeTruthy()
expect(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version).toBe('4.10.4')
expect(deepRequireCwd(['@pnpm.e2e/using-ajv', 'ajv-keywords', 'ajv', './package.json']).version).toBe('4.10.4')
await addDependenciesToPackage(manifest, ['using-ajv'], await testDefaults({ update: true }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/using-ajv'], await testDefaults({ update: true }))
const lockfile = await project.readLockfile()
expect(lockfile.packages['/using-ajv/1.0.0'].dependencies!['ajv-keywords']).toBe('1.5.0_ajv@4.10.4')
expect(lockfile.packages['/@pnpm.e2e/using-ajv/1.0.0'].dependencies!['ajv-keywords']).toBe('1.5.0_ajv@4.10.4')
// covers https://github.com/pnpm/pnpm/issues/1150
expect(lockfile.packages).toHaveProperty(['/ajv-keywords/1.5.0_ajv@4.10.4'])
})
@@ -58,11 +59,11 @@ test('nothing is needlessly removed from node_modules', async () => {
modulesCacheMaxAge: 0,
strictPeerDependencies: false,
})
const manifest = await addDependenciesToPackage({}, ['using-ajv', 'ajv-keywords@1.5.0'], opts)
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/using-ajv', 'ajv-keywords@1.5.0'], opts)
expect(await exists(path.resolve('node_modules/.pnpm/ajv-keywords@1.5.0_ajv@4.10.4/node_modules/ajv'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/ajv-keywords@1.5.0/node_modules/ajv-keywords'))).toBeTruthy()
expect(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version).toBe('4.10.4')
expect(deepRequireCwd(['@pnpm.e2e/using-ajv', 'ajv-keywords', 'ajv', './package.json']).version).toBe('4.10.4')
await mutateModules([
{
@@ -230,11 +231,11 @@ test('strict-peer-dependencies: error is thrown when cannot resolve peer depende
test('warning is reported when cannot resolve peer dependency for non-top-level dependency', async () => {
prepareEmpty()
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
const reporter = jest.fn()
await addDependenciesToPackage({}, ['abc-grand-parent-without-c'], await testDefaults({ reporter, strictPeerDependencies: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent-without-c'], await testDefaults({ reporter, strictPeerDependencies: false }))
expect(reporter).toHaveBeenCalledWith(
expect.objectContaining({
@@ -244,19 +245,19 @@ test('warning is reported when cannot resolve peer dependency for non-top-level
'.': {
bad: {},
missing: {
'peer-c': [
'@pnpm.e2e/peer-c': [
{
parents: [
{
name: 'abc-grand-parent-without-c',
name: '@pnpm.e2e/abc-grand-parent-without-c',
version: '1.0.0',
},
{
name: 'abc-parent-with-ab',
name: '@pnpm.e2e/abc-parent-with-ab',
version: '1.0.0',
},
{
name: 'abc',
name: '@pnpm.e2e/abc',
version: '1.0.0',
},
],
@@ -266,7 +267,7 @@ test('warning is reported when cannot resolve peer dependency for non-top-level
],
},
conflicts: [],
intersections: { 'peer-c': '^1.0.0' },
intersections: { '@pnpm.e2e/peer-c': '^1.0.0' },
},
},
})
@@ -274,12 +275,12 @@ test('warning is reported when cannot resolve peer dependency for non-top-level
})
test('warning is reported when bad version of resolved peer dependency for non-top-level dependency', async () => {
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
prepareEmpty()
const reporter = jest.fn()
await addDependenciesToPackage({}, ['abc-grand-parent-without-c', 'peer-c@2'], await testDefaults({ reporter, strictPeerDependencies: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent-without-c', '@pnpm.e2e/peer-c@2'], await testDefaults({ reporter, strictPeerDependencies: false }))
expect(reporter).toHaveBeenCalledWith(
expect.objectContaining({
@@ -288,19 +289,19 @@ test('warning is reported when bad version of resolved peer dependency for non-t
issuesByProjects: {
'.': {
bad: {
'peer-c': [
'@pnpm.e2e/peer-c': [
{
parents: [
{
name: 'abc-grand-parent-without-c',
name: '@pnpm.e2e/abc-grand-parent-without-c',
version: '1.0.0',
},
{
name: 'abc-parent-with-ab',
name: '@pnpm.e2e/abc-parent-with-ab',
version: '1.0.0',
},
{
name: 'abc',
name: '@pnpm.e2e/abc',
version: '1.0.0',
},
],
@@ -321,15 +322,15 @@ test('warning is reported when bad version of resolved peer dependency for non-t
})
test('strict-peer-dependencies: error is thrown when bad version of resolved peer dependency for non-top-level dependency', async () => {
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
prepareEmpty()
let err!: PeerDependencyIssuesError
try {
await install({
dependencies: {
'abc-grand-parent-without-c': '1.0.0',
'peer-c': '2',
'@pnpm.e2e/abc-grand-parent-without-c': '1.0.0',
'@pnpm.e2e/peer-c': '2',
},
}, await testDefaults({ strictPeerDependencies: true }))
} catch (_err: any) { // eslint-disable-line
@@ -338,19 +339,19 @@ test('strict-peer-dependencies: error is thrown when bad version of resolved pee
expect(err?.issuesByProjects['.']).toStrictEqual({
bad: {
'peer-c': [
'@pnpm.e2e/peer-c': [
{
parents: [
{
name: 'abc-grand-parent-without-c',
name: '@pnpm.e2e/abc-grand-parent-without-c',
version: '1.0.0',
},
{
name: 'abc-parent-with-ab',
name: '@pnpm.e2e/abc-parent-with-ab',
version: '1.0.0',
},
{
name: 'abc',
name: '@pnpm.e2e/abc',
version: '1.0.0',
},
],
@@ -370,36 +371,36 @@ test('strict-peer-dependencies: error is thrown when bad version of resolved pee
test('top peer dependency is linked on subsequent install', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['peer-c@1.0.0'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/peer-c@1.0.0'], await testDefaults())
await addDependenciesToPackage(manifest, ['abc-parent-with-ab@1.0.0'], await testDefaults())
await addDependenciesToPackage(manifest, ['@pnpm.e2e/abc-parent-with-ab@1.0.0'], await testDefaults())
expect(await exists(path.resolve('node_modules/.pnpm/abc-parent-with-ab@1.0.0/node_modules/abc-parent-with-ab'))).toBeFalsy()
expect(await exists(path.resolve('node_modules/.pnpm/abc-parent-with-ab@1.0.0_peer-c@1.0.0/node_modules/abc-parent-with-ab'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-parent-with-ab@1.0.0/node_modules/@pnpm.e2e/abc-parent-with-ab'))).toBeFalsy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-parent-with-ab@1.0.0_@pnpm.e2e+peer-c@1.0.0/node_modules/@pnpm.e2e/abc-parent-with-ab'))).toBeTruthy()
})
test('top peer dependency is linked on subsequent install, through transitive peer', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent@1.0.0'], await testDefaults({ strictPeerDependencies: false }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent@1.0.0'], await testDefaults({ strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['peer-c@1.0.0'], await testDefaults({ strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/peer-c@1.0.0'], await testDefaults({ strictPeerDependencies: false }))
expect(await exists(path.resolve('node_modules/.pnpm/abc-grand-parent@1.0.0_peer-c@1.0.0/node_modules/abc-grand-parent'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-grand-parent@1.0.0_@pnpm.e2e+peer-c@1.0.0/node_modules/@pnpm.e2e/abc-grand-parent'))).toBeTruthy()
})
test('the list of transitive peer dependencies is kept up to date', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent@1.0.0', 'peer-c@1.0.0'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent@1.0.0', '@pnpm.e2e/peer-c@1.0.0'], await testDefaults())
await addDistTag({ package: 'abc-parent-with-ab', version: '1.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.1.0', distTag: 'latest' })
expect(await exists(path.resolve('node_modules/.pnpm/abc-grand-parent@1.0.0_peer-c@1.0.0/node_modules/abc-grand-parent'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-grand-parent@1.0.0_@pnpm.e2e+peer-c@1.0.0/node_modules/@pnpm.e2e/abc-grand-parent'))).toBeTruthy()
{
const lockfile = await project.readLockfile()
expect(lockfile.packages['/abc-grand-parent/1.0.0_peer-c@1.0.0'].transitivePeerDependencies).toStrictEqual(['peer-c'])
expect(lockfile.packages['/@pnpm.e2e/abc-grand-parent/1.0.0_@pnpm.e2e+peer-c@1.0.0'].transitivePeerDependencies).toStrictEqual(['@pnpm.e2e/peer-c'])
}
await mutateModules([
@@ -411,24 +412,24 @@ test('the list of transitive peer dependencies is kept up to date', async () =>
},
], await testDefaults({ update: true, depth: Infinity }))
expect(await exists(path.resolve('node_modules/.pnpm/abc-grand-parent@1.0.0/node_modules/abc-grand-parent'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-grand-parent@1.0.0/node_modules/@pnpm.e2e/abc-grand-parent'))).toBeTruthy()
{
const lockfile = await project.readLockfile()
expect(lockfile.packages['/abc-grand-parent/1.0.0'].transitivePeerDependencies).toBeFalsy()
expect(lockfile.packages['/@pnpm.e2e/abc-grand-parent/1.0.0'].transitivePeerDependencies).toBeFalsy()
}
})
test('top peer dependency is linked on subsequent install. Reverse order', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['abc-parent-with-ab@1.0.0'], await testDefaults({ strictPeerDependencies: false }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/abc-parent-with-ab@1.0.0'], await testDefaults({ strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['peer-c@1.0.0'], await testDefaults({ modulesCacheMaxAge: 0, strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/peer-c@1.0.0'], await testDefaults({ modulesCacheMaxAge: 0, strictPeerDependencies: false }))
expect(await exists(path.resolve('node_modules/.pnpm/abc-parent-with-ab@1.0.0/node_modules/abc-parent-with-ab'))).toBeFalsy()
expect(await exists(path.resolve('node_modules/.pnpm/abc-parent-with-ab@1.0.0_peer-c@1.0.0/node_modules/abc-parent-with-ab'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/abc-parent-with-ab@1.0.0_peer-c@1.0.0/node_modules/is-positive'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-parent-with-ab@1.0.0/node_modules/@pnpm.e2e/abc-parent-with-ab'))).toBeFalsy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-parent-with-ab@1.0.0_@pnpm.e2e+peer-c@1.0.0/node_modules/@pnpm.e2e/abc-parent-with-ab'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/@pnpm.e2e+abc-parent-with-ab@1.0.0_@pnpm.e2e+peer-c@1.0.0/node_modules/is-positive'))).toBeTruthy()
})
async function okFile (filename: string) {
@@ -437,103 +438,103 @@ async function okFile (filename: string) {
// This usecase was failing. See https://github.com/pnpm/supi/issues/15
test('peer dependencies are linked when running one named installation', async () => {
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: 'peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' })
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c', 'abc-parent-with-ab', 'peer-c@2.0.0'], await testDefaults({ strictPeerDependencies: false }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent-with-c', '@pnpm.e2e/abc-parent-with-ab', '@pnpm.e2e/peer-c@2.0.0'], await testDefaults({ strictPeerDependencies: false }))
const pkgVariationsDir = path.resolve('node_modules/.pnpm/abc@1.0.0')
const pkgVariationsDir = path.resolve('node_modules/.pnpm/@pnpm.e2e+abc@1.0.0')
const pkgVariation1 = path.join(pkgVariationsDir + '_6ea473aweg4rki46lsbci3nehq/node_modules')
await okFile(path.join(pkgVariation1, 'abc'))
await okFile(path.join(pkgVariation1, 'peer-a'))
await okFile(path.join(pkgVariation1, 'peer-b'))
await okFile(path.join(pkgVariation1, 'peer-c'))
await okFile(path.join(pkgVariation1, 'dep-of-pkg-with-1-dep'))
const pkgVariation1 = path.join(pkgVariationsDir + createPeersFolderSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.0' }]), 'node_modules')
await okFile(path.join(pkgVariation1, '@pnpm.e2e/abc'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-a'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-b'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-c'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/dep-of-pkg-with-1-dep'))
const pkgVariation2 = path.join(pkgVariationsDir + '_czpb4cfd67t7o7o3k4vnbzkwma/node_modules')
await okFile(path.join(pkgVariation2, 'abc'))
await okFile(path.join(pkgVariation2, 'peer-a'))
await okFile(path.join(pkgVariation2, 'peer-b'))
await okFile(path.join(pkgVariation2, 'peer-c'))
await okFile(path.join(pkgVariation2, 'dep-of-pkg-with-1-dep'))
const pkgVariation2 = path.join(pkgVariationsDir + createPeersFolderSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.0' }]), 'node_modules')
await okFile(path.join(pkgVariation2, '@pnpm.e2e/abc'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/peer-a'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/peer-b'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/peer-c'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/dep-of-pkg-with-1-dep'))
expect(deepRequireCwd(['abc-parent-with-ab', 'abc', 'peer-c', './package.json']).version).toBe('2.0.0')
expect(deepRequireCwd(['abc-grand-parent-with-c', 'abc-parent-with-ab', 'abc', 'peer-c', './package.json']).version).toBe('1.0.0')
expect(deepRequireCwd(['@pnpm.e2e/abc-parent-with-ab', '@pnpm.e2e/abc', '@pnpm.e2e/peer-c', './package.json']).version).toBe('2.0.0')
expect(deepRequireCwd(['@pnpm.e2e/abc-grand-parent-with-c', '@pnpm.e2e/abc-parent-with-ab', '@pnpm.e2e/abc', '@pnpm.e2e/peer-c', './package.json']).version).toBe('1.0.0')
// this part was failing. See issue: https://github.com/pnpm/pnpm/issues/1201
await addDistTag({ package: 'peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' })
await install(manifest, await testDefaults({ update: true, depth: 100, strictPeerDependencies: false }))
})
test('peer dependencies are linked when running two separate named installations', async () => {
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: 'peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' })
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c', 'peer-c@2.0.0'], await testDefaults({ strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['abc-parent-with-ab'], await testDefaults({ strictPeerDependencies: false }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent-with-c', '@pnpm.e2e/peer-c@2.0.0'], await testDefaults({ strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/abc-parent-with-ab'], await testDefaults({ strictPeerDependencies: false }))
const pkgVariationsDir = path.resolve('node_modules/.pnpm/abc@1.0.0')
const pkgVariationsDir = path.resolve('node_modules/.pnpm/@pnpm.e2e+abc@1.0.0')
const pkgVariation1 = path.join(pkgVariationsDir + '_6ea473aweg4rki46lsbci3nehq/node_modules')
await okFile(path.join(pkgVariation1, 'abc'))
await okFile(path.join(pkgVariation1, 'peer-a'))
await okFile(path.join(pkgVariation1, 'peer-b'))
await okFile(path.join(pkgVariation1, 'peer-c'))
await okFile(path.join(pkgVariation1, 'dep-of-pkg-with-1-dep'))
const pkgVariation1 = path.join(pkgVariationsDir + createPeersFolderSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '1.0.0' }]), 'node_modules')
await okFile(path.join(pkgVariation1, '@pnpm.e2e/abc'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-a'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-b'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-c'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/dep-of-pkg-with-1-dep'))
const pkgVariation2 = path.join(pkgVariationsDir + '_6ea473aweg4rki46lsbci3nehq/node_modules')
await okFile(path.join(pkgVariation2, 'abc'))
await okFile(path.join(pkgVariation2, 'peer-a'))
await okFile(path.join(pkgVariation2, 'peer-b'))
await okFile(path.join(pkgVariation2, 'dep-of-pkg-with-1-dep'))
const pkgVariation2 = path.join(pkgVariationsDir + createPeersFolderSuffix([{ name: '@pnpm.e2e/peer-a', version: '1.0.0' }, { name: '@pnpm.e2e/peer-b', version: '1.0.0' }, { name: '@pnpm.e2e/peer-c', version: '2.0.0' }]), 'node_modules')
await okFile(path.join(pkgVariation2, '@pnpm.e2e/abc'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/peer-a'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/peer-b'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/dep-of-pkg-with-1-dep'))
expect(deepRequireCwd(['abc-parent-with-ab', 'abc', 'peer-c', './package.json']).version).toBe('2.0.0')
expect(deepRequireCwd(['abc-grand-parent-with-c', 'abc-parent-with-ab', 'abc', 'peer-c', './package.json']).version).toBe('1.0.0')
expect(deepRequireCwd(['@pnpm.e2e/abc-parent-with-ab', '@pnpm.e2e/abc', '@pnpm.e2e/peer-c', './package.json']).version).toBe('2.0.0')
expect(deepRequireCwd(['@pnpm.e2e/abc-grand-parent-with-c', '@pnpm.e2e/abc-parent-with-ab', '@pnpm.e2e/abc', '@pnpm.e2e/peer-c', './package.json']).version).toBe('1.0.0')
})
test.skip('peer dependencies are linked', async () => {
const project = prepareEmpty()
await install({
dependencies: {
'abc-grand-parent-with-c': '*',
'peer-c': '2.0.0',
'@pnpm.e2e/abc-grand-parent-with-c': '*',
'@pnpm.e2e/peer-c': '2.0.0',
},
devDependencies: {
'abc-parent-with-ab': '*',
'@pnpm.e2e/abc-parent-with-ab': '*',
},
}, await testDefaults())
const pkgVariationsDir = path.resolve('node_modules/.pnpm/abc@1.0.0')
const pkgVariation1 = path.join(pkgVariationsDir, '165e1e08a3f7e7f77ddb572ad0e55660/node_modules')
await okFile(path.join(pkgVariation1, 'abc'))
await okFile(path.join(pkgVariation1, 'peer-a'))
await okFile(path.join(pkgVariation1, 'peer-b'))
await okFile(path.join(pkgVariation1, 'peer-c'))
await okFile(path.join(pkgVariation1, 'dep-of-pkg-with-1-dep'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/abc'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-a'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-b'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/peer-c'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/dep-of-pkg-with-1-dep'))
const pkgVariation2 = path.join(pkgVariationsDir, 'peer-a@1.0.0+peer-b@1.0.0/node_modules')
await okFile(path.join(pkgVariation2, 'abc'))
await okFile(path.join(pkgVariation2, 'peer-a'))
await okFile(path.join(pkgVariation2, 'peer-b'))
await okFile(path.join(pkgVariation2, 'dep-of-pkg-with-1-dep'))
const pkgVariation2 = path.join(pkgVariationsDir, '@pnpm.e2e+peer-a@1.0.0+@pnpm.e2e+peer-b@1.0.0/node_modules')
await okFile(path.join(pkgVariation2, '@pnpm.e2e/abc'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/peer-a'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/peer-b'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/dep-of-pkg-with-1-dep'))
expect(deepRequireCwd(['abc-parent-with-ab', 'abc', 'peer-c', './package.json']).version).toBe('2.0.0')
expect(deepRequireCwd(['abc-grand-parent-with-c', 'abc-parent-with-ab', 'abc', 'peer-c', './package.json']).version).toBe('1.0.0')
expect(deepRequireCwd(['@pnpm.e2e/abc-parent-with-ab', '@pnpm.e2e/abc', '@pnpm.e2e/peer-c', './package.json']).version).toBe('2.0.0')
expect(deepRequireCwd(['@pnpm.e2e/abc-grand-parent-with-c', '@pnpm.e2e/abc-parent-with-ab', '@pnpm.e2e/abc', '@pnpm.e2e/peer-c', './package.json']).version).toBe('1.0.0')
const lockfile = await project.readLockfile()
expect(lockfile.packages['/abc-parent-with-ab/1.0.0/peer-a@1.0.0+peer-b@1.0.0'].dev).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/abc-parent-with-ab/1.0.0/@pnpm.e2e/peer-a@1.0.0+@pnpm.e2e+peer-b@1.0.0'].dev).toBeTruthy()
})
test('scoped peer dependency is linked', async () => {
prepareEmpty()
await addDependenciesToPackage({}, ['for-testing-scoped-peers'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/for-testing-scoped-peers'], await testDefaults())
const pkgVariation = path.resolve('node_modules/.pnpm/@having+scoped-peer@1.0.0_@scoped+peer@1.0.0/node_modules')
await okFile(path.join(pkgVariation, '@having', 'scoped-peer'))
@@ -543,43 +544,44 @@ test('scoped peer dependency is linked', async () => {
test('peer bins are linked', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['for-testing-peers-having-bins'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/for-testing-peers-having-bins'], await testDefaults({ fastUnpack: false }))
const pkgVariation = path.join('.pnpm/pkg-with-peer-having-bin@1.0.0_peer-with-bin@1.0.0/node_modules')
const suffix = createPeersFolderSuffix([{ name: '@pnpm.e2e/peer-with-bin', version: '1.0.0' }])
const pkgVariation = path.join(`.pnpm/@pnpm.e2e+pkg-with-peer-having-bin@1.0.0${suffix}/node_modules`)
await project.isExecutable(path.join(pkgVariation, 'pkg-with-peer-having-bin/node_modules/.bin', 'peer-with-bin'))
await project.isExecutable(path.join(pkgVariation, '@pnpm.e2e/pkg-with-peer-having-bin/node_modules/.bin', 'peer-with-bin'))
await project.isExecutable(path.join(pkgVariation, 'pkg-with-peer-having-bin/node_modules/.bin', 'hello-world-js-bin'))
await project.isExecutable(path.join(pkgVariation, '@pnpm.e2e/pkg-with-peer-having-bin/node_modules/.bin', 'hello-world-js-bin'))
})
test('run pre/postinstall scripts of each variations of packages with peer dependencies', async () => {
await addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' })
prepareEmpty()
await addDependenciesToPackage({}, ['parent-of-pkg-with-events-and-peers', 'pkg-with-events-and-peers', 'peer-c@2.0.0'], await testDefaults({ fastUnpack: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/parent-of-pkg-with-events-and-peers', '@pnpm.e2e/pkg-with-events-and-peers', '@pnpm.e2e/peer-c@2.0.0'], await testDefaults({ fastUnpack: false }))
const pkgVariation1 = path.resolve('node_modules/.pnpm/pkg-with-events-and-peers@1.0.0_peer-c@1.0.0/node_modules')
await okFile(path.join(pkgVariation1, 'pkg-with-events-and-peers', 'generated-by-preinstall.js'))
await okFile(path.join(pkgVariation1, 'pkg-with-events-and-peers', 'generated-by-postinstall.js'))
const pkgVariation1 = path.resolve('node_modules/.pnpm/@pnpm.e2e+pkg-with-events-and-peers@1.0.0_@pnpm.e2e+peer-c@1.0.0/node_modules')
await okFile(path.join(pkgVariation1, '@pnpm.e2e/pkg-with-events-and-peers', 'generated-by-preinstall.js'))
await okFile(path.join(pkgVariation1, '@pnpm.e2e/pkg-with-events-and-peers', 'generated-by-postinstall.js'))
const pkgVariation2 = path.resolve('node_modules/.pnpm/pkg-with-events-and-peers@1.0.0_peer-c@2.0.0/node_modules')
await okFile(path.join(pkgVariation2, 'pkg-with-events-and-peers', 'generated-by-preinstall.js'))
await okFile(path.join(pkgVariation2, 'pkg-with-events-and-peers', 'generated-by-postinstall.js'))
const pkgVariation2 = path.resolve('node_modules/.pnpm/@pnpm.e2e+pkg-with-events-and-peers@1.0.0_@pnpm.e2e+peer-c@2.0.0/node_modules')
await okFile(path.join(pkgVariation2, '@pnpm.e2e/pkg-with-events-and-peers', 'generated-by-preinstall.js'))
await okFile(path.join(pkgVariation2, '@pnpm.e2e/pkg-with-events-and-peers', 'generated-by-postinstall.js'))
})
test('package that has parent as peer dependency', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['has-alpha', 'alpha'], await testDefaults())
await addDependenciesToPackage({}, ['@pnpm.e2e/has-alpha', '@pnpm.e2e/alpha'], await testDefaults())
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/has-alpha-as-peer/1.0.0_alpha@1.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/has-alpha-as-peer/1.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/has-alpha-as-peer/1.0.0_@pnpm.e2e+alpha@1.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/has-alpha-as-peer/1.0.0'])
})
test('own peer installed in root as well is linked to root', async () => {
prepareEmpty()
await addDependenciesToPackage({}, ['is-negative@kevva/is-negative#2.1.0', 'peer-deps-in-child-pkg'], await testDefaults())
await addDependenciesToPackage({}, ['is-negative@kevva/is-negative#2.1.0', '@pnpm.e2e/peer-deps-in-child-pkg'], await testDefaults())
expect(deepRequireCwd.silent(['is-negative', './package.json'])).toBeTruthy()
})
@@ -620,12 +622,12 @@ test('peer dependency is grouped correctly with peer installed via separate inst
const manifest = await install({
dependencies: {
abc: '1.0.0',
'@pnpm.e2e/abc': '1.0.0',
},
}, await testDefaults({ reporter, lockfileDir, strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['peer-c@2.0.0'], await testDefaults({ reporter, lockfileDir, strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/peer-c@2.0.0'], await testDefaults({ reporter, lockfileDir, strictPeerDependencies: false }))
expect(await exists(path.join('../node_modules/.pnpm/abc@1.0.0_peer-c@2.0.0/node_modules/dep-of-pkg-with-1-dep'))).toBeTruthy()
expect(await exists(path.join('../node_modules/.pnpm/@pnpm.e2e+abc@1.0.0_@pnpm.e2e+peer-c@2.0.0/node_modules/@pnpm.e2e/dep-of-pkg-with-1-dep'))).toBeTruthy()
})
test('peer dependency is grouped with dependent when the peer is a top dependency and external node_modules is used', async () => {
@@ -740,39 +742,39 @@ test('external lockfile: peer dependency is grouped with dependent even after a
process.chdir('_')
const lockfileDir = path.resolve('..')
const manifest = await addDependenciesToPackage({}, ['peer-c@1.0.0', 'abc-parent-with-ab@1.0.0'], await testDefaults({ lockfileDir, strictPeerDependencies: false }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/peer-c@1.0.0', '@pnpm.e2e/abc-parent-with-ab@1.0.0'], await testDefaults({ lockfileDir, strictPeerDependencies: false }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
expect(lockfile.importers._).toStrictEqual({
dependencies: {
'abc-parent-with-ab': '1.0.0_peer-c@1.0.0',
'peer-c': '1.0.0',
'@pnpm.e2e/abc-parent-with-ab': '1.0.0_@pnpm.e2e+peer-c@1.0.0',
'@pnpm.e2e/peer-c': '1.0.0',
},
specifiers: {
'abc-parent-with-ab': '1.0.0',
'peer-c': '1.0.0',
'@pnpm.e2e/abc-parent-with-ab': '1.0.0',
'@pnpm.e2e/peer-c': '1.0.0',
},
})
}
await addDependenciesToPackage(manifest, ['peer-c@2.0.0'], await testDefaults({ lockfileDir, strictPeerDependencies: false }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/peer-c@2.0.0'], await testDefaults({ lockfileDir, strictPeerDependencies: false }))
{
const lockfile = await readYamlFile<Lockfile>(path.resolve('..', WANTED_LOCKFILE))
expect(lockfile.importers._).toStrictEqual({
dependencies: {
'abc-parent-with-ab': '1.0.0_peer-c@2.0.0',
'peer-c': '2.0.0',
'@pnpm.e2e/abc-parent-with-ab': '1.0.0_@pnpm.e2e+peer-c@2.0.0',
'@pnpm.e2e/peer-c': '2.0.0',
},
specifiers: {
'abc-parent-with-ab': '1.0.0',
'peer-c': '2.0.0',
'@pnpm.e2e/abc-parent-with-ab': '1.0.0',
'@pnpm.e2e/peer-c': '2.0.0',
},
})
}
expect(await exists(path.join('../node_modules/.pnpm/abc-parent-with-ab@1.0.0_peer-c@2.0.0/node_modules/is-positive'))).toBeTruthy()
expect(await exists(path.join('../node_modules/.pnpm/@pnpm.e2e+abc-parent-with-ab@1.0.0_@pnpm.e2e+peer-c@2.0.0/node_modules/is-positive'))).toBeTruthy()
})
test('regular dependencies are not removed on update from transitive packages that have children with peers resolved from above', async () => {
@@ -780,15 +782,15 @@ test('regular dependencies are not removed on update from transitive packages th
await fs.mkdir('_')
process.chdir('_')
const lockfileDir = path.resolve('..')
await addDistTag({ package: 'abc-parent-with-ab', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c@1.0.0'], await testDefaults({ lockfileDir }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent-with-c@1.0.0'], await testDefaults({ lockfileDir }))
await addDistTag({ package: 'peer-c', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.1', distTag: 'latest' })
await install(manifest, await testDefaults({ lockfileDir, update: true, depth: 2 }))
expect(await exists(path.join('../node_modules/.pnpm/abc-parent-with-ab@1.0.1_peer-c@1.0.1/node_modules/is-positive'))).toBeTruthy()
expect(await exists(path.join('../node_modules/.pnpm/@pnpm.e2e+abc-parent-with-ab@1.0.1_@pnpm.e2e+peer-c@1.0.1/node_modules/is-positive'))).toBeTruthy()
})
test('peer dependency is resolved from parent package', async () => {
@@ -799,7 +801,7 @@ test('peer dependency is resolved from parent package', async () => {
])
await mutateModules([
{
dependencySelectors: ['tango@1.0.0'],
dependencySelectors: ['@pnpm.e2e/tango@1.0.0'],
manifest: {},
mutation: 'installSome',
rootDir: path.resolve('pkg'),
@@ -808,8 +810,8 @@ test('peer dependency is resolved from parent package', async () => {
const lockfile = await readYamlFile<Lockfile>(WANTED_LOCKFILE)
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual([
'/has-tango-as-peer-dep/1.0.0_tango@1.0.0',
'/tango/1.0.0',
'/@pnpm.e2e/has-tango-as-peer-dep/1.0.0_@pnpm.e2e+tango@1.0.0',
'/@pnpm.e2e/tango/1.0.0',
])
})
@@ -854,7 +856,7 @@ test('peer dependency is resolved from parent package via its alias', async () =
])
await mutateModules([
{
dependencySelectors: ['tango@npm:tango-tango@1.0.0'],
dependencySelectors: ['@pnpm.e2e/tango@npm:@pnpm.e2e/tango-tango@1.0.0'],
manifest: {},
mutation: 'installSome',
rootDir: path.resolve('pkg'),
@@ -862,9 +864,10 @@ test('peer dependency is resolved from parent package via its alias', async () =
], await testDefaults())
const lockfile = await readYamlFile<Lockfile>(WANTED_LOCKFILE)
const suffix = createPeersFolderSuffix([{ name: '@pnpm.e2e/tango-tango', version: '1.0.0' }])
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual([
'/has-tango-as-peer-dep/1.0.0_tango-tango@1.0.0',
'/tango-tango/1.0.0_tango-tango@1.0.0',
`/@pnpm.e2e/has-tango-as-peer-dep/1.0.0${suffix}`,
`/@pnpm.e2e/tango-tango/1.0.0${suffix}`,
])
})
@@ -909,7 +912,7 @@ test('warning is not reported when cannot resolve optional peer dependency', asy
const reporter = jest.fn()
await addDependenciesToPackage({}, ['abc-optional-peers@1.0.0', 'peer-c@2.0.0'], await testDefaults({ reporter, strictPeerDependencies: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/abc-optional-peers@1.0.0', '@pnpm.e2e/peer-c@2.0.0'], await testDefaults({ reporter, strictPeerDependencies: false }))
expect(reporter).toHaveBeenCalledWith(
expect.objectContaining({
@@ -918,10 +921,10 @@ test('warning is not reported when cannot resolve optional peer dependency', asy
issuesByProjects: {
'.': {
bad: {
'peer-c': [{
'@pnpm.e2e/peer-c': [{
parents: [
{
name: 'abc-optional-peers',
name: '@pnpm.e2e/abc-optional-peers',
version: '1.0.0',
},
],
@@ -932,11 +935,11 @@ test('warning is not reported when cannot resolve optional peer dependency', asy
}],
},
missing: {
'peer-a': [
'@pnpm.e2e/peer-a': [
{
parents: [
{
name: 'abc-optional-peers',
name: '@pnpm.e2e/abc-optional-peers',
version: '1.0.0',
},
],
@@ -944,11 +947,11 @@ test('warning is not reported when cannot resolve optional peer dependency', asy
wantedRange: '^1.0.0',
},
],
'peer-b': [
'@pnpm.e2e/peer-b': [
{
parents: [
{
name: 'abc-optional-peers',
name: '@pnpm.e2e/abc-optional-peers',
version: '1.0.0',
},
],
@@ -958,7 +961,7 @@ test('warning is not reported when cannot resolve optional peer dependency', asy
],
},
conflicts: [],
intersections: { 'peer-a': '^1.0.0' },
intersections: { '@pnpm.e2e/peer-a': '^1.0.0' },
},
},
})
@@ -966,11 +969,11 @@ test('warning is not reported when cannot resolve optional peer dependency', asy
const lockfile = await project.readLockfile()
expect(lockfile.packages['/abc-optional-peers/1.0.0_peer-c@2.0.0'].peerDependenciesMeta).toStrictEqual({
'peer-b': {
expect(lockfile.packages['/@pnpm.e2e/abc-optional-peers/1.0.0_@pnpm.e2e+peer-c@2.0.0'].peerDependenciesMeta).toStrictEqual({
'@pnpm.e2e/peer-b': {
optional: true,
},
'peer-c': {
'@pnpm.e2e/peer-c': {
optional: true,
},
})
@@ -981,7 +984,7 @@ test('warning is not reported when cannot resolve optional peer dependency (spec
const reporter = jest.fn()
await addDependenciesToPackage({}, ['abc-optional-peers-meta-only@1.0.0', 'peer-c@2.0.0'], await testDefaults({ reporter, strictPeerDependencies: false }))
await addDependenciesToPackage({}, ['@pnpm.e2e/abc-optional-peers-meta-only@1.0.0', '@pnpm.e2e/peer-c@2.0.0'], await testDefaults({ reporter, strictPeerDependencies: false }))
expect(reporter).toHaveBeenCalledWith(
expect.objectContaining({
@@ -991,11 +994,11 @@ test('warning is not reported when cannot resolve optional peer dependency (spec
'.': {
bad: {},
missing: {
'peer-a': [
'@pnpm.e2e/peer-a': [
{
parents: [
{
name: 'abc-optional-peers-meta-only',
name: '@pnpm.e2e/abc-optional-peers-meta-only',
version: '1.0.0',
},
],
@@ -1003,11 +1006,11 @@ test('warning is not reported when cannot resolve optional peer dependency (spec
wantedRange: '^1.0.0',
},
],
'peer-b': [
'@pnpm.e2e/peer-b': [
{
parents: [
{
name: 'abc-optional-peers-meta-only',
name: '@pnpm.e2e/abc-optional-peers-meta-only',
version: '1.0.0',
},
],
@@ -1017,7 +1020,7 @@ test('warning is not reported when cannot resolve optional peer dependency (spec
],
},
conflicts: [],
intersections: { 'peer-a': '^1.0.0' },
intersections: { '@pnpm.e2e/peer-a': '^1.0.0' },
},
},
})
@@ -1025,16 +1028,16 @@ test('warning is not reported when cannot resolve optional peer dependency (spec
const lockfile = await project.readLockfile()
expect(lockfile.packages['/abc-optional-peers-meta-only/1.0.0_peer-c@2.0.0'].peerDependencies).toStrictEqual({
'peer-a': '^1.0.0',
'peer-b': '*',
'peer-c': '*',
expect(lockfile.packages['/@pnpm.e2e/abc-optional-peers-meta-only/1.0.0_@pnpm.e2e+peer-c@2.0.0'].peerDependencies).toStrictEqual({
'@pnpm.e2e/peer-a': '^1.0.0',
'@pnpm.e2e/peer-b': '*',
'@pnpm.e2e/peer-c': '*',
})
expect(lockfile.packages['/abc-optional-peers-meta-only/1.0.0_peer-c@2.0.0'].peerDependenciesMeta).toStrictEqual({
'peer-b': {
expect(lockfile.packages['/@pnpm.e2e/abc-optional-peers-meta-only/1.0.0_@pnpm.e2e+peer-c@2.0.0'].peerDependenciesMeta).toStrictEqual({
'@pnpm.e2e/peer-b': {
optional: true,
},
'peer-c': {
'@pnpm.e2e/peer-c': {
optional: true,
},
})
@@ -1047,8 +1050,8 @@ test('local tarball dependency with peer dependency', async () => {
const manifest = await addDependenciesToPackage({}, [
`file:${f.find('tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz')}`,
'bar@100.0.0',
'foo@100.0.0',
'bar@npm:@pnpm.e2e/bar@100.0.0',
'foo@npm:@pnpm.e2e/foo@100.0.0',
], await testDefaults({ reporter }))
const integrityLocalPkgDirs = (await fs.readdir('node_modules/.pnpm'))
+11 -9
View File
@@ -80,12 +80,13 @@ test('using side effects cache', async () => {
sideEffectsCacheWrite: true,
verifyStoreIntegrity: false,
}, {}, {}, { packageImportMethod: 'copy' })
const manifest = await addDependenciesToPackage({}, ['pre-and-postinstall-scripts-example@1.0.0'], opts)
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pre-and-postinstall-scripts-example@1.0.0'], opts)
const filesIndexFile = path.join(opts.storeDir, 'files/2e/28a020ed7c488057d208cd705442e275352fcf88a32b32d0d312668308cb87db3a6df9171ce90d501c3de162b2a6dd5cf62ed7ae8c76532f95adfac924b9a8-index.json')
const cafsDir = path.join(opts.storeDir, 'files')
const filesIndexFile = getFilePathInCafs(cafsDir, getIntegrity('@pnpm.e2e/pre-and-postinstall-scripts-example', '1.0.0'), 'index')
const filesIndex = await loadJsonFile<PackageFilesIndex>(filesIndexFile)
expect(filesIndex.sideEffects).toBeTruthy() // files index has side effects
const sideEffectsKey = `${ENGINE_NAME}-${JSON.stringify({ '/hello-world-js-bin/1.0.0': {} })}`
const sideEffectsKey = `${ENGINE_NAME}-${JSON.stringify({ '/@pnpm.e2e/hello-world-js-bin/1.0.0': {} })}`
expect(filesIndex.sideEffects).toHaveProperty([sideEffectsKey, 'generated-by-preinstall.js'])
expect(filesIndex.sideEffects).toHaveProperty([sideEffectsKey, 'generated-by-postinstall.js'])
delete filesIndex.sideEffects![sideEffectsKey]['generated-by-postinstall.js']
@@ -100,10 +101,10 @@ test('using side effects cache', async () => {
storeDir: opts.storeDir,
verifyStoreIntegrity: false,
}, {}, {}, { packageImportMethod: 'copy' })
await addDependenciesToPackage(manifest, ['pre-and-postinstall-scripts-example@1.0.0'], opts2)
await addDependenciesToPackage(manifest, ['@pnpm.e2e/pre-and-postinstall-scripts-example@1.0.0'], opts2)
expect(await exists(path.resolve('node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js'))).toBeTruthy() // side effects cache correctly used
expect(await exists(path.resolve('node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js'))).toBeFalsy() // side effects cache correctly used
expect(await exists(path.resolve('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js'))).toBeTruthy() // side effects cache correctly used
expect(await exists(path.resolve('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall.js'))).toBeFalsy() // side effects cache correctly used
})
test.skip('readonly side effects cache', async () => {
@@ -151,11 +152,12 @@ test('uploading errors do not interrupt installation', async () => {
opts.storeController.upload = async () => {
throw new Error('an unexpected error')
}
await addDependenciesToPackage({}, ['pre-and-postinstall-scripts-example@1.0.0'], opts)
await addDependenciesToPackage({}, ['@pnpm.e2e/pre-and-postinstall-scripts-example@1.0.0'], opts)
expect(await exists('node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeTruthy()
expect(await exists('node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall.js')).toBeTruthy()
const filesIndexFile = path.join(opts.storeDir, 'files/2e/28a020ed7c488057d208cd705442e275352fcf88a32b32d0d312668308cb87db3a6df9171ce90d501c3de162b2a6dd5cf62ed7ae8c76532f95adfac924b9a8-index.json')
const cafsDir = path.join(opts.storeDir, 'files')
const filesIndexFile = getFilePathInCafs(cafsDir, getIntegrity('@pnpm.e2e/pre-and-postinstall-scripts-example', '1.0.0'), 'index')
const filesIndex = await loadJsonFile<PackageFilesIndex>(filesIndexFile)
expect(filesIndex.sideEffects).toBeFalsy()
})
+85 -85
View File
@@ -11,22 +11,22 @@ test('preserve subdeps on update', async () => {
const project = prepareEmpty()
await Promise.all([
addDistTag({ package: 'abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' }),
])
const manifest = await addDependenciesToPackage({}, ['foobarqar', 'abc-grand-parent-with-c'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/foobarqar', '@pnpm.e2e/abc-grand-parent-with-c'], await testDefaults())
await Promise.all([
addDistTag({ package: 'abc-grand-parent-with-c', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-grand-parent-with-c', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.1', distTag: 'latest' }),
])
await install(manifest, await testDefaults({ update: true, depth: 0 }))
@@ -34,12 +34,12 @@ test('preserve subdeps on update', async () => {
const lockfile = await project.readLockfile()
expect(lockfile.packages).toBeTruthy()
expect(lockfile.packages).toHaveProperty(['/abc-parent-with-ab/1.0.0_peer-c@1.0.0'])
expect(lockfile.packages).toHaveProperty(['/foobarqar/1.0.1'])
expect(lockfile.packages['/foobarqar/1.0.1'].dependencies).toStrictEqual({
bar: '100.0.0',
foo: '100.0.0',
qar: '100.0.0',
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/abc-parent-with-ab/1.0.0_@pnpm.e2e+peer-c@1.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/foobarqar/1.0.1'])
expect(lockfile.packages['/@pnpm.e2e/foobarqar/1.0.1'].dependencies).toStrictEqual({
'@pnpm.e2e/bar': '100.0.0',
'@pnpm.e2e/foo': '100.0.0',
'@pnpm.e2e/qar': '100.0.0',
})
})
@@ -47,22 +47,22 @@ test('preserve subdeps on update when no node_modules is present', async () => {
const project = prepareEmpty()
await Promise.all([
addDistTag({ package: 'abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' }),
])
const manifest = await addDependenciesToPackage({}, ['foobarqar', 'abc-grand-parent-with-c'], await testDefaults({ lockfileOnly: true }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/foobarqar', '@pnpm.e2e/abc-grand-parent-with-c'], await testDefaults({ lockfileOnly: true }))
await Promise.all([
addDistTag({ package: 'abc-grand-parent-with-c', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-grand-parent-with-c', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.1', distTag: 'latest' }),
])
await install(manifest, await testDefaults({ update: true, depth: 0 }))
@@ -70,19 +70,19 @@ test('preserve subdeps on update when no node_modules is present', async () => {
const lockfile = await project.readLockfile()
expect(lockfile.packages).toBeTruthy()
expect(lockfile.packages).toHaveProperty(['/abc-parent-with-ab/1.0.0_peer-c@1.0.0']) // preserve version of package that has resolved peer deps
expect(lockfile.packages).toHaveProperty(['/foobarqar/1.0.1'])
expect(lockfile.packages['/foobarqar/1.0.1'].dependencies).toStrictEqual({
bar: '100.0.0',
foo: '100.0.0',
qar: '100.0.0',
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/abc-parent-with-ab/1.0.0_@pnpm.e2e+peer-c@1.0.0']) // preserve version of package that has resolved peer deps
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/foobarqar/1.0.1'])
expect(lockfile.packages['/@pnpm.e2e/foobarqar/1.0.1'].dependencies).toStrictEqual({
'@pnpm.e2e/bar': '100.0.0',
'@pnpm.e2e/foo': '100.0.0',
'@pnpm.e2e/qar': '100.0.0',
})
})
test('update does not fail when package has only peer dependencies', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['has-pkg-with-peer-only'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-pkg-with-peer-only'], await testDefaults())
await install(manifest, await testDefaults({ update: true, depth: Infinity }))
})
@@ -101,18 +101,18 @@ test('update does not install the package if it is not present in package.json',
test('update dependency when external lockfile directory is used', async () => {
prepareEmpty()
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
const lockfileDir = path.resolve('..')
const manifest = await addDependenciesToPackage({}, ['foo'], await testDefaults({ lockfileDir }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/foo'], await testDefaults({ lockfileDir }))
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
await install(manifest, await testDefaults({ update: true, depth: 0, lockfileDir }))
const lockfile = await readYamlFile<Lockfile>(path.join('..', WANTED_LOCKFILE))
expect(lockfile.packages).toHaveProperty(['/foo/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/foo/100.1.0'])
})
// Covers https://github.com/pnpm/pnpm/issues/2191
@@ -120,35 +120,35 @@ test('preserve subdeps when installing on a package that has one dependency spec
const project = prepareEmpty()
await Promise.all([
addDistTag({ package: 'abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' }),
])
const manifest = await addDependenciesToPackage({}, ['foobarqar', 'abc-grand-parent-with-c'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/foobarqar', '@pnpm.e2e/abc-grand-parent-with-c'], await testDefaults())
manifest.dependencies!['foobarqar'] = '^1.0.1'
manifest.dependencies!['@pnpm.e2e/foobarqar'] = '^1.0.1'
await Promise.all([
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.1', distTag: 'latest' }),
])
await install(manifest, await testDefaults())
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/abc-parent-with-ab/1.0.0_peer-c@1.0.0']) // preserve version of package that has resolved peer deps
expect(lockfile.packages).toHaveProperty(['/foobarqar/1.0.1'])
expect(lockfile.packages['/foobarqar/1.0.1'].dependencies).toStrictEqual({
bar: '100.0.0',
foo: '100.0.0',
qar: '100.0.0',
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/abc-parent-with-ab/1.0.0_@pnpm.e2e+peer-c@1.0.0']) // preserve version of package that has resolved peer deps
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/foobarqar/1.0.1'])
expect(lockfile.packages['/@pnpm.e2e/foobarqar/1.0.1'].dependencies).toStrictEqual({
'@pnpm.e2e/bar': '100.0.0',
'@pnpm.e2e/foo': '100.0.0',
'@pnpm.e2e/qar': '100.0.0',
})
})
@@ -156,57 +156,57 @@ test('preserve subdeps when installing on a package that has one dependency spec
test('update only the packages that were requested to be updated when hoisting is on', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
let manifest = await addDependenciesToPackage({}, ['bar', 'foo'], await testDefaults({ hoistPattern: ['*'] }))
let manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/bar', '@pnpm.e2e/foo'], await testDefaults({ hoistPattern: ['*'] }))
await addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
manifest = await addDependenciesToPackage(manifest, ['foo'], await testDefaults({ allowNew: false, update: true, hoistPattern: ['*'] }))
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/foo'], await testDefaults({ allowNew: false, update: true, hoistPattern: ['*'] }))
expect(manifest.dependencies).toStrictEqual({ bar: '^100.0.0', foo: '^100.1.0' })
expect(manifest.dependencies).toStrictEqual({ '@pnpm.e2e/bar': '^100.0.0', '@pnpm.e2e/foo': '^100.1.0' })
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages)).toStrictEqual(['/bar/100.0.0', '/foo/100.1.0'])
expect(Object.keys(lockfile.packages)).toStrictEqual(['/@pnpm.e2e/bar/100.0.0', '/@pnpm.e2e/foo/100.1.0'])
})
test('update only the specified package', async () => {
const project = prepareEmpty()
await Promise.all([
addDistTag({ package: 'abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: 'peer-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-grand-parent-with-c', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' }),
])
const manifest = await addDependenciesToPackage({}, ['foobarqar', 'abc-grand-parent-with-c'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/foobarqar', '@pnpm.e2e/abc-grand-parent-with-c'], await testDefaults())
await Promise.all([
addDistTag({ package: 'abc-grand-parent-with-c', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: 'abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: 'foobarqar', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-grand-parent-with-c', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/abc-parent-with-ab', version: '1.0.1', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' }),
addDistTag({ package: '@pnpm.e2e/foobarqar', version: '1.0.1', distTag: 'latest' }),
])
await install(manifest, await testDefaults({
depth: Infinity,
update: true,
updateMatching: (pkgName: string) => pkgName === 'foo',
updateMatching: (pkgName: string) => pkgName === '@pnpm.e2e/foo',
}))
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/abc-parent-with-ab/1.0.0_peer-c@1.0.0'])
expect(lockfile.packages).toHaveProperty(['/foobarqar/1.0.0'])
expect(lockfile.packages['/foobarqar/1.0.0'].dependencies).toStrictEqual({
bar: '100.0.0',
foo: '100.1.0',
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/abc-parent-with-ab/1.0.0_@pnpm.e2e+peer-c@1.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/foobarqar/1.0.0'])
expect(lockfile.packages['/@pnpm.e2e/foobarqar/1.0.0'].dependencies).toStrictEqual({
'@pnpm.e2e/bar': '100.0.0',
'@pnpm.e2e/foo': '100.1.0',
'is-positive': '3.1.0',
})
})
+48 -48
View File
@@ -50,100 +50,100 @@ test('saveDev scoped module to package.json (@rstacruz/tap-spec)', async () => {
})
test('dependency should not be added to package.json if it is already there', async () => {
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({
devDependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
optionalDependencies: {
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
}, ['foo', 'bar'], await testDefaults())
}, ['@pnpm.e2e/foo', '@pnpm.e2e/bar'], await testDefaults())
expect(manifest).toStrictEqual({
devDependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
optionalDependencies: {
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
})
const lockfile = await project.readLockfile()
expect(lockfile.devDependencies.foo).toBe('100.0.0')
expect(lockfile.packages['/foo/100.0.0'].dev).toBeTruthy()
expect(lockfile.devDependencies['@pnpm.e2e/foo']).toBe('100.0.0')
expect(lockfile.packages['/@pnpm.e2e/foo/100.0.0'].dev).toBeTruthy()
expect(lockfile.optionalDependencies.bar).toBe('100.0.0')
expect(lockfile.packages['/bar/100.0.0'].optional).toBeTruthy()
expect(lockfile.optionalDependencies['@pnpm.e2e/bar']).toBe('100.0.0')
expect(lockfile.packages['/@pnpm.e2e/bar/100.0.0'].optional).toBeTruthy()
})
test('dependencies should be updated in the fields where they already are', async () => {
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' })
prepareEmpty()
const manifest = await addDependenciesToPackage({
devDependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
optionalDependencies: {
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
}, ['foo@latest', 'bar@latest'], await testDefaults())
}, ['@pnpm.e2e/foo@latest', '@pnpm.e2e/bar@latest'], await testDefaults())
expect(manifest).toStrictEqual({
devDependencies: {
foo: '^100.1.0',
'@pnpm.e2e/foo': '^100.1.0',
},
optionalDependencies: {
bar: '^100.1.0',
'@pnpm.e2e/bar': '^100.1.0',
},
})
})
test('dependency should be removed from the old field when installing it as a different type of dependency', async () => {
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'qar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/qar', version: '100.0.0', distTag: 'latest' })
const project = prepareEmpty()
let manifest = await addDependenciesToPackage({
dependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
devDependencies: {
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
optionalDependencies: {
qar: '^100.0.0',
'@pnpm.e2e/qar': '^100.0.0',
},
}, ['foo'], await testDefaults({ targetDependenciesField: 'optionalDependencies' }))
manifest = await addDependenciesToPackage(manifest, ['bar'], await testDefaults({ targetDependenciesField: 'dependencies' }))
manifest = await addDependenciesToPackage(manifest, ['qar'], await testDefaults({ targetDependenciesField: 'devDependencies' }))
}, ['@pnpm.e2e/foo'], await testDefaults({ targetDependenciesField: 'optionalDependencies' }))
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/bar'], await testDefaults({ targetDependenciesField: 'dependencies' }))
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/qar'], await testDefaults({ targetDependenciesField: 'devDependencies' }))
expect(manifest).toStrictEqual({
dependencies: {
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
devDependencies: {
qar: '^100.0.0',
'@pnpm.e2e/qar': '^100.0.0',
},
optionalDependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
})
manifest = await addDependenciesToPackage(manifest, ['bar', 'foo', 'qar'], await testDefaults({ targetDependenciesField: 'dependencies' }))
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/bar', '@pnpm.e2e/foo', '@pnpm.e2e/qar'], await testDefaults({ targetDependenciesField: 'dependencies' }))
expect(manifest).toStrictEqual({
dependencies: {
bar: '^100.0.0',
foo: '^100.0.0',
qar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
'@pnpm.e2e/qar': '^100.0.0',
},
devDependencies: {},
optionalDependencies: {},
@@ -151,10 +151,10 @@ test('dependency should be removed from the old field when installing it as a di
{
const lockfile = await project.readCurrentLockfile()
expect(Object.keys(lockfile.dependencies)).toStrictEqual(['bar', 'foo', 'qar'])
expect(Object.keys(lockfile.dependencies)).toStrictEqual(['@pnpm.e2e/bar', '@pnpm.e2e/foo', '@pnpm.e2e/qar'])
}
console.log('manually editing package.json. Converting all prod deps to dev deps')
// manually editing package.json. Converting all prod deps to dev deps
manifest.devDependencies = manifest.dependencies
delete manifest.dependencies
@@ -163,7 +163,7 @@ test('dependency should be removed from the old field when installing it as a di
{
const lockfile = await project.readCurrentLockfile()
expect(Object.keys(lockfile.devDependencies)).toStrictEqual(['bar', 'foo', 'qar'])
expect(Object.keys(lockfile.devDependencies)).toStrictEqual(['@pnpm.e2e/bar', '@pnpm.e2e/foo', '@pnpm.e2e/qar'])
expect(lockfile.dependencies).toBeFalsy()
}
})
@@ -185,15 +185,15 @@ test('multiple save to package.json with `exact` versions (@rstacruz/tap-spec &
test('save to package.json with save prefix ~', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ pinnedVersion: 'minor' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ pinnedVersion: 'minor' }))
expect(manifest.dependencies).toStrictEqual({ 'pkg-with-1-dep': '~100.0.0' })
expect(manifest.dependencies).toStrictEqual({ '@pnpm.e2e/pkg-with-1-dep': '~100.0.0' })
})
test('an update bumps the versions in the manifest', async () => {
await addDistTag({ package: 'peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '2.0.0', distTag: 'latest' })
prepareEmpty()
@@ -202,13 +202,13 @@ test('an update bumps the versions in the manifest', async () => {
buildIndex: 0,
manifest: {
dependencies: {
'peer-a': '~1.0.0',
'@pnpm.e2e/peer-a': '~1.0.0',
},
devDependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
optionalDependencies: {
'peer-c': '^1.0.1',
'@pnpm.e2e/peer-c': '^1.0.1',
},
},
mutation: 'install',
@@ -221,13 +221,13 @@ test('an update bumps the versions in the manifest', async () => {
expect(manifest).toStrictEqual({
dependencies: {
'peer-a': '~1.0.1',
'@pnpm.e2e/peer-a': '~1.0.1',
},
devDependencies: {
foo: '^100.1.0',
'@pnpm.e2e/foo': '^100.1.0',
},
optionalDependencies: {
'peer-c': '^1.0.1',
'@pnpm.e2e/peer-c': '^1.0.1',
},
})
})
+15 -15
View File
@@ -27,7 +27,7 @@ test('relative link', async () => {
dir: process.cwd(),
manifest: {
dependencies: {
'hello-world-js-bin': '*',
'@pnpm.e2e/hello-world-js-bin': '*',
},
},
}))
@@ -35,11 +35,11 @@ test('relative link', async () => {
await project.isExecutable('.bin/hello-world-js-bin')
const wantedLockfile = await project.readLockfile()
expect(wantedLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin')
expect(wantedLockfile.specifiers['hello-world-js-bin']).toBe('*')
expect(wantedLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('link:../hello-world-js-bin')
expect(wantedLockfile.specifiers['@pnpm.e2e/hello-world-js-bin']).toBe('*')
const currentLockfile = await project.readCurrentLockfile()
expect(currentLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin')
expect(currentLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('link:../hello-world-js-bin')
})
test('relative link is linked by the name of the alias', async () => {
@@ -90,8 +90,8 @@ test('relative link is not rewritten by argumentless install', async () => {
added: {
dependencyType: undefined,
linkedFrom: linkedPkgPath,
name: 'hello-world-js-bin',
realName: 'hello-world-js-bin',
name: '@pnpm.e2e/hello-world-js-bin',
realName: '@pnpm.e2e/hello-world-js-bin',
version: '1.0.0',
},
level: 'debug',
@@ -101,11 +101,11 @@ test('relative link is not rewritten by argumentless install', async () => {
await install(manifest, opts)
expect(project.requireModule('hello-world-js-bin/package.json').isLocal).toBeTruthy()
expect(project.requireModule('@pnpm.e2e/hello-world-js-bin/package.json').isLocal).toBeTruthy()
})
test('relative link is rewritten by named installation to regular dependency', async () => {
await addDistTag({ package: 'hello-world-js-bin', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/hello-world-js-bin', version: '1.0.0', distTag: 'latest' })
const project = prepareEmpty()
const linkedPkgName = 'hello-world-js-bin'
@@ -130,8 +130,8 @@ test('relative link is rewritten by named installation to regular dependency', a
added: {
dependencyType: undefined,
linkedFrom: linkedPkgPath,
name: 'hello-world-js-bin',
realName: 'hello-world-js-bin',
name: '@pnpm.e2e/hello-world-js-bin',
realName: '@pnpm.e2e/hello-world-js-bin',
version: '1.0.0',
},
level: 'debug',
@@ -139,17 +139,17 @@ test('relative link is rewritten by named installation to regular dependency', a
prefix: process.cwd(),
} as RootLog)).toBeTruthy()
manifest = await addDependenciesToPackage(manifest, ['hello-world-js-bin'], opts)
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/hello-world-js-bin'], opts)
expect(manifest.dependencies).toStrictEqual({ 'hello-world-js-bin': '^1.0.0' })
expect(manifest.dependencies).toStrictEqual({ '@pnpm.e2e/hello-world-js-bin': '^1.0.0' })
expect(project.requireModule('hello-world-js-bin/package.json').isLocal).toBeFalsy()
expect(project.requireModule('@pnpm.e2e/hello-world-js-bin/package.json').isLocal).toBeFalsy()
const wantedLockfile = await project.readLockfile()
expect(wantedLockfile.dependencies['hello-world-js-bin']).toBe('1.0.0')
expect(wantedLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('1.0.0')
const currentLockfile = await project.readCurrentLockfile()
expect(currentLockfile.dependencies['hello-world-js-bin']).toBe('1.0.0')
expect(currentLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('1.0.0')
})
test('relative link uses realpath when contained in a symlinked dir', async () => {
+108 -108
View File
@@ -33,7 +33,7 @@ test('lockfile has correct format', async () => {
await addDependenciesToPackage({},
[
'pkg-with-1-dep',
'@pnpm.e2e/pkg-with-1-dep',
'@rstacruz/tap-spec@4.1.1',
'kevva/is-negative#1d7e288222b53a0cab90a331f1865220ec29560c',
], await testDefaults({ fastUnpack: false, save: true }))
@@ -43,20 +43,20 @@ test('lockfile has correct format', async () => {
expect(modules!.pendingBuilds.length).toBe(0)
const lockfile = await project.readLockfile()
const id = '/pkg-with-1-dep/100.0.0'
const id = '/@pnpm.e2e/pkg-with-1-dep/100.0.0'
expect(lockfile.lockfileVersion).toBe(LOCKFILE_VERSION)
expect(lockfile.specifiers).toBeTruthy()
expect(lockfile.dependencies).toBeTruthy()
expect(lockfile.dependencies['pkg-with-1-dep']).toBe('100.0.0')
expect(lockfile.dependencies['@pnpm.e2e/pkg-with-1-dep']).toBe('100.0.0')
expect(lockfile.dependencies).toHaveProperty(['@rstacruz/tap-spec'])
expect(lockfile.dependencies['is-negative']).toContain('/') // has not shortened tarball from the non-standard registry
expect(lockfile.packages).toBeTruthy() // has packages field
expect(lockfile.packages).toHaveProperty([id])
expect(lockfile.packages[id].dependencies).toBeTruthy()
expect(lockfile.packages[id].dependencies).toHaveProperty(['dep-of-pkg-with-1-dep'])
expect(lockfile.packages[id].dependencies).toHaveProperty(['@pnpm.e2e/dep-of-pkg-with-1-dep'])
expect(lockfile.packages[id].resolution).toBeTruthy()
expect((lockfile.packages[id].resolution as {integrity: string}).integrity).toBeTruthy()
expect((lockfile.packages[id].resolution as TarballResolution).tarball).toBeFalsy()
@@ -283,20 +283,20 @@ test(`respects ${WANTED_LOCKFILE} for top dependencies`, async () => {
// },
// })
const pkgs = ['foo', 'bar', 'qar']
const pkgs = ['@pnpm.e2e/foo', '@pnpm.e2e/bar', '@pnpm.e2e/qar']
await Promise.all(pkgs.map(async (pkgName) => addDistTag({ package: pkgName, version: '100.0.0', distTag: 'latest' })))
let manifest = await addDependenciesToPackage({}, ['foo'], await testDefaults({ save: true, reporter }))
let manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/foo'], await testDefaults({ save: true, reporter }))
// t.equal(reporter.withArgs(fooProgress).callCount, 1, 'reported foo once')
manifest = await addDependenciesToPackage(manifest, ['bar'], await testDefaults({ targetDependenciesField: 'optionalDependencies' }))
manifest = await addDependenciesToPackage(manifest, ['qar'], await testDefaults({ addDependenciesToPackage: 'devDependencies' }))
manifest = await addDependenciesToPackage(manifest, ['foobar'], await testDefaults({ save: true }))
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/bar'], await testDefaults({ targetDependenciesField: 'optionalDependencies' }))
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/qar'], await testDefaults({ addDependenciesToPackage: 'devDependencies' }))
manifest = await addDependenciesToPackage(manifest, ['@pnpm.e2e/foobar'], await testDefaults({ save: true }))
expect((await readPackageJsonFromDir(path.resolve('node_modules', 'foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', 'bar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', 'qar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/foobar@100.0.0/node_modules/foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/foobar@100.0.0/node_modules/bar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', '@pnpm.e2e/foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', '@pnpm.e2e/bar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', '@pnpm.e2e/qar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/@pnpm.e2e+foobar@100.0.0/node_modules/@pnpm.e2e/foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/@pnpm.e2e+foobar@100.0.0/node_modules/@pnpm.e2e/bar'))).version).toBe('100.0.0')
await Promise.all(pkgs.map(async (pkgName) => addDistTag({ package: pkgName, version: '100.1.0', distTag: 'latest' })))
@@ -317,42 +317,42 @@ test(`respects ${WANTED_LOCKFILE} for top dependencies`, async () => {
// t.equal(reporter.withArgs(fooProgress).callCount, 0, 'not reported foo')
await project.storeHasNot('foo', '100.1.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', 'foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', 'bar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', 'qar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/foobar@100.0.0/node_modules/foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/foobar@100.0.0/node_modules/bar'))).version).toBe('100.0.0')
await project.storeHasNot('@pnpm.e2e/foo', '100.1.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', '@pnpm.e2e/foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', '@pnpm.e2e/bar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules', '@pnpm.e2e/qar'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/@pnpm.e2e+foobar@100.0.0/node_modules/@pnpm.e2e/foo'))).version).toBe('100.0.0')
expect((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/@pnpm.e2e+foobar@100.0.0/node_modules/@pnpm.e2e/bar'))).version).toBe('100.0.0')
})
test(`subdeps are updated on repeat install if outer ${WANTED_LOCKFILE} does not match the inner one`, async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults())
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
delete lockfile.packages['/dep-of-pkg-with-1-dep/100.0.0']
delete lockfile.packages['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0']
lockfile.packages['/dep-of-pkg-with-1-dep/100.1.0'] = {
lockfile.packages['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'] = {
resolution: {
integrity: getIntegrity('dep-of-pkg-with-1-dep', '100.1.0'),
integrity: getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0'),
},
}
lockfile.packages['/pkg-with-1-dep/100.0.0'].dependencies!['dep-of-pkg-with-1-dep'] = '100.1.0'
lockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].dependencies!['@pnpm.e2e/dep-of-pkg-with-1-dep'] = '100.1.0'
await writeYamlFile(WANTED_LOCKFILE, lockfile, { lineWidth: 1000 })
await install(manifest, await testDefaults())
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
await project.storeHas('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0')
})
test("recreates lockfile if it doesn't match the dependencies in package.json", async () => {
@@ -405,32 +405,32 @@ test('repeat install with lockfile should not mutate lockfile when dependency ha
test('package is not marked dev if it is also a subdep of a regular dependency', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults())
console.log('installed pkg-with-1-dep')
console.log('installed @pnpm.e2e/pkg-with-1-dep')
await addDependenciesToPackage(manifest, ['dep-of-pkg-with-1-dep'], await testDefaults({ targetDependenciesField: 'devDependencies' }))
await addDependenciesToPackage(manifest, ['@pnpm.e2e/dep-of-pkg-with-1-dep'], await testDefaults({ targetDependenciesField: 'devDependencies' }))
console.log('installed optional dependency which is also a dependency of pkg-with-1-dep')
console.log('installed optional dependency which is also a dependency of @pnpm.e2e/pkg-with-1-dep')
const lockfile = await project.readLockfile()
expect(lockfile.packages['/dep-of-pkg-with-1-dep/100.0.0'].dev).toBeFalsy()
expect(lockfile.packages['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'].dev).toBeFalsy()
})
test('package is not marked optional if it is also a subdep of a regular dependency', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults())
await addDependenciesToPackage(manifest, ['dep-of-pkg-with-1-dep'], await testDefaults({ targetDependenciesField: 'optionalDependencies' }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults())
await addDependenciesToPackage(manifest, ['@pnpm.e2e/dep-of-pkg-with-1-dep'], await testDefaults({ targetDependenciesField: 'optionalDependencies' }))
const lockfile = await project.readLockfile()
expect(lockfile.packages['/dep-of-pkg-with-1-dep/100.0.0'].optional).toBeFalsy()
expect(lockfile.packages['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'].optional).toBeFalsy()
})
test('scoped module from different registry', async () => {
@@ -518,25 +518,25 @@ test('repeat install with no inner lockfile should not rewrite packages in node_
test('packages are placed in devDependencies even if they are present as non-dev as well', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
const reporter = sinon.spy()
await install({
devDependencies: {
'dep-of-pkg-with-1-dep': '^100.1.0',
'pkg-with-1-dep': '^100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '^100.1.0',
'@pnpm.e2e/pkg-with-1-dep': '^100.0.0',
},
}, await testDefaults({ reporter }))
const lockfile = await project.readLockfile()
expect(lockfile.devDependencies).toHaveProperty(['dep-of-pkg-with-1-dep'])
expect(lockfile.devDependencies).toHaveProperty(['pkg-with-1-dep'])
expect(lockfile.devDependencies).toHaveProperty(['@pnpm.e2e/dep-of-pkg-with-1-dep'])
expect(lockfile.devDependencies).toHaveProperty(['@pnpm.e2e/pkg-with-1-dep'])
expect(reporter.calledWithMatch({
added: {
dependencyType: 'dev',
name: 'dep-of-pkg-with-1-dep',
name: '@pnpm.e2e/dep-of-pkg-with-1-dep',
version: '100.1.0',
},
level: 'debug',
@@ -545,7 +545,7 @@ test('packages are placed in devDependencies even if they are present as non-dev
expect(reporter.calledWithMatch({
added: {
dependencyType: 'dev',
name: 'pkg-with-1-dep',
name: '@pnpm.e2e/pkg-with-1-dep',
version: '100.0.0',
},
level: 'debug',
@@ -558,15 +558,15 @@ test('packages are placed in devDependencies even if they are present as non-dev
test('updating package that has a github-hosted dependency', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['has-github-dep@1'], await testDefaults())
await addDependenciesToPackage(manifest, ['has-github-dep@latest'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/has-github-dep@1'], await testDefaults())
await addDependenciesToPackage(manifest, ['@pnpm.e2e/has-github-dep@latest'], await testDefaults())
})
test('updating package that has deps with peers', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c@0'], await testDefaults())
await addDependenciesToPackage(manifest, ['abc-grand-parent-with-c@1'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/abc-grand-parent-with-c@0'], await testDefaults())
await addDependenciesToPackage(manifest, ['@pnpm.e2e/abc-grand-parent-with-c@1'], await testDefaults())
})
test('pendingBuilds gets updated if install removes packages', async () => {
@@ -574,15 +574,15 @@ test('pendingBuilds gets updated if install removes packages', async () => {
await install({
dependencies: {
'pre-and-postinstall-scripts-example': '*',
'with-postinstall-b': '*',
'@pnpm.e2e/pre-and-postinstall-scripts-example': '*',
'@pnpm.e2e/with-postinstall-b': '*',
},
}, await testDefaults({ fastUnpack: false, ignoreScripts: true }))
const modules1 = await project.readModulesManifest()
await install({
dependencies: {
'pre-and-postinstall-scripts-example': '*',
'@pnpm.e2e/pre-and-postinstall-scripts-example': '*',
},
}, await testDefaults({ fastUnpack: false, ignoreScripts: true }))
const modules2 = await project.readModulesManifest()
@@ -744,7 +744,7 @@ test('packages installed via tarball URL from the default registry are normalize
const project = prepareEmpty()
await addDependenciesToPackage({}, [
`http://localhost:${REGISTRY_MOCK_PORT}/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz`,
`http://localhost:${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz`,
'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
], await testDefaults())
@@ -753,23 +753,23 @@ test('packages installed via tarball URL from the default registry are normalize
expect(lockfile).toStrictEqual({
dependencies: {
'is-positive': '@registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
'pkg-with-tarball-dep-from-registry': '1.0.0',
'@pnpm.e2e/pkg-with-tarball-dep-from-registry': '1.0.0',
},
lockfileVersion: LOCKFILE_VERSION,
packages: {
'/dep-of-pkg-with-1-dep/100.0.0': {
'/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0': {
dev: false,
resolution: {
integrity: getIntegrity('dep-of-pkg-with-1-dep', '100.0.0'),
integrity: getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0'),
},
},
'/pkg-with-tarball-dep-from-registry/1.0.0': {
'/@pnpm.e2e/pkg-with-tarball-dep-from-registry/1.0.0': {
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
dev: false,
resolution: {
integrity: getIntegrity('pkg-with-tarball-dep-from-registry', '1.0.0'),
integrity: getIntegrity('@pnpm.e2e/pkg-with-tarball-dep-from-registry', '1.0.0'),
},
},
'@registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz': {
@@ -784,7 +784,7 @@ test('packages installed via tarball URL from the default registry are normalize
},
specifiers: {
'is-positive': 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
'pkg-with-tarball-dep-from-registry': `http://localhost:${REGISTRY_MOCK_PORT}/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz`,
'@pnpm.e2e/pkg-with-tarball-dep-from-registry': `http://localhost:${REGISTRY_MOCK_PORT}/@pnpm.e2e/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz`,
},
})
})
@@ -797,7 +797,7 @@ test('lockfile file has correct format when lockfile directory does not equal th
const manifest = await addDependenciesToPackage(
{},
[
'pkg-with-1-dep',
'@pnpm.e2e/pkg-with-1-dep',
'@zkochan/foo@1.0.0',
'kevva/is-negative#1d7e288222b53a0cab90a331f1865220ec29560c',
],
@@ -814,7 +814,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'
const id = '/@pnpm.e2e/pkg-with-1-dep/100.0.0'
expect(lockfile.lockfileVersion).toBe(LOCKFILE_VERSION)
@@ -822,11 +822,11 @@ test('lockfile file has correct format when lockfile directory does not equal th
expect(lockfile.importers.project).toBeTruthy()
expect(lockfile.importers.project.specifiers).toBeTruthy()
expect(lockfile.importers.project.dependencies).toBeTruthy()
expect(lockfile.importers.project.dependencies!['pkg-with-1-dep']).toBe('100.0.0')
expect(lockfile.importers.project.dependencies!['@pnpm.e2e/pkg-with-1-dep']).toBe('100.0.0')
expect(lockfile.importers.project.dependencies!['@zkochan/foo']).toBeTruthy()
expect(lockfile.importers.project.dependencies!['is-negative']).toContain('/')
expect(lockfile.packages![id].dependencies).toHaveProperty(['dep-of-pkg-with-1-dep'])
expect(lockfile.packages![id].dependencies).toHaveProperty(['@pnpm.e2e/dep-of-pkg-with-1-dep'])
expect(lockfile.packages![id].resolution).toHaveProperty(['integrity'])
expect(lockfile.packages![id].resolution).not.toHaveProperty(['tarball'])
@@ -852,16 +852,16 @@ test('lockfile file has correct format when lockfile directory does not equal th
expect(lockfile.importers).toHaveProperty(['project-2'])
// previous entries are not removed
const id = '/pkg-with-1-dep/100.0.0'
const id = '/@pnpm.e2e/pkg-with-1-dep/100.0.0'
expect(lockfile.importers.project.specifiers).toBeTruthy()
expect(lockfile.importers.project.dependencies!['pkg-with-1-dep']).toBe('100.0.0')
expect(lockfile.importers.project.dependencies!['@pnpm.e2e/pkg-with-1-dep']).toBe('100.0.0')
expect(lockfile.importers.project.dependencies).toHaveProperty(['@zkochan/foo'])
expect(lockfile.importers.project.dependencies!['is-negative']).toContain('/')
expect(lockfile.packages).toHaveProperty([id])
expect(lockfile.packages![id].dependencies).toBeTruthy()
expect(lockfile.packages![id].dependencies).toHaveProperty(['dep-of-pkg-with-1-dep'])
expect(lockfile.packages![id].dependencies).toHaveProperty(['@pnpm.e2e/dep-of-pkg-with-1-dep'])
expect(lockfile.packages![id].resolution).toHaveProperty(['integrity'])
expect(lockfile.packages![id].resolution).not.toHaveProperty(['tarball'])
@@ -980,14 +980,14 @@ test(`use current ${WANTED_LOCKFILE} as initial wanted one, when wanted was remo
test('existing dependencies are preserved when updating a lockfile to a newer format', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults())
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults())
const initialLockfile = await project.readLockfile()
await writeYamlFile(WANTED_LOCKFILE, { ...initialLockfile, lockfileVersion: 5.01 }, { lineWidth: 1000 })
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await mutateModules([
{
@@ -1035,13 +1035,13 @@ test('lockfile is not getting broken if the used registry changes', async () =>
test('broken lockfile is fixed even if it seems like up to date at first. Unless frozenLockfile option is set to true', async () => {
const project = prepareEmpty()
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.0.0', distTag: 'latest' })
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep'], await testDefaults({ lockfileOnly: true }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep'], await testDefaults({ lockfileOnly: true }))
{
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
delete lockfile.packages['/dep-of-pkg-with-1-dep/100.0.0']
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
delete lockfile.packages['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0']
await writeYamlFile(WANTED_LOCKFILE, lockfile, { lineWidth: 1000 })
}
@@ -1069,9 +1069,9 @@ test('broken lockfile is fixed even if it seems like up to date at first. Unless
},
], await testDefaults({ preferFrozenLockfile: true }))
await project.has('pkg-with-1-dep')
await project.has('@pnpm.e2e/pkg-with-1-dep')
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
})
const REGISTRY_MIRROR_DIR = path.join(__dirname, '../../../registry-mirror')
@@ -1181,34 +1181,34 @@ importers:
.:
dependencies:
<<<<<<< HEAD
dep-of-pkg-with-1-dep: 100.0.0
'@pnpm.e2e/dep-of-pkg-with-1-dep': 100.0.0
=======
dep-of-pkg-with-1-dep: 100.1.0
'@pnpm.e2e/dep-of-pkg-with-1-dep': 100.1.0
>>>>>>> next
specifiers:
dep-of-pkg-with-1-dep: '>100.0.0'
'@pnpm.e2e/dep-of-pkg-with-1-dep': '>100.0.0'
lockfileVersion: ${LOCKFILE_VERSION}
packages:
<<<<<<< HEAD
/dep-of-pkg-with-1-dep/100.0.0:
/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0:
dev: false
resolution:
integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.0.0')}
integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')}
=======
/dep-of-pkg-with-1-dep/100.1.0:
/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0:
dev: false
resolution:
integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.1.0')}
integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.1.0')}
>>>>>>> next`, 'utf8')
await install({
dependencies: {
'dep-of-pkg-with-1-dep': '>100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '>100.0.0',
},
}, await testDefaults())
const lockfile = await project.readLockfile()
expect(lockfile.dependencies['dep-of-pkg-with-1-dep']).toBe('100.1.0')
expect(lockfile.dependencies['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('100.1.0')
})
test('a lockfile with duplicate keys is fixed', async () => {
@@ -1218,26 +1218,26 @@ test('a lockfile with duplicate keys is fixed', async () => {
importers:
.:
dependencies:
dep-of-pkg-with-1-dep: 100.0.0
'@pnpm.e2e/dep-of-pkg-with-1-dep': 100.0.0
specifiers:
dep-of-pkg-with-1-dep: '100.0.0'
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0'
lockfileVersion: ${LOCKFILE_VERSION}
packages:
/dep-of-pkg-with-1-dep/100.0.0:
resolution: {integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.0.0')}}
/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0:
resolution: {integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')}}
dev: false
resolution: {integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.0.0')}}
resolution: {integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')}}
`, 'utf8')
const reporter = jest.fn()
await install({
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
}, await testDefaults({ reporter }))
const lockfile = await project.readLockfile()
expect(lockfile.dependencies['dep-of-pkg-with-1-dep']).toBe('100.0.0')
expect(lockfile.dependencies['@pnpm.e2e/dep-of-pkg-with-1-dep']).toBe('100.0.0')
expect(reporter).toBeCalledWith(expect.objectContaining({
level: 'warn',
@@ -1254,21 +1254,21 @@ test('a lockfile with duplicate keys is causes an exception, when frozenLockfile
importers:
.:
dependencies:
dep-of-pkg-with-1-dep: 100.0.0
'@pnpm.e2e/dep-of-pkg-with-1-dep': 100.0.0
specifiers:
dep-of-pkg-with-1-dep: '100.0.0'
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0'
lockfileVersion: ${LOCKFILE_VERSION}
packages:
/dep-of-pkg-with-1-dep/100.0.0:
resolution: {integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.0.0')}}
/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0:
resolution: {integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')}}
dev: false
resolution: {integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.0.0')}}
resolution: {integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')}}
`, 'utf8')
await expect(
install({
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
}, await testDefaults({ frozenLockfile: true }))
).rejects.toThrow(/^The lockfile at .* is broken: duplicated mapping key/)
@@ -1279,7 +1279,7 @@ test('a broken private lockfile is ignored', async () => {
const manifest = await install({
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
},
}, await testDefaults())
@@ -1287,15 +1287,15 @@ test('a broken private lockfile is ignored', async () => {
importers:
.:
dependencies:
dep-of-pkg-with-1-dep: 100.0.0
'@pnpm.e2e/dep-of-pkg-with-1-dep': 100.0.0
specifiers:
dep-of-pkg-with-1-dep: '100.0.0'
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0'
lockfileVersion: ${LOCKFILE_VERSION}
packages:
/dep-of-pkg-with-1-dep/100.0.0:
resolution: {integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.0.0')}}
/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0:
resolution: {integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')}}
dev: false
resolution: {integrity: ${getIntegrity('dep-of-pkg-with-1-dep', '100.0.0')}}
resolution: {integrity: ${getIntegrity('@pnpm.e2e/dep-of-pkg-with-1-dep', '100.0.0')}}
`, 'utf8')
const reporter = jest.fn()
@@ -1381,9 +1381,9 @@ test('include tarball URL', async () => {
const project = prepareEmpty()
const opts = await testDefaults({ fastUnpack: false, lockfileIncludeTarballUrl: true })
await addDependenciesToPackage({}, ['pkg-with-1-dep@100.0.0'], opts)
await addDependenciesToPackage({}, ['@pnpm.e2e/pkg-with-1-dep@100.0.0'], opts)
const lockfile = await project.readLockfile()
expect((lockfile.packages['/pkg-with-1-dep/100.0.0'].resolution as TarballResolution).tarball)
.toBe(`http://localhost:${REGISTRY_MOCK_PORT}/pkg-with-1-dep/-/pkg-with-1-dep-100.0.0.tgz`)
expect((lockfile.packages['/@pnpm.e2e/pkg-with-1-dep/100.0.0'].resolution as TarballResolution).tarball)
.toBe(`http://localhost:${REGISTRY_MOCK_PORT}/@pnpm.e2e%2fpkg-with-1-dep/-/pkg-with-1-dep-100.0.0.tgz`)
})
+3 -3
View File
@@ -14,11 +14,11 @@ test('packageImportMethod can be set to copy', async () => {
test('copy does not fail on package that self-requires itself', async () => {
const project = prepareEmpty()
await addDependenciesToPackage({}, ['requires-itself'], await testDefaults({}, {}, {}, { packageImportMethod: 'copy' }))
await addDependenciesToPackage({}, ['@pnpm.e2e/requires-itself'], await testDefaults({}, {}, {}, { packageImportMethod: 'copy' }))
const m = project.requireModule('requires-itself/package.json')
const m = project.requireModule('@pnpm.e2e/requires-itself/package.json')
expect(m).toBeTruthy() // requires-itself is available with packageImportMethod = copy
const lockfile = await project.readLockfile()
expect(lockfile.packages['/requires-itself/1.0.0'].dependencies).toStrictEqual({ 'is-positive': '1.0.0' })
expect(lockfile.packages['/@pnpm.e2e/requires-itself/1.0.0'].dependencies).toStrictEqual({ 'is-positive': '1.0.0' })
})
+3 -3
View File
@@ -24,7 +24,7 @@ test('prune removes extraneous packages', async () => {
manifest = await addDependenciesToPackage(manifest, ['is-positive@2.0.0', '@zkochan/logger@0.1.0'], opts)
manifest = await link([linkedPkg], path.resolve('node_modules'), { ...opts, manifest, dir: process.cwd() })
await project.has('hello-world-js-bin') // external link added
await project.has('@pnpm.e2e/hello-world-js-bin') // external link added
delete manifest.dependencies!['is-positive']
delete manifest.dependencies!['@zkochan/logger']
@@ -53,12 +53,12 @@ test('prune removes extraneous packages', async () => {
name: 'pnpm:root',
removed: {
dependencyType: undefined,
name: 'hello-world-js-bin',
name: '@pnpm.e2e/hello-world-js-bin',
version: '1.0.0',
},
} as RootLog)).toBeTruthy()
await project.hasNot('hello-world-js-bin') // external link pruned
await project.hasNot('@pnpm.e2e/hello-world-js-bin') // external link pruned
await project.storeHasNot('is-positive', '2.0.0')
await project.hasNot('is-positive')
+4 -4
View File
@@ -179,10 +179,10 @@ test('uninstall package with dependencies and do not touch other deps', async ()
test('uninstall package with its bin files', async () => {
prepareEmpty()
const manifest = await addDependenciesToPackage({}, ['sh-hello-world@1.0.1'], await testDefaults({ fastUnpack: false, save: true }))
const manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/sh-hello-world@1.0.1'], await testDefaults({ fastUnpack: false, save: true }))
await mutateModules([
{
dependencyNames: ['sh-hello-world'],
dependencyNames: ['@pnpm.e2e/sh-hello-world'],
manifest,
mutation: 'uninstallSome',
rootDir: process.cwd(),
@@ -223,7 +223,7 @@ test('pendingBuilds gets updated after uninstall', async () => {
const project = prepareEmpty()
const manifest = await addDependenciesToPackage({},
['pre-and-postinstall-scripts-example', 'with-postinstall-b'],
['@pnpm.e2e/pre-and-postinstall-scripts-example', '@pnpm.e2e/with-postinstall-b'],
await testDefaults({ fastUnpack: false, save: true, ignoreScripts: true })
)
@@ -233,7 +233,7 @@ test('pendingBuilds gets updated after uninstall', async () => {
await mutateModules([
{
dependencyNames: ['with-postinstall-b'],
dependencyNames: ['@pnpm.e2e/with-postinstall-b'],
manifest,
mutation: 'uninstallSome',
rootDir: process.cwd(),
+12 -12
View File
@@ -73,25 +73,25 @@ test('unlink 1 package that exists in package.json', async () => {
test("don't update package when unlinking", async () => {
const project = prepareEmpty()
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
const opts = await testDefaults({ dir: process.cwd() })
let manifest = await addDependenciesToPackage({}, ['foo'], opts)
let manifest = await addDependenciesToPackage({}, ['@pnpm.e2e/foo'], opts)
process.chdir('..')
await writeJsonFile('foo/package.json', {
name: 'foo',
name: '@pnpm.e2e/foo',
version: '100.0.0',
})
manifest = await link(['foo'], path.join('project', 'node_modules'), { ...opts, manifest })
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
process.chdir('project')
await mutateModules(
[
{
dependencyNames: ['foo'],
dependencyNames: ['@pnpm.e2e/foo'],
manifest,
mutation: 'unlinkSome',
rootDir: process.cwd(),
@@ -100,7 +100,7 @@ test("don't update package when unlinking", async () => {
opts
)
expect(project.requireModule('foo/package.json').version).toBe('100.0.0')
expect(project.requireModule('@pnpm.e2e/foo/package.json').version).toBe('100.0.0')
})
test(`don't update package when unlinking. Initial link is done on a package w/o ${WANTED_LOCKFILE}`, async () => {
@@ -110,7 +110,7 @@ test(`don't update package when unlinking. Initial link is done on a package w/o
process.chdir('..')
await writeJsonFile('foo/package.json', {
name: 'foo',
name: '@pnpm.e2e/foo',
version: '100.0.0',
})
@@ -118,17 +118,17 @@ test(`don't update package when unlinking. Initial link is done on a package w/o
...opts,
manifest: {
dependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
},
})
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
process.chdir('project')
const unlinkResult = await mutateModules(
[
{
dependencyNames: ['foo'],
dependencyNames: ['@pnpm.e2e/foo'],
manifest,
mutation: 'unlinkSome',
rootDir: process.cwd(),
@@ -137,8 +137,8 @@ test(`don't update package when unlinking. Initial link is done on a package w/o
opts
)
expect(project.requireModule('foo/package.json').version).toBe('100.1.0')
expect(unlinkResult[0].manifest.dependencies).toStrictEqual({ foo: '^100.0.0' })
expect(project.requireModule('@pnpm.e2e/foo/package.json').version).toBe('100.1.0')
expect(unlinkResult[0].manifest.dependencies).toStrictEqual({ '@pnpm.e2e/foo': '^100.0.0' })
})
test('unlink 2 packages. One of them exists in package.json', async () => {
+2 -1
View File
@@ -16,13 +16,14 @@
},
"devDependencies": {
"@pnpm/assert-project": "workspace:*",
"@pnpm/cafs": "4.3.0",
"@pnpm/client": "workspace:*",
"@pnpm/headless": "workspace:*",
"@pnpm/logger": "^4.0.0",
"@pnpm/package-store": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/read-projects-context": "workspace:*",
"@pnpm/registry-mock": "3.0.0-0",
"@pnpm/registry-mock": "3.0.0-2",
"@pnpm/store-path": "workspace:*",
"@pnpm/test-fixtures": "workspace:*",
"@types/fs-extra": "^9.0.13",
@@ -5,6 +5,6 @@
},
"dependencies": {
"json-append": "1.1.1",
"pre-and-postinstall-scripts-example": "*"
"@pnpm.e2e/pre-and-postinstall-scripts-example": "*"
}
}
+15 -15
View File
@@ -1,15 +1,27 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
'@pnpm.e2e/pre-and-postinstall-scripts-example': '*'
json-append: 1.1.1
pre-and-postinstall-scripts-example: '*'
dependencies:
'@pnpm.e2e/pre-and-postinstall-scripts-example': 1.0.0
json-append: 1.1.1
pre-and-postinstall-scripts-example: 1.0.0
packages:
/@pnpm.e2e/hello-world-js-bin/1.0.0:
resolution: {integrity: sha512-3f6ugQfqFW9GR36OSeTfsSNlup7hIslT23haX3dvT/e5GyU3iInat3+0GI+MqvRcwcNzsBrTJq7yDWp3wk7O/Q==}
hasBin: true
dev: false
/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0:
resolution: {integrity: sha512-RWys6ZQfGRl4enR2IZv+Ear9h5v0p1LjwY36bxkBgJCEAV9lP1DksvXa3hATKgG9r3/FrkESKSwlMwZ8vLNgAg==}
requiresBuild: true
dependencies:
'@pnpm.e2e/hello-world-js-bin': 1.0.0
dev: false
/buffer-from/1.1.2:
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
dev: false
@@ -28,11 +40,6 @@ packages:
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
dev: false
/hello-world-js-bin/1.0.0:
resolution: {integrity: sha512-0wmzOwltlD4Vy3XHbJlASP2OOZOOk39jbxWVQdohHQPiSPq7UDKUMkykrl+09FjPhanu2c3DuCmRA0Jy9Hf8rQ==}
hasBin: true
dev: false
/inherits/2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
dev: false
@@ -48,13 +55,6 @@ packages:
concat-stream: 1.6.2
dev: false
/pre-and-postinstall-scripts-example/1.0.0:
resolution: {integrity: sha512-LiigIO18SIBX0gjNcFRC4nU1L8+Ioysy0NMSZoMIy4fbOm35FxzpDVAcPeFisqbdXPYu166MdlMvla36ySS5qA==}
requiresBuild: true
dependencies:
hello-world-js-bin: 1.0.0
dev: false
/process-nextick-args/2.0.1:
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
dev: false
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
glob: ^7.0.5
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
glob: ^7.0.5
@@ -2,6 +2,6 @@
"name": "has-incompatible-optional-subdep",
"version": "1.0.0",
"dependencies": {
"pkg-with-optional": "1.0.0"
"@pnpm.e2e/pkg-with-optional": "1.0.0"
}
}
@@ -1,29 +1,29 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
pkg-with-optional: 1.0.0
'@pnpm.e2e/pkg-with-optional': 1.0.0
dependencies:
pkg-with-optional: 1.0.0
'@pnpm.e2e/pkg-with-optional': 1.0.0
packages:
/dep-of-optional-pkg/1.0.0:
resolution: {integrity: sha512-fsFDBo/KrUZ9ljybu85d3mkr17LoTh3zV9TLncEddZkJ9GD9ql0ZVdftdAlsS46LdfeNKgte/2erZ8euekhWKQ==}
/@pnpm.e2e/dep-of-optional-pkg/1.0.0:
resolution: {integrity: sha512-ouCWx8q98JzIJ/Ef2Ny6uvHYWxe+T2irzTBhntx/31Jd+1QxbGVETO8yJXrDZyuD3rBGaZULj78gIcwa068fAA==}
dev: false
optional: true
/not-compatible-with-any-os/1.0.0:
resolution: {integrity: sha512-vTrzbhOeYAAhfduz8iCEmTC+512IDxBAaDLl3C6d3S+KOIKhSInhQbaTO3di+h7NND/2YpGUG4WmgGvAhzAcrA==}
/@pnpm.e2e/not-compatible-with-any-os/1.0.0:
resolution: {integrity: sha512-8sAm2PvHtibzjUYOXrmvmHXhthl7mD582GNDjhQ7CrQblo084OiAjNGaLka4vXXWF93LVaJ91btIRCECJPFLXw==}
os: [this-os-does-not-exist]
requiresBuild: true
dependencies:
dep-of-optional-pkg: 1.0.0
'@pnpm.e2e/dep-of-optional-pkg': 1.0.0
dev: false
optional: true
/pkg-with-optional/1.0.0:
resolution: {integrity: sha512-gGOtjrYcYG9FHYHHzaerrVwi5bRmPwrjYlm89lqr4j4HgtYNPXUN8skpzHjKvntregnF3K9dn0z2XxMQrLtydA==}
/@pnpm.e2e/pkg-with-optional/1.0.0:
resolution: {integrity: sha512-Er5ld8foGmtV7tEzjy8NPYoA9MkUfAe7iU4dx/5wpPYhX32+SUqML8iG2RmjqrVdCDFzRepG3zSP6RcCTVaMPQ==}
optionalDependencies:
not-compatible-with-any-os: 1.0.0
'@pnpm.e2e/not-compatible-with-any-os': 1.0.0
dev: false
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
tar-pkg: file:../tar-pkg-1.0.0.tgz
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
example: link:example
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
'@zkochan/not-exists': 1.2.0
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
has-flag: 1.0.0
@@ -14,6 +14,11 @@ packages:
/debug/2.6.9:
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.0.0
dev: false
@@ -117,6 +122,8 @@ packages:
on-finished: 2.3.0
range-parser: 1.2.1
statuses: 1.5.0
transitivePeerDependencies:
- supports-color
dev: false
/setprototypeof/1.2.0:
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
inflight: 1.0.6
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
pnpm-default-reporter: 0.14.7
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
expire-fs: 2.2.3
+1 -1
View File
@@ -1,5 +1,5 @@
{
"dependencies": {
"pre-and-postinstall-scripts-example": "1.0.0"
"@pnpm.e2e/pre-and-postinstall-scripts-example": "1.0.0"
}
}
+8 -8
View File
@@ -1,21 +1,21 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
pre-and-postinstall-scripts-example: 1.0.0
'@pnpm.e2e/pre-and-postinstall-scripts-example': 1.0.0
dependencies:
pre-and-postinstall-scripts-example: 1.0.0
'@pnpm.e2e/pre-and-postinstall-scripts-example': 1.0.0
packages:
/hello-world-js-bin/1.0.0:
resolution: {integrity: sha512-0wmzOwltlD4Vy3XHbJlASP2OOZOOk39jbxWVQdohHQPiSPq7UDKUMkykrl+09FjPhanu2c3DuCmRA0Jy9Hf8rQ==}
/@pnpm.e2e/hello-world-js-bin/1.0.0:
resolution: {integrity: sha512-3f6ugQfqFW9GR36OSeTfsSNlup7hIslT23haX3dvT/e5GyU3iInat3+0GI+MqvRcwcNzsBrTJq7yDWp3wk7O/Q==}
hasBin: true
dev: false
/pre-and-postinstall-scripts-example/1.0.0:
resolution: {integrity: sha512-LiigIO18SIBX0gjNcFRC4nU1L8+Ioysy0NMSZoMIy4fbOm35FxzpDVAcPeFisqbdXPYu166MdlMvla36ySS5qA==}
/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0:
resolution: {integrity: sha512-RWys6ZQfGRl4enR2IZv+Ear9h5v0p1LjwY36bxkBgJCEAV9lP1DksvXa3hATKgG9r3/FrkESKSwlMwZ8vLNgAg==}
requiresBuild: true
dependencies:
hello-world-js-bin: 1.0.0
'@pnpm.e2e/hello-world-js-bin': 1.0.0
dev: false
@@ -3,7 +3,7 @@
"version": "1.0.0",
"dependencies": {
"is-positive": "^1.0.0",
"pkg-with-peer-having-bin": "1.0.0",
"@pnpm.e2e/pkg-with-peer-having-bin": "1.0.0",
"rimraf": "^2.6.2"
},
"devDependencies": {
+16 -16
View File
@@ -1,15 +1,15 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
'@pnpm.e2e/pkg-with-peer-having-bin': 1.0.0
colors: 1.2.0
is-negative: ^2.1.0
is-positive: ^1.0.0
pkg-with-peer-having-bin: 1.0.0
rimraf: ^2.6.2
dependencies:
'@pnpm.e2e/pkg-with-peer-having-bin': 1.0.0
is-positive: 1.0.0
pkg-with-peer-having-bin: 1.0.0
rimraf: 2.7.1
optionalDependencies:
@@ -20,6 +20,19 @@ devDependencies:
packages:
/@pnpm.e2e/hello-world-js-bin/1.0.0:
resolution: {integrity: sha512-3f6ugQfqFW9GR36OSeTfsSNlup7hIslT23haX3dvT/e5GyU3iInat3+0GI+MqvRcwcNzsBrTJq7yDWp3wk7O/Q==}
hasBin: true
dev: false
/@pnpm.e2e/pkg-with-peer-having-bin/1.0.0:
resolution: {integrity: sha512-bbL3oe5SBIz54k276vb4pR5T0ZrKZ2p2+OObfMMtkG43nCfwRBca3+WAqKjs9pIu2c4vUFhnU4rcqdbeuJkIbg==}
peerDependencies:
'@pnpm.e2e/peer-with-bin': ^1.0.0
dependencies:
'@pnpm.e2e/hello-world-js-bin': 1.0.0
dev: false
/balanced-match/1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
dev: false
@@ -57,11 +70,6 @@ packages:
path-is-absolute: 1.0.1
dev: false
/hello-world-js-bin/1.0.0:
resolution: {integrity: sha512-0wmzOwltlD4Vy3XHbJlASP2OOZOOk39jbxWVQdohHQPiSPq7UDKUMkykrl+09FjPhanu2c3DuCmRA0Jy9Hf8rQ==}
hasBin: true
dev: false
/inflight/1.0.6:
resolution: {integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=}
dependencies:
@@ -100,14 +108,6 @@ packages:
engines: {node: '>=0.10.0'}
dev: false
/pkg-with-peer-having-bin/1.0.0:
resolution: {integrity: sha512-nkUSkBlH/EOCd3WhpWCeDLsl5In3oXLLQ83miHtqDzg7VG9ODhMcz/vYIUhSy9b7d8csEYS/0O30zjA/evqvrA==}
peerDependencies:
peer-with-bin: ^1.0.0
dependencies:
hello-world-js-bin: 1.0.0
dev: false
/rimraf/2.7.1:
resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==}
hasBin: true
+2 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
colors: 1.2.0
@@ -34,6 +34,7 @@ packages:
/colors/1.2.0:
resolution: {integrity: sha512-lweugcX5nailCqZBttArTojZZpHGWhmFJX78KJHlxwhM8tLAy5QCgRgRxrubrksdvA+2Y3inWG5TToyyjL82BQ==}
engines: {node: '>=0.1.90'}
requiresBuild: true
dev: false
optional: true
@@ -2,7 +2,7 @@
"name": "simple-with-optional-dep",
"version": "1.0.0",
"dependencies": {
"pkg-with-good-optional": "*"
"@pnpm.e2e/pkg-with-good-optional": "*"
},
"optionalDependencies": {
"is-positive": "1.0.0"
+14 -14
View File
@@ -1,32 +1,32 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
'@pnpm.e2e/pkg-with-good-optional': '*'
is-positive: 1.0.0
pkg-with-good-optional: '*'
dependencies:
pkg-with-good-optional: 1.0.0
'@pnpm.e2e/pkg-with-good-optional': 1.0.0
optionalDependencies:
is-positive: 1.0.0
packages:
/dep-of-pkg-with-1-dep/100.0.0:
resolution: {integrity: sha512-SHFc2UqTM7Vkk6n1stpLu3xRIBJniuiHhByk2ZXJ9RGepHH6WUbRlxRvhGPpIVYfcvtcag9NGPtoS/zTN2fnjA==}
/@pnpm.e2e/dep-of-pkg-with-1-dep/101.0.0:
resolution: {integrity: sha512-v/FQPTv+Y6j/J5a7ymlifFIhJa28wROyiTfg1vcAVKdJ9S94E32CHVUbzgvdcu9pAkLqe7INiwJ2ynqmgiTiiw==}
dev: false
/@pnpm.e2e/pkg-with-good-optional/1.0.0:
resolution: {integrity: sha512-nHI1OeIwd3u8wEhHBIgbJmK6ryrums0YrxVB3RHkpbXXeI3YFsxiv0T0+MuQc7ajXT5/pwUvkyo2g2n37cWuRA==}
dependencies:
'@pnpm.e2e/dep-of-pkg-with-1-dep': 101.0.0
optionalDependencies:
is-positive: 1.0.0
dev: false
/is-positive/1.0.0:
resolution: {integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss=}
resolution: {integrity: sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==}
engines: {node: '>=0.10.0'}
requiresBuild: true
dev: false
optional: true
/pkg-with-good-optional/1.0.0:
resolution: {integrity: sha512-wDCpH6PTS5BCNi3ugdM0xzVYNEeKcl8o5Zm+FxQuNU4WJsTCrRrPXN9r8T4UNT+kgIZzIY5bx8rcPlAzYYWOXw==}
dependencies:
dep-of-pkg-with-1-dep: 100.0.0
optionalDependencies:
is-positive: 1.0.0
dev: false
+2 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
colors: 1.2.0
@@ -32,6 +32,7 @@ packages:
/colors/1.2.0:
resolution: {integrity: sha512-lweugcX5nailCqZBttArTojZZpHGWhmFJX78KJHlxwhM8tLAy5QCgRgRxrubrksdvA+2Y3inWG5TToyyjL82BQ==}
engines: {node: '>=0.1.90'}
requiresBuild: true
dev: false
optional: true
+1 -1
View File
@@ -1,4 +1,4 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
rimraf: 2.5.1
+11 -9
View File
@@ -2,6 +2,7 @@
import { promises as fs, existsSync, realpathSync, writeFileSync } from 'fs'
import path from 'path'
import assertProject from '@pnpm/assert-project'
import { getFilePathInCafs } from '@pnpm/cafs'
import { ENGINE_NAME, WANTED_LOCKFILE } from '@pnpm/constants'
import {
PackageManifestLog,
@@ -15,7 +16,7 @@ import { read as readModulesYaml } from '@pnpm/modules-yaml'
import { tempDir } from '@pnpm/prepare'
import { fromDir as readPackageJsonFromDir } from '@pnpm/read-package-json'
import readprojectsContext from '@pnpm/read-projects-context'
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
import fixtures from '@pnpm/test-fixtures'
import rimraf from '@zkochan/rimraf'
import loadJsonFile from 'load-json-file'
@@ -296,7 +297,7 @@ test('not installing optional deps', async () => {
const project = assertProject(prefix)
await project.hasNot('is-positive')
await project.has('pkg-with-good-optional')
await project.has('@pnpm.e2e/pkg-with-good-optional')
})
test('skipping optional dependency if it cannot be fetched', async () => {
@@ -327,10 +328,10 @@ test('run pre/postinstall scripts', async () => {
await headless(await testDefaults({ lockfileDir: prefix }))
const project = assertProject(prefix)
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
const generatedByPreinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall')
expect(typeof generatedByPreinstall).toBe('function')
const generatedByPostinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-postinstall')
const generatedByPostinstall = project.requireModule('@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall')
expect(typeof generatedByPostinstall).toBe('function')
expect(require(path.join(prefix, 'output.json'))).toStrictEqual(['install', 'postinstall']) // eslint-disable-line
@@ -344,7 +345,7 @@ test('run pre/postinstall scripts', async () => {
const nmPath = path.join(prefix, 'node_modules')
const modulesYaml = await readModulesYaml(nmPath)
expect(modulesYaml).toBeTruthy()
expect(modulesYaml!.pendingBuilds).toStrictEqual(['.', '/pre-and-postinstall-scripts-example/1.0.0'])
expect(modulesYaml!.pendingBuilds).toStrictEqual(['.', '/@pnpm.e2e/pre-and-postinstall-scripts-example/1.0.0'])
})
test('orphan packages are removed', async () => {
@@ -685,10 +686,11 @@ test.each([['isolated'], ['hoisted']])('using side effects cache with nodeLinker
}, {}, {}, { packageImportMethod: 'copy' })
await headless(opts)
const cacheIntegrityPath = path.join(opts.storeDir, 'files/2e/28a020ed7c488057d208cd705442e275352fcf88a32b32d0d312668308cb87db3a6df9171ce90d501c3de162b2a6dd5cf62ed7ae8c76532f95adfac924b9a8-index.json')
const cafsDir = path.join(opts.storeDir, 'files')
const cacheIntegrityPath = getFilePathInCafs(cafsDir, getIntegrity('@pnpm.e2e/pre-and-postinstall-scripts-example', '1.0.0'), 'index')
const cacheIntegrity = await loadJsonFile(cacheIntegrityPath)
expect(cacheIntegrity!['sideEffects']).toBeTruthy()
const sideEffectsKey = `${ENGINE_NAME}-${JSON.stringify({ '/hello-world-js-bin/1.0.0': {} })}`
const sideEffectsKey = `${ENGINE_NAME}-${JSON.stringify({ '/@pnpm.e2e/hello-world-js-bin/1.0.0': {} })}`
expect(cacheIntegrity).toHaveProperty(['sideEffects', sideEffectsKey, 'generated-by-postinstall.js'])
delete cacheIntegrity!['sideEffects'][sideEffectsKey]['generated-by-postinstall.js']
@@ -706,8 +708,8 @@ test.each([['isolated'], ['hoisted']])('using side effects cache with nodeLinker
}, {}, {}, { packageImportMethod: 'copy' })
await headless(opts2)
expect(await exists(path.join(prefix, 'node_modules/pre-and-postinstall-scripts-example/generated-by-postinstall.js'))).toBeFalsy()
expect(await exists(path.join(prefix, 'node_modules/pre-and-postinstall-scripts-example/generated-by-preinstall.js'))).toBeTruthy()
expect(await exists(path.join(prefix, 'node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-postinstall.js'))).toBeFalsy()
expect(await exists(path.join(prefix, 'node_modules/@pnpm.e2e/pre-and-postinstall-scripts-example/generated-by-preinstall.js'))).toBeTruthy()
})
test.skip('using side effects cache and hoistPattern=*', async () => {
+3
View File
@@ -21,6 +21,9 @@
{
"path": "../build-modules"
},
{
"path": "../cafs"
},
{
"path": "../calc-dep-state"
},
+1 -1
View File
@@ -68,7 +68,7 @@
"@pnpm/create-cafs-store": "workspace:*",
"@pnpm/logger": "^4.0.0",
"@pnpm/package-requester": "workspace:*",
"@pnpm/registry-mock": "3.0.0-0",
"@pnpm/registry-mock": "3.0.0-2",
"@pnpm/test-fixtures": "workspace:*",
"@types/normalize-path": "^3.0.0",
"@types/ramda": "0.28.15",
+2 -2
View File
@@ -786,7 +786,7 @@ test('do not fetch an optional package that is not installable', async () => {
expect(typeof requestPackage).toBe('function')
const projectDir = tempy.directory()
const pkgResponse = await requestPackage({ alias: 'not-compatible-with-any-os', optional: true, pref: '*' }, {
const pkgResponse = await requestPackage({ alias: '@pnpm.e2e/not-compatible-with-any-os', optional: true, pref: '*' }, {
downloadPriority: 0,
lockfileDir: projectDir,
preferredVersions: {},
@@ -798,7 +798,7 @@ test('do not fetch an optional package that is not installable', async () => {
expect(pkgResponse.body).toBeTruthy()
expect(pkgResponse.body.isInstallable).toBe(false)
expect(pkgResponse.body.id).toBe(`localhost+${REGISTRY_MOCK_PORT}/not-compatible-with-any-os/1.0.0`)
expect(pkgResponse.body.id).toBe(`localhost+${REGISTRY_MOCK_PORT}/@pnpm.e2e/not-compatible-with-any-os/1.0.0`)
expect(pkgResponse.files).toBeFalsy()
expect(pkgResponse.finishing).toBeFalsy()
+1 -1
View File
@@ -43,7 +43,7 @@
"@pnpm/logger": "^4.0.0",
"@pnpm/plugin-commands-deploy": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "3.0.0-0"
"@pnpm/registry-mock": "3.0.0-2"
},
"dependencies": {
"@pnpm/cli-utils": "workspace:*",
@@ -39,7 +39,7 @@
"@pnpm/modules-yaml": "workspace:*",
"@pnpm/plugin-commands-installation": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "3.0.0-0",
"@pnpm/registry-mock": "3.0.0-2",
"@pnpm/test-fixtures": "workspace:*",
"@types/is-ci": "^3.0.0",
"@types/proxyquire": "^1.3.28",
@@ -324,7 +324,7 @@ test('pnpm add automatically installs missing peer dependencies', async () => {
autoInstallPeers: true,
dir: process.cwd(),
linkWorkspacePackages: false,
}, ['abc@1.0.0'])
}, ['@pnpm.e2e/abc@1.0.0'])
const lockfile = await project.readLockfile()
expect(Object.keys(lockfile.packages).length).toBe(5)
@@ -44,12 +44,12 @@ test('globally installed package is linked with active version of Node.js', asyn
global: true,
linkWorkspacePackages: false,
pnpmHomeDir: path.dirname(nodeExecPath),
}, ['hello-world-js-bin'])
}, ['@pnpm.e2e/hello-world-js-bin'])
const manifest = (await import(path.resolve('package.json')))
expect(
manifest.dependenciesMeta['hello-world-js-bin']?.node
manifest.dependenciesMeta['@pnpm.e2e/hello-world-js-bin']?.node
).toBeTruthy()
const shimContent = await fs.readFile('node_modules/.bin/hello-world-js-bin', 'utf-8')
@@ -64,7 +64,7 @@ test('globally installed package isn not linked with active version of Node.js i
global: true,
linkWorkspacePackages: false,
pnpmHomeDir: path.resolve('pnpm-home'),
}, ['hello-world-js-bin'])
}, ['@pnpm.e2e/hello-world-js-bin'])
const manifest = (await import(path.resolve('package.json')))
@@ -43,7 +43,7 @@ const DEFAULT_OPTS = {
}
test('import from package-lock.json', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
f.prepare('has-package-lock-json')
await importCommand.handler({
@@ -53,16 +53,16 @@ test('import from package-lock.json', async () => {
const project = assertProject(process.cwd())
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
// node_modules is not created
await project.hasNot('dep-of-pkg-with-1-dep')
await project.hasNot('pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/dep-of-pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/pkg-with-1-dep')
})
test('import from yarn.lock', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
f.prepare('has-yarn-lock')
@@ -73,12 +73,12 @@ test('import from yarn.lock', async () => {
const project = assertProject(process.cwd())
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
// node_modules is not created
await project.hasNot('dep-of-pkg-with-1-dep')
await project.hasNot('pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/dep-of-pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/pkg-with-1-dep')
})
test('import from yarn2 lock file', async () => {
@@ -101,7 +101,7 @@ test('import from yarn2 lock file', async () => {
})
test('import from npm-shrinkwrap.json', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
f.prepare('has-npm-shrinkwrap-json')
@@ -112,12 +112,12 @@ test('import from npm-shrinkwrap.json', async () => {
const project = assertProject(process.cwd())
const lockfile = await project.readLockfile()
expect(lockfile.packages).toHaveProperty(['/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/dep-of-pkg-with-1-dep/100.1.0'])
expect(lockfile.packages).toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.0.0'])
expect(lockfile.packages).not.toHaveProperty(['/@pnpm.e2e/dep-of-pkg-with-1-dep/100.1.0'])
// node_modules is not created
await project.hasNot('dep-of-pkg-with-1-dep')
await project.hasNot('pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/dep-of-pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/pkg-with-1-dep')
})
test('import fails when no lockfiles are found', async () => {
@@ -75,7 +75,7 @@ test('link global bin', async function () {
test('relative link', async () => {
const project = prepare({
dependencies: {
'hello-world-js-bin': '*',
'@pnpm.e2e/hello-world-js-bin': '*',
},
})
@@ -96,17 +96,17 @@ test('relative link', async () => {
await linkedProject.isExecutable('.bin/cowsay')
const wantedLockfile = await project.readLockfile()
expect(wantedLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
expect(wantedLockfile.specifiers['hello-world-js-bin']).toBe('*') // specifier of linked dependency added to ${WANTED_LOCKFILE}
expect(wantedLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
expect(wantedLockfile.specifiers['@pnpm.e2e/hello-world-js-bin']).toBe('*') // specifier of linked dependency added to ${WANTED_LOCKFILE}
const currentLockfile = await project.readCurrentLockfile()
expect(currentLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
expect(currentLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
})
test('absolute link', async () => {
const project = prepare({
dependencies: {
'hello-world-js-bin': '*',
'@pnpm.e2e/hello-world-js-bin': '*',
},
})
@@ -127,11 +127,11 @@ test('absolute link', async () => {
await linkedProject.isExecutable('.bin/cowsay')
const wantedLockfile = await project.readLockfile()
expect(wantedLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
expect(wantedLockfile.specifiers['hello-world-js-bin']).toBe('*') // specifier of linked dependency added to ${WANTED_LOCKFILE}
expect(wantedLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
expect(wantedLockfile.specifiers['@pnpm.e2e/hello-world-js-bin']).toBe('*') // specifier of linked dependency added to ${WANTED_LOCKFILE}
const currentLockfile = await project.readCurrentLockfile()
expect(currentLockfile.dependencies['hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
expect(currentLockfile.dependencies['@pnpm.e2e/hello-world-js-bin']).toBe('link:../hello-world-js-bin') // link added to wanted lockfile
})
test('link --production', async () => {
@@ -284,7 +284,7 @@ test('recursive installation fails when installation in one of the packages fail
version: '1.0.0',
dependencies: {
'this-pkg-does-not-exist': '100.100.100',
'@pnpm.e2e/this-pkg-does-not-exist': '100.100.100',
},
},
{
@@ -651,7 +651,7 @@ test('recursive install in a monorepo with different modules directories', async
test('prefer-workspace-package', async () => {
await addDistTag({
distTag: 'latest',
package: 'foo',
package: '@pnpm.e2e/foo',
version: '100.1.0',
})
preparePackages([
@@ -660,12 +660,15 @@ test('prefer-workspace-package', async () => {
version: '1.0.0',
dependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
},
{
name: 'foo',
version: '100.0.0',
location: 'foo',
package: {
name: '@pnpm.e2e/foo',
version: '100.0.0',
},
},
])
@@ -683,7 +686,7 @@ test('prefer-workspace-package', async () => {
})
const lockfile = await readYamlFile<Lockfile>(path.resolve('pnpm-lock.yaml'))
expect(lockfile.importers['project-1'].dependencies?.foo).toBe('link:../foo')
expect(lockfile.importers['project-1'].dependencies?.['@pnpm.e2e/foo']).toBe('link:../foo')
})
test('installing in monorepo with shared lockfile should work on virtual drives', async () => {
@@ -67,7 +67,7 @@ test('prune keeps hoisted dependencies', async () => {
cacheDir,
dir: process.cwd(),
storeDir,
}, ['pkg-with-1-dep@100.0.0'])
}, ['@pnpm.e2e/pkg-with-1-dep@100.0.0'])
await prune.handler({
...DEFAULT_OPTIONS,
@@ -76,7 +76,7 @@ test('prune keeps hoisted dependencies', async () => {
storeDir,
})
await project.hasNot('dep-of-pkg-with-1-dep')
await project.hasNot('@pnpm.e2e/dep-of-pkg-with-1-dep')
})
test('prune removes dev dependencies', async () => {
@@ -52,8 +52,8 @@ test('recursive update', async () => {
})
test('recursive update prod dependencies only', async () => {
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
preparePackages([
{
@@ -61,7 +61,7 @@ test('recursive update prod dependencies only', async () => {
version: '1.0.0',
dependencies: {
foo: '^100.0.0',
'@pnpm.e2e/foo': '^100.0.0',
},
},
{
@@ -69,7 +69,7 @@ test('recursive update prod dependencies only', async () => {
version: '1.0.0',
devDependencies: {
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
},
])
@@ -86,8 +86,8 @@ test('recursive update prod dependencies only', async () => {
workspaceDir: process.cwd(),
})
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' })
await update.handler({
...DEFAULT_OPTS,
@@ -112,7 +112,7 @@ test('recursive update prod dependencies only', async () => {
expect(
Object.keys(lockfile.packages ?? {})
).toStrictEqual(
['/bar/100.0.0', '/foo/100.1.0']
['/@pnpm.e2e/bar/100.0.0', '/@pnpm.e2e/foo/100.1.0']
)
const modules = await modulesYaml.read('./node_modules')
expect(modules?.included).toStrictEqual({
@@ -129,7 +129,7 @@ test('recursive update with pattern', async () => {
version: '1.0.0',
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/foo': '1.0.0',
},
},
@@ -138,7 +138,7 @@ test('recursive update with pattern', async () => {
version: '1.0.0',
dependencies: {
'peer-c': '1.0.0',
'@pnpm.e2e/peer-c': '1.0.0',
},
},
])
@@ -153,8 +153,8 @@ test('recursive update with pattern', async () => {
workspaceDir: process.cwd(),
})
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '2.0.0', distTag: 'latest' })
await update.handler({
@@ -165,18 +165,18 @@ test('recursive update with pattern', async () => {
recursive: true,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['peer-*', 'dep-of-pkg-*'])
}, ['@pnpm.e2e/peer-*', '@pnpm.e2e/dep-of-pkg-*'])
expect(projects['project-1'].requireModule('dep-of-pkg-with-1-dep/package.json').version).toBe('100.1.0')
expect(projects['project-1'].requireModule('@pnpm.e2e/dep-of-pkg-with-1-dep/package.json').version).toBe('100.1.0')
expect(projects['project-1'].requireModule('@pnpm.e2e/foo/package.json').version).toBe('1.0.0')
expect(projects['project-2'].requireModule('peer-c/package.json').version).toBe('2.0.0')
expect(projects['project-2'].requireModule('@pnpm.e2e/peer-c/package.json').version).toBe('2.0.0')
})
test('recursive update with pattern and name in project', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: 'print-version', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/print-version', version: '2.0.0', distTag: 'latest' })
const projects = preparePackages([
{
@@ -184,7 +184,7 @@ test('recursive update with pattern and name in project', async () => {
version: '1.0.0',
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/foo': '1.0.0',
},
},
@@ -193,8 +193,8 @@ test('recursive update with pattern and name in project', async () => {
version: '1.0.0',
dependencies: {
'peer-c': '1.0.0',
'print-version': '1.0.0',
'@pnpm.e2e/peer-c': '1.0.0',
'@pnpm.e2e/print-version': '1.0.0',
},
},
])
@@ -224,7 +224,7 @@ test('recursive update with pattern and name in project', async () => {
recursive: true,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['this-does-not-exist'])
}, ['@pnpm.e2e/this-does-not-exist'])
} catch (_err: any) { // eslint-disable-line
err = _err
}
@@ -241,7 +241,7 @@ test('recursive update with pattern and name in project', async () => {
recursive: true,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['this-does-not-exist'])
}, ['@pnpm.e2e/this-does-not-exist'])
await update.handler({
...DEFAULT_OPTS,
@@ -252,18 +252,18 @@ test('recursive update with pattern and name in project', async () => {
recursive: true,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['peer-*', 'dep-of-pkg-*', 'print-version'])
}, ['@pnpm.e2e/peer-*', '@pnpm.e2e/dep-of-pkg-*', '@pnpm.e2e/print-version'])
expect(projects['project-1'].requireModule('dep-of-pkg-with-1-dep/package.json').version).toBe('100.1.0')
expect(projects['project-1'].requireModule('@pnpm.e2e/dep-of-pkg-with-1-dep/package.json').version).toBe('100.1.0')
expect(projects['project-1'].requireModule('@pnpm.e2e/foo/package.json').version).toBe('1.0.0')
expect(projects['project-2'].requireModule('peer-c/package.json').version).toBe('2.0.0')
expect(projects['project-2'].requireModule('print-version/package.json').version).toBe('2.0.0')
expect(projects['project-2'].requireModule('@pnpm.e2e/peer-c/package.json').version).toBe('2.0.0')
expect(projects['project-2'].requireModule('@pnpm.e2e/print-version/package.json').version).toBe('2.0.0')
})
test('recursive update --latest foo should only update projects that have foo', async () => {
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'qar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/qar', version: '100.0.0', distTag: 'latest' })
preparePackages([
{
@@ -271,8 +271,8 @@ test('recursive update --latest foo should only update projects that have foo',
version: '1.0.0',
dependencies: {
foo: '100.0.0',
qar: '100.0.0',
'@pnpm.e2e/foo': '100.0.0',
'@pnpm.e2e/qar': '100.0.0',
},
},
{
@@ -281,7 +281,7 @@ test('recursive update --latest foo should only update projects that have foo',
dependencies: {
'@zkochan/async-regex-replace': '0.1.0',
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
},
])
@@ -299,8 +299,8 @@ test('recursive update --latest foo should only update projects that have foo',
workspaceDir: process.cwd(),
})
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' })
await update.handler({
...DEFAULT_OPTS,
@@ -311,22 +311,22 @@ test('recursive update --latest foo should only update projects that have foo',
recursive: true,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['@zkochan/async-regex-replace', 'foo', 'qar@100.1.0'])
}, ['@zkochan/async-regex-replace', '@pnpm.e2e/foo', '@pnpm.e2e/qar@100.1.0'])
const lockfile = await readYamlFile<Lockfile>('./pnpm-lock.yaml')
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual([
expect(Object.keys(lockfile.packages ?? {}).sort()).toStrictEqual([
'/@zkochan/async-regex-replace/0.2.0',
'/bar/100.0.0',
'/foo/100.1.0',
'/qar/100.1.0',
])
'/@pnpm.e2e/bar/100.0.0',
'/@pnpm.e2e/foo/100.1.0',
'/@pnpm.e2e/qar/100.1.0',
].sort())
})
test('recursive update --latest foo should only update packages that have foo', async () => {
await addDistTag({ package: 'foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: 'qar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/qar', version: '100.0.0', distTag: 'latest' })
const projects = preparePackages([
{
@@ -334,8 +334,8 @@ test('recursive update --latest foo should only update packages that have foo',
version: '1.0.0',
dependencies: {
foo: '100.0.0',
qar: '100.0.0',
'@pnpm.e2e/foo': '100.0.0',
'@pnpm.e2e/qar': '100.0.0',
},
},
{
@@ -343,7 +343,7 @@ test('recursive update --latest foo should only update packages that have foo',
version: '1.0.0',
dependencies: {
bar: '^100.0.0',
'@pnpm.e2e/bar': '^100.0.0',
},
},
])
@@ -358,8 +358,8 @@ test('recursive update --latest foo should only update packages that have foo',
workspaceDir: process.cwd(),
})
await addDistTag({ package: 'foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: 'bar', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/bar', version: '100.1.0', distTag: 'latest' })
await update.handler({
...DEFAULT_OPTS,
@@ -369,18 +369,18 @@ test('recursive update --latest foo should only update packages that have foo',
recursive: true,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['foo', 'qar@100.1.0'])
}, ['@pnpm.e2e/foo', '@pnpm.e2e/qar@100.1.0'])
{
const lockfile = await projects['project-1'].readLockfile()
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual(['/foo/100.1.0', '/qar/100.1.0'])
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual(['/@pnpm.e2e/foo/100.1.0', '/@pnpm.e2e/qar/100.1.0'])
}
{
const lockfile = await projects['project-2'].readLockfile()
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual(['/bar/100.0.0'])
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual(['/@pnpm.e2e/bar/100.0.0'])
}
})
@@ -8,14 +8,14 @@ import loadJsonFile from 'load-json-file'
import { DEFAULT_OPTS } from '../utils'
test('update with "*" pattern', async () => {
await addDistTag({ package: 'peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '2.0.0', distTag: 'latest' })
const project = prepare({
dependencies: {
'peer-a': '1.0.0',
'peer-c': '1.0.0',
'@pnpm.e2e/peer-a': '1.0.0',
'@pnpm.e2e/peer-c': '1.0.0',
'@pnpm.e2e/foo': '1.0.0',
},
})
@@ -31,12 +31,12 @@ test('update with "*" pattern', async () => {
dir: process.cwd(),
latest: true,
workspaceDir: process.cwd(),
}, ['peer-*'])
}, ['@pnpm.e2e/peer-*'])
const lockfile = await project.readLockfile()
expect(lockfile.packages['/peer-a/1.0.1']).toBeTruthy()
expect(lockfile.packages['/peer-c/2.0.0']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/peer-a/1.0.1']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/peer-c/2.0.0']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/foo/1.0.0']).toBeTruthy()
})
@@ -74,8 +74,8 @@ describe('update by package name', () => {
beforeAll(async () => {
prepare({
dependencies: {
'peer-a': '1.0.0',
'peer-c': '1.0.0',
'@pnpm.e2e/peer-a': '1.0.0',
'@pnpm.e2e/peer-c': '1.0.0',
},
})
await install.handler({
@@ -93,7 +93,7 @@ describe('update by package name', () => {
dir: process.cwd(),
sharedWorkspaceLockfile: true,
workspaceDir: process.cwd(),
}, ['peer-b'])
}, ['@pnpm.e2e/peer-b'])
} catch (_err: any) { // eslint-disable-line
err = _err
}
@@ -106,16 +106,16 @@ describe('update by package name', () => {
dir: process.cwd(),
sharedWorkspaceLockfile: true,
workspaceDir: process.cwd(),
}, ['peer-b'])
}, ['@pnpm.e2e/peer-b'])
})
})
test('update --no-save should not update package.json and pnpm-lock.yaml', async () => {
await addDistTag({ package: 'peer-a', version: '1.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.0', distTag: 'latest' })
const project = prepare({
dependencies: {
'peer-a': '^1.0.0',
'@pnpm.e2e/peer-a': '^1.0.0',
},
})
@@ -127,14 +127,14 @@ test('update --no-save should not update package.json and pnpm-lock.yaml', async
{
const manifest = await loadJsonFile<ProjectManifest>('package.json')
expect(manifest.dependencies?.['peer-a']).toBe('^1.0.0')
expect(manifest.dependencies?.['@pnpm.e2e/peer-a']).toBe('^1.0.0')
const lockfile = await project.readLockfile()
expect(lockfile.specifiers['peer-a']).toBe('^1.0.0')
expect(lockfile.packages['/peer-a/1.0.0']).toBeTruthy()
expect(lockfile.specifiers['@pnpm.e2e/peer-a']).toBe('^1.0.0')
expect(lockfile.packages['/@pnpm.e2e/peer-a/1.0.0']).toBeTruthy()
}
await addDistTag({ package: 'peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' })
await update.handler({
...DEFAULT_OPTS,
@@ -146,27 +146,27 @@ test('update --no-save should not update package.json and pnpm-lock.yaml', async
{
const manifest = await loadJsonFile<ProjectManifest>('package.json')
expect(manifest.dependencies?.['peer-a']).toBe('^1.0.0')
expect(manifest.dependencies?.['@pnpm.e2e/peer-a']).toBe('^1.0.0')
const lockfile = await project.readLockfile()
expect(lockfile.specifiers['peer-a']).toBe('^1.0.0')
expect(lockfile.packages['/peer-a/1.0.1']).toBeTruthy()
expect(lockfile.specifiers['@pnpm.e2e/peer-a']).toBe('^1.0.0')
expect(lockfile.packages['/@pnpm.e2e/peer-a/1.0.1']).toBeTruthy()
}
})
// fix: https://github.com/pnpm/pnpm/issues/4196
test('update should work normal when set empty string version', async () => {
await addDistTag({ package: 'peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: 'peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/peer-c', version: '2.0.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/foo', version: '2.0.0', distTag: 'latest' })
const project = prepare({
dependencies: {
'peer-a': '1.0.0',
'@pnpm.e2e/peer-a': '1.0.0',
},
devDependencies: {
'@pnpm.e2e/foo': '',
'peer-c': '',
'@pnpm.e2e/peer-c': '',
},
})
@@ -184,10 +184,10 @@ test('update should work normal when set empty string version', async () => {
}, ['*'])
const lockfile = await project.readLockfile()
expect(lockfile.packages['/peer-a/1.0.1']).toBeTruthy()
expect(lockfile.packages['/peer-c/2.0.0']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/peer-a/1.0.1']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/peer-c/2.0.0']).toBeTruthy()
expect(lockfile.packages['/@pnpm.e2e/foo/2.0.0']).toBeTruthy()
expect(lockfile.dependencies['peer-a']).toEqual('1.0.1')
expect(lockfile.dependencies['@pnpm.e2e/peer-a']).toEqual('1.0.1')
expect(lockfile.devDependencies['@pnpm.e2e/foo']).toEqual('2.0.0')
expect(lockfile.devDependencies['peer-c']).toEqual('2.0.0')
expect(lockfile.devDependencies['@pnpm.e2e/peer-c']).toEqual('2.0.0')
})
@@ -2,7 +2,7 @@ import updateToLatestSpecsFromManifest, { createLatestSpecs } from '../lib/updat
const MANIFEST = {
dependencies: {
'dep-of-pkg-with-1-dep': 'npm:pkg-with-1-dep@1.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': 'npm:@pnpm.e2e/pkg-with-1-dep@1.0.0',
},
devDependencies: {
foo: 'github:pnpm/foo',
@@ -19,7 +19,7 @@ test('updateToLatestSpecsFromManifest()', () => {
devDependencies: true,
}))
updateResult1.toHaveLength(2)
updateResult1.toContain('dep-of-pkg-with-1-dep@npm:pkg-with-1-dep@latest')
updateResult1.toContain('@pnpm.e2e/dep-of-pkg-with-1-dep@npm:@pnpm.e2e/pkg-with-1-dep@latest')
updateResult1.toContain('is-positive@latest')
const updateResult2 = expect(updateToLatestSpecsFromManifest(MANIFEST, {
@@ -28,15 +28,15 @@ test('updateToLatestSpecsFromManifest()', () => {
devDependencies: false,
}))
updateResult2.toHaveLength(1)
updateResult2.toStrictEqual(['dep-of-pkg-with-1-dep@npm:pkg-with-1-dep@latest'])
updateResult2.toStrictEqual(['@pnpm.e2e/dep-of-pkg-with-1-dep@npm:@pnpm.e2e/pkg-with-1-dep@latest'])
})
test('createLatestSpecs()', () => {
expect(
createLatestSpecs(['dep-of-pkg-with-1-dep', 'is-positive@2.0.0', 'foo'], MANIFEST)
).toStrictEqual(['dep-of-pkg-with-1-dep@npm:pkg-with-1-dep@latest', 'is-positive@2.0.0', 'foo'])
createLatestSpecs(['@pnpm.e2e/dep-of-pkg-with-1-dep', 'is-positive@2.0.0', 'foo'], MANIFEST)
).toStrictEqual(['@pnpm.e2e/dep-of-pkg-with-1-dep@npm:@pnpm.e2e/pkg-with-1-dep@latest', 'is-positive@2.0.0', 'foo'])
expect(
createLatestSpecs(['dep-of-pkg-with-1-dep', 'is-positive', 'foo', 'bar'], MANIFEST)
).toStrictEqual(['dep-of-pkg-with-1-dep@npm:pkg-with-1-dep@latest', 'is-positive@latest', 'foo'])
createLatestSpecs(['@pnpm.e2e/dep-of-pkg-with-1-dep', 'is-positive', 'foo', 'bar'], MANIFEST)
).toStrictEqual(['@pnpm.e2e/dep-of-pkg-with-1-dep@npm:@pnpm.e2e/pkg-with-1-dep@latest', 'is-positive@latest', 'foo'])
})
@@ -38,7 +38,7 @@
"@pnpm/plugin-commands-installation": "workspace:*",
"@pnpm/plugin-commands-listing": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "3.0.0-0",
"@pnpm/registry-mock": "3.0.0-2",
"@types/ramda": "0.28.15",
"execa": "npm:safe-execa@^0.1.2",
"strip-ansi": "^6.0.1",
@@ -69,14 +69,14 @@ is-negative 1.0.0`)
})
test('recursive list with shared-workspace-lockfile', async () => {
await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
await addDistTag({ package: '@pnpm.e2e/dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' })
preparePackages([
{
name: 'project-1',
version: '1.0.0',
dependencies: {
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
},
{
@@ -121,8 +121,8 @@ test('recursive list with shared-workspace-lockfile', async () => {
project-1@1.0.0 ${path.resolve('project-1')}
dependencies:
pkg-with-1-dep 100.0.0
└── dep-of-pkg-with-1-dep 100.1.0
@pnpm.e2e/pkg-with-1-dep 100.0.0
└── @pnpm.e2e/dep-of-pkg-with-1-dep 100.1.0
Legend: production dependency, optional only, dev only
+6 -6
View File
@@ -24,8 +24,8 @@ test('`pnpm why` should fail if no package name was provided', async () => {
test('"why" should find non-direct dependency', async () => {
prepare({
dependencies: {
'dep-of-pkg-with-1-dep': '100.0.0',
'pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
'@pnpm.e2e/pkg-with-1-dep': '100.0.0',
},
})
@@ -35,14 +35,14 @@ test('"why" should find non-direct dependency', async () => {
dev: false,
dir: process.cwd(),
optional: false,
}, ['dep-of-pkg-with-1-dep'])
}, ['@pnpm.e2e/dep-of-pkg-with-1-dep'])
expect(stripAnsi(output)).toBe(`Legend: production dependency, optional only, dev only
project@0.0.0 ${process.cwd()}
dependencies:
dep-of-pkg-with-1-dep 100.0.0
pkg-with-1-dep 100.0.0
└── dep-of-pkg-with-1-dep 100.0.0`)
@pnpm.e2e/dep-of-pkg-with-1-dep 100.0.0
@pnpm.e2e/pkg-with-1-dep 100.0.0
└── @pnpm.e2e/dep-of-pkg-with-1-dep 100.0.0`)
})
@@ -38,7 +38,7 @@
"@pnpm/plugin-commands-installation": "workspace:*",
"@pnpm/plugin-commands-outdated": "workspace:*",
"@pnpm/prepare": "workspace:*",
"@pnpm/registry-mock": "3.0.0-0",
"@pnpm/registry-mock": "3.0.0-2",
"@types/ramda": "0.28.15",
"@types/wrap-ansi": "^3.0.0",
"@types/zkochan__table": "npm:@types/table@6.0.0"
Loaded 100 of 129 files, more files were not shown because too many files have changed in this diff. Show more