qarpeo 0.1.21 → 0.1.23

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.21";
12
+ const version = "0.1.23";
13
13
 
14
14
  function scanSchemaExports(schemaFiles) {
15
15
  const types = [];
@@ -1428,6 +1428,48 @@ const deploy = defineCommand({
1428
1428
  config = JSON.parse(readFileSync(wranglerConfigPath, "utf8"));
1429
1429
  } catch {
1430
1430
  }
1431
+ const rootConfigPath = [resolve(cwd, "wrangler.json"), resolve(cwd, "wrangler.jsonc")].find(
1432
+ (p) => existsSync(p)
1433
+ );
1434
+ let rootConfig = {};
1435
+ if (rootConfigPath) {
1436
+ try {
1437
+ rootConfig = JSON.parse(readFileSync(rootConfigPath, "utf8"));
1438
+ } catch {
1439
+ }
1440
+ }
1441
+ if (rootConfigPath && wranglerConfigPath !== rootConfigPath) {
1442
+ let reconciled = false;
1443
+ if (!rootConfig.durable_objects && config.durable_objects) {
1444
+ delete config.durable_objects;
1445
+ delete config.migrations;
1446
+ reconciled = true;
1447
+ }
1448
+ if (!rootConfig.kv_namespaces && config.kv_namespaces) {
1449
+ delete config.kv_namespaces;
1450
+ reconciled = true;
1451
+ }
1452
+ if (!rootConfig.r2_buckets && config.r2_buckets) {
1453
+ delete config.r2_buckets;
1454
+ reconciled = true;
1455
+ }
1456
+ if (!rootConfig.d1_databases && config.d1_databases) {
1457
+ delete config.d1_databases;
1458
+ reconciled = true;
1459
+ }
1460
+ if (!rootConfig.ai && config.ai) {
1461
+ delete config.ai;
1462
+ delete config.vectorize;
1463
+ reconciled = true;
1464
+ }
1465
+ if (!rootConfig.queues && config.queues) {
1466
+ delete config.queues;
1467
+ reconciled = true;
1468
+ }
1469
+ if (reconciled) {
1470
+ writeFileSync(wranglerConfigPath, JSON.stringify(config, null, 2), "utf8");
1471
+ }
1472
+ }
1431
1473
  const defaultName = config.name || "qarpeo";
1432
1474
  const baseWorkerName = args.name || process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME || defaultName;
1433
1475
  const originalName = baseWorkerName;
@@ -1588,6 +1630,7 @@ const deploy = defineCommand({
1588
1630
  `
1589
1631
  \u26A1 [qarpeo] Applying D1 migrations for ${d1.database_name} (${isPreview ? "preview" : "remote"})...`
1590
1632
  );
1633
+ const migConfigPath = rootConfigPath || wranglerConfigPath;
1591
1634
  const migArgs = [
1592
1635
  "d1",
1593
1636
  "migrations",
@@ -1595,7 +1638,7 @@ const deploy = defineCommand({
1595
1638
  d1.database_name,
1596
1639
  "--remote",
1597
1640
  "-c",
1598
- wranglerConfigPath
1641
+ migConfigPath
1599
1642
  ];
1600
1643
  spawnBinSync(wranglerBin, migArgs, {
1601
1644
  cwd,
@@ -2404,28 +2447,29 @@ const init = defineCommand({
2404
2447
  }
2405
2448
  }
2406
2449
  }
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")) {
2450
+ const cleanNuxtConfig = nuxtConfigRaw.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
2451
+ if (existsSync(join(cwd, "server/db")) || existsSync(join(cwd, "server/database")) || existsSync(join(cwd, "migrations")) || /db:\s*true|d1:\s*true/i.test(cleanNuxtConfig)) {
2408
2452
  detectedFeatures.db = true;
2409
2453
  }
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")) {
2454
+ 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(cleanNuxtConfig)) {
2411
2455
  detectedFeatures.blob = true;
2412
2456
  }
2413
- if (/kv:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("kv_namespaces")) {
2457
+ if (/kv:\s*true/i.test(cleanNuxtConfig)) {
2414
2458
  detectedFeatures.kv = true;
2415
2459
  }
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")) {
2460
+ if (existsSync(join(cwd, "server/realtime")) || existsSync(join(cwd, "server/durable-objects")) || /realtime:\s*true|durableObjects:\s*true/i.test(cleanNuxtConfig)) {
2417
2461
  detectedFeatures.realtime = true;
2418
2462
  }
2419
- if (/ai:\s*true|vectorize:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("vectorize")) {
2463
+ if (/ai:\s*true|vectorize:\s*true/i.test(cleanNuxtConfig)) {
2420
2464
  detectedFeatures.ai = true;
2421
2465
  }
2422
- if (/queue:\s*true/i.test(nuxtConfigRaw) || wranglerRaw.includes("queues")) {
2466
+ if (/queue:\s*true/i.test(cleanNuxtConfig)) {
2423
2467
  detectedFeatures.queue = true;
2424
2468
  }
2425
- if (existsSync(join(cwd, "server/auth")) || /auth:\s*true/i.test(nuxtConfigRaw) || /better-auth/i.test(nuxtConfigRaw)) {
2469
+ if (existsSync(join(cwd, "server/auth")) || /auth:\s*true/i.test(cleanNuxtConfig) || /better-auth/i.test(cleanNuxtConfig)) {
2426
2470
  detectedFeatures.auth = true;
2427
2471
  }
2428
- if (/cms:\s*true|cms:\s*\{/i.test(nuxtConfigRaw) || existsSync(join(cwd, "content"))) {
2472
+ if (/cms:\s*true|cms:\s*\{/i.test(cleanNuxtConfig) || existsSync(join(cwd, "content"))) {
2429
2473
  detectedFeatures.cms = true;
2430
2474
  }
2431
2475
  const selectedFeatures = { ...detectedFeatures };
@@ -2462,7 +2506,7 @@ const init = defineCommand({
2462
2506
  } else {
2463
2507
  for (const feat of AVAILABLE_FEATURES) {
2464
2508
  if (selectedFeatures[feat.key] === void 0) {
2465
- selectedFeatures[feat.key] = feat.default;
2509
+ selectedFeatures[feat.key] = detectedKeys.length === 0 ? feat.default : false;
2466
2510
  }
2467
2511
  }
2468
2512
  }
package/dist/module.mjs CHANGED
@@ -2191,6 +2191,14 @@ 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
+ }
2194
2202
  nitroConfig.framework = nitroConfig.framework || {};
2195
2203
  nitroConfig.framework.previewCommand = "vpx nuxt preview";
2196
2204
  nitroConfig.framework.deployCommand = "vpx qp deploy";
@@ -2214,7 +2222,10 @@ export default async function (batch: any, env?: any, ctx?: any) {
2214
2222
  if (options.kv) {
2215
2223
  const kvBinding = resolveBindingName("kv");
2216
2224
  nitroConfig.cloudflare.wrangler.kv_namespaces = nitroConfig.cloudflare.wrangler.kv_namespaces || [];
2217
- 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) {
2218
2229
  const kvId = process.env.QARPEO_KV_ID || process.env.KV_ID || `${kvBinding}_LOCAL_DEV`;
2219
2230
  nitroConfig.cloudflare.wrangler.kv_namespaces.push({
2220
2231
  binding: kvBinding,
@@ -2226,7 +2237,8 @@ export default async function (batch: any, env?: any, ctx?: any) {
2226
2237
  const blobBinding = resolveBindingName("blob");
2227
2238
  const bucketName = process.env.QARPEO_BLOB_BUCKET || process.env.BLOB_NAME || process.env.BUCKET_NAME || `${blobBinding.toLowerCase().replace(/[^a-z0-9-]/g, "-")}-prod`;
2228
2239
  nitroConfig.cloudflare.wrangler.r2_buckets = nitroConfig.cloudflare.wrangler.r2_buckets || [];
2229
- 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) {
2230
2242
  nitroConfig.cloudflare.wrangler.r2_buckets.push({
2231
2243
  binding: blobBinding,
2232
2244
  bucket_name: bucketName
@@ -2236,7 +2248,8 @@ export default async function (batch: any, env?: any, ctx?: any) {
2236
2248
  if (options.db || options.d1) {
2237
2249
  const dbBinding = resolveBindingName("db", void 0);
2238
2250
  nitroConfig.cloudflare.wrangler.d1_databases = nitroConfig.cloudflare.wrangler.d1_databases || [];
2239
- 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) {
2240
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`;
2241
2254
  const dbName = typeof options.db === "object" && options.db.databaseName || process.env.QARPEO_DB_NAME || process.env.DB_NAME || dbBinding;
2242
2255
  nitroConfig.cloudflare.wrangler.d1_databases.push({
@@ -2282,9 +2295,10 @@ export default async function (batch: any, env?: any, ctx?: any) {
2282
2295
  const cacheBinding = cacheConfig.binding || resolveBindingName("cache");
2283
2296
  const cacheBase = cacheConfig.base || "nitro:cache:";
2284
2297
  nitroConfig.cloudflare.wrangler.kv_namespaces = nitroConfig.cloudflare.wrangler.kv_namespaces || [];
2285
- if (!nitroConfig.cloudflare.wrangler.kv_namespaces.some(
2298
+ const cacheKvAlreadyDefined = nitroConfig.cloudflare.wrangler.kv_namespaces.some(
2286
2299
  (ns) => ns.binding === cacheBinding
2287
- )) {
2300
+ ) || (rootWranglerBindings.kv_namespaces || []).some((ns) => ns.binding === cacheBinding);
2301
+ if (!cacheKvAlreadyDefined) {
2288
2302
  nitroConfig.cloudflare.wrangler.kv_namespaces.push({
2289
2303
  binding: cacheBinding,
2290
2304
  id: `${cacheBinding}_PROD`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qarpeo",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
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,12 +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": "qp init docs",
129
+ "init": "node ./dist/cli/index.mjs init docs",
130
+ "qp": "node ./dist/cli/index.mjs",
130
131
  "test": "vp test run"
131
132
  }
132
133
  }