skystream-cli 1.3.7 → 1.3.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 +33 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
+
import * as vm from 'vm';
|
|
4
5
|
import * as crypto from 'crypto';
|
|
5
6
|
import fs from 'fs-extra';
|
|
6
7
|
import { z } from 'zod';
|
|
@@ -10,7 +11,7 @@ const program = new Command();
|
|
|
10
11
|
program
|
|
11
12
|
.name('skystream')
|
|
12
13
|
.description('SkyStream Plugin Development Kit CLI (Sky Gen 2)')
|
|
13
|
-
.version('1.3.
|
|
14
|
+
.version('1.3.8');
|
|
14
15
|
// Schemas
|
|
15
16
|
const pluginSchema = z.object({
|
|
16
17
|
packageName: z.string().min(5).regex(/^[a-z0-9._-]+$/),
|
|
@@ -425,6 +426,15 @@ program.command('test')
|
|
|
425
426
|
const pluginDir = path.resolve(options.path);
|
|
426
427
|
const manifestPath = path.join(pluginDir, 'plugin.json');
|
|
427
428
|
const jsPath = path.join(pluginDir, 'plugin.js');
|
|
429
|
+
if (!await fs.pathExists(manifestPath)) {
|
|
430
|
+
console.error(`Error: plugin.json not found at ${manifestPath}`);
|
|
431
|
+
console.log('Hint: Run this command from your plugin directory or specify --path');
|
|
432
|
+
process.exit(1);
|
|
433
|
+
}
|
|
434
|
+
if (!await fs.pathExists(jsPath)) {
|
|
435
|
+
console.error(`Error: plugin.js not found at ${jsPath}`);
|
|
436
|
+
process.exit(1);
|
|
437
|
+
}
|
|
428
438
|
const manifest = await fs.readJson(manifestPath);
|
|
429
439
|
const jsContent = await fs.readFile(jsPath, 'utf8');
|
|
430
440
|
console.log(`\n--- Testing ${manifest.packageName} -> ${options.function} ---`);
|
|
@@ -560,22 +570,35 @@ program.command('test')
|
|
|
560
570
|
}
|
|
561
571
|
}
|
|
562
572
|
|
|
563
|
-
globalThis.
|
|
564
|
-
globalThis.Episode = Episode;
|
|
565
|
-
globalThis.StreamResult = StreamResult;
|
|
573
|
+
globalThis.clearInterval = clearInterval;
|
|
566
574
|
`;
|
|
567
|
-
|
|
575
|
+
const sandbox = Object.create(null);
|
|
576
|
+
sandbox.console = console;
|
|
577
|
+
sandbox.axios = axios;
|
|
578
|
+
sandbox.Buffer = Buffer;
|
|
579
|
+
sandbox.manifest = manifest;
|
|
580
|
+
sandbox.setTimeout = setTimeout;
|
|
581
|
+
sandbox.clearTimeout = clearTimeout;
|
|
582
|
+
sandbox.setInterval = setInterval;
|
|
583
|
+
sandbox.clearInterval = clearInterval;
|
|
584
|
+
sandbox.globalThis = sandbox;
|
|
585
|
+
// Inject the classes from entityDefs into the sandbox
|
|
586
|
+
const vmContext = vm.createContext(sandbox);
|
|
587
|
+
vm.runInContext(entityDefs, vmContext);
|
|
568
588
|
const combinedScript = `
|
|
569
|
-
${entityDefs}
|
|
570
589
|
try {
|
|
571
590
|
${jsContent}
|
|
572
|
-
} catch (e) {
|
|
591
|
+
} catch (e: any) {
|
|
573
592
|
console.error("Critical Runtime Error: " + e.stack);
|
|
574
593
|
}
|
|
575
594
|
`;
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
595
|
+
try {
|
|
596
|
+
vm.runInContext(combinedScript, vmContext, { timeout: 5000, breakOnSigint: true });
|
|
597
|
+
}
|
|
598
|
+
catch (e) {
|
|
599
|
+
console.error("VM Execution Error: " + e.message);
|
|
600
|
+
}
|
|
601
|
+
const fn = vmContext.globalThis[options.function];
|
|
579
602
|
if (typeof fn !== 'function') {
|
|
580
603
|
console.error('Error: exported function not found');
|
|
581
604
|
process.exit(1);
|