feat: add shamefully-flatten option (#1050)

* feat: add shamefully-flatten option

* feat: add --shamefully-flatten to help

* feat: --shamefully-flatten

* test: add simple test for --shamefully-flatten in pnpm

* fix: update supi
This commit is contained in:
Emanuele Tamponi
2018-02-22 20:47:35 +01:00
committed by Zoltan Kochan
parent 95f532b5c4
commit f4288ac2a3
6 changed files with 48 additions and 11 deletions

View File

@@ -20,7 +20,7 @@
"lib/"
],
"dependencies": {
"@pnpm/config": "^0.1.0",
"@pnpm/config": "^0.1.1",
"@pnpm/default-fetcher": "^0.4.0",
"@pnpm/default-resolver": "^0.1.3",
"@pnpm/logger": "^1.0.0",
@@ -61,7 +61,7 @@
"retry": "^0.10.1",
"signal-exit": "^3.0.2",
"strip-color": "^0.1.0",
"supi": "^0.12.9",
"supi": "^0.12.11",
"text-table": "^0.2.0",
"tree-kill": "^1.2.0",
"update-notifier": "^2.1.0",

View File

@@ -1,5 +1,5 @@
dependencies:
'@pnpm/config': 0.1.0
'@pnpm/config': 0.1.1
'@pnpm/default-fetcher': 0.4.0
'@pnpm/default-resolver': 0.1.3
'@pnpm/logger': 1.0.1
@@ -40,7 +40,7 @@ dependencies:
retry: 0.10.1
signal-exit: 3.0.2
strip-color: 0.1.0
supi: 0.12.9
supi: 0.12.11
text-table: 0.2.0
tree-kill: 1.2.0
update-notifier: 2.3.0
@@ -308,7 +308,7 @@ packages:
node: '>=4'
resolution:
integrity: sha512-rN+hiOjGtxwwus7c/E0xkCs9prBeXzZCSCW/Q3k2WdHGSRNLAepr777iv+i2eqTfz9vXlTF0rLZOGi62ujzwYA==
/@pnpm/config/0.1.0:
/@pnpm/config/0.1.1:
dependencies:
'@types/camelcase': 4.1.0
'@types/node': 9.4.6
@@ -318,7 +318,7 @@ packages:
engines:
node: '>=4'
resolution:
integrity: sha512-GQH+pQcmw4BQaK4W/n222pV87FgNvCsaqGoGORVkXG9kIYjZGiW8H2xGjOWdOkkj3GANU+F2O8iu97u9IlCqHA==
integrity: sha1-6anVVu5DkuF5OBnqAv2JFwNjkyY=
/@pnpm/default-fetcher/0.4.0:
dependencies:
'@pnpm/fetcher-base': 1.0.0
@@ -5582,7 +5582,7 @@ packages:
node: '>=0.10.0'
resolution:
integrity: sha1-PFMZQukIwml8DsNEhYwobHygpgo=
/supi/0.12.9:
/supi/0.12.11:
dependencies:
'@pnpm/check-package': 1.0.0
'@pnpm/fs-locker': 1.0.1
@@ -5638,6 +5638,7 @@ packages:
read-package-json: 2.0.12
remove-all-except-outer-links: 1.0.3
replace-string: 1.1.0
resolve-link-target: 1.0.1
rimraf-then: 1.0.1
semver: 5.5.0
symlink-dir: 1.1.2
@@ -5652,7 +5653,7 @@ packages:
peerDependencies:
'@pnpm/logger': ^1.0.0
resolution:
integrity: sha512-LElHPa9VBu/4WpaHMWSrTbQ7EBYXaPTrki4MFKfvM755cfhAwt79DHICDlcidOQluiKJGul8l1SZQ9XMQmiVag==
integrity: sha512-l1lp01kTexWUnv2VThfYBDIR5emDI/hkhTjTNOIr76nviBZeyUlYZZrJMQHp9XjimMcbBhQVzo41qItBLkagyA==
/supports-color/2.0.0:
engines:
node: '>=0.8.0'
@@ -6377,7 +6378,7 @@ specifiers:
'@commitlint/cli': ^4.0.0
'@commitlint/config-angular': ^4.2.0
'@commitlint/prompt-cli': ^5.0.0
'@pnpm/config': ^0.1.0
'@pnpm/config': ^0.1.1
'@pnpm/default-fetcher': ^0.4.0
'@pnpm/default-resolver': ^0.1.3
'@pnpm/logger': ^1.0.0
@@ -6451,7 +6452,7 @@ specifiers:
sepia: ^2.0.2
signal-exit: ^3.0.2
strip-color: ^0.1.0
supi: ^0.12.9
supi: ^0.12.11
tape: ^4.6.3
tape-promise: ^2.0.1
text-table: ^0.2.0

View File

@@ -60,6 +60,9 @@ function getHelpText (command: string) {
Experimental options:
--side-effects-cache use or cache the results of (pre/post)install hooks
--side-effects-cache-readonly only use the side effects cache if present, do not create it for new packages
Discouraged options:
--shamefully-flatten Attempt to flatten the dependency tree, similar to what npm does
`
case 'uninstall':
@@ -69,6 +72,9 @@ function getHelpText (command: string) {
Aliases: remove, rm, r, un, unlink
Removes packages from \`node_modules\` and from the project's \`packages.json\`
Discouraged options:
--shamefully-flatten Attempt to flatten the dependency tree, similar to what npm does
`
case 'link':
@@ -99,6 +105,9 @@ function getHelpText (command: string) {
-g, --global update globally installed packages
--depth how deep should levels of dependencies be inspected
0 is default, which means top-level dependencies
Discouraged options:
--shamefully-flatten Attempt to flatten the dependency tree, similar to what npm does
`
case 'list':
@@ -152,7 +161,7 @@ function getHelpText (command: string) {
It is good to keep unreferenced packages in the store for a while because frequently unreferenced packages are again needed
very soon. For instance, after changing branch on a project and installing from an older shrinkwrap file.
Prunning the store makes no harm. It only makes installation a bit slower in case the unreferenced files will be needed again.
Pruning the store makes no harm. It only makes installation a bit slower in case the unreferenced files will be needed again.
`
case 'root':

View File

@@ -65,6 +65,7 @@ export interface PnpmOptions {
ignorePnpmfile?: boolean,
independentLeaves?: boolean,
packageImportMethod?: 'auto' | 'hardlink' | 'copy' | 'reflink',
shamefullyFlatten?: boolean,
shrinkwrapOnly?: boolean, // like npm's --package-lock-only
useStoreServer?: boolean,

View File

@@ -5,3 +5,4 @@ import './hooks'
import './preferOffline'
import './sideEffects'
import './optional'
import './shamefullyFlatten'

View File

@@ -0,0 +1,25 @@
import tape = require('tape')
import promisifyTape from 'tape-promise'
import {
execPnpm,
prepare,
} from '../utils'
const test = promisifyTape(tape)
test('shamefully flatten the dependency tree', async function (t) {
const project = prepare(t)
await execPnpm('install', '--shamefully-flatten', 'express@4.16.2')
await project.has('express')
await project.has('debug')
await project.has('cookie')
await execPnpm('uninstall', '--shamefully-flatten', 'express')
await project.hasNot('express')
await project.hasNot('debug')
await project.hasNot('cookie')
})