skystream-cli 1.1.0 → 1.2.2
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 +18 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,12 +9,11 @@ const program = new Command();
|
|
|
9
9
|
program
|
|
10
10
|
.name('skystream')
|
|
11
11
|
.description('SkyStream Plugin Development Kit CLI (Sky Gen 2)')
|
|
12
|
-
.version('1.2.
|
|
12
|
+
.version('1.2.2');
|
|
13
13
|
// Schemas
|
|
14
14
|
const pluginSchema = z.object({
|
|
15
|
-
|
|
15
|
+
packageName: z.string().min(5).regex(/^[a-z0-9._-]+$/),
|
|
16
16
|
name: z.string().min(1),
|
|
17
|
-
internalName: z.string().min(1).regex(/^[A-Z0-9]+$/),
|
|
18
17
|
version: z.number().int().positive(),
|
|
19
18
|
description: z.string().min(1),
|
|
20
19
|
authors: z.array(z.string()).min(1),
|
|
@@ -23,7 +22,7 @@ const pluginSchema = z.object({
|
|
|
23
22
|
});
|
|
24
23
|
const repoSchema = z.object({
|
|
25
24
|
name: z.string().min(1),
|
|
26
|
-
|
|
25
|
+
packageName: z.string().min(3).regex(/^[a-z0-9._-]+$/),
|
|
27
26
|
description: z.string().min(1),
|
|
28
27
|
manifestVersion: z.number().int().positive(),
|
|
29
28
|
pluginLists: z.array(z.string().url()),
|
|
@@ -231,7 +230,7 @@ jobs:
|
|
|
231
230
|
- name: Build Repository
|
|
232
231
|
run: |
|
|
233
232
|
npm install -g skystream-cli
|
|
234
|
-
skystream build -u https://raw.githubusercontent.com/\${{ github.repository }}
|
|
233
|
+
skystream build -u https://raw.githubusercontent.com/\${{ github.repository }}/main
|
|
235
234
|
|
|
236
235
|
- name: Commit and Push changes
|
|
237
236
|
run: |
|
|
@@ -262,11 +261,11 @@ program.command('init')
|
|
|
262
261
|
const projectSlug = projectName.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
|
|
263
262
|
const repo = {
|
|
264
263
|
name: projectName,
|
|
265
|
-
|
|
264
|
+
packageName: options.packageName,
|
|
266
265
|
description: options.description,
|
|
267
266
|
manifestVersion: 1,
|
|
268
267
|
pluginLists: [
|
|
269
|
-
`
|
|
268
|
+
`https://raw.githubusercontent.com/USER_NAME/REPO_NAME/main/dist/plugins.json`
|
|
270
269
|
]
|
|
271
270
|
};
|
|
272
271
|
await fs.writeJson(path.join(rootDir, 'repo.json'), repo, { spaces: 2 });
|
|
@@ -282,9 +281,8 @@ program.command('init')
|
|
|
282
281
|
const pluginDir = path.join(rootDir, pluginSlug);
|
|
283
282
|
await fs.ensureDir(pluginDir);
|
|
284
283
|
const pluginManifest = {
|
|
285
|
-
|
|
284
|
+
packageName: `${packageName}.${pluginSlug}`,
|
|
286
285
|
name: pluginName,
|
|
287
|
-
internalName: pluginName.toUpperCase().replace(/\s+/g, ''),
|
|
288
286
|
version: 1,
|
|
289
287
|
description: `${pluginName} plugin (Sky Gen 2)`,
|
|
290
288
|
authors: [options.author],
|
|
@@ -295,7 +293,7 @@ program.command('init')
|
|
|
295
293
|
await fs.writeFile(path.join(pluginDir, 'plugin.js'), JS_TEMPLATE);
|
|
296
294
|
console.log('\nSky Gen 2 Repository successfully initialized!');
|
|
297
295
|
console.log(`Project Directory: ${rootDir}`);
|
|
298
|
-
console.log(`First Plugin
|
|
296
|
+
console.log(`First Plugin Package Name: ${pluginManifest.packageName}`);
|
|
299
297
|
});
|
|
300
298
|
program.command('add')
|
|
301
299
|
.description('Add a new Sky Gen 2 plugin to the repository')
|
|
@@ -317,11 +315,10 @@ program.command('add')
|
|
|
317
315
|
process.exit(1);
|
|
318
316
|
}
|
|
319
317
|
// Guess package-name from repo id
|
|
320
|
-
const packageName = repo.
|
|
318
|
+
const packageName = repo.packageName;
|
|
321
319
|
const pluginManifest = {
|
|
322
|
-
|
|
320
|
+
packageName: `${packageName}.${pluginSlug}`,
|
|
323
321
|
name: pluginName,
|
|
324
|
-
internalName: pluginName.toUpperCase().replace(/\s+/g, ''),
|
|
325
322
|
version: 1,
|
|
326
323
|
description: options.description || `${pluginName} plugin for ${repo.name}`,
|
|
327
324
|
authors: [options.author || repo.author || "Developer"],
|
|
@@ -331,7 +328,7 @@ program.command('add')
|
|
|
331
328
|
await fs.ensureDir(pluginDir);
|
|
332
329
|
await fs.writeJson(path.join(pluginDir, 'plugin.json'), pluginManifest, { spaces: 2 });
|
|
333
330
|
await fs.writeFile(path.join(pluginDir, 'plugin.js'), JS_TEMPLATE);
|
|
334
|
-
console.log(`✓ Added Plugin: ${pluginName} (
|
|
331
|
+
console.log(`✓ Added Plugin: ${pluginName} (Package: ${pluginManifest.packageName})`);
|
|
335
332
|
});
|
|
336
333
|
program.command('validate')
|
|
337
334
|
.description('Validate all plugins in the repo')
|
|
@@ -346,13 +343,13 @@ program.command('validate')
|
|
|
346
343
|
try {
|
|
347
344
|
const manifest = await fs.readJson(manifestPath);
|
|
348
345
|
pluginSchema.parse(manifest);
|
|
349
|
-
console.log(`✓ ${manifest.
|
|
346
|
+
console.log(`✓ ${manifest.packageName}: Manifest OK`);
|
|
350
347
|
const js = await fs.readFile(path.join(itemPath, 'plugin.js'), 'utf8');
|
|
351
348
|
if (js.includes('globalThis.getHome = getHome')) {
|
|
352
|
-
console.log(`✓ ${manifest.
|
|
349
|
+
console.log(`✓ ${manifest.packageName}: Logic OK`);
|
|
353
350
|
}
|
|
354
351
|
else {
|
|
355
|
-
console.warn(`! ${manifest.
|
|
352
|
+
console.warn(`! ${manifest.packageName}: Missing exports`);
|
|
356
353
|
}
|
|
357
354
|
count++;
|
|
358
355
|
}
|
|
@@ -377,7 +374,7 @@ program.command('test')
|
|
|
377
374
|
const jsPath = path.join(pluginDir, 'plugin.js');
|
|
378
375
|
const manifest = await fs.readJson(manifestPath);
|
|
379
376
|
const jsContent = await fs.readFile(jsPath, 'utf8');
|
|
380
|
-
console.log(`\n--- Testing ${manifest.
|
|
377
|
+
console.log(`\n--- Testing ${manifest.packageName} -> ${options.function} ---`);
|
|
381
378
|
const context = {
|
|
382
379
|
manifest,
|
|
383
380
|
console: { log: (...args) => console.log(' [JS]:', ...args), error: (...args) => console.error(' [JS ERR]:', ...args) },
|
|
@@ -438,7 +435,8 @@ program.command('build')
|
|
|
438
435
|
const mPath = path.join(itemPath, 'plugin.json');
|
|
439
436
|
if (await fs.pathExists(mPath) && (await fs.stat(itemPath)).isDirectory()) {
|
|
440
437
|
const manifest = await fs.readJson(mPath);
|
|
441
|
-
const
|
|
438
|
+
const packageName = manifest.packageName || manifest.id || item;
|
|
439
|
+
const bundleName = `${packageName}.sky`;
|
|
442
440
|
const outPath = path.join(distDir, bundleName);
|
|
443
441
|
const arch = archiver('zip', { zlib: { level: 9 } });
|
|
444
442
|
arch.pipe(fs.createWriteStream(outPath));
|
|
@@ -446,7 +444,7 @@ program.command('build')
|
|
|
446
444
|
arch.file(path.join(itemPath, 'plugin.js'), { name: 'plugin.js' });
|
|
447
445
|
await arch.finalize();
|
|
448
446
|
catalog.push({ ...manifest, url: `${distUrl}/${bundleName}` });
|
|
449
|
-
console.log(`✓ Bundled ${manifest.
|
|
447
|
+
console.log(`✓ Bundled ${manifest.packageName}`);
|
|
450
448
|
}
|
|
451
449
|
}
|
|
452
450
|
const finalRepo = {
|