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