@ucdjs/release-scripts 0.1.0-beta.42 → 0.1.0-beta.44
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 +85 -18
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -58,7 +58,7 @@ 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
63
|
const ucdjsReleaseOverridesPath = ".github/ucdjs-release.overrides.json";
|
|
64
64
|
const isCI = typeof process.env.CI === "string" && process.env.CI !== "" && process.env.CI.toLowerCase() !== "false";
|
|
@@ -73,7 +73,7 @@ const logger = {
|
|
|
73
73
|
console.error(` ${farver.red("✖")}`, ...args);
|
|
74
74
|
},
|
|
75
75
|
verbose: (...args) => {
|
|
76
|
-
if (!isVerbose) return;
|
|
76
|
+
if (!isVerbose$1) return;
|
|
77
77
|
if (args.length === 0) {
|
|
78
78
|
console.log();
|
|
79
79
|
return;
|
|
@@ -123,9 +123,67 @@ async function dryRun(bin, args, opts) {
|
|
|
123
123
|
return logger.verbose(farver.blue(`[dryrun] ${bin} ${args.join(" ")}`), opts || "");
|
|
124
124
|
}
|
|
125
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;
|
|
126
139
|
function isRecord(value) {
|
|
127
140
|
return typeof value === "object" && value !== null;
|
|
128
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
|
+
}
|
|
129
187
|
function formatUnknownError(error) {
|
|
130
188
|
if (error instanceof Error) {
|
|
131
189
|
const base = {
|
|
@@ -135,7 +193,8 @@ function formatUnknownError(error) {
|
|
|
135
193
|
const maybeError = error;
|
|
136
194
|
if (typeof maybeError.code === "string") base.code = maybeError.code;
|
|
137
195
|
if (typeof maybeError.status === "number") base.status = maybeError.status;
|
|
138
|
-
|
|
196
|
+
base.stderr = extractStderrLike(maybeError);
|
|
197
|
+
if (typeof maybeError.shortMessage === "string" && maybeError.shortMessage.trim() && base.message.startsWith("Process exited with non-zero status")) base.message = maybeError.shortMessage.trim();
|
|
139
198
|
if (!base.stderr && typeof maybeError.cause === "string" && maybeError.cause.trim()) base.stderr = maybeError.cause.trim();
|
|
140
199
|
return base;
|
|
141
200
|
}
|
|
@@ -144,13 +203,13 @@ function formatUnknownError(error) {
|
|
|
144
203
|
const formatted = { message: typeof error.message === "string" ? error.message : typeof error.error === "string" ? error.error : JSON.stringify(error) };
|
|
145
204
|
if (typeof error.code === "string") formatted.code = error.code;
|
|
146
205
|
if (typeof error.status === "number") formatted.status = error.status;
|
|
147
|
-
|
|
206
|
+
formatted.stderr = extractStderrLike(error);
|
|
148
207
|
return formatted;
|
|
149
208
|
}
|
|
150
209
|
return { message: String(error) };
|
|
151
210
|
}
|
|
152
211
|
function exitWithError(message, hint, cause) {
|
|
153
|
-
|
|
212
|
+
console.error(` ${farver.red("✖")} ${farver.bold(message)}`);
|
|
154
213
|
if (cause !== void 0) {
|
|
155
214
|
const formatted = formatUnknownError(cause);
|
|
156
215
|
if (formatted.message && formatted.message !== message) console.error(farver.gray(` Cause: ${formatted.message}`));
|
|
@@ -168,15 +227,6 @@ function exitWithError(message, hint, cause) {
|
|
|
168
227
|
if (hint) console.error(farver.gray(` ${hint}`));
|
|
169
228
|
process.exit(1);
|
|
170
229
|
}
|
|
171
|
-
if (isDryRun || isVerbose || isForce) {
|
|
172
|
-
logger.verbose(farver.inverse(farver.yellow(" Running with special flags ")));
|
|
173
|
-
logger.verbose({
|
|
174
|
-
isDryRun,
|
|
175
|
-
isVerbose,
|
|
176
|
-
isForce
|
|
177
|
-
});
|
|
178
|
-
logger.verbose();
|
|
179
|
-
}
|
|
180
230
|
|
|
181
231
|
//#endregion
|
|
182
232
|
//#region src/core/github.ts
|
|
@@ -645,7 +695,7 @@ async function pushBranch(branch, workspaceRoot, options) {
|
|
|
645
695
|
"origin",
|
|
646
696
|
branch
|
|
647
697
|
];
|
|
648
|
-
if (options?.forceWithLease) {
|
|
698
|
+
if (options?.forceWithLease) try {
|
|
649
699
|
await run("git", [
|
|
650
700
|
"fetch",
|
|
651
701
|
"origin",
|
|
@@ -656,7 +706,12 @@ async function pushBranch(branch, workspaceRoot, options) {
|
|
|
656
706
|
} });
|
|
657
707
|
args.push("--force-with-lease");
|
|
658
708
|
logger.info(`Pushing branch: ${farver.green(branch)} ${farver.dim("(with lease)")}`);
|
|
659
|
-
}
|
|
709
|
+
} catch (error) {
|
|
710
|
+
const fetchError = toGitError("pushBranch.fetch", error);
|
|
711
|
+
if (fetchError.stderr?.includes("couldn't find remote ref") || fetchError.message.includes("couldn't find remote ref")) logger.verbose(`Remote branch origin/${branch} does not exist yet, falling back to regular push without --force-with-lease.`);
|
|
712
|
+
else return err(fetchError);
|
|
713
|
+
}
|
|
714
|
+
else if (options?.force) {
|
|
660
715
|
args.push("--force");
|
|
661
716
|
logger.info(`Force pushing branch: ${farver.green(branch)}`);
|
|
662
717
|
} else logger.info(`Pushing branch: ${farver.green(branch)}`);
|
|
@@ -1568,10 +1623,15 @@ async function calculateVersionUpdates({ workspacePackages, packageCommits, work
|
|
|
1568
1623
|
const determinedBump = determineHighestBump(allCommitsForPackage);
|
|
1569
1624
|
const override = newOverrides[pkgName];
|
|
1570
1625
|
const effectiveBump = override?.type || determinedBump;
|
|
1571
|
-
|
|
1626
|
+
const canPrompt = !isCI && showPrompt;
|
|
1627
|
+
if (override?.type === "none" && override.version === pkg.version) {
|
|
1628
|
+
delete newOverrides[pkgName];
|
|
1629
|
+
logger.verbose(`Removed stale "none" override for ${pkgName}`);
|
|
1630
|
+
}
|
|
1631
|
+
if (effectiveBump === "none" && !canPrompt) continue;
|
|
1572
1632
|
let newVersion = override?.version || getNextVersion(pkg.version, effectiveBump);
|
|
1573
1633
|
let finalBumpType = effectiveBump;
|
|
1574
|
-
if (
|
|
1634
|
+
if (canPrompt) {
|
|
1575
1635
|
logger.clearScreen();
|
|
1576
1636
|
logger.section(`📝 Commits for ${farver.cyan(pkg.name)}`);
|
|
1577
1637
|
formatCommitsForDisplay(allCommitsForPackage).split("\n").forEach((line) => logger.item(line));
|
|
@@ -1580,6 +1640,13 @@ async function calculateVersionUpdates({ workspacePackages, packageCommits, work
|
|
|
1580
1640
|
if (selectedVersion === null) continue;
|
|
1581
1641
|
const userBump = calculateBumpType(pkg.version, selectedVersion);
|
|
1582
1642
|
finalBumpType = userBump;
|
|
1643
|
+
if (selectedVersion === pkg.version) {
|
|
1644
|
+
if (newOverrides[pkgName]) {
|
|
1645
|
+
delete newOverrides[pkgName];
|
|
1646
|
+
logger.info(`Version override removed for ${pkgName}.`);
|
|
1647
|
+
}
|
|
1648
|
+
continue;
|
|
1649
|
+
}
|
|
1583
1650
|
if (bumpRanks[userBump] < bumpRanks[determinedBump]) {
|
|
1584
1651
|
newOverrides[pkgName] = {
|
|
1585
1652
|
type: userBump,
|