@ucdjs/release-scripts 0.1.0-beta.43 → 0.1.0-beta.45
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 +112 -73
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -58,53 +58,8 @@ function buildTemplateGroups(options) {
|
|
|
58
58
|
//#region src/shared/utils.ts
|
|
59
59
|
const args = mri(process.argv.slice(2));
|
|
60
60
|
const isDryRun = !!args.dry;
|
|
61
|
-
const isVerbose = !!args.verbose;
|
|
61
|
+
const isVerbose$1 = !!args.verbose;
|
|
62
62
|
const isForce = !!args.force;
|
|
63
|
-
function toTrimmedString(value) {
|
|
64
|
-
if (typeof value === "string") {
|
|
65
|
-
const normalized = value.trim();
|
|
66
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
67
|
-
}
|
|
68
|
-
if (value instanceof Uint8Array) {
|
|
69
|
-
const normalized = new TextDecoder().decode(value).trim();
|
|
70
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
71
|
-
}
|
|
72
|
-
if (isRecord(value) && typeof value.toString === "function") {
|
|
73
|
-
const rendered = value.toString();
|
|
74
|
-
if (typeof rendered === "string" && rendered !== "[object Object]") {
|
|
75
|
-
const normalized = rendered.trim();
|
|
76
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function getNestedField(record, keys) {
|
|
81
|
-
let current = record;
|
|
82
|
-
for (const key of keys) {
|
|
83
|
-
if (!isRecord(current) || !(key in current)) return;
|
|
84
|
-
current = current[key];
|
|
85
|
-
}
|
|
86
|
-
return current;
|
|
87
|
-
}
|
|
88
|
-
function extractStderrLike(record) {
|
|
89
|
-
const candidates = [
|
|
90
|
-
record.stderr,
|
|
91
|
-
record.stdout,
|
|
92
|
-
record.shortMessage,
|
|
93
|
-
record.originalMessage,
|
|
94
|
-
getNestedField(record, ["result", "stderr"]),
|
|
95
|
-
getNestedField(record, ["result", "stdout"]),
|
|
96
|
-
getNestedField(record, ["output", "stderr"]),
|
|
97
|
-
getNestedField(record, ["output", "stdout"]),
|
|
98
|
-
getNestedField(record, ["cause", "stderr"]),
|
|
99
|
-
getNestedField(record, ["cause", "stdout"]),
|
|
100
|
-
getNestedField(record, ["cause", "shortMessage"]),
|
|
101
|
-
getNestedField(record, ["cause", "originalMessage"])
|
|
102
|
-
];
|
|
103
|
-
for (const candidate of candidates) {
|
|
104
|
-
const rendered = toTrimmedString(candidate);
|
|
105
|
-
if (rendered) return rendered;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
63
|
const ucdjsReleaseOverridesPath = ".github/ucdjs-release.overrides.json";
|
|
109
64
|
const isCI = typeof process.env.CI === "string" && process.env.CI !== "" && process.env.CI.toLowerCase() !== "false";
|
|
110
65
|
const logger = {
|
|
@@ -118,7 +73,7 @@ const logger = {
|
|
|
118
73
|
console.error(` ${farver.red("✖")}`, ...args);
|
|
119
74
|
},
|
|
120
75
|
verbose: (...args) => {
|
|
121
|
-
if (!isVerbose) return;
|
|
76
|
+
if (!isVerbose$1) return;
|
|
122
77
|
if (args.length === 0) {
|
|
123
78
|
console.log();
|
|
124
79
|
return;
|
|
@@ -168,9 +123,67 @@ async function dryRun(bin, args, opts) {
|
|
|
168
123
|
return logger.verbose(farver.blue(`[dryrun] ${bin} ${args.join(" ")}`), opts || "");
|
|
169
124
|
}
|
|
170
125
|
const runIfNotDry = isDryRun ? dryRun : run;
|
|
126
|
+
if (isDryRun || isVerbose$1 || isForce) {
|
|
127
|
+
logger.verbose(farver.inverse(farver.yellow(" Running with special flags ")));
|
|
128
|
+
logger.verbose({
|
|
129
|
+
isDryRun,
|
|
130
|
+
isVerbose: isVerbose$1,
|
|
131
|
+
isForce
|
|
132
|
+
});
|
|
133
|
+
logger.verbose();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/shared/errors.ts
|
|
138
|
+
const isVerbose = !!mri(process.argv.slice(2)).verbose;
|
|
171
139
|
function isRecord(value) {
|
|
172
140
|
return typeof value === "object" && value !== null;
|
|
173
141
|
}
|
|
142
|
+
function toTrimmedString(value) {
|
|
143
|
+
if (typeof value === "string") {
|
|
144
|
+
const normalized = value.trim();
|
|
145
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
146
|
+
}
|
|
147
|
+
if (value instanceof Uint8Array) {
|
|
148
|
+
const normalized = new TextDecoder().decode(value).trim();
|
|
149
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
150
|
+
}
|
|
151
|
+
if (isRecord(value) && typeof value.toString === "function") {
|
|
152
|
+
const rendered = value.toString();
|
|
153
|
+
if (typeof rendered === "string" && rendered !== "[object Object]") {
|
|
154
|
+
const normalized = rendered.trim();
|
|
155
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function getNestedField(record, keys) {
|
|
160
|
+
let current = record;
|
|
161
|
+
for (const key of keys) {
|
|
162
|
+
if (!isRecord(current) || !(key in current)) return;
|
|
163
|
+
current = current[key];
|
|
164
|
+
}
|
|
165
|
+
return current;
|
|
166
|
+
}
|
|
167
|
+
function extractStderrLike(record) {
|
|
168
|
+
const candidates = [
|
|
169
|
+
record.stderr,
|
|
170
|
+
record.stdout,
|
|
171
|
+
record.shortMessage,
|
|
172
|
+
record.originalMessage,
|
|
173
|
+
getNestedField(record, ["result", "stderr"]),
|
|
174
|
+
getNestedField(record, ["result", "stdout"]),
|
|
175
|
+
getNestedField(record, ["output", "stderr"]),
|
|
176
|
+
getNestedField(record, ["output", "stdout"]),
|
|
177
|
+
getNestedField(record, ["cause", "stderr"]),
|
|
178
|
+
getNestedField(record, ["cause", "stdout"]),
|
|
179
|
+
getNestedField(record, ["cause", "shortMessage"]),
|
|
180
|
+
getNestedField(record, ["cause", "originalMessage"])
|
|
181
|
+
];
|
|
182
|
+
for (const candidate of candidates) {
|
|
183
|
+
const rendered = toTrimmedString(candidate);
|
|
184
|
+
if (rendered) return rendered;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
174
187
|
function formatUnknownError(error) {
|
|
175
188
|
if (error instanceof Error) {
|
|
176
189
|
const base = {
|
|
@@ -196,7 +209,7 @@ function formatUnknownError(error) {
|
|
|
196
209
|
return { message: String(error) };
|
|
197
210
|
}
|
|
198
211
|
function exitWithError(message, hint, cause) {
|
|
199
|
-
|
|
212
|
+
console.error(` ${farver.red("✖")} ${farver.bold(message)}`);
|
|
200
213
|
if (cause !== void 0) {
|
|
201
214
|
const formatted = formatUnknownError(cause);
|
|
202
215
|
if (formatted.message && formatted.message !== message) console.error(farver.gray(` Cause: ${formatted.message}`));
|
|
@@ -214,15 +227,6 @@ function exitWithError(message, hint, cause) {
|
|
|
214
227
|
if (hint) console.error(farver.gray(` ${hint}`));
|
|
215
228
|
process.exit(1);
|
|
216
229
|
}
|
|
217
|
-
if (isDryRun || isVerbose || isForce) {
|
|
218
|
-
logger.verbose(farver.inverse(farver.yellow(" Running with special flags ")));
|
|
219
|
-
logger.verbose({
|
|
220
|
-
isDryRun,
|
|
221
|
-
isVerbose,
|
|
222
|
-
isForce
|
|
223
|
-
});
|
|
224
|
-
logger.verbose();
|
|
225
|
-
}
|
|
226
230
|
|
|
227
231
|
//#endregion
|
|
228
232
|
//#region src/core/github.ts
|
|
@@ -1531,12 +1535,16 @@ function getPackagePublishOrder(graph, packagesToPublish) {
|
|
|
1531
1535
|
* @param directUpdates - Packages with direct code changes
|
|
1532
1536
|
* @returns All updates including dependent packages that need patch bumps
|
|
1533
1537
|
*/
|
|
1534
|
-
function createDependentUpdates(graph, workspacePackages, directUpdates) {
|
|
1538
|
+
function createDependentUpdates(graph, workspacePackages, directUpdates, excludedPackages = /* @__PURE__ */ new Set()) {
|
|
1535
1539
|
const allUpdates = [...directUpdates];
|
|
1536
1540
|
const directUpdateMap = new Map(directUpdates.map((u) => [u.package.name, u]));
|
|
1537
1541
|
const affectedPackages = getAllAffectedPackages(graph, new Set(directUpdates.map((u) => u.package.name)));
|
|
1538
1542
|
for (const pkgName of affectedPackages) {
|
|
1539
1543
|
logger.verbose(`Processing affected package: ${pkgName}`);
|
|
1544
|
+
if (excludedPackages.has(pkgName)) {
|
|
1545
|
+
logger.verbose(`Skipping ${pkgName}, explicitly excluded from dependent bumps`);
|
|
1546
|
+
continue;
|
|
1547
|
+
}
|
|
1540
1548
|
if (directUpdateMap.has(pkgName)) {
|
|
1541
1549
|
logger.verbose(`Skipping ${pkgName}, already has a direct update`);
|
|
1542
1550
|
continue;
|
|
@@ -1600,6 +1608,7 @@ async function calculateVersionUpdates({ workspacePackages, packageCommits, work
|
|
|
1600
1608
|
const versionUpdates = [];
|
|
1601
1609
|
const processedPackages = /* @__PURE__ */ new Set();
|
|
1602
1610
|
const newOverrides = { ...initialOverrides };
|
|
1611
|
+
const excludedPackages = /* @__PURE__ */ new Set();
|
|
1603
1612
|
const bumpRanks = {
|
|
1604
1613
|
major: 3,
|
|
1605
1614
|
minor: 2,
|
|
@@ -1619,10 +1628,11 @@ async function calculateVersionUpdates({ workspacePackages, packageCommits, work
|
|
|
1619
1628
|
const determinedBump = determineHighestBump(allCommitsForPackage);
|
|
1620
1629
|
const override = newOverrides[pkgName];
|
|
1621
1630
|
const effectiveBump = override?.type || determinedBump;
|
|
1622
|
-
|
|
1631
|
+
const canPrompt = !isCI && showPrompt;
|
|
1632
|
+
if (effectiveBump === "none" && !canPrompt) continue;
|
|
1623
1633
|
let newVersion = override?.version || getNextVersion(pkg.version, effectiveBump);
|
|
1624
1634
|
let finalBumpType = effectiveBump;
|
|
1625
|
-
if (
|
|
1635
|
+
if (canPrompt) {
|
|
1626
1636
|
logger.clearScreen();
|
|
1627
1637
|
logger.section(`📝 Commits for ${farver.cyan(pkg.name)}`);
|
|
1628
1638
|
formatCommitsForDisplay(allCommitsForPackage).split("\n").forEach((line) => logger.item(line));
|
|
@@ -1631,6 +1641,27 @@ async function calculateVersionUpdates({ workspacePackages, packageCommits, work
|
|
|
1631
1641
|
if (selectedVersion === null) continue;
|
|
1632
1642
|
const userBump = calculateBumpType(pkg.version, selectedVersion);
|
|
1633
1643
|
finalBumpType = userBump;
|
|
1644
|
+
if (selectedVersion === pkg.version) {
|
|
1645
|
+
excludedPackages.add(pkgName);
|
|
1646
|
+
if (determinedBump !== "none") {
|
|
1647
|
+
newOverrides[pkgName] = {
|
|
1648
|
+
type: "none",
|
|
1649
|
+
version: pkg.version
|
|
1650
|
+
};
|
|
1651
|
+
logger.info(`Version override recorded for ${pkgName}: ${determinedBump} → none`);
|
|
1652
|
+
} else if (newOverrides[pkgName]) {
|
|
1653
|
+
delete newOverrides[pkgName];
|
|
1654
|
+
logger.info(`Version override removed for ${pkgName}.`);
|
|
1655
|
+
}
|
|
1656
|
+
versionUpdates.push({
|
|
1657
|
+
package: pkg,
|
|
1658
|
+
currentVersion: pkg.version,
|
|
1659
|
+
newVersion: pkg.version,
|
|
1660
|
+
bumpType: "none",
|
|
1661
|
+
hasDirectChanges: allCommitsForPackage.length > 0
|
|
1662
|
+
});
|
|
1663
|
+
continue;
|
|
1664
|
+
}
|
|
1634
1665
|
if (bumpRanks[userBump] < bumpRanks[determinedBump]) {
|
|
1635
1666
|
newOverrides[pkgName] = {
|
|
1636
1667
|
type: userBump,
|
|
@@ -1658,20 +1689,23 @@ async function calculateVersionUpdates({ workspacePackages, packageCommits, work
|
|
|
1658
1689
|
logger.item("No direct commits found");
|
|
1659
1690
|
const newVersion = await selectVersionPrompt(workspaceRoot, pkg, pkg.version, pkg.version);
|
|
1660
1691
|
if (newVersion === null) break;
|
|
1661
|
-
if (newVersion
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
package: pkg,
|
|
1665
|
-
currentVersion: pkg.version,
|
|
1666
|
-
newVersion,
|
|
1667
|
-
bumpType,
|
|
1668
|
-
hasDirectChanges: false
|
|
1669
|
-
});
|
|
1692
|
+
if (newVersion === pkg.version) {
|
|
1693
|
+
excludedPackages.add(pkg.name);
|
|
1694
|
+
continue;
|
|
1670
1695
|
}
|
|
1696
|
+
const bumpType = calculateBumpType(pkg.version, newVersion);
|
|
1697
|
+
versionUpdates.push({
|
|
1698
|
+
package: pkg,
|
|
1699
|
+
currentVersion: pkg.version,
|
|
1700
|
+
newVersion,
|
|
1701
|
+
bumpType,
|
|
1702
|
+
hasDirectChanges: false
|
|
1703
|
+
});
|
|
1671
1704
|
}
|
|
1672
1705
|
return {
|
|
1673
1706
|
updates: versionUpdates,
|
|
1674
|
-
overrides: newOverrides
|
|
1707
|
+
overrides: newOverrides,
|
|
1708
|
+
excludedPackages
|
|
1675
1709
|
};
|
|
1676
1710
|
}
|
|
1677
1711
|
/**
|
|
@@ -1679,7 +1713,7 @@ async function calculateVersionUpdates({ workspacePackages, packageCommits, work
|
|
|
1679
1713
|
* Returns both the updates and a function to apply them
|
|
1680
1714
|
*/
|
|
1681
1715
|
async function calculateAndPrepareVersionUpdates({ workspacePackages, packageCommits, workspaceRoot, showPrompt, globalCommitsPerPackage, overrides }) {
|
|
1682
|
-
const { updates: directUpdates, overrides: newOverrides } = await calculateVersionUpdates({
|
|
1716
|
+
const { updates: directUpdates, overrides: newOverrides, excludedPackages: promptExcludedPackages } = await calculateVersionUpdates({
|
|
1683
1717
|
workspacePackages,
|
|
1684
1718
|
packageCommits,
|
|
1685
1719
|
workspaceRoot,
|
|
@@ -1687,7 +1721,9 @@ async function calculateAndPrepareVersionUpdates({ workspacePackages, packageCom
|
|
|
1687
1721
|
globalCommitsPerPackage,
|
|
1688
1722
|
overrides
|
|
1689
1723
|
});
|
|
1690
|
-
const
|
|
1724
|
+
const graph = buildPackageDependencyGraph(workspacePackages);
|
|
1725
|
+
const overrideExcludedPackages = new Set(Object.entries(newOverrides).filter(([, override]) => override.type === "none").map(([pkgName]) => pkgName));
|
|
1726
|
+
const allUpdates = createDependentUpdates(graph, workspacePackages, directUpdates, new Set([...overrideExcludedPackages, ...promptExcludedPackages]));
|
|
1691
1727
|
const applyUpdates = async () => {
|
|
1692
1728
|
await Promise.all(allUpdates.map(async (update) => {
|
|
1693
1729
|
const depUpdates = getDependencyUpdates(update.package, allUpdates);
|
|
@@ -1894,7 +1930,10 @@ async function prepareWorkflow(options) {
|
|
|
1894
1930
|
if (allUpdates.filter((u) => u.hasDirectChanges).length === 0) logger.warn("No packages have changes requiring a release");
|
|
1895
1931
|
logger.section("🔄 Version Updates");
|
|
1896
1932
|
logger.item(`Updating ${allUpdates.length} packages (including dependents)`);
|
|
1897
|
-
for (const update of allUpdates)
|
|
1933
|
+
for (const update of allUpdates) {
|
|
1934
|
+
const suffix = update.currentVersion === update.newVersion ? farver.dim(" (as-is)") : "";
|
|
1935
|
+
logger.item(`${update.package.name}: ${update.currentVersion} → ${update.newVersion}${suffix}`);
|
|
1936
|
+
}
|
|
1898
1937
|
await applyUpdates();
|
|
1899
1938
|
if (options.changelog?.enabled) {
|
|
1900
1939
|
logger.step("Updating changelogs");
|