lumia-plugin 0.1.8 → 0.1.11
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/examples/base-plugin/GETTING_STARTED.md +2 -2
- package/examples/base-plugin/README.md +1 -1
- package/examples/base-plugin/main.js +1 -1
- package/examples/base-plugin/manifest.json +3 -3
- package/package.json +2 -2
- package/scripts/cli.js +3 -3
- package/scripts/create-plugin.js +13 -13
- package/scripts/utils.js +19 -7
|
@@ -18,7 +18,7 @@ your-plugin/
|
|
|
18
18
|
|
|
19
19
|
This file defines your plugin's metadata and capabilities:
|
|
20
20
|
|
|
21
|
-
- **id**: Unique identifier
|
|
21
|
+
- **id**: Unique identifier using letters, numbers, or underscores (e.g., "my_awesome_plugin")
|
|
22
22
|
- **name**: Display name shown to users
|
|
23
23
|
- **description**: Short description for the plugin marketplace
|
|
24
24
|
- **main**: Entry point file (usually "main.js")
|
|
@@ -116,7 +116,7 @@ Variables let other Lumia features access your plugin's data:
|
|
|
116
116
|
{
|
|
117
117
|
"name": "my_variable",
|
|
118
118
|
"key": "myVariable",
|
|
119
|
-
"origin": "
|
|
119
|
+
"origin": "your_plugin_id",
|
|
120
120
|
"type": "string",
|
|
121
121
|
"example": "Sample value"
|
|
122
122
|
}
|
|
@@ -11,7 +11,7 @@ This template demonstrates a handful of common Lumia Stream plugin capabilities:
|
|
|
11
11
|
Use the CLI to copy and customise the template:
|
|
12
12
|
|
|
13
13
|
```
|
|
14
|
-
npx lumia-plugin create
|
|
14
|
+
npx lumia-plugin create my_plugin
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
After scaffolding you can tailor the manifest, code, and README to match your idea.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "showcase_plugin",
|
|
3
3
|
"name": "Showcase Plugin",
|
|
4
4
|
"version": "1.0.0",
|
|
5
5
|
"author": "LumiaStream",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
{
|
|
109
109
|
"name": "last_message",
|
|
110
110
|
"system": false,
|
|
111
|
-
"origin": "
|
|
111
|
+
"origin": "showcase_plugin",
|
|
112
112
|
"allowedPlaces": ["automations", "overlays"],
|
|
113
113
|
"description": "Stores the most recent message handled by the plugin.",
|
|
114
114
|
"value": "",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
{
|
|
118
118
|
"name": "last_alert_color",
|
|
119
119
|
"system": false,
|
|
120
|
-
"origin": "
|
|
120
|
+
"origin": "showcase_plugin",
|
|
121
121
|
"allowedPlaces": ["automations", "overlays"],
|
|
122
122
|
"description": "Tracks the color used by the latest sample alert.",
|
|
123
123
|
"value": "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lumia-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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": "^0.1.
|
|
23
|
+
"@lumiastream/plugin": "^0.1.11",
|
|
24
24
|
"jszip": "3.10.1"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/scripts/cli.js
CHANGED
|
@@ -24,9 +24,9 @@ Commands:
|
|
|
24
24
|
validate [file] Validate a .lumiaplugin package
|
|
25
25
|
|
|
26
26
|
Examples:
|
|
27
|
-
lumia-plugin create
|
|
28
|
-
lumia-plugin build ./
|
|
29
|
-
lumia-plugin validate
|
|
27
|
+
lumia-plugin create my_plugin
|
|
28
|
+
lumia-plugin build ./my_plugin
|
|
29
|
+
lumia-plugin validate my_plugin.lumiaplugin
|
|
30
30
|
`);
|
|
31
31
|
process.exit(command ? 1 : 0);
|
|
32
32
|
}
|
package/scripts/create-plugin.js
CHANGED
|
@@ -4,19 +4,19 @@ const fs = require("fs");
|
|
|
4
4
|
|
|
5
5
|
const TEMPLATE_DIR = path.resolve(__dirname, "..", "examples", "base-plugin");
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
function toSafeId(value) {
|
|
8
|
+
const cleaned = value
|
|
9
|
+
.trim()
|
|
10
|
+
.toLowerCase()
|
|
11
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
12
|
+
.replace(/^_+|_+$/g, "");
|
|
13
|
+
const safe = cleaned.replace(/__+/g, "_");
|
|
14
|
+
return safe || "my_plugin";
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function toDisplayName(id) {
|
|
18
18
|
return id
|
|
19
|
-
.split(
|
|
19
|
+
.split(/[_-]+/)
|
|
20
20
|
.filter(Boolean)
|
|
21
21
|
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
22
22
|
.join(" ");
|
|
@@ -24,7 +24,7 @@ function toDisplayName(id) {
|
|
|
24
24
|
|
|
25
25
|
function printHelp() {
|
|
26
26
|
console.log(
|
|
27
|
-
`Scaffold a new Lumia Stream plugin directory using the showcase template.\n\nUsage: npx lumia-plugin create [target-directory]\n\nExamples:\n npx lumia-plugin create ./plugins/
|
|
27
|
+
`Scaffold a new Lumia Stream plugin directory using the showcase template.\n\nUsage: npx lumia-plugin create [target-directory]\n\nExamples:\n npx lumia-plugin create ./plugins/my_plugin\n npx lumia-plugin create my_awesome_plugin\n`
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -149,7 +149,7 @@ async function updateMain(mainPath, pluginId, className, displayName) {
|
|
|
149
149
|
`Hello from ${displayName}!`
|
|
150
150
|
);
|
|
151
151
|
source = source.replace(/Showcase Plugin/g, displayName);
|
|
152
|
-
source = source.replace(/showcase-plugin/g, pluginId);
|
|
152
|
+
source = source.replace(/showcase[-_]plugin/g, pluginId);
|
|
153
153
|
await fs.promises.writeFile(mainPath, source);
|
|
154
154
|
}
|
|
155
155
|
|
|
@@ -192,8 +192,8 @@ async function main() {
|
|
|
192
192
|
process.exit(1);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
const targetDir = path.resolve(args[0] || "
|
|
196
|
-
const pluginId =
|
|
195
|
+
const targetDir = path.resolve(args[0] || "my_plugin");
|
|
196
|
+
const pluginId = toSafeId(path.basename(targetDir));
|
|
197
197
|
const displayName = toDisplayName(pluginId) || "My Plugin";
|
|
198
198
|
const className = displayName.replace(/[^a-zA-Z0-9]/g, "") || "MyPlugin";
|
|
199
199
|
|
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
|
-
|
|
9
|
-
shared.validatePluginManifest ||
|
|
10
|
-
|
|
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
|
|
14
|
-
|
|
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
|
-
|
|
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;
|