@peiyanlu/release 0.0.3 → 0.0.5
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 +147 -20
- package/dist/cli.mjs +302 -452
- package/dist/index.d.mts +35 -43
- package/package.json +14 -11
- package/dist/index.cjs +0 -26
- package/dist/index.d.cts +0 -166
package/dist/index.d.mts
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import { DeepPartial, DeepRequired } from "@peiyanlu/ts-utils";
|
|
2
|
+
import { log } from "@clack/prompts";
|
|
2
3
|
|
|
3
|
-
//#region src/git/changetype.d.ts
|
|
4
|
-
interface CommitType {
|
|
5
|
-
type: string;
|
|
6
|
-
section: string;
|
|
7
|
-
description: string;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
4
|
//#region src/types.d.ts
|
|
11
5
|
|
|
6
|
+
type Logger = typeof log;
|
|
12
7
|
type HookTiming = 'before' | 'after';
|
|
13
8
|
type HookAction = 'bump' | 'publish' | 'push' | 'release';
|
|
14
9
|
type ReleaseHookKey = `${HookTiming}:${HookAction}`;
|
|
15
|
-
type ReleaseHookValue = string | string[] | (() => Promise<void> | void);
|
|
10
|
+
type ReleaseHookValue = string | string[] | ((logger: Logger) => Promise<void> | void);
|
|
16
11
|
type HookConfig = { [key in ReleaseHookKey]: ReleaseHookValue };
|
|
17
12
|
interface ReleaseConfig {
|
|
18
13
|
/**
|
|
19
14
|
* 生命周期钩子配置
|
|
15
|
+
* 用于在 Release 关键阶段注入自定义逻辑(如 before/after hooks)。
|
|
20
16
|
*/
|
|
21
17
|
hooks: HookConfig;
|
|
18
|
+
/** 是否是 monorepo */
|
|
19
|
+
isMonorepo: boolean;
|
|
20
|
+
/** 使用 monorepo 时发布的包列表,后续回调的 `pkg`。默认为 `[]` 作为单仓库 */
|
|
21
|
+
packages: string[];
|
|
22
|
+
/** 使用 monorepo 时使用 getPkgDir,例如 `packages/${pkg}`。 默认为 `.` 作为单仓库 */
|
|
23
|
+
getPkgDir: (pkg: string) => string;
|
|
24
|
+
/** 使用 monorepo 时使用 toTag,例如 `${pkg}@${version}`,默认为 `v${version}` 作为单仓库 */
|
|
25
|
+
toTag: (pkg: string, version: string) => string;
|
|
26
|
+
/** 作为 CHANGELOG 标题的 Tag 前缀,多包场景下需要 `${pkg}@` */
|
|
27
|
+
tagPrefix: ((pkg: string) => string | undefined) | undefined;
|
|
22
28
|
/**
|
|
23
29
|
* Git 相关配置
|
|
30
|
+
* 影响提交、打 tag、推送等本地/远程 Git 行为。
|
|
24
31
|
*/
|
|
25
32
|
git: {
|
|
26
33
|
/**
|
|
27
|
-
*
|
|
34
|
+
* 是否创建 Git 提交
|
|
28
35
|
*/
|
|
29
36
|
commit: boolean | undefined;
|
|
30
37
|
/**
|
|
@@ -40,7 +47,7 @@ interface ReleaseConfig {
|
|
|
40
47
|
*/
|
|
41
48
|
commitMessage: string;
|
|
42
49
|
/**
|
|
43
|
-
* 额外的 git commit
|
|
50
|
+
* 额外的 git commit 参数(透传给 git CLI)
|
|
44
51
|
*/
|
|
45
52
|
commitArgs: string[];
|
|
46
53
|
/**
|
|
@@ -48,27 +55,23 @@ interface ReleaseConfig {
|
|
|
48
55
|
*/
|
|
49
56
|
tagMessage: string;
|
|
50
57
|
/**
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
tagName: string;
|
|
54
|
-
/**
|
|
55
|
-
* 额外的 git tag 参数
|
|
58
|
+
* 额外的 git tag 参数(透传给 git CLI)
|
|
56
59
|
*/
|
|
57
60
|
tagArgs: string[];
|
|
58
61
|
/**
|
|
59
|
-
* 额外的 git push
|
|
62
|
+
* 额外的 git push 参数(透传给 git CLI)
|
|
60
63
|
*/
|
|
61
64
|
pushArgs: string[];
|
|
62
65
|
/**
|
|
63
|
-
*
|
|
66
|
+
* 是否自动添加未追踪的文件(git add -A)
|
|
64
67
|
*/
|
|
65
68
|
addUntrackedFiles: boolean;
|
|
66
69
|
/**
|
|
67
|
-
*
|
|
70
|
+
* 是否要求必须配置远程仓库(存在 git remote)
|
|
68
71
|
*/
|
|
69
72
|
requireRemote: boolean;
|
|
70
73
|
/**
|
|
71
|
-
*
|
|
74
|
+
* 是否要求当前工作目录必须是 Git 仓库
|
|
72
75
|
*/
|
|
73
76
|
requireRepository: boolean;
|
|
74
77
|
/**
|
|
@@ -78,27 +81,29 @@ interface ReleaseConfig {
|
|
|
78
81
|
};
|
|
79
82
|
/**
|
|
80
83
|
* NPM 发布相关配置
|
|
84
|
+
* 影响 npm publish 的目标路径、参数与前置校验。
|
|
81
85
|
*/
|
|
82
86
|
npm: {
|
|
83
87
|
/**
|
|
84
|
-
*
|
|
88
|
+
* 是否启用 npm 发布流程
|
|
85
89
|
*/
|
|
86
90
|
publish: boolean | undefined;
|
|
87
91
|
/**
|
|
88
|
-
*
|
|
92
|
+
* npm 发布目标路径,对应 `npm publish <package-spec>`
|
|
89
93
|
*/
|
|
90
94
|
publishPath: string;
|
|
91
95
|
/**
|
|
92
|
-
* 额外的 npm publish
|
|
96
|
+
* 额外的 npm publish 参数(透传给 npm CLI)
|
|
93
97
|
*/
|
|
94
98
|
pushArgs: string[];
|
|
95
99
|
/**
|
|
96
|
-
*
|
|
100
|
+
* 是否跳过发布前检查(如 ping、whoami 等校验)
|
|
97
101
|
*/
|
|
98
102
|
skipChecks: boolean;
|
|
99
103
|
};
|
|
100
104
|
/**
|
|
101
105
|
* GitHub Release 相关配置
|
|
106
|
+
* 控制是否创建 Release、发布方式以及上传资源。
|
|
102
107
|
*/
|
|
103
108
|
github: {
|
|
104
109
|
/**
|
|
@@ -106,27 +111,27 @@ interface ReleaseConfig {
|
|
|
106
111
|
*/
|
|
107
112
|
release: boolean | undefined;
|
|
108
113
|
/**
|
|
109
|
-
* Release
|
|
114
|
+
* Release 展示名称(标题)
|
|
110
115
|
*/
|
|
111
116
|
releaseName: string;
|
|
112
117
|
/**
|
|
113
|
-
*
|
|
118
|
+
* 是否由 GitHub 自动生成 Release Notes(通常用于 CI)
|
|
114
119
|
*/
|
|
115
120
|
autoGenerate: boolean;
|
|
116
121
|
/**
|
|
117
|
-
*
|
|
122
|
+
* 是否标记为预发布版本(pre-release)
|
|
118
123
|
*/
|
|
119
124
|
prerelease: boolean;
|
|
120
125
|
/**
|
|
121
|
-
*
|
|
126
|
+
* 是否创建为草稿(draft)
|
|
122
127
|
*/
|
|
123
128
|
draft: boolean;
|
|
124
129
|
/**
|
|
125
|
-
* GitHub Token
|
|
130
|
+
* GitHub Token 引用名称(用于从环境变量或配置中读取)
|
|
126
131
|
*/
|
|
127
132
|
tokenRef: string;
|
|
128
133
|
/**
|
|
129
|
-
*
|
|
134
|
+
* 需要上传到 Release 的资源文件列表
|
|
130
135
|
*/
|
|
131
136
|
assets: string[];
|
|
132
137
|
/**
|
|
@@ -134,19 +139,6 @@ interface ReleaseConfig {
|
|
|
134
139
|
*/
|
|
135
140
|
skipChecks: boolean;
|
|
136
141
|
};
|
|
137
|
-
/**
|
|
138
|
-
* Changelog 生成相关配置
|
|
139
|
-
*/
|
|
140
|
-
changelog: {
|
|
141
|
-
/**
|
|
142
|
-
* Changelog 输入文件路径
|
|
143
|
-
*/
|
|
144
|
-
infile: string;
|
|
145
|
-
/**
|
|
146
|
-
* 用于生成 Changelog 的提交类型映射规则
|
|
147
|
-
*/
|
|
148
|
-
types: CommitType[];
|
|
149
|
-
};
|
|
150
142
|
}
|
|
151
143
|
//#endregion
|
|
152
144
|
//#region src/config.d.ts
|
|
@@ -163,4 +155,4 @@ declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
|
163
155
|
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
164
156
|
declare const mergeConfig: <T extends object>(defaults: DeepRequired<T>, overrides?: DeepPartial<T>) => DeepRequired<T>;
|
|
165
157
|
//#endregion
|
|
166
|
-
export { type UserConfig, defineConfig, mergeConfig };
|
|
158
|
+
export { type Logger, type UserConfig, defineConfig, mergeConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peiyanlu/release",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Release project tool.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,38 +13,41 @@
|
|
|
13
13
|
"import": {
|
|
14
14
|
"types": "./dist/index.d.mts",
|
|
15
15
|
"default": "./dist/index.mjs"
|
|
16
|
-
},
|
|
17
|
-
"require": {
|
|
18
|
-
"types": "./dist/index.d.cts",
|
|
19
|
-
"default": "./dist/index.cjs"
|
|
20
16
|
}
|
|
21
|
-
}
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
22
19
|
},
|
|
23
20
|
"scripts": {
|
|
24
21
|
"dev": "tsdown -w",
|
|
25
22
|
"build": "tsdown",
|
|
26
23
|
"prepublish": "tsdown",
|
|
27
|
-
"
|
|
24
|
+
"release": "tsdown && node index.js",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:cov": "vitest run --coverage"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
29
|
"@clack/prompts": "^0.11.0",
|
|
31
30
|
"@octokit/rest": "^22.0.1",
|
|
32
|
-
"@peiyanlu/cli-utils": "^0.0.
|
|
31
|
+
"@peiyanlu/cli-utils": "^0.0.6",
|
|
33
32
|
"@peiyanlu/ts-utils": "^0.0.4",
|
|
34
33
|
"ansis": "^4.2.0",
|
|
35
34
|
"commander": "^14.0.2",
|
|
35
|
+
"conventional-changelog": "^7.1.1",
|
|
36
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
36
37
|
"mime-types": "^3.0.2",
|
|
37
38
|
"open": "^11.0.0",
|
|
39
|
+
"publint": "^0.3.17",
|
|
38
40
|
"semver": "^7.7.3",
|
|
39
41
|
"tinyglobby": "^0.2.15"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
|
-
"@types/semver": "^7.7.1",
|
|
43
44
|
"@types/mime-types": "^3.0.1",
|
|
44
45
|
"@types/node": "^24.10.3",
|
|
46
|
+
"@types/semver": "^7.7.1",
|
|
47
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
45
48
|
"tsdown": "^0.18.4",
|
|
46
49
|
"typescript": "^5.9.3",
|
|
47
|
-
"vitest": "^4.0.
|
|
50
|
+
"vitest": "^4.0.18"
|
|
48
51
|
},
|
|
49
52
|
"author": {
|
|
50
53
|
"name": "YanluPei",
|
|
@@ -66,7 +69,7 @@
|
|
|
66
69
|
},
|
|
67
70
|
"repository": {
|
|
68
71
|
"type": "git",
|
|
69
|
-
"url": "https://github.com/peiyanlu/release.git"
|
|
72
|
+
"url": "git+https://github.com/peiyanlu/release.git"
|
|
70
73
|
},
|
|
71
74
|
"bugs": {
|
|
72
75
|
"url": "https://github.com/peiyanlu/release/issues"
|
package/dist/index.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
let _peiyanlu_ts_utils = require("@peiyanlu/ts-utils");
|
|
2
|
-
|
|
3
|
-
//#region src/config.ts
|
|
4
|
-
function defineConfig(config) {
|
|
5
|
-
return config;
|
|
6
|
-
}
|
|
7
|
-
const isFunction = (v) => typeof v === "function";
|
|
8
|
-
const mergeConfig = (defaults, overrides) => {
|
|
9
|
-
if (!overrides) return structuredClone(defaults);
|
|
10
|
-
if (Object.keys(defaults).length === 0) return structuredClone(overrides);
|
|
11
|
-
const result = {};
|
|
12
|
-
for (const key in defaults) {
|
|
13
|
-
const defaultValue = defaults[key];
|
|
14
|
-
const overrideValue = overrides[key];
|
|
15
|
-
if (overrideValue === void 0) if (isFunction(defaultValue)) result[key] = defaultValue;
|
|
16
|
-
else result[key] = structuredClone(defaultValue);
|
|
17
|
-
else if ((0, _peiyanlu_ts_utils.isPlainObject)(defaultValue) && (0, _peiyanlu_ts_utils.isPlainObject)(overrideValue)) result[key] = mergeConfig(defaultValue, overrideValue);
|
|
18
|
-
else if (isFunction(overrideValue)) result[key] = overrideValue;
|
|
19
|
-
else result[key] = structuredClone(overrideValue);
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
exports.defineConfig = defineConfig;
|
|
26
|
-
exports.mergeConfig = mergeConfig;
|
package/dist/index.d.cts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { DeepPartial, DeepRequired } from "@peiyanlu/ts-utils";
|
|
2
|
-
|
|
3
|
-
//#region src/git/changetype.d.ts
|
|
4
|
-
interface CommitType {
|
|
5
|
-
type: string;
|
|
6
|
-
section: string;
|
|
7
|
-
description: string;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/types.d.ts
|
|
11
|
-
|
|
12
|
-
type HookTiming = 'before' | 'after';
|
|
13
|
-
type HookAction = 'bump' | 'publish' | 'push' | 'release';
|
|
14
|
-
type ReleaseHookKey = `${HookTiming}:${HookAction}`;
|
|
15
|
-
type ReleaseHookValue = string | string[] | (() => Promise<void> | void);
|
|
16
|
-
type HookConfig = { [key in ReleaseHookKey]: ReleaseHookValue };
|
|
17
|
-
interface ReleaseConfig {
|
|
18
|
-
/**
|
|
19
|
-
* 生命周期钩子配置
|
|
20
|
-
*/
|
|
21
|
-
hooks: HookConfig;
|
|
22
|
-
/**
|
|
23
|
-
* Git 相关配置
|
|
24
|
-
*/
|
|
25
|
-
git: {
|
|
26
|
-
/**
|
|
27
|
-
* 是否创建提交
|
|
28
|
-
*/
|
|
29
|
-
commit: boolean | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* 是否创建 Git Tag
|
|
32
|
-
*/
|
|
33
|
-
tag: boolean | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* 是否推送到远程仓库
|
|
36
|
-
*/
|
|
37
|
-
push: boolean | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Git 提交信息模板
|
|
40
|
-
*/
|
|
41
|
-
commitMessage: string;
|
|
42
|
-
/**
|
|
43
|
-
* 额外的 git commit 参数
|
|
44
|
-
*/
|
|
45
|
-
commitArgs: string[];
|
|
46
|
-
/**
|
|
47
|
-
* Git Tag 的消息内容
|
|
48
|
-
*/
|
|
49
|
-
tagMessage: string;
|
|
50
|
-
/**
|
|
51
|
-
* Git Tag 名称模板
|
|
52
|
-
*/
|
|
53
|
-
tagName: string;
|
|
54
|
-
/**
|
|
55
|
-
* 额外的 git tag 参数
|
|
56
|
-
*/
|
|
57
|
-
tagArgs: string[];
|
|
58
|
-
/**
|
|
59
|
-
* 额外的 git push 参数
|
|
60
|
-
*/
|
|
61
|
-
pushArgs: string[];
|
|
62
|
-
/**
|
|
63
|
-
* 是否自动添加未追踪的文件
|
|
64
|
-
*/
|
|
65
|
-
addUntrackedFiles: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* 是否要求配置远程仓库
|
|
68
|
-
*/
|
|
69
|
-
requireRemote: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* 是否要求当前目录为 Git 仓库
|
|
72
|
-
*/
|
|
73
|
-
requireRepository: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* 是否要求工作目录保持干净(无未提交的更改)
|
|
76
|
-
*/
|
|
77
|
-
requireWorkDirClean: boolean;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* NPM 发布相关配置
|
|
81
|
-
*/
|
|
82
|
-
npm: {
|
|
83
|
-
/**
|
|
84
|
-
* 是否发布到 npm
|
|
85
|
-
*/
|
|
86
|
-
publish: boolean | undefined;
|
|
87
|
-
/**
|
|
88
|
-
* 发布目录路径
|
|
89
|
-
*/
|
|
90
|
-
publishPath: string;
|
|
91
|
-
/**
|
|
92
|
-
* 额外的 npm publish 参数
|
|
93
|
-
*/
|
|
94
|
-
pushArgs: string[];
|
|
95
|
-
/**
|
|
96
|
-
* 是否跳过发布前检查
|
|
97
|
-
*/
|
|
98
|
-
skipChecks: boolean;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* GitHub Release 相关配置
|
|
102
|
-
*/
|
|
103
|
-
github: {
|
|
104
|
-
/**
|
|
105
|
-
* 是否创建 GitHub Release
|
|
106
|
-
*/
|
|
107
|
-
release: boolean | undefined;
|
|
108
|
-
/**
|
|
109
|
-
* Release 展示名称
|
|
110
|
-
*/
|
|
111
|
-
releaseName: string;
|
|
112
|
-
/**
|
|
113
|
-
* 是否自动生成 Release Notes (CI)
|
|
114
|
-
*/
|
|
115
|
-
autoGenerate: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* 是否标记为预发布版本
|
|
118
|
-
*/
|
|
119
|
-
prerelease: boolean;
|
|
120
|
-
/**
|
|
121
|
-
* 是否创建为草稿
|
|
122
|
-
*/
|
|
123
|
-
draft: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* GitHub Token 引用名称
|
|
126
|
-
*/
|
|
127
|
-
tokenRef: string;
|
|
128
|
-
/**
|
|
129
|
-
* 需要上传的 Release 资源文件
|
|
130
|
-
*/
|
|
131
|
-
assets: string[];
|
|
132
|
-
/**
|
|
133
|
-
* 是否跳过 GitHub 发布前检查
|
|
134
|
-
*/
|
|
135
|
-
skipChecks: boolean;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Changelog 生成相关配置
|
|
139
|
-
*/
|
|
140
|
-
changelog: {
|
|
141
|
-
/**
|
|
142
|
-
* Changelog 输入文件路径
|
|
143
|
-
*/
|
|
144
|
-
infile: string;
|
|
145
|
-
/**
|
|
146
|
-
* 用于生成 Changelog 的提交类型映射规则
|
|
147
|
-
*/
|
|
148
|
-
types: CommitType[];
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/config.d.ts
|
|
153
|
-
type UserConfig = DeepPartial<ReleaseConfig>;
|
|
154
|
-
type UserConfigFnObject = () => UserConfig;
|
|
155
|
-
type UserConfigFnPromise = () => Promise<UserConfig>;
|
|
156
|
-
type UserConfigFn = () => UserConfig | Promise<UserConfig>;
|
|
157
|
-
type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
|
|
158
|
-
declare function defineConfig(config: UserConfig): UserConfig;
|
|
159
|
-
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
160
|
-
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
161
|
-
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
162
|
-
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
163
|
-
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
164
|
-
declare const mergeConfig: <T extends object>(defaults: DeepRequired<T>, overrides?: DeepPartial<T>) => DeepRequired<T>;
|
|
165
|
-
//#endregion
|
|
166
|
-
export { type UserConfig, defineConfig, mergeConfig };
|