@peiyanlu/release 0.0.11 → 0.0.13
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/dist/cli.mjs +37 -44
- package/dist/index.d.mts +7 -1
- package/package.json +14 -14
package/dist/cli.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import { Octokit } from "@octokit/rest";
|
|
|
19
19
|
import { contentType } from "mime-types";
|
|
20
20
|
import open from "open";
|
|
21
21
|
import { glob } from "tinyglobby";
|
|
22
|
-
//#region node_modules/.pnpm/tsdown@0.
|
|
22
|
+
//#region node_modules/.pnpm/tsdown@0.22.1_publint@0.3.21_typescript@6.0.3/node_modules/tsdown/esm-shims.js
|
|
23
23
|
const getFilename = () => fileURLToPath(import.meta.url);
|
|
24
24
|
const getDirname = () => path.dirname(getFilename());
|
|
25
25
|
const __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -156,13 +156,23 @@ const MSG = {
|
|
|
156
156
|
//#region src/git/commit.ts
|
|
157
157
|
const gitCheck = async (ctx, config) => {
|
|
158
158
|
const { pkg: { name } } = ctx;
|
|
159
|
-
const { git: { requireRepository, requireRemote, requireWorkDirClean } } = config;
|
|
159
|
+
const { git: { requireRepository, requireRemote, requireWorkDirClean }, ignoreGit, ignoreGithub } = config;
|
|
160
|
+
if (ignoreGit) {
|
|
161
|
+
ctx.noGit = true;
|
|
162
|
+
ctx.noGitHub = true;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
160
165
|
if (!await isGitRepo()) if (requireRepository) throw new Error(MSG.ERROR.GIT_REGISTRY(name));
|
|
161
166
|
else {
|
|
162
167
|
ctx.noGit = true;
|
|
168
|
+
ctx.noGitHub = true;
|
|
163
169
|
return;
|
|
164
170
|
}
|
|
165
171
|
if (requireWorkDirClean && !await isWorkingDirClean()) throw new Error(MSG.ERROR.GIT_WORKDIR);
|
|
172
|
+
if (ignoreGithub) {
|
|
173
|
+
ctx.noGitHub = true;
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
166
176
|
const { remoteName, remoteUrl } = await getRemote();
|
|
167
177
|
if (!remoteUrl) if (requireRemote) throw new Error(MSG.ERROR.GIT_REMOTE(name));
|
|
168
178
|
else {
|
|
@@ -228,11 +238,11 @@ const abortGroupPrompt = (ctx) => {
|
|
|
228
238
|
ctx && gitRollback(ctx);
|
|
229
239
|
abortTask(MSG.ABORT.CANCEL);
|
|
230
240
|
};
|
|
231
|
-
const abortOnError = (err, ctx) => {
|
|
241
|
+
const abortOnError = (err, ctx, exit = true) => {
|
|
232
242
|
ctx && gitRollback(ctx);
|
|
233
243
|
const msg = err.message.replace(/^\[(github|npm|git)]/, (a) => red(a));
|
|
234
244
|
log.message(`\n${msg}\n`);
|
|
235
|
-
process.exit(1);
|
|
245
|
+
exit && process.exit(1);
|
|
236
246
|
};
|
|
237
247
|
const taskEnd = (msg) => {
|
|
238
248
|
outro(msg);
|
|
@@ -293,39 +303,15 @@ const formatTemplate = async (ctx, config) => {
|
|
|
293
303
|
};
|
|
294
304
|
//#endregion
|
|
295
305
|
//#region src/version/prompts.ts
|
|
296
|
-
let Release = /* @__PURE__ */ function(Release) {
|
|
297
|
-
Release["MAJOR"] = "major";
|
|
298
|
-
Release["MINOR"] = "minor";
|
|
299
|
-
Release["PATCH"] = "patch";
|
|
300
|
-
Release["RELEASE"] = "release";
|
|
301
|
-
return Release;
|
|
302
|
-
}({});
|
|
303
|
-
let PreRelease = /* @__PURE__ */ function(PreRelease) {
|
|
304
|
-
PreRelease["MAJOR"] = "premajor";
|
|
305
|
-
PreRelease["MINOR"] = "preminor";
|
|
306
|
-
PreRelease["PATCH"] = "prepatch";
|
|
307
|
-
PreRelease["RELEASE"] = "prerelease";
|
|
308
|
-
return PreRelease;
|
|
309
|
-
}({});
|
|
310
|
-
let PreId = /* @__PURE__ */ function(PreId) {
|
|
311
|
-
PreId["ALPHA"] = "alpha";
|
|
312
|
-
PreId["BETA"] = "beta";
|
|
313
|
-
PreId["RC"] = "rc";
|
|
314
|
-
PreId["NET"] = "next";
|
|
315
|
-
PreId["CANARY"] = "canary";
|
|
316
|
-
PreId["NIGHT"] = "nightly";
|
|
317
|
-
PreId["DEV"] = "dev";
|
|
318
|
-
return PreId;
|
|
319
|
-
}({});
|
|
320
306
|
const createVersionMap = (current) => ({
|
|
321
|
-
patch: inc(current,
|
|
322
|
-
minor: inc(current,
|
|
323
|
-
major: inc(current,
|
|
324
|
-
release: inc(current,
|
|
325
|
-
prerelease: inc(current,
|
|
326
|
-
prepatch: inc(current,
|
|
327
|
-
preminor: inc(current,
|
|
328
|
-
premajor: inc(current,
|
|
307
|
+
patch: inc(current, "patch"),
|
|
308
|
+
minor: inc(current, "minor"),
|
|
309
|
+
major: inc(current, "major"),
|
|
310
|
+
release: inc(current, "release"),
|
|
311
|
+
prerelease: inc(current, "prerelease"),
|
|
312
|
+
prepatch: inc(current, "prepatch", "beta"),
|
|
313
|
+
preminor: inc(current, "preminor", "beta"),
|
|
314
|
+
premajor: inc(current, "premajor", "beta")
|
|
329
315
|
});
|
|
330
316
|
const option = (label, value, hint) => ({
|
|
331
317
|
label,
|
|
@@ -402,7 +388,7 @@ const createDefaultContext = () => {
|
|
|
402
388
|
access: "public",
|
|
403
389
|
registry: "https://registry.npmjs.org"
|
|
404
390
|
},
|
|
405
|
-
preId:
|
|
391
|
+
preId: "beta",
|
|
406
392
|
preBase: "0"
|
|
407
393
|
},
|
|
408
394
|
npm: {
|
|
@@ -458,7 +444,12 @@ const createDefaultConfig = (isCI) => {
|
|
|
458
444
|
toTag(pkg, version) {
|
|
459
445
|
return `v${version}`;
|
|
460
446
|
},
|
|
461
|
-
tagPrefix
|
|
447
|
+
tagPrefix(pkg) {
|
|
448
|
+
return "";
|
|
449
|
+
},
|
|
450
|
+
ignoreGit: false,
|
|
451
|
+
ignoreNpm: false,
|
|
452
|
+
ignoreGithub: false,
|
|
462
453
|
git: {
|
|
463
454
|
commit: isCI,
|
|
464
455
|
tag: isCI,
|
|
@@ -989,7 +980,7 @@ var Action = class {
|
|
|
989
980
|
info(MSG.INFO.CONFIG(configPath));
|
|
990
981
|
console.log();
|
|
991
982
|
intro(prepare ? MSG.INTRO_PREPARE(dryRun) : MSG.INTRO(dryRun));
|
|
992
|
-
const { isMonorepo, packages, getPkgDir } = config;
|
|
983
|
+
const { isMonorepo, packages, getPkgDir, ignoreNpm } = config;
|
|
993
984
|
if (isMonorepo) {
|
|
994
985
|
if (ci) {
|
|
995
986
|
if (!defPkg) abortTask(MSG.ABORT.MONOREPO_CI_NO_PACKAGE);
|
|
@@ -1035,7 +1026,7 @@ var Action = class {
|
|
|
1035
1026
|
toPreRelease: false,
|
|
1036
1027
|
publishConfig: { ...publishConfig }
|
|
1037
1028
|
},
|
|
1038
|
-
noNpm: pkgPrivate
|
|
1029
|
+
noNpm: pkgPrivate || ignoreNpm
|
|
1039
1030
|
});
|
|
1040
1031
|
const { messages } = await publint({ pkgDir });
|
|
1041
1032
|
for (const message of messages) {
|
|
@@ -1080,7 +1071,7 @@ var Action = class {
|
|
|
1080
1071
|
]).catch(abortOnError);
|
|
1081
1072
|
}
|
|
1082
1073
|
async bumpTask(ctx, config) {
|
|
1083
|
-
const { pkg: { current }, dryRun, isCI, showRelease, showChangelog, selectedPkg } = ctx;
|
|
1074
|
+
const { pkg: { current }, dryRun, isCI, showRelease, showChangelog, selectedPkg, noGit } = ctx;
|
|
1084
1075
|
const { isMonorepo, hooks, getPkgDir, tagPrefix } = config;
|
|
1085
1076
|
const need = (ctx) => {
|
|
1086
1077
|
const { pkg: { next }, isIncrement } = ctx;
|
|
@@ -1110,6 +1101,7 @@ var Action = class {
|
|
|
1110
1101
|
}
|
|
1111
1102
|
}]).catch((err) => abortOnError(err, ctx));
|
|
1112
1103
|
await runLifeCycleHook(hooks, "after:bump", dryRun);
|
|
1104
|
+
if (noGit) return;
|
|
1113
1105
|
const { from, to } = await resolveChangelogRange(isIncrement, isMonorepo ? `${tagPrefix?.(selectedPkg)}*` : "*");
|
|
1114
1106
|
const commits = await getLog(from, to, getPkgDir(selectedPkg));
|
|
1115
1107
|
const changelog = await getChangelog({
|
|
@@ -1124,8 +1116,9 @@ var Action = class {
|
|
|
1124
1116
|
} else msg("GIT", MSG.LOG.CHANGELOG_EMPTY);
|
|
1125
1117
|
}
|
|
1126
1118
|
async changelogTask(ctx, config) {
|
|
1127
|
-
const { isIncrement, dryRun, selectedPkg } = ctx;
|
|
1119
|
+
const { isIncrement, dryRun, selectedPkg, noGit } = ctx;
|
|
1128
1120
|
const { getPkgDir, tagPrefix } = config;
|
|
1121
|
+
if (noGit) return;
|
|
1129
1122
|
await tasks([{
|
|
1130
1123
|
title: MSG.TASK.CHANGELOG.START,
|
|
1131
1124
|
task: async () => {
|
|
@@ -1175,7 +1168,7 @@ var Action = class {
|
|
|
1175
1168
|
const url = getPackageUrl(name, next);
|
|
1176
1169
|
return success(MSG.TASK.NPM.END(url), dryRun);
|
|
1177
1170
|
}
|
|
1178
|
-
}]).catch((err) => abortOnError(err, ctx));
|
|
1171
|
+
}]).catch((err) => abortOnError(err, ctx, false));
|
|
1179
1172
|
await runLifeCycleHook(hooks, "after:publish", dryRun);
|
|
1180
1173
|
}
|
|
1181
1174
|
async githubTask(ctx, config) {
|
|
@@ -1192,7 +1185,7 @@ var Action = class {
|
|
|
1192
1185
|
const url = getGithubReleaseUrl(owner, repo, currentTag);
|
|
1193
1186
|
return success(MSG.TASK.GITHUB.END(url), dryRun);
|
|
1194
1187
|
}
|
|
1195
|
-
}]).catch((err) => abortOnError(err, ctx));
|
|
1188
|
+
}]).catch((err) => abortOnError(err, ctx, false));
|
|
1196
1189
|
await runLifeCycleHook(hooks, "after:release", dryRun);
|
|
1197
1190
|
}
|
|
1198
1191
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -24,7 +24,13 @@ interface ReleaseConfig {
|
|
|
24
24
|
/** 使用 monorepo 时使用 toTag,例如 `${pkg}@${version}`,默认为 `v${version}` 作为单仓库 */
|
|
25
25
|
toTag: (pkg: string, version: string) => string;
|
|
26
26
|
/** 作为 CHANGELOG 标题的 Tag 前缀,多包场景下需要 `${pkg}@` */
|
|
27
|
-
tagPrefix: ((pkg: string) => string
|
|
27
|
+
tagPrefix: ((pkg: string) => string) | undefined;
|
|
28
|
+
/** 忽略 git、github 环境检查以及后续操作 */
|
|
29
|
+
ignoreGit: boolean | undefined;
|
|
30
|
+
/** 忽略 npm 环境检查以及后续操作 */
|
|
31
|
+
ignoreNpm: boolean | undefined;
|
|
32
|
+
/** 忽略 github 环境检查以及后续操作 */
|
|
33
|
+
ignoreGithub: boolean | undefined;
|
|
28
34
|
/**
|
|
29
35
|
* Git 相关配置
|
|
30
36
|
* 影响提交、打 tag、推送等本地/远程 Git 行为。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peiyanlu/release",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Release project tool.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,30 +26,30 @@
|
|
|
26
26
|
"test:cov": "vitest run --coverage"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@actions/core": "^3.0.
|
|
30
|
-
"@actions/github": "^9.
|
|
31
|
-
"@clack/prompts": "^1.
|
|
29
|
+
"@actions/core": "^3.0.1",
|
|
30
|
+
"@actions/github": "^9.1.1",
|
|
31
|
+
"@clack/prompts": "^1.5.0",
|
|
32
32
|
"@octokit/rest": "^22.0.1",
|
|
33
33
|
"@peiyanlu/cli-utils": "^0.0.8",
|
|
34
34
|
"@peiyanlu/ts-utils": "^0.0.5",
|
|
35
|
-
"ansis": "^4.
|
|
36
|
-
"commander": "^
|
|
35
|
+
"ansis": "^4.3.1",
|
|
36
|
+
"commander": "^15.0.0",
|
|
37
37
|
"conventional-changelog": "^7.2.0",
|
|
38
38
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
39
39
|
"mime-types": "^3.0.2",
|
|
40
40
|
"open": "^11.0.0",
|
|
41
|
-
"publint": "^0.3.
|
|
42
|
-
"semver": "^7.
|
|
43
|
-
"tinyglobby": "^0.2.
|
|
41
|
+
"publint": "^0.3.21",
|
|
42
|
+
"semver": "^7.8.1",
|
|
43
|
+
"tinyglobby": "^0.2.17"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/mime-types": "^3.0.1",
|
|
47
|
-
"@types/node": "^
|
|
47
|
+
"@types/node": "^24.12.4",
|
|
48
48
|
"@types/semver": "^7.7.1",
|
|
49
|
-
"@vitest/coverage-v8": "^4.1.
|
|
50
|
-
"tsdown": "^0.
|
|
51
|
-
"typescript": "^6.0.
|
|
52
|
-
"vitest": "^4.1.
|
|
49
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
50
|
+
"tsdown": "^0.22.1",
|
|
51
|
+
"typescript": "^6.0.3",
|
|
52
|
+
"vitest": "^4.1.8"
|
|
53
53
|
},
|
|
54
54
|
"author": {
|
|
55
55
|
"name": "YanluPei",
|