From f4288ac2a35daa5bdc0e2bec7e89d1ecb8bf1ce0 Mon Sep 17 00:00:00 2001 From: Emanuele Tamponi Date: Thu, 22 Feb 2018 20:47:35 +0100 Subject: [PATCH] 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 --- package.json | 4 ++-- shrinkwrap.yaml | 17 +++++++++-------- src/cmd/help.ts | 11 ++++++++++- src/types.ts | 1 + test/install/index.ts | 1 + test/install/shamefullyFlatten.ts | 25 +++++++++++++++++++++++++ 6 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 test/install/shamefullyFlatten.ts diff --git a/package.json b/package.json index 161b763bc9..1aa947d6d6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/shrinkwrap.yaml b/shrinkwrap.yaml index 2fadcecb16..268c7b232f 100644 --- a/shrinkwrap.yaml +++ b/shrinkwrap.yaml @@ -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 diff --git a/src/cmd/help.ts b/src/cmd/help.ts index bc54993032..e526909bca 100644 --- a/src/cmd/help.ts +++ b/src/cmd/help.ts @@ -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': diff --git a/src/types.ts b/src/types.ts index 2e05b28040..b9b8c5de40 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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, diff --git a/test/install/index.ts b/test/install/index.ts index e39b662a8a..cb48375170 100644 --- a/test/install/index.ts +++ b/test/install/index.ts @@ -5,3 +5,4 @@ import './hooks' import './preferOffline' import './sideEffects' import './optional' +import './shamefullyFlatten' diff --git a/test/install/shamefullyFlatten.ts b/test/install/shamefullyFlatten.ts new file mode 100644 index 0000000000..ce7ec78c9c --- /dev/null +++ b/test/install/shamefullyFlatten.ts @@ -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') +})