@peiyanlu/release 1.3.0 → 2.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.md +138 -356
- package/dist/action.mjs +1036 -0
- package/dist/cli.mjs +878 -1411
- package/dist/index.d.mts +850 -253
- package/dist/index.mjs +2848 -149
- package/package.json +27 -12
- package/template/release.config.hbs +29 -0
- package/template/release.text +82 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,269 +1,866 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConventionalChangelog } from "conventional-changelog";
|
|
3
|
-
import { CommitType
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Git 提交信息模板
|
|
81
|
-
*/
|
|
82
|
-
commitMessage: string;
|
|
83
|
-
/**
|
|
84
|
-
* 额外的 git commit 参数(透传给 git CLI)
|
|
85
|
-
*/
|
|
86
|
-
commitArgs: string[];
|
|
87
|
-
/**
|
|
88
|
-
* Git Tag 的消息内容
|
|
89
|
-
*/
|
|
90
|
-
tagMessage: string;
|
|
91
|
-
/**
|
|
92
|
-
* 额外的 git tag 参数(透传给 git CLI)
|
|
93
|
-
*/
|
|
94
|
-
tagArgs: string[];
|
|
95
|
-
/**
|
|
96
|
-
* 额外的 git push 参数(透传给 git CLI)
|
|
97
|
-
*/
|
|
98
|
-
pushArgs: string[];
|
|
99
|
-
/**
|
|
100
|
-
* 是否自动添加未追踪的文件(git add -A)
|
|
101
|
-
*/
|
|
102
|
-
addUntrackedFiles: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* 是否要求必须配置远程仓库(存在 git remote)
|
|
105
|
-
*/
|
|
106
|
-
requireRemote: boolean;
|
|
107
|
-
/**
|
|
108
|
-
* 是否要求当前工作目录必须是 Git 仓库
|
|
109
|
-
*/
|
|
110
|
-
requireRepository: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* 是否要求工作目录保持干净(无未提交的更改)
|
|
113
|
-
*/
|
|
114
|
-
requireCleanWorkingTree: boolean;
|
|
115
|
-
};
|
|
1
|
+
import { AnyFunction, Dict, Simplify } from "@peiyanlu/ts-utils";
|
|
2
|
+
import { ConventionalChangelog, Preset } from "conventional-changelog";
|
|
3
|
+
import { CommitType } from "conventional-changelog-conventionalcommits";
|
|
4
|
+
import { FinalTemplateContext } from "@conventional-changelog/template";
|
|
5
|
+
import { ReleaseType } from "semver";
|
|
6
|
+
import { Octokit, Octokit as Octokit$1 } from "@octokit/rest";
|
|
7
|
+
import { getOctokit } from "@actions/github";
|
|
8
|
+
//#region src/core/changelog/changelog.types.d.ts
|
|
9
|
+
export interface ChangelogOptions {
|
|
10
|
+
pkgDir?: string;
|
|
11
|
+
tagPrefix?: string;
|
|
12
|
+
/** 生成多少个变更日志,详见 {@link Options} */
|
|
13
|
+
releaseCount?: number;
|
|
14
|
+
/** 自定义 markdown 插入到更新日志的版本标题后,在生成的内容之前 */
|
|
15
|
+
preamble?: string;
|
|
16
|
+
/** 对默认 commit types 进行转换 */
|
|
17
|
+
transformTypes?: (types: CommitType[]) => CommitType[];
|
|
18
|
+
/** 提交范围(scope) */
|
|
19
|
+
scope?: string | string[];
|
|
20
|
+
filename?: string;
|
|
21
|
+
version?: string;
|
|
22
|
+
previousTag?: string;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/core/changelog/changelog.d.ts
|
|
26
|
+
interface LastRelease {
|
|
27
|
+
version: string;
|
|
28
|
+
notes: string;
|
|
29
|
+
previousTag: string;
|
|
30
|
+
nextTag: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const extractLastRelease: (input: string | string[] | Iterable<string> | AsyncIterable<string | Buffer>) => Promise<LastRelease>;
|
|
33
|
+
export declare class Changelog {
|
|
34
|
+
options: ChangelogOptions;
|
|
35
|
+
constructor(options?: ChangelogOptions);
|
|
36
|
+
get infile(): string;
|
|
37
|
+
setOptions(options: ChangelogOptions): void;
|
|
38
|
+
parsePreset(): Preset;
|
|
39
|
+
inferReleaseType(): Promise<{
|
|
40
|
+
releaseType?: undefined;
|
|
41
|
+
reason?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
releaseType: "major" | "minor" | "patch";
|
|
44
|
+
reason: string;
|
|
45
|
+
}>;
|
|
46
|
+
createGenerator(): ConventionalChangelog;
|
|
47
|
+
read(): Promise<string>;
|
|
48
|
+
write(): Promise<string>;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/core/changelog/committype.d.ts
|
|
52
|
+
export declare const defaultTypes: CommitType[];
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/core/changelog/templates.d.ts
|
|
55
|
+
export declare function headerPartial(context: FinalTemplateContext): string;
|
|
56
|
+
export declare function preamblePartial(contest: FinalTemplateContext): string;
|
|
57
|
+
export declare function template(context: FinalTemplateContext): string;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/core/logger.d.ts
|
|
60
|
+
export type Printer = (message: LoggerMessage) => void;
|
|
61
|
+
export type Color = (text: string) => string;
|
|
62
|
+
export interface LoggerOptions {
|
|
63
|
+
silent?: boolean;
|
|
64
|
+
dryRun?: boolean;
|
|
65
|
+
verbose?: boolean;
|
|
66
|
+
printer?: Printer;
|
|
67
|
+
colors?: Color[];
|
|
68
|
+
}
|
|
69
|
+
export interface LoggerMessage {
|
|
70
|
+
dryRun?: boolean;
|
|
71
|
+
stage: string;
|
|
72
|
+
message: unknown;
|
|
73
|
+
color: Color;
|
|
74
|
+
}
|
|
75
|
+
/** 一个子消息记录器,绑定到特定阶段 */
|
|
76
|
+
export declare class ChildLogger {
|
|
77
|
+
parent: Logger;
|
|
78
|
+
stage: string;
|
|
116
79
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* 是否启用 npm 发布流程
|
|
123
|
-
*/
|
|
124
|
-
publish: boolean | undefined;
|
|
125
|
-
/**
|
|
126
|
-
* 额外的 npm publish 参数(透传给 npm CLI)
|
|
127
|
-
*/
|
|
128
|
-
publishArgs: string[];
|
|
129
|
-
/**
|
|
130
|
-
* 是否跳过发布前检查(如 ping、whoami 等校验)
|
|
131
|
-
*
|
|
132
|
-
* 启用后可减少发布前的网络请求,但可能无法提前发现登录状态异常或 Registry 不可用等问题
|
|
133
|
-
*/
|
|
134
|
-
skipChecks: boolean;
|
|
135
|
-
/**
|
|
136
|
-
* 发布前的文件清理配置
|
|
137
|
-
*
|
|
138
|
-
* 用于控制复制到临时发布目录后的清理行为,不会修改源项目文件
|
|
139
|
-
*/
|
|
140
|
-
cleanup: {
|
|
141
|
-
/**
|
|
142
|
-
* 是否清理 package.json
|
|
143
|
-
*
|
|
144
|
-
* 包括移除开发相关字段、应用 publishConfig,并保留发布所需内容
|
|
145
|
-
*/
|
|
146
|
-
packageJson: boolean | {
|
|
147
|
-
/** 需要忽略的字段,支持 `a.b.c` */
|
|
148
|
-
ignoreFields: string[];
|
|
149
|
-
/** 需要保留的脚本,默认:`preinstall | install | postinstall` */
|
|
150
|
-
keepScripts: string[];
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* 是否清理 README.md
|
|
154
|
-
*
|
|
155
|
-
* 仅保留主要内容,并移除或精简不需要随包发布的文档内容
|
|
156
|
-
*/
|
|
157
|
-
readme: boolean;
|
|
158
|
-
/**
|
|
159
|
-
* 是否在发布之后删除临时目录
|
|
160
|
-
*/
|
|
161
|
-
removeTempDir: boolean;
|
|
162
|
-
};
|
|
163
|
-
};
|
|
80
|
+
* 创建子日志记录器。
|
|
81
|
+
* @param parent - 要继承其选项的父日志记录器。
|
|
82
|
+
* @param stage - 此日志记录器所属的处理阶段。
|
|
83
|
+
*/
|
|
84
|
+
constructor(parent: Logger, stage: string);
|
|
164
85
|
/**
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
86
|
+
* 记录一条普通信息。
|
|
87
|
+
* @param message - 要记录的信息。
|
|
88
|
+
*/
|
|
89
|
+
info(message: unknown): void;
|
|
90
|
+
/**
|
|
91
|
+
* 记录一条详细信息。
|
|
92
|
+
* @param message - 要记录的信息。
|
|
93
|
+
*/
|
|
94
|
+
verbose(message: unknown): void;
|
|
95
|
+
}
|
|
96
|
+
/** 消息记录器 */
|
|
97
|
+
export declare class Logger {
|
|
98
|
+
options: LoggerOptions;
|
|
99
|
+
readonly printer: Printer;
|
|
100
|
+
private readonly colors;
|
|
101
|
+
private readonly colorMap;
|
|
102
|
+
constructor(options?: LoggerOptions);
|
|
103
|
+
info(stage: string, message: unknown): void;
|
|
104
|
+
verbose(stage: string, message: unknown): void;
|
|
105
|
+
createChild(stage: string): ChildLogger;
|
|
106
|
+
private getColor;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/core/manifest/manifest.types.d.ts
|
|
110
|
+
export interface ProjectManifestVersionUpdate {
|
|
111
|
+
name: string;
|
|
112
|
+
from: string;
|
|
113
|
+
to: string;
|
|
114
|
+
files: string[];
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/core/manifest/manifest.d.ts
|
|
118
|
+
export declare abstract class ProjectManifest<T = Dict> {
|
|
119
|
+
filepath: string;
|
|
120
|
+
static Filename: string;
|
|
121
|
+
projectDir: string;
|
|
122
|
+
abstract contents?: string;
|
|
123
|
+
abstract manifest?: T;
|
|
124
|
+
constructor(filepath: string);
|
|
125
|
+
abstract readManifest(): Promise<T>;
|
|
126
|
+
abstract getName(): Promise<string>;
|
|
127
|
+
abstract getVersion(): Promise<string>;
|
|
128
|
+
abstract isPrivate(): Promise<boolean>;
|
|
129
|
+
abstract writeVersion(versin: string, dryRun?: boolean): Promise<ProjectManifestVersionUpdate>;
|
|
130
|
+
getPrereleaseVersion(): Promise<readonly (string | number)[] | null>;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/core/utils.d.ts
|
|
134
|
+
interface HostedGitInfo {
|
|
135
|
+
host: string;
|
|
136
|
+
prefix: string;
|
|
137
|
+
owner: string;
|
|
138
|
+
repo: string;
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/core/manifest/packageJson.types.d.ts
|
|
142
|
+
export interface PackageJsonProps extends Dict<any> {
|
|
143
|
+
name: string;
|
|
144
|
+
version: string;
|
|
145
|
+
private?: boolean;
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/core/manifest/packageJson.d.ts
|
|
149
|
+
export declare class PackageJsonManifest<T extends PackageJsonProps = PackageJsonProps> extends ProjectManifest<T> {
|
|
150
|
+
static override Filename: string;
|
|
151
|
+
contents?: string;
|
|
152
|
+
manifest?: T;
|
|
153
|
+
readManifest(): Promise<T>;
|
|
154
|
+
getName(): Promise<string>;
|
|
155
|
+
getVersion(): Promise<string>;
|
|
156
|
+
isPrivate(): Promise<boolean>;
|
|
157
|
+
writeVersion(version: string, dryRun?: boolean): Promise<ProjectManifestVersionUpdate>;
|
|
158
|
+
private contentsMutex?;
|
|
207
159
|
}
|
|
208
160
|
//#endregion
|
|
209
|
-
//#region src/
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
161
|
+
//#region src/core/manifest/composed.d.ts
|
|
162
|
+
export declare class ComposedProjectManifest<T = Dict> extends ProjectManifest<T> {
|
|
163
|
+
mainManifest: ProjectManifest<T>;
|
|
164
|
+
subManifests: ProjectManifest[];
|
|
165
|
+
constructor(mainManifest: ProjectManifest<T>, subManifests: ProjectManifest[]);
|
|
166
|
+
get contents(): string | undefined;
|
|
167
|
+
get manifest(): T | undefined;
|
|
168
|
+
readManifest(): Promise<T>;
|
|
169
|
+
getName(): Promise<string>;
|
|
170
|
+
getVersion(): Promise<string>;
|
|
171
|
+
isPrivate(): Promise<boolean>;
|
|
172
|
+
writeVersion(version: string, dryRun?: boolean): Promise<ProjectManifestVersionUpdate>;
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/core/project/project.types.d.ts
|
|
176
|
+
export type TagPrefixResolver = (scope: string) => string | Promise<string>;
|
|
177
|
+
export interface ProjectOptions {
|
|
178
|
+
changelogFile?: string;
|
|
179
|
+
manifest: ProjectManifest;
|
|
180
|
+
tagPrefix?: string | TagPrefixResolver;
|
|
181
|
+
compose?(manifest: ProjectManifest): ProjectManifest;
|
|
182
|
+
}
|
|
183
|
+
interface ProjectTagPrefixOptions {
|
|
184
|
+
/**
|
|
185
|
+
* 标签前缀。
|
|
186
|
+
* @default 'v'
|
|
187
|
+
*/
|
|
228
188
|
tagPrefix?: string;
|
|
229
|
-
/** 生成多少个变更日志,详见 {@link Options} */
|
|
230
|
-
releaseCount?: number;
|
|
231
189
|
}
|
|
232
|
-
interface
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
190
|
+
export interface ProjectVersionUpdate extends ProjectManifestVersionUpdate {
|
|
191
|
+
notes: string;
|
|
192
|
+
}
|
|
193
|
+
export interface ProjectTagsOptions extends ProjectTagPrefixOptions {
|
|
194
|
+
verify?: boolean;
|
|
195
|
+
}
|
|
196
|
+
export interface ProjectReleaseOptions extends ProjectTagPrefixOptions {}
|
|
197
|
+
export interface ProjectMaintenanceBranchesOptions extends ProjectTagPrefixOptions {
|
|
198
|
+
/**
|
|
199
|
+
* 维护分支名称的前缀。
|
|
200
|
+
* 默认使用标签前缀。
|
|
201
|
+
*/
|
|
202
|
+
branchPrefix?: string;
|
|
203
|
+
}
|
|
204
|
+
export interface ProjectMaintenanceBranch {
|
|
205
|
+
/**
|
|
206
|
+
* 创建分支所基于的源标签。
|
|
207
|
+
*/
|
|
208
|
+
from: string;
|
|
209
|
+
/**
|
|
210
|
+
* 要创建的目标分支名称。
|
|
211
|
+
*/
|
|
212
|
+
to: string;
|
|
213
|
+
}
|
|
214
|
+
export interface ProjectNextVersionOptions extends ProjectTagPrefixOptions {
|
|
215
|
+
/**
|
|
216
|
+
* 忽略项目为私有项目这一限制。
|
|
217
|
+
*/
|
|
218
|
+
forcePrivate?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* 强制升级到指定版本。
|
|
221
|
+
* 未提供时,根据提交记录确定版本。
|
|
222
|
+
*/
|
|
223
|
+
version?: string;
|
|
224
|
+
/**
|
|
225
|
+
* 用于计算升级版本的基准版本。
|
|
226
|
+
* 未提供时,从清单文件中读取版本。
|
|
227
|
+
*/
|
|
228
|
+
baseVersion?: string;
|
|
229
|
+
/**
|
|
230
|
+
* 要升级到的发布类型。
|
|
231
|
+
* 未提供时,根据提交记录确定版本。
|
|
232
|
+
*/
|
|
233
|
+
as?: ReleaseType;
|
|
234
|
+
/**
|
|
235
|
+
* 要使用的预发布标识符。
|
|
236
|
+
*/
|
|
237
|
+
prerelease?: string;
|
|
238
|
+
/**
|
|
239
|
+
* 快照预发布标识符,版本号末尾会附加时间戳。
|
|
240
|
+
*/
|
|
241
|
+
snapshot?: string;
|
|
242
|
+
/**
|
|
243
|
+
* 是否为首次发布。
|
|
244
|
+
* 默认根据标签是否存在自动判断。
|
|
245
|
+
*/
|
|
246
|
+
firstRelease?: boolean;
|
|
247
|
+
}
|
|
248
|
+
type ProjectBumpChangelogOptions = Pick<ChangelogOptions, "releaseCount" | "preamble" | "transformTypes">;
|
|
249
|
+
export interface ProjectBumpOptions extends ProjectNextVersionOptions, ProjectBumpChangelogOptions {
|
|
250
|
+
/** 跳过变更日志生成 */
|
|
251
|
+
skipChangelog?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* 是否仅试运行。
|
|
254
|
+
* 为 `true` 时,不会将版本写入清单文件,只在内存中更新。
|
|
255
|
+
*/
|
|
256
|
+
dryRun?: boolean;
|
|
257
|
+
logger?: ChildLogger;
|
|
258
|
+
}
|
|
259
|
+
export interface ProjectRevertOptions {
|
|
260
|
+
dryRun?: boolean;
|
|
261
|
+
logger?: ChildLogger;
|
|
262
|
+
}
|
|
263
|
+
export interface ProjectPublishOptions {
|
|
264
|
+
dryRun?: boolean;
|
|
265
|
+
logger?: ChildLogger;
|
|
266
|
+
/** 发布通道标签。由具体项目类型解释,例如 npm dist-tag 或 GitHub Action 分支别名。 */
|
|
267
|
+
tag?: string | ((version: string, prerelease: readonly (string | number)[] | null) => string);
|
|
268
|
+
}
|
|
269
|
+
export interface ProjectPublishCheckOptions {
|
|
270
|
+
logger?: ChildLogger;
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/core/project/monorepo.types.d.ts
|
|
274
|
+
export type MonorepoMode = "fixed" | "independent";
|
|
275
|
+
export type GetProjectsOptions = Simplify<Required<Pick<ProjectOptions, "compose" | "manifest">>>;
|
|
276
|
+
export interface MonorepoProjectOptions extends ProjectOptions {
|
|
277
|
+
/**
|
|
278
|
+
* 单体仓库的版本模式。
|
|
279
|
+
* `fixed` 表示所有项目统一升级到同一版本;`independent` 表示各项目分别升级版本。
|
|
280
|
+
*/
|
|
281
|
+
mode: MonorepoMode;
|
|
282
|
+
/**
|
|
283
|
+
* 用于组合 package.json 的钩子函数。
|
|
284
|
+
*/
|
|
285
|
+
compose?(packageJson: ProjectManifest, isRoot?: boolean): ProjectManifest;
|
|
286
|
+
/**
|
|
287
|
+
* 获取单体仓库中的项目。
|
|
288
|
+
*/
|
|
289
|
+
getProjects(options: GetProjectsOptions): AsyncIterable<Project>;
|
|
290
|
+
/**
|
|
291
|
+
* 获取单体仓库中项目的 scope。
|
|
292
|
+
* @param projectName - 要获取 scope 的项目名称。
|
|
293
|
+
* @param rootName - 根项目名称。
|
|
294
|
+
* @returns 项目的 scope。
|
|
295
|
+
*/
|
|
296
|
+
scope?(projectName: string, rootName: string): string | Promise<string>;
|
|
297
|
+
/**
|
|
298
|
+
* 获取单体仓库中项目的标签前缀。
|
|
299
|
+
* @param scope - 项目的 scope 名称。
|
|
300
|
+
* @returns 项目的标签前缀。
|
|
301
|
+
*/
|
|
302
|
+
tagPrefix?(scope: string): string | Promise<string>;
|
|
303
|
+
}
|
|
304
|
+
type NextVersionKeys = "skip" | "version" | "as" | "prerelease" | "snapshot" | "firstRelease";
|
|
305
|
+
type BumpKeys = "skipChangelog" | "releaseCount" | "preamble" | "transformTypes";
|
|
306
|
+
export type MonorepoProjectBumpByProjectOptions = Pick<ProjectBumpOptions, NextVersionKeys | BumpKeys>;
|
|
307
|
+
export interface MonorepoProjectBumpOptions extends Omit<ProjectBumpOptions, "tagPrefix"> {
|
|
308
|
+
/**
|
|
309
|
+
* 在固定版本模式下,强制升级单体仓库中没有变更的项目。
|
|
310
|
+
*/
|
|
311
|
+
force?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* 要纳入项目变更日志的额外 scope。
|
|
314
|
+
* 例如,要纳入 `fix(deps): 修复依赖项漏洞` 这类提交,可将 `deps` 添加到 `extraScopes`。
|
|
315
|
+
*/
|
|
316
|
+
extraScopes?: string[];
|
|
317
|
+
/**
|
|
318
|
+
* 针对特定项目的版本升级选项。
|
|
319
|
+
*/
|
|
320
|
+
byProject?: Record<string, MonorepoProjectBumpByProjectOptions>;
|
|
321
|
+
}
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/core/project/monorepo.d.ts
|
|
324
|
+
export declare abstract class MonorepoProject extends Project {
|
|
325
|
+
readonly mode: MonorepoMode;
|
|
326
|
+
options: MonorepoProjectOptions & ProjectOptions;
|
|
327
|
+
override getCommitMessage(): Promise<string>;
|
|
328
|
+
override getTagPrefix(scope: string): Promise<string>;
|
|
329
|
+
override getTags(options?: ProjectTagsOptions): Promise<string[]>;
|
|
330
|
+
override getReleaseData(options?: ProjectReleaseOptions): Promise<ReleaseData[]>;
|
|
331
|
+
override isFirstRelease(options?: ProjectReleaseOptions): Promise<boolean>;
|
|
332
|
+
override getDefaultPublishTag(options?: ProjectReleaseOptions): Promise<Map<string, string>>;
|
|
333
|
+
override getMaintenanceBranches(options?: ProjectMaintenanceBranchesOptions): Promise<ProjectMaintenanceBranch[]>;
|
|
334
|
+
override getNextVersion(options?: MonorepoProjectBumpOptions): Promise<string | undefined>;
|
|
335
|
+
override bump(options?: MonorepoProjectBumpOptions): Promise<boolean>;
|
|
336
|
+
override revert(options?: ProjectRevertOptions): Promise<boolean>;
|
|
337
|
+
private projectsMutex?;
|
|
338
|
+
protected constructor(options: Simplify<MonorepoProjectOptions>);
|
|
339
|
+
get isFixedMode(): boolean;
|
|
340
|
+
get isIndependentMode(): boolean;
|
|
341
|
+
getProjects(): AsyncGenerator<Project>;
|
|
342
|
+
getScope(name: string): Promise<string>;
|
|
343
|
+
getMaxVersion(): Promise<{
|
|
344
|
+
version: string;
|
|
345
|
+
packages: string[];
|
|
346
|
+
}>;
|
|
347
|
+
private getIndependentCommitMessage;
|
|
348
|
+
private getIndependentTags;
|
|
349
|
+
private getIndependentReleaseData;
|
|
350
|
+
private getIndependentDefaultPublishTag;
|
|
351
|
+
private getIndependentMaintenanceBranches;
|
|
352
|
+
private getBumpOptions;
|
|
353
|
+
private independentBump;
|
|
354
|
+
private fixedBump;
|
|
355
|
+
private isIndependentFirstRelease;
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/core/project/project.d.ts
|
|
359
|
+
export declare const DEFAULT_TAG_PREFIX = "v";
|
|
360
|
+
export declare const DEFAULT_CHANGELOG_FILE = "CHANGELOG.md";
|
|
361
|
+
export declare const DEFAULT_PUBLISH_TAG = "latest";
|
|
362
|
+
export declare const DEFAULT_PRE_PUBLISH_TAG = "next";
|
|
363
|
+
export declare abstract class Project {
|
|
364
|
+
options: ProjectOptions;
|
|
365
|
+
manifest: ProjectManifest;
|
|
366
|
+
changedFiles: string[];
|
|
367
|
+
versionUpdates: ProjectVersionUpdate[];
|
|
368
|
+
protected constructor(options: ProjectOptions);
|
|
369
|
+
get hasBump(): boolean;
|
|
370
|
+
getHostedGitInfo(): Promise<HostedGitInfo>;
|
|
371
|
+
isMonorepoMode(): this is MonorepoProject;
|
|
372
|
+
getCommitMessage(): Promise<string>;
|
|
373
|
+
toTag(tagPrefix: string, version: string): string;
|
|
374
|
+
toBranch(branchPrefix: string, version: string): string;
|
|
375
|
+
getTagPrefix(override?: string): Promise<string>;
|
|
376
|
+
getTags(options?: ProjectTagsOptions): Promise<string[]>;
|
|
377
|
+
getReleaseData(options?: ProjectReleaseOptions): Promise<ReleaseData[]>;
|
|
378
|
+
isFirstRelease(options?: ProjectReleaseOptions): Promise<boolean>;
|
|
379
|
+
getLastReleaseTag(options?: ProjectReleaseOptions): Promise<string | undefined>;
|
|
380
|
+
isLatestRelease(options?: ProjectReleaseOptions): Promise<boolean>;
|
|
381
|
+
getDefaultPublishTag(options?: ProjectReleaseOptions): Promise<Map<string, string>>;
|
|
382
|
+
/** 在主要版本发布后创建维护分支引用 */
|
|
383
|
+
getMaintenanceBranches(options?: ProjectMaintenanceBranchesOptions): Promise<ProjectMaintenanceBranch[]>;
|
|
384
|
+
changelog(options?: ProjectBumpOptions & {
|
|
385
|
+
scope?: string[];
|
|
386
|
+
}): Changelog;
|
|
387
|
+
getNextVersion(options?: ProjectBumpOptions): Promise<string | undefined>;
|
|
388
|
+
inferReleaseType(options?: ProjectBumpOptions): Promise<ReleaseType | undefined>;
|
|
389
|
+
bump(options?: ProjectBumpOptions): Promise<boolean>;
|
|
390
|
+
revert(options?: ProjectRevertOptions, filesSet?: Set<string>): Promise<boolean>;
|
|
391
|
+
abstract publish(options?: ProjectPublishOptions): Promise<void>;
|
|
392
|
+
abstract publishCheck(options?: ProjectPublishCheckOptions): Promise<void>;
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/core/hosting/hosting.types.d.ts
|
|
396
|
+
export interface ReleaseData {
|
|
397
|
+
version: string;
|
|
398
|
+
title: string;
|
|
399
|
+
notes: string;
|
|
400
|
+
previousTag: string;
|
|
401
|
+
nextTag: string;
|
|
402
|
+
isPrerelease: boolean;
|
|
403
|
+
isLatest: boolean;
|
|
404
|
+
}
|
|
405
|
+
export interface CreateReleaseOptions {
|
|
406
|
+
project: Project;
|
|
407
|
+
dryRun?: boolean;
|
|
408
|
+
logger?: ChildLogger;
|
|
409
|
+
}
|
|
410
|
+
export interface CreatePullRequestOptions {
|
|
411
|
+
project: Project;
|
|
412
|
+
to?: string;
|
|
413
|
+
from?: string;
|
|
414
|
+
dryRun?: boolean;
|
|
415
|
+
logger?: ChildLogger;
|
|
416
|
+
}
|
|
417
|
+
export interface ReleaseCheckOptions {
|
|
418
|
+
logger?: ChildLogger;
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/core/hosting/hosting.d.ts
|
|
422
|
+
/** Git 仓库托管服务的基类 */
|
|
423
|
+
export declare abstract class GitRepositoryHosting {
|
|
424
|
+
/** 为提供的项目创建 release */
|
|
425
|
+
abstract createRelease(options: CreateReleaseOptions): Promise<void>;
|
|
426
|
+
/** 未提供的项目创建 pull request */
|
|
427
|
+
abstract createPullRequest(options: CreatePullRequestOptions): Promise<void>;
|
|
428
|
+
/** 检查创建 release 需要的条件 */
|
|
429
|
+
abstract releaseCheck(options?: ReleaseCheckOptions): Promise<void>;
|
|
430
|
+
}
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/core/project/packageJson.types.d.ts
|
|
433
|
+
export interface PackageJsonProjectOptions extends Omit<ProjectOptions, "manifest"> {
|
|
434
|
+
/**
|
|
435
|
+
* package.json 文件的路径。
|
|
436
|
+
*/
|
|
437
|
+
path?: string;
|
|
438
|
+
}
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/core/project/packageJson.d.ts
|
|
441
|
+
export declare class PackageJsonProject extends Project {
|
|
442
|
+
constructor(options?: Simplify<PackageJsonProjectOptions>);
|
|
443
|
+
override publish(_options?: ProjectPublishOptions): Promise<void>;
|
|
444
|
+
override publishCheck(_options?: ProjectPublishCheckOptions): Promise<void>;
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/core/project/packageJsonMonorepo.types.d.ts
|
|
448
|
+
export interface PackageJsonMonorepoProjectOptions extends Omit<MonorepoProjectOptions, "getProjects" | "manifest"> {
|
|
449
|
+
mode: MonorepoMode;
|
|
450
|
+
/**
|
|
451
|
+
* 单体仓库的根目录。
|
|
452
|
+
*/
|
|
453
|
+
root?: string;
|
|
454
|
+
/**
|
|
455
|
+
* 获取单体仓库中各项目的 package.json。
|
|
456
|
+
*/
|
|
457
|
+
getProjects(options: GetProjectsOptions): AsyncIterable<string>;
|
|
458
|
+
}
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/core/project/packageJsonMonorepo.d.ts
|
|
461
|
+
/**
|
|
462
|
+
* 基于 package.json 的单体仓库项目。
|
|
463
|
+
*/
|
|
464
|
+
export declare class PackageJsonMonorepoProject extends MonorepoProject {
|
|
465
|
+
constructor(options: Simplify<PackageJsonMonorepoProjectOptions>);
|
|
466
|
+
override publish(_options?: ProjectPublishOptions): Promise<void>;
|
|
467
|
+
override publishCheck(_options?: ProjectPublishCheckOptions): Promise<void>;
|
|
468
|
+
}
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/core/releaser.type.d.ts
|
|
471
|
+
export type PickOverridableOptions<T extends AnyFunction> = Partial<Omit<Exclude<Parameters<T>[0], undefined>, "dryRun" | "logger" | "tagPrefix" | "project">>;
|
|
472
|
+
export interface ReleaserOptions<P extends Project = Project, G extends GitRepositoryHosting = GitRepositoryHosting> {
|
|
473
|
+
/**
|
|
474
|
+
* 要发布的项目。
|
|
475
|
+
*/
|
|
476
|
+
project: P;
|
|
477
|
+
/**
|
|
478
|
+
* 用于创建 Release 和拉取请求的 Git 仓库托管服务。
|
|
479
|
+
*/
|
|
480
|
+
hosting?: G;
|
|
481
|
+
dryRun?: boolean;
|
|
482
|
+
silent?: boolean;
|
|
483
|
+
verbose?: boolean;
|
|
484
|
+
logger?: Logger;
|
|
485
|
+
}
|
|
486
|
+
export interface ReleaserCheckoutOptions {
|
|
487
|
+
branch?: string;
|
|
488
|
+
/**
|
|
489
|
+
* 如果分支已存在,则删除并重新创建。
|
|
490
|
+
*/
|
|
491
|
+
force?: boolean;
|
|
492
|
+
/**
|
|
493
|
+
* 强制从远程仓库获取所有提交和标签。
|
|
494
|
+
*/
|
|
495
|
+
fetch?: boolean;
|
|
496
|
+
}
|
|
497
|
+
export interface ReleaserSetUserOptions {
|
|
498
|
+
/**
|
|
499
|
+
* 设置 Git 用户名。
|
|
500
|
+
*/
|
|
501
|
+
username?: string;
|
|
502
|
+
/**
|
|
503
|
+
* 设置 Git 用户邮箱。
|
|
504
|
+
*/
|
|
505
|
+
email?: string;
|
|
506
|
+
}
|
|
507
|
+
export interface ReleaserCommitOptions {
|
|
508
|
+
sign?: boolean;
|
|
509
|
+
allowEmpty?: boolean;
|
|
510
|
+
}
|
|
511
|
+
export interface ReleaserTagOptions {
|
|
512
|
+
sign?: boolean;
|
|
513
|
+
/** 在创建标签之前,从远程仓库获取最新的标签 */
|
|
514
|
+
fetch?: boolean;
|
|
515
|
+
}
|
|
516
|
+
export interface ReleaserPushOptions {
|
|
517
|
+
/** 强制推送分支 */
|
|
518
|
+
force?: boolean;
|
|
519
|
+
}
|
|
520
|
+
export interface ReleaserMaintenanceBranchOptions {
|
|
521
|
+
/** 强制创建分支 */
|
|
522
|
+
force?: boolean;
|
|
523
|
+
/** 启用维护分支创建 */
|
|
524
|
+
enabled?: boolean;
|
|
525
|
+
}
|
|
526
|
+
export interface ReleaserStepsOptions<P extends Project = Project, G extends GitRepositoryHosting = GitRepositoryHosting> {
|
|
527
|
+
setUser?: ReleaserSetUserOptions;
|
|
528
|
+
maintenanceBranch?: ReleaserMaintenanceBranchOptions;
|
|
529
|
+
checkout?: ReleaserCheckoutOptions;
|
|
530
|
+
bump?: PickOverridableOptions<P["bump"]>;
|
|
531
|
+
commit?: ReleaserCommitOptions;
|
|
532
|
+
tag?: ReleaserTagOptions;
|
|
533
|
+
push?: ReleaserPushOptions;
|
|
534
|
+
publish?: PickOverridableOptions<P["publish"]>;
|
|
535
|
+
release?: PickOverridableOptions<G["createRelease"]>;
|
|
536
|
+
pullRequest?: PickOverridableOptions<G["createPullRequest"]>;
|
|
537
|
+
}
|
|
538
|
+
export type ReleaserStep = keyof ReleaserStepsOptions;
|
|
539
|
+
export type ReleaserSkipOptions = Partial<Record<ReleaserStep, boolean>>;
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/core/releaser.d.ts
|
|
542
|
+
export declare class Releaser<P extends Project = Project, G extends GitRepositoryHosting = GitRepositoryHosting> {
|
|
543
|
+
options: ReleaserOptions<P, G>;
|
|
544
|
+
readonly project: P;
|
|
545
|
+
readonly hosting?: G;
|
|
546
|
+
readonly logger: Logger;
|
|
547
|
+
readonly stepsOptions: ReleaserStepsOptions<P, G>;
|
|
548
|
+
protected readonly skippedSteps: ReleaserSkipOptions;
|
|
549
|
+
protected readonly state: {
|
|
550
|
+
headBranch?: string;
|
|
551
|
+
baseBranch?: string;
|
|
552
|
+
bump?: boolean;
|
|
553
|
+
tags?: boolean;
|
|
554
|
+
};
|
|
555
|
+
private readonly queue;
|
|
556
|
+
constructor(options: ReleaserOptions<P, G>);
|
|
557
|
+
enqueue(fn: () => Promise<void>): this;
|
|
558
|
+
setOptions(options: ReleaserStepsOptions<P, G>): this;
|
|
559
|
+
setUser(options?: ReleaserSetUserOptions): this;
|
|
560
|
+
setSkippedSteps(options: ReleaserSkipOptions): this;
|
|
561
|
+
checkout(options?: ReleaserCheckoutOptions): this;
|
|
562
|
+
bump(options?: PickOverridableOptions<P["bump"]>): this;
|
|
563
|
+
commit(options?: ReleaserCommitOptions): this;
|
|
564
|
+
revert(): this;
|
|
565
|
+
maintenanceBranch(options?: ReleaserMaintenanceBranchOptions): this;
|
|
566
|
+
tag(options?: ReleaserTagOptions): this;
|
|
567
|
+
push(options?: ReleaserPushOptions): this;
|
|
568
|
+
publish(options?: PickOverridableOptions<P["publish"]>): this;
|
|
569
|
+
release(option?: PickOverridableOptions<G["createRelease"]>): this;
|
|
570
|
+
pullRequest(option?: PickOverridableOptions<G["createPullRequest"]>): this;
|
|
571
|
+
run(condition?: (releaser: this) => Promise<boolean>): Promise<void>;
|
|
572
|
+
protected shouldSkip(step: ReleaserStep): boolean;
|
|
573
|
+
private getBaseBranch;
|
|
574
|
+
}
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region src/config/index.d.ts
|
|
577
|
+
export interface UserConfig<P extends Project = Project, G extends GitRepositoryHosting = GitRepositoryHosting> extends ReleaserStepsOptions<P, G> {
|
|
578
|
+
project?: P;
|
|
579
|
+
hosting?: G;
|
|
580
|
+
releaser?: Omit<ReleaserOptions, "project" | "hosting">;
|
|
581
|
+
}
|
|
582
|
+
export declare const defineConfig: <P extends Project = Project, G extends GitRepositoryHosting = GitRepositoryHosting>(config: UserConfig<P, G>) => UserConfig<P, G>;
|
|
583
|
+
export declare const loadJavaScriptFile: <T extends object>(file: string) => Promise<T>;
|
|
584
|
+
export declare const findFile: (cwd: string, filename: string, extensions: string[]) => string | undefined;
|
|
585
|
+
export declare const loadConfig: <T extends object>(cwd?: string) => Promise<{
|
|
586
|
+
file: string;
|
|
587
|
+
config: T;
|
|
588
|
+
}>;
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/hosting-github/github.type.d.ts
|
|
591
|
+
export interface GithubOptions {
|
|
592
|
+
/**
|
|
593
|
+
* 用于通过 GitHub API 进行身份验证的 GitHub Personal Access Token。
|
|
594
|
+
*/
|
|
595
|
+
token?: string;
|
|
596
|
+
/**
|
|
597
|
+
* 用于发起 API 请求的 GitHub Octokit 实例。
|
|
598
|
+
*/
|
|
599
|
+
octokit?: Octokit$1;
|
|
600
|
+
/**
|
|
601
|
+
* GitHub 仓库的所有者(用户名或组织)。
|
|
602
|
+
* 如果未提供,则会从远程仓库 URL 中自动推断。
|
|
603
|
+
*/
|
|
604
|
+
owner?: string;
|
|
605
|
+
/**
|
|
606
|
+
* 用于创建 Release 的 GitHub 项目(仓库)名称。
|
|
607
|
+
* 如果未提供,则会从远程仓库 URL 中自动推断。
|
|
608
|
+
*/
|
|
609
|
+
repo?: string;
|
|
610
|
+
/**
|
|
611
|
+
* web-based GitHub Release
|
|
612
|
+
*/
|
|
613
|
+
browser?: boolean;
|
|
614
|
+
}
|
|
615
|
+
export interface GithubCreatePullRequestOptions extends CreatePullRequestOptions {
|
|
616
|
+
draft?: boolean;
|
|
617
|
+
}
|
|
618
|
+
export interface UploadAssetsOptions {
|
|
619
|
+
owner: string;
|
|
620
|
+
repo: string;
|
|
621
|
+
release_id: number;
|
|
622
|
+
assets: string[];
|
|
623
|
+
}
|
|
624
|
+
export interface GetReleaseOptions {
|
|
625
|
+
owner: string;
|
|
626
|
+
repo: string;
|
|
627
|
+
tag: string;
|
|
628
|
+
}
|
|
629
|
+
export type RepositoryId = [owner: string, repo: string];
|
|
630
|
+
export interface ListPullRequestOptions {
|
|
631
|
+
owner: string;
|
|
632
|
+
repo: string;
|
|
633
|
+
from: string;
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/hosting-github/github.d.ts
|
|
637
|
+
export declare class GithubHosting extends GitRepositoryHosting {
|
|
638
|
+
private readonly options;
|
|
639
|
+
readonly octokit: Octokit;
|
|
640
|
+
readonly browser: boolean;
|
|
641
|
+
constructor(options?: GithubOptions);
|
|
642
|
+
createRelease(options: CreateReleaseOptions): Promise<void>;
|
|
643
|
+
createPullRequest(options: GithubCreatePullRequestOptions): Promise<void>;
|
|
644
|
+
releaseCheck(options?: ReleaseCheckOptions): Promise<void>;
|
|
645
|
+
getRepositoryId(project: Project): Promise<RepositoryId>;
|
|
646
|
+
private uploadAssets;
|
|
647
|
+
private getRelease;
|
|
648
|
+
private listPullRequest;
|
|
649
|
+
private getDefaultBranch;
|
|
650
|
+
private getPullRequestData;
|
|
239
651
|
}
|
|
240
|
-
type GOptions = Simplify<GenerateOptions & ParsePresetOptions>;
|
|
241
|
-
declare const createGenerator: (options: GOptions) => Promise<ConventionalChangelog>;
|
|
242
|
-
declare const getChangelog: (options: GOptions) => Promise<string>;
|
|
243
|
-
declare const generateChangelog: (options: GOptions) => Promise<void>;
|
|
244
652
|
//#endregion
|
|
245
|
-
//#region src/
|
|
246
|
-
interface
|
|
653
|
+
//#region src/project-github-action/publish.d.ts
|
|
654
|
+
export interface PublishOptions extends ProjectPublishOptions {
|
|
655
|
+
/**
|
|
656
|
+
* 发布引用前要运行的构建或安装命令。
|
|
657
|
+
*/
|
|
658
|
+
build?: string | string[];
|
|
247
659
|
/**
|
|
248
|
-
*
|
|
249
|
-
* @example v1.0.0; pkg@1.0.1;
|
|
250
|
-
* @example my-cli v1.0.0;
|
|
660
|
+
* 构建后要暂存的文件。默认使用 package.json 中的 `files`。
|
|
251
661
|
*/
|
|
252
|
-
|
|
253
|
-
/** @defaults `@` */
|
|
254
|
-
tagSeparator?: string;
|
|
662
|
+
files?: string[];
|
|
255
663
|
/**
|
|
256
|
-
*
|
|
257
|
-
* @
|
|
664
|
+
* 运行构建命令前要设置的环境变量。
|
|
665
|
+
* @default process.env
|
|
258
666
|
*/
|
|
259
|
-
|
|
667
|
+
env?: Record<string, string | undefined>;
|
|
668
|
+
}
|
|
669
|
+
export declare const publish: (project: NodeGithubActionProject, options?: PublishOptions) => Promise<void>;
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/project-github-action/project.d.ts
|
|
672
|
+
export interface NodeGithubActionProjectOptions extends PackageJsonProjectOptions {
|
|
673
|
+
/**
|
|
674
|
+
* 版本标签的前缀。
|
|
675
|
+
* @default 'v'
|
|
676
|
+
*/
|
|
677
|
+
tagPrefix?: string;
|
|
678
|
+
}
|
|
679
|
+
export type NodeGithubActionProjectBumpOptions = ProjectBumpOptions;
|
|
680
|
+
export type NodeGithubActionProjectPublishOptions = PublishOptions;
|
|
681
|
+
/** Node.js GitHub Actions 项目,将版本引用发布到 Git 分支和标签 */
|
|
682
|
+
export declare class NodeGithubActionProject extends PackageJsonProject {
|
|
683
|
+
options: NodeGithubActionProjectOptions & ProjectOptions;
|
|
260
684
|
/**
|
|
261
|
-
*
|
|
685
|
+
* 获取项目最近一次发布的标签。
|
|
686
|
+
* GitHub Action 发布标签指向发布分支中的打包提交,无法从源分支到达。因此需要遍历所有引用,并通过标签的父提交判断它是否属于当前分支。
|
|
262
687
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
688
|
+
override getLastReleaseTag(options?: ProjectReleaseOptions): Promise<string | undefined>;
|
|
689
|
+
override publish(options?: NodeGithubActionProjectPublishOptions): Promise<void>;
|
|
690
|
+
override publishCheck(options: ProjectPublishCheckOptions): Promise<void>;
|
|
691
|
+
constructor(options?: NodeGithubActionProjectOptions);
|
|
692
|
+
private isReachableFromHead;
|
|
693
|
+
}
|
|
694
|
+
//#endregion
|
|
695
|
+
//#region src/project-npm/publish.d.ts
|
|
696
|
+
interface CleanupOptions$1 {
|
|
697
|
+
/** 是否清理项目内容后再发布 */
|
|
698
|
+
cleanPublish?: boolean;
|
|
699
|
+
/** package.json 需要忽略的字段,支持 `a.b.c` */
|
|
700
|
+
ignoreFields?: string[];
|
|
701
|
+
/** package.json 需要保留的脚本,默认:`preinstall | install | postinstall` */
|
|
702
|
+
keepScripts?: string[];
|
|
703
|
+
/** 是否精简 README.md,仅保留主要内容 */
|
|
704
|
+
cleanReadme?: boolean;
|
|
705
|
+
}
|
|
706
|
+
interface PublishOptions$2 extends ProjectPublishOptions, CleanupOptions$1 {
|
|
707
|
+
access?: string;
|
|
708
|
+
registry?: string;
|
|
709
|
+
otp?: string;
|
|
710
|
+
env?: Record<string, string | undefined>;
|
|
711
|
+
}
|
|
712
|
+
//#endregion
|
|
713
|
+
//#region src/project-npm/project.d.ts
|
|
714
|
+
export type NpmProjectOptions = PackageJsonProjectOptions;
|
|
715
|
+
export type NpmProjectBumpOptions = ProjectBumpOptions;
|
|
716
|
+
export type NpmProjectPublishOptions = PublishOptions$2;
|
|
717
|
+
/** 一个基于 npm 的项目,使用 package.json 进行配置 */
|
|
718
|
+
export declare class NpmProject extends PackageJsonProject {
|
|
719
|
+
override publish(options?: NpmProjectPublishOptions): Promise<void>;
|
|
720
|
+
override publishCheck(options?: ProjectPublishCheckOptions): Promise<void>;
|
|
721
|
+
}
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/project-npm/workspacesProject.d.ts
|
|
724
|
+
export type NpmWorkspacesProjectOptions = Omit<PackageJsonMonorepoProjectOptions, "getProjects">;
|
|
725
|
+
export type NpmWorkspacesProjectBumpOptions = ProjectBumpOptions;
|
|
726
|
+
export type NpmWorkspacesProjectPublishOptions = PublishOptions$2;
|
|
727
|
+
/** 一个基于 npm workspaces 的 monorepo 项目,使用 package.json 的 workspaces 进行配置 */
|
|
728
|
+
export declare class NpmWorkspacesProject extends PackageJsonMonorepoProject {
|
|
729
|
+
static GlobIgnore: string[];
|
|
730
|
+
constructor(options: NpmWorkspacesProjectOptions);
|
|
731
|
+
override publish(options?: NpmWorkspacesProjectPublishOptions): Promise<void>;
|
|
732
|
+
override publishCheck(options?: ProjectPublishCheckOptions): Promise<void>;
|
|
733
|
+
}
|
|
734
|
+
//#endregion
|
|
735
|
+
//#region src/project-pnpm/publish.d.ts
|
|
736
|
+
interface CleanupOptions {
|
|
737
|
+
/** 是否清理项目内容后再发布 */
|
|
738
|
+
cleanPublish?: boolean;
|
|
739
|
+
/** package.json 需要忽略的字段,支持 `a.b.c` */
|
|
740
|
+
ignoreFields?: string[];
|
|
741
|
+
/** package.json 需要保留的脚本,默认:`preinstall | install | postinstall` */
|
|
742
|
+
keepScripts?: string[];
|
|
743
|
+
/** 是否精简 README.md,仅保留主要内容 */
|
|
744
|
+
cleanReadme?: boolean;
|
|
745
|
+
}
|
|
746
|
+
interface PublishOptions$1 extends ProjectPublishOptions, CleanupOptions {
|
|
747
|
+
access?: string;
|
|
748
|
+
registry?: string;
|
|
749
|
+
otp?: string;
|
|
750
|
+
env?: Record<string, string | undefined>;
|
|
751
|
+
/** 是否在发布前执行 git 检查 */
|
|
752
|
+
gitChecks?: boolean;
|
|
753
|
+
}
|
|
754
|
+
//#endregion
|
|
755
|
+
//#region src/project-pnpm/project.d.ts
|
|
756
|
+
export type PnpmProjectOptions = PackageJsonProjectOptions;
|
|
757
|
+
export type PnpmProjectBumpOptions = ProjectBumpOptions;
|
|
758
|
+
export type PnpmProjectPublishOptions = PublishOptions$1;
|
|
759
|
+
/** 一个基于 pnpm 的项目,使用 package.json 进行配置 */
|
|
760
|
+
export declare class PnpmProject extends PackageJsonProject {
|
|
761
|
+
override publish(options?: PnpmProjectPublishOptions): Promise<void>;
|
|
762
|
+
override publishCheck(options?: ProjectPublishCheckOptions): Promise<void>;
|
|
763
|
+
}
|
|
764
|
+
//#endregion
|
|
765
|
+
//#region src/project-pnpm/workspacesProject.d.ts
|
|
766
|
+
export type PnpmWorkspacesProjectOptions = Omit<PackageJsonMonorepoProjectOptions, "getProjects">;
|
|
767
|
+
export type PnpmWorkspacesProjectBumpOptions = ProjectBumpOptions;
|
|
768
|
+
export type PnpmWorkspacesProjectPublishOptions = PublishOptions$1;
|
|
769
|
+
/** 一个基于 pnpm 工作区的单体仓库项目,使用 package.json 和 pnpm-workspace.yaml 进行配置 */
|
|
770
|
+
export declare class PnpmWorkspacesProject extends PackageJsonMonorepoProject {
|
|
771
|
+
static WorkspaceFile: string;
|
|
772
|
+
static GlobIgnore: string[];
|
|
773
|
+
constructor(options: PnpmWorkspacesProjectOptions);
|
|
774
|
+
override publish(options?: PnpmWorkspacesProjectPublishOptions): Promise<void>;
|
|
775
|
+
override publishCheck(options?: ProjectPublishCheckOptions): Promise<void>;
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/releaser-github-action/releaser.d.ts
|
|
779
|
+
export interface ReleaserGithubActionOptions<P extends Project = Project> extends Omit<ReleaserOptions<P, GithubHosting>, "hosting"> {
|
|
780
|
+
/** 用于进行 GitHub API 调用的 Octokit 实例 */
|
|
781
|
+
octokit: ReturnType<typeof getOctokit>;
|
|
782
|
+
}
|
|
783
|
+
export declare class ReleaserGithubAction<P extends Project = Project> extends Releaser<P, GithubHosting> {
|
|
784
|
+
readonly hosting: GithubHosting;
|
|
785
|
+
override setUser(options?: ReleaserSetUserOptions): this;
|
|
786
|
+
override checkout(options?: ReleaserCheckoutOptions): this;
|
|
787
|
+
override tag(options?: ReleaserTagOptions): this;
|
|
788
|
+
override push(options?: ReleaserPushOptions): this;
|
|
789
|
+
constructor(options: Simplify<ReleaserGithubActionOptions<P>>);
|
|
790
|
+
fetchOptions(): this;
|
|
791
|
+
fetch(): this;
|
|
792
|
+
runPullRequestAction(): Promise<void>;
|
|
793
|
+
runReleaseAction(check?: boolean): Promise<void>;
|
|
794
|
+
runSnapshotAction(snapshotTag: string): Promise<void>;
|
|
795
|
+
runAction(): Promise<void>;
|
|
796
|
+
}
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region src/releaser-github-action/conditions.d.ts
|
|
799
|
+
export declare const ifReleaseCommit: (releaser: ReleaserGithubAction) => Promise<boolean>;
|
|
800
|
+
/**
|
|
801
|
+
* 检测当前事件是否为针对处于打开状态的发布拉取请求的受支持命令评论:
|
|
802
|
+
* (`!release/set-options` 或 `!release/set-preamble`)
|
|
803
|
+
*
|
|
804
|
+
* @returns 如果是此类评论,则返回 `目标分支`;如果是评论事件但不是命令评论,则返回 `false`;如果根本不是评论事件,则返回 `null`
|
|
805
|
+
*/
|
|
806
|
+
export declare const ifCommandComment: () => string | false | null;
|
|
807
|
+
//#endregion
|
|
808
|
+
//#region src/releaser-github-action/options.d.ts
|
|
809
|
+
interface InputOptions<T> {
|
|
810
|
+
checkout: Partial<{
|
|
811
|
+
branch: string;
|
|
812
|
+
}>;
|
|
813
|
+
bump: Partial<{
|
|
814
|
+
version: string;
|
|
815
|
+
as: ReleaseType;
|
|
816
|
+
prerelease: string;
|
|
817
|
+
snapshot: string;
|
|
818
|
+
firstRelease: boolean;
|
|
819
|
+
skip: boolean;
|
|
820
|
+
/** monorepo bump */
|
|
821
|
+
byProject: T;
|
|
822
|
+
}>;
|
|
823
|
+
maintenanceBranch: Partial<{
|
|
824
|
+
enabled: boolean;
|
|
825
|
+
}>;
|
|
826
|
+
publish: Partial<{
|
|
827
|
+
skip: boolean;
|
|
828
|
+
/** npm publish */
|
|
829
|
+
access: string;
|
|
830
|
+
tag: string;
|
|
831
|
+
}>;
|
|
832
|
+
}
|
|
833
|
+
export declare const getInputOptions: <T extends Dict>() => InputOptions<T>;
|
|
834
|
+
export declare const getInputSkippedSteps: () => ReleaserSkipOptions;
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/releaser-cli/releaser.d.ts
|
|
837
|
+
export interface ReleaserCliRunOptions {
|
|
838
|
+
dryRun?: boolean;
|
|
839
|
+
ci?: boolean;
|
|
840
|
+
skipGit?: boolean;
|
|
841
|
+
skipPublish?: boolean;
|
|
842
|
+
skipRelease?: boolean;
|
|
843
|
+
releaseType?: ReleaseType;
|
|
844
|
+
}
|
|
845
|
+
export interface CliStepsSkip {
|
|
846
|
+
commit?: boolean;
|
|
847
|
+
tag?: boolean;
|
|
848
|
+
push?: boolean;
|
|
849
|
+
publish?: boolean;
|
|
850
|
+
release?: boolean;
|
|
851
|
+
}
|
|
852
|
+
export type ReleaserCliOptions<P extends Project = Project, G extends GitRepositoryHosting = GitRepositoryHosting> = ReleaserOptions<P, G>;
|
|
853
|
+
export declare class ReleaserCli<P extends Project = Project, G extends GitRepositoryHosting = GitRepositoryHosting> extends Releaser<P, G> {
|
|
854
|
+
constructor(options: ReleaserCliOptions<P, G>);
|
|
855
|
+
override tag(options?: ReleaserTagOptions): this;
|
|
856
|
+
override push(options?: ReleaserPushOptions): this;
|
|
857
|
+
override run(...args: []): Promise<void>;
|
|
858
|
+
setCliOptions(options: ReleaserCliRunOptions): this;
|
|
859
|
+
setLegacyOptions(): this;
|
|
860
|
+
check(): this;
|
|
861
|
+
start(): this;
|
|
862
|
+
end(): void;
|
|
863
|
+
runAction(options: ReleaserCliRunOptions): Promise<void>;
|
|
266
864
|
}
|
|
267
|
-
declare const publishTagToNpm: (options: PublishTagOptions) => Promise<void>;
|
|
268
865
|
//#endregion
|
|
269
|
-
export {
|
|
866
|
+
export { Octokit };
|