-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathpublish.js.test.cjs
More file actions
476 lines (443 loc) · 13.3 KB
/
publish.js.test.cjs
File metadata and controls
476 lines (443 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
/* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/lib/commands/publish.js TAP _auth config default registry > new package version 1`] = `
+ @npmcli/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP bare _auth and registry config > new package version 1`] = `
+ @npm/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP dry-run > must match snapshot 1`] = `
Array [
"package: @npmcli/test-package@1.0.0",
"Tarball Contents",
"95B package.json",
"Tarball Details",
"name: @npmcli/test-package",
"version: 1.0.0",
"filename: npmcli-test-package-1.0.0.tgz",
"package size: {size}",
"unpacked size: 95 B",
"shasum: {sha}",
"integrity: {integrity}
"total files: 1",
"Publishing to https://registry.npmjs.org/ with tag latest and default access (dry-run)",
]
`
exports[`test/lib/commands/publish.js TAP foreground-scripts can still be set to false > must match snapshot 1`] = `
Array [
"package: test-fg-scripts@0.0.0",
"Tarball Contents",
"110B package.json",
"Tarball Details",
"name: test-fg-scripts",
"version: 0.0.0",
"filename: test-fg-scripts-0.0.0.tgz",
"package size: {size}",
"unpacked size: 110 B",
"shasum: {sha}",
"integrity: {integrity}
"total files: 1",
"Publishing to https://registry.npmjs.org/ with tag latest and default access (dry-run)",
]
`
exports[`test/lib/commands/publish.js TAP foreground-scripts defaults to true > must match snapshot 1`] = `
Array [
"package: test-fg-scripts@0.0.0",
"Tarball Contents",
"110B package.json",
"Tarball Details",
"name: test-fg-scripts",
"version: 0.0.0",
"filename: test-fg-scripts-0.0.0.tgz",
"package size: {size}",
"unpacked size: 110 B",
"shasum: {sha}",
"integrity: {integrity}
"total files: 1",
"Publishing to https://registry.npmjs.org/ with tag latest and default access (dry-run)",
]
`
exports[`test/lib/commands/publish.js TAP has mTLS auth for scope configured registry > new package version 1`] = `
+ @npm/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP has token auth for scope configured registry > new package version 1`] = `
+ @npm/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP ignore-scripts > new package version 1`] = `
+ @npmcli/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP json > must match snapshot 1`] = `
Array [
"Publishing to https://registry.npmjs.org/ with tag latest and default access",
]
`
exports[`test/lib/commands/publish.js TAP json > new package json 1`] = `
{
"id": "@npmcli/test-package@1.0.0",
"name": "@npmcli/test-package",
"version": "1.0.0",
"size": "{size}",
"unpackedSize": 95,
"shasum": "{sha}",
"integrity": "{integrity}",
"filename": "npmcli-test-package-1.0.0.tgz",
"files": [
{
"path": "package.json",
"size": "{size}",
"mode": 420
}
],
"entryCount": 1,
"bundled": []
}
`
exports[`test/lib/commands/publish.js TAP manifest > manifest 1`] = `
Object {
"_id": "npm@{VERSION}",
"author": Object {
"name": "GitHub Inc.",
},
"bin": Object {
"npm": "bin/npm-cli.js",
"npx": "bin/npx-cli.js",
},
"bugs": Object {
"url": "https://github.com/npm/cli/issues",
},
"description": "a package manager for JavaScript",
"directories": Object {
"doc": "./doc",
"man": "./man",
},
"exports": Object {
".": Array [
Object {
"default": "./index.js",
},
"./index.js",
],
"./package.json": "./package.json",
},
"files": Array [
"bin/",
"lib/",
"index.js",
"docs/content/",
"docs/output/",
"man/",
],
"homepage": "https://docs.npmjs.com/",
"keywords": Array [
"install",
"modules",
"package manager",
"package.json",
],
"license": "Artistic-2.0",
"main": "./index.js",
"man": Array [
"man/man1/npm-access.1",
"man/man1/npm-audit.1",
"man/man1/npm-bugs.1",
"man/man1/npm-cache.1",
"man/man1/npm-ci.1",
"man/man1/npm-completion.1",
"man/man1/npm-config.1",
"man/man1/npm-dedupe.1",
"man/man1/npm-deprecate.1",
"man/man1/npm-diff.1",
"man/man1/npm-dist-tag.1",
"man/man1/npm-docs.1",
"man/man1/npm-doctor.1",
"man/man1/npm-edit.1",
"man/man1/npm-exec.1",
"man/man1/npm-explain.1",
"man/man1/npm-explore.1",
"man/man1/npm-find-dupes.1",
"man/man1/npm-fund.1",
"man/man1/npm-get.1",
"man/man1/npm-help-search.1",
"man/man1/npm-help.1",
"man/man1/npm-init.1",
"man/man1/npm-install-ci-test.1",
"man/man1/npm-install-test.1",
"man/man1/npm-install.1",
"man/man1/npm-link.1",
"man/man1/npm-ll.1",
"man/man1/npm-login.1",
"man/man1/npm-logout.1",
"man/man1/npm-ls.1",
"man/man1/npm-org.1",
"man/man1/npm-outdated.1",
"man/man1/npm-owner.1",
"man/man1/npm-pack.1",
"man/man1/npm-ping.1",
"man/man1/npm-pkg.1",
"man/man1/npm-prefix.1",
"man/man1/npm-profile.1",
"man/man1/npm-prune.1",
"man/man1/npm-publish.1",
"man/man1/npm-query.1",
"man/man1/npm-rebuild.1",
"man/man1/npm-repo.1",
"man/man1/npm-restart.1",
"man/man1/npm-root.1",
"man/man1/npm-run.1",
"man/man1/npm-sbom.1",
"man/man1/npm-search.1",
"man/man1/npm-set.1",
"man/man1/npm-shrinkwrap.1",
"man/man1/npm-star.1",
"man/man1/npm-stars.1",
"man/man1/npm-start.1",
"man/man1/npm-stop.1",
"man/man1/npm-team.1",
"man/man1/npm-test.1",
"man/man1/npm-token.1",
"man/man1/npm-trust.1",
"man/man1/npm-undeprecate.1",
"man/man1/npm-uninstall.1",
"man/man1/npm-unpublish.1",
"man/man1/npm-unstar.1",
"man/man1/npm-update.1",
"man/man1/npm-version.1",
"man/man1/npm-view.1",
"man/man1/npm-whoami.1",
"man/man1/npm.1",
"man/man1/npx.1",
"man/man5/folders.5",
"man/man5/install.5",
"man/man5/npm-global.5",
"man/man5/npm-json.5",
"man/man5/npm-shrinkwrap-json.5",
"man/man5/npmrc.5",
"man/man5/package-json.5",
"man/man5/package-lock-json.5",
"man/man7/config.7",
"man/man7/dependency-selectors.7",
"man/man7/developers.7",
"man/man7/logging.7",
"man/man7/orgs.7",
"man/man7/package-spec.7",
"man/man7/registry.7",
"man/man7/removal.7",
"man/man7/scope.7",
"man/man7/scripts.7",
"man/man7/workspaces.7",
],
"name": "npm",
"readmeFilename": "README.md",
"repository": Object {
"type": "git",
"url": "git+https://github.com/npm/cli.git",
},
"version": "{VERSION}",
}
`
exports[`test/lib/commands/publish.js TAP no auth dry-run > must match snapshot 1`] = `
+ @npmcli/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP no auth dry-run > warns about auth being needed 1`] = `
Array [
"This command requires you to be logged in to https://registry.npmjs.org/ (dry-run)",
]
`
exports[`test/lib/commands/publish.js TAP prioritize CLI flags over publishConfig > new package version 1`] = `
+ @npmcli/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP public access > must match snapshot 1`] = `
Array [
"package: @npm/test-package@1.0.0",
"Tarball Contents",
"55B package.json",
"Tarball Details",
"name: @npm/test-package",
"version: 1.0.0",
"filename: npm-test-package-1.0.0.tgz",
"package size: {size}",
"unpacked size: 55 B",
"shasum: {sha}",
"integrity: {integrity}
"total files: 1",
"Publishing to https://registry.npmjs.org/ with tag latest and public access",
]
`
exports[`test/lib/commands/publish.js TAP public access > new package version 1`] = `
+ @npm/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP re-loads publishConfig.registry if added during script process > new package version 1`] = `
+ @npmcli/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP respects publishConfig.registry, runs appropriate scripts > new package version 1`] = `
> @npmcli/test-package@1.0.0 prepublishOnly
> touch scripts-prepublishonly
> @npmcli/test-package@1.0.0 publish
> touch scripts-publish
> @npmcli/test-package@1.0.0 postpublish
> touch scripts-postpublish
+ @npmcli/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP restricted access > must match snapshot 1`] = `
Array [
"package: @npm/test-package@1.0.0",
"Tarball Contents",
"55B package.json",
"Tarball Details",
"name: @npm/test-package",
"version: 1.0.0",
"filename: npm-test-package-1.0.0.tgz",
"package size: {size}",
"unpacked size: 55 B",
"shasum: {sha}",
"integrity: {integrity}
"total files: 1",
"Publishing to https://registry.npmjs.org/ with tag latest and restricted access",
]
`
exports[`test/lib/commands/publish.js TAP restricted access > new package version 1`] = `
+ @npm/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP scoped _auth config scoped registry > new package version 1`] = `
+ @npm/test-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP tarball > must match snapshot 1`] = `
Array [
"package: test-tar-package@1.0.0",
"Tarball Contents",
String(
26B index.js
98B package.json
),
"Tarball Details",
"name: test-tar-package",
"version: 1.0.0",
"filename: test-tar-package-1.0.0.tgz",
"package size: {size}",
"unpacked size: 124 B",
"shasum: {sha}",
"integrity: {integrity}
"total files: 2",
"Publishing to https://registry.npmjs.org/ with tag latest and default access",
]
`
exports[`test/lib/commands/publish.js TAP tarball > new package json 1`] = `
+ test-tar-package@1.0.0
`
exports[`test/lib/commands/publish.js TAP workspaces all workspaces - color > all public workspaces 1`] = `
+ workspace-a@1.2.3-a
+ workspace-b@1.2.3-n
+ workspace-n@1.2.3-n
`
exports[`test/lib/commands/publish.js TAP workspaces all workspaces - color > warns about skipped private workspace in color 1`] = `
Array [
"\\u001b[94mpublish\\u001b[39m npm auto-corrected some errors in your package.json when publishing. Please run \\"npm pkg fix\\" to address these errors.",
String(
\\u001b[94mpublish\\u001b[39m errors corrected:
\\u001b[94mpublish\\u001b[39m "repository" was changed from a string to an object
),
"\\u001b[94mpublish\\u001b[39m npm auto-corrected some errors in your package.json when publishing. Please run \\"npm pkg fix\\" to address these errors.",
String(
\\u001b[94mpublish\\u001b[39m errors corrected:
\\u001b[94mpublish\\u001b[39m "repository" was changed from a string to an object
\\u001b[94mpublish\\u001b[39m "repository.url" was normalized to "git+https://github.com/npm/workspace-b.git"
),
"\\u001b[94mpublish\\u001b[39m Skipping workspace \\u001b[36mworkspace-p\\u001b[39m, marked as \\u001b[1mprivate\\u001b[22m",
]
`
exports[`test/lib/commands/publish.js TAP workspaces all workspaces - no color > all public workspaces 1`] = `
+ workspace-a@1.2.3-a
+ workspace-b@1.2.3-n
+ workspace-n@1.2.3-n
`
exports[`test/lib/commands/publish.js TAP workspaces all workspaces - no color > warns about skipped private workspace 1`] = `
Array [
"publish npm auto-corrected some errors in your package.json when publishing. Please run \\"npm pkg fix\\" to address these errors.",
String(
publish errors corrected:
publish "repository" was changed from a string to an object
),
"publish npm auto-corrected some errors in your package.json when publishing. Please run \\"npm pkg fix\\" to address these errors.",
String(
publish errors corrected:
publish "repository" was changed from a string to an object
publish "repository.url" was normalized to "git+https://github.com/npm/workspace-b.git"
),
"publish Skipping workspace workspace-p, marked as private",
]
`
exports[`test/lib/commands/publish.js TAP workspaces all workspaces - some marked private > one marked private 1`] = `
+ workspace-a@1.2.3-a
`
exports[`test/lib/commands/publish.js TAP workspaces different package spec > publish different package spec 1`] = `
+ pkg@1.2.3
`
exports[`test/lib/commands/publish.js TAP workspaces json > all workspaces in json 1`] = `
{
"workspace-a": {
"id": "workspace-a@1.2.3-a",
"name": "workspace-a",
"version": "1.2.3-a",
"size": "{size}",
"unpackedSize": 82,
"shasum": "{sha}",
"integrity": "{integrity}",
"filename": "workspace-a-1.2.3-a.tgz",
"files": [
{
"path": "package.json",
"size": "{size}",
"mode": 420
}
],
"entryCount": 1,
"bundled": []
},
"workspace-b": {
"id": "workspace-b@1.2.3-n",
"name": "workspace-b",
"version": "1.2.3-n",
"size": "{size}",
"unpackedSize": 92,
"shasum": "{sha}",
"integrity": "{integrity}",
"filename": "workspace-b-1.2.3-n.tgz",
"files": [
{
"path": "package.json",
"size": "{size}",
"mode": 420
}
],
"entryCount": 1,
"bundled": []
},
"workspace-n": {
"id": "workspace-n@1.2.3-n",
"name": "workspace-n",
"version": "1.2.3-n",
"size": "{size}",
"unpackedSize": 42,
"shasum": "{sha}",
"integrity": "{integrity}",
"filename": "workspace-n-1.2.3-n.tgz",
"files": [
{
"path": "package.json",
"size": "{size}",
"mode": 420
}
],
"entryCount": 1,
"bundled": []
}
}
`
exports[`test/lib/commands/publish.js TAP workspaces one workspace - success > single workspace 1`] = `
+ workspace-a@1.2.3-a
`