lumia-plugin 0.2.6 → 0.2.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/examples/base_plugin/package.json +1 -1
- package/package.json +2 -2
- package/scripts/build-plugin.js +18 -9
- package/scripts/utils.js +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lumia-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Command-line tools for creating, building, and validating Lumia Stream plugins.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lumia-plugin": "scripts/cli.js"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"author": "Lumia Stream",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lumiastream/plugin": "^0.2.
|
|
27
|
+
"@lumiastream/plugin": "^0.2.8",
|
|
28
28
|
"jszip": "3.10.1"
|
|
29
29
|
}
|
|
30
30
|
}
|
package/scripts/build-plugin.js
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
|
|
12
12
|
function parseArgs() {
|
|
13
13
|
const args = process.argv.slice(2);
|
|
14
|
-
const options = { dir: process.cwd(), outFile: null };
|
|
14
|
+
const options = { dir: process.cwd(), outFile: null, install: false };
|
|
15
15
|
while (args.length) {
|
|
16
16
|
const arg = args.shift();
|
|
17
17
|
switch (arg) {
|
|
@@ -23,6 +23,10 @@ function parseArgs() {
|
|
|
23
23
|
case "-o":
|
|
24
24
|
options.outFile = path.resolve(args.shift() || "");
|
|
25
25
|
break;
|
|
26
|
+
case "--install":
|
|
27
|
+
case "-i":
|
|
28
|
+
options.install = true;
|
|
29
|
+
break;
|
|
26
30
|
case "--help":
|
|
27
31
|
case "-h":
|
|
28
32
|
printHelp();
|
|
@@ -49,6 +53,7 @@ Usage: npx lumia-plugin build [options]
|
|
|
49
53
|
Options:
|
|
50
54
|
--dir, -d Plugin directory (defaults to cwd)
|
|
51
55
|
--out, -o Output file path (defaults to ./<id>-<version>.lumiaplugin)
|
|
56
|
+
--install, -i Run npm install before packaging
|
|
52
57
|
--help, -h Show this help message
|
|
53
58
|
`);
|
|
54
59
|
}
|
|
@@ -67,14 +72,18 @@ async function main() {
|
|
|
67
72
|
try {
|
|
68
73
|
const packageJsonPath = path.join(pluginDir, "package.json");
|
|
69
74
|
if (fs.existsSync(packageJsonPath)) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
if (options.install) {
|
|
76
|
+
console.log("• Running npm install...");
|
|
77
|
+
const result = spawnSync("npm", ["install"], {
|
|
78
|
+
cwd: pluginDir,
|
|
79
|
+
stdio: "inherit",
|
|
80
|
+
});
|
|
81
|
+
if (result.status !== 0) {
|
|
82
|
+
console.error("✖ npm install failed. Aborting build.");
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
console.log("• Skipping npm install (use --install to enable).");
|
|
78
87
|
}
|
|
79
88
|
} else {
|
|
80
89
|
console.log("• No package.json found; skipping npm install.");
|
package/scripts/utils.js
CHANGED
|
@@ -65,8 +65,20 @@ async function readManifest(pluginDir) {
|
|
|
65
65
|
|
|
66
66
|
async function collectFiles(pluginDir, ignore = DEFAULT_IGNORE) {
|
|
67
67
|
const entries = [];
|
|
68
|
+
const visited = new Set();
|
|
68
69
|
|
|
69
70
|
async function walk(currentDir) {
|
|
71
|
+
let realpath = currentDir;
|
|
72
|
+
try {
|
|
73
|
+
realpath = await fs.promises.realpath(currentDir);
|
|
74
|
+
} catch {
|
|
75
|
+
// ignore
|
|
76
|
+
}
|
|
77
|
+
if (visited.has(realpath)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
visited.add(realpath);
|
|
81
|
+
|
|
70
82
|
const list = await fs.promises.readdir(currentDir, { withFileTypes: true });
|
|
71
83
|
for (const entry of list) {
|
|
72
84
|
if (ignore.has(entry.name)) continue;
|
|
@@ -83,6 +95,18 @@ async function collectFiles(pluginDir, ignore = DEFAULT_IGNORE) {
|
|
|
83
95
|
continue;
|
|
84
96
|
}
|
|
85
97
|
|
|
98
|
+
if (entry.isSymbolicLink()) {
|
|
99
|
+
const stats = await fs.promises.stat(absolute).catch(() => null);
|
|
100
|
+
if (stats?.isDirectory()) {
|
|
101
|
+
await walk(absolute);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (stats?.isFile()) {
|
|
105
|
+
entries.push({ absolute, relative: toPosix(relative) });
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
86
110
|
if (entry.isDirectory()) {
|
|
87
111
|
await walk(absolute);
|
|
88
112
|
} else if (entry.isFile()) {
|