glidercli 0.3.19 → 0.3.20
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/bin/glider.js +27 -12
- package/package.json +1 -1
package/bin/glider.js
CHANGED
|
@@ -1445,25 +1445,40 @@ async function cmdCorsFetch(url, opts = []) {
|
|
|
1445
1445
|
}
|
|
1446
1446
|
|
|
1447
1447
|
try {
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1448
|
+
// Browser-typical Accept by default (unlocks Yammer-family 406-strict endpoints).
|
|
1449
|
+
const defaultAccept = 'application/json, text/plain, */*';
|
|
1450
|
+
async function doFetch(acceptHeader) {
|
|
1451
|
+
return httpPost('/extension', {
|
|
1452
|
+
method: 'corsFetch',
|
|
1453
|
+
params: {
|
|
1454
|
+
url,
|
|
1455
|
+
options: { method, body, headers: { 'Accept': acceptHeader } }
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
let result = await doFetch(defaultAccept);
|
|
1461
|
+
// /extension response envelope varies (flat vs wrapped); normalize
|
|
1462
|
+
let payload = result?.result ?? result;
|
|
1463
|
+
// 2-shot Accept fallback: if server returns 406 on the loose Accept, retry strict
|
|
1464
|
+
if (payload?.status === 406) {
|
|
1465
|
+
result = await doFetch('application/json');
|
|
1466
|
+
payload = result?.result ?? result;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1456
1469
|
if (result?.error) {
|
|
1457
1470
|
log.fail(`Fetch error: ${result.error}`);
|
|
1458
1471
|
process.exit(1);
|
|
1459
1472
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1473
|
+
|
|
1474
|
+
// cli_gap: cfetch_empty_response_crash - data may be undefined/null on empty bodies
|
|
1475
|
+
let data = payload?.data;
|
|
1476
|
+
if (data === undefined || data === null) data = '';
|
|
1477
|
+
const output = typeof data === 'object' ? JSON.stringify(data, null, 2) : String(data);
|
|
1463
1478
|
|
|
1464
1479
|
if (outputFile) {
|
|
1465
1480
|
fs.writeFileSync(outputFile, output);
|
|
1466
|
-
log.ok(`Saved to ${outputFile} (status: ${
|
|
1481
|
+
log.ok(`Saved to ${outputFile} (status: ${payload?.status})`);
|
|
1467
1482
|
} else {
|
|
1468
1483
|
console.log(output);
|
|
1469
1484
|
}
|
package/package.json
CHANGED