@varlet/release 0.4.4 → 1.0.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/README.zh-CN.md CHANGED
@@ -1,161 +1,163 @@
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
- | -p --preset \<preset\> | 指定变更预设 |
70
-
71
- #### lint-commit
72
-
73
- | 参数 | 说明 |
74
- | ------------------------------- | --------------------------------------------------------------------------- |
75
- | -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
76
- | -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
77
- | -e --errorMessage \<message\> | 验证失败展示的错误信息 |
78
- | -w --warningMessage \<message\> | 验证失败展示的提示信息 |
79
-
80
- #### publish
81
-
82
- | 参数 | 说明 |
83
- | ------------------------- | --------------------------------------------------------------------- |
84
- | -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
85
- | -nt --npm-tag \<npmTag\> | npm tag |
86
-
87
- ### 自定义处理
88
-
89
- #### 示例
90
-
91
- ```js
92
- import { changelog, release } from '@varlet/release'
93
-
94
- // Do what you want to do...
95
- release()
96
- ```
97
-
98
- 你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
99
-
100
- ```js
101
- import { changelog, release } from '@varlet/release'
102
-
103
- async function task() {
104
- await doSomething1()
105
- await doSomething2()
106
- }
107
-
108
- release({ task })
109
- ```
110
-
111
- #### 类型
112
-
113
- ```ts
114
- interface PublishCommandOptions {
115
- preRelease?: boolean
116
- checkRemoteVersion?: boolean
117
- npmTag?: string
118
- }
119
- function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>
120
- function updateVersion(version: string): void
121
- interface ReleaseCommandOptions {
122
- remote?: string
123
- skipNpmPublish?: boolean
124
- skipChangelog?: boolean
125
- skipGitTag?: boolean
126
- npmTag?: string
127
- task?(newVersion: string, oldVersion: string): Promise<void>
128
- }
129
- function release(options: ReleaseCommandOptions): Promise<void>
130
-
131
- interface ChangelogCommandOptions {
132
- file?: string
133
- releaseCount?: number
134
- preset?:
135
- | 'angular'
136
- | 'atom'
137
- | 'codemirror'
138
- | 'conventionalcommits'
139
- | 'ember'
140
- | 'eslint'
141
- | 'express'
142
- | 'jquery'
143
- | 'jshint'
144
- }
145
- function changelog({ releaseCount, file, preset }?: ChangelogCommandOptions): Promise<void>
146
-
147
- const COMMIT_MESSAGE_RE: RegExp
148
- function isVersionCommitMessage(message: string): string | false | null
149
- function getCommitMessage(commitMessagePath: string): string
150
- interface CommitLintCommandOptions {
151
- commitMessagePath: string
152
- commitMessageRe?: string | RegExp
153
- errorMessage?: string
154
- warningMessage?: string
155
- }
156
- function commitLint(options: CommitLintCommandOptions): void
157
- ```
158
-
159
- ## 许可证
160
-
161
- [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
+ `Varlet Release` 需要 `Node.js` ^20.19.0 || >=22.12.0,并且仅支持 `esm`。
17
+
18
+ ## 安装
19
+
20
+ ```shell
21
+ pnpm add @varlet/release -D
22
+ ```
23
+
24
+ ## 使用
25
+
26
+ ### 使用命令
27
+
28
+ ```shell
29
+ # 发布所有包并生成变更日志
30
+ npx vr release
31
+
32
+ # 指定远程仓库名称
33
+ npx vr release -r https://github.com/varletjs/varlet-release
34
+ # or
35
+ npx vr release --remote https://github.com/varletjs/varlet-release
36
+
37
+ # 仅生成变更日志
38
+ npx vr changelog
39
+
40
+ # 指定变更日志文件名
41
+ npx vr changelog -f changelog.md
42
+ # or
43
+ npx vr changelog --file changelog.md
44
+
45
+ # 检测 commit message
46
+ npx vr lint-commit -p .git/COMMIT_EDITMSG
47
+
48
+ # 发布到 npm,可以在 ci 中执行
49
+ npx vr publish
50
+ ```
51
+
52
+ ### 配置
53
+
54
+ #### release
55
+
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 |
64
+
65
+ #### changelog
66
+
67
+ | 参数 | 说明 |
68
+ | ----------------------------------- | ------------------ |
69
+ | -f --file \<filename\> | 指定变更日志文件名 |
70
+ | -rc --releaseCount \<releaseCount\> | 发布数量 |
71
+ | -p --preset \<preset\> | 指定变更预设 |
72
+
73
+ #### lint-commit
74
+
75
+ | 参数 | 说明 |
76
+ | ------------------------------- | --------------------------------------------------------------------------- |
77
+ | -p --commitMessagePath \<path\> | 提交 `git message` 的临时文件路径。`git` 钩子 `commit-msg` 会传递这个参数。 |
78
+ | -r --commitMessageRe \<reg\> | 验证 `commit message` 是否通过的正则 |
79
+ | -e --errorMessage \<message\> | 验证失败展示的错误信息 |
80
+ | -w --warningMessage \<message\> | 验证失败展示的提示信息 |
81
+
82
+ #### publish
83
+
84
+ | 参数 | 说明 |
85
+ | ------------------------- | --------------------------------------------------------------------- |
86
+ | -c --check-remote-version | 检测npm包的远程版本是否与要在本地发布的包版本相同,如果是,则跳过发布 |
87
+ | -nt --npm-tag \<npmTag\> | npm tag |
88
+
89
+ ### 自定义处理
90
+
91
+ #### 示例
92
+
93
+ ```js
94
+ import { changelog, release } from '@varlet/release'
95
+
96
+ // Do what you want to do...
97
+ release()
98
+ ```
99
+
100
+ 你可以传入一个 `task`,在包版本更改后,在发布之前会调用 `task`。
101
+
102
+ ```js
103
+ import { changelog, release } from '@varlet/release'
104
+
105
+ async function task() {
106
+ await doSomething1()
107
+ await doSomething2()
108
+ }
109
+
110
+ release({ task })
111
+ ```
112
+
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
+ ## 许可证
162
+
163
+ [MIT](https://github.com/varletjs/release/blob/main/LICENSE)
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.js ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { changelog, commitLint, publish, release } from "./index.js";
3
+ import { Command } from "commander";
4
+
5
+ //#region package.json
6
+ var version = "1.0.0";
7
+
8
+ //#endregion
9
+ //#region src/cli.ts
10
+ const program = new Command();
11
+ program.version(version);
12
+ program.command("release").option("-r --remote <remote>", "Remote name").option("-s --skip-npm-publish", "Skip npm publish").option("-sc --skip-changelog", "Skip generate changelog").option("-sgt --skip-git-tag", "Skip git tag").option("-nt --npm-tag <npmTag>", "Npm tag").option("-c --check-remote-version", "Check remote version").description("Release all packages and generate changelogs").action((options) => release(options));
13
+ program.command("publish").option("-c --check-remote-version", "Check remote version").option("-nt --npm-tag <npmTag>", "Npm tag").description("Publish to npm").action((options) => publish(options));
14
+ 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
+ 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
+ program.parse();
17
+
18
+ //#endregion
19
+ export { };
package/dist/index.d.ts CHANGED
@@ -1,41 +1,54 @@
1
- import conventionalChangelog from 'conventional-changelog';
1
+ import conventionalChangelog from "conventional-changelog";
2
2
 
3
+ //#region src/release.d.ts
3
4
  declare function isSameVersion(version?: string): Promise<boolean | undefined>;
4
5
  interface PublishCommandOptions {
5
- preRelease?: boolean;
6
- checkRemoteVersion?: boolean;
7
- npmTag?: string;
6
+ preRelease?: boolean;
7
+ checkRemoteVersion?: boolean;
8
+ npmTag?: string;
8
9
  }
9
- declare function publish({ preRelease, checkRemoteVersion, npmTag }: PublishCommandOptions): Promise<void>;
10
+ declare function publish({
11
+ preRelease,
12
+ checkRemoteVersion,
13
+ npmTag
14
+ }: PublishCommandOptions): Promise<void>;
15
+ declare function getAllPackageJsons(): string[];
10
16
  declare function updateVersion(version: string): void;
11
17
  interface ReleaseCommandOptions {
12
- remote?: string;
13
- npmTag?: string;
14
- skipNpmPublish?: boolean;
15
- skipChangelog?: boolean;
16
- skipGitTag?: boolean;
17
- checkRemoteVersion?: boolean;
18
- task?(newVersion: string, oldVersion: string): Promise<void>;
18
+ remote?: string;
19
+ npmTag?: string;
20
+ skipNpmPublish?: boolean;
21
+ skipChangelog?: boolean;
22
+ skipGitTag?: boolean;
23
+ checkRemoteVersion?: boolean;
24
+ task?(newVersion: string, oldVersion: string): Promise<void>;
19
25
  }
20
26
  declare function release(options: ReleaseCommandOptions): Promise<void>;
21
-
27
+ //#endregion
28
+ //#region src/changelog.d.ts
22
29
  interface ChangelogCommandOptions {
23
- file?: string;
24
- releaseCount?: number;
25
- preset?: 'angular' | 'atom' | 'codemirror' | 'conventionalcommits' | 'ember' | 'eslint' | 'express' | 'jquery' | 'jshint';
26
- writerOpts?: Parameters<typeof conventionalChangelog>['4'];
30
+ file?: string;
31
+ releaseCount?: number;
32
+ preset?: "angular" | "atom" | "codemirror" | "conventionalcommits" | "ember" | "eslint" | "express" | "jquery" | "jshint";
33
+ writerOpts?: Parameters<typeof conventionalChangelog>["4"];
27
34
  }
28
- declare function changelog({ releaseCount, file, preset, writerOpts, }?: ChangelogCommandOptions): Promise<void>;
29
-
35
+ declare function changelog({
36
+ releaseCount,
37
+ file,
38
+ preset,
39
+ writerOpts
40
+ }?: ChangelogCommandOptions): Promise<void>;
41
+ //#endregion
42
+ //#region src/commitLint.d.ts
30
43
  declare const COMMIT_MESSAGE_RE: RegExp;
31
- declare function isVersionCommitMessage(message: string): string | false | null;
44
+ declare function isVersionCommitMessage(message: string): boolean;
32
45
  declare function getCommitMessage(commitMessagePath: string): string;
33
46
  interface CommitLintCommandOptions {
34
- commitMessagePath: string;
35
- commitMessageRe?: string | RegExp;
36
- errorMessage?: string;
37
- warningMessage?: string;
47
+ commitMessagePath: string;
48
+ commitMessageRe?: string | RegExp;
49
+ errorMessage?: string;
50
+ warningMessage?: string;
38
51
  }
39
52
  declare function commitLint(options: CommitLintCommandOptions): void;
40
-
41
- export { COMMIT_MESSAGE_RE, type ChangelogCommandOptions, type CommitLintCommandOptions, type PublishCommandOptions, type ReleaseCommandOptions, changelog, commitLint, getCommitMessage, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };
53
+ //#endregion
54
+ export { COMMIT_MESSAGE_RE, ChangelogCommandOptions, CommitLintCommandOptions, PublishCommandOptions, ReleaseCommandOptions, changelog, commitLint, getAllPackageJsons, getCommitMessage, isSameVersion, isVersionCommitMessage, publish, release, updateVersion };