Skip to content

Commit 7213cc7

Browse files
committed
feat(core,npm,pnpm): add skip option to publish step
1 parent ba498f9 commit 7213cc7

File tree

8 files changed

+43
-5
lines changed

8 files changed

+43
-5
lines changed

packages/core/src/project/project.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,8 @@ export interface ProjectReleaseOptions {
104104
export interface ProjectPublishOptions {
105105
dryRun?: boolean
106106
logger?: ChildLogger
107+
/**
108+
* Skip publishing.
109+
*/
110+
skip?: boolean
107111
}

packages/core/src/releaser.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,21 @@ export class Releaser<
376376
const { project } = this
377377
const { dryRun } = this.options
378378
const logger = this.logger.createChild('package')
379-
380-
logger.info('Publishing...')
381-
382-
await project.publish({
379+
const publishOptions = {
383380
dryRun,
384381
logger,
385382
...this.stepsOptions.publish,
386383
...options
387-
})
384+
}
385+
386+
if (publishOptions.skip) {
387+
logger.verbose('Skipping publish')
388+
return
389+
}
390+
391+
logger.info('Publishing...')
392+
393+
await project.publish(publishOptions)
388394
})
389395
}
390396

packages/npm/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ Function to format tag prefix from scope name. By default, tag prefix will be th
155155

156156
Publish options for `NpmProject` and `NpmWorkspacesProject`.
157157

158+
#### `skip`
159+
160+
If true, skip publishing. Optional.
161+
158162
#### `access`
159163

160164
Access level for the package. Optional.

packages/npm/src/project.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export type NpmProjectPublishOptions = Omit<PublishOptions, 'workspaces'>
1919
*/
2020
export class NpmProject extends PackageJsonProject {
2121
override async publish(options: NpmProjectPublishOptions = {}): Promise<void> {
22+
if (options.skip) {
23+
options.logger?.info('Skipping publish')
24+
return
25+
}
26+
2227
await publish(this, options)
2328
}
2429
}

packages/npm/src/workspacesProject.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export class NpmWorkspacesProject extends PackageJsonMonorepoProject {
4343
}
4444

4545
override async publish(options: NpmWorkspacesProjectPublishOptions = {}): Promise<void> {
46+
if (options.skip) {
47+
options.logger?.info('Skipping publish')
48+
return
49+
}
50+
4651
await publish(this, {
4752
...options,
4853
workspaces: true

packages/pnpm/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ Function to format tag prefix from scope name. By default, tag prefix will be th
155155

156156
Publish options for `PnpmProject` and `PnpmWorkspacesProject`.
157157

158+
#### `skip`
159+
160+
If true, skip publishing. Optional.
161+
158162
#### `access`
159163

160164
Access level for the package. Optional.

packages/pnpm/src/project.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ export type PnpmProjectPublishOptions = Omit<PublishOptions, 'workspaces'>
1919
*/
2020
export class PnpmProject extends PackageJsonProject {
2121
override async publish(options: PnpmProjectPublishOptions = {}): Promise<void> {
22+
if (options.skip) {
23+
options.logger?.info('Skipping publish')
24+
return
25+
}
26+
2227
await publish(this, options)
2328
}
2429
}

packages/pnpm/src/workspacesProject.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export class PnpmWorkspacesProject extends PackageJsonMonorepoProject {
6060
}
6161

6262
override async publish(options: PnpmWorkspacesProjectPublishOptions = {}): Promise<void> {
63+
if (options.skip) {
64+
options.logger?.info('Skipping publish')
65+
return
66+
}
67+
6368
await publish(this, {
6469
...options,
6570
workspaces: true

0 commit comments

Comments
 (0)