Skip to content

Commit 4439e2a

Browse files
committed
feat: add publish command to CLI and update configuration types
1 parent 0d3e2b7 commit 4439e2a

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

docs/index.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ hero:
99
image:
1010
src: /logo.svg
1111
actions:
12-
- theme: brand
13-
text: Why Rattail
14-
link: /why-rattail
1512
- theme: brand
1613
text: Get Started
1714
link: /getting-started

docs/zh/index.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ hero:
66
text: '前端工具链'
77
tagline: 面向 Vite+、AI Agent 友好的前端工具链
88
actions:
9-
- theme: brand
10-
text: 为什么选择 Rattail
11-
link: /zh/why-rattail
129
- theme: brand
1310
text: 快速开始
1411
link: /zh/getting-started

src/cli/bin.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ program
4343
return release()
4444
})
4545

46+
program
47+
.command('publish')
48+
.description('Publish workspace packages to npm (pnpm recursive publish)')
49+
.option('-c, --checkRemoteVersion', 'Skip publish if the current version already exists on npm')
50+
.option('-t, --npmTag <tag>', 'npm dist-tag (e.g. beta, next); ignored when --pre-release is set')
51+
.option('--pre-release', 'Publish with alpha dist-tag')
52+
.action(async (options: { checkRemoteVersion?: boolean; npmTag?: string; preRelease?: boolean }) => {
53+
const { getConfig } = await import('./config')
54+
const { publish } = await import('./publish')
55+
const config = (await getConfig()).publish ?? {}
56+
57+
return publish({
58+
...config,
59+
...(options.checkRemoteVersion ? { checkRemoteVersion: true } : {}),
60+
...(options.npmTag != null ? { npmTag: options.npmTag } : {}),
61+
...(options.preRelease ? { preRelease: true } : {}),
62+
})
63+
})
64+
4665
program
4766
.command('changelog')
4867
.description('Generate changelog')

src/cli/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ChangelogOptions, ReleaseCommandOptions } from '@varlet/release'
1+
import type { ChangelogOptions, PublishCommandOptions, ReleaseCommandOptions } from '@varlet/release'
22
import type { GenerateOptions } from 'api-farmer'
33
import { loadConfig } from 'unconfig'
44
import { callOrReturn } from '../function'
@@ -32,6 +32,8 @@ export type RattailConfig = {
3232

3333
release?: ReleaseCommandOptions
3434

35+
publish?: PublishCommandOptions
36+
3537
changelog?: ChangelogOptions
3638
}
3739

src/cli/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from './clean'
22
export * from './api'
33
export * from './hook'
44
export * from './release'
5+
export * from './publish'
56
export * from './changelog'
67
export * from './commitLint'
78
export * from './lockfileCheck'

src/cli/publish.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { publish as publishPackages, type PublishCommandOptions } from '@varlet/release'
2+
import { getConfig } from './config'
3+
4+
export type PublishConfig = PublishCommandOptions
5+
6+
export async function publish(config?: PublishConfig) {
7+
const resolvedConfig = config ?? (await getConfig()).publish ?? {}
8+
await publishPackages(resolvedConfig)
9+
}

0 commit comments

Comments
 (0)