@varlet/release 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,163 +1,150 @@
1
- <h1 align="center">Varlet Release</h1>
2
-
3
- <p align="center">
4
- <span>English</span> |
5
- <a href="https://github.com/varletjs/release/blob/main/README.zh-CN.md">中文</a>
6
- </p>
7
- <p align="center">
8
- <a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
9
- <a href="https://github.com/varletjs/release/blob/main/LICENCE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
10
- </p>
11
-
12
- ## Intro
13
-
14
- `Varlet Release` is a tool to release all packages, generate changelogs and lint commit message.
15
-
16
- ## Installation
17
-
18
- ### npm
19
-
20
- ```shell
21
- npm i @varlet/release -D
22
- ```
23
-
24
- ### yarn
25
-
26
- ```shell
27
- yarn add @varlet/release -D
28
- ```
29
-
30
- ### pnpm
31
-
32
- ```shell
33
- pnpm add @varlet/release -D
34
- ```
35
-
36
- ## Usage
37
-
38
- ### Using Command
39
-
40
- ```shell
41
- # Release all packages and generate changelogs
42
- npx vr release
43
-
44
- # Specify remote name
45
- npx vr release -r https://github.com/varletjs/varlet-release
46
- # or
47
- npx vr release --remote https://github.com/varletjs/varlet-release
48
-
49
- # Just generate changelogs
50
- npx vr changelog
51
-
52
- # Specify changelog filename
53
- npx vr changelog -f changelog.md
54
- # or
55
- npx vr changelog --file changelog.md
56
-
57
- # Lint commit message
58
- npx vr lint-commit -p .git/COMMIT_EDITMSG
59
-
60
- # Publish to npm, which can be called in the ci environment
61
- npx vr publish
62
- ```
63
-
64
- ### Configuration
65
-
66
- #### release
67
-
68
- | Params | Instructions |
69
- | ---------------------- | ------------------- |
70
- | -r --remote \<remote\> | Specify remote name |
71
- | -s --skip-npm-publish | Skip npm publish |
72
- | -sc --skip-changelog | Skip generate changelog |
73
- | -sgt --skip-git-tag | Skip git tag |
74
- | -nt --npm-tag \<npmTag\> | npm tag |
75
-
76
- #### changelog
77
-
78
- | Params | Instructions |
79
- | ----------------------------------- | -------------------------- |
80
- | -f --file \<filename\> | Specify changelog filename |
81
- | -rc --releaseCount \<releaseCount\> | Release count |
82
-
83
- #### lint-commit
84
-
85
- | Params | Instructions |
86
- | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
87
- | -p --commitMessagePath \<path\> | The path of the temporary file to which the git message is submitted. The git hook commit-msg will pass this parameter |
88
- | -r --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
89
- | -e --errorMessage \<message\> | Validation failed to display error messages |
90
- | -w --warningMessage \<message\> | Validation failed to display warning messages |
91
-
92
- #### publish
93
-
94
- | Params | Instructions |
95
- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
96
- | -c --check-remote-version | Detects whether the remote version of the npm package is the same as the package version to be published locally, and if it is, skip the release |
97
- | -nt --npm-tag \<npmTag\> | npm tag |
98
-
99
- ### Custom Handle
100
-
101
- #### Example
102
-
103
- ```js
104
- import { release, changelog } from '@varlet/release'
105
-
106
- // Do what you want to do...
107
- release()
108
- ```
109
-
110
- You can pass in a task that will be called before the publish after the package version is changed.
111
-
112
- ```js
113
- import { release, changelog } from '@varlet/release'
114
-
115
- async function task() {
116
- await doSomething1()
117
- await doSomething2()
118
- }
119
-
120
- release({ task })
121
- ```
122
-
123
- #### Types
124
-
125
- ```ts
126
- interface PublishCommandOptions {
127
- preRelease?: boolean
128
- checkRemoteVersion?: boolean
129
- npmTag?: string
130
- }
131
- function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
132
- function updateVersion(version: string): void
133
- interface ReleaseCommandOptions {
134
- remote?: string
135
- skipNpmPublish?: boolean
136
- skipChangelog?: boolean
137
- skipGitTag?: boolean
138
- npmTag?: string
139
- task?(): Promise<void>
140
- }
141
- function release(options: ReleaseCommandOptions): Promise<void>
142
-
143
- interface ChangelogCommandOptions {
144
- file?: string
145
- releaseCount?: number
146
- }
147
- function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
148
-
149
- const COMMIT_MESSAGE_RE: RegExp
150
- function isVersionCommitMessage(message: string): string | false | null
151
- function getCommitMessage(commitMessagePath: string): string
152
- interface CommitLintCommandOptions {
153
- commitMessagePath: string
154
- commitMessageRe?: string | RegExp
155
- errorMessage?: string
156
- warningMessage?: string
157
- }
158
- function commitLint(options: CommitLintCommandOptions): void
159
- ```
160
-
161
- ## License
162
-
163
- [MIT](https://github.com/varletjs/release/blob/main/LICENCE)
1
+ <h1 align="center">Varlet Release</h1>
2
+
3
+ <p align="center">
4
+ <span>English</span> |
5
+ <a href="https://github.com/varletjs/release/blob/main/README.zh-CN.md">中文</a>
6
+ </p>
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
9
+ <a href="https://github.com/varletjs/release/blob/main/LICENCE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
10
+ </p>
11
+
12
+ ## Intro
13
+
14
+ `Varlet Release` is a tool used for publishing all packages, generating change logs, and checking `commit messages`, relying on `pnpm`.
15
+
16
+ ## Installation
17
+
18
+ ```shell
19
+ pnpm add @varlet/release -D
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Using Command
25
+
26
+ ```shell
27
+ # Release all packages and generate changelogs
28
+ npx vr release
29
+
30
+ # Specify remote name
31
+ npx vr release -r https://github.com/varletjs/varlet-release
32
+ # or
33
+ npx vr release --remote https://github.com/varletjs/varlet-release
34
+
35
+ # Just generate changelogs
36
+ npx vr changelog
37
+
38
+ # Specify changelog filename
39
+ npx vr changelog -f changelog.md
40
+ # or
41
+ npx vr changelog --file changelog.md
42
+
43
+ # Lint commit message
44
+ npx vr lint-commit -p .git/COMMIT_EDITMSG
45
+
46
+ # Publish to npm, which can be called in the ci environment
47
+ npx vr publish
48
+ ```
49
+
50
+ ### Configuration
51
+
52
+ #### release
53
+
54
+ | Params | Instructions |
55
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
56
+ | -r --remote \<remote\> | Specify remote name |
57
+ | -s --skip-npm-publish | Skip npm publish |
58
+ | -c --check-remote-version | Check if the remote version of the npm package is the same as the one you want to publish locally, if so, stop execution. |
59
+ | -sc --skip-changelog | Skip generate changelog |
60
+ | -sgt --skip-git-tag | Skip git tag |
61
+ | -nt --npm-tag \<npmTag\> | npm tag |
62
+
63
+ #### changelog
64
+
65
+ | Params | Instructions |
66
+ | ----------------------------------- | -------------------------- |
67
+ | -f --file \<filename\> | Specify changelog filename |
68
+ | -rc --releaseCount \<releaseCount\> | Release count |
69
+
70
+ #### lint-commit
71
+
72
+ | Params | Instructions |
73
+ | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
74
+ | -p --commitMessagePath \<path\> | The path of the temporary file to which the git message is submitted. The git hook commit-msg will pass this parameter |
75
+ | -r --commitMessageRe \<reg\> | Validate the regular of whether the commit message passes |
76
+ | -e --errorMessage \<message\> | Validation failed to display error messages |
77
+ | -w --warningMessage \<message\> | Validation failed to display warning messages |
78
+
79
+ #### publish
80
+
81
+ | Params | Instructions |
82
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
83
+ | -c --check-remote-version | Detects whether the remote version of the npm package is the same as the package version to be published locally, and if it is, skip the release |
84
+ | -nt --npm-tag \<npmTag\> | npm tag |
85
+
86
+ ### Custom Handle
87
+
88
+ #### Example
89
+
90
+ ```js
91
+ import { release, changelog } from '@varlet/release'
92
+
93
+ // Do what you want to do...
94
+ release()
95
+ ```
96
+
97
+ You can pass in a task that will be called before the publish after the package version is changed.
98
+
99
+ ```js
100
+ import { release, changelog } from '@varlet/release'
101
+
102
+ async function task() {
103
+ await doSomething1()
104
+ await doSomething2()
105
+ }
106
+
107
+ release({ task })
108
+ ```
109
+
110
+ #### Types
111
+
112
+ ```ts
113
+ interface PublishCommandOptions {
114
+ preRelease?: boolean
115
+ checkRemoteVersion?: boolean
116
+ npmTag?: string
117
+ }
118
+ function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
119
+ function updateVersion(version: string): void
120
+ interface ReleaseCommandOptions {
121
+ remote?: string
122
+ skipNpmPublish?: boolean
123
+ skipChangelog?: boolean
124
+ skipGitTag?: boolean
125
+ npmTag?: string
126
+ task?(newVersion: string, oldVersion: string): Promise<void>
127
+ }
128
+ function release(options: ReleaseCommandOptions): Promise<void>
129
+
130
+ interface ChangelogCommandOptions {
131
+ file?: string
132
+ releaseCount?: number
133
+ }
134
+ function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
135
+
136
+ const COMMIT_MESSAGE_RE: RegExp
137
+ function isVersionCommitMessage(message: string): string | false | null
138
+ function getCommitMessage(commitMessagePath: string): string
139
+ interface CommitLintCommandOptions {
140
+ commitMessagePath: string
141
+ commitMessageRe?: string | RegExp
142
+ errorMessage?: string
143
+ warningMessage?: string
144
+ }
145
+ function commitLint(options: CommitLintCommandOptions): void
146
+ ```
147
+
148
+ ## License
149
+
150
+ [MIT](https://github.com/varletjs/release/blob/main/LICENCE)
package/README.zh-CN.md CHANGED
@@ -1,163 +1,150 @@
1
- <h1 align="center">Varlet Release</h1>
2
-
3
- <p align="center">
4
- <span>中文</span> |
5
- <a href="https://github.com/varletjs/release/blob/main/README.md">English</a>
6
- </p>
7
- <p align="center">
8
- <a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
9
- <a href="https://github.com/valetjs/release/blob/master/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
10
- </p>
11
-
12
- ## 介绍
13
-
14
- `Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message` 的工具。
15
-
16
- ## 安装
17
-
18
- ### npm
19
-
20
- ```shell
21
- npm i @varlet/release -D
22
- ```
23
-
24
- ### yarn
25
-
26
- ```shell
27
- yarn add @varlet/release -D
28
- ```
29
-
30
- ### pnpm
31
-
32
- ```shell
33
- pnpm add @varlet/release -D
34
- ```
35
-
36
- ## 使用
37
-
38
- ### 使用命令
39
-
40
- ```shell
41
- # 发布所有包并生成变更日志
42
- npx vr release
43
-
44
- # 指定远程仓库名称
45
- npx vr release -r https://github.com/varletjs/varlet-release
46
- # or
47
- npx vr release --remote https://github.com/varletjs/varlet-release
48
-
49
- # 仅生成变更日志
50
- npx vr changelog
51
-
52
- # 指定变更日志文件名
53
- npx vr changelog -f changelog.md
54
- # or
55
- npx vr changelog --file changelog.md
56
-
57
- # 检测 commit message
58
- npx vr lint-commit -p .git/COMMIT_EDITMSG
59
-
60
- # 发布到 npm,可以在 ci 中执行
61
- npx vr publish
62
- ```
63
-
64
- ### 配置
65
-
66
- #### release
67
-
68
- | 参数 | 说明 |
69
- | ---------------------- | ---------------- |
70
- | -r --remote \<remote\> | 指定远程仓库名称 |
71
- | -s --skip-npm-publish | 跳过 npm 发布 |
72
- | -sc --skip-changelog | 跳过生成变更日志 |
73
- | -sgt --skip-git-tag | 跳过 git tag |
74
- | -nt --npm-tag \<npmTag\> | npm tag |
75
-
76
- #### changelog
77
-
78
- | 参数 | 说明 |
79
- | ----------------------------------- | ------------------ |
80
- | -f --file \<filename\> | 指定变更日志文件名 |
81
- | -rc --releaseCount \<releaseCount\> | 发布数量 |
82
-
83
- #### lint-commit
84
-
85
- | 参数 | 说明 |
86
- | ------------------------------- | --------------------------------------------------------------------------- |
87
- | -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
88
- | -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
89
- | -e --errorMessage \<message\> | 验证失败展示的错误信息 |
90
- | -w --warningMessage \<message\> | 验证失败展示的提示信息 |
91
-
92
- #### publish
93
-
94
- | 参数 | 说明 |
95
- | ------------------------- | --------------------------------------------------------------------- |
96
- | -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
97
- | -nt --npm-tag \<npmTag\> | npm tag |
98
-
99
- ### 自定义处理
100
-
101
- #### 示例
102
-
103
- ```js
104
- import { release, changelog } from '@varlet/release'
105
-
106
- // Do what you want to do...
107
- release()
108
- ```
109
-
110
- 你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
111
-
112
- ```js
113
- import { release, changelog } from '@varlet/release'
114
-
115
- async function task() {
116
- await doSomething1()
117
- await doSomething2()
118
- }
119
-
120
- release({ task })
121
- ```
122
-
123
- #### 类型
124
-
125
- ```ts
126
- interface PublishCommandOptions {
127
- preRelease?: boolean
128
- checkRemoteVersion?: boolean
129
- npmTag?: string
130
- }
131
- function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
132
- function updateVersion(version: string): void
133
- interface ReleaseCommandOptions {
134
- remote?: string
135
- skipNpmPublish?: boolean
136
- skipChangelog?: boolean
137
- skipGitTag?: boolean
138
- npmTag?: string
139
- task?(): Promise<void>
140
- }
141
- function release(options: ReleaseCommandOptions): Promise<void>
142
-
143
- interface ChangelogCommandOptions {
144
- file?: string
145
- releaseCount?: number
146
- }
147
- function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
148
-
149
- const COMMIT_MESSAGE_RE: RegExp
150
- function isVersionCommitMessage(message: string): string | false | null
151
- function getCommitMessage(commitMessagePath: string): string
152
- interface CommitLintCommandOptions {
153
- commitMessagePath: string
154
- commitMessageRe?: string | RegExp
155
- errorMessage?: string
156
- warningMessage?: string
157
- }
158
- function commitLint(options: CommitLintCommandOptions): void
159
- ```
160
-
161
- ## License
162
-
163
- [MIT](https://github.com/varletjs/release/blob/main/LICENSE)
1
+ <h1 align="center">Varlet Release</h1>
2
+
3
+ <p align="center">
4
+ <span>中文</span> |
5
+ <a href="https://github.com/varletjs/release/blob/main/README.md">English</a>
6
+ </p>
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@varlet/release" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/npm/v/@varlet/release" alt="NPM Version" /></a>
9
+ <a href="https://github.com/valetjs/release/blob/master/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
10
+ </p>
11
+
12
+ ## 介绍
13
+
14
+ `Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message` 的工具,依赖于 `pnpm`。
15
+
16
+ ## 安装
17
+
18
+ ```shell
19
+ pnpm add @varlet/release -D
20
+ ```
21
+
22
+ ## 使用
23
+
24
+ ### 使用命令
25
+
26
+ ```shell
27
+ # 发布所有包并生成变更日志
28
+ npx vr release
29
+
30
+ # 指定远程仓库名称
31
+ npx vr release -r https://github.com/varletjs/varlet-release
32
+ # or
33
+ npx vr release --remote https://github.com/varletjs/varlet-release
34
+
35
+ # 仅生成变更日志
36
+ npx vr changelog
37
+
38
+ # 指定变更日志文件名
39
+ npx vr changelog -f changelog.md
40
+ # or
41
+ npx vr changelog --file changelog.md
42
+
43
+ # 检测 commit message
44
+ npx vr lint-commit -p .git/COMMIT_EDITMSG
45
+
46
+ # 发布到 npm,可以在 ci 中执行
47
+ npx vr publish
48
+ ```
49
+
50
+ ### 配置
51
+
52
+ #### release
53
+
54
+ | 参数 | 说明 |
55
+ | ------------------------- | ----------------------------------------------------------------------- |
56
+ | -r --remote \<remote\> | 指定远程仓库名称 |
57
+ | -s --skip-npm-publish | 跳过 npm 发布 |
58
+ | -c --check-remote-version | 检测 npm 包的远程版本是否与要在本地发布的包版本相同,如果是,则停止执行 |
59
+ | -sc --skip-changelog | 跳过生成变更日志 |
60
+ | -sgt --skip-git-tag | 跳过 git tag |
61
+ | -nt --npm-tag \<npmTag\> | npm tag |
62
+
63
+ #### changelog
64
+
65
+ | 参数 | 说明 |
66
+ | ----------------------------------- | ------------------ |
67
+ | -f --file \<filename\> | 指定变更日志文件名 |
68
+ | -rc --releaseCount \<releaseCount\> | 发布数量 |
69
+
70
+ #### lint-commit
71
+
72
+ | 参数 | 说明 |
73
+ | ------------------------------- | --------------------------------------------------------------------------- |
74
+ | -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
75
+ | -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
76
+ | -e --errorMessage \<message\> | 验证失败展示的错误信息 |
77
+ | -w --warningMessage \<message\> | 验证失败展示的提示信息 |
78
+
79
+ #### publish
80
+
81
+ | 参数 | 说明 |
82
+ | ------------------------- | --------------------------------------------------------------------- |
83
+ | -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
84
+ | -nt --npm-tag \<npmTag\> | npm tag |
85
+
86
+ ### 自定义处理
87
+
88
+ #### 示例
89
+
90
+ ```js
91
+ import { release, changelog } from '@varlet/release'
92
+
93
+ // Do what you want to do...
94
+ release()
95
+ ```
96
+
97
+ 你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
98
+
99
+ ```js
100
+ import { release, changelog } from '@varlet/release'
101
+
102
+ async function task() {
103
+ await doSomething1()
104
+ await doSomething2()
105
+ }
106
+
107
+ release({ task })
108
+ ```
109
+
110
+ #### 类型
111
+
112
+ ```ts
113
+ interface PublishCommandOptions {
114
+ preRelease?: boolean
115
+ checkRemoteVersion?: boolean
116
+ npmTag?: string
117
+ }
118
+ function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
119
+ function updateVersion(version: string): void
120
+ interface ReleaseCommandOptions {
121
+ remote?: string
122
+ skipNpmPublish?: boolean
123
+ skipChangelog?: boolean
124
+ skipGitTag?: boolean
125
+ npmTag?: string
126
+ task?(newVersion: string, oldVersion: string): Promise<void>
127
+ }
128
+ function release(options: ReleaseCommandOptions): Promise<void>
129
+
130
+ interface ChangelogCommandOptions {
131
+ file?: string
132
+ releaseCount?: number
133
+ }
134
+ function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
135
+
136
+ const COMMIT_MESSAGE_RE: RegExp
137
+ function isVersionCommitMessage(message: string): string | false | null
138
+ function getCommitMessage(commitMessagePath: string): string
139
+ interface CommitLintCommandOptions {
140
+ commitMessagePath: string
141
+ commitMessageRe?: string | RegExp
142
+ errorMessage?: string
143
+ warningMessage?: string
144
+ }
145
+ function commitLint(options: CommitLintCommandOptions): void
146
+ ```
147
+
148
+ ## License
149
+
150
+ [MIT](https://github.com/varletjs/release/blob/main/LICENSE)
package/bin/index.js CHANGED
@@ -1,40 +1,41 @@
1
- #!/usr/bin/env node
2
- import { release, publish, changelog, commitLint } from '../dist/index.js'
3
- import { Command } from 'commander'
4
-
5
- const program = new Command()
6
-
7
- program
8
- .command('release')
9
- .option('-r --remote <remote>', 'Remote name')
10
- .option('-s --skip-npm-publish', 'Skip npm publish')
11
- .option('-sc --skip-changelog', 'Skip generate changelog')
12
- .option('-sgt --skip-git-tag', 'Skip git tag')
13
- .option('-nt --npm-tag <npmTag>', 'Npm tag')
14
- .description('Release all packages and generate changelogs')
15
- .action(async (options) => release(options))
16
-
17
- program
18
- .command('publish')
19
- .option('-c --check-remote-version', 'Check remote version')
20
- .option('-nt --npm-tag <npmTag>', 'Npm tag')
21
- .description('Publish to npm')
22
- .action(async (options) => publish(options))
23
-
24
- program
25
- .command('changelog')
26
- .option('-rc --releaseCount <releaseCount>', 'Release count')
27
- .option('-f --file <file>', 'Changelog filename')
28
- .description('Generate changelog')
29
- .action(async (options) => changelog(options))
30
-
31
- program
32
- .command('commit-lint')
33
- .option('-p --commitMessagePath <path>', 'Git commit message path')
34
- .option('-r --commitMessageRe <reg>', 'Validate the regular of whether the commit message passes')
35
- .option('-e --errorMessage <message>', 'Validation failed to display error messages')
36
- .option('-w --warningMessage <message>', 'Validation failed to display warning messages')
37
- .description('Lint commit message')
38
- .action(async (option) => commitLint(option))
39
-
40
- program.parse()
1
+ #!/usr/bin/env node
2
+ import { release, publish, changelog, commitLint } from '../dist/index.js'
3
+ import { Command } from 'commander'
4
+
5
+ const program = new Command()
6
+
7
+ program
8
+ .command('release')
9
+ .option('-r --remote <remote>', 'Remote name')
10
+ .option('-s --skip-npm-publish', 'Skip npm publish')
11
+ .option('-sc --skip-changelog', 'Skip generate changelog')
12
+ .option('-sgt --skip-git-tag', 'Skip git tag')
13
+ .option('-nt --npm-tag <npmTag>', 'Npm tag')
14
+ .option('-c --check-remote-version', 'Check remote version')
15
+ .description('Release all packages and generate changelogs')
16
+ .action(async (options) => release(options))
17
+
18
+ program
19
+ .command('publish')
20
+ .option('-c --check-remote-version', 'Check remote version')
21
+ .option('-nt --npm-tag <npmTag>', 'Npm tag')
22
+ .description('Publish to npm')
23
+ .action(async (options) => publish(options))
24
+
25
+ program
26
+ .command('changelog')
27
+ .option('-rc --releaseCount <releaseCount>', 'Release count')
28
+ .option('-f --file <file>', 'Changelog filename')
29
+ .description('Generate changelog')
30
+ .action(async (options) => changelog(options))
31
+
32
+ program
33
+ .command('commit-lint')
34
+ .option('-p --commitMessagePath <path>', 'Git commit message path')
35
+ .option('-r --commitMessageRe <reg>', 'Validate the regular of whether the commit message passes')
36
+ .option('-e --errorMessage <message>', 'Validation failed to display error messages')
37
+ .option('-w --warningMessage <message>', 'Validation failed to display warning messages')
38
+ .description('Lint commit message')
39
+ .action(async (option) => commitLint(option))
40
+
41
+ program.parse()
package/dist/index.cjs CHANGED
@@ -34,6 +34,7 @@ __export(src_exports, {
34
34
  changelog: () => changelog,
35
35
  commitLint: () => commitLint,
36
36
  getCommitMessage: () => getCommitMessage,
37
+ isSameVersion: () => isSameVersion,
37
38
  isVersionCommitMessage: () => isVersionCommitMessage,
38
39
  publish: () => publish,
39
40
  release: () => release,
@@ -101,22 +102,30 @@ async function isWorktreeEmpty() {
101
102
  const ret = await (0, import_execa.execa)("git", ["status", "--porcelain"]);
102
103
  return !ret.stdout;
103
104
  }
105
+ async function isSameVersion(version) {
106
+ const s = (0, import_nanospinner2.createSpinner)("Check remote version...").start();
107
+ const packageJsones = getPackageJsons();
108
+ const packageJson = packageJsones.find((packageJson2) => !packageJson2.config.private) || packageJsones[0];
109
+ if (packageJson) {
110
+ const { config } = packageJson;
111
+ try {
112
+ await (0, import_execa.execa)("npm", ["view", `${config.name}@${version ?? config.version}`, "version"]);
113
+ s.warn({
114
+ text: `The npm package has a same remote version ${config.version}.`
115
+ });
116
+ return true;
117
+ } catch {
118
+ s.success();
119
+ return false;
120
+ }
121
+ }
122
+ }
104
123
  async function publish({ preRelease, checkRemoteVersion, npmTag }) {
105
124
  const s = (0, import_nanospinner2.createSpinner)("Publishing all packages").start();
106
125
  const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
107
- if (checkRemoteVersion) {
108
- const packageJson = getPackageJsons().find((packageJson2) => !packageJson2.config.private);
109
- if (packageJson) {
110
- const { config } = packageJson;
111
- try {
112
- await (0, import_execa.execa)("npm", ["view", `${config.name}@${config.version}`, "version"]);
113
- s.warn({
114
- text: `The npm package has a same remote version ${config.version}, publishing automatically skipped.`
115
- });
116
- return;
117
- } catch {
118
- }
119
- }
126
+ if (checkRemoteVersion && await isSameVersion()) {
127
+ logger_default.error("publishing automatically skipped.");
128
+ return;
120
129
  }
121
130
  if (preRelease) {
122
131
  args.push("--tag", "alpha");
@@ -240,9 +249,13 @@ async function release(options) {
240
249
  return;
241
250
  }
242
251
  const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
252
+ if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
253
+ logger_default.error("Please check remote version.");
254
+ return;
255
+ }
243
256
  updateVersion(expectVersion);
244
257
  if (options.task) {
245
- await options.task();
258
+ await options.task(expectVersion, currentVersion);
246
259
  }
247
260
  if (!options.skipNpmPublish) {
248
261
  await publish({ preRelease: isPreRelease, npmTag: options.npmTag });
@@ -338,6 +351,7 @@ function commitLint(options) {
338
351
  changelog,
339
352
  commitLint,
340
353
  getCommitMessage,
354
+ isSameVersion,
341
355
  isVersionCommitMessage,
342
356
  publish,
343
357
  release,
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ declare function isSameVersion(version?: string): Promise<boolean | undefined>;
1
2
  interface PublishCommandOptions {
2
3
  preRelease?: boolean;
3
4
  checkRemoteVersion?: boolean;
@@ -11,7 +12,8 @@ interface ReleaseCommandOptions {
11
12
  skipNpmPublish?: boolean;
12
13
  skipChangelog?: boolean;
13
14
  skipGitTag?: boolean;
14
- task?(): Promise<void>;
15
+ checkRemoteVersion?: boolean;
16
+ task?(newVersion: string, oldVersion: string): Promise<void>;
15
17
  }
16
18
  declare function release(options: ReleaseCommandOptions): Promise<void>;
17
19
 
@@ -32,4 +34,4 @@ interface CommitLintCommandOptions {
32
34
  }
33
35
  declare function commitLint(options: CommitLintCommandOptions): void;
34
36
 
35
- export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, publish, release, updateVersion };
37
+ export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ declare function isSameVersion(version?: string): Promise<boolean | undefined>;
1
2
  interface PublishCommandOptions {
2
3
  preRelease?: boolean;
3
4
  checkRemoteVersion?: boolean;
@@ -11,7 +12,8 @@ interface ReleaseCommandOptions {
11
12
  skipNpmPublish?: boolean;
12
13
  skipChangelog?: boolean;
13
14
  skipGitTag?: boolean;
14
- task?(): Promise<void>;
15
+ checkRemoteVersion?: boolean;
16
+ task?(newVersion: string, oldVersion: string): Promise<void>;
15
17
  }
16
18
  declare function release(options: ReleaseCommandOptions): Promise<void>;
17
19
 
@@ -32,4 +34,4 @@ interface CommitLintCommandOptions {
32
34
  }
33
35
  declare function commitLint(options: CommitLintCommandOptions): void;
34
36
 
35
- export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isVersionCommitMessage, publish, release, updateVersion };
37
+ export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };
package/dist/index.js CHANGED
@@ -58,22 +58,30 @@ async function isWorktreeEmpty() {
58
58
  const ret = await execa("git", ["status", "--porcelain"]);
59
59
  return !ret.stdout;
60
60
  }
61
+ async function isSameVersion(version) {
62
+ const s = createSpinner2("Check remote version...").start();
63
+ const packageJsones = getPackageJsons();
64
+ const packageJson = packageJsones.find((packageJson2) => !packageJson2.config.private) || packageJsones[0];
65
+ if (packageJson) {
66
+ const { config } = packageJson;
67
+ try {
68
+ await execa("npm", ["view", `${config.name}@${version ?? config.version}`, "version"]);
69
+ s.warn({
70
+ text: `The npm package has a same remote version ${config.version}.`
71
+ });
72
+ return true;
73
+ } catch {
74
+ s.success();
75
+ return false;
76
+ }
77
+ }
78
+ }
61
79
  async function publish({ preRelease, checkRemoteVersion, npmTag }) {
62
80
  const s = createSpinner2("Publishing all packages").start();
63
81
  const args = ["-r", "publish", "--no-git-checks", "--access", "public"];
64
- if (checkRemoteVersion) {
65
- const packageJson = getPackageJsons().find((packageJson2) => !packageJson2.config.private);
66
- if (packageJson) {
67
- const { config } = packageJson;
68
- try {
69
- await execa("npm", ["view", `${config.name}@${config.version}`, "version"]);
70
- s.warn({
71
- text: `The npm package has a same remote version ${config.version}, publishing automatically skipped.`
72
- });
73
- return;
74
- } catch {
75
- }
76
- }
82
+ if (checkRemoteVersion && await isSameVersion()) {
83
+ logger_default.error("publishing automatically skipped.");
84
+ return;
77
85
  }
78
86
  if (preRelease) {
79
87
  args.push("--tag", "alpha");
@@ -197,9 +205,13 @@ async function release(options) {
197
205
  return;
198
206
  }
199
207
  const { isPreRelease, expectVersion } = await getReleaseVersion(currentVersion);
208
+ if (options.checkRemoteVersion && await isSameVersion(expectVersion)) {
209
+ logger_default.error("Please check remote version.");
210
+ return;
211
+ }
200
212
  updateVersion(expectVersion);
201
213
  if (options.task) {
202
- await options.task();
214
+ await options.task(expectVersion, currentVersion);
203
215
  }
204
216
  if (!options.skipNpmPublish) {
205
217
  await publish({ preRelease: isPreRelease, npmTag: options.npmTag });
@@ -294,6 +306,7 @@ export {
294
306
  changelog,
295
307
  commitLint,
296
308
  getCommitMessage,
309
+ isSameVersion,
297
310
  isVersionCommitMessage,
298
311
  publish,
299
312
  release,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@varlet/release",
3
3
  "type": "module",
4
- "version": "0.2.9",
4
+ "version": "0.2.11",
5
5
  "description": "release all packages and generate changelogs",
6
6
  "keywords": [
7
7
  "varlet",
@@ -71,7 +71,7 @@
71
71
  "scripts": {
72
72
  "dev": "tsup --watch",
73
73
  "build": "tsup",
74
- "release": "pnpm build && node bin/index.js release",
74
+ "release": "pnpm build && node bin/index.js release -c",
75
75
  "lint": "eslint --ext .ts,.js",
76
76
  "commit-lint": "node bin/index.js commit-lint"
77
77
  }