Skip to content

Commit

Permalink
feat: deprecated set-script, birthday, --global, and --local
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzy committed May 18, 2022
1 parent 8a49e3a commit 8898710
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 40 deletions.
2 changes: 2 additions & 0 deletions docs/content/commands/npm-bin.md
Expand Up @@ -34,6 +34,8 @@ Print the folder where npm will install executables.

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
11 changes: 11 additions & 0 deletions docs/content/commands/npm-config.md
Expand Up @@ -124,6 +124,8 @@ Not supported by all npm commands.
* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.
Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down Expand Up @@ -156,6 +158,15 @@ The command to run for `npm edit` and `npm config edit`.
When passed to `npm config` this refers to which config file to use.
When set to "global" mode, packages are installed into the `prefix` folder
instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
of the current working directory.
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-diff.md
Expand Up @@ -248,6 +248,8 @@ Treat all files as text in `npm diff`.
* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.
Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-install-test.md
Expand Up @@ -70,6 +70,8 @@ rather than using npm's default semver range operator.

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-install.md
Expand Up @@ -460,6 +460,8 @@ rather than using npm's default semver range operator.
* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.
Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-link.md
Expand Up @@ -153,6 +153,8 @@ rather than using npm's default semver range operator.

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-ls.md
Expand Up @@ -137,6 +137,8 @@ Output parseable results from commands that write to standard output. For

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-outdated.md
Expand Up @@ -150,6 +150,8 @@ Output parseable results from commands that write to standard output. For

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-prefix.md
Expand Up @@ -51,6 +51,8 @@ npm prefix -g

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-rebuild.md
Expand Up @@ -42,6 +42,8 @@ will be rebuilt.

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-root.md
Expand Up @@ -41,6 +41,8 @@ echo "Global packages installed in: ${global_node_modules}"

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-set-script.md
Expand Up @@ -7,6 +7,8 @@ description: Set tasks in the scripts section of package.json
### Synopsis
An npm command that lets you create a task in the `scripts` section of the `package.json`.

Deprecated.

<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
<!-- automatically generated, do not edit manually -->
<!-- see lib/commands/set-script.js -->
Expand Down
2 changes: 2 additions & 0 deletions docs/content/commands/npm-update.md
Expand Up @@ -188,6 +188,8 @@ Will also prevent writing to `package-lock.json` if set to `false`.

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
Expand Down
45 changes: 28 additions & 17 deletions docs/content/using-npm/config.md
Expand Up @@ -687,23 +687,6 @@ results in no commit being made at all.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

#### `global`

* Default: false
* Type: Boolean

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.

* packages are installed into the `{prefix}/lib/node_modules` folder, instead
of the current working directory.
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`

<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

#### `global-style`

* Default: false
Expand Down Expand Up @@ -1001,6 +984,15 @@ npm registry. Must be IPv4 in versions of Node prior to 0.12.

When passed to `npm config` this refers to which config file to use.

When set to "global" mode, packages are installed into the `prefix` folder
instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.

* packages are installed into the `{prefix}/lib/node_modules` folder, instead
of the current working directory.
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`

<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

Expand Down Expand Up @@ -1941,6 +1933,25 @@ Alias for `--include=dev`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

#### `global`

* Default: false
* Type: Boolean
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
instead.

Operates in "global" mode, so that packages are installed into the `prefix`
folder instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.

* packages are installed into the `{prefix}/lib/node_modules` folder, instead
of the current working directory.
* bin files are linked to `{prefix}/bin`
* man pages are linked to `{prefix}/share/man`

<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->

#### `init.author.email`

* Default: ""
Expand Down
4 changes: 3 additions & 1 deletion lib/commands/birthday.js
@@ -1,13 +1,15 @@
const BaseCommand = require('../base-command.js')
const log = require('../utils/log-shim')

class Birthday extends BaseCommand {
static name = 'birthday'
static description = 'Birthday'
static description = 'Birthday, deprecated'
static ignoreImplicitWorkspace = true
static isShellout = true

async exec () {
this.npm.config.set('yes', true)
log.warn('birthday', 'birthday is deprecated and will be removed in a future release')
return this.npm.exec('exec', ['@npmcli/npm-birthday'])
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/commands/set-script.js
Expand Up @@ -5,7 +5,7 @@ const log = require('../utils/log-shim')

const BaseCommand = require('../base-command.js')
class SetScript extends BaseCommand {
static description = 'Set tasks in the scripts section of package.json'
static description = 'Set tasks in the scripts section of package.json, deprecated'
static params = ['workspace', 'workspaces', 'include-workspace-root']
static name = 'set-script'
static usage = ['[<script>] [<command>]']
Expand Down Expand Up @@ -34,6 +34,8 @@ class SetScript extends BaseCommand {

async exec (args) {
this.validate(args)
log.warn('set-script',
'set-script is deprecated, use `npm pkg set scripts.scriptname="cmd" instead.')
const warn = await this.doSetScript(this.npm.localPrefix, args[0], args[1])
if (warn) {
log.warn('set-script', `Script "${args[0]}" was overwritten`)
Expand Down
15 changes: 15 additions & 0 deletions lib/utils/config/definitions.js
Expand Up @@ -811,6 +811,9 @@ define('global', {
default: false,
type: Boolean,
short: 'g',
deprecated: `
\`--global\`, \`--local\` are deprecated. Use \`--location=global\` instead.
`,
description: `
Operates in "global" mode, so that packages are installed into the
\`prefix\` folder instead of the current working directory. See
Expand Down Expand Up @@ -1179,12 +1182,24 @@ define('location', {
`,
description: `
When passed to \`npm config\` this refers to which config file to use.
When set to "global" mode, packages are installed into the \`prefix\` folder
instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.
* packages are installed into the \`{prefix}/lib/node_modules\` folder,
instead of the current working directory.
* bin files are linked to \`{prefix}/bin\`
* man pages are linked to \`{prefix}/share/man\`
`,
flatten: (key, obj, flatOptions) => {
flatten(key, obj, flatOptions)
if (flatOptions.global) {
flatOptions.location = 'global'
}
if (obj.location === 'global') {
flatOptions.global = true
}
},
})

Expand Down
4 changes: 2 additions & 2 deletions tap-snapshots/test/lib/load-all-commands.js.test.cjs
Expand Up @@ -69,7 +69,7 @@ Run "npm help bin" for more info
`

exports[`test/lib/load-all-commands.js TAP load each command birthday > must match snapshot 1`] = `
Birthday
Birthday, deprecated
Usage:
npm birthday
Expand Down Expand Up @@ -802,7 +802,7 @@ Run "npm help set" for more info
`

exports[`test/lib/load-all-commands.js TAP load each command set-script > must match snapshot 1`] = `
Set tasks in the scripts section of package.json
Set tasks in the scripts section of package.json, deprecated
Usage:
npm set-script [<script>] [<command>]
Expand Down
11 changes: 11 additions & 0 deletions tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
Expand Up @@ -731,6 +731,8 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for globa
* Default: false
* Type: Boolean
* DEPRECATED: \`--global\`, \`--local\` are deprecated. Use \`--location=global\`
instead.
Operates in "global" mode, so that packages are installed into the \`prefix\`
folder instead of the current working directory. See
Expand Down Expand Up @@ -1077,6 +1079,15 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for locat
* Type: "global", "user", or "project"
When passed to \`npm config\` this refers to which config file to use.
When set to "global" mode, packages are installed into the \`prefix\` folder
instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
of the current working directory.
* bin files are linked to \`{prefix}/bin\`
* man pages are linked to \`{prefix}/share/man\`
`

exports[`test/lib/utils/config/definitions.js TAP > config description for lockfile-version 1`] = `
Expand Down
45 changes: 28 additions & 17 deletions tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
Expand Up @@ -560,23 +560,6 @@ results in no commit being made at all.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### \`global\`
* Default: false
* Type: Boolean
Operates in "global" mode, so that packages are installed into the \`prefix\`
folder instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
of the current working directory.
* bin files are linked to \`{prefix}/bin\`
* man pages are linked to \`{prefix}/share/man\`
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### \`global-style\`
* Default: false
Expand Down Expand Up @@ -874,6 +857,15 @@ npm registry. Must be IPv4 in versions of Node prior to 0.12.
When passed to \`npm config\` this refers to which config file to use.
When set to "global" mode, packages are installed into the \`prefix\` folder
instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
of the current working directory.
* bin files are linked to \`{prefix}/bin\`
* man pages are linked to \`{prefix}/share/man\`
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
Expand Down Expand Up @@ -1814,6 +1806,25 @@ Alias for \`--include=dev\`.
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### \`global\`
* Default: false
* Type: Boolean
* DEPRECATED: \`--global\`, \`--local\` are deprecated. Use \`--location=global\`
instead.
Operates in "global" mode, so that packages are installed into the \`prefix\`
folder instead of the current working directory. See
[folders](/configuring-npm/folders) for more on the differences in behavior.
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
of the current working directory.
* bin files are linked to \`{prefix}/bin\`
* man pages are linked to \`{prefix}/share/man\`
<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
#### \`init.author.email\`
* Default: ""
Expand Down
2 changes: 1 addition & 1 deletion tap-snapshots/test/lib/utils/npm-usage.js.test.cjs
Expand Up @@ -840,7 +840,7 @@ All commands:
Run "npm help set" for more info
set-script Set tasks in the scripts section of package.json
set-script Set tasks in the scripts section of package.json, deprecated
Usage:
npm set-script [<script>] [<command>]
Expand Down
2 changes: 1 addition & 1 deletion test/lib/commands/set-script.js
Expand Up @@ -130,7 +130,7 @@ t.test('warns when overwriting', async t => {
})

await setScript.exec(['arg1', 'arg2'])
t.hasStrict(WARN_OUTPUT[0], ['set-script', 'Script "arg1" was overwritten'], 'warning was logged')
t.hasStrict(WARN_OUTPUT[1], ['set-script', 'Script "arg1" was overwritten'], 'warning was logged')
})

t.test('workspaces', async t => {
Expand Down

0 comments on commit 8898710

Please sign in to comment.