mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-24 18:11:39 -04:00
feat: no tarball paths in shrinkwrap.yaml for default registries
Ref #664, PR #666
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
"find-up": "2.1.0",
|
||||
"fs-write-stream-atomic": "1.0.10",
|
||||
"get-link-target": "1.0.0",
|
||||
"get-npm-tarball-url": "1.0.0",
|
||||
"global-bin-path": "0.1.1",
|
||||
"graceful-fs": "4.1.11",
|
||||
"is-ci": "1.0.10",
|
||||
|
||||
@@ -9,6 +9,8 @@ import resolve, {
|
||||
PackageMeta,
|
||||
} from '../resolve'
|
||||
import mkdirp = require('mkdirp-promise')
|
||||
import getNpmTarballUrl from 'get-npm-tarball-url'
|
||||
import registryUrl = require('registry-url')
|
||||
import readPkg from '../fs/readPkg'
|
||||
import exists = require('path-exists')
|
||||
import memoize, {MemoizedFunc} from '../memoize'
|
||||
@@ -69,6 +71,9 @@ export default async function fetch (
|
||||
if (resolveResult.package) {
|
||||
fetchingPkg = Promise.resolve(resolveResult.package)
|
||||
}
|
||||
} else if (resolution.type === undefined && resolution.tarball === undefined) {
|
||||
const parts = pkgId!.split('/')
|
||||
resolution.tarball = getNpmTarballUrl(parts[1], parts[2], {registry: registryUrl()})
|
||||
}
|
||||
|
||||
const id = <string>pkgId
|
||||
|
||||
@@ -211,7 +211,10 @@ async function install (
|
||||
|
||||
const shortId = pkgShortId(fetchedPkg.id, ctx.shrinkwrap.registry)
|
||||
ctx.shrinkwrap.packages[shortId] = ctx.shrinkwrap.packages[shortId] || {}
|
||||
ctx.shrinkwrap.packages[shortId].resolution = fetchedPkg.resolution
|
||||
ctx.shrinkwrap.packages[shortId].resolution = Object.assign({}, fetchedPkg.resolution)
|
||||
if (shortId.startsWith('/') && ctx.shrinkwrap.packages[shortId].resolution.type === undefined) {
|
||||
delete ctx.shrinkwrap.packages[shortId].resolution['tarball']
|
||||
}
|
||||
|
||||
const pkg = await fetchedPkg.fetchingPkg
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ test('shrinkwrap file has correct format', async t => {
|
||||
t.ok(shr.packages[id].dependencies, `has dependency resolutions for ${id}`)
|
||||
t.ok(shr.packages[id].dependencies['dep-of-pkg-with-1-dep'], `has dependency resolved for ${id}`)
|
||||
t.ok(shr.packages[id].resolution, `has resolution for ${id}`)
|
||||
t.equal(shr.packages[id].resolution.tarball, 'http://localhost:4873/pkg-with-1-dep/-/pkg-with-1-dep-100.0.0.tgz', `has tarball for ${id}`)
|
||||
t.ok(!shr.packages[id].resolution.tarball, `has no tarball for package in the default registry`)
|
||||
})
|
||||
|
||||
test('fail when shasum from shrinkwrap does not match with the actual one', async t => {
|
||||
|
||||
Reference in New Issue
Block a user