create-deck-plugin 0.15.1 → 0.16.0

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/index.mjs CHANGED
@@ -56,13 +56,38 @@ for (const rel of ["plugin.json", "package.json", "src/plugin.tsx", "README.md"]
56
56
  .replaceAll("__COMPONENT__", component));
57
57
  }
58
58
 
59
+ /**
60
+ * Run a command in the new plugin's directory.
61
+ *
62
+ * npm needs care on Windows. `npm` there is npm.cmd, and recent Node refuses to execFile a .cmd
63
+ * at all — EINVAL, a deliberate fix for an argument-injection class of bug — so the scaffolder
64
+ * silently installed nothing for every Windows user, which is every Deck user. Running it
65
+ * through a shell works but is itself deprecated for the same reason, so npm's own JS entry
66
+ * point is located and run with node instead: no shell, no .cmd, nothing to escape.
67
+ */
68
+ function npmCli() {
69
+ // npm sits beside node in the same installation, as lib/node_modules/npm/bin/npm-cli.js.
70
+ const guess = join(dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
71
+ if (existsSync(guess)) return guess;
72
+ const unix = join(dirname(process.execPath), "..", "lib", "node_modules", "npm", "bin", "npm-cli.js");
73
+ return existsSync(unix) ? unix : null;
74
+ }
75
+
59
76
  const run = (cmd, args) => {
60
- try { execFileSync(cmd, args, { cwd: dir, stdio: "inherit" }); return true; }
61
- catch { return false; }
77
+ try {
78
+ if (cmd === "npm") {
79
+ const cli = npmCli();
80
+ if (!cli) return false;
81
+ execFileSync(process.execPath, [cli, ...args], { cwd: dir, stdio: "inherit" });
82
+ } else {
83
+ execFileSync(cmd, args, { cwd: dir, stdio: "inherit" });
84
+ }
85
+ return true;
86
+ } catch { return false; }
62
87
  };
63
88
 
64
89
  console.log(`\nInstalling deck-plugin-sdk…`);
65
- const npm = process.platform === "win32" ? "npm.cmd" : "npm";
90
+ const npm = "npm";
66
91
  const installed = run(npm, ["install", "--save-dev", "deck-plugin-sdk",
67
92
  "react", "lucide-react", "@types/react"]);
68
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-deck-plugin",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "Scaffold a Deck plugin.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -4,5 +4,5 @@
4
4
  "description": "One line on what this is for, shown under its name in Settings.",
5
5
  "icon": "Sparkles",
6
6
  "version": "0.1.0",
7
- "minDeck": "0.15.0"
7
+ "minDeck": "0.16.0"
8
8
  }