lumia-plugin 0.1.6 → 0.1.7

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/package.json +2 -1
  2. package/scripts/utils.js +29 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumia-plugin",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Command-line tools for creating, building, and validating Lumia Stream plugins.",
5
5
  "bin": {
6
6
  "lumia-plugin": "scripts/cli.js"
@@ -20,6 +20,7 @@
20
20
  "author": "Lumia Stream",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
+ "@lumiastream/plugin": "latest",
23
24
  "jszip": "3.10.1"
24
25
  }
25
26
  }
package/scripts/utils.js CHANGED
@@ -2,6 +2,35 @@ const fs = require("fs");
2
2
  const path = require("path");
3
3
  const JSZip = require("jszip");
4
4
 
5
+ function loadSharedValidator() {
6
+ try {
7
+ const shared = require("@lumiastream/plugin");
8
+ return (
9
+ shared.validatePluginManifest ||
10
+ shared.validateManifest
11
+ );
12
+ } catch (error) {
13
+ if (error.code !== "MODULE_NOT_FOUND") {
14
+ throw error;
15
+ }
16
+ }
17
+
18
+ try {
19
+ const fallback = require("../../dist/manifest-validation");
20
+ return fallback.validatePluginManifest || fallback.validateManifest;
21
+ } catch (error) {
22
+ if (error.code !== "MODULE_NOT_FOUND") {
23
+ throw error;
24
+ }
25
+ }
26
+
27
+ throw new Error(
28
+ "Unable to locate manifest validation helpers. Ensure @lumiastream/plugin is installed."
29
+ );
30
+ }
31
+
32
+ const validateManifest = loadSharedValidator();
33
+
5
34
  const DEFAULT_IGNORE = new Set([
6
35
  ".git",
7
36
  ".DS_Store",
@@ -22,56 +51,6 @@ async function readManifest(pluginDir) {
22
51
  return { manifest: JSON.parse(raw), manifestPath };
23
52
  }
24
53
 
25
- function validateManifest(manifest) {
26
- const errors = [];
27
- const requiredStringFields = [
28
- "id",
29
- "name",
30
- "version",
31
- "author",
32
- "description",
33
- "license",
34
- "lumiaVersion",
35
- ];
36
- for (const field of requiredStringFields) {
37
- const value = manifest[field];
38
- if (typeof value !== "string" || value.trim().length === 0) {
39
- errors.push(`Missing or invalid manifest field: ${field}`);
40
- }
41
- }
42
-
43
- if (
44
- !manifest.category ||
45
- (typeof manifest.category !== "string" && !Array.isArray(manifest.category))
46
- ) {
47
- errors.push("Manifest must declare a category string");
48
- }
49
-
50
- if (!manifest.config || typeof manifest.config !== "object") {
51
- errors.push("Manifest config must be an object");
52
- }
53
-
54
- if (manifest.config) {
55
- if (manifest.config.settings && !Array.isArray(manifest.config.settings)) {
56
- errors.push("config.settings must be an array when provided");
57
- }
58
- if (manifest.config.actions && !Array.isArray(manifest.config.actions)) {
59
- errors.push("config.actions must be an array when provided");
60
- }
61
- if (
62
- manifest.config.variables &&
63
- !Array.isArray(manifest.config.variables)
64
- ) {
65
- errors.push("config.variables must be an array when provided");
66
- }
67
- if (manifest.config.alerts && !Array.isArray(manifest.config.alerts)) {
68
- errors.push("config.alerts must be an array when provided");
69
- }
70
- }
71
-
72
- return errors;
73
- }
74
-
75
54
  async function collectFiles(pluginDir, ignore = DEFAULT_IGNORE) {
76
55
  const entries = [];
77
56