create-zenbu-app 0.0.18 → 0.0.20

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/dist/index.mjs CHANGED
@@ -138,6 +138,51 @@ function probeVersion(pm) {
138
138
  const match = (res.stdout ?? "").trim().match(/\d+\.\d+\.\d+(?:[-+][\w.]+)?/);
139
139
  return match ? match[0] : null;
140
140
  }
141
+ /**
142
+ * `npx`, `npm create`, and `npm exec` all set the same `npm/<version>`
143
+ * user agent, so when `detectPackageManager` reports `npm` the user may
144
+ * actually prefer a different installed pm. Probe all four candidates,
145
+ * present only the ones present on the machine, and let the user pick
146
+ * (or pick automatically when only one is installed / `--yes`).
147
+ */
148
+ async function resolveNpmAmbiguity(detected, opts) {
149
+ const candidates = [
150
+ "pnpm",
151
+ "npm",
152
+ "yarn",
153
+ "bun"
154
+ ];
155
+ const installed = [];
156
+ for (const c of candidates) {
157
+ if (c === "npm") {
158
+ installed.push({
159
+ type: "npm",
160
+ version: detected.version,
161
+ fallback: false
162
+ });
163
+ continue;
164
+ }
165
+ const v = probeVersion(c);
166
+ if (v) installed.push({
167
+ type: c,
168
+ version: v,
169
+ fallback: false
170
+ });
171
+ }
172
+ if (installed.length === 1) return installed[0];
173
+ const preferPnpm = installed.find((p) => p.type === "pnpm");
174
+ if (opts.yes) return preferPnpm ?? installed.find((p) => p.type === "npm");
175
+ const pick = await p.select({
176
+ message: "Which package manager should this app use?",
177
+ initialValue: preferPnpm?.type ?? "npm",
178
+ options: installed.map((p) => ({
179
+ value: p.type,
180
+ label: p.type === "pnpm" ? "pnpm (recommended)" : p.type
181
+ }))
182
+ });
183
+ if (p.isCancel(pick)) bail("Scaffolding cancelled.");
184
+ return installed.find((p) => p.type === pick);
185
+ }
141
186
  function renderTemplate(value, ctx) {
142
187
  return value.replace(/\{\{(\w+)\}\}/g, (full, key) => {
143
188
  return Object.prototype.hasOwnProperty.call(ctx, key) ? ctx[key] : full;
@@ -407,7 +452,8 @@ async function main() {
407
452
  templateDir = path.join(TEMPLATES_DIR, slug);
408
453
  }
409
454
  if (!fs.existsSync(templateDir)) bail(`No template found for configuration "${slug}".`);
410
- const pm = detectPackageManager();
455
+ let pm = detectPackageManager();
456
+ if (pm.type === "npm") pm = await resolveNpmAmbiguity(pm, { yes });
411
457
  p.log.step(`Scaffolding Zenbu ${pluginMode ? "plugin" : "app"} in "${displayName}" (template: ${slug})`);
412
458
  const ctx = pluginMode ? {
413
459
  projectName: displayName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-zenbu-app",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Scaffold a new Zenbu app",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -18,7 +18,7 @@ function Home() {
18
18
 
19
19
  return (
20
20
  <main className="flex-1 px-8 pt-6 pb-8 font-sans text-[#e5e5e5]">
21
- <h1 className="text-2xl font-bold mb-2">Welcome to Zenbu</h1>
21
+ <h1 className="text-2xl font-bold mb-2">Welcome to Zenbu.js</h1>
22
22
  <p className="text-[#888] mb-6">
23
23
  Edit <code>src/renderer/App.tsx</code> to get started.
24
24
  </p>
@@ -18,7 +18,7 @@ function Home() {
18
18
 
19
19
  return (
20
20
  <main className="home">
21
- <h1>Welcome to Zenbu</h1>
21
+ <h1>Welcome to Zenbu.js</h1>
22
22
  <p className="lede">
23
23
  Edit <code>src/renderer/App.tsx</code> to get started.
24
24
  </p>