qarpeo 0.1.18 → 0.1.21
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/README.md +96 -96
- package/dist/chunks/auth-schema.mjs +3 -1
- package/dist/chunks/wrangler.mjs +22 -3
- package/dist/cli/index.mjs +448 -221
- package/dist/fate/index.d.ts +29 -22
- package/dist/fate/index.mjs +1 -3
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +103 -82
- package/dist/runtime/ai.d.ts +2 -2
- package/dist/runtime/app/components/BlobImage.vue +119 -107
- package/dist/runtime/app/components/CMSBlocks.vue +104 -93
- package/dist/runtime/app/components/CMSContent.vue +24 -23
- package/dist/runtime/app/components/CMSImage.vue +49 -49
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -110
- package/dist/runtime/app/components/CMSPreviewBanner.vue +83 -79
- package/dist/runtime/app/components/CMSVersionBanner.vue +53 -49
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +140 -140
- package/dist/runtime/app/components/ContentRenderer.vue +83 -80
- package/dist/runtime/app/components/FileUpload.vue +200 -196
- package/dist/runtime/app/components/ImpersonationBanner.vue +61 -57
- package/dist/runtime/app/components/QarpeoWelcome.vue +84 -84
- package/dist/runtime/app/components/SignedIn.vue +13 -13
- package/dist/runtime/app/components/SignedOut.vue +13 -13
- package/dist/runtime/app/components/shiki.css +34 -34
- package/dist/runtime/app/composables/ai.d.ts +22 -22
- package/dist/runtime/app/composables/ai.mjs +3 -7
- package/dist/runtime/app/composables/analytics.mjs +1 -1
- package/dist/runtime/app/composables/api-tokens.mjs +1 -1
- package/dist/runtime/app/composables/auth.d.ts +6 -7
- package/dist/runtime/app/composables/auth.mjs +6 -3
- package/dist/runtime/app/composables/chat.mjs +3 -7
- package/dist/runtime/app/composables/cms-preview.d.ts +3 -3
- package/dist/runtime/app/composables/cms-preview.mjs +1 -1
- package/dist/runtime/app/composables/cms.d.ts +3 -5
- package/dist/runtime/app/composables/cms.mjs +2 -2
- package/dist/runtime/app/composables/docs-version.d.ts +8 -7
- package/dist/runtime/app/composables/docs-version.mjs +3 -3
- package/dist/runtime/app/composables/impersonation.mjs +1 -1
- package/dist/runtime/app/composables/notifications.d.ts +5 -5
- package/dist/runtime/app/composables/notifications.mjs +4 -5
- package/dist/runtime/app/composables/organization.mjs +1 -1
- package/dist/runtime/app/composables/passkey.mjs +1 -1
- package/dist/runtime/app/composables/passwordless.mjs +1 -1
- package/dist/runtime/app/composables/payments.d.ts +2 -1
- package/dist/runtime/app/composables/payments.mjs +1 -1
- package/dist/runtime/app/composables/realtime.d.ts +13 -13
- package/dist/runtime/app/composables/realtime.mjs +2 -2
- package/dist/runtime/app/composables/resumable-upload.d.ts +11 -11
- package/dist/runtime/app/composables/resumable-upload.mjs +1 -1
- package/dist/runtime/app/composables/site.mjs +1 -1
- package/dist/runtime/app/composables/storage.d.ts +151 -11
- package/dist/runtime/app/composables/storage.mjs +291 -33
- package/dist/runtime/app/composables/turnstile.mjs +1 -1
- package/dist/runtime/app/composables/two-factor.mjs +1 -1
- package/dist/runtime/app/pages/devtools/agents.vue +716 -716
- package/dist/runtime/app/pages/devtools/analytics.vue +616 -616
- package/dist/runtime/app/pages/devtools/auth.vue +381 -350
- package/dist/runtime/app/pages/devtools/blob.vue +743 -744
- package/dist/runtime/app/pages/devtools/db.vue +545 -545
- package/dist/runtime/app/pages/devtools/domains.vue +771 -771
- package/dist/runtime/app/pages/devtools/kv.vue +827 -828
- package/dist/runtime/app/pages/devtools/logs.vue +649 -653
- package/dist/runtime/app/pages/devtools/mail.vue +388 -388
- package/dist/runtime/app/pages/devtools/overview.vue +391 -389
- package/dist/runtime/app/pages/devtools/realtime.vue +89 -27
- package/dist/runtime/app/pages/devtools/security.vue +20 -5
- package/dist/runtime/app/pages/devtools/settings.vue +559 -559
- package/dist/runtime/app/pages/devtools/tasks.vue +26 -10
- package/dist/runtime/app/pages/devtools.vue +176 -176
- package/dist/runtime/app/plugins/seo.mjs +1 -1
- package/dist/runtime/app/plugins/shortcuts.client.d.ts +1 -4
- package/dist/runtime/app/public/sw-notifications.mjs +47 -52
- package/dist/runtime/blob.mjs +11 -4
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.mjs +12 -2
- package/dist/runtime/cache.d.ts +2 -1
- package/dist/runtime/kv.mjs +4 -1
- package/dist/runtime/providers/qarpeo.d.ts +3 -3
- package/dist/runtime/server/durable-objects/agent.mjs +1 -1
- package/dist/runtime/server/durable-objects/room.d.ts +2 -2
- package/dist/runtime/server/durable-objects/room.mjs +5 -5
- package/dist/runtime/server/middleware/devtools.mjs +6 -2
- package/dist/runtime/server/plugins/cms.d.ts +4 -2
- package/dist/runtime/server/plugins/dev-proxy.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +4 -1
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +4 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +2 -2
- package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/room.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/rooms.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/analytics.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/ban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/unban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/tasks/run.post.mjs +3 -1
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +8 -2
- package/dist/runtime/server/routes/ai/embed.post.d.ts +1 -4
- package/dist/runtime/server/routes/ai/search.post.d.ts +2 -2
- package/dist/runtime/server/routes/auth/account.delete.mjs +1 -1
- package/dist/runtime/server/routes/auth/handler.mjs +6 -1
- package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +7 -1
- package/dist/runtime/server/routes/auth/otp/verify.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +7 -1
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +8 -2
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +6 -1
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/crawl.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/invoice.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/og-image.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/pdf.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/pdf.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/screenshot.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/screenshot.post.mjs +5 -1
- package/dist/runtime/server/routes/cms/components/index.get.d.ts +2 -2
- package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +4 -3
- package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +8 -8
- package/dist/runtime/server/routes/cms/search.get.mjs +1 -1
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +7 -7
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +9 -2
- package/dist/runtime/server/routes/docs/search.get.d.ts +9 -9
- package/dist/runtime/server/routes/fate.mjs +5 -8
- package/dist/runtime/server/routes/mail/bounce.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/unsubscribe.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +7 -1
- package/dist/runtime/server/routes/payments/usage.get.d.ts +8 -8
- package/dist/runtime/server/routes/payments/usage.post.d.ts +2 -2
- package/dist/runtime/server/routes/realtime/history.delete.d.ts +4 -3
- package/dist/runtime/server/routes/realtime/history.get.d.ts +7 -6
- package/dist/runtime/server/routes/realtime/ws.get.mjs +6 -1
- package/dist/runtime/server/routes/robots.txt.get.mjs +1 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
- package/dist/runtime/server/routes/storage/multipart/abort.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.mjs +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.mjs +7 -3
- package/dist/runtime/server/routes/storage/multipart/part.put.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/part.put.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +2 -4
- package/dist/runtime/server/tasks/cms/publish.mjs +1 -1
- package/dist/runtime/server/utils/ai.d.ts +9 -9
- package/dist/runtime/server/utils/ai.mjs +3 -3
- package/dist/runtime/server/utils/auth.d.ts +12 -16
- package/dist/runtime/server/utils/auth.mjs +15 -9
- package/dist/runtime/server/utils/bots.mjs +21 -7
- package/dist/runtime/server/utils/browser-utils.d.ts +44 -41
- package/dist/runtime/server/utils/browser-utils.mjs +14 -4
- package/dist/runtime/server/utils/cache.d.ts +5 -5
- package/dist/runtime/server/utils/cms/common.d.ts +26 -0
- package/dist/runtime/server/utils/cms/common.mjs +68 -0
- package/dist/runtime/server/utils/cms/git.d.ts +24 -0
- package/dist/runtime/server/utils/cms/git.mjs +240 -0
- package/dist/runtime/server/utils/cms/markdown.d.ts +22 -0
- package/dist/runtime/server/utils/cms/markdown.mjs +92 -0
- package/dist/runtime/server/utils/cms/path.d.ts +51 -0
- package/dist/runtime/server/utils/cms/path.mjs +127 -0
- package/dist/runtime/server/utils/cms/search.d.ts +22 -0
- package/dist/runtime/server/utils/cms/search.mjs +221 -0
- package/dist/runtime/server/utils/cms-events.d.ts +1 -1
- package/dist/runtime/server/utils/cms-events.mjs +2 -2
- package/dist/runtime/server/utils/cms-filter.mjs +2 -2
- package/dist/runtime/server/utils/cms.d.ts +17 -149
- package/dist/runtime/server/utils/cms.mjs +52 -761
- package/dist/runtime/server/utils/config.d.ts +5 -4
- package/dist/runtime/server/utils/domains.mjs +7 -4
- package/dist/runtime/server/utils/email-templates.d.ts +10 -7
- package/dist/runtime/server/utils/email-templates.mjs +20 -5
- package/dist/runtime/server/utils/feed.d.ts +2 -2
- package/dist/runtime/server/utils/feed.mjs +3 -1
- package/dist/runtime/server/utils/mail-suppression.d.ts +8 -24
- package/dist/runtime/server/utils/mail-suppression.mjs +2 -2
- package/dist/runtime/server/utils/mail.d.ts +7 -8
- package/dist/runtime/server/utils/mail.mjs +17 -12
- package/dist/runtime/server/utils/multipart-store.d.ts +2 -2
- package/dist/runtime/server/utils/notifications.d.ts +9 -23
- package/dist/runtime/server/utils/organization.mjs +4 -12
- package/dist/runtime/server/utils/passwordless.mjs +1 -1
- package/dist/runtime/server/utils/payments.d.ts +2 -6
- package/dist/runtime/server/utils/payments.mjs +1 -1
- package/dist/runtime/server/utils/queue.d.ts +21 -31
- package/dist/runtime/server/utils/rag.d.ts +4 -4
- package/dist/runtime/server/utils/rag.mjs +8 -8
- package/dist/runtime/server/utils/realtime-store.d.ts +2 -2
- package/dist/runtime/server/utils/realtime.d.ts +26 -28
- package/dist/runtime/server/utils/scheduled-task.d.ts +1 -3
- package/dist/runtime/server/utils/security-store.d.ts +2 -2
- package/dist/runtime/server/utils/session.d.ts +9 -11
- package/dist/runtime/server/utils/sso.d.ts +9 -15
- package/dist/runtime/server/utils/sso.mjs +4 -8
- package/dist/runtime/server/utils/storage.d.ts +19 -2
- package/dist/runtime/server/utils/storage.mjs +36 -7
- package/dist/runtime/server/utils/tenant.mjs +3 -1
- package/dist/runtime/server/utils/turnstile.d.ts +3 -5
- package/dist/runtime/server/utils/vapid.d.ts +5 -8
- package/dist/runtime/server/utils/vapid.mjs +26 -13
- package/dist/runtime/service.d.ts +13 -13
- package/dist/runtime/service.mjs +4 -2
- package/dist/runtime/test-utils.d.ts +20 -30
- package/dist/runtime/test-utils.mjs +5 -4
- package/dist/runtime/types/auth-globals.d.ts +14 -14
- package/dist/runtime/types/imports.d.ts +82 -82
- package/dist/runtime/types/index.d.ts +2 -2
- package/dist/runtime/types/r2.d.ts +5 -0
- package/dist/runtime/types/service.d.ts +11 -18
- package/dist/types.d.ts +100 -107
- package/dist/utils/auth-schema.d.ts +2 -2
- package/dist/utils/cms-sources.d.ts +3 -3
- package/dist/utils/local-db.d.ts +3 -3
- package/dist/utils/notifications-schema.d.ts +1 -3
- package/dist/utils/pkg.d.ts +7 -0
- package/dist/utils/queue.d.ts +3 -3
- package/dist/utils/tasks.d.ts +3 -2
- package/package.json +11 -8
package/dist/cli/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { defineCommand, runMain } from 'citty';
|
|
3
|
+
import { j as findSchemaFiles, k as resolveBinaryPath, e as ensurePackage, l as getLocalDatabaseContext, m as getJiti, n as spawnBinSync, b as resolveProjectName, a as checkDrizzleVersion, o as findLocalD1Database, v as version } from '../chunks/wrangler.mjs';
|
|
3
4
|
import { spawnSync, spawn } from 'node:child_process';
|
|
4
5
|
import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
5
6
|
import { loadNuxtConfig } from '@nuxt/kit';
|
|
6
7
|
import { resolve, join, extname } from 'pathe';
|
|
7
|
-
import { j as findSchemaFiles, k as resolveBinaryPath, e as ensurePackage, l as getLocalDatabaseContext, m as getJiti, b as resolveProjectName, a as checkDrizzleVersion, n as findLocalD1Database } from '../chunks/wrangler.mjs';
|
|
8
8
|
import { reset, seed } from 'drizzle-seed';
|
|
9
9
|
import { stdin, stdout } from 'node:process';
|
|
10
10
|
import readline from 'node:readline/promises';
|
|
@@ -429,7 +429,9 @@ const list = defineCommand({
|
|
|
429
429
|
shell: process.platform === "win32"
|
|
430
430
|
});
|
|
431
431
|
if (result.status !== 0) {
|
|
432
|
-
console.error(
|
|
432
|
+
console.error(
|
|
433
|
+
"\n\u274C [qarpeo] Failed to list D1 databases. Make sure you are logged in (`qp login`) or have CLOUDFLARE_API_TOKEN set in .env."
|
|
434
|
+
);
|
|
433
435
|
process.exit(result.status ?? 1);
|
|
434
436
|
}
|
|
435
437
|
if (!args.json) {
|
|
@@ -525,7 +527,9 @@ const migrate = defineCommand({
|
|
|
525
527
|
);
|
|
526
528
|
}
|
|
527
529
|
if (args.backup && args.remote && !args.dryRun) {
|
|
528
|
-
console.log(
|
|
530
|
+
console.log(
|
|
531
|
+
`\u{1F6E1}\uFE0F [qarpeo] Creating automatic snapshot backup of remote D1 database "${dbName}"...`
|
|
532
|
+
);
|
|
529
533
|
const backupArgs = ["d1", "backup", "create", dbName];
|
|
530
534
|
if (wranglerConfigPath) backupArgs.push("-c", wranglerConfigPath);
|
|
531
535
|
const backupRes = spawnSync(execPath, backupArgs, {
|
|
@@ -536,7 +540,9 @@ const migrate = defineCommand({
|
|
|
536
540
|
if (backupRes.status === 0) {
|
|
537
541
|
console.log(`\u2705 [qarpeo] Backup created successfully prior to migration.`);
|
|
538
542
|
} else {
|
|
539
|
-
console.warn(
|
|
543
|
+
console.warn(
|
|
544
|
+
`\u26A0\uFE0F [qarpeo] Backup command exited with code ${backupRes.status}. Continuing...`
|
|
545
|
+
);
|
|
540
546
|
}
|
|
541
547
|
}
|
|
542
548
|
const wranglerArgs = ["d1", "migrations", "apply", dbName];
|
|
@@ -564,7 +570,7 @@ const migrate = defineCommand({
|
|
|
564
570
|
console.log(`\u2705 [qarpeo] Migrations applied successfully!`);
|
|
565
571
|
if (args.prune) {
|
|
566
572
|
const { getActiveAuthTableNames, ALL_AUTH_TABLE_NAMES } = await import('../chunks/auth-schema.mjs');
|
|
567
|
-
const { findLocalD1Database } = await import('../chunks/wrangler.mjs').then(function (n) { return n.
|
|
573
|
+
const { findLocalD1Database } = await import('../chunks/wrangler.mjs').then(function (n) { return n.p; });
|
|
568
574
|
const authConfig = nuxtConfig.qarpeo?.auth || nuxtConfig.auth;
|
|
569
575
|
const activeTables = getActiveAuthTableNames(authConfig);
|
|
570
576
|
const deprecatedTables = ALL_AUTH_TABLE_NAMES.filter(
|
|
@@ -602,7 +608,11 @@ const migrate = defineCommand({
|
|
|
602
608
|
`--command=DROP TABLE IF EXISTS ${tbl};`
|
|
603
609
|
];
|
|
604
610
|
if (wranglerConfigPath) dropArgs.push("-c", wranglerConfigPath);
|
|
605
|
-
spawnSync(execPath, dropArgs, {
|
|
611
|
+
spawnSync(execPath, dropArgs, {
|
|
612
|
+
cwd,
|
|
613
|
+
stdio: "inherit",
|
|
614
|
+
shell: process.platform === "win32"
|
|
615
|
+
});
|
|
606
616
|
console.log(` \u2713 Dropped remote table: ${tbl}`);
|
|
607
617
|
}
|
|
608
618
|
console.log(`\u2705 [qarpeo] Remote auth tables pruned successfully.`);
|
|
@@ -774,8 +784,10 @@ const rollback = defineCommand({
|
|
|
774
784
|
console.error(" Usage: qp db rollback [name] --backup-id <id>\n");
|
|
775
785
|
process.exit(1);
|
|
776
786
|
}
|
|
777
|
-
console.log(
|
|
778
|
-
|
|
787
|
+
console.log(
|
|
788
|
+
`
|
|
789
|
+
\u26A0\uFE0F [qarpeo] Restoring D1 database "${dbName}" to backup snapshot: ${backupId}...`
|
|
790
|
+
);
|
|
779
791
|
const restoreArgs = ["d1", "backup", "restore", dbName, backupId];
|
|
780
792
|
if (wranglerConfigPath) restoreArgs.push("-c", wranglerConfigPath);
|
|
781
793
|
const restoreRes = spawnSync(wrangler, restoreArgs, {
|
|
@@ -788,9 +800,11 @@ const rollback = defineCommand({
|
|
|
788
800
|
\u274C [qarpeo] Rollback failed. Please check your permissions and try again.`);
|
|
789
801
|
process.exit(restoreRes.status ?? 1);
|
|
790
802
|
}
|
|
791
|
-
console.log(
|
|
803
|
+
console.log(
|
|
804
|
+
`
|
|
792
805
|
\u2705 [qarpeo] D1 database "${dbName}" successfully restored to snapshot ${backupId}!
|
|
793
|
-
`
|
|
806
|
+
`
|
|
807
|
+
);
|
|
794
808
|
}
|
|
795
809
|
});
|
|
796
810
|
|
|
@@ -1157,7 +1171,7 @@ const deleteCommand = defineCommand({
|
|
|
1157
1171
|
\u2705 [qarpeo] Successfully deleted Worker "${workerName}" from Cloudflare!
|
|
1158
1172
|
`);
|
|
1159
1173
|
return;
|
|
1160
|
-
} catch
|
|
1174
|
+
} catch {
|
|
1161
1175
|
}
|
|
1162
1176
|
}
|
|
1163
1177
|
await ensurePackage("wrangler", {
|
|
@@ -1169,11 +1183,10 @@ const deleteCommand = defineCommand({
|
|
|
1169
1183
|
if (args.env) {
|
|
1170
1184
|
wranglerArgs.push("--env", args.env);
|
|
1171
1185
|
}
|
|
1172
|
-
const result =
|
|
1186
|
+
const result = spawnBinSync(wrangler, wranglerArgs, {
|
|
1173
1187
|
cwd,
|
|
1174
1188
|
stdio: "inherit",
|
|
1175
|
-
env: process.env
|
|
1176
|
-
shell: process.platform === "win32"
|
|
1189
|
+
env: process.env
|
|
1177
1190
|
});
|
|
1178
1191
|
if (result.status !== 0) {
|
|
1179
1192
|
console.error(`
|
|
@@ -1191,26 +1204,39 @@ function loadDotEnv$2(cwd) {
|
|
|
1191
1204
|
if (!existsSync(envPath)) return;
|
|
1192
1205
|
try {
|
|
1193
1206
|
const raw = readFileSync(envPath, "utf8");
|
|
1207
|
+
let hasDummy = false;
|
|
1208
|
+
const cleanedLines = [];
|
|
1194
1209
|
for (const line of raw.split(/\r?\n/)) {
|
|
1195
1210
|
const trimmed = line.trim();
|
|
1196
|
-
if (!trimmed || trimmed.startsWith("#"))
|
|
1211
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
1212
|
+
cleanedLines.push(line);
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1197
1215
|
const eqIdx = trimmed.indexOf("=");
|
|
1198
|
-
if (eqIdx === -1)
|
|
1216
|
+
if (eqIdx === -1) {
|
|
1217
|
+
cleanedLines.push(line);
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1199
1220
|
const key = trimmed.slice(0, eqIdx).trim();
|
|
1200
1221
|
let val = trimmed.slice(eqIdx + 1).trim();
|
|
1201
1222
|
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
1202
1223
|
val = val.slice(1, -1);
|
|
1203
1224
|
}
|
|
1204
1225
|
if ((key === "CLOUDFLARE_API_TOKEN" || key === "CLOUDFLARE_ACCOUNT_ID" || key === "CF_API_TOKEN") && (val.startsWith("dummy-") || val === "dummy-dev-api-token" || val === "dummy-dev-account-id")) {
|
|
1226
|
+
hasDummy = true;
|
|
1205
1227
|
if (process.env[key] && (process.env[key].startsWith("dummy-") || process.env[key] === val)) {
|
|
1206
1228
|
delete process.env[key];
|
|
1207
1229
|
}
|
|
1208
1230
|
continue;
|
|
1209
1231
|
}
|
|
1232
|
+
cleanedLines.push(line);
|
|
1210
1233
|
if (process.env[key] === void 0) {
|
|
1211
1234
|
process.env[key] = val;
|
|
1212
1235
|
}
|
|
1213
1236
|
}
|
|
1237
|
+
if (hasDummy) {
|
|
1238
|
+
writeFileSync(envPath, cleanedLines.join("\n"), "utf8");
|
|
1239
|
+
}
|
|
1214
1240
|
} catch {
|
|
1215
1241
|
}
|
|
1216
1242
|
}
|
|
@@ -1218,31 +1244,18 @@ function getGitBranch(cwd) {
|
|
|
1218
1244
|
if (process.env.GITHUB_HEAD_REF) return process.env.GITHUB_HEAD_REF;
|
|
1219
1245
|
if (process.env.GITHUB_REF_NAME) return process.env.GITHUB_REF_NAME;
|
|
1220
1246
|
try {
|
|
1221
|
-
const res =
|
|
1247
|
+
const res = spawnBinSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
1222
1248
|
cwd,
|
|
1223
1249
|
encoding: "utf8"
|
|
1224
1250
|
});
|
|
1225
|
-
|
|
1226
|
-
|
|
1251
|
+
const out = String(res.stdout || "").trim();
|
|
1252
|
+
if (res.status === 0 && out) {
|
|
1253
|
+
return out;
|
|
1227
1254
|
}
|
|
1228
1255
|
} catch {
|
|
1229
1256
|
}
|
|
1230
1257
|
return null;
|
|
1231
1258
|
}
|
|
1232
|
-
async function promptWorkerName(defaultName) {
|
|
1233
|
-
if (!stdin.isTTY) {
|
|
1234
|
-
return defaultName;
|
|
1235
|
-
}
|
|
1236
|
-
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
1237
|
-
try {
|
|
1238
|
-
const answer = await rl.question(`
|
|
1239
|
-
\u{1F3F7}\uFE0F Cloudflare Worker Name [${defaultName}]: `);
|
|
1240
|
-
const trimmed = answer.trim();
|
|
1241
|
-
return trimmed || defaultName;
|
|
1242
|
-
} finally {
|
|
1243
|
-
rl.close();
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
1259
|
function sanitizeSuffix(raw) {
|
|
1247
1260
|
const clean = raw.toLowerCase().replace(/[^a-z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
1248
1261
|
return clean.slice(0, 20) || "preview";
|
|
@@ -1253,6 +1266,12 @@ const deploy = defineCommand({
|
|
|
1253
1266
|
description: "Build and deploy full-stack Nuxt application directly to Cloudflare Workers"
|
|
1254
1267
|
},
|
|
1255
1268
|
args: {
|
|
1269
|
+
dir: {
|
|
1270
|
+
type: "positional",
|
|
1271
|
+
description: "Project directory to deploy (e.g. docs, playground)",
|
|
1272
|
+
required: false,
|
|
1273
|
+
default: "."
|
|
1274
|
+
},
|
|
1256
1275
|
cwd: {
|
|
1257
1276
|
type: "string",
|
|
1258
1277
|
description: "Working directory",
|
|
@@ -1262,6 +1281,12 @@ const deploy = defineCommand({
|
|
|
1262
1281
|
type: "string",
|
|
1263
1282
|
description: "Cloudflare Worker service name (overrides package.json and config)"
|
|
1264
1283
|
},
|
|
1284
|
+
yes: {
|
|
1285
|
+
type: "boolean",
|
|
1286
|
+
alias: "y",
|
|
1287
|
+
description: "Auto-confirm existing worker name and prompts",
|
|
1288
|
+
default: false
|
|
1289
|
+
},
|
|
1265
1290
|
build: {
|
|
1266
1291
|
type: "boolean",
|
|
1267
1292
|
description: "Build the Nuxt application before deploying (pass --no-build to skip)",
|
|
@@ -1303,15 +1328,18 @@ const deploy = defineCommand({
|
|
|
1303
1328
|
}
|
|
1304
1329
|
},
|
|
1305
1330
|
async run({ args }) {
|
|
1306
|
-
const
|
|
1331
|
+
const targetDir = args.dir && args.dir !== "." ? args.dir : args.cwd;
|
|
1332
|
+
const cwd = resolve(process.cwd(), targetDir);
|
|
1307
1333
|
loadDotEnv$2(cwd);
|
|
1308
1334
|
const isPreview = Boolean(args.preview);
|
|
1309
1335
|
const branch = getGitBranch(cwd);
|
|
1310
1336
|
const previewSuffix = branch && branch !== "main" && branch !== "master" && branch !== "HEAD" ? sanitizeSuffix(branch) : "preview";
|
|
1311
1337
|
if (isPreview) {
|
|
1312
|
-
console.log(
|
|
1338
|
+
console.log(
|
|
1339
|
+
`
|
|
1313
1340
|
\u26A1 [qarpeo] Starting Cloudflare Workers PREVIEW deployment (${previewSuffix})...
|
|
1314
|
-
`
|
|
1341
|
+
`
|
|
1342
|
+
);
|
|
1315
1343
|
} else {
|
|
1316
1344
|
console.log(`
|
|
1317
1345
|
\u26A1 [qarpeo] Starting Cloudflare Workers edge deployment...
|
|
@@ -1334,16 +1362,17 @@ const deploy = defineCommand({
|
|
|
1334
1362
|
process.env.CLOUDFLARE_API_TOKEN || process.env.CF_API_TOKEN || process.env.CLOUDFLARE_EMAIL && process.env.CLOUDFLARE_API_KEY
|
|
1335
1363
|
);
|
|
1336
1364
|
if (!hasEnvAuth && !args.dryRun) {
|
|
1337
|
-
|
|
1365
|
+
console.log("\u{1F50D} [qarpeo] Verifying Cloudflare credentials...");
|
|
1366
|
+
const whoamiRes = spawnBinSync(wranglerBin, ["whoami"], {
|
|
1338
1367
|
cwd,
|
|
1339
|
-
encoding: "utf8"
|
|
1340
|
-
shell: process.platform === "win32"
|
|
1368
|
+
encoding: "utf8"
|
|
1341
1369
|
});
|
|
1342
1370
|
if (whoamiRes.status !== 0) {
|
|
1343
1371
|
console.error("\u274C [qarpeo] Not authenticated with Cloudflare.");
|
|
1344
|
-
console.error("\u{1F449} Run '
|
|
1372
|
+
console.error("\u{1F449} Run 'vpx qp login' or set CLOUDFLARE_API_TOKEN in your environment.\n");
|
|
1345
1373
|
process.exit(1);
|
|
1346
1374
|
}
|
|
1375
|
+
console.log("\u2714 Cloudflare credentials verified\n");
|
|
1347
1376
|
}
|
|
1348
1377
|
if (args.build) {
|
|
1349
1378
|
console.log("\u{1F4E6} [qarpeo] Building Nuxt application for Cloudflare Workers...");
|
|
@@ -1354,26 +1383,23 @@ const deploy = defineCommand({
|
|
|
1354
1383
|
const nuxtBin = resolveBinaryPath("nuxt", cwd);
|
|
1355
1384
|
let buildRes;
|
|
1356
1385
|
if (nuxtBin) {
|
|
1357
|
-
buildRes =
|
|
1386
|
+
buildRes = spawnBinSync(nuxtBin, ["build"], {
|
|
1358
1387
|
cwd,
|
|
1359
1388
|
stdio: "inherit",
|
|
1360
|
-
shell: process.platform === "win32",
|
|
1361
1389
|
env: buildEnv
|
|
1362
1390
|
});
|
|
1363
1391
|
} else {
|
|
1364
|
-
const
|
|
1365
|
-
buildRes =
|
|
1392
|
+
const vpxBin = process.platform === "win32" ? "vpx.cmd" : "vpx";
|
|
1393
|
+
buildRes = spawnBinSync(vpxBin, ["nuxt", "build"], {
|
|
1366
1394
|
cwd,
|
|
1367
1395
|
stdio: "inherit",
|
|
1368
|
-
shell: process.platform === "win32",
|
|
1369
1396
|
env: buildEnv
|
|
1370
1397
|
});
|
|
1371
1398
|
if (buildRes.status !== 0) {
|
|
1372
1399
|
const npxBin = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
1373
|
-
buildRes =
|
|
1400
|
+
buildRes = spawnBinSync(npxBin, ["nuxt", "build"], {
|
|
1374
1401
|
cwd,
|
|
1375
1402
|
stdio: "inherit",
|
|
1376
|
-
shell: process.platform === "win32",
|
|
1377
1403
|
env: buildEnv
|
|
1378
1404
|
});
|
|
1379
1405
|
}
|
|
@@ -1403,14 +1429,7 @@ const deploy = defineCommand({
|
|
|
1403
1429
|
} catch {
|
|
1404
1430
|
}
|
|
1405
1431
|
const defaultName = config.name || "qarpeo";
|
|
1406
|
-
|
|
1407
|
-
if (!baseWorkerName) {
|
|
1408
|
-
if (!args.dryRun) {
|
|
1409
|
-
baseWorkerName = await promptWorkerName(defaultName);
|
|
1410
|
-
} else {
|
|
1411
|
-
baseWorkerName = defaultName;
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1432
|
+
const baseWorkerName = args.name || process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME || defaultName;
|
|
1414
1433
|
const originalName = baseWorkerName;
|
|
1415
1434
|
if (isPreview) {
|
|
1416
1435
|
config.name = `${baseWorkerName}-${previewSuffix}`;
|
|
@@ -1426,14 +1445,13 @@ const deploy = defineCommand({
|
|
|
1426
1445
|
try {
|
|
1427
1446
|
let modified = isPreview;
|
|
1428
1447
|
if (Array.isArray(config.d1_databases) && config.d1_databases.length > 0) {
|
|
1429
|
-
const listRes =
|
|
1448
|
+
const listRes = spawnBinSync(wranglerBin, ["d1", "list", "--json"], {
|
|
1430
1449
|
cwd,
|
|
1431
|
-
encoding: "utf8"
|
|
1432
|
-
shell: process.platform === "win32"
|
|
1450
|
+
encoding: "utf8"
|
|
1433
1451
|
});
|
|
1434
1452
|
let existingDbs = [];
|
|
1435
1453
|
try {
|
|
1436
|
-
existingDbs = JSON.parse(listRes.stdout || "[]");
|
|
1454
|
+
existingDbs = JSON.parse(String(listRes.stdout || "[]"));
|
|
1437
1455
|
} catch {
|
|
1438
1456
|
}
|
|
1439
1457
|
for (const d1 of config.d1_databases) {
|
|
@@ -1441,7 +1459,9 @@ const deploy = defineCommand({
|
|
|
1441
1459
|
const explicitName = isPreview ? process.env.QARPEO_PREVIEW_DB_NAME || process.env.PREVIEW_DB_NAME : process.env.QARPEO_PROD_DB_NAME || process.env.QARPEO_DB_NAME || process.env.DB_NAME;
|
|
1442
1460
|
const targetDbName = explicitName || (isPreview ? `${d1.database_name}_preview` : d1.database_name);
|
|
1443
1461
|
if (explicitId) {
|
|
1444
|
-
console.log(
|
|
1462
|
+
console.log(
|
|
1463
|
+
`\u{1F517} [qarpeo] Using explicit ${isPreview ? "preview" : "production"} D1 database: ${targetDbName} (${explicitId})`
|
|
1464
|
+
);
|
|
1445
1465
|
d1.database_id = explicitId;
|
|
1446
1466
|
d1.database_name = targetDbName;
|
|
1447
1467
|
modified = true;
|
|
@@ -1451,43 +1471,52 @@ const deploy = defineCommand({
|
|
|
1451
1471
|
if (isPlaceholder) {
|
|
1452
1472
|
const match = existingDbs.find((db) => db.name === targetDbName);
|
|
1453
1473
|
if (match) {
|
|
1454
|
-
console.log(
|
|
1474
|
+
console.log(
|
|
1475
|
+
`\u{1F517} [qarpeo] Linked ${isPreview ? "preview" : "remote"} D1 database: ${targetDbName} (${match.uuid})`
|
|
1476
|
+
);
|
|
1455
1477
|
d1.database_id = match.uuid;
|
|
1456
1478
|
d1.database_name = targetDbName;
|
|
1457
1479
|
modified = true;
|
|
1458
1480
|
} else {
|
|
1459
|
-
console.log(
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1481
|
+
console.log(
|
|
1482
|
+
`\u{1F528} [qarpeo] Creating ${isPreview ? "preview" : "remote"} D1 database: ${targetDbName}...`
|
|
1483
|
+
);
|
|
1484
|
+
const createRes = spawnBinSync(wranglerBin, ["d1", "create", targetDbName], {
|
|
1485
|
+
cwd,
|
|
1486
|
+
encoding: "utf8"
|
|
1487
|
+
});
|
|
1488
|
+
const stdoutText = String(createRes.stdout || "");
|
|
1489
|
+
const matchUuid = stdoutText.match(/database_id\s*:\s*"([^"]+)"/) || stdoutText.match(/database_id\s*=\s*"([^"]+)"/) || stdoutText.match(/"database_id"\s*:\s*"([^"]+)"/) || stdoutText.match(
|
|
1490
|
+
/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i
|
|
1464
1491
|
);
|
|
1465
|
-
const matchUuid = createRes.stdout.match(/database_id\s*:\s*"([^"]+)"/) || createRes.stdout.match(/database_id\s*=\s*"([^"]+)"/) || createRes.stdout.match(/"database_id"\s*:\s*"([^"]+)"/) || createRes.stdout.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
|
|
1466
1492
|
if (matchUuid?.[1]) {
|
|
1467
1493
|
d1.database_id = matchUuid[1];
|
|
1468
1494
|
d1.database_name = targetDbName;
|
|
1469
1495
|
modified = true;
|
|
1470
|
-
console.log(
|
|
1496
|
+
console.log(
|
|
1497
|
+
`\u2705 [qarpeo] Created ${isPreview ? "preview" : "remote"} D1 database: ${matchUuid[1]}`
|
|
1498
|
+
);
|
|
1471
1499
|
}
|
|
1472
1500
|
}
|
|
1473
1501
|
}
|
|
1474
1502
|
}
|
|
1475
1503
|
}
|
|
1476
1504
|
if (Array.isArray(config.kv_namespaces) && config.kv_namespaces.length > 0) {
|
|
1477
|
-
const listRes =
|
|
1505
|
+
const listRes = spawnBinSync(wranglerBin, ["kv", "namespace", "list"], {
|
|
1478
1506
|
cwd,
|
|
1479
|
-
encoding: "utf8"
|
|
1480
|
-
shell: process.platform === "win32"
|
|
1507
|
+
encoding: "utf8"
|
|
1481
1508
|
});
|
|
1482
1509
|
let existingKvs = [];
|
|
1483
1510
|
try {
|
|
1484
|
-
existingKvs = JSON.parse(listRes.stdout || "[]");
|
|
1511
|
+
existingKvs = JSON.parse(String(listRes.stdout || "[]"));
|
|
1485
1512
|
} catch {
|
|
1486
1513
|
}
|
|
1487
1514
|
for (const kv of config.kv_namespaces) {
|
|
1488
1515
|
const explicitKvId = isPreview ? process.env.QARPEO_PREVIEW_KV_ID || process.env.PREVIEW_KV_ID : process.env.QARPEO_PROD_KV_ID || process.env.QARPEO_KV_ID || process.env.KV_ID;
|
|
1489
1516
|
if (explicitKvId) {
|
|
1490
|
-
console.log(
|
|
1517
|
+
console.log(
|
|
1518
|
+
`\u{1F517} [qarpeo] Using explicit ${isPreview ? "preview" : "production"} KV namespace for ${kv.binding}: (${explicitKvId})`
|
|
1519
|
+
);
|
|
1491
1520
|
kv.id = explicitKvId;
|
|
1492
1521
|
modified = true;
|
|
1493
1522
|
continue;
|
|
@@ -1499,21 +1528,28 @@ const deploy = defineCommand({
|
|
|
1499
1528
|
(k) => k.title === expectedTitle || k.title === kv.binding
|
|
1500
1529
|
);
|
|
1501
1530
|
if (match) {
|
|
1502
|
-
console.log(
|
|
1531
|
+
console.log(
|
|
1532
|
+
`\u{1F517} [qarpeo] Linked ${isPreview ? "preview" : "remote"} KV namespace: ${expectedTitle} (${match.id})`
|
|
1533
|
+
);
|
|
1503
1534
|
kv.id = match.id;
|
|
1504
1535
|
modified = true;
|
|
1505
1536
|
} else {
|
|
1506
|
-
console.log(
|
|
1507
|
-
|
|
1537
|
+
console.log(
|
|
1538
|
+
`\u{1F528} [qarpeo] Creating ${isPreview ? "preview" : "remote"} KV namespace: ${expectedTitle}...`
|
|
1539
|
+
);
|
|
1540
|
+
const createRes = spawnBinSync(
|
|
1508
1541
|
wranglerBin,
|
|
1509
1542
|
["kv", "namespace", "create", expectedTitle],
|
|
1510
|
-
{ cwd, encoding: "utf8"
|
|
1543
|
+
{ cwd, encoding: "utf8" }
|
|
1511
1544
|
);
|
|
1512
|
-
const
|
|
1545
|
+
const stdoutKv = String(createRes.stdout || "");
|
|
1546
|
+
const matchId = stdoutKv.match(/id\s*=\s*"([^"]+)"/);
|
|
1513
1547
|
if (matchId?.[1]) {
|
|
1514
1548
|
kv.id = matchId[1];
|
|
1515
1549
|
modified = true;
|
|
1516
|
-
console.log(
|
|
1550
|
+
console.log(
|
|
1551
|
+
`\u2705 [qarpeo] Created ${isPreview ? "preview" : "remote"} KV namespace: ${matchId[1]}`
|
|
1552
|
+
);
|
|
1517
1553
|
}
|
|
1518
1554
|
}
|
|
1519
1555
|
}
|
|
@@ -1522,10 +1558,9 @@ const deploy = defineCommand({
|
|
|
1522
1558
|
if (Array.isArray(config.r2_buckets) && config.r2_buckets.length > 0) {
|
|
1523
1559
|
for (const r2 of config.r2_buckets) {
|
|
1524
1560
|
if (r2.bucket_name) {
|
|
1525
|
-
|
|
1561
|
+
spawnBinSync(wranglerBin, ["r2", "bucket", "create", r2.bucket_name], {
|
|
1526
1562
|
cwd,
|
|
1527
|
-
stdio: "pipe"
|
|
1528
|
-
shell: process.platform === "win32"
|
|
1563
|
+
stdio: "pipe"
|
|
1529
1564
|
});
|
|
1530
1565
|
}
|
|
1531
1566
|
}
|
|
@@ -1562,10 +1597,9 @@ const deploy = defineCommand({
|
|
|
1562
1597
|
"-c",
|
|
1563
1598
|
wranglerConfigPath
|
|
1564
1599
|
];
|
|
1565
|
-
|
|
1600
|
+
spawnBinSync(wranglerBin, migArgs, {
|
|
1566
1601
|
cwd,
|
|
1567
|
-
stdio: "inherit"
|
|
1568
|
-
shell: process.platform === "win32"
|
|
1602
|
+
stdio: "inherit"
|
|
1569
1603
|
});
|
|
1570
1604
|
}
|
|
1571
1605
|
}
|
|
@@ -1607,10 +1641,9 @@ const deploy = defineCommand({
|
|
|
1607
1641
|
if (args.env) {
|
|
1608
1642
|
deployArgs.push("--env", args.env);
|
|
1609
1643
|
}
|
|
1610
|
-
const deployRes =
|
|
1644
|
+
const deployRes = spawnBinSync(wranglerBin, deployArgs, {
|
|
1611
1645
|
cwd,
|
|
1612
|
-
stdio: "inherit"
|
|
1613
|
-
shell: process.platform === "win32"
|
|
1646
|
+
stdio: "inherit"
|
|
1614
1647
|
});
|
|
1615
1648
|
if (deployRes.status !== 0) {
|
|
1616
1649
|
console.error(`
|
|
@@ -1710,15 +1743,11 @@ const doctor = defineCommand({
|
|
|
1710
1743
|
const wranglerBin = resolveBinaryPath("wrangler", cwd);
|
|
1711
1744
|
if (wranglerBin) {
|
|
1712
1745
|
try {
|
|
1713
|
-
const proc =
|
|
1714
|
-
cwd,
|
|
1715
|
-
encoding: "utf8",
|
|
1716
|
-
shell: true
|
|
1717
|
-
}) : spawnSync(wranglerBin, ["--version"], {
|
|
1746
|
+
const proc = spawnBinSync(wranglerBin, ["--version"], {
|
|
1718
1747
|
cwd,
|
|
1719
1748
|
encoding: "utf8"
|
|
1720
1749
|
});
|
|
1721
|
-
const out = proc.stdout ? proc.stdout.trim() : "";
|
|
1750
|
+
const out = proc.stdout ? String(proc.stdout).trim() : "";
|
|
1722
1751
|
envItems.push({
|
|
1723
1752
|
status: "pass",
|
|
1724
1753
|
title: "Wrangler CLI",
|
|
@@ -1736,7 +1765,7 @@ const doctor = defineCommand({
|
|
|
1736
1765
|
status: isRemote ? "fail" : "warn",
|
|
1737
1766
|
title: "Wrangler CLI",
|
|
1738
1767
|
message: "Not found locally in node_modules or PATH",
|
|
1739
|
-
help: "Install wrangler as a dev dependency:
|
|
1768
|
+
help: "Install wrangler as a dev dependency: vp add -D wrangler"
|
|
1740
1769
|
});
|
|
1741
1770
|
}
|
|
1742
1771
|
categories.push({
|
|
@@ -1822,7 +1851,10 @@ const doctor = defineCommand({
|
|
|
1822
1851
|
title: "Active Features",
|
|
1823
1852
|
message: enabledFeatures.length > 0 ? enabledFeatures.join(", ") : "None explicitly enabled (running bare runtime)"
|
|
1824
1853
|
});
|
|
1825
|
-
const projectName = resolveProjectName(
|
|
1854
|
+
const projectName = resolveProjectName(
|
|
1855
|
+
{ options: { ...nuxtConfig, rootDir: cwd } },
|
|
1856
|
+
qarpeoConfig
|
|
1857
|
+
);
|
|
1826
1858
|
configItems.push({
|
|
1827
1859
|
status: "info",
|
|
1828
1860
|
title: "Project / Worker Name",
|
|
@@ -1876,7 +1908,9 @@ const doctor = defineCommand({
|
|
|
1876
1908
|
message: "Local dev uses Miniflare emulation (no account ID required)"
|
|
1877
1909
|
});
|
|
1878
1910
|
}
|
|
1879
|
-
const isDbEnabled = Boolean(
|
|
1911
|
+
const isDbEnabled = Boolean(
|
|
1912
|
+
qarpeoConfig.db || qarpeoConfig.d1 || qarpeoConfig.cms || qarpeoConfig.auth || qarpeoConfig.payments
|
|
1913
|
+
);
|
|
1880
1914
|
if (isDbEnabled) {
|
|
1881
1915
|
const dbBinding = typeof qarpeoConfig.db === "object" && qarpeoConfig.db?.binding ? qarpeoConfig.db.binding : process.env.QARPEO_DB_BINDING || "DB";
|
|
1882
1916
|
const dbId = typeof qarpeoConfig.db === "object" && qarpeoConfig.db?.databaseId || process.env.QARPEO_DB_ID || process.env.DATABASE_ID || process.env.DB_ID;
|
|
@@ -1903,7 +1937,9 @@ const doctor = defineCommand({
|
|
|
1903
1937
|
});
|
|
1904
1938
|
}
|
|
1905
1939
|
}
|
|
1906
|
-
const isBlobEnabled = Boolean(
|
|
1940
|
+
const isBlobEnabled = Boolean(
|
|
1941
|
+
qarpeoConfig.blob || qarpeoConfig.r2 || qarpeoConfig.cms || qarpeoConfig.storage
|
|
1942
|
+
);
|
|
1907
1943
|
if (isBlobEnabled) {
|
|
1908
1944
|
const blobBucket = process.env.QARPEO_BLOB_BUCKET || process.env.BLOB_NAME || typeof qarpeoConfig.blob === "object" && qarpeoConfig.blob?.bucket;
|
|
1909
1945
|
if (isRemote && (!blobBucket || blobBucket.includes("local-dev"))) {
|
|
@@ -1958,7 +1994,7 @@ const doctor = defineCommand({
|
|
|
1958
1994
|
status: "fail",
|
|
1959
1995
|
title: "Drizzle ORM",
|
|
1960
1996
|
message: drizzleCheck.error || `Outdated version v${drizzleCheck.version}`,
|
|
1961
|
-
help: "Upgrade drizzle-orm to v1.0.0 RC:
|
|
1997
|
+
help: "Upgrade drizzle-orm to v1.0.0 RC: vp add drizzle-orm@rc"
|
|
1962
1998
|
});
|
|
1963
1999
|
}
|
|
1964
2000
|
} else {
|
|
@@ -2216,13 +2252,62 @@ ${cat.icon} ${cat.title}`);
|
|
|
2216
2252
|
});
|
|
2217
2253
|
|
|
2218
2254
|
const AVAILABLE_FEATURES = [
|
|
2219
|
-
{
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2255
|
+
{
|
|
2256
|
+
key: "db",
|
|
2257
|
+
name: "D1 Database & Drizzle ORM",
|
|
2258
|
+
binding: "DB",
|
|
2259
|
+
desc: "Serverless SQL database (D1 + Drizzle)",
|
|
2260
|
+
default: true
|
|
2261
|
+
},
|
|
2262
|
+
{
|
|
2263
|
+
key: "kv",
|
|
2264
|
+
name: "KV Namespaces",
|
|
2265
|
+
binding: "KV",
|
|
2266
|
+
desc: "Low-latency key-value data storage and sessions",
|
|
2267
|
+
default: true
|
|
2268
|
+
},
|
|
2269
|
+
{
|
|
2270
|
+
key: "blob",
|
|
2271
|
+
name: "R2 Object Storage",
|
|
2272
|
+
binding: "BLOB",
|
|
2273
|
+
desc: "Zero egress-fee file & media storage (R2)",
|
|
2274
|
+
default: true
|
|
2275
|
+
},
|
|
2276
|
+
{
|
|
2277
|
+
key: "realtime",
|
|
2278
|
+
name: "Realtime & Durable Objects",
|
|
2279
|
+
binding: "QARPEO_ROOM_DO",
|
|
2280
|
+
desc: "Hibernatable WebSockets, rooms, presence & state",
|
|
2281
|
+
default: false
|
|
2282
|
+
},
|
|
2283
|
+
{
|
|
2284
|
+
key: "ai",
|
|
2285
|
+
name: "Workers AI & Vectorize",
|
|
2286
|
+
binding: "AI",
|
|
2287
|
+
desc: "Edge LLMs, embeddings & vector search",
|
|
2288
|
+
default: false
|
|
2289
|
+
},
|
|
2290
|
+
{
|
|
2291
|
+
key: "queue",
|
|
2292
|
+
name: "Queues & Background Jobs",
|
|
2293
|
+
binding: "QUEUE",
|
|
2294
|
+
desc: "Asynchronous task processing and queues",
|
|
2295
|
+
default: false
|
|
2296
|
+
},
|
|
2297
|
+
{
|
|
2298
|
+
key: "auth",
|
|
2299
|
+
name: "Better Auth Integration",
|
|
2300
|
+
binding: "DB",
|
|
2301
|
+
desc: "Complete auth schemas, sessions & OAuth",
|
|
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
|
|
2310
|
+
}
|
|
2226
2311
|
];
|
|
2227
2312
|
function getWranglerBin$2(cwd) {
|
|
2228
2313
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
@@ -2246,6 +2331,12 @@ const init = defineCommand({
|
|
|
2246
2331
|
description: "Initialize Qarpeo in your project with interactive resource setup (.env, wrangler.json, nuxt.config)"
|
|
2247
2332
|
},
|
|
2248
2333
|
args: {
|
|
2334
|
+
dir: {
|
|
2335
|
+
type: "positional",
|
|
2336
|
+
description: "Project directory to initialize (e.g. docs, playground)",
|
|
2337
|
+
required: false,
|
|
2338
|
+
default: "."
|
|
2339
|
+
},
|
|
2249
2340
|
cwd: {
|
|
2250
2341
|
type: "string",
|
|
2251
2342
|
description: "Working directory",
|
|
@@ -2264,7 +2355,8 @@ const init = defineCommand({
|
|
|
2264
2355
|
}
|
|
2265
2356
|
},
|
|
2266
2357
|
async run({ args }) {
|
|
2267
|
-
const
|
|
2358
|
+
const targetDir = args.dir && args.dir !== "." ? args.dir : args.cwd;
|
|
2359
|
+
const cwd = resolve(process.cwd(), targetDir);
|
|
2268
2360
|
console.log("\n\u{1F680} \x1B[1m\x1B[36mQarpeo Edge Platform Initialization\x1B[0m");
|
|
2269
2361
|
console.log(" Configuring Cloudflare edge primitives for your Nuxt application...\n");
|
|
2270
2362
|
const pkgPath = join(cwd, "package.json");
|
|
@@ -2281,27 +2373,97 @@ const init = defineCommand({
|
|
|
2281
2373
|
const isInteractive = stdin.isTTY && !args.yes;
|
|
2282
2374
|
const rl = isInteractive ? readline.createInterface({ input: stdin, output: stdout }) : null;
|
|
2283
2375
|
if (rl) {
|
|
2284
|
-
const nameAnswer = await rl.question(
|
|
2376
|
+
const nameAnswer = await rl.question(
|
|
2377
|
+
`\u{1F3F7}\uFE0F \x1B[1mWorker Service Name\x1B[0m [${projectName}]: `
|
|
2378
|
+
);
|
|
2285
2379
|
if (nameAnswer.trim()) {
|
|
2286
2380
|
projectName = nameAnswer.trim().toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
2287
2381
|
}
|
|
2288
2382
|
}
|
|
2289
|
-
const
|
|
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
|
+
}
|
|
2290
2441
|
if (rl) {
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
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;
|
|
2300
2460
|
}
|
|
2301
2461
|
}
|
|
2302
2462
|
} else {
|
|
2303
2463
|
for (const feat of AVAILABLE_FEATURES) {
|
|
2304
|
-
selectedFeatures[feat.key]
|
|
2464
|
+
if (selectedFeatures[feat.key] === void 0) {
|
|
2465
|
+
selectedFeatures[feat.key] = feat.default;
|
|
2466
|
+
}
|
|
2305
2467
|
}
|
|
2306
2468
|
}
|
|
2307
2469
|
let shouldProvisionRemote = Boolean(args.remote);
|
|
@@ -2320,30 +2482,30 @@ const init = defineCommand({
|
|
|
2320
2482
|
const dbName = `${projectName}-db`;
|
|
2321
2483
|
console.log(`
|
|
2322
2484
|
\u23F3 Provisioning Cloudflare D1 Database "${dbName}"...`);
|
|
2323
|
-
const res =
|
|
2485
|
+
const res = spawnBinSync(wrangler, ["d1", "create", dbName], {
|
|
2324
2486
|
cwd,
|
|
2325
2487
|
encoding: "utf8",
|
|
2326
|
-
env: process.env
|
|
2327
|
-
shell: process.platform === "win32"
|
|
2488
|
+
env: process.env
|
|
2328
2489
|
});
|
|
2329
|
-
const uuidMatch = res.stdout
|
|
2490
|
+
const uuidMatch = String(res.stdout || "").match(/database_id\s*=\s*"([a-f0-9-]+)"/i) || String(res.stdout || "").match(/"([a-f0-9-]{36})"/i);
|
|
2330
2491
|
if (uuidMatch) {
|
|
2331
2492
|
createdResources.dbId = uuidMatch[1];
|
|
2332
2493
|
console.log(` \x1B[32m\u2714\x1B[0m Created D1 database: ${createdResources.dbId}`);
|
|
2333
2494
|
} else {
|
|
2334
|
-
console.log(
|
|
2495
|
+
console.log(
|
|
2496
|
+
` \u2139\uFE0F Note: If database already exists or output was masked, default binding was applied.`
|
|
2497
|
+
);
|
|
2335
2498
|
}
|
|
2336
2499
|
}
|
|
2337
2500
|
if (selectedFeatures.kv) {
|
|
2338
2501
|
const kvTitle = `${projectName}-kv`;
|
|
2339
2502
|
console.log(`\u23F3 Provisioning Cloudflare KV Namespace "${kvTitle}"...`);
|
|
2340
|
-
const res =
|
|
2503
|
+
const res = spawnBinSync(wrangler, ["kv", "namespace", "create", kvTitle], {
|
|
2341
2504
|
cwd,
|
|
2342
2505
|
encoding: "utf8",
|
|
2343
|
-
env: process.env
|
|
2344
|
-
shell: process.platform === "win32"
|
|
2506
|
+
env: process.env
|
|
2345
2507
|
});
|
|
2346
|
-
const kvMatch = res.stdout
|
|
2508
|
+
const kvMatch = String(res.stdout || "").match(/id\s*=\s*"([a-f0-9]+)"/i) || String(res.stdout || "").match(/"([a-f0-9]{32})"/i);
|
|
2347
2509
|
if (kvMatch) {
|
|
2348
2510
|
createdResources.kvId = kvMatch[1];
|
|
2349
2511
|
console.log(` \x1B[32m\u2714\x1B[0m Created KV namespace: ${createdResources.kvId}`);
|
|
@@ -2352,11 +2514,10 @@ const init = defineCommand({
|
|
|
2352
2514
|
if (selectedFeatures.blob) {
|
|
2353
2515
|
const bucketName = `${projectName}-storage`;
|
|
2354
2516
|
console.log(`\u23F3 Provisioning Cloudflare R2 Bucket "${bucketName}"...`);
|
|
2355
|
-
|
|
2517
|
+
spawnBinSync(wrangler, ["r2", "bucket", "create", bucketName], {
|
|
2356
2518
|
cwd,
|
|
2357
2519
|
encoding: "utf8",
|
|
2358
|
-
env: process.env
|
|
2359
|
-
shell: process.platform === "win32"
|
|
2520
|
+
env: process.env
|
|
2360
2521
|
});
|
|
2361
2522
|
createdResources.blobBucket = bucketName;
|
|
2362
2523
|
console.log(` \x1B[32m\u2714\x1B[0m Created R2 bucket: ${bucketName}`);
|
|
@@ -2365,6 +2526,31 @@ const init = defineCommand({
|
|
|
2365
2526
|
if (rl) {
|
|
2366
2527
|
rl.close();
|
|
2367
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;
|
|
2368
2554
|
console.log("\n\u{1F4DD} \x1B[1mGenerating root wrangler.json configuration...\x1B[0m");
|
|
2369
2555
|
const wranglerConfig = {
|
|
2370
2556
|
$schema: "node_modules/wrangler/config-schema.json",
|
|
@@ -2374,14 +2560,14 @@ const init = defineCommand({
|
|
|
2374
2560
|
compatibility_flags: ["nodejs_compat"],
|
|
2375
2561
|
observability: { enabled: true }
|
|
2376
2562
|
};
|
|
2377
|
-
if (
|
|
2378
|
-
wranglerConfig.account_id =
|
|
2563
|
+
if (accountId) {
|
|
2564
|
+
wranglerConfig.account_id = accountId;
|
|
2379
2565
|
}
|
|
2380
2566
|
if (selectedFeatures.kv) {
|
|
2381
2567
|
wranglerConfig.kv_namespaces = [
|
|
2382
2568
|
{
|
|
2383
2569
|
binding: "KV",
|
|
2384
|
-
id:
|
|
2570
|
+
id: existingKvId || "KV_LOCAL_DEV"
|
|
2385
2571
|
}
|
|
2386
2572
|
];
|
|
2387
2573
|
}
|
|
@@ -2390,7 +2576,7 @@ const init = defineCommand({
|
|
|
2390
2576
|
{
|
|
2391
2577
|
binding: "DB",
|
|
2392
2578
|
database_name: `${projectName}-db`,
|
|
2393
|
-
database_id:
|
|
2579
|
+
database_id: existingDbId || "DB_LOCAL_DEV",
|
|
2394
2580
|
migrations_dir: "server/db/migrations"
|
|
2395
2581
|
}
|
|
2396
2582
|
];
|
|
@@ -2399,7 +2585,7 @@ const init = defineCommand({
|
|
|
2399
2585
|
wranglerConfig.r2_buckets = [
|
|
2400
2586
|
{
|
|
2401
2587
|
binding: "BLOB",
|
|
2402
|
-
bucket_name:
|
|
2588
|
+
bucket_name: existingBlobBucket || `${projectName}-storage-local-dev`
|
|
2403
2589
|
}
|
|
2404
2590
|
];
|
|
2405
2591
|
}
|
|
@@ -2447,23 +2633,23 @@ const init = defineCommand({
|
|
|
2447
2633
|
}
|
|
2448
2634
|
];
|
|
2449
2635
|
}
|
|
2450
|
-
const wranglerPath = join(cwd, "wrangler.json");
|
|
2451
2636
|
writeFileSync(wranglerPath, JSON.stringify(wranglerConfig, null, 2) + "\n", "utf8");
|
|
2452
2637
|
console.log(` \x1B[32m\u2714\x1B[0m Generated ${wranglerPath}`);
|
|
2453
2638
|
console.log("\u{1F511} \x1B[1mUpdating .env file with secrets and binding identifiers...\x1B[0m");
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
if (cfAuth?.accountId) {
|
|
2457
|
-
envContent = updateOrAppendEnv(envContent, "CLOUDFLARE_ACCOUNT_ID", cfAuth.accountId);
|
|
2639
|
+
if (accountId) {
|
|
2640
|
+
envContent = updateOrAppendEnv(envContent, "CLOUDFLARE_ACCOUNT_ID", accountId);
|
|
2458
2641
|
}
|
|
2459
|
-
|
|
2460
|
-
|
|
2642
|
+
const finalDbId = createdResources.dbId || (existingDbId && existingDbId !== "DB_LOCAL_DEV" ? existingDbId : null);
|
|
2643
|
+
if (finalDbId) {
|
|
2644
|
+
envContent = updateOrAppendEnv(envContent, "QARPEO_DB_ID", finalDbId);
|
|
2461
2645
|
}
|
|
2462
|
-
|
|
2463
|
-
|
|
2646
|
+
const finalKvId = createdResources.kvId || (existingKvId && existingKvId !== "KV_LOCAL_DEV" ? existingKvId : null);
|
|
2647
|
+
if (finalKvId) {
|
|
2648
|
+
envContent = updateOrAppendEnv(envContent, "QARPEO_KV_ID", finalKvId);
|
|
2464
2649
|
}
|
|
2465
|
-
|
|
2466
|
-
|
|
2650
|
+
const finalBlobBucket = createdResources.blobBucket || (existingBlobBucket && !existingBlobBucket.includes("local-dev") ? existingBlobBucket : null);
|
|
2651
|
+
if (finalBlobBucket) {
|
|
2652
|
+
envContent = updateOrAppendEnv(envContent, "QARPEO_BLOB_BUCKET", finalBlobBucket);
|
|
2467
2653
|
}
|
|
2468
2654
|
if (selectedFeatures.auth) {
|
|
2469
2655
|
if (!envContent.includes("BETTER_AUTH_SECRET=")) {
|
|
@@ -2478,7 +2664,6 @@ const init = defineCommand({
|
|
|
2478
2664
|
}
|
|
2479
2665
|
writeFileSync(envPath, envContent, "utf8");
|
|
2480
2666
|
console.log(` \x1B[32m\u2714\x1B[0m Updated ${envPath}`);
|
|
2481
|
-
const nuxtConfigCandidates = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"];
|
|
2482
2667
|
let nuxtConfigPath = null;
|
|
2483
2668
|
for (const file of nuxtConfigCandidates) {
|
|
2484
2669
|
const candidate = join(cwd, file);
|
|
@@ -2533,21 +2718,25 @@ ${qarpeoConfigBlock}`
|
|
|
2533
2718
|
} else {
|
|
2534
2719
|
console.log(`
|
|
2535
2720
|
\u{1F4A1} Add the following to your \x1B[1mnuxt.config.ts\x1B[0m:`);
|
|
2536
|
-
console.log(
|
|
2721
|
+
console.log(
|
|
2722
|
+
`
|
|
2537
2723
|
export default defineNuxtConfig({
|
|
2538
2724
|
modules: ["qarpeo"],
|
|
2539
2725
|
${qarpeoConfigBlock}
|
|
2540
2726
|
})
|
|
2541
|
-
`
|
|
2727
|
+
`
|
|
2728
|
+
);
|
|
2542
2729
|
}
|
|
2543
2730
|
console.log("\n\u{1F389} \x1B[1m\x1B[32mQarpeo initialized successfully!\x1B[0m\n");
|
|
2544
2731
|
console.log(" \x1B[1mNext Steps:\x1B[0m");
|
|
2545
|
-
console.log(
|
|
2732
|
+
console.log(
|
|
2733
|
+
" \u2022 Run \x1B[36mvpr dev\x1B[0m (or \x1B[36mvpx nuxt dev\x1B[0m) to start your edge development server"
|
|
2734
|
+
);
|
|
2546
2735
|
if (selectedFeatures.db) {
|
|
2547
|
-
console.log(" \u2022 Run \x1B[
|
|
2736
|
+
console.log(" \u2022 Run \x1B[36mvpx qp db push\x1B[0m to apply your database schemas");
|
|
2548
2737
|
}
|
|
2549
|
-
console.log(" \u2022 Run \x1B[
|
|
2550
|
-
console.log(" \u2022 Run \x1B[
|
|
2738
|
+
console.log(" \u2022 Run \x1B[36mvpx qp doctor\x1B[0m to verify all edge bindings");
|
|
2739
|
+
console.log(" \u2022 Run \x1B[36mvpx qp deploy\x1B[0m to deploy directly to Cloudflare Workers\n");
|
|
2551
2740
|
}
|
|
2552
2741
|
});
|
|
2553
2742
|
|
|
@@ -2612,14 +2801,16 @@ const listCommand = defineCommand({
|
|
|
2612
2801
|
}
|
|
2613
2802
|
const tableData = workers.map((w) => ({
|
|
2614
2803
|
"Worker Name": w.id,
|
|
2615
|
-
|
|
2804
|
+
Created: w.created_on ? w.created_on.slice(0, 19).replace("T", " ") : "-",
|
|
2616
2805
|
"Last Modified": w.modified_on ? w.modified_on.slice(0, 19).replace("T", " ") : "-",
|
|
2617
|
-
|
|
2806
|
+
Assets: w.has_assets ? "Yes" : "No"
|
|
2618
2807
|
}));
|
|
2619
2808
|
console.table(tableData);
|
|
2620
2809
|
console.log(`
|
|
2621
2810
|
\u{1F4E6} Total Workers: ${workers.length}`);
|
|
2622
|
-
console.log(
|
|
2811
|
+
console.log(
|
|
2812
|
+
"\u{1F4A1} Tip: Run `qp delete <worker-name>` or simply `qp delete` to interactively select and delete.\n"
|
|
2813
|
+
);
|
|
2623
2814
|
} catch (err) {
|
|
2624
2815
|
console.error(`
|
|
2625
2816
|
\u274C [qarpeo] ${err?.message || err}
|
|
@@ -2637,20 +2828,27 @@ const login = defineCommand({
|
|
|
2637
2828
|
name: "login",
|
|
2638
2829
|
description: "Authenticate with Cloudflare via browser OAuth (powered by Wrangler)"
|
|
2639
2830
|
},
|
|
2640
|
-
args: {
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2831
|
+
args: {
|
|
2832
|
+
browser: {
|
|
2833
|
+
type: "boolean",
|
|
2834
|
+
description: "Automatically open the link in your default browser",
|
|
2835
|
+
default: false
|
|
2836
|
+
}
|
|
2837
|
+
},
|
|
2838
|
+
async run({ args }) {
|
|
2839
|
+
console.log("\u{1F510} [qarpeo] Authenticating with Cloudflare...");
|
|
2840
|
+
console.log(" After login, your credentials will be stored in ~/.wrangler/config/\n");
|
|
2646
2841
|
await ensurePackage("wrangler", {
|
|
2647
2842
|
purpose: "authenticating with Cloudflare"
|
|
2648
2843
|
});
|
|
2649
2844
|
const wrangler = getWranglerBin$1();
|
|
2650
|
-
const
|
|
2845
|
+
const wranglerArgs = ["login"];
|
|
2846
|
+
if (!args.browser) {
|
|
2847
|
+
wranglerArgs.push("--no-browser");
|
|
2848
|
+
}
|
|
2849
|
+
const result = spawnBinSync(wrangler, wranglerArgs, {
|
|
2651
2850
|
stdio: "inherit",
|
|
2652
|
-
env: process.env
|
|
2653
|
-
shell: process.platform === "win32"
|
|
2851
|
+
env: process.env
|
|
2654
2852
|
});
|
|
2655
2853
|
if (result.status !== 0) {
|
|
2656
2854
|
console.error(
|
|
@@ -2674,21 +2872,16 @@ const logout = defineCommand({
|
|
|
2674
2872
|
purpose: "logging out of Cloudflare"
|
|
2675
2873
|
});
|
|
2676
2874
|
const wrangler = getWranglerBin$1();
|
|
2677
|
-
const result =
|
|
2875
|
+
const result = spawnBinSync(wrangler, ["logout"], {
|
|
2678
2876
|
stdio: "inherit",
|
|
2679
|
-
env: process.env
|
|
2680
|
-
shell: process.platform === "win32"
|
|
2877
|
+
env: process.env
|
|
2681
2878
|
});
|
|
2682
2879
|
if (result.status !== 0) {
|
|
2683
|
-
console.error(
|
|
2684
|
-
"\n\u274C [qarpeo] Logout failed. You may not have been logged in."
|
|
2685
|
-
);
|
|
2880
|
+
console.error("\n\u274C [qarpeo] Logout failed. You may not have been logged in.");
|
|
2686
2881
|
process.exit(result.status ?? 1);
|
|
2687
2882
|
}
|
|
2688
2883
|
console.log("\n\u2705 [qarpeo] Successfully logged out of Cloudflare.");
|
|
2689
|
-
console.log(
|
|
2690
|
-
" To re-authenticate, run `qp login` or set CLOUDFLARE_API_TOKEN in .env\n"
|
|
2691
|
-
);
|
|
2884
|
+
console.log(" To re-authenticate, run `qp login` or set CLOUDFLARE_API_TOKEN in .env\n");
|
|
2692
2885
|
}
|
|
2693
2886
|
});
|
|
2694
2887
|
const whoami = defineCommand({
|
|
@@ -2702,10 +2895,9 @@ const whoami = defineCommand({
|
|
|
2702
2895
|
purpose: "checking Cloudflare account status"
|
|
2703
2896
|
});
|
|
2704
2897
|
const wrangler = getWranglerBin$1();
|
|
2705
|
-
const result =
|
|
2898
|
+
const result = spawnBinSync(wrangler, ["whoami"], {
|
|
2706
2899
|
stdio: "inherit",
|
|
2707
|
-
env: process.env
|
|
2708
|
-
shell: process.platform === "win32"
|
|
2900
|
+
env: process.env
|
|
2709
2901
|
});
|
|
2710
2902
|
if (result.status !== 0) {
|
|
2711
2903
|
console.error(
|
|
@@ -2809,11 +3001,21 @@ const logs = defineCommand({
|
|
|
2809
3001
|
console.log(`> wrangler ${tailArgs.join(" ")}
|
|
2810
3002
|
`);
|
|
2811
3003
|
console.log("Press Ctrl+C to exit streaming logs.\n");
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
3004
|
+
let child;
|
|
3005
|
+
if (process.platform === "win32" && (wranglerBin.endsWith(".cmd") || wranglerBin.endsWith(".bat"))) {
|
|
3006
|
+
const cmd = process.env.ComSpec || "cmd.exe";
|
|
3007
|
+
child = spawn(cmd, ["/d", "/s", "/c", wranglerBin, ...tailArgs], {
|
|
3008
|
+
cwd,
|
|
3009
|
+
stdio: "inherit",
|
|
3010
|
+
shell: false
|
|
3011
|
+
});
|
|
3012
|
+
} else {
|
|
3013
|
+
child = spawn(wranglerBin, tailArgs, {
|
|
3014
|
+
cwd,
|
|
3015
|
+
stdio: "inherit",
|
|
3016
|
+
shell: false
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
2817
3019
|
await new Promise((resolvePromise) => {
|
|
2818
3020
|
child.on("close", () => {
|
|
2819
3021
|
resolvePromise();
|
|
@@ -2888,8 +3090,10 @@ const pushSecret = defineCommand({
|
|
|
2888
3090
|
console.log("\u2139\uFE0F [qarpeo] No secret keys detected in .env to synchronize.");
|
|
2889
3091
|
return;
|
|
2890
3092
|
}
|
|
2891
|
-
console.log(
|
|
2892
|
-
|
|
3093
|
+
console.log(
|
|
3094
|
+
`
|
|
3095
|
+
\u{1F510} [qarpeo] Found ${secretEntries.length} secrets to synchronize with Cloudflare Workers:`
|
|
3096
|
+
);
|
|
2893
3097
|
for (const [k] of secretEntries) {
|
|
2894
3098
|
console.log(` \u2022 ${k}`);
|
|
2895
3099
|
}
|
|
@@ -2905,11 +3109,10 @@ const pushSecret = defineCommand({
|
|
|
2905
3109
|
console.log("\n\u{1F680} [qarpeo] Uploading secrets via wrangler secret:bulk...");
|
|
2906
3110
|
const wranglerArgs = ["secret:bulk"];
|
|
2907
3111
|
if (args.env) wranglerArgs.push("--env", args.env);
|
|
2908
|
-
const res =
|
|
3112
|
+
const res = spawnBinSync(wrangler, wranglerArgs, {
|
|
2909
3113
|
cwd,
|
|
2910
3114
|
input: JSON.stringify(secretJson),
|
|
2911
|
-
encoding: "utf8"
|
|
2912
|
-
shell: process.platform === "win32"
|
|
3115
|
+
encoding: "utf8"
|
|
2913
3116
|
});
|
|
2914
3117
|
if (res.status === 0) {
|
|
2915
3118
|
console.log("\n\u2705 [qarpeo] All secrets synchronized successfully with Cloudflare Workers!\n");
|
|
@@ -2919,11 +3122,10 @@ const pushSecret = defineCommand({
|
|
|
2919
3122
|
for (const [k, v] of secretEntries) {
|
|
2920
3123
|
const putArgs = ["secret", "put", k];
|
|
2921
3124
|
if (args.env) putArgs.push("--env", args.env);
|
|
2922
|
-
const putRes =
|
|
3125
|
+
const putRes = spawnBinSync(wrangler, putArgs, {
|
|
2923
3126
|
cwd,
|
|
2924
3127
|
input: v,
|
|
2925
|
-
encoding: "utf8"
|
|
2926
|
-
shell: process.platform === "win32"
|
|
3128
|
+
encoding: "utf8"
|
|
2927
3129
|
});
|
|
2928
3130
|
if (putRes.status === 0) {
|
|
2929
3131
|
console.log(` \u2714 Synced ${k}`);
|
|
@@ -2972,16 +3174,17 @@ const pullSecret = defineCommand({
|
|
|
2972
3174
|
console.log("\n\u{1F50D} [qarpeo] Fetching Cloudflare Worker secrets list...");
|
|
2973
3175
|
const listArgs = ["secret", "list"];
|
|
2974
3176
|
if (args.env) listArgs.push("--env", args.env);
|
|
2975
|
-
const res =
|
|
3177
|
+
const res = spawnBinSync(wrangler, listArgs, {
|
|
2976
3178
|
cwd,
|
|
2977
|
-
stdio: "inherit"
|
|
2978
|
-
shell: process.platform === "win32"
|
|
3179
|
+
stdio: "inherit"
|
|
2979
3180
|
});
|
|
2980
3181
|
if (res.status !== 0) {
|
|
2981
3182
|
console.error("\n\u274C [qarpeo] Failed to retrieve secrets from Cloudflare.");
|
|
2982
3183
|
process.exit(res.status ?? 1);
|
|
2983
3184
|
}
|
|
2984
|
-
console.log(
|
|
3185
|
+
console.log(
|
|
3186
|
+
"\n\u{1F4A1} Note: Cloudflare encrypted secrets cannot be downloaded in plaintext for security."
|
|
3187
|
+
);
|
|
2985
3188
|
console.log(" The list above displays the secrets currently active on the edge.\n");
|
|
2986
3189
|
}
|
|
2987
3190
|
});
|
|
@@ -3068,9 +3271,7 @@ const taskList = defineCommand({
|
|
|
3068
3271
|
const tasks = findProjectTasks(cwd);
|
|
3069
3272
|
if (tasks.length === 0) {
|
|
3070
3273
|
console.log("\n\u26A1 [qarpeo] No scheduled tasks found.");
|
|
3071
|
-
console.log(
|
|
3072
|
-
" Create tasks in server/tasks/ or server/cron/ using defineScheduledTask().\n"
|
|
3073
|
-
);
|
|
3274
|
+
console.log(" Create tasks in server/tasks/ or server/cron/ using defineScheduledTask().\n");
|
|
3074
3275
|
return;
|
|
3075
3276
|
}
|
|
3076
3277
|
console.log(`
|
|
@@ -3078,9 +3279,7 @@ const taskList = defineCommand({
|
|
|
3078
3279
|
`);
|
|
3079
3280
|
const col1 = Math.max(4, ...tasks.map((t) => t.name.length));
|
|
3080
3281
|
const col2 = Math.max(16, ...tasks.map((t) => (t.cron || "manual only").length));
|
|
3081
|
-
console.log(
|
|
3082
|
-
` ${"Task".padEnd(col1)} ${"Cron".padEnd(col2)} Description`
|
|
3083
|
-
);
|
|
3282
|
+
console.log(` ${"Task".padEnd(col1)} ${"Cron".padEnd(col2)} Description`);
|
|
3084
3283
|
console.log(` ${"\u2500".repeat(col1)} ${"\u2500".repeat(col2)} ${"\u2500".repeat(32)}`);
|
|
3085
3284
|
for (const task2 of tasks) {
|
|
3086
3285
|
const cron = task2.cron || "manual only";
|
|
@@ -3203,7 +3402,7 @@ const testCommand = defineCommand({
|
|
|
3203
3402
|
process.env.QARPEO_EDGE_TEST = "1";
|
|
3204
3403
|
process.env.NODE_ENV = "test";
|
|
3205
3404
|
const isWindows = process.platform === "win32";
|
|
3206
|
-
let runner = isWindows ? "
|
|
3405
|
+
let runner = isWindows ? "vp.cmd" : "vp";
|
|
3207
3406
|
let runnerArgs = ["test"];
|
|
3208
3407
|
if (args.watch) {
|
|
3209
3408
|
runnerArgs.push("--watch");
|
|
@@ -3215,20 +3414,34 @@ const testCommand = defineCommand({
|
|
|
3215
3414
|
}
|
|
3216
3415
|
console.log(`\u25B6 Executing: ${runner} ${runnerArgs.join(" ")}
|
|
3217
3416
|
`);
|
|
3218
|
-
return new Promise((
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3417
|
+
return new Promise((resolve, reject) => {
|
|
3418
|
+
let child;
|
|
3419
|
+
if (isWindows) {
|
|
3420
|
+
const cmd = process.env.ComSpec || "cmd.exe";
|
|
3421
|
+
child = spawn(cmd, ["/d", "/s", "/c", runner, ...runnerArgs], {
|
|
3422
|
+
cwd,
|
|
3423
|
+
stdio: "inherit",
|
|
3424
|
+
shell: false,
|
|
3425
|
+
env: {
|
|
3426
|
+
...process.env,
|
|
3427
|
+
QARPEO_EDGE_TEST: "1"
|
|
3428
|
+
}
|
|
3429
|
+
});
|
|
3430
|
+
} else {
|
|
3431
|
+
child = spawn(runner, runnerArgs, {
|
|
3432
|
+
cwd,
|
|
3433
|
+
stdio: "inherit",
|
|
3434
|
+
shell: false,
|
|
3435
|
+
env: {
|
|
3436
|
+
...process.env,
|
|
3437
|
+
QARPEO_EDGE_TEST: "1"
|
|
3438
|
+
}
|
|
3439
|
+
});
|
|
3440
|
+
}
|
|
3228
3441
|
child.on("close", (code) => {
|
|
3229
3442
|
if (code === 0) {
|
|
3230
3443
|
console.log("\n\u2705 All edge tests completed successfully!\n");
|
|
3231
|
-
|
|
3444
|
+
resolve();
|
|
3232
3445
|
} else {
|
|
3233
3446
|
console.error(`
|
|
3234
3447
|
\u274C Tests failed with exit code ${code}
|
|
@@ -3287,11 +3500,21 @@ const tunnel = defineCommand({
|
|
|
3287
3500
|
} else {
|
|
3288
3501
|
tunnelArgs.push("tunnel", "--url", targetUrl);
|
|
3289
3502
|
}
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3503
|
+
let child;
|
|
3504
|
+
if (process.platform === "win32" && (cloudflaredBin.endsWith(".cmd") || cloudflaredBin.endsWith(".bat"))) {
|
|
3505
|
+
const cmd = process.env.ComSpec || "cmd.exe";
|
|
3506
|
+
child = spawn(cmd, ["/d", "/s", "/c", cloudflaredBin, ...tunnelArgs], {
|
|
3507
|
+
cwd,
|
|
3508
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
3509
|
+
shell: false
|
|
3510
|
+
});
|
|
3511
|
+
} else {
|
|
3512
|
+
child = spawn(cloudflaredBin, tunnelArgs, {
|
|
3513
|
+
cwd,
|
|
3514
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
3515
|
+
shell: false
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3295
3518
|
let publicUrl = "";
|
|
3296
3519
|
const parseOutput = (data) => {
|
|
3297
3520
|
const text = data.toString();
|
|
@@ -3318,9 +3541,13 @@ const tunnel = defineCommand({
|
|
|
3318
3541
|
if (err?.code === "ENOENT") {
|
|
3319
3542
|
console.error("\u274C [qarpeo] 'cloudflared' CLI was not found on your system.");
|
|
3320
3543
|
console.error("\u{1F449} Install it with:");
|
|
3321
|
-
console.error(
|
|
3544
|
+
console.error(
|
|
3545
|
+
" \u2022 Windows: winget install Cloudflare.cloudflared (or choco install cloudflared)"
|
|
3546
|
+
);
|
|
3322
3547
|
console.error(" \u2022 macOS: brew install cloudflare/cloudflare/cloudflared");
|
|
3323
|
-
console.error(
|
|
3548
|
+
console.error(
|
|
3549
|
+
" \u2022 Linux: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/\n"
|
|
3550
|
+
);
|
|
3324
3551
|
} else {
|
|
3325
3552
|
console.error("\u274C [qarpeo] Cloudflare Tunnel failed:", err.message);
|
|
3326
3553
|
}
|
|
@@ -3338,7 +3565,7 @@ const tunnel = defineCommand({
|
|
|
3338
3565
|
const main = defineCommand({
|
|
3339
3566
|
meta: {
|
|
3340
3567
|
name: "qp",
|
|
3341
|
-
version
|
|
3568
|
+
version,
|
|
3342
3569
|
description: "Cloudflare-native powerhouse module for Nuxt"
|
|
3343
3570
|
},
|
|
3344
3571
|
subCommands: {
|