@qlover/fe-release 5.0.2 → 5.0.5
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.cjs +100 -25
- package/dist/cli.js +100 -25
- package/dist/index.cjs +99 -24
- package/dist/index.d.ts +42 -6
- package/dist/index.js +99 -24
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -28,7 +28,7 @@ var import_commander = require("commander");
|
|
|
28
28
|
|
|
29
29
|
// package.json
|
|
30
30
|
var description = "A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.";
|
|
31
|
-
var version = "5.0.
|
|
31
|
+
var version = "5.0.5";
|
|
32
32
|
|
|
33
33
|
// src/cli.ts
|
|
34
34
|
var import_semver = __toESM(require("semver"), 1);
|
|
@@ -69,16 +69,23 @@ var releaseJson = {
|
|
|
69
69
|
autoMergeReleasePR: false,
|
|
70
70
|
pushChangeLabels: false,
|
|
71
71
|
skipCreateReleasePR: false,
|
|
72
|
-
|
|
72
|
+
/** Used when releasing 1–2 packages */
|
|
73
|
+
PRTitle: "Release ${spaces}",
|
|
74
|
+
/** Used when releasing more than 2 packages */
|
|
75
|
+
PRTitleMany: "Release ${count} packages: ${spaces}",
|
|
73
76
|
PRBody: "## Changelog\n\n${changelog}",
|
|
74
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Per-workspace section in the PR body (single and multi package).
|
|
79
|
+
* `${changeTypeSection}` is Patch/Minor/Major Changes from increment.
|
|
80
|
+
*/
|
|
81
|
+
batchPRBody: "\n### ${name}@${newVersion}\n\n#### ${changeTypeSection}\n\n${changelog}\n",
|
|
75
82
|
branchName: "release/${repoName}-${releaseId}",
|
|
76
83
|
releaseTagName: "release-tag-${count}-patch-${releaseId}",
|
|
77
84
|
commitMessage: "chore(release): ${spaces}",
|
|
78
85
|
label: {
|
|
79
86
|
name: "CI-Release",
|
|
80
87
|
color: "1A7F37",
|
|
81
|
-
description: "
|
|
88
|
+
description: "Automated release PR (merge to publish)"
|
|
82
89
|
}
|
|
83
90
|
},
|
|
84
91
|
changesetVersion: {
|
|
@@ -1662,17 +1669,27 @@ var ChangesetVersion = class extends import_scripts_context4.ScriptPlugin {
|
|
|
1662
1669
|
});
|
|
1663
1670
|
this.context.setWorkspaces(newWorkspaces);
|
|
1664
1671
|
}
|
|
1672
|
+
printWorksapces() {
|
|
1673
|
+
const workspaces = this.context.workspaces;
|
|
1674
|
+
this.logger.info(
|
|
1675
|
+
`ChangesetVersion Workspaces (${workspaces?.length}):
|
|
1676
|
+
${workspaces?.map((workspace) => workspace.toString()).join("\n")}`
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1665
1679
|
async onSuccess() {
|
|
1666
1680
|
if (this.mode === "publish") {
|
|
1667
1681
|
await this.runChangesetPublish();
|
|
1682
|
+
this.printWorksapces();
|
|
1668
1683
|
return;
|
|
1669
1684
|
}
|
|
1670
1685
|
if (this.mode === "both") {
|
|
1671
1686
|
await this.runVersionFlow();
|
|
1672
1687
|
await this.runChangesetPublish();
|
|
1688
|
+
this.printWorksapces();
|
|
1673
1689
|
return;
|
|
1674
1690
|
}
|
|
1675
1691
|
await this.runVersionFlow();
|
|
1692
|
+
this.printWorksapces();
|
|
1676
1693
|
}
|
|
1677
1694
|
logDryRun(message) {
|
|
1678
1695
|
this.logger.info(`[dry-run] ${message}`);
|
|
@@ -1711,18 +1728,59 @@ var ChangesetVersion = class extends import_scripts_context4.ScriptPlugin {
|
|
|
1711
1728
|
this.syncWorkspaces(this.context.workspaces ?? workspaces);
|
|
1712
1729
|
}
|
|
1713
1730
|
async runChangesetPublish() {
|
|
1731
|
+
const workspaces = this.context.workspaces ?? [];
|
|
1714
1732
|
if (this.context.dryRun) {
|
|
1715
1733
|
this.logDryRun("Would run: changeset publish, publish packages and tags");
|
|
1734
|
+
const preview = this.mergeWorkspaces(workspaces);
|
|
1735
|
+
this.context.setWorkspaces(preview);
|
|
1736
|
+
const previewTags = preview.filter(
|
|
1737
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && workspace.tagName
|
|
1738
|
+
).map((workspace) => workspace.tagName);
|
|
1739
|
+
this.logDryRun(
|
|
1740
|
+
previewTags.length === 0 ? "Would push release tag(s) from workspace.tagName: none" : `Would push release tag(s) from workspace.tagName:
|
|
1741
|
+
${previewTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1742
|
+
);
|
|
1716
1743
|
return;
|
|
1717
1744
|
}
|
|
1718
1745
|
await this.step({
|
|
1719
1746
|
label: "Changeset Publish",
|
|
1720
1747
|
task: () => this.context.runChangesetsCli("publish")
|
|
1721
1748
|
});
|
|
1722
|
-
|
|
1723
|
-
if (workspaces && workspaces.length > 0) {
|
|
1749
|
+
if (workspaces.length > 0) {
|
|
1724
1750
|
this.syncWorkspaces(workspaces);
|
|
1725
1751
|
}
|
|
1752
|
+
await this.step({
|
|
1753
|
+
label: "Push Release Tags",
|
|
1754
|
+
task: () => this.pushWorkspaceReleaseTags(this.context.workspaces ?? workspaces)
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Push release tags from synced workspaces' `tagName` fields.
|
|
1759
|
+
*
|
|
1760
|
+
* `changeset publish` only creates tags locally. After {@link syncWorkspaces},
|
|
1761
|
+
* each publishable workspace should already have `tagName` (e.g. `pkg@1.2.3`).
|
|
1762
|
+
*/
|
|
1763
|
+
async pushWorkspaceReleaseTags(workspaces) {
|
|
1764
|
+
const tags = workspaces.filter(
|
|
1765
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && !!workspace.tagName
|
|
1766
|
+
).map((workspace) => workspace.tagName);
|
|
1767
|
+
const uniqueTags = [...new Set(tags)];
|
|
1768
|
+
if (uniqueTags.length === 0) {
|
|
1769
|
+
this.logger.warn(
|
|
1770
|
+
"No workspace.tagName found after publish sync; skip tag push"
|
|
1771
|
+
);
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
this.logger.info(
|
|
1775
|
+
`Pushing ${uniqueTags.length} release tag(s) to origin:
|
|
1776
|
+
${uniqueTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1777
|
+
);
|
|
1778
|
+
await this.shell.exec([
|
|
1779
|
+
"git",
|
|
1780
|
+
"push",
|
|
1781
|
+
"origin",
|
|
1782
|
+
...uniqueTags.map((tag) => `"refs/tags/${tag}"`)
|
|
1783
|
+
]);
|
|
1726
1784
|
}
|
|
1727
1785
|
syncWorkspaces(workspaces) {
|
|
1728
1786
|
let newWorkspaces = this.mergeWorkspaces(workspaces);
|
|
@@ -1813,10 +1871,11 @@ ${lines.join("\n")}`
|
|
|
1813
1871
|
dependencyReleaseOf: workspace.dependencyReleaseOf,
|
|
1814
1872
|
lastTag: workspace.lastTag
|
|
1815
1873
|
});
|
|
1816
|
-
|
|
1874
|
+
const releaseVersion = newWorkspace.newVersion || newWorkspace.version;
|
|
1875
|
+
if (releaseVersion) {
|
|
1817
1876
|
newWorkspace.tagName = this.generateTagName({
|
|
1818
1877
|
...newWorkspace,
|
|
1819
|
-
version:
|
|
1878
|
+
version: releaseVersion
|
|
1820
1879
|
});
|
|
1821
1880
|
}
|
|
1822
1881
|
return newWorkspace;
|
|
@@ -1935,7 +1994,9 @@ ${lines.join("\n")}`
|
|
|
1935
1994
|
getIncrementLabels() {
|
|
1936
1995
|
const fromConfig = this.context.parameters.workspaces?.changeLabels;
|
|
1937
1996
|
if (Array.isArray(fromConfig) && fromConfig.length > 0) {
|
|
1938
|
-
return fromConfig.filter(
|
|
1997
|
+
return fromConfig.filter(
|
|
1998
|
+
(label) => typeof label === "string"
|
|
1999
|
+
);
|
|
1939
2000
|
}
|
|
1940
2001
|
return this.readGithubEventLabelNames();
|
|
1941
2002
|
}
|
|
@@ -1950,7 +2011,9 @@ ${lines.join("\n")}`
|
|
|
1950
2011
|
if (!Array.isArray(labels)) {
|
|
1951
2012
|
return [];
|
|
1952
2013
|
}
|
|
1953
|
-
return labels.map((label) => label?.name).filter(
|
|
2014
|
+
return labels.map((label) => label?.name).filter(
|
|
2015
|
+
(name) => typeof name === "string" && name.length > 0
|
|
2016
|
+
);
|
|
1954
2017
|
} catch (error) {
|
|
1955
2018
|
this.logger.debug("Failed to read labels from GITHUB_EVENT_PATH", error);
|
|
1956
2019
|
return [];
|
|
@@ -3319,23 +3382,33 @@ var ReleaseFormatter = class {
|
|
|
3319
3382
|
if (workspaces.length === 0) {
|
|
3320
3383
|
return "";
|
|
3321
3384
|
}
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
}
|
|
3385
|
+
const changeTypeSection = this.getChangeTypeSection();
|
|
3386
|
+
const batchTpl = this.config.batchPRBody || releaseJson.github.batchPRBody;
|
|
3325
3387
|
return workspaces.map(
|
|
3326
|
-
(workspace) => this.templateEngine.render(
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
}
|
|
3334
|
-
)
|
|
3388
|
+
(workspace) => this.templateEngine.render(batchTpl, {
|
|
3389
|
+
...workspace,
|
|
3390
|
+
// Prefer bumped version in PR changelog section headers
|
|
3391
|
+
version: workspace.newVersion || workspace.version,
|
|
3392
|
+
newVersion: workspace.newVersion || workspace.version,
|
|
3393
|
+
changeTypeSection
|
|
3394
|
+
})
|
|
3335
3395
|
).join("\n");
|
|
3336
3396
|
}
|
|
3397
|
+
/**
|
|
3398
|
+
* Map semver increment to Changesets-style section title.
|
|
3399
|
+
*/
|
|
3400
|
+
getChangeTypeSection() {
|
|
3401
|
+
const increment = (this.config.increment || "patch").toLowerCase();
|
|
3402
|
+
if (increment === "major") {
|
|
3403
|
+
return "Major Changes";
|
|
3404
|
+
}
|
|
3405
|
+
if (increment === "minor") {
|
|
3406
|
+
return "Minor Changes";
|
|
3407
|
+
}
|
|
3408
|
+
return "Patch Changes";
|
|
3409
|
+
}
|
|
3337
3410
|
formatPRTagName(workspaces, releaseBranchResult) {
|
|
3338
|
-
if (workspaces.length
|
|
3411
|
+
if (workspaces.length === 0) {
|
|
3339
3412
|
return releaseBranchResult.releaseTagName;
|
|
3340
3413
|
}
|
|
3341
3414
|
return workspaces.map(
|
|
@@ -3343,7 +3416,8 @@ var ReleaseFormatter = class {
|
|
|
3343
3416
|
).join(" ");
|
|
3344
3417
|
}
|
|
3345
3418
|
getPRTitle(releaseBranchResult, context, workspaces = []) {
|
|
3346
|
-
const
|
|
3419
|
+
const count = workspaces.length;
|
|
3420
|
+
const prTitleTpl = count > 2 ? this.config.PRTitleMany || this.config.PRTitle || releaseJson.github.PRTitleMany : this.config.PRTitle || releaseJson.github.PRTitle;
|
|
3347
3421
|
return this.templateEngine.render(
|
|
3348
3422
|
prTitleTpl,
|
|
3349
3423
|
this.buildPRTemplateVars(workspaces, releaseBranchResult, context)
|
|
@@ -3381,7 +3455,8 @@ var Github = class extends GitBase {
|
|
|
3381
3455
|
repoName: this.context.options.repoName,
|
|
3382
3456
|
authorName: this.context.options.authorName,
|
|
3383
3457
|
env: this.context.options.releaseEnv,
|
|
3384
|
-
releaseId: this.context.releaseId
|
|
3458
|
+
releaseId: this.context.releaseId,
|
|
3459
|
+
increment: this.context.parameters.changesetVersion?.increment || releaseJson.changesetVersion.increment
|
|
3385
3460
|
});
|
|
3386
3461
|
this.logger.info(`Github mode: ${this.mode}`);
|
|
3387
3462
|
}
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from "commander";
|
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
7
|
var description = "A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.";
|
|
8
|
-
var version = "5.0.
|
|
8
|
+
var version = "5.0.5";
|
|
9
9
|
|
|
10
10
|
// src/cli.ts
|
|
11
11
|
import semver from "semver";
|
|
@@ -46,16 +46,23 @@ var releaseJson = {
|
|
|
46
46
|
autoMergeReleasePR: false,
|
|
47
47
|
pushChangeLabels: false,
|
|
48
48
|
skipCreateReleasePR: false,
|
|
49
|
-
|
|
49
|
+
/** Used when releasing 1–2 packages */
|
|
50
|
+
PRTitle: "Release ${spaces}",
|
|
51
|
+
/** Used when releasing more than 2 packages */
|
|
52
|
+
PRTitleMany: "Release ${count} packages: ${spaces}",
|
|
50
53
|
PRBody: "## Changelog\n\n${changelog}",
|
|
51
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Per-workspace section in the PR body (single and multi package).
|
|
56
|
+
* `${changeTypeSection}` is Patch/Minor/Major Changes from increment.
|
|
57
|
+
*/
|
|
58
|
+
batchPRBody: "\n### ${name}@${newVersion}\n\n#### ${changeTypeSection}\n\n${changelog}\n",
|
|
52
59
|
branchName: "release/${repoName}-${releaseId}",
|
|
53
60
|
releaseTagName: "release-tag-${count}-patch-${releaseId}",
|
|
54
61
|
commitMessage: "chore(release): ${spaces}",
|
|
55
62
|
label: {
|
|
56
63
|
name: "CI-Release",
|
|
57
64
|
color: "1A7F37",
|
|
58
|
-
description: "
|
|
65
|
+
description: "Automated release PR (merge to publish)"
|
|
59
66
|
}
|
|
60
67
|
},
|
|
61
68
|
changesetVersion: {
|
|
@@ -1642,17 +1649,27 @@ var ChangesetVersion = class extends ScriptPlugin2 {
|
|
|
1642
1649
|
});
|
|
1643
1650
|
this.context.setWorkspaces(newWorkspaces);
|
|
1644
1651
|
}
|
|
1652
|
+
printWorksapces() {
|
|
1653
|
+
const workspaces = this.context.workspaces;
|
|
1654
|
+
this.logger.info(
|
|
1655
|
+
`ChangesetVersion Workspaces (${workspaces?.length}):
|
|
1656
|
+
${workspaces?.map((workspace) => workspace.toString()).join("\n")}`
|
|
1657
|
+
);
|
|
1658
|
+
}
|
|
1645
1659
|
async onSuccess() {
|
|
1646
1660
|
if (this.mode === "publish") {
|
|
1647
1661
|
await this.runChangesetPublish();
|
|
1662
|
+
this.printWorksapces();
|
|
1648
1663
|
return;
|
|
1649
1664
|
}
|
|
1650
1665
|
if (this.mode === "both") {
|
|
1651
1666
|
await this.runVersionFlow();
|
|
1652
1667
|
await this.runChangesetPublish();
|
|
1668
|
+
this.printWorksapces();
|
|
1653
1669
|
return;
|
|
1654
1670
|
}
|
|
1655
1671
|
await this.runVersionFlow();
|
|
1672
|
+
this.printWorksapces();
|
|
1656
1673
|
}
|
|
1657
1674
|
logDryRun(message) {
|
|
1658
1675
|
this.logger.info(`[dry-run] ${message}`);
|
|
@@ -1691,18 +1708,59 @@ var ChangesetVersion = class extends ScriptPlugin2 {
|
|
|
1691
1708
|
this.syncWorkspaces(this.context.workspaces ?? workspaces);
|
|
1692
1709
|
}
|
|
1693
1710
|
async runChangesetPublish() {
|
|
1711
|
+
const workspaces = this.context.workspaces ?? [];
|
|
1694
1712
|
if (this.context.dryRun) {
|
|
1695
1713
|
this.logDryRun("Would run: changeset publish, publish packages and tags");
|
|
1714
|
+
const preview = this.mergeWorkspaces(workspaces);
|
|
1715
|
+
this.context.setWorkspaces(preview);
|
|
1716
|
+
const previewTags = preview.filter(
|
|
1717
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && workspace.tagName
|
|
1718
|
+
).map((workspace) => workspace.tagName);
|
|
1719
|
+
this.logDryRun(
|
|
1720
|
+
previewTags.length === 0 ? "Would push release tag(s) from workspace.tagName: none" : `Would push release tag(s) from workspace.tagName:
|
|
1721
|
+
${previewTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1722
|
+
);
|
|
1696
1723
|
return;
|
|
1697
1724
|
}
|
|
1698
1725
|
await this.step({
|
|
1699
1726
|
label: "Changeset Publish",
|
|
1700
1727
|
task: () => this.context.runChangesetsCli("publish")
|
|
1701
1728
|
});
|
|
1702
|
-
|
|
1703
|
-
if (workspaces && workspaces.length > 0) {
|
|
1729
|
+
if (workspaces.length > 0) {
|
|
1704
1730
|
this.syncWorkspaces(workspaces);
|
|
1705
1731
|
}
|
|
1732
|
+
await this.step({
|
|
1733
|
+
label: "Push Release Tags",
|
|
1734
|
+
task: () => this.pushWorkspaceReleaseTags(this.context.workspaces ?? workspaces)
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Push release tags from synced workspaces' `tagName` fields.
|
|
1739
|
+
*
|
|
1740
|
+
* `changeset publish` only creates tags locally. After {@link syncWorkspaces},
|
|
1741
|
+
* each publishable workspace should already have `tagName` (e.g. `pkg@1.2.3`).
|
|
1742
|
+
*/
|
|
1743
|
+
async pushWorkspaceReleaseTags(workspaces) {
|
|
1744
|
+
const tags = workspaces.filter(
|
|
1745
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && !!workspace.tagName
|
|
1746
|
+
).map((workspace) => workspace.tagName);
|
|
1747
|
+
const uniqueTags = [...new Set(tags)];
|
|
1748
|
+
if (uniqueTags.length === 0) {
|
|
1749
|
+
this.logger.warn(
|
|
1750
|
+
"No workspace.tagName found after publish sync; skip tag push"
|
|
1751
|
+
);
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
this.logger.info(
|
|
1755
|
+
`Pushing ${uniqueTags.length} release tag(s) to origin:
|
|
1756
|
+
${uniqueTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1757
|
+
);
|
|
1758
|
+
await this.shell.exec([
|
|
1759
|
+
"git",
|
|
1760
|
+
"push",
|
|
1761
|
+
"origin",
|
|
1762
|
+
...uniqueTags.map((tag) => `"refs/tags/${tag}"`)
|
|
1763
|
+
]);
|
|
1706
1764
|
}
|
|
1707
1765
|
syncWorkspaces(workspaces) {
|
|
1708
1766
|
let newWorkspaces = this.mergeWorkspaces(workspaces);
|
|
@@ -1793,10 +1851,11 @@ ${lines.join("\n")}`
|
|
|
1793
1851
|
dependencyReleaseOf: workspace.dependencyReleaseOf,
|
|
1794
1852
|
lastTag: workspace.lastTag
|
|
1795
1853
|
});
|
|
1796
|
-
|
|
1854
|
+
const releaseVersion = newWorkspace.newVersion || newWorkspace.version;
|
|
1855
|
+
if (releaseVersion) {
|
|
1797
1856
|
newWorkspace.tagName = this.generateTagName({
|
|
1798
1857
|
...newWorkspace,
|
|
1799
|
-
version:
|
|
1858
|
+
version: releaseVersion
|
|
1800
1859
|
});
|
|
1801
1860
|
}
|
|
1802
1861
|
return newWorkspace;
|
|
@@ -1915,7 +1974,9 @@ ${lines.join("\n")}`
|
|
|
1915
1974
|
getIncrementLabels() {
|
|
1916
1975
|
const fromConfig = this.context.parameters.workspaces?.changeLabels;
|
|
1917
1976
|
if (Array.isArray(fromConfig) && fromConfig.length > 0) {
|
|
1918
|
-
return fromConfig.filter(
|
|
1977
|
+
return fromConfig.filter(
|
|
1978
|
+
(label) => typeof label === "string"
|
|
1979
|
+
);
|
|
1919
1980
|
}
|
|
1920
1981
|
return this.readGithubEventLabelNames();
|
|
1921
1982
|
}
|
|
@@ -1930,7 +1991,9 @@ ${lines.join("\n")}`
|
|
|
1930
1991
|
if (!Array.isArray(labels)) {
|
|
1931
1992
|
return [];
|
|
1932
1993
|
}
|
|
1933
|
-
return labels.map((label) => label?.name).filter(
|
|
1994
|
+
return labels.map((label) => label?.name).filter(
|
|
1995
|
+
(name) => typeof name === "string" && name.length > 0
|
|
1996
|
+
);
|
|
1934
1997
|
} catch (error) {
|
|
1935
1998
|
this.logger.debug("Failed to read labels from GITHUB_EVENT_PATH", error);
|
|
1936
1999
|
return [];
|
|
@@ -3299,23 +3362,33 @@ var ReleaseFormatter = class {
|
|
|
3299
3362
|
if (workspaces.length === 0) {
|
|
3300
3363
|
return "";
|
|
3301
3364
|
}
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
}
|
|
3365
|
+
const changeTypeSection = this.getChangeTypeSection();
|
|
3366
|
+
const batchTpl = this.config.batchPRBody || releaseJson.github.batchPRBody;
|
|
3305
3367
|
return workspaces.map(
|
|
3306
|
-
(workspace) => this.templateEngine.render(
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
}
|
|
3314
|
-
)
|
|
3368
|
+
(workspace) => this.templateEngine.render(batchTpl, {
|
|
3369
|
+
...workspace,
|
|
3370
|
+
// Prefer bumped version in PR changelog section headers
|
|
3371
|
+
version: workspace.newVersion || workspace.version,
|
|
3372
|
+
newVersion: workspace.newVersion || workspace.version,
|
|
3373
|
+
changeTypeSection
|
|
3374
|
+
})
|
|
3315
3375
|
).join("\n");
|
|
3316
3376
|
}
|
|
3377
|
+
/**
|
|
3378
|
+
* Map semver increment to Changesets-style section title.
|
|
3379
|
+
*/
|
|
3380
|
+
getChangeTypeSection() {
|
|
3381
|
+
const increment = (this.config.increment || "patch").toLowerCase();
|
|
3382
|
+
if (increment === "major") {
|
|
3383
|
+
return "Major Changes";
|
|
3384
|
+
}
|
|
3385
|
+
if (increment === "minor") {
|
|
3386
|
+
return "Minor Changes";
|
|
3387
|
+
}
|
|
3388
|
+
return "Patch Changes";
|
|
3389
|
+
}
|
|
3317
3390
|
formatPRTagName(workspaces, releaseBranchResult) {
|
|
3318
|
-
if (workspaces.length
|
|
3391
|
+
if (workspaces.length === 0) {
|
|
3319
3392
|
return releaseBranchResult.releaseTagName;
|
|
3320
3393
|
}
|
|
3321
3394
|
return workspaces.map(
|
|
@@ -3323,7 +3396,8 @@ var ReleaseFormatter = class {
|
|
|
3323
3396
|
).join(" ");
|
|
3324
3397
|
}
|
|
3325
3398
|
getPRTitle(releaseBranchResult, context, workspaces = []) {
|
|
3326
|
-
const
|
|
3399
|
+
const count = workspaces.length;
|
|
3400
|
+
const prTitleTpl = count > 2 ? this.config.PRTitleMany || this.config.PRTitle || releaseJson.github.PRTitleMany : this.config.PRTitle || releaseJson.github.PRTitle;
|
|
3327
3401
|
return this.templateEngine.render(
|
|
3328
3402
|
prTitleTpl,
|
|
3329
3403
|
this.buildPRTemplateVars(workspaces, releaseBranchResult, context)
|
|
@@ -3361,7 +3435,8 @@ var Github = class extends GitBase {
|
|
|
3361
3435
|
repoName: this.context.options.repoName,
|
|
3362
3436
|
authorName: this.context.options.authorName,
|
|
3363
3437
|
env: this.context.options.releaseEnv,
|
|
3364
|
-
releaseId: this.context.releaseId
|
|
3438
|
+
releaseId: this.context.releaseId,
|
|
3439
|
+
increment: this.context.parameters.changesetVersion?.increment || releaseJson.changesetVersion.increment
|
|
3365
3440
|
});
|
|
3366
3441
|
this.logger.info(`Github mode: ${this.mode}`);
|
|
3367
3442
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -66,16 +66,23 @@ var releaseJson = {
|
|
|
66
66
|
autoMergeReleasePR: false,
|
|
67
67
|
pushChangeLabels: false,
|
|
68
68
|
skipCreateReleasePR: false,
|
|
69
|
-
|
|
69
|
+
/** Used when releasing 1–2 packages */
|
|
70
|
+
PRTitle: "Release ${spaces}",
|
|
71
|
+
/** Used when releasing more than 2 packages */
|
|
72
|
+
PRTitleMany: "Release ${count} packages: ${spaces}",
|
|
70
73
|
PRBody: "## Changelog\n\n${changelog}",
|
|
71
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Per-workspace section in the PR body (single and multi package).
|
|
76
|
+
* `${changeTypeSection}` is Patch/Minor/Major Changes from increment.
|
|
77
|
+
*/
|
|
78
|
+
batchPRBody: "\n### ${name}@${newVersion}\n\n#### ${changeTypeSection}\n\n${changelog}\n",
|
|
72
79
|
branchName: "release/${repoName}-${releaseId}",
|
|
73
80
|
releaseTagName: "release-tag-${count}-patch-${releaseId}",
|
|
74
81
|
commitMessage: "chore(release): ${spaces}",
|
|
75
82
|
label: {
|
|
76
83
|
name: "CI-Release",
|
|
77
84
|
color: "1A7F37",
|
|
78
|
-
description: "
|
|
85
|
+
description: "Automated release PR (merge to publish)"
|
|
79
86
|
}
|
|
80
87
|
},
|
|
81
88
|
changesetVersion: {
|
|
@@ -1667,17 +1674,27 @@ var ChangesetVersion = class extends import_scripts_context4.ScriptPlugin {
|
|
|
1667
1674
|
});
|
|
1668
1675
|
this.context.setWorkspaces(newWorkspaces);
|
|
1669
1676
|
}
|
|
1677
|
+
printWorksapces() {
|
|
1678
|
+
const workspaces = this.context.workspaces;
|
|
1679
|
+
this.logger.info(
|
|
1680
|
+
`ChangesetVersion Workspaces (${workspaces?.length}):
|
|
1681
|
+
${workspaces?.map((workspace) => workspace.toString()).join("\n")}`
|
|
1682
|
+
);
|
|
1683
|
+
}
|
|
1670
1684
|
async onSuccess() {
|
|
1671
1685
|
if (this.mode === "publish") {
|
|
1672
1686
|
await this.runChangesetPublish();
|
|
1687
|
+
this.printWorksapces();
|
|
1673
1688
|
return;
|
|
1674
1689
|
}
|
|
1675
1690
|
if (this.mode === "both") {
|
|
1676
1691
|
await this.runVersionFlow();
|
|
1677
1692
|
await this.runChangesetPublish();
|
|
1693
|
+
this.printWorksapces();
|
|
1678
1694
|
return;
|
|
1679
1695
|
}
|
|
1680
1696
|
await this.runVersionFlow();
|
|
1697
|
+
this.printWorksapces();
|
|
1681
1698
|
}
|
|
1682
1699
|
logDryRun(message) {
|
|
1683
1700
|
this.logger.info(`[dry-run] ${message}`);
|
|
@@ -1716,18 +1733,59 @@ var ChangesetVersion = class extends import_scripts_context4.ScriptPlugin {
|
|
|
1716
1733
|
this.syncWorkspaces(this.context.workspaces ?? workspaces);
|
|
1717
1734
|
}
|
|
1718
1735
|
async runChangesetPublish() {
|
|
1736
|
+
const workspaces = this.context.workspaces ?? [];
|
|
1719
1737
|
if (this.context.dryRun) {
|
|
1720
1738
|
this.logDryRun("Would run: changeset publish, publish packages and tags");
|
|
1739
|
+
const preview = this.mergeWorkspaces(workspaces);
|
|
1740
|
+
this.context.setWorkspaces(preview);
|
|
1741
|
+
const previewTags = preview.filter(
|
|
1742
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && workspace.tagName
|
|
1743
|
+
).map((workspace) => workspace.tagName);
|
|
1744
|
+
this.logDryRun(
|
|
1745
|
+
previewTags.length === 0 ? "Would push release tag(s) from workspace.tagName: none" : `Would push release tag(s) from workspace.tagName:
|
|
1746
|
+
${previewTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1747
|
+
);
|
|
1721
1748
|
return;
|
|
1722
1749
|
}
|
|
1723
1750
|
await this.step({
|
|
1724
1751
|
label: "Changeset Publish",
|
|
1725
1752
|
task: () => this.context.runChangesetsCli("publish")
|
|
1726
1753
|
});
|
|
1727
|
-
|
|
1728
|
-
if (workspaces && workspaces.length > 0) {
|
|
1754
|
+
if (workspaces.length > 0) {
|
|
1729
1755
|
this.syncWorkspaces(workspaces);
|
|
1730
1756
|
}
|
|
1757
|
+
await this.step({
|
|
1758
|
+
label: "Push Release Tags",
|
|
1759
|
+
task: () => this.pushWorkspaceReleaseTags(this.context.workspaces ?? workspaces)
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Push release tags from synced workspaces' `tagName` fields.
|
|
1764
|
+
*
|
|
1765
|
+
* `changeset publish` only creates tags locally. After {@link syncWorkspaces},
|
|
1766
|
+
* each publishable workspace should already have `tagName` (e.g. `pkg@1.2.3`).
|
|
1767
|
+
*/
|
|
1768
|
+
async pushWorkspaceReleaseTags(workspaces) {
|
|
1769
|
+
const tags = workspaces.filter(
|
|
1770
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && !!workspace.tagName
|
|
1771
|
+
).map((workspace) => workspace.tagName);
|
|
1772
|
+
const uniqueTags = [...new Set(tags)];
|
|
1773
|
+
if (uniqueTags.length === 0) {
|
|
1774
|
+
this.logger.warn(
|
|
1775
|
+
"No workspace.tagName found after publish sync; skip tag push"
|
|
1776
|
+
);
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
this.logger.info(
|
|
1780
|
+
`Pushing ${uniqueTags.length} release tag(s) to origin:
|
|
1781
|
+
${uniqueTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1782
|
+
);
|
|
1783
|
+
await this.shell.exec([
|
|
1784
|
+
"git",
|
|
1785
|
+
"push",
|
|
1786
|
+
"origin",
|
|
1787
|
+
...uniqueTags.map((tag) => `"refs/tags/${tag}"`)
|
|
1788
|
+
]);
|
|
1731
1789
|
}
|
|
1732
1790
|
syncWorkspaces(workspaces) {
|
|
1733
1791
|
let newWorkspaces = this.mergeWorkspaces(workspaces);
|
|
@@ -1818,10 +1876,11 @@ ${lines.join("\n")}`
|
|
|
1818
1876
|
dependencyReleaseOf: workspace.dependencyReleaseOf,
|
|
1819
1877
|
lastTag: workspace.lastTag
|
|
1820
1878
|
});
|
|
1821
|
-
|
|
1879
|
+
const releaseVersion = newWorkspace.newVersion || newWorkspace.version;
|
|
1880
|
+
if (releaseVersion) {
|
|
1822
1881
|
newWorkspace.tagName = this.generateTagName({
|
|
1823
1882
|
...newWorkspace,
|
|
1824
|
-
version:
|
|
1883
|
+
version: releaseVersion
|
|
1825
1884
|
});
|
|
1826
1885
|
}
|
|
1827
1886
|
return newWorkspace;
|
|
@@ -1940,7 +1999,9 @@ ${lines.join("\n")}`
|
|
|
1940
1999
|
getIncrementLabels() {
|
|
1941
2000
|
const fromConfig = this.context.parameters.workspaces?.changeLabels;
|
|
1942
2001
|
if (Array.isArray(fromConfig) && fromConfig.length > 0) {
|
|
1943
|
-
return fromConfig.filter(
|
|
2002
|
+
return fromConfig.filter(
|
|
2003
|
+
(label) => typeof label === "string"
|
|
2004
|
+
);
|
|
1944
2005
|
}
|
|
1945
2006
|
return this.readGithubEventLabelNames();
|
|
1946
2007
|
}
|
|
@@ -1955,7 +2016,9 @@ ${lines.join("\n")}`
|
|
|
1955
2016
|
if (!Array.isArray(labels)) {
|
|
1956
2017
|
return [];
|
|
1957
2018
|
}
|
|
1958
|
-
return labels.map((label) => label?.name).filter(
|
|
2019
|
+
return labels.map((label) => label?.name).filter(
|
|
2020
|
+
(name) => typeof name === "string" && name.length > 0
|
|
2021
|
+
);
|
|
1959
2022
|
} catch (error) {
|
|
1960
2023
|
this.logger.debug("Failed to read labels from GITHUB_EVENT_PATH", error);
|
|
1961
2024
|
return [];
|
|
@@ -3324,23 +3387,33 @@ var ReleaseFormatter = class {
|
|
|
3324
3387
|
if (workspaces.length === 0) {
|
|
3325
3388
|
return "";
|
|
3326
3389
|
}
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
}
|
|
3390
|
+
const changeTypeSection = this.getChangeTypeSection();
|
|
3391
|
+
const batchTpl = this.config.batchPRBody || releaseJson.github.batchPRBody;
|
|
3330
3392
|
return workspaces.map(
|
|
3331
|
-
(workspace) => this.templateEngine.render(
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
}
|
|
3339
|
-
)
|
|
3393
|
+
(workspace) => this.templateEngine.render(batchTpl, {
|
|
3394
|
+
...workspace,
|
|
3395
|
+
// Prefer bumped version in PR changelog section headers
|
|
3396
|
+
version: workspace.newVersion || workspace.version,
|
|
3397
|
+
newVersion: workspace.newVersion || workspace.version,
|
|
3398
|
+
changeTypeSection
|
|
3399
|
+
})
|
|
3340
3400
|
).join("\n");
|
|
3341
3401
|
}
|
|
3402
|
+
/**
|
|
3403
|
+
* Map semver increment to Changesets-style section title.
|
|
3404
|
+
*/
|
|
3405
|
+
getChangeTypeSection() {
|
|
3406
|
+
const increment = (this.config.increment || "patch").toLowerCase();
|
|
3407
|
+
if (increment === "major") {
|
|
3408
|
+
return "Major Changes";
|
|
3409
|
+
}
|
|
3410
|
+
if (increment === "minor") {
|
|
3411
|
+
return "Minor Changes";
|
|
3412
|
+
}
|
|
3413
|
+
return "Patch Changes";
|
|
3414
|
+
}
|
|
3342
3415
|
formatPRTagName(workspaces, releaseBranchResult) {
|
|
3343
|
-
if (workspaces.length
|
|
3416
|
+
if (workspaces.length === 0) {
|
|
3344
3417
|
return releaseBranchResult.releaseTagName;
|
|
3345
3418
|
}
|
|
3346
3419
|
return workspaces.map(
|
|
@@ -3348,7 +3421,8 @@ var ReleaseFormatter = class {
|
|
|
3348
3421
|
).join(" ");
|
|
3349
3422
|
}
|
|
3350
3423
|
getPRTitle(releaseBranchResult, context, workspaces = []) {
|
|
3351
|
-
const
|
|
3424
|
+
const count = workspaces.length;
|
|
3425
|
+
const prTitleTpl = count > 2 ? this.config.PRTitleMany || this.config.PRTitle || releaseJson.github.PRTitleMany : this.config.PRTitle || releaseJson.github.PRTitle;
|
|
3352
3426
|
return this.templateEngine.render(
|
|
3353
3427
|
prTitleTpl,
|
|
3354
3428
|
this.buildPRTemplateVars(workspaces, releaseBranchResult, context)
|
|
@@ -3386,7 +3460,8 @@ var Github = class extends GitBase {
|
|
|
3386
3460
|
repoName: this.context.options.repoName,
|
|
3387
3461
|
authorName: this.context.options.authorName,
|
|
3388
3462
|
env: this.context.options.releaseEnv,
|
|
3389
|
-
releaseId: this.context.releaseId
|
|
3463
|
+
releaseId: this.context.releaseId,
|
|
3464
|
+
increment: this.context.parameters.changesetVersion?.increment || releaseJson.changesetVersion.increment
|
|
3390
3465
|
});
|
|
3391
3466
|
this.logger.info(`Github mode: ${this.mode}`);
|
|
3392
3467
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -216,11 +216,19 @@ interface ReleaseFormatterConfig {
|
|
|
216
216
|
more: string;
|
|
217
217
|
};
|
|
218
218
|
/**
|
|
219
|
-
* Pull request title template
|
|
219
|
+
* Pull request title template (1–2 packages)
|
|
220
220
|
*
|
|
221
|
-
* @default {@link
|
|
221
|
+
* @default {@link releaseJson.github.PRTitle}
|
|
222
222
|
*/
|
|
223
223
|
PRTitle?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Pull request title template when releasing more than 2 packages
|
|
226
|
+
*
|
|
227
|
+
* Falls back to {@link PRTitle} when unset.
|
|
228
|
+
*
|
|
229
|
+
* @default {@link releaseJson.github.PRTitleMany}
|
|
230
|
+
*/
|
|
231
|
+
PRTitleMany?: string;
|
|
224
232
|
/**
|
|
225
233
|
* Pull request body template
|
|
226
234
|
*
|
|
@@ -228,11 +236,19 @@ interface ReleaseFormatterConfig {
|
|
|
228
236
|
*/
|
|
229
237
|
PRBody?: string;
|
|
230
238
|
/**
|
|
231
|
-
* Template for each workspace section in
|
|
239
|
+
* Template for each workspace section in the PR body
|
|
240
|
+
*
|
|
241
|
+
* Used for both single- and multi-workspace releases.
|
|
242
|
+
* Supports `${changeTypeSection}` (Patch/Minor/Major Changes).
|
|
232
243
|
*
|
|
233
244
|
* @default from release.json
|
|
234
245
|
*/
|
|
235
246
|
batchPRBody?: string;
|
|
247
|
+
/**
|
|
248
|
+
* Semver increment used to title changelog sections (patch | minor | major)
|
|
249
|
+
* @default 'patch'
|
|
250
|
+
*/
|
|
251
|
+
increment?: string;
|
|
236
252
|
}
|
|
237
253
|
|
|
238
254
|
/**
|
|
@@ -839,6 +855,11 @@ interface ChangeLogInterface {
|
|
|
839
855
|
* when `ignoreNonUpdatedPackages` is enabled)
|
|
840
856
|
* - **onSuccess**: run version and/or publish flow based on `mode`
|
|
841
857
|
*
|
|
858
|
+
* Publish flow (`mode: 'publish'` or second half of `'both'`):
|
|
859
|
+
* 1. Run `changeset publish` (npm publish + local `git tag` only)
|
|
860
|
+
* 2. Sync workspaces from disk so `tagName` is set from the release version
|
|
861
|
+
* 3. Push `workspace.tagName` refs to `origin`
|
|
862
|
+
*
|
|
842
863
|
* Version flow (`mode: 'version'` or first half of `'both'`):
|
|
843
864
|
* 1. Write `.changeset/*.md` files for directly changed packages only
|
|
844
865
|
* 2. Run `changeset version` (optionally with `changelog: false` when `onlyVersion`)
|
|
@@ -966,10 +987,18 @@ declare class ChangesetVersion extends ScriptPlugin<ReleaseContext, ChangesetVer
|
|
|
966
987
|
*/
|
|
967
988
|
protected validateNpmToken(): Promise<void>;
|
|
968
989
|
onExec(_context: ReleaseContext): Promise<void>;
|
|
990
|
+
protected printWorksapces(): void;
|
|
969
991
|
onSuccess(): Promise<void>;
|
|
970
992
|
protected logDryRun(message: string): void;
|
|
971
993
|
protected runVersionFlow(): Promise<void>;
|
|
972
994
|
protected runChangesetPublish(): Promise<void>;
|
|
995
|
+
/**
|
|
996
|
+
* Push release tags from synced workspaces' `tagName` fields.
|
|
997
|
+
*
|
|
998
|
+
* `changeset publish` only creates tags locally. After {@link syncWorkspaces},
|
|
999
|
+
* each publishable workspace should already have `tagName` (e.g. `pkg@1.2.3`).
|
|
1000
|
+
*/
|
|
1001
|
+
protected pushWorkspaceReleaseTags(workspaces: WorkspaceInterface[]): Promise<void>;
|
|
973
1002
|
protected syncWorkspaces(workspaces: WorkspaceInterface[]): void;
|
|
974
1003
|
/**
|
|
975
1004
|
* Rebuild `dependencyRelease` changelogs after source packages have `newVersion`.
|
|
@@ -1402,16 +1431,23 @@ declare const releaseJson: {
|
|
|
1402
1431
|
readonly autoMergeReleasePR: false;
|
|
1403
1432
|
readonly pushChangeLabels: false;
|
|
1404
1433
|
readonly skipCreateReleasePR: false;
|
|
1405
|
-
|
|
1434
|
+
/** Used when releasing 1–2 packages */
|
|
1435
|
+
readonly PRTitle: "Release ${spaces}";
|
|
1436
|
+
/** Used when releasing more than 2 packages */
|
|
1437
|
+
readonly PRTitleMany: "Release ${count} packages: ${spaces}";
|
|
1406
1438
|
readonly PRBody: "## Changelog\n\n${changelog}";
|
|
1407
|
-
|
|
1439
|
+
/**
|
|
1440
|
+
* Per-workspace section in the PR body (single and multi package).
|
|
1441
|
+
* `${changeTypeSection}` is Patch/Minor/Major Changes from increment.
|
|
1442
|
+
*/
|
|
1443
|
+
readonly batchPRBody: "\n### ${name}@${newVersion}\n\n#### ${changeTypeSection}\n\n${changelog}\n";
|
|
1408
1444
|
readonly branchName: "release/${repoName}-${releaseId}";
|
|
1409
1445
|
readonly releaseTagName: "release-tag-${count}-patch-${releaseId}";
|
|
1410
1446
|
readonly commitMessage: "chore(release): ${spaces}";
|
|
1411
1447
|
readonly label: {
|
|
1412
1448
|
readonly name: "CI-Release";
|
|
1413
1449
|
readonly color: "1A7F37";
|
|
1414
|
-
readonly description: "
|
|
1450
|
+
readonly description: "Automated release PR (merge to publish)";
|
|
1415
1451
|
};
|
|
1416
1452
|
};
|
|
1417
1453
|
readonly changesetVersion: {
|
package/dist/index.js
CHANGED
|
@@ -14,16 +14,23 @@ var releaseJson = {
|
|
|
14
14
|
autoMergeReleasePR: false,
|
|
15
15
|
pushChangeLabels: false,
|
|
16
16
|
skipCreateReleasePR: false,
|
|
17
|
-
|
|
17
|
+
/** Used when releasing 1–2 packages */
|
|
18
|
+
PRTitle: "Release ${spaces}",
|
|
19
|
+
/** Used when releasing more than 2 packages */
|
|
20
|
+
PRTitleMany: "Release ${count} packages: ${spaces}",
|
|
18
21
|
PRBody: "## Changelog\n\n${changelog}",
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Per-workspace section in the PR body (single and multi package).
|
|
24
|
+
* `${changeTypeSection}` is Patch/Minor/Major Changes from increment.
|
|
25
|
+
*/
|
|
26
|
+
batchPRBody: "\n### ${name}@${newVersion}\n\n#### ${changeTypeSection}\n\n${changelog}\n",
|
|
20
27
|
branchName: "release/${repoName}-${releaseId}",
|
|
21
28
|
releaseTagName: "release-tag-${count}-patch-${releaseId}",
|
|
22
29
|
commitMessage: "chore(release): ${spaces}",
|
|
23
30
|
label: {
|
|
24
31
|
name: "CI-Release",
|
|
25
32
|
color: "1A7F37",
|
|
26
|
-
description: "
|
|
33
|
+
description: "Automated release PR (merge to publish)"
|
|
27
34
|
}
|
|
28
35
|
},
|
|
29
36
|
changesetVersion: {
|
|
@@ -1618,17 +1625,27 @@ var ChangesetVersion = class extends ScriptPlugin2 {
|
|
|
1618
1625
|
});
|
|
1619
1626
|
this.context.setWorkspaces(newWorkspaces);
|
|
1620
1627
|
}
|
|
1628
|
+
printWorksapces() {
|
|
1629
|
+
const workspaces = this.context.workspaces;
|
|
1630
|
+
this.logger.info(
|
|
1631
|
+
`ChangesetVersion Workspaces (${workspaces?.length}):
|
|
1632
|
+
${workspaces?.map((workspace) => workspace.toString()).join("\n")}`
|
|
1633
|
+
);
|
|
1634
|
+
}
|
|
1621
1635
|
async onSuccess() {
|
|
1622
1636
|
if (this.mode === "publish") {
|
|
1623
1637
|
await this.runChangesetPublish();
|
|
1638
|
+
this.printWorksapces();
|
|
1624
1639
|
return;
|
|
1625
1640
|
}
|
|
1626
1641
|
if (this.mode === "both") {
|
|
1627
1642
|
await this.runVersionFlow();
|
|
1628
1643
|
await this.runChangesetPublish();
|
|
1644
|
+
this.printWorksapces();
|
|
1629
1645
|
return;
|
|
1630
1646
|
}
|
|
1631
1647
|
await this.runVersionFlow();
|
|
1648
|
+
this.printWorksapces();
|
|
1632
1649
|
}
|
|
1633
1650
|
logDryRun(message) {
|
|
1634
1651
|
this.logger.info(`[dry-run] ${message}`);
|
|
@@ -1667,18 +1684,59 @@ var ChangesetVersion = class extends ScriptPlugin2 {
|
|
|
1667
1684
|
this.syncWorkspaces(this.context.workspaces ?? workspaces);
|
|
1668
1685
|
}
|
|
1669
1686
|
async runChangesetPublish() {
|
|
1687
|
+
const workspaces = this.context.workspaces ?? [];
|
|
1670
1688
|
if (this.context.dryRun) {
|
|
1671
1689
|
this.logDryRun("Would run: changeset publish, publish packages and tags");
|
|
1690
|
+
const preview = this.mergeWorkspaces(workspaces);
|
|
1691
|
+
this.context.setWorkspaces(preview);
|
|
1692
|
+
const previewTags = preview.filter(
|
|
1693
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && workspace.tagName
|
|
1694
|
+
).map((workspace) => workspace.tagName);
|
|
1695
|
+
this.logDryRun(
|
|
1696
|
+
previewTags.length === 0 ? "Would push release tag(s) from workspace.tagName: none" : `Would push release tag(s) from workspace.tagName:
|
|
1697
|
+
${previewTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1698
|
+
);
|
|
1672
1699
|
return;
|
|
1673
1700
|
}
|
|
1674
1701
|
await this.step({
|
|
1675
1702
|
label: "Changeset Publish",
|
|
1676
1703
|
task: () => this.context.runChangesetsCli("publish")
|
|
1677
1704
|
});
|
|
1678
|
-
|
|
1679
|
-
if (workspaces && workspaces.length > 0) {
|
|
1705
|
+
if (workspaces.length > 0) {
|
|
1680
1706
|
this.syncWorkspaces(workspaces);
|
|
1681
1707
|
}
|
|
1708
|
+
await this.step({
|
|
1709
|
+
label: "Push Release Tags",
|
|
1710
|
+
task: () => this.pushWorkspaceReleaseTags(this.context.workspaces ?? workspaces)
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Push release tags from synced workspaces' `tagName` fields.
|
|
1715
|
+
*
|
|
1716
|
+
* `changeset publish` only creates tags locally. After {@link syncWorkspaces},
|
|
1717
|
+
* each publishable workspace should already have `tagName` (e.g. `pkg@1.2.3`).
|
|
1718
|
+
*/
|
|
1719
|
+
async pushWorkspaceReleaseTags(workspaces) {
|
|
1720
|
+
const tags = workspaces.filter(
|
|
1721
|
+
(workspace) => this.shouldProcessWorkspace(workspace) && !workspace.dependencyRelease && !!workspace.tagName
|
|
1722
|
+
).map((workspace) => workspace.tagName);
|
|
1723
|
+
const uniqueTags = [...new Set(tags)];
|
|
1724
|
+
if (uniqueTags.length === 0) {
|
|
1725
|
+
this.logger.warn(
|
|
1726
|
+
"No workspace.tagName found after publish sync; skip tag push"
|
|
1727
|
+
);
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
this.logger.info(
|
|
1731
|
+
`Pushing ${uniqueTags.length} release tag(s) to origin:
|
|
1732
|
+
${uniqueTags.map((tag) => ` ${tag}`).join("\n")}`
|
|
1733
|
+
);
|
|
1734
|
+
await this.shell.exec([
|
|
1735
|
+
"git",
|
|
1736
|
+
"push",
|
|
1737
|
+
"origin",
|
|
1738
|
+
...uniqueTags.map((tag) => `"refs/tags/${tag}"`)
|
|
1739
|
+
]);
|
|
1682
1740
|
}
|
|
1683
1741
|
syncWorkspaces(workspaces) {
|
|
1684
1742
|
let newWorkspaces = this.mergeWorkspaces(workspaces);
|
|
@@ -1769,10 +1827,11 @@ ${lines.join("\n")}`
|
|
|
1769
1827
|
dependencyReleaseOf: workspace.dependencyReleaseOf,
|
|
1770
1828
|
lastTag: workspace.lastTag
|
|
1771
1829
|
});
|
|
1772
|
-
|
|
1830
|
+
const releaseVersion = newWorkspace.newVersion || newWorkspace.version;
|
|
1831
|
+
if (releaseVersion) {
|
|
1773
1832
|
newWorkspace.tagName = this.generateTagName({
|
|
1774
1833
|
...newWorkspace,
|
|
1775
|
-
version:
|
|
1834
|
+
version: releaseVersion
|
|
1776
1835
|
});
|
|
1777
1836
|
}
|
|
1778
1837
|
return newWorkspace;
|
|
@@ -1891,7 +1950,9 @@ ${lines.join("\n")}`
|
|
|
1891
1950
|
getIncrementLabels() {
|
|
1892
1951
|
const fromConfig = this.context.parameters.workspaces?.changeLabels;
|
|
1893
1952
|
if (Array.isArray(fromConfig) && fromConfig.length > 0) {
|
|
1894
|
-
return fromConfig.filter(
|
|
1953
|
+
return fromConfig.filter(
|
|
1954
|
+
(label) => typeof label === "string"
|
|
1955
|
+
);
|
|
1895
1956
|
}
|
|
1896
1957
|
return this.readGithubEventLabelNames();
|
|
1897
1958
|
}
|
|
@@ -1906,7 +1967,9 @@ ${lines.join("\n")}`
|
|
|
1906
1967
|
if (!Array.isArray(labels)) {
|
|
1907
1968
|
return [];
|
|
1908
1969
|
}
|
|
1909
|
-
return labels.map((label) => label?.name).filter(
|
|
1970
|
+
return labels.map((label) => label?.name).filter(
|
|
1971
|
+
(name) => typeof name === "string" && name.length > 0
|
|
1972
|
+
);
|
|
1910
1973
|
} catch (error) {
|
|
1911
1974
|
this.logger.debug("Failed to read labels from GITHUB_EVENT_PATH", error);
|
|
1912
1975
|
return [];
|
|
@@ -3275,23 +3338,33 @@ var ReleaseFormatter = class {
|
|
|
3275
3338
|
if (workspaces.length === 0) {
|
|
3276
3339
|
return "";
|
|
3277
3340
|
}
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
}
|
|
3341
|
+
const changeTypeSection = this.getChangeTypeSection();
|
|
3342
|
+
const batchTpl = this.config.batchPRBody || releaseJson.github.batchPRBody;
|
|
3281
3343
|
return workspaces.map(
|
|
3282
|
-
(workspace) => this.templateEngine.render(
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
}
|
|
3290
|
-
)
|
|
3344
|
+
(workspace) => this.templateEngine.render(batchTpl, {
|
|
3345
|
+
...workspace,
|
|
3346
|
+
// Prefer bumped version in PR changelog section headers
|
|
3347
|
+
version: workspace.newVersion || workspace.version,
|
|
3348
|
+
newVersion: workspace.newVersion || workspace.version,
|
|
3349
|
+
changeTypeSection
|
|
3350
|
+
})
|
|
3291
3351
|
).join("\n");
|
|
3292
3352
|
}
|
|
3353
|
+
/**
|
|
3354
|
+
* Map semver increment to Changesets-style section title.
|
|
3355
|
+
*/
|
|
3356
|
+
getChangeTypeSection() {
|
|
3357
|
+
const increment = (this.config.increment || "patch").toLowerCase();
|
|
3358
|
+
if (increment === "major") {
|
|
3359
|
+
return "Major Changes";
|
|
3360
|
+
}
|
|
3361
|
+
if (increment === "minor") {
|
|
3362
|
+
return "Minor Changes";
|
|
3363
|
+
}
|
|
3364
|
+
return "Patch Changes";
|
|
3365
|
+
}
|
|
3293
3366
|
formatPRTagName(workspaces, releaseBranchResult) {
|
|
3294
|
-
if (workspaces.length
|
|
3367
|
+
if (workspaces.length === 0) {
|
|
3295
3368
|
return releaseBranchResult.releaseTagName;
|
|
3296
3369
|
}
|
|
3297
3370
|
return workspaces.map(
|
|
@@ -3299,7 +3372,8 @@ var ReleaseFormatter = class {
|
|
|
3299
3372
|
).join(" ");
|
|
3300
3373
|
}
|
|
3301
3374
|
getPRTitle(releaseBranchResult, context, workspaces = []) {
|
|
3302
|
-
const
|
|
3375
|
+
const count = workspaces.length;
|
|
3376
|
+
const prTitleTpl = count > 2 ? this.config.PRTitleMany || this.config.PRTitle || releaseJson.github.PRTitleMany : this.config.PRTitle || releaseJson.github.PRTitle;
|
|
3303
3377
|
return this.templateEngine.render(
|
|
3304
3378
|
prTitleTpl,
|
|
3305
3379
|
this.buildPRTemplateVars(workspaces, releaseBranchResult, context)
|
|
@@ -3337,7 +3411,8 @@ var Github = class extends GitBase {
|
|
|
3337
3411
|
repoName: this.context.options.repoName,
|
|
3338
3412
|
authorName: this.context.options.authorName,
|
|
3339
3413
|
env: this.context.options.releaseEnv,
|
|
3340
|
-
releaseId: this.context.releaseId
|
|
3414
|
+
releaseId: this.context.releaseId,
|
|
3415
|
+
increment: this.context.parameters.changesetVersion?.increment || releaseJson.changesetVersion.increment
|
|
3341
3416
|
});
|
|
3342
3417
|
this.logger.info(`Github mode: ${this.mode}`);
|
|
3343
3418
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlover/fe-release",
|
|
3
3
|
"description": "A tool for releasing front-end projects, supporting multiple release modes and configurations, simplifying the release process and improving efficiency.",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"homepage": "https://github.com/qlover/fe-base/tree/master/packages/fe-release",
|