Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/commands/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ class Pack extends BaseCommand {
tarballs.push(await getContents(manifest, tarballData))
}

for (const [index, tar] of Object.entries(tarballs)) {
// XXX(BREAKING_CHANGE): publish outputs a json object with package names as keys.
// Pack should do the same here instead of an array
logTar(tar, { unicode, json, key: index })
for (const tar of tarballs) {
logTar(tar, { unicode, json, key: tar.name })
if (!json) {
output.standard(tar.filename.replace(/^@/, '').replace(/\//, '-'))
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Publish extends BaseCommand {
workspaces: this.workspacePaths,
})
const pkgContents = await getContents(manifest, tarballData)
const logPkg = () => logTar(pkgContents, { unicode, json, key: workspace })
const logPkg = () => logTar(pkgContents, { unicode, json, key: pkgContents.name })

// The purpose of re-reading the manifest is in case it changed, so that we send the latest and greatest thing to the registry note that publishConfig might have changed as well!
manifest = await this.#getManifest(spec, opts, true)
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ const getArrayOrObject = (items) => {
return foundNonObject
}
// We use objects with 0,1,2,etc keys to merge array
// We don't currently use this but want to allow for it again
// istanbul ignore next
if (items.every((o, i) => Object.hasOwn(o, i))) {
return Object.assign([], ...items)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/tar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const localeCompare = require('@isaacs/string-locale-compare')('en', {

const logTar = (tarball, { unicode = false, json, key } = {}) => {
if (json) {
output.buffer(key == null ? tarball : { [key]: tarball })
output.buffer({ [key]: tarball })
return
}
log.notice('')
Expand Down
12 changes: 6 additions & 6 deletions tap-snapshots/test/lib/commands/pack.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Array []

exports[`test/lib/commands/pack.js TAP should log output as valid json > outputs as json 1`] = `
Array [
Array [
Object {
Object {
"test-package": Object {
"bundled": Array [],
"entryCount": 1,
"filename": "test-package-1.0.0.tgz",
Expand All @@ -82,7 +82,7 @@ Array [
"unpackedSize": 41,
"version": "1.0.0",
},
],
},
]
`

Expand All @@ -92,8 +92,8 @@ Array []

exports[`test/lib/commands/pack.js TAP should log scoped package output as valid json > outputs as json 1`] = `
Array [
Array [
Object {
Object {
"@myscope/test-package": Object {
"bundled": Array [],
"entryCount": 1,
"filename": "myscope-test-package-1.0.0.tgz",
Expand All @@ -112,7 +112,7 @@ Array [
"unpackedSize": 88,
"version": "1.0.0",
},
],
},
]
`

Expand Down
36 changes: 19 additions & 17 deletions tap-snapshots/test/lib/commands/publish.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,25 @@ Array [

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": []
"@npmcli/test-package": {
"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": []
}
}
`

Expand Down
Loading