@mznjs/mbump 1.0.2 → 1.0.6

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.
@@ -1,18 +1,38 @@
1
- import { ProgressEvent, loadBumpConfig, versionBump, versionBumpInfo } from "bumpp";
1
+ import { generateMarkDown, getGitDiff, getLastGitTag, loadChangelogConfig, parseCommits } from "changelogen";
2
+ import { loadBumpConfig, versionBump, versionBumpInfo } from "bumpp";
2
3
  import { consola } from "consola";
3
4
  import { oraPromise } from "ora";
5
+ import { spawnSync } from "node:child_process";
4
6
  import { existsSync } from "node:fs";
5
7
  import { readFile, writeFile } from "node:fs/promises";
6
- import { generateMarkDown, getGitDiff, getLastGitTag, loadChangelogConfig, parseCommits } from "changelogen";
7
- import { x } from "tinyexec";
8
8
  import { defu } from "defu";
9
9
  import { loadConfig, presetMini } from "esconf";
10
10
  import { glob } from "tinyglobby";
11
11
 
12
12
  //#region src/changelog.ts
13
+ function x(command, args) {
14
+ return new Promise((resolve, reject) => {
15
+ try {
16
+ let result;
17
+ if (command === "git" && args[0] === "commit" && args[1] === "-m") result = spawnSync(`git commit -m "${args[2]}"`, [], {
18
+ stdio: "inherit",
19
+ shell: true
20
+ });
21
+ else result = spawnSync(command, args, {
22
+ stdio: "inherit",
23
+ shell: true
24
+ });
25
+ if (result.status === 0) resolve();
26
+ else reject(/* @__PURE__ */ new Error(`Command failed with status ${result.status}`));
27
+ } catch (error) {
28
+ reject(error);
29
+ }
30
+ });
31
+ }
13
32
  /**
14
- * 获取远程仓库的最新tag
15
- * @returns
33
+ * 获取最新的 Git 标签
34
+ *
35
+ * @returns 返回最新的 Git 标签,如果获取失败则返回空字符串
16
36
  */
17
37
  async function getTag() {
18
38
  try {
@@ -32,10 +52,9 @@ async function changelog(rawConfig) {
32
52
  to: `v${rawConfig.to}`,
33
53
  from: `v${rawConfig.from}`
34
54
  };
35
- const rawCommits = await getGitDiff(config.from);
36
- const commits = parseCommits(rawCommits, config).filter((c) => config.types[c.type] && !(c.type === "chore" && c.scope === "deps" && !c.isBreaking));
37
- let markdown = await generateMarkDown(commits, config);
38
- markdown = markdown.replace("#### ⚠️ Breaking Changes", `#### ${config.types.BreakingChange.title}`).replace("### ❤️ Contributors", "### ❤️ 贡献者");
55
+ let markdown = await generateMarkDown(parseCommits(await getGitDiff(config.from), config).filter((c) => config.types[c.type] && !(c.type === "chore" && c.scope === "deps" && !c.isBreaking)), config);
56
+ const breakingChangeTitle = typeof config.types.BreakingChange === "object" && config.types.BreakingChange !== null ? config.types.BreakingChange.title : "⚠️ Breaking Changes";
57
+ markdown = markdown.replace("#### ⚠️ Breaking Changes", `#### ${breakingChangeTitle}`).replace("### ❤️ Contributors", "### ❤️ 贡献者");
39
58
  let changelogMD;
40
59
  if (existsSync(config.output)) changelogMD = await readFile(config.output, "utf8");
41
60
  else changelogMD = "# Changelog\n\n";
@@ -104,16 +123,13 @@ async function resolveConfig(rawConfig) {
104
123
  bumpp,
105
124
  accesstoken: {}
106
125
  });
107
- if (rawConfig.bumpp?.recursive) {
108
- const files = await glob("**/package.json", {
109
- ignore: ["**/node_modules/**"],
110
- cwd,
111
- onlyFiles: true
112
- });
113
- files.forEach((item) => {
114
- _resolveConfig.bumpp.files.push(item);
115
- });
116
- }
126
+ if (rawConfig.bumpp?.recursive) (await glob("**/package.json", {
127
+ ignore: ["**/node_modules/**"],
128
+ cwd,
129
+ onlyFiles: true
130
+ })).forEach((item) => {
131
+ _resolveConfig.bumpp.files.push(item);
132
+ });
117
133
  _resolveConfig.bumpp.recursive = false;
118
134
  _resolveConfig.bumpp.files = [...new Set(_resolveConfig.bumpp.files)];
119
135
  return _resolveConfig;
@@ -127,22 +143,22 @@ const defineConfig = (config) => config;
127
143
  */
128
144
  function progress({ event, script, updatedFiles, skippedFiles, newVersion }) {
129
145
  switch (event) {
130
- case ProgressEvent.FileUpdated:
146
+ case "FILE_UPDATED":
131
147
  consola.success(`Updated ${updatedFiles.pop()} to ${newVersion}`);
132
148
  break;
133
- case ProgressEvent.FileSkipped:
149
+ case "FILE_SKIPPED":
134
150
  consola.info(`${skippedFiles.pop()} did not need to be updated`);
135
151
  break;
136
- case ProgressEvent.GitCommit:
152
+ case "GIT_COMMIT":
137
153
  consola.info("Git commit");
138
154
  break;
139
- case ProgressEvent.GitTag:
155
+ case "GIT_TAG":
140
156
  consola.info("Git tag");
141
157
  break;
142
- case ProgressEvent.GitPush:
158
+ case "GIT_PUSH":
143
159
  consola.success("Git push");
144
160
  break;
145
- case ProgressEvent.NpmScript:
161
+ case "NPM_SCRIPT":
146
162
  consola.success(`Npm run ${script}`);
147
163
  break;
148
164
  }
@@ -193,4 +209,4 @@ async function bumpVersionWithBaseRelease(option = {}, addRelease, provider) {
193
209
  }
194
210
 
195
211
  //#endregion
196
- export { bumpVersion, bumpVersionWithBaseRelease, defineConfig };
212
+ export { bumpVersionWithBaseRelease as n, defineConfig as r, bumpVersion as t };
@@ -0,0 +1 @@
1
+ export * from "changelogen";
@@ -1 +1,3 @@
1
1
  export * from "changelogen"
2
+
3
+ export { };
package/dist/cli.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { Config } from "./types.d-B0g2i1Ge.js";
1
+ import { o as Config } from "./types-DoXYJODS.js";
2
2
 
3
3
  //#region src/cli.d.ts
4
4
  declare function createBaseCli(bumpVersion: (config?: Config) => Promise<any>, version?: string): void;
5
5
  declare const createCli: () => void;
6
-
7
6
  //#endregion
8
7
  export { createBaseCli, createCli };
package/dist/cli.js CHANGED
@@ -1,8 +1,12 @@
1
- import { bumpVersion } from "./bump-CtknNhb9.js";
1
+ import { t as bumpVersion } from "./bump-C1ZmU9eM.js";
2
2
  import { cac } from "cac";
3
3
 
4
+ //#region package.json
5
+ var version = "1.0.6-beta.0";
6
+
7
+ //#endregion
4
8
  //#region src/cli.ts
5
- function createBaseCli(bumpVersion$1, version) {
9
+ function createBaseCli(bumpVersion$1, version$1) {
6
10
  const $cac = cac("mbump");
7
11
  $cac.command("[...files]").option("-o,--output [output]", "CHANGELOG.md 生成位置", { default: "CHANGELOG.md" }).option("-r,--recursive", "recursively", { default: false }).action(async (files, options) => {
8
12
  await bumpVersion$1({
@@ -13,7 +17,7 @@ function createBaseCli(bumpVersion$1, version) {
13
17
  changelog: { output: options.output }
14
18
  });
15
19
  });
16
- $cac.version(version || "1.0.1");
20
+ $cac.version(version$1 || version);
17
21
  $cac.help();
18
22
  $cac.parse();
19
23
  }
package/dist/index.d.ts CHANGED
@@ -1,22 +1,21 @@
1
- import { Accesstokens, BumpVersion, BumppResult, ChangelogOptions, ChangelogResult, Config, ResolveConfig } from "./types.d-B0g2i1Ge.js";
1
+ import { a as ChangelogResult, i as ChangelogOptions, n as BumpVersion, o as Config, r as BumppResult, s as ResolveConfig, t as Accesstokens } from "./types-DoXYJODS.js";
2
2
 
3
3
  //#region src/bump.d.ts
4
+
4
5
  /**
5
- * 更新版本
6
- * @param option
7
- */
6
+ * 更新版本
7
+ * @param option
8
+ */
8
9
  declare function bumpVersion(option?: Config): Promise<BumpVersion>;
9
10
  /**
10
- * 更新版本伴随基础 release 基础等待动画
11
- * @param option 更新版本配置
12
- * @param addRelease release脚本
13
- * @param provider git 远程储存提供商
14
- */
11
+ * 更新版本伴随基础 release 基础等待动画
12
+ * @param option 更新版本配置
13
+ * @param addRelease release脚本
14
+ * @param provider git 远程储存提供商
15
+ */
15
16
  declare function bumpVersionWithBaseRelease(option: Config | undefined, addRelease: (res: BumpVersion) => Promise<any>, provider: string): Promise<void>;
16
-
17
17
  //#endregion
18
18
  //#region src/config.d.ts
19
19
  declare const defineConfig: (config: Config) => Config;
20
-
21
20
  //#endregion
22
21
  export { Accesstokens, BumpVersion, BumppResult, ChangelogOptions, ChangelogResult, Config, ResolveConfig, bumpVersion, bumpVersionWithBaseRelease, defineConfig };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { bumpVersion, bumpVersionWithBaseRelease, defineConfig } from "./bump-CtknNhb9.js";
1
+ import { n as bumpVersionWithBaseRelease, r as defineConfig, t as bumpVersion } from "./bump-C1ZmU9eM.js";
2
2
 
3
3
  export { bumpVersion, bumpVersionWithBaseRelease, defineConfig };
@@ -0,0 +1,74 @@
1
+ import { ChangelogConfig, ResolvedChangelogConfig } from "changelogen";
2
+ import { VersionBumpOptions, versionBumpInfo } from "bumpp";
3
+
4
+ //#region src/changelog.d.ts
5
+
6
+ /**
7
+ * 生成changelog
8
+ * @param rawConfig
9
+ */
10
+ declare function changelog(rawConfig: ResolvedChangelogConfig): Promise<{
11
+ markdown: string;
12
+ changelogMD: string;
13
+ }>;
14
+ //#endregion
15
+ //#region src/types.d.ts
16
+ /**
17
+ * changelog 生成配置信息
18
+ */
19
+ interface ChangelogOptions extends Omit<Partial<ChangelogConfig>, 'cwd' | 'tokens' | 'newVersion' | 'to' | 'from' | 'publish'> {}
20
+ interface Accesstokens {
21
+ [key: string]: string;
22
+ }
23
+ /**
24
+ * 用户配置信息
25
+ */
26
+ interface Config {
27
+ /**
28
+ * changelog 生成配置信息
29
+ */
30
+ changelog?: ChangelogOptions;
31
+ /**
32
+ * bumpp 配置信息
33
+ */
34
+ bumpp?: Omit<VersionBumpOptions, 'progress' | 'cwd'>;
35
+ accesstoken?: Accesstokens;
36
+ }
37
+ /**
38
+ * 合并后的配置信息
39
+ */
40
+ interface ResolveConfig {
41
+ /**
42
+ * changelog 生成配置信息
43
+ */
44
+ changelog: ResolvedChangelogConfig;
45
+ /**
46
+ * bumpp 配置信息
47
+ */
48
+ bumpp: Omit<VersionBumpOptions, 'progress'>;
49
+ accesstoken: Accesstokens;
50
+ }
51
+ /**
52
+ * bumpp 生成结果
53
+ */
54
+ type BumppResult = Awaited<ReturnType<typeof versionBumpInfo>>;
55
+ /**
56
+ * changelog 生成结果
57
+ */
58
+ type ChangelogResult = Awaited<ReturnType<typeof changelog>>;
59
+ /**
60
+ * bumppVersion 方法返回结果
61
+ */
62
+ interface BumpVersion {
63
+ /**
64
+ * bumpp 生成结果
65
+ */
66
+ bumpp: BumppResult['state'];
67
+ /**
68
+ * changelog 生成结果
69
+ */
70
+ changelog: ChangelogResult;
71
+ config: ResolveConfig;
72
+ }
73
+ //#endregion
74
+ export { ChangelogResult as a, ChangelogOptions as i, BumpVersion as n, Config as o, BumppResult as r, ResolveConfig as s, Accesstokens as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mznjs/mbump",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "./changelogen": {
36
36
  "import": {
37
- "types": "./dist/changelogens.d.ts",
38
- "default": "./dist/changelogens.js"
37
+ "types": "./dist/changelogen.d.ts",
38
+ "default": "./dist/changelogen.js"
39
39
  }
40
40
  },
41
41
  "./cli": {
@@ -53,7 +53,6 @@
53
53
  "defu": "^6.1.4",
54
54
  "esconf": "~0.5.1",
55
55
  "ora": "^8.2.0",
56
- "tinyexec": "^1.0.1",
57
56
  "tinyglobby": "^0.2.13"
58
57
  },
59
58
  "publishConfig": {
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 白鸢
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1 +0,0 @@
1
- export * from "changelogen"
@@ -1,76 +0,0 @@
1
- import { VersionBumpOptions, versionBumpInfo } from "bumpp";
2
- import { ChangelogConfig, ResolvedChangelogConfig } from "changelogen";
3
-
4
- //#region src/changelog.d.ts
5
- /**
6
- * 生成changelog
7
- * @param rawConfig
8
- */
9
- declare function changelog(rawConfig: ResolvedChangelogConfig): Promise<{
10
- markdown: string;
11
- changelogMD: string;
12
- }>;
13
-
14
- //#endregion
15
- //#region src/types.d.ts
16
- /**
17
- * changelog 生成配置信息
18
- */
19
- interface ChangelogOptions extends Omit<Partial<ChangelogConfig>, 'cwd' | 'tokens' | 'newVersion' | 'to' | 'from' | 'publish'> {
20
- }
21
- interface Accesstokens {
22
- [key: string]: string;
23
- }
24
- /**
25
- * 用户配置信息
26
- */
27
- interface Config {
28
- /**
29
- * changelog 生成配置信息
30
- */
31
- changelog?: ChangelogOptions;
32
- /**
33
- * bumpp 配置信息
34
- */
35
- bumpp?: Omit<VersionBumpOptions, 'progress' | 'cwd'>;
36
- accesstoken?: Accesstokens;
37
- }
38
- /**
39
- * 合并后的配置信息
40
- */
41
- interface ResolveConfig {
42
- /**
43
- * changelog 生成配置信息
44
- */
45
- changelog: ResolvedChangelogConfig;
46
- /**
47
- * bumpp 配置信息
48
- */
49
- bumpp: Omit<VersionBumpOptions, 'progress'>;
50
- accesstoken: Accesstokens;
51
- }
52
- /**
53
- * bumpp 生成结果
54
- */
55
- type BumppResult = Awaited<ReturnType<typeof versionBumpInfo>>;
56
- /**
57
- * changelog 生成结果
58
- */
59
- type ChangelogResult = Awaited<ReturnType<typeof changelog>>;
60
- /**
61
- * bumppVersion 方法返回结果
62
- */
63
- interface BumpVersion {
64
- /**
65
- * bumpp 生成结果
66
- */
67
- bumpp: BumppResult['state'];
68
- /**
69
- * changelog 生成结果
70
- */
71
- changelog: ChangelogResult;
72
- config: ResolveConfig;
73
- }
74
-
75
- //#endregion
76
- export { Accesstokens, BumpVersion, BumppResult, ChangelogOptions, ChangelogResult, Config, ResolveConfig };