skystream-cli 1.4.6 → 1.4.8
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.js +21 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const program = new Command();
|
|
|
12
12
|
program
|
|
13
13
|
.name('skystream')
|
|
14
14
|
.description('SkyStream Plugin Development Kit CLI (Sky Gen 2)')
|
|
15
|
-
.version('1.4.
|
|
15
|
+
.version('1.4.8');
|
|
16
16
|
// Schemas
|
|
17
17
|
const pluginSchema = z.object({
|
|
18
18
|
packageName: z.string().min(5).regex(/^[a-z0-9._-]+$/),
|
|
@@ -455,42 +455,54 @@ program.command('test')
|
|
|
455
455
|
log: (...args) => console.log(' [JS]:', ...args),
|
|
456
456
|
error: (...args) => console.error(' [JS ERR]:', ...args)
|
|
457
457
|
},
|
|
458
|
-
http_get: async (url,
|
|
458
|
+
http_get: async (url, headers_or_options, cb) => {
|
|
459
459
|
try {
|
|
460
|
+
let headers = headers_or_options;
|
|
461
|
+
if (typeof headers_or_options === 'object' && headers_or_options !== null && (headers_or_options.headers || headers_or_options.body)) {
|
|
462
|
+
headers = headers_or_options.headers;
|
|
463
|
+
}
|
|
460
464
|
const finalHeaders = { ...(headers || {}) };
|
|
461
465
|
if (!Object.keys(finalHeaders).some(k => k.toLowerCase() === 'user-agent')) {
|
|
462
466
|
finalHeaders['User-Agent'] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36";
|
|
463
467
|
}
|
|
464
468
|
const res = await axios.get(url, { headers: finalHeaders });
|
|
465
469
|
const body = typeof res.data === 'string' ? res.data : JSON.stringify(res.data);
|
|
470
|
+
const response = { status: res.status, statusCode: res.status, body, headers: res.headers };
|
|
466
471
|
if (cb)
|
|
467
|
-
cb(
|
|
468
|
-
return body;
|
|
472
|
+
cb(response);
|
|
473
|
+
return response.body;
|
|
469
474
|
}
|
|
470
475
|
catch (e) {
|
|
471
476
|
const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
472
477
|
if (cb)
|
|
473
478
|
cb(res);
|
|
474
|
-
return
|
|
479
|
+
return res.body;
|
|
475
480
|
}
|
|
476
481
|
},
|
|
477
|
-
http_post: async (url,
|
|
482
|
+
http_post: async (url, headers_or_options, body_arg, cb) => {
|
|
478
483
|
try {
|
|
484
|
+
let headers = headers_or_options;
|
|
485
|
+
let body = body_arg;
|
|
486
|
+
if (typeof headers_or_options === 'object' && headers_or_options !== null && !body_arg && (headers_or_options.body || headers_or_options.headers)) {
|
|
487
|
+
body = headers_or_options.body;
|
|
488
|
+
headers = headers_or_options.headers;
|
|
489
|
+
}
|
|
479
490
|
const finalHeaders = { ...(headers || {}) };
|
|
480
491
|
if (!Object.keys(finalHeaders).some(k => k.toLowerCase() === 'user-agent')) {
|
|
481
492
|
finalHeaders['User-Agent'] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36";
|
|
482
493
|
}
|
|
483
494
|
const res = await axios.post(url, body, { headers: finalHeaders });
|
|
484
495
|
const resBody = typeof res.data === 'string' ? res.data : JSON.stringify(res.data);
|
|
496
|
+
const response = { status: res.status, statusCode: res.status, body: resBody, headers: res.headers };
|
|
485
497
|
if (cb)
|
|
486
|
-
cb(
|
|
487
|
-
return
|
|
498
|
+
cb(response);
|
|
499
|
+
return response.body;
|
|
488
500
|
}
|
|
489
501
|
catch (e) {
|
|
490
502
|
const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
491
503
|
if (cb)
|
|
492
504
|
cb(res);
|
|
493
|
-
return
|
|
505
|
+
return res.body;
|
|
494
506
|
}
|
|
495
507
|
},
|
|
496
508
|
registerSettings: (schema) => {
|