@ucdjs/release-scripts 0.1.0-beta.32 โ 0.1.0-beta.33
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/index.mjs +78 -72
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1009,32 +1009,32 @@ var VersionCalculatorService = class extends Effect.Service()("@ucdjs/release-sc
|
|
|
1009
1009
|
|
|
1010
1010
|
//#endregion
|
|
1011
1011
|
//#region src/services/version-prompt.service.ts
|
|
1012
|
+
const GREY = "\x1B[90m";
|
|
1013
|
+
const RESET = "\x1B[0m";
|
|
1014
|
+
const NON_VERSIONING_TYPES = new Set([
|
|
1015
|
+
"chore",
|
|
1016
|
+
"docs",
|
|
1017
|
+
"style",
|
|
1018
|
+
"test",
|
|
1019
|
+
"ci",
|
|
1020
|
+
"build",
|
|
1021
|
+
"refactor"
|
|
1022
|
+
]);
|
|
1023
|
+
function isVersioningCommit(commit) {
|
|
1024
|
+
return !NON_VERSIONING_TYPES.has(commit.type) || commit.isBreaking;
|
|
1025
|
+
}
|
|
1012
1026
|
function formatCommit(commit) {
|
|
1013
|
-
const
|
|
1027
|
+
const isGreyed = !isVersioningCommit(commit);
|
|
1014
1028
|
const scope = commit.scope ? `(${commit.scope})` : "";
|
|
1015
|
-
const
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1018
|
-
return refs ? `${header} (${refs})` : header;
|
|
1019
|
-
}
|
|
1020
|
-
function getTypeEmoji(type) {
|
|
1021
|
-
return {
|
|
1022
|
-
feat: "โจ",
|
|
1023
|
-
fix: "๐",
|
|
1024
|
-
docs: "๐",
|
|
1025
|
-
style: "๐",
|
|
1026
|
-
refactor: "๐ง",
|
|
1027
|
-
perf: "๐๏ธ",
|
|
1028
|
-
test: "๐งช",
|
|
1029
|
-
build: "๐ฆ",
|
|
1030
|
-
ci: "๐ท",
|
|
1031
|
-
chore: "๐ง",
|
|
1032
|
-
revert: "โช"
|
|
1033
|
-
}[type] || "๐";
|
|
1029
|
+
const description = commit.isConventional ? commit.description : commit.message.split("\n")[0] ?? commit.message;
|
|
1030
|
+
const line = `${commit.shortHash} ${commit.type.padEnd(12)}${scope.padEnd(10)}: ${description}`;
|
|
1031
|
+
return isGreyed ? `${GREY}${line}${RESET}` : line;
|
|
1034
1032
|
}
|
|
1035
1033
|
function formatCommits(commits) {
|
|
1036
1034
|
if (commits.length === 0) return " No commits since the last version";
|
|
1037
|
-
|
|
1035
|
+
const lines = commits.slice(0, 10).map((c) => ` ${formatCommit(c)}`);
|
|
1036
|
+
if (commits.length > 10) lines.push(` ${GREY}... and ${commits.length - 10} more${RESET}`);
|
|
1037
|
+
return lines.join("\n");
|
|
1038
1038
|
}
|
|
1039
1039
|
function getPrereleaseInfo(version) {
|
|
1040
1040
|
const parsed = semver.parse(version);
|
|
@@ -1081,8 +1081,8 @@ function generateVersionOptions(currentVersion, conventionalBump, prereleaseInfo
|
|
|
1081
1081
|
}
|
|
1082
1082
|
});
|
|
1083
1083
|
}
|
|
1084
|
-
const conventionalVersion = conventionalBump !== "none" ? semver.inc(currentVersion, conventionalBump) :
|
|
1085
|
-
if (conventionalVersion
|
|
1084
|
+
const conventionalVersion = conventionalBump !== "none" ? semver.inc(currentVersion, conventionalBump) : null;
|
|
1085
|
+
if (conventionalVersion) options.push({
|
|
1086
1086
|
title: `conventional ${conventionalVersion}`,
|
|
1087
1087
|
value: {
|
|
1088
1088
|
version: conventionalVersion,
|
|
@@ -1156,6 +1156,11 @@ function generateVersionOptions(currentVersion, conventionalBump, prereleaseInfo
|
|
|
1156
1156
|
});
|
|
1157
1157
|
return options;
|
|
1158
1158
|
}
|
|
1159
|
+
function findDefaultIndex(options, conventionalBump) {
|
|
1160
|
+
if (conventionalBump === "none") return 0;
|
|
1161
|
+
const conventionalIndex = options.findIndex((o) => o.title.startsWith("conventional"));
|
|
1162
|
+
return conventionalIndex >= 0 ? conventionalIndex : 0;
|
|
1163
|
+
}
|
|
1159
1164
|
async function promptForCustomVersion(currentVersion) {
|
|
1160
1165
|
return (await prompts({
|
|
1161
1166
|
type: "text",
|
|
@@ -1175,11 +1180,9 @@ var VersionPromptService = class extends Effect.Service()("@ucdjs/release-script
|
|
|
1175
1180
|
return Effect.async((resume) => {
|
|
1176
1181
|
const allCommits = [...pkg.commits, ...pkg.globalCommits];
|
|
1177
1182
|
const prereleaseInfo = getPrereleaseInfo(pkg.version);
|
|
1183
|
+
const commitCount = allCommits.length;
|
|
1178
1184
|
console.log("");
|
|
1179
|
-
console.log(
|
|
1180
|
-
console.log(`Current version: ${pkg.version}`);
|
|
1181
|
-
console.log("");
|
|
1182
|
-
console.log("Commits:");
|
|
1185
|
+
console.log(`${commitCount} commit${commitCount === 1 ? "" : "s"} since the last version:`);
|
|
1183
1186
|
console.log(formatCommits(allCommits));
|
|
1184
1187
|
console.log("");
|
|
1185
1188
|
if (applyToAllRemainingChoice) {
|
|
@@ -1192,6 +1195,7 @@ var VersionPromptService = class extends Effect.Service()("@ucdjs/release-script
|
|
|
1192
1195
|
return;
|
|
1193
1196
|
}
|
|
1194
1197
|
const options = generateVersionOptions(pkg.version, conventionalBump, prereleaseInfo);
|
|
1198
|
+
const defaultIndex = findDefaultIndex(options, conventionalBump);
|
|
1195
1199
|
if (remainingCount > 1) options.push({
|
|
1196
1200
|
title: "apply-to-all โบ",
|
|
1197
1201
|
value: {
|
|
@@ -1202,11 +1206,12 @@ var VersionPromptService = class extends Effect.Service()("@ucdjs/release-script
|
|
|
1202
1206
|
prompts({
|
|
1203
1207
|
type: "select",
|
|
1204
1208
|
name: "choice",
|
|
1205
|
-
message: `
|
|
1209
|
+
message: `Current version ${pkg.version}`,
|
|
1206
1210
|
choices: options.map((o) => ({
|
|
1207
1211
|
title: o.title,
|
|
1208
1212
|
value: o.value
|
|
1209
1213
|
})),
|
|
1214
|
+
initial: defaultIndex,
|
|
1210
1215
|
hint: "Use arrow keys to navigate, enter to select"
|
|
1211
1216
|
}).then(async (response) => {
|
|
1212
1217
|
if (!response.choice) {
|
|
@@ -1227,7 +1232,8 @@ var VersionPromptService = class extends Effect.Service()("@ucdjs/release-script
|
|
|
1227
1232
|
choices: applyOptions.map((o) => ({
|
|
1228
1233
|
title: o.title,
|
|
1229
1234
|
value: o.value
|
|
1230
|
-
}))
|
|
1235
|
+
})),
|
|
1236
|
+
initial: findDefaultIndex(applyOptions, conventionalBump)
|
|
1231
1237
|
});
|
|
1232
1238
|
if (applyResponse.choice) {
|
|
1233
1239
|
if (applyResponse.choice.version === "custom") {
|
|
@@ -1477,32 +1483,32 @@ function constructPrepareProgram(config) {
|
|
|
1477
1483
|
const isNewRelease = !releasePullRequest;
|
|
1478
1484
|
const branchExists = yield* git.branches.exists(config.branch.release);
|
|
1479
1485
|
if (!branchExists) {
|
|
1480
|
-
yield* Console.log(
|
|
1486
|
+
yield* Console.log(`Creating release branch "${config.branch.release}" from "${config.branch.default}"...`);
|
|
1481
1487
|
yield* git.branches.create(config.branch.release, config.branch.default);
|
|
1482
|
-
yield* Console.log(
|
|
1488
|
+
yield* Console.log(`Release branch created.`);
|
|
1483
1489
|
}
|
|
1484
1490
|
if ((yield* git.branches.get) !== config.branch.release) {
|
|
1485
1491
|
yield* git.branches.checkout(config.branch.release);
|
|
1486
|
-
yield* Console.log(
|
|
1492
|
+
yield* Console.log(`Checked out to release branch "${config.branch.release}".`);
|
|
1487
1493
|
}
|
|
1488
1494
|
if (!isNewRelease || branchExists) {
|
|
1489
|
-
yield* Console.log(
|
|
1495
|
+
yield* Console.log(`Rebasing "${config.branch.release}" onto "${config.branch.default}"...`);
|
|
1490
1496
|
yield* git.branches.rebase(config.branch.default);
|
|
1491
|
-
yield* Console.log(
|
|
1497
|
+
yield* Console.log(`Rebase complete.`);
|
|
1492
1498
|
}
|
|
1493
1499
|
const overrides = yield* loadOverrides({
|
|
1494
1500
|
sha: config.branch.default,
|
|
1495
1501
|
overridesPath: ".github/ucdjs-release.overrides.json"
|
|
1496
1502
|
});
|
|
1497
|
-
if (Object.keys(overrides).length > 0) yield* Console.log("
|
|
1503
|
+
if (Object.keys(overrides).length > 0) yield* Console.log("Loaded version overrides:", overrides);
|
|
1498
1504
|
const originalBranch = yield* git.branches.get;
|
|
1499
1505
|
yield* git.branches.checkout(config.branch.default);
|
|
1500
1506
|
const packages = yield* workspace.discoverWorkspacePackages.pipe(Effect.flatMap(mergePackageCommitsIntoPackages), Effect.flatMap((pkgs) => mergeCommitsAffectingGloballyIntoPackage(pkgs, config.globalCommitMode)));
|
|
1501
|
-
yield* Console.log(
|
|
1507
|
+
yield* Console.log(`Discovered ${packages.length} packages with commits.`);
|
|
1502
1508
|
yield* dependencyGraph.topologicalOrder(packages);
|
|
1503
1509
|
const releases = [];
|
|
1504
1510
|
if (versionPrompt.isEnabled) {
|
|
1505
|
-
yield* Console.log("\
|
|
1511
|
+
yield* Console.log("\nInteractive version selection enabled.\n");
|
|
1506
1512
|
versionPrompt.resetApplyToAll();
|
|
1507
1513
|
for (let i = 0; i < packages.length; i++) {
|
|
1508
1514
|
const pkg = packages[i];
|
|
@@ -1548,12 +1554,12 @@ function constructPrepareProgram(config) {
|
|
|
1548
1554
|
releases.push(...calculatedReleases);
|
|
1549
1555
|
}
|
|
1550
1556
|
const releasesCount = releases.length;
|
|
1551
|
-
yield* Console.log(`\n
|
|
1557
|
+
yield* Console.log(`\n${releasesCount} package${releasesCount === 1 ? "" : "s"} will be released.`);
|
|
1552
1558
|
yield* git.branches.checkout(originalBranch);
|
|
1553
|
-
yield* Console.log("
|
|
1559
|
+
yield* Console.log("Updating package.json files...");
|
|
1554
1560
|
yield* packageUpdater.applyReleases(packages, releases);
|
|
1555
|
-
yield* Console.log("
|
|
1556
|
-
yield* Console.log("
|
|
1561
|
+
yield* Console.log("package.json files updated.");
|
|
1562
|
+
yield* Console.log("Generating changelogs...");
|
|
1557
1563
|
const changelogFiles = [];
|
|
1558
1564
|
for (const release of releases) {
|
|
1559
1565
|
const pkg = packages.find((p) => p.name === release.package.name);
|
|
@@ -1567,28 +1573,28 @@ function constructPrepareProgram(config) {
|
|
|
1567
1573
|
});
|
|
1568
1574
|
changelogFiles.push(result.filePath);
|
|
1569
1575
|
}
|
|
1570
|
-
yield* Console.log(
|
|
1576
|
+
yield* Console.log(`Generated ${changelogFiles.length} changelog file${changelogFiles.length === 1 ? "" : "s"}.`);
|
|
1571
1577
|
const filesToStage = [...releases.map((r) => `${r.package.path}/package.json`), ...changelogFiles];
|
|
1572
|
-
yield* Console.log(
|
|
1578
|
+
yield* Console.log(`Staging ${filesToStage.length} file${filesToStage.length === 1 ? "" : "s"}...`);
|
|
1573
1579
|
yield* git.commits.stage(filesToStage);
|
|
1574
1580
|
const commitMessage = `chore(release): prepare release
|
|
1575
1581
|
|
|
1576
1582
|
${releasesCount} package${releasesCount === 1 ? "" : "s"} updated:
|
|
1577
1583
|
${releases.map((r) => ` - ${r.package.name}@${r.newVersion}`).join("\n")}`;
|
|
1578
|
-
yield* Console.log("
|
|
1584
|
+
yield* Console.log("Creating commit...");
|
|
1579
1585
|
yield* git.commits.write(commitMessage);
|
|
1580
|
-
yield* Console.log("
|
|
1581
|
-
yield* Console.log(
|
|
1586
|
+
yield* Console.log("Commit created.");
|
|
1587
|
+
yield* Console.log(`Pushing to "${config.branch.release}"...`);
|
|
1582
1588
|
if (isNewRelease && !branchExists) yield* git.commits.push(config.branch.release);
|
|
1583
1589
|
else yield* git.commits.forcePush(config.branch.release);
|
|
1584
|
-
yield* Console.log(
|
|
1590
|
+
yield* Console.log(`Push complete.`);
|
|
1585
1591
|
const prBody = yield* github.generateReleasePRBody(releases.map((r) => ({
|
|
1586
1592
|
packageName: r.package.name,
|
|
1587
1593
|
version: r.newVersion,
|
|
1588
1594
|
previousVersion: r.package.version
|
|
1589
1595
|
})));
|
|
1590
1596
|
if (isNewRelease) {
|
|
1591
|
-
yield* Console.log("
|
|
1597
|
+
yield* Console.log("Creating release pull request...");
|
|
1592
1598
|
releasePullRequest = yield* github.createPullRequest({
|
|
1593
1599
|
title: config.pullRequest.title,
|
|
1594
1600
|
body: prBody,
|
|
@@ -1596,15 +1602,15 @@ ${releases.map((r) => ` - ${r.package.name}@${r.newVersion}`).join("\n")}`;
|
|
|
1596
1602
|
base: config.branch.default,
|
|
1597
1603
|
draft: true
|
|
1598
1604
|
});
|
|
1599
|
-
yield* Console.log(
|
|
1605
|
+
yield* Console.log(`Release pull request #${releasePullRequest.number} created.`);
|
|
1600
1606
|
} else {
|
|
1601
|
-
yield* Console.log("
|
|
1607
|
+
yield* Console.log("Updating pull request...");
|
|
1602
1608
|
yield* github.updatePullRequest(releasePullRequest.number, { body: prBody });
|
|
1603
|
-
yield* Console.log("
|
|
1609
|
+
yield* Console.log("Pull request updated.");
|
|
1604
1610
|
}
|
|
1605
|
-
yield* Console.log(`\
|
|
1611
|
+
yield* Console.log(`\nRelease preparation complete! View PR: #${releasePullRequest.number}`);
|
|
1606
1612
|
yield* git.branches.checkout(config.branch.default);
|
|
1607
|
-
yield* Console.log(
|
|
1613
|
+
yield* Console.log(`Switched back to "${config.branch.default}".`);
|
|
1608
1614
|
});
|
|
1609
1615
|
}
|
|
1610
1616
|
|
|
@@ -1633,9 +1639,9 @@ function constructPublishProgram(config) {
|
|
|
1633
1639
|
yield* git.workspace.assertWorkspaceReady;
|
|
1634
1640
|
const currentBranch = yield* git.branches.get;
|
|
1635
1641
|
if (currentBranch !== config.branch.default) return yield* Effect.fail(/* @__PURE__ */ new Error(`Publish must be run on the default branch "${config.branch.default}". Current branch: "${currentBranch}"`));
|
|
1636
|
-
yield* Console.log(
|
|
1642
|
+
yield* Console.log(`On default branch "${config.branch.default}".`);
|
|
1637
1643
|
const publicPackages = (yield* workspace.discoverWorkspacePackages).filter((pkg) => !pkg.packageJson.private);
|
|
1638
|
-
yield* Console.log(
|
|
1644
|
+
yield* Console.log(`Found ${publicPackages.length} public package${publicPackages.length === 1 ? "" : "s"} to check.`);
|
|
1639
1645
|
const orderedPackages = yield* dependencyGraph.topologicalOrder(publicPackages);
|
|
1640
1646
|
const results = [];
|
|
1641
1647
|
for (const updateOrder of orderedPackages) {
|
|
@@ -1643,7 +1649,7 @@ function constructPublishProgram(config) {
|
|
|
1643
1649
|
const version = pkg.version;
|
|
1644
1650
|
const tagName = `${pkg.name}@${version}`;
|
|
1645
1651
|
if (yield* npm.versionExists(pkg.name, version)) {
|
|
1646
|
-
yield* Console.log(
|
|
1652
|
+
yield* Console.log(`Skipping ${pkg.name}@${version} - already published.`);
|
|
1647
1653
|
results.push({
|
|
1648
1654
|
packageName: pkg.name,
|
|
1649
1655
|
version,
|
|
@@ -1652,11 +1658,11 @@ function constructPublishProgram(config) {
|
|
|
1652
1658
|
});
|
|
1653
1659
|
continue;
|
|
1654
1660
|
}
|
|
1655
|
-
yield* Console.log(
|
|
1661
|
+
yield* Console.log(`Building ${pkg.name}...`);
|
|
1656
1662
|
yield* buildPackage(pkg.path);
|
|
1657
|
-
yield* Console.log(
|
|
1663
|
+
yield* Console.log(`Build complete for ${pkg.name}.`);
|
|
1658
1664
|
const distTag = getDistTag(version);
|
|
1659
|
-
yield* Console.log(
|
|
1665
|
+
yield* Console.log(`Publishing ${pkg.name}@${version} with tag "${distTag}"...`);
|
|
1660
1666
|
const publishResult = yield* npm.publish({
|
|
1661
1667
|
packagePath: pkg.path,
|
|
1662
1668
|
tagName: distTag,
|
|
@@ -1668,13 +1674,13 @@ function constructPublishProgram(config) {
|
|
|
1668
1674
|
error: err
|
|
1669
1675
|
})));
|
|
1670
1676
|
if (publishResult.success) {
|
|
1671
|
-
yield* Console.log(
|
|
1677
|
+
yield* Console.log(`Published ${pkg.name}@${version}.`);
|
|
1672
1678
|
if (!config.dryRun) {
|
|
1673
|
-
yield* Console.log(
|
|
1679
|
+
yield* Console.log(`Creating tag ${tagName}...`);
|
|
1674
1680
|
yield* git.tags.create(tagName, `Release ${tagName}`);
|
|
1675
1681
|
yield* git.tags.push(tagName);
|
|
1676
|
-
yield* Console.log(
|
|
1677
|
-
} else yield* Console.log(
|
|
1682
|
+
yield* Console.log(`Tag ${tagName} created and pushed.`);
|
|
1683
|
+
} else yield* Console.log(`[Dry Run] Would create and push tag ${tagName}.`);
|
|
1678
1684
|
results.push({
|
|
1679
1685
|
packageName: pkg.name,
|
|
1680
1686
|
version,
|
|
@@ -1682,7 +1688,7 @@ function constructPublishProgram(config) {
|
|
|
1682
1688
|
});
|
|
1683
1689
|
} else {
|
|
1684
1690
|
const error = publishResult.error;
|
|
1685
|
-
yield* Console.log(
|
|
1691
|
+
yield* Console.log(`Failed to publish ${pkg.name}@${version}: ${error.message}`);
|
|
1686
1692
|
results.push({
|
|
1687
1693
|
packageName: pkg.name,
|
|
1688
1694
|
version,
|
|
@@ -1694,17 +1700,17 @@ function constructPublishProgram(config) {
|
|
|
1694
1700
|
const published = results.filter((r) => r.status === "published");
|
|
1695
1701
|
const skipped = results.filter((r) => r.status === "skipped");
|
|
1696
1702
|
const failed = results.filter((r) => r.status === "failed");
|
|
1697
|
-
yield* Console.log("\
|
|
1703
|
+
yield* Console.log("\nPublish Summary:");
|
|
1698
1704
|
yield* Console.log(` Published: ${published.length}`);
|
|
1699
1705
|
yield* Console.log(` Skipped: ${skipped.length}`);
|
|
1700
1706
|
yield* Console.log(` Failed: ${failed.length}`);
|
|
1701
1707
|
if (failed.length > 0) {
|
|
1702
|
-
yield* Console.log("\
|
|
1708
|
+
yield* Console.log("\nFailed packages:");
|
|
1703
1709
|
for (const f of failed) yield* Console.log(` - ${f.packageName}@${f.version}: ${f.reason}`);
|
|
1704
1710
|
return yield* Effect.fail(/* @__PURE__ */ new Error("Some packages failed to publish."));
|
|
1705
1711
|
}
|
|
1706
|
-
if (published.length === 0 && skipped.length > 0) yield* Console.log("\
|
|
1707
|
-
else if (published.length > 0) yield* Console.log("\
|
|
1712
|
+
if (published.length === 0 && skipped.length > 0) yield* Console.log("\nAll packages were already published.");
|
|
1713
|
+
else if (published.length > 0) yield* Console.log("\nPublish complete!");
|
|
1708
1714
|
});
|
|
1709
1715
|
}
|
|
1710
1716
|
|
|
@@ -1790,10 +1796,10 @@ function constructVerifyProgram(config) {
|
|
|
1790
1796
|
yield* git.workspace.assertWorkspaceReady;
|
|
1791
1797
|
const releasePullRequest = yield* github.getPullRequestByBranch(config.branch.release);
|
|
1792
1798
|
if (!releasePullRequest || !releasePullRequest.head) return yield* Effect.fail(/* @__PURE__ */ new Error(`Release pull request for branch "${config.branch.release}" does not exist.`));
|
|
1793
|
-
yield* Console.log(
|
|
1799
|
+
yield* Console.log(`Release pull request #${releasePullRequest.number} exists.`);
|
|
1794
1800
|
if ((yield* git.branches.get) !== config.branch.default) {
|
|
1795
1801
|
yield* git.branches.checkout(config.branch.default);
|
|
1796
|
-
yield* Console.log(
|
|
1802
|
+
yield* Console.log(`Checked out to default branch "${config.branch.default}".`);
|
|
1797
1803
|
}
|
|
1798
1804
|
const overrides = yield* loadOverrides({
|
|
1799
1805
|
sha: releasePullRequest.head.sha,
|
|
@@ -1813,8 +1819,8 @@ function constructVerifyProgram(config) {
|
|
|
1813
1819
|
branchSnapshots.set(pkg.name, snapshot);
|
|
1814
1820
|
}
|
|
1815
1821
|
const drift = findDrift(packages, releases, branchSnapshots);
|
|
1816
|
-
if (drift.length === 0) yield* Console.log("
|
|
1817
|
-
else yield* Console.log("
|
|
1822
|
+
if (drift.length === 0) yield* Console.log("Release branch is in sync with expected releases.");
|
|
1823
|
+
else yield* Console.log("Release branch is out of sync:", drift);
|
|
1818
1824
|
const status = drift.length === 0 ? {
|
|
1819
1825
|
state: "success",
|
|
1820
1826
|
description: "Release artifacts in sync",
|