@varlet/release 1.0.5-alpha.1773908865255 → 1.1.0

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 varlet
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 varlet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -13,6 +13,11 @@
13
13
 
14
14
  `Varlet Release` is a tool used for publishing all packages, generating change logs, and checking `commit messages`, relying on `pnpm`.
15
15
 
16
+ - 📦 **Out of the box**: Zero-configuration release experience
17
+ - 🤖 **Interactive CLI**: Friendly interactive terminal prompts
18
+ - 🛠 **Standardization**: Validates Git Commit messages and generates standard changelogs
19
+ - 🔗 **Extensibility**: Supports both CLI commands and Node.js API for deep customization
20
+
16
21
  > `Varlet Release` requires `Node.js` ^20.19.0 || >=22.12.0 and `esm` only.
17
22
 
18
23
  ## Installation
@@ -23,10 +28,21 @@ pnpm add @varlet/release -D
23
28
 
24
29
  ## Usage
25
30
 
31
+ ### Core Workflow
32
+
33
+ When executing `vr release`, the following sequence of lifecycles occurs automatically:
34
+
35
+ 1. Select/Confirm the **version** to publish interactively
36
+ 2. Execute the user-defined `task` function (optional, e.g., to rebuild projects based on the new version)
37
+ 3. Update the `package.json` **version** programmatically
38
+ 4. Generate the **Changelog**
39
+ 5. **Git Commit** & **Git Tag**
40
+ 6. **Publish** to npm
41
+
26
42
  ### Using Command
27
43
 
28
44
  ```shell
29
- # Release all packages and generate changelogs
45
+ # Release all packages and run the full workflow
30
46
  npx vr release
31
47
 
32
48
  # Specify remote name
@@ -49,26 +65,38 @@ npx vr lint-commit -p .git/COMMIT_EDITMSG
49
65
  npx vr publish
50
66
  ```
51
67
 
68
+ ### Git Hooks Integration (Best Practice)
69
+
70
+ It is highly recommended to use `commit-lint` with `simple-git-hooks` or `husky` in `package.json` to automatically check developers' commit messages before committing:
71
+
72
+ ```json
73
+ {
74
+ "simple-git-hooks": {
75
+ "commit-msg": "npx vr lint-commit -p $1"
76
+ }
77
+ }
78
+ ```
79
+
52
80
  ### Configuration
53
81
 
54
82
  #### release
55
83
 
56
- | Params | Instructions |
57
- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
58
- | -r --remote \<remote\> | Specify remote name |
59
- | -s --skip-npm-publish | Skip npm publish |
60
- | -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. |
61
- | -sc --skip-changelog | Skip generate changelog |
62
- | -sgt --skip-git-tag | Skip git tag |
63
- | -nt --npm-tag \<npmTag\> | npm tag |
84
+ | Params | Instructions | Default |
85
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------- |
86
+ | -r --remote \<remote\> | Specify remote name | `origin` |
87
+ | -s --skip-npm-publish | Skip npm publish | `false` |
88
+ | -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. | `false` |
89
+ | -sc --skip-changelog | Skip generate changelog | `false` |
90
+ | -sgt --skip-git-tag | Skip git tag | `false` |
91
+ | -nt --npm-tag \<npmTag\> | npm tag | `-` |
64
92
 
65
93
  #### changelog
66
94
 
67
- | Params | Instructions |
68
- | ----------------------------------- | -------------------------- |
69
- | -f --file \<filename\> | Specify changelog filename |
70
- | -rc --releaseCount \<releaseCount\> | Release count |
71
- | -p --preset \<preset\> | Specify changelog preset |
95
+ | Params | Instructions | Default |
96
+ | ----------------------------------- | -------------------------- | -------------- |
97
+ | -f --file \<filename\> | Specify changelog filename | `CHANGELOG.md` |
98
+ | -rc --releaseCount \<releaseCount\> | Release count | `0` |
99
+ | -p --preset \<preset\> | Specify changelog preset | `angular` |
72
100
 
73
101
  #### lint-commit
74
102
 
@@ -81,28 +109,30 @@ npx vr publish
81
109
 
82
110
  #### publish
83
111
 
84
- | Params | Instructions |
85
- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
86
- | -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 |
87
- | -nt --npm-tag \<npmTag\> | npm tag |
112
+ | Params | Instructions | Default |
113
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
114
+ | -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 | `false` |
115
+ | -nt --npm-tag \<npmTag\> | npm tag | `-` |
88
116
 
89
- ### Custom Handle
117
+ ### Node API Custom Handle
118
+
119
+ You can write your own release scripts with Internal Node.js API instead of CLI.
90
120
 
91
121
  #### Example
92
122
 
93
123
  ```js
94
124
  import { changelog, release } from '@varlet/release'
95
125
 
96
- // Do what you want to do...
126
+ // Run the core release workflow directly
97
127
  release()
98
128
  ```
99
129
 
100
- You can pass in a task that will be called before the publish after the package version is changed.
130
+ You can pass in a custom `task` function that will be called after the package version is updated but before the remaining publish steps.
101
131
 
102
132
  ```js
103
133
  import { changelog, release } from '@varlet/release'
104
134
 
105
- async function task() {
135
+ async function task(newVersion, oldVersion) {
106
136
  await doSomething1()
107
137
  await doSomething2()
108
138
  }
@@ -110,54 +140,6 @@ async function task() {
110
140
  release({ task })
111
141
  ```
112
142
 
113
- #### Types
114
-
115
- ```ts
116
- interface PublishCommandOptions {
117
- preRelease?: boolean
118
- checkRemoteVersion?: boolean
119
- npmTag?: string
120
- }
121
- function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
122
- function updateVersion(version: string): void
123
- interface ReleaseCommandOptions {
124
- remote?: string
125
- skipNpmPublish?: boolean
126
- skipChangelog?: boolean
127
- skipGitTag?: boolean
128
- npmTag?: string
129
- task?(newVersion: string, oldVersion: string): Promise<void>
130
- }
131
- function release(options: ReleaseCommandOptions): Promise<void>
132
-
133
- interface ChangelogCommandOptions {
134
- file?: string
135
- releaseCount?: number
136
- preset?:
137
- | 'angular'
138
- | 'atom'
139
- | 'codemirror'
140
- | 'conventionalcommits'
141
- | 'ember'
142
- | 'eslint'
143
- | 'express'
144
- | 'jquery'
145
- | 'jshint'
146
- }
147
- function changelog({ releaseCount, file, preset }?: 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
143
  ## License
162
144
 
163
145
  [MIT](https://github.com/varletjs/release/blob/main/LICENSE)
package/README.zh-CN.md CHANGED
@@ -6,14 +6,19 @@
6
6
  </p>
7
7
  <p align="center">
8
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>
9
+ <a href="https://github.com/varletjs/release/blob/main/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/varletjs/release" alt="License" /></a>
10
10
  </p>
11
11
 
12
12
  ## 介绍
13
13
 
14
- `Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message` 的工具,依赖于 `pnpm`。
14
+ `Varlet Release` 是一个用于发布所有包、生成变更日志和检测 `commit message` 的辅助工具,依赖于 `pnpm`。
15
15
 
16
- `Varlet Release` 需要 `Node.js` ^20.19.0 || >=22.12.0,并且仅支持 `esm`。
16
+ - 📦 **开箱即用**:零配置的极简发布体验
17
+ - 🤖 **直观交互**:提供非常友好的交互式终端提示
18
+ - 🛠 **规范驱动**:自动校验 Git Commit 并生成标准 Changelog
19
+ - 🔗 **深度扩展**:支持命令行调用与 Node.js API 无缝扩展
20
+
21
+ > `Varlet Release` 需要 `Node.js` ^20.19.0 || >=22.12.0,并且仅支持 `esm`。
17
22
 
18
23
  ## 安装
19
24
 
@@ -23,15 +28,26 @@ pnpm add @varlet/release -D
23
28
 
24
29
  ## 使用
25
30
 
26
- ### 使用命令
31
+ ### 核心工作流
32
+
33
+ 执行 `vr release` 时,背后会自动完成以下流程(保障每一步的严谨性):
34
+
35
+ 1. 交互式选择/确认要发布的版本号
36
+ 2. 执行用户自定义的额外 `task` 操作(可选,如重新构建以注入新版本号)
37
+ 3. 自动修改工程中的版本号信息
38
+ 4. 自动生成符合规范的 Changelog
39
+ 5. Git 提交 (Commit) 与打标签 (Tag)
40
+ 6. 发布至 npm
41
+
42
+ ### 命令行使用
27
43
 
28
44
  ```shell
29
- # 发布所有包并生成变更日志
45
+ # 发布所有包并执行完整工作流程
30
46
  npx vr release
31
47
 
32
48
  # 指定远程仓库名称
33
49
  npx vr release -r https://github.com/varletjs/varlet-release
34
- # or
50
+ #
35
51
  npx vr release --remote https://github.com/varletjs/varlet-release
36
52
 
37
53
  # 仅生成变更日志
@@ -39,36 +55,48 @@ npx vr changelog
39
55
 
40
56
  # 指定变更日志文件名
41
57
  npx vr changelog -f changelog.md
42
- # or
58
+ #
43
59
  npx vr changelog --file changelog.md
44
60
 
45
- # 检测 commit message
61
+ # 检测 commit message 是否符合规范
46
62
  npx vr lint-commit -p .git/COMMIT_EDITMSG
47
63
 
48
- # 发布到 npm,可以在 ci 中执行
64
+ # 发布到 npm(通常在 CI/CD 中执行)
49
65
  npx vr publish
50
66
  ```
51
67
 
52
- ### 配置
68
+ ### Git Hooks 集成 (推荐最佳实践)
69
+
70
+ 建议在 `package.json` 中配合 `simple-git-hooks` 或 `husky` 使用 `commit-lint`,在开发者提交代码时自动触发校验:
71
+
72
+ ```json
73
+ {
74
+ "simple-git-hooks": {
75
+ "commit-msg": "npx vr lint-commit -p $1"
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### 配置参考
53
81
 
54
82
  #### release
55
83
 
56
- | 参数 | 说明 |
57
- | ------------------------- | ----------------------------------------------------------------------- |
58
- | -r --remote \<remote\> | 指定远程仓库名称 |
59
- | -s --skip-npm-publish | 跳过 npm 发布 |
60
- | -c --check-remote-version | 检测 npm 包的远程版本是否与要在本地发布的包版本相同,如果是,则停止执行 |
61
- | -sc --skip-changelog | 跳过生成变更日志 |
62
- | -sgt --skip-git-tag | 跳过 git tag |
63
- | -nt --npm-tag \<npmTag\> | npm tag |
84
+ | 参数 | 说明 | 默认值 |
85
+ | ------------------------- | ----------------------------------------------------------------------- | -------- |
86
+ | -r --remote \<remote\> | 指定远程仓库名称 | `origin` |
87
+ | -s --skip-npm-publish | 跳过 npm 发布 | `false` |
88
+ | -c --check-remote-version | 检测 npm 包的远程版本是否与要在本地发布的包版本相同,如果是,则停止执行 | `false` |
89
+ | -sc --skip-changelog | 跳过生成变更日志 | `false` |
90
+ | -sgt --skip-git-tag | 跳过 git tag | `false` |
91
+ | -nt --npm-tag \<npmTag\> | npm tag | `-` |
64
92
 
65
93
  #### changelog
66
94
 
67
- | 参数 | 说明 |
68
- | ----------------------------------- | ------------------ |
69
- | -f --file \<filename\> | 指定变更日志文件名 |
70
- | -rc --releaseCount \<releaseCount\> | 发布数量 |
71
- | -p --preset \<preset\> | 指定变更预设 |
95
+ | 参数 | 说明 | 默认值 |
96
+ | ----------------------------------- | ------------------ | -------------- |
97
+ | -f --file \<filename\> | 指定变更日志文件名 | `CHANGELOG.md` |
98
+ | -rc --releaseCount \<releaseCount\> | 发布数量 | `0` |
99
+ | -p --preset \<preset\> | 指定变更预设 | `angular` |
72
100
 
73
101
  #### lint-commit
74
102
 
@@ -81,28 +109,30 @@ npx vr publish
81
109
 
82
110
  #### publish
83
111
 
84
- | 参数 | 说明 |
85
- | ------------------------- | --------------------------------------------------------------------- |
86
- | -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
87
- | -nt --npm-tag \<npmTag\> | npm tag |
112
+ | 参数 | 说明 | 默认值 |
113
+ | ------------------------- | --------------------------------------------------------------------- | ------- |
114
+ | -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 | `false` |
115
+ | -nt --npm-tag \<npmTag\> | npm tag | `-` |
88
116
 
89
- ### 自定义处理
117
+ ### Node API 自定义处理
90
118
 
91
- #### 示例
119
+ 除了命令行,你也可以使用 Node.js API 结合内部逻辑编写发布脚本。
120
+
121
+ #### 示例代码
92
122
 
93
123
  ```js
94
124
  import { changelog, release } from '@varlet/release'
95
125
 
96
- // Do what you want to do...
126
+ // 执行默认发布流程
97
127
  release()
98
128
  ```
99
129
 
100
- 你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
130
+ 你可以传入一个 `task` 函数,在版本号变更之后、发布到 npm 等后续操作之前被调用。
101
131
 
102
132
  ```js
103
133
  import { changelog, release } from '@varlet/release'
104
134
 
105
- async function task() {
135
+ async function task(newVersion, oldVersion) {
106
136
  await doSomething1()
107
137
  await doSomething2()
108
138
  }
@@ -110,54 +140,6 @@ async function task() {
110
140
  release({ task })
111
141
  ```
112
142
 
113
- #### 类型
114
-
115
- ```ts
116
- interface PublishCommandOptions {
117
- preRelease?: boolean
118
- checkRemoteVersion?: boolean
119
- npmTag?: string
120
- }
121
- function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
122
- function updateVersion(version: string): void
123
- interface ReleaseCommandOptions {
124
- remote?: string
125
- skipNpmPublish?: boolean
126
- skipChangelog?: boolean
127
- skipGitTag?: boolean
128
- npmTag?: string
129
- task?(newVersion: string, oldVersion: string): Promise<void>
130
- }
131
- function release(options: ReleaseCommandOptions): Promise<void>
132
-
133
- interface ChangelogCommandOptions {
134
- file?: string
135
- releaseCount?: number
136
- preset?:
137
- | 'angular'
138
- | 'atom'
139
- | 'codemirror'
140
- | 'conventionalcommits'
141
- | 'ember'
142
- | 'eslint'
143
- | 'express'
144
- | 'jquery'
145
- | 'jshint'
146
- }
147
- function changelog({ releaseCount, file, preset }?: 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
143
  ## 许可证
162
144
 
163
145
  [MIT](https://github.com/varletjs/release/blob/main/LICENSE)
package/dist/cli.js CHANGED
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { changelog, commitLint, publish, release } from "./index.js";
2
+ import { i as release, l as commitLint, o as changelog, r as publish } from "./src-BWrnR5U-.js";
3
3
  import { Command } from "commander";
4
-
5
4
  //#region package.json
6
- var version = "1.0.5-alpha.1773908865255";
7
-
5
+ var version = "1.1.0";
8
6
  //#endregion
9
7
  //#region src/cli.ts
10
8
  const program = new Command();
@@ -14,6 +12,5 @@ program.command("publish").option("-c --check-remote-version", "Check remote ver
14
12
  program.command("changelog").option("-rc --releaseCount <releaseCount>", "Release count").option("-f --file <file>", "Changelog filename").option("-p --preset <preset>", "Changelog preset").description("Generate changelog").action((options) => changelog(options));
15
13
  program.command("commit-lint").option("-p --commitMessagePath <path>", "Git commit message path").option("-r --commitMessageRe <reg>", "Validate the regular of whether the commit message passes").option("-e --errorMessage <message>", "Validation failed to display error messages").option("-w --warningMessage <message>", "Validation failed to display warning messages").description("Lint commit message").action((option) => commitLint(option));
16
14
  program.parse();
17
-
18
15
  //#endregion
19
- export { };
16
+ export {};
package/dist/index.d.ts CHANGED
@@ -12,7 +12,14 @@ declare function publish({
12
12
  checkRemoteVersion,
13
13
  npmTag
14
14
  }: PublishCommandOptions): Promise<void>;
15
- declare function getAllPackageJsons(): string[];
15
+ declare function getPackageJsons(): {
16
+ filePath: string;
17
+ config: {
18
+ name: string;
19
+ version: string;
20
+ private: boolean;
21
+ };
22
+ }[];
16
23
  declare function updateVersion(version: string): void;
17
24
  interface ReleaseCommandOptions {
18
25
  remote?: string;
@@ -52,4 +59,4 @@ interface CommitLintCommandOptions {
52
59
  }
53
60
  declare function commitLint(options: CommitLintCommandOptions): void;
54
61
  //#endregion
55
- export { COMMIT_HEADER_RE, COMMIT_MESSAGE_RE, ChangelogCommandOptions, CommitLintCommandOptions, PublishCommandOptions, ReleaseCommandOptions, changelog, commitLint, getAllPackageJsons, getCommitMessage, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };
62
+ export { COMMIT_HEADER_RE, COMMIT_MESSAGE_RE, ChangelogCommandOptions, CommitLintCommandOptions, PublishCommandOptions, ReleaseCommandOptions, changelog, commitLint, getCommitMessage, getPackageJsons, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };