nuxt-backend 0.4.0 → 0.5.1
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 +5 -2
- package/dist/chunks/catalog.mjs +1 -1
- package/dist/chunks/doctor.mjs +4 -4
- package/dist/chunks/email-previews.mjs +1 -1
- package/dist/chunks/health.mjs +2 -2
- package/dist/chunks/index.mjs +2 -2
- package/dist/chunks/install.mjs +8 -8
- package/dist/chunks/run.mjs +1 -1
- package/dist/chunks/server.mjs +4 -4
- package/dist/cli.mjs +13 -56
- package/dist/devtools-client/index.html +1 -1
- package/dist/module.js +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/vue/components/auth/InviteRedeem.vue +4 -22
- package/dist/runtime/vue/components/auth/WaitlistStatus.vue +7 -17
- package/dist/runtime/vue/components/billing/PricingTable.vue +17 -51
- package/dist/runtime/vue/components/billing/ReferralLanding.vue +1 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceBilling.vue +15 -18
- package/dist/runtime/vue/components/workspaces/WorkspaceBillingPause.vue +1 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.d.vue.ts +2 -2
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue +9 -22
- package/dist/runtime/vue/components/workspaces/WorkspaceSettings.vue.d.ts +2 -2
- package/dist/runtime/vue/components/workspaces/workspace-billing.d.ts +12 -16
- package/dist/runtime/vue/components/workspaces/workspace-billing.js +22 -37
- package/dist/runtime/vue/composables/use-access.d.ts +18 -0
- package/dist/runtime/vue/composables/use-access.js +33 -6
- package/dist/runtime/vue/composables/use-billing-section.d.ts +115 -0
- package/dist/runtime/vue/composables/use-billing-section.js +76 -0
- package/dist/runtime/vue/composables/use-gift-form.js +7 -24
- package/dist/runtime/vue/composables/use-gift-list.d.ts +18 -1
- package/dist/runtime/vue/composables/use-gift-list.js +6 -1
- package/dist/runtime/vue/composables/use-plan-change.d.ts +148 -0
- package/dist/runtime/vue/composables/use-plan-change.js +130 -0
- package/dist/runtime/vue/composables/use-pricing.d.ts +29 -0
- package/dist/runtime/vue/composables/use-pricing.js +53 -14
- package/dist/runtime/vue/composables/use-referral-invite.d.ts +7 -0
- package/dist/runtime/vue/composables/use-referral-invite.js +4 -1
- package/dist/runtime/vue/composables/use-waitlist.d.ts +18 -0
- package/dist/runtime/vue/composables/use-waitlist.js +24 -0
- package/dist/runtime/vue/pages/pricing.vue +1 -2
- package/dist/runtime/vue/plugins/checkout-return.js +9 -2
- package/dist/runtime/vue/utils/checkout-return.d.ts +11 -1
- package/dist/runtime/vue/utils/checkout-return.js +6 -2
- package/dist/runtime/vue/utils/gift-days.d.ts +20 -0
- package/dist/runtime/vue/utils/gift-days.js +32 -0
- package/dist/runtime/vue/utils/namespace.js +7 -2
- package/dist/runtime/vue/utils/page-open.d.ts +1 -0
- package/dist/runtime/vue/utils/page-open.js +12 -0
- package/dist/runtime/vue/utils/plan-change-confirm.d.ts +38 -26
- package/dist/runtime/vue/utils/plan-change-confirm.js +25 -16
- package/dist/runtime/vue/utils/pricing-checkout.d.ts +39 -0
- package/dist/runtime/vue/utils/pricing-checkout.js +22 -0
- package/dist/runtime/vue/utils/tab-keep.d.ts +3 -1
- package/dist/runtime/vue/utils/tab-keep.js +1 -1
- package/dist/shared/{nuxt-backend.CbR37s_c.mjs → nuxt-backend.0r1vvS1c.mjs} +24 -4
- package/dist/shared/{nuxt-backend.BjQoqNIu.mjs → nuxt-backend.BvKvJ1mo.mjs} +1 -1
- package/dist/shared/nuxt-backend.DRuHg-IQ.mjs +290 -0
- package/dist/shared/{nuxt-backend.9IVxzzft.mjs → nuxt-backend.suXOnqOQ.mjs} +163 -4
- package/dist/shared/{nuxt-backend.Baxb382E.mjs → nuxt-backend.zY6UDqDu.mjs} +1 -1
- package/package.json +2 -2
- package/skills/nuxt-backend/references/api.md +3 -1
- package/skills/nuxt-backend/references/install.md +9 -3
- package/skills/nuxt-backend/references/renames.json +8 -0
- package/skills/nuxt-backend/references/surface.json +2 -0
- package/skills/nuxt-backend-billing/SKILL.md +9 -0
- package/skills/nuxt-backend-billing/references/api.md +2 -0
- package/skills/nuxt-backend-upgrade/references/upgrade.md +6 -0
- package/src/runtime/vue/components/auth/InviteRedeem.vue +5 -26
- package/src/runtime/vue/components/auth/WaitlistStatus.vue +11 -20
- package/src/runtime/vue/components/billing/PricingTable.vue +25 -82
- package/src/runtime/vue/components/billing/ReferralLanding.vue +1 -2
- package/src/runtime/vue/components/workspaces/WorkspaceBilling.vue +21 -25
- package/src/runtime/vue/components/workspaces/WorkspaceBillingPause.vue +1 -2
- package/src/runtime/vue/components/workspaces/WorkspaceSettings.vue +16 -29
- package/src/runtime/vue/pages/pricing.vue +1 -4
- package/dist/shared/nuxt-backend.BCjeoX0x.mjs +0 -119
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useLogger, addPlugin, hasNuxtModule, addVitePlugin, addServerHandler, addNitroPlugin, extendRouteRules, extendPages, addTypeTemplate, addPluginTemplate, updateTemplates, addImports, addComponent, addServerImports, addRouteMiddleware, addTemplate, resolveModule, defineNuxtModule, createResolver } from '@nuxt/kit';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
|
-
import { j as resolveFunctionsDir, T as BACKEND_PAGE_DEFS, a1 as pagePathShape, J as computeDeployment, a2 as collectPreflightFindings, N as detectCapabilities, K as appMonitoringDsn, L as monitoringSdkInstalled, a3 as OPTIONAL_DEPLOYMENT_ENV, a4 as REQUIRED_DEPLOYMENT_ENV, a5 as deriveDeploymentUrls, a6 as provisionedEnvNames, a7 as appComponentIsStarter, r as readEnvFiles, a8 as resolveSiteUrl, _ as formatPreflightSummary, a9 as needsSetup, aa as AGENT_HINT, ab as HEALTH_ROUTE, ac as LOCAL_LOG_ROUTE, ad as monitoringSdkVersion, ae as MONITORING_SDK, af as TUNNEL_SDK_VERSION, ag as SOURCE_MAP_ENV, ah as sdkServesTunnel, ai as installableProblems, aj as pagesOptionProblems, ak as resolvedBackendPages, al as DEFAULT_AUTH_ROUTE, Q as REGISTERED_UI, am as publishedBackendPages, an as isPageOff, ao as privatePagePaths, ap as collectExistingPagePaths, aq as adoptChildPages, ar as pageRouteRules, as as cachingRulesOver, V as packageDir, z as appBrandOf, A as syncBrandFile, E as brandFileLocation, F as appLabelsOf, G as syncLabelsFile, H as labelsFileLocation, at as PUSH_WORKER_URL, au as ownsManifest, av as MANIFEST_MODULES, aw as namedIconWarnings, ax as installableGaps, ay as installIcons, az as webAppManifest, aA as maskableIcons, aB as MANIFEST_ROUTE, aC as APPLE_TOUCH_ICON, aD as themeColorMeta, w as syncPathsFile, x as backendPathsOf, y as pathsFileLocation, S as uiPath, aE as UI_SHARED_STYLES, aF as UI_ENTRIES, aG as UI_INTERNALS, aH as moduleDir, aI as VISITOR_IP_ROUTE, aJ as resolvePagePath, aK as dependencyRange, aL as runsFromSource, Y as packageVersion } from './nuxt-backend.
|
|
3
|
+
import { j as resolveFunctionsDir, T as BACKEND_PAGE_DEFS, a1 as pagePathShape, J as computeDeployment, a2 as collectPreflightFindings, N as detectCapabilities, K as appMonitoringDsn, L as monitoringSdkInstalled, a3 as OPTIONAL_DEPLOYMENT_ENV, a4 as REQUIRED_DEPLOYMENT_ENV, a5 as deriveDeploymentUrls, a6 as provisionedEnvNames, a7 as appComponentIsStarter, r as readEnvFiles, a8 as resolveSiteUrl, _ as formatPreflightSummary, a9 as needsSetup, aa as AGENT_HINT, ab as HEALTH_ROUTE, ac as LOCAL_LOG_ROUTE, ad as monitoringSdkVersion, ae as MONITORING_SDK, af as TUNNEL_SDK_VERSION, ag as SOURCE_MAP_ENV, ah as sdkServesTunnel, ai as installableProblems, aj as pagesOptionProblems, ak as resolvedBackendPages, al as DEFAULT_AUTH_ROUTE, Q as REGISTERED_UI, am as publishedBackendPages, an as isPageOff, ao as privatePagePaths, ap as collectExistingPagePaths, aq as adoptChildPages, ar as pageRouteRules, as as cachingRulesOver, V as packageDir, z as appBrandOf, A as syncBrandFile, E as brandFileLocation, F as appLabelsOf, G as syncLabelsFile, H as labelsFileLocation, at as PUSH_WORKER_URL, au as ownsManifest, av as MANIFEST_MODULES, aw as namedIconWarnings, ax as installableGaps, ay as installIcons, az as webAppManifest, aA as maskableIcons, aB as MANIFEST_ROUTE, aC as APPLE_TOUCH_ICON, aD as themeColorMeta, w as syncPathsFile, x as backendPathsOf, y as pathsFileLocation, S as uiPath, aE as UI_SHARED_STYLES, aF as UI_ENTRIES, aG as UI_INTERNALS, aH as moduleDir, aI as VISITOR_IP_ROUTE, aJ as resolvePagePath, aK as dependencyRange, aL as runsFromSource, Y as packageVersion } from './nuxt-backend.suXOnqOQ.mjs';
|
|
4
4
|
import { backendAppConfigDefaults } from '../../dist/runtime/config.js';
|
|
5
|
-
import {
|
|
5
|
+
import { readFileSync, existsSync, readdirSync, realpathSync } from 'node:fs';
|
|
6
6
|
import { join, resolve, extname, dirname } from 'node:path';
|
|
7
7
|
import { detectAgent } from 'std-env';
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
@@ -14,6 +14,22 @@ function hasGeneratedApi(rootDir, functionsDir = resolveFunctionsDir(rootDir)) {
|
|
|
14
14
|
const generatedApi = join(rootDir, functionsDir, "_generated", "api");
|
|
15
15
|
return existsSync(`${generatedApi}.d.ts`) || existsSync(`${generatedApi}.js`);
|
|
16
16
|
}
|
|
17
|
+
function generatedModules(rootDir, functionsDir = resolveFunctionsDir(rootDir)) {
|
|
18
|
+
let source;
|
|
19
|
+
try {
|
|
20
|
+
source = readFileSync(join(rootDir, functionsDir, "_generated", "api.d.ts"), "utf8");
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const block = /ApiFromModules<\{([^}]*)\}>/.exec(source)?.[1];
|
|
25
|
+
if (block === void 0) return null;
|
|
26
|
+
if (block.trim() === "") return [];
|
|
27
|
+
const names = /* @__PURE__ */ new Set();
|
|
28
|
+
for (const [, quoted, bare] of block.matchAll(/^\s*(?:"([^"]+)"|([\w$]+))\s*:\s*typeof\b/gm)) {
|
|
29
|
+
names.add((quoted ?? bare).split("/")[0]);
|
|
30
|
+
}
|
|
31
|
+
return names.size > 0 ? [...names].sort() : null;
|
|
32
|
+
}
|
|
17
33
|
function getBackendAliases(rootDir, runtimeDir) {
|
|
18
34
|
const functionsDir = resolveFunctionsDir(rootDir);
|
|
19
35
|
const backendDir = join(rootDir, functionsDir);
|
|
@@ -188,7 +204,7 @@ function runPreflight(options, nuxt) {
|
|
|
188
204
|
});
|
|
189
205
|
if (appComponentIsStarter(nuxt.options.rootDir)) {
|
|
190
206
|
logger.warn(
|
|
191
|
-
"app.vue still renders <NuxtWelcome /> and no <NuxtPage />, so the pages this module registers (/login, /pricing, \u2026) will not render. Replace <NuxtWelcome /> with <NuxtLayout><NuxtPage /></NuxtLayout> \u2014 `npx nuxt-backend init` does it for you, and adds the app shell as the default layout
|
|
207
|
+
"app.vue still renders <NuxtWelcome /> and no <NuxtPage />, so the pages this module registers (/login, /pricing, \u2026) will not render. Replace <NuxtWelcome /> with <NuxtLayout><NuxtPage /></NuxtLayout> \u2014 `npx nuxt-backend init` does it for you, and adds the app shell as the default layout and a home page at /."
|
|
192
208
|
);
|
|
193
209
|
}
|
|
194
210
|
reportPreflight(findings);
|
|
@@ -863,6 +879,8 @@ function registerSaasComposables(resolver) {
|
|
|
863
879
|
{ name: "useFeatures", from: resolver.resolve("./runtime/vue/composables/use-features") },
|
|
864
880
|
{ name: "useCredits", from: resolver.resolve("./runtime/vue/composables/use-credits") },
|
|
865
881
|
{ name: "usePricing", from: resolver.resolve("./runtime/vue/composables/use-pricing") },
|
|
882
|
+
{ name: "usePlanChange", from: resolver.resolve("./runtime/vue/composables/use-plan-change") },
|
|
883
|
+
{ name: "useBillingSection", from: resolver.resolve("./runtime/vue/composables/use-billing-section") },
|
|
866
884
|
{ name: "useCampaign", from: resolver.resolve("./runtime/vue/composables/use-campaign") },
|
|
867
885
|
{ name: "useOrders", from: resolver.resolve("./runtime/vue/composables/use-orders") },
|
|
868
886
|
{ name: "useUsage", from: resolver.resolve("./runtime/vue/composables/use-usage") },
|
|
@@ -1050,7 +1068,9 @@ function registerBackendApi(resolver, nuxt) {
|
|
|
1050
1068
|
"import { defineNuxtPlugin } from '#app'",
|
|
1051
1069
|
"import { api } from '#backend/api'",
|
|
1052
1070
|
`import { provideBackendApi } from ${JSON.stringify(namespaceModule)}`,
|
|
1053
|
-
|
|
1071
|
+
// The top-level names codegen listed: `api` itself answers any name.
|
|
1072
|
+
`const modules = ${JSON.stringify(generatedModules(nuxt.options.rootDir, functionsDir))}`,
|
|
1073
|
+
"export default defineNuxtPlugin({ name: 'nuxt-backend:api', setup(nuxtApp) { provideBackendApi(api, nuxtApp.vueApp, modules ?? undefined) } })",
|
|
1054
1074
|
""
|
|
1055
1075
|
].join("\n") : "import { defineNuxtPlugin } from '#app'\nexport default defineNuxtPlugin({ name: 'nuxt-backend:api', setup() {} })\n"
|
|
1056
1076
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bI as CAPABILITIES, aO as BACKEND_ENV, j as resolveFunctionsDir, u as scaffoldBackendFiles, q as configuredDeployment, I as isDevDeploymentId, bJ as isEnvProvisioned, a0 as devPushRefusal, bK as markEnvProvisioned, b2 as finding, $ as runEnvPush, t as spawnConvex } from './nuxt-backend.suXOnqOQ.mjs';
|
|
2
2
|
import { existsSync, writeFileSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { resolve, join, delimiter } from 'node:path';
|
|
4
4
|
import { defineCommand } from 'citty';
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { join, dirname, relative } from 'node:path';
|
|
5
|
+
import { aR as PROJECT_SKILLS, aS as CORE_SKILL, k as readTextIfPresent, u as scaffoldBackendFiles, aT as mountPagesInAppComponent, aU as ensureDefaultLayout, aV as ensureIndexPage, aW as writeAgentFiles, U as installedVersion, M as MCP_SDK, V as packageDir } from './nuxt-backend.suXOnqOQ.mjs';
|
|
6
|
+
import { a as adoptBackendDevScript, r as renderEnvExample } from './nuxt-backend.BvKvJ1mo.mjs';
|
|
7
|
+
|
|
8
|
+
const LOCKFILES = [
|
|
9
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
10
|
+
["yarn.lock", "yarn"],
|
|
11
|
+
["bun.lock", "bun"],
|
|
12
|
+
["bun.lockb", "bun"],
|
|
13
|
+
["package-lock.json", "npm"],
|
|
14
|
+
["npm-shrinkwrap.json", "npm"]
|
|
15
|
+
];
|
|
16
|
+
function pinned(dir) {
|
|
17
|
+
try {
|
|
18
|
+
const field = JSON.parse(readFileSync(join(dir, "package.json"), "utf8")).packageManager;
|
|
19
|
+
const name = typeof field === "string" ? field.split("@")[0] : void 0;
|
|
20
|
+
return LOCKFILES.find(([, manager]) => manager === name)?.[1] ?? null;
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function packageManagerOf(rootDir) {
|
|
26
|
+
let dir = rootDir;
|
|
27
|
+
for (; ; ) {
|
|
28
|
+
const manager = pinned(dir) ?? LOCKFILES.find(([file]) => existsSync(join(dir, file)))?.[1];
|
|
29
|
+
if (manager) return manager;
|
|
30
|
+
if (dir === dirname(dir) || existsSync(join(dir, ".git"))) return "npm";
|
|
31
|
+
dir = dirname(dir);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function runScript(manager, script) {
|
|
35
|
+
return `${manager} run ${script}`;
|
|
36
|
+
}
|
|
37
|
+
function execBinary(manager, binary) {
|
|
38
|
+
switch (manager) {
|
|
39
|
+
case "pnpm":
|
|
40
|
+
return `pnpm exec ${binary}`;
|
|
41
|
+
// Yarn 1 and Yarn Berry both run an installed binary by its name, Plug'n'Play too.
|
|
42
|
+
case "yarn":
|
|
43
|
+
return `yarn ${binary}`;
|
|
44
|
+
case "bun":
|
|
45
|
+
return `bunx ${binary}`;
|
|
46
|
+
default:
|
|
47
|
+
return `npx ${binary}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const PNPM_WORKSPACE = "pnpm-workspace.yaml";
|
|
52
|
+
const PERMISSIONS_SINCE = { major: 12, minor: 11 };
|
|
53
|
+
const ENTRY_COMMENT = "# The nuxt-backend agent skills are in .agents/skills, where `npx nuxt-backend init` copies them";
|
|
54
|
+
function pinnedPnpm(rootDir) {
|
|
55
|
+
try {
|
|
56
|
+
const field = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8")).packageManager;
|
|
57
|
+
return typeof field === "string" ? /^pnpm@(\d+\.\d+\.\d+)/.exec(field)?.[1] : void 0;
|
|
58
|
+
} catch {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function pnpmVersionIn(rootDir) {
|
|
63
|
+
const known = pinnedPnpm(rootDir) ?? /^pnpm\/(\d+\.\d+\.\d+)/.exec(process.env.npm_config_user_agent ?? "")?.[1];
|
|
64
|
+
if (known) return known;
|
|
65
|
+
const result = spawnSync("pnpm", ["--version"], { cwd: rootDir, encoding: "utf8", shell: process.platform === "win32", timeout: 1e4 });
|
|
66
|
+
return result.status === 0 ? /\d+\.\d+\.\d+/.exec(result.stdout)?.[0] : void 0;
|
|
67
|
+
}
|
|
68
|
+
function pnpmReadsPermissions(version) {
|
|
69
|
+
const [major = 0, minor = 0] = (version ?? "").split(".").map(Number);
|
|
70
|
+
return major > PERMISSIONS_SINCE.major || major === PERMISSIONS_SINCE.major && minor >= PERMISSIONS_SINCE.minor;
|
|
71
|
+
}
|
|
72
|
+
function pnpmWorkspaceFile(rootDir) {
|
|
73
|
+
for (let dir = rootDir; ; dir = dirname(dir)) {
|
|
74
|
+
const path = join(dir, PNPM_WORKSPACE);
|
|
75
|
+
const source = readTextIfPresent(path);
|
|
76
|
+
if (source !== void 0) return { path, source };
|
|
77
|
+
if (dir === dirname(dir)) return { path: join(rootDir, PNPM_WORKSPACE) };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function keyAt(line, indent) {
|
|
81
|
+
const rest = line.startsWith(indent) ? line.slice(indent.length) : "";
|
|
82
|
+
const colon = rest.search(/:(?:\s|$)/);
|
|
83
|
+
if (colon <= 0 || /^[\s#\-{[!&*?|>]/.test(rest)) return void 0;
|
|
84
|
+
return rest.slice(0, colon).trim().replace(/^(["'])(.*)\1$/, "$2");
|
|
85
|
+
}
|
|
86
|
+
const indentOf = (line) => /^ */.exec(line)[0];
|
|
87
|
+
const isContent = (line) => line.trim() !== "" && !line.trimStart().startsWith("#");
|
|
88
|
+
function blockAfter(lines, index, indent) {
|
|
89
|
+
const block = [];
|
|
90
|
+
for (let at = index + 1; at < lines.length; at++) {
|
|
91
|
+
const line = lines[at];
|
|
92
|
+
if (isContent(line) && indentOf(line).length <= indent.length) break;
|
|
93
|
+
block.push(at);
|
|
94
|
+
}
|
|
95
|
+
return block;
|
|
96
|
+
}
|
|
97
|
+
function isBlockMapping(lines) {
|
|
98
|
+
const content = lines.filter(isContent).filter((line) => !line.startsWith("%"));
|
|
99
|
+
if (/^---\s*(?:#.*)?$/.test(content[0] ?? "")) content.shift();
|
|
100
|
+
if (content.some((line) => /^(?:---|\.\.\.)(?:\s|$)/.test(line))) return false;
|
|
101
|
+
return content.length === 0 || keyAt(content[0], "") !== void 0;
|
|
102
|
+
}
|
|
103
|
+
const inlineValue = (line) => line.slice(line.indexOf(":") + 1).replace(/\s#.*$/, "").trim();
|
|
104
|
+
const entryLines = (indent, step) => [`${indent}${ENTRY_COMMENT}`, `${indent}${CORE_SKILL.name}:`, `${indent}${step}skills: false`];
|
|
105
|
+
function denyPnpmSkills(source) {
|
|
106
|
+
if (source === void 0) return { action: "created", content: ["permissions:", ...entryLines(" ", " "), ""].join("\n") };
|
|
107
|
+
const eol = source.includes("\r\n") ? "\r\n" : "\n";
|
|
108
|
+
const lines = source.split(/\r?\n/);
|
|
109
|
+
if (!isBlockMapping(lines)) return { action: "manual" };
|
|
110
|
+
const top = lines.findIndex((line) => keyAt(line, "") === "permissions");
|
|
111
|
+
if (top === -1) {
|
|
112
|
+
const end = lines.at(-1) === "" ? lines.length - 1 : lines.length;
|
|
113
|
+
lines.splice(end, 0, "permissions:", ...entryLines(" ", " "));
|
|
114
|
+
if (lines.at(-1) !== "") lines.push("");
|
|
115
|
+
return { action: "added", content: lines.join(eol) };
|
|
116
|
+
}
|
|
117
|
+
const action = denyUnderPermissions(lines, top);
|
|
118
|
+
return action === "added" ? { action, content: lines.join(eol) } : { action };
|
|
119
|
+
}
|
|
120
|
+
function blockKeys(lines, at, indent, fallback) {
|
|
121
|
+
const keys = blockAfter(lines, at, indent).filter((index) => isContent(lines[index]));
|
|
122
|
+
if (keys.length === 0) return { keys, indent: fallback };
|
|
123
|
+
const inner = indentOf(lines[keys[0]]);
|
|
124
|
+
return keyAt(lines[keys[0]], inner) === void 0 ? void 0 : { keys, indent: inner };
|
|
125
|
+
}
|
|
126
|
+
function denyUnderPermissions(lines, top) {
|
|
127
|
+
if (inlineValue(lines[top]) !== "") return "manual";
|
|
128
|
+
const packages = blockKeys(lines, top, "", " ");
|
|
129
|
+
if (!packages) return "manual";
|
|
130
|
+
const own = packages.keys.find((at) => keyAt(lines[at], packages.indent) === CORE_SKILL.name);
|
|
131
|
+
if (own === void 0) {
|
|
132
|
+
lines.splice(top + 1, 0, ...entryLines(packages.indent, packages.indent));
|
|
133
|
+
return "added";
|
|
134
|
+
}
|
|
135
|
+
const value = inlineValue(lines[own]);
|
|
136
|
+
if (value !== "") return /\bskills\s*:/.test(value) ? "unchanged" : "manual";
|
|
137
|
+
const settings = blockKeys(lines, own, packages.indent, packages.indent.repeat(2));
|
|
138
|
+
if (!settings) return "manual";
|
|
139
|
+
if (settings.keys.some((at) => keyAt(lines[at], settings.indent) === "skills")) return "unchanged";
|
|
140
|
+
lines.splice(own + 1, 0, `${settings.indent}skills: false`);
|
|
141
|
+
return "added";
|
|
142
|
+
}
|
|
143
|
+
function recordPnpmSkillsDenial(rootDir, { version = pnpmVersionIn } = {}) {
|
|
144
|
+
if (packageManagerOf(rootDir) !== "pnpm") return null;
|
|
145
|
+
if (!existsSync(join(rootDir, PROJECT_SKILLS, CORE_SKILL.name, "SKILL.md"))) return null;
|
|
146
|
+
if (!pnpmReadsPermissions(version(rootDir))) return null;
|
|
147
|
+
const { path, source } = pnpmWorkspaceFile(rootDir);
|
|
148
|
+
const { action, content } = denyPnpmSkills(source);
|
|
149
|
+
if (content !== void 0) writeFileSync(path, content, { flag: source === void 0 ? "wx" : "w" });
|
|
150
|
+
return { action, file: relative(rootDir, path).replace(/\\/g, "/") };
|
|
151
|
+
}
|
|
152
|
+
function pnpmWorkspaceMessage({ action, file }) {
|
|
153
|
+
const why = `its agent skills are in ${PROJECT_SKILLS} already, so pnpm links no second copy and stops listing it as awaiting approval`;
|
|
154
|
+
switch (action) {
|
|
155
|
+
case "created":
|
|
156
|
+
return `Created ${file} with skills: false for nuxt-backend under permissions: ${why}`;
|
|
157
|
+
case "added":
|
|
158
|
+
return `Added skills: false for nuxt-backend under permissions in ${file}: ${why}`;
|
|
159
|
+
case "manual":
|
|
160
|
+
return `${file} is written in a form init does not edit line by line (a flow mapping, or more than one document), so it was left alone. Run \`pnpm approve '!nuxt-backend'\`: the agent skills are in ${PROJECT_SKILLS} already`;
|
|
161
|
+
default:
|
|
162
|
+
return void 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const ENV_EXAMPLE = renderEnvExample();
|
|
167
|
+
function declareConvexDependency(rootDir) {
|
|
168
|
+
return declarePeer(rootDir, "convex", "dependencies");
|
|
169
|
+
}
|
|
170
|
+
function declareMcpSdkDependency(rootDir) {
|
|
171
|
+
return declarePeer(rootDir, MCP_SDK, "devDependencies");
|
|
172
|
+
}
|
|
173
|
+
function declarePeer(rootDir, name, field) {
|
|
174
|
+
const manifestPath = join(rootDir, "package.json");
|
|
175
|
+
let source;
|
|
176
|
+
let manifest;
|
|
177
|
+
try {
|
|
178
|
+
source = readFileSync(manifestPath, "utf-8");
|
|
179
|
+
manifest = JSON.parse(source);
|
|
180
|
+
} catch {
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
if (manifest.dependencies?.[name] || manifest.devDependencies?.[name]) return void 0;
|
|
184
|
+
let range;
|
|
185
|
+
try {
|
|
186
|
+
const installed = JSON.parse(readFileSync(createRequire(manifestPath).resolve(`${name}/package.json`), "utf-8"));
|
|
187
|
+
range = `^${installed.version}`;
|
|
188
|
+
} catch {
|
|
189
|
+
const own = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8"));
|
|
190
|
+
range = own.peerDependencies?.[name];
|
|
191
|
+
}
|
|
192
|
+
if (!range) return void 0;
|
|
193
|
+
const entries = Object.fromEntries(
|
|
194
|
+
Object.entries({ ...manifest[field], [name]: range }).sort(([a], [b]) => a.localeCompare(b))
|
|
195
|
+
);
|
|
196
|
+
const indent = /^(\s+)"/m.exec(source)?.[1] ?? " ";
|
|
197
|
+
const eol = source.endsWith("\n") ? "\n" : "";
|
|
198
|
+
writeFileSync(manifestPath, JSON.stringify({ ...manifest, [field]: entries }, null, indent) + eol);
|
|
199
|
+
return range;
|
|
200
|
+
}
|
|
201
|
+
function setUpProject(rootDir, { force = false, agents = true, print }) {
|
|
202
|
+
const created = scaffoldBackendFiles(rootDir, { force, log: print });
|
|
203
|
+
if (writeEnvExample(rootDir, force, print)) created.push(".env.example");
|
|
204
|
+
const appComponent = mountPagesInAppComponent(rootDir) ?? null;
|
|
205
|
+
if (appComponent) print(`[nuxt-backend] Replaced <NuxtWelcome /> with <NuxtLayout><NuxtPage /></NuxtLayout> in ${appComponent} so the module's pages render`);
|
|
206
|
+
const layout = ensureDefaultLayout(rootDir);
|
|
207
|
+
if (layout) {
|
|
208
|
+
created.push(layout);
|
|
209
|
+
print(`[nuxt-backend] Created ${layout}: <AppShell> around your pages, with the brand, the workspace switcher and the account menu`);
|
|
210
|
+
}
|
|
211
|
+
const indexPage = ensureIndexPage(rootDir);
|
|
212
|
+
if (indexPage) {
|
|
213
|
+
created.push(indexPage);
|
|
214
|
+
print(`[nuxt-backend] Created ${indexPage}: the home page, with the app's name and a link to sign in, since nothing answered at /`);
|
|
215
|
+
}
|
|
216
|
+
const agentFiles = agents ? setUpAgentFiles(rootDir, force, print) : null;
|
|
217
|
+
return { created, agentsMd: agentFiles?.agentsMd ?? null, mcpJson: agentFiles?.mcpJson ?? null, skills: agentFiles?.skills ?? null, pnpmWorkspace: agentFiles?.pnpmWorkspace ?? null, appComponent, ...adoptProjectFiles(rootDir, print), mcpSdkDependency: agentFiles?.mcpSdkDependency ?? null };
|
|
218
|
+
}
|
|
219
|
+
function writeEnvExample(rootDir, force, print) {
|
|
220
|
+
const envExamplePath = join(rootDir, ".env.example");
|
|
221
|
+
if (!force && existsSync(envExamplePath)) return false;
|
|
222
|
+
writeFileSync(envExamplePath, ENV_EXAMPLE);
|
|
223
|
+
print("[nuxt-backend] Created .env.example");
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
function setUpAgentFiles(rootDir, force, print) {
|
|
227
|
+
const agentFiles = writeAgentFiles(rootDir, { force, version: installedVersion(rootDir) });
|
|
228
|
+
for (const message of agentFiles.messages) print(`[nuxt-backend] ${message}`);
|
|
229
|
+
const mcpSdkDependency = declareMcpSdkDependency(rootDir) ?? null;
|
|
230
|
+
if (mcpSdkDependency) print(`[nuxt-backend] Added ${MCP_SDK}@${mcpSdkDependency} to devDependencies (the nuxt-backend server in .mcp.json runs on it)`);
|
|
231
|
+
const pnpmWorkspace = recordPnpmSkillsDenial(rootDir);
|
|
232
|
+
const pnpmMessage = pnpmWorkspace && pnpmWorkspaceMessage(pnpmWorkspace);
|
|
233
|
+
if (pnpmMessage) print(`[nuxt-backend] ${pnpmMessage}`);
|
|
234
|
+
return { ...agentFiles, mcpSdkDependency, pnpmWorkspace: pnpmWorkspace?.action ?? null };
|
|
235
|
+
}
|
|
236
|
+
function adoptProjectFiles(rootDir, print) {
|
|
237
|
+
const devScript = adoptBackendDevScript(rootDir);
|
|
238
|
+
if (devScript?.changed) {
|
|
239
|
+
print(`[nuxt-backend] Set scripts.dev to \`${devScript.script}\`: one command sets up the deployment, provisions its env and runs Convex beside Nuxt`);
|
|
240
|
+
}
|
|
241
|
+
const convexDependency = declareConvexDependency(rootDir) ?? null;
|
|
242
|
+
if (convexDependency) {
|
|
243
|
+
print(`[nuxt-backend] Added convex@${convexDependency} to dependencies (\`npx convex dev\` needs the app itself to declare it)`);
|
|
244
|
+
}
|
|
245
|
+
const packageManager = packageManagerOf(rootDir);
|
|
246
|
+
return {
|
|
247
|
+
devScript: devScript?.changed ? devScript.script : null,
|
|
248
|
+
convexDependency,
|
|
249
|
+
packageManager,
|
|
250
|
+
start: devScript ? runScript(packageManager, "dev") : execBinary(packageManager, "nuxt-backend dev")
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function addedDependencies(setup) {
|
|
254
|
+
return Boolean(setup.convexDependency || setup.mcpSdkDependency);
|
|
255
|
+
}
|
|
256
|
+
function installCommand(packageManager) {
|
|
257
|
+
return `${packageManager} install`;
|
|
258
|
+
}
|
|
259
|
+
function nextCommands(setup, { installed = false } = {}) {
|
|
260
|
+
return [...addedDependencies(setup) && !installed ? [installCommand(setup.packageManager)] : [], setup.start];
|
|
261
|
+
}
|
|
262
|
+
function formatNextSteps(setup, { installed = false } = {}) {
|
|
263
|
+
const comment = (command, text) => ` ${command.padEnd(27)}# ${text}`;
|
|
264
|
+
const added = setup.convexDependency && setup.mcpSdkDependency ? "convex and the MCP SDK, added above" : setup.convexDependency ? "the convex dependency added above" : "the MCP SDK added above";
|
|
265
|
+
const install = addedDependencies(setup) && !installed ? [comment(installCommand(setup.packageManager), `links ${added}`)] : [];
|
|
266
|
+
return [
|
|
267
|
+
"Next steps:",
|
|
268
|
+
...install,
|
|
269
|
+
comment(setup.start, "the first run sets up your Convex dev deployment (log in"),
|
|
270
|
+
comment("", "when asked) and provisions its env, then runs Convex and Nuxt"),
|
|
271
|
+
" Sign in at /login: in development, the sign-in code prints in the same terminal."
|
|
272
|
+
].join("\n");
|
|
273
|
+
}
|
|
274
|
+
function installDeclaredDependencies(rootDir, packageManager) {
|
|
275
|
+
const options = { cwd: rootDir, shell: process.platform === "win32", stdio: "inherit" };
|
|
276
|
+
switch (packageManager) {
|
|
277
|
+
case "npm":
|
|
278
|
+
return spawnSync("npm", ["install"], options).status === 0;
|
|
279
|
+
case "pnpm":
|
|
280
|
+
return spawnSync("pnpm", ["install"], options).status === 0;
|
|
281
|
+
case "yarn":
|
|
282
|
+
return spawnSync("yarn", ["install"], options).status === 0;
|
|
283
|
+
case "bun":
|
|
284
|
+
return spawnSync("bun", ["install"], options).status === 0;
|
|
285
|
+
default:
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export { setUpAgentFiles as a, addedDependencies as b, installDeclaredDependencies as c, execBinary as e, formatNextSteps as f, installCommand as i, nextCommands as n, packageManagerOf as p, runScript as r, setUpProject as s };
|
|
@@ -897,7 +897,7 @@ const TASK_SKILLS = [
|
|
|
897
897
|
covers: "the catalog, plans, checkout, the portal, feature gates, plan quotas and credits",
|
|
898
898
|
docs: ["/docs/build/billing"],
|
|
899
899
|
entrypoints: ["nuxt-backend/billing"],
|
|
900
|
-
composables: ["useBilling", "useFeatures", "useCredits", "usePricing", "useOrders", "useUsage", "useWithdrawal", "formatBillingAmount"],
|
|
900
|
+
composables: ["useBilling", "useFeatures", "useCredits", "usePricing", "usePlanChange", "useBillingSection", "useOrders", "useUsage", "useWithdrawal", "formatBillingAmount"],
|
|
901
901
|
components: ["PricingTable", "BillingCheckoutLink", "BillingPortalLink", "BillingHistory", "UsageHistory", "UpgradePrompt", "CancelFlow", "WithdrawalButton"],
|
|
902
902
|
commands: ["billing sync", "billing reset", "billing resync"],
|
|
903
903
|
findings: ["billing"],
|
|
@@ -2253,7 +2253,7 @@ function parsePathsFile(text) {
|
|
|
2253
2253
|
var __freeze = Object.freeze;
|
|
2254
2254
|
var __defProp = Object.defineProperty;
|
|
2255
2255
|
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
2256
|
-
var _a;
|
|
2256
|
+
var _a, _b;
|
|
2257
2257
|
const AUTH_CONFIG_TEMPLATE = dedent`
|
|
2258
2258
|
import { defineBackendAuthConfig } from 'nuxt-backend/auth.config'
|
|
2259
2259
|
import { paths } from './paths.generated'
|
|
@@ -2832,6 +2832,63 @@ const BACKEND_FILE_TEMPLATES = {
|
|
|
2832
2832
|
[LABELS_FILE]: renderLabelsFile({})
|
|
2833
2833
|
};
|
|
2834
2834
|
const DEFAULT_LAYOUT_TEMPLATE = dedent(_a || (_a = __template(['\n <script setup lang="ts">\n // The frame of the app: the header with your brand, the workspace switcher,\n // the notification bell and the account menu, then the app-wide notices and\n // your page. Put your links in the `nav` slot, and your buttons before the\n // account menu in `actions`. `<AppShell :switcher="false">` hides the\n // switcher for an app whose people never share a workspace.\n const { brand } = useBackendConfig()\n <\/script>\n\n <template>\n <AppShell>\n <template #brand>\n <NuxtLink to="/">\n {{ brand.name || \'Your app\' }}\n </NuxtLink>\n </template>\n <slot />\n </AppShell>\n </template>\n '], ['\n <script setup lang="ts">\n // The frame of the app: the header with your brand, the workspace switcher,\n // the notification bell and the account menu, then the app-wide notices and\n // your page. Put your links in the \\`nav\\` slot, and your buttons before the\n // account menu in \\`actions\\`. \\`<AppShell :switcher="false">\\` hides the\n // switcher for an app whose people never share a workspace.\n const { brand } = useBackendConfig()\n <\/script>\n\n <template>\n <AppShell>\n <template #brand>\n <NuxtLink to="/">\n {{ brand.name || \'Your app\' }}\n </NuxtLink>\n </template>\n <slot />\n </AppShell>\n </template>\n ']))) + "\n";
|
|
2835
|
+
const DEFAULT_INDEX_PAGE_TEMPLATE = dedent(_b || (_b = __template([`
|
|
2836
|
+
<script setup lang="ts">
|
|
2837
|
+
// The app's home page, which \`npx nuxt-backend init\` wrote because nothing
|
|
2838
|
+
// answered at /: make it yours. It names the app, and links to the sign-in
|
|
2839
|
+
// page, or to the account once signed in.
|
|
2840
|
+
const { brand } = useBackendConfig()
|
|
2841
|
+
const { isSignedIn } = useAuth()
|
|
2842
|
+
const login = useBackendPagePath('login')
|
|
2843
|
+
const profile = useBackendPagePath('profile')
|
|
2844
|
+
<\/script>
|
|
2845
|
+
|
|
2846
|
+
<template>
|
|
2847
|
+
<div>
|
|
2848
|
+
<h1>{{ brand.name || 'Your app' }}</h1>
|
|
2849
|
+
<NuxtLink
|
|
2850
|
+
v-if="isSignedIn && profile"
|
|
2851
|
+
:to="profile"
|
|
2852
|
+
>
|
|
2853
|
+
Your account
|
|
2854
|
+
</NuxtLink>
|
|
2855
|
+
<NuxtLink
|
|
2856
|
+
v-else-if="!isSignedIn && login"
|
|
2857
|
+
:to="login"
|
|
2858
|
+
>
|
|
2859
|
+
Sign in
|
|
2860
|
+
</NuxtLink>
|
|
2861
|
+
</div>
|
|
2862
|
+
</template>
|
|
2863
|
+
`], [`
|
|
2864
|
+
<script setup lang="ts">
|
|
2865
|
+
// The app's home page, which \\\`npx nuxt-backend init\\\` wrote because nothing
|
|
2866
|
+
// answered at /: make it yours. It names the app, and links to the sign-in
|
|
2867
|
+
// page, or to the account once signed in.
|
|
2868
|
+
const { brand } = useBackendConfig()
|
|
2869
|
+
const { isSignedIn } = useAuth()
|
|
2870
|
+
const login = useBackendPagePath('login')
|
|
2871
|
+
const profile = useBackendPagePath('profile')
|
|
2872
|
+
<\/script>
|
|
2873
|
+
|
|
2874
|
+
<template>
|
|
2875
|
+
<div>
|
|
2876
|
+
<h1>{{ brand.name || 'Your app' }}</h1>
|
|
2877
|
+
<NuxtLink
|
|
2878
|
+
v-if="isSignedIn && profile"
|
|
2879
|
+
:to="profile"
|
|
2880
|
+
>
|
|
2881
|
+
Your account
|
|
2882
|
+
</NuxtLink>
|
|
2883
|
+
<NuxtLink
|
|
2884
|
+
v-else-if="!isSignedIn && login"
|
|
2885
|
+
:to="login"
|
|
2886
|
+
>
|
|
2887
|
+
Sign in
|
|
2888
|
+
</NuxtLink>
|
|
2889
|
+
</div>
|
|
2890
|
+
</template>
|
|
2891
|
+
`]))) + "\n";
|
|
2835
2892
|
|
|
2836
2893
|
const DEFAULT_FUNCTIONS_DIR = "backend";
|
|
2837
2894
|
const STANDARD_FUNCTIONS_DIR = "convex";
|
|
@@ -2905,8 +2962,71 @@ function normalizeFunctionsDir(functionsDir) {
|
|
|
2905
2962
|
const normalized = functionsDir.replace(/^\.?\//, "").replace(/\/+$/, "");
|
|
2906
2963
|
return normalized || void 0;
|
|
2907
2964
|
}
|
|
2965
|
+
const NUXT_CONFIG_FILES = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs", "nuxt.config.mts"];
|
|
2966
|
+
const withoutComments = (code) => code.replace(/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1|\/\/[^\n]*|\/\*[\s\S]*?\*\//g, (match) => match.startsWith("/") ? " " : match);
|
|
2967
|
+
function closingQuote(code, open) {
|
|
2968
|
+
let at = open + 1;
|
|
2969
|
+
while (at < code.length && code[at] !== code[open]) at += code[at] === "\\" ? 2 : 1;
|
|
2970
|
+
return at;
|
|
2971
|
+
}
|
|
2972
|
+
function objectProperties(code, open) {
|
|
2973
|
+
const properties = /* @__PURE__ */ new Map();
|
|
2974
|
+
const add = (entry) => {
|
|
2975
|
+
if (entry.trim().startsWith("...")) properties.set("...", entry.trim());
|
|
2976
|
+
const match = /^(?:(["'])([^"']+)\1|([\w$]+))\s*:([\s\S]*)$/.exec(entry.trim());
|
|
2977
|
+
if (match) properties.set(match[2] ?? match[3], match[4].trim());
|
|
2978
|
+
};
|
|
2979
|
+
let depth = 0;
|
|
2980
|
+
let start = open + 1;
|
|
2981
|
+
for (let at = open; at < code.length; at++) {
|
|
2982
|
+
const char = code[at];
|
|
2983
|
+
if ("\"'`".includes(char)) {
|
|
2984
|
+
at = closingQuote(code, at);
|
|
2985
|
+
} else if ("{[(".includes(char)) {
|
|
2986
|
+
depth++;
|
|
2987
|
+
} else if ("}])".includes(char) && --depth === 0) {
|
|
2988
|
+
add(code.slice(start, at));
|
|
2989
|
+
break;
|
|
2990
|
+
} else if (char === "," && depth === 1) {
|
|
2991
|
+
add(code.slice(start, at));
|
|
2992
|
+
start = at + 1;
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
return properties;
|
|
2996
|
+
}
|
|
2997
|
+
const stringValue = (value) => /^(["'`])([^"'`$\\]+)\1$/.exec(value ?? "")?.[2];
|
|
2998
|
+
function readSourceConfig(dir) {
|
|
2999
|
+
const source = NUXT_CONFIG_FILES.map((name) => readTextIfPresent(join(dir, name))).find((text) => text !== void 0) ?? "";
|
|
3000
|
+
const code = withoutComments(source);
|
|
3001
|
+
const open = /\bdefineNuxtConfig\s*\(\s*\{|\bexport\s+default\s*\{/.exec(code);
|
|
3002
|
+
const config = open ? objectProperties(code, open.index + open[0].length - 1) : /* @__PURE__ */ new Map();
|
|
3003
|
+
const folders = config.get("dir");
|
|
3004
|
+
const unread = code.trim() !== "" && (!open || config.has("..."));
|
|
3005
|
+
return {
|
|
3006
|
+
srcDir: stringValue(config.get("srcDir")),
|
|
3007
|
+
pages: folders?.startsWith("{") ? stringValue(objectProperties(folders, 0).get("pages")) : void 0,
|
|
3008
|
+
extendsLayer: unread || config.has("extends")
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3011
|
+
function sourceDir(dir, config = readSourceConfig(dir)) {
|
|
3012
|
+
if (config.srcDir) return resolve(dir, config.srcDir);
|
|
3013
|
+
const app = join(dir, "app");
|
|
3014
|
+
let files;
|
|
3015
|
+
try {
|
|
3016
|
+
files = readdirSync(app);
|
|
3017
|
+
} catch {
|
|
3018
|
+
return dir;
|
|
3019
|
+
}
|
|
3020
|
+
if (files.some((file) => file !== "spa-loading-template.html" && !file.startsWith("router.options"))) return app;
|
|
3021
|
+
const legacy = ["app.vue", "App.vue", "assets", "layouts", "middleware", config.pages ?? "pages", "plugins"];
|
|
3022
|
+
return legacy.some((name) => existsSync(resolve(dir, name))) ? dir : app;
|
|
3023
|
+
}
|
|
3024
|
+
function pagesDir(dir, config = readSourceConfig(dir)) {
|
|
3025
|
+
return resolve(sourceDir(dir, config), config.pages ?? "pages");
|
|
3026
|
+
}
|
|
2908
3027
|
function resolveAppComponent(rootDir) {
|
|
2909
|
-
|
|
3028
|
+
const folder = sourceDir(rootDir);
|
|
3029
|
+
return ["app.vue", "App.vue"].map((file) => join(folder, file)).filter(existsSync).map((path) => ({ name: relative(rootDir, path).replace(/\\/g, "/"), path }))[0];
|
|
2910
3030
|
}
|
|
2911
3031
|
function appComponentIsStarter(rootDir) {
|
|
2912
3032
|
const component = resolveAppComponent(rootDir);
|
|
@@ -2934,6 +3054,45 @@ function ensureDefaultLayout(rootDir) {
|
|
|
2934
3054
|
writeFileSync(join(folder, "default.vue"), DEFAULT_LAYOUT_TEMPLATE);
|
|
2935
3055
|
return join(dirname(component.name), "layouts/default.vue").replace(/\\/g, "/").replace(/^\.\//, "");
|
|
2936
3056
|
}
|
|
3057
|
+
const ROOT_PAGE_FILE = /^(?:index|\[\[[^\]]+\]\]|\[\.\.\.[^\]]+\])(?:\.(?:client|server))?\.(?:vue|[cm]?[jt]sx?)$/;
|
|
3058
|
+
const ROOT_PAGE_FOLDER = /^(?:index|\(.+\)|\[\[[^\]]+\]\]|\[\.\.\.[^\]]+\])$/;
|
|
3059
|
+
const PAGE_FILE = /\.(?:vue|[cm]?[jt]sx?)$/;
|
|
3060
|
+
const withoutStrings = (code) => code.replace(/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*\1/g, (match) => `${match[0]}${" ".repeat(match.length - 2)}${match[0]}`);
|
|
3061
|
+
function declaresRootPath(path) {
|
|
3062
|
+
const source = readTextIfPresent(path) ?? "";
|
|
3063
|
+
const script = path.endsWith(".vue") ? [...source.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\b[^>]*>/gi)].map((match) => match[1]).join("\n") : source;
|
|
3064
|
+
const code = withoutComments(script);
|
|
3065
|
+
const call = /\bdefinePageMeta\s*\(\s*\{/.exec(withoutStrings(code));
|
|
3066
|
+
return call !== null && stringValue(objectProperties(code, call.index + call[0].length - 1).get("path")) === "/";
|
|
3067
|
+
}
|
|
3068
|
+
function pagesServeRoot(dir, atRoot = true) {
|
|
3069
|
+
let entries;
|
|
3070
|
+
try {
|
|
3071
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
3072
|
+
} catch {
|
|
3073
|
+
return false;
|
|
3074
|
+
}
|
|
3075
|
+
return entries.some((entry) => {
|
|
3076
|
+
const path = join(dir, entry.name);
|
|
3077
|
+
if (entry.isDirectory()) return pagesServeRoot(path, atRoot && ROOT_PAGE_FOLDER.test(entry.name));
|
|
3078
|
+
return atRoot && ROOT_PAGE_FILE.test(entry.name) || PAGE_FILE.test(entry.name) && declaresRootPath(path);
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
function localLayerPages(rootDir) {
|
|
3082
|
+
const layers = join(rootDir, "layers");
|
|
3083
|
+
if (!existsSync(layers)) return [];
|
|
3084
|
+
return readdirSync(layers, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => pagesDir(join(layers, entry.name)));
|
|
3085
|
+
}
|
|
3086
|
+
function ensureIndexPage(rootDir) {
|
|
3087
|
+
const component = resolveAppComponent(rootDir);
|
|
3088
|
+
if (!component || !readFileSync(component.path, "utf-8").includes("<NuxtPage")) return void 0;
|
|
3089
|
+
const config = readSourceConfig(rootDir);
|
|
3090
|
+
if (config.extendsLayer) return void 0;
|
|
3091
|
+
const pages = pagesDir(rootDir, config);
|
|
3092
|
+
if ([pages, ...localLayerPages(rootDir)].some((folder) => pagesServeRoot(folder))) return void 0;
|
|
3093
|
+
const page = join(pages, "index.vue");
|
|
3094
|
+
return writeUnlessPresent(page, DEFAULT_INDEX_PAGE_TEMPLATE) ? relative(rootDir, page).replace(/\\/g, "/") : void 0;
|
|
3095
|
+
}
|
|
2937
3096
|
|
|
2938
3097
|
const STRINGS_AND_COMMENTS = /(['"`])(?:\\[\s\S]|(?!\1)[^\\])*\1|\/\*[\s\S]*?\*\/|\/\/[^\n]*/g;
|
|
2939
3098
|
function sourceFiles(dir) {
|
|
@@ -4122,4 +4281,4 @@ const UI_SHARED_STYLES = [
|
|
|
4122
4281
|
{ file: "admin/admin.css", capability: "auth" }
|
|
4123
4282
|
];
|
|
4124
4283
|
|
|
4125
|
-
export { runEnvPush as $, syncBrandFile as A, BACKEND_ENV_NAMES as B, CAPABILITY_STATES as C, DERIVED_DEPLOYMENT_ENV as D, brandFileLocation as E, appLabelsOf as F, syncLabelsFile as G, labelsFileLocation as H, isDevDeploymentId as I, computeDeployment as J, appMonitoringDsn as K, monitoringSdkInstalled as L, MCP_SDK as M, detectCapabilities as N, DEPLOYMENT_KIND_LABEL as O, CAPABILITY_NAMES as P, REGISTERED_UI as Q, RESYNC_ENTITLEMENTS_FUNCTION as R, uiPath as S, BACKEND_PAGE_DEFS as T, installedVersion as U, packageDir as V, uiEntry as W, agentsMdVersion as X, packageVersion as Y, doctorReport as Z, formatPreflightSummary as _, deploymentEnvNames as a,
|
|
4284
|
+
export { runEnvPush as $, syncBrandFile as A, BACKEND_ENV_NAMES as B, CAPABILITY_STATES as C, DERIVED_DEPLOYMENT_ENV as D, brandFileLocation as E, appLabelsOf as F, syncLabelsFile as G, labelsFileLocation as H, isDevDeploymentId as I, computeDeployment as J, appMonitoringDsn as K, monitoringSdkInstalled as L, MCP_SDK as M, detectCapabilities as N, DEPLOYMENT_KIND_LABEL as O, CAPABILITY_NAMES as P, REGISTERED_UI as Q, RESYNC_ENTITLEMENTS_FUNCTION as R, uiPath as S, BACKEND_PAGE_DEFS as T, installedVersion as U, packageDir as V, uiEntry as W, agentsMdVersion as X, packageVersion as Y, doctorReport as Z, formatPreflightSummary as _, deploymentEnvNames as a, envNames as a$, devPushRefusal as a0, pagePathShape as a1, collectPreflightFindings as a2, OPTIONAL_DEPLOYMENT_ENV as a3, REQUIRED_DEPLOYMENT_ENV as a4, deriveDeploymentUrls as a5, provisionedEnvNames as a6, appComponentIsStarter as a7, resolveSiteUrl as a8, needsSetup as a9, maskableIcons as aA, MANIFEST_ROUTE as aB, APPLE_TOUCH_ICON as aC, themeColorMeta as aD, UI_SHARED_STYLES as aE, UI_ENTRIES as aF, UI_INTERNALS as aG, moduleDir as aH, VISITOR_IP_ROUTE as aI, resolvePagePath as aJ, dependencyRange as aK, runsFromSource as aL, resolveConvexCli as aM, RECENT_SIGN_IN_SECONDS as aN, BACKEND_ENV as aO, capabilityOfEnv as aP, REMOVED_DEPLOYMENT_ENV as aQ, PROJECT_SKILLS as aR, CORE_SKILL as aS, mountPagesInAppComponent as aT, ensureDefaultLayout as aU, ensureIndexPage as aV, writeAgentFiles as aW, isDevDeployment as aX, RPC_NAMESPACE as aY, DEVTOOLS_UI_ROUTE as aZ, DEVTOOLS_UI_LOCAL_PORT as a_, AGENT_HINT as aa, HEALTH_ROUTE as ab, LOCAL_LOG_ROUTE as ac, monitoringSdkVersion as ad, MONITORING_SDK as ae, TUNNEL_SDK_VERSION as af, SOURCE_MAP_ENV as ag, sdkServesTunnel as ah, installableProblems as ai, pagesOptionProblems as aj, resolvedBackendPages as ak, DEFAULT_AUTH_ROUTE as al, publishedBackendPages as am, isPageOff as an, privatePagePaths as ao, collectExistingPagePaths as ap, adoptChildPages as aq, pageRouteRules as ar, cachingRulesOver as as, PUSH_WORKER_URL as at, ownsManifest as au, MANIFEST_MODULES as av, namedIconWarnings as aw, installableGaps as ax, installIcons as ay, webAppManifest as az, deploymentBackendEnvironment as b, DEV_ONLY_DEPLOYMENT_ENV as b0, DEV_SITE_URL as b1, finding as b2, parseBackendEnvironment as b3, proofKeys as b4, TEST_CHALLENGE_SITE_KEYS as b5, deploymentEnvId as b6, protectionTakes as b7, TEST_CHALLENGE_SECRET_KEYS as b8, PROTECTED_AUTH_ROUTES as b9, namesModerationModel as bA, GATEWAY_ORDER_UNREAD as bB, routeKeyFor as bC, installableFinding as bD, gatewayKeyIsTheFix as bE, DEFAULT_MODERATION_MODEL as bF, mountsComponent as bG, GATEWAY_KEY_FIX as bH, CAPABILITIES as bI, isEnvProvisioned as bJ, markEnvProvisioned as bK, readSource as bL, parse as bM, keyOf$1 as bN, writeSource as bO, REMOVED_ENV as bP, applyEdits as bQ, walk as bR, BACKEND_FILE_TEMPLATES as bS, PROOF_HEADER as ba, signProof as bb, proofAudience as bc, deploymentSiteOrigin as bd, isLocalDeploymentId as be, capabilityOfGroup as bf, agentFilesFinding as bg, chosenRoutes as bh, chosenGateways as bi, pinnedRegion as bj, namedModels as bk, usesProvenance as bl, moderationProviders as bm, monitoringDsnFinding as bn, monitoringFindings as bo, usageAlertsFinding as bp, readUsageLimits as bq, applyProductionPosture as br, billingWebhookSecretHint as bs, BACKEND_PATH_KEYS as bt, pathOption as bu, aiFeatures as bv, pathsFileFinding as bw, brandFileFinding as bx, labelsFileFinding as by, checksImages as bz, billingEnvironment as c, deploymentFunctionSpec as d, deployKeyType as e, runConvex as f, deploymentFlags as g, ConvexCliError as h, isHttpUrl as i, resolveFunctionsDir as j, readTextIfPresent as k, executeEnvPush as l, generateAuthSecret as m, nonProductionDeployKey as n, setDeploymentEnv as o, isLoopbackUrl as p, configuredDeployment as q, readEnvFiles as r, siteFromCloudUrl as s, spawnConvex as t, scaffoldBackendFiles as u, pathsSourceOf as v, syncPathsFile as w, backendPathsOf as x, pathsFileLocation as y, appBrandOf as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import {
|
|
4
|
+
import { b2 as finding, j as resolveFunctionsDir, bL as readSource, bM as parse, bN as keyOf, bO as writeSource, bP as REMOVED_ENV, bQ as applyEdits, bR as walk, bS as BACKEND_FILE_TEMPLATES } from './nuxt-backend.suXOnqOQ.mjs';
|
|
5
5
|
|
|
6
6
|
const LAST_SCAFFOLD_MOUNT = "@convex-dev/workpool/convex.config";
|
|
7
7
|
const OPTIONAL_MOUNTS = [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "nuxt-backend",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"description": "The complete backend for a Nuxt app on Convex: passwordless sign-in with passkeys, workspaces, plans and credits, email, notifications and metered AI, with the pages that use them, in one module.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"fflate": "^0.8.3",
|
|
192
192
|
"magicast": "^0.5.4",
|
|
193
193
|
"nanostores": "^1.5.5",
|
|
194
|
-
"nuxt-convex-module": "^0.14.
|
|
194
|
+
"nuxt-convex-module": "^0.14.3",
|
|
195
195
|
"nuxt-security": "^2.7.0",
|
|
196
196
|
"resend": "^6.35.0",
|
|
197
197
|
"standardwebhooks": "^1.1.1",
|
|
@@ -23,6 +23,8 @@ skill's own `references/api.md` has the part it covers. The docs: https://nuxt-b
|
|
|
23
23
|
| `useFeatures()` | Reactive feature-gating for the current user — the SaaS access primitive. |
|
|
24
24
|
| `useCredits()` | Reactive prepaid-credit balance for the current user, plus a `topUp()` checkout and a `refresh()` re-sync. |
|
|
25
25
|
| `usePricing()` | The app's plans and credit packs as a pricing page shows them — every plan with its monthly and yearly price, what a year saves, its trial and the credits it grants per cycle; every pack with its price per credit and which is the best value — read through the scaffolded `getPricing`, in the visitor's currency where the catalog prices it. |
|
|
26
|
+
| `usePlanChange()` | A subscriber's switch to another plan or billing period, without its markup: the prices it can move to, in the subscription's own currency, and one confirmation that says what the switch does before it does it — the price, when it happens (a yearly price left for a monthly one waits for the paid year's end) and how the period's difference is settled, or, in a trial, what becomes of it — then the switch itself, settling that difference at once (`proration: 'invoice'`), so the words stay true whatever the organization's default. |
|
|
27
|
+
| `useBillingSection()` | The billing section of `/settings` without its markup: the state the plan is in, in the order the section tries them (a gifted plan, a failed payment, a pause, a cancellation or a plan change set for the period's end, a trial, else active), a read that failed as a failure rather than a plan, a return from checkout still finishing as busy, and what each state calls for, with the rules each offer follows: a switch only while nothing is scheduled, a pause only while none is, and its resume date counted the way the provider counts months. |
|
|
26
28
|
| `useCampaign()` | The campaign a visitor arrived with, read from the address: a campaign link's discount code and its UTM attribution, ready for checkout. |
|
|
27
29
|
| `useOrders()` | The signed-in customer's billing history — past charges straight from the provider's orders API, plus the per-order invoice link. |
|
|
28
30
|
| `useUsage()` | Consumption history for a credit meter, read from the provider's events API — the events your server ingested when it spent credits. |
|
|
@@ -465,7 +467,7 @@ Scaffold the backend files, .env.example, and nuxt.config wiring (re-run to rest
|
|
|
465
467
|
- `--no-agents`: Coding-agent files: --agents rewrites only AGENTS.md's nuxt-backend section, .mcp.json and the agent skills in .agents/skills for the installed version, and adds the MCP SDK to devDependencies when missing; --no-agents skips them all
|
|
466
468
|
- `--json`: Machine-readable output
|
|
467
469
|
|
|
468
|
-
`--json`: `{ created, agentsMd, mcpJson, skills, appComponent, devScript, convexDependency, mcpSdkDependency, nuxtConfig, next }`, or `{ agentsMd, mcpJson, skills, mcpSdkDependency }` with `--agents`, where `skills` is `{ installed, refreshed, removed, stale }`, each a list of skill names; progress goes to stderr.
|
|
470
|
+
`--json`: `{ created, agentsMd, mcpJson, skills, pnpmWorkspace, appComponent, devScript, convexDependency, mcpSdkDependency, nuxtConfig, next }`, or `{ agentsMd, mcpJson, skills, mcpSdkDependency, pnpmWorkspace }` with `--agents`, where `skills` is `{ installed, refreshed, removed, stale }`, each a list of skill names, and `pnpmWorkspace` is `created`, `added`, `unchanged`, `manual` or null; progress goes to stderr.
|
|
469
471
|
|
|
470
472
|
### `npx nuxt-backend dev`
|
|
471
473
|
|