badmfck-api-server 4.1.47 → 4.1.48
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.
|
@@ -173,35 +173,12 @@ async function Deploy(opt) {
|
|
|
173
173
|
headersTimeout: 5 * 60 * 1000,
|
|
174
174
|
bodyTimeout: 5 * 60 * 1000,
|
|
175
175
|
});
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
headers: { authorization: `Bearer ${authToken}` },
|
|
183
|
-
body: formData,
|
|
184
|
-
signal: abortController.signal,
|
|
185
|
-
...{ dispatcher: uploadAgent },
|
|
186
|
-
});
|
|
187
|
-
const rawText = await res.text();
|
|
188
|
-
let parsed;
|
|
189
|
-
try {
|
|
190
|
-
parsed = rawText.length > 0 ? JSON.parse(rawText) : null;
|
|
191
|
-
}
|
|
192
|
-
catch {
|
|
193
|
-
parsed = rawText;
|
|
194
|
-
}
|
|
195
|
-
uploadResponse = res.ok
|
|
196
|
-
? { ok: true, status: res.status, data: parsed }
|
|
197
|
-
: { ok: false, status: res.status, error: parsed };
|
|
198
|
-
}
|
|
199
|
-
catch (err) {
|
|
200
|
-
uploadResponse = { ok: false, error: err };
|
|
201
|
-
}
|
|
202
|
-
finally {
|
|
203
|
-
clearTimeout(abortTimer);
|
|
204
|
-
}
|
|
176
|
+
const uploadResponse = await __1.Http.post(opt.host, formData, {
|
|
177
|
+
headers: { authorization: `Bearer ${authToken}` },
|
|
178
|
+
dispatcher: uploadAgent,
|
|
179
|
+
timeoutMs: 5 * 60 * 1000,
|
|
180
|
+
retry: { enabled: false },
|
|
181
|
+
});
|
|
205
182
|
const elapsedMs = Date.now() - startedAt;
|
|
206
183
|
const useColor = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
207
184
|
const c = (code, t) => useColor ? `\x1b[${code}m${t}\x1b[0m` : t;
|
|
@@ -281,18 +258,23 @@ async function Deploy(opt) {
|
|
|
281
258
|
console.log(` ${dim("elapsed: ")} ${elapsedMs}ms`);
|
|
282
259
|
console.log(` ${dim("time: ")} ${stamp}`);
|
|
283
260
|
const info = body?.data?.data;
|
|
284
|
-
if (info && typeof info === "object" &&
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
261
|
+
if (info && typeof info === "object" && "ok" in info) {
|
|
262
|
+
if (info.project && info.project !== opt.name) {
|
|
263
|
+
console.log(` ${dim("server project:")} ${info.project}`);
|
|
264
|
+
}
|
|
265
|
+
if (info.bluegreen === true) {
|
|
266
|
+
const slotBadge = info.activeThisDeploy
|
|
267
|
+
? green("← active in production")
|
|
268
|
+
: yellow("(inactive — deploy landed but nginx still points at " + info.active + "; run /pckg/switch to promote)");
|
|
269
|
+
console.log(` ${dim("mode: ")} blue-green`);
|
|
270
|
+
console.log(` ${dim("slot: ")} ${bold(String(info.slot))} ${slotBadge}`);
|
|
271
|
+
if (info.active && info.active !== info.slot) {
|
|
272
|
+
console.log(` ${dim("active: ")} ${info.active}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else if (info.bluegreen === false) {
|
|
276
|
+
console.log(` ${dim("mode: ")} single-instance ${green("← active")}`);
|
|
292
277
|
}
|
|
293
|
-
}
|
|
294
|
-
else if (info && typeof info === "object" && info.bluegreen === false) {
|
|
295
|
-
console.log(` ${dim("mode: ")} single-instance`);
|
|
296
278
|
}
|
|
297
279
|
if (!emptyResponse) {
|
|
298
280
|
const payload = JSON.stringify(body);
|
|
@@ -43,6 +43,32 @@ function normalizeHeaders(headers) {
|
|
|
43
43
|
function isRetryableStatus(status, retryOnStatuses) {
|
|
44
44
|
return retryOnStatuses.includes(status);
|
|
45
45
|
}
|
|
46
|
+
function isFormDataLike(value) {
|
|
47
|
+
return (value !== null &&
|
|
48
|
+
typeof value === "object" &&
|
|
49
|
+
Object.prototype.toString.call(value) === "[object FormData]" &&
|
|
50
|
+
typeof value.entries === "function");
|
|
51
|
+
}
|
|
52
|
+
function normalizeFormData(source) {
|
|
53
|
+
if (source instanceof undici_1.FormData)
|
|
54
|
+
return source;
|
|
55
|
+
const target = new undici_1.FormData();
|
|
56
|
+
for (const [name, value] of source.entries()) {
|
|
57
|
+
if (typeof value === "string") {
|
|
58
|
+
target.append(name, value);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
target.append(name, value, value.name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return target;
|
|
65
|
+
}
|
|
66
|
+
function removeContentTypeHeader(headers) {
|
|
67
|
+
for (const key of Object.keys(headers)) {
|
|
68
|
+
if (key.toLowerCase() === "content-type")
|
|
69
|
+
delete headers[key];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
46
72
|
function isLikelyNetworkError(err) {
|
|
47
73
|
if (!err || typeof err !== "object")
|
|
48
74
|
return false;
|
|
@@ -423,11 +449,12 @@ class Http {
|
|
|
423
449
|
let body = undefined;
|
|
424
450
|
const hasBody = opts.body !== undefined && opts.body !== null;
|
|
425
451
|
const allowBody = opts.allowBody ?? (opts.method !== "GET" && opts.method !== "DELETE");
|
|
452
|
+
let isMultipart = false;
|
|
426
453
|
if (hasBody && allowBody) {
|
|
427
|
-
if (
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
454
|
+
if (isFormDataLike(opts.body)) {
|
|
455
|
+
isMultipart = true;
|
|
456
|
+
body = normalizeFormData(opts.body);
|
|
457
|
+
removeContentTypeHeader(headers);
|
|
431
458
|
}
|
|
432
459
|
else {
|
|
433
460
|
const ct = (headers["content-type"] || headers["Content-Type"] || "").toLowerCase();
|
|
@@ -442,6 +469,9 @@ class Http {
|
|
|
442
469
|
}
|
|
443
470
|
}
|
|
444
471
|
}
|
|
472
|
+
if (isMultipart && retryCfg.maxAttempts !== 1) {
|
|
473
|
+
retryCfg.maxAttempts = 1;
|
|
474
|
+
}
|
|
445
475
|
const responseType = opts.responseType ?? "json";
|
|
446
476
|
const throwOnJsonParseError = opts.throwOnJsonParseError ?? false;
|
|
447
477
|
let attemptsMade = 0;
|