@velastack/patterns 0.13.2 → 0.13.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CZKIKP3B.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","getLogger","modifyOutcomeToFile","probeFirstExisting","VITE_CONFIG_CANDIDATES","withInMemoryScript","ensureNamedImport","formatLikeSource","ensureImports","modifyLayoutServerLocale","ensureRootLayoutI18n","modifyPrettierignore","modifyAppDts","modifyPackageImportsI18n","dedent","addHandle","SvelteFile","APP_LAYOUT_PATH","modifyAppLayoutLanguageSelect","withTranslations","translateCatalog","entriesInProject","AUTH_TRANSLATIONS","withWuchaleJsFiles","TRANSLATED_LIB_FILES","fs","path","FAILURE_HINT$4","NOT_FOUND_HINT$3","modifyViteConfig","viteConfigPath","sourceFile","Project","QuoteKind","changed","failed","d","configArg","SyntaxKind","ce","configObj","pluginsProp","pluginsInit","arr","el","I18N_HANDLE","HANDLE_BODY","types","indent","text","line","IMPORTS","STARTUP","UNTYPED_HANDLE","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","ensureNamespaceImport","moduleSpecifier","ns","modifyHooksServerI18n","hooksServerPath","original","composed","handleStmt","DELOCALIZE_HELPER","HOOKS_SNIPPET","FAILURE_HINT$2","NEGOTIATE_ONLY_REROUTE","hasOtherReroute","n","ensureDeLocalizeImports","modifyHooksI18n","hooksPath","rerouteDecl","init","target","s","FAILURE_HINT$1","NOT_FOUND_HINT$2","modifyAppHtml","appHtmlPath","updated","match","NOT_FOUND_HINT$1","modifyGitignore","gitignorePath","block","LANGUAGE_SELECT_SNIPPET","PLAIN_LANGUAGE_SELECT_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","PLAIN_FAILURE_HINT","PLAIN_NOT_FOUND_HINT","addImport","out","source","sf","modifyRootLayoutLanguageSelect","plain","ui","layoutPath","file","PAGE_PATH","CATALOG_PATH","WELCOME_PAGE","PAGE_ENTRIES","PLAIN_SELECT_ENTRY","HEADER","normalize","welcomePageCatalog","root","pagePath","entry","withLibraryTexts","present","creates","edited","generate","logger","options","modifies","pushResult","imports","appDtsPath","layoutServerPath","rootLayoutCandidates","resolveUi","rootLayoutPath","p","appLayoutPath","prettierignorePath","catalog","shipped","content","translated"],"sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/hooks.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/enable/i18n/welcome-catalog.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the wuchale plugin to your Vite config:\",\n \"\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the wuchale plugin:\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale()],\",\n \"});\",\n].join(\"\\n\");\n\nexport function modifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as import(\"ts-morph\").ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: \"[wuchale()]\",\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\n\n/**\n * The handle's body: which language the request is in (the URL on a public\n * page, the visitor's preference elsewhere: see `src/lib/locale.ts`), and the\n * cookie that remembers the last public page opened.\n */\nconst HANDLE_BODY = (types: { locale: string; html: string }) => dedent`\n const urlLocale = deLocalizeDefault(event.url.pathname, locales)[1] as Locale | null;\n const localizedUrl = hasLocalizedUrl(event.url.pathname);\n const cookie${types.locale} = event.cookies.get(LOCALE_COOKIE);\n const locale = pickLocale({\n urlLocale,\n localizedUrl,\n cookie,\n acceptLanguage: event.request.headers.get('accept-language'),\n locales,\n defaultLocale\n });\n event.locals.locale = locale;\n\n const response${types.html ? \": Response\" : \"\"} = await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }${types.html}) => html.replace('%sveltekit.lang%', locale)\n })\n );\n\n // Opening a public page sets the language of the pages that have no\n // language in their URL. Only when the page itself is opened: a preload\n // (hovering a link) must not change it.\n if (localizedUrl && cookie !== locale && event.request.method === 'GET' && !event.isDataRequest) {\n try {\n response.headers.append('set-cookie', localeCookie(locale));\n } catch {\n // a response with immutable headers (a proxied file): nothing to remember\n }\n }\n return response;\n`;\n\nconst indent = (text: string) =>\n text\n .split(\"\\n\")\n .map((line) => (line ? ` ${line}` : line))\n .join(\"\\n\");\n\nconst IMPORTS = dedent`\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { deLocalizeDefault } from 'wuchale/url';\n import { locales, type Locale } from '#locales/data.js';\n import { defaultLocale, hasLocalizedUrl } from '#lib/url.js';\n import { LOCALE_COOKIE, localeCookie, pickLocale } from '#lib/locale.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n`;\n\nconst STARTUP = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n`;\n\n/** The handle as it is added to a file whose own handle is typed loosely. */\nconst UNTYPED_HANDLE = [\n `const ${I18N_HANDLE} = async ({ event, resolve }: any) => {`,\n indent(\n HANDLE_BODY({ locale: \": string | undefined\", html: \": { html: string }\" }),\n ),\n \"};\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Wrap your exported handle with the wuchale i18n handler:\",\n \"\",\n \"import { sequence } from '@sveltejs/kit/hooks';\",\n IMPORTS,\n \"\",\n STARTUP,\n \"\",\n UNTYPED_HANDLE,\n \"\",\n \"export const handle = sequence(handleWuchale, /* your existing handle */);\",\n].join(\"\\n\");\n\n/**\n * The whole file, for a project that had no server hooks: a fresh `sv create`\n * app or a static site. `disable-i18n` deletes it again once the i18n handle\n * is all that is left.\n */\nexport const HOOKS_SERVER_SNIPPET = [\n \"import type { Handle } from '@sveltejs/kit/hooks';\",\n IMPORTS,\n \"\",\n STARTUP,\n \"\",\n `const ${I18N_HANDLE}: Handle = async ({ event, resolve }) => {`,\n indent(HANDLE_BODY({ locale: \"\", html: \"\" })),\n \"};\",\n \"\",\n `export const handle = ${I18N_HANDLE};`,\n].join(\"\\n\");\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || original.includes(\"loadLocales(\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: I18N_HANDLE });\n if (composed.status === \"unsupported\" || !composed.statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const handleStmt = composed.statement;\n\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"Locale\", true);\n ensureNamedImport(sourceFile, \"#lib/url.js\", \"defaultLocale\");\n ensureNamedImport(sourceFile, \"#lib/url.js\", \"hasLocalizedUrl\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"LOCALE_COOKIE\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"localeCookie\");\n ensureNamedImport(sourceFile, \"#lib/locale.js\", \"pickLocale\");\n ensureNamespaceImport(\n sourceFile,\n \"#locales/main.loader.server.svelte.js\",\n \"main\",\n );\n ensureNamespaceImport(sourceFile, \"#locales/js.loader.server.js\", \"js\");\n\n // Above the handle and its JSDoc, so `handleWuchale` is declared before\n // the handle reads it.\n sourceFile.insertText(\n handleStmt.getStart(true),\n `${STARTUP}\\n\\n${UNTYPED_HANDLE}\\n\\n`,\n );\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst DELOCALIZE_HELPER = dedent`\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n`;\n\n/**\n * The whole file, for a project that had no universal hooks. `disable-i18n`\n * deletes it again once the de-localizing reroute is all that is left.\n */\nexport const HOOKS_SNIPPET = dedent`\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:\n\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));\n`;\n\n/** What `enable-content-negotiation` leaves behind, to the whitespace. */\nconst NEGOTIATE_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)$/;\n\n/** A `reroute` this modifier cannot compose with: not a variable declaration. */\nfunction hasOtherReroute(sourceFile: SourceFile): boolean {\n if (sourceFile.getFunction(\"reroute\")) return true;\n return sourceFile\n .getExportDeclarations()\n .some((d) =>\n d\n .getNamedExports()\n .some(\n (n) => (n.getAliasNode()?.getText() ?? n.getName()) === \"reroute\",\n ),\n );\n}\n\nfunction ensureDeLocalizeImports(sourceFile: SourceFile) {\n ensureNamedImport(sourceFile, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"matchUrl\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n}\n\n/**\n * Add the de-localizing reroute to `src/hooks.ts`, composing with the one\n * `enable-content-negotiation` wrote rather than replacing the file: either\n * pattern may be enabled first, and negotiation's `modifyHooksNegotiate`\n * composes the other way round.\n */\nexport function modifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, HOOKS_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (original.includes(\"rerouteDeLocalize\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n\n if (!rerouteDecl) {\n // A reroute in a shape ts-morph cannot rewrite (a function declaration,\n // a re-export) would collide with the one added below.\n if (hasOtherReroute(sourceFile)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureDeLocalizeImports(sourceFile);\n sourceFile.addStatements(\n `\\n${DELOCALIZE_HELPER}\\n\\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init || !NEGOTIATE_ONLY_REROUTE.test(init.getText())) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureDeLocalizeImports(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n\n // Last: inserting text forgets the nodes above, and the helper has to be\n // declared before the reroute that reads it.\n const target = sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"reroute\"))!;\n sourceFile.insertText(target.getStart(true), `${DELOCALIZE_HELPER}\\n\\n`);\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the sveltekit lang placeholder to the <html> tag:\",\n \"\",\n '<html lang=\"%sveltekit.lang%\">',\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/app.html with a lang placeholder:\",\n \"\",\n \"<!doctype html>\",\n '<html lang=\"%sveltekit.lang%\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n \" %sveltekit.head%\",\n \" </head>\",\n ' <body data-sveltekit-preload-data=\"hover\">',\n ' <div style=\"display: contents\">%sveltekit.body%</div>',\n \" </body>\",\n \"</html>\",\n].join(\"\\n\");\n\nexport function modifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n // A static lang (the templates ship lang=\"en\") is replaced by the\n // placeholder so the server hook can fill in the negotiated locale.\n if (/\\slang\\s*=/i.test(match)) {\n return match.replace(\n /\\slang\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/i,\n ' lang=\"%sveltekit.lang%\"',\n );\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.writeFileSync(appHtmlPath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create a .gitignore with the wuchale cache ignored:\",\n \"\",\n \"# Wuchale\",\n \"src/locales/.wuchale\",\n].join(\"\\n\");\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { Ui } from \"../../../../core/field/ui\";\n\nconst LANGUAGE_SELECT_SNIPPET = `<Navbar.Item>\n\t\t\t\t<LanguageSelect />\n\t\t\t</Navbar.Item>\n\t\t\t`;\n\nconst PLAIN_LANGUAGE_SELECT_SNIPPET = \"<LanguageSelect />\";\n\nconst IMPORT_SNIPPET = dedent`\n import LanguageSelect from '#lib/components/language-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the language select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a language select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_FAILURE_HINT = [\n \"Add the language select to your root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add wherever it should render, e.g. above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_NOT_FOUND_HINT = [\n \"Create a root layout that includes the language select.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nfunction addImport(file: SvelteFile): void {\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"LanguageSelect\",\n moduleSpecifier: \"#lib/components/language-select.svelte\",\n },\n ]);\n });\n return out;\n });\n}\n\n/**\n * A vela layout gets the select as the last `<Navbar.List>` item. A plain one\n * (a project vela did not create) has no navbar, so the select goes above the\n * layout's children.\n */\nexport function modifyRootLayoutLanguageSelect(\n layoutPath: string,\n ui: Ui = \"shadcn\",\n): ModifyOutcome {\n const plain = ui === \"plain\";\n if (!fs.existsSync(layoutPath)) {\n return {\n status: \"not-found\",\n message: plain ? PLAIN_NOT_FOUND_HINT : NOT_FOUND_HINT,\n };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n if (plain) {\n // Without a <script> the import has nowhere to go, and the markup alone\n // would not compile.\n if (!file.getScript()) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n if (!file.insertBeforeChildren(PLAIN_LANGUAGE_SELECT_SNIPPET)) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n addImport(file);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n }\n\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n addImport(file);\n file.insertBeforeClosingTag(\"Navbar.List\", LANGUAGE_SELECT_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File } from \"../../../core/types\";\nimport type { Ui } from \"../../../core/field/ui\";\n\nconst PAGE_PATH = \"src/routes/+page.svelte\";\nconst CATALOG_PATH = \"src/locales/es.po\";\n\n/** `src/routes/+page.svelte` as `sv create` writes it. */\nconst WELCOME_PAGE = [\n \"<h1>Welcome to SvelteKit</h1>\",\n '<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>',\n].join(\"\\n\");\n\ninterface Entry {\n reference: string;\n msgid: string;\n msgstr: string;\n}\n\nconst PAGE_ENTRIES: Entry[] = [\n {\n reference: PAGE_PATH,\n msgid: \"Welcome to SvelteKit\",\n msgstr: \"Bienvenido a SvelteKit\",\n },\n {\n reference: PAGE_PATH,\n msgid: \"Visit <0>svelte.dev/docs/kit</0> to read the documentation\",\n msgstr: \"Visita <0>svelte.dev/docs/kit</0> para leer la documentación\",\n },\n];\n\n// The native <select>'s aria-label. The shadcn select has no text of its own:\n// locale names come from Intl.DisplayNames.\nconst PLAIN_SELECT_ENTRY: Entry = {\n reference: \"src/lib/components/language-select.svelte\",\n msgid: \"Language\",\n msgstr: \"Idioma\",\n};\n\n// What wuchale writes for `es`. It rewrites the file on the first extraction,\n// keeping these translations and adding the source locale's catalog.\nconst HEADER = [\n 'msgid \"\"',\n 'msgstr \"\"',\n '\"Source-Language: en\\\\n\"',\n '\"Language: es\\\\n\"',\n '\"MIME-Version: 1.0\\\\n\"',\n '\"Content-Type: text/plain; charset=utf-8\\\\n\"',\n '\"Content-Transfer-Encoding: 8bit\\\\n\"',\n '\"Plural-Forms: nplurals=3\\\\n\"',\n '\"X-Plurals-Order: one, many, other\\\\n\"',\n].join(\"\\n\");\n\n// Whitespace is ignored so a page prettier has rewrapped still counts.\nconst normalize = (source: string) => source.replace(/\\s+/g, \"\");\n\n/**\n * A Spanish catalog for the `sv create` welcome page, so the language select\n * visibly does something on a fresh project. Anything else in the project is\n * left for the user to translate. Null unless the page is untouched, and never\n * over an existing catalog.\n */\nexport function welcomePageCatalog(root: string, ui: Ui): File | null {\n if (fs.existsSync(path.join(root, CATALOG_PATH))) return null;\n\n const pagePath = path.join(root, PAGE_PATH);\n if (!fs.existsSync(pagePath)) return null;\n const page = fs.readFileSync(pagePath, \"utf8\");\n if (normalize(page) !== normalize(WELCOME_PAGE)) return null;\n\n const entries =\n ui === \"plain\" ? [...PAGE_ENTRIES, PLAIN_SELECT_ENTRY] : PAGE_ENTRIES;\n const blocks = entries.map((entry) =>\n [\n `#: ${entry.reference}`,\n `msgid \"${entry.msgid}\"`,\n `msgstr \"${entry.msgstr}\"`,\n ].join(\"\\n\"),\n );\n\n return {\n path: CATALOG_PATH,\n language: \"text\",\n content: [HEADER, ...blocks].join(\"\\n\\n\") + \"\\n\",\n status: \"success\",\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveUi } from \"../../../core/field/ui\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifyPackageImportsI18n } from \"./modifies/package-imports\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyHooksI18n } from \"./modifies/hooks\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { modifyPrettierignore } from \"./modifies/prettierignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { modifyLayoutServerLocale } from \"./modifies/layout.server\";\nimport { modifyAppDts } from \"./modifies/app-d-ts\";\nimport {\n APP_LAYOUT_PATH,\n modifyAppLayoutLanguageSelect,\n} from \"./modifies/app-layout.svelte\";\nimport { welcomePageCatalog } from \"./welcome-catalog\";\nimport {\n entriesInProject,\n translateCatalog,\n withTranslations,\n} from \"../../../runtime/wuchale-catalog\";\nimport { AUTH_TRANSLATIONS } from \"../auth/translations\";\nimport {\n TRANSLATED_LIB_FILES,\n withWuchaleJsFiles,\n} from \"../../../runtime/wuchale-config\";\n\n/**\n * The `wuchale.config.js` create, with the library modules that carry\n * visitor-facing text and already exist in the project (the WhatsApp order\n * message, say) listed for the js adapter. A pattern enabled later adds its\n * own module to the written config.\n */\nexport function withLibraryTexts(root: string, creates: File[]): File[] {\n const present = TRANSLATED_LIB_FILES.filter((file) =>\n fs.existsSync(path.join(root, file)),\n );\n if (present.length === 0) return creates;\n return creates.map((file) => {\n if (!file.path.endsWith(\"wuchale.config.js\")) return file;\n const edited = withWuchaleJsFiles(file.content, present);\n return edited?.changed ? { ...file, content: edited.source } : file;\n });\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, modifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Adding #locales to package.json imports\");\n const imports = modifyPackageImportsI18n(options.root);\n pushResult(modifyOutcomeToFile(imports.filePath, imports.outcome));\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerI18n(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksI18n(hooksPath)));\n\n logger.info(\"Modifying app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, modifyAppHtml(appHtmlPath)));\n\n logger.info(\"Declaring the request's language in app.d.ts\");\n const appDtsPath = path.join(options.root, \"src\", \"app.d.ts\");\n pushResult(modifyOutcomeToFile(appDtsPath, modifyAppDts(appDtsPath)));\n\n logger.info(\"Modifying root +layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServerLocale(layoutServerPath),\n ),\n );\n\n logger.info(\"Modifying root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushResult(modifyOutcomeToFile(layoutPath, ensureRootLayoutI18n(layoutPath)));\n\n logger.info(\"Modifying root layout language select\");\n const rootLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const ui = resolveUi(options);\n // With no layout at all, a plain project's not-found hint names the\n // +layout.svelte it would have rather than vela's root-layout.svelte.\n const rootLayoutPath =\n rootLayoutCandidates.find((p) => fs.existsSync(p)) ??\n (ui === \"plain\" ? rootLayoutCandidates[3] : rootLayoutCandidates[0]);\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyRootLayoutLanguageSelect(rootLayoutPath, ui),\n ),\n );\n\n // Signed-in pages have one URL for every language; the select is how a\n // visitor changes it there.\n const appLayoutPath = path.join(options.root, APP_LAYOUT_PATH);\n if (fs.existsSync(appLayoutPath)) {\n logger.info(\"Adding the language select to the signed-in layout\");\n pushResult(\n modifyOutcomeToFile(\n appLayoutPath,\n modifyAppLayoutLanguageSelect(appLayoutPath),\n ),\n );\n }\n\n logger.info(\"Updating .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, modifyGitignore(gitignorePath)),\n );\n\n logger.info(\"Updating .prettierignore\");\n const prettierignorePath = path.join(options.root, \".prettierignore\");\n pushResult(\n modifyOutcomeToFile(\n prettierignorePath,\n modifyPrettierignore(prettierignorePath),\n ),\n );\n\n const catalog = welcomePageCatalog(options.root, ui);\n if (catalog) logger.info(\"Translating the welcome page into Spanish\");\n\n // Spanish for the pages other patterns wrote before this one: without it\n // they stay in English, and nothing says so.\n const shipped = entriesInProject(options.root, AUTH_TRANSLATIONS);\n if (shipped.length > 0)\n logger.info(\"Translating the sign-in pages into Spanish\");\n const creates: File[] = [];\n if (catalog) {\n const content = withTranslations(catalog.content, shipped).source;\n creates.push({ ...catalog, content });\n } else {\n const translated = translateCatalog(options.root, shipped);\n if (translated.create) creates.push(translated.create);\n pushResult(translated.modify);\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,IAAMA,IAAe,oLAUfC,IAAiB;AAWvB,SAAgBkC,GAAiB,GAAuC;CACtE,IAAI,CAACJ,EAAG,WAAWK,CAA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FW.js";
6
6
  import { _ as s, a as c, o as l, r as u } from "./ts-morph-helpers-B4KZXP44.js";
7
7
  import { t as d } from "./svelte-file-DfplF3BU.js";
8
- import f from "node:fs";
9
- import p from "node:path";
10
- import { Project as m, SyntaxKind as h } from "ts-morph";
8
+ import { localizeAuthPages as f } from "./i18n-BHCytiiO.js";
9
+ import p from "node:fs";
10
+ import m from "node:path";
11
+ import { Project as h, SyntaxKind as g } from "ts-morph";
11
12
  // src/patterns/enable/auth/modifies/+layout.server.ts
12
- function g(e) {
13
- if (!f.existsSync(e)) {
13
+ function _(e) {
14
+ if (!p.existsSync(e)) {
14
15
  let t = o`
15
16
  export const load = async ({ locals }) => {
16
17
  return { user: locals.pb.authStore.record };
17
18
  };
18
19
  `;
19
- return f.writeFileSync(e, t), {
20
+ return p.writeFileSync(e, t), {
20
21
  status: "success",
21
22
  changed: !0
22
23
  };
23
24
  }
24
- let t = f.readFileSync(e, "utf8"), n = new m().addSourceFileAtPath(e), r = (e) => {
25
+ let t = p.readFileSync(e, "utf8"), n = new h().addSourceFileAtPath(e), r = (e) => {
25
26
  e.getProperty("user") || e.addPropertyAssignment({
26
27
  name: "user",
27
28
  initializer: "locals.pb.authStore.record"
28
29
  });
29
30
  }, i, a, s = n.getVariableDeclaration("load");
30
- if (s && s.getFirstAncestorByKind(h.VariableStatement)?.hasExportKeyword()) {
31
- let e = s.getInitializerIfKind(h.ArrowFunction);
31
+ if (s && s.getFirstAncestorByKind(g.VariableStatement)?.hasExportKeyword()) {
32
+ let e = s.getInitializerIfKind(g.ArrowFunction);
32
33
  if (e) i = e;
33
34
  else {
34
35
  let e = s.getInitializer();
35
36
  if (e) {
36
- let t = e.getFirstDescendantByKind(h.ArrowFunction);
37
+ let t = e.getFirstDescendantByKind(g.ArrowFunction);
37
38
  if (t) i = t;
38
39
  else {
39
- let t = e.getFirstDescendantByKind(h.FunctionExpression);
40
+ let t = e.getFirstDescendantByKind(g.FunctionExpression);
40
41
  t && (a = t);
41
42
  }
42
43
  }
@@ -60,7 +61,7 @@ function g(e) {
60
61
  if (u.length === 0) c.insertParameter(0, { name: "{ locals }" });
61
62
  else {
62
63
  let e = u[0], t = e.getStructure(), n = e.getNameNode();
63
- if (n.getKind() === h.ObjectBindingPattern) {
64
+ if (n.getKind() === g.ObjectBindingPattern) {
64
65
  let r = n;
65
66
  if (!r.getElements().some((e) => e.getName() === "locals")) {
66
67
  let n = r.getElements().map((e) => e.getText()).filter(Boolean), i = n.length > 0 ? ", " + n.join(", ") : "";
@@ -81,32 +82,32 @@ function g(e) {
81
82
  }
82
83
  if (i) {
83
84
  let e = i.getBody();
84
- if (e.getKind() === h.Block) e.getDescendantsOfKind(h.ReturnStatement).forEach((e) => {
85
+ if (e.getKind() === g.Block) e.getDescendantsOfKind(g.ReturnStatement).forEach((e) => {
85
86
  let t = e.getExpression();
86
87
  if (t) {
87
- if (t.getKind() === h.ObjectLiteralExpression) r(t);
88
- else if (t.getKind() === h.ParenthesizedExpression) {
88
+ if (t.getKind() === g.ObjectLiteralExpression) r(t);
89
+ else if (t.getKind() === g.ParenthesizedExpression) {
89
90
  let e = t.getExpression();
90
- e.getKind() === h.ObjectLiteralExpression && r(e);
91
+ e.getKind() === g.ObjectLiteralExpression && r(e);
91
92
  }
92
93
  }
93
94
  });
94
95
  else {
95
96
  let t = e;
96
- if (t.getKind() === h.ParenthesizedExpression) {
97
+ if (t.getKind() === g.ParenthesizedExpression) {
97
98
  let e = t.getExpression();
98
- e.getKind() === h.ObjectLiteralExpression && r(e);
99
- } else t.getKind() === h.ObjectLiteralExpression && r(t);
99
+ e.getKind() === g.ObjectLiteralExpression && r(e);
100
+ } else t.getKind() === g.ObjectLiteralExpression && r(t);
100
101
  }
101
102
  } else if (a) {
102
103
  let e = a.getBody();
103
- e && e.getDescendantsOfKind(h.ReturnStatement).forEach((e) => {
104
+ e && e.getDescendantsOfKind(g.ReturnStatement).forEach((e) => {
104
105
  let t = e.getExpression();
105
106
  if (t) {
106
- if (t.getKind() === h.ObjectLiteralExpression) r(t);
107
- else if (t.getKind() === h.ParenthesizedExpression) {
107
+ if (t.getKind() === g.ObjectLiteralExpression) r(t);
108
+ else if (t.getKind() === g.ParenthesizedExpression) {
108
109
  let e = t.getExpression();
109
- e.getKind() === h.ObjectLiteralExpression && r(e);
110
+ e.getKind() === g.ObjectLiteralExpression && r(e);
110
111
  }
111
112
  }
112
113
  });
@@ -117,32 +118,32 @@ function g(e) {
117
118
  };
118
119
  }
119
120
  // src/patterns/enable/auth/modifies/root-layout.svelte.ts
120
- var _ = "\n <Navbar.Item\n class=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n >\n <AuthMenu.Root>\n {#snippet user()}\n <AuthMenu.Trigger>\n <UserAvatar user={data.user} />\n </AuthMenu.Trigger>\n\n <AuthMenu.Content align=\"end\">\n <AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n <AuthMenu.Group>\n <AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n <AuthMenu.Item>\n <form action=\"/logout\" method=\"post\">\n <button type=\"submit\" class=\"contents\">Logout</button>\n </form>\n </AuthMenu.Item>\n </AuthMenu.Group>\n </AuthMenu.Content>\n {/snippet}\n\n {#snippet guest()}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n href=\"/login\">Login</Button\n >\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"outline\"\n href=\"/signup\">Sign up</Button\n >\n {/snippet}\n </AuthMenu.Root>\n </Navbar.Item>\n ", v = o`
121
+ var v = "\n <Navbar.Item\n class=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n >\n <AuthMenu.Root>\n {#snippet user()}\n <AuthMenu.Trigger>\n <UserAvatar user={data.user} />\n </AuthMenu.Trigger>\n\n <AuthMenu.Content align=\"end\">\n <AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n <AuthMenu.Group>\n <AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n <AuthMenu.Item>\n <form action=\"/logout\" method=\"post\">\n <button type=\"submit\" class=\"contents\">Logout</button>\n </form>\n </AuthMenu.Item>\n </AuthMenu.Group>\n </AuthMenu.Content>\n {/snippet}\n\n {#snippet guest()}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n href=\"/login\">Login</Button\n >\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"outline\"\n href=\"/signup\">Sign up</Button\n >\n {/snippet}\n </AuthMenu.Root>\n </Navbar.Item>\n ", y = o`
121
122
  import * as AuthMenu from '#lib/components/ui/auth-menu/index.js';
122
123
  import UserAvatar from '#lib/components/user-avatar.svelte';
123
- `, y = [
124
+ `, b = [
124
125
  "Add the auth menu inside your <Navbar.List> in the root layout.",
125
126
  "",
126
127
  "Imports to add to the <script> tag:",
127
128
  "",
128
- v,
129
+ y,
129
130
  "",
130
131
  "Markup to add inside <Navbar.List>:",
131
- _
132
- ].join("\n"), b = [
132
+ v
133
+ ].join("\n"), x = [
133
134
  "Create a root layout that includes an auth menu inside <Navbar.List>.",
134
135
  "",
135
136
  "Imports for the <script> tag:",
136
137
  "",
137
- v,
138
+ y,
138
139
  "",
139
140
  "Markup inside <Navbar.List>:",
140
- _
141
+ v
141
142
  ].join("\n");
142
- function x(e) {
143
- if (!f.existsSync(e)) return {
143
+ function S(e) {
144
+ if (!p.existsSync(e)) return {
144
145
  status: "not-found",
145
- message: b
146
+ message: x
146
147
  };
147
148
  let t = d.fromPath(e);
148
149
  return t.hasElement("Navbar.List") ? t.hasElement("AuthMenu.Root") ? {
@@ -159,22 +160,22 @@ function x(e) {
159
160
  }]), c(e, "data");
160
161
  });
161
162
  return t;
162
- }), t.insertBeforeClosingTag("Navbar.List", _), t.writeTo(e), {
163
+ }), t.insertBeforeClosingTag("Navbar.List", v), t.writeTo(e), {
163
164
  status: "success",
164
165
  changed: t.hasChanged()
165
166
  }) : {
166
167
  status: "failed",
167
- message: y
168
+ message: b
168
169
  };
169
170
  }
170
171
  // src/patterns/enable/auth/modifies/hooks.server.ts
171
- var S = o`
172
+ var C = o`
172
173
  Configure handlePocketbase() with the auth option in hooks.server.ts:
173
174
 
174
175
  handlePocketbase({
175
176
  auth: { protectedRoutes: ['/(app)'] },
176
177
  });
177
- `, C = o`
178
+ `, w = o`
178
179
  Create src/hooks.server.ts with handlePocketbase:
179
180
 
180
181
  import { handlePocketbase } from '@velastack/pocketbase';
@@ -183,15 +184,15 @@ var S = o`
183
184
  auth: { protectedRoutes: ['/(app)'] },
184
185
  });
185
186
  `;
186
- function w(e) {
187
- if (!f.existsSync(e)) return {
187
+ function T(e) {
188
+ if (!p.existsSync(e)) return {
188
189
  status: "not-found",
189
- message: C
190
+ message: w
190
191
  };
191
- let t = f.readFileSync(e, "utf8"), n = new m().addSourceFileAtPath(e), r = n.getDescendantsOfKind(h.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
192
+ let t = p.readFileSync(e, "utf8"), n = new h().addSourceFileAtPath(e), r = n.getDescendantsOfKind(g.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
192
193
  if (!r) return {
193
194
  status: "failed",
194
- message: S
195
+ message: C
195
196
  };
196
197
  let i = r.getArguments();
197
198
  if (i.length === 0) return r.addArgument("{ auth: { protectedRoutes: ['/(app)'] } }"), l(n), n.saveSync(), {
@@ -199,11 +200,11 @@ function w(e) {
199
200
  changed: !0
200
201
  };
201
202
  let a = i[0];
202
- if (a.getKind() !== h.ObjectLiteralExpression) return r.insertArgument(0, "{ auth: { protectedRoutes: ['/(app)'] } }"), l(n), n.saveSync(), {
203
+ if (a.getKind() !== g.ObjectLiteralExpression) return r.insertArgument(0, "{ auth: { protectedRoutes: ['/(app)'] } }"), l(n), n.saveSync(), {
203
204
  status: "success",
204
205
  changed: !0
205
206
  };
206
- let o = a.asKindOrThrow(h.ObjectLiteralExpression), s = o.getProperty("auth");
207
+ let o = a.asKindOrThrow(g.ObjectLiteralExpression), s = o.getProperty("auth");
207
208
  if (!s) return o.addPropertyAssignment({
208
209
  name: "auth",
209
210
  initializer: "{ protectedRoutes: ['/(app)'] }"
@@ -211,17 +212,17 @@ function w(e) {
211
212
  status: "success",
212
213
  changed: !0
213
214
  };
214
- if (s.getKind() === h.PropertyAssignment) {
215
+ if (s.getKind() === g.PropertyAssignment) {
215
216
  let e = s.getInitializer();
216
- if (e && e.getKind() === h.ObjectLiteralExpression) {
217
+ if (e && e.getKind() === g.ObjectLiteralExpression) {
217
218
  let t = e, n = t.getProperty("protectedRoutes");
218
219
  if (!n) t.addPropertyAssignment({
219
220
  name: "protectedRoutes",
220
221
  initializer: "['/(app)']"
221
222
  });
222
- else if (n.getKind() === h.PropertyAssignment) {
223
+ else if (n.getKind() === g.PropertyAssignment) {
223
224
  let e = n.getInitializer();
224
- if (e && e.getKind() === h.ArrayLiteralExpression) {
225
+ if (e && e.getKind() === g.ArrayLiteralExpression) {
225
226
  let t = e;
226
227
  t.getElements().some((e) => e.getText().replace(/['"`]/g, "") === "/(app)") || t.addElement("'/(app)'");
227
228
  } else n.setInitializer("['/(app)']");
@@ -234,39 +235,39 @@ function w(e) {
234
235
  };
235
236
  }
236
237
  // src/patterns/enable/auth/modifies/sidebar-menu-button.svelte.ts
237
- var T = [{
238
+ var E = [{
238
239
  from: "'data-active': isActive,",
239
240
  to: "'data-active': isActive ? true : undefined,"
240
241
  }, {
241
242
  from: "\"data-active\": isActive,",
242
243
  to: "\"data-active\": isActive ? true : undefined,"
243
- }], E = o`
244
+ }], D = o`
244
245
  The shadcn-svelte sidebar component was not installed at the expected path.
245
246
  Run: vela enable auth (or install the 'sidebar' shadcn-svelte component).
246
247
  `;
247
- function D(e) {
248
- if (!f.existsSync(e)) return {
248
+ function O(e) {
249
+ if (!p.existsSync(e)) return {
249
250
  status: "not-found",
250
- message: E
251
+ message: D
251
252
  };
252
- let t = f.readFileSync(e, "utf8");
253
- if (T.some(({ to: e }) => t.includes(e))) return {
253
+ let t = p.readFileSync(e, "utf8");
254
+ if (E.some(({ to: e }) => t.includes(e))) return {
254
255
  status: "success",
255
256
  changed: !1
256
257
  };
257
- let n = T.find(({ from: e }) => t.includes(e));
258
+ let n = E.find(({ from: e }) => t.includes(e));
258
259
  if (!n) return {
259
260
  status: "success",
260
261
  changed: !1
261
262
  };
262
263
  let r = t.replace(n.from, n.to);
263
- return f.writeFileSync(e, r, "utf8"), {
264
+ return p.writeFileSync(e, r, "utf8"), {
264
265
  status: "success",
265
266
  changed: !0
266
267
  };
267
268
  }
268
269
  // src/patterns/enable/auth/generate.runtime.ts
269
- async function O(o) {
270
+ async function k(o) {
270
271
  let { input: s } = o, c = e(o), l = [];
271
272
  await t(o.root, async (e) => {
272
273
  c.info("Updating PocketBase mail settings"), await e.settings.update({ meta: {
@@ -290,7 +291,7 @@ async function O(o) {
290
291
  d && l.push({
291
292
  path: d,
292
293
  language: "ts",
293
- content: f.readFileSync(d, "utf8"),
294
+ content: p.readFileSync(d, "utf8"),
294
295
  status: "success"
295
296
  });
296
297
  });
@@ -298,22 +299,22 @@ async function O(o) {
298
299
  e && u.push(e);
299
300
  };
300
301
  c.info("Modifying +layout.server.ts");
301
- let m = p.join(o.root, "src", "routes", "+layout.server.ts");
302
- d(i(m, g(m))), c.info("Modifying root layout");
303
- let h = [
304
- p.join(o.root, "src", "routes", "(public)", "root-layout.svelte"),
305
- p.join(o.root, "src", "routes", "root-layout.svelte"),
306
- p.join(o.root, "src", "routes", "(public)", "+layout.svelte"),
307
- p.join(o.root, "src", "routes", "+layout.svelte")
308
- ], _ = h.find((e) => f.existsSync(e)) ?? h[0];
309
- d(i(_, x(_))), c.info("Modifying hooks.server.ts");
310
- let v = p.join(o.root, "src", "hooks.server.ts");
311
- d(i(v, w(v))), c.info("Modifying sidebar-menu-button.svelte");
312
- let y = p.join(o.root, "src", "lib", "components", "ui", "sidebar", "sidebar-menu-button.svelte");
313
- d(i(y, D(y)));
314
- let b = await a(o);
315
- return {
316
- creates: b ? [...l, b] : l,
302
+ let h = m.join(o.root, "src", "routes", "+layout.server.ts");
303
+ d(i(h, _(h))), c.info("Modifying root layout");
304
+ let g = [
305
+ m.join(o.root, "src", "routes", "(public)", "root-layout.svelte"),
306
+ m.join(o.root, "src", "routes", "root-layout.svelte"),
307
+ m.join(o.root, "src", "routes", "(public)", "+layout.svelte"),
308
+ m.join(o.root, "src", "routes", "+layout.svelte")
309
+ ], v = g.find((e) => p.existsSync(e)) ?? g[0];
310
+ d(i(v, S(v))), c.info("Modifying hooks.server.ts");
311
+ let y = m.join(o.root, "src", "hooks.server.ts");
312
+ d(i(y, T(y))), c.info("Modifying sidebar-menu-button.svelte");
313
+ let b = m.join(o.root, "src", "lib", "components", "ui", "sidebar", "sidebar-menu-button.svelte");
314
+ d(i(b, O(b)));
315
+ let x = await a(o), C = x ? [...l, x] : [...l], w = f(o);
316
+ return C.push(...w.creates), u.push(...w.modifies), {
317
+ creates: C,
317
318
  modifies: u,
318
319
  deletes: [],
319
320
  components: [],
@@ -323,6 +324,6 @@ async function O(o) {
323
324
  collectionDrops: []
324
325
  };
325
326
  }
326
- export { O as generate };
327
+ export { k as generate };
327
328
 
328
- //# sourceMappingURL=generate.runtime-B6FeCL5I.js.map
329
+ //# sourceMappingURL=generate.runtime-CsP4c8GY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CsP4c8GY.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","getLogger","withPocketbase","getMigrationFile","modifyOutcomeToFile","ensureSiteFile","dedent","withInMemoryScript","ensurePropsBinding","formatLikeSource","ensureImports","SvelteFile","fs","path","modifyLayoutServer","layoutPath","snippet","originalSource","sourceFile","Project","addUserProp","obj","loadArrow","loadFn","varDecl","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","el","parts","tail","currentName","body","expr","ret","inner","bodyExpr","AUTH_MENU_NAVBAR_ITEM","IMPORT_SNIPPET","FAILURE_HINT$1","NOT_FOUND_HINT$2","modifyRootLayoutSvelte","file","out","source","sf","FAILURE_HINT","NOT_FOUND_HINT$1","modifyHooksServer","hooksServerPath","callExpr","ce","args","firstArg","optionsObj","authProp","authInit","authObj","prProp","prInit","arr","VARIANTS","NOT_FOUND_HINT","modifySidebarMenuButton","filePath","to","variant","from","updated","generate","options","logger","creates","pb","input","migrationDelay","userCollection","verificationTemplate","resetPasswordTemplate","confirmEmailChangeTemplate","migrationFile","modifies","pushResult","layoutServerFile","layoutCandidates","layoutFile","p","hooksServerFile","sidebarMenuButtonFile","siteFile","written","localized","localizeAuthPages"],"sources":["../../src/patterns/enable/auth/modifies/+layout.server.ts","../../src/patterns/enable/auth/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth/modifies/hooks.server.ts","../../src/patterns/enable/auth/modifies/sidebar-menu-button.svelte.ts","../../src/patterns/enable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function modifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n ensurePropsBinding,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst AUTH_MENU_NAVBAR_ITEM = `\n\t\t<Navbar.Item\n\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t>\n\t\t\t<AuthMenu.Root>\n\t\t\t\t{#snippet user()}\n\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t<UserAvatar user={data.user} />\n\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t{/snippet}\n\n\t\t\t\t{#snippet guest()}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t>\n\t\t\t\t{/snippet}\n\t\t\t</AuthMenu.Root>\n\t\t</Navbar.Item>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import * as AuthMenu from '#lib/components/ui/auth-menu/index.js';\n import UserAvatar from '#lib/components/user-avatar.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the auth menu inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes an auth menu inside <Navbar.List>.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nexport function modifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namespaceImport: \"AuthMenu\",\n moduleSpecifier: \"#lib/components/ui/auth-menu/index.js\",\n },\n {\n defaultImport: \"UserAvatar\",\n moduleSpecifier: \"#lib/components/user-avatar.svelte\",\n },\n ]);\n // The menu reads `data.user`; the template's layout takes no props.\n ensurePropsBinding(sf, \"data\");\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"Navbar.List\", AUTH_MENU_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the auth option in hooks.server.ts:\n\n handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from '@velastack/pocketbase';\n\n export const handle = handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst VARIANTS = [\n {\n from: \"'data-active': isActive,\",\n to: \"'data-active': isActive ? true : undefined,\",\n },\n {\n from: '\"data-active\": isActive,',\n to: '\"data-active\": isActive ? true : undefined,',\n },\n];\n\nconst NOT_FOUND_HINT = dedent`\n The shadcn-svelte sidebar component was not installed at the expected path.\n Run: vela enable auth (or install the 'sidebar' shadcn-svelte component).\n`;\n\nexport function modifySidebarMenuButton(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n\n if (VARIANTS.some(({ to }) => original.includes(to))) {\n return { status: \"success\", changed: false };\n }\n\n const variant = VARIANTS.find(({ from }) => original.includes(from));\n if (!variant) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original.replace(variant.from, variant.to);\n fs.writeFileSync(filePath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifySidebarMenuButton } from \"./modifies/sidebar-menu-button.svelte\";\nimport { localizeAuthPages } from \"./i18n\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n const logger = getLogger(options);\n\n const creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n logger.info(\"Updating PocketBase mail settings\");\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n await migrationDelay();\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-reset/{TOKEN}\",\n \"{APP_URL}/confirm-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n logger.info(\"Locking down users collection rules and email templates\");\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n // Modify files\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerFile, modifyLayoutServer(layoutServerFile)),\n );\n\n logger.info(\"Modifying root layout\");\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, modifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, modifyHooksServer(hooksServerFile)),\n );\n\n logger.info(\"Modifying sidebar-menu-button.svelte\");\n const sidebarMenuButtonFile = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"ui\",\n \"sidebar\",\n \"sidebar-menu-button.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n sidebarMenuButtonFile,\n modifySidebarMenuButton(sidebarMenuButtonFile),\n ),\n );\n\n // The auth pages and the app sidebar show `site.name`.\n const siteFile = await ensureSiteFile(options);\n const written: File[] = siteFile ? [...creates, siteFile] : [...creates];\n\n // In a project that already has i18n: the language select and the Spanish\n // enable-i18n would have added had these pages been there when it ran.\n const localized = localizeAuthPages(options);\n written.push(...localized.creates);\n modifies.push(...localized.modifies);\n\n return {\n creates: written,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAgBgB,EAAmB,GAAmC;CACpE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAAG;EAC9B,IAAMC,IAAU,CAAM;;;;;EAOtB,OADAJ,EAAG,cAAcG,GAAYC,CAAO,GAC7B;GAAE,QAAQ;GAAW,SAAS;EAAK;CAC5C;CAEA,IAAMC,IAAiBL,EAAG,aAAaG,GAAY,MAAM,GAEnDG,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBJ,CAAU,GAGnDK,KAAe,MAAoD;EAEvE,AADkBC,EAAI,YAAY,MAAM,KAEtCA,E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