mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-23 16:20:57 -04:00
refactor(publish): remove meaningless key in publishConfig (#4334)
This commit is contained in:
6
.changeset/odd-donuts-argue.md
Normal file
6
.changeset/odd-donuts-argue.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/exportable-manifest": minor
|
||||
"@pnpm/plugin-commands-publishing": minor
|
||||
---
|
||||
|
||||
remove meaningless key in publishConfig when use `pack` or `pulish` commands [#4311](https://github.com/pnpm/pnpm/issues/4311)
|
||||
@@ -3,6 +3,7 @@ import PnpmError from '@pnpm/error'
|
||||
import { tryReadProjectManifest } from '@pnpm/read-project-manifest'
|
||||
import { Dependencies, ProjectManifest } from '@pnpm/types'
|
||||
import fromPairs from 'ramda/src/fromPairs'
|
||||
import isEmpty from 'ramda/src/isEmpty'
|
||||
import omit from 'ramda/src/omit'
|
||||
|
||||
// property keys that are copied from publishConfig into the manifest
|
||||
@@ -48,13 +49,18 @@ export default async function makePublishManifest (dir: string, originalManifest
|
||||
}
|
||||
}
|
||||
|
||||
const { publishConfig } = originalManifest
|
||||
const { publishConfig } = publishManifest
|
||||
if (publishConfig != null) {
|
||||
Object.keys(publishConfig)
|
||||
.filter(key => PUBLISH_CONFIG_WHITELIST.has(key))
|
||||
.forEach(key => {
|
||||
publishManifest[key] = publishConfig[key]
|
||||
delete publishConfig[key]
|
||||
})
|
||||
|
||||
if (isEmpty(publishConfig)) {
|
||||
delete publishManifest.publishConfig
|
||||
}
|
||||
}
|
||||
|
||||
if (opts?.readmeFile) {
|
||||
|
||||
@@ -165,3 +165,33 @@ test('pack: should not embed readme', async () => {
|
||||
|
||||
expect(pkg.readme).toBeFalsy()
|
||||
})
|
||||
|
||||
test('pack: remove publishConfig', async () => {
|
||||
prepare({
|
||||
name: 'remove-publish-config',
|
||||
version: '0.0.0',
|
||||
main: 'index.d.js',
|
||||
publishConfig: {
|
||||
types: 'index.d.ts',
|
||||
main: 'index.js',
|
||||
},
|
||||
})
|
||||
|
||||
await pack.handler({
|
||||
...DEFAULT_OPTS,
|
||||
argv: { original: [] },
|
||||
dir: process.cwd(),
|
||||
extraBinPaths: [],
|
||||
packDestination: process.cwd(),
|
||||
embedReadme: false,
|
||||
})
|
||||
|
||||
await tar.x({ file: 'remove-publish-config-0.0.0.tgz' })
|
||||
|
||||
expect((await import(path.resolve('package/package.json'))).default).toStrictEqual({
|
||||
name: 'remove-publish-config',
|
||||
version: '0.0.0',
|
||||
main: 'index.js',
|
||||
types: 'index.d.ts',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -268,20 +268,6 @@ test('publish: package with all possible fields in publishConfig', async () => {
|
||||
types: './published-types.d.ts',
|
||||
typings: './published-typings.d.ts',
|
||||
|
||||
publishConfig: {
|
||||
bin: './published-bin.js',
|
||||
browser: './published-browser.js',
|
||||
es2015: './published-es2015.js',
|
||||
esnext: './published-esnext.js',
|
||||
exports: './published-exports.js',
|
||||
main: './published.js',
|
||||
module: './published.mjs',
|
||||
types: './published-types.d.ts',
|
||||
typings: './published-typings.d.ts',
|
||||
'umd:main': './published-umd.js',
|
||||
unpkg: './published-unpkg.js',
|
||||
},
|
||||
|
||||
browser: './published-browser.js',
|
||||
es2015: './published-es2015.js',
|
||||
esnext: './published-esnext.js',
|
||||
|
||||
Reference in New Issue
Block a user