mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
fix: install a pkg hosted not under registry domain
close #2586 PR #2588
This commit is contained in:
6
.changeset/cool-pugs-reply.md
Normal file
6
.changeset/cool-pugs-reply.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"supi": patch
|
||||
---
|
||||
|
||||
Fix a regression introduced in pnpm v5.0.0.
|
||||
Create correct lockfile when the package tarball is hosted not under the registry domain.
|
||||
@@ -103,6 +103,7 @@
|
||||
"is-ci": "2.0.0",
|
||||
"is-windows": "1.0.2",
|
||||
"ncp": "2.0.0",
|
||||
"nock": "^12.0.3",
|
||||
"npm-run-all": "4.1.5",
|
||||
"path-exists": "4.0.0",
|
||||
"path-name": "1.0.0",
|
||||
|
||||
@@ -18,7 +18,7 @@ export function depPathToRef (
|
||||
if (depPath.startsWith(`${registryName}/`) && !depPath.includes('/-/')) {
|
||||
depPath = depPath.replace(`${registryName}/`, '/')
|
||||
}
|
||||
if (opts.alias === opts.realName) {
|
||||
if (depPath[0] === '/' && opts.alias === opts.realName) {
|
||||
const ref = depPath.replace(`/${opts.realName}/`, '')
|
||||
if (!ref.includes('/')) return ref
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import { fromDir as readPackageJsonFromDir } from '@pnpm/read-package-json'
|
||||
import { getIntegrity, REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
import { ProjectManifest } from '@pnpm/types'
|
||||
import rimraf = require('@zkochan/rimraf')
|
||||
import loadJsonFile = require('load-json-file')
|
||||
import fs = require('mz/fs')
|
||||
import nock = require('nock')
|
||||
import path = require('path')
|
||||
import exists = require('path-exists')
|
||||
import R = require('ramda')
|
||||
@@ -1128,3 +1130,58 @@ test('broken lockfile is fixed even if it seems like up-to-date at first. Unless
|
||||
const lockfile = await project.readLockfile()
|
||||
t.ok(lockfile.packages['/dep-of-pkg-with-1-dep/100.0.0'])
|
||||
})
|
||||
|
||||
const REGISTRY_MIRROR_DIR = path.join(__dirname, '../../../registry-mirror')
|
||||
|
||||
// tslint:disable:no-any
|
||||
const isPositiveMeta = loadJsonFile.sync<any>(path.join(REGISTRY_MIRROR_DIR, 'is-positive.json'))
|
||||
// tslint:enable:no-any
|
||||
const tarballPath = path.join(REGISTRY_MIRROR_DIR, 'is-positive-3.1.0.tgz')
|
||||
|
||||
test('tarball domain differs from registry domain', async (t: tape.Test) => {
|
||||
nock('https://registry.example.com', { allowUnmocked: true })
|
||||
.get('/is-positive')
|
||||
.reply(200, isPositiveMeta)
|
||||
|
||||
nock('https://registry.npmjs.org', { allowUnmocked: true })
|
||||
.get('/is-positive/-/is-positive-3.1.0.tgz')
|
||||
.replyWithFile(200, tarballPath)
|
||||
|
||||
const project = prepareEmpty(t)
|
||||
|
||||
await addDependenciesToPackage({},
|
||||
[
|
||||
'is-positive',
|
||||
], await testDefaults({
|
||||
fastUnpack: false,
|
||||
lockfileOnly: true,
|
||||
registries: {
|
||||
default: 'https://registry.example.com',
|
||||
},
|
||||
save: true,
|
||||
})
|
||||
)
|
||||
|
||||
const lockfile = await project.readLockfile()
|
||||
|
||||
t.deepEqual(lockfile, {
|
||||
dependencies: {
|
||||
'is-positive': 'registry.npmjs.org/is-positive/3.1.0',
|
||||
},
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
packages: {
|
||||
'registry.npmjs.org/is-positive/3.1.0': {
|
||||
dev: false,
|
||||
engines: { node: '>=0.10.0' },
|
||||
name: 'is-positive',
|
||||
resolution: {
|
||||
integrity: 'sha1-hX21hKG6XRyymAUn/DtsQ103sP0=',
|
||||
registry: 'https://registry.example.com/',
|
||||
tarball: 'https://registry.npmjs.org/is-positive/-/is-positive-3.1.0.tgz',
|
||||
},
|
||||
version: '3.1.0',
|
||||
},
|
||||
},
|
||||
specifiers: { 'is-positive': '^3.1.0' },
|
||||
})
|
||||
})
|
||||
|
||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -2640,6 +2640,7 @@ importers:
|
||||
is-ci: 2.0.0
|
||||
is-windows: 1.0.2
|
||||
ncp: 2.0.0
|
||||
nock: 12.0.3
|
||||
npm-run-all: 4.1.5
|
||||
path-exists: 4.0.0
|
||||
path-name: 1.0.0
|
||||
@@ -2727,6 +2728,7 @@ importers:
|
||||
load-json-file: 6.2.0
|
||||
mz: 2.7.0
|
||||
ncp: 2.0.0
|
||||
nock: ^12.0.3
|
||||
normalize-path: 3.0.0
|
||||
npm-run-all: 4.1.5
|
||||
p-every: 2.0.0
|
||||
|
||||
BIN
registry-mirror/is-positive-3.1.0.tgz
Normal file
BIN
registry-mirror/is-positive-3.1.0.tgz
Normal file
Binary file not shown.
78
registry-mirror/is-positive.json
Normal file
78
registry-mirror/is-positive.json
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"versions": {
|
||||
"1.0.0": {
|
||||
"name": "is-positive",
|
||||
"version": "1.0.0",
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4"
|
||||
},
|
||||
"_hasShrinkwrap": false,
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-9cI+DmhNhA8ioT/3EJFnt0s1yehnAECyIOXdT+2uQGzcEEBaj8oNmVWj33+ZjPndMIFRQh8JeJlEu1uv5/J7pQ==",
|
||||
"shasum": "88009856b64a2f1eb7d8bb0179418424ae0452cb",
|
||||
"tarball": "https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"2.0.0": {
|
||||
"name": "is-positive",
|
||||
"version": "2.0.0",
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4"
|
||||
},
|
||||
"_hasShrinkwrap": false,
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-K+obMwRFQAMZb54Jia82SjPdOyBQ4UX8DSowwWCVhzwJOnAxZZ7UsAEI8sH2R6GhFI9efNeH3VGgOLPdzkMTaA==",
|
||||
"shasum": "b14f06bd2db810ae6c8b12741d136bfaef0d87bd",
|
||||
"tarball": "https://registry.npmjs.org/is-positive/-/is-positive-2.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"3.0.0": {
|
||||
"name": "is-positive",
|
||||
"version": "3.0.0",
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4"
|
||||
},
|
||||
"_hasShrinkwrap": false,
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-k1fsSAMxK5AjqPB45vXZrojz/UvY+BMSut1nrFBv5MM7uBIrncljDKEElsem5yEkFGxIiRpbCwgaMvny+85DsQ==",
|
||||
"shasum": "8ef0ee22f7ce24f7633f8908030ec48b62acf4a3",
|
||||
"tarball": "https://registry.npmjs.org/is-positive/-/is-positive-3.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"3.1.0": {
|
||||
"name": "is-positive",
|
||||
"version": "3.1.0",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"_hasShrinkwrap": false,
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "857db584a1ba5d1cb2980527fc3b6c435d37b0fd",
|
||||
"tarball": "https://registry.npmjs.org/is-positive/-/is-positive-3.1.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"name": "is-positive",
|
||||
"dist-tags": {
|
||||
"stable": "3.0.0",
|
||||
"latest": "3.1.0"
|
||||
},
|
||||
"modified": "2017-08-17T19:26:00.508Z"
|
||||
}
|
||||
Reference in New Issue
Block a user