Skip to content

Commit 8898710

Browse files
committed
feat: deprecated set-script, birthday, --global, and --local
1 parent 8a49e3a commit 8898710

22 files changed

+127
-40
lines changed

docs/content/commands/npm-bin.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Print the folder where npm will install executables.
3434

3535
* Default: false
3636
* Type: Boolean
37+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
38+
instead.
3739

3840
Operates in "global" mode, so that packages are installed into the `prefix`
3941
folder instead of the current working directory. See

docs/content/commands/npm-config.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ Not supported by all npm commands.
124124
125125
* Default: false
126126
* Type: Boolean
127+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
128+
instead.
127129
128130
Operates in "global" mode, so that packages are installed into the `prefix`
129131
folder instead of the current working directory. See
@@ -156,6 +158,15 @@ The command to run for `npm edit` and `npm config edit`.
156158
157159
When passed to `npm config` this refers to which config file to use.
158160
161+
When set to "global" mode, packages are installed into the `prefix` folder
162+
instead of the current working directory. See
163+
[folders](/configuring-npm/folders) for more on the differences in behavior.
164+
165+
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
166+
of the current working directory.
167+
* bin files are linked to `{prefix}/bin`
168+
* man pages are linked to `{prefix}/share/man`
169+
159170
<!-- automatically generated, do not edit manually -->
160171
<!-- see lib/utils/config/definitions.js -->
161172

docs/content/commands/npm-diff.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ Treat all files as text in `npm diff`.
248248
249249
* Default: false
250250
* Type: Boolean
251+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
252+
instead.
251253
252254
Operates in "global" mode, so that packages are installed into the `prefix`
253255
folder instead of the current working directory. See

docs/content/commands/npm-install-test.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ rather than using npm's default semver range operator.
7070

7171
* Default: false
7272
* Type: Boolean
73+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
74+
instead.
7375

7476
Operates in "global" mode, so that packages are installed into the `prefix`
7577
folder instead of the current working directory. See

docs/content/commands/npm-install.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,8 @@ rather than using npm's default semver range operator.
460460
461461
* Default: false
462462
* Type: Boolean
463+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
464+
instead.
463465
464466
Operates in "global" mode, so that packages are installed into the `prefix`
465467
folder instead of the current working directory. See

docs/content/commands/npm-link.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ rather than using npm's default semver range operator.
153153

154154
* Default: false
155155
* Type: Boolean
156+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
157+
instead.
156158

157159
Operates in "global" mode, so that packages are installed into the `prefix`
158160
folder instead of the current working directory. See

docs/content/commands/npm-ls.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ Output parseable results from commands that write to standard output. For
137137

138138
* Default: false
139139
* Type: Boolean
140+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
141+
instead.
140142

141143
Operates in "global" mode, so that packages are installed into the `prefix`
142144
folder instead of the current working directory. See

docs/content/commands/npm-outdated.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ Output parseable results from commands that write to standard output. For
150150

151151
* Default: false
152152
* Type: Boolean
153+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
154+
instead.
153155

154156
Operates in "global" mode, so that packages are installed into the `prefix`
155157
folder instead of the current working directory. See

docs/content/commands/npm-prefix.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ npm prefix -g
5151

5252
* Default: false
5353
* Type: Boolean
54+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
55+
instead.
5456

5557
Operates in "global" mode, so that packages are installed into the `prefix`
5658
folder instead of the current working directory. See

docs/content/commands/npm-rebuild.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ will be rebuilt.
4242

4343
* Default: false
4444
* Type: Boolean
45+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
46+
instead.
4547

4648
Operates in "global" mode, so that packages are installed into the `prefix`
4749
folder instead of the current working directory. See

docs/content/commands/npm-root.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ echo "Global packages installed in: ${global_node_modules}"
4141

4242
* Default: false
4343
* Type: Boolean
44+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
45+
instead.
4446

4547
Operates in "global" mode, so that packages are installed into the `prefix`
4648
folder instead of the current working directory. See

docs/content/commands/npm-set-script.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ description: Set tasks in the scripts section of package.json
77
### Synopsis
88
An npm command that lets you create a task in the `scripts` section of the `package.json`.
99

10+
Deprecated.
11+
1012
<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
1113
<!-- automatically generated, do not edit manually -->
1214
<!-- see lib/commands/set-script.js -->

docs/content/commands/npm-update.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ Will also prevent writing to `package-lock.json` if set to `false`.
188188

189189
* Default: false
190190
* Type: Boolean
191+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
192+
instead.
191193

192194
Operates in "global" mode, so that packages are installed into the `prefix`
193195
folder instead of the current working directory. See

docs/content/using-npm/config.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -687,23 +687,6 @@ results in no commit being made at all.
687687
<!-- automatically generated, do not edit manually -->
688688
<!-- see lib/utils/config/definitions.js -->
689689

690-
#### `global`
691-
692-
* Default: false
693-
* Type: Boolean
694-
695-
Operates in "global" mode, so that packages are installed into the `prefix`
696-
folder instead of the current working directory. See
697-
[folders](/configuring-npm/folders) for more on the differences in behavior.
698-
699-
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
700-
of the current working directory.
701-
* bin files are linked to `{prefix}/bin`
702-
* man pages are linked to `{prefix}/share/man`
703-
704-
<!-- automatically generated, do not edit manually -->
705-
<!-- see lib/utils/config/definitions.js -->
706-
707690
#### `global-style`
708691

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

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

987+
When set to "global" mode, packages are installed into the `prefix` folder
988+
instead of the current working directory. See
989+
[folders](/configuring-npm/folders) for more on the differences in behavior.
990+
991+
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
992+
of the current working directory.
993+
* bin files are linked to `{prefix}/bin`
994+
* man pages are linked to `{prefix}/share/man`
995+
1004996
<!-- automatically generated, do not edit manually -->
1005997
<!-- see lib/utils/config/definitions.js -->
1006998

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

1936+
#### `global`
1937+
1938+
* Default: false
1939+
* Type: Boolean
1940+
* DEPRECATED: `--global`, `--local` are deprecated. Use `--location=global`
1941+
instead.
1942+
1943+
Operates in "global" mode, so that packages are installed into the `prefix`
1944+
folder instead of the current working directory. See
1945+
[folders](/configuring-npm/folders) for more on the differences in behavior.
1946+
1947+
* packages are installed into the `{prefix}/lib/node_modules` folder, instead
1948+
of the current working directory.
1949+
* bin files are linked to `{prefix}/bin`
1950+
* man pages are linked to `{prefix}/share/man`
1951+
1952+
<!-- automatically generated, do not edit manually -->
1953+
<!-- see lib/utils/config/definitions.js -->
1954+
19441955
#### `init.author.email`
19451956

19461957
* Default: ""

lib/commands/birthday.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
const BaseCommand = require('../base-command.js')
2+
const log = require('../utils/log-shim')
23

34
class Birthday extends BaseCommand {
45
static name = 'birthday'
5-
static description = 'Birthday'
6+
static description = 'Birthday, deprecated'
67
static ignoreImplicitWorkspace = true
78
static isShellout = true
89

910
async exec () {
1011
this.npm.config.set('yes', true)
12+
log.warn('birthday', 'birthday is deprecated and will be removed in a future release')
1113
return this.npm.exec('exec', ['@npmcli/npm-birthday'])
1214
}
1315
}

lib/commands/set-script.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const log = require('../utils/log-shim')
55

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

3535
async exec (args) {
3636
this.validate(args)
37+
log.warn('set-script',
38+
'set-script is deprecated, use `npm pkg set scripts.scriptname="cmd" instead.')
3739
const warn = await this.doSetScript(this.npm.localPrefix, args[0], args[1])
3840
if (warn) {
3941
log.warn('set-script', `Script "${args[0]}" was overwritten`)

lib/utils/config/definitions.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,9 @@ define('global', {
811811
default: false,
812812
type: Boolean,
813813
short: 'g',
814+
deprecated: `
815+
\`--global\`, \`--local\` are deprecated. Use \`--location=global\` instead.
816+
`,
814817
description: `
815818
Operates in "global" mode, so that packages are installed into the
816819
\`prefix\` folder instead of the current working directory. See
@@ -1179,12 +1182,24 @@ define('location', {
11791182
`,
11801183
description: `
11811184
When passed to \`npm config\` this refers to which config file to use.
1185+
1186+
When set to "global" mode, packages are installed into the \`prefix\` folder
1187+
instead of the current working directory. See
1188+
[folders](/configuring-npm/folders) for more on the differences in behavior.
1189+
1190+
* packages are installed into the \`{prefix}/lib/node_modules\` folder,
1191+
instead of the current working directory.
1192+
* bin files are linked to \`{prefix}/bin\`
1193+
* man pages are linked to \`{prefix}/share/man\`
11821194
`,
11831195
flatten: (key, obj, flatOptions) => {
11841196
flatten(key, obj, flatOptions)
11851197
if (flatOptions.global) {
11861198
flatOptions.location = 'global'
11871199
}
1200+
if (obj.location === 'global') {
1201+
flatOptions.global = true
1202+
}
11881203
},
11891204
})
11901205

tap-snapshots/test/lib/load-all-commands.js.test.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Run "npm help bin" for more info
6969
`
7070

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

804804
exports[`test/lib/load-all-commands.js TAP load each command set-script > must match snapshot 1`] = `
805-
Set tasks in the scripts section of package.json
805+
Set tasks in the scripts section of package.json, deprecated
806806
807807
Usage:
808808
npm set-script [<script>] [<command>]

tap-snapshots/test/lib/utils/config/definitions.js.test.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for globa
731731
732732
* Default: false
733733
* Type: Boolean
734+
* DEPRECATED: \`--global\`, \`--local\` are deprecated. Use \`--location=global\`
735+
instead.
734736
735737
Operates in "global" mode, so that packages are installed into the \`prefix\`
736738
folder instead of the current working directory. See
@@ -1077,6 +1079,15 @@ exports[`test/lib/utils/config/definitions.js TAP > config description for locat
10771079
* Type: "global", "user", or "project"
10781080
10791081
When passed to \`npm config\` this refers to which config file to use.
1082+
1083+
When set to "global" mode, packages are installed into the \`prefix\` folder
1084+
instead of the current working directory. See
1085+
[folders](/configuring-npm/folders) for more on the differences in behavior.
1086+
1087+
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
1088+
of the current working directory.
1089+
* bin files are linked to \`{prefix}/bin\`
1090+
* man pages are linked to \`{prefix}/share/man\`
10801091
`
10811092

10821093
exports[`test/lib/utils/config/definitions.js TAP > config description for lockfile-version 1`] = `

tap-snapshots/test/lib/utils/config/describe-all.js.test.cjs

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -560,23 +560,6 @@ results in no commit being made at all.
560560
<!-- automatically generated, do not edit manually -->
561561
<!-- see lib/utils/config/definitions.js -->
562562
563-
#### \`global\`
564-
565-
* Default: false
566-
* Type: Boolean
567-
568-
Operates in "global" mode, so that packages are installed into the \`prefix\`
569-
folder instead of the current working directory. See
570-
[folders](/configuring-npm/folders) for more on the differences in behavior.
571-
572-
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
573-
of the current working directory.
574-
* bin files are linked to \`{prefix}/bin\`
575-
* man pages are linked to \`{prefix}/share/man\`
576-
577-
<!-- automatically generated, do not edit manually -->
578-
<!-- see lib/utils/config/definitions.js -->
579-
580563
#### \`global-style\`
581564
582565
* Default: false
@@ -874,6 +857,15 @@ npm registry. Must be IPv4 in versions of Node prior to 0.12.
874857
875858
When passed to \`npm config\` this refers to which config file to use.
876859
860+
When set to "global" mode, packages are installed into the \`prefix\` folder
861+
instead of the current working directory. See
862+
[folders](/configuring-npm/folders) for more on the differences in behavior.
863+
864+
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
865+
of the current working directory.
866+
* bin files are linked to \`{prefix}/bin\`
867+
* man pages are linked to \`{prefix}/share/man\`
868+
877869
<!-- automatically generated, do not edit manually -->
878870
<!-- see lib/utils/config/definitions.js -->
879871
@@ -1814,6 +1806,25 @@ Alias for \`--include=dev\`.
18141806
<!-- automatically generated, do not edit manually -->
18151807
<!-- see lib/utils/config/definitions.js -->
18161808
1809+
#### \`global\`
1810+
1811+
* Default: false
1812+
* Type: Boolean
1813+
* DEPRECATED: \`--global\`, \`--local\` are deprecated. Use \`--location=global\`
1814+
instead.
1815+
1816+
Operates in "global" mode, so that packages are installed into the \`prefix\`
1817+
folder instead of the current working directory. See
1818+
[folders](/configuring-npm/folders) for more on the differences in behavior.
1819+
1820+
* packages are installed into the \`{prefix}/lib/node_modules\` folder, instead
1821+
of the current working directory.
1822+
* bin files are linked to \`{prefix}/bin\`
1823+
* man pages are linked to \`{prefix}/share/man\`
1824+
1825+
<!-- automatically generated, do not edit manually -->
1826+
<!-- see lib/utils/config/definitions.js -->
1827+
18171828
#### \`init.author.email\`
18181829
18191830
* Default: ""

tap-snapshots/test/lib/utils/npm-usage.js.test.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ All commands:
840840
841841
Run "npm help set" for more info
842842
843-
set-script Set tasks in the scripts section of package.json
843+
set-script Set tasks in the scripts section of package.json, deprecated
844844
845845
Usage:
846846
npm set-script [<script>] [<command>]

test/lib/commands/set-script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ t.test('warns when overwriting', async t => {
130130
})
131131

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

136136
t.test('workspaces', async t => {

0 commit comments

Comments
 (0)