diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2022-06-02 00:11:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 00:11:16 +0300 |
commit | aee6fc857458ac660bf90ecd0af94212c7269fd7 (patch) | |
tree | 464eec61f9a60ea2e97d76ffd04f6a886f6b1396 /tap-snapshots | |
parent | 66981ecf08b888fde9188c162cc928fff7d6d9d6 (diff) |
feat(init): reify on init new workspace (#4892)
Adds a minimalistic reify step that updates the installed tree after
initializing a new workspace.
Moved the shared update logic from `lib/commands/version.js` to a
`lib/workspaces/update-workspaces.js` module that is reused between
both `npm version` and `npm init`.
Relates to: https://github.com/npm/rfcs/issues/556
Relates to: https://github.com/npm/cli/pull/4588
Diffstat (limited to 'tap-snapshots')
-rw-r--r-- | tap-snapshots/test/lib/commands/init.js.test.cjs | 49 | ||||
-rw-r--r-- | tap-snapshots/test/lib/load-all-commands.js.test.cjs | 2 | ||||
-rw-r--r-- | tap-snapshots/test/lib/npm.js.test.cjs | 2 |
3 files changed, 40 insertions, 13 deletions
diff --git a/tap-snapshots/test/lib/commands/init.js.test.cjs b/tap-snapshots/test/lib/commands/init.js.test.cjs index 3ca9d9317..97a6722f3 100644 --- a/tap-snapshots/test/lib/commands/init.js.test.cjs +++ b/tap-snapshots/test/lib/commands/init.js.test.cjs @@ -10,26 +10,53 @@ Array [] ` exports[`test/lib/commands/init.js TAP workspaces no args > should print helper info 1`] = ` +Array [] +` + +exports[`test/lib/commands/init.js TAP workspaces no args, existing folder > should print helper info 1`] = ` +Array [] +` + +exports[`test/lib/commands/init.js TAP workspaces post workspace-init reify > should print helper info 1`] = ` Array [ Array [ String( - This utility will walk you through creating a package.json file. - It only covers the most common items, and tries to guess sensible defaults. - - See \`npm help init\` for definitive documentation on these fields - and exactly what they do. - - Use \`npm install <pkg>\` afterwards to install a package and - save it as a dependency in the package.json file. - Press ^C at any time to quit. + added 1 package in 100ms ), ], ] ` -exports[`test/lib/commands/init.js TAP workspaces no args, existing folder > should print helper info 1`] = ` -Array [] +exports[`test/lib/commands/init.js TAP workspaces post workspace-init reify > should reify tree on init ws complete 1`] = ` +{ + "name": "top-level", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "top-level", + "workspaces": [ + "a" + ] + }, + "a": { + "version": "1.0.0", + "license": "ISC", + "devDependencies": {} + }, + "node_modules/a": { + "resolved": "a", + "link": true + } + }, + "dependencies": { + "a": { + "version": "file:a" + } + } +} + ` exports[`test/lib/commands/init.js TAP workspaces with arg but missing workspace folder > should print helper info 1`] = ` diff --git a/tap-snapshots/test/lib/load-all-commands.js.test.cjs b/tap-snapshots/test/lib/load-all-commands.js.test.cjs index b8c274b08..7bcdd949b 100644 --- a/tap-snapshots/test/lib/load-all-commands.js.test.cjs +++ b/tap-snapshots/test/lib/load-all-commands.js.test.cjs @@ -396,7 +396,7 @@ npm init [<@scope>/]<name> (same as \`npx [<@scope>/]create-<name>\`) Options: [-y|--yes] [-f|--force] [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]] -[-ws|--workspaces] [--include-workspace-root] +[-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root] aliases: create, innit diff --git a/tap-snapshots/test/lib/npm.js.test.cjs b/tap-snapshots/test/lib/npm.js.test.cjs index e71bc8268..d15cae442 100644 --- a/tap-snapshots/test/lib/npm.js.test.cjs +++ b/tap-snapshots/test/lib/npm.js.test.cjs @@ -486,7 +486,7 @@ All commands: Options: [-y|--yes] [-f|--force] [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]] - [-ws|--workspaces] [--include-workspace-root] + [-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root] aliases: create, innit |