@peiyanlu/release 1.1.0 → 1.1.2
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 +27 -19
- package/dist/index.d.mts +10 -3
- package/dist/index.mjs +11 -11
- package/package.json +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { dim, green, red, rgb, underline, yellow } from "ansis";
|
|
|
5
5
|
import { program } from "commander";
|
|
6
6
|
import { createReadStream, createWriteStream, existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
7
7
|
import { cancel, confirm, group, intro, isCancel, log, outro, select, tasks, text } from "@clack/prompts";
|
|
8
|
-
import { castArray, isFunction, isPlainObject, isUndefined, isZero,
|
|
8
|
+
import { castArray, isFunction, isPlainObject, isUndefined, isZero, mapObject } from "@peiyanlu/ts-utils";
|
|
9
9
|
import { publint } from "publint";
|
|
10
10
|
import { formatMessage } from "publint/utils";
|
|
11
11
|
import { inc, neq } from "semver";
|
|
@@ -553,12 +553,6 @@ const defaultTypes = [
|
|
|
553
553
|
effect: "hidden",
|
|
554
554
|
description: "持续集成配置"
|
|
555
555
|
},
|
|
556
|
-
{
|
|
557
|
-
type: "deps",
|
|
558
|
-
section: "📦 依赖更新",
|
|
559
|
-
effect: "changelog",
|
|
560
|
-
description: "依赖版本变更"
|
|
561
|
-
},
|
|
562
556
|
{
|
|
563
557
|
type: "security",
|
|
564
558
|
section: "🛡️ 安全修复",
|
|
@@ -584,16 +578,22 @@ const defaultTypes = [
|
|
|
584
578
|
description: "用户体验改进"
|
|
585
579
|
},
|
|
586
580
|
{
|
|
587
|
-
type: "
|
|
588
|
-
section: "
|
|
589
|
-
effect: "
|
|
590
|
-
description: "
|
|
581
|
+
type: "deps",
|
|
582
|
+
section: "📦 依赖更新",
|
|
583
|
+
effect: "changelog",
|
|
584
|
+
description: "依赖版本变更"
|
|
591
585
|
},
|
|
592
586
|
{
|
|
593
587
|
type: "tool",
|
|
594
588
|
section: "🛠️ 工具链",
|
|
595
589
|
effect: "hidden",
|
|
596
590
|
description: "工具链变更"
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
type: "config",
|
|
594
|
+
section: "⚙️ 配置",
|
|
595
|
+
effect: "hidden",
|
|
596
|
+
description: "配置文件更新"
|
|
597
597
|
}
|
|
598
598
|
];
|
|
599
599
|
//#endregion
|
|
@@ -607,7 +607,7 @@ function headerPartial(context) {
|
|
|
607
607
|
function template(context) {
|
|
608
608
|
const { headerPartial, preamblePartial, commitPartial, footerPartial, noteGroups, commitGroups } = context;
|
|
609
609
|
return segments(headerPartial(context), preamblePartial(context), each(noteGroups, (group) => segments(heading(3, words("⚠", group.title)), list(group.notes, (note) => {
|
|
610
|
-
return each([words(note.commit.scope && bold(`${note.commit.scope}:`), commitPartial(context, note.commit)), list([note.text], (t) => t)], (t) => t, newline());
|
|
610
|
+
return each([words(note.commit.scope && bold(`${note.commit.scope}:`), commitPartial(context, note.commit)), note.commit.subject.trim() !== note.text.trim() ? list([note.text], (t) => t) : ""], (t) => t, newline());
|
|
611
611
|
})), newline(2)), each(commitGroups, (group) => segments(group.title && heading(3, group.title), list(group.commits, (commit) => commitPartial(context, commit))), newline(2)), footerPartial(context));
|
|
612
612
|
}
|
|
613
613
|
//#endregion
|
|
@@ -627,8 +627,13 @@ const parsePreset = (options = {}) => {
|
|
|
627
627
|
};
|
|
628
628
|
const inferReleaseType = async (options) => {
|
|
629
629
|
const preset = parsePreset(options);
|
|
630
|
-
const res = await new Bumper().bump(preset.whatBump);
|
|
631
|
-
|
|
630
|
+
const res = await new Bumper().config(preset).bump(preset.whatBump);
|
|
631
|
+
if (!("releaseType" in res)) return void 0;
|
|
632
|
+
const { releaseType, reason } = res;
|
|
633
|
+
return options?.json ? {
|
|
634
|
+
releaseType,
|
|
635
|
+
reason
|
|
636
|
+
} : releaseType;
|
|
632
637
|
};
|
|
633
638
|
const createGenerator = async (options) => {
|
|
634
639
|
const { getPkgDir, tagPrefix, releaseCount = 1, includeHidden, transformTypes } = options;
|
|
@@ -981,14 +986,14 @@ var Action = class {
|
|
|
981
986
|
async createContext(cmdArgs, options, prepare = false) {
|
|
982
987
|
const { version: cVersion, name: cName } = readJsonFile(join(__dirname, "../package.json"));
|
|
983
988
|
const { otp, package: defPkg, releaseCount, ...others } = options;
|
|
984
|
-
const { showChangelog, showRelease, ci, dryRun, onlyChangelog } =
|
|
989
|
+
const { showChangelog, showRelease, ci, dryRun, onlyChangelog } = mapObject(others, (k, v) => [k, Boolean(v)]);
|
|
985
990
|
process.env["dryRun"] = String(dryRun);
|
|
986
991
|
const { configFile, config: local } = await resolveConfig(process.cwd());
|
|
987
992
|
const config = mergeConfig(createDefaultConfig(ci ? true : void 0), local);
|
|
988
993
|
info(MSG.INFO.TOOL(cName, cVersion));
|
|
989
994
|
info(MSG.INFO.CONFIG(configFile));
|
|
990
995
|
{
|
|
991
|
-
const { requireCleanWorkingTree, skipGit, skipNpm, skipGithub, isMonorepo, includeHidden } =
|
|
996
|
+
const { requireCleanWorkingTree, skipGit, skipNpm, skipGithub, isMonorepo, includeHidden } = mapObject(others, (k, v) => [k, Boolean(v)]);
|
|
992
997
|
const count = Number(releaseCount);
|
|
993
998
|
config.changelog.releaseCount = isNaN(count) ? 0 : count;
|
|
994
999
|
config.changelog.includeHidden = includeHidden;
|
|
@@ -1124,10 +1129,13 @@ var Action = class {
|
|
|
1124
1129
|
return !next && isIncrement;
|
|
1125
1130
|
};
|
|
1126
1131
|
if (need(ctx)) {
|
|
1127
|
-
const
|
|
1132
|
+
const res = await inferReleaseType({
|
|
1128
1133
|
includeHidden,
|
|
1129
|
-
transformTypes
|
|
1134
|
+
transformTypes,
|
|
1135
|
+
json: true
|
|
1130
1136
|
});
|
|
1137
|
+
if (res) msg("BUMP", res.reason);
|
|
1138
|
+
const inferred = res?.releaseType;
|
|
1131
1139
|
const nextVersion = (isCI ? inferred ?? inc(current, "patch") : void 0) || await runVersionPrompts(ctx, config, inferred);
|
|
1132
1140
|
ctx.isIncrement = neq(current, nextVersion);
|
|
1133
1141
|
const { version: next, isPrerelease: toPreRelease, preId, preBase } = parseVersion(nextVersion);
|
|
@@ -1270,7 +1278,7 @@ program.command("init").description("Create a release configuration file").optio
|
|
|
1270
1278
|
if (add) gitAddSync([infile]);
|
|
1271
1279
|
console.log(`\n${content}`);
|
|
1272
1280
|
});
|
|
1273
|
-
program.addHelpText("afterAll", "\nThanks for using!");
|
|
1281
|
+
program.addHelpText("afterAll", "\nCASE: release -C -r0 --include-hidden --only-changelog\n\nThanks for using!");
|
|
1274
1282
|
program.parse(process.argv);
|
|
1275
1283
|
program.on("command:*", () => {
|
|
1276
1284
|
console.error(`\n${red`Error`} Invalid command: ${red`%s`}`, program.args.join(" "));
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { DeepPartial, DeepRequired } from "@peiyanlu/ts-utils";
|
|
2
2
|
import { ConventionalChangelog } from "conventional-changelog";
|
|
3
|
-
import { CommitType } from "conventional-changelog-conventionalcommits";
|
|
3
|
+
import { CommitType as CommitType$1 } from "conventional-changelog-conventionalcommits";
|
|
4
4
|
import { log } from "@clack/prompts";
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
7
|
+
interface CommitType {
|
|
8
|
+
type: string;
|
|
9
|
+
section?: string;
|
|
10
|
+
effect?: 'bump' | 'changelog' | 'hidden';
|
|
11
|
+
scope?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
7
14
|
type Logger = typeof log;
|
|
8
15
|
type HookTiming = 'before' | 'after';
|
|
9
16
|
type HookAction = 'bump' | 'publish' | 'push' | 'release';
|
|
@@ -192,7 +199,7 @@ interface ParsePresetOptions {
|
|
|
192
199
|
/** 生成 CHANGELOG 时包含默认隐藏的 commit 类型 */
|
|
193
200
|
includeHidden?: boolean;
|
|
194
201
|
/** 对默认 commit types 进行转换 */
|
|
195
|
-
transformTypes?: (types: CommitType[]) => CommitType[];
|
|
202
|
+
transformTypes?: (types: CommitType$1[]) => CommitType$1[];
|
|
196
203
|
}
|
|
197
204
|
declare const createGenerator: (options: GenerateOptions & ParsePresetOptions) => Promise<ConventionalChangelog>;
|
|
198
205
|
declare const getChangelog: (options: GenerateOptions & ParsePresetOptions) => Promise<string>;
|
|
@@ -222,4 +229,4 @@ interface PublishTagOptions {
|
|
|
222
229
|
}
|
|
223
230
|
declare const publishTagToNpm: (options: PublishTagOptions) => Promise<void>;
|
|
224
231
|
//#endregion
|
|
225
|
-
export { type Logger, type UserConfig, createGenerator, defineConfig, generateChangelog, getChangelog, mergeConfig, publishTagToNpm };
|
|
232
|
+
export { type CommitType, type Logger, type UserConfig, createGenerator, defineConfig, generateChangelog, getChangelog, mergeConfig, publishTagToNpm };
|
package/dist/index.mjs
CHANGED
|
@@ -102,12 +102,6 @@ const defaultTypes = [
|
|
|
102
102
|
effect: "hidden",
|
|
103
103
|
description: "持续集成配置"
|
|
104
104
|
},
|
|
105
|
-
{
|
|
106
|
-
type: "deps",
|
|
107
|
-
section: "📦 依赖更新",
|
|
108
|
-
effect: "changelog",
|
|
109
|
-
description: "依赖版本变更"
|
|
110
|
-
},
|
|
111
105
|
{
|
|
112
106
|
type: "security",
|
|
113
107
|
section: "🛡️ 安全修复",
|
|
@@ -133,16 +127,22 @@ const defaultTypes = [
|
|
|
133
127
|
description: "用户体验改进"
|
|
134
128
|
},
|
|
135
129
|
{
|
|
136
|
-
type: "
|
|
137
|
-
section: "
|
|
138
|
-
effect: "
|
|
139
|
-
description: "
|
|
130
|
+
type: "deps",
|
|
131
|
+
section: "📦 依赖更新",
|
|
132
|
+
effect: "changelog",
|
|
133
|
+
description: "依赖版本变更"
|
|
140
134
|
},
|
|
141
135
|
{
|
|
142
136
|
type: "tool",
|
|
143
137
|
section: "🛠️ 工具链",
|
|
144
138
|
effect: "hidden",
|
|
145
139
|
description: "工具链变更"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: "config",
|
|
143
|
+
section: "⚙️ 配置",
|
|
144
|
+
effect: "hidden",
|
|
145
|
+
description: "配置文件更新"
|
|
146
146
|
}
|
|
147
147
|
];
|
|
148
148
|
//#endregion
|
|
@@ -156,7 +156,7 @@ function headerPartial(context) {
|
|
|
156
156
|
function template(context) {
|
|
157
157
|
const { headerPartial, preamblePartial, commitPartial, footerPartial, noteGroups, commitGroups } = context;
|
|
158
158
|
return segments(headerPartial(context), preamblePartial(context), each(noteGroups, (group) => segments(heading(3, words("⚠", group.title)), list(group.notes, (note) => {
|
|
159
|
-
return each([words(note.commit.scope && bold(`${note.commit.scope}:`), commitPartial(context, note.commit)), list([note.text], (t) => t)], (t) => t, newline());
|
|
159
|
+
return each([words(note.commit.scope && bold(`${note.commit.scope}:`), commitPartial(context, note.commit)), note.commit.subject.trim() !== note.text.trim() ? list([note.text], (t) => t) : ""], (t) => t, newline());
|
|
160
160
|
})), newline(2)), each(commitGroups, (group) => segments(group.title && heading(3, group.title), list(group.commits, (commit) => commitPartial(context, commit))), newline(2)), footerPartial(context));
|
|
161
161
|
}
|
|
162
162
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peiyanlu/release",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Release project tool.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@actions/github": "^9.1.1",
|
|
31
31
|
"@clack/prompts": "^1.5.0",
|
|
32
32
|
"@octokit/rest": "^22.0.1",
|
|
33
|
-
"@peiyanlu/cli-utils": "^0.0.
|
|
34
|
-
"@peiyanlu/ts-utils": "^0.0.
|
|
33
|
+
"@peiyanlu/cli-utils": "^0.0.13",
|
|
34
|
+
"@peiyanlu/ts-utils": "^0.0.9",
|
|
35
35
|
"ansis": "^4.3.1",
|
|
36
36
|
"commander": "^15.0.0",
|
|
37
37
|
"conventional-changelog": "^8.0.0",
|