Skip to content

Commit 8f6126c

Browse files
committed
feat: enhance CLI release command with additional options and update documentation
1 parent c7bddf1 commit 8f6126c

File tree

5 files changed

+87
-8
lines changed

5 files changed

+87
-8
lines changed

docs/cli/release.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,25 @@ Interactive package release.
66

77
```shell
88
rt release
9+
rt release --skip-npm-publish
10+
rt release --npm-tag beta
11+
rt release --skip-changelog --skip-git-tag
12+
rt release --check-remote-version --remote upstream
913
```
1014

15+
### CLI Arguments
16+
17+
All options can be passed as command-line arguments. CLI arguments take priority over config file options.
18+
19+
| Argument | Description |
20+
| --- | --- |
21+
| `-t, --npm-tag <tag>` | npm dist-tag for publishing, e.g. `beta`, `next` |
22+
| `-r, --remote <remote>` | Git remote name for pushing |
23+
| `--skip-npm-publish` | Skip npm publish |
24+
| `--skip-changelog` | Skip changelog generation |
25+
| `--skip-git-tag` | Skip git tag |
26+
| `-c, --check-remote-version` | Skip publish if the current version already exists on npm |
27+
1128
### Config
1229

1330
```ts

docs/zh/cli/release.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,25 @@
66

77
```shell
88
rt release
9+
rt release --skip-npm-publish
10+
rt release --npm-tag beta
11+
rt release --skip-changelog --skip-git-tag
12+
rt release --check-remote-version --remote upstream
913
```
1014

15+
### 命令行参数
16+
17+
所有选项均可通过命令行参数传递,命令行参数的优先级高于配置文件。
18+
19+
| 参数 | 描述 |
20+
| --- | --- |
21+
| `-t, --npm-tag <tag>` | npm 发布的 dist-tag,如 `beta``next` |
22+
| `-r, --remote <remote>` | git push 使用的 remote 名称 |
23+
| `--skip-npm-publish` | 跳过 npm 发布 |
24+
| `--skip-changelog` | 跳过 changelog 生成 |
25+
| `--skip-git-tag` | 跳过 git tag |
26+
| `-c, --check-remote-version` | 发布前检查 npm 远程版本,若版本已存在则跳过发布 |
27+
1128
### 配置
1229

1330
```ts

skills/rattail/references/cli/release.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,24 @@ Release all packages, generate changelogs, tag, and optionally publish to npm. P
1414

1515
```bash
1616
rt release
17+
rt release --skip-npm-publish
18+
rt release --npm-tag beta
19+
rt release --skip-changelog --skip-git-tag
20+
rt release --check-remote-version --remote upstream
1721
```
1822

19-
This replaces the standalone `vr release` CLI. The command reads configuration from `rattail.release` in `vite.config.ts`.
23+
This replaces the standalone `vr release` CLI. The command reads configuration from `rattail.release` in `vite.config.ts`. All config options (except `task`) can also be passed as CLI arguments. CLI arguments take priority over config.
24+
25+
## CLI Arguments
26+
27+
| Argument | Description |
28+
| ---------------------------- | --------------------------------------------------------- |
29+
| `-t, --npm-tag <tag>` | npm dist-tag for publishing, e.g. `beta`, `next` |
30+
| `-r, --remote <remote>` | Git remote name for pushing |
31+
| `--skip-npm-publish` | Skip npm publish |
32+
| `--skip-changelog` | Skip changelog generation |
33+
| `--skip-git-tag` | Skip git tag |
34+
| `-c, --check-remote-version` | Skip publish if the current version already exists on npm |
2035

2136
## Configuration
2237

@@ -53,6 +68,12 @@ export default defineConfig({
5368
| `checkRemoteVersion` | `boolean` | Abort if npm already has same version |
5469
| `task` | `(newVersion, oldVersion) => Promise<void>` | Hook to run after version bump (e.g. build) |
5570

71+
## Priority
72+
73+
CLI arguments > config file (`rattail.release` in `vite.config.ts`) > defaults.
74+
75+
The merge logic in `src/cli/bin.ts` spreads config first, then overlays any CLI arguments on top.
76+
5677
## Programmatic
5778

5879
```ts

src/cli/bin.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,36 @@ program
3737
program
3838
.command('release')
3939
.description('Release all packages and generate changelogs')
40-
.action(async () => {
41-
const { release } = await import('./release')
42-
43-
return release()
44-
})
40+
.option('-t, --npmTag <tag>', 'npm dist-tag (e.g. beta, next)')
41+
.option('-r, --remote <remote>', 'Git remote name for pushing')
42+
.option('--skip-npm-publish', 'Skip npm publish')
43+
.option('--skip-changelog', 'Skip changelog generation')
44+
.option('--skip-git-tag', 'Skip git tag')
45+
.option('-c, --check-remote-version', 'Skip publish if the current version already exists on npm')
46+
.action(
47+
async (options: {
48+
npmTag?: string
49+
remote?: string
50+
skipNpmPublish?: boolean
51+
skipChangelog?: boolean
52+
skipGitTag?: boolean
53+
checkRemoteVersion?: boolean
54+
}) => {
55+
const { getConfig } = await import('./config')
56+
const { release } = await import('./release')
57+
const config = (await getConfig()).release ?? {}
58+
59+
return release({
60+
...config,
61+
...(options.npmTag != null ? { npmTag: options.npmTag } : {}),
62+
...(options.remote != null ? { remote: options.remote } : {}),
63+
...(options.skipNpmPublish ? { skipNpmPublish: true } : {}),
64+
...(options.skipChangelog ? { skipChangelog: true } : {}),
65+
...(options.skipGitTag ? { skipGitTag: true } : {}),
66+
...(options.checkRemoteVersion ? { checkRemoteVersion: true } : {}),
67+
})
68+
},
69+
)
4570

4671
program
4772
.command('publish')

src/vite-plus/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { UserConfig, ConfigEnv } from '@voidzero-dev/vite-plus-core'
2-
import { defineConfig as defineVitePlusConfig } from 'vite-plus'
1+
import { defineConfig as defineVitePlusConfig, type UserConfig, type ConfigEnv } from 'vite-plus'
32
import type { HookConfig, RattailConfig } from '../cli/config'
43

54
export type {

0 commit comments

Comments
 (0)