qarpeo 0.1.20 → 0.1.22

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,7 @@ import { fileURLToPath } from 'node:url';
9
9
  import { mkdir, writeFile, readFile } from 'node:fs/promises';
10
10
  import { defu } from 'defu';
11
11
 
12
- const version = "0.1.19";
12
+ const version = "0.1.22";
13
13
 
14
14
  function scanSchemaExports(schemaFiles) {
15
15
  const types = [];
@@ -1256,70 +1256,6 @@ function getGitBranch(cwd) {
1256
1256
  }
1257
1257
  return null;
1258
1258
  }
1259
- async function resolveWorkerName(defaultName, args, cwd) {
1260
- if (args.name) return args.name;
1261
- if (process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME) {
1262
- return process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME;
1263
- }
1264
- if (!stdin.isTTY || args.yes) {
1265
- return defaultName || "qarpeo";
1266
- }
1267
- const rl = readline.createInterface({ input: stdin, output: stdout });
1268
- try {
1269
- if (defaultName) {
1270
- const answer = await rl.question(
1271
- `
1272
- \u{1F3F7}\uFE0F Target Worker: \x1B[1m\x1B[36m${defaultName}\x1B[0m
1273
- Deploy with this name? [Y/n] (Press Enter to confirm, 'n' to change): `
1274
- );
1275
- const trimmed = answer.trim();
1276
- if (!trimmed || trimmed.toLowerCase() === "y" || trimmed.toLowerCase() === "yes") {
1277
- return defaultName;
1278
- }
1279
- if (trimmed.toLowerCase() !== "n" && trimmed.toLowerCase() !== "no" && trimmed.toLowerCase() !== "list") {
1280
- return trimmed;
1281
- }
1282
- }
1283
- console.log("\n\u{1F50D} [qarpeo] Fetching existing Cloudflare Workers...");
1284
- let remoteWorkers = [];
1285
- try {
1286
- const auth = await getCloudflareAuth(cwd);
1287
- if (auth) {
1288
- const list = await listCloudflareWorkers(auth);
1289
- remoteWorkers = list.map((w) => w.id);
1290
- }
1291
- } catch {
1292
- }
1293
- if (remoteWorkers.length > 0) {
1294
- console.log("\n\u{1F4CB} Existing Cloudflare Workers:");
1295
- remoteWorkers.forEach((w, i) => {
1296
- const isCurrent = w === defaultName ? " \x1B[32m(current)\x1B[0m" : "";
1297
- console.log(` ${i + 1}) ${w}${isCurrent}`);
1298
- });
1299
- console.log(` ${remoteWorkers.length + 1}) [Enter a new name]`);
1300
- const choice = await rl.question(
1301
- `
1302
- Select a worker [1-${remoteWorkers.length + 1}] or type a name: `
1303
- );
1304
- const choiceTrimmed = choice.trim();
1305
- const num = parseInt(choiceTrimmed, 10);
1306
- if (!isNaN(num) && num >= 1 && num <= remoteWorkers.length) {
1307
- return remoteWorkers[num - 1];
1308
- }
1309
- if (num === remoteWorkers.length + 1 || !choiceTrimmed) {
1310
- const newName = await rl.question("\u{1F3F7}\uFE0F New Worker Name: ");
1311
- return newName.trim() || defaultName || "qarpeo";
1312
- }
1313
- return choiceTrimmed;
1314
- }
1315
- const fallbackAnswer = await rl.question(
1316
- `\u{1F3F7}\uFE0F Cloudflare Worker Name [${defaultName || "qarpeo"}]: `
1317
- );
1318
- return fallbackAnswer.trim() || defaultName || "qarpeo";
1319
- } finally {
1320
- rl.close();
1321
- }
1322
- }
1323
1259
  function sanitizeSuffix(raw) {
1324
1260
  const clean = raw.toLowerCase().replace(/[^a-z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
1325
1261
  return clean.slice(0, 20) || "preview";
@@ -1493,14 +1429,7 @@ const deploy = defineCommand({
1493
1429
  } catch {
1494
1430
  }
1495
1431
  const defaultName = config.name || "qarpeo";
1496
- let baseWorkerName = args.name || process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME;
1497
- if (!baseWorkerName) {
1498
- if (!args.dryRun) {
1499
- baseWorkerName = await resolveWorkerName(defaultName, args, cwd);
1500
- } else {
1501
- baseWorkerName = defaultName;
1502
- }
1503
- }
1432
+ const baseWorkerName = args.name || process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME || defaultName;
1504
1433
  const originalName = baseWorkerName;
1505
1434
  if (isPreview) {
1506
1435
  config.name = `${baseWorkerName}-${previewSuffix}`;
@@ -2371,6 +2300,13 @@ const AVAILABLE_FEATURES = [
2371
2300
  binding: "DB",
2372
2301
  desc: "Complete auth schemas, sessions & OAuth",
2373
2302
  default: true
2303
+ },
2304
+ {
2305
+ key: "cms",
2306
+ name: "Edge CMS",
2307
+ binding: "DB",
2308
+ desc: "Hybrid Git markdown + edge content management",
2309
+ default: false
2374
2310
  }
2375
2311
  ];
2376
2312
  function getWranglerBin$2(cwd) {
@@ -2395,6 +2331,12 @@ const init = defineCommand({
2395
2331
  description: "Initialize Qarpeo in your project with interactive resource setup (.env, wrangler.json, nuxt.config)"
2396
2332
  },
2397
2333
  args: {
2334
+ dir: {
2335
+ type: "positional",
2336
+ description: "Project directory to initialize (e.g. docs, playground)",
2337
+ required: false,
2338
+ default: "."
2339
+ },
2398
2340
  cwd: {
2399
2341
  type: "string",
2400
2342
  description: "Working directory",
@@ -2413,7 +2355,8 @@ const init = defineCommand({
2413
2355
  }
2414
2356
  },
2415
2357
  async run({ args }) {
2416
- const cwd = resolve(process.cwd(), args.cwd);
2358
+ const targetDir = args.dir && args.dir !== "." ? args.dir : args.cwd;
2359
+ const cwd = resolve(process.cwd(), targetDir);
2417
2360
  console.log("\n\u{1F680} \x1B[1m\x1B[36mQarpeo Edge Platform Initialization\x1B[0m");
2418
2361
  console.log(" Configuring Cloudflare edge primitives for your Nuxt application...\n");
2419
2362
  const pkgPath = join(cwd, "package.json");
@@ -2437,24 +2380,90 @@ const init = defineCommand({
2437
2380
  projectName = nameAnswer.trim().toLowerCase().replace(/[^a-z0-9_-]/g, "-");
2438
2381
  }
2439
2382
  }
2440
- const selectedFeatures = {};
2383
+ const detectedFeatures = {};
2384
+ const nuxtConfigCandidates = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"];
2385
+ let nuxtConfigRaw = "";
2386
+ for (const file of nuxtConfigCandidates) {
2387
+ const candidate = join(cwd, file);
2388
+ if (existsSync(candidate)) {
2389
+ try {
2390
+ nuxtConfigRaw = readFileSync(candidate, "utf8");
2391
+ break;
2392
+ } catch {
2393
+ }
2394
+ }
2395
+ }
2396
+ let wranglerRaw = "";
2397
+ for (const file of ["wrangler.json", "wrangler.jsonc", ".output/server/wrangler.json"]) {
2398
+ const candidate = join(cwd, file);
2399
+ if (existsSync(candidate)) {
2400
+ try {
2401
+ wranglerRaw = readFileSync(candidate, "utf8");
2402
+ break;
2403
+ } catch {
2404
+ }
2405
+ }
2406
+ }
2407
+ if (existsSync(join(cwd, "server/db")) || existsSync(join(cwd, "server/database")) || existsSync(join(cwd, "migrations")) || /db:\s*true|d1:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("d1_databases")) {
2408
+ detectedFeatures.db = true;
2409
+ }
2410
+ if (existsSync(join(cwd, "server/api/storage")) || existsSync(join(cwd, "server/api/blob")) || existsSync(join(cwd, "server/api/upload")) || /blob:\s*true|r2:\s*true|storage:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("r2_buckets")) {
2411
+ detectedFeatures.blob = true;
2412
+ }
2413
+ if (/kv:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("kv_namespaces")) {
2414
+ detectedFeatures.kv = true;
2415
+ }
2416
+ if (existsSync(join(cwd, "server/realtime")) || existsSync(join(cwd, "server/durable-objects")) || /realtime:\s*true|durableObjects:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("durable_objects")) {
2417
+ detectedFeatures.realtime = true;
2418
+ }
2419
+ if (/ai:\s*true|vectorize:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("vectorize")) {
2420
+ detectedFeatures.ai = true;
2421
+ }
2422
+ if (/queue:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("queues")) {
2423
+ detectedFeatures.queue = true;
2424
+ }
2425
+ if (existsSync(join(cwd, "server/auth")) || /auth:\s*true/i.test(nuxtConfigRaw) || /better-auth/i.test(nuxtConfigRaw)) {
2426
+ detectedFeatures.auth = true;
2427
+ }
2428
+ if (/cms:\s*true|cms:\s*\{/i.test(nuxtConfigRaw) || existsSync(join(cwd, "content"))) {
2429
+ detectedFeatures.cms = true;
2430
+ }
2431
+ const selectedFeatures = { ...detectedFeatures };
2432
+ const detectedKeys = Object.keys(detectedFeatures).filter((k) => detectedFeatures[k]);
2433
+ if (detectedKeys.length > 0) {
2434
+ console.log(`
2435
+ \u2714 \x1B[32mAuto-detected active features in project:\x1B[0m`);
2436
+ for (const k of detectedKeys) {
2437
+ const feat = AVAILABLE_FEATURES.find((f) => f.key === k);
2438
+ console.log(` \u2022 ${feat?.name || k}`);
2439
+ }
2440
+ }
2441
2441
  if (rl) {
2442
- console.log("\n\u{1F4E6} \x1B[1mSelect Cloudflare Edge Services to Enable:\x1B[0m");
2443
- for (const feat of AVAILABLE_FEATURES) {
2444
- const defaultHint = feat.default ? "Y/n" : "y/N";
2445
- const answer = await rl.question(
2446
- ` \u2022 Enable ${feat.name} (${feat.desc})? [${defaultHint}]: `
2447
- );
2448
- const trimmed = answer.trim().toLowerCase();
2449
- if (trimmed === "") {
2450
- selectedFeatures[feat.key] = feat.default;
2451
- } else {
2452
- selectedFeatures[feat.key] = trimmed === "y" || trimmed === "yes";
2442
+ const undetectedFeatures = AVAILABLE_FEATURES.filter((f) => !detectedFeatures[f.key]);
2443
+ if (undetectedFeatures.length > 0 && detectedKeys.length === 0) {
2444
+ console.log("\n\u{1F4E6} \x1B[1mSelect Cloudflare Edge Services to Enable:\x1B[0m");
2445
+ for (const feat of undetectedFeatures) {
2446
+ const defaultHint = feat.default ? "Y/n" : "y/N";
2447
+ const answer = await rl.question(
2448
+ ` \u2022 Enable ${feat.name} (${feat.desc})? [${defaultHint}]: `
2449
+ );
2450
+ const trimmed = answer.trim().toLowerCase();
2451
+ if (trimmed === "") {
2452
+ selectedFeatures[feat.key] = feat.default;
2453
+ } else {
2454
+ selectedFeatures[feat.key] = trimmed === "y" || trimmed === "yes";
2455
+ }
2456
+ }
2457
+ } else {
2458
+ for (const feat of undetectedFeatures) {
2459
+ selectedFeatures[feat.key] = false;
2453
2460
  }
2454
2461
  }
2455
2462
  } else {
2456
2463
  for (const feat of AVAILABLE_FEATURES) {
2457
- selectedFeatures[feat.key] = feat.default;
2464
+ if (selectedFeatures[feat.key] === void 0) {
2465
+ selectedFeatures[feat.key] = feat.default;
2466
+ }
2458
2467
  }
2459
2468
  }
2460
2469
  let shouldProvisionRemote = Boolean(args.remote);
@@ -2517,6 +2526,31 @@ const init = defineCommand({
2517
2526
  if (rl) {
2518
2527
  rl.close();
2519
2528
  }
2529
+ const wranglerPath = join(cwd, "wrangler.json");
2530
+ let existingConfig = {};
2531
+ if (existsSync(wranglerPath)) {
2532
+ try {
2533
+ existingConfig = JSON.parse(readFileSync(wranglerPath, "utf8"));
2534
+ } catch {
2535
+ }
2536
+ }
2537
+ const envPath = join(cwd, ".env");
2538
+ let envContent = existsSync(envPath) ? readFileSync(envPath, "utf8") : "";
2539
+ const getEnvVal = (key) => {
2540
+ const match = envContent.match(new RegExp(`^${key}=(.*)$`, "m"));
2541
+ return match ? match[1].trim().replace(/^['"]|['"]$/g, "") : null;
2542
+ };
2543
+ const envDbId = getEnvVal("QARPEO_DB_ID") || getEnvVal("DATABASE_ID") || process.env.QARPEO_DB_ID || process.env.DATABASE_ID;
2544
+ const envKvId = getEnvVal("QARPEO_KV_ID") || process.env.QARPEO_KV_ID;
2545
+ const envBlobBucket = getEnvVal("QARPEO_BLOB_BUCKET") || process.env.QARPEO_BLOB_BUCKET;
2546
+ const wranglerDbId = existingConfig.d1_databases?.[0]?.database_id;
2547
+ const wranglerKvId = existingConfig.kv_namespaces?.[0]?.id;
2548
+ const wranglerBlobBucket = existingConfig.r2_buckets?.[0]?.bucket_name;
2549
+ const isReal = (v) => !!v && !v.includes("LOCAL_DEV") && !v.includes("local-dev");
2550
+ const existingDbId = createdResources.dbId || (isReal(envDbId) ? envDbId : null) || (isReal(wranglerDbId) ? wranglerDbId : null);
2551
+ const existingKvId = createdResources.kvId || (isReal(envKvId) ? envKvId : null) || (isReal(wranglerKvId) ? wranglerKvId : null);
2552
+ const existingBlobBucket = createdResources.blobBucket || (isReal(envBlobBucket) ? envBlobBucket : null) || (isReal(wranglerBlobBucket) ? wranglerBlobBucket : null);
2553
+ const accountId = cfAuth?.accountId || getEnvVal("CLOUDFLARE_ACCOUNT_ID") || process.env.CLOUDFLARE_ACCOUNT_ID || existingConfig.account_id;
2520
2554
  console.log("\n\u{1F4DD} \x1B[1mGenerating root wrangler.json configuration...\x1B[0m");
2521
2555
  const wranglerConfig = {
2522
2556
  $schema: "node_modules/wrangler/config-schema.json",
@@ -2526,14 +2560,14 @@ const init = defineCommand({
2526
2560
  compatibility_flags: ["nodejs_compat"],
2527
2561
  observability: { enabled: true }
2528
2562
  };
2529
- if (cfAuth?.accountId) {
2530
- wranglerConfig.account_id = cfAuth.accountId;
2563
+ if (accountId) {
2564
+ wranglerConfig.account_id = accountId;
2531
2565
  }
2532
2566
  if (selectedFeatures.kv) {
2533
2567
  wranglerConfig.kv_namespaces = [
2534
2568
  {
2535
2569
  binding: "KV",
2536
- id: createdResources.kvId || "KV_LOCAL_DEV"
2570
+ id: existingKvId || "KV_LOCAL_DEV"
2537
2571
  }
2538
2572
  ];
2539
2573
  }
@@ -2542,7 +2576,7 @@ const init = defineCommand({
2542
2576
  {
2543
2577
  binding: "DB",
2544
2578
  database_name: `${projectName}-db`,
2545
- database_id: createdResources.dbId || "DB_LOCAL_DEV",
2579
+ database_id: existingDbId || "DB_LOCAL_DEV",
2546
2580
  migrations_dir: "server/db/migrations"
2547
2581
  }
2548
2582
  ];
@@ -2551,7 +2585,7 @@ const init = defineCommand({
2551
2585
  wranglerConfig.r2_buckets = [
2552
2586
  {
2553
2587
  binding: "BLOB",
2554
- bucket_name: createdResources.blobBucket || `${projectName}-storage-local-dev`
2588
+ bucket_name: existingBlobBucket || `${projectName}-storage-local-dev`
2555
2589
  }
2556
2590
  ];
2557
2591
  }
@@ -2599,23 +2633,23 @@ const init = defineCommand({
2599
2633
  }
2600
2634
  ];
2601
2635
  }
2602
- const wranglerPath = join(cwd, "wrangler.json");
2603
2636
  writeFileSync(wranglerPath, JSON.stringify(wranglerConfig, null, 2) + "\n", "utf8");
2604
2637
  console.log(` \x1B[32m\u2714\x1B[0m Generated ${wranglerPath}`);
2605
2638
  console.log("\u{1F511} \x1B[1mUpdating .env file with secrets and binding identifiers...\x1B[0m");
2606
- const envPath = join(cwd, ".env");
2607
- let envContent = existsSync(envPath) ? readFileSync(envPath, "utf8") : "";
2608
- if (cfAuth?.accountId) {
2609
- envContent = updateOrAppendEnv(envContent, "CLOUDFLARE_ACCOUNT_ID", cfAuth.accountId);
2639
+ if (accountId) {
2640
+ envContent = updateOrAppendEnv(envContent, "CLOUDFLARE_ACCOUNT_ID", accountId);
2610
2641
  }
2611
- if (createdResources.dbId) {
2612
- envContent = updateOrAppendEnv(envContent, "QARPEO_DB_ID", createdResources.dbId);
2642
+ const finalDbId = createdResources.dbId || (existingDbId && existingDbId !== "DB_LOCAL_DEV" ? existingDbId : null);
2643
+ if (finalDbId) {
2644
+ envContent = updateOrAppendEnv(envContent, "QARPEO_DB_ID", finalDbId);
2613
2645
  }
2614
- if (createdResources.kvId) {
2615
- envContent = updateOrAppendEnv(envContent, "QARPEO_KV_ID", createdResources.kvId);
2646
+ const finalKvId = createdResources.kvId || (existingKvId && existingKvId !== "KV_LOCAL_DEV" ? existingKvId : null);
2647
+ if (finalKvId) {
2648
+ envContent = updateOrAppendEnv(envContent, "QARPEO_KV_ID", finalKvId);
2616
2649
  }
2617
- if (createdResources.blobBucket) {
2618
- envContent = updateOrAppendEnv(envContent, "QARPEO_BLOB_BUCKET", createdResources.blobBucket);
2650
+ const finalBlobBucket = createdResources.blobBucket || (existingBlobBucket && !existingBlobBucket.includes("local-dev") ? existingBlobBucket : null);
2651
+ if (finalBlobBucket) {
2652
+ envContent = updateOrAppendEnv(envContent, "QARPEO_BLOB_BUCKET", finalBlobBucket);
2619
2653
  }
2620
2654
  if (selectedFeatures.auth) {
2621
2655
  if (!envContent.includes("BETTER_AUTH_SECRET=")) {
@@ -2630,7 +2664,6 @@ const init = defineCommand({
2630
2664
  }
2631
2665
  writeFileSync(envPath, envContent, "utf8");
2632
2666
  console.log(` \x1B[32m\u2714\x1B[0m Updated ${envPath}`);
2633
- const nuxtConfigCandidates = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"];
2634
2667
  let nuxtConfigPath = null;
2635
2668
  for (const file of nuxtConfigCandidates) {
2636
2669
  const candidate = join(cwd, file);
package/dist/module.mjs CHANGED
@@ -2191,21 +2191,41 @@ export default async function (batch: any, env?: any, ctx?: any) {
2191
2191
  }
2192
2192
  });
2193
2193
  nitroConfig.cloudflare.wrangler = nitroConfig.cloudflare.wrangler || {};
2194
+ const rootWranglerPath = resolve(nuxt.options.rootDir, "wrangler.json");
2195
+ let rootWranglerBindings = {};
2196
+ if (existsSync(rootWranglerPath)) {
2197
+ try {
2198
+ rootWranglerBindings = JSON.parse(readFileSync(rootWranglerPath, "utf8"));
2199
+ } catch {
2200
+ }
2201
+ }
2202
+ nitroConfig.framework = nitroConfig.framework || {};
2203
+ nitroConfig.framework.previewCommand = "vpx nuxt preview";
2204
+ nitroConfig.framework.deployCommand = "vpx qp deploy";
2194
2205
  nitroConfig.externals = nitroConfig.externals || {};
2195
2206
  nitroConfig.externals.external = nitroConfig.externals.external || [];
2196
2207
  if (!nitroConfig.externals.external.includes("wrangler")) {
2197
2208
  nitroConfig.externals.external.push("wrangler");
2198
2209
  }
2210
+ if (!nitroConfig.externals.external.includes("@cloudflare/puppeteer")) {
2211
+ nitroConfig.externals.external.push("@cloudflare/puppeteer");
2212
+ }
2199
2213
  nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};
2200
2214
  if (Array.isArray(nitroConfig.rollupConfig.external)) {
2201
2215
  if (!nitroConfig.rollupConfig.external.includes("wrangler")) {
2202
2216
  nitroConfig.rollupConfig.external.push("wrangler");
2203
2217
  }
2218
+ if (!nitroConfig.rollupConfig.external.includes("@cloudflare/puppeteer")) {
2219
+ nitroConfig.rollupConfig.external.push("@cloudflare/puppeteer");
2220
+ }
2204
2221
  }
2205
2222
  if (options.kv) {
2206
2223
  const kvBinding = resolveBindingName("kv");
2207
2224
  nitroConfig.cloudflare.wrangler.kv_namespaces = nitroConfig.cloudflare.wrangler.kv_namespaces || [];
2208
- if (!nitroConfig.cloudflare.wrangler.kv_namespaces.some((ns) => ns.binding === kvBinding)) {
2225
+ const alreadyDefined = nitroConfig.cloudflare.wrangler.kv_namespaces.some(
2226
+ (ns) => ns.binding === kvBinding
2227
+ ) || (rootWranglerBindings.kv_namespaces || []).some((ns) => ns.binding === kvBinding);
2228
+ if (!alreadyDefined) {
2209
2229
  const kvId = process.env.QARPEO_KV_ID || process.env.KV_ID || `${kvBinding}_LOCAL_DEV`;
2210
2230
  nitroConfig.cloudflare.wrangler.kv_namespaces.push({
2211
2231
  binding: kvBinding,
@@ -2217,7 +2237,8 @@ export default async function (batch: any, env?: any, ctx?: any) {
2217
2237
  const blobBinding = resolveBindingName("blob");
2218
2238
  const bucketName = process.env.QARPEO_BLOB_BUCKET || process.env.BLOB_NAME || process.env.BUCKET_NAME || `${blobBinding.toLowerCase().replace(/[^a-z0-9-]/g, "-")}-prod`;
2219
2239
  nitroConfig.cloudflare.wrangler.r2_buckets = nitroConfig.cloudflare.wrangler.r2_buckets || [];
2220
- if (!nitroConfig.cloudflare.wrangler.r2_buckets.some((b) => b.binding === blobBinding)) {
2240
+ const alreadyDefined = nitroConfig.cloudflare.wrangler.r2_buckets.some((b) => b.binding === blobBinding) || (rootWranglerBindings.r2_buckets || []).some((b) => b.binding === blobBinding);
2241
+ if (!alreadyDefined) {
2221
2242
  nitroConfig.cloudflare.wrangler.r2_buckets.push({
2222
2243
  binding: blobBinding,
2223
2244
  bucket_name: bucketName
@@ -2227,7 +2248,8 @@ export default async function (batch: any, env?: any, ctx?: any) {
2227
2248
  if (options.db || options.d1) {
2228
2249
  const dbBinding = resolveBindingName("db", void 0);
2229
2250
  nitroConfig.cloudflare.wrangler.d1_databases = nitroConfig.cloudflare.wrangler.d1_databases || [];
2230
- if (!nitroConfig.cloudflare.wrangler.d1_databases.some((d) => d.binding === dbBinding)) {
2251
+ const alreadyDefined = nitroConfig.cloudflare.wrangler.d1_databases.some((d) => d.binding === dbBinding) || (rootWranglerBindings.d1_databases || []).some((d) => d.binding === dbBinding);
2252
+ if (!alreadyDefined) {
2231
2253
  const dbId = typeof options.db === "object" && options.db.databaseId || process.env.QARPEO_DB_ID || process.env.DATABASE_ID || process.env.DB_ID || `${dbBinding}_PROD`;
2232
2254
  const dbName = typeof options.db === "object" && options.db.databaseName || process.env.QARPEO_DB_NAME || process.env.DB_NAME || dbBinding;
2233
2255
  nitroConfig.cloudflare.wrangler.d1_databases.push({
@@ -2273,9 +2295,10 @@ export default async function (batch: any, env?: any, ctx?: any) {
2273
2295
  const cacheBinding = cacheConfig.binding || resolveBindingName("cache");
2274
2296
  const cacheBase = cacheConfig.base || "nitro:cache:";
2275
2297
  nitroConfig.cloudflare.wrangler.kv_namespaces = nitroConfig.cloudflare.wrangler.kv_namespaces || [];
2276
- if (!nitroConfig.cloudflare.wrangler.kv_namespaces.some(
2298
+ const cacheKvAlreadyDefined = nitroConfig.cloudflare.wrangler.kv_namespaces.some(
2277
2299
  (ns) => ns.binding === cacheBinding
2278
- )) {
2300
+ ) || (rootWranglerBindings.kv_namespaces || []).some((ns) => ns.binding === cacheBinding);
2301
+ if (!cacheKvAlreadyDefined) {
2279
2302
  nitroConfig.cloudflare.wrangler.kv_namespaces.push({
2280
2303
  binding: cacheBinding,
2281
2304
  id: `${cacheBinding}_PROD`
@@ -12,7 +12,11 @@ export function getBrowserBinding(bindingName, event) {
12
12
  }
13
13
  async function loadPuppeteer() {
14
14
  try {
15
- const puppeteer = await import("@cloudflare/puppeteer");
15
+ const modName = "@cloudflare/puppeteer";
16
+ const puppeteer = await import(
17
+ /* @vite-ignore */
18
+ modName
19
+ );
16
20
  return puppeteer.default || puppeteer;
17
21
  } catch {
18
22
  return null;
@@ -13,7 +13,11 @@ function getBrowserBinding(name = "BROWSER") {
13
13
  }
14
14
  async function loadPuppeteer() {
15
15
  try {
16
- const mod = await import("@cloudflare/puppeteer");
16
+ const modName = "@cloudflare/puppeteer";
17
+ const mod = await import(
18
+ /* @vite-ignore */
19
+ modName
20
+ );
17
21
  return mod.default || mod;
18
22
  } catch {
19
23
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qarpeo",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Zero-config Cloudflare Edge Platform for Nuxt",
5
5
  "keywords": [
6
6
  "analytics-engine",
@@ -59,7 +59,7 @@
59
59
  "@better-auth/drizzle-adapter": "1.7.20",
60
60
  "@comark/vue": "0.9.1",
61
61
  "@nuxt/devtools-kit": "^4.1.0",
62
- "@nuxt/kit": "npm:@nuxt/kit-nightly@^5.0.0-2611101502-0366cac",
62
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@^5.0.0-2611110934-dd0e705",
63
63
  "@simplewebauthn/browser": "14.0.0",
64
64
  "@simplewebauthn/server": "14.0.3",
65
65
  "better-auth": "1.7.20",
@@ -85,12 +85,12 @@
85
85
  "@typescript/typescript6": "^6.0.2",
86
86
  "h3": "^2.0.8",
87
87
  "nitro": "3.0.261103-rc",
88
- "nuxt": "npm:nuxt-nightly@^5.0.0-2611101502-0366cac",
88
+ "nuxt": "npm:nuxt-nightly@^5.0.0-2611110934-dd0e705",
89
89
  "typescript": "^7.0.2",
90
90
  "unbuild": "^3.6.1",
91
91
  "vite-plus": "1.6.0",
92
92
  "vue": "^3.6.0-rc.14",
93
- "vue-sfc-transformer": "^0.3.2"
93
+ "vue-sfc-transformer": "^0.3.3"
94
94
  },
95
95
  "peerDependencies": {
96
96
  "@cloudflare/puppeteer": ">=1.0.0",
@@ -121,11 +121,13 @@
121
121
  "dev:build": "nuxt build playground",
122
122
  "dev:prepare": "nuxt prepare playground",
123
123
  "docs:build": "nuxt build docs",
124
- "docs:deploy": "qp deploy docs",
125
- "docs:deploy:no-build": "qp deploy docs --no-build",
124
+ "docs:deploy": "node ./dist/cli/index.mjs deploy docs",
125
+ "docs:deploy:no-build": "node ./dist/cli/index.mjs deploy docs --no-build",
126
126
  "docs:dev": "nuxt dev docs",
127
127
  "docs:generate": "nuxt generate docs",
128
128
  "docs:prepare": "nuxt prepare docs",
129
+ "init": "node ./dist/cli/index.mjs init docs",
130
+ "qp": "node ./dist/cli/index.mjs",
129
131
  "test": "vp test run"
130
132
  }
131
133
  }