mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-23 17:41:50 -04:00
@@ -6,6 +6,7 @@
|
||||
"build": "pnpm run -r tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pnpm/registry-mock": "1.7.2",
|
||||
"@pnpm/tsconfig": "link:utils/tsconfig",
|
||||
"@pnpm/tslint-config": "link:utils/tslint-config",
|
||||
"@types/node": "*",
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"@pnpm/logger": "3.1.0",
|
||||
"@pnpm/package-store": "file:../package-store",
|
||||
"@pnpm/read-importers-context": "file:../read-importers-context",
|
||||
"@pnpm/registry-mock": "1.6.0",
|
||||
"@pnpm/store-path": "2.1.1",
|
||||
"@types/fs-extra": "^8.0.1",
|
||||
"@types/mz": "0.0.32",
|
||||
@@ -67,7 +66,7 @@
|
||||
"lint": "tslint -c tslint.json src/**/*.ts test/**/*.ts",
|
||||
"registry-mock": "registry-mock",
|
||||
"test:tap": "ts-node test",
|
||||
"test:e2e": "run-p -r registry-mock test:tap",
|
||||
"test:e2e": "cross-env PNPM_REGISTRY_MOCK_PORT=7770 run-p -r registry-mock test:tap",
|
||||
"pretest": "rimraf ../.tmp/ && registry-mock prepare && ts-node test/pretest",
|
||||
"test-with-preview": "pnpm run lint && pnpm run test:e2e",
|
||||
"test": "pnpm run lint && pnpm run tsc && pnpm run test:e2e",
|
||||
|
||||
@@ -12,6 +12,7 @@ import { readWantedLockfile } from '@pnpm/lockfile-file'
|
||||
import { read as readModulesYaml } from '@pnpm/modules-yaml'
|
||||
import readImportersContext from '@pnpm/read-importers-context'
|
||||
import { fromDir as readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import fse = require('fs-extra')
|
||||
import path = require('path')
|
||||
@@ -40,7 +41,7 @@ test('installing a simple project', async (t) => {
|
||||
t.ok(project.requireModule('colors'), 'optional dep installed')
|
||||
|
||||
// test that independent leaves is false by default
|
||||
await project.has('.pnpm/localhost+4873/colors') // colors is not symlinked from the store
|
||||
await project.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/colors`) // colors is not symlinked from the store
|
||||
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
|
||||
@@ -72,7 +73,7 @@ test('installing a simple project', async (t) => {
|
||||
} as StageLog), 'importing stage done logged')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/is-negative/2.1.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
requester: prefix,
|
||||
status: 'resolved',
|
||||
}), 'logs that package is being resolved')
|
||||
@@ -271,10 +272,10 @@ test('installing with independent-leaves and hoistPattern=*', async (t) => {
|
||||
await project.has('.pnpm/node_modules/path-is-absolute')
|
||||
|
||||
// wrappy is linked directly from the store
|
||||
await project.hasNot('.pnpm/localhost+4873/wrappy/1.0.2')
|
||||
await project.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/wrappy/1.0.2`)
|
||||
await project.storeHas('wrappy', '1.0.2')
|
||||
|
||||
await project.has('.pnpm/localhost+4873/rimraf/2.5.1')
|
||||
await project.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/rimraf/2.5.1`)
|
||||
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
|
||||
@@ -407,13 +408,13 @@ test('available packages are used when node_modules is not clean', async (t) =>
|
||||
|
||||
t.notOk(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/balanced-match/1.0.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/balanced-match/1.0.0`,
|
||||
requester: projectDir,
|
||||
status: 'resolved',
|
||||
}), 'does not resolve already available package')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/rimraf/2.6.2',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/rimraf/2.6.2`,
|
||||
requester: projectDir,
|
||||
status: 'resolved',
|
||||
}), 'resolves rimraf')
|
||||
@@ -447,13 +448,13 @@ test('available packages are relinked during forced install', async (t) => {
|
||||
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/balanced-match/1.0.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/balanced-match/1.0.0`,
|
||||
requester: projectDir,
|
||||
status: 'resolved',
|
||||
}), 'does not resolve already available package')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/rimraf/2.6.2',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/rimraf/2.6.2`,
|
||||
requester: projectDir,
|
||||
status: 'resolved',
|
||||
}), 'resolves rimraf')
|
||||
@@ -553,8 +554,8 @@ test('independent-leaves: installing a simple project', async (t) => {
|
||||
t.ok(project.requireModule('rimraf'), 'prod dep installed')
|
||||
t.ok(project.requireModule('is-negative'), 'dev dep installed')
|
||||
t.ok(project.requireModule('colors'), 'optional dep installed')
|
||||
await project.has('.pnpm/localhost+4873/rimraf') // rimraf is not symlinked from the store
|
||||
await project.hasNot('.pnpm/localhost+4873/colors') // colors is symlinked from the store
|
||||
await project.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/rimraf`) // rimraf is not symlinked from the store
|
||||
await project.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/colors`) // colors is symlinked from the store
|
||||
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
|
||||
@@ -602,7 +603,7 @@ test('installing with hoistPattern=*', async (t) => {
|
||||
t.ok(project.requireModule('colors'), 'optional dep installed')
|
||||
|
||||
// test that independent leaves is false by default
|
||||
await project.has('.pnpm/localhost+4873/colors') // colors is not symlinked from the store
|
||||
await project.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/colors`) // colors is not symlinked from the store
|
||||
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
await project.isExecutable('.pnpm/node_modules/.bin/hello-world-js-bin')
|
||||
@@ -635,14 +636,14 @@ test('installing with hoistPattern=*', async (t) => {
|
||||
} as StageLog), 'importing stage done logged')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/is-negative/2.1.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
requester: prefix,
|
||||
status: 'resolved',
|
||||
}), 'logs that package is being resolved')
|
||||
|
||||
const modules = await project.readModulesManifest()
|
||||
|
||||
t.deepEqual(modules!.hoistedAliases['localhost+4873/balanced-match/1.0.0'], ['balanced-match'], 'hoisted field populated in .modules.yaml')
|
||||
t.deepEqual(modules!.hoistedAliases[`localhost+${REGISTRY_MOCK_PORT}/balanced-match/1.0.0`], ['balanced-match'], 'hoisted field populated in .modules.yaml')
|
||||
|
||||
t.end()
|
||||
})
|
||||
@@ -662,7 +663,7 @@ test('installing with hoistPattern=* and shamefullyHoist=true', async (t) => {
|
||||
t.ok(project.requireModule('colors'), 'optional dep installed')
|
||||
|
||||
// test that independent leaves is false by default
|
||||
await project.has('.pnpm/localhost+4873/colors') // colors is not symlinked from the store
|
||||
await project.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/colors`) // colors is not symlinked from the store
|
||||
|
||||
await project.isExecutable('.bin/rimraf')
|
||||
await project.isExecutable('.bin/hello-world-js-bin')
|
||||
@@ -695,14 +696,14 @@ test('installing with hoistPattern=* and shamefullyHoist=true', async (t) => {
|
||||
} as StageLog), 'importing stage done logged')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/is-negative/2.1.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
requester: prefix,
|
||||
status: 'resolved',
|
||||
}), 'logs that package is being resolved')
|
||||
|
||||
const modules = await project.readModulesManifest()
|
||||
|
||||
t.deepEqual(modules!.hoistedAliases['localhost+4873/balanced-match/1.0.0'], ['balanced-match'], 'hoisted field populated in .modules.yaml')
|
||||
t.deepEqual(modules!.hoistedAliases[`localhost+${REGISTRY_MOCK_PORT}/balanced-match/1.0.0`], ['balanced-match'], 'hoisted field populated in .modules.yaml')
|
||||
|
||||
t.end()
|
||||
})
|
||||
@@ -722,7 +723,7 @@ test('using side effects cache', async (t) => {
|
||||
}, {}, {}, { packageImportMethod: 'copy' })
|
||||
await headless(opts)
|
||||
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
fse.writeFileSync(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')
|
||||
|
||||
await rimraf(path.join(prefix, 'node_modules'))
|
||||
@@ -762,7 +763,7 @@ test('using side effects cache and hoistPattern=*', async (t) => {
|
||||
const project = assertProject(t, prefix)
|
||||
await project.has('.pnpm/node_modules/es6-promise') // verifying that a flat node_modules was created
|
||||
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
fse.writeFileSync(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')
|
||||
|
||||
await rimraf(path.join(prefix, 'node_modules'))
|
||||
@@ -844,7 +845,7 @@ test('independent-leaves: installing in a workspace', async (t) => {
|
||||
const projectBar = assertProject(t, path.join(workspaceFixture, 'bar'))
|
||||
|
||||
await projectBar.has('foo')
|
||||
t.ok(await exists(path.join(workspaceFixture, 'node_modules/.pnpm/localhost+4873/express/4.16.4/node_modules/array-flatten')), 'independent package linked')
|
||||
t.ok(await exists(path.join(workspaceFixture, `node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/express/4.16.4/node_modules/array-flatten`)), 'independent package linked')
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
@@ -4,11 +4,12 @@ import { HeadlessOptions } from '@pnpm/headless'
|
||||
import createStore from '@pnpm/package-store'
|
||||
import readImportersContext from '@pnpm/read-importers-context'
|
||||
import { fromDir as readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import storePath from '@pnpm/store-path'
|
||||
import path = require('path')
|
||||
import tempy = require('tempy')
|
||||
|
||||
const registry = 'http://localhost:4873/'
|
||||
const registry = `http://localhost:${REGISTRY_MOCK_PORT}/`
|
||||
|
||||
const retryOpts = {
|
||||
fetchRetries: 2,
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
"devDependencies": {
|
||||
"@pnpm/logger": "3.1.0",
|
||||
"@pnpm/outdated": "link:",
|
||||
"@pnpm/registry-mock": "1.6.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"tape": "4.11.0"
|
||||
}
|
||||
|
||||
@@ -102,7 +102,6 @@
|
||||
"@pnpm/modules-yaml": "link:../modules-yaml",
|
||||
"@pnpm/prepare": "0.0.0",
|
||||
"@pnpm/read-package-json": "link:../read-package-json",
|
||||
"@pnpm/registry-mock": "1.6.0",
|
||||
"@pnpm/write-importer-manifest": "link:../write-importer-manifest",
|
||||
"@types/byline": "4.2.31",
|
||||
"@types/common-tags": "1.8.0",
|
||||
@@ -179,7 +178,7 @@
|
||||
"registry-mock": "registry-mock",
|
||||
"test:tap": "ts-node test --type-check",
|
||||
"pretest:e2e": "rimraf ../../../.tmp/ && rimraf node_modules/.bin/pnpm && registry-mock prepare",
|
||||
"test:e2e": "run-p -r registry-mock test:tap",
|
||||
"test:e2e": "cross-env PNPM_REGISTRY_MOCK_PORT=7772 run-p -r registry-mock test:tap",
|
||||
"test": "npm run lint && npm run tsc && npm run test:e2e",
|
||||
"tsc": "rimraf lib && tsc",
|
||||
"release": "sh .scripts/release.sh"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Lockfile } from '@pnpm/lockfile-types'
|
||||
import prepare, { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import readImporterManifest from '@pnpm/read-importer-manifest'
|
||||
import { fromDir as readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import writeImporterManifest from '@pnpm/write-importer-manifest'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import crossSpawn = require('cross-spawn')
|
||||
@@ -161,7 +162,7 @@ test("don't fail on case insensitive filesystems when package has 2 files with s
|
||||
await project.has('with-same-file-in-different-cases')
|
||||
|
||||
const storeDir = await project.getStorePath()
|
||||
const integrityFile = await import(path.join(storeDir, 'localhost+4873', 'with-same-file-in-different-cases', '1.0.0', 'integrity.json'))
|
||||
const integrityFile = await import(path.join(storeDir, `localhost+${REGISTRY_MOCK_PORT}`, 'with-same-file-in-different-cases', '1.0.0', 'integrity.json'))
|
||||
const packageFiles = Object.keys(integrityFile).sort()
|
||||
|
||||
if (await dirIsCaseSensitive(storeDir)) {
|
||||
@@ -481,7 +482,7 @@ test('using a custom virtual-store-dir location', async (t: tape.Test) => {
|
||||
|
||||
await execPnpm('install', '--virtual-store-dir=.pnpm')
|
||||
|
||||
t.ok(await exists('.pnpm/localhost+4873/rimraf/2.5.1/node_modules/rimraf/package.json'))
|
||||
t.ok(await exists(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/rimraf/2.5.1/node_modules/rimraf/package.json`))
|
||||
t.ok(await exists('.pnpm/lock.yaml'))
|
||||
t.ok(await exists('.pnpm/node_modules/once/package.json'))
|
||||
|
||||
@@ -490,7 +491,7 @@ test('using a custom virtual-store-dir location', async (t: tape.Test) => {
|
||||
|
||||
await execPnpm('install', '--virtual-store-dir=.pnpm', '--frozen-lockfile')
|
||||
|
||||
t.ok(await exists('.pnpm/localhost+4873/rimraf/2.5.1/node_modules/rimraf/package.json'))
|
||||
t.ok(await exists(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/rimraf/2.5.1/node_modules/rimraf/package.json`))
|
||||
t.ok(await exists('.pnpm/lock.yaml'))
|
||||
t.ok(await exists('.pnpm/node_modules/once/package.json'))
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import prepare from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import fs = require('mz/fs')
|
||||
import path = require('path')
|
||||
@@ -16,7 +17,7 @@ test('caching side effects of native package', async function (t) {
|
||||
|
||||
await execPnpm('add', '--side-effects-cache', 'diskusage@1.1.3')
|
||||
const storePath = await project.getStorePath()
|
||||
const cacheBuildDir = path.join(storePath, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(storePath, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const stat1 = await fs.stat(cacheBuildDir)
|
||||
|
||||
t.ok(await fs.exists(path.join('node_modules/diskusage/build')), 'build folder created')
|
||||
@@ -41,7 +42,7 @@ test('using side effects cache', async function (t) {
|
||||
await execPnpm('add', 'diskusage@1.1.3', '--side-effects-cache', '--no-verify-store-integrity', '--package-import-method', 'copy')
|
||||
const storePath = await project.getStorePath()
|
||||
|
||||
const cacheBuildDir = path.join(storePath, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(storePath, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
await fs.writeFile(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')
|
||||
|
||||
await rimraf('node_modules')
|
||||
@@ -59,7 +60,7 @@ test('readonly side effects cache', async function (t) {
|
||||
const storePath = await project.getStorePath()
|
||||
|
||||
// Modify the side effects cache to make sure we are using it
|
||||
const cacheBuildDir = path.join(storePath, `localhost+4873/diskusage/1.1.2/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(storePath, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.2/side_effects/${ENGINE_DIR}/package/build`)
|
||||
await fs.writeFile(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')
|
||||
|
||||
await rimraf('node_modules')
|
||||
@@ -72,7 +73,7 @@ test('readonly side effects cache', async function (t) {
|
||||
await execPnpm('add', 'diskusage@1.1.3', '--side-effects-cache-readonly', '--no-verify-store-integrity', '--package-import-method', 'copy')
|
||||
|
||||
t.ok(await fs.exists('node_modules/diskusage/build'), 'build folder created')
|
||||
t.notOk(await fs.exists(path.join(storePath, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)), 'cache folder not created')
|
||||
t.notOk(await fs.exists(path.join(storePath, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)), 'cache folder not created')
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import prepare from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import makeDir = require('make-dir')
|
||||
import ncpCB = require('ncp')
|
||||
@@ -17,11 +18,11 @@ test('corrupted tarball should be redownloaded to the store', async (t: tape.Tes
|
||||
|
||||
await execPnpm('store', 'add', 'is-positive@1.0.0', 'is-positive@2.0.0')
|
||||
|
||||
await rimraf(path.resolve('../store/2/localhost+4873/is-positive/2.0.0'))
|
||||
await makeDir(path.resolve('../store/2/localhost+4873/is-positive/2.0.0'))
|
||||
await rimraf(path.resolve(`../store/2/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0`))
|
||||
await makeDir(path.resolve(`../store/2/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0`))
|
||||
await ncp(
|
||||
path.resolve('../store/2/localhost+4873/is-positive/1.0.0/packed.tgz'),
|
||||
path.resolve('../store/2/localhost+4873/is-positive/2.0.0/packed.tgz'),
|
||||
path.resolve(`../store/2/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0/packed.tgz`),
|
||||
path.resolve(`../store/2/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0/packed.tgz`),
|
||||
)
|
||||
|
||||
await execPnpm('add', 'is-positive@2.0.0')
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Lockfile } from '@pnpm/lockfile-types'
|
||||
import { read as readModulesManifest } from '@pnpm/modules-yaml'
|
||||
import prepare, { preparePackages, tempDir as makeTempDir } from '@pnpm/prepare'
|
||||
import { fromDir as readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import loadJsonFile = require('load-json-file')
|
||||
import fs = require('mz/fs')
|
||||
@@ -446,7 +447,7 @@ test('recursive install with link-workspace-packages and shared-workspace-lockfi
|
||||
t.deepEqual(outputs, ['is-positive', 'project-1'])
|
||||
|
||||
const storeJson = await loadJsonFile<object>(path.resolve('store', '2', 'store.json'))
|
||||
t.deepEqual(storeJson['localhost+4873/is-negative/1.0.0'].length, 1, 'new connections saved in store.json')
|
||||
t.deepEqual(storeJson[`localhost+${REGISTRY_MOCK_PORT}/is-negative/1.0.0`].length, 1, 'new connections saved in store.json')
|
||||
|
||||
await execPnpm('recursive', 'install', 'pkg-with-1-dep', '--link-workspace-packages', '--shared-workspace-lockfile=true', '--store-dir', 'store')
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import prepare, { tempDir } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import chalk from 'chalk'
|
||||
import { stripIndent } from 'common-tags'
|
||||
import isCI = require('is-ci')
|
||||
@@ -36,8 +37,8 @@ test('pnpm outdated', async (t: tape.Test) => {
|
||||
independentLeaves: false,
|
||||
networkConcurrency: 16,
|
||||
offline: false,
|
||||
rawConfig: { registry: 'https://localhost:4873' },
|
||||
registries: { default: 'https://localhost:4873' },
|
||||
rawConfig: { registry: `https://localhost:${REGISTRY_MOCK_PORT}` },
|
||||
registries: { default: `https://localhost:${REGISTRY_MOCK_PORT}` },
|
||||
strictSsl: false,
|
||||
tag: 'latest',
|
||||
userAgent: '',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import prepare, { preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import fs = require('mz/fs')
|
||||
import path = require('path')
|
||||
import exists = require('path-exists')
|
||||
@@ -12,9 +13,9 @@ const testOnly = promisifyTape(tape.only)
|
||||
|
||||
const testFromNode10 = parseInt(process.version.split('.')[0].substr(1), 10) >= 10 ? test : promisifyTape(test['skip'])
|
||||
|
||||
const CREDENTIALS = `//localhost:4873/:username=username
|
||||
//localhost:4873/:_password=${Buffer.from('password').toString('base64')}
|
||||
//localhost:4873/:email=foo@bar.net`
|
||||
const CREDENTIALS = `//localhost:${REGISTRY_MOCK_PORT}/:username=username
|
||||
//localhost:${REGISTRY_MOCK_PORT}/:_password=${Buffer.from('password').toString('base64')}
|
||||
//localhost:${REGISTRY_MOCK_PORT}/:email=foo@bar.net`
|
||||
|
||||
test('publish: package with package.json', async (t: tape.Test) => {
|
||||
prepare(t, {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import prepare from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import byline = require('byline')
|
||||
import { ChildProcess } from 'child_process'
|
||||
import delay from 'delay'
|
||||
@@ -167,7 +168,7 @@ test('uploading cache can be disabled without breaking install', async (t: tape.
|
||||
await project.has('diskusage')
|
||||
const storePath = await project.getStorePath()
|
||||
const engine = `${process.platform}-${process.arch}-node-${process.version.split('.')[0]}`
|
||||
const cacheDir = path.join(storePath, `localhost+4873/diskusage/1.1.3/side_effects/${engine}/package`)
|
||||
const cacheDir = path.join(storePath, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${engine}/package`)
|
||||
t.notOk(await pathExists(cacheDir), 'side effects cache not uploaded')
|
||||
|
||||
await execPnpm('server', 'stop')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { tempDir } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import loadJsonFile = require('load-json-file')
|
||||
import fs = require('mz/fs')
|
||||
import path = require('path')
|
||||
@@ -17,14 +18,14 @@ test('pnpm store add express@4.16.3', async function (t: tape.Test) {
|
||||
|
||||
await execPnpm('store', 'add', 'express@4.16.3', '--store-dir', storeDir)
|
||||
|
||||
const pathToCheck = path.join(storeDir, '2', 'localhost+4873', 'express', '4.16.3')
|
||||
const pathToCheck = path.join(storeDir, '2', `localhost+${REGISTRY_MOCK_PORT}`, 'express', '4.16.3')
|
||||
t.ok(await exists(pathToCheck), `express@4.16.3 is in store (at ${pathToCheck})`)
|
||||
|
||||
const storeIndex = await loadJsonFile(path.join(storeDir, '2', 'store.json'))
|
||||
t.deepEqual(
|
||||
storeIndex,
|
||||
{
|
||||
'localhost+4873/express/4.16.3': [],
|
||||
[`localhost+${REGISTRY_MOCK_PORT}/express/4.16.3`]: [],
|
||||
},
|
||||
'package has been added to the store index',
|
||||
)
|
||||
@@ -32,20 +33,20 @@ test('pnpm store add express@4.16.3', async function (t: tape.Test) {
|
||||
|
||||
test('pnpm store add scoped package that uses not the standard registry', async function (t: tape.Test) {
|
||||
tempDir(t)
|
||||
await fs.writeFile('.npmrc', '@foo:registry=http://localhost:4873/', 'utf8')
|
||||
await fs.writeFile('.npmrc', `@foo:registry=http://localhost:${REGISTRY_MOCK_PORT}/`, 'utf8')
|
||||
|
||||
const storeDir = path.resolve('store')
|
||||
|
||||
await execPnpm('store', 'add', '@foo/no-deps@1.0.0', '--registry', 'https://registry.npmjs.org/', '--store-dir', storeDir)
|
||||
|
||||
const pathToCheck = path.join(storeDir, '2', 'localhost+4873', '@foo', 'no-deps', '1.0.0')
|
||||
const pathToCheck = path.join(storeDir, '2', `localhost+${REGISTRY_MOCK_PORT}`, '@foo', 'no-deps', '1.0.0')
|
||||
t.ok(await exists(pathToCheck), `@foo/no-deps@1.0.0 is in store (at ${pathToCheck})`)
|
||||
|
||||
const storeIndex = await loadJsonFile(path.join(storeDir, '2', 'store.json'))
|
||||
t.deepEqual(
|
||||
storeIndex,
|
||||
{
|
||||
'localhost+4873/@foo/no-deps/1.0.0': [],
|
||||
[`localhost+${REGISTRY_MOCK_PORT}/@foo/no-deps/1.0.0`]: [],
|
||||
},
|
||||
'package has been added to the store index',
|
||||
)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import RegClient = require('anonymous-npm-registry-client')
|
||||
|
||||
export async function add (pkg: string, version: string, distTag: string) {
|
||||
const client = new RegClient()
|
||||
|
||||
// just to make verdaccio cache the package
|
||||
await new Promise((resolve, reject) => client.distTags.fetch('http://localhost:4873', { package: pkg }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.fetch(`http://localhost:${REGISTRY_MOCK_PORT}`, { package: pkg }, (err: Error) => err ? reject(err) : resolve()))
|
||||
|
||||
// the tag has to be removed first because in verdaccio it is an array of versions
|
||||
await new Promise((resolve, reject) => client.distTags.rm('http://localhost:4873', { package: pkg, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.add('http://localhost:4873', { package: pkg, version, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.rm(`http://localhost:${REGISTRY_MOCK_PORT}`, { package: pkg, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.add(`http://localhost:${REGISTRY_MOCK_PORT}`, { package: pkg, version, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { ChildProcess as NodeChildProcess } from 'child_process'
|
||||
import crossSpawn = require('cross-spawn')
|
||||
import path = require('path')
|
||||
@@ -69,7 +70,7 @@ function createEnv (opts?: {storeDir?: string}) {
|
||||
npm_config_fetch_retries: 4,
|
||||
npm_config_hoist: true,
|
||||
npm_config_independent_leaves: false,
|
||||
npm_config_registry: 'http://localhost:4873/',
|
||||
npm_config_registry: `http://localhost:${REGISTRY_MOCK_PORT}/`,
|
||||
npm_config_silent: 'true',
|
||||
npm_config_store_dir: opts && opts.storeDir || '../store',
|
||||
// Although this is the default value of verify-store-integrity (as of pnpm 1.38.0)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import path = require('path')
|
||||
|
||||
export default function testDefaults (opts?: any): any & { storeDir: string } { // tslint:disable-line
|
||||
return Object.assign({
|
||||
registry: 'http://localhost:4873/',
|
||||
registry: `http://localhost:${REGISTRY_MOCK_PORT}/`,
|
||||
storeDir: path.resolve('..', '.store'),
|
||||
}, opts)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
"@pnpm/logger": "3.1.0",
|
||||
"@pnpm/package-store": "file:../package-store",
|
||||
"@pnpm/prepare": "0.0.0",
|
||||
"@pnpm/registry-mock": "1.6.0",
|
||||
"@pnpm/store-path": "2.1.1",
|
||||
"@types/common-tags": "1.8.0",
|
||||
"@types/fs-extra": "^8.0.1",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import RegClient = require('anonymous-npm-registry-client')
|
||||
import path = require('path')
|
||||
@@ -16,7 +17,7 @@ test('a package that need authentication', async (t: tape.Test) => {
|
||||
const client = new RegClient()
|
||||
|
||||
const data = await new Promise((resolve, reject) => {
|
||||
client.adduser('http://localhost:4873', {
|
||||
client.adduser(`http://localhost:${REGISTRY_MOCK_PORT}`, {
|
||||
auth: {
|
||||
email: 'foo@bar.com',
|
||||
password: 'bar',
|
||||
@@ -26,8 +27,8 @@ test('a package that need authentication', async (t: tape.Test) => {
|
||||
}) as {token: string}
|
||||
|
||||
let rawConfig = {
|
||||
'//localhost:4873/:_authToken': data.token,
|
||||
'registry': 'http://localhost:4873/',
|
||||
[`//localhost:${REGISTRY_MOCK_PORT}/:_authToken`]: data.token,
|
||||
'registry': `http://localhost:${REGISTRY_MOCK_PORT}/`,
|
||||
}
|
||||
const manifest = await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({}, {
|
||||
rawConfig,
|
||||
@@ -43,7 +44,7 @@ test('a package that need authentication', async (t: tape.Test) => {
|
||||
await rimraf(path.join('..', '.store'))
|
||||
|
||||
rawConfig = {
|
||||
'//localhost:4873/:_authToken': data.token,
|
||||
[`//localhost:${REGISTRY_MOCK_PORT}/:_authToken`]: data.token,
|
||||
'registry': 'https://registry.npmjs.org/',
|
||||
}
|
||||
await addDependenciesToPackage(manifest, ['needs-auth'], await testDefaults({}, {
|
||||
@@ -62,7 +63,7 @@ test('installing a package that need authentication, using password', async (t:
|
||||
const client = new RegClient()
|
||||
|
||||
const data = await new Promise((resolve, reject) => {
|
||||
client.adduser('http://localhost:4873', {
|
||||
client.adduser(`http://localhost:${REGISTRY_MOCK_PORT}`, {
|
||||
auth: {
|
||||
email: 'foo@bar.com',
|
||||
password: 'bar',
|
||||
@@ -73,9 +74,9 @@ test('installing a package that need authentication, using password', async (t:
|
||||
|
||||
const encodedPassword = Buffer.from('bar').toString('base64')
|
||||
let rawConfig = {
|
||||
'//localhost:4873/:_password': encodedPassword,
|
||||
'//localhost:4873/:username': 'foo',
|
||||
'registry': 'http://localhost:4873/',
|
||||
[`//localhost:${REGISTRY_MOCK_PORT}/:_password`]: encodedPassword,
|
||||
[`//localhost:${REGISTRY_MOCK_PORT}/:username`]: 'foo',
|
||||
'registry': `http://localhost:${REGISTRY_MOCK_PORT}/`,
|
||||
}
|
||||
await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({}, {
|
||||
rawConfig,
|
||||
@@ -92,7 +93,7 @@ test('a package that need authentication, legacy way', async (t: tape.Test) => {
|
||||
const client = new RegClient()
|
||||
|
||||
const data = await new Promise((resolve, reject) => {
|
||||
client.adduser('http://localhost:4873', {
|
||||
client.adduser(`http://localhost:${REGISTRY_MOCK_PORT}`, {
|
||||
auth: {
|
||||
email: 'foo@bar.com',
|
||||
password: 'bar',
|
||||
@@ -104,7 +105,7 @@ test('a package that need authentication, legacy way', async (t: tape.Test) => {
|
||||
const rawConfig = {
|
||||
'_auth': 'Zm9vOmJhcg==', // base64 encoded foo:bar
|
||||
'always-auth': true,
|
||||
'registry': 'http://localhost:4873',
|
||||
'registry': `http://localhost:${REGISTRY_MOCK_PORT}`,
|
||||
}
|
||||
await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({}, {
|
||||
rawConfig,
|
||||
@@ -121,7 +122,7 @@ test('a scoped package that need authentication specific to scope', async (t: ta
|
||||
const client = new RegClient()
|
||||
|
||||
const data = await new Promise((resolve, reject) => {
|
||||
client.adduser('http://localhost:4873', {
|
||||
client.adduser(`http://localhost:${REGISTRY_MOCK_PORT}`, {
|
||||
auth: {
|
||||
email: 'foo@bar.com',
|
||||
password: 'bar',
|
||||
@@ -131,8 +132,8 @@ test('a scoped package that need authentication specific to scope', async (t: ta
|
||||
}) as {token: string}
|
||||
|
||||
const rawConfig = {
|
||||
'//localhost:4873/:_authToken': data.token,
|
||||
'@private:registry': 'http://localhost:4873/',
|
||||
[`//localhost:${REGISTRY_MOCK_PORT}/:_authToken`]: data.token,
|
||||
'@private:registry': `http://localhost:${REGISTRY_MOCK_PORT}/`,
|
||||
'registry': 'https://registry.npmjs.org/',
|
||||
}
|
||||
let opts = await testDefaults({}, {
|
||||
@@ -167,7 +168,7 @@ test('a package that need authentication reuses authorization tokens for tarball
|
||||
const client = new RegClient()
|
||||
|
||||
const data = await new Promise((resolve, reject) => {
|
||||
client.adduser('http://localhost:4873', {
|
||||
client.adduser(`http://localhost:${REGISTRY_MOCK_PORT}`, {
|
||||
auth: {
|
||||
email: 'foo@bar.com',
|
||||
password: 'bar',
|
||||
@@ -177,17 +178,17 @@ test('a package that need authentication reuses authorization tokens for tarball
|
||||
}) as {token: string}
|
||||
|
||||
const rawConfig = {
|
||||
'//127.0.0.1:4873/:_authToken': data.token,
|
||||
'//127.0.0.1:4873/:always-auth': true,
|
||||
'registry': 'http://127.0.0.1:4873',
|
||||
[`//127.0.0.1:${REGISTRY_MOCK_PORT}/:_authToken`]: data.token,
|
||||
[`//127.0.0.1:${REGISTRY_MOCK_PORT}/:always-auth`]: true,
|
||||
'registry': `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
}
|
||||
await addDependenciesToPackage({}, ['needs-auth'], await testDefaults({
|
||||
registries: {
|
||||
default: 'http://127.0.0.1:4873',
|
||||
default: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
},
|
||||
}, {
|
||||
rawConfig,
|
||||
registry: 'http://127.0.0.1:4873',
|
||||
registry: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
}, {
|
||||
rawConfig,
|
||||
}))
|
||||
@@ -201,7 +202,7 @@ test('a package that need authentication reuses authorization tokens for tarball
|
||||
const client = new RegClient()
|
||||
|
||||
const data = await new Promise((resolve, reject) => {
|
||||
client.adduser('http://localhost:4873', {
|
||||
client.adduser(`http://localhost:${REGISTRY_MOCK_PORT}`, {
|
||||
auth: {
|
||||
email: 'foo@bar.com',
|
||||
password: 'bar',
|
||||
@@ -211,17 +212,17 @@ test('a package that need authentication reuses authorization tokens for tarball
|
||||
}) as {token: string}
|
||||
|
||||
const rawConfig = {
|
||||
'//127.0.0.1:4873/:_authToken': data.token,
|
||||
'//127.0.0.1:4873/:always-auth': true,
|
||||
'registry': 'http://127.0.0.1:4873',
|
||||
[`//127.0.0.1:${REGISTRY_MOCK_PORT}/:_authToken`]: data.token,
|
||||
[`//127.0.0.1:${REGISTRY_MOCK_PORT}/:always-auth`]: true,
|
||||
'registry': `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
}
|
||||
let opts = await testDefaults({
|
||||
registries: {
|
||||
default: 'http://127.0.0.1:4873',
|
||||
default: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
},
|
||||
}, {
|
||||
rawConfig,
|
||||
registry: 'http://127.0.0.1:4873',
|
||||
registry: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
}, {
|
||||
rawConfig,
|
||||
})
|
||||
@@ -235,11 +236,11 @@ test('a package that need authentication reuses authorization tokens for tarball
|
||||
// Recreating options to clean store cache
|
||||
opts = await testDefaults({
|
||||
registries: {
|
||||
default: 'http://127.0.0.1:4873',
|
||||
default: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
},
|
||||
}, {
|
||||
rawConfig,
|
||||
registry: 'http://127.0.0.1:4873',
|
||||
registry: `http://127.0.0.1:${REGISTRY_MOCK_PORT}`,
|
||||
}, {
|
||||
rawConfig,
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { RootLog } from '@pnpm/core-loggers'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import isCI = require('is-ci')
|
||||
import path = require('path')
|
||||
import exists = require('path-exists')
|
||||
@@ -119,7 +120,7 @@ test('a subdependency is from a github repo with different name', async (t: tape
|
||||
await project.isExecutable('has-aliased-git-dependency/node_modules/.bin/hi')
|
||||
await project.isExecutable('has-aliased-git-dependency/node_modules/.bin/szia')
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/has-say-hi-peer/1.0.0_say-hi@1.0.0/node_modules/has-say-hi-peer')),
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/has-say-hi-peer/1.0.0_say-hi@1.0.0/node_modules/has-say-hi-peer`)),
|
||||
'aliased name used to resolve a peer dependency')
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { addDependenciesToPackage } from 'supi'
|
||||
import tape = require('tape')
|
||||
import promisifyTape from 'tape-promise'
|
||||
@@ -9,12 +10,12 @@ const test = promisifyTape(tape)
|
||||
test('tarball from npm registry', async (t: tape.Test) => {
|
||||
const project = prepareEmpty(t)
|
||||
|
||||
const manifest = await addDependenciesToPackage({}, ['http://localhost:4873/is-array/-/is-array-1.0.1.tgz'], await testDefaults())
|
||||
const manifest = await addDependenciesToPackage({}, [`http://localhost:${REGISTRY_MOCK_PORT}/is-array/-/is-array-1.0.1.tgz`], await testDefaults())
|
||||
|
||||
await project.has('is-array')
|
||||
await project.storeHas('localhost+4873/is-array/1.0.1')
|
||||
await project.storeHas(`localhost+${REGISTRY_MOCK_PORT}/is-array/1.0.1`)
|
||||
|
||||
t.deepEqual(manifest.dependencies, { 'is-array': 'http://localhost:4873/is-array/-/is-array-1.0.1.tgz' }, 'has been added to dependencies in package.json')
|
||||
t.deepEqual(manifest.dependencies, { 'is-array': `http://localhost:${REGISTRY_MOCK_PORT}/is-array/-/is-array-1.0.1.tgz` }, 'has been added to dependencies in package.json')
|
||||
})
|
||||
|
||||
test('tarball not from npm registry', async (t) => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import fs = require('fs')
|
||||
import path = require('path')
|
||||
@@ -113,7 +114,7 @@ test('should rehoist when uninstalling a package', async (t: tape.Test) => {
|
||||
|
||||
const modules = await project.readModulesManifest()
|
||||
t.ok(modules)
|
||||
t.deepEqual(modules!.hoistedAliases['localhost+4873/debug/2.6.9'], ['debug'], 'new hoisted debug added to .modules.yaml')
|
||||
t.deepEqual(modules!.hoistedAliases[`localhost+${REGISTRY_MOCK_PORT}/debug/2.6.9`], ['debug'], 'new hoisted debug added to .modules.yaml')
|
||||
})
|
||||
|
||||
test('should rehoist after running a general install', async (t) => {
|
||||
@@ -210,7 +211,7 @@ test('hoist by alias', async (t: tape.Test) => {
|
||||
|
||||
const modules = await project.readModulesManifest()
|
||||
t.ok(modules)
|
||||
t.deepEqual(modules!.hoistedAliases, { 'localhost+4873/dep-of-pkg-with-1-dep/100.1.0': [ 'dep' ] }, '.modules.yaml updated correctly')
|
||||
t.deepEqual(modules!.hoistedAliases, { [`localhost+${REGISTRY_MOCK_PORT}/dep-of-pkg-with-1-dep/100.1.0`]: [ 'dep' ] }, '.modules.yaml updated correctly')
|
||||
})
|
||||
|
||||
test('should remove aliased hoisted dependencies', async (t) => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import isSubdir = require('is-subdir')
|
||||
import path = require('path')
|
||||
import resolveLinkTarget = require('resolve-link-target')
|
||||
@@ -77,8 +78,8 @@ test('installing with independent-leaves and hoistPattern', async (t) => {
|
||||
await project.has('.pnpm/node_modules/dep-of-pkg-with-1-dep')
|
||||
|
||||
// wrappy is linked directly from the store
|
||||
await project.hasNot('.pnpm/localhost+4873/dep-of-pkg-with-1-dep/100.0.0')
|
||||
await project.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/dep-of-pkg-with-1-dep/100.0.0`)
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
|
||||
|
||||
await project.has('.pnpm/localhost+4873/pkg-with-1-dep/100.0.0')
|
||||
await project.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { LifecycleLog } from '@pnpm/core-loggers'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import loadJsonFile = require('load-json-file')
|
||||
import path = require('path')
|
||||
@@ -178,14 +179,14 @@ test("reports child's output", async (t: tape.Test) => {
|
||||
await addDependenciesToPackage({}, ['count-to-10'], await testDefaults({ fastUnpack: false, reporter }))
|
||||
|
||||
t.ok(reporter.calledWithMatch({
|
||||
depPath: 'localhost+4873/count-to-10/1.0.0',
|
||||
depPath: `localhost+${REGISTRY_MOCK_PORT}/count-to-10/1.0.0`,
|
||||
level: 'debug',
|
||||
name: 'pnpm:lifecycle',
|
||||
script: 'node postinstall',
|
||||
stage: 'postinstall',
|
||||
} as LifecycleLog))
|
||||
t.ok(reporter.calledWithMatch({
|
||||
depPath: 'localhost+4873/count-to-10/1.0.0',
|
||||
depPath: `localhost+${REGISTRY_MOCK_PORT}/count-to-10/1.0.0`,
|
||||
level: 'debug',
|
||||
line: '1',
|
||||
name: 'pnpm:lifecycle',
|
||||
@@ -193,7 +194,7 @@ test("reports child's output", async (t: tape.Test) => {
|
||||
stdio: 'stdout',
|
||||
} as LifecycleLog))
|
||||
t.ok(reporter.calledWithMatch({
|
||||
depPath: 'localhost+4873/count-to-10/1.0.0',
|
||||
depPath: `localhost+${REGISTRY_MOCK_PORT}/count-to-10/1.0.0`,
|
||||
level: 'debug',
|
||||
line: '2',
|
||||
name: 'pnpm:lifecycle',
|
||||
@@ -201,7 +202,7 @@ test("reports child's output", async (t: tape.Test) => {
|
||||
stdio: 'stdout',
|
||||
} as LifecycleLog))
|
||||
t.ok(reporter.calledWithMatch({
|
||||
depPath: 'localhost+4873/count-to-10/1.0.0',
|
||||
depPath: `localhost+${REGISTRY_MOCK_PORT}/count-to-10/1.0.0`,
|
||||
level: 'debug',
|
||||
line: '6',
|
||||
name: 'pnpm:lifecycle',
|
||||
@@ -209,7 +210,7 @@ test("reports child's output", async (t: tape.Test) => {
|
||||
stdio: 'stderr',
|
||||
} as LifecycleLog))
|
||||
t.ok(reporter.calledWithMatch({
|
||||
depPath: 'localhost+4873/count-to-10/1.0.0',
|
||||
depPath: `localhost+${REGISTRY_MOCK_PORT}/count-to-10/1.0.0`,
|
||||
exitCode: 0,
|
||||
level: 'debug',
|
||||
name: 'pnpm:lifecycle',
|
||||
@@ -227,7 +228,7 @@ test("reports child's close event", async (t: tape.Test) => {
|
||||
t.fail()
|
||||
} catch (err) {
|
||||
t.ok(reporter.calledWithMatch({
|
||||
depPath: 'localhost+4873/failing-postinstall/1.0.0',
|
||||
depPath: `localhost+${REGISTRY_MOCK_PORT}/failing-postinstall/1.0.0`,
|
||||
exitCode: 1,
|
||||
level: 'debug',
|
||||
name: 'pnpm:lifecycle',
|
||||
@@ -262,7 +263,7 @@ test('run lifecycle scripts of dependent packages after running scripts of their
|
||||
|
||||
await addDependenciesToPackage({}, ['with-postinstall-a'], await testDefaults({ fastUnpack: false }))
|
||||
|
||||
t.ok(+project.requireModule('.pnpm/localhost+4873/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json')[0] < +project.requireModule('with-postinstall-a/output.json')[0])
|
||||
t.ok(+project.requireModule(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json`)[0] < +project.requireModule('with-postinstall-a/output.json')[0])
|
||||
})
|
||||
|
||||
test('run prepare script for git-hosted dependencies', async (t: tape.Test) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import fs = require('mz/fs')
|
||||
import path = require('path')
|
||||
import sinon = require('sinon')
|
||||
@@ -20,8 +21,8 @@ test('install with lockfileOnly = true', async (t: tape.Test) => {
|
||||
const opts = await testDefaults({ lockfileOnly: true, pinnedVersion: 'patch' })
|
||||
const manifest = await addDependenciesToPackage({}, ['pkg-with-1-dep@100.0.0'], opts)
|
||||
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, 'localhost+4873', 'pkg-with-1-dep')), ['100.0.0', 'index.json'])
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, 'localhost+4873', 'dep-of-pkg-with-1-dep')), ['100.1.0', 'index.json'])
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}`, 'pkg-with-1-dep')), ['100.0.0', 'index.json'])
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}`, 'dep-of-pkg-with-1-dep')), ['100.1.0', 'index.json'])
|
||||
await project.hasNot('pkg-with-1-dep')
|
||||
|
||||
t.ok(manifest.dependencies!['pkg-with-1-dep'], 'the new dependency added to package.json')
|
||||
@@ -37,8 +38,8 @@ test('install with lockfileOnly = true', async (t: tape.Test) => {
|
||||
t.comment(`doing repeat install when ${WANTED_LOCKFILE} is available already`)
|
||||
await install(manifest, opts)
|
||||
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, 'localhost+4873', 'pkg-with-1-dep')), ['100.0.0', 'index.json'])
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, 'localhost+4873', 'dep-of-pkg-with-1-dep')), ['100.1.0', 'index.json'])
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}`, 'pkg-with-1-dep')), ['100.0.0', 'index.json'])
|
||||
t.deepEqual(await fs.readdir(path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}`, 'dep-of-pkg-with-1-dep')), ['100.1.0', 'index.json'])
|
||||
await project.hasNot('pkg-with-1-dep')
|
||||
|
||||
t.notOk(await project.readCurrentLockfile(), 'current lockfile not created')
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
StatsLog,
|
||||
} from '@pnpm/core-loggers'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { getIntegrity } from '@pnpm/registry-mock'
|
||||
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { ImporterManifest } from '@pnpm/types'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import deepRequireCwd = require('deep-require-cwd')
|
||||
@@ -166,7 +166,7 @@ test('scoped package with custom registry', async (t) => {
|
||||
await addDependenciesToPackage({}, ['@scoped/peer'], await testDefaults({
|
||||
// setting an incorrect default registry URL
|
||||
rawConfig: {
|
||||
'@scoped:registry': 'http://localhost:4873/',
|
||||
'@scoped:registry': `http://localhost:${REGISTRY_MOCK_PORT}/`,
|
||||
},
|
||||
registry: 'http://localhost:9999/',
|
||||
}))
|
||||
@@ -401,7 +401,7 @@ test("don't refetch package to store if it has been modified and verify-store-in
|
||||
const opts = await testDefaults({ verifyStoreIntegrity: false })
|
||||
const manifest = await addDependenciesToPackage({}, ['magic-hook@2.0.0'], opts)
|
||||
|
||||
await writeJsonFile(path.join(await project.getStorePath(), 'localhost+4873', 'magic-hook', '2.0.0', 'node_modules', 'magic-hook', 'package.json'), {})
|
||||
await writeJsonFile(path.join(await project.getStorePath(), `localhost+${REGISTRY_MOCK_PORT}`, 'magic-hook', '2.0.0', 'node_modules', 'magic-hook', 'package.json'), {})
|
||||
|
||||
await rimraf('node_modules')
|
||||
|
||||
@@ -459,10 +459,10 @@ test('concurrent circular deps', async (t: tape.Test) => {
|
||||
const m = project.requireModule('es6-iterator')
|
||||
|
||||
t.ok(m, 'es6-iterator is installed')
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/es6-iterator/2.0.0/node_modules/es5-ext')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/es6-iterator/2.0.1/node_modules/es5-ext')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/es5-ext/0.10.31/node_modules/es6-iterator')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/es5-ext/0.10.31/node_modules/es6-symbol')))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/es6-iterator/2.0.0/node_modules/es5-ext`)))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/es6-iterator/2.0.1/node_modules/es5-ext`)))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/es5-ext/0.10.31/node_modules/es6-iterator`)))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/es5-ext/0.10.31/node_modules/es6-symbol`)))
|
||||
})
|
||||
|
||||
test('concurrent installation of the same packages', async (t) => {
|
||||
@@ -702,13 +702,13 @@ test('lockfile locks npm dependencies', async (t: tape.Test) => {
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
name: 'pnpm:progress',
|
||||
packageId: 'localhost+4873/pkg-with-1-dep/100.0.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
|
||||
requester: process.cwd(),
|
||||
status: 'resolved',
|
||||
} as ProgressLog), 'logs that package is being resolved')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/pkg-with-1-dep/100.0.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
|
||||
requester: process.cwd(),
|
||||
status: 'fetched',
|
||||
} as ProgressLog), 'logged that package was fetched from registry')
|
||||
@@ -724,18 +724,18 @@ test('lockfile locks npm dependencies', async (t: tape.Test) => {
|
||||
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/pkg-with-1-dep/100.0.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
|
||||
requester: process.cwd(),
|
||||
status: 'resolved',
|
||||
} as ProgressLog), 'logs that package is being resolved')
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
packageId: 'localhost+4873/pkg-with-1-dep/100.0.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0`,
|
||||
requester: process.cwd(),
|
||||
status: 'found_in_store',
|
||||
} as ProgressLog), 'logged that package was found in store')
|
||||
|
||||
const m = project.requireModule('.pnpm/localhost+4873/pkg-with-1-dep/100.0.0/node_modules/dep-of-pkg-with-1-dep/package.json')
|
||||
const m = project.requireModule(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0/node_modules/dep-of-pkg-with-1-dep/package.json`)
|
||||
|
||||
t.equal(m.version, '100.0.0', `dependency specified in ${WANTED_LOCKFILE} is installed`)
|
||||
})
|
||||
@@ -835,7 +835,7 @@ test("don't fail on case insensitive filesystems when package has 2 files with s
|
||||
test('reinstalls missing packages to node_modules', async (t) => {
|
||||
prepareEmpty(t)
|
||||
const reporter = sinon.spy()
|
||||
const depLocation = path.resolve('node_modules/.pnpm/localhost+4873/is-positive/1.0.0/node_modules/is-positive')
|
||||
const depLocation = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0/node_modules/is-positive`)
|
||||
const missingDepLog = {
|
||||
level: 'debug',
|
||||
missing: depLocation,
|
||||
@@ -871,7 +871,7 @@ test('reinstalls missing packages to node_modules', async (t) => {
|
||||
test('reinstalls missing packages to node_modules during headless install', async (t) => {
|
||||
prepareEmpty(t)
|
||||
const reporter = sinon.spy()
|
||||
const depLocation = path.resolve('node_modules/.pnpm/localhost+4873/is-positive/1.0.0/node_modules/is-positive')
|
||||
const depLocation = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0/node_modules/is-positive`)
|
||||
const missingDepLog = {
|
||||
level: 'debug',
|
||||
missing: depLocation,
|
||||
@@ -1000,7 +1000,7 @@ test('all the subdeps of dependencies are linked when a node_modules is partiall
|
||||
], await testDefaults({ preferFrozenLockfile: false }))
|
||||
|
||||
t.deepEqual(
|
||||
await fs.readdir(path.resolve('node_modules/.pnpm/localhost+4873/foobarqar/1.0.1/node_modules')),
|
||||
await fs.readdir(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/foobarqar/1.0.1/node_modules`)),
|
||||
[
|
||||
'bar',
|
||||
'foo',
|
||||
@@ -1087,7 +1087,7 @@ test('subdep symlinks are updated if the lockfile has new subdep versions specif
|
||||
},
|
||||
], await testDefaults({ preferFrozenLockfile: false }))
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/pkg-with-1-dep/100.0.0/node_modules/dep-of-pkg-with-1-dep/package.json')))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0/node_modules/dep-of-pkg-with-1-dep/package.json`)))
|
||||
})
|
||||
|
||||
test("store metadata is always saved, even if there's a fatal error", async (t: tape.Test) => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import assertProject from '@pnpm/assert-project'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { readCurrentLockfile } from '@pnpm/lockfile-file'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import path = require('path')
|
||||
import exists = require('path-exists')
|
||||
import sinon = require('sinon')
|
||||
@@ -66,8 +67,8 @@ test('install only the dependencies of the specified importer', async (t) => {
|
||||
await projects['project-2'].hasNot('is-negative')
|
||||
|
||||
const rootNodeModules = assertProject(t, process.cwd())
|
||||
await rootNodeModules.has('.pnpm/localhost+4873/is-positive/1.0.0')
|
||||
await rootNodeModules.hasNot('.pnpm/localhost+4873/is-negative/1.0.0')
|
||||
await rootNodeModules.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`)
|
||||
await rootNodeModules.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-negative/1.0.0`)
|
||||
})
|
||||
|
||||
test('dependencies of other importers are not pruned when installing for a subset of importers', async (t) => {
|
||||
@@ -120,9 +121,9 @@ test('dependencies of other importers are not pruned when installing for a subse
|
||||
await projects['project-2'].has('is-negative')
|
||||
|
||||
const rootNodeModules = assertProject(t, process.cwd())
|
||||
await rootNodeModules.has('.pnpm/localhost+4873/is-positive/2.0.0')
|
||||
await rootNodeModules.hasNot('.pnpm/localhost+4873/is-positive/1.0.0')
|
||||
await rootNodeModules.has('.pnpm/localhost+4873/is-negative/1.0.0')
|
||||
await rootNodeModules.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0`)
|
||||
await rootNodeModules.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`)
|
||||
await rootNodeModules.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-negative/1.0.0`)
|
||||
|
||||
const lockfile = await rootNodeModules.readCurrentLockfile()
|
||||
t.deepEqual(Object.keys(lockfile.importers), ['project-1', 'project-2'])
|
||||
@@ -185,9 +186,9 @@ test('dependencies of other importers are not pruned when (headless) installing
|
||||
await projects['project-2'].has('is-negative')
|
||||
|
||||
const rootNodeModules = assertProject(t, process.cwd())
|
||||
await rootNodeModules.has('.pnpm/localhost+4873/is-positive/2.0.0')
|
||||
await rootNodeModules.hasNot('.pnpm/localhost+4873/is-positive/1.0.0')
|
||||
await rootNodeModules.has('.pnpm/localhost+4873/is-negative/1.0.0')
|
||||
await rootNodeModules.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0`)
|
||||
await rootNodeModules.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0`)
|
||||
await rootNodeModules.has(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-negative/1.0.0`)
|
||||
})
|
||||
|
||||
test('adding a new dev dependency to project that uses a shared lockfile', async (t) => {
|
||||
@@ -458,9 +459,9 @@ test('partial installation in a monorepo does not remove dependencies of other w
|
||||
},
|
||||
], await testDefaults())
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/is-positive/2.0.0/node_modules/is-positive')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/pkg-with-1-dep/100.0.0/node_modules/pkg-with-1-dep')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/dep-of-pkg-with-1-dep/100.1.0/node_modules/dep-of-pkg-with-1-dep')))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/2.0.0/node_modules/is-positive`)))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0/node_modules/pkg-with-1-dep`)))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/dep-of-pkg-with-1-dep/100.1.0/node_modules/dep-of-pkg-with-1-dep`)))
|
||||
})
|
||||
|
||||
test('partial installation in a monorepo does not remove dependencies of other workspace packages when lockfile is frozen', async (t: tape.Test) => {
|
||||
@@ -551,9 +552,9 @@ test('partial installation in a monorepo does not remove dependencies of other w
|
||||
},
|
||||
], await testDefaults({ frozenLockfile: true }))
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/is-positive/1.0.0/node_modules/is-positive')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/pkg-with-1-dep/100.0.0/node_modules/pkg-with-1-dep')))
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/dep-of-pkg-with-1-dep/100.1.0/node_modules/dep-of-pkg-with-1-dep')))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0/node_modules/is-positive`)))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/pkg-with-1-dep/100.0.0/node_modules/pkg-with-1-dep`)))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/dep-of-pkg-with-1-dep/100.1.0/node_modules/dep-of-pkg-with-1-dep`)))
|
||||
})
|
||||
|
||||
test('adding a new dependency with the workspace: protocol', async (t) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import deepRequireCwd = require('deep-require-cwd')
|
||||
import path = require('path')
|
||||
@@ -70,7 +71,7 @@ test('skip optional dependency that does not support the current OS', async (t:
|
||||
|
||||
await project.hasNot('not-compatible-with-any-os')
|
||||
await project.storeHas('not-compatible-with-any-os', '1.0.0')
|
||||
t.notOk(await exists(path.resolve('node_modules/.pnpm/localhost+4873/dep-of-optional-pkg/1.0.0')), "isn't linked into node_modules")
|
||||
t.notOk(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/dep-of-optional-pkg/1.0.0`)), "isn't linked into node_modules")
|
||||
|
||||
const lockfile = await project.readLockfile()
|
||||
t.ok(lockfile.packages['/not-compatible-with-any-os/1.0.0'], 'lockfile contains optional dependency')
|
||||
@@ -88,7 +89,7 @@ test('skip optional dependency that does not support the current OS', async (t:
|
||||
|
||||
const logMatcher = sinon.match({
|
||||
package: {
|
||||
id: 'localhost+4873/not-compatible-with-any-os/1.0.0',
|
||||
id: `localhost+${REGISTRY_MOCK_PORT}/not-compatible-with-any-os/1.0.0`,
|
||||
name: 'not-compatible-with-any-os',
|
||||
version: '1.0.0',
|
||||
},
|
||||
@@ -146,7 +147,7 @@ test('skip optional dependency that does not support the current Node version',
|
||||
|
||||
const logMatcher = sinon.match({
|
||||
package: {
|
||||
id: 'localhost+4873/for-legacy-node/1.0.0',
|
||||
id: `localhost+${REGISTRY_MOCK_PORT}/for-legacy-node/1.0.0`,
|
||||
name: 'for-legacy-node',
|
||||
version: '1.0.0',
|
||||
},
|
||||
@@ -171,7 +172,7 @@ test('skip optional dependency that does not support the current pnpm version',
|
||||
|
||||
const logMatcher = sinon.match({
|
||||
package: {
|
||||
id: 'localhost+4873/for-legacy-pnpm/1.0.0',
|
||||
id: `localhost+${REGISTRY_MOCK_PORT}/for-legacy-pnpm/1.0.0`,
|
||||
name: 'for-legacy-pnpm',
|
||||
version: '1.0.0',
|
||||
},
|
||||
@@ -207,12 +208,12 @@ test('optional subdependency is skipped', async (t: tape.Test) => {
|
||||
t.deepEqual(modulesInfo.skipped, ['/not-compatible-with-any-os/1.0.0'], 'optional subdep skipped')
|
||||
}
|
||||
|
||||
t.ok(await exists('node_modules/.pnpm/localhost+4873/pkg-with-optional/1.0.0'), 'regular dependency linked')
|
||||
t.notOk(await exists('node_modules/.pnpm/localhost+4873/not-compatible-with-any-os/1.0.0'), 'optional dependency not linked')
|
||||
t.ok(await exists(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/pkg-with-optional/1.0.0`), 'regular dependency linked')
|
||||
t.notOk(await exists(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/not-compatible-with-any-os/1.0.0`), 'optional dependency not linked')
|
||||
|
||||
const logMatcher = sinon.match({
|
||||
package: {
|
||||
id: 'localhost+4873/not-compatible-with-any-os/1.0.0',
|
||||
id: `localhost+${REGISTRY_MOCK_PORT}/not-compatible-with-any-os/1.0.0`,
|
||||
name: 'not-compatible-with-any-os',
|
||||
version: '1.0.0',
|
||||
},
|
||||
@@ -234,7 +235,7 @@ test('optional subdependency is skipped', async (t: tape.Test) => {
|
||||
await testDefaults({ force: true, frozenLockfile: true }),
|
||||
)
|
||||
|
||||
t.ok(await exists('node_modules/.pnpm/localhost+4873/not-compatible-with-any-os/1.0.0'), 'optional dependency linked after forced headless install')
|
||||
t.ok(await exists(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/not-compatible-with-any-os/1.0.0`), 'optional dependency linked after forced headless install')
|
||||
|
||||
{
|
||||
const modulesInfo = await readYamlFile<{ skipped: string[] }>(path.join('node_modules', '.modules.yaml'))
|
||||
@@ -348,10 +349,10 @@ test('only skip optional dependencies', async (t: tape.Test) => {
|
||||
},
|
||||
}, await testDefaults({ fastUnpack: false, preferredVersions }))
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/duplexify/3.6.0')), 'duplexify is linked into node_modules')
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/stream-shift/1.0.0')), 'stream-shift is linked into node_modules')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/duplexify/3.6.0`)), 'duplexify is linked into node_modules')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/stream-shift/1.0.0`)), 'stream-shift is linked into node_modules')
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/got/3.3.1/node_modules/duplexify')), 'duplexify is linked into node_modules of got')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/got/3.3.1/node_modules/duplexify`)), 'duplexify is linked into node_modules of got')
|
||||
})
|
||||
|
||||
test(`rebuild should not fail on incomplete ${WANTED_LOCKFILE}`, async (t: tape.Test) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { Lockfile } from '@pnpm/lockfile-file'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { addDistTag } from '@pnpm/registry-mock'
|
||||
import { addDistTag, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import deepRequireCwd = require('deep-require-cwd')
|
||||
import loadJsonFile = require('load-json-file')
|
||||
@@ -33,19 +33,19 @@ test('peer dependency is grouped with dependency when peer is resolved not from
|
||||
const opts = await testDefaults()
|
||||
let manifest = await addDependenciesToPackage({}, ['using-ajv'], opts)
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv')), 'peer dependency is linked')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv`)), 'peer dependency is linked')
|
||||
t.equal(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version, '4.10.4')
|
||||
|
||||
const storeIndex = await loadJsonFile<object>(path.join(opts.storeDir, 'store.json'))
|
||||
t.ok(storeIndex['localhost+4873/ajv-keywords/1.5.0'], 'localhost+4873/ajv-keywords/1.5.0 added to store index')
|
||||
t.ok(storeIndex['localhost+4873/using-ajv/1.0.0'], 'localhost+4873/using-ajv/1.0.0 added to store index')
|
||||
t.ok(storeIndex[`localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0`], `localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0 added to store index`)
|
||||
t.ok(storeIndex[`localhost+${REGISTRY_MOCK_PORT}/using-ajv/1.0.0`], `localhost+${REGISTRY_MOCK_PORT}/using-ajv/1.0.0 added to store index`)
|
||||
|
||||
// testing that peers are reinstalled correctly using info from the lockfile
|
||||
await rimraf('node_modules')
|
||||
await rimraf(path.resolve('..', '.store'))
|
||||
manifest = await install(manifest, await testDefaults())
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv')), 'peer dependency is linked')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv`)), 'peer dependency is linked')
|
||||
t.equal(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version, '4.10.4')
|
||||
|
||||
await addDependenciesToPackage(manifest, ['using-ajv'], await testDefaults({ update: true }))
|
||||
@@ -67,8 +67,8 @@ test('nothing is needlessly removed from node_modules', async (t: tape.Test) =>
|
||||
const opts = await testDefaults()
|
||||
const manifest = await addDependenciesToPackage({}, ['using-ajv', 'ajv-keywords@1.5.0'], opts)
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv')), 'peer dependency is linked')
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/ajv-keywords/1.5.0/node_modules/ajv-keywords')), 'root dependency resolution is present')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv`)), 'peer dependency is linked')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0/node_modules/ajv-keywords`)), 'root dependency resolution is present')
|
||||
t.equal(deepRequireCwd(['using-ajv', 'ajv-keywords', 'ajv', './package.json']).version, '4.10.4')
|
||||
|
||||
await mutateModules([
|
||||
@@ -80,8 +80,8 @@ test('nothing is needlessly removed from node_modules', async (t: tape.Test) =>
|
||||
}
|
||||
], opts)
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv')), 'peer dependency link is not removed')
|
||||
t.notOk(await exists(path.resolve('node_modules/.pnpm/localhost+4873', 'ajv-keywords', '1.5.0/node_modules/ajv-keywords')), 'root dependency resolution is removed')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0_ajv@4.10.4/node_modules/ajv`)), 'peer dependency link is not removed')
|
||||
t.notOk(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'ajv-keywords', '1.5.0/node_modules/ajv-keywords')), 'root dependency resolution is removed')
|
||||
})
|
||||
|
||||
test('peer dependency is grouped with dependent when the peer is a top dependency', async (t: tape.Test) => {
|
||||
@@ -92,10 +92,10 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
|
||||
await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'], await testDefaults({ reporter }))
|
||||
|
||||
t.notOk(reporter.calledWithMatch({
|
||||
message: 'localhost+4873/ajv-keywords/1.5.0 requires a peer of ajv@>=4.10.0 but none was installed.',
|
||||
message: `localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0 requires a peer of ajv@>=4.10.0 but none was installed.`,
|
||||
}), 'no warning is logged about unresolved peer dep')
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873', 'ajv-keywords', '1.5.0_ajv@4.10.4/node_modules/ajv-keywords')), 'dependent is grouped with top peer dep')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'ajv-keywords', '1.5.0_ajv@4.10.4/node_modules/ajv-keywords')), 'dependent is grouped with top peer dep')
|
||||
})
|
||||
|
||||
test('the right peer dependency is used in every workspace package', async (t: tape.Test) => {
|
||||
@@ -261,8 +261,8 @@ test('top peer dependency is linked on subsequent install', async (t: tape.Test)
|
||||
|
||||
await addDependenciesToPackage(manifest, ['ajv-keywords@1.5.0'], await testDefaults())
|
||||
|
||||
t.notOk(await exists(path.resolve('node_modules/.pnpm/localhost+4873', 'ajv-keywords', '1.5.0/node_modules/ajv-keywords')), 'dependency without peer is prunned')
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873', 'ajv-keywords', '1.5.0_ajv@4.10.4/node_modules/ajv')), 'peer dependency is linked')
|
||||
t.notOk(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'ajv-keywords', '1.5.0/node_modules/ajv-keywords')), 'dependency without peer is prunned')
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'ajv-keywords', '1.5.0_ajv@4.10.4/node_modules/ajv')), 'peer dependency is linked')
|
||||
})
|
||||
|
||||
async function okFile (t: tape.Test, filename: string) {
|
||||
@@ -278,7 +278,7 @@ test('peer dependencies are linked when running one named installation', async (
|
||||
|
||||
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c', 'abc-parent-with-ab', 'peer-c@2.0.0'], await testDefaults())
|
||||
|
||||
const pkgVariationsDir = path.resolve('node_modules/.pnpm/localhost+4873', 'abc', '1.0.0')
|
||||
const pkgVariationsDir = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'abc', '1.0.0')
|
||||
|
||||
const pkgVariation1 = path.join(pkgVariationsDir + '_165e1e08a3f7e7f77ddb572ad0e55660/node_modules')
|
||||
await okFile(t, path.join(pkgVariation1, 'abc'))
|
||||
@@ -310,7 +310,7 @@ test('peer dependencies are linked when running two separate named installations
|
||||
const manifest = await addDependenciesToPackage({}, ['abc-grand-parent-with-c', 'peer-c@2.0.0'], await testDefaults())
|
||||
await addDependenciesToPackage(manifest, ['abc-parent-with-ab'], await testDefaults())
|
||||
|
||||
const pkgVariationsDir = path.resolve('node_modules/.pnpm/localhost+4873', 'abc', '1.0.0')
|
||||
const pkgVariationsDir = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'abc', '1.0.0')
|
||||
|
||||
const pkgVariation1 = path.join(pkgVariationsDir + '_165e1e08a3f7e7f77ddb572ad0e55660/node_modules')
|
||||
await okFile(t, path.join(pkgVariation1, 'abc'))
|
||||
@@ -342,7 +342,7 @@ test['skip']('peer dependencies are linked', async (t: tape.Test) => {
|
||||
},
|
||||
}, await testDefaults())
|
||||
|
||||
const pkgVariationsDir = path.resolve('node_modules/.pnpm/localhost+4873', 'abc', '1.0.0')
|
||||
const pkgVariationsDir = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'abc', '1.0.0')
|
||||
|
||||
const pkgVariation1 = path.join(pkgVariationsDir, '165e1e08a3f7e7f77ddb572ad0e55660/node_modules')
|
||||
await okFile(t, path.join(pkgVariation1, 'abc'))
|
||||
@@ -368,7 +368,7 @@ test('scoped peer dependency is linked', async (t: tape.Test) => {
|
||||
prepareEmpty(t)
|
||||
await addDependenciesToPackage({}, ['for-testing-scoped-peers'], await testDefaults())
|
||||
|
||||
const pkgVariation = path.resolve('node_modules/.pnpm/localhost+4873', '@having', 'scoped-peer', '1.0.0_@scoped+peer@1.0.0/node_modules')
|
||||
const pkgVariation = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, '@having', 'scoped-peer', '1.0.0_@scoped+peer@1.0.0/node_modules')
|
||||
await okFile(t, path.join(pkgVariation, '@having', 'scoped-peer'))
|
||||
await okFile(t, path.join(pkgVariation, '@scoped', 'peer'))
|
||||
})
|
||||
@@ -378,7 +378,7 @@ test('peer bins are linked', async (t: tape.Test) => {
|
||||
|
||||
await addDependenciesToPackage({}, ['for-testing-peers-having-bins'], await testDefaults({ fastUnpack: false }))
|
||||
|
||||
const pkgVariation = path.join('.pnpm/localhost+4873', 'pkg-with-peer-having-bin', '1.0.0_peer-with-bin@1.0.0/node_modules')
|
||||
const pkgVariation = path.join(`.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'pkg-with-peer-having-bin', '1.0.0_peer-with-bin@1.0.0/node_modules')
|
||||
|
||||
await project.isExecutable(path.join(pkgVariation, 'pkg-with-peer-having-bin/node_modules/.bin', 'peer-with-bin'))
|
||||
|
||||
@@ -390,11 +390,11 @@ test('run pre/postinstall scripts of each variations of packages with peer depen
|
||||
prepareEmpty(t)
|
||||
await addDependenciesToPackage({}, ['parent-of-pkg-with-events-and-peers', 'pkg-with-events-and-peers', 'peer-c@2.0.0'], await testDefaults({ fastUnpack: false }))
|
||||
|
||||
const pkgVariation1 = path.resolve('node_modules/.pnpm/localhost+4873', 'pkg-with-events-and-peers', '1.0.0_peer-c@1.0.0/node_modules')
|
||||
const pkgVariation1 = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'pkg-with-events-and-peers', '1.0.0_peer-c@1.0.0/node_modules')
|
||||
await okFile(t, path.join(pkgVariation1, 'pkg-with-events-and-peers', 'generated-by-preinstall.js'))
|
||||
await okFile(t, path.join(pkgVariation1, 'pkg-with-events-and-peers', 'generated-by-postinstall.js'))
|
||||
|
||||
const pkgVariation2 = path.resolve('node_modules/.pnpm/localhost+4873', 'pkg-with-events-and-peers', '1.0.0_peer-c@2.0.0/node_modules')
|
||||
const pkgVariation2 = path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'pkg-with-events-and-peers', '1.0.0_peer-c@2.0.0/node_modules')
|
||||
await okFile(t, path.join(pkgVariation2, 'pkg-with-events-and-peers', 'generated-by-preinstall.js'))
|
||||
await okFile(t, path.join(pkgVariation2, 'pkg-with-events-and-peers', 'generated-by-postinstall.js'))
|
||||
})
|
||||
@@ -410,7 +410,7 @@ test('package that resolves its own peer dependency', async (t: tape.Test) => {
|
||||
|
||||
t.equal(deepRequireCwd(['pkg-with-resolved-peer', 'peer-c', './package.json']).version, '1.0.0')
|
||||
|
||||
t.ok(await exists(path.resolve('node_modules/.pnpm/localhost+4873/pkg-with-resolved-peer/1.0.0/node_modules/pkg-with-resolved-peer')))
|
||||
t.ok(await exists(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/pkg-with-resolved-peer/1.0.0/node_modules/pkg-with-resolved-peer`)))
|
||||
|
||||
const lockfile = await project.readLockfile()
|
||||
|
||||
@@ -445,10 +445,10 @@ test('peer dependency is grouped with dependent when the peer is a top dependenc
|
||||
await addDependenciesToPackage({}, ['ajv@4.10.4', 'ajv-keywords@1.5.0'], await testDefaults({ reporter, lockfileDir: path.resolve('..') }))
|
||||
|
||||
t.notOk(reporter.calledWithMatch({
|
||||
message: 'localhost+4873/ajv-keywords/1.5.0 requires a peer of ajv@>=4.10.0 but none was installed.',
|
||||
message: `localhost+${REGISTRY_MOCK_PORT}/ajv-keywords/1.5.0 requires a peer of ajv@>=4.10.0 but none was installed.`,
|
||||
}), 'no warning is logged about unresolved peer dep')
|
||||
|
||||
t.ok(await exists(path.join('../node_modules/.pnpm/localhost+4873', 'ajv-keywords', '1.5.0_ajv@4.10.4/node_modules/ajv-keywords')))
|
||||
t.ok(await exists(path.join(`../node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'ajv-keywords', '1.5.0_ajv@4.10.4/node_modules/ajv-keywords')))
|
||||
|
||||
const lockfile = await readYamlFile<Lockfile>(path.join('..', WANTED_LOCKFILE))
|
||||
|
||||
@@ -478,7 +478,7 @@ test('peer dependency is grouped correctly with peer installed via separate inst
|
||||
}, await testDefaults({ reporter, lockfileDir }))
|
||||
await addDependenciesToPackage(manifest, ['peer-c@2.0.0'], await testDefaults({ reporter, lockfileDir }))
|
||||
|
||||
t.ok(await exists(path.join('../node_modules/.pnpm/localhost+4873', 'abc', '1.0.0_peer-c@2.0.0/node_modules/dep-of-pkg-with-1-dep')))
|
||||
t.ok(await exists(path.join(`../node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'abc', '1.0.0_peer-c@2.0.0/node_modules/dep-of-pkg-with-1-dep')))
|
||||
})
|
||||
|
||||
test('peer dependency is grouped with dependent when the peer is a top dependency and external node_modules is used', async (t: tape.Test) => {
|
||||
@@ -624,7 +624,7 @@ test('external lockfile: peer dependency is grouped with dependent even after a
|
||||
})
|
||||
}
|
||||
|
||||
t.ok(await exists(path.join('../node_modules/.pnpm/localhost+4873', 'abc-parent-with-ab', '1.0.0_peer-c@2.0.0/node_modules/is-positive')))
|
||||
t.ok(await exists(path.join(`../node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'abc-parent-with-ab', '1.0.0_peer-c@2.0.0/node_modules/is-positive')))
|
||||
})
|
||||
|
||||
test('regular dependencies are not removed on update from transitive packages that have children with peers resolved from above', async (t: tape.Test) => {
|
||||
@@ -640,7 +640,7 @@ test('regular dependencies are not removed on update from transitive packages th
|
||||
await addDistTag({ package: 'peer-c', version: '1.0.1', distTag: 'latest' })
|
||||
await install(manifest, await testDefaults({ lockfileDir, update: true, depth: 2 }))
|
||||
|
||||
t.ok(await exists(path.join('../node_modules/.pnpm/localhost+4873', 'abc-parent-with-ab', '1.0.1_peer-c@1.0.1/node_modules/is-positive')))
|
||||
t.ok(await exists(path.join(`../node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}`, 'abc-parent-with-ab', '1.0.1_peer-c@1.0.1/node_modules/is-positive')))
|
||||
})
|
||||
|
||||
test('peer dependency is resolved from parent package', async (t) => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { DeprecationLog } from '@pnpm/core-loggers'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import sinon = require('sinon')
|
||||
import {
|
||||
addDependenciesToPackage,
|
||||
@@ -25,7 +26,7 @@ test('reports warning when installing deprecated packages', async (t: tape.Test)
|
||||
deprecated: 'express 0.x series is deprecated',
|
||||
level: 'debug',
|
||||
name: 'pnpm:deprecation',
|
||||
pkgId: 'localhost+4873/express/0.14.1',
|
||||
pkgId: `localhost+${REGISTRY_MOCK_PORT}/express/0.14.1`,
|
||||
} as DeprecationLog), 'deprecation warning reported')
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ test('reports warning when installing deprecated packages', async (t: tape.Test)
|
||||
t.notOk(reporter.calledWithMatch({
|
||||
level: 'debug',
|
||||
name: 'pnpm:deprecation',
|
||||
pkgId: 'localhost+4873/express/4.16.3',
|
||||
pkgId: `localhost+${REGISTRY_MOCK_PORT}/express/4.16.3`,
|
||||
} as DeprecationLog), 'deprecation warning reported')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import fs = require('mz/fs')
|
||||
import path = require('path')
|
||||
@@ -22,7 +23,7 @@ test('caching side effects of native package', async (t) => {
|
||||
sideEffectsCacheWrite: true,
|
||||
})
|
||||
let manifest = await addDependenciesToPackage({}, ['diskusage@1.1.3'], opts)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const stat1 = await fs.stat(cacheBuildDir)
|
||||
|
||||
t.ok(await exists('node_modules/diskusage/build'), 'build folder created')
|
||||
@@ -48,7 +49,7 @@ test('caching side effects of native package when hoisting is used', async (t) =
|
||||
sideEffectsCacheWrite: true,
|
||||
})
|
||||
let manifest = await addDependenciesToPackage({}, ['expire-fs@2.2.3'], opts)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const stat1 = await fs.stat(cacheBuildDir)
|
||||
|
||||
await project.has('.pnpm/node_modules/diskusage/build') // build folder created
|
||||
@@ -80,7 +81,7 @@ test('using side effects cache', async (t) => {
|
||||
}, {}, {}, { packageImportMethod: 'copy' })
|
||||
const manifest = await addDependenciesToPackage({}, ['diskusage@1.1.3'], opts)
|
||||
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
await fs.writeFile(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')
|
||||
|
||||
await rimraf('node_modules')
|
||||
@@ -101,7 +102,7 @@ test('readonly side effects cache', async (t) => {
|
||||
let manifest = await addDependenciesToPackage({}, ['diskusage@1.1.3'], opts1)
|
||||
|
||||
// Modify the side effects cache to make sure we are using it
|
||||
const cacheBuildDir = path.join(opts1.storeDir, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(opts1.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
await fs.writeFile(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')
|
||||
|
||||
await rimraf('node_modules')
|
||||
@@ -120,7 +121,7 @@ test('readonly side effects cache', async (t) => {
|
||||
await addDependenciesToPackage(manifest, ['diskusage@1.1.2'], opts2)
|
||||
|
||||
t.ok(await exists('node_modules/diskusage/build'), 'build folder created')
|
||||
t.notOk(await exists(path.join(opts2.storeDir, `localhost+4873/diskusage/1.1.2/side_effects/${ENGINE_DIR}/package/build`)), 'cache folder not created')
|
||||
t.notOk(await exists(path.join(opts2.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.2/side_effects/${ENGINE_DIR}/package/build`)), 'cache folder not created')
|
||||
})
|
||||
|
||||
test('uploading errors do not interrupt installation', async (t) => {
|
||||
@@ -138,7 +139,7 @@ test('uploading errors do not interrupt installation', async (t) => {
|
||||
|
||||
t.ok(await exists('node_modules/diskusage/build'), 'build folder created')
|
||||
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+4873/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
const cacheBuildDir = path.join(opts.storeDir, `localhost+${REGISTRY_MOCK_PORT}/diskusage/1.1.3/side_effects/${ENGINE_DIR}/package/build`)
|
||||
t.notOk(await exists(cacheBuildDir), 'side effects cache not created')
|
||||
|
||||
t.end()
|
||||
|
||||
@@ -2,6 +2,7 @@ import { isExecutable } from '@pnpm/assert-project'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { RootLog } from '@pnpm/core-loggers'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import fs = require('mz/fs')
|
||||
import ncpCB = require('ncp')
|
||||
import path = require('path')
|
||||
@@ -212,11 +213,11 @@ test('node_modules is pruned after linking', async (t: tape.Test) => {
|
||||
|
||||
const manifest = await addDependenciesToPackage({}, ['is-positive@1.0.0'], await testDefaults())
|
||||
|
||||
t.ok(await exists('node_modules/.pnpm/localhost+4873/is-positive/1.0.0/node_modules/is-positive/package.json'))
|
||||
t.ok(await exists(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0/node_modules/is-positive/package.json`))
|
||||
|
||||
await link(['../is-positive'], path.resolve('node_modules'), await testDefaults({ manifest, dir: process.cwd() }))
|
||||
|
||||
t.notOk(await exists('node_modules/.pnpm/localhost+4873/is-positive/1.0.0/node_modules/is-positive/package.json'), 'pruned')
|
||||
t.notOk(await exists(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/is-positive/1.0.0/node_modules/is-positive/package.json`), 'pruned')
|
||||
})
|
||||
|
||||
test('relative link uses realpath when contained in a symlinked dir', async (t: tape.Test) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { RootLog } from '@pnpm/core-loggers'
|
||||
import { Lockfile, TarballResolution } from '@pnpm/lockfile-file'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { fromDir as readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { getIntegrity } from '@pnpm/registry-mock'
|
||||
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { ImporterManifest } from '@pnpm/types'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import makeDir = require('make-dir')
|
||||
@@ -131,7 +131,7 @@ test('fail when shasum from lockfile does not match with the actual one', async
|
||||
'/is-negative/2.1.0': {
|
||||
resolution: {
|
||||
integrity: 'sha1-uZnX2TX0P1IHsBsA094ghS9Mp10=',
|
||||
tarball: 'http://localhost:4873/is-negative/-/is-negative-2.1.0.tgz',
|
||||
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-negative/-/is-negative-2.1.0.tgz`,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -162,7 +162,7 @@ test("lockfile doesn't lock subdependencies that don't satisfy the new specs", a
|
||||
await addDependenciesToPackage(manifest, ['react-datetime@1.3.0'], await testDefaults({ save: true }))
|
||||
|
||||
t.equal(
|
||||
project.requireModule('.pnpm/localhost+4873/react-datetime/1.3.0/node_modules/react-onclickoutside/package.json').version,
|
||||
project.requireModule(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/react-datetime/1.3.0/node_modules/react-onclickoutside/package.json`).version,
|
||||
'0.3.4',
|
||||
'react-datetime@1.3.0 has react-onclickoutside@0.3.4 in its node_modules')
|
||||
|
||||
@@ -191,7 +191,7 @@ test('lockfile removed when no deps in package.json', async (t: tape.Test) => {
|
||||
packages: {
|
||||
'/is-negative/2.1.0': {
|
||||
resolution: {
|
||||
tarball: 'http://localhost:4873/is-negative/-/is-negative-2.1.0.tgz',
|
||||
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-negative/-/is-negative-2.1.0.tgz`,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -223,7 +223,7 @@ test('lockfile is fixed when it does not match package.json', async (t: tape.Tes
|
||||
},
|
||||
'/is-negative/2.1.0': {
|
||||
resolution: {
|
||||
tarball: 'http://localhost:4873/is-negative/-/is-negative-2.1.0.tgz',
|
||||
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-negative/-/is-negative-2.1.0.tgz`,
|
||||
},
|
||||
},
|
||||
'/is-positive/3.1.0': {
|
||||
@@ -281,7 +281,7 @@ test(`doing named installation when ${WANTED_LOCKFILE} exists already`, async (t
|
||||
},
|
||||
'/is-negative/2.1.0': {
|
||||
resolution: {
|
||||
tarball: 'http://localhost:4873/is-negative/-/is-negative-2.1.0.tgz',
|
||||
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-negative/-/is-negative-2.1.0.tgz`,
|
||||
},
|
||||
},
|
||||
'/is-positive/3.1.0': {
|
||||
@@ -336,8 +336,8 @@ test(`respects ${WANTED_LOCKFILE} for top dependencies`, async (t: tape.Test) =>
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules', 'foo'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules', 'bar'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules', 'qar'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/localhost+4873/foobar/100.0.0/node_modules/foo'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/localhost+4873/foobar/100.0.0/node_modules/bar'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/foobar/100.0.0/node_modules/foo`))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/foobar/100.0.0/node_modules/bar`))).version, '100.0.0')
|
||||
|
||||
await Promise.all(pkgs.map((pkgName) => addDistTag(pkgName, '100.1.0', 'latest')))
|
||||
|
||||
@@ -362,8 +362,8 @@ test(`respects ${WANTED_LOCKFILE} for top dependencies`, async (t: tape.Test) =>
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules', 'foo'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules', 'bar'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules', 'qar'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/localhost+4873/foobar/100.0.0/node_modules/foo'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve('node_modules/.pnpm/localhost+4873/foobar/100.0.0/node_modules/bar'))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/foobar/100.0.0/node_modules/foo`))).version, '100.0.0')
|
||||
t.equal((await readPackageJsonFromDir(path.resolve(`node_modules/.pnpm/localhost+${REGISTRY_MOCK_PORT}/foobar/100.0.0/node_modules/bar`))).version, '100.0.0')
|
||||
})
|
||||
|
||||
test(`subdeps are updated on repeat install if outer ${WANTED_LOCKFILE} does not match the inner one`, async (t: tape.Test) => {
|
||||
@@ -479,8 +479,8 @@ test('scoped module from different registry', async (t: tape.Test) => {
|
||||
|
||||
const opts = await testDefaults()
|
||||
opts.registries!.default = 'https://registry.npmjs.org/' // tslint:disable-line
|
||||
opts.registries!['@zkochan'] = 'http://localhost:4873' // tslint:disable-line
|
||||
opts.registries!['@foo'] = 'http://localhost:4873' // tslint:disable-line
|
||||
opts.registries!['@zkochan'] = `http://localhost:${REGISTRY_MOCK_PORT}` // tslint:disable-line
|
||||
opts.registries!['@foo'] = `http://localhost:${REGISTRY_MOCK_PORT}` // tslint:disable-line
|
||||
await addDependenciesToPackage({}, ['@zkochan/foo', '@foo/has-dep-from-same-scope', 'is-positive'], opts)
|
||||
|
||||
await project.has('@zkochan/foo')
|
||||
@@ -742,7 +742,7 @@ test('lockfile is ignored when lockfile = false', async (t: tape.Test) => {
|
||||
'/is-negative/2.1.0': {
|
||||
resolution: {
|
||||
integrity: 'sha1-uZnX2TX0P1IHsBsA094ghS9Mp10=', // Invalid integrity
|
||||
tarball: 'http://localhost:4873/is-negative/-/is-negative-2.1.0.tgz',
|
||||
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-negative/-/is-negative-2.1.0.tgz`,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -833,7 +833,7 @@ test('packages installed via tarball URL from the default registry are normalize
|
||||
const project = prepareEmpty(t)
|
||||
|
||||
await addDependenciesToPackage({}, [
|
||||
'http://localhost:4873/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz',
|
||||
`http://localhost:${REGISTRY_MOCK_PORT}/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz`,
|
||||
'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
|
||||
], await testDefaults())
|
||||
|
||||
@@ -873,7 +873,7 @@ test('packages installed via tarball URL from the default registry are normalize
|
||||
},
|
||||
specifiers: {
|
||||
'is-positive': 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
|
||||
'pkg-with-tarball-dep-from-registry': 'http://localhost:4873/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz',
|
||||
'pkg-with-tarball-dep-from-registry': `http://localhost:${REGISTRY_MOCK_PORT}/pkg-with-tarball-dep-from-registry/-/pkg-with-tarball-dep-from-registry-1.0.0.tgz`,
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -1010,7 +1010,7 @@ test(`doing named installation when shared ${WANTED_LOCKFILE} exists already`, a
|
||||
packages: {
|
||||
'/is-negative/2.1.0': {
|
||||
resolution: {
|
||||
tarball: 'http://localhost:4873/is-negative/-/is-negative-2.1.0.tgz',
|
||||
tarball: `http://localhost:${REGISTRY_MOCK_PORT}/is-negative/-/is-negative-2.1.0.tgz`,
|
||||
},
|
||||
},
|
||||
'/is-positive/3.1.0': {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { PackageManifest } from '@pnpm/types'
|
||||
import ncpCB = require('ncp')
|
||||
import path = require('path')
|
||||
@@ -156,7 +157,7 @@ test('rebuild dependencies in correct order', async (t: tape.Test) => {
|
||||
t.ok(modules)
|
||||
t.doesNotEqual(modules!.pendingBuilds.length, 0)
|
||||
|
||||
await project.hasNot('.pnpm/localhost+4873/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json')
|
||||
await project.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json`)
|
||||
await project.hasNot('with-postinstall-a/output.json')
|
||||
|
||||
await rebuild([{ buildIndex: 0, manifest, prefix: process.cwd() }], await testDefaults({ rawConfig: { pending: true } }))
|
||||
@@ -165,7 +166,7 @@ test('rebuild dependencies in correct order', async (t: tape.Test) => {
|
||||
t.ok(modules)
|
||||
t.equal(modules!.pendingBuilds.length, 0)
|
||||
|
||||
t.ok(+project.requireModule('.pnpm/localhost+4873/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json')[0] < +project.requireModule('with-postinstall-a/output.json')[0])
|
||||
t.ok(+project.requireModule(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json`)[0] < +project.requireModule('with-postinstall-a/output.json')[0])
|
||||
})
|
||||
|
||||
test('rebuild dependencies in correct order when node_modules uses independent-leaves', async (t: tape.Test) => {
|
||||
@@ -177,7 +178,7 @@ test('rebuild dependencies in correct order when node_modules uses independent-l
|
||||
t.ok(modules)
|
||||
t.doesNotEqual(modules!.pendingBuilds.length, 0)
|
||||
|
||||
await project.hasNot('.pnpm/localhost+4873/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json')
|
||||
await project.hasNot(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json`)
|
||||
await project.hasNot('with-postinstall-a/output.json')
|
||||
|
||||
await rebuild([{ buildIndex: 0, manifest, prefix: process.cwd() }], await testDefaults({ rawConfig: { pending: true }, independentLeaves: true }))
|
||||
@@ -186,7 +187,7 @@ test('rebuild dependencies in correct order when node_modules uses independent-l
|
||||
t.ok(modules)
|
||||
t.equal(modules!.pendingBuilds.length, 0)
|
||||
|
||||
t.ok(+project.requireModule('.pnpm/localhost+4873/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json')[0] < +project.requireModule('with-postinstall-a/output.json')[0])
|
||||
t.ok(+project.requireModule(`.pnpm/localhost+${REGISTRY_MOCK_PORT}/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json`)[0] < +project.requireModule('with-postinstall-a/output.json')[0])
|
||||
})
|
||||
|
||||
test('rebuild multiple packages in correct order', async (t: tape.Test) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assertStore from '@pnpm/assert-store'
|
||||
import { tempDir } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import fs = require('fs')
|
||||
import loadJsonFile = require('load-json-file')
|
||||
import path = require('path')
|
||||
@@ -30,7 +31,7 @@ test('add packages to the store', async (t: tape.Test) => {
|
||||
t.deepEqual(
|
||||
storeIndex,
|
||||
{
|
||||
'localhost+4873/express/4.16.3': [],
|
||||
[`localhost+${REGISTRY_MOCK_PORT}/express/4.16.3`]: [],
|
||||
},
|
||||
'package has been added to the store index',
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import assertStore from '@pnpm/assert-store'
|
||||
import { Lockfile } from '@pnpm/lockfile-file'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import R = require('ramda')
|
||||
import sinon = require('sinon')
|
||||
@@ -36,7 +37,7 @@ test('remove unreferenced packages', async (t: tape.Test) => {
|
||||
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'info',
|
||||
message: '- localhost+4873/is-negative/2.1.0',
|
||||
message: `- localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
}))
|
||||
|
||||
await project.storeHasNot('is-negative', '2.1.0')
|
||||
@@ -46,7 +47,7 @@ test('remove unreferenced packages', async (t: tape.Test) => {
|
||||
|
||||
t.notOk(reporter.calledWithMatch({
|
||||
level: 'info',
|
||||
message: '- localhost+4873/is-negative/2.1.0',
|
||||
message: `- localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
}))
|
||||
})
|
||||
|
||||
@@ -66,7 +67,7 @@ test('remove packages that are used by project that no longer exist', async (t:
|
||||
|
||||
t.ok(reporter.calledWithMatch({
|
||||
level: 'info',
|
||||
message: '- localhost+4873/is-negative/2.1.0',
|
||||
message: `- localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
}))
|
||||
|
||||
await store.storeHasNot('is-negative', '2.1.0')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import assertStore from '@pnpm/assert-store'
|
||||
import { prepareEmpty } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import {
|
||||
addDependenciesToPackage,
|
||||
storeAdd,
|
||||
@@ -27,7 +28,7 @@ test('find usages for single package in store and in a project', async (t: tape.
|
||||
|
||||
const packageUsages = packageUsagesBySelectors['is-negative'][0]
|
||||
|
||||
t.equal(packageUsages.packageId, 'localhost+4873/is-negative/2.1.0', 'correct packageId found')
|
||||
t.equal(packageUsages.packageId, `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`, 'correct packageId found')
|
||||
t.equal(packageUsages.usages.length, 1, 'there should only be 1 usage be found')
|
||||
})
|
||||
|
||||
@@ -46,7 +47,7 @@ test('find usages for single package in store (by version) and in a project', as
|
||||
|
||||
const packageUsages = packageUsagesBySelectors['is-negative@2.1.0'][0]
|
||||
|
||||
t.equal(packageUsages.packageId, 'localhost+4873/is-negative/2.1.0', 'correct packageId found')
|
||||
t.equal(packageUsages.packageId, `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`, 'correct packageId found')
|
||||
t.equal(packageUsages.usages.length, 1, 'there should only be 1 usage be found')
|
||||
})
|
||||
|
||||
@@ -84,7 +85,7 @@ test('find usages of packages in store (multiple queries)', async (t: tape.Test)
|
||||
|
||||
const packageUsages = packageUsagesBySelectors['is-negative'][0]
|
||||
|
||||
t.equal(packageUsages.packageId, 'localhost+4873/is-negative/2.1.0', 'correct packageId found')
|
||||
t.equal(packageUsages.packageId, `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`, 'correct packageId found')
|
||||
t.equal(packageUsages.usages.length, 1, 'there should only be 1 usage be found')
|
||||
}
|
||||
|
||||
@@ -93,7 +94,7 @@ test('find usages of packages in store (multiple queries)', async (t: tape.Test)
|
||||
|
||||
const packageUsages = packageUsagesBySelectors['is-odd'][0]
|
||||
|
||||
t.equal(packageUsages.packageId, 'localhost+4873/is-odd/3.0.0', 'correct packageId found')
|
||||
t.equal(packageUsages.packageId, `localhost+${REGISTRY_MOCK_PORT}/is-odd/3.0.0`, 'correct packageId found')
|
||||
t.equal(packageUsages.usages.length, 1, 'there should only be 1 usage be found')
|
||||
}
|
||||
})
|
||||
@@ -122,7 +123,7 @@ test('find usages for package in store but not in any projects', async (t: tape.
|
||||
{
|
||||
'is-negative': [
|
||||
{
|
||||
packageId: 'localhost+4873/is-negative/2.1.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
usages: [],
|
||||
},
|
||||
],
|
||||
@@ -160,11 +161,11 @@ test('find usages for multiple packages in store but not in any projects', async
|
||||
{
|
||||
'is-negative': [
|
||||
{
|
||||
packageId: 'localhost+4873/is-negative/2.0.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.0.0`,
|
||||
usages: [],
|
||||
},
|
||||
{
|
||||
packageId: 'localhost+4873/is-negative/2.1.0',
|
||||
packageId: `localhost+${REGISTRY_MOCK_PORT}/is-negative/2.1.0`,
|
||||
usages: [],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
} from '@pnpm/core-loggers'
|
||||
import { Lockfile } from '@pnpm/lockfile-file'
|
||||
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { PackageManifest } from '@pnpm/types'
|
||||
import existsSymlink = require('exists-link')
|
||||
import ncpCB = require('ncp')
|
||||
@@ -134,7 +135,7 @@ test('uninstall tarball dependency', async (t: tape.Test) => {
|
||||
const project = prepareEmpty(t)
|
||||
const opts = await testDefaults({ save: true })
|
||||
|
||||
let manifest = await addDependenciesToPackage({}, ['http://localhost:4873/is-array/-/is-array-1.0.1.tgz'], opts)
|
||||
let manifest = await addDependenciesToPackage({}, [`http://localhost:${REGISTRY_MOCK_PORT}/is-array/-/is-array-1.0.1.tgz`], opts)
|
||||
manifest = (await mutateModules([
|
||||
{
|
||||
dependencyNames: ['is-array'],
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import RegClient = require('anonymous-npm-registry-client')
|
||||
|
||||
export async function add (packageName: string, version: string, distTag: string) {
|
||||
const client = new RegClient()
|
||||
|
||||
// just to make verdaccio cache the package
|
||||
await new Promise((resolve, reject) => client.distTags.fetch('http://localhost:4873', { package: packageName }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.fetch(`http://localhost:${REGISTRY_MOCK_PORT}`, { package: packageName }, (err: Error) => err ? reject(err) : resolve()))
|
||||
|
||||
// the tag has to be removed first because in verdaccio it is an array of versions
|
||||
await new Promise((resolve, reject) => client.distTags.rm('http://localhost:4873', { package: packageName, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.add('http://localhost:4873', { package: packageName, version, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.rm(`http://localhost:${REGISTRY_MOCK_PORT}`, { package: packageName, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
await new Promise((resolve, reject) => client.distTags.add(`http://localhost:${REGISTRY_MOCK_PORT}`, { package: packageName, version, distTag }, (err: Error) => err ? reject(err) : resolve()))
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import createFetcher from '@pnpm/default-fetcher'
|
||||
import createResolver from '@pnpm/default-resolver'
|
||||
import createStore from '@pnpm/package-store'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { StoreController } from '@pnpm/store-controller-types'
|
||||
import storePath from '@pnpm/store-path'
|
||||
import { Registries } from '@pnpm/types'
|
||||
import path = require('path')
|
||||
import { InstallOptions } from 'supi'
|
||||
|
||||
const registry = 'http://localhost:4873/'
|
||||
const registry = `http://localhost:${REGISTRY_MOCK_PORT}/`
|
||||
|
||||
const retryOpts = {
|
||||
fetchRetries: 4,
|
||||
|
||||
36
pnpm-lock.yaml
generated
36
pnpm-lock.yaml
generated
@@ -1,6 +1,7 @@
|
||||
importers:
|
||||
.:
|
||||
devDependencies:
|
||||
'@pnpm/registry-mock': 1.7.2
|
||||
'@pnpm/tsconfig': 'link:utils/tsconfig'
|
||||
'@pnpm/tslint-config': 'link:utils/tslint-config'
|
||||
'@types/node': 12.11.1
|
||||
@@ -12,6 +13,7 @@ importers:
|
||||
typescript: 3.7.1-rc
|
||||
verdaccio: 4.3.4
|
||||
specifiers:
|
||||
'@pnpm/registry-mock': 1.7.2
|
||||
'@pnpm/tsconfig': 'link:utils/tsconfig'
|
||||
'@pnpm/tslint-config': 'link:utils/tslint-config'
|
||||
'@types/node': '*'
|
||||
@@ -432,7 +434,6 @@ importers:
|
||||
'@pnpm/logger': 3.1.0
|
||||
'@pnpm/package-store': 'link:../package-store'
|
||||
'@pnpm/read-importers-context': 'link:../read-importers-context'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
'@pnpm/store-path': 2.1.1
|
||||
'@types/fs-extra': 8.0.1
|
||||
'@types/mz': 0.0.32
|
||||
@@ -476,7 +477,6 @@ importers:
|
||||
'@pnpm/read-importer-manifest': 'workspace:2.0.0'
|
||||
'@pnpm/read-importers-context': 'file:../read-importers-context'
|
||||
'@pnpm/read-package-json': 'workspace:3.0.0'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
'@pnpm/store-controller-types': 'workspace:4.0.0'
|
||||
'@pnpm/store-path': 2.1.1
|
||||
'@pnpm/symlink-dependency': 'workspace:3.0.0'
|
||||
@@ -868,7 +868,6 @@ importers:
|
||||
devDependencies:
|
||||
'@pnpm/logger': 3.1.0
|
||||
'@pnpm/outdated': 'link:'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
npm-run-all: 4.1.5
|
||||
tape: 4.11.0
|
||||
specifiers:
|
||||
@@ -877,7 +876,6 @@ importers:
|
||||
'@pnpm/lockfile-utils': 'workspace:2.0.0'
|
||||
'@pnpm/logger': 3.1.0
|
||||
'@pnpm/outdated': 'link:'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
'@pnpm/types': 'workspace:4.0.0'
|
||||
dependency-path: 'workspace:4.0.0'
|
||||
npm-run-all: 4.1.5
|
||||
@@ -1158,7 +1156,6 @@ importers:
|
||||
'@pnpm/modules-yaml': 'link:../modules-yaml'
|
||||
'@pnpm/prepare': 'link:../../privatePackages/prepare'
|
||||
'@pnpm/read-package-json': 'link:../read-package-json'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
'@pnpm/write-importer-manifest': 'link:../write-importer-manifest'
|
||||
'@types/byline': 4.2.31
|
||||
'@types/common-tags': 1.8.0
|
||||
@@ -1210,7 +1207,6 @@ importers:
|
||||
'@pnpm/prepare': 0.0.0
|
||||
'@pnpm/read-importer-manifest': 'workspace:2.0.0'
|
||||
'@pnpm/read-package-json': 'link:../read-package-json'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
'@pnpm/semver-diff': 1.0.2
|
||||
'@pnpm/server': 'workspace:4.0.0'
|
||||
'@pnpm/store-controller-types': 'workspace:4.0.0'
|
||||
@@ -1572,7 +1568,6 @@ importers:
|
||||
'@pnpm/logger': 3.1.0
|
||||
'@pnpm/package-store': 'link:../package-store'
|
||||
'@pnpm/prepare': 'link:../../privatePackages/prepare'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
'@pnpm/store-path': 2.1.1
|
||||
'@types/common-tags': 1.8.0
|
||||
'@types/fs-extra': 8.0.1
|
||||
@@ -1635,7 +1630,6 @@ importers:
|
||||
'@pnpm/read-importers-context': 'workspace:2.0.1'
|
||||
'@pnpm/read-modules-dir': 'workspace:2.0.1'
|
||||
'@pnpm/read-package-json': 'workspace:3.0.0'
|
||||
'@pnpm/registry-mock': 1.6.0
|
||||
'@pnpm/resolve-dependencies': 'workspace:10.0.0'
|
||||
'@pnpm/resolver-base': 'workspace:4.0.0'
|
||||
'@pnpm/store-controller-types': 'workspace:4.0.0'
|
||||
@@ -2272,7 +2266,7 @@ packages:
|
||||
node: '>=10'
|
||||
resolution:
|
||||
integrity: sha512-8PqdjPslNqoCcv15vivjG+Mzpwe2tDBnDDjhj7fIbY1CgsNWrM2F1k3f1T5V05CloJOnAsD4A2JTSuSNzkkxvA==
|
||||
/@pnpm/registry-mock/1.6.0:
|
||||
/@pnpm/registry-mock/1.7.2:
|
||||
dependencies:
|
||||
anonymous-npm-registry-client: 0.1.2
|
||||
cpr: 3.0.1
|
||||
@@ -2285,7 +2279,7 @@ packages:
|
||||
node: '>=8.15'
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-5y+IcXnFI6WTJfP0W/d/fTVal2p8AxxKAmrNz3QH81ArTzk1Gd7vOkczA1pvcm3NwQcB1zmTgStjGMcpsxb6mQ==
|
||||
integrity: sha512-Bh15Ra9uICAnLYqcyaM9UU7ZrFj9Zj0ho27MWB5cF9GEL4mUnRgr7TYTqxSPKkb5D/MptGVxue02iRZdtqEssA==
|
||||
/@pnpm/semver-diff/1.0.2:
|
||||
dev: false
|
||||
engines:
|
||||
@@ -2545,18 +2539,18 @@ packages:
|
||||
npm: '>=2.15.9'
|
||||
resolution:
|
||||
integrity: sha512-FncTOEL01a8yd6xOcNX1TQgc3pRYxByAI2OaAJHjGu5xxcGoqTo6RrIDU3ILdW2ypjc9Ow/xJLarUkr6zDhyfQ==
|
||||
/@verdaccio/file-locking/8.2.0:
|
||||
/@verdaccio/file-locking/8.3.0:
|
||||
dependencies:
|
||||
lockfile: 1.0.4
|
||||
dev: true
|
||||
engines:
|
||||
node: '>=8'
|
||||
resolution:
|
||||
integrity: sha512-s3gzuRWN2IgaEUPtwsnB24gRRVFaD26fbh+32RN7hcxlqCtZh8s7spKu5cFYCxtyoYkFVFxn3PsJcWkGaKda7Q==
|
||||
integrity: sha512-9kPaQ6HNeAhmkvW0sTj6qhLm2XjmIimUHSJR4w/uChL8f7niyx0wnXV6nMG10EsGjLYte9BG9rfDon4LynGuFQ==
|
||||
/@verdaccio/local-storage/8.2.0:
|
||||
dependencies:
|
||||
'@verdaccio/commons-api': 8.2.0
|
||||
'@verdaccio/file-locking': 8.2.0
|
||||
'@verdaccio/file-locking': 8.3.0
|
||||
'@verdaccio/streams': 8.2.0
|
||||
async: 3.1.0
|
||||
level: 5.0.1
|
||||
@@ -2805,7 +2799,7 @@ packages:
|
||||
/anonymous-npm-registry-client/0.1.2:
|
||||
dependencies:
|
||||
concat-stream: 1.6.2
|
||||
graceful-fs: 4.2.1
|
||||
graceful-fs: 4.2.3
|
||||
normalize-package-data: 2.5.0
|
||||
npm-package-arg: 4.2.1
|
||||
once: 1.4.0
|
||||
@@ -5078,7 +5072,7 @@ packages:
|
||||
array-union: 1.0.2
|
||||
dir-glob: 2.2.2
|
||||
fast-glob: 2.2.7
|
||||
glob: 7.1.4
|
||||
glob: 7.1.5
|
||||
ignore: 4.0.6
|
||||
pify: 4.0.1
|
||||
slash: 2.0.0
|
||||
@@ -5112,7 +5106,6 @@ packages:
|
||||
resolution:
|
||||
integrity: sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==
|
||||
/graceful-fs/4.2.3:
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==
|
||||
/graceful-git/2.0.0:
|
||||
@@ -5866,6 +5859,9 @@ packages:
|
||||
node: '>=8'
|
||||
peerDependencies:
|
||||
canvas: ^2.5.0
|
||||
peerDependenciesMeta:
|
||||
canvas:
|
||||
optional: true
|
||||
resolution:
|
||||
integrity: sha512-+hRyEfjRPFwTYMmSQ3/f7U9nP8ZNZmbkmUek760ZpxnCPWJIhaaLRuUSvpJ36fZKCGENxLwxClzwpOpnXNfChQ==
|
||||
/json-append/1.1.1:
|
||||
@@ -7735,7 +7731,7 @@ packages:
|
||||
integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==
|
||||
/read-yaml-file/1.1.0:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.2
|
||||
graceful-fs: 4.2.3
|
||||
js-yaml: 3.13.1
|
||||
pify: 4.0.1
|
||||
strip-bom: 3.0.0
|
||||
@@ -8046,7 +8042,7 @@ packages:
|
||||
integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==
|
||||
/rimraf/3.0.0:
|
||||
dependencies:
|
||||
glob: 7.1.4
|
||||
glob: 7.1.5
|
||||
hasBin: true
|
||||
resolution:
|
||||
integrity: sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg==
|
||||
@@ -9474,7 +9470,7 @@ packages:
|
||||
integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
|
||||
/write-file-atomic/2.4.3:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.2
|
||||
graceful-fs: 4.2.3
|
||||
imurmurhash: 0.1.4
|
||||
signal-exit: 3.0.2
|
||||
resolution:
|
||||
@@ -9525,7 +9521,7 @@ packages:
|
||||
integrity: sha512-v2UQ+50TNf2rNHJ8NyWttfm/EJUBWMJcx6ZTYZr6Qp52uuegWw/lBkCtCbnYZEmPRNL61m+u67dAmGxo+HTULA==
|
||||
/write-yaml-file/3.0.1:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.2
|
||||
graceful-fs: 4.2.3
|
||||
js-yaml: 3.13.1
|
||||
make-dir: 3.0.0
|
||||
pify: 4.0.1
|
||||
|
||||
@@ -2,6 +2,7 @@ import assertStore from '@pnpm/assert-store'
|
||||
import { WANTED_LOCKFILE } from '@pnpm/constants'
|
||||
import { Lockfile, LockfileImporter } from '@pnpm/lockfile-types'
|
||||
import { Modules, read as readModules } from '@pnpm/modules-yaml'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import path = require('path')
|
||||
import exists = require('path-exists')
|
||||
import readYamlFile from 'read-yaml-file'
|
||||
@@ -39,7 +40,7 @@ export interface Project {
|
||||
}
|
||||
|
||||
export default (t: Test, projectPath: string, encodedRegistryName?: string): Project => {
|
||||
const ern = encodedRegistryName || 'localhost+4873'
|
||||
const ern = encodedRegistryName || `localhost+${REGISTRY_MOCK_PORT}`
|
||||
const modules = path.join(projectPath, 'node_modules')
|
||||
|
||||
let cachedStore: {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import path = require('path')
|
||||
import exists = require('path-exists')
|
||||
import { Test } from 'tape'
|
||||
|
||||
export default (t: Test, storePath: string | Promise<string>, encodedRegistryName?: string) => {
|
||||
const ern = encodedRegistryName || 'localhost+4873'
|
||||
const ern = encodedRegistryName || `localhost+${REGISTRY_MOCK_PORT}`
|
||||
const store = {
|
||||
async storeHas (pkgName: string, version?: string): Promise<void> {
|
||||
const pathToCheck = await store.resolve(pkgName, version)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"typings/**/*.d.ts",
|
||||
"test/typings/**/*.d.ts"
|
||||
"../../typings/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
1
typings/typed.d.ts
vendored
1
typings/typed.d.ts
vendored
@@ -3,6 +3,7 @@
|
||||
declare module '@pnpm/registry-mock' {
|
||||
export function getIntegrity (pkgName: string, pkgVersion: string): string
|
||||
export function addDistTag (opts: {package: string, version: string, distTag: string}): Promise<void>
|
||||
export const REGISTRY_MOCK_PORT: string
|
||||
}
|
||||
|
||||
declare module 'cli-columns' {
|
||||
|
||||
Reference in New Issue
Block a user