From e4b9c4bc3ada4075e613167cf4d3f1dca04113fe Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Fri, 31 Dec 2021 16:59:58 +0200 Subject: [PATCH] refactor: fixtures (#4182) --- .meta-updater/src/index.ts | 3 - packages/core/jest.config.js | 1 + packages/core/package.json | 2 - .../core/test}/fixtures/missing-pkg-name.tgz | Bin .../fixtures/missing-pkg-name/package.json | 0 .../app1/packages/public/bar/package.json | 0 .../app1/packages/public/foo/package.json | 0 .../app1/packages/public/foo/pnpm-lock.yaml | 0 .../symlink-workspace/app2/packages/.keep | 0 .../fixtures/tar-pkg-with-dep-1/package.json | 0 .../tar-pkg-with-dep-1.0.0.tgz | Bin .../fixtures/tar-pkg-with-dep-2/package.json | 0 .../tar-pkg-with-dep-1.0.0.tgz | Bin .../fixtures/tar-pkg-with-peers}/index.js | 0 .../fixtures/tar-pkg-with-peers/package.json | 0 .../tar-pkg-with-peers-1.0.0.tgz | Bin packages/core/test/install/local.ts | 32 +- packages/core/test/install/lockfileDir.ts | 6 +- packages/core/test/install/misc.ts | 5 +- .../core/test/install/peerDependencies.ts | 6 +- packages/core/test/link.ts | 18 +- packages/core/test/prune.ts | 7 +- packages/core/test/uninstall.ts | 8 +- packages/headless/package.json | 4 +- .../has-local-dep/{ => pkg}/package.json | 0 .../has-local-dep/{ => pkg}/pnpm-lock.yaml | 0 .../{ => has-local-dep}/tar-pkg-1.0.0.tgz | Bin .../test/fixtures/pnpm-workspace.yaml | 3 + .../workspace}/.npmrc | 0 .../workspace}/bar/package.json | 0 .../workspace}/foo/package.json | 0 .../workspace}/pnpm-lock.yaml | 0 .../workspace}/pnpm-workspace.yaml | 0 packages/headless/test/index.ts | 108 ++--- packages/headless/test/pretest.ts | 27 -- .../headless/test/workspace-fixture2/.npmrc | 2 - .../test/workspace-fixture2/bar/package.json | 9 - .../test/workspace-fixture2/foo/package.json | 7 - .../test/workspace-fixture2/pnpm-lock.yaml | 392 ------------------ packages/link-bins/package.json | 7 +- .../fixtures/bin-dir/pkg/bin/subdir/index.js | 0 packages/link-bins/test/index.ts | 42 +- packages/link-bins/tsconfig.json | 3 + packages/make-dedicated-lockfile/package.json | 6 +- .../test/fixture/pnpm-workspace.yaml | 0 .../packages/is-negative/example/package.json | 0 .../fixture/packages/is-negative/package.json | 0 .../fixture/packages/is-positive/package.json | 0 .../{ => fixtures}/fixture/pnpm-lock.yaml | 0 .../fixtures/fixture}/pnpm-workspace.yaml | 0 .../make-dedicated-lockfile/test/index.ts | 11 +- .../make-dedicated-lockfile/tsconfig.json | 2 +- packages/npm-resolver/package.json | 1 + .../test/{meta => fixtures}/JSON.json | 0 .../{meta => fixtures}/broken-integrity.json | 0 .../is-positive-broken.json | 0 .../{meta => fixtures}/is-positive-full.json | 0 .../is-positive-with-deprecated.json | 0 .../test/{meta => fixtures}/is-positive.json | 0 .../test/{meta => fixtures}/malformed.json | 0 .../{meta => fixtures}/sindresorhus-is.json | 0 packages/npm-resolver/test/index.ts | 18 +- packages/npm-resolver/tsconfig.json | 3 + packages/package-requester/package.json | 3 +- .../test/{ => fixtures}/is-positive-1.0.0.tgz | Bin .../pnpm-package-requester-0.8.1.tgz | Bin .../pnpm-package-requester-4.1.2.tgz | Bin packages/package-requester/test/index.ts | 15 +- packages/package-requester/tsconfig.json | 3 + packages/plugin-commands-audit/test/fix.ts | 11 +- .../plugin-commands-installation/package.json | 2 - .../test/import.ts | 23 +- .../test/importRecursive.ts | 21 +- .../plugin-commands-installation/test/link.ts | 8 +- .../test/prune.ts | 5 +- .../plugin-commands-rebuild/test/index.ts | 5 +- packages/pnpm/package.json | 2 - packages/tarball-fetcher/package.json | 2 +- packages/tarball-fetcher/test/download.ts | 23 +- .../babel-helper-hoist-variables-6.24.1.tgz | Bin ...-helper-hoist-variables-7.0.0-alpha.10.tgz | Bin packages/tarball-fetcher/tsconfig.json | 3 + pnpm-lock.yaml | 65 +-- .../has-broken-symlink.tar.gz | Bin 320 -> 0 bytes .../fixtures/hello-world-js-bin/index.js | 2 - .../fixtures/hello-world-js-bin/package.json | 19 - .../fixtures/local-pkg/package.json | 4 - .../fixtures/local-scoped-pkg/index.js | 1 - .../fixtures/local-scoped-pkg/package.json | 4 - .../fixtures/tar-pkg-with-peers/index.js | 1 - .../test-fixtures/fixtures/tar-pkg/index.js | 1 - .../fixtures/tar-pkg/package.json | 4 - .../fixtures/tar-pkg/tar-pkg-1.0.0.tgz | Bin 214 -> 0 bytes privatePackages/test-fixtures/package.json | 6 +- privatePackages/test-fixtures/src/index.ts | 35 +- privatePackages/test-fixtures/tsconfig.json | 6 +- 96 files changed, 240 insertions(+), 767 deletions(-) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/missing-pkg-name.tgz (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/missing-pkg-name/package.json (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/symlink-workspace/app1/packages/public/bar/package.json (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/symlink-workspace/app1/packages/public/foo/package.json (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/symlink-workspace/app1/packages/public/foo/pnpm-lock.yaml (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/symlink-workspace/app2/packages/.keep (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/tar-pkg-with-dep-1/package.json (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/tar-pkg-with-dep-2/package.json (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz (100%) rename {privatePackages/test-fixtures/fixtures/local-pkg => packages/core/test/fixtures/tar-pkg-with-peers}/index.js (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/tar-pkg-with-peers/package.json (100%) rename {privatePackages/test-fixtures => packages/core/test}/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz (100%) rename packages/headless/test/fixtures/has-local-dep/{ => pkg}/package.json (100%) rename packages/headless/test/fixtures/has-local-dep/{ => pkg}/pnpm-lock.yaml (100%) rename packages/headless/test/fixtures/{ => has-local-dep}/tar-pkg-1.0.0.tgz (100%) rename packages/headless/test/{workspace-fixture => fixtures/workspace}/.npmrc (100%) rename packages/headless/test/{workspace-fixture => fixtures/workspace}/bar/package.json (100%) rename packages/headless/test/{workspace-fixture => fixtures/workspace}/foo/package.json (100%) rename packages/headless/test/{workspace-fixture => fixtures/workspace}/pnpm-lock.yaml (100%) rename packages/headless/test/{workspace-fixture => fixtures/workspace}/pnpm-workspace.yaml (100%) delete mode 100644 packages/headless/test/pretest.ts delete mode 100644 packages/headless/test/workspace-fixture2/.npmrc delete mode 100644 packages/headless/test/workspace-fixture2/bar/package.json delete mode 100644 packages/headless/test/workspace-fixture2/foo/package.json delete mode 100644 packages/headless/test/workspace-fixture2/pnpm-lock.yaml mode change 100644 => 100755 packages/link-bins/test/fixtures/bin-dir/pkg/bin/subdir/index.js delete mode 100644 packages/make-dedicated-lockfile/test/fixture/pnpm-workspace.yaml rename packages/make-dedicated-lockfile/test/{ => fixtures}/fixture/packages/is-negative/example/package.json (100%) rename packages/make-dedicated-lockfile/test/{ => fixtures}/fixture/packages/is-negative/package.json (100%) rename packages/make-dedicated-lockfile/test/{ => fixtures}/fixture/packages/is-positive/package.json (100%) rename packages/make-dedicated-lockfile/test/{ => fixtures}/fixture/pnpm-lock.yaml (100%) rename packages/{headless/test/workspace-fixture2 => make-dedicated-lockfile/test/fixtures/fixture}/pnpm-workspace.yaml (100%) rename packages/npm-resolver/test/{meta => fixtures}/JSON.json (100%) rename packages/npm-resolver/test/{meta => fixtures}/broken-integrity.json (100%) rename packages/npm-resolver/test/{meta => fixtures}/is-positive-broken.json (100%) rename packages/npm-resolver/test/{meta => fixtures}/is-positive-full.json (100%) rename packages/npm-resolver/test/{meta => fixtures}/is-positive-with-deprecated.json (100%) rename packages/npm-resolver/test/{meta => fixtures}/is-positive.json (100%) rename packages/npm-resolver/test/{meta => fixtures}/malformed.json (100%) rename packages/npm-resolver/test/{meta => fixtures}/sindresorhus-is.json (100%) rename packages/package-requester/test/{ => fixtures}/is-positive-1.0.0.tgz (100%) rename packages/package-requester/test/{ => fixtures}/pnpm-package-requester-0.8.1.tgz (100%) rename packages/package-requester/test/{ => fixtures}/pnpm-package-requester-4.1.2.tgz (100%) rename packages/tarball-fetcher/test/{tars => fixtures}/babel-helper-hoist-variables-6.24.1.tgz (100%) rename packages/tarball-fetcher/test/{tars => fixtures}/babel-helper-hoist-variables-7.0.0-alpha.10.tgz (100%) delete mode 100644 privatePackages/test-fixtures/fixtures/has-broken-symlink/has-broken-symlink.tar.gz delete mode 100755 privatePackages/test-fixtures/fixtures/hello-world-js-bin/index.js delete mode 100644 privatePackages/test-fixtures/fixtures/hello-world-js-bin/package.json delete mode 100644 privatePackages/test-fixtures/fixtures/local-pkg/package.json delete mode 100644 privatePackages/test-fixtures/fixtures/local-scoped-pkg/index.js delete mode 100644 privatePackages/test-fixtures/fixtures/local-scoped-pkg/package.json delete mode 100644 privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/index.js delete mode 100644 privatePackages/test-fixtures/fixtures/tar-pkg/index.js delete mode 100644 privatePackages/test-fixtures/fixtures/tar-pkg/package.json delete mode 100644 privatePackages/test-fixtures/fixtures/tar-pkg/tar-pkg-1.0.0.tgz diff --git a/.meta-updater/src/index.ts b/.meta-updater/src/index.ts index d79e5eba8b..d1efff60e9 100644 --- a/.meta-updater/src/index.ts +++ b/.meta-updater/src/index.ts @@ -131,9 +131,6 @@ async function updateManifest (workspaceDir: string, manifest: ProjectManifest, } scripts.test = 'pnpm run compile && pnpm run _test' scripts._test = `cross-env PNPM_REGISTRY_MOCK_PORT=${port} pnpm run test:e2e` - if (manifest.name === '@pnpm/headless') { - scripts._test = `ts-node test/pretest && ${scripts._test}` - } break } default: diff --git a/packages/core/jest.config.js b/packages/core/jest.config.js index a366d1f375..03129325a1 100644 --- a/packages/core/jest.config.js +++ b/packages/core/jest.config.js @@ -6,6 +6,7 @@ module.exports = { '/test/utils/distTags.ts', '/test/utils/index.ts', '/test/utils/testDefaults.ts', + '/test/fixtures/.+', ], } diff --git a/packages/core/package.json b/packages/core/package.json index 922cf6c824..47df04a7dc 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -77,7 +77,6 @@ "@types/fs-extra": "^9.0.5", "@types/is-ci": "^3.0.0", "@types/is-windows": "^1.0.0", - "@types/ncp": "^2.0.4", "@types/normalize-path": "^3.0.0", "@types/ramda": "0.27.39", "@types/semver": "^7.3.4", @@ -87,7 +86,6 @@ "exists-link": "2.0.0", "is-ci": "^3.0.0", "is-windows": "^1.0.2", - "ncp": "^2.0.0", "nock": "12.0.3", "path-name": "^1.0.0", "read-yaml-file": "^2.1.0", diff --git a/privatePackages/test-fixtures/fixtures/missing-pkg-name.tgz b/packages/core/test/fixtures/missing-pkg-name.tgz similarity index 100% rename from privatePackages/test-fixtures/fixtures/missing-pkg-name.tgz rename to packages/core/test/fixtures/missing-pkg-name.tgz diff --git a/privatePackages/test-fixtures/fixtures/missing-pkg-name/package.json b/packages/core/test/fixtures/missing-pkg-name/package.json similarity index 100% rename from privatePackages/test-fixtures/fixtures/missing-pkg-name/package.json rename to packages/core/test/fixtures/missing-pkg-name/package.json diff --git a/privatePackages/test-fixtures/fixtures/symlink-workspace/app1/packages/public/bar/package.json b/packages/core/test/fixtures/symlink-workspace/app1/packages/public/bar/package.json similarity index 100% rename from privatePackages/test-fixtures/fixtures/symlink-workspace/app1/packages/public/bar/package.json rename to packages/core/test/fixtures/symlink-workspace/app1/packages/public/bar/package.json diff --git a/privatePackages/test-fixtures/fixtures/symlink-workspace/app1/packages/public/foo/package.json b/packages/core/test/fixtures/symlink-workspace/app1/packages/public/foo/package.json similarity index 100% rename from privatePackages/test-fixtures/fixtures/symlink-workspace/app1/packages/public/foo/package.json rename to packages/core/test/fixtures/symlink-workspace/app1/packages/public/foo/package.json diff --git a/privatePackages/test-fixtures/fixtures/symlink-workspace/app1/packages/public/foo/pnpm-lock.yaml b/packages/core/test/fixtures/symlink-workspace/app1/packages/public/foo/pnpm-lock.yaml similarity index 100% rename from privatePackages/test-fixtures/fixtures/symlink-workspace/app1/packages/public/foo/pnpm-lock.yaml rename to packages/core/test/fixtures/symlink-workspace/app1/packages/public/foo/pnpm-lock.yaml diff --git a/privatePackages/test-fixtures/fixtures/symlink-workspace/app2/packages/.keep b/packages/core/test/fixtures/symlink-workspace/app2/packages/.keep similarity index 100% rename from privatePackages/test-fixtures/fixtures/symlink-workspace/app2/packages/.keep rename to packages/core/test/fixtures/symlink-workspace/app2/packages/.keep diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-1/package.json b/packages/core/test/fixtures/tar-pkg-with-dep-1/package.json similarity index 100% rename from privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-1/package.json rename to packages/core/test/fixtures/tar-pkg-with-dep-1/package.json diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz b/packages/core/test/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz similarity index 100% rename from privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz rename to packages/core/test/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-2/package.json b/packages/core/test/fixtures/tar-pkg-with-dep-2/package.json similarity index 100% rename from privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-2/package.json rename to packages/core/test/fixtures/tar-pkg-with-dep-2/package.json diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz b/packages/core/test/fixtures/tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz similarity index 100% rename from privatePackages/test-fixtures/fixtures/tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz rename to packages/core/test/fixtures/tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz diff --git a/privatePackages/test-fixtures/fixtures/local-pkg/index.js b/packages/core/test/fixtures/tar-pkg-with-peers/index.js similarity index 100% rename from privatePackages/test-fixtures/fixtures/local-pkg/index.js rename to packages/core/test/fixtures/tar-pkg-with-peers/index.js diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/package.json b/packages/core/test/fixtures/tar-pkg-with-peers/package.json similarity index 100% rename from privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/package.json rename to packages/core/test/fixtures/tar-pkg-with-peers/package.json diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz b/packages/core/test/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz similarity index 100% rename from privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz rename to packages/core/test/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz diff --git a/packages/core/test/install/local.ts b/packages/core/test/install/local.ts index f2798d59c2..d4535c14dd 100644 --- a/packages/core/test/install/local.ts +++ b/packages/core/test/install/local.ts @@ -3,7 +3,7 @@ import path from 'path' import { LOCKFILE_VERSION } from '@pnpm/constants' import { prepareEmpty } from '@pnpm/prepare' import { addDistTag } from '@pnpm/registry-mock' -import { copyFixture, pathToLocalPkg } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import { addDependenciesToPackage, install, @@ -14,9 +14,11 @@ import normalizePath from 'normalize-path' import symlinkDir from 'symlink-dir' import { testDefaults } from '../utils' +const f = fixtures(__dirname) + test('scoped modules from a directory', async () => { const project = prepareEmpty() - await addDependenciesToPackage({}, [`file:${pathToLocalPkg('local-scoped-pkg')}`], await testDefaults()) + await addDependenciesToPackage({}, [`file:${f.find('local-scoped-pkg')}`], await testDefaults()) const m = project.requireModule('@scope/local-scoped-pkg') @@ -25,7 +27,7 @@ test('scoped modules from a directory', async () => { test('local file', async () => { const project = prepareEmpty() - await copyFixture('local-pkg', path.resolve('..', 'local-pkg')) + f.copy('local-pkg', path.resolve('..', 'local-pkg')) const manifest = await addDependenciesToPackage({}, ['file:../local-pkg'], await testDefaults()) @@ -66,7 +68,7 @@ test('local directory with no package.json', async () => { test('local file via link:', async () => { const project = prepareEmpty() - await copyFixture('local-pkg', path.resolve('..', 'local-pkg')) + f.copy('local-pkg', path.resolve('..', 'local-pkg')) const manifest = await addDependenciesToPackage({}, ['link:../local-pkg'], await testDefaults()) @@ -90,7 +92,7 @@ test('local file via link:', async () => { test('local file with symlinked node_modules', async () => { const project = prepareEmpty() - await copyFixture('local-pkg', path.resolve('..', 'local-pkg')) + f.copy('local-pkg', path.resolve('..', 'local-pkg')) await fs.mkdir(path.join('..', 'node_modules')) await symlinkDir(path.join('..', 'node_modules'), 'node_modules') @@ -116,7 +118,7 @@ test('local file with symlinked node_modules', async () => { test('package with a broken symlink', async () => { const project = prepareEmpty() - await addDependenciesToPackage({}, [pathToLocalPkg('has-broken-symlink/has-broken-symlink.tar.gz')], await testDefaults({ fastUnpack: false })) + await addDependenciesToPackage({}, [f.find('has-broken-symlink/has-broken-symlink.tar.gz')], await testDefaults({ fastUnpack: false })) const m = project.requireModule('has-broken-symlink') @@ -125,13 +127,13 @@ test('package with a broken symlink', async () => { test('tarball local package', async () => { const project = prepareEmpty() - const manifest = await addDependenciesToPackage({}, [pathToLocalPkg('tar-pkg/tar-pkg-1.0.0.tgz')], await testDefaults({ fastUnpack: false })) + const manifest = await addDependenciesToPackage({}, [f.find('tar-pkg/tar-pkg-1.0.0.tgz')], await testDefaults({ fastUnpack: false })) const m = project.requireModule('tar-pkg') expect(m()).toBe('tar-pkg') - const pkgSpec = `file:${normalizePath(pathToLocalPkg('tar-pkg/tar-pkg-1.0.0.tgz'))}` + const pkgSpec = `file:${normalizePath(f.find('tar-pkg/tar-pkg-1.0.0.tgz'))}` expect(manifest.dependencies).toStrictEqual({ 'tar-pkg': pkgSpec }) const lockfile = await project.readLockfile() @@ -140,7 +142,7 @@ test('tarball local package', async () => { name: 'tar-pkg', resolution: { integrity: 'sha512-HP/5Rgt3pVFLzjmN9qJJ6vZMgCwoCIl/m2bPndYT283CUqnmFiMx0GeeIJ7SyK6TYoJM78SEvFEOQie++caHqw==', - tarball: `file:${normalizePath(path.relative(process.cwd(), pathToLocalPkg('tar-pkg/tar-pkg-1.0.0.tgz')))}`, + tarball: `file:${normalizePath(path.relative(process.cwd(), f.find('tar-pkg/tar-pkg-1.0.0.tgz')))}`, }, version: '1.0.0', }) @@ -149,7 +151,7 @@ test('tarball local package', async () => { test('tarball local package from project directory', async () => { const project = prepareEmpty() - await copyFixture('tar-pkg/tar-pkg-1.0.0.tgz', path.resolve('tar-pkg-1.0.0.tgz')) + f.copy('tar-pkg/tar-pkg-1.0.0.tgz', path.resolve('tar-pkg-1.0.0.tgz')) const manifest = await install({ dependencies: { @@ -180,13 +182,13 @@ test('tarball local package from project directory', async () => { test('update tarball local package when its integrity changes', async () => { const project = prepareEmpty() - await copyFixture('tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz')) + 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'], await testDefaults()) const lockfile1 = await project.readLockfile() expect(lockfile1.packages['file:../tar.tgz'].dependencies!['is-positive']).toBe('1.0.0') - await copyFixture('tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz')) + f.copy('tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz')) await install(manifest, await testDefaults()) const lockfile2 = await project.readLockfile() @@ -201,7 +203,7 @@ test('do not update deps when installing in a project that has local tarball dep await addDistTag({ package: 'peer-a', version: '1.0.0', distTag: 'latest' }) const project = prepareEmpty() - await copyFixture('tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz')) + 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 initialLockfile = await project.readLockfile() @@ -226,12 +228,12 @@ test('do not update deps when installing in a project that has local tarball dep test('frozen-lockfile: installation fails if the integrity of a tarball dependency changed', async () => { prepareEmpty() - await copyFixture('tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz')) + 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'], await testDefaults()) await rimraf('node_modules') - await copyFixture('tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz')) + f.copy('tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz', path.resolve('..', 'tar.tgz')) await expect( install(manifest, await testDefaults({ frozenLockfile: true })) diff --git a/packages/core/test/install/lockfileDir.ts b/packages/core/test/install/lockfileDir.ts index 56e94004fe..a1f07bcea9 100644 --- a/packages/core/test/install/lockfileDir.ts +++ b/packages/core/test/install/lockfileDir.ts @@ -2,12 +2,14 @@ import path from 'path' import { WANTED_LOCKFILE } from '@pnpm/constants' import { Lockfile } from '@pnpm/lockfile-file' import { prepareEmpty } from '@pnpm/prepare' -import { copyFixture } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import readYamlFile from 'read-yaml-file' import { addDependenciesToPackage, mutateModules } from '@pnpm/core' import rimraf from '@zkochan/rimraf' import { testDefaults } from '../utils' +const f = fixtures(__dirname) + test.skip('subsequent installation uses same lockfile directory by default', async () => { prepareEmpty() @@ -40,7 +42,7 @@ test.skip('subsequent installation fails if a different lockfile directory is sp test(`tarball location is correctly saved to ${WANTED_LOCKFILE} when a shared ${WANTED_LOCKFILE} is used`, async () => { const project = prepareEmpty() - await copyFixture('tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz', 'pkg.tgz') + f.copy('tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz', 'pkg.tgz') const lockfileDir = path.resolve('..') const [{ manifest }] = await mutateModules( diff --git a/packages/core/test/install/misc.ts b/packages/core/test/install/misc.ts index bbb0b0178d..aa44651b3c 100644 --- a/packages/core/test/install/misc.ts +++ b/packages/core/test/install/misc.ts @@ -10,7 +10,7 @@ import { StatsLog, } from '@pnpm/core-loggers' import { LOCKFILE_VERSION } from '@pnpm/constants' -import { pathToLocalPkg } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import { ProjectManifest } from '@pnpm/types' import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import { @@ -34,6 +34,7 @@ import { testDefaults, } from '../utils' +const f = fixtures(__dirname) const IS_WINDOWS = isWindows() const testOnNonWindows = IS_WINDOWS ? test.skip : test @@ -811,7 +812,7 @@ test('install a dependency with * range', async () => { test('should throw error when trying to install a package without name', async () => { prepareEmpty() await expect( - addDependenciesToPackage({}, [`file:${pathToLocalPkg('missing-pkg-name.tgz')}`], await testDefaults()) + addDependenciesToPackage({}, [`file:${f.find('missing-pkg-name.tgz')}`], await testDefaults()) ).rejects.toThrow(/^Can't install .*: Missing package name$/) }) diff --git a/packages/core/test/install/peerDependencies.ts b/packages/core/test/install/peerDependencies.ts index 2937f01802..4298c8ffef 100644 --- a/packages/core/test/install/peerDependencies.ts +++ b/packages/core/test/install/peerDependencies.ts @@ -4,7 +4,7 @@ import { WANTED_LOCKFILE } from '@pnpm/constants' import { Lockfile } from '@pnpm/lockfile-file' import { prepareEmpty, preparePackages } from '@pnpm/prepare' import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' -import { pathToLocalPkg } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import readYamlFile from 'read-yaml-file' import { addDependenciesToPackage, @@ -19,6 +19,8 @@ import sinon from 'sinon' import deepRequireCwd from 'deep-require-cwd' 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()) @@ -1139,7 +1141,7 @@ test('local tarball dependency with peer dependency', async () => { const reporter = sinon.spy() const manifest = await addDependenciesToPackage({}, [ - `file:${pathToLocalPkg('tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz')}`, + `file:${f.find('tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz')}`, 'bar@100.0.0', 'foo@100.0.0', ], await testDefaults({ reporter })) diff --git a/packages/core/test/link.ts b/packages/core/test/link.ts index 4b5e5b13c8..7d21208acb 100644 --- a/packages/core/test/link.ts +++ b/packages/core/test/link.ts @@ -1,4 +1,3 @@ -import { promisify } from 'util' import { promises as fs } from 'fs' import path from 'path' import { @@ -8,18 +7,17 @@ import { linkFromGlobal, linkToGlobal, } from '@pnpm/core' -import { pathToLocalPkg } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import { prepareEmpty } from '@pnpm/prepare' import { RootLog } from '@pnpm/core-loggers' import { isExecutable } from '@pnpm/assert-project' import exists from 'path-exists' import sinon from 'sinon' import writeJsonFile from 'write-json-file' -import ncpCB from 'ncp' import symlink from 'symlink-dir' import { testDefaults } from './utils' -const ncp = promisify(ncpCB.ncp) +const f = fixtures(__dirname) test('relative link', async () => { const project = prepareEmpty() @@ -27,7 +25,7 @@ test('relative link', async () => { const linkedPkgName = 'hello-world-js-bin' const linkedPkgPath = path.resolve('..', linkedPkgName) - await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) await link([`../${linkedPkgName}`], path.join(process.cwd(), 'node_modules'), await testDefaults({ dir: process.cwd(), manifest: { @@ -54,7 +52,7 @@ test('relative link is linked by the name of the alias', async () => { const linkedPkgPath = path.resolve('..', linkedPkgName) - await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) await install({ dependencies: { hello: `link:../${linkedPkgName}`, @@ -80,7 +78,7 @@ test('relative link is not rewritten by argumentless install', async () => { const reporter = sinon.spy() const opts = await testDefaults() - await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) const manifest = await link( [linkedPkgPath], path.join(process.cwd(), 'node_modules'), @@ -118,7 +116,7 @@ test('relative link is rewritten by named installation to regular dependency', a const reporter = sinon.spy() const opts = await testDefaults({ fastUnpack: false }) - await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) let manifest = await link( [linkedPkgPath], path.join(process.cwd(), 'node_modules'), @@ -163,7 +161,7 @@ test('global link', async () => { const linkedPkgName = 'hello-world-js-bin' const linkedPkgPath = path.resolve('..', linkedPkgName) - await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) const opts = await testDefaults() @@ -217,7 +215,7 @@ test('relative link uses realpath when contained in a symlinked dir', async () = // `process.cwd()` is now `.tmp/X/project`. - await ncp(pathToLocalPkg('symlink-workspace'), path.resolve('../symlink-workspace')) + f.copy('symlink-workspace', path.resolve('../symlink-workspace')) const app1RelPath = '../symlink-workspace/app1' const app2RelPath = '../symlink-workspace/app2' diff --git a/packages/core/test/prune.ts b/packages/core/test/prune.ts index db07e82040..f5a653f039 100644 --- a/packages/core/test/prune.ts +++ b/packages/core/test/prune.ts @@ -1,7 +1,7 @@ import path from 'path' import { RootLog } from '@pnpm/core-loggers' import { prepareEmpty } from '@pnpm/prepare' -import { pathToLocalPkg } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import { addDependenciesToPackage, install, @@ -11,7 +11,10 @@ import { import sinon from 'sinon' import { testDefaults } from './utils' +const f = fixtures(__dirname) + test('prune removes extraneous packages', async () => { + const linkedPkg = f.prepare('hello-world-js-bin') const project = prepareEmpty() const opts = await testDefaults() @@ -19,7 +22,7 @@ test('prune removes extraneous packages', async () => { manifest = await addDependenciesToPackage(manifest, ['applyq@0.2.1'], { ...opts, targetDependenciesField: 'devDependencies' }) manifest = await addDependenciesToPackage(manifest, ['fnumber@0.1.0'], { ...opts, targetDependenciesField: 'optionalDependencies' }) manifest = await addDependenciesToPackage(manifest, ['is-positive@2.0.0', '@zkochan/logger@0.1.0'], opts) - manifest = await link([pathToLocalPkg('hello-world-js-bin')], path.resolve(process.cwd(), 'node_modules'), { ...opts, manifest, dir: process.cwd() }) + manifest = await link([linkedPkg], path.resolve('node_modules'), { ...opts, manifest, dir: process.cwd() }) await project.has('hello-world-js-bin') // external link added diff --git a/packages/core/test/uninstall.ts b/packages/core/test/uninstall.ts index e1f183b0e5..f94eb764fb 100644 --- a/packages/core/test/uninstall.ts +++ b/packages/core/test/uninstall.ts @@ -1,4 +1,3 @@ -import { promisify } from 'util' import path from 'path' import { LOCKFILE_VERSION, WANTED_LOCKFILE } from '@pnpm/constants' import { @@ -9,7 +8,7 @@ import { import { Lockfile } from '@pnpm/lockfile-file' import { prepareEmpty, preparePackages } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' -import { pathToLocalPkg } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import { PackageManifest } from '@pnpm/types' import readYamlFile from 'read-yaml-file' import { @@ -21,10 +20,9 @@ import exists from 'path-exists' import sinon from 'sinon' import writeJsonFile from 'write-json-file' import existsSymlink from 'exists-link' -import ncpCB from 'ncp' import { testDefaults } from './utils' -const ncp = promisify(ncpCB.ncp) +const f = fixtures(__dirname) test('uninstall package with no dependencies', async () => { const project = prepareEmpty() @@ -207,7 +205,7 @@ test('relative link is uninstalled', async () => { const linkedPkgName = 'hello-world-js-bin' const linkedPkgPath = path.resolve('..', linkedPkgName) - await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) const manifest = await link([`../${linkedPkgName}`], path.join(process.cwd(), 'node_modules'), opts as (typeof opts & { dir: string, manifest: PackageManifest })) await mutateModules([ { diff --git a/packages/headless/package.json b/packages/headless/package.json index 270b551d45..a8249268b2 100644 --- a/packages/headless/package.json +++ b/packages/headless/package.json @@ -59,10 +59,10 @@ "registry-mock": "registry-mock", "test:jest": "jest", "test:e2e": "registry-mock prepare && run-p -r registry-mock test:jest", - "_test": "ts-node test/pretest && cross-env PNPM_REGISTRY_MOCK_PORT=7770 pnpm run test:e2e", + "_test": "cross-env PNPM_REGISTRY_MOCK_PORT=7770 pnpm run test:e2e", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", - "runPrepareFixtures": "node ../pnpm/bin/pnpm.cjs i -r -C test/fixtures --no-shared-workspace-lockfile --no-link-workspace-packages --lockfile-only --registry http://localhost:4873/ --ignore-scripts --force", + "runPrepareFixtures": "node ../pnpm/bin/pnpm.cjs i -r -C test/fixtures --no-shared-workspace-lockfile --no-link-workspace-packages --lockfile-only --registry http://localhost:4873/ --ignore-scripts --force --no-strict-peer-dependencies", "prepareFixtures": "registry-mock prepare && run-p -r registry-mock runPrepareFixtures", "compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run lint -- --fix" }, diff --git a/packages/headless/test/fixtures/has-local-dep/package.json b/packages/headless/test/fixtures/has-local-dep/pkg/package.json similarity index 100% rename from packages/headless/test/fixtures/has-local-dep/package.json rename to packages/headless/test/fixtures/has-local-dep/pkg/package.json diff --git a/packages/headless/test/fixtures/has-local-dep/pnpm-lock.yaml b/packages/headless/test/fixtures/has-local-dep/pkg/pnpm-lock.yaml similarity index 100% rename from packages/headless/test/fixtures/has-local-dep/pnpm-lock.yaml rename to packages/headless/test/fixtures/has-local-dep/pkg/pnpm-lock.yaml diff --git a/packages/headless/test/fixtures/tar-pkg-1.0.0.tgz b/packages/headless/test/fixtures/has-local-dep/tar-pkg-1.0.0.tgz similarity index 100% rename from packages/headless/test/fixtures/tar-pkg-1.0.0.tgz rename to packages/headless/test/fixtures/has-local-dep/tar-pkg-1.0.0.tgz diff --git a/packages/headless/test/fixtures/pnpm-workspace.yaml b/packages/headless/test/fixtures/pnpm-workspace.yaml index e69de29bb2..91039349b6 100644 --- a/packages/headless/test/fixtures/pnpm-workspace.yaml +++ b/packages/headless/test/fixtures/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + - "**" + - "!workspace/**" diff --git a/packages/headless/test/workspace-fixture/.npmrc b/packages/headless/test/fixtures/workspace/.npmrc similarity index 100% rename from packages/headless/test/workspace-fixture/.npmrc rename to packages/headless/test/fixtures/workspace/.npmrc diff --git a/packages/headless/test/workspace-fixture/bar/package.json b/packages/headless/test/fixtures/workspace/bar/package.json similarity index 100% rename from packages/headless/test/workspace-fixture/bar/package.json rename to packages/headless/test/fixtures/workspace/bar/package.json diff --git a/packages/headless/test/workspace-fixture/foo/package.json b/packages/headless/test/fixtures/workspace/foo/package.json similarity index 100% rename from packages/headless/test/workspace-fixture/foo/package.json rename to packages/headless/test/fixtures/workspace/foo/package.json diff --git a/packages/headless/test/workspace-fixture/pnpm-lock.yaml b/packages/headless/test/fixtures/workspace/pnpm-lock.yaml similarity index 100% rename from packages/headless/test/workspace-fixture/pnpm-lock.yaml rename to packages/headless/test/fixtures/workspace/pnpm-lock.yaml diff --git a/packages/headless/test/workspace-fixture/pnpm-workspace.yaml b/packages/headless/test/fixtures/workspace/pnpm-workspace.yaml similarity index 100% rename from packages/headless/test/workspace-fixture/pnpm-workspace.yaml rename to packages/headless/test/fixtures/workspace/pnpm-workspace.yaml diff --git a/packages/headless/test/index.ts b/packages/headless/test/index.ts index 1dcdcc296f..55b7404781 100644 --- a/packages/headless/test/index.ts +++ b/packages/headless/test/index.ts @@ -16,7 +16,7 @@ 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 { copyFixture } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import rimraf from '@zkochan/rimraf' import isWindows from 'is-windows' import loadJsonFile from 'load-json-file' @@ -25,11 +25,11 @@ import sinon from 'sinon' import writeJsonFile from 'write-json-file' import testDefaults from './utils/testDefaults' -const fixtures = path.join(__dirname, 'fixtures') +const f = fixtures(__dirname) const skipOnWindows = isWindows() ? test.skip : test test('installing a simple project', async () => { - const prefix = path.join(fixtures, 'simple') + const prefix = f.prepare('simple') const reporter = sinon.spy() await headless(await testDefaults({ @@ -82,8 +82,7 @@ test('installing a simple project', async () => { }) test('installing only prod deps', async () => { - const prefix = path.join(fixtures, 'simple') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('simple') await headless(await testDefaults({ include: { @@ -104,8 +103,7 @@ test('installing only prod deps', async () => { }) test('installing only dev deps', async () => { - const prefix = path.join(fixtures, 'simple') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('simple') await headless(await testDefaults({ include: { @@ -124,8 +122,7 @@ test('installing only dev deps', async () => { }) test('installing with package manifest ignored', async () => { - const prefix = path.join(fixtures, 'ignore-package-manifest') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('ignore-package-manifest') const opt = await testDefaults({ projects: [], include: { @@ -149,8 +146,7 @@ test('installing with package manifest ignored', async () => { }) test('installing only prod package with package manifest ignored', async () => { - const prefix = path.join(fixtures, 'ignore-package-manifest') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('ignore-package-manifest') const opt = await testDefaults({ projects: [], include: { @@ -174,8 +170,7 @@ test('installing only prod package with package manifest ignored', async () => { }) test('installing only dev package with package manifest ignored', async () => { - const prefix = path.join(fixtures, 'ignore-package-manifest') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('ignore-package-manifest') const opt = await testDefaults({ projects: [], include: { @@ -199,7 +194,7 @@ test('installing only dev package with package manifest ignored', async () => { }) test('installing non-prod deps then all deps', async () => { - const prefix = path.join(fixtures, 'prod-dep-is-dev-subdep') + const prefix = f.prepare('prod-dep-is-dev-subdep') await headless(await testDefaults({ include: { @@ -267,8 +262,7 @@ test('installing non-prod deps then all deps', async () => { }) test('installing only optional deps', async () => { - const prefix = path.join(fixtures, 'simple') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('simple') await headless(await testDefaults({ development: false, @@ -291,8 +285,7 @@ test('installing only optional deps', async () => { // Covers https://github.com/pnpm/pnpm/issues/1958 test('not installing optional deps', async () => { - const prefix = path.join(fixtures, 'simple-with-optional-dep') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('simple-with-optional-dep') await headless(await testDefaults({ include: { @@ -309,7 +302,7 @@ test('not installing optional deps', async () => { }) test('skipping optional dependency if it cannot be fetched', async () => { - const prefix = path.join(fixtures, 'has-nonexistent-optional-dep') + const prefix = f.prepare('has-nonexistent-optional-dep') const reporter = sinon.spy() await headless(await testDefaults({ @@ -331,9 +324,7 @@ test('skipping optional dependency if it cannot be fetched', async () => { }) test('run pre/postinstall scripts', async () => { - const prefix = path.join(fixtures, 'deps-have-lifecycle-scripts') - const outputJsonPath = path.join(prefix, 'output.json') - await rimraf(outputJsonPath) + let prefix = f.prepare('deps-have-lifecycle-scripts') await headless(await testDefaults({ lockfileDir: prefix })) @@ -344,14 +335,13 @@ test('run pre/postinstall scripts', async () => { const generatedByPostinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-postinstall') expect(typeof generatedByPostinstall).toBe('function') - expect(require(outputJsonPath)).toStrictEqual(['install', 'postinstall']) // eslint-disable-line + expect(require(path.join(prefix, 'output.json'))).toStrictEqual(['install', 'postinstall']) // eslint-disable-line - await rimraf(outputJsonPath) - await rimraf(path.join(prefix, 'node_modules')) + prefix = f.prepare('deps-have-lifecycle-scripts') await headless(await testDefaults({ lockfileDir: prefix, ignoreScripts: true })) - expect(await exists(outputJsonPath)).toBeFalsy() + expect(await exists(path.join(prefix, 'output.json'))).toBeFalsy() const nmPath = path.join(prefix, 'node_modules') const modulesYaml = await readModulesYaml(nmPath) @@ -360,22 +350,21 @@ test('run pre/postinstall scripts', async () => { }) test('orphan packages are removed', async () => { - const projectDir = tempDir() - - const destPackageJsonPath = path.join(projectDir, 'package.json') - const destLockfileYamlPath = path.join(projectDir, WANTED_LOCKFILE) - - const simpleWithMoreDepsDir = path.join(fixtures, 'simple-with-more-deps') - const simpleDir = path.join(fixtures, 'simple') - await fs.copyFile(path.join(simpleWithMoreDepsDir, 'package.json'), destPackageJsonPath) - await fs.copyFile(path.join(simpleWithMoreDepsDir, WANTED_LOCKFILE), destLockfileYamlPath) + const projectDir = f.prepare('simple-with-more-deps') await headless(await testDefaults({ lockfileDir: projectDir, })) - await fs.copyFile(path.join(simpleDir, 'package.json'), destPackageJsonPath) - await fs.copyFile(path.join(simpleDir, WANTED_LOCKFILE), destLockfileYamlPath) + const simpleDir = f.find('simple') + await fs.copyFile( + path.join(simpleDir, 'package.json'), + path.join(projectDir, 'package.json') + ) + await fs.copyFile( + path.join(simpleDir, WANTED_LOCKFILE), + path.join(projectDir, WANTED_LOCKFILE) + ) const reporter = sinon.spy() await headless(await testDefaults({ @@ -403,13 +392,13 @@ test('available packages are used when node_modules is not clean', async () => { const destPackageJsonPath = path.join(projectDir, 'package.json') const destLockfileYamlPath = path.join(projectDir, WANTED_LOCKFILE) - const hasGlobDir = path.join(fixtures, 'has-glob') - const hasGlobAndRimrafDir = path.join(fixtures, 'has-glob-and-rimraf') + const hasGlobDir = f.find('has-glob') await fs.copyFile(path.join(hasGlobDir, 'package.json'), destPackageJsonPath) await fs.copyFile(path.join(hasGlobDir, WANTED_LOCKFILE), destLockfileYamlPath) await headless(await testDefaults({ lockfileDir: projectDir })) + const hasGlobAndRimrafDir = f.find('has-glob-and-rimraf') await fs.copyFile(path.join(hasGlobAndRimrafDir, 'package.json'), destPackageJsonPath) await fs.copyFile(path.join(hasGlobAndRimrafDir, WANTED_LOCKFILE), destLockfileYamlPath) @@ -440,13 +429,13 @@ test('available packages are relinked during forced install', async () => { const destPackageJsonPath = path.join(projectDir, 'package.json') const destLockfileYamlPath = path.join(projectDir, WANTED_LOCKFILE) - const hasGlobDir = path.join(fixtures, 'has-glob') - const hasGlobAndRimrafDir = path.join(fixtures, 'has-glob-and-rimraf') + const hasGlobDir = f.find('has-glob') await fs.copyFile(path.join(hasGlobDir, 'package.json'), destPackageJsonPath) await fs.copyFile(path.join(hasGlobDir, WANTED_LOCKFILE), destLockfileYamlPath) await headless(await testDefaults({ lockfileDir: projectDir })) + const hasGlobAndRimrafDir = f.find('has-glob-and-rimraf') await fs.copyFile(path.join(hasGlobAndRimrafDir, 'package.json'), destPackageJsonPath) await fs.copyFile(path.join(hasGlobAndRimrafDir, WANTED_LOCKFILE), destLockfileYamlPath) @@ -474,10 +463,10 @@ test('available packages are relinked during forced install', async () => { test(`fail when ${WANTED_LOCKFILE} is not up-to-date with package.json`, async () => { const projectDir = tempDir() - const simpleDir = path.join(fixtures, 'simple') + const simpleDir = f.find('simple') await fs.copyFile(path.join(simpleDir, 'package.json'), path.join(projectDir, 'package.json')) - const simpleWithMoreDepsDir = path.join(fixtures, 'simple-with-more-deps') + const simpleWithMoreDepsDir = f.find('simple-with-more-deps') await fs.copyFile(path.join(simpleWithMoreDepsDir, WANTED_LOCKFILE), path.join(projectDir, WANTED_LOCKFILE)) try { @@ -489,7 +478,8 @@ test(`fail when ${WANTED_LOCKFILE} is not up-to-date with package.json`, async ( }) test('installing local dependency', async () => { - const prefix = path.join(fixtures, 'has-local-dep') + let prefix = f.prepare('has-local-dep') + prefix = path.join(prefix, 'pkg') const reporter = sinon.spy() await headless(await testDefaults({ lockfileDir: prefix, reporter })) @@ -499,7 +489,7 @@ test('installing local dependency', async () => { }) test('installing local directory dependency', async () => { - const prefix = path.join(fixtures, 'has-local-dir-dep') + const prefix = f.prepare('has-local-dir-dep') const reporter = sinon.spy() await headless(await testDefaults({ lockfileDir: prefix, reporter })) @@ -511,7 +501,7 @@ test('installing local directory dependency', async () => { test('installing using passed in lockfile files', async () => { const prefix = tempDir() - const simplePkgPath = path.join(fixtures, 'simple') + const simplePkgPath = f.find('simple') await fs.copyFile(path.join(simplePkgPath, 'package.json'), path.join(prefix, 'package.json')) await fs.copyFile(path.join(simplePkgPath, WANTED_LOCKFILE), path.join(prefix, WANTED_LOCKFILE)) @@ -531,7 +521,7 @@ test('installing using passed in lockfile files', async () => { }) test('installation of a dependency that has a resolved peer in subdeps', async () => { - const prefix = path.join(fixtures, 'resolved-peer-deps-in-subdeps') + const prefix = f.prepare('resolved-peer-deps-in-subdeps') await headless(await testDefaults({ lockfileDir: prefix })) @@ -540,7 +530,7 @@ test('installation of a dependency that has a resolved peer in subdeps', async ( }) test('installing with hoistPattern=*', async () => { - const prefix = path.join(fixtures, 'simple-shamefully-flatten') + const prefix = f.prepare('simple-shamefully-flatten') const reporter = jest.fn() await headless(await testDefaults({ lockfileDir: prefix, reporter, hoistPattern: '*' })) @@ -599,8 +589,7 @@ test('installing with hoistPattern=*', async () => { }) test('installing with publicHoistPattern=*', async () => { - const prefix = path.join(fixtures, 'simple-shamefully-flatten') - await rimraf(path.join(prefix, 'node_modules')) + const prefix = f.prepare('simple-shamefully-flatten') const reporter = sinon.spy() await headless(await testDefaults({ lockfileDir: prefix, reporter, publicHoistPattern: '*' })) @@ -656,8 +645,7 @@ test('installing with publicHoistPattern=*', async () => { }) test('installing with publicHoistPattern=* in a project with external lockfile', async () => { - const lockfileDir = tempDir() - await copyFixture('pkg-with-external-lockfile', lockfileDir) + const lockfileDir = f.prepare('pkg-with-external-lockfile') const prefix = path.join(lockfileDir, 'pkg') let { projects } = await readprojectsContext( @@ -686,7 +674,7 @@ test('installing with publicHoistPattern=* in a project with external lockfile', const ENGINE_DIR = `${process.platform}-${process.arch}-node-${process.version.split('.')[0]}` skipOnWindows('using side effects cache', async () => { - const prefix = path.join(fixtures, 'side-effects') + let prefix = f.prepare('side-effects') // Right now, hardlink does not work with side effects, so we specify copy as the packageImportMethod // We disable verifyStoreIntegrity because we are going to change the cache @@ -707,7 +695,7 @@ skipOnWindows('using side effects cache', async () => { expect(cacheIntegrity).toHaveProperty(['sideEffects', ENGINE_NAME, 'build/binding.Makefile']) await writeJsonFile(cacheIntegrityPath, cacheIntegrity) - await rimraf(path.join(prefix, 'node_modules')) + prefix = f.prepare('side-effects') const opts2 = await testDefaults({ lockfileDir: prefix, sideEffectsCacheRead: true, @@ -722,7 +710,7 @@ skipOnWindows('using side effects cache', async () => { }) test.skip('using side effects cache and hoistPattern=*', async () => { - const lockfileDir = path.join(fixtures, 'side-effects-of-subdep') + const lockfileDir = f.prepare('side-effects-of-subdep') const { projects } = await readprojectsContext( [ @@ -762,7 +750,7 @@ test.skip('using side effects cache and hoistPattern=*', async () => { }) test('installing in a workspace', async () => { - const workspaceFixture = path.join(__dirname, 'workspace-fixture') + const workspaceFixture = f.prepare('workspace') let { projects } = await readprojectsContext( [ @@ -803,9 +791,7 @@ test('installing in a workspace', async () => { }) test('installing with no symlinks but with PnP', async () => { - const prefix = path.join(fixtures, 'simple') - await rimraf(path.join(prefix, 'node_modules')) - await rimraf(path.join(prefix, '.pnp.cjs')) + const prefix = f.prepare('simple') await headless(await testDefaults({ enablePnp: true, @@ -823,9 +809,7 @@ test('installing with no symlinks but with PnP', async () => { }) test('installing with no modules directory', async () => { - const prefix = path.join(fixtures, 'simple') - await rimraf(path.join(prefix, 'node_modules')) - await rimraf(path.join(prefix, '.pnp.cjs')) + const prefix = f.prepare('simple') await headless(await testDefaults({ enableModulesDir: false, diff --git a/packages/headless/test/pretest.ts b/packages/headless/test/pretest.ts deleted file mode 100644 index 6a31389f7d..0000000000 --- a/packages/headless/test/pretest.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { promises as fs } from 'fs' -import path from 'path' -import rimrafModule from 'rimraf' - -const fixtures = path.join(__dirname, 'fixtures') -const workspaceFixture = path.join(__dirname, 'workspace-fixture') -const workspaceFixture2 = path.join(__dirname, 'workspace-fixture2') - -removeModules() - .then(() => console.log('Done')) - .catch(err => console.error(err)) - -async function removeModules () { - const dirsToRemove = [ - ...(await fs.readdir(fixtures)).map((dir) => path.join(fixtures, dir)), - ...(await fs.readdir(workspaceFixture)).map((dir) => path.join(workspaceFixture, dir)), - ...(await fs.readdir(workspaceFixture2)).map((dir) => path.join(workspaceFixture2, dir)), - workspaceFixture, - workspaceFixture2, - ] - .map((dir) => path.join(dir, 'node_modules')) - await Promise.all(dirsToRemove.map(async (dir) => rimraf(dir))) -} - -async function rimraf (dir: string) { - return new Promise((resolve, reject) => rimrafModule(dir, err => err ? reject(err) : resolve())) -} diff --git a/packages/headless/test/workspace-fixture2/.npmrc b/packages/headless/test/workspace-fixture2/.npmrc deleted file mode 100644 index 32b7ad3cf0..0000000000 --- a/packages/headless/test/workspace-fixture2/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -link-workspace-packages=true -shared-workspace-lockfile=true diff --git a/packages/headless/test/workspace-fixture2/bar/package.json b/packages/headless/test/workspace-fixture2/bar/package.json deleted file mode 100644 index b3646df497..0000000000 --- a/packages/headless/test/workspace-fixture2/bar/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "bar", - "version": "1.0.0", - "dependencies": { - "foo": "1.0.0", - "is-positive": "1.0.0", - "express": "4.16.4" - } -} diff --git a/packages/headless/test/workspace-fixture2/foo/package.json b/packages/headless/test/workspace-fixture2/foo/package.json deleted file mode 100644 index 47776daf7d..0000000000 --- a/packages/headless/test/workspace-fixture2/foo/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "foo", - "version": "1.0.0", - "dependencies": { - "is-negative": "1.0.0" - } -} diff --git a/packages/headless/test/workspace-fixture2/pnpm-lock.yaml b/packages/headless/test/workspace-fixture2/pnpm-lock.yaml deleted file mode 100644 index 42dc23c4dc..0000000000 --- a/packages/headless/test/workspace-fixture2/pnpm-lock.yaml +++ /dev/null @@ -1,392 +0,0 @@ -importers: - bar: - dependencies: - express: 4.16.4 - foo: 'link:../foo' - is-positive: 1.0.0 - specifiers: - express: 4.16.4 - foo: 1.0.0 - is-positive: 1.0.0 - foo: - dependencies: - is-negative: 1.0.0 - specifiers: - is-negative: 1.0.0 -lockfileVersion: 5 -packages: - /accepts/1.3.5: - dependencies: - mime-types: 2.1.21 - negotiator: 0.6.1 - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-63d99gEXI6OxTopywIBcjoZ0a9I= - /array-flatten/1.1.1: - dev: false - resolution: - integrity: sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= - /body-parser/1.18.3: - dependencies: - bytes: 3.0.0 - content-type: 1.0.4 - debug: 2.6.9 - depd: 1.1.2 - http-errors: 1.6.3 - iconv-lite: 0.4.23 - on-finished: 2.3.0 - qs: 6.5.2 - raw-body: 2.3.3 - type-is: 1.6.16 - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ= - /bytes/3.0.0: - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg= - /content-disposition/0.5.2: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-DPaLud318r55YcOoUXjLhdunjLQ= - /content-type/1.0.4: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== - /cookie-signature/1.0.6: - dev: false - resolution: - integrity: sha1-4wOogrNCzD7oylE6eZmXNNqzriw= - /cookie/0.3.1: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= - /debug/2.6.9: - dependencies: - ms: 2.0.0 - dev: false - resolution: - integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== - /depd/1.1.2: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= - /destroy/1.0.4: - dev: false - resolution: - integrity: sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= - /ee-first/1.1.1: - dev: false - resolution: - integrity: sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= - /encodeurl/1.0.2: - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= - /escape-html/1.0.3: - dev: false - resolution: - integrity: sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= - /etag/1.8.1: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= - /express/4.16.4: - dependencies: - accepts: 1.3.5 - array-flatten: 1.1.1 - body-parser: 1.18.3 - content-disposition: 0.5.2 - content-type: 1.0.4 - cookie: 0.3.1 - cookie-signature: 1.0.6 - debug: 2.6.9 - depd: 1.1.2 - encodeurl: 1.0.2 - escape-html: 1.0.3 - etag: 1.8.1 - finalhandler: 1.1.1 - fresh: 0.5.2 - merge-descriptors: 1.0.1 - methods: 1.1.2 - on-finished: 2.3.0 - parseurl: 1.3.2 - path-to-regexp: 0.1.7 - proxy-addr: 2.0.4 - qs: 6.5.2 - range-parser: 1.2.0 - safe-buffer: 5.1.2 - send: 0.16.2 - serve-static: 1.13.2 - setprototypeof: 1.1.0 - statuses: 1.4.0 - type-is: 1.6.16 - utils-merge: 1.0.1 - vary: 1.1.2 - dev: false - engines: - node: '>= 0.10.0' - resolution: - integrity: sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg== - /finalhandler/1.1.1: - dependencies: - debug: 2.6.9 - encodeurl: 1.0.2 - escape-html: 1.0.3 - on-finished: 2.3.0 - parseurl: 1.3.2 - statuses: 1.4.0 - unpipe: 1.0.0 - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg== - /forwarded/0.1.2: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= - /fresh/0.5.2: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac= - /http-errors/1.6.3: - dependencies: - depd: 1.1.2 - inherits: 2.0.3 - setprototypeof: 1.1.0 - statuses: 1.5.0 - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0= - /iconv-lite/0.4.23: - dependencies: - safer-buffer: 2.1.2 - dev: false - engines: - node: '>=0.10.0' - resolution: - integrity: sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA== - /inherits/2.0.3: - dev: false - resolution: - integrity: sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - /ipaddr.js/1.8.0: - dev: false - engines: - node: '>= 0.10' - resolution: - integrity: sha1-6qM9bd16zo9/b+DJygRA5wZzix4= - /is-negative/1.0.0: - dev: false - engines: - node: '>=0.10.0' - resolution: - integrity: sha1-clmHeoPIAKwxkd17nZ+80PdS1P4= - /is-positive/1.0.0: - dev: false - engines: - node: '>=0.10.0' - resolution: - integrity: sha1-iACYVrZKLx632LsBeUGEJK4EUss= - /media-typer/0.3.0: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= - /merge-descriptors/1.0.1: - dev: false - resolution: - integrity: sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E= - /methods/1.1.2: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= - /mime-db/1.37.0: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg== - /mime-types/2.1.21: - dependencies: - mime-db: 1.37.0 - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg== - /mime/1.4.1: - dev: false - hasBin: true - resolution: - integrity: sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ== - /ms/2.0.0: - dev: false - resolution: - integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= - /negotiator/0.6.1: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= - /on-finished/2.3.0: - dependencies: - ee-first: 1.1.1 - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= - /parseurl/1.3.2: - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha1-/CidTtiZMRlGDBViUyYs3I3mW/M= - /path-to-regexp/0.1.7: - dev: false - resolution: - integrity: sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= - /proxy-addr/2.0.4: - dependencies: - forwarded: 0.1.2 - ipaddr.js: 1.8.0 - dev: false - engines: - node: '>= 0.10' - resolution: - integrity: sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA== - /qs/6.5.2: - dev: false - engines: - node: '>=0.6' - resolution: - integrity: sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== - /range-parser/1.2.0: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4= - /raw-body/2.3.3: - dependencies: - bytes: 3.0.0 - http-errors: 1.6.3 - iconv-lite: 0.4.23 - unpipe: 1.0.0 - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw== - /safe-buffer/5.1.2: - dev: false - resolution: - integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - /safer-buffer/2.1.2: - dev: false - resolution: - integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== - /send/0.16.2: - dependencies: - debug: 2.6.9 - depd: 1.1.2 - destroy: 1.0.4 - encodeurl: 1.0.2 - escape-html: 1.0.3 - etag: 1.8.1 - fresh: 0.5.2 - http-errors: 1.6.3 - mime: 1.4.1 - ms: 2.0.0 - on-finished: 2.3.0 - range-parser: 1.2.0 - statuses: 1.4.0 - dev: false - engines: - node: '>= 0.8.0' - resolution: - integrity: sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw== - /serve-static/1.13.2: - dependencies: - encodeurl: 1.0.2 - escape-html: 1.0.3 - parseurl: 1.3.2 - send: 0.16.2 - dev: false - engines: - node: '>= 0.8.0' - resolution: - integrity: sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw== - /setprototypeof/1.1.0: - dev: false - resolution: - integrity: sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== - /statuses/1.4.0: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew== - /statuses/1.5.0: - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= - /type-is/1.6.16: - dependencies: - media-typer: 0.3.0 - mime-types: 2.1.21 - dev: false - engines: - node: '>= 0.6' - resolution: - integrity: sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q== - /unpipe/1.0.0: - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= - /utils-merge/1.0.1: - dev: false - engines: - node: '>= 0.4.0' - resolution: - integrity: sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= - /vary/1.1.2: - dev: false - engines: - node: '>= 0.8' - resolution: - integrity: sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= diff --git a/packages/link-bins/package.json b/packages/link-bins/package.json index b5c04f723c..2ffac159c7 100644 --- a/packages/link-bins/package.json +++ b/packages/link-bins/package.json @@ -13,9 +13,7 @@ }, "scripts": { "lint": "eslint src/**/*.ts test/**/*.ts", - "pretest": "ncp test/fixtures test/fixtures_for_testing", - "posttest": "rimraf test/fixtures_for_testing", - "_test": "pnpm pretest && jest && pnpm posttest", + "_test": "jest", "test": "pnpm run compile && pnpm run _test", "prepublishOnly": "pnpm run compile", "fix": "tslint -c tslint.json --project . --fix", @@ -50,13 +48,12 @@ }, "devDependencies": { "@pnpm/logger": "^4.0.0", + "@pnpm/test-fixtures": "workspace:*", "@types/is-windows": "^1.0.0", - "@types/ncp": "^2.0.4", "@types/node": "^14.17.32", "@types/normalize-path": "^3.0.0", "@types/ramda": "0.27.39", "cmd-extension": "^1.0.2", - "ncp": "^2.0.0", "path-exists": "^4.0.0", "tempy": "^1.0.0" }, diff --git a/packages/link-bins/test/fixtures/bin-dir/pkg/bin/subdir/index.js b/packages/link-bins/test/fixtures/bin-dir/pkg/bin/subdir/index.js old mode 100644 new mode 100755 diff --git a/packages/link-bins/test/index.ts b/packages/link-bins/test/index.ts index 49dd02938d..d92edaabe3 100644 --- a/packages/link-bins/test/index.ts +++ b/packages/link-bins/test/index.ts @@ -1,14 +1,13 @@ /// -import { promisify } from 'util' import { promises as fs } from 'fs' import path from 'path' import logger, { globalWarn } from '@pnpm/logger' import linkBins, { linkBinsOfPackages, } from '@pnpm/link-bins' +import fixtures from '@pnpm/test-fixtures' import CMD_EXTENSION from 'cmd-extension' import isWindows from 'is-windows' -import ncpcb from 'ncp' import normalizePath from 'normalize-path' import exists from 'path-exists' import tempy from 'tempy' @@ -25,24 +24,14 @@ jest.mock('@pnpm/logger', () => { }) const binsConflictLogger = logger('bins-conflict') -const ncp = promisify(ncpcb) +// The fixture directories are copied to before the tests run +// This happens because the tests convert some of the files into executables +const f = fixtures(__dirname) beforeEach(() => { binsConflictLogger.debug['mockClear']() }) -// The fixtures directory is copied to fixtures_for_testing before the tests run -// This happens because the tests conver some of the files into executables -const fixtures = path.join(__dirname, 'fixtures_for_testing') -const simpleFixture = path.join(fixtures, 'simple-fixture') -const binNameConflictsFixture = path.join(fixtures, 'bin-name-conflicts') -const foobarFixture = path.join(fixtures, 'foobar') -const exoticManifestFixture = path.join(fixtures, 'exotic-manifest') -const noNameFixture = path.join(fixtures, 'no-name') -const noBinFixture = path.join(fixtures, 'no-bin') -const windowShebangFixture = path.join(fixtures, 'bin-window-shebang') -const binNotExistFixture = path.join(fixtures, 'bin-not-exist') - const POWER_SHELL_IS_SUPPORTED = isWindows() const IS_WINDOWS = isWindows() const EXECUTABLE_SHEBANG_SUPPORTED = !IS_WINDOWS @@ -61,6 +50,7 @@ function getExpectedBins (bins: string[]) { test('linkBins()', async () => { const binTarget = tempy.directory() const warn = jest.fn() + const simpleFixture = f.prepare('simple-fixture') await linkBins(path.join(simpleFixture, 'node_modules'), binTarget, { warn }) @@ -81,9 +71,10 @@ test('linkBins()', async () => { test('linkBins() never creates a PowerShell shim for the pnpm CLI', async () => { const binTarget = tempy.directory() + const fixture = f.prepare('pnpm-cli') const warn = jest.fn() - await linkBins(path.join(fixtures, 'pnpm-cli/node_modules'), binTarget, { warn }) + await linkBins(path.join(fixture, 'node_modules'), binTarget, { warn }) const bins = await fs.readdir(binTarget) expect(bins).toContain('pnpm') @@ -92,6 +83,7 @@ test('linkBins() never creates a PowerShell shim for the pnpm CLI', async () => test('linkBins() finds exotic manifests', async () => { const binTarget = tempy.directory() + const exoticManifestFixture = f.prepare('exotic-manifest') const warn = jest.fn() await linkBins(path.join(exoticManifestFixture, 'node_modules'), binTarget, { @@ -118,7 +110,7 @@ test('linkBins() do not fail on directory w/o manifest file', async () => { const binTarget = tempy.directory() const warn = jest.fn() - await linkBins(path.join(fixtures, 'dir-with-no-manifest/node_modules'), binTarget, { + await linkBins(f.find('dir-with-no-manifest/node_modules'), binTarget, { allowExoticManifests: false, warn, }) @@ -130,7 +122,7 @@ test('linkBins() with exotic manifests do not fail on directory w/o manifest fil const binTarget = tempy.directory() const warn = jest.fn() - await linkBins(path.join(fixtures, 'dir-with-no-manifest/node_modules'), binTarget, { + await linkBins(f.find('dir-with-no-manifest/node_modules'), binTarget, { allowExoticManifests: true, warn, }) @@ -139,8 +131,7 @@ test('linkBins() with exotic manifests do not fail on directory w/o manifest fil }) test('linkBins() does not link own bins', async () => { - const target = tempy.directory() - await ncp(foobarFixture, target) + const target = f.prepare('foobar') const warn = jest.fn() const modules = path.join(target, 'node_modules') @@ -154,6 +145,7 @@ test('linkBins() does not link own bins', async () => { test('linkBinsOfPackages()', async () => { const binTarget = tempy.directory() + const simpleFixture = f.prepare('simple-fixture') const warn = jest.fn() await linkBinsOfPackages( @@ -177,6 +169,7 @@ test('linkBinsOfPackages()', async () => { test('linkBins() resolves conflicts. Prefer packages that use their name as bin name', async () => { const binTarget = tempy.directory() + const binNameConflictsFixture = f.prepare('bin-name-conflicts') const warn = jest.fn() await linkBins(path.join(binNameConflictsFixture, 'node_modules'), binTarget, { warn }) @@ -206,6 +199,7 @@ test('linkBins() resolves conflicts. Prefer packages that use their name as bin test('linkBinsOfPackages() resolves conflicts. Prefer packages that use their name as bin name', async () => { const binTarget = tempy.directory() + const binNameConflictsFixture = f.prepare('bin-name-conflicts') const warn = jest.fn() const modulesPath = path.join(binNameConflictsFixture, 'node_modules') @@ -250,6 +244,7 @@ test('linkBinsOfPackages() resolves conflicts. Prefer packages that use their na test('linkBins() resolves conflicts. Prefer packages are direct dependencies', async () => { const binTarget = tempy.directory() + const binNameConflictsFixture = f.prepare('bin-name-conflicts') const warn = jest.fn() await linkBins(path.join(binNameConflictsFixture, 'node_modules'), binTarget, { @@ -281,6 +276,7 @@ test('linkBins() resolves conflicts. Prefer packages are direct dependencies', a test('linkBins() would throw error if package has no name field', async () => { const binTarget = tempy.directory() + const noNameFixture = f.prepare('no-name') const warn = jest.fn() try { @@ -299,6 +295,7 @@ test('linkBins() would throw error if package has no name field', async () => { test('linkBins() would give warning if package has no bin field', async () => { const binTarget = tempy.directory() + const noBinFixture = f.prepare('no-bin') const warn = jest.fn() await linkBins(path.join(noBinFixture, 'packages'), binTarget, { @@ -312,6 +309,7 @@ test('linkBins() would give warning if package has no bin field', async () => { test('linkBins() would not give warning if package has no bin field but inside node_modules', async () => { const binTarget = tempy.directory() + const noBinFixture = f.prepare('no-bin') const warn = jest.fn() await linkBins(path.join(noBinFixture, 'node_modules'), binTarget, { @@ -325,13 +323,14 @@ test('linkBins() would not give warning if package has no bin field but inside n test('linkBins() links commands from bin directory with a subdirectory', async () => { const binTarget = tempy.directory() - await linkBins(path.join(fixtures, 'bin-dir'), binTarget, { warn: () => {} }) + await linkBins(f.find('bin-dir'), binTarget, { warn: () => {} }) expect(await fs.readdir(binTarget)).toEqual(getExpectedBins(['index.js'])) }) test('linkBins() fix window shebang line', async () => { const binTarget = tempy.directory() + const windowShebangFixture = f.prepare('bin-window-shebang') const warn = jest.fn() await linkBins(path.join(windowShebangFixture, 'node_modules'), binTarget, { warn }) @@ -365,6 +364,7 @@ test('linkBins() fix window shebang line', async () => { test("linkBins() emits global warning when bin points to path that doesn't exist", async () => { const binTarget = tempy.directory() + const binNotExistFixture = f.prepare('bin-not-exist') await linkBins(path.join(binNotExistFixture, 'node_modules'), binTarget, { allowExoticManifests: true, diff --git a/packages/link-bins/tsconfig.json b/packages/link-bins/tsconfig.json index 82bfda2d0e..6f540a32cc 100644 --- a/packages/link-bins/tsconfig.json +++ b/packages/link-bins/tsconfig.json @@ -9,6 +9,9 @@ "../../typings/**/*.d.ts" ], "references": [ + { + "path": "../../privatePackages/test-fixtures" + }, { "path": "../error" }, diff --git a/packages/make-dedicated-lockfile/package.json b/packages/make-dedicated-lockfile/package.json index 6821dea2f7..4256cc9f42 100644 --- a/packages/make-dedicated-lockfile/package.json +++ b/packages/make-dedicated-lockfile/package.json @@ -46,9 +46,7 @@ }, "funding": "https://opencollective.com/pnpm", "devDependencies": { - "@pnpm/prepare": "workspace:0.0.31", - "@types/ncp": "^2.0.4", - "@types/ramda": "0.27.39", - "ncp": "^2.0.0" + "@pnpm/test-fixtures": "workspace:*", + "@types/ramda": "0.27.39" } } diff --git a/packages/make-dedicated-lockfile/test/fixture/pnpm-workspace.yaml b/packages/make-dedicated-lockfile/test/fixture/pnpm-workspace.yaml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/make-dedicated-lockfile/test/fixture/packages/is-negative/example/package.json b/packages/make-dedicated-lockfile/test/fixtures/fixture/packages/is-negative/example/package.json similarity index 100% rename from packages/make-dedicated-lockfile/test/fixture/packages/is-negative/example/package.json rename to packages/make-dedicated-lockfile/test/fixtures/fixture/packages/is-negative/example/package.json diff --git a/packages/make-dedicated-lockfile/test/fixture/packages/is-negative/package.json b/packages/make-dedicated-lockfile/test/fixtures/fixture/packages/is-negative/package.json similarity index 100% rename from packages/make-dedicated-lockfile/test/fixture/packages/is-negative/package.json rename to packages/make-dedicated-lockfile/test/fixtures/fixture/packages/is-negative/package.json diff --git a/packages/make-dedicated-lockfile/test/fixture/packages/is-positive/package.json b/packages/make-dedicated-lockfile/test/fixtures/fixture/packages/is-positive/package.json similarity index 100% rename from packages/make-dedicated-lockfile/test/fixture/packages/is-positive/package.json rename to packages/make-dedicated-lockfile/test/fixtures/fixture/packages/is-positive/package.json diff --git a/packages/make-dedicated-lockfile/test/fixture/pnpm-lock.yaml b/packages/make-dedicated-lockfile/test/fixtures/fixture/pnpm-lock.yaml similarity index 100% rename from packages/make-dedicated-lockfile/test/fixture/pnpm-lock.yaml rename to packages/make-dedicated-lockfile/test/fixtures/fixture/pnpm-lock.yaml diff --git a/packages/headless/test/workspace-fixture2/pnpm-workspace.yaml b/packages/make-dedicated-lockfile/test/fixtures/fixture/pnpm-workspace.yaml similarity index 100% rename from packages/headless/test/workspace-fixture2/pnpm-workspace.yaml rename to packages/make-dedicated-lockfile/test/fixtures/fixture/pnpm-workspace.yaml diff --git a/packages/make-dedicated-lockfile/test/index.ts b/packages/make-dedicated-lockfile/test/index.ts index ff94ede14c..fc5e0b497f 100644 --- a/packages/make-dedicated-lockfile/test/index.ts +++ b/packages/make-dedicated-lockfile/test/index.ts @@ -1,17 +1,12 @@ -import { promisify } from 'util' import path from 'path' import { readWantedLockfile } from '@pnpm/lockfile-file' -import { tempDir } from '@pnpm/prepare' -import ncpCB from 'ncp' +import fixtures from '@pnpm/test-fixtures' import makeDedicatedLockfile from '../lib' -const ncp = promisify(ncpCB) - -const fixture = path.join(__dirname, 'fixture') +const f = fixtures(__dirname) test('makeDedicatedLockfile()', async () => { - const tmp = tempDir() - await ncp(fixture, tmp) + const tmp = f.prepare('fixture') const projectDir = path.join(tmp, 'packages/is-negative') await makeDedicatedLockfile(tmp, projectDir) diff --git a/packages/make-dedicated-lockfile/tsconfig.json b/packages/make-dedicated-lockfile/tsconfig.json index 52efe5d5d3..f196e7d157 100644 --- a/packages/make-dedicated-lockfile/tsconfig.json +++ b/packages/make-dedicated-lockfile/tsconfig.json @@ -10,7 +10,7 @@ ], "references": [ { - "path": "../../privatePackages/prepare" + "path": "../../privatePackages/test-fixtures" }, { "path": "../error" diff --git a/packages/npm-resolver/package.json b/packages/npm-resolver/package.json index ef96813182..227b88411f 100644 --- a/packages/npm-resolver/package.json +++ b/packages/npm-resolver/package.json @@ -58,6 +58,7 @@ "devDependencies": { "@pnpm/fetch": "workspace:4.2.3", "@pnpm/logger": "^4.0.0", + "@pnpm/test-fixtures": "workspace:*", "@types/lru-cache": "^5.1.0", "@types/normalize-path": "^3.0.0", "@types/semver": "^7.3.4", diff --git a/packages/npm-resolver/test/meta/JSON.json b/packages/npm-resolver/test/fixtures/JSON.json similarity index 100% rename from packages/npm-resolver/test/meta/JSON.json rename to packages/npm-resolver/test/fixtures/JSON.json diff --git a/packages/npm-resolver/test/meta/broken-integrity.json b/packages/npm-resolver/test/fixtures/broken-integrity.json similarity index 100% rename from packages/npm-resolver/test/meta/broken-integrity.json rename to packages/npm-resolver/test/fixtures/broken-integrity.json diff --git a/packages/npm-resolver/test/meta/is-positive-broken.json b/packages/npm-resolver/test/fixtures/is-positive-broken.json similarity index 100% rename from packages/npm-resolver/test/meta/is-positive-broken.json rename to packages/npm-resolver/test/fixtures/is-positive-broken.json diff --git a/packages/npm-resolver/test/meta/is-positive-full.json b/packages/npm-resolver/test/fixtures/is-positive-full.json similarity index 100% rename from packages/npm-resolver/test/meta/is-positive-full.json rename to packages/npm-resolver/test/fixtures/is-positive-full.json diff --git a/packages/npm-resolver/test/meta/is-positive-with-deprecated.json b/packages/npm-resolver/test/fixtures/is-positive-with-deprecated.json similarity index 100% rename from packages/npm-resolver/test/meta/is-positive-with-deprecated.json rename to packages/npm-resolver/test/fixtures/is-positive-with-deprecated.json diff --git a/packages/npm-resolver/test/meta/is-positive.json b/packages/npm-resolver/test/fixtures/is-positive.json similarity index 100% rename from packages/npm-resolver/test/meta/is-positive.json rename to packages/npm-resolver/test/fixtures/is-positive.json diff --git a/packages/npm-resolver/test/meta/malformed.json b/packages/npm-resolver/test/fixtures/malformed.json similarity index 100% rename from packages/npm-resolver/test/meta/malformed.json rename to packages/npm-resolver/test/fixtures/malformed.json diff --git a/packages/npm-resolver/test/meta/sindresorhus-is.json b/packages/npm-resolver/test/fixtures/sindresorhus-is.json similarity index 100% rename from packages/npm-resolver/test/meta/sindresorhus-is.json rename to packages/npm-resolver/test/fixtures/sindresorhus-is.json diff --git a/packages/npm-resolver/test/index.ts b/packages/npm-resolver/test/index.ts index f102633346..06646bf378 100644 --- a/packages/npm-resolver/test/index.ts +++ b/packages/npm-resolver/test/index.ts @@ -6,19 +6,21 @@ import _createResolveFromNpm, { RegistryResponseError, NoMatchingVersionError, } from '@pnpm/npm-resolver' +import fixtures from '@pnpm/test-fixtures' import loadJsonFile from 'load-json-file' import nock from 'nock' import exists from 'path-exists' import tempy from 'tempy' +const f = fixtures(__dirname) /* eslint-disable @typescript-eslint/no-explicit-any */ -const isPositiveMeta = loadJsonFile.sync(path.join(__dirname, 'meta', 'is-positive.json')) -const isPositiveMetaWithDeprecated = loadJsonFile.sync(path.join(__dirname, 'meta', 'is-positive-with-deprecated.json')) -const isPositiveMetaFull = loadJsonFile.sync(path.join(__dirname, 'meta', 'is-positive-full.json')) -const isPositiveBrokenMeta = loadJsonFile.sync(path.join(__dirname, 'meta', 'is-positive-broken.json')) -const sindresorhusIsMeta = loadJsonFile.sync(path.join(__dirname, 'meta', 'sindresorhus-is.json')) -const jsonMeta = loadJsonFile.sync(path.join(__dirname, 'meta', 'JSON.json')) -const brokenIntegrity = loadJsonFile.sync(path.join(__dirname, 'meta', 'broken-integrity.json')) +const isPositiveMeta = loadJsonFile.sync(f.find('is-positive.json')) +const isPositiveMetaWithDeprecated = loadJsonFile.sync(f.find('is-positive-with-deprecated.json')) +const isPositiveMetaFull = loadJsonFile.sync(f.find('is-positive-full.json')) +const isPositiveBrokenMeta = loadJsonFile.sync(f.find('is-positive-broken.json')) +const sindresorhusIsMeta = loadJsonFile.sync(f.find('sindresorhus-is.json')) +const jsonMeta = loadJsonFile.sync(f.find('JSON.json')) +const brokenIntegrity = loadJsonFile.sync(f.find('broken-integrity.json')) /* eslint-enable @typescript-eslint/no-explicit-any */ const registry = 'https://registry.npmjs.org/' @@ -1616,7 +1618,7 @@ test('request to metadata is retried if the received JSON is broken', async () = test('request to a package with malformed metadata', async () => { nock(registry) .get('/code-snippet') - .reply(200, loadJsonFile.sync(path.join(__dirname, 'meta/malformed.json'))) + .reply(200, loadJsonFile.sync(f.find('malformed.json'))) const cacheDir = tempy.directory() const resolve = createResolveFromNpm({ cacheDir }) diff --git a/packages/npm-resolver/tsconfig.json b/packages/npm-resolver/tsconfig.json index 409002c4c0..e94db4fe11 100644 --- a/packages/npm-resolver/tsconfig.json +++ b/packages/npm-resolver/tsconfig.json @@ -9,6 +9,9 @@ "../../typings/**/*.d.ts" ], "references": [ + { + "path": "../../privatePackages/test-fixtures" + }, { "path": "../core-loggers" }, diff --git a/packages/package-requester/package.json b/packages/package-requester/package.json index 22a156c9fa..042390305f 100644 --- a/packages/package-requester/package.json +++ b/packages/package-requester/package.json @@ -64,12 +64,11 @@ "@pnpm/client": "workspace:6.0.11", "@pnpm/logger": "^4.0.0", "@pnpm/package-store": "workspace:12.1.6", - "@types/ncp": "^2.0.4", + "@pnpm/test-fixtures": "workspace:*", "@types/normalize-path": "^3.0.0", "@types/ramda": "0.27.39", "@types/ssri": "^7.1.0", "delay": "^5.0.0", - "ncp": "^2.0.0", "nock": "12.0.3", "normalize-path": "^3.0.0", "tempy": "^1.0.0" diff --git a/packages/package-requester/test/is-positive-1.0.0.tgz b/packages/package-requester/test/fixtures/is-positive-1.0.0.tgz similarity index 100% rename from packages/package-requester/test/is-positive-1.0.0.tgz rename to packages/package-requester/test/fixtures/is-positive-1.0.0.tgz diff --git a/packages/package-requester/test/pnpm-package-requester-0.8.1.tgz b/packages/package-requester/test/fixtures/pnpm-package-requester-0.8.1.tgz similarity index 100% rename from packages/package-requester/test/pnpm-package-requester-0.8.1.tgz rename to packages/package-requester/test/fixtures/pnpm-package-requester-0.8.1.tgz diff --git a/packages/package-requester/test/pnpm-package-requester-4.1.2.tgz b/packages/package-requester/test/fixtures/pnpm-package-requester-4.1.2.tgz similarity index 100% rename from packages/package-requester/test/pnpm-package-requester-4.1.2.tgz rename to packages/package-requester/test/fixtures/pnpm-package-requester-4.1.2.tgz diff --git a/packages/package-requester/test/index.ts b/packages/package-requester/test/index.ts index b86b0819b9..ab65ecf6fa 100644 --- a/packages/package-requester/test/index.ts +++ b/packages/package-requester/test/index.ts @@ -1,5 +1,4 @@ /// -import { promisify } from 'util' import { promises as fs, statSync } from 'fs' import path from 'path' import { getFilePathInCafs, PackageFilesIndex } from '@pnpm/cafs' @@ -8,18 +7,18 @@ import { streamParser } from '@pnpm/logger' import createPackageRequester, { PackageFilesResponse, PackageResponse } from '@pnpm/package-requester' import { createCafsStore } from '@pnpm/package-store' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' +import fixtures from '@pnpm/test-fixtures' import { DependencyManifest } from '@pnpm/types' import delay from 'delay' import { depPathToFilename } from 'dependency-path' import loadJsonFile from 'load-json-file' -import ncpCB from 'ncp' import nock from 'nock' import normalize from 'normalize-path' import tempy from 'tempy' const registry = `http://localhost:${REGISTRY_MOCK_PORT}` -const IS_POSTIVE_TARBALL = path.join(__dirname, 'is-positive-1.0.0.tgz') -const ncp = promisify(ncpCB as any) // eslint-disable-line @typescript-eslint/no-explicit-any +const f = fixtures(__dirname) +const IS_POSTIVE_TARBALL = f.find('is-positive-1.0.0.tgz') const authConfig = { registry } @@ -176,7 +175,7 @@ test('refetch local tarball if its integrity has changed', async () => { const projectDir = tempy.directory() const tarballPath = path.join(projectDir, 'tarball.tgz') const tarballRelativePath = path.relative(projectDir, tarballPath) - await ncp(path.join(__dirname, 'pnpm-package-requester-0.8.1.tgz'), tarballPath) + f.copy('pnpm-package-requester-0.8.1.tgz', tarballPath) const tarball = `file:${tarballRelativePath}` const wantedPackage = { pref: tarball } const storeDir = tempy.directory() @@ -224,7 +223,7 @@ test('refetch local tarball if its integrity has changed', async () => { expect(await response.bundledManifest!()).toBeTruthy() } - await ncp(path.join(__dirname, 'pnpm-package-requester-4.1.2.tgz'), tarballPath) + f.copy('pnpm-package-requester-4.1.2.tgz', tarballPath) await delay(50) { @@ -292,7 +291,7 @@ test('refetch local tarball if its integrity has changed', async () => { test('refetch local tarball if its integrity has changed. The requester does not know the correct integrity', async () => { const projectDir = tempy.directory() const tarballPath = path.join(projectDir, 'tarball.tgz') - await ncp(path.join(__dirname, 'pnpm-package-requester-0.8.1.tgz'), tarballPath) + f.copy('pnpm-package-requester-0.8.1.tgz', tarballPath) const tarball = `file:${tarballPath}` const wantedPackage = { pref: tarball } const storeDir = path.join(__dirname, '..', '.store') @@ -327,7 +326,7 @@ test('refetch local tarball if its integrity has changed. The requester does not expect(await response.bundledManifest!()).toBeTruthy() } - await ncp(path.join(__dirname, 'pnpm-package-requester-4.1.2.tgz'), tarballPath) + f.copy('pnpm-package-requester-4.1.2.tgz', tarballPath) await delay(50) { diff --git a/packages/package-requester/tsconfig.json b/packages/package-requester/tsconfig.json index 54f2b39e5d..b00877f372 100644 --- a/packages/package-requester/tsconfig.json +++ b/packages/package-requester/tsconfig.json @@ -9,6 +9,9 @@ "../../typings/**/*.d.ts" ], "references": [ + { + "path": "../../privatePackages/test-fixtures" + }, { "path": "../cafs" }, diff --git a/packages/plugin-commands-audit/test/fix.ts b/packages/plugin-commands-audit/test/fix.ts index 46736f8be8..244acb4758 100644 --- a/packages/plugin-commands-audit/test/fix.ts +++ b/packages/plugin-commands-audit/test/fix.ts @@ -1,13 +1,13 @@ import path from 'path' -import { copyFixture } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import { ProjectManifest } from '@pnpm/types' import { audit } from '@pnpm/plugin-commands-audit' import loadJsonFile from 'load-json-file' -import tempy from 'tempy' + +const f = fixtures(__dirname) test('overrides are added for vulnerable dependencies', async () => { - const tmp = tempy.directory() - await copyFixture('has-vulnerabilities', tmp, __dirname) + const tmp = f.prepare('has-vulnerabilities') const { exitCode, output } = await audit.handler({ auditLevel: 'moderate', @@ -27,8 +27,7 @@ test('overrides are added for vulnerable dependencies', async () => { }) test('no overrides are added if no vulnerabilities are found', async () => { - const tmp = tempy.directory() - await copyFixture('fixture', tmp, __dirname) + const tmp = f.prepare('fixture') const { exitCode, output } = await audit.handler({ auditLevel: 'moderate', diff --git a/packages/plugin-commands-installation/package.json b/packages/plugin-commands-installation/package.json index 15682a147b..423c024a78 100644 --- a/packages/plugin-commands-installation/package.json +++ b/packages/plugin-commands-installation/package.json @@ -41,13 +41,11 @@ "@pnpm/prepare": "workspace:0.0.31", "@pnpm/test-fixtures": "workspace:*", "@types/is-ci": "^3.0.0", - "@types/ncp": "^2.0.4", "@types/proxyquire": "^1.3.28", "@types/ramda": "0.27.39", "@types/sinon": "^9.0.11", "@types/yarnpkg__lockfile": "^1.1.5", "@types/zkochan__table": "npm:@types/table@6.0.0", - "ncp": "^2.0.0", "path-name": "^1.0.0", "proxyquire": "^2.1.3", "read-yaml-file": "^2.1.0", diff --git a/packages/plugin-commands-installation/test/import.ts b/packages/plugin-commands-installation/test/import.ts index 91cd83b318..4f2e23cbf3 100644 --- a/packages/plugin-commands-installation/test/import.ts +++ b/packages/plugin-commands-installation/test/import.ts @@ -1,17 +1,14 @@ /// -import { promisify } from 'util' import path from 'path' import assertProject from '@pnpm/assert-project' import PnpmError from '@pnpm/error' import { importCommand } from '@pnpm/plugin-commands-installation' -import prepare, { tempDir } from '@pnpm/prepare' +import prepare from '@pnpm/prepare' +import fixtures from '@pnpm/test-fixtures' import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import tempy from 'tempy' -import ncpCB from 'ncp' -const ncp = promisify(ncpCB) - -const fixtures = path.join(__dirname, '../../../fixtures') +const f = fixtures(__dirname) const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}` const TMP = tempy.directory() @@ -46,9 +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' }) - tempDir() - - await ncp(path.join(fixtures, 'has-package-lock-json'), process.cwd()) + f.prepare('has-package-lock-json') await importCommand.handler({ ...DEFAULT_OPTS, @@ -67,9 +62,8 @@ test('import from package-lock.json', async () => { test('import from yarn.lock', async () => { await addDistTag({ package: 'dep-of-pkg-with-1-dep', version: '100.1.0', distTag: 'latest' }) - tempDir() - await ncp(path.join(fixtures, 'has-yarn-lock'), process.cwd()) + f.prepare('has-yarn-lock') await importCommand.handler({ ...DEFAULT_OPTS, @@ -87,9 +81,7 @@ test('import from yarn.lock', async () => { }) test('import from yarn2 lock file', async () => { - tempDir() - - await ncp(path.join(fixtures, 'has-yarn2-lock'), process.cwd()) + f.prepare('has-yarn2-lock') await importCommand.handler({ ...DEFAULT_OPTS, @@ -109,9 +101,8 @@ 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' }) - tempDir() - await ncp(path.join(fixtures, 'has-npm-shrinkwrap-json'), process.cwd()) + f.prepare('has-npm-shrinkwrap-json') await importCommand.handler({ ...DEFAULT_OPTS, diff --git a/packages/plugin-commands-installation/test/importRecursive.ts b/packages/plugin-commands-installation/test/importRecursive.ts index 72dc949a78..4bb9311442 100644 --- a/packages/plugin-commands-installation/test/importRecursive.ts +++ b/packages/plugin-commands-installation/test/importRecursive.ts @@ -1,18 +1,13 @@ /// -import { promisify } from 'util' import path from 'path' import assertProject from '@pnpm/assert-project' import { importCommand } from '@pnpm/plugin-commands-installation' -import { tempDir } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' import { readProjects } from '@pnpm/filter-workspace-packages' +import fixtures from '@pnpm/test-fixtures' import tempy from 'tempy' -import ncpCB from 'ncp' - -const ncp = promisify(ncpCB) - -const fixtures = path.join(__dirname, '../../../fixtures') +const f = fixtures(__dirname) const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}` const TMP = tempy.directory() @@ -45,9 +40,7 @@ const DEFAULT_OPTS = { } test('import from shared yarn.lock of monorepo', async () => { - tempDir() - - await ncp(path.join(fixtures, 'workspace-has-shared-yarn-lock'), process.cwd()) + f.prepare('workspace-has-shared-yarn-lock') const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), []) await importCommand.handler({ ...DEFAULT_OPTS, @@ -69,9 +62,7 @@ test('import from shared yarn.lock of monorepo', async () => { }) test('import from shared package-lock.json of monorepo', async () => { - tempDir() - - await ncp(path.join(fixtures, 'workspace-has-shared-package-lock-json'), process.cwd()) + f.prepare('workspace-has-shared-package-lock-json') const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), []) await importCommand.handler({ ...DEFAULT_OPTS, @@ -93,9 +84,7 @@ test('import from shared package-lock.json of monorepo', async () => { }) test('import from shared npm-shrinkwrap.json of monorepo', async () => { - tempDir() - - await ncp(path.join(fixtures, 'workspace-has-shared-npm-shrinkwrap-json'), process.cwd()) + f.prepare('workspace-has-shared-npm-shrinkwrap-json') const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), []) await importCommand.handler({ ...DEFAULT_OPTS, diff --git a/packages/plugin-commands-installation/test/link.ts b/packages/plugin-commands-installation/test/link.ts index 8acca6573a..a3088fd6d8 100644 --- a/packages/plugin-commands-installation/test/link.ts +++ b/packages/plugin-commands-installation/test/link.ts @@ -4,11 +4,13 @@ import readYamlFile from 'read-yaml-file' import { install, link } from '@pnpm/plugin-commands-installation' import prepare, { preparePackages } from '@pnpm/prepare' import assertProject, { isExecutable } from '@pnpm/assert-project' -import { copyFixture } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import PATH from 'path-name' import writePkg from 'write-pkg' import { DEFAULT_OPTS } from './utils' +const f = fixtures(__dirname) + test('linking multiple packages', async () => { const project = prepare() @@ -80,7 +82,7 @@ test('relative link', async () => { const linkedPkgName = 'hello-world-js-bin' const linkedPkgPath = path.resolve('..', linkedPkgName) - await copyFixture(linkedPkgName, linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) await link.handler({ ...DEFAULT_OPTS, dir: process.cwd(), @@ -111,7 +113,7 @@ test('absolute link', async () => { const linkedPkgName = 'hello-world-js-bin' const linkedPkgPath = path.resolve('..', linkedPkgName) - await copyFixture(linkedPkgName, linkedPkgPath) + f.copy(linkedPkgName, linkedPkgPath) await link.handler({ ...DEFAULT_OPTS, dir: process.cwd(), diff --git a/packages/plugin-commands-installation/test/prune.ts b/packages/plugin-commands-installation/test/prune.ts index 3456e03374..d653f8d151 100644 --- a/packages/plugin-commands-installation/test/prune.ts +++ b/packages/plugin-commands-installation/test/prune.ts @@ -2,9 +2,10 @@ import path from 'path' import { install, link, prune } from '@pnpm/plugin-commands-installation' import prepare from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' -import { copyFixture } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}` +const f = fixtures(__dirname) const DEFAULT_OPTIONS = { argv: { @@ -33,7 +34,7 @@ const DEFAULT_OPTIONS = { test('prune removes external link that is not in package.json', async () => { const project = prepare(undefined) const storeDir = path.resolve('store') - await copyFixture('local-pkg', 'local') + f.copy('local-pkg', 'local') await link.handler({ ...DEFAULT_OPTIONS, diff --git a/packages/plugin-commands-rebuild/test/index.ts b/packages/plugin-commands-rebuild/test/index.ts index 0b1c546e61..85022a988e 100644 --- a/packages/plugin-commands-rebuild/test/index.ts +++ b/packages/plugin-commands-rebuild/test/index.ts @@ -4,7 +4,7 @@ import { WANTED_LOCKFILE } from '@pnpm/constants' import { rebuild } from '@pnpm/plugin-commands-rebuild' import prepare, { prepareEmpty } from '@pnpm/prepare' import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock' -import { copyFixture } from '@pnpm/test-fixtures' +import fixtures from '@pnpm/test-fixtures' import execa from 'execa' import exists from 'path-exists' import sinon from 'sinon' @@ -12,6 +12,7 @@ import { DEFAULT_OPTS } from './utils' const REGISTRY = `http://localhost:${REGISTRY_MOCK_PORT}/` const pnpmBin = path.join(__dirname, '../../pnpm/bin/pnpm.cjs') +const f = fixtures(__dirname) test('rebuilds dependencies', async () => { const project = prepareEmpty() @@ -73,7 +74,7 @@ test('rebuild does not fail when a linked package is present', async () => { prepareEmpty() const cacheDir = path.resolve('cache') const storeDir = path.resolve('store') - await copyFixture('local-pkg', path.resolve('..', 'local-pkg')) + f.copy('local-pkg', path.resolve('..', 'local-pkg')) await execa('node', [ pnpmBin, diff --git a/packages/pnpm/package.json b/packages/pnpm/package.json index ddeccf2673..9780d2188e 100644 --- a/packages/pnpm/package.json +++ b/packages/pnpm/package.json @@ -63,7 +63,6 @@ "@types/cross-spawn": "^6.0.2", "@types/is-ci": "^3.0.0", "@types/is-windows": "^1.0.0", - "@types/ncp": "^2.0.4", "@types/pnpm__byline": "npm:@types/byline@^4.2.32", "@types/ramda": "0.27.39", "@types/semver": "^7.3.4", @@ -84,7 +83,6 @@ "is-windows": "^1.0.2", "load-json-file": "^6.2.0", "loud-rejection": "^2.2.0", - "ncp": "^2.0.0", "normalize-newline": "3.0.0", "npm-run-all": "^4.1.5", "p-any": "3.0.0", diff --git a/packages/tarball-fetcher/package.json b/packages/tarball-fetcher/package.json index c82a63f193..9fbb873320 100644 --- a/packages/tarball-fetcher/package.json +++ b/packages/tarball-fetcher/package.json @@ -48,9 +48,9 @@ "@pnpm/fetch": "workspace:4.2.3", "@pnpm/logger": "^4.0.0", "@pnpm/package-store": "workspace:12.1.6", + "@pnpm/test-fixtures": "workspace:*", "@types/retry": "^0.12.0", "@types/ssri": "^7.1.0", - "cp-file": "^9.0.0", "nock": "12.0.3", "tempy": "^1.0.0" }, diff --git a/packages/tarball-fetcher/test/download.ts b/packages/tarball-fetcher/test/download.ts index e35ca2edb0..f45b51ce4a 100644 --- a/packages/tarball-fetcher/test/download.ts +++ b/packages/tarball-fetcher/test/download.ts @@ -4,11 +4,11 @@ import path from 'path' import PnpmError, { FetchError } from '@pnpm/error' import { createFetchFromRegistry } from '@pnpm/fetch' import { createCafsStore } from '@pnpm/package-store' +import fixtures from '@pnpm/test-fixtures' import createFetcher, { BadTarballError, TarballIntegrityError, } from '@pnpm/tarball-fetcher' -import cpFile from 'cp-file' import nock from 'nock' import ssri from 'ssri' import tempy from 'tempy' @@ -16,7 +16,8 @@ import tempy from 'tempy' const cafsDir = tempy.directory() const cafs = createCafsStore(cafsDir) -const tarballPath = path.join(__dirname, 'tars', 'babel-helper-hoist-variables-6.24.1.tgz') +const f = fixtures(__dirname) +const tarballPath = f.find('babel-helper-hoist-variables-6.24.1.tgz') const tarballSize = 1279 const tarballIntegrity = 'sha1-HssnaJydJVE+rbyZFKc/VAi+enY=' const registry = 'http://example.com/' @@ -92,7 +93,7 @@ test('fail when integrity check fails two times in a row', async () => { const scope = nock(registry) .get('/foo.tgz') .times(2) - .replyWithFile(200, path.join(__dirname, 'tars', 'babel-helper-hoist-variables-7.0.0-alpha.10.tgz'), { + .replyWithFile(200, f.find('babel-helper-hoist-variables-7.0.0-alpha.10.tgz'), { 'Content-Length': '1194', }) @@ -122,7 +123,7 @@ test('fail when integrity check fails two times in a row', async () => { test('retry when integrity check fails', async () => { const scope = nock(registry) .get('/foo.tgz') - .replyWithFile(200, path.join(__dirname, 'tars', 'babel-helper-hoist-variables-7.0.0-alpha.10.tgz'), { + .replyWithFile(200, f.find('babel-helper-hoist-variables-7.0.0-alpha.10.tgz'), { 'Content-Length': '1194', }) .get('/foo.tgz') @@ -155,10 +156,7 @@ test('fail when integrity check of local file fails', async () => { const storeDir = tempy.directory() process.chdir(storeDir) - await cpFile( - path.join(__dirname, 'tars', 'babel-helper-hoist-variables-7.0.0-alpha.10.tgz'), - path.resolve('tar.tgz') - ) + f.copy('babel-helper-hoist-variables-7.0.0-alpha.10.tgz', 'tar.tgz') const resolution = { integrity: tarballIntegrity, tarball: 'file:tar.tgz', @@ -183,10 +181,7 @@ test("don't fail when integrity check of local file succeeds", async () => { process.chdir(tempy.directory()) const localTarballLocation = path.resolve('tar.tgz') - await cpFile( - path.join(__dirname, 'tars', 'babel-helper-hoist-variables-7.0.0-alpha.10.tgz'), - localTarballLocation - ) + f.copy('babel-helper-hoist-variables-7.0.0-alpha.10.tgz', localTarballLocation) const resolution = { integrity: await getFileIntegrity(localTarballLocation), tarball: 'file:tar.tgz', @@ -202,7 +197,7 @@ test("don't fail when integrity check of local file succeeds", async () => { test("don't fail when fetching a local tarball in offline mode", async () => { process.chdir(tempy.directory()) - const tarballAbsoluteLocation = path.join(__dirname, 'tars', 'babel-helper-hoist-variables-7.0.0-alpha.10.tgz') + const tarballAbsoluteLocation = f.find('babel-helper-hoist-variables-7.0.0-alpha.10.tgz') const resolution = { integrity: await getFileIntegrity(tarballAbsoluteLocation), tarball: `file:${tarballAbsoluteLocation}`, @@ -226,7 +221,7 @@ test("don't fail when fetching a local tarball in offline mode", async () => { test('fail when trying to fetch a non-local tarball in offline mode', async () => { process.chdir(tempy.directory()) - const tarballAbsoluteLocation = path.join(__dirname, 'tars', 'babel-helper-hoist-variables-7.0.0-alpha.10.tgz') + const tarballAbsoluteLocation = f.find('babel-helper-hoist-variables-7.0.0-alpha.10.tgz') const resolution = { integrity: await getFileIntegrity(tarballAbsoluteLocation), tarball: `${registry}foo.tgz`, diff --git a/packages/tarball-fetcher/test/tars/babel-helper-hoist-variables-6.24.1.tgz b/packages/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-6.24.1.tgz similarity index 100% rename from packages/tarball-fetcher/test/tars/babel-helper-hoist-variables-6.24.1.tgz rename to packages/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-6.24.1.tgz diff --git a/packages/tarball-fetcher/test/tars/babel-helper-hoist-variables-7.0.0-alpha.10.tgz b/packages/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-7.0.0-alpha.10.tgz similarity index 100% rename from packages/tarball-fetcher/test/tars/babel-helper-hoist-variables-7.0.0-alpha.10.tgz rename to packages/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-7.0.0-alpha.10.tgz diff --git a/packages/tarball-fetcher/tsconfig.json b/packages/tarball-fetcher/tsconfig.json index f292e01ba9..edf4cb80f5 100644 --- a/packages/tarball-fetcher/tsconfig.json +++ b/packages/tarball-fetcher/tsconfig.json @@ -9,6 +9,9 @@ "../../typings/**/*.d.ts" ], "references": [ + { + "path": "../../privatePackages/test-fixtures" + }, { "path": "../core-loggers" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd3913147f..22969c6832 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -420,7 +420,6 @@ importers: '@types/fs-extra': ^9.0.5 '@types/is-ci': ^3.0.0 '@types/is-windows': ^1.0.0 - '@types/ncp': ^2.0.4 '@types/normalize-path': ^3.0.0 '@types/ramda': 0.27.39 '@types/semver': ^7.3.4 @@ -436,7 +435,6 @@ importers: is-inner-link: ^4.0.0 is-windows: ^1.0.2 load-json-file: ^6.2.0 - ncp: ^2.0.0 nock: 12.0.3 normalize-path: ^3.0.0 p-every: ^2.0.0 @@ -518,7 +516,6 @@ importers: '@types/fs-extra': 9.0.13 '@types/is-ci': 3.0.0 '@types/is-windows': 1.0.0 - '@types/ncp': 2.0.5 '@types/normalize-path': 3.0.0 '@types/ramda': 0.27.39 '@types/semver': 7.3.9 @@ -528,7 +525,6 @@ importers: exists-link: 2.0.0 is-ci: 3.0.1 is-windows: 1.0.2 - ncp: 2.0.0 nock: 12.0.3 path-name: 1.0.0 read-yaml-file: 2.1.0 @@ -1207,9 +1203,9 @@ importers: '@pnpm/read-modules-dir': workspace:3.0.1 '@pnpm/read-package-json': workspace:5.0.9 '@pnpm/read-project-manifest': workspace:2.0.10 + '@pnpm/test-fixtures': workspace:* '@pnpm/types': workspace:7.8.0 '@types/is-windows': ^1.0.0 - '@types/ncp': ^2.0.4 '@types/node': ^14.17.32 '@types/normalize-path': ^3.0.0 '@types/ramda': 0.27.39 @@ -1218,7 +1214,6 @@ importers: cmd-extension: ^1.0.2 is-subdir: ^1.1.1 is-windows: ^1.0.2 - ncp: ^2.0.0 normalize-path: ^3.0.0 p-settle: ^4.1.1 path-exists: ^4.0.0 @@ -1242,13 +1237,12 @@ importers: devDependencies: '@pnpm/link-bins': 'link:' '@pnpm/logger': 4.0.0 + '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/is-windows': 1.0.0 - '@types/ncp': 2.0.5 '@types/node': 14.18.2 '@types/normalize-path': 3.0.0 '@types/ramda': 0.27.39 cmd-extension: 1.0.2 - ncp: 2.0.0 path-exists: 4.0.0 tempy: 1.0.1 @@ -1466,13 +1460,11 @@ importers: '@pnpm/lockfile-file': workspace:4.2.5 '@pnpm/logger': ^4.0.0 '@pnpm/make-dedicated-lockfile': 'link:' - '@pnpm/prepare': workspace:0.0.31 '@pnpm/prune-lockfile': workspace:3.0.13 '@pnpm/read-project-manifest': workspace:2.0.10 + '@pnpm/test-fixtures': workspace:* '@pnpm/types': workspace:7.8.0 - '@types/ncp': ^2.0.4 '@types/ramda': 0.27.39 - ncp: ^2.0.0 ramda: ^0.27.1 rename-overwrite: ^4.0.0 dependencies: @@ -1489,10 +1481,8 @@ importers: rename-overwrite: 4.0.0 devDependencies: '@pnpm/make-dedicated-lockfile': 'link:' - '@pnpm/prepare': link:../../privatePackages/prepare - '@types/ncp': 2.0.5 + '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/ramda': 0.27.39 - ncp: 2.0.0 packages/manifest-utils: specifiers: @@ -1662,6 +1652,7 @@ importers: '@pnpm/npm-resolver': 'link:' '@pnpm/resolve-workspace-range': workspace:2.1.0 '@pnpm/resolver-base': workspace:8.1.4 + '@pnpm/test-fixtures': workspace:* '@pnpm/types': workspace:7.8.0 '@types/lru-cache': ^5.1.0 '@types/normalize-path': ^3.0.0 @@ -1708,6 +1699,7 @@ importers: '@pnpm/fetch': link:../fetch '@pnpm/logger': 4.0.0 '@pnpm/npm-resolver': 'link:' + '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/lru-cache': 5.1.1 '@types/normalize-path': 3.0.0 '@types/semver': 7.3.9 @@ -1810,15 +1802,14 @@ importers: '@pnpm/read-package-json': workspace:5.0.9 '@pnpm/resolver-base': workspace:8.1.4 '@pnpm/store-controller-types': workspace:11.0.10 + '@pnpm/test-fixtures': workspace:* '@pnpm/types': workspace:7.8.0 - '@types/ncp': ^2.0.4 '@types/normalize-path': ^3.0.0 '@types/ramda': 0.27.39 '@types/ssri': ^7.1.0 delay: ^5.0.0 dependency-path: workspace:8.0.9 load-json-file: ^6.2.0 - ncp: ^2.0.0 nock: 12.0.3 normalize-path: ^3.0.0 p-defer: ^3.0.0 @@ -1858,12 +1849,11 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/package-requester': 'link:' '@pnpm/package-store': link:../package-store - '@types/ncp': 2.0.5 + '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/normalize-path': 3.0.0 '@types/ramda': 0.27.39 '@types/ssri': 7.1.1 delay: 5.0.0 - ncp: 2.0.0 nock: 12.0.3 normalize-path: 3.0.0 tempy: 1.0.1 @@ -2123,7 +2113,6 @@ importers: '@pnpm/test-fixtures': workspace:* '@pnpm/types': workspace:7.8.0 '@types/is-ci': ^3.0.0 - '@types/ncp': ^2.0.4 '@types/proxyquire': ^1.3.28 '@types/ramda': 0.27.39 '@types/sinon': ^9.0.11 @@ -2142,7 +2131,6 @@ importers: is-subdir: ^1.1.1 load-json-file: ^6.2.0 mem: ^8.0.0 - ncp: ^2.0.0 p-filter: ^2.1.0 p-limit: ^3.1.0 path-absolute: ^1.0.1 @@ -2215,13 +2203,11 @@ importers: '@pnpm/prepare': link:../../privatePackages/prepare '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/is-ci': 3.0.0 - '@types/ncp': 2.0.5 '@types/proxyquire': 1.3.28 '@types/ramda': 0.27.39 '@types/sinon': 9.0.11 '@types/yarnpkg__lockfile': 1.1.5 '@types/zkochan__table': /@types/table/6.0.0 - ncp: 2.0.0 path-name: 1.0.0 proxyquire: 2.1.3 read-yaml-file: 2.1.0 @@ -2749,7 +2735,6 @@ importers: '@types/cross-spawn': ^6.0.2 '@types/is-ci': ^3.0.0 '@types/is-windows': ^1.0.0 - '@types/ncp': ^2.0.4 '@types/pnpm__byline': npm:@types/byline@^4.2.32 '@types/ramda': 0.27.39 '@types/semver': ^7.3.4 @@ -2770,7 +2755,6 @@ importers: is-windows: ^1.0.2 load-json-file: ^6.2.0 loud-rejection: ^2.2.0 - ncp: ^2.0.0 node-gyp: ^8.0.0 normalize-newline: 3.0.0 npm-run-all: ^4.1.5 @@ -2840,7 +2824,6 @@ importers: '@types/cross-spawn': 6.0.2 '@types/is-ci': 3.0.0 '@types/is-windows': 1.0.0 - '@types/ncp': 2.0.5 '@types/pnpm__byline': /@types/byline/4.2.33 '@types/ramda': 0.27.39 '@types/semver': 7.3.9 @@ -2861,7 +2844,6 @@ importers: is-windows: 1.0.2 load-json-file: 6.2.0 loud-rejection: 2.2.0 - ncp: 2.0.0 normalize-newline: 3.0.0 npm-run-all: 4.1.5 p-any: 3.0.0 @@ -3292,10 +3274,10 @@ importers: '@pnpm/package-store': workspace:12.1.6 '@pnpm/prepare-package': workspace:1.0.10 '@pnpm/tarball-fetcher': 'link:' + '@pnpm/test-fixtures': workspace:* '@types/retry': ^0.12.0 '@types/ssri': ^7.1.0 '@zkochan/retry': ^0.2.0 - cp-file: ^9.0.0 nock: 12.0.3 ramda: ^0.27.1 ssri: ^8.0.1 @@ -3315,9 +3297,9 @@ importers: '@pnpm/logger': 4.0.0 '@pnpm/package-store': link:../package-store '@pnpm/tarball-fetcher': 'link:' + '@pnpm/test-fixtures': link:../../privatePackages/test-fixtures '@types/retry': 0.12.1 '@types/ssri': 7.1.1 - cp-file: 9.1.0 nock: 12.0.3 tempy: 1.0.1 @@ -3431,14 +3413,14 @@ importers: privatePackages/test-fixtures: specifiers: + '@pnpm/prepare': workspace:0.0.31 '@pnpm/test-fixtures': 'link:' - '@types/ncp': ^2.0.4 - ncp: ^2.0.0 + fs-extra: ^10.0.0 dependencies: - ncp: 2.0.0 + '@pnpm/prepare': link:../prepare + fs-extra: 10.0.0 devDependencies: '@pnpm/test-fixtures': 'link:' - '@types/ncp': 2.0.5 typings: specifiers: {} @@ -5284,12 +5266,6 @@ packages: '@types/node': 17.0.4 dev: true - /@types/ncp/2.0.5: - resolution: {integrity: sha512-ocK0p8JuFmX7UkMabFPjY0F7apPvQyLWt5qtdvuvQEBz9i4m2dbzV+6L1zNaUp042RfnL6pHnxDE53OH6XQ9VQ==} - dependencies: - '@types/node': 17.0.4 - dev: true - /@types/node/12.20.38: resolution: {integrity: sha512-NxmtBRGipjx1B225OeMdI+CQmLbYqvvmYbukDTJGDgzIDgPQ1EcjGmYxGhOk5hTBqeB558S6RgHSpq2iiqifAQ==} dev: true @@ -7553,16 +7529,6 @@ packages: p-event: 4.2.0 dev: true - /cp-file/9.1.0: - resolution: {integrity: sha512-3scnzFj/94eb7y4wyXRWwvzLFaQp87yyfTnChIjlfYrVqp5lVO3E2hIJMeQIltUT0K2ZAB3An1qXcBmwGyvuwA==} - engines: {node: '>=10'} - dependencies: - graceful-fs: 4.2.8 - make-dir: 3.1.0 - nested-error-stacks: 2.1.0 - p-event: 4.2.0 - dev: true - /cpr/3.0.1: resolution: {integrity: sha1-uaVQOLfNgaNcF7l2GJW9hJau8eU=} hasBin: true @@ -9207,7 +9173,6 @@ packages: graceful-fs: 4.2.8 jsonfile: 6.1.0 universalify: 2.0.0 - dev: true /fs-extra/4.0.3: resolution: {integrity: sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==} @@ -12023,6 +11988,7 @@ packages: /ncp/2.0.0: resolution: {integrity: sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=} hasBin: true + dev: true /ndjson/2.0.0: resolution: {integrity: sha512-nGl7LRGrzugTtaFcJMhLbpzJM6XdivmbkdlaGcrk/LXg2KL/YBC6z1g70xh0/al+oFuVFP8N8kiWRucmeEH/qQ==} @@ -12285,6 +12251,7 @@ packages: /npmlog/4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} + requiresBuild: true dependencies: are-we-there-yet: 1.1.7 console-control-strings: 1.1.0 diff --git a/privatePackages/test-fixtures/fixtures/has-broken-symlink/has-broken-symlink.tar.gz b/privatePackages/test-fixtures/fixtures/has-broken-symlink/has-broken-symlink.tar.gz deleted file mode 100644 index 4a12ecb11c014091c2c548b55a4512ca67201e3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 320 zcmV-G0l)qqiwFSnM15EQ1MSvbPr@)12H;)uD^7L;BvSgZc8Ll8mnoeNST{RnAjbdh zCWw+4jEVIlywA>jPc6E=0;wqJiR7MgPQYRuJ9lo_F zYMXWDyH+wc_jX%Xb^Y0;5JNx_#H@6$MXu|E$y$_QlC-OJuHGiRGKmUp3Dk2`Pr8j4ue_74jm1TBQ zSAN~lj7DRcU6Hr (http://kochan.io/)", - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/pnpm/pnpm/tree/master/test/packages/hello-world-js-bin" - }, - "dependencies": { - "cowsay": "1.2.1" - } -} diff --git a/privatePackages/test-fixtures/fixtures/local-pkg/package.json b/privatePackages/test-fixtures/fixtures/local-pkg/package.json deleted file mode 100644 index e7362abbe8..0000000000 --- a/privatePackages/test-fixtures/fixtures/local-pkg/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "local-pkg", - "version": "1.0.0" -} diff --git a/privatePackages/test-fixtures/fixtures/local-scoped-pkg/index.js b/privatePackages/test-fixtures/fixtures/local-scoped-pkg/index.js deleted file mode 100644 index 6b5a79544f..0000000000 --- a/privatePackages/test-fixtures/fixtures/local-scoped-pkg/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => require('./package.json').name diff --git a/privatePackages/test-fixtures/fixtures/local-scoped-pkg/package.json b/privatePackages/test-fixtures/fixtures/local-scoped-pkg/package.json deleted file mode 100644 index 593050620d..0000000000 --- a/privatePackages/test-fixtures/fixtures/local-scoped-pkg/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@scope/local-scoped-pkg", - "version": "1.0.0" -} diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/index.js b/privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/index.js deleted file mode 100644 index 6b5a79544f..0000000000 --- a/privatePackages/test-fixtures/fixtures/tar-pkg-with-peers/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => require('./package.json').name diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg/index.js b/privatePackages/test-fixtures/fixtures/tar-pkg/index.js deleted file mode 100644 index 6b5a79544f..0000000000 --- a/privatePackages/test-fixtures/fixtures/tar-pkg/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => require('./package.json').name diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg/package.json b/privatePackages/test-fixtures/fixtures/tar-pkg/package.json deleted file mode 100644 index ea2caa9c80..0000000000 --- a/privatePackages/test-fixtures/fixtures/tar-pkg/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "tar-pkg", - "version": "1.0.0" -} diff --git a/privatePackages/test-fixtures/fixtures/tar-pkg/tar-pkg-1.0.0.tgz b/privatePackages/test-fixtures/fixtures/tar-pkg/tar-pkg-1.0.0.tgz deleted file mode 100644 index cbfecaa621e1a3f73ff1166396021b0701e8b210..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 214 zcmV;{04e_;iwFP!000003+V0H9zkhZ_LxORQ8=!KEvnxHh#Eu1*j}7>1Yd-)=oqbI*NJ zi;@pE{ogp_UH<8F{z>NZ{}WnS_6Lsmprq~$C_uab#TICO>}$>A2tE7^(E_