@velastack/patterns 0.13.2 → 0.14.0

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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/app-d-ts-h33RrYIv.js +198 -0
  3. package/dist/chunks/app-d-ts-h33RrYIv.js.map +1 -0
  4. package/dist/chunks/app-layout.svelte-CZ0hw-pi.js +51 -0
  5. package/dist/chunks/app-layout.svelte-CZ0hw-pi.js.map +1 -0
  6. package/dist/chunks/constants-DpK-r_m5.js.map +1 -1
  7. package/dist/chunks/{generate.runtime-CzYArKUA.js → generate.runtime-BSxSHNh7.js} +2 -2
  8. package/dist/chunks/{generate.runtime-CzYArKUA.js.map → generate.runtime-BSxSHNh7.js.map} +1 -1
  9. package/dist/chunks/{generate.runtime-Dfl-07VS.js → generate.runtime-CZKIKP3B.js} +214 -178
  10. package/dist/chunks/generate.runtime-CZKIKP3B.js.map +1 -0
  11. package/dist/chunks/{generate.runtime-DaPA2NNL.js → generate.runtime-CqCXFeWH.js} +2 -2
  12. package/dist/chunks/{generate.runtime-DaPA2NNL.js.map → generate.runtime-CqCXFeWH.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-B6FeCL5I.js → generate.runtime-CsP4c8GY.js} +78 -77
  14. package/dist/chunks/generate.runtime-CsP4c8GY.js.map +1 -0
  15. package/dist/chunks/generate.runtime-DZUPtJVF.js +429 -0
  16. package/dist/chunks/generate.runtime-DZUPtJVF.js.map +1 -0
  17. package/dist/chunks/{generate.runtime-C_SdcnRs.js → generate.runtime-Db7JwGTb.js} +2 -2
  18. package/dist/chunks/{generate.runtime-C_SdcnRs.js.map → generate.runtime-Db7JwGTb.js.map} +1 -1
  19. package/dist/chunks/{generate.runtime-i3tMIA1A.js → generate.runtime-pbIrEsa7.js} +45 -45
  20. package/dist/chunks/generate.runtime-pbIrEsa7.js.map +1 -0
  21. package/dist/chunks/i18n-BHCytiiO.js +28 -0
  22. package/dist/chunks/i18n-BHCytiiO.js.map +1 -0
  23. package/dist/chunks/{table-core-BXmnfjln.js → table-core-Dua6QnXM.js} +14 -4
  24. package/dist/chunks/table-core-Dua6QnXM.js.map +1 -0
  25. package/dist/chunks/{test-setup-cZj1tqaf.js → test-setup-gJdzWWs_.js} +2 -2
  26. package/dist/chunks/{test-setup-cZj1tqaf.js.map → test-setup-gJdzWWs_.js.map} +1 -1
  27. package/dist/chunks/translations-CiJnl574.js +189 -0
  28. package/dist/chunks/translations-CiJnl574.js.map +1 -0
  29. package/dist/chunks/{ui-IkdkLwmB.js → ui-CD61O7Sb.js} +3 -3
  30. package/dist/chunks/{ui-IkdkLwmB.js.map → ui-CD61O7Sb.js.map} +1 -1
  31. package/dist/chunks/write-result-B7MewKhQ.js +499 -0
  32. package/dist/chunks/write-result-B7MewKhQ.js.map +1 -0
  33. package/dist/index.js +734 -721
  34. package/dist/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunks/_layout-xBzFhszN.js +0 -78
  37. package/dist/chunks/_layout-xBzFhszN.js.map +0 -1
  38. package/dist/chunks/generate.runtime-B6FeCL5I.js.map +0 -1
  39. package/dist/chunks/generate.runtime-DLg2CKxQ.js +0 -341
  40. package/dist/chunks/generate.runtime-DLg2CKxQ.js.map +0 -1
  41. package/dist/chunks/generate.runtime-Dfl-07VS.js.map +0 -1
  42. package/dist/chunks/generate.runtime-i3tMIA1A.js.map +0 -1
  43. package/dist/chunks/table-core-BXmnfjln.js.map +0 -1
  44. package/dist/chunks/write-result-C1GYInL8.js +0 -499
  45. package/dist/chunks/write-result-C1GYInL8.js.map +0 -1
@@ -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;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AGC,EAAU,OAAO,GACjCV,EAAS,KAAK,GAAGU,EAAU,QAAQ,GAE5B;EACL,SAASD;EACT;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,429 @@
1
+ import { n as e } from "./logger-t1HxmpG2.js";
2
+ import { a as t, r as n } from "./modify-file-CRZ_gMg0.js";
3
+ import { a as r, o as i, s as a, t as o } from "./config-target-DJbVHwHl.js";
4
+ import { i as s, l as c, n as l, o as u, s as d, t as f } from "./app-d-ts-h33RrYIv.js";
5
+ import { _ as p, c as m, d as h, g, h as _, m as v, n as y, o as b, s as x, u as S } from "./ts-morph-helpers-B4KZXP44.js";
6
+ import { r as C } from "./package-imports-CcIIHbp5.js";
7
+ import { t as w } from "./dedent-CCUOcPFW.js";
8
+ import { n as T } from "./compose-handle-Da7m6lV_.js";
9
+ import { r as E } from "./lib-specifier-C3M0WTev.js";
10
+ import { t as D } from "./svelte-file-DfplF3BU.js";
11
+ import { i as O } from "./load-function-BFvIVsh7.js";
12
+ import { n as ee, t as k } from "./app-layout.svelte-CZ0hw-pi.js";
13
+ import A from "node:fs";
14
+ import j from "node:path";
15
+ import { Node as te, Project as M, QuoteKind as N, SyntaxKind as P } from "ts-morph";
16
+ // src/patterns/disable/i18n/modifies/gitignore.ts
17
+ function F(e) {
18
+ if (!A.existsSync(e)) return {
19
+ status: "success",
20
+ changed: !1
21
+ };
22
+ let t = A.readFileSync(e, "utf8");
23
+ if (!t.includes("src/locales/.wuchale")) return {
24
+ status: "success",
25
+ changed: !1
26
+ };
27
+ let n = t.split("\n"), r = [];
28
+ for (let e = 0; e < n.length; e++) {
29
+ let t = n[e];
30
+ if (t === "# Wuchale") {
31
+ let t = e + 1, r = !1;
32
+ for (; t < n.length && n[t].trim() !== "";) n[t] === "src/locales/.wuchale" && (r = !0), t++;
33
+ if (r) {
34
+ e = t;
35
+ continue;
36
+ }
37
+ }
38
+ t !== "src/locales/.wuchale" && r.push(t);
39
+ }
40
+ let i = r.join("\n");
41
+ return i = i.replace(/\n{3,}/g, "\n\n"), i === t ? {
42
+ status: "success",
43
+ changed: !1
44
+ } : (A.writeFileSync(e, i), {
45
+ status: "success",
46
+ changed: !0
47
+ });
48
+ }
49
+ // src/patterns/disable/i18n/modifies/prettierignore.ts
50
+ function I(e) {
51
+ if (!A.existsSync(e)) return {
52
+ status: "success",
53
+ changed: !1
54
+ };
55
+ let t = A.readFileSync(e, "utf8").split("\n"), n = t.findIndex((e, n) => e === "# Wuchale" && t[n + 1] === "src/locales/");
56
+ return n === -1 ? {
57
+ status: "success",
58
+ changed: !1
59
+ } : (t.splice(n, 2), n > 0 && t[n - 1] === "" && (t[n] ?? "") === "" && t.splice(n - 1, 1), A.writeFileSync(e, t.join("\n")), {
60
+ status: "success",
61
+ changed: !0
62
+ });
63
+ }
64
+ // src/patterns/disable/i18n/modifies/vite-config.ts
65
+ function L(e) {
66
+ if (!A.existsSync(e)) return {
67
+ status: "success",
68
+ changed: !1
69
+ };
70
+ let t = A.readFileSync(e, "utf8");
71
+ if (!t.includes("wuchale")) return {
72
+ status: "success",
73
+ changed: !1
74
+ };
75
+ let n = new M({
76
+ compilerOptions: { allowJs: !0 },
77
+ manipulationSettings: { quoteKind: N.Single }
78
+ }).addSourceFileAtPath(e);
79
+ for (;;) {
80
+ let e = !1;
81
+ for (let t of n.getDescendantsOfKind(P.ArrayLiteralExpression)) {
82
+ let n = t.getElements().findIndex((e) => e.getText().replace(/\s/g, "") === "wuchale()");
83
+ if (n >= 0) {
84
+ t.removeElement(n), e = !0;
85
+ break;
86
+ }
87
+ }
88
+ if (!e) break;
89
+ }
90
+ return S(n, "wuchale/vite"), b(n), n.saveSync(), {
91
+ status: "success",
92
+ changed: n.getFullText() !== t
93
+ };
94
+ }
95
+ // src/patterns/disable/i18n/modifies/locales-alias.ts
96
+ var ne = {
97
+ notFound: "No SvelteKit config to revert.",
98
+ failed: "Remove the $locales alias from the sveltekit() arg in vite.config by hand."
99
+ };
100
+ function re(e) {
101
+ let t = i(e, ne);
102
+ if (t.status === "not-found") return {
103
+ filePath: t.filePath,
104
+ outcome: {
105
+ status: "success",
106
+ changed: !1
107
+ }
108
+ };
109
+ if (t.status === "failed") return {
110
+ filePath: t.filePath,
111
+ outcome: {
112
+ status: "failed",
113
+ message: t.message
114
+ }
115
+ };
116
+ let { target: n } = t, r = n.configObject.getProperty("alias")?.asKind(P.PropertyAssignment), o = r?.getInitializer()?.asKind(P.ObjectLiteralExpression), s = o?.getProperties().find((e) => e.getText().replace(/['"]/g, "").startsWith("$locales"));
117
+ return r && o && s && (s.remove(), o.getProperties().length === 0 && r.remove()), {
118
+ filePath: n.filePath,
119
+ outcome: a(n)
120
+ };
121
+ }
122
+ // src/patterns/disable/i18n/modifies/locales-module.ts
123
+ function R(e) {
124
+ let t = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), n = RegExp(`^[$#]locales/${t}(\\.js)?$`);
125
+ return (e) => n.test(e);
126
+ }
127
+ // src/patterns/disable/i18n/modifies/hooks.server.ts
128
+ var z = "handleWuchale", B = w`
129
+ Take handleWuchale out of the exported handle in src/hooks.server.ts, then
130
+ remove its declaration, the loadLocales(...) calls and the wuchale and
131
+ #locales imports.
132
+ `, V = [
133
+ "wuchale/load-utils/server",
134
+ "wuchale/url",
135
+ E("url.ts"),
136
+ E("locale.ts"),
137
+ R("main.url"),
138
+ R("data"),
139
+ R("main.loader.server.svelte"),
140
+ R("js.loader.server")
141
+ ];
142
+ function H(e) {
143
+ if (!A.existsSync(e)) return {
144
+ status: "success",
145
+ changed: !1
146
+ };
147
+ let t = A.readFileSync(e, "utf8");
148
+ if (!t.includes(z) && !t.includes("loadLocales(")) return {
149
+ status: "success",
150
+ changed: !1
151
+ };
152
+ let n = new M({
153
+ compilerOptions: { allowJs: !0 },
154
+ manipulationSettings: { quoteKind: N.Single }
155
+ }).addSourceFileAtPath(e);
156
+ for (;;) {
157
+ let e = n.getStatements().find((e) => e.getKind() === P.ExpressionStatement && /^loadLocales\s*\(/.test(e.getText()));
158
+ if (!e) break;
159
+ e.remove();
160
+ }
161
+ if (T(n, z).status === "unsupported") return {
162
+ status: "failed",
163
+ message: B
164
+ };
165
+ _(n, z);
166
+ for (let e of V) S(n, e);
167
+ return h(n, "@sveltejs/kit/hooks", "sequence"), h(n, "@sveltejs/kit/hooks", "Handle"), h(n, "@sveltejs/kit", "Handle"), b(n), y(n), n.saveSync(), {
168
+ status: "success",
169
+ changed: n.getFullText() !== t
170
+ };
171
+ }
172
+ // src/patterns/disable/i18n/modifies/hooks.ts
173
+ var U = "rerouteDeLocalize", W = w`
174
+ Take rerouteDeLocalize out of the exported reroute in src/hooks.ts, then
175
+ remove its declaration and the wuchale and #locales imports.
176
+ `, G = [
177
+ "wuchale/url",
178
+ R("main.url"),
179
+ R("data")
180
+ ], K = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*rerouteDeLocalize\(\s*url\.pathname\s*\)$/, q = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*rerouteDeLocalize\(\s*negotiateReroute\(\s*url\.pathname\s*\)\s*\)$/;
181
+ function J(e) {
182
+ if (!A.existsSync(e)) return {
183
+ status: "success",
184
+ changed: !1
185
+ };
186
+ let t = A.readFileSync(e, "utf8");
187
+ if (!t.includes(U)) return {
188
+ status: "success",
189
+ changed: !1
190
+ };
191
+ let n = new M({
192
+ compilerOptions: { allowJs: !0 },
193
+ manipulationSettings: { quoteKind: N.Single }
194
+ }).addSourceFileAtPath(e), r = n.getVariableDeclaration(U)?.getFirstAncestorByKind(P.VariableStatement), i = n.getVariableDeclaration("reroute"), a = i?.getInitializer()?.getText() ?? "", o = q.test(a), s = o || K.test(a) ? i?.getFirstAncestorByKind(P.VariableStatement) : void 0;
195
+ return n.getStatements().filter((e) => e !== r && e !== s && e.getText().includes(U)).length > 0 ? {
196
+ status: "failed",
197
+ message: W
198
+ } : (o ? i?.setInitializer("({ url }) => negotiateReroute(url.pathname)") : s && _(n, "reroute"), _(n, U), m(n, G), x(n) ? (A.writeFileSync(e, "", "utf8"), {
199
+ status: "success",
200
+ changed: !0
201
+ }) : (b(n), y(n), n.saveSync(), {
202
+ status: "success",
203
+ changed: n.getFullText() !== t
204
+ }));
205
+ }
206
+ // src/patterns/disable/i18n/modifies/app-html.ts
207
+ function Y(e) {
208
+ if (!A.existsSync(e)) return {
209
+ status: "success",
210
+ changed: !1
211
+ };
212
+ let t = A.readFileSync(e, "utf8"), n = t.replace(/lang\s*=\s*(?:"%sveltekit\.lang%"|'%sveltekit\.lang%')/g, "lang=\"en\"");
213
+ return n === t ? {
214
+ status: "success",
215
+ changed: !1
216
+ } : (A.writeFileSync(e, n, "utf8"), {
217
+ status: "success",
218
+ changed: !0
219
+ });
220
+ }
221
+ // src/patterns/disable/i18n/modifies/+layout.ts
222
+ var ie = w`
223
+ src/routes/+layout.ts still loads wuchale locales. Remove these from it:
224
+
225
+ import { browser } from '$app/env';
226
+ import { loadLocale } from 'wuchale/load-utils';
227
+ import { getLocale } from '#locales/main.url.js';
228
+ import { hasLocalizedUrl } from '#lib/url.js';
229
+ import '#locales/main.loader.svelte.js';
230
+ import '#locales/js.loader.js';
231
+
232
+ and the loadLocale(...) call inside load().
233
+ `, ae = [R("main.loader.svelte"), R("js.loader")], oe = [
234
+ (e) => /^\$app\/env(ironment)?$/.test(e),
235
+ "wuchale/load-utils",
236
+ R("main.url"),
237
+ E("url.ts")
238
+ ], se = [d, u];
239
+ function X(e) {
240
+ return e.replace(/["']/g, "'").replace(/\s+/g, "");
241
+ }
242
+ function ce(e) {
243
+ if (!A.existsSync(e)) return {
244
+ status: "success",
245
+ changed: !1
246
+ };
247
+ let t = A.readFileSync(e, "utf8");
248
+ if (!t.includes("loadLocale") && !/[$#]locales\//.test(t)) return {
249
+ status: "success",
250
+ changed: !1
251
+ };
252
+ let n = new M({
253
+ compilerOptions: { allowJs: !0 },
254
+ manipulationSettings: { quoteKind: N.Single }
255
+ }).addSourceFileAtPath(e), r = n.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "load")) ?? n.getFunction("load");
256
+ if (r) {
257
+ let e = X(r.getText());
258
+ if (!se.some((t) => X(t) === e)) return {
259
+ status: "failed",
260
+ message: ie
261
+ };
262
+ v(n, r);
263
+ }
264
+ for (let e of ae) S(n, e);
265
+ return m(n, oe), x(n) ? (A.writeFileSync(e, "", "utf8"), {
266
+ status: "success",
267
+ changed: !0
268
+ }) : (b(n), y(n), n.saveSync(), {
269
+ status: "success",
270
+ changed: n.getFullText() !== t
271
+ });
272
+ }
273
+ // src/patterns/disable/i18n/modifies/root-layout.svelte.ts
274
+ function le(e) {
275
+ if (!A.existsSync(e)) return {
276
+ status: "success",
277
+ changed: !1
278
+ };
279
+ let t = A.readFileSync(e, "utf8");
280
+ if (!t.includes("LanguageSelect")) return {
281
+ status: "success",
282
+ changed: !1
283
+ };
284
+ let n = D.fromPath(e);
285
+ n.modifyScript((e) => {
286
+ let { source: t } = p(e, (e) => {
287
+ S(e, E("components/language-select.svelte")), y(e);
288
+ });
289
+ return t;
290
+ });
291
+ let r = n.toString();
292
+ return r = r.replace(/[ \t]*<Navbar\.Item>\s*<LanguageSelect\s*\/>\s*<\/Navbar\.Item>[ \t]*\r?\n?/g, ""), r = r.replace(/[ \t]*<LanguageSelect\s*\/>[ \t]*\r?\n?/g, ""), A.writeFileSync(e, r, "utf8"), {
293
+ status: "success",
294
+ changed: r !== t
295
+ };
296
+ }
297
+ // src/patterns/disable/i18n/modifies/layout.server.ts
298
+ var Z = (e) => e.replace(/["']/g, "'").replace(/\s+/g, ""), ue = /^[ \t]*\/\/ Decided on the server \(src\/hooks\.server\.ts\), because pages without a\r?\n[ \t]*\/\/ language in their URL follow the visitor's preference\.\r?\n/m, de = "src/routes/+layout.server.ts still returns `locale: locals.locale`. Remove it from the load.";
299
+ function fe(e) {
300
+ if (!A.existsSync(e)) return {
301
+ status: "success",
302
+ changed: !1
303
+ };
304
+ let t = A.readFileSync(e, "utf8");
305
+ if (!t.includes("locals.locale")) return {
306
+ status: "success",
307
+ changed: !1
308
+ };
309
+ if (Z(t) === Z(s)) return A.writeFileSync(e, "", "utf8"), {
310
+ status: "success",
311
+ changed: !0
312
+ };
313
+ let { source: n } = p(t.replace(ue, ""), (e) => {
314
+ let t = (O(e) ?? e).getDescendantsOfKind(P.PropertyAssignment).filter((e) => e.getName() === "locale" && /(^|\.)locals\.locale$/.test(e.getInitializer()?.getText() ?? ""));
315
+ for (let e of t) {
316
+ let t = e.getParent();
317
+ e.remove(), te.isObjectLiteralExpression(t) && t.getProperties().length === 0 && t.replaceWithText("{}");
318
+ }
319
+ g(e, "locals");
320
+ });
321
+ return n === t ? {
322
+ status: "failed",
323
+ message: de
324
+ } : (A.writeFileSync(e, n, "utf8"), {
325
+ status: "success",
326
+ changed: n !== t
327
+ });
328
+ }
329
+ // src/patterns/disable/i18n/modifies/app-d-ts.ts
330
+ var Q = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $ = RegExp(`(?:^[ \\t]*${Q(f)}[ \\t]*\\r?\\n)?^[ \\t]*${Q(l)}[ \\t]*\\r?\\n`, "m"), pe = /^([ \t]*)interface Locals\s*\{\s*\}/m;
331
+ function me(e) {
332
+ if (!A.existsSync(e)) return {
333
+ status: "success",
334
+ changed: !1
335
+ };
336
+ let t = A.readFileSync(e, "utf8");
337
+ if (!$.test(t)) return {
338
+ status: "success",
339
+ changed: !1
340
+ };
341
+ let n = t.replace($, "").replace(pe, "$1// interface Locals {}");
342
+ return A.writeFileSync(e, n, "utf8"), {
343
+ status: "success",
344
+ changed: !0
345
+ };
346
+ }
347
+ // src/patterns/disable/i18n/modifies/app-layout.svelte.ts
348
+ function he(e) {
349
+ if (!A.existsSync(e)) return {
350
+ status: "success",
351
+ changed: !1
352
+ };
353
+ let t = A.readFileSync(e, "utf8");
354
+ if (!t.includes("LanguageSelect")) return {
355
+ status: "success",
356
+ changed: !1
357
+ };
358
+ let n = D.fromPath(e);
359
+ n.modifyScript((e) => {
360
+ let { source: t } = p(e, (e) => {
361
+ S(e, E("components/language-select.svelte")), y(e);
362
+ });
363
+ return t;
364
+ });
365
+ let r = n.toString().replace(k, "").replace(/[ \t]*<LanguageSelect\s*\/>[ \t]*\r?\n?/g, "");
366
+ return A.writeFileSync(e, r, "utf8"), {
367
+ status: "success",
368
+ changed: r !== t
369
+ };
370
+ }
371
+ // src/patterns/disable/i18n/generate.runtime.ts
372
+ async function ge(i) {
373
+ let a = e(i), s = [], l = [], u = (e) => {
374
+ e && s.push(e);
375
+ };
376
+ a.info("Reverting vite.config");
377
+ let d = r(i.root, o) ?? j.join(i.root, o[0]);
378
+ u(n(d, L(d))), a.info("Removing #locales from package.json imports");
379
+ let f = C(i.root, Object.keys(c), c);
380
+ u(n(f.filePath, f.outcome)), a.info("Reverting the legacy $locales alias");
381
+ let p = re(i.root);
382
+ u(n(p.filePath, p.outcome)), a.info("Reverting hooks.server.ts");
383
+ let m = j.join(i.root, "src", "hooks.server.ts"), h = t(m, H(m));
384
+ u(h.modify), h.delete && l.push(h.delete), a.info("Reverting hooks.ts");
385
+ let g = j.join(i.root, "src", "hooks.ts"), _ = t(g, J(g));
386
+ u(_.modify), _.delete && l.push(_.delete), a.info("Reverting app.html");
387
+ let v = j.join(i.root, "src", "app.html");
388
+ u(n(v, Y(v))), a.info("Reverting root +layout.ts");
389
+ let y = j.join(i.root, "src", "routes", "+layout.ts"), b = t(y, ce(y));
390
+ u(b.modify), b.delete && l.push(b.delete), a.info("Reverting root +layout.server.ts");
391
+ let x = j.join(i.root, "src", "routes", "+layout.server.ts"), S = t(x, fe(x));
392
+ u(S.modify), S.delete && l.push(S.delete), a.info("Reverting app.d.ts");
393
+ let w = j.join(i.root, "src", "app.d.ts");
394
+ u(n(w, me(w))), a.info("Reverting the signed-in layout language select");
395
+ let T = j.join(i.root, ee);
396
+ u(n(T, he(T))), a.info("Reverting root layout language select");
397
+ let E = [
398
+ j.join(i.root, "src", "routes", "(public)", "root-layout.svelte"),
399
+ j.join(i.root, "src", "routes", "root-layout.svelte"),
400
+ j.join(i.root, "src", "routes", "(public)", "+layout.svelte"),
401
+ j.join(i.root, "src", "routes", "+layout.svelte")
402
+ ];
403
+ for (let e of E) A.existsSync(e) && u(n(e, le(e)));
404
+ a.info("Reverting .gitignore");
405
+ let D = j.join(i.root, ".gitignore");
406
+ u(n(D, F(D))), a.info("Reverting .prettierignore");
407
+ let O = j.join(i.root, ".prettierignore");
408
+ u(n(O, I(O))), a.info("Removing wuchale's loaders from src/locales");
409
+ let k = j.join(i.root, "src", "locales");
410
+ if (A.existsSync(k)) for (let e of A.readdirSync(k, { withFileTypes: !0 })) e.isFile() && e.name.endsWith(".js") && l.push({
411
+ path: j.join(k, e.name),
412
+ language: "js",
413
+ content: "",
414
+ status: "success"
415
+ });
416
+ return {
417
+ creates: [],
418
+ modifies: s,
419
+ deletes: l,
420
+ components: [],
421
+ packages: [],
422
+ collections: [],
423
+ collectionPatches: [],
424
+ collectionDrops: []
425
+ };
426
+ }
427
+ export { ge as generate };
428
+
429
+ //# sourceMappingURL=generate.runtime-DZUPtJVF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-DZUPtJVF.js","names":["FAILURE_HINT","I18N_MODULES","FAILURE_HINT","FAILURE_HINT","normalize","getLogger","revertOutcomeToFile","modifyOutcomeToFile","probeFirstExisting","resolveConfigTarget","saveTarget","VITE_CONFIG_CANDIDATES","LAYOUT_SERVER_SNIPPET","LOCALES_IMPORTS","LOCALS_MEMBER","LEGACY_LOAD_STATEMENT","LOAD_STATEMENT","LOCALS_COMMENT","withInMemoryScript","pruneUnusedImports","removeNamedImportIfUnused","removeTopLevelStatementByIdentifier","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","isEffectivelyEmpty","removeImportByModuleSpecifier","removePackageImports","dedent","removeHandle","libModule","SvelteFile","findLoadFunction","APP_LAYOUT_PATH","APP_LANGUAGE_SELECT","fs","path","unmodifyGitignore","gitignorePath","original","lines","out","i","line","j","hasWuchale","updated","unmodifyPrettierignore","filePath","at","index","unmodifyViteConfig","viteConfigPath","sourceFile","Project","QuoteKind","removed","arr","SyntaxKind","el","HINTS","unmodifyLocalesAlias","res","root","aliasProp","target","aliasObj","locales","p","localesModule","escaped","name","pattern","specifier","I18N_HANDLE","FAILURE_HINT$3","I18N_MODULES$1","unmodifyHooksServerI18n","hooksServerPath","stmt","s","moduleSpecifier","DELOCALIZE_HELPER","FAILURE_HINT$2","I18N_MODULES","I18N_ONLY_REROUTE","COMPOSED_REROUTE","unmodifyHooksI18n","hooksPath","helperStatement","rerouteDecl","initText","composed","rerouteStatement","unmodifyAppHtml","appHtmlPath","FAILURE_HINT$1","SIDE_EFFECT_MODULES","BINDING_MODULES","WRITTEN_LOADS","normalize$1","source","unmodifyRootLayoutI18n","layoutPath","loadStatement","d","load","written","unmodifyRootLayoutLanguageSelect","file","sf","normalize","LOCALE_COMMENT","FAILURE_HINT","unmodifyLayoutServerLocale","layoutServerPath","properties","property","object","Node","escape","text","MEMBER","EMPTY_LOCALS","unmodifyAppDts","appDtsPath","unmodifyAppLayoutLanguageSelect","generate","logger","options","modifies","deletes","pushResult","imports","alias","hooksServerRevert","hooksRevert","layoutRevert","layoutServerRevert","appLayoutPath","rootLayoutCandidates","candidate","prettierignorePath","localesDir","entry"],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/modifies/prettierignore.ts","../../src/patterns/disable/i18n/modifies/vite-config.ts","../../src/patterns/disable/i18n/modifies/locales-alias.ts","../../src/patterns/disable/i18n/modifies/locales-module.ts","../../src/patterns/disable/i18n/modifies/hooks.server.ts","../../src/patterns/disable/i18n/modifies/hooks.ts","../../src/patterns/disable/i18n/modifies/app-html.ts","../../src/patterns/disable/i18n/modifies/+layout.ts","../../src/patterns/disable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/disable/i18n/modifies/layout.server.ts","../../src/patterns/disable/i18n/modifies/app-d-ts.ts","../../src/patterns/disable/i18n/modifies/app-layout.svelte.ts","../../src/patterns/disable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\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 lines = original.split(\"\\n\");\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === \"# Wuchale\") {\n let j = i + 1;\n let hasWuchale = false;\n while (j < lines.length && lines[j].trim() !== \"\") {\n if (lines[j] === \"src/locales/.wuchale\") {\n hasWuchale = true;\n }\n j++;\n }\n if (hasWuchale) {\n i = j;\n continue;\n }\n }\n if (line === \"src/locales/.wuchale\") continue;\n out.push(line);\n }\n\n let updated = out.join(\"\\n\");\n updated = updated.replace(/\\n{3,}/g, \"\\n\\n\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n LOCALES_ENTRY,\n PRETTIERIGNORE_HEADER,\n} from \"../../../enable/i18n/modifies/prettierignore\";\n\n/** Removes the block enable-i18n appended; an entry the project wrote itself stays. */\nexport function unmodifyPrettierignore(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n const lines = original.split(\"\\n\");\n const at = lines.findIndex(\n (line, index) =>\n line === PRETTIERIGNORE_HEADER && lines[index + 1] === LOCALES_ENTRY,\n );\n if (at === -1) {\n return { status: \"success\", changed: false };\n }\n\n lines.splice(at, 2);\n // The blank line that set the block apart goes with it.\n if (at > 0 && lines[at - 1] === \"\" && (lines[at] ?? \"\") === \"\") {\n lines.splice(at - 1, 1);\n }\n fs.writeFileSync(filePath, lines.join(\"\\n\"));\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** Remove `wuchale()` from the Vite plugins and its import. */\nexport function unmodifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(viteConfigPath, \"utf8\");\n if (!original.includes(\"wuchale\")) {\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(viteConfigPath);\n\n // One removal at a time: manipulating the tree invalidates sibling nodes.\n for (;;) {\n let removed = false;\n for (const arr of sourceFile.getDescendantsOfKind(\n SyntaxKind.ArrayLiteralExpression,\n )) {\n const index = arr\n .getElements()\n .findIndex((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n if (index >= 0) {\n arr.removeElement(index);\n removed = true;\n break;\n }\n }\n if (!removed) break;\n }\n\n removeImportByModuleSpecifier(sourceFile, \"wuchale/vite\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import { SyntaxKind } from \"ts-morph\";\nimport {\n resolveConfigTarget,\n saveTarget,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\n\nconst HINTS = {\n notFound: \"No SvelteKit config to revert.\",\n failed:\n \"Remove the $locales alias from the sveltekit() arg in vite.config by hand.\",\n};\n\n/**\n * Remove the `$locales` alias enable-i18n wrote before SvelteKit 3, which\n * `sv migrate sveltekit-3` moves into the inline `sveltekit({...})` arg;\n * `alias` goes too once it is empty. Projects enabled since then map\n * `#locales/*` in package.json `imports` instead.\n */\nexport function unmodifyLocalesAlias(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, HINTS);\n // Nothing to revert in a project without a config.\n if (res.status === \"not-found\") {\n return {\n filePath: res.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n if (res.status === \"failed\") {\n return {\n filePath: res.filePath,\n outcome: { status: \"failed\", message: res.message },\n };\n }\n\n const { target } = res;\n const aliasProp = target.configObject\n .getProperty(\"alias\")\n ?.asKind(SyntaxKind.PropertyAssignment);\n const aliasObj = aliasProp\n ?.getInitializer()\n ?.asKind(SyntaxKind.ObjectLiteralExpression);\n const locales = aliasObj\n ?.getProperties()\n .find((p) => p.getText().replace(/['\"]/g, \"\").startsWith(\"$locales\"));\n if (aliasProp && aliasObj && locales) {\n locales.remove();\n if (aliasObj.getProperties().length === 0) aliasProp.remove();\n }\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n","/**\n * Matches an import of wuchale's `src/locales/<name>.js` the way enable-i18n\n * writes it (`#locales/main.url.js`), and the `$locales/main.url` alias form\n * it wrote before SvelteKit 3, so disabling works on either.\n */\nexport function localesModule(name: string): (specifier: string) => boolean {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const pattern = new RegExp(`^[$#]locales/${escaped}(\\\\.js)?$`);\n return (specifier) => pattern.test(specifier);\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removeNamedImportIfUnused,\n removeTopLevelStatementByIdentifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport { localesModule } from \"./locales-module\";\n\nconst I18N_HANDLE = \"handleWuchale\";\nconst FAILURE_HINT = dedent`\n Take handleWuchale out of the exported handle in src/hooks.server.ts, then\n remove its declaration, the loadLocales(...) calls and the wuchale and\n #locales imports.\n`;\n\nconst I18N_MODULES = [\n \"wuchale/load-utils/server\",\n // Since the handle follows the visitor's preference on pages without a\n // language in their URL; a project enabled before has none of the three.\n \"wuchale/url\",\n libModule(\"url.ts\"),\n libModule(\"locale.ts\"),\n localesModule(\"main.url\"),\n localesModule(\"data\"),\n localesModule(\"main.loader.server.svelte\"),\n localesModule(\"js.loader.server\"),\n];\n\n/**\n * Undo `modifyHooksServerI18n`: drop the locale bootstrap, the wuchale handle\n * and its imports, and unwrap `sequence(handleWuchale, ...)`. A file that\n * enable-i18n created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerI18n(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(I18N_HANDLE) && !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 // loadLocales(...) bootstrap calls, one at a time (removal invalidates siblings).\n for (;;) {\n const stmt = sourceFile\n .getStatements()\n .find(\n (s) =>\n s.getKind() === SyntaxKind.ExpressionStatement &&\n /^loadLocales\\s*\\(/.test(s.getText()),\n );\n if (!stmt) break;\n stmt.remove();\n }\n\n // `export const handle = handleWuchale` goes altogether; a sequence loses\n // the argument, or unwraps to the handle it composed with.\n const removed = removeHandle(sourceFile, I18N_HANDLE);\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, I18N_HANDLE);\n for (const moduleSpecifier of I18N_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"Handle\");\n // A project from before SvelteKit 3 imports it from the package root.\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit\", \"Handle\");\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureBlankLineAfterImports,\n isEffectivelyEmpty,\n pruneUnusedImports,\n removeTopLevelStatementByIdentifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { localesModule } from \"./locales-module\";\n\nconst DELOCALIZE_HELPER = \"rerouteDeLocalize\";\n\nconst FAILURE_HINT = dedent`\n Take rerouteDeLocalize out of the exported reroute in src/hooks.ts, then\n remove its declaration and the wuchale and #locales imports.\n`;\n\nconst I18N_MODULES = [\n \"wuchale/url\",\n localesModule(\"main.url\"),\n localesModule(\"data\"),\n];\n\n/** The two reroutes `modifyHooksI18n` writes: on its own, and composed. */\nconst I18N_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*rerouteDeLocalize\\(\\s*url\\.pathname\\s*\\)$/;\nconst COMPOSED_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*rerouteDeLocalize\\(\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)\\s*\\)$/;\n\n/**\n * Undo `modifyHooksI18n`: drop the de-localizer and its imports, leaving the\n * negotiation reroute it may have been composed with. A file that enable-i18n\n * created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (!original.includes(DELOCALIZE_HELPER)) {\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 helperStatement = sourceFile\n .getVariableDeclaration(DELOCALIZE_HELPER)\n ?.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const initText = rerouteDecl?.getInitializer()?.getText() ?? \"\";\n const composed = COMPOSED_REROUTE.test(initText);\n const rerouteStatement =\n composed || I18N_ONLY_REROUTE.test(initText)\n ? rerouteDecl?.getFirstAncestorByKind(SyntaxKind.VariableStatement)\n : undefined;\n\n // Anything else reading the de-localizer is code enable-i18n did not write,\n // so undoing it is the developer's call.\n const otherReaders = sourceFile\n .getStatements()\n .filter(\n (s) =>\n s !== helperStatement &&\n s !== rerouteStatement &&\n s.getText().includes(DELOCALIZE_HELPER),\n );\n if (otherReaders.length > 0) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (composed) {\n // content-negotiation's reroute is underneath; it stays.\n rerouteDecl?.setInitializer(\"({ url }) => negotiateReroute(url.pathname)\");\n } else if (rerouteStatement) {\n removeTopLevelStatementByIdentifier(sourceFile, \"reroute\");\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, DELOCALIZE_HELPER);\n pruneUnusedImports(sourceFile, I18N_MODULES);\n\n if (isEffectivelyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty hooks.ts into a\n // delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(hooksPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Put a real language back. `%sveltekit.lang%` is not a SvelteKit\n * placeholder; only the wuchale hook replaced it, so without that hook it\n * would be served literally.\n */\nexport function unmodifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n const updated = original.replace(\n /lang\\s*=\\s*(?:\"%sveltekit\\.lang%\"|'%sveltekit\\.lang%')/g,\n 'lang=\"en\"',\n );\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(appHtmlPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type Statement } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n LEGACY_LOAD_STATEMENT,\n LOAD_STATEMENT,\n} from \"../../../enable/i18n/modifies/+layout\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport {\n ensureBlankLineAfterImports,\n isEffectivelyEmpty,\n pruneUnusedImports,\n removeImportByModuleSpecifier,\n removeStatementWithComments,\n formatLikeSource,\n type ModuleMatch,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { localesModule } from \"./locales-module\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.ts still loads wuchale locales. Remove these from it:\n\n import { browser } from '$app/env';\n import { loadLocale } from 'wuchale/load-utils';\n import { getLocale } from '#locales/main.url.js';\n import { hasLocalizedUrl } from '#lib/url.js';\n import '#locales/main.loader.svelte.js';\n import '#locales/js.loader.js';\n\n and the loadLocale(...) call inside load().\n`;\n\nconst SIDE_EFFECT_MODULES = [\n localesModule(\"main.loader.svelte\"),\n localesModule(\"js.loader\"),\n];\nconst BINDING_MODULES: ModuleMatch[] = [\n // `$app/env`, or the module it replaced before SvelteKit 3.\n (specifier) => /^\\$app\\/env(ironment)?$/.test(specifier),\n \"wuchale/load-utils\",\n localesModule(\"main.url\"),\n libModule(\"url.ts\"),\n];\n\n/** The loads enable-i18n has written: today's, and the URL-only one before it. */\nconst WRITTEN_LOADS = [LOAD_STATEMENT, LEGACY_LOAD_STATEMENT];\n\nfunction normalize(source: string): string {\n return source.replace(/[\"']/g, \"'\").replace(/\\s+/g, \"\");\n}\n\n/**\n * Undo `ensureRootLayoutI18n`: drop the wuchale load and its imports, leaving\n * whatever else the file holds. A file enable-i18n wrote whole comes out\n * empty, for the caller to delete.\n */\nexport function unmodifyRootLayoutI18n(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"loadLocale\") && !/[$#]locales\\//.test(original)) {\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(layoutPath);\n\n const loadStatement: Statement | undefined =\n sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"load\")) ??\n sourceFile.getFunction(\"load\");\n\n if (loadStatement) {\n // A load that grew code of its own needs a hand; only the one enable-i18n\n // wrote is safe to take out wholesale.\n const load = normalize(loadStatement.getText());\n if (!WRITTEN_LOADS.some((written) => normalize(written) === load)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n removeStatementWithComments(sourceFile, loadStatement);\n }\n\n for (const moduleSpecifier of SIDE_EFFECT_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n pruneUnusedImports(sourceFile, BINDING_MODULES);\n\n if (isEffectivelyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty +layout.ts into\n // a delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(layoutPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\n/** Take the language select (and the nav item enable-i18n wrapped it in) back out. */\nexport function unmodifyRootLayoutLanguageSelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/language-select.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<LanguageSelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<LanguageSelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { LAYOUT_SERVER_SNIPPET } from \"../../../enable/i18n/modifies/layout.server\";\nimport { Node, SyntaxKind } from \"ts-morph\";\nimport { findLoadFunction } from \"../../../../runtime/load-function\";\nimport {\n removeUnusedBindingElement,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst normalize = (source: string) =>\n source.replace(/[\"']/g, \"'\").replace(/\\s+/g, \"\");\n\n/** The comment enable-i18n put above the property, on its own lines. */\nconst LOCALE_COMMENT =\n /^[ \\t]*\\/\\/ Decided on the server \\(src\\/hooks\\.server\\.ts\\), because pages without a\\r?\\n[ \\t]*\\/\\/ language in their URL follow the visitor's preference\\.\\r?\\n/m;\n\nconst FAILURE_HINT =\n \"src/routes/+layout.server.ts still returns `locale: locals.locale`. Remove it from the load.\";\n\n/**\n * Undo `modifyLayoutServerLocale`: the root layout's server load stops\n * returning `locale`. A file enable-i18n wrote whole comes out empty, for the\n * caller to delete.\n */\nexport function unmodifyLayoutServerLocale(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.locale\")) {\n return { status: \"success\", changed: false };\n }\n\n if (normalize(original) === normalize(LAYOUT_SERVER_SNIPPET)) {\n fs.writeFileSync(layoutServerPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n // The comment first: left above a removed property it would attach itself\n // to whatever follows.\n const { source } = withInMemoryScript(\n original.replace(LOCALE_COMMENT, \"\"),\n (sf) => {\n const load = findLoadFunction(sf);\n const properties = (load ?? sf)\n .getDescendantsOfKind(SyntaxKind.PropertyAssignment)\n .filter(\n (property) =>\n property.getName() === \"locale\" &&\n /(^|\\.)locals\\.locale$/.test(\n property.getInitializer()?.getText() ?? \"\",\n ),\n );\n for (const property of properties) {\n const object = property.getParent();\n property.remove();\n // `return {}` reads worse on three lines than on one.\n if (\n Node.isObjectLiteralExpression(object) &&\n object.getProperties().length === 0\n ) {\n object.replaceWithText(\"{}\");\n }\n }\n removeUnusedBindingElement(sf, \"locals\");\n },\n );\n if (source === original) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.writeFileSync(layoutServerPath, source, \"utf8\");\n return { status: \"success\", changed: source !== original };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n LOCALS_COMMENT,\n LOCALS_MEMBER,\n} from \"../../../enable/i18n/modifies/app-d-ts\";\n\nconst escape = (text: string) => text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nconst MEMBER = new RegExp(\n `(?:^[ \\\\t]*${escape(LOCALS_COMMENT)}[ \\\\t]*\\\\r?\\\\n)?^[ \\\\t]*${escape(LOCALS_MEMBER)}[ \\\\t]*\\\\r?\\\\n`,\n \"m\",\n);\n\n/** An `interface Locals` left with nothing in it. */\nconst EMPTY_LOCALS = /^([ \\t]*)interface Locals\\s*\\{\\s*\\}/m;\n\n/**\n * Undo `modifyAppDts`: `App.Locals` loses `locale`, and an interface left\n * empty goes back to the comment `sv create` writes.\n */\nexport function unmodifyAppDts(appDtsPath: string): ModifyOutcome {\n if (!fs.existsSync(appDtsPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(appDtsPath, \"utf8\");\n if (!MEMBER.test(original)) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original\n .replace(MEMBER, \"\")\n .replace(EMPTY_LOCALS, \"$1// interface Locals {}\");\n fs.writeFileSync(appDtsPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\nimport { APP_LANGUAGE_SELECT } from \"../../../enable/i18n/modifies/app-layout.svelte\";\n\n/** Take the language select back out of the signed-in layout's header. */\nexport function unmodifyAppLayoutLanguageSelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/language-select.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n const updated = file\n .toString()\n .replace(APP_LANGUAGE_SELECT, \"\")\n // Moved out of the wrapper by hand: the component alone still goes.\n .replace(/[ \\t]*<LanguageSelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\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 {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\nimport { unmodifyPrettierignore } from \"./modifies/prettierignore\";\nimport { unmodifyViteConfig } from \"./modifies/vite-config\";\nimport { unmodifyLocalesAlias } from \"./modifies/locales-alias\";\nimport { removePackageImports } from \"../../../runtime/package-imports\";\nimport { LOCALES_IMPORTS } from \"../../enable/i18n/modifies/package-imports\";\nimport { unmodifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { unmodifyHooksI18n } from \"./modifies/hooks\";\nimport { unmodifyAppHtml } from \"./modifies/app-html\";\nimport { unmodifyRootLayoutI18n } from \"./modifies/+layout\";\nimport { unmodifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { unmodifyLayoutServerLocale } from \"./modifies/layout.server\";\nimport { unmodifyAppDts } from \"./modifies/app-d-ts\";\nimport { unmodifyAppLayoutLanguageSelect } from \"./modifies/app-layout.svelte\";\nimport { APP_LAYOUT_PATH } from \"../../enable/i18n/modifies/app-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting 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, unmodifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Removing #locales from package.json imports\");\n // Only while it still maps where enable-i18n pointed it.\n const imports = removePackageImports(\n options.root,\n Object.keys(LOCALES_IMPORTS),\n LOCALES_IMPORTS,\n );\n pushResult(modifyOutcomeToFile(imports.filePath, imports.outcome));\n\n // A project enabled before SvelteKit 3 has the `$locales` alias instead,\n // moved into the sveltekit() arg by `vela migrate sveltekit-3`.\n logger.info(\"Reverting the legacy $locales alias\");\n const alias = unmodifyLocalesAlias(options.root);\n pushResult(modifyOutcomeToFile(alias.filePath, alias.outcome));\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // enable-i18n may have created it; emptied, it goes.\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerI18n(hooksServerPath),\n );\n pushResult(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n logger.info(\"Reverting hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n // The de-localizing reroute may be all it holds; emptied, it goes.\n const hooksRevert = revertOutcomeToFile(\n hooksPath,\n unmodifyHooksI18n(hooksPath),\n );\n pushResult(hooksRevert.modify);\n if (hooksRevert.delete) deletes.push(hooksRevert.delete);\n\n logger.info(\"Reverting app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, unmodifyAppHtml(appHtmlPath)));\n\n logger.info(\"Reverting root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n // enable-i18n may have written the whole file; emptied, it goes.\n const layoutRevert = revertOutcomeToFile(\n layoutPath,\n unmodifyRootLayoutI18n(layoutPath),\n );\n pushResult(layoutRevert.modify);\n if (layoutRevert.delete) deletes.push(layoutRevert.delete);\n\n logger.info(\"Reverting root +layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n // enable-i18n may have written the whole file; emptied, it goes.\n const layoutServerRevert = revertOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerLocale(layoutServerPath),\n );\n pushResult(layoutServerRevert.modify);\n if (layoutServerRevert.delete) deletes.push(layoutServerRevert.delete);\n\n logger.info(\"Reverting app.d.ts\");\n const appDtsPath = path.join(options.root, \"src\", \"app.d.ts\");\n pushResult(modifyOutcomeToFile(appDtsPath, unmodifyAppDts(appDtsPath)));\n\n logger.info(\"Reverting the signed-in layout language select\");\n const appLayoutPath = path.join(options.root, APP_LAYOUT_PATH);\n pushResult(\n modifyOutcomeToFile(\n appLayoutPath,\n unmodifyAppLayoutLanguageSelect(appLayoutPath),\n ),\n );\n\n logger.info(\"Reverting 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 for (const candidate of rootLayoutCandidates) {\n if (!fs.existsSync(candidate)) continue;\n pushResult(\n modifyOutcomeToFile(\n candidate,\n unmodifyRootLayoutLanguageSelect(candidate),\n ),\n );\n }\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, unmodifyGitignore(gitignorePath)),\n );\n\n logger.info(\"Reverting .prettierignore\");\n const prettierignorePath = path.join(options.root, \".prettierignore\");\n pushResult(\n modifyOutcomeToFile(\n prettierignorePath,\n unmodifyPrettierignore(prettierignorePath),\n ),\n );\n\n // wuchale's loaders import the packages this uninstalls, and without the\n // .prettierignore block they would fail the project's lint. The catalogs\n // (.po) beside them are the translations, and stay.\n logger.info(\"Removing wuchale's loaders from src/locales\");\n const localesDir = path.join(options.root, \"src\", \"locales\");\n if (fs.existsSync(localesDir)) {\n for (const entry of fs.readdirSync(localesDir, { withFileTypes: true })) {\n if (!entry.isFile() || !entry.name.endsWith(\".js\")) continue;\n deletes.push({\n path: path.join(localesDir, entry.name),\n language: \"js\",\n content: \"\",\n status: \"success\",\n });\n }\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":";;;;;;;;;;;;;;;;AAGA,SAAgBqC,EAAkB,GAAsC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAa,GAC9B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWJ,EAAG,aAAaG,GAAe,MAAM;CACtD,IAAI,CAACC,EAAS,SAAS,sBAAsB,GAC3C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAQD,EAAS,MAAM,IAAI,GAC3BE,IAAgB,CAAC;CACvB,KAAK,IAAIC,IAAI,GAAGA,IAAIF,EAAM,QAAQ,KAAK;EACrC,IAAMG,IAAOH,EAAME;EACnB,IAAIC,MAAS,aAAa;GACxB,IAAIC,IAAIF,IAAI,GACRG,IAAa;GACjB,OAAOD,IAAIJ,EAAM,UAAUA,EAAMI,EAAE,CAAC,KAAK,MAAM,KAI7C,AAHIJ,EAAMI,OAAO,2BACf,IAAa,KAEf;GAEF,IAAIC,GAAY;IACd,IAAID;IACJ;GACF;EACF;EACA,AAAID,MAAS,0BACbF,EAAI,KAAKE,C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2.js";
2
2
  import { r as t } from "./modify-file-CRZ_gMg0.js";
3
- import { c as n, i as r, n as i, o as a, r as o, t as s } from "./test-setup-cZj1tqaf.js";
3
+ import { c as n, i as r, n as i, o as a, r as o, t as s } from "./test-setup-gJdzWWs_.js";
4
4
  import { a as c } from "./util-ILWdjRAd.js";
5
5
  import { t as l } from "./dedent-CCUOcPFW.js";
6
6
  import { r as u } from "./compose-handle-Da7m6lV_.js";
@@ -158,4 +158,4 @@ async function k(l) {
158
158
  }
159
159
  export { k as generate };
160
160
 
161
- //# sourceMappingURL=generate.runtime-C_SdcnRs.js.map
161
+ //# sourceMappingURL=generate.runtime-Db7JwGTb.js.map