@modern-js/plugin-changeset 2.0.0-beta.2 → 2.0.0-beta.4
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/CHANGELOG.md +60 -0
- package/dist/js/modern/commands/bump.js +63 -30
- package/dist/js/modern/commands/change.js +54 -25
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/pre.js +32 -7
- package/dist/js/modern/commands/release-note.js +131 -91
- package/dist/js/modern/commands/release.js +75 -46
- package/dist/js/modern/commands/status.js +41 -20
- package/dist/js/modern/index.js +44 -19
- package/dist/js/modern/locale/en.js +27 -24
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +27 -24
- package/dist/js/modern/utils/changeset.js +11 -7
- package/dist/js/modern/utils/index.js +1 -1
- package/dist/js/modern/utils/language.js +6 -3
- package/dist/js/node/commands/bump.js +82 -36
- package/dist/js/node/commands/change.js +69 -32
- package/dist/js/node/commands/index.js +22 -71
- package/dist/js/node/commands/pre.js +51 -13
- package/dist/js/node/commands/release-note.js +153 -97
- package/dist/js/node/commands/release.js +95 -53
- package/dist/js/node/commands/status.js +60 -26
- package/dist/js/node/index.js +66 -39
- package/dist/js/node/locale/en.js +43 -28
- package/dist/js/node/locale/index.js +27 -15
- package/dist/js/node/locale/zh.js +43 -28
- package/dist/js/node/utils/changeset.js +35 -14
- package/dist/js/node/utils/index.js +18 -27
- package/dist/js/node/utils/language.js +24 -8
- package/dist/types/index.d.ts +2 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @modern-js/plugin-changeset
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [7879e8f]
|
|
12
|
+
- Updated dependencies [6aca875]
|
|
13
|
+
- Updated dependencies [2e6031955e]
|
|
14
|
+
- Updated dependencies [7b7d12c]
|
|
15
|
+
- Updated dependencies [92f0eade39]
|
|
16
|
+
- Updated dependencies [edd1cfb1af]
|
|
17
|
+
- Updated dependencies [cc971eabfc]
|
|
18
|
+
- Updated dependencies [5b9049f2e9]
|
|
19
|
+
- Updated dependencies [92004d1906]
|
|
20
|
+
- Updated dependencies [b8bbe036c7]
|
|
21
|
+
- Updated dependencies [d5a31df781]
|
|
22
|
+
- Updated dependencies [dda38c9c3e]
|
|
23
|
+
- Updated dependencies [3bbea92b2a]
|
|
24
|
+
- Updated dependencies [b710adb843]
|
|
25
|
+
- Updated dependencies [ea7cf06]
|
|
26
|
+
- Updated dependencies [bbe4c4a]
|
|
27
|
+
- Updated dependencies [e4558a0]
|
|
28
|
+
- Updated dependencies [abf3421a75]
|
|
29
|
+
- Updated dependencies [543be9558e]
|
|
30
|
+
- Updated dependencies [14b712da84]
|
|
31
|
+
- @modern-js/utils@2.0.0-beta.4
|
|
32
|
+
- @modern-js/plugin-i18n@2.0.0-beta.4
|
|
33
|
+
|
|
34
|
+
## 2.0.0-beta.3
|
|
35
|
+
|
|
36
|
+
### Major Changes
|
|
37
|
+
|
|
38
|
+
- dda38c9c3e: chore: v2
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [6aca875]
|
|
43
|
+
- Updated dependencies [2e60319]
|
|
44
|
+
- Updated dependencies [92f0eade39]
|
|
45
|
+
- Updated dependencies [edd1cfb1af]
|
|
46
|
+
- Updated dependencies [cc971eabfc]
|
|
47
|
+
- Updated dependencies [5b9049f2e9]
|
|
48
|
+
- Updated dependencies [92004d1906]
|
|
49
|
+
- Updated dependencies [b8bbe036c7]
|
|
50
|
+
- Updated dependencies [d5a31df781]
|
|
51
|
+
- Updated dependencies [dda38c9c3e]
|
|
52
|
+
- Updated dependencies [3bbea92b2a]
|
|
53
|
+
- Updated dependencies [b710adb]
|
|
54
|
+
- Updated dependencies [ea7cf06]
|
|
55
|
+
- Updated dependencies [bbe4c4a]
|
|
56
|
+
- Updated dependencies [e4558a0]
|
|
57
|
+
- Updated dependencies [abf3421a75]
|
|
58
|
+
- Updated dependencies [543be9558e]
|
|
59
|
+
- Updated dependencies [14b712da84]
|
|
60
|
+
- @modern-js/utils@2.0.0-beta.3
|
|
61
|
+
- @modern-js/plugin-i18n@2.0.0-beta.3
|
|
62
|
+
|
|
3
63
|
## 2.0.0-beta.2
|
|
4
64
|
|
|
5
65
|
### Major Changes
|
|
@@ -1,33 +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
|
+
};
|
|
1
21
|
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
snapshot,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
params.push('--snapshot');
|
|
12
|
-
if (typeof snapshot === 'string') {
|
|
13
|
-
params.push(snapshot);
|
|
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
|
+
}
|
|
14
31
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
if (canary) {
|
|
23
|
-
await execaWithStreamLog(process.execPath, [CHANGESET_PATH, 'pre', 'enter', preid || 'next']);
|
|
24
|
-
try {
|
|
25
|
-
await execaWithStreamLog(process.execPath, params);
|
|
26
|
-
await execaWithStreamLog(process.execPath, [CHANGESET_PATH, 'pre', 'exit']);
|
|
27
|
-
} catch (e) {
|
|
28
|
-
await execaWithStreamLog(process.execPath, [CHANGESET_PATH, 'pre', 'exit']);
|
|
32
|
+
if (ignore) {
|
|
33
|
+
ignore.forEach((pkg) => {
|
|
34
|
+
params.push("--ignore");
|
|
35
|
+
params.push(pkg);
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
};
|
|
@@ -1,28 +1,57 @@
|
|
|
1
|
-
|
|
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";
|
|
2
27
|
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
3
28
|
import { i18n, localeKeys } from "../locale";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
}
|
|
14
43
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
empty
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
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
|
+
};
|
|
@@ -1,8 +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
|
+
};
|
|
1
21
|
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
};
|
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) {
|
|
6
26
|
const commitRegex = /(.*)\(#(\d*)\)/;
|
|
7
|
-
const [, message, author] = commit.split(
|
|
27
|
+
const [, message, author] = commit.split("--");
|
|
8
28
|
commitObj.author = author;
|
|
9
29
|
if ((message || commitObj.summary).match(commitRegex)) {
|
|
10
30
|
const [, messageShort, pullRequestId] = (message || commitObj.summary).match(commitRegex);
|
|
@@ -14,109 +34,129 @@ export function getReleaseInfo(commit, commitObj) {
|
|
|
14
34
|
return commitObj;
|
|
15
35
|
}
|
|
16
36
|
function formatSummary(summary, pullRequestId) {
|
|
17
|
-
const [firstLine, ...futureLines] = summary.split(
|
|
37
|
+
const [firstLine, ...futureLines] = summary.split("\n").map((l) => l.trimRight());
|
|
18
38
|
let returnVal = firstLine;
|
|
19
39
|
if (futureLines.length > 0) {
|
|
20
40
|
if (pullRequestId) {
|
|
21
|
-
returnVal =
|
|
41
|
+
returnVal = `
|
|
42
|
+
|
|
43
|
+
${returnVal}`;
|
|
22
44
|
} else {
|
|
23
|
-
returnVal =
|
|
45
|
+
returnVal = `
|
|
46
|
+
${returnVal}`;
|
|
24
47
|
}
|
|
25
|
-
returnVal +=
|
|
48
|
+
returnVal += `
|
|
49
|
+
|
|
50
|
+
${futureLines.filter((l) => Boolean(l)).map((l) => l).join("\n\n")}`;
|
|
26
51
|
}
|
|
27
52
|
return returnVal;
|
|
28
53
|
}
|
|
29
|
-
|
|
30
|
-
if (customReleaseNoteFunction
|
|
54
|
+
function getReleaseNoteLine(commit, customReleaseNoteFunction) {
|
|
55
|
+
if (customReleaseNoteFunction == null ? void 0 : customReleaseNoteFunction.getReleaseNoteLine) {
|
|
31
56
|
return customReleaseNoteFunction.getReleaseNoteLine(commit);
|
|
32
57
|
}
|
|
33
|
-
const {
|
|
34
|
-
repository,
|
|
35
|
-
pullRequestId,
|
|
36
|
-
summary
|
|
37
|
-
} = commit;
|
|
58
|
+
const { repository, pullRequestId, summary } = commit;
|
|
38
59
|
if (pullRequestId && repository) {
|
|
39
|
-
return `- [#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId}) ${formatSummary(
|
|
60
|
+
return `- [#${pullRequestId}](https://github.com/${repository}/pull/${pullRequestId}) ${formatSummary(
|
|
61
|
+
summary,
|
|
62
|
+
pullRequestId
|
|
63
|
+
)}
|
|
64
|
+
`;
|
|
40
65
|
}
|
|
41
66
|
if (pullRequestId) {
|
|
42
|
-
return `#${pullRequestId} ${formatSummary(summary, pullRequestId)}
|
|
67
|
+
return `#${pullRequestId} ${formatSummary(summary, pullRequestId)}
|
|
68
|
+
`;
|
|
43
69
|
}
|
|
44
|
-
return `${formatSummary(summary, pullRequestId)}
|
|
70
|
+
return `${formatSummary(summary, pullRequestId)}
|
|
71
|
+
`;
|
|
45
72
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
repo,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const pkg = await fs.readJSON(path.join(cwd, 'package.json'));
|
|
56
|
-
({
|
|
57
|
-
repository
|
|
58
|
-
} = pkg);
|
|
59
|
-
}
|
|
60
|
-
if (custom) {
|
|
61
|
-
let possibleReleaseNoteFunc;
|
|
62
|
-
const releasenotePath = resolveFrom(cwd, custom);
|
|
63
|
-
possibleReleaseNoteFunc = require(releasenotePath);
|
|
64
|
-
if (possibleReleaseNoteFunc.default) {
|
|
65
|
-
possibleReleaseNoteFunc = possibleReleaseNoteFunc.default;
|
|
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);
|
|
66
82
|
}
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
}
|
|
71
95
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// eslint-disable-next-line no-process-exit
|
|
77
|
-
process.exit(1);
|
|
78
|
-
}
|
|
79
|
-
const features = [];
|
|
80
|
-
const bugFix = [];
|
|
81
|
-
for (const changeset of changesets) {
|
|
82
|
-
var _customReleaseNoteFun;
|
|
83
|
-
const {
|
|
84
|
-
stdout
|
|
85
|
-
} = await execa('git', ['log', '--pretty=format:%h--%s--%an', `.changeset/${changeset.id}.md`]);
|
|
86
|
-
const [id, message] = stdout.split('--');
|
|
87
|
-
let commitObj = {
|
|
88
|
-
id,
|
|
89
|
-
type: (message || changeset.summary).startsWith('fix') ? 'fix' : 'feature',
|
|
90
|
-
repository,
|
|
91
|
-
message: (message || changeset.summary).trim(),
|
|
92
|
-
summary: changeset.summary
|
|
93
|
-
};
|
|
94
|
-
if ((_customReleaseNoteFun = customReleaseNoteFunction) !== null && _customReleaseNoteFun !== void 0 && _customReleaseNoteFun.getReleaseInfo) {
|
|
95
|
-
commitObj = await customReleaseNoteFunction.getReleaseInfo(stdout, commitObj);
|
|
96
|
-
} else {
|
|
97
|
-
commitObj = getReleaseInfo(stdout, commitObj);
|
|
96
|
+
const changesets = yield readChangesets(cwd);
|
|
97
|
+
if (changesets.length === 0) {
|
|
98
|
+
console.warn("No unreleased changesets found.");
|
|
99
|
+
process.exit(1);
|
|
98
100
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
}
|
|
103
130
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (features.length) {
|
|
109
|
-
console.info('## Features:\n');
|
|
110
|
-
for (const commit of features) {
|
|
111
|
-
const releaseNote = await getReleaseNoteLine(commit, customReleaseNoteFunction);
|
|
112
|
-
console.info(releaseNote);
|
|
131
|
+
if (!features.length && !bugFix.length) {
|
|
132
|
+
console.warn(
|
|
133
|
+
"no release note found, you can run `pnpm run add` to add changeset"
|
|
134
|
+
);
|
|
113
135
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
+
}
|
|
120
145
|
}
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
};
|
|
@@ -1,47 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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";
|
|
4
29
|
import { CHANGESET_PATH, execaWithStreamLog } from "../utils";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
tag,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
params.push(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
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
|
+
};
|