@modern-js/plugin-changeset 2.21.2-alpha.2 → 2.22.0

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/commands/bump.js +3 -1
  3. package/dist/cjs/commands/change.js +3 -1
  4. package/dist/cjs/commands/pre.js +3 -1
  5. package/dist/cjs/commands/release.js +3 -1
  6. package/dist/cjs/commands/releaseNote.js +27 -9
  7. package/dist/cjs/commands/status.js +3 -1
  8. package/dist/cjs/index.js +3 -1
  9. package/dist/cjs/locale/en.js +3 -1
  10. package/dist/cjs/locale/index.js +6 -2
  11. package/dist/cjs/locale/zh.js +3 -1
  12. package/dist/cjs/utils/changeset.js +6 -2
  13. package/package.json +7 -7
  14. package/dist/js/modern/commands/bump.js +0 -66
  15. package/dist/js/modern/commands/change.js +0 -57
  16. package/dist/js/modern/commands/index.js +0 -6
  17. package/dist/js/modern/commands/pre.js +0 -33
  18. package/dist/js/modern/commands/release-note.js +0 -162
  19. package/dist/js/modern/commands/release.js +0 -76
  20. package/dist/js/modern/commands/status.js +0 -42
  21. package/dist/js/modern/index.js +0 -53
  22. package/dist/js/modern/locale/en.js +0 -41
  23. package/dist/js/modern/locale/index.js +0 -9
  24. package/dist/js/modern/locale/zh.js +0 -41
  25. package/dist/js/modern/utils/changeset.js +0 -14
  26. package/dist/js/modern/utils/index.js +0 -2
  27. package/dist/js/modern/utils/language.js +0 -8
  28. package/dist/js/node/commands/bump.js +0 -89
  29. package/dist/js/node/commands/change.js +0 -75
  30. package/dist/js/node/commands/index.js +0 -22
  31. package/dist/js/node/commands/pre.js +0 -56
  32. package/dist/js/node/commands/release-note.js +0 -193
  33. package/dist/js/node/commands/release.js +0 -100
  34. package/dist/js/node/commands/status.js +0 -65
  35. package/dist/js/node/index.js +0 -75
  36. package/dist/js/node/locale/en.js +0 -64
  37. package/dist/js/node/locale/index.js +0 -33
  38. package/dist/js/node/locale/zh.js +0 -64
  39. package/dist/js/node/utils/changeset.js +0 -44
  40. package/dist/js/node/utils/index.js +0 -18
  41. package/dist/js/node/utils/language.js +0 -31
@@ -1,53 +0,0 @@
1
- import { change, bump, pre, release, status, genReleaseNote } from "./commands";
2
- import { i18n, localeKeys } from "./locale";
3
- import { getLocaleLanguage } from "./utils";
4
- export * from "./commands";
5
- var src_default = () => ({
6
- name: "@modern-js/plugin-changeset",
7
- setup: () => {
8
- i18n.changeLanguage({ locale: getLocaleLanguage() });
9
- return {
10
- commands({ program }) {
11
- program.command("change").description(i18n.t(localeKeys.command.change.describe)).option("--empty", i18n.t(localeKeys.command.change.empty), false).option("--open", i18n.t(localeKeys.command.change.open), false).action((options) => change(options));
12
- program.command("bump").description(i18n.t(localeKeys.command.bump.describe)).option("--canary", i18n.t(localeKeys.command.bump.canary), false).option(
13
- "--ignore <package>",
14
- i18n.t(localeKeys.command.bump.ignore),
15
- (val, memo) => {
16
- memo.push(val);
17
- return memo;
18
- },
19
- []
20
- ).option(
21
- "--preid <tag>",
22
- i18n.t(localeKeys.command.bump.preid),
23
- "next"
24
- ).option(
25
- "--snapshot [snapshot]",
26
- i18n.t(localeKeys.command.bump.snapshot),
27
- false
28
- ).action((options) => bump(options));
29
- program.command("pre <enter|exit> [tag]").description(i18n.t(localeKeys.command.pre.describe)).action((type, tag) => pre(type, tag));
30
- program.command("release").description(i18n.t(localeKeys.command.release.describe)).option("--tag <tag>", i18n.t(localeKeys.command.release.tag), "").option("--otp <token>", i18n.t(localeKeys.command.release.otp), "").option(
31
- "--ignore-scripts",
32
- i18n.t(localeKeys.command.release.ignore_scripts),
33
- ""
34
- ).option(
35
- "--no-git-checks",
36
- i18n.t(localeKeys.command.release.no_git_checks),
37
- ""
38
- ).action((options) => release(options));
39
- program.command("change-status").description(i18n.t(localeKeys.command.status.describe)).option("--verbose", i18n.t(localeKeys.command.status.verbose)).option("--output <file>", i18n.t(localeKeys.command.status.output)).option("--since <ref>", i18n.t(localeKeys.command.status.since)).action((options) => status(options));
40
- program.command("gen-release-note").description(i18n.t(localeKeys.command.gen_release_note.describe)).option(
41
- "--repo <repo>",
42
- i18n.t(localeKeys.command.gen_release_note.repo)
43
- ).option(
44
- "--custom <cumtom>",
45
- i18n.t(localeKeys.command.gen_release_note.custom)
46
- ).action((options) => genReleaseNote(options));
47
- }
48
- };
49
- }
50
- });
51
- export {
52
- src_default as default
53
- };
@@ -1,41 +0,0 @@
1
- const EN_LOCALE = {
2
- command: {
3
- change: {
4
- describe: "create changeset",
5
- empty: "create an empty changeset",
6
- open: "opens the created changeset in an external editor",
7
- no_packages: "not find sub-project,please use `{packageManager} new` to create sub-project"
8
- },
9
- bump: {
10
- describe: "auto update publish version and changelog using changeset",
11
- canary: "create a prerelease version of publishing for testing",
12
- preid: "specify the identifier when versioning a prerelease",
13
- snapshot: "create a snapshot version of publishing for testing",
14
- ignore: "skip packages from being published"
15
- },
16
- pre: {
17
- describe: "enters and exits pre mode"
18
- },
19
- release: {
20
- describe: "publish changes to npm",
21
- tag: "publish use special tag",
22
- otp: "publish package use one-time password, if you have auth and writes enabled on npm ",
23
- ignore_scripts: "publish command ignore npm scripts, only can use in pnpm monorepo",
24
- no_git_checks: "publish command ignore checking if current branch is your publish branch, clean, and up-to-date, only can use in pnpm monorepo"
25
- },
26
- status: {
27
- describe: "provides information about the changesets that currently exist",
28
- verbose: "provides detail information about the changesets that currently exist with table",
29
- output: "write the information about the changesets that currently exist to json file",
30
- since: "only display information about changesets since a specific branch or git tag"
31
- },
32
- gen_release_note: {
33
- describe: "generator release note info from changesets",
34
- repo: "reponame to generator pull request link, like modern-js-dev/modern.js",
35
- custom: "custom release note render rules"
36
- }
37
- }
38
- };
39
- export {
40
- EN_LOCALE
41
- };
@@ -1,9 +0,0 @@
1
- import { I18n } from "@modern-js/plugin-i18n";
2
- import { ZH_LOCALE } from "./zh";
3
- import { EN_LOCALE } from "./en";
4
- const i18n = new I18n();
5
- const localeKeys = i18n.init("zh", { zh: ZH_LOCALE, en: EN_LOCALE });
6
- export {
7
- i18n,
8
- localeKeys
9
- };
@@ -1,41 +0,0 @@
1
- const ZH_LOCALE = {
2
- command: {
3
- change: {
4
- describe: "创建变更集",
5
- empty: "创建空变更集",
6
- open: "使用编辑器中打开创建的变更集",
7
- no_packages: "未找到子项目,请先执行 「{packageManager} new」 命令创建子项目"
8
- },
9
- bump: {
10
- describe: "使用变更集自动更新发布版本和变更日志",
11
- canary: "创建一个预发布版本进行测试",
12
- preid: "在对预发布版本进行版本控制时指定标识符",
13
- snapshot: "创建一个快照版本进行测试",
14
- ignore: "跳过部分包发布版本"
15
- },
16
- pre: {
17
- describe: "进入和退出预发布模式"
18
- },
19
- release: {
20
- describe: "发布 npm 包",
21
- tag: "发布 npm 包使用特定的 tag",
22
- otp: "发布 npm 包的一次性 token,该 token 需要写权限",
23
- ignore_scripts: "发布时忽略 package.json 中的 scripts 命令,仅支持在 pnpm monorepo 中使用",
24
- no_git_checks: "发布命令忽略检查当前分支是否是发布分支,干净且最新,仅支持在 pnpm monorepo 中使用"
25
- },
26
- status: {
27
- describe: "展示当前存在的变更集的状态信息",
28
- verbose: "使用表格展示当前存在的变更集状态信息,包含变更集文件名称",
29
- output: "将当前存在的变更集状态信息导出为 JSON 文件",
30
- since: "展示基于指定分支或者 tag 的变更集状态信息"
31
- },
32
- gen_release_note: {
33
- describe: "根据当前仓库 changeset 文件生成 Release Note",
34
- repo: "仓库名称,用于生成 Pull Request 链接, 例如: modern-js-dev/modern.js",
35
- custom: "自定义 Release Note 生成函数"
36
- }
37
- }
38
- };
39
- export {
40
- ZH_LOCALE
41
- };
@@ -1,14 +0,0 @@
1
- import { execa } from "@modern-js/utils";
2
- const CHANGESET_PATH = require.resolve("@changesets/cli");
3
- function execaWithStreamLog(command, args) {
4
- const promise = execa(command, args, {
5
- stdin: "inherit",
6
- stdout: "inherit",
7
- stderr: "inherit"
8
- });
9
- return promise;
10
- }
11
- export {
12
- CHANGESET_PATH,
13
- execaWithStreamLog
14
- };
@@ -1,2 +0,0 @@
1
- export * from "./changeset";
2
- export * from "./language";
@@ -1,8 +0,0 @@
1
- import { I18CLILanguageDetector } from "@modern-js/plugin-i18n/language-detector";
2
- function getLocaleLanguage() {
3
- const detector = new I18CLILanguageDetector();
4
- return detector.detect();
5
- }
6
- export {
7
- getLocaleLanguage
8
- };
@@ -1,89 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var __async = (__this, __arguments, generator) => {
19
- return new Promise((resolve, reject) => {
20
- var fulfilled = (value) => {
21
- try {
22
- step(generator.next(value));
23
- } catch (e) {
24
- reject(e);
25
- }
26
- };
27
- var rejected = (value) => {
28
- try {
29
- step(generator.throw(value));
30
- } catch (e) {
31
- reject(e);
32
- }
33
- };
34
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
- step((generator = generator.apply(__this, __arguments)).next());
36
- });
37
- };
38
- var bump_exports = {};
39
- __export(bump_exports, {
40
- bump: () => bump
41
- });
42
- module.exports = __toCommonJS(bump_exports);
43
- var import_utils = require("../utils");
44
- function bump(options) {
45
- return __async(this, null, function* () {
46
- const { snapshot, canary, preid, ignore } = options;
47
- const params = [import_utils.CHANGESET_PATH, "version"];
48
- if (snapshot) {
49
- params.push("--snapshot");
50
- if (typeof snapshot === "string") {
51
- params.push(snapshot);
52
- }
53
- }
54
- if (ignore) {
55
- ignore.forEach((pkg) => {
56
- params.push("--ignore");
57
- params.push(pkg);
58
- });
59
- }
60
- if (canary) {
61
- yield (0, import_utils.execaWithStreamLog)(process.execPath, [
62
- import_utils.CHANGESET_PATH,
63
- "pre",
64
- "enter",
65
- preid || "next"
66
- ]);
67
- try {
68
- yield (0, import_utils.execaWithStreamLog)(process.execPath, params);
69
- yield (0, import_utils.execaWithStreamLog)(process.execPath, [
70
- import_utils.CHANGESET_PATH,
71
- "pre",
72
- "exit"
73
- ]);
74
- } catch (e) {
75
- yield (0, import_utils.execaWithStreamLog)(process.execPath, [
76
- import_utils.CHANGESET_PATH,
77
- "pre",
78
- "exit"
79
- ]);
80
- }
81
- } else {
82
- yield (0, import_utils.execaWithStreamLog)(process.execPath, params);
83
- }
84
- });
85
- }
86
- // Annotate the CommonJS export names for ESM import in node:
87
- 0 && (module.exports = {
88
- bump
89
- });
@@ -1,75 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var __async = (__this, __arguments, generator) => {
19
- return new Promise((resolve, reject) => {
20
- var fulfilled = (value) => {
21
- try {
22
- step(generator.next(value));
23
- } catch (e) {
24
- reject(e);
25
- }
26
- };
27
- var rejected = (value) => {
28
- try {
29
- step(generator.throw(value));
30
- } catch (e) {
31
- reject(e);
32
- }
33
- };
34
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
- step((generator = generator.apply(__this, __arguments)).next());
36
- });
37
- };
38
- var change_exports = {};
39
- __export(change_exports, {
40
- change: () => change
41
- });
42
- module.exports = __toCommonJS(change_exports);
43
- var import_utils = require("@modern-js/utils");
44
- var import_utils2 = require("../utils");
45
- var import_locale = require("../locale");
46
- function change(options) {
47
- return __async(this, null, function* () {
48
- const appDir = process.cwd();
49
- if ((0, import_utils.isMonorepo)(appDir)) {
50
- const packages = (0, import_utils.getMonorepoPackages)(appDir);
51
- if (packages.length === 0) {
52
- const packageManager = yield (0, import_utils.getPackageManager)(appDir);
53
- import_utils.logger.warn(
54
- import_locale.i18n.t(import_locale.localeKeys.command.change.no_packages, {
55
- packageManager: packageManager === "yarn" ? "yarn" : `${packageManager} run`
56
- })
57
- );
58
- return;
59
- }
60
- }
61
- const { empty, open } = options;
62
- const params = [import_utils2.CHANGESET_PATH, "add"];
63
- if (empty) {
64
- params.push("--empty");
65
- }
66
- if (open) {
67
- params.push("--open");
68
- }
69
- yield (0, import_utils2.execaWithStreamLog)(process.execPath, params);
70
- });
71
- }
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- change
75
- });
@@ -1,22 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var commands_exports = {};
16
- module.exports = __toCommonJS(commands_exports);
17
- __reExport(commands_exports, require("./change"), module.exports);
18
- __reExport(commands_exports, require("./bump"), module.exports);
19
- __reExport(commands_exports, require("./pre"), module.exports);
20
- __reExport(commands_exports, require("./release"), module.exports);
21
- __reExport(commands_exports, require("./status"), module.exports);
22
- __reExport(commands_exports, require("./release-note"), module.exports);
@@ -1,56 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var __async = (__this, __arguments, generator) => {
19
- return new Promise((resolve, reject) => {
20
- var fulfilled = (value) => {
21
- try {
22
- step(generator.next(value));
23
- } catch (e) {
24
- reject(e);
25
- }
26
- };
27
- var rejected = (value) => {
28
- try {
29
- step(generator.throw(value));
30
- } catch (e) {
31
- reject(e);
32
- }
33
- };
34
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
- step((generator = generator.apply(__this, __arguments)).next());
36
- });
37
- };
38
- var pre_exports = {};
39
- __export(pre_exports, {
40
- pre: () => pre
41
- });
42
- module.exports = __toCommonJS(pre_exports);
43
- var import_utils = require("../utils");
44
- function pre(type, tag = "next") {
45
- return __async(this, null, function* () {
46
- const params = [import_utils.CHANGESET_PATH, "pre", type];
47
- if (type === "enter") {
48
- params.push(tag);
49
- }
50
- yield (0, import_utils.execaWithStreamLog)(process.execPath, params);
51
- });
52
- }
53
- // Annotate the CommonJS export names for ESM import in node:
54
- 0 && (module.exports = {
55
- pre
56
- });
@@ -1,193 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
- mod
22
- ));
23
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
- var __async = (__this, __arguments, generator) => {
25
- return new Promise((resolve, reject) => {
26
- var fulfilled = (value) => {
27
- try {
28
- step(generator.next(value));
29
- } catch (e) {
30
- reject(e);
31
- }
32
- };
33
- var rejected = (value) => {
34
- try {
35
- step(generator.throw(value));
36
- } catch (e) {
37
- reject(e);
38
- }
39
- };
40
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41
- step((generator = generator.apply(__this, __arguments)).next());
42
- });
43
- };
44
- var release_note_exports = {};
45
- __export(release_note_exports, {
46
- genReleaseNote: () => genReleaseNote,
47
- getReleaseInfo: () => getReleaseInfo,
48
- getReleaseNoteLine: () => getReleaseNoteLine
49
- });
50
- module.exports = __toCommonJS(release_note_exports);
51
- var import_path = __toESM(require("path"));
52
- var import_resolve_from = __toESM(require("resolve-from"));
53
- var import_utils = require("@modern-js/utils");
54
- var import_read = __toESM(require("@changesets/read"));
55
- function getReleaseInfo(commit, commitObj) {
56
- const commitRegex = /(.*)\(#(\d*)\)/;
57
- const [, message, author] = commit.split("--");
58
- commitObj.author = author;
59
- if ((message || commitObj.summary).match(commitRegex)) {
60
- const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
61
- commitObj.pullRequestId = pullRequestId;
62
- commitObj.message = messageShort.trim();
63
- }
64
- return commitObj;
65
- }
66
- function formatSummary(summary, pullRequestId) {
67
- const [firstLine, ...futureLines] = summary.split("\n").map((l) => l.trimRight());
68
- let returnVal = firstLine;
69
- if (futureLines.length > 0) {
70
- if (pullRequestId) {
71
- returnVal = `
72
-
73
- ${returnVal}`;
74
- } else {
75
- returnVal = `
76
- ${returnVal}`;
77
- }
78
- returnVal += `
79
-
80
- ${futureLines.filter((l) => Boolean(l)).map((l) => l).join("\n\n")}`;
81
- }
82
- return returnVal;
83
- }
84
- function getReleaseNoteLine(commit, customReleaseNoteFunction) {
85
- if (customReleaseNoteFunction == null ? void 0 : customReleaseNoteFunction.getReleaseNoteLine) {
86
- return customReleaseNoteFunction.getReleaseNoteLine(commit);
87
- }
88
- const { repository, pullRequestId, summary } = commit;
89
- if (pullRequestId && repository) {
90
- return `- [#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId}) ${formatSummary(
91
- summary,
92
- pullRequestId
93
- )}
94
- `;
95
- }
96
- if (pullRequestId) {
97
- return `#${pullRequestId} ${formatSummary(summary, pullRequestId)}
98
- `;
99
- }
100
- return `${formatSummary(summary, pullRequestId)}
101
- `;
102
- }
103
- function genReleaseNote(options) {
104
- return __async(this, null, function* () {
105
- const cwd = process.cwd();
106
- const { repo, custom } = options;
107
- let repository = repo;
108
- let customReleaseNoteFunction;
109
- if (!repo) {
110
- const pkg = yield import_utils.fs.readJSON(import_path.default.join(cwd, "package.json"));
111
- ({ repository } = pkg);
112
- }
113
- if (custom) {
114
- let possibleReleaseNoteFunc;
115
- const releasenotePath = (0, import_resolve_from.default)(cwd, custom);
116
- possibleReleaseNoteFunc = require(releasenotePath);
117
- if (possibleReleaseNoteFunc.default) {
118
- possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
119
- }
120
- if (typeof possibleReleaseNoteFunc.getReleaseInfo === "function" && typeof possibleReleaseNoteFunc.getReleaseNoteLine === "function") {
121
- customReleaseNoteFunction = possibleReleaseNoteFunc;
122
- } else {
123
- throw new Error("Could not resolve relesae note generation functions");
124
- }
125
- }
126
- const changesets = yield (0, import_read.default)(cwd);
127
- if (changesets.length === 0) {
128
- console.warn("No unreleased changesets found.");
129
- process.exit(1);
130
- }
131
- const features = [];
132
- const bugFix = [];
133
- for (const changeset of changesets) {
134
- const { stdout } = yield (0, import_utils.execa)("git", [
135
- "log",
136
- "--pretty=format:%h--%s--%an",
137
- `.changeset/${changeset.id}.md`
138
- ]);
139
- const [id, message] = stdout.split("--");
140
- let commitObj = {
141
- id,
142
- type: (message || changeset.summary).startsWith("fix") ? "fix" : "feature",
143
- repository,
144
- message: (message || changeset.summary).trim(),
145
- summary: changeset.summary
146
- };
147
- if (customReleaseNoteFunction == null ? void 0 : customReleaseNoteFunction.getReleaseInfo) {
148
- commitObj = yield customReleaseNoteFunction.getReleaseInfo(
149
- stdout,
150
- commitObj
151
- );
152
- } else {
153
- commitObj = getReleaseInfo(stdout, commitObj);
154
- }
155
- if (commitObj.type === "fix") {
156
- bugFix.push(commitObj);
157
- } else {
158
- features.push(commitObj);
159
- }
160
- }
161
- if (!features.length && !bugFix.length) {
162
- console.warn(
163
- "no release note found, you can run `pnpm run add` to add changeset"
164
- );
165
- }
166
- if (features.length) {
167
- console.info("## Features:\n");
168
- for (const commit of features) {
169
- const releaseNote = yield getReleaseNoteLine(
170
- commit,
171
- customReleaseNoteFunction
172
- );
173
- console.info(releaseNote);
174
- }
175
- }
176
- if (bugFix.length) {
177
- console.info("## Bug Fix:\n");
178
- for (const commit of bugFix) {
179
- const relesaeNote = yield getReleaseNoteLine(
180
- commit,
181
- customReleaseNoteFunction
182
- );
183
- console.info(relesaeNote);
184
- }
185
- }
186
- });
187
- }
188
- // Annotate the CommonJS export names for ESM import in node:
189
- 0 && (module.exports = {
190
- genReleaseNote,
191
- getReleaseInfo,
192
- getReleaseNoteLine
193
- });