mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-24 08:35:19 -04:00
refactor: fixtures (#4182)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -6,6 +6,7 @@ module.exports = {
|
||||
'<rootDir>/test/utils/distTags.ts',
|
||||
'<rootDir>/test/utils/index.ts',
|
||||
'<rootDir>/test/utils/testDefaults.ts',
|
||||
'<rootDir>/test/fixtures/.+',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 }))
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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$/)
|
||||
})
|
||||
|
||||
|
||||
@@ -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 }))
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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([
|
||||
{
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
packages:
|
||||
- "**"
|
||||
- "!workspace/**"
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<void>((resolve, reject) => rimrafModule(dir, err => err ? reject(err) : resolve()))
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
link-workspace-packages=true
|
||||
shared-workspace-lockfile=true
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"name": "bar",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"foo": "1.0.0",
|
||||
"is-positive": "1.0.0",
|
||||
"express": "4.16.4"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"name": "foo",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"is-negative": "1.0.0"
|
||||
}
|
||||
}
|
||||
392
packages/headless/test/workspace-fixture2/pnpm-lock.yaml
generated
392
packages/headless/test/workspace-fixture2/pnpm-lock.yaml
generated
@@ -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=
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
0
packages/link-bins/test/fixtures/bin-dir/pkg/bin/subdir/index.js
vendored
Normal file → Executable file
0
packages/link-bins/test/fixtures/bin-dir/pkg/bin/subdir/index.js
vendored
Normal file → Executable file
@@ -1,14 +1,13 @@
|
||||
/// <reference path="../../../typings/index.d.ts"/>
|
||||
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,
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../privatePackages/test-fixtures"
|
||||
},
|
||||
{
|
||||
"path": "../error"
|
||||
},
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../privatePackages/prepare"
|
||||
"path": "../../privatePackages/test-fixtures"
|
||||
},
|
||||
{
|
||||
"path": "../error"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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<any>(path.join(__dirname, 'meta', 'is-positive.json'))
|
||||
const isPositiveMetaWithDeprecated = loadJsonFile.sync<any>(path.join(__dirname, 'meta', 'is-positive-with-deprecated.json'))
|
||||
const isPositiveMetaFull = loadJsonFile.sync<any>(path.join(__dirname, 'meta', 'is-positive-full.json'))
|
||||
const isPositiveBrokenMeta = loadJsonFile.sync<any>(path.join(__dirname, 'meta', 'is-positive-broken.json'))
|
||||
const sindresorhusIsMeta = loadJsonFile.sync<any>(path.join(__dirname, 'meta', 'sindresorhus-is.json'))
|
||||
const jsonMeta = loadJsonFile.sync<any>(path.join(__dirname, 'meta', 'JSON.json'))
|
||||
const brokenIntegrity = loadJsonFile.sync<any>(path.join(__dirname, 'meta', 'broken-integrity.json'))
|
||||
const isPositiveMeta = loadJsonFile.sync<any>(f.find('is-positive.json'))
|
||||
const isPositiveMetaWithDeprecated = loadJsonFile.sync<any>(f.find('is-positive-with-deprecated.json'))
|
||||
const isPositiveMetaFull = loadJsonFile.sync<any>(f.find('is-positive-full.json'))
|
||||
const isPositiveBrokenMeta = loadJsonFile.sync<any>(f.find('is-positive-broken.json'))
|
||||
const sindresorhusIsMeta = loadJsonFile.sync<any>(f.find('sindresorhus-is.json'))
|
||||
const jsonMeta = loadJsonFile.sync<any>(f.find('JSON.json'))
|
||||
const brokenIntegrity = loadJsonFile.sync<any>(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 })
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../privatePackages/test-fixtures"
|
||||
},
|
||||
{
|
||||
"path": "../core-loggers"
|
||||
},
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/// <reference path="../../../typings/index.d.ts" />
|
||||
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)
|
||||
|
||||
{
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../privatePackages/test-fixtures"
|
||||
},
|
||||
{
|
||||
"path": "../cafs"
|
||||
},
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
/// <reference path="../../../typings/index.d.ts" />
|
||||
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,
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
/// <reference path="../../../typings/index.d.ts" />
|
||||
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,
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
@@ -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`,
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../privatePackages/test-fixtures"
|
||||
},
|
||||
{
|
||||
"path": "../core-loggers"
|
||||
},
|
||||
|
||||
65
pnpm-lock.yaml
generated
65
pnpm-lock.yaml
generated
@@ -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
|
||||
|
||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
console.log('Hello world!')
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "hello-world-js-bin",
|
||||
"version": "1.0.0",
|
||||
"description": "A package with a hello world js bin",
|
||||
"bin": "./index.js",
|
||||
"isLocal": true,
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Zoltan Kochan <zoltan.kochan@gmail.com> (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"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"name": "local-pkg",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = () => require('./package.json').name
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"name": "@scope/local-scoped-pkg",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = () => require('./package.json').name
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = () => require('./package.json').name
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"name": "tar-pkg",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
Binary file not shown.
@@ -16,9 +16,6 @@
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/ncp": "^2.0.4"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
@@ -35,6 +32,7 @@
|
||||
"test": "pnpm run tsc"
|
||||
},
|
||||
"dependencies": {
|
||||
"ncp": "^2.0.0"
|
||||
"@pnpm/prepare": "workspace:0.0.31",
|
||||
"fs-extra": "^10.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
import { promisify } from 'util'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import ncpCB from 'ncp'
|
||||
import { tempDir } from '@pnpm/prepare'
|
||||
import fsx from 'fs-extra'
|
||||
|
||||
const ncp = promisify(ncpCB)
|
||||
|
||||
export async function copyFixture (fixtureName: string, dest: string, searchFromDir?: string) {
|
||||
const fixturePath = pathToLocalPkg(fixtureName, searchFromDir)
|
||||
if (!fixturePath) throw new Error(`${fixtureName} not found`)
|
||||
return ncp(fixturePath, dest)
|
||||
export default function (searchFromDir: string) {
|
||||
return {
|
||||
copy: copyFixture.bind(null, searchFromDir),
|
||||
find: findFixture.bind(null, searchFromDir),
|
||||
prepare: prepareFixture.bind(null, searchFromDir),
|
||||
}
|
||||
}
|
||||
|
||||
export function pathToLocalPkg (pkgName: string, _dir?: string) {
|
||||
let dir = _dir ?? __dirname
|
||||
function prepareFixture (searchFromDir: string, name: string): string {
|
||||
const dir = tempDir()
|
||||
copyFixture(searchFromDir, name, dir)
|
||||
return dir
|
||||
}
|
||||
|
||||
function copyFixture (searchFromDir: string, name: string, dest: string): void {
|
||||
const fixturePath = findFixture(searchFromDir, name)
|
||||
if (!fixturePath) throw new Error(`${name} not found`)
|
||||
fsx.copySync(fixturePath, dest)
|
||||
}
|
||||
|
||||
function findFixture (dir: string, name: string): string {
|
||||
const { root } = path.parse(dir)
|
||||
while (true) {
|
||||
const checkDir = path.join(dir, 'fixtures', pkgName)
|
||||
const checkDir = path.join(dir, 'fixtures', name)
|
||||
if (fs.existsSync(checkDir)) return checkDir
|
||||
if (dir === root) throw new Error(`Local package "${pkgName}" not found`)
|
||||
if (dir === root) throw new Error(`Local package "${name}" not found`)
|
||||
dir = path.dirname(dir)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,9 @@
|
||||
"src/**/*.ts",
|
||||
"../../typings/**/*.d.ts"
|
||||
],
|
||||
"references": []
|
||||
"references": [
|
||||
{
|
||||
"path": "../prepare"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user