lumia-plugin 0.1.7 → 0.1.10

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 -2
  2. package/scripts/utils.js +19 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumia-plugin",
3
- "version": "0.1.7",
3
+ "version": "0.1.10",
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,7 +20,7 @@
20
20
  "author": "Lumia Stream",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@lumiastream/plugin": "latest",
23
+ "@lumiastream/plugin": "^0.1.10",
24
24
  "jszip": "3.10.1"
25
25
  }
26
26
  }
package/scripts/utils.js CHANGED
@@ -5,19 +5,31 @@ const JSZip = require("jszip");
5
5
  function loadSharedValidator() {
6
6
  try {
7
7
  const shared = require("@lumiastream/plugin");
8
- return (
9
- shared.validatePluginManifest ||
10
- shared.validateManifest
11
- );
8
+ const validator =
9
+ shared && (shared.validatePluginManifest || shared.validateManifest);
10
+ if (typeof validator === "function") {
11
+ return validator;
12
+ }
13
+ throw new Error("@lumiastream/plugin does not expose a manifest validator");
12
14
  } catch (error) {
13
- if (error.code !== "MODULE_NOT_FOUND") {
14
- throw error;
15
+ if (error.code === "MODULE_NOT_FOUND") {
16
+ // ignore and fall back to bundled validators
17
+ } else {
18
+ console.warn(
19
+ `Falling back to bundled manifest validator: ${error.message}`
20
+ );
15
21
  }
16
22
  }
17
23
 
18
24
  try {
19
25
  const fallback = require("../../dist/manifest-validation");
20
- return fallback.validatePluginManifest || fallback.validateManifest;
26
+ const validator =
27
+ fallback &&
28
+ (fallback.validatePluginManifest || fallback.validateManifest);
29
+ if (typeof validator === "function") {
30
+ return validator;
31
+ }
32
+ throw new Error("Bundled manifest validators are missing or invalid");
21
33
  } catch (error) {
22
34
  if (error.code !== "MODULE_NOT_FOUND") {
23
35
  throw error;