@modern-js/plugin-changeset 2.22.0 → 2.22.1-beta.1
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/cjs/commands/releaseNote.js +26 -5
- package/dist/esm/commands/releaseNote.js +26 -5
- package/dist/js/modern/commands/bump.js +66 -0
- package/dist/js/modern/commands/change.js +57 -0
- package/dist/js/modern/commands/index.js +6 -0
- package/dist/js/modern/commands/pre.js +33 -0
- package/dist/js/modern/commands/release-note.js +162 -0
- package/dist/js/modern/commands/release.js +76 -0
- package/dist/js/modern/commands/status.js +42 -0
- package/dist/js/modern/index.js +53 -0
- package/dist/js/modern/locale/en.js +41 -0
- package/dist/js/modern/locale/index.js +9 -0
- package/dist/js/modern/locale/zh.js +41 -0
- package/dist/js/modern/utils/changeset.js +14 -0
- package/dist/js/modern/utils/index.js +2 -0
- package/dist/js/modern/utils/language.js +8 -0
- package/dist/js/node/commands/bump.js +89 -0
- package/dist/js/node/commands/change.js +75 -0
- package/dist/js/node/commands/index.js +22 -0
- package/dist/js/node/commands/pre.js +56 -0
- package/dist/js/node/commands/release-note.js +193 -0
- package/dist/js/node/commands/release.js +100 -0
- package/dist/js/node/commands/status.js +65 -0
- package/dist/js/node/index.js +75 -0
- package/dist/js/node/locale/en.js +64 -0
- package/dist/js/node/locale/index.js +33 -0
- package/dist/js/node/locale/zh.js +64 -0
- package/dist/js/node/utils/changeset.js +44 -0
- package/dist/js/node/utils/index.js +18 -0
- package/dist/js/node/utils/language.js +31 -0
- package/dist/types/commands/releaseNote.d.ts +2 -1
- package/package.json +8 -7
|
@@ -41,6 +41,7 @@ _export(exports, {
|
|
|
41
41
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
42
42
|
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
43
43
|
const _resolvefrom = /* @__PURE__ */ _interop_require_default._(require("resolve-from"));
|
|
44
|
+
const _axios = /* @__PURE__ */ _interop_require_default._(require("axios"));
|
|
44
45
|
const _utils = require("@modern-js/utils");
|
|
45
46
|
const _read = /* @__PURE__ */ _interop_require_default._(require("@changesets/read"));
|
|
46
47
|
var CommitType;
|
|
@@ -82,10 +83,30 @@ function getCommitType(message) {
|
|
|
82
83
|
}
|
|
83
84
|
return CommitType.Other;
|
|
84
85
|
}
|
|
85
|
-
|
|
86
|
+
const AuthorMap = /* @__PURE__ */ new Map();
|
|
87
|
+
async function getReleaseInfo(commit, commitObj, authToken) {
|
|
86
88
|
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
87
|
-
const [, message,
|
|
88
|
-
|
|
89
|
+
const [commitId, message, email] = commit.split("--");
|
|
90
|
+
const author = AuthorMap.get(email);
|
|
91
|
+
const AuthToken = authToken || process.env.GITHUB_AUTH_TOKEN;
|
|
92
|
+
if (author) {
|
|
93
|
+
commitObj.author = author;
|
|
94
|
+
} else if (AuthToken) {
|
|
95
|
+
try {
|
|
96
|
+
const res = await _axios.default.get(`https://api.github.com/repos/web-infra-dev/modern.js/commits/${commitId}`, {
|
|
97
|
+
method: "GET",
|
|
98
|
+
headers: {
|
|
99
|
+
"Content-Type": "application/json",
|
|
100
|
+
Authorization: AuthToken
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const author2 = res.data.author.login;
|
|
104
|
+
commitObj.author = author2;
|
|
105
|
+
AuthorMap.set(email, author2);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.warn(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
89
110
|
if ((message || commitObj.summary).match(commitRegex)) {
|
|
90
111
|
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
91
112
|
commitObj.pullRequestId = pullRequestId;
|
|
@@ -158,7 +179,7 @@ async function genReleaseNote(options) {
|
|
|
158
179
|
for (const changeset of changesets) {
|
|
159
180
|
const { stdout } = await (0, _utils.execa)("git", [
|
|
160
181
|
"log",
|
|
161
|
-
"--pretty=format:%h--%s--%
|
|
182
|
+
"--pretty=format:%h--%s--%ae",
|
|
162
183
|
`.changeset/${changeset.id}.md`
|
|
163
184
|
]);
|
|
164
185
|
const [id, message] = stdout.split("--");
|
|
@@ -174,7 +195,7 @@ async function genReleaseNote(options) {
|
|
|
174
195
|
if (customReleaseNoteFunction === null || customReleaseNoteFunction === void 0 ? void 0 : customReleaseNoteFunction.getReleaseInfo) {
|
|
175
196
|
commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
176
197
|
} else {
|
|
177
|
-
commitObj = getReleaseInfo(stdout, commitObj);
|
|
198
|
+
commitObj = await getReleaseInfo(stdout, commitObj);
|
|
178
199
|
}
|
|
179
200
|
releaseNote[commitObj.type].en.push(commitObj);
|
|
180
201
|
if (commitObj.summary_zh) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import resolveFrom from "resolve-from";
|
|
3
|
+
import axios from "axios";
|
|
3
4
|
import { fs, execa } from "@modern-js/utils";
|
|
4
5
|
import readChangesets from "@changesets/read";
|
|
5
6
|
export var CommitType;
|
|
@@ -41,10 +42,30 @@ export function getCommitType(message) {
|
|
|
41
42
|
}
|
|
42
43
|
return CommitType.Other;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
const AuthorMap = /* @__PURE__ */ new Map();
|
|
46
|
+
export async function getReleaseInfo(commit, commitObj, authToken) {
|
|
45
47
|
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
46
|
-
const [, message,
|
|
47
|
-
|
|
48
|
+
const [commitId, message, email] = commit.split("--");
|
|
49
|
+
const author = AuthorMap.get(email);
|
|
50
|
+
const AuthToken = authToken || process.env.GITHUB_AUTH_TOKEN;
|
|
51
|
+
if (author) {
|
|
52
|
+
commitObj.author = author;
|
|
53
|
+
} else if (AuthToken) {
|
|
54
|
+
try {
|
|
55
|
+
const res = await axios.get(`https://api.github.com/repos/web-infra-dev/modern.js/commits/${commitId}`, {
|
|
56
|
+
method: "GET",
|
|
57
|
+
headers: {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
Authorization: AuthToken
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const author2 = res.data.author.login;
|
|
63
|
+
commitObj.author = author2;
|
|
64
|
+
AuthorMap.set(email, author2);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.warn(e);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
48
69
|
if ((message || commitObj.summary).match(commitRegex)) {
|
|
49
70
|
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
50
71
|
commitObj.pullRequestId = pullRequestId;
|
|
@@ -117,7 +138,7 @@ export async function genReleaseNote(options) {
|
|
|
117
138
|
for (const changeset of changesets) {
|
|
118
139
|
const { stdout } = await execa("git", [
|
|
119
140
|
"log",
|
|
120
|
-
"--pretty=format:%h--%s--%
|
|
141
|
+
"--pretty=format:%h--%s--%ae",
|
|
121
142
|
`.changeset/${changeset.id}.md`
|
|
122
143
|
]);
|
|
123
144
|
const [id, message] = stdout.split("--");
|
|
@@ -133,7 +154,7 @@ export async function genReleaseNote(options) {
|
|
|
133
154
|
if (customReleaseNoteFunction === null || customReleaseNoteFunction === void 0 ? void 0 : customReleaseNoteFunction.getReleaseInfo) {
|
|
134
155
|
commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
135
156
|
} else {
|
|
136
|
-
commitObj = getReleaseInfo(stdout, commitObj);
|
|
157
|
+
commitObj = await getReleaseInfo(stdout, commitObj);
|
|
137
158
|
}
|
|
138
159
|
releaseNote[commitObj.type].en.push(commitObj);
|
|
139
160
|
if (commitObj.summary_zh) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
22
|
+
function bump(options) {
|
|
23
|
+
return __async(this, null, function* () {
|
|
24
|
+
const { snapshot, canary, preid, ignore } = options;
|
|
25
|
+
const params = [CHANGESET_PATH, "version"];
|
|
26
|
+
if (snapshot) {
|
|
27
|
+
params.push("--snapshot");
|
|
28
|
+
if (typeof snapshot === "string") {
|
|
29
|
+
params.push(snapshot);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (ignore) {
|
|
33
|
+
ignore.forEach((pkg) => {
|
|
34
|
+
params.push("--ignore");
|
|
35
|
+
params.push(pkg);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (canary) {
|
|
39
|
+
yield execaWithStreamLog(process.execPath, [
|
|
40
|
+
CHANGESET_PATH,
|
|
41
|
+
"pre",
|
|
42
|
+
"enter",
|
|
43
|
+
preid || "next"
|
|
44
|
+
]);
|
|
45
|
+
try {
|
|
46
|
+
yield execaWithStreamLog(process.execPath, params);
|
|
47
|
+
yield execaWithStreamLog(process.execPath, [
|
|
48
|
+
CHANGESET_PATH,
|
|
49
|
+
"pre",
|
|
50
|
+
"exit"
|
|
51
|
+
]);
|
|
52
|
+
} catch (e) {
|
|
53
|
+
yield execaWithStreamLog(process.execPath, [
|
|
54
|
+
CHANGESET_PATH,
|
|
55
|
+
"pre",
|
|
56
|
+
"exit"
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
yield execaWithStreamLog(process.execPath, params);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
bump
|
|
66
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import {
|
|
22
|
+
isMonorepo,
|
|
23
|
+
getMonorepoPackages,
|
|
24
|
+
getPackageManager,
|
|
25
|
+
logger
|
|
26
|
+
} from "@modern-js/utils";
|
|
27
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
28
|
+
import { i18n, localeKeys } from "../locale";
|
|
29
|
+
function change(options) {
|
|
30
|
+
return __async(this, null, function* () {
|
|
31
|
+
const appDir = process.cwd();
|
|
32
|
+
if (isMonorepo(appDir)) {
|
|
33
|
+
const packages = getMonorepoPackages(appDir);
|
|
34
|
+
if (packages.length === 0) {
|
|
35
|
+
const packageManager = yield getPackageManager(appDir);
|
|
36
|
+
logger.warn(
|
|
37
|
+
i18n.t(localeKeys.command.change.no_packages, {
|
|
38
|
+
packageManager: packageManager === "yarn" ? "yarn" : `${packageManager} run`
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const { empty, open } = options;
|
|
45
|
+
const params = [CHANGESET_PATH, "add"];
|
|
46
|
+
if (empty) {
|
|
47
|
+
params.push("--empty");
|
|
48
|
+
}
|
|
49
|
+
if (open) {
|
|
50
|
+
params.push("--open");
|
|
51
|
+
}
|
|
52
|
+
yield execaWithStreamLog(process.execPath, params);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
change
|
|
57
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
22
|
+
function pre(type, tag = "next") {
|
|
23
|
+
return __async(this, null, function* () {
|
|
24
|
+
const params = [CHANGESET_PATH, "pre", type];
|
|
25
|
+
if (type === "enter") {
|
|
26
|
+
params.push(tag);
|
|
27
|
+
}
|
|
28
|
+
yield execaWithStreamLog(process.execPath, params);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
pre
|
|
33
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import path from "path";
|
|
22
|
+
import resolveFrom from "resolve-from";
|
|
23
|
+
import { fs, execa } from "@modern-js/utils";
|
|
24
|
+
import readChangesets from "@changesets/read";
|
|
25
|
+
function getReleaseInfo(commit, commitObj) {
|
|
26
|
+
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
27
|
+
const [, message, author] = commit.split("--");
|
|
28
|
+
commitObj.author = author;
|
|
29
|
+
if ((message || commitObj.summary).match(commitRegex)) {
|
|
30
|
+
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
31
|
+
commitObj.pullRequestId = pullRequestId;
|
|
32
|
+
commitObj.message = messageShort.trim();
|
|
33
|
+
}
|
|
34
|
+
return commitObj;
|
|
35
|
+
}
|
|
36
|
+
function formatSummary(summary, pullRequestId) {
|
|
37
|
+
const [firstLine, ...futureLines] = summary.split("\n").map((l) => l.trimRight());
|
|
38
|
+
let returnVal = firstLine;
|
|
39
|
+
if (futureLines.length > 0) {
|
|
40
|
+
if (pullRequestId) {
|
|
41
|
+
returnVal = `
|
|
42
|
+
|
|
43
|
+
${returnVal}`;
|
|
44
|
+
} else {
|
|
45
|
+
returnVal = `
|
|
46
|
+
${returnVal}`;
|
|
47
|
+
}
|
|
48
|
+
returnVal += `
|
|
49
|
+
|
|
50
|
+
${futureLines.filter((l) => Boolean(l)).map((l) => l).join("\n\n")}`;
|
|
51
|
+
}
|
|
52
|
+
return returnVal;
|
|
53
|
+
}
|
|
54
|
+
function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
55
|
+
if (customReleaseNoteFunction == null ? void 0 : customReleaseNoteFunction.getReleaseNoteLine) {
|
|
56
|
+
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
57
|
+
}
|
|
58
|
+
const { repository, pullRequestId, summary } = commit;
|
|
59
|
+
if (pullRequestId && repository) {
|
|
60
|
+
return `- [#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId}) ${formatSummary(
|
|
61
|
+
summary,
|
|
62
|
+
pullRequestId
|
|
63
|
+
)}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
if (pullRequestId) {
|
|
67
|
+
return `#${pullRequestId} ${formatSummary(summary, pullRequestId)}
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
return `${formatSummary(summary, pullRequestId)}
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
function genReleaseNote(options) {
|
|
74
|
+
return __async(this, null, function* () {
|
|
75
|
+
const cwd = process.cwd();
|
|
76
|
+
const { repo, custom } = options;
|
|
77
|
+
let repository = repo;
|
|
78
|
+
let customReleaseNoteFunction;
|
|
79
|
+
if (!repo) {
|
|
80
|
+
const pkg = yield fs.readJSON(path.join(cwd, "package.json"));
|
|
81
|
+
({ repository } = pkg);
|
|
82
|
+
}
|
|
83
|
+
if (custom) {
|
|
84
|
+
let possibleReleaseNoteFunc;
|
|
85
|
+
const releasenotePath = resolveFrom(cwd, custom);
|
|
86
|
+
possibleReleaseNoteFunc = require(releasenotePath);
|
|
87
|
+
if (possibleReleaseNoteFunc.default) {
|
|
88
|
+
possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
|
|
89
|
+
}
|
|
90
|
+
if (typeof possibleReleaseNoteFunc.getReleaseInfo === "function" && typeof possibleReleaseNoteFunc.getReleaseNoteLine === "function") {
|
|
91
|
+
customReleaseNoteFunction = possibleReleaseNoteFunc;
|
|
92
|
+
} else {
|
|
93
|
+
throw new Error("Could not resolve relesae note generation functions");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const changesets = yield readChangesets(cwd);
|
|
97
|
+
if (changesets.length === 0) {
|
|
98
|
+
console.warn("No unreleased changesets found.");
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
const features = [];
|
|
102
|
+
const bugFix = [];
|
|
103
|
+
for (const changeset of changesets) {
|
|
104
|
+
const { stdout } = yield execa("git", [
|
|
105
|
+
"log",
|
|
106
|
+
"--pretty=format:%h--%s--%an",
|
|
107
|
+
`.changeset/${changeset.id}.md`
|
|
108
|
+
]);
|
|
109
|
+
const [id, message] = stdout.split("--");
|
|
110
|
+
let commitObj = {
|
|
111
|
+
id,
|
|
112
|
+
type: (message || changeset.summary).startsWith("fix") ? "fix" : "feature",
|
|
113
|
+
repository,
|
|
114
|
+
message: (message || changeset.summary).trim(),
|
|
115
|
+
summary: changeset.summary
|
|
116
|
+
};
|
|
117
|
+
if (customReleaseNoteFunction == null ? void 0 : customReleaseNoteFunction.getReleaseInfo) {
|
|
118
|
+
commitObj = yield customReleaseNoteFunction.getReleaseInfo(
|
|
119
|
+
stdout,
|
|
120
|
+
commitObj
|
|
121
|
+
);
|
|
122
|
+
} else {
|
|
123
|
+
commitObj = getReleaseInfo(stdout, commitObj);
|
|
124
|
+
}
|
|
125
|
+
if (commitObj.type === "fix") {
|
|
126
|
+
bugFix.push(commitObj);
|
|
127
|
+
} else {
|
|
128
|
+
features.push(commitObj);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (!features.length && !bugFix.length) {
|
|
132
|
+
console.warn(
|
|
133
|
+
"no release note found, you can run `pnpm run add` to add changeset"
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (features.length) {
|
|
137
|
+
console.info("## Features:\n");
|
|
138
|
+
for (const commit of features) {
|
|
139
|
+
const releaseNote = yield getReleaseNoteLine(
|
|
140
|
+
commit,
|
|
141
|
+
customReleaseNoteFunction
|
|
142
|
+
);
|
|
143
|
+
console.info(releaseNote);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (bugFix.length) {
|
|
147
|
+
console.info("## Bug Fix:\n");
|
|
148
|
+
for (const commit of bugFix) {
|
|
149
|
+
const relesaeNote = yield getReleaseNoteLine(
|
|
150
|
+
commit,
|
|
151
|
+
customReleaseNoteFunction
|
|
152
|
+
);
|
|
153
|
+
console.info(relesaeNote);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
genReleaseNote,
|
|
160
|
+
getReleaseInfo,
|
|
161
|
+
getReleaseNoteLine
|
|
162
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import path from "path";
|
|
22
|
+
import {
|
|
23
|
+
getPackageManager,
|
|
24
|
+
isMonorepo,
|
|
25
|
+
fs,
|
|
26
|
+
getPnpmVersion
|
|
27
|
+
} from "@modern-js/utils";
|
|
28
|
+
import { tag as gitTag } from "@changesets/git";
|
|
29
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
30
|
+
function release(options) {
|
|
31
|
+
return __async(this, null, function* () {
|
|
32
|
+
const appDir = process.cwd();
|
|
33
|
+
const packageManager = yield getPackageManager(process.cwd());
|
|
34
|
+
const params = ["publish"];
|
|
35
|
+
const { tag, otp, ignoreScripts, gitChecks } = options;
|
|
36
|
+
if (tag) {
|
|
37
|
+
params.push("--tag");
|
|
38
|
+
params.push(tag);
|
|
39
|
+
}
|
|
40
|
+
if (otp) {
|
|
41
|
+
params.push("--otp");
|
|
42
|
+
params.push(otp);
|
|
43
|
+
}
|
|
44
|
+
if (!isMonorepo(appDir) || packageManager === "yarn" || packageManager === "npm") {
|
|
45
|
+
yield execaWithStreamLog(process.execPath, [CHANGESET_PATH, ...params]);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
params.push("-r");
|
|
49
|
+
params.push("--filter");
|
|
50
|
+
const pnpmVersion = yield getPnpmVersion();
|
|
51
|
+
if (pnpmVersion.startsWith("6")) {
|
|
52
|
+
params.push("./packages/");
|
|
53
|
+
} else {
|
|
54
|
+
params.push("{./packages/**}");
|
|
55
|
+
}
|
|
56
|
+
params.push("--report-summary");
|
|
57
|
+
if (ignoreScripts) {
|
|
58
|
+
params.push("--ignore-scripts");
|
|
59
|
+
}
|
|
60
|
+
if (!gitChecks) {
|
|
61
|
+
params.push("--no-git-checks");
|
|
62
|
+
}
|
|
63
|
+
yield execaWithStreamLog(packageManager, params);
|
|
64
|
+
const pnpmPublishSummaryFile = path.join(appDir, "pnpm-publish-summary.json");
|
|
65
|
+
const publishInfo = yield fs.readJSON(pnpmPublishSummaryFile, "utf-8");
|
|
66
|
+
yield Promise.all(
|
|
67
|
+
(publishInfo.publishedPackages || []).map(
|
|
68
|
+
(pkg) => gitTag(`${pkg.name}@${pkg.version}`, appDir)
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
yield fs.remove(pnpmPublishSummaryFile);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
release
|
|
76
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
22
|
+
function status(options) {
|
|
23
|
+
return __async(this, null, function* () {
|
|
24
|
+
const params = [CHANGESET_PATH, "status"];
|
|
25
|
+
const { verbose, output, since } = options;
|
|
26
|
+
if (verbose) {
|
|
27
|
+
params.push("--verbose");
|
|
28
|
+
}
|
|
29
|
+
if (output) {
|
|
30
|
+
params.push("--output");
|
|
31
|
+
params.push(output);
|
|
32
|
+
}
|
|
33
|
+
if (since) {
|
|
34
|
+
params.push("--since");
|
|
35
|
+
params.push(since);
|
|
36
|
+
}
|
|
37
|
+
yield execaWithStreamLog(process.execPath, params);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
status
|
|
42
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
};
|