vslides 1.0.14 → 1.0.15
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/cli.js +23 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3248,8 +3248,9 @@ async function getGuide() {
|
|
|
3248
3248
|
}
|
|
3249
3249
|
async function uploadAsset(slug, token, filename, content) {
|
|
3250
3250
|
for (let i = 0; i < MAX_RETRIES; i++) {
|
|
3251
|
+
let response;
|
|
3251
3252
|
try {
|
|
3252
|
-
|
|
3253
|
+
response = await fetch(`${BASE_URL}/api/slides/assets`, {
|
|
3253
3254
|
method: "POST",
|
|
3254
3255
|
headers: {
|
|
3255
3256
|
"X-Slug": slug,
|
|
@@ -3257,27 +3258,35 @@ async function uploadAsset(slug, token, filename, content) {
|
|
|
3257
3258
|
"X-Filename": filename,
|
|
3258
3259
|
"Content-Type": "application/octet-stream"
|
|
3259
3260
|
},
|
|
3260
|
-
body:
|
|
3261
|
+
body: content
|
|
3262
|
+
// Node.js fetch handles Buffer directly
|
|
3261
3263
|
});
|
|
3262
|
-
if (response.status === 503) {
|
|
3263
|
-
console.log("Sandbox waking up...");
|
|
3264
|
-
await sleep(RETRY_DELAY);
|
|
3265
|
-
continue;
|
|
3266
|
-
}
|
|
3267
|
-
if (response.status === 401) {
|
|
3268
|
-
clearCLIAuth();
|
|
3269
|
-
throw new AuthExpiredError();
|
|
3270
|
-
}
|
|
3271
|
-
const data = await response.json();
|
|
3272
|
-
return { ok: response.ok, status: response.status, data };
|
|
3273
3264
|
} catch (err) {
|
|
3274
3265
|
if (i < MAX_RETRIES - 1) {
|
|
3275
|
-
|
|
3266
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
3267
|
+
console.log(`Upload network error: ${errMsg}, retrying... (${i + 1}/${MAX_RETRIES})`);
|
|
3276
3268
|
await sleep(RETRY_DELAY);
|
|
3277
3269
|
continue;
|
|
3278
3270
|
}
|
|
3279
3271
|
throw err;
|
|
3280
3272
|
}
|
|
3273
|
+
if (response.status === 503) {
|
|
3274
|
+
console.log("Sandbox waking up...");
|
|
3275
|
+
await sleep(RETRY_DELAY);
|
|
3276
|
+
continue;
|
|
3277
|
+
}
|
|
3278
|
+
if (response.status === 401) {
|
|
3279
|
+
clearCLIAuth();
|
|
3280
|
+
throw new AuthExpiredError();
|
|
3281
|
+
}
|
|
3282
|
+
let data;
|
|
3283
|
+
try {
|
|
3284
|
+
data = await response.json();
|
|
3285
|
+
} catch {
|
|
3286
|
+
const text = await response.text().catch(() => "unknown");
|
|
3287
|
+
throw new Error(`Upload failed (${response.status}): ${text}`);
|
|
3288
|
+
}
|
|
3289
|
+
return { ok: response.ok, status: response.status, data };
|
|
3281
3290
|
}
|
|
3282
3291
|
throw new Error("Upload failed after max retries");
|
|
3283
3292
|
}
|