From ddc69abd9ffd7e5278fa2280d61ef0bc03b98098 Mon Sep 17 00:00:00 2001 From: zkochan Date: Sat, 4 Mar 2017 21:57:01 +0200 Subject: [PATCH] feat(shrinkwrap): respect shrinkwrap.yaml for top deps --- src/api/extendOptions.ts | 2 +- test/cache.ts | 19 ++++++++----------- test/cli.ts | 10 ++++------ test/install.ts | 10 ++++------ test/shrinkwrap.ts | 18 +++++++++++++++++- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/api/extendOptions.ts b/src/api/extendOptions.ts index e23b6fc62d..0cfb9c738b 100644 --- a/src/api/extendOptions.ts +++ b/src/api/extendOptions.ts @@ -22,7 +22,7 @@ const defaults = () => ({ 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, diff --git a/test/cache.ts b/test/cache.ts index 502888f26b..aec060386c 100644 --- a/test/cache.ts +++ b/test/cache.ts @@ -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') }) diff --git a/test/cli.ts b/test/cli.ts index 3fd89c011f..2d5a52dd7e 100644 --- a/test/cli.ts +++ b/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') }) diff --git a/test/install.ts b/test/install.ts index 631f933b40..92af465a1f 100644 --- a/test/install.ts +++ b/test/install.ts @@ -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') diff --git a/test/shrinkwrap.ts b/test/shrinkwrap.ts index 6a77cc3af7..e57ae86a37 100644 --- a/test/shrinkwrap.ts +++ b/test/shrinkwrap.ts @@ -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') +})