mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-24 18:11:39 -04:00
feat(shrinkwrap): respect shrinkwrap.yaml for top deps
This commit is contained in:
@@ -22,7 +22,7 @@ const defaults = () => (<StrictPnpmOptions>{
|
||||
cwd: process.cwd(),
|
||||
nodeVersion: process.version,
|
||||
force: false,
|
||||
depth: 0,
|
||||
depth: -1, // respect everything that is in shrinkwrap.yaml by default
|
||||
engineStrict: false,
|
||||
metaCache: new Map(),
|
||||
networkConcurrency: 16,
|
||||
|
||||
@@ -10,18 +10,17 @@ const test = promisifyTape(tape)
|
||||
test('should fail to update when requests are cached', async function (t) {
|
||||
const project = prepare(t)
|
||||
|
||||
const latest = 'stable'
|
||||
const metaCache = new Map()
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', latest)
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
|
||||
|
||||
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, tag: latest, metaCache}))
|
||||
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, metaCache}))
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', latest)
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
|
||||
|
||||
await install(testDefaults({depth: 1, tag: latest, metaCache}))
|
||||
await install(testDefaults({depth: 1, metaCache}))
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
|
||||
})
|
||||
@@ -29,17 +28,15 @@ test('should fail to update when requests are cached', async function (t) {
|
||||
test('should not cache when cache is not used', async function (t) {
|
||||
const project = prepare(t)
|
||||
|
||||
const latest = 'stable'
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', latest)
|
||||
|
||||
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, tag: latest}))
|
||||
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true}))
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', latest)
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
|
||||
|
||||
await install(testDefaults({depth: 1, tag: latest}))
|
||||
await install(testDefaults({depth: 1}))
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
|
||||
})
|
||||
|
||||
10
test/cli.ts
10
test/cli.ts
@@ -22,17 +22,15 @@ test('return error status code when underlying command fails', t => {
|
||||
test('update', async function (t) {
|
||||
const project = prepare(t)
|
||||
|
||||
const latest = 'stable'
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', latest)
|
||||
|
||||
await execPnpm('install', 'pkg-with-1-dep', '-S', '--tag', latest, '--cache-ttl', '0')
|
||||
await execPnpm('install', 'pkg-with-1-dep', '-S')
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', latest)
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
|
||||
|
||||
await execPnpm('update', '--depth', '1', '--tag', latest)
|
||||
await execPnpm('update', '--depth', '1')
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
|
||||
})
|
||||
|
||||
@@ -759,11 +759,9 @@ test('building native addons', async function (t) {
|
||||
test('should update subdep on second install', async function (t) {
|
||||
const project = prepare(t)
|
||||
|
||||
const latest = 'stable'
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', latest)
|
||||
|
||||
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true, tag: latest}))
|
||||
await installPkgs(['pkg-with-1-dep'], testDefaults({save: true}))
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
|
||||
|
||||
@@ -771,9 +769,9 @@ test('should update subdep on second install', async function (t) {
|
||||
|
||||
t.ok(shr.packages['localhost+4873/dep-of-pkg-with-1-dep/100.0.0'], 'shrinkwrap has resolution for package')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', latest)
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
|
||||
|
||||
await install(testDefaults({depth: 1, tag: latest}))
|
||||
await install(testDefaults({depth: 1}))
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import tape = require('tape')
|
||||
import promisifyTape from 'tape-promise'
|
||||
import writeYamlFile = require('write-yaml-file')
|
||||
import exists = require('path-exists')
|
||||
import {prepare, testDefaults} from './utils'
|
||||
import {prepare, testDefaults, addDistTag} from './utils'
|
||||
import {installPkgs, install} from '../src'
|
||||
|
||||
const test = promisifyTape(tape)
|
||||
@@ -84,3 +84,19 @@ test('shrinkwrap not created when no deps in package.json', async t => {
|
||||
|
||||
t.ok(!await project.loadShrinkwrap(), 'shrinkwrap file not created')
|
||||
})
|
||||
|
||||
test('respects shrinkwrap.yaml for top dependencies', async t => {
|
||||
const project = prepare(t)
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
|
||||
|
||||
await installPkgs(['dep-of-pkg-with-1-dep'], testDefaults({save: true}))
|
||||
|
||||
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
|
||||
|
||||
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
|
||||
|
||||
await install(testDefaults())
|
||||
|
||||
await project.storeHasNot('dep-of-pkg-with-1-dep', '100.1.0')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user