qarpeo 0.1.18 → 0.1.20
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 +373 -179
- 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 +94 -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 +7 -1
- 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 +9 -3
- 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 +10 -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,27 +1244,78 @@ 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
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1259
|
+
async function resolveWorkerName(defaultName, args, cwd) {
|
|
1260
|
+
if (args.name) return args.name;
|
|
1261
|
+
if (process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME) {
|
|
1262
|
+
return process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME;
|
|
1263
|
+
}
|
|
1264
|
+
if (!stdin.isTTY || args.yes) {
|
|
1265
|
+
return defaultName || "qarpeo";
|
|
1235
1266
|
}
|
|
1236
1267
|
const rl = readline.createInterface({ input: stdin, output: stdout });
|
|
1237
1268
|
try {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1269
|
+
if (defaultName) {
|
|
1270
|
+
const answer = await rl.question(
|
|
1271
|
+
`
|
|
1272
|
+
\u{1F3F7}\uFE0F Target Worker: \x1B[1m\x1B[36m${defaultName}\x1B[0m
|
|
1273
|
+
Deploy with this name? [Y/n] (Press Enter to confirm, 'n' to change): `
|
|
1274
|
+
);
|
|
1275
|
+
const trimmed = answer.trim();
|
|
1276
|
+
if (!trimmed || trimmed.toLowerCase() === "y" || trimmed.toLowerCase() === "yes") {
|
|
1277
|
+
return defaultName;
|
|
1278
|
+
}
|
|
1279
|
+
if (trimmed.toLowerCase() !== "n" && trimmed.toLowerCase() !== "no" && trimmed.toLowerCase() !== "list") {
|
|
1280
|
+
return trimmed;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
console.log("\n\u{1F50D} [qarpeo] Fetching existing Cloudflare Workers...");
|
|
1284
|
+
let remoteWorkers = [];
|
|
1285
|
+
try {
|
|
1286
|
+
const auth = await getCloudflareAuth(cwd);
|
|
1287
|
+
if (auth) {
|
|
1288
|
+
const list = await listCloudflareWorkers(auth);
|
|
1289
|
+
remoteWorkers = list.map((w) => w.id);
|
|
1290
|
+
}
|
|
1291
|
+
} catch {
|
|
1292
|
+
}
|
|
1293
|
+
if (remoteWorkers.length > 0) {
|
|
1294
|
+
console.log("\n\u{1F4CB} Existing Cloudflare Workers:");
|
|
1295
|
+
remoteWorkers.forEach((w, i) => {
|
|
1296
|
+
const isCurrent = w === defaultName ? " \x1B[32m(current)\x1B[0m" : "";
|
|
1297
|
+
console.log(` ${i + 1}) ${w}${isCurrent}`);
|
|
1298
|
+
});
|
|
1299
|
+
console.log(` ${remoteWorkers.length + 1}) [Enter a new name]`);
|
|
1300
|
+
const choice = await rl.question(
|
|
1301
|
+
`
|
|
1302
|
+
Select a worker [1-${remoteWorkers.length + 1}] or type a name: `
|
|
1303
|
+
);
|
|
1304
|
+
const choiceTrimmed = choice.trim();
|
|
1305
|
+
const num = parseInt(choiceTrimmed, 10);
|
|
1306
|
+
if (!isNaN(num) && num >= 1 && num <= remoteWorkers.length) {
|
|
1307
|
+
return remoteWorkers[num - 1];
|
|
1308
|
+
}
|
|
1309
|
+
if (num === remoteWorkers.length + 1 || !choiceTrimmed) {
|
|
1310
|
+
const newName = await rl.question("\u{1F3F7}\uFE0F New Worker Name: ");
|
|
1311
|
+
return newName.trim() || defaultName || "qarpeo";
|
|
1312
|
+
}
|
|
1313
|
+
return choiceTrimmed;
|
|
1314
|
+
}
|
|
1315
|
+
const fallbackAnswer = await rl.question(
|
|
1316
|
+
`\u{1F3F7}\uFE0F Cloudflare Worker Name [${defaultName || "qarpeo"}]: `
|
|
1317
|
+
);
|
|
1318
|
+
return fallbackAnswer.trim() || defaultName || "qarpeo";
|
|
1242
1319
|
} finally {
|
|
1243
1320
|
rl.close();
|
|
1244
1321
|
}
|
|
@@ -1253,6 +1330,12 @@ const deploy = defineCommand({
|
|
|
1253
1330
|
description: "Build and deploy full-stack Nuxt application directly to Cloudflare Workers"
|
|
1254
1331
|
},
|
|
1255
1332
|
args: {
|
|
1333
|
+
dir: {
|
|
1334
|
+
type: "positional",
|
|
1335
|
+
description: "Project directory to deploy (e.g. docs, playground)",
|
|
1336
|
+
required: false,
|
|
1337
|
+
default: "."
|
|
1338
|
+
},
|
|
1256
1339
|
cwd: {
|
|
1257
1340
|
type: "string",
|
|
1258
1341
|
description: "Working directory",
|
|
@@ -1262,6 +1345,12 @@ const deploy = defineCommand({
|
|
|
1262
1345
|
type: "string",
|
|
1263
1346
|
description: "Cloudflare Worker service name (overrides package.json and config)"
|
|
1264
1347
|
},
|
|
1348
|
+
yes: {
|
|
1349
|
+
type: "boolean",
|
|
1350
|
+
alias: "y",
|
|
1351
|
+
description: "Auto-confirm existing worker name and prompts",
|
|
1352
|
+
default: false
|
|
1353
|
+
},
|
|
1265
1354
|
build: {
|
|
1266
1355
|
type: "boolean",
|
|
1267
1356
|
description: "Build the Nuxt application before deploying (pass --no-build to skip)",
|
|
@@ -1303,15 +1392,18 @@ const deploy = defineCommand({
|
|
|
1303
1392
|
}
|
|
1304
1393
|
},
|
|
1305
1394
|
async run({ args }) {
|
|
1306
|
-
const
|
|
1395
|
+
const targetDir = args.dir && args.dir !== "." ? args.dir : args.cwd;
|
|
1396
|
+
const cwd = resolve(process.cwd(), targetDir);
|
|
1307
1397
|
loadDotEnv$2(cwd);
|
|
1308
1398
|
const isPreview = Boolean(args.preview);
|
|
1309
1399
|
const branch = getGitBranch(cwd);
|
|
1310
1400
|
const previewSuffix = branch && branch !== "main" && branch !== "master" && branch !== "HEAD" ? sanitizeSuffix(branch) : "preview";
|
|
1311
1401
|
if (isPreview) {
|
|
1312
|
-
console.log(
|
|
1402
|
+
console.log(
|
|
1403
|
+
`
|
|
1313
1404
|
\u26A1 [qarpeo] Starting Cloudflare Workers PREVIEW deployment (${previewSuffix})...
|
|
1314
|
-
`
|
|
1405
|
+
`
|
|
1406
|
+
);
|
|
1315
1407
|
} else {
|
|
1316
1408
|
console.log(`
|
|
1317
1409
|
\u26A1 [qarpeo] Starting Cloudflare Workers edge deployment...
|
|
@@ -1334,16 +1426,17 @@ const deploy = defineCommand({
|
|
|
1334
1426
|
process.env.CLOUDFLARE_API_TOKEN || process.env.CF_API_TOKEN || process.env.CLOUDFLARE_EMAIL && process.env.CLOUDFLARE_API_KEY
|
|
1335
1427
|
);
|
|
1336
1428
|
if (!hasEnvAuth && !args.dryRun) {
|
|
1337
|
-
|
|
1429
|
+
console.log("\u{1F50D} [qarpeo] Verifying Cloudflare credentials...");
|
|
1430
|
+
const whoamiRes = spawnBinSync(wranglerBin, ["whoami"], {
|
|
1338
1431
|
cwd,
|
|
1339
|
-
encoding: "utf8"
|
|
1340
|
-
shell: process.platform === "win32"
|
|
1432
|
+
encoding: "utf8"
|
|
1341
1433
|
});
|
|
1342
1434
|
if (whoamiRes.status !== 0) {
|
|
1343
1435
|
console.error("\u274C [qarpeo] Not authenticated with Cloudflare.");
|
|
1344
|
-
console.error("\u{1F449} Run '
|
|
1436
|
+
console.error("\u{1F449} Run 'vpx qp login' or set CLOUDFLARE_API_TOKEN in your environment.\n");
|
|
1345
1437
|
process.exit(1);
|
|
1346
1438
|
}
|
|
1439
|
+
console.log("\u2714 Cloudflare credentials verified\n");
|
|
1347
1440
|
}
|
|
1348
1441
|
if (args.build) {
|
|
1349
1442
|
console.log("\u{1F4E6} [qarpeo] Building Nuxt application for Cloudflare Workers...");
|
|
@@ -1354,26 +1447,23 @@ const deploy = defineCommand({
|
|
|
1354
1447
|
const nuxtBin = resolveBinaryPath("nuxt", cwd);
|
|
1355
1448
|
let buildRes;
|
|
1356
1449
|
if (nuxtBin) {
|
|
1357
|
-
buildRes =
|
|
1450
|
+
buildRes = spawnBinSync(nuxtBin, ["build"], {
|
|
1358
1451
|
cwd,
|
|
1359
1452
|
stdio: "inherit",
|
|
1360
|
-
shell: process.platform === "win32",
|
|
1361
1453
|
env: buildEnv
|
|
1362
1454
|
});
|
|
1363
1455
|
} else {
|
|
1364
|
-
const
|
|
1365
|
-
buildRes =
|
|
1456
|
+
const vpxBin = process.platform === "win32" ? "vpx.cmd" : "vpx";
|
|
1457
|
+
buildRes = spawnBinSync(vpxBin, ["nuxt", "build"], {
|
|
1366
1458
|
cwd,
|
|
1367
1459
|
stdio: "inherit",
|
|
1368
|
-
shell: process.platform === "win32",
|
|
1369
1460
|
env: buildEnv
|
|
1370
1461
|
});
|
|
1371
1462
|
if (buildRes.status !== 0) {
|
|
1372
1463
|
const npxBin = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
1373
|
-
buildRes =
|
|
1464
|
+
buildRes = spawnBinSync(npxBin, ["nuxt", "build"], {
|
|
1374
1465
|
cwd,
|
|
1375
1466
|
stdio: "inherit",
|
|
1376
|
-
shell: process.platform === "win32",
|
|
1377
1467
|
env: buildEnv
|
|
1378
1468
|
});
|
|
1379
1469
|
}
|
|
@@ -1406,7 +1496,7 @@ const deploy = defineCommand({
|
|
|
1406
1496
|
let baseWorkerName = args.name || process.env.QARPEO_WORKER_NAME || process.env.WORKER_NAME;
|
|
1407
1497
|
if (!baseWorkerName) {
|
|
1408
1498
|
if (!args.dryRun) {
|
|
1409
|
-
baseWorkerName = await
|
|
1499
|
+
baseWorkerName = await resolveWorkerName(defaultName, args, cwd);
|
|
1410
1500
|
} else {
|
|
1411
1501
|
baseWorkerName = defaultName;
|
|
1412
1502
|
}
|
|
@@ -1426,14 +1516,13 @@ const deploy = defineCommand({
|
|
|
1426
1516
|
try {
|
|
1427
1517
|
let modified = isPreview;
|
|
1428
1518
|
if (Array.isArray(config.d1_databases) && config.d1_databases.length > 0) {
|
|
1429
|
-
const listRes =
|
|
1519
|
+
const listRes = spawnBinSync(wranglerBin, ["d1", "list", "--json"], {
|
|
1430
1520
|
cwd,
|
|
1431
|
-
encoding: "utf8"
|
|
1432
|
-
shell: process.platform === "win32"
|
|
1521
|
+
encoding: "utf8"
|
|
1433
1522
|
});
|
|
1434
1523
|
let existingDbs = [];
|
|
1435
1524
|
try {
|
|
1436
|
-
existingDbs = JSON.parse(listRes.stdout || "[]");
|
|
1525
|
+
existingDbs = JSON.parse(String(listRes.stdout || "[]"));
|
|
1437
1526
|
} catch {
|
|
1438
1527
|
}
|
|
1439
1528
|
for (const d1 of config.d1_databases) {
|
|
@@ -1441,7 +1530,9 @@ const deploy = defineCommand({
|
|
|
1441
1530
|
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
1531
|
const targetDbName = explicitName || (isPreview ? `${d1.database_name}_preview` : d1.database_name);
|
|
1443
1532
|
if (explicitId) {
|
|
1444
|
-
console.log(
|
|
1533
|
+
console.log(
|
|
1534
|
+
`\u{1F517} [qarpeo] Using explicit ${isPreview ? "preview" : "production"} D1 database: ${targetDbName} (${explicitId})`
|
|
1535
|
+
);
|
|
1445
1536
|
d1.database_id = explicitId;
|
|
1446
1537
|
d1.database_name = targetDbName;
|
|
1447
1538
|
modified = true;
|
|
@@ -1451,43 +1542,52 @@ const deploy = defineCommand({
|
|
|
1451
1542
|
if (isPlaceholder) {
|
|
1452
1543
|
const match = existingDbs.find((db) => db.name === targetDbName);
|
|
1453
1544
|
if (match) {
|
|
1454
|
-
console.log(
|
|
1545
|
+
console.log(
|
|
1546
|
+
`\u{1F517} [qarpeo] Linked ${isPreview ? "preview" : "remote"} D1 database: ${targetDbName} (${match.uuid})`
|
|
1547
|
+
);
|
|
1455
1548
|
d1.database_id = match.uuid;
|
|
1456
1549
|
d1.database_name = targetDbName;
|
|
1457
1550
|
modified = true;
|
|
1458
1551
|
} else {
|
|
1459
|
-
console.log(
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1552
|
+
console.log(
|
|
1553
|
+
`\u{1F528} [qarpeo] Creating ${isPreview ? "preview" : "remote"} D1 database: ${targetDbName}...`
|
|
1554
|
+
);
|
|
1555
|
+
const createRes = spawnBinSync(wranglerBin, ["d1", "create", targetDbName], {
|
|
1556
|
+
cwd,
|
|
1557
|
+
encoding: "utf8"
|
|
1558
|
+
});
|
|
1559
|
+
const stdoutText = String(createRes.stdout || "");
|
|
1560
|
+
const matchUuid = stdoutText.match(/database_id\s*:\s*"([^"]+)"/) || stdoutText.match(/database_id\s*=\s*"([^"]+)"/) || stdoutText.match(/"database_id"\s*:\s*"([^"]+)"/) || stdoutText.match(
|
|
1561
|
+
/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i
|
|
1464
1562
|
);
|
|
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
1563
|
if (matchUuid?.[1]) {
|
|
1467
1564
|
d1.database_id = matchUuid[1];
|
|
1468
1565
|
d1.database_name = targetDbName;
|
|
1469
1566
|
modified = true;
|
|
1470
|
-
console.log(
|
|
1567
|
+
console.log(
|
|
1568
|
+
`\u2705 [qarpeo] Created ${isPreview ? "preview" : "remote"} D1 database: ${matchUuid[1]}`
|
|
1569
|
+
);
|
|
1471
1570
|
}
|
|
1472
1571
|
}
|
|
1473
1572
|
}
|
|
1474
1573
|
}
|
|
1475
1574
|
}
|
|
1476
1575
|
if (Array.isArray(config.kv_namespaces) && config.kv_namespaces.length > 0) {
|
|
1477
|
-
const listRes =
|
|
1576
|
+
const listRes = spawnBinSync(wranglerBin, ["kv", "namespace", "list"], {
|
|
1478
1577
|
cwd,
|
|
1479
|
-
encoding: "utf8"
|
|
1480
|
-
shell: process.platform === "win32"
|
|
1578
|
+
encoding: "utf8"
|
|
1481
1579
|
});
|
|
1482
1580
|
let existingKvs = [];
|
|
1483
1581
|
try {
|
|
1484
|
-
existingKvs = JSON.parse(listRes.stdout || "[]");
|
|
1582
|
+
existingKvs = JSON.parse(String(listRes.stdout || "[]"));
|
|
1485
1583
|
} catch {
|
|
1486
1584
|
}
|
|
1487
1585
|
for (const kv of config.kv_namespaces) {
|
|
1488
1586
|
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
1587
|
if (explicitKvId) {
|
|
1490
|
-
console.log(
|
|
1588
|
+
console.log(
|
|
1589
|
+
`\u{1F517} [qarpeo] Using explicit ${isPreview ? "preview" : "production"} KV namespace for ${kv.binding}: (${explicitKvId})`
|
|
1590
|
+
);
|
|
1491
1591
|
kv.id = explicitKvId;
|
|
1492
1592
|
modified = true;
|
|
1493
1593
|
continue;
|
|
@@ -1499,21 +1599,28 @@ const deploy = defineCommand({
|
|
|
1499
1599
|
(k) => k.title === expectedTitle || k.title === kv.binding
|
|
1500
1600
|
);
|
|
1501
1601
|
if (match) {
|
|
1502
|
-
console.log(
|
|
1602
|
+
console.log(
|
|
1603
|
+
`\u{1F517} [qarpeo] Linked ${isPreview ? "preview" : "remote"} KV namespace: ${expectedTitle} (${match.id})`
|
|
1604
|
+
);
|
|
1503
1605
|
kv.id = match.id;
|
|
1504
1606
|
modified = true;
|
|
1505
1607
|
} else {
|
|
1506
|
-
console.log(
|
|
1507
|
-
|
|
1608
|
+
console.log(
|
|
1609
|
+
`\u{1F528} [qarpeo] Creating ${isPreview ? "preview" : "remote"} KV namespace: ${expectedTitle}...`
|
|
1610
|
+
);
|
|
1611
|
+
const createRes = spawnBinSync(
|
|
1508
1612
|
wranglerBin,
|
|
1509
1613
|
["kv", "namespace", "create", expectedTitle],
|
|
1510
|
-
{ cwd, encoding: "utf8"
|
|
1614
|
+
{ cwd, encoding: "utf8" }
|
|
1511
1615
|
);
|
|
1512
|
-
const
|
|
1616
|
+
const stdoutKv = String(createRes.stdout || "");
|
|
1617
|
+
const matchId = stdoutKv.match(/id\s*=\s*"([^"]+)"/);
|
|
1513
1618
|
if (matchId?.[1]) {
|
|
1514
1619
|
kv.id = matchId[1];
|
|
1515
1620
|
modified = true;
|
|
1516
|
-
console.log(
|
|
1621
|
+
console.log(
|
|
1622
|
+
`\u2705 [qarpeo] Created ${isPreview ? "preview" : "remote"} KV namespace: ${matchId[1]}`
|
|
1623
|
+
);
|
|
1517
1624
|
}
|
|
1518
1625
|
}
|
|
1519
1626
|
}
|
|
@@ -1522,10 +1629,9 @@ const deploy = defineCommand({
|
|
|
1522
1629
|
if (Array.isArray(config.r2_buckets) && config.r2_buckets.length > 0) {
|
|
1523
1630
|
for (const r2 of config.r2_buckets) {
|
|
1524
1631
|
if (r2.bucket_name) {
|
|
1525
|
-
|
|
1632
|
+
spawnBinSync(wranglerBin, ["r2", "bucket", "create", r2.bucket_name], {
|
|
1526
1633
|
cwd,
|
|
1527
|
-
stdio: "pipe"
|
|
1528
|
-
shell: process.platform === "win32"
|
|
1634
|
+
stdio: "pipe"
|
|
1529
1635
|
});
|
|
1530
1636
|
}
|
|
1531
1637
|
}
|
|
@@ -1562,10 +1668,9 @@ const deploy = defineCommand({
|
|
|
1562
1668
|
"-c",
|
|
1563
1669
|
wranglerConfigPath
|
|
1564
1670
|
];
|
|
1565
|
-
|
|
1671
|
+
spawnBinSync(wranglerBin, migArgs, {
|
|
1566
1672
|
cwd,
|
|
1567
|
-
stdio: "inherit"
|
|
1568
|
-
shell: process.platform === "win32"
|
|
1673
|
+
stdio: "inherit"
|
|
1569
1674
|
});
|
|
1570
1675
|
}
|
|
1571
1676
|
}
|
|
@@ -1607,10 +1712,9 @@ const deploy = defineCommand({
|
|
|
1607
1712
|
if (args.env) {
|
|
1608
1713
|
deployArgs.push("--env", args.env);
|
|
1609
1714
|
}
|
|
1610
|
-
const deployRes =
|
|
1715
|
+
const deployRes = spawnBinSync(wranglerBin, deployArgs, {
|
|
1611
1716
|
cwd,
|
|
1612
|
-
stdio: "inherit"
|
|
1613
|
-
shell: process.platform === "win32"
|
|
1717
|
+
stdio: "inherit"
|
|
1614
1718
|
});
|
|
1615
1719
|
if (deployRes.status !== 0) {
|
|
1616
1720
|
console.error(`
|
|
@@ -1710,15 +1814,11 @@ const doctor = defineCommand({
|
|
|
1710
1814
|
const wranglerBin = resolveBinaryPath("wrangler", cwd);
|
|
1711
1815
|
if (wranglerBin) {
|
|
1712
1816
|
try {
|
|
1713
|
-
const proc =
|
|
1714
|
-
cwd,
|
|
1715
|
-
encoding: "utf8",
|
|
1716
|
-
shell: true
|
|
1717
|
-
}) : spawnSync(wranglerBin, ["--version"], {
|
|
1817
|
+
const proc = spawnBinSync(wranglerBin, ["--version"], {
|
|
1718
1818
|
cwd,
|
|
1719
1819
|
encoding: "utf8"
|
|
1720
1820
|
});
|
|
1721
|
-
const out = proc.stdout ? proc.stdout.trim() : "";
|
|
1821
|
+
const out = proc.stdout ? String(proc.stdout).trim() : "";
|
|
1722
1822
|
envItems.push({
|
|
1723
1823
|
status: "pass",
|
|
1724
1824
|
title: "Wrangler CLI",
|
|
@@ -1736,7 +1836,7 @@ const doctor = defineCommand({
|
|
|
1736
1836
|
status: isRemote ? "fail" : "warn",
|
|
1737
1837
|
title: "Wrangler CLI",
|
|
1738
1838
|
message: "Not found locally in node_modules or PATH",
|
|
1739
|
-
help: "Install wrangler as a dev dependency:
|
|
1839
|
+
help: "Install wrangler as a dev dependency: vp add -D wrangler"
|
|
1740
1840
|
});
|
|
1741
1841
|
}
|
|
1742
1842
|
categories.push({
|
|
@@ -1822,7 +1922,10 @@ const doctor = defineCommand({
|
|
|
1822
1922
|
title: "Active Features",
|
|
1823
1923
|
message: enabledFeatures.length > 0 ? enabledFeatures.join(", ") : "None explicitly enabled (running bare runtime)"
|
|
1824
1924
|
});
|
|
1825
|
-
const projectName = resolveProjectName(
|
|
1925
|
+
const projectName = resolveProjectName(
|
|
1926
|
+
{ options: { ...nuxtConfig, rootDir: cwd } },
|
|
1927
|
+
qarpeoConfig
|
|
1928
|
+
);
|
|
1826
1929
|
configItems.push({
|
|
1827
1930
|
status: "info",
|
|
1828
1931
|
title: "Project / Worker Name",
|
|
@@ -1876,7 +1979,9 @@ const doctor = defineCommand({
|
|
|
1876
1979
|
message: "Local dev uses Miniflare emulation (no account ID required)"
|
|
1877
1980
|
});
|
|
1878
1981
|
}
|
|
1879
|
-
const isDbEnabled = Boolean(
|
|
1982
|
+
const isDbEnabled = Boolean(
|
|
1983
|
+
qarpeoConfig.db || qarpeoConfig.d1 || qarpeoConfig.cms || qarpeoConfig.auth || qarpeoConfig.payments
|
|
1984
|
+
);
|
|
1880
1985
|
if (isDbEnabled) {
|
|
1881
1986
|
const dbBinding = typeof qarpeoConfig.db === "object" && qarpeoConfig.db?.binding ? qarpeoConfig.db.binding : process.env.QARPEO_DB_BINDING || "DB";
|
|
1882
1987
|
const dbId = typeof qarpeoConfig.db === "object" && qarpeoConfig.db?.databaseId || process.env.QARPEO_DB_ID || process.env.DATABASE_ID || process.env.DB_ID;
|
|
@@ -1903,7 +2008,9 @@ const doctor = defineCommand({
|
|
|
1903
2008
|
});
|
|
1904
2009
|
}
|
|
1905
2010
|
}
|
|
1906
|
-
const isBlobEnabled = Boolean(
|
|
2011
|
+
const isBlobEnabled = Boolean(
|
|
2012
|
+
qarpeoConfig.blob || qarpeoConfig.r2 || qarpeoConfig.cms || qarpeoConfig.storage
|
|
2013
|
+
);
|
|
1907
2014
|
if (isBlobEnabled) {
|
|
1908
2015
|
const blobBucket = process.env.QARPEO_BLOB_BUCKET || process.env.BLOB_NAME || typeof qarpeoConfig.blob === "object" && qarpeoConfig.blob?.bucket;
|
|
1909
2016
|
if (isRemote && (!blobBucket || blobBucket.includes("local-dev"))) {
|
|
@@ -1958,7 +2065,7 @@ const doctor = defineCommand({
|
|
|
1958
2065
|
status: "fail",
|
|
1959
2066
|
title: "Drizzle ORM",
|
|
1960
2067
|
message: drizzleCheck.error || `Outdated version v${drizzleCheck.version}`,
|
|
1961
|
-
help: "Upgrade drizzle-orm to v1.0.0 RC:
|
|
2068
|
+
help: "Upgrade drizzle-orm to v1.0.0 RC: vp add drizzle-orm@rc"
|
|
1962
2069
|
});
|
|
1963
2070
|
}
|
|
1964
2071
|
} else {
|
|
@@ -2216,13 +2323,55 @@ ${cat.icon} ${cat.title}`);
|
|
|
2216
2323
|
});
|
|
2217
2324
|
|
|
2218
2325
|
const AVAILABLE_FEATURES = [
|
|
2219
|
-
{
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2326
|
+
{
|
|
2327
|
+
key: "db",
|
|
2328
|
+
name: "D1 Database & Drizzle ORM",
|
|
2329
|
+
binding: "DB",
|
|
2330
|
+
desc: "Serverless SQL database (D1 + Drizzle)",
|
|
2331
|
+
default: true
|
|
2332
|
+
},
|
|
2333
|
+
{
|
|
2334
|
+
key: "kv",
|
|
2335
|
+
name: "KV Namespaces",
|
|
2336
|
+
binding: "KV",
|
|
2337
|
+
desc: "Low-latency key-value data storage and sessions",
|
|
2338
|
+
default: true
|
|
2339
|
+
},
|
|
2340
|
+
{
|
|
2341
|
+
key: "blob",
|
|
2342
|
+
name: "R2 Object Storage",
|
|
2343
|
+
binding: "BLOB",
|
|
2344
|
+
desc: "Zero egress-fee file & media storage (R2)",
|
|
2345
|
+
default: true
|
|
2346
|
+
},
|
|
2347
|
+
{
|
|
2348
|
+
key: "realtime",
|
|
2349
|
+
name: "Realtime & Durable Objects",
|
|
2350
|
+
binding: "QARPEO_ROOM_DO",
|
|
2351
|
+
desc: "Hibernatable WebSockets, rooms, presence & state",
|
|
2352
|
+
default: false
|
|
2353
|
+
},
|
|
2354
|
+
{
|
|
2355
|
+
key: "ai",
|
|
2356
|
+
name: "Workers AI & Vectorize",
|
|
2357
|
+
binding: "AI",
|
|
2358
|
+
desc: "Edge LLMs, embeddings & vector search",
|
|
2359
|
+
default: false
|
|
2360
|
+
},
|
|
2361
|
+
{
|
|
2362
|
+
key: "queue",
|
|
2363
|
+
name: "Queues & Background Jobs",
|
|
2364
|
+
binding: "QUEUE",
|
|
2365
|
+
desc: "Asynchronous task processing and queues",
|
|
2366
|
+
default: false
|
|
2367
|
+
},
|
|
2368
|
+
{
|
|
2369
|
+
key: "auth",
|
|
2370
|
+
name: "Better Auth Integration",
|
|
2371
|
+
binding: "DB",
|
|
2372
|
+
desc: "Complete auth schemas, sessions & OAuth",
|
|
2373
|
+
default: true
|
|
2374
|
+
}
|
|
2226
2375
|
];
|
|
2227
2376
|
function getWranglerBin$2(cwd) {
|
|
2228
2377
|
return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
|
|
@@ -2281,7 +2430,9 @@ const init = defineCommand({
|
|
|
2281
2430
|
const isInteractive = stdin.isTTY && !args.yes;
|
|
2282
2431
|
const rl = isInteractive ? readline.createInterface({ input: stdin, output: stdout }) : null;
|
|
2283
2432
|
if (rl) {
|
|
2284
|
-
const nameAnswer = await rl.question(
|
|
2433
|
+
const nameAnswer = await rl.question(
|
|
2434
|
+
`\u{1F3F7}\uFE0F \x1B[1mWorker Service Name\x1B[0m [${projectName}]: `
|
|
2435
|
+
);
|
|
2285
2436
|
if (nameAnswer.trim()) {
|
|
2286
2437
|
projectName = nameAnswer.trim().toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
2287
2438
|
}
|
|
@@ -2291,7 +2442,9 @@ const init = defineCommand({
|
|
|
2291
2442
|
console.log("\n\u{1F4E6} \x1B[1mSelect Cloudflare Edge Services to Enable:\x1B[0m");
|
|
2292
2443
|
for (const feat of AVAILABLE_FEATURES) {
|
|
2293
2444
|
const defaultHint = feat.default ? "Y/n" : "y/N";
|
|
2294
|
-
const answer = await rl.question(
|
|
2445
|
+
const answer = await rl.question(
|
|
2446
|
+
` \u2022 Enable ${feat.name} (${feat.desc})? [${defaultHint}]: `
|
|
2447
|
+
);
|
|
2295
2448
|
const trimmed = answer.trim().toLowerCase();
|
|
2296
2449
|
if (trimmed === "") {
|
|
2297
2450
|
selectedFeatures[feat.key] = feat.default;
|
|
@@ -2320,30 +2473,30 @@ const init = defineCommand({
|
|
|
2320
2473
|
const dbName = `${projectName}-db`;
|
|
2321
2474
|
console.log(`
|
|
2322
2475
|
\u23F3 Provisioning Cloudflare D1 Database "${dbName}"...`);
|
|
2323
|
-
const res =
|
|
2476
|
+
const res = spawnBinSync(wrangler, ["d1", "create", dbName], {
|
|
2324
2477
|
cwd,
|
|
2325
2478
|
encoding: "utf8",
|
|
2326
|
-
env: process.env
|
|
2327
|
-
shell: process.platform === "win32"
|
|
2479
|
+
env: process.env
|
|
2328
2480
|
});
|
|
2329
|
-
const uuidMatch = res.stdout
|
|
2481
|
+
const uuidMatch = String(res.stdout || "").match(/database_id\s*=\s*"([a-f0-9-]+)"/i) || String(res.stdout || "").match(/"([a-f0-9-]{36})"/i);
|
|
2330
2482
|
if (uuidMatch) {
|
|
2331
2483
|
createdResources.dbId = uuidMatch[1];
|
|
2332
2484
|
console.log(` \x1B[32m\u2714\x1B[0m Created D1 database: ${createdResources.dbId}`);
|
|
2333
2485
|
} else {
|
|
2334
|
-
console.log(
|
|
2486
|
+
console.log(
|
|
2487
|
+
` \u2139\uFE0F Note: If database already exists or output was masked, default binding was applied.`
|
|
2488
|
+
);
|
|
2335
2489
|
}
|
|
2336
2490
|
}
|
|
2337
2491
|
if (selectedFeatures.kv) {
|
|
2338
2492
|
const kvTitle = `${projectName}-kv`;
|
|
2339
2493
|
console.log(`\u23F3 Provisioning Cloudflare KV Namespace "${kvTitle}"...`);
|
|
2340
|
-
const res =
|
|
2494
|
+
const res = spawnBinSync(wrangler, ["kv", "namespace", "create", kvTitle], {
|
|
2341
2495
|
cwd,
|
|
2342
2496
|
encoding: "utf8",
|
|
2343
|
-
env: process.env
|
|
2344
|
-
shell: process.platform === "win32"
|
|
2497
|
+
env: process.env
|
|
2345
2498
|
});
|
|
2346
|
-
const kvMatch = res.stdout
|
|
2499
|
+
const kvMatch = String(res.stdout || "").match(/id\s*=\s*"([a-f0-9]+)"/i) || String(res.stdout || "").match(/"([a-f0-9]{32})"/i);
|
|
2347
2500
|
if (kvMatch) {
|
|
2348
2501
|
createdResources.kvId = kvMatch[1];
|
|
2349
2502
|
console.log(` \x1B[32m\u2714\x1B[0m Created KV namespace: ${createdResources.kvId}`);
|
|
@@ -2352,11 +2505,10 @@ const init = defineCommand({
|
|
|
2352
2505
|
if (selectedFeatures.blob) {
|
|
2353
2506
|
const bucketName = `${projectName}-storage`;
|
|
2354
2507
|
console.log(`\u23F3 Provisioning Cloudflare R2 Bucket "${bucketName}"...`);
|
|
2355
|
-
|
|
2508
|
+
spawnBinSync(wrangler, ["r2", "bucket", "create", bucketName], {
|
|
2356
2509
|
cwd,
|
|
2357
2510
|
encoding: "utf8",
|
|
2358
|
-
env: process.env
|
|
2359
|
-
shell: process.platform === "win32"
|
|
2511
|
+
env: process.env
|
|
2360
2512
|
});
|
|
2361
2513
|
createdResources.blobBucket = bucketName;
|
|
2362
2514
|
console.log(` \x1B[32m\u2714\x1B[0m Created R2 bucket: ${bucketName}`);
|
|
@@ -2533,21 +2685,25 @@ ${qarpeoConfigBlock}`
|
|
|
2533
2685
|
} else {
|
|
2534
2686
|
console.log(`
|
|
2535
2687
|
\u{1F4A1} Add the following to your \x1B[1mnuxt.config.ts\x1B[0m:`);
|
|
2536
|
-
console.log(
|
|
2688
|
+
console.log(
|
|
2689
|
+
`
|
|
2537
2690
|
export default defineNuxtConfig({
|
|
2538
2691
|
modules: ["qarpeo"],
|
|
2539
2692
|
${qarpeoConfigBlock}
|
|
2540
2693
|
})
|
|
2541
|
-
`
|
|
2694
|
+
`
|
|
2695
|
+
);
|
|
2542
2696
|
}
|
|
2543
2697
|
console.log("\n\u{1F389} \x1B[1m\x1B[32mQarpeo initialized successfully!\x1B[0m\n");
|
|
2544
2698
|
console.log(" \x1B[1mNext Steps:\x1B[0m");
|
|
2545
|
-
console.log(
|
|
2699
|
+
console.log(
|
|
2700
|
+
" \u2022 Run \x1B[36mvpr dev\x1B[0m (or \x1B[36mvpx nuxt dev\x1B[0m) to start your edge development server"
|
|
2701
|
+
);
|
|
2546
2702
|
if (selectedFeatures.db) {
|
|
2547
|
-
console.log(" \u2022 Run \x1B[
|
|
2703
|
+
console.log(" \u2022 Run \x1B[36mvpx qp db push\x1B[0m to apply your database schemas");
|
|
2548
2704
|
}
|
|
2549
|
-
console.log(" \u2022 Run \x1B[
|
|
2550
|
-
console.log(" \u2022 Run \x1B[
|
|
2705
|
+
console.log(" \u2022 Run \x1B[36mvpx qp doctor\x1B[0m to verify all edge bindings");
|
|
2706
|
+
console.log(" \u2022 Run \x1B[36mvpx qp deploy\x1B[0m to deploy directly to Cloudflare Workers\n");
|
|
2551
2707
|
}
|
|
2552
2708
|
});
|
|
2553
2709
|
|
|
@@ -2612,14 +2768,16 @@ const listCommand = defineCommand({
|
|
|
2612
2768
|
}
|
|
2613
2769
|
const tableData = workers.map((w) => ({
|
|
2614
2770
|
"Worker Name": w.id,
|
|
2615
|
-
|
|
2771
|
+
Created: w.created_on ? w.created_on.slice(0, 19).replace("T", " ") : "-",
|
|
2616
2772
|
"Last Modified": w.modified_on ? w.modified_on.slice(0, 19).replace("T", " ") : "-",
|
|
2617
|
-
|
|
2773
|
+
Assets: w.has_assets ? "Yes" : "No"
|
|
2618
2774
|
}));
|
|
2619
2775
|
console.table(tableData);
|
|
2620
2776
|
console.log(`
|
|
2621
2777
|
\u{1F4E6} Total Workers: ${workers.length}`);
|
|
2622
|
-
console.log(
|
|
2778
|
+
console.log(
|
|
2779
|
+
"\u{1F4A1} Tip: Run `qp delete <worker-name>` or simply `qp delete` to interactively select and delete.\n"
|
|
2780
|
+
);
|
|
2623
2781
|
} catch (err) {
|
|
2624
2782
|
console.error(`
|
|
2625
2783
|
\u274C [qarpeo] ${err?.message || err}
|
|
@@ -2637,20 +2795,27 @@ const login = defineCommand({
|
|
|
2637
2795
|
name: "login",
|
|
2638
2796
|
description: "Authenticate with Cloudflare via browser OAuth (powered by Wrangler)"
|
|
2639
2797
|
},
|
|
2640
|
-
args: {
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2798
|
+
args: {
|
|
2799
|
+
browser: {
|
|
2800
|
+
type: "boolean",
|
|
2801
|
+
description: "Automatically open the link in your default browser",
|
|
2802
|
+
default: false
|
|
2803
|
+
}
|
|
2804
|
+
},
|
|
2805
|
+
async run({ args }) {
|
|
2806
|
+
console.log("\u{1F510} [qarpeo] Authenticating with Cloudflare...");
|
|
2807
|
+
console.log(" After login, your credentials will be stored in ~/.wrangler/config/\n");
|
|
2646
2808
|
await ensurePackage("wrangler", {
|
|
2647
2809
|
purpose: "authenticating with Cloudflare"
|
|
2648
2810
|
});
|
|
2649
2811
|
const wrangler = getWranglerBin$1();
|
|
2650
|
-
const
|
|
2812
|
+
const wranglerArgs = ["login"];
|
|
2813
|
+
if (!args.browser) {
|
|
2814
|
+
wranglerArgs.push("--no-browser");
|
|
2815
|
+
}
|
|
2816
|
+
const result = spawnBinSync(wrangler, wranglerArgs, {
|
|
2651
2817
|
stdio: "inherit",
|
|
2652
|
-
env: process.env
|
|
2653
|
-
shell: process.platform === "win32"
|
|
2818
|
+
env: process.env
|
|
2654
2819
|
});
|
|
2655
2820
|
if (result.status !== 0) {
|
|
2656
2821
|
console.error(
|
|
@@ -2674,21 +2839,16 @@ const logout = defineCommand({
|
|
|
2674
2839
|
purpose: "logging out of Cloudflare"
|
|
2675
2840
|
});
|
|
2676
2841
|
const wrangler = getWranglerBin$1();
|
|
2677
|
-
const result =
|
|
2842
|
+
const result = spawnBinSync(wrangler, ["logout"], {
|
|
2678
2843
|
stdio: "inherit",
|
|
2679
|
-
env: process.env
|
|
2680
|
-
shell: process.platform === "win32"
|
|
2844
|
+
env: process.env
|
|
2681
2845
|
});
|
|
2682
2846
|
if (result.status !== 0) {
|
|
2683
|
-
console.error(
|
|
2684
|
-
"\n\u274C [qarpeo] Logout failed. You may not have been logged in."
|
|
2685
|
-
);
|
|
2847
|
+
console.error("\n\u274C [qarpeo] Logout failed. You may not have been logged in.");
|
|
2686
2848
|
process.exit(result.status ?? 1);
|
|
2687
2849
|
}
|
|
2688
2850
|
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
|
-
);
|
|
2851
|
+
console.log(" To re-authenticate, run `qp login` or set CLOUDFLARE_API_TOKEN in .env\n");
|
|
2692
2852
|
}
|
|
2693
2853
|
});
|
|
2694
2854
|
const whoami = defineCommand({
|
|
@@ -2702,10 +2862,9 @@ const whoami = defineCommand({
|
|
|
2702
2862
|
purpose: "checking Cloudflare account status"
|
|
2703
2863
|
});
|
|
2704
2864
|
const wrangler = getWranglerBin$1();
|
|
2705
|
-
const result =
|
|
2865
|
+
const result = spawnBinSync(wrangler, ["whoami"], {
|
|
2706
2866
|
stdio: "inherit",
|
|
2707
|
-
env: process.env
|
|
2708
|
-
shell: process.platform === "win32"
|
|
2867
|
+
env: process.env
|
|
2709
2868
|
});
|
|
2710
2869
|
if (result.status !== 0) {
|
|
2711
2870
|
console.error(
|
|
@@ -2809,11 +2968,21 @@ const logs = defineCommand({
|
|
|
2809
2968
|
console.log(`> wrangler ${tailArgs.join(" ")}
|
|
2810
2969
|
`);
|
|
2811
2970
|
console.log("Press Ctrl+C to exit streaming logs.\n");
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2971
|
+
let child;
|
|
2972
|
+
if (process.platform === "win32" && (wranglerBin.endsWith(".cmd") || wranglerBin.endsWith(".bat"))) {
|
|
2973
|
+
const cmd = process.env.ComSpec || "cmd.exe";
|
|
2974
|
+
child = spawn(cmd, ["/d", "/s", "/c", wranglerBin, ...tailArgs], {
|
|
2975
|
+
cwd,
|
|
2976
|
+
stdio: "inherit",
|
|
2977
|
+
shell: false
|
|
2978
|
+
});
|
|
2979
|
+
} else {
|
|
2980
|
+
child = spawn(wranglerBin, tailArgs, {
|
|
2981
|
+
cwd,
|
|
2982
|
+
stdio: "inherit",
|
|
2983
|
+
shell: false
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2817
2986
|
await new Promise((resolvePromise) => {
|
|
2818
2987
|
child.on("close", () => {
|
|
2819
2988
|
resolvePromise();
|
|
@@ -2888,8 +3057,10 @@ const pushSecret = defineCommand({
|
|
|
2888
3057
|
console.log("\u2139\uFE0F [qarpeo] No secret keys detected in .env to synchronize.");
|
|
2889
3058
|
return;
|
|
2890
3059
|
}
|
|
2891
|
-
console.log(
|
|
2892
|
-
|
|
3060
|
+
console.log(
|
|
3061
|
+
`
|
|
3062
|
+
\u{1F510} [qarpeo] Found ${secretEntries.length} secrets to synchronize with Cloudflare Workers:`
|
|
3063
|
+
);
|
|
2893
3064
|
for (const [k] of secretEntries) {
|
|
2894
3065
|
console.log(` \u2022 ${k}`);
|
|
2895
3066
|
}
|
|
@@ -2905,11 +3076,10 @@ const pushSecret = defineCommand({
|
|
|
2905
3076
|
console.log("\n\u{1F680} [qarpeo] Uploading secrets via wrangler secret:bulk...");
|
|
2906
3077
|
const wranglerArgs = ["secret:bulk"];
|
|
2907
3078
|
if (args.env) wranglerArgs.push("--env", args.env);
|
|
2908
|
-
const res =
|
|
3079
|
+
const res = spawnBinSync(wrangler, wranglerArgs, {
|
|
2909
3080
|
cwd,
|
|
2910
3081
|
input: JSON.stringify(secretJson),
|
|
2911
|
-
encoding: "utf8"
|
|
2912
|
-
shell: process.platform === "win32"
|
|
3082
|
+
encoding: "utf8"
|
|
2913
3083
|
});
|
|
2914
3084
|
if (res.status === 0) {
|
|
2915
3085
|
console.log("\n\u2705 [qarpeo] All secrets synchronized successfully with Cloudflare Workers!\n");
|
|
@@ -2919,11 +3089,10 @@ const pushSecret = defineCommand({
|
|
|
2919
3089
|
for (const [k, v] of secretEntries) {
|
|
2920
3090
|
const putArgs = ["secret", "put", k];
|
|
2921
3091
|
if (args.env) putArgs.push("--env", args.env);
|
|
2922
|
-
const putRes =
|
|
3092
|
+
const putRes = spawnBinSync(wrangler, putArgs, {
|
|
2923
3093
|
cwd,
|
|
2924
3094
|
input: v,
|
|
2925
|
-
encoding: "utf8"
|
|
2926
|
-
shell: process.platform === "win32"
|
|
3095
|
+
encoding: "utf8"
|
|
2927
3096
|
});
|
|
2928
3097
|
if (putRes.status === 0) {
|
|
2929
3098
|
console.log(` \u2714 Synced ${k}`);
|
|
@@ -2972,16 +3141,17 @@ const pullSecret = defineCommand({
|
|
|
2972
3141
|
console.log("\n\u{1F50D} [qarpeo] Fetching Cloudflare Worker secrets list...");
|
|
2973
3142
|
const listArgs = ["secret", "list"];
|
|
2974
3143
|
if (args.env) listArgs.push("--env", args.env);
|
|
2975
|
-
const res =
|
|
3144
|
+
const res = spawnBinSync(wrangler, listArgs, {
|
|
2976
3145
|
cwd,
|
|
2977
|
-
stdio: "inherit"
|
|
2978
|
-
shell: process.platform === "win32"
|
|
3146
|
+
stdio: "inherit"
|
|
2979
3147
|
});
|
|
2980
3148
|
if (res.status !== 0) {
|
|
2981
3149
|
console.error("\n\u274C [qarpeo] Failed to retrieve secrets from Cloudflare.");
|
|
2982
3150
|
process.exit(res.status ?? 1);
|
|
2983
3151
|
}
|
|
2984
|
-
console.log(
|
|
3152
|
+
console.log(
|
|
3153
|
+
"\n\u{1F4A1} Note: Cloudflare encrypted secrets cannot be downloaded in plaintext for security."
|
|
3154
|
+
);
|
|
2985
3155
|
console.log(" The list above displays the secrets currently active on the edge.\n");
|
|
2986
3156
|
}
|
|
2987
3157
|
});
|
|
@@ -3068,9 +3238,7 @@ const taskList = defineCommand({
|
|
|
3068
3238
|
const tasks = findProjectTasks(cwd);
|
|
3069
3239
|
if (tasks.length === 0) {
|
|
3070
3240
|
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
|
-
);
|
|
3241
|
+
console.log(" Create tasks in server/tasks/ or server/cron/ using defineScheduledTask().\n");
|
|
3074
3242
|
return;
|
|
3075
3243
|
}
|
|
3076
3244
|
console.log(`
|
|
@@ -3078,9 +3246,7 @@ const taskList = defineCommand({
|
|
|
3078
3246
|
`);
|
|
3079
3247
|
const col1 = Math.max(4, ...tasks.map((t) => t.name.length));
|
|
3080
3248
|
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
|
-
);
|
|
3249
|
+
console.log(` ${"Task".padEnd(col1)} ${"Cron".padEnd(col2)} Description`);
|
|
3084
3250
|
console.log(` ${"\u2500".repeat(col1)} ${"\u2500".repeat(col2)} ${"\u2500".repeat(32)}`);
|
|
3085
3251
|
for (const task2 of tasks) {
|
|
3086
3252
|
const cron = task2.cron || "manual only";
|
|
@@ -3203,7 +3369,7 @@ const testCommand = defineCommand({
|
|
|
3203
3369
|
process.env.QARPEO_EDGE_TEST = "1";
|
|
3204
3370
|
process.env.NODE_ENV = "test";
|
|
3205
3371
|
const isWindows = process.platform === "win32";
|
|
3206
|
-
let runner = isWindows ? "
|
|
3372
|
+
let runner = isWindows ? "vp.cmd" : "vp";
|
|
3207
3373
|
let runnerArgs = ["test"];
|
|
3208
3374
|
if (args.watch) {
|
|
3209
3375
|
runnerArgs.push("--watch");
|
|
@@ -3215,20 +3381,34 @@ const testCommand = defineCommand({
|
|
|
3215
3381
|
}
|
|
3216
3382
|
console.log(`\u25B6 Executing: ${runner} ${runnerArgs.join(" ")}
|
|
3217
3383
|
`);
|
|
3218
|
-
return new Promise((
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3384
|
+
return new Promise((resolve, reject) => {
|
|
3385
|
+
let child;
|
|
3386
|
+
if (isWindows) {
|
|
3387
|
+
const cmd = process.env.ComSpec || "cmd.exe";
|
|
3388
|
+
child = spawn(cmd, ["/d", "/s", "/c", runner, ...runnerArgs], {
|
|
3389
|
+
cwd,
|
|
3390
|
+
stdio: "inherit",
|
|
3391
|
+
shell: false,
|
|
3392
|
+
env: {
|
|
3393
|
+
...process.env,
|
|
3394
|
+
QARPEO_EDGE_TEST: "1"
|
|
3395
|
+
}
|
|
3396
|
+
});
|
|
3397
|
+
} else {
|
|
3398
|
+
child = spawn(runner, runnerArgs, {
|
|
3399
|
+
cwd,
|
|
3400
|
+
stdio: "inherit",
|
|
3401
|
+
shell: false,
|
|
3402
|
+
env: {
|
|
3403
|
+
...process.env,
|
|
3404
|
+
QARPEO_EDGE_TEST: "1"
|
|
3405
|
+
}
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3228
3408
|
child.on("close", (code) => {
|
|
3229
3409
|
if (code === 0) {
|
|
3230
3410
|
console.log("\n\u2705 All edge tests completed successfully!\n");
|
|
3231
|
-
|
|
3411
|
+
resolve();
|
|
3232
3412
|
} else {
|
|
3233
3413
|
console.error(`
|
|
3234
3414
|
\u274C Tests failed with exit code ${code}
|
|
@@ -3287,11 +3467,21 @@ const tunnel = defineCommand({
|
|
|
3287
3467
|
} else {
|
|
3288
3468
|
tunnelArgs.push("tunnel", "--url", targetUrl);
|
|
3289
3469
|
}
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3470
|
+
let child;
|
|
3471
|
+
if (process.platform === "win32" && (cloudflaredBin.endsWith(".cmd") || cloudflaredBin.endsWith(".bat"))) {
|
|
3472
|
+
const cmd = process.env.ComSpec || "cmd.exe";
|
|
3473
|
+
child = spawn(cmd, ["/d", "/s", "/c", cloudflaredBin, ...tunnelArgs], {
|
|
3474
|
+
cwd,
|
|
3475
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
3476
|
+
shell: false
|
|
3477
|
+
});
|
|
3478
|
+
} else {
|
|
3479
|
+
child = spawn(cloudflaredBin, tunnelArgs, {
|
|
3480
|
+
cwd,
|
|
3481
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
3482
|
+
shell: false
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3295
3485
|
let publicUrl = "";
|
|
3296
3486
|
const parseOutput = (data) => {
|
|
3297
3487
|
const text = data.toString();
|
|
@@ -3318,9 +3508,13 @@ const tunnel = defineCommand({
|
|
|
3318
3508
|
if (err?.code === "ENOENT") {
|
|
3319
3509
|
console.error("\u274C [qarpeo] 'cloudflared' CLI was not found on your system.");
|
|
3320
3510
|
console.error("\u{1F449} Install it with:");
|
|
3321
|
-
console.error(
|
|
3511
|
+
console.error(
|
|
3512
|
+
" \u2022 Windows: winget install Cloudflare.cloudflared (or choco install cloudflared)"
|
|
3513
|
+
);
|
|
3322
3514
|
console.error(" \u2022 macOS: brew install cloudflare/cloudflare/cloudflared");
|
|
3323
|
-
console.error(
|
|
3515
|
+
console.error(
|
|
3516
|
+
" \u2022 Linux: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/\n"
|
|
3517
|
+
);
|
|
3324
3518
|
} else {
|
|
3325
3519
|
console.error("\u274C [qarpeo] Cloudflare Tunnel failed:", err.message);
|
|
3326
3520
|
}
|
|
@@ -3338,7 +3532,7 @@ const tunnel = defineCommand({
|
|
|
3338
3532
|
const main = defineCommand({
|
|
3339
3533
|
meta: {
|
|
3340
3534
|
name: "qp",
|
|
3341
|
-
version
|
|
3535
|
+
version,
|
|
3342
3536
|
description: "Cloudflare-native powerhouse module for Nuxt"
|
|
3343
3537
|
},
|
|
3344
3538
|
subCommands: {
|