From 7ec017e13fdf1abf87f49dbcf40f5f5233c1203e Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Wed, 18 Dec 2024 03:06:51 +0100 Subject: [PATCH] chore: move all tarball files out from Git LFS to a package dependency (#8885) --- .../has-broken-symlink.tar.gz | Bin 320 -> 0 bytes __fixtures__/tar-pkg/index.js | 1 - __fixtures__/tar-pkg/package.json | 4 --- __fixtures__/tar-pkg/pnpm-lock.yaml | 9 ------ __fixtures__/tar-pkg/tar-pkg-1.0.0.tgz | Bin 128 -> 0 bytes __utils__/prepare-temp-dir/package.json | 17 ++++++++++ __utils__/prepare-temp-dir/src/index.ts | 29 ++++++++++++++++++ __utils__/prepare-temp-dir/tsconfig.json | 12 ++++++++ __utils__/prepare-temp-dir/tsconfig.lint.json | 8 +++++ __utils__/prepare/package.json | 1 + __utils__/prepare/src/index.ts | 29 ++---------------- __utils__/prepare/tsconfig.json | 3 ++ __utils__/test-fixtures/package.json | 2 +- __utils__/test-fixtures/src/index.ts | 4 ++- __utils__/test-fixtures/tsconfig.json | 2 +- .../babel-helper-hoist-variables-6.24.1.tgz | Bin 129 -> 0 bytes ...-helper-hoist-variables-7.0.0-alpha.10.tgz | Bin 129 -> 0 bytes package.json | 1 + .../core/test/fixtures/missing-pkg-name.tgz | Bin 128 -> 0 bytes .../fixtures/missing-pkg-name/package.json | 1 - .../test/fixtures/pkg-with-1-dep-100.0.0.tgz | Bin 128 -> 0 bytes ...kg-with-bundle-dependencies-true-1.0.0.tgz | Bin 128 -> 0 bytes .../pkg-with-bundled-dependencies-1.0.0.tgz | Bin 128 -> 0 bytes .../fixtures/tar-pkg-with-dep-1/package.json | 7 ----- .../tar-pkg-with-dep-1.0.0.tgz | Bin 128 -> 0 bytes .../fixtures/tar-pkg-with-dep-2/package.json | 7 ----- .../tar-pkg-with-dep-1.0.0.tgz | Bin 128 -> 0 bytes .../tar-pkg-with-peers-1.0.0.tgz | Bin 128 -> 0 bytes .../core/test/install/bundledDependencies.ts | 4 +-- pkg-manager/core/test/install/local.ts | 10 +++--- .../core/test/install/peerDependencies.ts | 2 +- pkg-manager/core/test/lockfile.ts | 2 +- .../registry-mirror/is-positive-3.1.0.tgz | Bin 129 -> 0 bytes .../fixtures/has-local-dep/tar-pkg-1.0.0.tgz | Bin 128 -> 0 bytes pkg-manager/headless/test/index.ts | 1 + .../test/fixtures/is-positive-1.0.0.tgz | Bin 129 -> 0 bytes .../fixtures/pnpm-package-requester-0.8.1.tgz | Bin 130 -> 0 bytes .../fixtures/pnpm-package-requester-4.1.2.tgz | Bin 130 -> 0 bytes pnpm-lock.yaml | 27 ++++++++++++++-- resolving/local-resolver/test/index.ts | 16 +++++----- .../test/pnpm-local-resolver-0.1.1.tgz | Bin 129 -> 0 bytes store/cafs/__fixtures__/devextreme-17.1.6.tgz | Bin 132 -> 0 bytes store/cafs/__fixtures__/node-gyp-6.1.0.tgz | Bin 131 -> 0 bytes store/cafs/package.json | 1 + .../test/fixtures/colorize-semver-diff.tgz | Bin 129 -> 0 bytes .../test/fixtures/jquery.dirtyforms-2.0.0.tgz | Bin 130 -> 0 bytes .../test/fixtures/parsers-3.0.0-rc.48.1.tgz | Bin 130 -> 0 bytes .../vue.examples.todomvc.todo-store-0.0.1.tgz | Bin 129 -> 0 bytes store/cafs/test/index.ts | 15 +++++---- store/cafs/tsconfig.json | 3 ++ .../test/pnpm-9.1.0.tgz | Bin 132 -> 0 bytes .../test/selfUpdate.test.ts | 8 +++-- 52 files changed, 140 insertions(+), 86 deletions(-) delete mode 100644 __fixtures__/has-broken-symlink/has-broken-symlink.tar.gz delete mode 100644 __fixtures__/tar-pkg/index.js delete mode 100644 __fixtures__/tar-pkg/package.json delete mode 100644 __fixtures__/tar-pkg/pnpm-lock.yaml delete mode 100644 __fixtures__/tar-pkg/tar-pkg-1.0.0.tgz create mode 100644 __utils__/prepare-temp-dir/package.json create mode 100644 __utils__/prepare-temp-dir/src/index.ts create mode 100644 __utils__/prepare-temp-dir/tsconfig.json create mode 100644 __utils__/prepare-temp-dir/tsconfig.lint.json delete mode 100644 fetching/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-6.24.1.tgz delete mode 100644 fetching/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-7.0.0-alpha.10.tgz delete mode 100644 pkg-manager/core/test/fixtures/missing-pkg-name.tgz delete mode 100644 pkg-manager/core/test/fixtures/missing-pkg-name/package.json delete mode 100644 pkg-manager/core/test/fixtures/pkg-with-1-dep-100.0.0.tgz delete mode 100644 pkg-manager/core/test/fixtures/pkg-with-bundle-dependencies-true/pkg-with-bundle-dependencies-true-1.0.0.tgz delete mode 100644 pkg-manager/core/test/fixtures/pkg-with-bundled-dependencies/pkg-with-bundled-dependencies-1.0.0.tgz delete mode 100644 pkg-manager/core/test/fixtures/tar-pkg-with-dep-1/package.json delete mode 100644 pkg-manager/core/test/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz delete mode 100644 pkg-manager/core/test/fixtures/tar-pkg-with-dep-2/package.json delete mode 100644 pkg-manager/core/test/fixtures/tar-pkg-with-dep-2/tar-pkg-with-dep-1.0.0.tgz delete mode 100644 pkg-manager/core/test/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz delete mode 100644 pkg-manager/core/test/registry-mirror/is-positive-3.1.0.tgz delete mode 100644 pkg-manager/headless/test/fixtures/has-local-dep/tar-pkg-1.0.0.tgz delete mode 100644 pkg-manager/package-requester/test/fixtures/is-positive-1.0.0.tgz delete mode 100644 pkg-manager/package-requester/test/fixtures/pnpm-package-requester-0.8.1.tgz delete mode 100644 pkg-manager/package-requester/test/fixtures/pnpm-package-requester-4.1.2.tgz delete mode 100644 resolving/local-resolver/test/pnpm-local-resolver-0.1.1.tgz delete mode 100644 store/cafs/__fixtures__/devextreme-17.1.6.tgz delete mode 100644 store/cafs/__fixtures__/node-gyp-6.1.0.tgz delete mode 100644 store/cafs/test/fixtures/colorize-semver-diff.tgz delete mode 100644 store/cafs/test/fixtures/jquery.dirtyforms-2.0.0.tgz delete mode 100644 store/cafs/test/fixtures/parsers-3.0.0-rc.48.1.tgz delete mode 100644 store/cafs/test/fixtures/vue.examples.todomvc.todo-store-0.0.1.tgz delete mode 100644 tools/plugin-commands-self-updater/test/pnpm-9.1.0.tgz diff --git a/__fixtures__/has-broken-symlink/has-broken-symlink.tar.gz b/__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 require('./package.json').name diff --git a/__fixtures__/tar-pkg/package.json b/__fixtures__/tar-pkg/package.json deleted file mode 100644 index ea2caa9c80..0000000000 --- a/__fixtures__/tar-pkg/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "tar-pkg", - "version": "1.0.0" -} diff --git a/__fixtures__/tar-pkg/pnpm-lock.yaml b/__fixtures__/tar-pkg/pnpm-lock.yaml deleted file mode 100644 index 9b60ae1782..0000000000 --- a/__fixtures__/tar-pkg/pnpm-lock.yaml +++ /dev/null @@ -1,9 +0,0 @@ -lockfileVersion: '9.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -importers: - - .: {} diff --git a/__fixtures__/tar-pkg/tar-pkg-1.0.0.tgz b/__fixtures__/tar-pkg/tar-pkg-1.0.0.tgz deleted file mode 100644 index 000caee73f42e376a96ced57a9672737025dc154..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmWl~NfN>!5CFhCuiyiQCCo77H*68AR8kJf!Pl#o?yJ7JkC$w79=s`a@ALN9dHLPW zwB+$reAKKiBStThTeN^1U`d4DS50ouF2$mOJP_g^7jVU7*JMg9Mms1PDHG%vJXs7n L3GSaNt#RTDamywA diff --git a/__utils__/prepare-temp-dir/package.json b/__utils__/prepare-temp-dir/package.json new file mode 100644 index 0000000000..abc4ae0322 --- /dev/null +++ b/__utils__/prepare-temp-dir/package.json @@ -0,0 +1,17 @@ +{ + "name": "@pnpm/prepare-temp-dir", + "version": "0.0.0", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "dependencies": {}, + "devDependencies": { + "@pnpm/prepare-temp-dir": "workspace:*", + "@types/node": "catalog:" + }, + "scripts": { + "lint": "eslint src/**/*.ts", + "prepublishOnly": "pnpm run compile", + "test": "pnpm run compile", + "compile": "rimraf tsconfig.tsbuildinfo lib && tsc --build" + } +} diff --git a/__utils__/prepare-temp-dir/src/index.ts b/__utils__/prepare-temp-dir/src/index.ts new file mode 100644 index 0000000000..9404b4a386 --- /dev/null +++ b/__utils__/prepare-temp-dir/src/index.ts @@ -0,0 +1,29 @@ +import fs from 'fs' +import path from 'path' + +// The testing folder should be outside of the project to avoid lookup in the project's node_modules +// Not using the OS temp directory due to issues on Windows CI. +const tmpBaseDir = path.join(__dirname, '../../../../pnpm_tmp') + +const tmpPath = path.join(tmpBaseDir, `${getFilesCountInDir(tmpBaseDir).toString()}_${process.pid.toString()}`) + +let dirNumber = 0 + +export function tempDir (chdir: boolean = true): string { + dirNumber++ + const dirname = dirNumber.toString() + const tmpDir = path.join(tmpPath, dirname) + fs.mkdirSync(tmpDir, { recursive: true }) + + if (chdir) process.chdir(tmpDir) + + return tmpDir +} + +function getFilesCountInDir (dir: string): number { + try { + return fs.readdirSync(dir).length + } catch { + return 0 + } +} diff --git a/__utils__/prepare-temp-dir/tsconfig.json b/__utils__/prepare-temp-dir/tsconfig.json new file mode 100644 index 0000000000..c6f0399f60 --- /dev/null +++ b/__utils__/prepare-temp-dir/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "@pnpm/tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "src/**/*.ts", + "../../__typings__/**/*.d.ts" + ], + "references": [] +} diff --git a/__utils__/prepare-temp-dir/tsconfig.lint.json b/__utils__/prepare-temp-dir/tsconfig.lint.json new file mode 100644 index 0000000000..1bbe711971 --- /dev/null +++ b/__utils__/prepare-temp-dir/tsconfig.lint.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "src/**/*.ts", + "test/**/*.ts", + "../../__typings__/**/*.d.ts" + ] +} diff --git a/__utils__/prepare/package.json b/__utils__/prepare/package.json index 6857bbab25..d39c44112a 100644 --- a/__utils__/prepare/package.json +++ b/__utils__/prepare/package.json @@ -5,6 +5,7 @@ "types": "lib/index.d.ts", "dependencies": { "@pnpm/assert-project": "workspace:*", + "@pnpm/prepare-temp-dir": "workspace:*", "@pnpm/types": "workspace:*", "write-json5-file": "^3.1.0", "write-pkg": "catalog:", diff --git a/__utils__/prepare/src/index.ts b/__utils__/prepare/src/index.ts index f82fdc8a4f..b3d2857d26 100644 --- a/__utils__/prepare/src/index.ts +++ b/__utils__/prepare/src/index.ts @@ -2,39 +2,14 @@ import fs from 'fs' import path from 'path' import { assertProject, type Modules, type Project } from '@pnpm/assert-project' import { type ProjectManifest } from '@pnpm/types' +import { tempDir } from '@pnpm/prepare-temp-dir' import { sync as writeJson5File } from 'write-json5-file' import { sync as writeYamlFile } from 'write-yaml-file' import writePkg from 'write-pkg' export type { Modules, Project } export type ManifestFormat = 'JSON' | 'JSON5' | 'YAML' - -// The testing folder should be outside of the project to avoid lookup in the project's node_modules -// Not using the OS temp directory due to issues on Windows CI. -const tmpBaseDir = path.join(__dirname, '../../../../pnpm_tmp') - -function getFilesCountInDir (dir: string): number { - try { - return fs.readdirSync(dir).length - } catch { - return 0 - } -} - -const tmpPath = path.join(tmpBaseDir, `${getFilesCountInDir(tmpBaseDir).toString()}_${process.pid.toString()}`) - -let dirNumber = 0 - -export function tempDir (chdir: boolean = true): string { - dirNumber++ - const dirname = dirNumber.toString() - const tmpDir = path.join(tmpPath, dirname) - fs.mkdirSync(tmpDir, { recursive: true }) - - if (chdir) process.chdir(tmpDir) - - return tmpDir -} +export { tempDir } interface LocationAndManifest { location: string diff --git a/__utils__/prepare/tsconfig.json b/__utils__/prepare/tsconfig.json index b6f10467f4..7259768768 100644 --- a/__utils__/prepare/tsconfig.json +++ b/__utils__/prepare/tsconfig.json @@ -14,6 +14,9 @@ }, { "path": "../assert-project" + }, + { + "path": "../prepare-temp-dir" } ] } diff --git a/__utils__/test-fixtures/package.json b/__utils__/test-fixtures/package.json index 97751b9fc4..6958b80ca3 100644 --- a/__utils__/test-fixtures/package.json +++ b/__utils__/test-fixtures/package.json @@ -32,7 +32,7 @@ "prepublishOnly": "pnpm run compile" }, "dependencies": { - "@pnpm/prepare": "workspace:*", + "@pnpm/prepare-temp-dir": "workspace:*", "fs-extra": "catalog:" }, "devDependencies": { diff --git a/__utils__/test-fixtures/src/index.ts b/__utils__/test-fixtures/src/index.ts index e5161b9b32..de4a8bc887 100644 --- a/__utils__/test-fixtures/src/index.ts +++ b/__utils__/test-fixtures/src/index.ts @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -import { tempDir } from '@pnpm/prepare' +import { tempDir } from '@pnpm/prepare-temp-dir' export interface FixturesHandle { copy: (name: string, dest: string) => void @@ -62,6 +62,8 @@ function findFixture (dir: string, name: string): string { if (fs.existsSync(checkDir)) return checkDir checkDir = path.join(dir, '__fixtures__', name) if (fs.existsSync(checkDir)) return checkDir + checkDir = path.join(dir, 'node_modules/@pnpm/tgz-fixtures/tgz', name) + if (fs.existsSync(checkDir)) return checkDir if (dir === root) throw new Error(`Local package "${name}" not found`) dir = path.dirname(dir) } diff --git a/__utils__/test-fixtures/tsconfig.json b/__utils__/test-fixtures/tsconfig.json index 7b1ede671a..609fe94b80 100644 --- a/__utils__/test-fixtures/tsconfig.json +++ b/__utils__/test-fixtures/tsconfig.json @@ -10,7 +10,7 @@ ], "references": [ { - "path": "../prepare" + "path": "../prepare-temp-dir" } ] } diff --git a/fetching/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-6.24.1.tgz b/fetching/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-6.24.1.tgz deleted file mode 100644 index 41b0184bdfb89bf1c2b64b24c7b9ebb408147d9f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmWN{xe>!45CFiODrmrhJKj?_yoMRuXbe)|>aA##y~=m?@!@T)W9~vc`+B_U+-}<$ zw=~{j9wmtj*yx$h7SPyT`C?>6FdnPDa6m`w4};+)@c;k- diff --git a/fetching/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-7.0.0-alpha.10.tgz b/fetching/tarball-fetcher/test/fixtures/babel-helper-hoist-variables-7.0.0-alpha.10.tgz deleted file mode 100644 index c074b44bda3d1a53011e180df9467aaafc5e2888..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmWN?%MHUI3;@tOQ?Nk8Ctx7km|z#AwnT;G(CM4Q)4S+9TK~v8=P@>=o^3u}JeK=< z=4J11H4fUdeY|y>^N`J$N1wMR%W~Pi zWvSz3M4h{@D|Y>>g>PUvDq(k2sg LWik7grEwsBmu4qQ diff --git a/pkg-manager/core/test/fixtures/pkg-with-bundle-dependencies-true/pkg-with-bundle-dependencies-true-1.0.0.tgz b/pkg-manager/core/test/fixtures/pkg-with-bundle-dependencies-true/pkg-with-bundle-dependencies-true-1.0.0.tgz deleted file mode 100644 index 30a4189bc10fb139dbf83c2894ae8d70e0efbe86..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmWN?%MrpL5CG6SRnUNe1r|uU+2te5sAL3luzG!$ca`_-<0ac#=RB0U_jP;Jx&3b+ z-qLugd6uLu5Tj=~8yWNm*pNLVXdgn~I75M=)4sB2 MM`HGGk!YOw0e&(jlK=n! diff --git a/pkg-manager/core/test/fixtures/pkg-with-bundled-dependencies/pkg-with-bundled-dependencies-1.0.0.tgz b/pkg-manager/core/test/fixtures/pkg-with-bundled-dependencies/pkg-with-bundled-dependencies-1.0.0.tgz deleted file mode 100644 index b5c4a31028f9f5a81da132edbe72deaaf5b44a2f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmWN{OA^8$3;@tQr{Dq>Q%JzxhF^pkm5!lZczU~fn|Ic)^zqSc&RsTRo_*e4EX!p( z(vrv9$X>HKL5*Itw74Q|z7}WEQ+@=%8kvYfObD2L37i}-v$HGZ$c6oN%e??&0P-m~ M7nJm0)o4Ne0jO~&OaK4? diff --git a/pkg-manager/core/test/fixtures/tar-pkg-with-dep-1/package.json b/pkg-manager/core/test/fixtures/tar-pkg-with-dep-1/package.json deleted file mode 100644 index 6d129af51b..0000000000 --- a/pkg-manager/core/test/fixtures/tar-pkg-with-dep-1/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "tar-pkg-with-dep", - "version": "1.0.0", - "dependencies": { - "is-positive": "^1.0.0" - } -} diff --git a/pkg-manager/core/test/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz b/pkg-manager/core/test/fixtures/tar-pkg-with-dep-1/tar-pkg-with-dep-1.0.0.tgz deleted file mode 100644 index 62c79c0c843858021e55a8c7e539e3c86ea94c78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmWN?OA^8$3;@tQr{Dq>Ncq{@5J-d>m5yn<@bvmN@1l>4`PTh7cG--1jN|rXS^oDE zmpWfYcB|~0RpA{O#(rfQRxWw;OliSd&zsW{!(?$a~xXV+q^x>SpU}# zuc<%vI3?-JEWKqlDp?V+M3#k1WXwFcy!2qmU6a?4WEQBGwT>aKMCsF*ySA L%V=LwCT`0QvGpfx diff --git a/pkg-manager/core/test/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz b/pkg-manager/core/test/fixtures/tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz deleted file mode 100644 index 7a2ee4dd3711b320dbe07176c78c56af31dc1201..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmWN?OA^8$3;@tQr{DsXkAzQe14$~(sB}!*g{RlIc^7|V%(w2xvCC@AV;r~VCd>bR zwgu { test('local tarball with bundledDependencies', async () => { const project = prepareEmpty() - f.copy('pkg-with-bundled-dependencies/pkg-with-bundled-dependencies-1.0.0.tgz', 'pkg.tgz') + f.copy('pkg-with-bundled-dependencies-1.0.0.tgz', 'pkg.tgz') await addDependenciesToPackage({}, ['file:pkg.tgz'], testDefaults({ fastUnpack: false })) const lockfile = project.readLockfile() @@ -45,7 +45,7 @@ test('local tarball with bundledDependencies', async () => { test('local tarball with bundledDependencies true', async () => { const project = prepareEmpty() - f.copy('pkg-with-bundle-dependencies-true/pkg-with-bundle-dependencies-true-1.0.0.tgz', 'pkg.tgz') + f.copy('pkg-with-bundle-dependencies-true-1.0.0.tgz', 'pkg.tgz') await addDependenciesToPackage({}, ['file:pkg.tgz'], testDefaults({ fastUnpack: false })) const lockfile = project.readLockfile() diff --git a/pkg-manager/core/test/install/local.ts b/pkg-manager/core/test/install/local.ts index c17aa976c7..0e2a4b4503 100644 --- a/pkg-manager/core/test/install/local.ts +++ b/pkg-manager/core/test/install/local.ts @@ -164,7 +164,7 @@ test('local file with symlinked node_modules', async () => { test('package with a broken symlink', async () => { const project = prepareEmpty() - await addDependenciesToPackage({}, [f.find('has-broken-symlink/has-broken-symlink.tar.gz')], testDefaults({ fastUnpack: false })) + await addDependenciesToPackage({}, [f.find('has-broken-symlink.tar.gz')], testDefaults({ fastUnpack: false })) const m = project.requireModule('has-broken-symlink') @@ -173,20 +173,20 @@ test('package with a broken symlink', async () => { test('tarball local package', async () => { const project = prepareEmpty() - const manifest = await addDependenciesToPackage({}, [f.find('tar-pkg/tar-pkg-1.0.0.tgz')], testDefaults({ fastUnpack: false })) + const manifest = await addDependenciesToPackage({}, [f.find('tar-pkg-1.0.0.tgz')], testDefaults({ fastUnpack: false })) const m = project.requireModule('tar-pkg') expect(m()).toBe('tar-pkg') - const pkgSpec = `file:${normalizePath(f.find('tar-pkg/tar-pkg-1.0.0.tgz'))}` + const pkgSpec = `file:${normalizePath(f.find('tar-pkg-1.0.0.tgz'))}` expect(manifest.dependencies).toStrictEqual({ 'tar-pkg': pkgSpec }) const lockfile = project.readLockfile() expect(lockfile.packages[`tar-pkg@${lockfile.importers['.'].dependencies!['tar-pkg'].version}`]).toStrictEqual({ resolution: { integrity: 'sha512-HP/5Rgt3pVFLzjmN9qJJ6vZMgCwoCIl/m2bPndYT283CUqnmFiMx0GeeIJ7SyK6TYoJM78SEvFEOQie++caHqw==', - tarball: `file:${normalizePath(path.relative(process.cwd(), f.find('tar-pkg/tar-pkg-1.0.0.tgz')))}`, + tarball: `file:${normalizePath(path.relative(process.cwd(), f.find('tar-pkg-1.0.0.tgz')))}`, }, version: '1.0.0', }) @@ -195,7 +195,7 @@ test('tarball local package', async () => { test('tarball local package from project directory', async () => { const project = prepareEmpty() - f.copy('tar-pkg/tar-pkg-1.0.0.tgz', path.resolve('tar-pkg-1.0.0.tgz')) + f.copy('tar-pkg-1.0.0.tgz', path.resolve('tar-pkg-1.0.0.tgz')) const manifest = await install({ dependencies: { diff --git a/pkg-manager/core/test/install/peerDependencies.ts b/pkg-manager/core/test/install/peerDependencies.ts index 1a7ba188f2..b32c9cb356 100644 --- a/pkg-manager/core/test/install/peerDependencies.ts +++ b/pkg-manager/core/test/install/peerDependencies.ts @@ -1176,7 +1176,7 @@ test('local tarball dependency with peer dependency', async () => { const reporter = sinon.spy() const manifest = await addDependenciesToPackage({}, [ - `file:${f.find('tar-pkg-with-peers/tar-pkg-with-peers-1.0.0.tgz')}`, + `file:${f.find('tar-pkg-with-peers-1.0.0.tgz')}`, 'bar@npm:@pnpm.e2e/bar@100.0.0', 'foo@npm:@pnpm.e2e/foo@100.0.0', ], testDefaults({ reporter })) diff --git a/pkg-manager/core/test/lockfile.ts b/pkg-manager/core/test/lockfile.ts index 78aa190ad5..3bcd337a3f 100644 --- a/pkg-manager/core/test/lockfile.ts +++ b/pkg-manager/core/test/lockfile.ts @@ -1062,7 +1062,7 @@ const REGISTRY_MIRROR_DIR = path.join(__dirname, './registry-mirror') /* eslint-disable @typescript-eslint/no-explicit-any */ const isPositiveMeta = loadJsonFile.sync(path.join(REGISTRY_MIRROR_DIR, 'is-positive.json')) /* eslint-enable @typescript-eslint/no-explicit-any */ -const tarballPath = path.join(REGISTRY_MIRROR_DIR, 'is-positive-3.1.0.tgz') +const tarballPath = f.find('is-positive-3.1.0.tgz') test('tarball domain differs from registry domain', async () => { nock('https://registry.example.com', { allowUnmocked: true }) diff --git a/pkg-manager/core/test/registry-mirror/is-positive-3.1.0.tgz b/pkg-manager/core/test/registry-mirror/is-positive-3.1.0.tgz deleted file mode 100644 index 752bb921e4b22f00775d3396f3d257dc304ab04b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmWN?%MrpL5CG6SRnUMT%b#?!3yUzLk`c_o>h)dT#qZh2OSZMnc_?-7>-MN~``!5CFhCuiyiQCCo77H*68AR8kJf!Pl#o?yJ7JkC$w79=s`a@ALN9dHLPW zwB+$reAKKiBStThTeN^1U`d4DS50ouF2$mOJP_g^7jVU7*JMg9Mms1PDHG%vJXs7n L3GSaNt#RTDamywA diff --git a/pkg-manager/headless/test/index.ts b/pkg-manager/headless/test/index.ts index 3e31dc416e..f60c4cb768 100644 --- a/pkg-manager/headless/test/index.ts +++ b/pkg-manager/headless/test/index.ts @@ -472,6 +472,7 @@ test('available packages are relinked during forced install', async () => { test('installing local dependency', async () => { let prefix = f.prepare('has-local-dep') + f.copy('tar-pkg-1.0.0.tgz', path.join(prefix, 'tar-pkg-1.0.0.tgz')) prefix = path.join(prefix, 'pkg') const reporter = sinon.spy() diff --git a/pkg-manager/package-requester/test/fixtures/is-positive-1.0.0.tgz b/pkg-manager/package-requester/test/fixtures/is-positive-1.0.0.tgz deleted file mode 100644 index 59b744ef30d9a5dfbe8da9b059582ec2c7b8702b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmWN?OA^8$3;@tQr{DsXKg8aq2|<`q>6o?)Pp@zDF8;`vZ{3e$m(`fZIBw4-%m04j zLi1&0XEK*lb5t#T^C_>^VFIw#bB(rjM|4DTb}4mNAx4d`L*#DEkrt?>S-y Mib}?pwF}_X54f2p2mk;8 diff --git a/pkg-manager/package-requester/test/fixtures/pnpm-package-requester-0.8.1.tgz b/pkg-manager/package-requester/test/fixtures/pnpm-package-requester-0.8.1.tgz deleted file mode 100644 index 30b3e2af9f816c40bfe3e5c75dab3a2d0a53b676..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 130 zcmWN?OA^8$3;@tQr{DsXgz#%`Q%DqMR60Vt@bvmN?~>1G{jKYq$JmT{w0V2p$MV0P zc`5y6#v#RAsCr{P>TZ45ps**xl!cMRx$H|S9?5b-O9?o-1Tn};99Iz_$Tk8}*jW-e MR-=7IBSeqt2gTebl>h($ diff --git a/pkg-manager/package-requester/test/fixtures/pnpm-package-requester-4.1.2.tgz b/pkg-manager/package-requester/test/fixtures/pnpm-package-requester-4.1.2.tgz deleted file mode 100644 index 8e2c189e06783f03bdca4b16e18e67e0b0b2dfe4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 130 zcmWN?%MHUI3;@u3reJ{vZ2s8>8&Z(k5*3m|r*95V?<(KX`bX3`kFiPlZ1eHj$9i8+ zTDiaFI10-Pmfo@$HKBD|MoxtYvQ`AvF#20`m^Fck(E>n>o{VFy6noE{@Bjb+ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2047523d0c..54304a6ce2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -720,6 +720,9 @@ importers: '@pnpm/meta-updater': specifier: 'catalog:' version: 2.0.3 + '@pnpm/tgz-fixtures': + specifier: 0.0.0 + version: 0.0.0 '@pnpm/tsconfig': specifier: workspace:* version: link:__utils__/tsconfig @@ -972,6 +975,9 @@ importers: '@pnpm/assert-project': specifier: workspace:* version: link:../assert-project + '@pnpm/prepare-temp-dir': + specifier: workspace:* + version: link:../prepare-temp-dir '@pnpm/types': specifier: workspace:* version: link:../../packages/types @@ -992,6 +998,15 @@ importers: specifier: 'catalog:' version: 18.19.34 + __utils__/prepare-temp-dir: + devDependencies: + '@pnpm/prepare-temp-dir': + specifier: workspace:* + version: 'link:' + '@types/node': + specifier: 'catalog:' + version: 18.19.34 + __utils__/scripts: dependencies: '@pnpm/workspace.find-packages': @@ -1025,9 +1040,9 @@ importers: __utils__/test-fixtures: dependencies: - '@pnpm/prepare': + '@pnpm/prepare-temp-dir': specifier: workspace:* - version: link:../prepare + version: link:../prepare-temp-dir fs-extra: specifier: 'catalog:' version: 11.2.0 @@ -7060,6 +7075,9 @@ importers: '@pnpm/store.cafs': specifier: workspace:* version: 'link:' + '@pnpm/test-fixtures': + specifier: workspace:* + version: link:../../__utils__/test-fixtures '@pnpm/types': specifier: workspace:* version: link:../../packages/types @@ -9091,6 +9109,9 @@ packages: resolution: {integrity: sha512-BSGvYd59kPKVTUk1InekEp+TiPnJ8650/bQyiOUFSvqHi61YipcR+E4H2i3xTnk2e+GHdGbXvEtAZbQmyxb0/g==} engines: {node: '>=18.12'} + '@pnpm/tgz-fixtures@0.0.0': + resolution: {integrity: sha512-6YlfA/aWpeYbX9ADtSv3kKJYjTUE8rXw3gKzLPuO8hc4S7fP6sZwQXaYP7uwyWieU45TR3u0V/g8esQQYZrGMA==} + '@pnpm/types@11.1.0': resolution: {integrity: sha512-wnlOhu7hjv9/qsf2cbK0YqpaV9c4LS69Utxd+r8hq/GWhyrOHcM1QOlfQb0Mzci0q4DDgB8VXT4dhBnEBL4c5g==} engines: {node: '>=18.12'} @@ -16066,6 +16087,8 @@ snapshots: dependencies: strip-comments-strings: 1.2.0 + '@pnpm/tgz-fixtures@0.0.0': {} + '@pnpm/types@11.1.0': {} '@pnpm/types@12.0.0': {} diff --git a/resolving/local-resolver/test/index.ts b/resolving/local-resolver/test/index.ts index c9d9c77f17..81925d7d0a 100644 --- a/resolving/local-resolver/test/index.ts +++ b/resolving/local-resolver/test/index.ts @@ -5,6 +5,8 @@ import { type DirectoryResolution } from '@pnpm/resolver-base' import normalize from 'normalize-path' import { logger } from '@pnpm/logger' +const TEST_DIR = path.dirname(require.resolve('@pnpm/tgz-fixtures/tgz/pnpm-local-resolver-0.1.1.tgz')) + test('resolve directory', async () => { const resolveResult = await resolveFromLocal({ pref: '..' }, { projectDir: __dirname }) expect(resolveResult!.id).toEqual('link:..') @@ -63,7 +65,7 @@ test('resolve directory specified using the link: protocol', async () => { test('resolve file', async () => { const wantedDependency = { pref: './pnpm-local-resolver-0.1.1.tgz' } - const resolveResult = await resolveFromLocal(wantedDependency, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal(wantedDependency, { projectDir: TEST_DIR }) expect(resolveResult).toEqual({ id: 'file:pnpm-local-resolver-0.1.1.tgz', @@ -79,16 +81,16 @@ test('resolve file', async () => { test("resolve file when lockfile directory differs from the package's dir", async () => { const wantedDependency = { pref: './pnpm-local-resolver-0.1.1.tgz' } const resolveResult = await resolveFromLocal(wantedDependency, { - lockfileDir: path.join(__dirname, '..'), - projectDir: __dirname, + lockfileDir: path.join(TEST_DIR, '..'), + projectDir: TEST_DIR, }) expect(resolveResult).toEqual({ - id: 'file:test/pnpm-local-resolver-0.1.1.tgz', + id: 'file:tgz/pnpm-local-resolver-0.1.1.tgz', normalizedPref: 'file:pnpm-local-resolver-0.1.1.tgz', resolution: { integrity: 'sha512-UHd2zKRT/w70KKzFlj4qcT81A1Q0H7NM9uKxLzIZ/VZqJXzt5Hnnp2PYPb5Ezq/hAamoYKIn5g7fuv69kP258w==', - tarball: 'file:test/pnpm-local-resolver-0.1.1.tgz', + tarball: 'file:tgz/pnpm-local-resolver-0.1.1.tgz', }, resolvedVia: 'local-filesystem', }) @@ -96,7 +98,7 @@ test("resolve file when lockfile directory differs from the package's dir", asyn test('resolve tarball specified with file: protocol', async () => { const wantedDependency = { pref: 'file:./pnpm-local-resolver-0.1.1.tgz' } - const resolveResult = await resolveFromLocal(wantedDependency, { projectDir: __dirname }) + const resolveResult = await resolveFromLocal(wantedDependency, { projectDir: TEST_DIR }) expect(resolveResult).toEqual({ id: 'file:pnpm-local-resolver-0.1.1.tgz', @@ -112,7 +114,7 @@ test('resolve tarball specified with file: protocol', async () => { test('fail when resolving tarball specified with the link: protocol', async () => { try { const wantedDependency = { pref: 'link:./pnpm-local-resolver-0.1.1.tgz' } - await resolveFromLocal(wantedDependency, { projectDir: __dirname }) + await resolveFromLocal(wantedDependency, { projectDir: TEST_DIR }) fail() } catch (err: any) { // eslint-disable-line expect(err).toBeDefined() diff --git a/resolving/local-resolver/test/pnpm-local-resolver-0.1.1.tgz b/resolving/local-resolver/test/pnpm-local-resolver-0.1.1.tgz deleted file mode 100644 index ce08408f9ce90451074f7cd8be1e8004fd250c84..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmWN?OA^8$3;@tQr{Dq>NW-VSO-VqQQRx`$!qe;9ysNyWkC$$9p0XQr@ALMkvixtK zywG?WISZM~snJ!5CFhCuiyiQHO!FTuna<#O3J|;e7*LiFM9KsFWJ{R`B3UU*6q=F``|~1VWqiHxNLWQRxWw;OliSd*%0N{iW)h=Qy;!w|RS%vHq{0 zxJrNOac0pMEWIT)YOsDg1ci}zx5vcULMHT-!3N6)j2ANC5-=4s0c|Npl8b1fXF`+` N+%noXD};@RmmlnhClLSu diff --git a/store/cafs/package.json b/store/cafs/package.json index 88464c8f0d..a35b06bef1 100644 --- a/store/cafs/package.json +++ b/store/cafs/package.json @@ -29,6 +29,7 @@ "devDependencies": { "@pnpm/cafs-types": "workspace:*", "@pnpm/store.cafs": "workspace:*", + "@pnpm/test-fixtures": "workspace:*", "@pnpm/types": "workspace:*", "@types/is-gzip": "catalog:", "@types/node": "catalog:", diff --git a/store/cafs/test/fixtures/colorize-semver-diff.tgz b/store/cafs/test/fixtures/colorize-semver-diff.tgz deleted file mode 100644 index c1f84940407b964f60f52c424f04de67b402e7a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 129 zcmWN@%MpVh5CG6SRnR~Lmd}FSpt}TSlHdgNkm}>k`*_Q?)-iXb9(~=Ob#9mK zo3=b&Y95@`X~gJ7&KB>^@7XyZ4$PRyP$@ZEaHNZ8<`Nw;a)hWMp$^2AD#q*xJRnAU NjhOw%(i#sz`~em=C{O?Z diff --git a/store/cafs/test/fixtures/parsers-3.0.0-rc.48.1.tgz b/store/cafs/test/fixtures/parsers-3.0.0-rc.48.1.tgz deleted file mode 100644 index 745f120dec24ba9299866bbc2ef3cda373fcc1ec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 130 zcmWN?K@!3s3;@78uiyg~1OlbMNkR~2R60_7@b&hxd&+0_@z(7)_PH7J=*R6@=W^Y? zwD5SDxeJ@~u0}6!5CFhCuiyiQeVF7oEQ3&`l5#KyU$1@Xi{3ouOZK%+K9stTb$c}4{`XJb z%6uw5si@0{IjZEIY=9#nr3BG6Bo8K#uC+ljStAtfT8rLgL)t~G0aFadqqSHd6jwEP M6g<8p;~sYL1IZdD { it('unpack', () => { const dest = tempy.directory() const cafs = createCafs(dest) const { filesIndex } = cafs.addFilesFromTarball( - fs.readFileSync(path.join(__dirname, '../__fixtures__/node-gyp-6.1.0.tgz')) + fs.readFileSync(f.find('node-gyp-6.1.0.tgz')) ) expect(Object.keys(filesIndex)).toHaveLength(121) const pkgFile = filesIndex['package.json'] @@ -86,7 +89,7 @@ test('file names are normalized when unpacking a tarball', () => { const dest = tempy.directory() const cafs = createCafs(dest) const { filesIndex } = cafs.addFilesFromTarball( - fs.readFileSync(path.join(__dirname, 'fixtures/colorize-semver-diff.tgz')) + fs.readFileSync(f.find('colorize-semver-diff.tgz')) ) expect(Object.keys(filesIndex).sort()).toStrictEqual([ 'LICENSE', @@ -101,7 +104,7 @@ test('broken magic in tarball headers is handled gracefully', () => { const dest = tempy.directory() const cafs = createCafs(dest) cafs.addFilesFromTarball( - fs.readFileSync(path.join(__dirname, 'fixtures/jquery.dirtyforms-2.0.0.tgz')) + fs.readFileSync(f.find('jquery.dirtyforms-2.0.0.tgz')) ) }) @@ -109,7 +112,7 @@ test('unpack an older version of tar that prefixes with spaces', () => { const dest = tempy.directory() const cafs = createCafs(dest) const { filesIndex } = cafs.addFilesFromTarball( - fs.readFileSync(path.join(__dirname, 'fixtures/parsers-3.0.0-rc.48.1.tgz')) + fs.readFileSync(f.find('parsers-3.0.0-rc.48.1.tgz')) ) expect(Object.keys(filesIndex).sort()).toStrictEqual([ 'lib/grammars/resolution.d.ts', @@ -137,7 +140,7 @@ test('unpack a tarball that contains hard links', () => { const dest = tempy.directory() const cafs = createCafs(dest) const { filesIndex } = cafs.addFilesFromTarball( - fs.readFileSync(path.join(__dirname, 'fixtures/vue.examples.todomvc.todo-store-0.0.1.tgz')) + fs.readFileSync(f.find('vue.examples.todomvc.todo-store-0.0.1.tgz')) ) expect(Object.keys(filesIndex).length).toBeGreaterThan(0) }) @@ -147,7 +150,7 @@ test('unpack should not fail when the tarball format seems to be not USTAR or GN const dest = tempy.directory() const cafs = createCafs(dest) const { filesIndex } = cafs.addFilesFromTarball( - fs.readFileSync(path.join(__dirname, '../__fixtures__/devextreme-17.1.6.tgz')) + fs.readFileSync(f.find('devextreme-17.1.6.tgz')) ) expect(Object.keys(filesIndex).length).toBeGreaterThan(0) }) diff --git a/store/cafs/tsconfig.json b/store/cafs/tsconfig.json index 9444b8a138..e00a610153 100644 --- a/store/cafs/tsconfig.json +++ b/store/cafs/tsconfig.json @@ -9,6 +9,9 @@ "../../__typings__/**/*.d.ts" ], "references": [ + { + "path": "../../__utils__/test-fixtures" + }, { "path": "../../fetching/fetcher-base" }, diff --git a/tools/plugin-commands-self-updater/test/pnpm-9.1.0.tgz b/tools/plugin-commands-self-updater/test/pnpm-9.1.0.tgz deleted file mode 100644 index bd939bd2dbd7ec3f3038a2ae05b062550166262f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 132 zcmWN?NfN>!5CFhCuiyiQ05dH44a { const actualModule = jest.requireActual('@pnpm/cli-meta') @@ -89,7 +91,7 @@ test('self-update', async () => { .reply(200, createMetadata('9.1.0', opts.registries.default)) nock(opts.registries.default) .get('/pnpm/-/pnpm-9.1.0.tgz') - .replyWithFile(200, path.join(__dirname, 'pnpm-9.1.0.tgz')) + .replyWithFile(200, pnpmTarballPath) await selfUpdate.handler(opts, []) @@ -114,7 +116,7 @@ test('self-update by exact version', async () => { .reply(200, createMetadata('9.2.0', opts.registries.default, ['9.1.0'])) nock(opts.registries.default) .get('/pnpm/-/pnpm-9.1.0.tgz') - .replyWithFile(200, path.join(__dirname, 'pnpm-9.1.0.tgz')) + .replyWithFile(200, pnpmTarballPath) await selfUpdate.handler(opts, ['9.1.0']) @@ -186,7 +188,7 @@ test('self-update updates the packageManager field in package.json', async () => .reply(200, createMetadata('9.1.0', opts.registries.default)) nock(opts.registries.default) .get('/pnpm/-/pnpm-9.1.0.tgz') - .replyWithFile(200, path.join(__dirname, 'pnpm-9.1.0.tgz')) + .replyWithFile(200, pnpmTarballPath) const output = await selfUpdate.handler(opts, [])