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 f985dbb commit 809d9ff
Show file tree
Hide file tree
Showing 22 changed files with 119 additions and 40 deletions.
2 changes: 2 additions & 0 deletions docs/content/commands/npm-bin.md
Original file line number Diff line number Diff line change
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
9 changes: 9 additions & 0 deletions docs/content/commands/npm-config.md
Original file line number Diff line number Diff line change
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,13 @@ 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
43 changes: 26 additions & 17 deletions docs/content/using-npm/config.md
Original file line number Diff line number Diff line change
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,13 @@ 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 @@ -1928,6 +1918,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
5 changes: 4 additions & 1 deletion lib/commands/birthday.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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 () {
log.warn('birthday', 'birthday is deprecated, and will be removed in a future version.')
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
Original file line number Diff line number Diff line change
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
14 changes: 14 additions & 0 deletions lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
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,23 @@ 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
Original file line number Diff line number Diff line change
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
9 changes: 9 additions & 0 deletions tap-snapshots/test/lib/utils/config/definitions.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,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 @@ -1076,6 +1078,13 @@ 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
43 changes: 26 additions & 17 deletions tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs
Original file line number Diff line number Diff line change
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,13 @@ 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 @@ -1801,6 +1791,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 809d9ff

Please sign in to comment.