@ucdjs/release-scripts 0.1.0-beta.42 → 0.1.0-beta.43
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 +55 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -60,6 +60,51 @@ const args = mri(process.argv.slice(2));
|
|
|
60
60
|
const isDryRun = !!args.dry;
|
|
61
61
|
const isVerbose = !!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
|
+
}
|
|
63
108
|
const ucdjsReleaseOverridesPath = ".github/ucdjs-release.overrides.json";
|
|
64
109
|
const isCI = typeof process.env.CI === "string" && process.env.CI !== "" && process.env.CI.toLowerCase() !== "false";
|
|
65
110
|
const logger = {
|
|
@@ -135,7 +180,8 @@ function formatUnknownError(error) {
|
|
|
135
180
|
const maybeError = error;
|
|
136
181
|
if (typeof maybeError.code === "string") base.code = maybeError.code;
|
|
137
182
|
if (typeof maybeError.status === "number") base.status = maybeError.status;
|
|
138
|
-
|
|
183
|
+
base.stderr = extractStderrLike(maybeError);
|
|
184
|
+
if (typeof maybeError.shortMessage === "string" && maybeError.shortMessage.trim() && base.message.startsWith("Process exited with non-zero status")) base.message = maybeError.shortMessage.trim();
|
|
139
185
|
if (!base.stderr && typeof maybeError.cause === "string" && maybeError.cause.trim()) base.stderr = maybeError.cause.trim();
|
|
140
186
|
return base;
|
|
141
187
|
}
|
|
@@ -144,7 +190,7 @@ function formatUnknownError(error) {
|
|
|
144
190
|
const formatted = { message: typeof error.message === "string" ? error.message : typeof error.error === "string" ? error.error : JSON.stringify(error) };
|
|
145
191
|
if (typeof error.code === "string") formatted.code = error.code;
|
|
146
192
|
if (typeof error.status === "number") formatted.status = error.status;
|
|
147
|
-
|
|
193
|
+
formatted.stderr = extractStderrLike(error);
|
|
148
194
|
return formatted;
|
|
149
195
|
}
|
|
150
196
|
return { message: String(error) };
|
|
@@ -645,7 +691,7 @@ async function pushBranch(branch, workspaceRoot, options) {
|
|
|
645
691
|
"origin",
|
|
646
692
|
branch
|
|
647
693
|
];
|
|
648
|
-
if (options?.forceWithLease) {
|
|
694
|
+
if (options?.forceWithLease) try {
|
|
649
695
|
await run("git", [
|
|
650
696
|
"fetch",
|
|
651
697
|
"origin",
|
|
@@ -656,7 +702,12 @@ async function pushBranch(branch, workspaceRoot, options) {
|
|
|
656
702
|
} });
|
|
657
703
|
args.push("--force-with-lease");
|
|
658
704
|
logger.info(`Pushing branch: ${farver.green(branch)} ${farver.dim("(with lease)")}`);
|
|
659
|
-
}
|
|
705
|
+
} catch (error) {
|
|
706
|
+
const fetchError = toGitError("pushBranch.fetch", error);
|
|
707
|
+
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.`);
|
|
708
|
+
else return err(fetchError);
|
|
709
|
+
}
|
|
710
|
+
else if (options?.force) {
|
|
660
711
|
args.push("--force");
|
|
661
712
|
logger.info(`Force pushing branch: ${farver.green(branch)}`);
|
|
662
713
|
} else logger.info(`Pushing branch: ${farver.green(branch)}`);
|