skystream-cli 1.4.7 → 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.
Files changed (2) hide show
  1. package/dist/index.js +17 -7
  2. 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.7');
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,8 +455,12 @@ 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, headers, cb) => {
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";
@@ -466,17 +470,23 @@ program.command('test')
466
470
  const response = { status: res.status, statusCode: res.status, body, headers: res.headers };
467
471
  if (cb)
468
472
  cb(response);
469
- return response;
473
+ return response.body;
470
474
  }
471
475
  catch (e) {
472
476
  const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
473
477
  if (cb)
474
478
  cb(res);
475
- return res;
479
+ return res.body;
476
480
  }
477
481
  },
478
- http_post: async (url, headers, body, cb) => {
482
+ http_post: async (url, headers_or_options, body_arg, cb) => {
479
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
+ }
480
490
  const finalHeaders = { ...(headers || {}) };
481
491
  if (!Object.keys(finalHeaders).some(k => k.toLowerCase() === 'user-agent')) {
482
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";
@@ -486,13 +496,13 @@ program.command('test')
486
496
  const response = { status: res.status, statusCode: res.status, body: resBody, headers: res.headers };
487
497
  if (cb)
488
498
  cb(response);
489
- return response;
499
+ return response.body;
490
500
  }
491
501
  catch (e) {
492
502
  const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
493
503
  if (cb)
494
504
  cb(res);
495
- return res;
505
+ return res.body;
496
506
  }
497
507
  },
498
508
  registerSettings: (schema) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skystream-cli",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "type": "module",
5
5
  "description": "SkyStream Plugin Development Kit & Repository Manager",
6
6
  "main": "dist/index.js",