Skip to content

Commit 71cb65b

Browse files
owlstronautwraithgar
authored andcommitted
fix(libnpmpublish): Remove dependence on deprecated library
1 parent bc08ac7 commit 71cb65b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

workspaces/libnpmpublish/lib/publish.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const { fixer } = require('normalize-package-data')
21
const npmFetch = require('npm-registry-fetch')
32
const npa = require('npm-package-arg')
3+
const PackageJson = require('@npmcli/package-json')
44
const { log } = require('proc-log')
55
const semver = require('semver')
66
const { URL } = require('node:url')
@@ -31,7 +31,7 @@ Remove the 'private' field from the package.json to publish it.`),
3131
}
3232

3333
const reg = npmFetch.pickRegistry(spec, opts)
34-
const pubManifest = patchManifest(manifest, opts)
34+
const pubManifest = await patchManifest(manifest, opts)
3535

3636
// registry-frontdoor cares about the access level,
3737
// which is only configurable for scoped packages
@@ -62,17 +62,18 @@ Remove the 'private' field from the package.json to publish it.`),
6262
return res
6363
}
6464

65-
const patchManifest = (_manifest, opts) => {
65+
const patchManifest = async (_manifest, opts) => {
6666
const { npmVersion } = opts
67-
// we only update top-level fields, so a shallow clone is fine
68-
const manifest = { ..._manifest }
69-
70-
manifest._nodeVersion = process.versions.node
71-
if (npmVersion) {
72-
manifest._npmVersion = npmVersion
67+
const steps = ['fixName']
68+
const manifestInput = { ..._manifest, _nodeVersion: process.versions.node }
69+
if (npmVersion != null) {
70+
manifestInput._npmVersion = npmVersion
7371
}
72+
const manifest = await new PackageJson()
73+
.fromContent(manifestInput)
74+
.normalize({ steps })
75+
.then(p => p.content)
7476

75-
fixer.fixNameField(manifest, { strict: true, allowLegacyCase: true })
7677
const version = semver.clean(manifest.version)
7778
if (!version) {
7879
throw Object.assign(

0 commit comments

Comments
 (0)