qarpeo 0.4.10 → 0.4.12

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.
@@ -9,7 +9,300 @@ import { useRuntimeConfig, defineEventHandler } from 'nuxt/server';
9
9
  import { mkdir, writeFile, readFile } from 'node:fs/promises';
10
10
  import { defu } from 'defu';
11
11
 
12
- const version = "0.4.10";
12
+ const version = "0.4.12";
13
+
14
+ function spawnBinSync(bin, args, options = {}) {
15
+ const isWindows = process.platform === "win32";
16
+ const env = {
17
+ ...process.env,
18
+ ...options.env,
19
+ WRANGLER_HIDE_BANNER: "true"
20
+ };
21
+ if (isWindows && (bin.endsWith(".cmd") || bin.endsWith(".bat"))) {
22
+ const cmd = process.env.ComSpec || "cmd.exe";
23
+ return spawnSync(cmd, ["/d", "/s", "/c", bin, ...args], {
24
+ ...options,
25
+ env,
26
+ shell: false
27
+ });
28
+ }
29
+ return spawnSync(bin, args, { ...options, env, shell: false });
30
+ }
31
+ function isPackageInstalled(packageName, cwd = process.cwd(), options = {}) {
32
+ const localDir = resolve(cwd, "node_modules", packageName);
33
+ const rootDir = resolve(cwd, "../node_modules", packageName);
34
+ if (existsSync(localDir) || existsSync(rootDir)) {
35
+ return true;
36
+ }
37
+ try {
38
+ const req = createRequire(resolve(cwd, "package.json"));
39
+ req.resolve(packageName);
40
+ return true;
41
+ } catch {
42
+ if (options.localOnly) return false;
43
+ try {
44
+ const selfReq = createRequire(import.meta.url);
45
+ selfReq.resolve(packageName);
46
+ return true;
47
+ } catch {
48
+ return false;
49
+ }
50
+ }
51
+ }
52
+ function resolveBinaryPath(binName, cwd = process.cwd()) {
53
+ const isWindows = process.platform === "win32";
54
+ const actualBin = isWindows ? `${binName}.cmd` : binName;
55
+ const localBin = resolve(cwd, "node_modules/.bin", actualBin);
56
+ if (existsSync(localBin)) return localBin;
57
+ const rootBin = resolve(cwd, "../node_modules/.bin", actualBin);
58
+ if (existsSync(rootBin)) return rootBin;
59
+ try {
60
+ let currentDir = dirname(fileURLToPath(import.meta.url));
61
+ while (currentDir !== dirname(currentDir)) {
62
+ const binCandidate = resolve(currentDir, "node_modules/.bin", actualBin);
63
+ if (existsSync(binCandidate)) {
64
+ return binCandidate;
65
+ }
66
+ currentDir = dirname(currentDir);
67
+ }
68
+ } catch {
69
+ }
70
+ return null;
71
+ }
72
+ async function confirmInstall(packageName, purpose) {
73
+ if (!stdin.isTTY || stdin.isRaw || process.env.npm_lifecycle_event === "postinstall") {
74
+ return false;
75
+ }
76
+ const rl = readline.createInterface({ input: stdin, output: stdout });
77
+ try {
78
+ const answer = await rl.question(
79
+ `
80
+ \u{1F4E6} [qarpeo] "${packageName}" is required for ${purpose}.
81
+ Would you like to install it now? (Y/n): `
82
+ );
83
+ return answer.trim().toLowerCase() !== "n";
84
+ } finally {
85
+ rl.close();
86
+ }
87
+ }
88
+ async function formatAddCommand(packageName, options = {}) {
89
+ const cwd = options.cwd || process.cwd();
90
+ try {
91
+ const { detectPackageManager, addDependencyCommand } = await import('nypm');
92
+ const pm = await detectPackageManager(cwd);
93
+ if (pm) {
94
+ return addDependencyCommand(pm.name, packageName, { dev: options.dev });
95
+ }
96
+ } catch {
97
+ }
98
+ return `npm install ${options.dev ? "-D " : ""}${packageName}`;
99
+ }
100
+ async function formatDlxCommand(command, args = [], options = {}) {
101
+ const cwd = options.cwd || process.cwd();
102
+ const fullCmd = args.length > 0 ? `${command} ${args.join(" ")}` : command;
103
+ try {
104
+ const { detectPackageManager, dlxCommand } = await import('nypm');
105
+ const pm = await detectPackageManager(cwd);
106
+ if (pm) {
107
+ return dlxCommand(pm.name, fullCmd);
108
+ }
109
+ } catch {
110
+ }
111
+ return `npx ${fullCmd}`;
112
+ }
113
+ async function ensurePackage(packageName, options = {}) {
114
+ const cwd = options?.cwd || process.cwd();
115
+ const purpose = options?.purpose || "this operation";
116
+ if (isPackageInstalled(packageName, cwd)) {
117
+ return true;
118
+ }
119
+ if (process.env.npm_lifecycle_event === "postinstall") {
120
+ const addCmd = await formatAddCommand(packageName, { cwd, dev: options.dev });
121
+ console.warn(
122
+ `
123
+ \u26A0\uFE0F [qarpeo] Missing optional dependency "${packageName}" for ${purpose}. Run: ${addCmd}`
124
+ );
125
+ return false;
126
+ }
127
+ const confirmed = options.autoInstall ? true : await confirmInstall(packageName, purpose);
128
+ if (!confirmed) {
129
+ const addCmd = await formatAddCommand(packageName, { cwd, dev: options.dev });
130
+ console.error(
131
+ `
132
+ \u274C [qarpeo] Missing dependency: "${packageName}". Please install it manually:
133
+ ${addCmd}
134
+ `
135
+ );
136
+ return false;
137
+ }
138
+ console.log(`
139
+ \u26A1 [qarpeo] Installing ${packageName}...`);
140
+ try {
141
+ const { addDependency } = await import('nypm');
142
+ await addDependency(packageName, {
143
+ cwd,
144
+ dev: options.dev ?? true,
145
+ silent: false
146
+ });
147
+ console.log(`\u2705 [qarpeo] Successfully installed ${packageName}!
148
+ `);
149
+ return true;
150
+ } catch (err) {
151
+ console.error(`\u274C [qarpeo] Failed to install ${packageName}:`, err?.message || err);
152
+ return false;
153
+ }
154
+ }
155
+
156
+ const FEATURE_DEPS = {
157
+ cms: {
158
+ description: "Edge CMS markdown rendering (@comark/vue, comark)",
159
+ dependencies: {
160
+ "@comark/vue": "0.9.1",
161
+ comark: "0.9.1"
162
+ }
163
+ },
164
+ shiki: {
165
+ description: "Syntax highlighting for CMS code blocks (shiki)",
166
+ dependencies: {
167
+ shiki: "4.6.0"
168
+ }
169
+ },
170
+ drizzle: {
171
+ description: "Drizzle ORM, Drizzle Kit, and Drizzle Seed",
172
+ dependencies: {
173
+ "drizzle-orm": "1.0.0-rc.5"
174
+ },
175
+ devDependencies: {
176
+ "drizzle-kit": "1.0.0-rc.5",
177
+ "drizzle-seed": "1.0.0-rc.5"
178
+ }
179
+ },
180
+ auth: {
181
+ description: "Better Auth + Drizzle adapter",
182
+ dependencies: {
183
+ "better-auth": "1.7.20",
184
+ "@better-auth/drizzle-adapter": "1.7.20"
185
+ }
186
+ },
187
+ webauthn: {
188
+ description: "Passkey / WebAuthn server support",
189
+ dependencies: {
190
+ "@simplewebauthn/server": "14.0.3"
191
+ }
192
+ },
193
+ browser: {
194
+ description: "Cloudflare Browser Rendering (@cloudflare/puppeteer)",
195
+ dependencies: {
196
+ "@cloudflare/puppeteer": "1.4.0"
197
+ }
198
+ },
199
+ fate: {
200
+ description: "Normalized data-fetching client (@nkzw/fate, vue-fate)",
201
+ dependencies: {
202
+ "@nkzw/fate": "1.0.0",
203
+ "vue-fate": "1.0.0"
204
+ }
205
+ },
206
+ postgres: {
207
+ description: "PostgreSQL / Hyperdrive driver",
208
+ dependencies: {
209
+ postgres: "4.1.1"
210
+ }
211
+ }
212
+ };
213
+ function getFeatureNames() {
214
+ return Object.keys(FEATURE_DEPS);
215
+ }
216
+ function toVersionedSpecs(pkgMap) {
217
+ if (!pkgMap) return [];
218
+ return Object.entries(pkgMap).map(([name, version]) => `${name}@${version}`);
219
+ }
220
+ function resolveFeatureInstall(target) {
221
+ const key = target.trim().toLowerCase();
222
+ if (key in FEATURE_DEPS) {
223
+ const def = FEATURE_DEPS[key];
224
+ return {
225
+ label: key,
226
+ dependencies: toVersionedSpecs(def.dependencies),
227
+ devDependencies: toVersionedSpecs(def.devDependencies)
228
+ };
229
+ }
230
+ for (const def of Object.values(FEATURE_DEPS)) {
231
+ if (key in def.dependencies) {
232
+ return {
233
+ label: target,
234
+ dependencies: [`${key}@${def.dependencies[key]}`],
235
+ devDependencies: []
236
+ };
237
+ }
238
+ if (def.devDependencies && key in def.devDependencies) {
239
+ return {
240
+ label: target,
241
+ dependencies: [],
242
+ devDependencies: [`${key}@${def.devDependencies[key]}`]
243
+ };
244
+ }
245
+ }
246
+ return null;
247
+ }
248
+ function getEnabledFeatureNames(options) {
249
+ const enabled = [];
250
+ if (options.db || options.d1) enabled.push("drizzle");
251
+ if (options.auth) enabled.push("auth");
252
+ if (options.cms) {
253
+ enabled.push("cms");
254
+ const cmsCfg = typeof options.cms === "object" ? options.cms : {};
255
+ const shikiOpt = cmsCfg.shiki !== void 0 ? cmsCfg.shiki : cmsCfg.plugins?.shiki;
256
+ if (shikiOpt) enabled.push("shiki");
257
+ }
258
+ if (options.fate) enabled.push("fate");
259
+ if (options.browser) enabled.push("browser");
260
+ return enabled;
261
+ }
262
+ async function ensureEnabledFeatures(options, nuxt, logger) {
263
+ if (!nuxt.options.dev) return;
264
+ if (options.autoInstall === false || process.env.npm_lifecycle_event === "postinstall" || process.env.CI || process.env.VITEST || nuxt.options.test) {
265
+ return;
266
+ }
267
+ const rootDir = nuxt.options.rootDir;
268
+ const missingFeatures = [];
269
+ const deps = [];
270
+ const devDeps = [];
271
+ for (const feature of getEnabledFeatureNames(options)) {
272
+ const def = FEATURE_DEPS[feature];
273
+ const requiredPkgs = Object.keys(def.dependencies);
274
+ if (requiredPkgs.some((pkg) => !isPackageInstalled(pkg, rootDir, { localOnly: true }))) {
275
+ missingFeatures.push(feature);
276
+ deps.push(...toVersionedSpecs(def.dependencies));
277
+ devDeps.push(...toVersionedSpecs(def.devDependencies));
278
+ }
279
+ }
280
+ if (missingFeatures.length === 0) return;
281
+ const uniqueDeps = [...new Set(deps)];
282
+ const uniqueDevDeps = [...new Set(devDeps)];
283
+ const allSpecs = [...uniqueDeps, ...uniqueDevDeps];
284
+ const { useTerminal } = await import('@nuxt/kit');
285
+ const terminal = useTerminal();
286
+ const task = terminal.startTask(
287
+ `[qarpeo] Installing pinned dependencies for ${missingFeatures.join(", ")}...`
288
+ );
289
+ try {
290
+ const { addDependency } = await import('nypm');
291
+ if (uniqueDeps.length > 0) {
292
+ await addDependency(uniqueDeps, { cwd: rootDir, dev: false, silent: true });
293
+ }
294
+ if (uniqueDevDeps.length > 0) {
295
+ await addDependency(uniqueDevDeps, { cwd: rootDir, dev: true, silent: true });
296
+ }
297
+ task.stop(`[qarpeo] Installed ${allSpecs.join(", ")}`);
298
+ } catch (err) {
299
+ task.stop(void 0, "failure");
300
+ logger.warn(
301
+ `[qarpeo] Could not auto-install dependencies for ${missingFeatures.join(", ")}: ${err?.message || err}
302
+ Run: qp add ${missingFeatures.join(" ")}`
303
+ );
304
+ }
305
+ }
13
306
 
14
307
  function resolveBindingName(service, override, defaultName) {
15
308
  if (override && typeof override === "string") {
@@ -573,147 +866,6 @@ function findSchemaFiles(layers, targetDb) {
573
866
  return Array.from(files);
574
867
  }
575
868
 
576
- function spawnBinSync(bin, args, options = {}) {
577
- const isWindows = process.platform === "win32";
578
- const env = {
579
- ...process.env,
580
- ...options.env,
581
- WRANGLER_HIDE_BANNER: "true"
582
- };
583
- if (isWindows && (bin.endsWith(".cmd") || bin.endsWith(".bat"))) {
584
- const cmd = process.env.ComSpec || "cmd.exe";
585
- return spawnSync(cmd, ["/d", "/s", "/c", bin, ...args], {
586
- ...options,
587
- env,
588
- shell: false
589
- });
590
- }
591
- return spawnSync(bin, args, { ...options, env, shell: false });
592
- }
593
- function isPackageInstalled(packageName, cwd = process.cwd()) {
594
- const localDir = resolve(cwd, "node_modules", packageName);
595
- const rootDir = resolve(cwd, "../node_modules", packageName);
596
- if (existsSync(localDir) || existsSync(rootDir)) {
597
- return true;
598
- }
599
- try {
600
- const req = createRequire(resolve(cwd, "package.json"));
601
- req.resolve(packageName);
602
- return true;
603
- } catch {
604
- try {
605
- const selfReq = createRequire(import.meta.url);
606
- selfReq.resolve(packageName);
607
- return true;
608
- } catch {
609
- return false;
610
- }
611
- }
612
- }
613
- function resolveBinaryPath(binName, cwd = process.cwd()) {
614
- const isWindows = process.platform === "win32";
615
- const actualBin = isWindows ? `${binName}.cmd` : binName;
616
- const localBin = resolve(cwd, "node_modules/.bin", actualBin);
617
- if (existsSync(localBin)) return localBin;
618
- const rootBin = resolve(cwd, "../node_modules/.bin", actualBin);
619
- if (existsSync(rootBin)) return rootBin;
620
- try {
621
- let currentDir = dirname(fileURLToPath(import.meta.url));
622
- while (currentDir !== dirname(currentDir)) {
623
- const binCandidate = resolve(currentDir, "node_modules/.bin", actualBin);
624
- if (existsSync(binCandidate)) {
625
- return binCandidate;
626
- }
627
- currentDir = dirname(currentDir);
628
- }
629
- } catch {
630
- }
631
- return null;
632
- }
633
- async function confirmInstall(packageName, purpose) {
634
- if (!stdin.isTTY || stdin.isRaw || process.env.npm_lifecycle_event === "postinstall") {
635
- return false;
636
- }
637
- const rl = readline.createInterface({ input: stdin, output: stdout });
638
- try {
639
- const answer = await rl.question(
640
- `
641
- \u{1F4E6} [qarpeo] "${packageName}" is required for ${purpose}.
642
- Would you like to install it now? (Y/n): `
643
- );
644
- return answer.trim().toLowerCase() !== "n";
645
- } finally {
646
- rl.close();
647
- }
648
- }
649
- async function formatAddCommand(packageName, options = {}) {
650
- const cwd = options.cwd || process.cwd();
651
- try {
652
- const { detectPackageManager, addDependencyCommand } = await import('nypm');
653
- const pm = await detectPackageManager(cwd);
654
- if (pm) {
655
- return addDependencyCommand(pm.name, packageName, { dev: options.dev });
656
- }
657
- } catch {
658
- }
659
- return `npm install ${options.dev ? "-D " : ""}${packageName}`;
660
- }
661
- async function formatDlxCommand(command, args = [], options = {}) {
662
- const cwd = options.cwd || process.cwd();
663
- const fullCmd = args.length > 0 ? `${command} ${args.join(" ")}` : command;
664
- try {
665
- const { detectPackageManager, dlxCommand } = await import('nypm');
666
- const pm = await detectPackageManager(cwd);
667
- if (pm) {
668
- return dlxCommand(pm.name, fullCmd);
669
- }
670
- } catch {
671
- }
672
- return `npx ${fullCmd}`;
673
- }
674
- async function ensurePackage(packageName, options = {}) {
675
- const cwd = options?.cwd || process.cwd();
676
- const purpose = options?.purpose || "this operation";
677
- if (isPackageInstalled(packageName, cwd)) {
678
- return true;
679
- }
680
- if (process.env.npm_lifecycle_event === "postinstall") {
681
- const addCmd = await formatAddCommand(packageName, { cwd, dev: options.dev });
682
- console.warn(
683
- `
684
- \u26A0\uFE0F [qarpeo] Missing optional dependency "${packageName}" for ${purpose}. Run: ${addCmd}`
685
- );
686
- return false;
687
- }
688
- const confirmed = options.autoInstall ? true : await confirmInstall(packageName, purpose);
689
- if (!confirmed) {
690
- const addCmd = await formatAddCommand(packageName, { cwd, dev: options.dev });
691
- console.error(
692
- `
693
- \u274C [qarpeo] Missing dependency: "${packageName}". Please install it manually:
694
- ${addCmd}
695
- `
696
- );
697
- return false;
698
- }
699
- console.log(`
700
- \u26A1 [qarpeo] Installing ${packageName}...`);
701
- try {
702
- const { addDependency } = await import('nypm');
703
- await addDependency(packageName, {
704
- cwd,
705
- dev: options.dev ?? true,
706
- silent: false
707
- });
708
- console.log(`\u2705 [qarpeo] Successfully installed ${packageName}!
709
- `);
710
- return true;
711
- } catch (err) {
712
- console.error(`\u274C [qarpeo] Failed to install ${packageName}:`, err?.message || err);
713
- return false;
714
- }
715
- }
716
-
717
869
  function findLocalD1Database(cwd) {
718
870
  const possibleDirs = [
719
871
  resolve(cwd, ".wrangler/state/v3/d1/miniflare-D1DatabaseObject"),
@@ -2729,4 +2881,4 @@ defineEventHandler((event) => {
2729
2881
  );
2730
2882
  });
2731
2883
 
2732
- export { ALL_CMS_TABLE_NAMES as A, buildDevWranglerConfig as B, generateAuthSchema as C, generateCommentsSchema as D, generateStoreSchema as E, findScheduledTasks as F, formatDlxCommand as G, resolveBindingName as H, createWranglerConfig as I, generateDevWranglerConfig as J, applyD1Migrations as K, findQueueFiles as L, findDurableObjectFiles as M, isPackageInstalled as N, getActiveCmsTableNames as O, getActiveCommentsTableNames as P, getActiveStoreTableNames as Q, hasDatabaseSchema as R, localDb as S, authSchema as T, wrangler as U, resolveBinaryPath as a, getActiveAuthTableNames as b, ALL_STORE_TABLE_NAMES as c, ALL_COMMENTS_TABLE_NAMES as d, ensurePackage as e, discoverDatabases as f, getLocalDatabaseContext as g, findLocalD1Database as h, spawnBinSync as i, getJiti as j, resolveProjectName as k, checkDrizzleVersion as l, findSchemaFiles as m, findAgentFiles as n, findToolFiles as o, findBotFiles as p, findMcpFiles as q, resolveDatabaseTarget as r, scanSchemaExports as s, findJobFiles as t, findWorkflowFiles as u, findEmailHandlerFiles as v, buildQarpeoManifest as w, version as x, resolveTableName as y, resolveIndexName as z };
2884
+ export { ALL_CMS_TABLE_NAMES as A, resolveTableName as B, resolveIndexName as C, buildDevWranglerConfig as D, generateAuthSchema as E, FEATURE_DEPS as F, generateCommentsSchema as G, generateStoreSchema as H, findScheduledTasks as I, formatDlxCommand as J, resolveBindingName as K, createWranglerConfig as L, generateDevWranglerConfig as M, applyD1Migrations as N, findQueueFiles as O, findDurableObjectFiles as P, isPackageInstalled as Q, ensureEnabledFeatures as R, getActiveCmsTableNames as S, getActiveCommentsTableNames as T, getActiveStoreTableNames as U, hasDatabaseSchema as V, localDb as W, authSchema as X, wrangler as Y, resolveDatabaseTarget as a, resolveBinaryPath as b, getLocalDatabaseContext as c, getActiveAuthTableNames as d, ensurePackage as e, ALL_STORE_TABLE_NAMES as f, getFeatureNames as g, ALL_COMMENTS_TABLE_NAMES as h, discoverDatabases as i, findLocalD1Database as j, spawnBinSync as k, getJiti as l, resolveProjectName as m, checkDrizzleVersion as n, findSchemaFiles as o, findAgentFiles as p, findToolFiles as q, resolveFeatureInstall as r, scanSchemaExports as s, findBotFiles as t, findMcpFiles as u, findJobFiles as v, findWorkflowFiles as w, findEmailHandlerFiles as x, buildQarpeoManifest as y, version as z };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
- import { r as resolveDatabaseTarget, a as resolveBinaryPath, e as ensurePackage, g as getLocalDatabaseContext, b as getActiveAuthTableNames, A as ALL_CMS_TABLE_NAMES, c as ALL_STORE_TABLE_NAMES, d as ALL_COMMENTS_TABLE_NAMES, s as scanSchemaExports, f as discoverDatabases, h as findLocalD1Database, i as spawnBinSync, j as getJiti, k as resolveProjectName, l as checkDrizzleVersion, m as findSchemaFiles, n as findAgentFiles, o as findToolFiles, p as findBotFiles, q as findMcpFiles, t as findJobFiles, u as findWorkflowFiles, v as findEmailHandlerFiles, w as buildQarpeoManifest, x as version } from '../chunks/manifest.get.mjs';
3
+ import { r as resolveFeatureInstall, g as getFeatureNames, F as FEATURE_DEPS, a as resolveDatabaseTarget, b as resolveBinaryPath, e as ensurePackage, c as getLocalDatabaseContext, d as getActiveAuthTableNames, A as ALL_CMS_TABLE_NAMES, f as ALL_STORE_TABLE_NAMES, h as ALL_COMMENTS_TABLE_NAMES, s as scanSchemaExports, i as discoverDatabases, j as findLocalD1Database, k as spawnBinSync, l as getJiti, m as resolveProjectName, n as checkDrizzleVersion, o as findSchemaFiles, p as findAgentFiles, q as findToolFiles, t as findBotFiles, u as findMcpFiles, v as findJobFiles, w as findWorkflowFiles, x as findEmailHandlerFiles, y as buildQarpeoManifest, z as version } from '../chunks/manifest.get.mjs';
4
4
  import { resolve, join, dirname, relative, basename, extname } from 'pathe';
5
5
  import { spawnSync, spawn } from 'node:child_process';
6
6
  import { existsSync, mkdirSync, writeFileSync, readFileSync, rmSync, readdirSync, statSync } from 'node:fs';
@@ -15,94 +15,6 @@ import 'nuxt/server';
15
15
  import 'node:fs/promises';
16
16
  import 'defu';
17
17
 
18
- const FEATURE_DEPS = {
19
- cms: {
20
- description: "Edge CMS markdown/syntax highlighting (@comark/vue, comark, shiki)",
21
- dependencies: {
22
- "@comark/vue": "0.9.1",
23
- comark: "0.9.1",
24
- shiki: "4.6.0"
25
- }
26
- },
27
- drizzle: {
28
- description: "Drizzle ORM, Drizzle Kit, and Drizzle Seed",
29
- dependencies: {
30
- "drizzle-orm": "1.0.0-rc.5"
31
- },
32
- devDependencies: {
33
- "drizzle-kit": "1.0.0-rc.5",
34
- "drizzle-seed": "1.0.0-rc.5"
35
- }
36
- },
37
- auth: {
38
- description: "Better Auth + Drizzle adapter",
39
- dependencies: {
40
- "better-auth": "1.7.20",
41
- "@better-auth/drizzle-adapter": "1.7.20"
42
- }
43
- },
44
- webauthn: {
45
- description: "Passkey / WebAuthn server support",
46
- dependencies: {
47
- "@simplewebauthn/server": "14.0.3"
48
- }
49
- },
50
- browser: {
51
- description: "Cloudflare Browser Rendering (@cloudflare/puppeteer)",
52
- dependencies: {
53
- "@cloudflare/puppeteer": "1.4.0"
54
- }
55
- },
56
- fate: {
57
- description: "Normalized data-fetching client (@nkzw/fate, vue-fate)",
58
- dependencies: {
59
- "@nkzw/fate": "1.0.0",
60
- "vue-fate": "1.0.0"
61
- }
62
- },
63
- postgres: {
64
- description: "PostgreSQL / Hyperdrive driver",
65
- dependencies: {
66
- postgres: "4.1.1"
67
- }
68
- }
69
- };
70
- function getFeatureNames() {
71
- return Object.keys(FEATURE_DEPS);
72
- }
73
- function toVersionedSpecs(pkgMap) {
74
- if (!pkgMap) return [];
75
- return Object.entries(pkgMap).map(([name, version]) => `${name}@${version}`);
76
- }
77
- function resolveFeatureInstall(target) {
78
- const key = target.trim().toLowerCase();
79
- if (key in FEATURE_DEPS) {
80
- const def = FEATURE_DEPS[key];
81
- return {
82
- label: key,
83
- dependencies: toVersionedSpecs(def.dependencies),
84
- devDependencies: toVersionedSpecs(def.devDependencies)
85
- };
86
- }
87
- for (const def of Object.values(FEATURE_DEPS)) {
88
- if (key in def.dependencies) {
89
- return {
90
- label: target,
91
- dependencies: [`${key}@${def.dependencies[key]}`],
92
- devDependencies: []
93
- };
94
- }
95
- if (def.devDependencies && key in def.devDependencies) {
96
- return {
97
- label: target,
98
- dependencies: [],
99
- devDependencies: [`${key}@${def.devDependencies[key]}`]
100
- };
101
- }
102
- }
103
- return null;
104
- }
105
-
106
18
  function printAvailableFeatures() {
107
19
  console.log("\n\u{1F4E6} Available qarpeo features:\n");
108
20
  for (const name of getFeatureNames()) {
@@ -1488,7 +1400,7 @@ const migrate = defineCommand({
1488
1400
  } else if (existsSync(resolve(cwd, ".nuxt/wrangler.json"))) {
1489
1401
  wranglerConfigPath = resolve(cwd, ".nuxt/wrangler.json");
1490
1402
  } else {
1491
- const { generateDevWranglerConfig } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.U; });
1403
+ const { generateDevWranglerConfig } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.Y; });
1492
1404
  const buildDir = resolve(cwd, ".nuxt");
1493
1405
  wranglerConfigPath = await generateDevWranglerConfig(
1494
1406
  {
@@ -1760,8 +1672,8 @@ const migrate = defineCommand({
1760
1672
  if (args.prune && targets.some((t) => t.isPrimary)) {
1761
1673
  const primaryTarget = targets.find((t) => t.isPrimary);
1762
1674
  const primaryBinding = primaryTarget.binding;
1763
- const { getActiveAuthTableNames, ALL_AUTH_TABLE_NAMES } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.T; });
1764
- const { findLocalD1Database } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.S; });
1675
+ const { getActiveAuthTableNames, ALL_AUTH_TABLE_NAMES } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.X; });
1676
+ const { findLocalD1Database } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.W; });
1765
1677
  const authConfig = nuxtConfig.qarpeo?.auth || nuxtConfig.auth;
1766
1678
  const activeTables = getActiveAuthTableNames(authConfig);
1767
1679
  const unusedTables = ALL_AUTH_TABLE_NAMES.filter(
@@ -2633,7 +2545,7 @@ const deploy = defineCommand({
2633
2545
  if (!wranglerConfigPath) {
2634
2546
  try {
2635
2547
  const { loadNuxtConfig } = await import('@nuxt/kit');
2636
- const { generateDevWranglerConfig } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.U; });
2548
+ const { generateDevWranglerConfig } = await import('../chunks/manifest.get.mjs').then(function (n) { return n.Y; });
2637
2549
  const nuxtConfig = await loadNuxtConfig({ cwd });
2638
2550
  const qarpeoOpts = nuxtConfig.qarpeo || {};
2639
2551
  const buildDir = resolve(cwd, ".nuxt");
package/dist/module.mjs CHANGED
@@ -2,8 +2,8 @@ import { existsSync, rmSync, readdirSync, readFileSync, appendFileSync } from 'n
2
2
  import { dirname, resolve, normalize, relative, join } from 'pathe';
3
3
  import { addTemplate, hasNuxtModule, addNitroPlugin, addServerImports, addImports, addTypeTemplate, updateTemplates, addServerImportsDir, addServerHandler, extendPages, addPlugin, addComponent, addImportsDir, addRouteMiddleware, installModule, defineNuxtModule, useLogger, createResolver } from '@nuxt/kit';
4
4
  import { defu } from 'defu';
5
- import { y as resolveTableName, z as resolveIndexName, B as buildDevWranglerConfig, l as checkDrizzleVersion, C as generateAuthSchema, D as generateCommentsSchema, E as generateStoreSchema, s as scanSchemaExports, f as discoverDatabases, F as findScheduledTasks, G as formatDlxCommand, H as resolveBindingName, I as createWranglerConfig, J as generateDevWranglerConfig, K as applyD1Migrations, x as version, L as findQueueFiles, t as findJobFiles, v as findEmailHandlerFiles, M as findDurableObjectFiles, u as findWorkflowFiles, e as ensurePackage, N as isPackageInstalled, n as findAgentFiles, o as findToolFiles, p as findBotFiles, q as findMcpFiles, m as findSchemaFiles, w as buildQarpeoManifest } from './chunks/manifest.get.mjs';
6
- export { A as ALL_CMS_TABLE_NAMES, d as ALL_COMMENTS_TABLE_NAMES, c as ALL_STORE_TABLE_NAMES, b as getActiveAuthTableNames, O as getActiveCmsTableNames, P as getActiveCommentsTableNames, Q as getActiveStoreTableNames, R as hasDatabaseSchema, r as resolveDatabaseTarget, k as resolveProjectName } from './chunks/manifest.get.mjs';
5
+ import { B as resolveTableName, C as resolveIndexName, D as buildDevWranglerConfig, n as checkDrizzleVersion, E as generateAuthSchema, G as generateCommentsSchema, H as generateStoreSchema, s as scanSchemaExports, i as discoverDatabases, I as findScheduledTasks, J as formatDlxCommand, K as resolveBindingName, L as createWranglerConfig, M as generateDevWranglerConfig, N as applyD1Migrations, z as version, O as findQueueFiles, v as findJobFiles, x as findEmailHandlerFiles, P as findDurableObjectFiles, w as findWorkflowFiles, e as ensurePackage, Q as isPackageInstalled, p as findAgentFiles, q as findToolFiles, t as findBotFiles, u as findMcpFiles, o as findSchemaFiles, R as ensureEnabledFeatures, y as buildQarpeoManifest } from './chunks/manifest.get.mjs';
6
+ export { A as ALL_CMS_TABLE_NAMES, h as ALL_COMMENTS_TABLE_NAMES, f as ALL_STORE_TABLE_NAMES, d as getActiveAuthTableNames, S as getActiveCmsTableNames, T as getActiveCommentsTableNames, U as getActiveStoreTableNames, V as hasDatabaseSchema, a as resolveDatabaseTarget, m as resolveProjectName } from './chunks/manifest.get.mjs';
7
7
  import { createHash } from 'node:crypto';
8
8
  import { readdir, readFile } from 'node:fs/promises';
9
9
  import { createRequire } from 'node:module';
@@ -1308,6 +1308,10 @@ async function setupSchema(options, nuxt, resolver, logger) {
1308
1308
  if (isDrizzle) {
1309
1309
  const drizzleCheck = checkDrizzleVersion(nuxt.options.rootDir);
1310
1310
  if (!drizzleCheck.isRC) {
1311
+ if (process.env.npm_lifecycle_event === "postinstall" || nuxt.options._prepare && options.autoInstall !== false) {
1312
+ logger.warn(drizzleCheck.error);
1313
+ return;
1314
+ }
1311
1315
  throw new Error(drizzleCheck.error);
1312
1316
  }
1313
1317
  const tableResolveOpts = {
@@ -5414,22 +5418,29 @@ async function setupConsole(options, nuxt, resolver, logger) {
5414
5418
  });
5415
5419
  }
5416
5420
 
5421
+ function resolveShikiConfig(cmsConfig) {
5422
+ const shikiOpt = cmsConfig.shiki !== void 0 ? cmsConfig.shiki : cmsConfig.plugins?.shiki;
5423
+ if (!shikiOpt) return false;
5424
+ return typeof shikiOpt === "object" ? shikiOpt : true;
5425
+ }
5417
5426
  async function setupCMS(options, nuxt, resolver, logger) {
5418
5427
  if (options.cms) {
5419
5428
  const cmsOptions = typeof options.cms === "object" ? options.cms : {};
5420
- const pluginConfig = cmsOptions.plugins || {};
5421
- const shikiOption = cmsOptions.shiki !== void 0 ? cmsOptions.shiki : pluginConfig.shiki;
5422
- const shikiEnabled = shikiOption !== false;
5423
- const missing = [];
5424
- if (!isPackageInstalled("@comark/vue", nuxt.options.rootDir)) missing.push("@comark/vue");
5425
- if (!isPackageInstalled("comark", nuxt.options.rootDir)) missing.push("comark");
5426
- if (shikiEnabled && !isPackageInstalled("shiki", nuxt.options.rootDir)) missing.push("shiki");
5427
- if (missing.length > 0) {
5429
+ const shikiEnabled = Boolean(resolveShikiConfig(cmsOptions));
5430
+ const missingCms = [];
5431
+ if (!isPackageInstalled("@comark/vue", nuxt.options.rootDir)) missingCms.push("@comark/vue");
5432
+ if (!isPackageInstalled("comark", nuxt.options.rootDir)) missingCms.push("comark");
5433
+ const missingShiki = shikiEnabled && !isPackageInstalled("shiki", nuxt.options.rootDir);
5434
+ if (missingCms.length > 0 || missingShiki) {
5435
+ const commands = [];
5436
+ if (missingCms.length > 0) commands.push("qp add cms");
5437
+ if (missingShiki) commands.push("qp add shiki");
5438
+ const missingAll = [...missingCms, ...missingShiki ? ["shiki"] : []];
5428
5439
  logger.error(
5429
5440
  `[qarpeo] CMS is enabled but the following required packages are not installed:
5430
- ${missing.map((p) => `"${p}"`).join(", ")}
5441
+ ${missingAll.map((p) => `"${p}"`).join(", ")}
5431
5442
 
5432
- Run: qp add cms
5443
+ Run: ${commands.join(" && ")}
5433
5444
  `
5434
5445
  );
5435
5446
  return;
@@ -5459,13 +5470,11 @@ async function setupCMS(options, nuxt, resolver, logger) {
5459
5470
  if (options.cms) {
5460
5471
  const cmsOptions = typeof options.cms === "object" ? options.cms : {};
5461
5472
  const pluginConfig = cmsOptions.plugins || {};
5462
- const shikiOption = cmsOptions.shiki !== void 0 ? cmsOptions.shiki : pluginConfig.shiki;
5463
- const shikiEnabled = shikiOption !== false;
5464
5473
  const publicConfig = nuxt.options.runtimeConfig.public = nuxt.options.runtimeConfig.public || {};
5465
5474
  publicConfig.qarpeo = publicConfig.qarpeo || {};
5466
5475
  publicConfig.qarpeo.cms = {
5467
5476
  plugins: {
5468
- shiki: shikiEnabled ? typeof shikiOption === "object" ? shikiOption : true : false,
5477
+ shiki: resolveShikiConfig(cmsOptions),
5469
5478
  math: pluginConfig.math === true,
5470
5479
  mermaid: pluginConfig.mermaid === true
5471
5480
  }
@@ -5585,13 +5594,12 @@ async function setupCMS(options, nuxt, resolver, logger) {
5585
5594
  write: true,
5586
5595
  async getContents() {
5587
5596
  try {
5588
- const shikiOpt = cmsConfig.shiki !== void 0 ? cmsConfig.shiki : cmsConfig.plugins?.shiki;
5589
5597
  const entries = await scanContentEntries({
5590
5598
  contentDir: resolvedContentDir,
5591
5599
  collectionsConfig: cmsConfig.collections,
5592
5600
  sources: resolvedSources,
5593
5601
  exclude: cmsConfig.exclude,
5594
- shiki: shikiOpt !== false ? typeof shikiOpt === "object" ? shikiOpt : true : false
5602
+ shiki: resolveShikiConfig(cmsConfig)
5595
5603
  });
5596
5604
  const payload = JSON.stringify({
5597
5605
  entries,
@@ -5619,13 +5627,12 @@ export const manifestCollections = ${JSON.stringify(cmsConfig.collections || {})
5619
5627
  const prerenderPatterns = Object.entries(routeRules).filter(([, rule]) => rule?.prerender === true).map(([pattern]) => pattern);
5620
5628
  if (prerenderPatterns.length > 0) {
5621
5629
  try {
5622
- const shikiOpt = cmsConfig.shiki !== void 0 ? cmsConfig.shiki : cmsConfig.plugins?.shiki;
5623
5630
  const entries = await scanContentEntries({
5624
5631
  contentDir: resolvedContentDir,
5625
5632
  collectionsConfig: cmsConfig.collections,
5626
5633
  sources: resolvedSources,
5627
5634
  exclude: cmsConfig.exclude,
5628
- shiki: shikiOpt !== false ? typeof shikiOpt === "object" ? shikiOpt : true : false
5635
+ shiki: resolveShikiConfig(cmsConfig)
5629
5636
  });
5630
5637
  const matchingRoutes = entries.map((e) => e.path).filter((p) => Boolean(p) && matchPathPatterns(p, prerenderPatterns));
5631
5638
  if (matchingRoutes.length > 0) {
@@ -6868,6 +6875,7 @@ ${extraSources}
6868
6875
  if (options.store) {
6869
6876
  if (options.db !== false) options.db = true;
6870
6877
  }
6878
+ await ensureEnabledFeatures(options, nuxt, logger);
6871
6879
  await setupAliases(options, nuxt, resolver);
6872
6880
  addComponent({
6873
6881
  name: "QWelcome",
@@ -6880,7 +6888,7 @@ ${extraSources}
6880
6888
  return;
6881
6889
  }
6882
6890
  await setupWrangler(options, nuxt, resolver, logger);
6883
- await setupSchema(options, nuxt, resolver);
6891
+ await setupSchema(options, nuxt, resolver, logger);
6884
6892
  await setupNitro(options, nuxt, resolver);
6885
6893
  await setupD1Migrate(options, nuxt);
6886
6894
  await setupServerUtils(options, nuxt, resolver);
@@ -42,6 +42,13 @@ export interface FateOptions {
42
42
  auth?: boolean;
43
43
  }
44
44
  export interface QarpeoOptions {
45
+ /**
46
+ * Automatically install missing pinned feature dependencies in `nuxt dev`.
47
+ * Set to `false` to disable dev-time auto-installation and install manually via `qp add <feature>`.
48
+ *
49
+ * @default true
50
+ */
51
+ autoInstall?: boolean;
45
52
  /**
46
53
  * Database table prefix for Qarpeo-managed tables (comments, payments, notifications, CMS, multi-tenancy, audit logs).
47
54
  * - `false` or `""` (default): clean singular table names (`comment`, `customer`, `subscription`, `cms_entry`, `audit_log`)
@@ -1,3 +1,6 @@
1
+ import type { Nuxt } from "@nuxt/schema";
2
+ import type { useLogger } from "@nuxt/kit";
3
+ import type { QarpeoOptions } from "../types";
1
4
  export interface FeatureDefinition {
2
5
  description: string;
3
6
  dependencies: Record<string, string>;
@@ -9,10 +12,15 @@ export interface FeatureDefinition {
9
12
  */
10
13
  export declare const FEATURE_DEPS: {
11
14
  readonly cms: {
12
- readonly description: "Edge CMS markdown/syntax highlighting (@comark/vue, comark, shiki)";
15
+ readonly description: "Edge CMS markdown rendering (@comark/vue, comark)";
13
16
  readonly dependencies: {
14
17
  readonly "@comark/vue": "0.9.1";
15
18
  readonly comark: "0.9.1";
19
+ };
20
+ };
21
+ readonly shiki: {
22
+ readonly description: "Syntax highlighting for CMS code blocks (shiki)";
23
+ readonly dependencies: {
16
24
  readonly shiki: "4.6.0";
17
25
  };
18
26
  };
@@ -72,3 +80,8 @@ export declare function getFeatureNames(): FeatureName[];
72
80
  * into exact `pkg@version` install specs. Returns `null` if unknown.
73
81
  */
74
82
  export declare function resolveFeatureInstall(target: string): ResolvedInstallSpecs | null;
83
+ /**
84
+ * Dev-only safety net: installs missing pinned dependencies for enabled features using
85
+ * `@nuxt/kit`'s `useTerminal()` and `nypm`, skipping CI, tests, and `postinstall`.
86
+ */
87
+ export declare function ensureEnabledFeatures(options: QarpeoOptions, nuxt: Nuxt, logger: ReturnType<typeof useLogger>): Promise<void>;
@@ -5,8 +5,10 @@ import { type SpawnSyncOptions, type SpawnSyncReturns } from "node:child_process
5
5
  * so they can still run without a shell.
6
6
  */
7
7
  export declare function spawnBinSync(bin: string, args: string[], options?: Omit<SpawnSyncOptions, "shell">): SpawnSyncReturns<any>;
8
- /** Checks if a package is installed in the target project directory or bundled by qarpeo. */
9
- export declare function isPackageInstalled(packageName: string, cwd?: string): boolean;
8
+ /** Checks if a package is installed in the target project directory (or optionally bundled by qarpeo). */
9
+ export declare function isPackageInstalled(packageName: string, cwd?: string, options?: {
10
+ localOnly?: boolean;
11
+ }): boolean;
10
12
  /** Checks if a binary exists in node_modules/.bin (in cwd, parent, or qarpeo tree). */
11
13
  export declare function resolveBinaryPath(binName: string, cwd?: string): string | null;
12
14
  /** Prompts the user interactively in the terminal to confirm package installation. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qarpeo",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "Zero-config Cloudflare Edge Platform for Nuxt",
5
5
  "keywords": [
6
6
  "analytics-engine",