qarpeo 0.1.26 → 0.1.27
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/chunks/wrangler.mjs +5 -3
- package/dist/cli/index.mjs +100 -537
- package/dist/module.mjs +29 -13
- package/dist/types.d.ts +15 -1
- package/package.json +1 -1
package/dist/chunks/wrangler.mjs
CHANGED
|
@@ -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.
|
|
12
|
+
const version = "0.1.27";
|
|
13
13
|
|
|
14
14
|
function scanSchemaExports(schemaFiles) {
|
|
15
15
|
const types = [];
|
|
@@ -516,11 +516,13 @@ function scanDirectory(currentDir, rootDir, map) {
|
|
|
516
516
|
|
|
517
517
|
function resolveProjectName(nuxt, options) {
|
|
518
518
|
let rawName = "";
|
|
519
|
-
if (options?.
|
|
519
|
+
if (options?.workerName) rawName = options.workerName;
|
|
520
|
+
else if (options?.site?.name) rawName = options.site.name;
|
|
520
521
|
else if (options?.name) rawName = options.name;
|
|
521
522
|
else {
|
|
522
523
|
const qarpeoConfig = nuxt.options.qarpeo || {};
|
|
523
|
-
if (qarpeoConfig.
|
|
524
|
+
if (qarpeoConfig.workerName) rawName = qarpeoConfig.workerName;
|
|
525
|
+
else if (qarpeoConfig.site?.name) rawName = qarpeoConfig.site.name;
|
|
524
526
|
else if (qarpeoConfig.name) rawName = qarpeoConfig.name;
|
|
525
527
|
else {
|
|
526
528
|
const siteConfig = nuxt.options.site || {};
|
package/dist/cli/index.mjs
CHANGED
|
@@ -9,7 +9,6 @@ import { reset, seed } from 'drizzle-seed';
|
|
|
9
9
|
import { stdin, stdout } from 'node:process';
|
|
10
10
|
import readline from 'node:readline/promises';
|
|
11
11
|
import { homedir } from 'node:os';
|
|
12
|
-
import { randomBytes } from 'node:crypto';
|
|
13
12
|
import 'node:module';
|
|
14
13
|
import 'drizzle-orm/node-sqlite';
|
|
15
14
|
import 'node:url';
|
|
@@ -170,7 +169,7 @@ const cleanCommand = defineCommand({
|
|
|
170
169
|
}
|
|
171
170
|
});
|
|
172
171
|
|
|
173
|
-
function getWranglerBin$
|
|
172
|
+
function getWranglerBin$6(cwd) {
|
|
174
173
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
175
174
|
}
|
|
176
175
|
function loadDotEnv$7(cwd) {
|
|
@@ -236,7 +235,7 @@ const create = defineCommand({
|
|
|
236
235
|
cwd,
|
|
237
236
|
purpose: "creating Cloudflare D1 database"
|
|
238
237
|
});
|
|
239
|
-
const wrangler = getWranglerBin$
|
|
238
|
+
const wrangler = getWranglerBin$6(cwd);
|
|
240
239
|
console.log(`
|
|
241
240
|
\u26A1 [qarpeo] Creating D1 database "${dbName}" on Cloudflare...
|
|
242
241
|
`);
|
|
@@ -262,7 +261,7 @@ const create = defineCommand({
|
|
|
262
261
|
}
|
|
263
262
|
});
|
|
264
263
|
|
|
265
|
-
function getWranglerBin$
|
|
264
|
+
function getWranglerBin$5(cwd) {
|
|
266
265
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
267
266
|
}
|
|
268
267
|
function loadDotEnv$6(cwd) {
|
|
@@ -342,7 +341,7 @@ const deleteDb = defineCommand({
|
|
|
342
341
|
cwd,
|
|
343
342
|
purpose: "deleting Cloudflare D1 database"
|
|
344
343
|
});
|
|
345
|
-
const wrangler = getWranglerBin$
|
|
344
|
+
const wrangler = getWranglerBin$5(cwd);
|
|
346
345
|
console.log(`
|
|
347
346
|
\u{1F5D1}\uFE0F [qarpeo] Deleting D1 database "${dbName}" on Cloudflare...
|
|
348
347
|
`);
|
|
@@ -367,7 +366,7 @@ const deleteDb = defineCommand({
|
|
|
367
366
|
}
|
|
368
367
|
});
|
|
369
368
|
|
|
370
|
-
function getWranglerBin$
|
|
369
|
+
function getWranglerBin$4(cwd) {
|
|
371
370
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
372
371
|
}
|
|
373
372
|
function loadDotEnv$5(cwd) {
|
|
@@ -416,7 +415,7 @@ const list = defineCommand({
|
|
|
416
415
|
cwd,
|
|
417
416
|
purpose: "listing Cloudflare D1 databases"
|
|
418
417
|
});
|
|
419
|
-
const wrangler = getWranglerBin$
|
|
418
|
+
const wrangler = getWranglerBin$4(cwd);
|
|
420
419
|
console.log("\u{1F50D} [qarpeo] Fetching D1 databases from Cloudflare...\n");
|
|
421
420
|
const wranglerArgs = ["d1", "list"];
|
|
422
421
|
if (args.json) {
|
|
@@ -691,7 +690,7 @@ const push = defineCommand({
|
|
|
691
690
|
}
|
|
692
691
|
});
|
|
693
692
|
|
|
694
|
-
function getWranglerBin$
|
|
693
|
+
function getWranglerBin$3(cwd) {
|
|
695
694
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
696
695
|
}
|
|
697
696
|
function loadDotEnv$4(cwd) {
|
|
@@ -748,7 +747,7 @@ const rollback = defineCommand({
|
|
|
748
747
|
cwd,
|
|
749
748
|
purpose: "restoring Cloudflare D1 backup"
|
|
750
749
|
});
|
|
751
|
-
const wrangler = getWranglerBin$
|
|
750
|
+
const wrangler = getWranglerBin$3(cwd);
|
|
752
751
|
let wranglerConfigPath = null;
|
|
753
752
|
if (existsSync(resolve(cwd, "wrangler.jsonc"))) {
|
|
754
753
|
wranglerConfigPath = resolve(cwd, "wrangler.jsonc");
|
|
@@ -1019,7 +1018,7 @@ async function deleteCloudflareWorker(auth, workerName) {
|
|
|
1019
1018
|
return data.success === true;
|
|
1020
1019
|
}
|
|
1021
1020
|
|
|
1022
|
-
function getWranglerBin$
|
|
1021
|
+
function getWranglerBin$2(cwd) {
|
|
1023
1022
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
1024
1023
|
}
|
|
1025
1024
|
function loadDotEnv$3(cwd) {
|
|
@@ -1178,7 +1177,7 @@ const deleteCommand = defineCommand({
|
|
|
1178
1177
|
cwd,
|
|
1179
1178
|
purpose: "deleting Cloudflare Worker"
|
|
1180
1179
|
});
|
|
1181
|
-
const wrangler = getWranglerBin$
|
|
1180
|
+
const wrangler = getWranglerBin$2(cwd);
|
|
1182
1181
|
const wranglerArgs = ["delete", workerName, "--force"];
|
|
1183
1182
|
if (args.env) {
|
|
1184
1183
|
wranglerArgs.push("--env", args.env);
|
|
@@ -1417,6 +1416,26 @@ const deploy = defineCommand({
|
|
|
1417
1416
|
resolve(cwd, ".nuxt/wrangler.json")
|
|
1418
1417
|
];
|
|
1419
1418
|
let wranglerConfigPath = candidateConfigs.find((p) => existsSync(p)) || null;
|
|
1419
|
+
if (!wranglerConfigPath) {
|
|
1420
|
+
try {
|
|
1421
|
+
const { loadNuxtConfig } = await import('@nuxt/kit');
|
|
1422
|
+
const { generateDevWranglerConfig } = await import('../chunks/wrangler.mjs').then(function (n) { return n.w; });
|
|
1423
|
+
const nuxtConfig = await loadNuxtConfig({ cwd });
|
|
1424
|
+
const qarpeoOpts = nuxtConfig.qarpeo || {};
|
|
1425
|
+
const buildDir = resolve(cwd, ".nuxt");
|
|
1426
|
+
wranglerConfigPath = await generateDevWranglerConfig(
|
|
1427
|
+
{
|
|
1428
|
+
options: {
|
|
1429
|
+
...nuxtConfig,
|
|
1430
|
+
rootDir: cwd,
|
|
1431
|
+
buildDir
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
qarpeoOpts
|
|
1435
|
+
);
|
|
1436
|
+
} catch {
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1420
1439
|
if (!wranglerConfigPath) {
|
|
1421
1440
|
console.error(
|
|
1422
1441
|
"\u274C [qarpeo] Could not find wrangler.json output in .output/server/. Make sure nitro.preset is set to 'cloudflare-module'."
|
|
@@ -1470,7 +1489,22 @@ const deploy = defineCommand({
|
|
|
1470
1489
|
writeFileSync(wranglerConfigPath, JSON.stringify(config, null, 2), "utf8");
|
|
1471
1490
|
}
|
|
1472
1491
|
}
|
|
1473
|
-
|
|
1492
|
+
let nuxtConfigWorkerName = null;
|
|
1493
|
+
for (const f of ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"]) {
|
|
1494
|
+
const p = resolve(cwd, f);
|
|
1495
|
+
if (existsSync(p)) {
|
|
1496
|
+
try {
|
|
1497
|
+
const raw = readFileSync(p, "utf8");
|
|
1498
|
+
const m = raw.match(/qarpeo\s*:\s*\{[\s\S]*?(?:workerName|name)\s*:\s*["']([^"']+)["']/i);
|
|
1499
|
+
if (m && m[1]) {
|
|
1500
|
+
nuxtConfigWorkerName = m[1].toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
1501
|
+
break;
|
|
1502
|
+
}
|
|
1503
|
+
} catch {
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
const defaultName = nuxtConfigWorkerName || config.name || "qarpeo";
|
|
1474
1508
|
const baseWorkerName = args.name || process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME || defaultName;
|
|
1475
1509
|
const originalName = baseWorkerName;
|
|
1476
1510
|
if (isPreview) {
|
|
@@ -1960,10 +1994,9 @@ const doctor = defineCommand({
|
|
|
1960
1994
|
if (isRemote) {
|
|
1961
1995
|
if (!dbId || dbId.includes("LOCAL_DEV")) {
|
|
1962
1996
|
bindingItems.push({
|
|
1963
|
-
status: "
|
|
1964
|
-
title: "D1 Database
|
|
1965
|
-
message: `
|
|
1966
|
-
help: "Create a D1 database via `wrangler d1 create <name>` and set QARPEO_DB_ID or DATABASE_ID in .env."
|
|
1997
|
+
status: "info",
|
|
1998
|
+
title: "D1 Database Binding",
|
|
1999
|
+
message: `Binding '${dbBinding}' will be automatically provisioned on Cloudflare during 'qp deploy'`
|
|
1967
2000
|
});
|
|
1968
2001
|
} else {
|
|
1969
2002
|
bindingItems.push({
|
|
@@ -1987,10 +2020,9 @@ const doctor = defineCommand({
|
|
|
1987
2020
|
const blobBucket = process.env.QARPEO_BLOB_BUCKET || process.env.BLOB_NAME || typeof qarpeoConfig.blob === "object" && qarpeoConfig.blob?.bucket;
|
|
1988
2021
|
if (isRemote && (!blobBucket || blobBucket.includes("local-dev"))) {
|
|
1989
2022
|
bindingItems.push({
|
|
1990
|
-
status: "
|
|
1991
|
-
title: "R2 Bucket
|
|
1992
|
-
message: "No
|
|
1993
|
-
help: "Create an R2 bucket via `wrangler r2 bucket create <name>` and set QARPEO_BLOB_BUCKET in .env."
|
|
2023
|
+
status: "info",
|
|
2024
|
+
title: "R2 Bucket",
|
|
2025
|
+
message: "No static bucket ID in .env; will be automatically provisioned on Cloudflare during 'qp deploy'"
|
|
1994
2026
|
});
|
|
1995
2027
|
} else {
|
|
1996
2028
|
bindingItems.push({
|
|
@@ -2294,497 +2326,6 @@ ${cat.icon} ${cat.title}`);
|
|
|
2294
2326
|
}
|
|
2295
2327
|
});
|
|
2296
2328
|
|
|
2297
|
-
const AVAILABLE_FEATURES = [
|
|
2298
|
-
{
|
|
2299
|
-
key: "db",
|
|
2300
|
-
name: "D1 Database & Drizzle ORM",
|
|
2301
|
-
binding: "DB",
|
|
2302
|
-
desc: "Serverless SQL database (D1 + Drizzle)",
|
|
2303
|
-
default: true
|
|
2304
|
-
},
|
|
2305
|
-
{
|
|
2306
|
-
key: "kv",
|
|
2307
|
-
name: "KV Namespaces",
|
|
2308
|
-
binding: "KV",
|
|
2309
|
-
desc: "Low-latency key-value data storage and sessions",
|
|
2310
|
-
default: true
|
|
2311
|
-
},
|
|
2312
|
-
{
|
|
2313
|
-
key: "blob",
|
|
2314
|
-
name: "R2 Object Storage",
|
|
2315
|
-
binding: "BLOB",
|
|
2316
|
-
desc: "Zero egress-fee file & media storage (R2)",
|
|
2317
|
-
default: true
|
|
2318
|
-
},
|
|
2319
|
-
{
|
|
2320
|
-
key: "realtime",
|
|
2321
|
-
name: "Realtime & Durable Objects",
|
|
2322
|
-
binding: "QARPEO_ROOM_DO",
|
|
2323
|
-
desc: "Hibernatable WebSockets, rooms, presence & state",
|
|
2324
|
-
default: false
|
|
2325
|
-
},
|
|
2326
|
-
{
|
|
2327
|
-
key: "ai",
|
|
2328
|
-
name: "Workers AI & Vectorize",
|
|
2329
|
-
binding: "AI",
|
|
2330
|
-
desc: "Edge LLMs, embeddings & vector search",
|
|
2331
|
-
default: false
|
|
2332
|
-
},
|
|
2333
|
-
{
|
|
2334
|
-
key: "queue",
|
|
2335
|
-
name: "Queues & Background Jobs",
|
|
2336
|
-
binding: "QUEUE",
|
|
2337
|
-
desc: "Asynchronous task processing and queues",
|
|
2338
|
-
default: false
|
|
2339
|
-
},
|
|
2340
|
-
{
|
|
2341
|
-
key: "auth",
|
|
2342
|
-
name: "Better Auth Integration",
|
|
2343
|
-
binding: "DB",
|
|
2344
|
-
desc: "Complete auth schemas, sessions & OAuth",
|
|
2345
|
-
default: true
|
|
2346
|
-
},
|
|
2347
|
-
{
|
|
2348
|
-
key: "cms",
|
|
2349
|
-
name: "Edge CMS",
|
|
2350
|
-
binding: "DB",
|
|
2351
|
-
desc: "Hybrid Git markdown + edge content management",
|
|
2352
|
-
default: false
|
|
2353
|
-
}
|
|
2354
|
-
];
|
|
2355
|
-
function getWranglerBin$2(cwd) {
|
|
2356
|
-
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
2357
|
-
}
|
|
2358
|
-
function generateSecret(length = 32) {
|
|
2359
|
-
return randomBytes(length).toString("base64url");
|
|
2360
|
-
}
|
|
2361
|
-
function updateOrAppendEnv(envContent, key, value) {
|
|
2362
|
-
const lineRegex = new RegExp(`^${key}=.*$`, "m");
|
|
2363
|
-
if (lineRegex.test(envContent)) {
|
|
2364
|
-
return envContent.replace(lineRegex, `${key}=${value}`);
|
|
2365
|
-
}
|
|
2366
|
-
const trimmed = envContent.trimEnd();
|
|
2367
|
-
return (trimmed ? `${trimmed}
|
|
2368
|
-
` : "") + `${key}=${value}
|
|
2369
|
-
`;
|
|
2370
|
-
}
|
|
2371
|
-
const init = defineCommand({
|
|
2372
|
-
meta: {
|
|
2373
|
-
name: "init",
|
|
2374
|
-
description: "Initialize Qarpeo in your project with interactive resource setup (.env, wrangler.json, nuxt.config)"
|
|
2375
|
-
},
|
|
2376
|
-
args: {
|
|
2377
|
-
dir: {
|
|
2378
|
-
type: "positional",
|
|
2379
|
-
description: "Project directory to initialize (e.g. docs, playground)",
|
|
2380
|
-
required: false,
|
|
2381
|
-
default: "."
|
|
2382
|
-
},
|
|
2383
|
-
cwd: {
|
|
2384
|
-
type: "string",
|
|
2385
|
-
description: "Working directory",
|
|
2386
|
-
default: "."
|
|
2387
|
-
},
|
|
2388
|
-
yes: {
|
|
2389
|
-
type: "boolean",
|
|
2390
|
-
alias: "y",
|
|
2391
|
-
description: "Accept all defaults automatically without interactive prompts",
|
|
2392
|
-
default: false
|
|
2393
|
-
},
|
|
2394
|
-
remote: {
|
|
2395
|
-
type: "boolean",
|
|
2396
|
-
description: "Provision live Cloudflare resources immediately (D1, KV, R2)",
|
|
2397
|
-
default: false
|
|
2398
|
-
}
|
|
2399
|
-
},
|
|
2400
|
-
async run({ args }) {
|
|
2401
|
-
const targetDir = args.dir && args.dir !== "." ? args.dir : args.cwd;
|
|
2402
|
-
const cwd = resolve(process.cwd(), targetDir);
|
|
2403
|
-
console.log("\n\u{1F680} \x1B[1m\x1B[36mQarpeo Edge Platform Initialization\x1B[0m");
|
|
2404
|
-
console.log(" Configuring Cloudflare edge primitives for your Nuxt application...\n");
|
|
2405
|
-
const pkgPath = join(cwd, "package.json");
|
|
2406
|
-
let projectName = "my-qarpeo-app";
|
|
2407
|
-
if (existsSync(pkgPath)) {
|
|
2408
|
-
try {
|
|
2409
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
2410
|
-
if (pkg.name) {
|
|
2411
|
-
projectName = pkg.name.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
2412
|
-
}
|
|
2413
|
-
} catch {
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
const isInteractive = stdin.isTTY && !args.yes;
|
|
2417
|
-
const rl = isInteractive ? readline.createInterface({ input: stdin, output: stdout }) : null;
|
|
2418
|
-
if (rl) {
|
|
2419
|
-
const nameAnswer = await rl.question(
|
|
2420
|
-
`\u{1F3F7}\uFE0F \x1B[1mWorker Service Name\x1B[0m [${projectName}]: `
|
|
2421
|
-
);
|
|
2422
|
-
if (nameAnswer.trim()) {
|
|
2423
|
-
projectName = nameAnswer.trim().toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
const detectedFeatures = {};
|
|
2427
|
-
const nuxtConfigCandidates = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"];
|
|
2428
|
-
let nuxtConfigRaw = "";
|
|
2429
|
-
for (const file of nuxtConfigCandidates) {
|
|
2430
|
-
const candidate = join(cwd, file);
|
|
2431
|
-
if (existsSync(candidate)) {
|
|
2432
|
-
try {
|
|
2433
|
-
nuxtConfigRaw = readFileSync(candidate, "utf8");
|
|
2434
|
-
break;
|
|
2435
|
-
} catch {
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
let wranglerRaw = "";
|
|
2440
|
-
for (const file of ["wrangler.json", "wrangler.jsonc", ".output/server/wrangler.json"]) {
|
|
2441
|
-
const candidate = join(cwd, file);
|
|
2442
|
-
if (existsSync(candidate)) {
|
|
2443
|
-
try {
|
|
2444
|
-
wranglerRaw = readFileSync(candidate, "utf8");
|
|
2445
|
-
break;
|
|
2446
|
-
} catch {
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
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)) {
|
|
2452
|
-
detectedFeatures.db = true;
|
|
2453
|
-
}
|
|
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)) {
|
|
2455
|
-
detectedFeatures.blob = true;
|
|
2456
|
-
}
|
|
2457
|
-
if (/kv:\s*true/i.test(cleanNuxtConfig)) {
|
|
2458
|
-
detectedFeatures.kv = true;
|
|
2459
|
-
}
|
|
2460
|
-
if (existsSync(join(cwd, "server/realtime")) || existsSync(join(cwd, "server/durable-objects")) || /realtime:\s*true|durableObjects:\s*true/i.test(cleanNuxtConfig)) {
|
|
2461
|
-
detectedFeatures.realtime = true;
|
|
2462
|
-
}
|
|
2463
|
-
if (/ai:\s*true|vectorize:\s*true/i.test(cleanNuxtConfig)) {
|
|
2464
|
-
detectedFeatures.ai = true;
|
|
2465
|
-
}
|
|
2466
|
-
if (/queue:\s*true/i.test(cleanNuxtConfig)) {
|
|
2467
|
-
detectedFeatures.queue = true;
|
|
2468
|
-
}
|
|
2469
|
-
if (existsSync(join(cwd, "server/auth")) || /auth:\s*true/i.test(cleanNuxtConfig) || /better-auth/i.test(cleanNuxtConfig)) {
|
|
2470
|
-
detectedFeatures.auth = true;
|
|
2471
|
-
}
|
|
2472
|
-
if (/cms:\s*true|cms:\s*\{/i.test(cleanNuxtConfig) || existsSync(join(cwd, "content"))) {
|
|
2473
|
-
detectedFeatures.cms = true;
|
|
2474
|
-
}
|
|
2475
|
-
const selectedFeatures = { ...detectedFeatures };
|
|
2476
|
-
const detectedKeys = Object.keys(detectedFeatures).filter((k) => detectedFeatures[k]);
|
|
2477
|
-
if (detectedKeys.length > 0) {
|
|
2478
|
-
console.log(`
|
|
2479
|
-
\u2714 \x1B[32mAuto-detected active features in project:\x1B[0m`);
|
|
2480
|
-
for (const k of detectedKeys) {
|
|
2481
|
-
const feat = AVAILABLE_FEATURES.find((f) => f.key === k);
|
|
2482
|
-
console.log(` \u2022 ${feat?.name || k}`);
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
if (rl) {
|
|
2486
|
-
const undetectedFeatures = AVAILABLE_FEATURES.filter((f) => !detectedFeatures[f.key]);
|
|
2487
|
-
if (undetectedFeatures.length > 0 && detectedKeys.length === 0) {
|
|
2488
|
-
console.log("\n\u{1F4E6} \x1B[1mSelect Cloudflare Edge Services to Enable:\x1B[0m");
|
|
2489
|
-
for (const feat of undetectedFeatures) {
|
|
2490
|
-
const defaultHint = feat.default ? "Y/n" : "y/N";
|
|
2491
|
-
const answer = await rl.question(
|
|
2492
|
-
` \u2022 Enable ${feat.name} (${feat.desc})? [${defaultHint}]: `
|
|
2493
|
-
);
|
|
2494
|
-
const trimmed = answer.trim().toLowerCase();
|
|
2495
|
-
if (trimmed === "") {
|
|
2496
|
-
selectedFeatures[feat.key] = feat.default;
|
|
2497
|
-
} else {
|
|
2498
|
-
selectedFeatures[feat.key] = trimmed === "y" || trimmed === "yes";
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
} else {
|
|
2502
|
-
for (const feat of undetectedFeatures) {
|
|
2503
|
-
selectedFeatures[feat.key] = false;
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
} else {
|
|
2507
|
-
for (const feat of AVAILABLE_FEATURES) {
|
|
2508
|
-
if (selectedFeatures[feat.key] === void 0) {
|
|
2509
|
-
selectedFeatures[feat.key] = detectedKeys.length === 0 ? feat.default : false;
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
let shouldProvisionRemote = Boolean(args.remote);
|
|
2514
|
-
const cfAuth = await getCloudflareAuth(cwd).catch(() => null);
|
|
2515
|
-
if (rl && cfAuth && !shouldProvisionRemote) {
|
|
2516
|
-
const provAnswer = await rl.question(
|
|
2517
|
-
`
|
|
2518
|
-
\u2601\uFE0F Cloudflare account detected (\x1B[32m${cfAuth.accountId}\x1B[0m). Provision live resources on Cloudflare now? [y/N]: `
|
|
2519
|
-
);
|
|
2520
|
-
shouldProvisionRemote = provAnswer.trim().toLowerCase() === "y" || provAnswer.trim().toLowerCase() === "yes";
|
|
2521
|
-
}
|
|
2522
|
-
const createdResources = {};
|
|
2523
|
-
if (shouldProvisionRemote && cfAuth) {
|
|
2524
|
-
const wrangler = getWranglerBin$2(cwd);
|
|
2525
|
-
if (selectedFeatures.db) {
|
|
2526
|
-
const dbName = `${projectName}-db`;
|
|
2527
|
-
console.log(`
|
|
2528
|
-
\u23F3 Provisioning Cloudflare D1 Database "${dbName}"...`);
|
|
2529
|
-
const res = spawnBinSync(wrangler, ["d1", "create", dbName], {
|
|
2530
|
-
cwd,
|
|
2531
|
-
encoding: "utf8",
|
|
2532
|
-
env: process.env
|
|
2533
|
-
});
|
|
2534
|
-
const uuidMatch = String(res.stdout || "").match(/database_id\s*=\s*"([a-f0-9-]+)"/i) || String(res.stdout || "").match(/"([a-f0-9-]{36})"/i);
|
|
2535
|
-
if (uuidMatch) {
|
|
2536
|
-
createdResources.dbId = uuidMatch[1];
|
|
2537
|
-
console.log(` \x1B[32m\u2714\x1B[0m Created D1 database: ${createdResources.dbId}`);
|
|
2538
|
-
} else {
|
|
2539
|
-
console.log(
|
|
2540
|
-
` \u2139\uFE0F Note: If database already exists or output was masked, default binding was applied.`
|
|
2541
|
-
);
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
if (selectedFeatures.kv) {
|
|
2545
|
-
const kvTitle = `${projectName}-kv`;
|
|
2546
|
-
console.log(`\u23F3 Provisioning Cloudflare KV Namespace "${kvTitle}"...`);
|
|
2547
|
-
const res = spawnBinSync(wrangler, ["kv", "namespace", "create", kvTitle], {
|
|
2548
|
-
cwd,
|
|
2549
|
-
encoding: "utf8",
|
|
2550
|
-
env: process.env
|
|
2551
|
-
});
|
|
2552
|
-
const kvMatch = String(res.stdout || "").match(/id\s*=\s*"([a-f0-9]+)"/i) || String(res.stdout || "").match(/"([a-f0-9]{32})"/i);
|
|
2553
|
-
if (kvMatch) {
|
|
2554
|
-
createdResources.kvId = kvMatch[1];
|
|
2555
|
-
console.log(` \x1B[32m\u2714\x1B[0m Created KV namespace: ${createdResources.kvId}`);
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
if (selectedFeatures.blob) {
|
|
2559
|
-
const bucketName = `${projectName}-storage`;
|
|
2560
|
-
console.log(`\u23F3 Provisioning Cloudflare R2 Bucket "${bucketName}"...`);
|
|
2561
|
-
spawnBinSync(wrangler, ["r2", "bucket", "create", bucketName], {
|
|
2562
|
-
cwd,
|
|
2563
|
-
encoding: "utf8",
|
|
2564
|
-
env: process.env
|
|
2565
|
-
});
|
|
2566
|
-
createdResources.blobBucket = bucketName;
|
|
2567
|
-
console.log(` \x1B[32m\u2714\x1B[0m Created R2 bucket: ${bucketName}`);
|
|
2568
|
-
}
|
|
2569
|
-
}
|
|
2570
|
-
if (rl) {
|
|
2571
|
-
rl.close();
|
|
2572
|
-
}
|
|
2573
|
-
const wranglerPath = join(cwd, "wrangler.json");
|
|
2574
|
-
let existingConfig = {};
|
|
2575
|
-
if (existsSync(wranglerPath)) {
|
|
2576
|
-
try {
|
|
2577
|
-
existingConfig = JSON.parse(readFileSync(wranglerPath, "utf8"));
|
|
2578
|
-
} catch {
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
const envPath = join(cwd, ".env");
|
|
2582
|
-
let envContent = existsSync(envPath) ? readFileSync(envPath, "utf8") : "";
|
|
2583
|
-
const getEnvVal = (key) => {
|
|
2584
|
-
const match = envContent.match(new RegExp(`^${key}=(.*)$`, "m"));
|
|
2585
|
-
return match ? match[1].trim().replace(/^['"]|['"]$/g, "") : null;
|
|
2586
|
-
};
|
|
2587
|
-
const envDbId = getEnvVal("QARPEO_DB_ID") || getEnvVal("DATABASE_ID") || process.env.QARPEO_DB_ID || process.env.DATABASE_ID;
|
|
2588
|
-
const envKvId = getEnvVal("QARPEO_KV_ID") || process.env.QARPEO_KV_ID;
|
|
2589
|
-
const envBlobBucket = getEnvVal("QARPEO_BLOB_BUCKET") || process.env.QARPEO_BLOB_BUCKET;
|
|
2590
|
-
const wranglerDbId = existingConfig.d1_databases?.[0]?.database_id;
|
|
2591
|
-
const wranglerKvId = existingConfig.kv_namespaces?.[0]?.id;
|
|
2592
|
-
const wranglerBlobBucket = existingConfig.r2_buckets?.[0]?.bucket_name;
|
|
2593
|
-
const isReal = (v) => !!v && !v.includes("LOCAL_DEV") && !v.includes("local-dev");
|
|
2594
|
-
const existingDbId = createdResources.dbId || (isReal(envDbId) ? envDbId : null) || (isReal(wranglerDbId) ? wranglerDbId : null);
|
|
2595
|
-
const existingKvId = createdResources.kvId || (isReal(envKvId) ? envKvId : null) || (isReal(wranglerKvId) ? wranglerKvId : null);
|
|
2596
|
-
const existingBlobBucket = createdResources.blobBucket || (isReal(envBlobBucket) ? envBlobBucket : null) || (isReal(wranglerBlobBucket) ? wranglerBlobBucket : null);
|
|
2597
|
-
const accountId = cfAuth?.accountId || getEnvVal("CLOUDFLARE_ACCOUNT_ID") || process.env.CLOUDFLARE_ACCOUNT_ID || existingConfig.account_id;
|
|
2598
|
-
console.log("\n\u{1F4DD} \x1B[1mGenerating root wrangler.json configuration...\x1B[0m");
|
|
2599
|
-
const wranglerConfig = {
|
|
2600
|
-
$schema: "node_modules/wrangler/config-schema.json",
|
|
2601
|
-
name: projectName,
|
|
2602
|
-
main: "./.output/server/index.mjs",
|
|
2603
|
-
compatibility_date: "2025-02-01",
|
|
2604
|
-
compatibility_flags: ["nodejs_compat"],
|
|
2605
|
-
observability: { enabled: true }
|
|
2606
|
-
};
|
|
2607
|
-
if (accountId) {
|
|
2608
|
-
wranglerConfig.account_id = accountId;
|
|
2609
|
-
}
|
|
2610
|
-
if (selectedFeatures.kv) {
|
|
2611
|
-
wranglerConfig.kv_namespaces = [
|
|
2612
|
-
{
|
|
2613
|
-
binding: "KV",
|
|
2614
|
-
id: existingKvId || "KV_LOCAL_DEV"
|
|
2615
|
-
}
|
|
2616
|
-
];
|
|
2617
|
-
}
|
|
2618
|
-
if (selectedFeatures.db) {
|
|
2619
|
-
wranglerConfig.d1_databases = [
|
|
2620
|
-
{
|
|
2621
|
-
binding: "DB",
|
|
2622
|
-
database_name: `${projectName}-db`,
|
|
2623
|
-
database_id: existingDbId || "DB_LOCAL_DEV",
|
|
2624
|
-
migrations_dir: "server/db/migrations",
|
|
2625
|
-
migrations_pattern: "server/db/migrations/*/migration.sql"
|
|
2626
|
-
}
|
|
2627
|
-
];
|
|
2628
|
-
}
|
|
2629
|
-
if (selectedFeatures.blob) {
|
|
2630
|
-
wranglerConfig.r2_buckets = [
|
|
2631
|
-
{
|
|
2632
|
-
binding: "BLOB",
|
|
2633
|
-
bucket_name: existingBlobBucket || `${projectName}-storage-local-dev`
|
|
2634
|
-
}
|
|
2635
|
-
];
|
|
2636
|
-
}
|
|
2637
|
-
if (selectedFeatures.ai) {
|
|
2638
|
-
wranglerConfig.ai = {
|
|
2639
|
-
binding: "AI"
|
|
2640
|
-
};
|
|
2641
|
-
wranglerConfig.vectorize = [
|
|
2642
|
-
{
|
|
2643
|
-
binding: "VECTORIZE",
|
|
2644
|
-
index_name: `${projectName}-vectors`
|
|
2645
|
-
}
|
|
2646
|
-
];
|
|
2647
|
-
}
|
|
2648
|
-
if (selectedFeatures.queue) {
|
|
2649
|
-
wranglerConfig.queues = {
|
|
2650
|
-
producers: [
|
|
2651
|
-
{
|
|
2652
|
-
binding: "QUEUE",
|
|
2653
|
-
queue: `${projectName}-queue`
|
|
2654
|
-
}
|
|
2655
|
-
],
|
|
2656
|
-
consumers: [
|
|
2657
|
-
{
|
|
2658
|
-
queue: `${projectName}-queue`,
|
|
2659
|
-
max_batch_size: 10,
|
|
2660
|
-
max_batch_timeout: 5
|
|
2661
|
-
}
|
|
2662
|
-
]
|
|
2663
|
-
};
|
|
2664
|
-
}
|
|
2665
|
-
if (selectedFeatures.realtime) {
|
|
2666
|
-
wranglerConfig.durable_objects = {
|
|
2667
|
-
bindings: [
|
|
2668
|
-
{
|
|
2669
|
-
name: "QARPEO_ROOM_DO",
|
|
2670
|
-
class_name: "QarpeoRoomDO"
|
|
2671
|
-
}
|
|
2672
|
-
]
|
|
2673
|
-
};
|
|
2674
|
-
wranglerConfig.migrations = [
|
|
2675
|
-
{
|
|
2676
|
-
tag: "v1",
|
|
2677
|
-
new_classes: ["QarpeoRoomDO"]
|
|
2678
|
-
}
|
|
2679
|
-
];
|
|
2680
|
-
}
|
|
2681
|
-
writeFileSync(wranglerPath, JSON.stringify(wranglerConfig, null, 2) + "\n", "utf8");
|
|
2682
|
-
console.log(` \x1B[32m\u2714\x1B[0m Generated ${wranglerPath}`);
|
|
2683
|
-
console.log("\u{1F511} \x1B[1mUpdating .env file with secrets and binding identifiers...\x1B[0m");
|
|
2684
|
-
if (accountId) {
|
|
2685
|
-
envContent = updateOrAppendEnv(envContent, "CLOUDFLARE_ACCOUNT_ID", accountId);
|
|
2686
|
-
}
|
|
2687
|
-
const finalDbId = createdResources.dbId || (existingDbId && existingDbId !== "DB_LOCAL_DEV" ? existingDbId : null);
|
|
2688
|
-
if (finalDbId) {
|
|
2689
|
-
envContent = updateOrAppendEnv(envContent, "QARPEO_DB_ID", finalDbId);
|
|
2690
|
-
}
|
|
2691
|
-
const finalKvId = createdResources.kvId || (existingKvId && existingKvId !== "KV_LOCAL_DEV" ? existingKvId : null);
|
|
2692
|
-
if (finalKvId) {
|
|
2693
|
-
envContent = updateOrAppendEnv(envContent, "QARPEO_KV_ID", finalKvId);
|
|
2694
|
-
}
|
|
2695
|
-
const finalBlobBucket = createdResources.blobBucket || (existingBlobBucket && !existingBlobBucket.includes("local-dev") ? existingBlobBucket : null);
|
|
2696
|
-
if (finalBlobBucket) {
|
|
2697
|
-
envContent = updateOrAppendEnv(envContent, "QARPEO_BLOB_BUCKET", finalBlobBucket);
|
|
2698
|
-
}
|
|
2699
|
-
if (selectedFeatures.auth) {
|
|
2700
|
-
if (!envContent.includes("BETTER_AUTH_SECRET=")) {
|
|
2701
|
-
envContent = updateOrAppendEnv(envContent, "BETTER_AUTH_SECRET", generateSecret(32));
|
|
2702
|
-
}
|
|
2703
|
-
if (!envContent.includes("BETTER_AUTH_URL=")) {
|
|
2704
|
-
envContent = updateOrAppendEnv(envContent, "BETTER_AUTH_URL", "http://localhost:3000");
|
|
2705
|
-
}
|
|
2706
|
-
if (!envContent.includes("NUXT_SESSION_PASSWORD=")) {
|
|
2707
|
-
envContent = updateOrAppendEnv(envContent, "NUXT_SESSION_PASSWORD", generateSecret(32));
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
writeFileSync(envPath, envContent, "utf8");
|
|
2711
|
-
console.log(` \x1B[32m\u2714\x1B[0m Updated ${envPath}`);
|
|
2712
|
-
let nuxtConfigPath = null;
|
|
2713
|
-
for (const file of nuxtConfigCandidates) {
|
|
2714
|
-
const candidate = join(cwd, file);
|
|
2715
|
-
if (existsSync(candidate)) {
|
|
2716
|
-
nuxtConfigPath = candidate;
|
|
2717
|
-
break;
|
|
2718
|
-
}
|
|
2719
|
-
}
|
|
2720
|
-
const qarpeoConfigBlock = [
|
|
2721
|
-
" qarpeo: {",
|
|
2722
|
-
selectedFeatures.db ? " db: true," : null,
|
|
2723
|
-
selectedFeatures.kv ? " kv: true," : null,
|
|
2724
|
-
selectedFeatures.blob ? " blob: true," : null,
|
|
2725
|
-
selectedFeatures.realtime ? " realtime: true," : null,
|
|
2726
|
-
selectedFeatures.ai ? " ai: true," : null,
|
|
2727
|
-
selectedFeatures.queue ? " queue: true," : null,
|
|
2728
|
-
selectedFeatures.auth ? " auth: true," : null,
|
|
2729
|
-
" },"
|
|
2730
|
-
].filter(Boolean).join("\n");
|
|
2731
|
-
if (nuxtConfigPath) {
|
|
2732
|
-
try {
|
|
2733
|
-
let nuxtConfigContent = readFileSync(nuxtConfigPath, "utf8");
|
|
2734
|
-
let updated = false;
|
|
2735
|
-
if (!nuxtConfigContent.includes('"qarpeo"') && !nuxtConfigContent.includes("'qarpeo'")) {
|
|
2736
|
-
if (/modules:\s*\[/.test(nuxtConfigContent)) {
|
|
2737
|
-
nuxtConfigContent = nuxtConfigContent.replace(
|
|
2738
|
-
/modules:\s*\[/,
|
|
2739
|
-
`modules: [
|
|
2740
|
-
"qarpeo",`
|
|
2741
|
-
);
|
|
2742
|
-
updated = true;
|
|
2743
|
-
}
|
|
2744
|
-
}
|
|
2745
|
-
if (!nuxtConfigContent.includes("qarpeo:")) {
|
|
2746
|
-
if (nuxtConfigContent.includes("defineNuxtConfig({")) {
|
|
2747
|
-
nuxtConfigContent = nuxtConfigContent.replace(
|
|
2748
|
-
/defineNuxtConfig\(\{/,
|
|
2749
|
-
`defineNuxtConfig({
|
|
2750
|
-
${qarpeoConfigBlock}`
|
|
2751
|
-
);
|
|
2752
|
-
updated = true;
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
if (updated) {
|
|
2756
|
-
writeFileSync(nuxtConfigPath, nuxtConfigContent, "utf8");
|
|
2757
|
-
console.log(` \x1B[32m\u2714\x1B[0m Configured ${nuxtConfigPath}`);
|
|
2758
|
-
} else {
|
|
2759
|
-
console.log(` \u2139\uFE0F ${nuxtConfigPath} already contains qarpeo configuration.`);
|
|
2760
|
-
}
|
|
2761
|
-
} catch {
|
|
2762
|
-
}
|
|
2763
|
-
} else {
|
|
2764
|
-
console.log(`
|
|
2765
|
-
\u{1F4A1} Add the following to your \x1B[1mnuxt.config.ts\x1B[0m:`);
|
|
2766
|
-
console.log(
|
|
2767
|
-
`
|
|
2768
|
-
export default defineNuxtConfig({
|
|
2769
|
-
modules: ["qarpeo"],
|
|
2770
|
-
${qarpeoConfigBlock}
|
|
2771
|
-
})
|
|
2772
|
-
`
|
|
2773
|
-
);
|
|
2774
|
-
}
|
|
2775
|
-
console.log("\n\u{1F389} \x1B[1m\x1B[32mQarpeo initialized successfully!\x1B[0m\n");
|
|
2776
|
-
console.log(" \x1B[1mNext Steps:\x1B[0m");
|
|
2777
|
-
console.log(
|
|
2778
|
-
" \u2022 Run \x1B[36mvpr dev\x1B[0m (or \x1B[36mvpx nuxt dev\x1B[0m) to start your edge development server"
|
|
2779
|
-
);
|
|
2780
|
-
if (selectedFeatures.db) {
|
|
2781
|
-
console.log(" \u2022 Run \x1B[36mvpx qp db push\x1B[0m to apply your database schemas");
|
|
2782
|
-
}
|
|
2783
|
-
console.log(" \u2022 Run \x1B[36mvpx qp doctor\x1B[0m to verify all edge bindings");
|
|
2784
|
-
console.log(" \u2022 Run \x1B[36mvpx qp deploy\x1B[0m to deploy directly to Cloudflare Workers\n");
|
|
2785
|
-
}
|
|
2786
|
-
});
|
|
2787
|
-
|
|
2788
2329
|
function loadDotEnv(cwd) {
|
|
2789
2330
|
const envPath = join(cwd, ".env");
|
|
2790
2331
|
if (!existsSync(envPath)) return;
|
|
@@ -2876,8 +2417,8 @@ const login = defineCommand({
|
|
|
2876
2417
|
args: {
|
|
2877
2418
|
browser: {
|
|
2878
2419
|
type: "boolean",
|
|
2879
|
-
description: "Automatically open the link in your default browser",
|
|
2880
|
-
default:
|
|
2420
|
+
description: "Automatically open the link in your default browser (use --no-browser for headless environments)",
|
|
2421
|
+
default: true
|
|
2881
2422
|
}
|
|
2882
2423
|
},
|
|
2883
2424
|
async run({ args }) {
|
|
@@ -3369,11 +2910,18 @@ const taskRun = defineCommand({
|
|
|
3369
2910
|
\u{1F680} [qarpeo] Triggering task "${taskName}" on ${host}...`);
|
|
3370
2911
|
let result;
|
|
3371
2912
|
try {
|
|
3372
|
-
|
|
2913
|
+
let res = await fetch(`${host}/__qarpeo/tasks/run`, {
|
|
3373
2914
|
method: "POST",
|
|
3374
2915
|
headers: { "Content-Type": "application/json" },
|
|
3375
2916
|
body: JSON.stringify({ task: taskName, payload })
|
|
3376
2917
|
});
|
|
2918
|
+
if (res.status === 404) {
|
|
2919
|
+
res = await fetch(`${host}/_qarpeo/tasks/run`, {
|
|
2920
|
+
method: "POST",
|
|
2921
|
+
headers: { "Content-Type": "application/json" },
|
|
2922
|
+
body: JSON.stringify({ task: taskName, payload })
|
|
2923
|
+
});
|
|
2924
|
+
}
|
|
3377
2925
|
if (!res.ok) {
|
|
3378
2926
|
const text = await res.text();
|
|
3379
2927
|
console.error(`
|
|
@@ -3447,12 +2995,21 @@ const testCommand = defineCommand({
|
|
|
3447
2995
|
process.env.QARPEO_EDGE_TEST = "1";
|
|
3448
2996
|
process.env.NODE_ENV = "test";
|
|
3449
2997
|
const isWindows = process.platform === "win32";
|
|
3450
|
-
|
|
3451
|
-
let
|
|
3452
|
-
|
|
3453
|
-
|
|
2998
|
+
const vitestBin = resolveBinaryPath("vitest", cwd);
|
|
2999
|
+
let runner;
|
|
3000
|
+
let runnerArgs = [];
|
|
3001
|
+
if (vitestBin) {
|
|
3002
|
+
runner = vitestBin;
|
|
3003
|
+
runnerArgs = [args.watch ? "watch" : "run"];
|
|
3454
3004
|
} else {
|
|
3455
|
-
|
|
3005
|
+
const vpBin = resolveBinaryPath("vp", cwd);
|
|
3006
|
+
if (vpBin) {
|
|
3007
|
+
runner = vpBin;
|
|
3008
|
+
runnerArgs = ["test", args.watch ? "--watch" : "run"];
|
|
3009
|
+
} else {
|
|
3010
|
+
runner = isWindows ? "npx.cmd" : "npx";
|
|
3011
|
+
runnerArgs = ["vitest", args.watch ? "watch" : "run"];
|
|
3012
|
+
}
|
|
3456
3013
|
}
|
|
3457
3014
|
if (args.filter) {
|
|
3458
3015
|
runnerArgs.push(args.filter);
|
|
@@ -3607,6 +3164,20 @@ const tunnel = defineCommand({
|
|
|
3607
3164
|
}
|
|
3608
3165
|
});
|
|
3609
3166
|
|
|
3167
|
+
const ALIASES = {
|
|
3168
|
+
d1: "db",
|
|
3169
|
+
destroy: "delete",
|
|
3170
|
+
ls: "list",
|
|
3171
|
+
workers: "list",
|
|
3172
|
+
tail: "logs",
|
|
3173
|
+
tun: "tunnel",
|
|
3174
|
+
tasks: "task",
|
|
3175
|
+
secrets: "secret"
|
|
3176
|
+
};
|
|
3177
|
+
const invokedCmd = process.argv[2];
|
|
3178
|
+
if (invokedCmd && ALIASES[invokedCmd]) {
|
|
3179
|
+
process.argv[2] = ALIASES[invokedCmd];
|
|
3180
|
+
}
|
|
3610
3181
|
const main = defineCommand({
|
|
3611
3182
|
meta: {
|
|
3612
3183
|
name: "qp",
|
|
@@ -3614,31 +3185,23 @@ const main = defineCommand({
|
|
|
3614
3185
|
description: "Cloudflare-native powerhouse module for Nuxt"
|
|
3615
3186
|
},
|
|
3616
3187
|
subCommands: {
|
|
3617
|
-
d1: db,
|
|
3618
3188
|
db,
|
|
3619
|
-
delete: deleteCommand,
|
|
3620
3189
|
deploy,
|
|
3621
|
-
|
|
3622
|
-
doctor,
|
|
3623
|
-
generate,
|
|
3624
|
-
init,
|
|
3625
|
-
list: listCommand,
|
|
3626
|
-
login,
|
|
3627
|
-
logout,
|
|
3190
|
+
delete: deleteCommand,
|
|
3628
3191
|
logs,
|
|
3629
|
-
|
|
3630
|
-
migrate,
|
|
3631
|
-
push,
|
|
3192
|
+
list: listCommand,
|
|
3632
3193
|
secret,
|
|
3633
|
-
secrets: secret,
|
|
3634
|
-
tail: logs,
|
|
3635
3194
|
task,
|
|
3636
|
-
tasks: task,
|
|
3637
|
-
test: testCommand,
|
|
3638
|
-
tun: tunnel,
|
|
3639
3195
|
tunnel,
|
|
3196
|
+
test: testCommand,
|
|
3197
|
+
doctor,
|
|
3198
|
+
login,
|
|
3199
|
+
logout,
|
|
3640
3200
|
whoami,
|
|
3641
|
-
|
|
3201
|
+
// Database shortcuts
|
|
3202
|
+
push,
|
|
3203
|
+
migrate,
|
|
3204
|
+
generate
|
|
3642
3205
|
}
|
|
3643
3206
|
});
|
|
3644
3207
|
void runMain(main);
|
package/dist/module.mjs
CHANGED
|
@@ -1740,6 +1740,18 @@ export default async function (batch: any, env?: any, ctx?: any) {
|
|
|
1740
1740
|
senders: senderIdentities
|
|
1741
1741
|
};
|
|
1742
1742
|
}
|
|
1743
|
+
const schemaFallback = resolver.resolve("./runtime/server/utils/schema-fallback");
|
|
1744
|
+
nuxt.options.alias["#qarpeo/auth/schema"] = schemaFallback;
|
|
1745
|
+
nuxt.options.alias["#qarpeo/cms/schema"] = schemaFallback;
|
|
1746
|
+
nuxt.options.alias["#qarpeo/cms/manifest"] = schemaFallback;
|
|
1747
|
+
nuxt.options.alias["#qarpeo/payments/schema"] = schemaFallback;
|
|
1748
|
+
nuxt.options.alias["#qarpeo/notifications/schema"] = schemaFallback;
|
|
1749
|
+
nuxt.options.alias["#qarpeo/tenants/schema"] = schemaFallback;
|
|
1750
|
+
nuxt.options.alias["#qarpeo/schema"] = schemaFallback;
|
|
1751
|
+
nuxt.options.alias["@schema"] = schemaFallback;
|
|
1752
|
+
nuxt.options.alias["#qarpeo/db/types"] = schemaFallback;
|
|
1753
|
+
nuxt.options.alias["qarpeo/db/types"] = schemaFallback;
|
|
1754
|
+
nuxt.options.alias["#qarpeo/db/zod"] = schemaFallback;
|
|
1743
1755
|
const isDrizzle = Boolean(options.db || options.d1);
|
|
1744
1756
|
let schemaTemplateDst = "";
|
|
1745
1757
|
if (isDrizzle) {
|
|
@@ -2258,19 +2270,23 @@ export default async function (batch: any, env?: any, ctx?: any) {
|
|
|
2258
2270
|
database_id: dbId
|
|
2259
2271
|
});
|
|
2260
2272
|
}
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2273
|
+
nitroConfig.alias = nitroConfig.alias || {};
|
|
2274
|
+
const schemaAliases = [
|
|
2275
|
+
"#qarpeo/auth/schema",
|
|
2276
|
+
"#qarpeo/cms/schema",
|
|
2277
|
+
"#qarpeo/cms/manifest",
|
|
2278
|
+
"#qarpeo/payments/schema",
|
|
2279
|
+
"#qarpeo/notifications/schema",
|
|
2280
|
+
"#qarpeo/tenants/schema",
|
|
2281
|
+
"#qarpeo/schema",
|
|
2282
|
+
"@schema",
|
|
2283
|
+
"#qarpeo/db/types",
|
|
2284
|
+
"qarpeo/db/types",
|
|
2285
|
+
"#qarpeo/db/zod"
|
|
2286
|
+
];
|
|
2287
|
+
for (const k of schemaAliases) {
|
|
2288
|
+
if (nuxt.options.alias[k]) {
|
|
2289
|
+
nitroConfig.alias[k] = nuxt.options.alias[k];
|
|
2274
2290
|
}
|
|
2275
2291
|
}
|
|
2276
2292
|
if (options.queue) {
|
package/dist/types.d.ts
CHANGED
|
@@ -2551,7 +2551,21 @@ export interface QarpeoOptions {
|
|
|
2551
2551
|
site?: QarpeoSiteConfig;
|
|
2552
2552
|
/** Native SEO engine configuration (alias for site config) */
|
|
2553
2553
|
seo?: boolean | QarpeoSiteConfig;
|
|
2554
|
-
/**
|
|
2554
|
+
/**
|
|
2555
|
+
* Cloudflare Worker service name override.
|
|
2556
|
+
*
|
|
2557
|
+
* By default, Qarpeo infers the worker name from `package.json` -> `name` (sanitized for
|
|
2558
|
+
* Cloudflare).
|
|
2559
|
+
*
|
|
2560
|
+
* @example
|
|
2561
|
+
* ;```ts
|
|
2562
|
+
* qarpeo: {
|
|
2563
|
+
* workerName: "my-edge-app",
|
|
2564
|
+
* }
|
|
2565
|
+
* ```
|
|
2566
|
+
*/
|
|
2567
|
+
workerName?: string;
|
|
2568
|
+
/** Project / Cloudflare Worker name override (alias for workerName) */
|
|
2555
2569
|
name?: string;
|
|
2556
2570
|
/**
|
|
2557
2571
|
* Use live Cloudflare remote bindings during `nuxt dev` instead of local Miniflare emulation.
|