mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 18:49:41 -04:00
feat: print an info message when there is no new packages to publish recursively (#3099)
* feat: print an info message when there is no new packages to publish recursively * feat: use publishedPkgDirs to check close #2775
This commit is contained in:
5
.changeset/afraid-dryers-sin.md
Normal file
5
.changeset/afraid-dryers-sin.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-publishing": minor
|
||||
---
|
||||
|
||||
feat: print an info message when there's nothing new to publish recursively
|
||||
@@ -35,6 +35,7 @@
|
||||
"homepage": "https://github.com/pnpm/pnpm/blob/master/packages/plugin-commands-publishing#readme",
|
||||
"devDependencies": {
|
||||
"@pnpm/filter-workspace-packages": "workspace:2.3.6",
|
||||
"@pnpm/logger": "^3.2.3",
|
||||
"@pnpm/prepare": "workspace:0.0.17",
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/mz": "^2.7.3",
|
||||
@@ -71,5 +72,8 @@
|
||||
"render-help": "^1.0.1",
|
||||
"write-json-file": "^4.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@pnpm/logger": "^3.2.3"
|
||||
},
|
||||
"funding": "https://opencollective.com/pnpm"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createResolver } from '@pnpm/client'
|
||||
import { Config } from '@pnpm/config'
|
||||
import logger from '@pnpm/logger'
|
||||
import pickRegistryForPackage from '@pnpm/pick-registry-for-package'
|
||||
import { ResolveFunction } from '@pnpm/resolver-base'
|
||||
import sortPackages from '@pnpm/sort-packages'
|
||||
@@ -64,6 +65,13 @@ export default async function (
|
||||
}, pkg.manifest.name, pkg.manifest.version))
|
||||
})
|
||||
const publishedPkgDirs = new Set(pkgsToPublish.map(({ dir }) => dir))
|
||||
if (publishedPkgDirs.size === 0) {
|
||||
logger.info({
|
||||
message: 'There are no new packages that should be published',
|
||||
prefix: opts.dir,
|
||||
})
|
||||
return
|
||||
}
|
||||
const appendedArgs = []
|
||||
if (opts.cliOptions['access']) {
|
||||
appendedArgs.push(`--access=${opts.cliOptions['access'] as string}`)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { readProjects } from '@pnpm/filter-workspace-packages'
|
||||
import { streamParser } from '@pnpm/logger'
|
||||
import { publish } from '@pnpm/plugin-commands-publishing'
|
||||
import { preparePackages } from '@pnpm/prepare'
|
||||
import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
|
||||
@@ -114,3 +115,57 @@ test('recursive publish', async () => {
|
||||
expect(stdout.toString().includes('next: 2.0.0')).toBeTruthy()
|
||||
}
|
||||
})
|
||||
|
||||
test('print info when no packages are published', async () => {
|
||||
preparePackages([
|
||||
// This will not be published because is-positive@1.0.0 is in the registry
|
||||
{
|
||||
name: 'is-positive',
|
||||
version: '1.0.0',
|
||||
|
||||
scripts: {
|
||||
prepublishOnly: 'exit 1',
|
||||
},
|
||||
},
|
||||
// This will not be published because it is a private package
|
||||
{
|
||||
name: 'i-am-private',
|
||||
version: '1.0.0',
|
||||
|
||||
private: true,
|
||||
scripts: {
|
||||
prepublishOnly: 'exit 1',
|
||||
},
|
||||
},
|
||||
// Package with no name is skipped
|
||||
{
|
||||
location: 'no-name',
|
||||
package: {
|
||||
scripts: {
|
||||
prepublishOnly: 'exit 1',
|
||||
},
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await fs.writeFile('.npmrc', CREDENTIALS, 'utf8')
|
||||
|
||||
const reporter = jest.fn()
|
||||
streamParser.on('data', reporter)
|
||||
|
||||
await publish.handler({
|
||||
...DEFAULT_OPTS,
|
||||
...await readProjects(process.cwd(), []),
|
||||
dir: process.cwd(),
|
||||
dryRun: true,
|
||||
recursive: true,
|
||||
}, [])
|
||||
|
||||
streamParser.removeListener('data', reporter)
|
||||
expect(reporter).toBeCalledWith(expect.objectContaining({
|
||||
level: 'info',
|
||||
message: 'There are no new packages that should be published',
|
||||
name: 'pnpm',
|
||||
prefix: process.cwd(),
|
||||
}))
|
||||
})
|
||||
|
||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -1936,6 +1936,7 @@ importers:
|
||||
write-json-file: 4.3.0
|
||||
devDependencies:
|
||||
'@pnpm/filter-workspace-packages': link:../filter-workspace-packages
|
||||
'@pnpm/logger': 3.2.3
|
||||
'@pnpm/plugin-commands-publishing': 'link:'
|
||||
'@pnpm/prepare': link:../../privatePackages/prepare
|
||||
'@types/cross-spawn': 6.0.2
|
||||
@@ -1956,6 +1957,7 @@ importers:
|
||||
'@pnpm/exportable-manifest': workspace:1.2.1
|
||||
'@pnpm/filter-workspace-packages': workspace:2.3.6
|
||||
'@pnpm/lifecycle': workspace:9.6.4
|
||||
'@pnpm/logger': ^3.2.3
|
||||
'@pnpm/pick-registry-for-package': workspace:1.0.6
|
||||
'@pnpm/plugin-commands-publishing': 'link:'
|
||||
'@pnpm/prepare': workspace:0.0.17
|
||||
|
||||
Reference in New Issue
Block a user