@velastack/patterns 0.2.12 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/chunks/{collections-CcL5bbBk.js → collections-CgdvZXmh.js} +17 -17
- package/dist/chunks/{collections-CcL5bbBk.js.map → collections-CgdvZXmh.js.map} +1 -1
- package/dist/chunks/{compose-handle-D16KmBVd.js → compose-handle-Cg9jnCsS.js} +21 -21
- package/dist/chunks/{compose-handle-D16KmBVd.js.map → compose-handle-Cg9jnCsS.js.map} +1 -1
- package/dist/chunks/dispatch-BRnt8PcW.js +6 -0
- package/dist/chunks/dispatch-BRnt8PcW.js.map +1 -0
- package/dist/chunks/generate-BkQ1xMDp.js +30 -0
- package/dist/chunks/generate-BkQ1xMDp.js.map +1 -0
- package/dist/chunks/{generate-Va1sxVPG.js → generate-DRA63W0r.js} +17 -64
- package/dist/chunks/generate-DRA63W0r.js.map +1 -0
- package/dist/chunks/generate-_LvrYK6i.js +55 -0
- package/dist/chunks/generate-_LvrYK6i.js.map +1 -0
- package/dist/chunks/generate-iQP31-m1.js +252 -0
- package/dist/chunks/generate-iQP31-m1.js.map +1 -0
- package/dist/chunks/{generate.runtime-j1gfY6Xq.js → generate.runtime-B0hhtyAL.js} +2 -2
- package/dist/chunks/{generate.runtime-j1gfY6Xq.js.map → generate.runtime-B0hhtyAL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CSXj-ebM.js → generate.runtime-B49wetSx.js} +12 -12
- package/dist/chunks/{generate.runtime-CSXj-ebM.js.map → generate.runtime-B49wetSx.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DAkg7Fy5.js → generate.runtime-B7LRx-BU.js} +2 -2
- package/dist/chunks/{generate.runtime-DAkg7Fy5.js.map → generate.runtime-B7LRx-BU.js.map} +1 -1
- package/dist/chunks/generate.runtime-BKo-Nidn.js +38 -0
- package/dist/chunks/generate.runtime-BKo-Nidn.js.map +1 -0
- package/dist/chunks/{generate.runtime-Zh5n8XpR.js → generate.runtime-BORbegw_.js} +106 -96
- package/dist/chunks/generate.runtime-BORbegw_.js.map +1 -0
- package/dist/chunks/{generate.runtime-BL7uKgW7.js → generate.runtime-BbIN0tUZ.js} +16 -16
- package/dist/chunks/{generate.runtime-BL7uKgW7.js.map → generate.runtime-BbIN0tUZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CwzHEcKv.js → generate.runtime-BnWE4qsu.js} +24 -24
- package/dist/chunks/generate.runtime-BnWE4qsu.js.map +1 -0
- package/dist/chunks/{generate.runtime-CiTmbkAk.js → generate.runtime-BwhGDnGu.js} +3 -3
- package/dist/chunks/generate.runtime-BwhGDnGu.js.map +1 -0
- package/dist/chunks/{generate.runtime-BdPtilz4.js → generate.runtime-CCg2Pjcv.js} +13 -13
- package/dist/chunks/{generate.runtime-BdPtilz4.js.map → generate.runtime-CCg2Pjcv.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BbNMkG4j.js → generate.runtime-CRYjWJRe.js} +9 -9
- package/dist/chunks/{generate.runtime-BbNMkG4j.js.map → generate.runtime-CRYjWJRe.js.map} +1 -1
- package/dist/chunks/generate.runtime-CcuAXuV2.js +60 -0
- package/dist/chunks/generate.runtime-CcuAXuV2.js.map +1 -0
- package/dist/chunks/{generate.runtime-DPIH5sSI.js → generate.runtime-D0icLb5j.js} +51 -48
- package/dist/chunks/{generate.runtime-DPIH5sSI.js.map → generate.runtime-D0icLb5j.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CJVy-mMN.js → generate.runtime-D2e_KRj0.js} +2 -2
- package/dist/chunks/{generate.runtime-CJVy-mMN.js.map → generate.runtime-D2e_KRj0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DnWw9tL1.js → generate.runtime-D44gjxRA.js} +105 -102
- package/dist/chunks/generate.runtime-D44gjxRA.js.map +1 -0
- package/dist/chunks/{generate.runtime-1gbaOucO.js → generate.runtime-D8vgh5MH.js} +48 -7
- package/dist/chunks/generate.runtime-D8vgh5MH.js.map +1 -0
- package/dist/chunks/generate.runtime-DAmYsIvF.js +32 -0
- package/dist/chunks/generate.runtime-DAmYsIvF.js.map +1 -0
- package/dist/chunks/{generate.runtime-CVLtEsXb.js → generate.runtime-DNaQxed-.js} +35 -35
- package/dist/chunks/{generate.runtime-CVLtEsXb.js.map → generate.runtime-DNaQxed-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-d9HT4v-7.js → generate.runtime-DOuufRLr.js} +4 -4
- package/dist/chunks/generate.runtime-DOuufRLr.js.map +1 -0
- package/dist/chunks/{generate.runtime-A8wfItN7.js → generate.runtime-DSqkXvps.js} +12 -12
- package/dist/chunks/{generate.runtime-A8wfItN7.js.map → generate.runtime-DSqkXvps.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BX53l-rL.js → generate.runtime-DhkaXTq3.js} +3 -3
- package/dist/chunks/{generate.runtime-BX53l-rL.js.map → generate.runtime-DhkaXTq3.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dywp4xth.js → generate.runtime-DoZdSh9W.js} +2 -2
- package/dist/chunks/{generate.runtime-Dywp4xth.js.map → generate.runtime-DoZdSh9W.js.map} +1 -1
- package/dist/chunks/{generate.runtime-T9DZJH8m.js → generate.runtime-S5RIgbQx.js} +103 -100
- package/dist/chunks/generate.runtime-S5RIgbQx.js.map +1 -0
- package/dist/chunks/{generate.runtime-CN3v78hx.js → generate.runtime-WmSMWL15.js} +17 -17
- package/dist/chunks/{generate.runtime-CN3v78hx.js.map → generate.runtime-WmSMWL15.js.map} +1 -1
- package/dist/chunks/generate.runtime-acRmiU7e.js +81 -0
- package/dist/chunks/generate.runtime-acRmiU7e.js.map +1 -0
- package/dist/chunks/{generate.runtime-l-Tiahb2.js → generate.runtime-flFRYzpi.js} +34 -59
- package/dist/chunks/generate.runtime-flFRYzpi.js.map +1 -0
- package/dist/chunks/generate.runtime-gtpOuLNO.js +110 -0
- package/dist/chunks/generate.runtime-gtpOuLNO.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dx8Mcs2i.js → generate.runtime-kLxeDGnS.js} +13 -13
- package/dist/chunks/{generate.runtime-Dx8Mcs2i.js.map → generate.runtime-kLxeDGnS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BqxVaq5P.js → generate.runtime-wA1G3tQ4.js} +18 -18
- package/dist/chunks/{generate.runtime-BqxVaq5P.js.map → generate.runtime-wA1G3tQ4.js.map} +1 -1
- package/dist/chunks/{modify-file-BlWTOkCH.js → modify-file-GQD6uNgI.js} +52 -10
- package/dist/chunks/modify-file-GQD6uNgI.js.map +1 -0
- package/dist/chunks/{pocketbase-ewxQLtse.js → pocketbase-CeG5BMN2.js} +59 -52
- package/dist/chunks/{pocketbase-ewxQLtse.js.map → pocketbase-CeG5BMN2.js.map} +1 -1
- package/dist/chunks/providers-DO9kMyzB.js +69 -0
- package/dist/chunks/providers-DO9kMyzB.js.map +1 -0
- package/dist/chunks/rolldown-runtime-DArdT4gl.js +23 -0
- package/dist/chunks/{shared-Bm3eMFy-.js → shared-BwHQM-a9.js} +2 -2
- package/dist/chunks/{shared-Bm3eMFy-.js.map → shared-BwHQM-a9.js.map} +1 -1
- package/dist/chunks/site-D027dpBm.js +55 -0
- package/dist/chunks/site-D027dpBm.js.map +1 -0
- package/dist/chunks/{ui-CD-psDWi.js → ui-B4Tuit-7.js} +2 -2
- package/dist/chunks/{ui-CD-psDWi.js.map → ui-B4Tuit-7.js.map} +1 -1
- package/dist/chunks/{write-result-DBKv-Q7J.js → write-result-DewHCNhM.js} +2 -2
- package/dist/chunks/{write-result-DBKv-Q7J.js.map → write-result-DewHCNhM.js.map} +1 -1
- package/dist/index.d.ts +268 -62
- package/dist/index.js +2265 -2246
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/dispatch-B5PfQ2CA.js +0 -6
- package/dist/chunks/dispatch-B5PfQ2CA.js.map +0 -1
- package/dist/chunks/generate-Va1sxVPG.js.map +0 -1
- package/dist/chunks/generate.runtime-1gbaOucO.js.map +0 -1
- package/dist/chunks/generate.runtime-Bb64J0ab.js +0 -87
- package/dist/chunks/generate.runtime-Bb64J0ab.js.map +0 -1
- package/dist/chunks/generate.runtime-CiTmbkAk.js.map +0 -1
- package/dist/chunks/generate.runtime-CwzHEcKv.js.map +0 -1
- package/dist/chunks/generate.runtime-Dj22Kx0W.js +0 -107
- package/dist/chunks/generate.runtime-Dj22Kx0W.js.map +0 -1
- package/dist/chunks/generate.runtime-DnWw9tL1.js.map +0 -1
- package/dist/chunks/generate.runtime-T9DZJH8m.js.map +0 -1
- package/dist/chunks/generate.runtime-Zh5n8XpR.js.map +0 -1
- package/dist/chunks/generate.runtime-d9HT4v-7.js.map +0 -1
- package/dist/chunks/generate.runtime-l-Tiahb2.js.map +0 -1
- package/dist/chunks/modify-file-BlWTOkCH.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-S5RIgbQx.js","names":[],"sources":["../../src/patterns/enable/auth-remote/modifies/+layout.server.ts","../../src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth-remote/modifies/hooks.server.ts","../../src/patterns/enable/auth-remote/modifies/test-setup.ts","../../src/patterns/enable/auth-remote/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\";\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 sourceFile.formatText();\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 sourceFile.formatText();\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<Avatar.Root>\n\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t{data.user?.email?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t</Avatar.Root>\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';\n import * as Avatar from '$lib/components/ui/avatar';\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\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"$lib/components/ui/avatar\",\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\";\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 sourceFile.formatText();\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 sourceFile.formatText();\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 sourceFile.formatText();\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 sourceFile.formatText();\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 { Project } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst COOKIE_LOGIN = dedent`\n // Login is a remote function, so there is no form action to post to: carry\n // the session the way the browser does, in the \\`pb_auth\\` cookie.\n async function authenticateUser(agent: Agent, user: { email: string }) {\n const client = new PocketBase(process.env.POCKETBASE_URL!);\n await client.collection(\"users\").authWithPassword(user.email, testUserPassword);\n agent.set(\"Cookie\", client.authStore.exportToCookie().split(\";\")[0]);\n }\n`;\n\n/**\n * The template's server-test helper logs in by posting the `/login` form\n * action, which this pattern replaces with a remote function. A project\n * without the helper (or with its own) has nothing to fix.\n */\nexport function modifyTestSetup(setupPath: string): ModifyOutcome {\n if (!fs.existsSync(setupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(setupPath);\n const helper = sourceFile.getFunction(\"authenticateUser\");\n\n if (!helper || !/\\.post\\(\\s*[\"'`]\\/login[\"'`]\\s*\\)/.test(helper.getText())) {\n return { status: \"success\", changed: false };\n }\n\n helper.replaceWithText(COOKIE_LOGIN);\n sourceFile.saveSync();\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\";\nimport { modifySvelteConfigRemote } from \"../../../runtime/modify-svelte-config-remote\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyTestSetup } from \"./modifies/test-setup\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n const logger = getLogger(options);\n\n let 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 test/setup.ts\");\n const testSetupFile = path.join(options.root, \"test\", \"setup.ts\");\n pushResult(\n modifyOutcomeToFile(testSetupFile, modifyTestSetup(testSetupFile)),\n );\n\n logger.info(\"Modifying config for remote functions\");\n const remote = modifySvelteConfigRemote(options.root);\n pushResult(modifyOutcomeToFile(remote.filePath, remote.outcome));\n\n // The auth pages and the app sidebar show `site.name`.\n const siteFile = await ensureSiteFile(options);\n\n return {\n creates: siteFile ? [siteFile] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } sat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AAK,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAC3D,GACM,IACJ,EAAiB,MAAM,MAAM,EAAG,WAAW,CAAC,CAAC,KAAK,EAAiB;CAKrE,AAJA,EACE,EAAoB,GAAY,EAAuB,CAAU,CAAC,CACpE,GAEA,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,iBAAiB;CAKxE,AAJA,EACE,EAAoB,GAAiB,EAAkB,CAAe,CAAC,CACzE,GAEA,EAAO,KAAK,yBAAyB;CACrC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,QAAQ,UAAU;CAKhE,AAJA,EACE,EAAoB,GAAe,EAAgB,CAAa,CAAC,CACnE,GAEA,EAAO,KAAK,uCAAuC;CACnD,IAAM,IAAS,EAAyB,EAAQ,IAAI;CACpD,EAAW,EAAoB,EAAO,UAAU,EAAO,OAAO,CAAC;CAG/D,IAAM,IAAW,MAAM,EAAe,CAAO;CAE7C,OAAO;EACL,SAAS,IAAW,CAAC,CAAQ,IAAI,CAAC;EAClC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import {
|
|
4
|
-
import { r as o } from "./compose-handle-
|
|
3
|
+
import { i as n, modifyOutcomeToFile as r, n as i, o as a } from "./modify-file-GQD6uNgI.js";
|
|
4
|
+
import { r as o } from "./compose-handle-Cg9jnCsS.js";
|
|
5
5
|
import { a as s, r as c, t as l } from "./test-setup-B2hd8I-s.js";
|
|
6
6
|
import u from "node:fs";
|
|
7
7
|
import d from "node:path";
|
|
@@ -30,10 +30,10 @@ function _(e) {
|
|
|
30
30
|
status: "success",
|
|
31
31
|
changed: !1
|
|
32
32
|
};
|
|
33
|
-
let t = u.readFileSync(e, "utf8"),
|
|
33
|
+
let t = u.readFileSync(e, "utf8"), r = new p({
|
|
34
34
|
compilerOptions: { allowJs: !0 },
|
|
35
35
|
manipulationSettings: { quoteKind: m.Single }
|
|
36
|
-
}).addSourceFileAtPath(e), s = o(
|
|
36
|
+
}).addSourceFileAtPath(e), s = o(r, "handleStatic", {
|
|
37
37
|
expression: h,
|
|
38
38
|
name: "handlePocketbase",
|
|
39
39
|
position: "last"
|
|
@@ -48,26 +48,26 @@ function _(e) {
|
|
|
48
48
|
};
|
|
49
49
|
let c = s.statement;
|
|
50
50
|
if (c && f.isJSDocable(c)) for (let e of c.getJsDocs()) e.getText().includes("vela legal") && e.remove();
|
|
51
|
-
return
|
|
51
|
+
return a(r, ["@velastack/kit"]), n(r, "$env/dynamic/private", "env"), n(r, "@velastack/pocketbase", "handlePocketbase"), r.formatText(), i(r), r.saveSync(), {
|
|
52
52
|
status: "success",
|
|
53
|
-
changed:
|
|
53
|
+
changed: r.getFullText() !== t
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region src/patterns/enable/backend/generate.runtime.ts
|
|
58
58
|
async function v(e) {
|
|
59
|
-
let n = t(e),
|
|
59
|
+
let n = t(e), i = [];
|
|
60
60
|
n.info("Modifying adapter config");
|
|
61
|
-
let a = s(e.root), o =
|
|
62
|
-
o &&
|
|
63
|
-
let u = d.join(e.root, "src", "hooks.server.ts"), f =
|
|
64
|
-
f && (n.info("Modifying hooks.server.ts"),
|
|
65
|
-
let p = d.join(e.root, ".gitignore"), m =
|
|
66
|
-
m &&
|
|
67
|
-
let h = d.join(e.root, "test", "setup.ts"), g =
|
|
68
|
-
return g &&
|
|
61
|
+
let a = s(e.root), o = r(a.filePath, a.outcome);
|
|
62
|
+
o && i.push(o);
|
|
63
|
+
let u = d.join(e.root, "src", "hooks.server.ts"), f = r(u, _(u));
|
|
64
|
+
f && (n.info("Modifying hooks.server.ts"), i.push(f)), n.info("Modifying .gitignore");
|
|
65
|
+
let p = d.join(e.root, ".gitignore"), m = r(p, c(p));
|
|
66
|
+
m && i.push(m), n.info("Modifying test/setup.ts");
|
|
67
|
+
let h = d.join(e.root, "test", "setup.ts"), g = r(h, l(h));
|
|
68
|
+
return g && i.push(g), {
|
|
69
69
|
creates: [],
|
|
70
|
-
modifies:
|
|
70
|
+
modifies: i,
|
|
71
71
|
deletes: [],
|
|
72
72
|
components: [],
|
|
73
73
|
packages: [],
|
|
@@ -79,4 +79,4 @@ async function v(e) {
|
|
|
79
79
|
//#endregion
|
|
80
80
|
export { v as generate };
|
|
81
81
|
|
|
82
|
-
//# sourceMappingURL=generate.runtime-
|
|
82
|
+
//# sourceMappingURL=generate.runtime-WmSMWL15.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-WmSMWL15.js","names":[],"sources":["../../src/patterns/enable/backend/modifies/hooks.server.ts","../../src/patterns/enable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node, Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { replaceHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n pruneUnusedImports,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** The handle `creates/src/hooks.server.ts` exports, for a file that already exists. */\nexport const POCKETBASE_HANDLE = dedent`\n handlePocketbase({\n \tpocketbaseUrl: env.POCKETBASE_URL,\n \tsuperuserEmail: env.POCKETBASE_SUPERUSER_EMAIL,\n \tsuperuserPassword: env.POCKETBASE_SUPERUSER_PASSWORD\n })\n`;\n\nconst FAILURE_HINT = dedent`\n Add the PocketBase handle to the exported handle in src/hooks.server.ts:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { env } from '$env/dynamic/private';\n import { handlePocketbase } from '@velastack/pocketbase';\n\n export const handle = sequence(\n \t/* your existing handle */,\n \t${POCKETBASE_HANDLE.replace(/\\n/g, \"\\n\\t\")}\n );\n`;\n\n/**\n * Compose the PocketBase handle into a `hooks.server.ts` the project already\n * has, instead of the create overwriting it: a static site's, or one i18n or\n * content negotiation wrote. It takes `handleStatic()`'s place, since\n * `handlePocketbase` does what that did and more; otherwise it goes last, so\n * the handles already there keep running first.\n */\nexport function modifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // The create writes it.\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const composed = replaceHandle(sourceFile, \"handleStatic\", {\n expression: POCKETBASE_HANDLE,\n name: \"handlePocketbase\",\n position: \"last\",\n });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (composed.status === \"unchanged\") {\n return { status: \"success\", changed: false };\n }\n\n // The static template's comment explains handleStatic(). Where that was the\n // whole handle, replaceHandle already dropped it; in a sequence (i18n or\n // negotiation composed in since) it is still there, describing a handle\n // that is gone.\n const statement = composed.statement;\n if (statement && Node.isJSDocable(statement)) {\n for (const doc of statement.getJsDocs()) {\n if (doc.getText().includes(\"vela legal\")) doc.remove();\n }\n }\n\n pruneUnusedImports(sourceFile, [\"@velastack/kit\"]);\n ensureNamedImport(sourceFile, \"$env/dynamic/private\", \"env\");\n ensureNamedImport(sourceFile, \"@velastack/pocketbase\", \"handlePocketbase\");\n\n sourceFile.formatText();\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { modifyTestSetup } from \"./modifies/test-setup\";\nimport { modifyHooksServerBackend } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying adapter config\");\n const adapter = modifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(\n adapter.filePath,\n adapter.outcome,\n );\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // A hooks.server.ts the project already has keeps its handles; the create\n // only writes the file where there is none (see `keepMissing` in index.ts).\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerFile = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerFile) {\n logger.info(\"Modifying hooks.server.ts\");\n modifies.push(hooksServerFile);\n }\n\n logger.info(\"Modifying .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n modifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Modifying test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n modifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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":";;;;;;;;;AAYA,IAAa,IAAoB,CAAM;;;;;;GAQjC,IAAe,CAAM;;;;;;;;;KAStB,EAAkB,QAAQ,OAAO,KAAM,EAAE;;;AAW9C,SAAgB,EACd,GACe;CACf,IAAI,CAAC,EAAG,WAAW,CAAe,GAEhC,OAAO;EAAE,QAAQ;EA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ClC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,YAAY,GACpD,IAAgB,EACpB,GACA,EAAgB,CAAa,CAC/B;CAGA,AAFI,KAAe,EAAS,KAAK,CAAa,GAE9C,EAAO,KAAK,yBAAyB;CACrC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,QAAQ,UAAU,GAC1D,IAAgB,EACpB,GACA,EAAgB,CAAa,CAC/B;CAGA,OAFI,KAAe,EAAS,KAAK,CAAa,GAEvC;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { a as e, o as t } from "./providers-DO9kMyzB.js";
|
|
2
|
+
import { t as n } from "./dedent-Gq6Krl4n.js";
|
|
3
|
+
import { n as r } from "./logger-CQONztPm.js";
|
|
4
|
+
import { r as i, t as a } from "./generate-DRA63W0r.js";
|
|
5
|
+
import { t as o } from "./env-BPfk1VAw.js";
|
|
6
|
+
import { h as s, modifyOutcomeToFile as c, r as l } from "./modify-file-GQD6uNgI.js";
|
|
7
|
+
import { t as u } from "./svelte-file-B3RfgVdt.js";
|
|
8
|
+
import d from "node:fs";
|
|
9
|
+
import f from "node:path";
|
|
10
|
+
//#region src/patterns/enable/analytics/modifies/layout.svelte.ts
|
|
11
|
+
var p = "$lib/components/analytics/analytics.svelte", m = n`
|
|
12
|
+
import Analytics from '${p}';
|
|
13
|
+
`, h = "\n<Analytics />\n", g = [
|
|
14
|
+
"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.",
|
|
15
|
+
"",
|
|
16
|
+
"Import for the <script> tag:",
|
|
17
|
+
"",
|
|
18
|
+
m,
|
|
19
|
+
"",
|
|
20
|
+
"Markup to add at the top level of the layout, above {@render children()}:",
|
|
21
|
+
h.trim()
|
|
22
|
+
].join("\n"), _ = [
|
|
23
|
+
"Mount <Analytics /> in the root src/routes/+layout.svelte.",
|
|
24
|
+
"",
|
|
25
|
+
"Import for a <script lang=\"ts\"> tag:",
|
|
26
|
+
"",
|
|
27
|
+
m,
|
|
28
|
+
"",
|
|
29
|
+
"Markup to add at the top level of the layout, above {@render children()}:",
|
|
30
|
+
h.trim()
|
|
31
|
+
].join("\n");
|
|
32
|
+
function v(e) {
|
|
33
|
+
if (!d.existsSync(e)) return {
|
|
34
|
+
status: "not-found",
|
|
35
|
+
message: g
|
|
36
|
+
};
|
|
37
|
+
let t = u.fromPath(e);
|
|
38
|
+
return t.hasElement("Analytics") ? {
|
|
39
|
+
status: "success",
|
|
40
|
+
changed: !1
|
|
41
|
+
} : t.getScript() ? (t.modifyScript((e) => {
|
|
42
|
+
let { source: t } = s(e, (e) => {
|
|
43
|
+
l(e, [{
|
|
44
|
+
defaultImport: "Analytics",
|
|
45
|
+
moduleSpecifier: p
|
|
46
|
+
}]);
|
|
47
|
+
});
|
|
48
|
+
return t;
|
|
49
|
+
}), t.insertBeforeChildren(h) || t.appendMarkup(h), t.writeTo(e), {
|
|
50
|
+
status: "success",
|
|
51
|
+
changed: t.hasChanged()
|
|
52
|
+
}) : {
|
|
53
|
+
status: "failed",
|
|
54
|
+
message: _
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/patterns/enable/analytics/generate.runtime.ts
|
|
59
|
+
async function y(n) {
|
|
60
|
+
let s = r(n), l = e(a, n), u = [], d = (e) => {
|
|
61
|
+
e && u.push(e);
|
|
62
|
+
};
|
|
63
|
+
s.info("Modifying src/routes/+layout.svelte");
|
|
64
|
+
let p = f.join(n.root, "src", "routes", "+layout.svelte");
|
|
65
|
+
d(c(p, v(p))), s.info("Updating .env");
|
|
66
|
+
let m = f.join(n.root, ".env");
|
|
67
|
+
return d(c(m, o(m, i(l, t(n))))), {
|
|
68
|
+
creates: [],
|
|
69
|
+
modifies: u,
|
|
70
|
+
deletes: [],
|
|
71
|
+
components: [],
|
|
72
|
+
packages: [],
|
|
73
|
+
collections: [],
|
|
74
|
+
collectionPatches: [],
|
|
75
|
+
collectionDrops: []
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { y as generate };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=generate.runtime-acRmiU7e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-acRmiU7e.js","names":[],"sources":["../../src/patterns/enable/analytics/modifies/layout.svelte.ts","../../src/patterns/enable/analytics/generate.runtime.ts"],"sourcesContent":["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\";\n\nconst MODULE_SPECIFIER = \"$lib/components/analytics/analytics.svelte\";\n\nconst IMPORT_SNIPPET = dedent`\n import Analytics from '${MODULE_SPECIFIER}';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Analytics />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <Analytics /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<Analytics />` at the top level of the root layout, ahead of\n * `{@render children()}`. The component is the same path for every provider,\n * so this modifier is provider-agnostic and a re-run with another provider\n * leaves the layout alone.\n */\nexport function modifyLayoutSvelte(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(\"Analytics\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"Analytics\", moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveProvider, suppliedProviderEnv } from \"../../../core/providers\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath)));\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\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":";;;;;;;;;;AASA,IAAM,IAA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;CAQ9C,OAPA,EACE,EACE,GACA,EAAU,GAAS,EAAY,GAAU,EAAoB,CAAO,CAAC,CAAC,CACxE,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "./
|
|
3
|
-
import { n } from "./
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { n as l } from "./compose-handle-
|
|
1
|
+
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
+
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
+
import { n } from "./shared-BwHQM-a9.js";
|
|
4
|
+
import { f as r, modifyOutcomeToFile as i, n as a, o, revertOutcomeToFile as s } from "./modify-file-GQD6uNgI.js";
|
|
5
|
+
import { t as c } from "./site-D027dpBm.js";
|
|
6
|
+
import { n as l } from "./compose-handle-Cg9jnCsS.js";
|
|
7
7
|
import { i as u, n as d, o as f } from "./test-setup-B2hd8I-s.js";
|
|
8
8
|
import p from "node:fs";
|
|
9
9
|
import m from "node:path";
|
|
10
10
|
import { Node as h, Project as g, QuoteKind as _ } from "ts-morph";
|
|
11
11
|
//#region src/patterns/disable/backend/modifies/hooks.server.ts
|
|
12
|
-
var v =
|
|
12
|
+
var v = e`
|
|
13
13
|
Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,
|
|
14
14
|
and its imports from '@velastack/pocketbase' and '$env/dynamic/private'.
|
|
15
|
-
`, y =
|
|
15
|
+
`, y = e`
|
|
16
16
|
The workflows are removed with the backend. Take the startWorker() call out
|
|
17
17
|
of the init hook in src/hooks.server.ts, and its import:
|
|
18
18
|
|
|
@@ -61,15 +61,15 @@ function w(e) {
|
|
|
61
61
|
status: "failed",
|
|
62
62
|
message: v
|
|
63
63
|
};
|
|
64
|
-
let
|
|
65
|
-
return
|
|
64
|
+
let i = C(n);
|
|
65
|
+
return i && i !== "custom" && r(n, i), o(n, b), n.formatText(), a(n), n.saveSync(), {
|
|
66
66
|
status: "success",
|
|
67
67
|
changed: n.getFullText() !== t
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/patterns/disable/backend/modifies/layout-server.ts
|
|
72
|
-
var T =
|
|
72
|
+
var T = e`
|
|
73
73
|
src/routes/+layout.server.ts still reads locals.meta, which only the
|
|
74
74
|
PocketBase hook provides. Read the values from a static module instead:
|
|
75
75
|
|
|
@@ -103,59 +103,34 @@ function E(e) {
|
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region src/patterns/disable/backend/generate.runtime.ts
|
|
105
105
|
function D(e) {
|
|
106
|
-
let t = "My App";
|
|
107
|
-
try {
|
|
108
|
-
let n = JSON.parse(p.readFileSync(m.join(e, "package.json"), "utf8"));
|
|
109
|
-
n.name && (t = n.name);
|
|
110
|
-
} catch {}
|
|
111
|
-
return [
|
|
112
|
-
"/**",
|
|
113
|
-
" * Site-wide metadata.",
|
|
114
|
-
" *",
|
|
115
|
-
" * Without a backend there is nothing to read this from at runtime, so this",
|
|
116
|
-
" * file is the source of truth. Set `url` to where the site is deployed:",
|
|
117
|
-
" * canonical links and Open Graph image URLs are built from it.",
|
|
118
|
-
" */",
|
|
119
|
-
"export const site = {",
|
|
120
|
-
`\tname: ${JSON.stringify(t)},`,
|
|
121
|
-
" url: 'http://localhost:5173'",
|
|
122
|
-
"};",
|
|
123
|
-
""
|
|
124
|
-
].join("\n");
|
|
125
|
-
}
|
|
126
|
-
function O(e) {
|
|
127
106
|
if (!p.existsSync(e)) return [];
|
|
128
107
|
let t = [];
|
|
129
108
|
for (let n of p.readdirSync(e, { withFileTypes: !0 })) {
|
|
130
109
|
let r = m.join(e, n.name);
|
|
131
|
-
n.isDirectory() ? t.push(...
|
|
110
|
+
n.isDirectory() ? t.push(...D(r)) : n.name === "server.test.ts" && t.push(r);
|
|
132
111
|
}
|
|
133
112
|
return t;
|
|
134
113
|
}
|
|
135
|
-
async function
|
|
136
|
-
let
|
|
137
|
-
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
let
|
|
141
|
-
|
|
142
|
-
let
|
|
143
|
-
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
let T = m.join(t.root, "test", "setup.ts"), k = a(T, d(T));
|
|
156
|
-
return k && c.push(k), {
|
|
157
|
-
creates: o,
|
|
158
|
-
modifies: c,
|
|
114
|
+
async function O(e) {
|
|
115
|
+
let r = t(e), a = [], o = [], l = [];
|
|
116
|
+
r.info("Reverting adapter config");
|
|
117
|
+
let p = f(e.root), h = i(p.filePath, p.outcome);
|
|
118
|
+
h && o.push(h), r.info("Reverting hooks.server.ts");
|
|
119
|
+
let g = m.join(e.root, "src", "hooks.server.ts"), _ = s(g, w(g));
|
|
120
|
+
_.modify && o.push(_.modify), _.delete && l.push(_.delete), r.info("Reverting .gitignore");
|
|
121
|
+
let v = m.join(e.root, ".gitignore"), y = i(v, u(v));
|
|
122
|
+
y && o.push(y), r.info("Reverting src/routes/+layout.server.ts");
|
|
123
|
+
let b = m.join(e.root, "src", "routes", "+layout.server.ts"), x = i(b, E(b));
|
|
124
|
+
if (x && o.push(x), x?.status === "success") {
|
|
125
|
+
let t = await c(e);
|
|
126
|
+
t && a.push(t);
|
|
127
|
+
}
|
|
128
|
+
for (let t of D(m.join(e.root, "src"))) r.info(`Removing ${m.relative(e.root, t)}`), l.push(n(t));
|
|
129
|
+
r.info("Reverting test/setup.ts");
|
|
130
|
+
let S = m.join(e.root, "test", "setup.ts"), C = i(S, d(S));
|
|
131
|
+
return C && o.push(C), {
|
|
132
|
+
creates: a,
|
|
133
|
+
modifies: o,
|
|
159
134
|
deletes: l,
|
|
160
135
|
components: [],
|
|
161
136
|
packages: [],
|
|
@@ -165,6 +140,6 @@ async function k(t) {
|
|
|
165
140
|
};
|
|
166
141
|
}
|
|
167
142
|
//#endregion
|
|
168
|
-
export {
|
|
143
|
+
export { O as generate };
|
|
169
144
|
|
|
170
|
-
//# sourceMappingURL=generate.runtime-
|
|
145
|
+
//# sourceMappingURL=generate.runtime-flFRYzpi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-flFRYzpi.js","names":[],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$env/dynamic/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '$lib/server/workflows';\n`;\n\n/** Modules only the backend's handle and init import from. */\nconst BACKEND_MODULES = [\n \"@velastack/pocketbase\",\n \"$env/dynamic/private\",\n \"$lib/server/workflows\",\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\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 (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\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 // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n sourceFile.formatText();\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 type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '$lib/site';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point an older root layout's meta at `$lib/site` instead of `locals.meta`.\n * Templates from before `src/lib/site.ts` read the app name and URL off the\n * PocketBase hook; without the backend nothing sets them, and `App.Locals` no\n * longer declares them. Current templates read `$lib/site` already, so this\n * leaves them alone.\n */\nexport function unmodifyLayoutServerMeta(\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.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n if (!/from\\s+['\"]\\$lib\\/site['\"]/.test(updated)) {\n updated = \"import { site } from '$lib/site';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\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 { toDeleteEntry } from \"../../destroy/shared\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n // The converted layout reads `src/lib/site.ts`. Every template ships it; a\n // project from before that gets one here, named as PocketBase knew it.\n if (layoutServerFile?.status === \"success\") {\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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":";;;;;;;;;;;AAiBA,IAAM,IAAc,CAAM;;;GAKpB,IAAY,C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K,CAAgB,GAIhD,GAAkB,WAAW,WAAW;EAC1C,IAAM,IAAW,MAAM,EAAe,CAAO;EAC7C,AAAI,KAAU,EAAQ,KAAK,CAAQ;CACrC;CAKA,KAAK,IAAM,KAAY,EAAgB,EAAK,KAAK,EAAQ,MAAM,KAAK,CAAC,GAEnE,AADA,EAAO,KAAK,YAAY,EAAK,SAAS,EAAQ,MAAM,CAAQ,GAAG,GAC/D,EAAQ,KAAK,EAAc,CAAQ,CAAC;CAGtC,EAAO,KAAK,yBAAyB;CACrC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,QAAQ,UAAU,GAC1D,IAAgB,EACpB,GACA,EAAkB,CAAa,CACjC;CAGA,OAFI,KAAe,EAAS,KAAK,CAAa,GAEvC;EACL;EACA;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
+
import { t } from "./shared-BwHQM-a9.js";
|
|
3
|
+
import { c as n, d as r, h as i, m as a, modifyOutcomeToFile as o } from "./modify-file-GQD6uNgI.js";
|
|
4
|
+
import { t as s } from "./svelte-file-B3RfgVdt.js";
|
|
5
|
+
import c from "node:fs";
|
|
6
|
+
import l from "node:path";
|
|
7
|
+
import { Project as u, SyntaxKind as d } from "ts-morph";
|
|
8
|
+
//#region src/patterns/disable/auth/modifies/+layout.server.ts
|
|
9
|
+
function f(e) {
|
|
10
|
+
if (!c.existsSync(e)) return {
|
|
11
|
+
status: "success",
|
|
12
|
+
changed: !1
|
|
13
|
+
};
|
|
14
|
+
let t = c.readFileSync(e, "utf8");
|
|
15
|
+
if (!t.includes("locals.pb.authStore.record")) return {
|
|
16
|
+
status: "success",
|
|
17
|
+
changed: !1
|
|
18
|
+
};
|
|
19
|
+
let n = new u().addSourceFileAtPath(e), r = n.getDescendantsOfKind(d.ObjectLiteralExpression);
|
|
20
|
+
for (let e of r) {
|
|
21
|
+
let t = e.getProperty("user");
|
|
22
|
+
t && t.getKind() === d.PropertyAssignment && t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
|
|
23
|
+
}
|
|
24
|
+
return a(n, "locals"), n.formatText(), n.saveSync(), {
|
|
25
|
+
status: "success",
|
|
26
|
+
changed: n.getFullText() !== t
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/patterns/disable/auth/modifies/root-layout.svelte.ts
|
|
31
|
+
function p(e) {
|
|
32
|
+
if (!c.existsSync(e)) return {
|
|
33
|
+
status: "success",
|
|
34
|
+
changed: !1
|
|
35
|
+
};
|
|
36
|
+
let t = c.readFileSync(e, "utf8"), a = new s(t);
|
|
37
|
+
if (!a.hasElement("AuthMenu.Root")) return {
|
|
38
|
+
status: "success",
|
|
39
|
+
changed: !1
|
|
40
|
+
};
|
|
41
|
+
a.removeElement("AuthMenu.Root");
|
|
42
|
+
let o = a.toString().replace(/<script[\s\S]*?<\/script>/g, "");
|
|
43
|
+
return a.modifyScript((e) => {
|
|
44
|
+
let { source: t } = i(e, (e) => {
|
|
45
|
+
n(e, "$lib/components/ui/auth-menu"), n(e, "$lib/components/ui/avatar"), r(e, "data", o);
|
|
46
|
+
});
|
|
47
|
+
return t;
|
|
48
|
+
}), a.writeTo(e), {
|
|
49
|
+
status: "success",
|
|
50
|
+
changed: a.hasChanged()
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/patterns/disable/auth/modifies/hooks.server.ts
|
|
55
|
+
function m(e) {
|
|
56
|
+
if (!c.existsSync(e)) return {
|
|
57
|
+
status: "success",
|
|
58
|
+
changed: !1
|
|
59
|
+
};
|
|
60
|
+
let t = c.readFileSync(e, "utf8"), n = new u().addSourceFileAtPath(e), r = n.getDescendantsOfKind(d.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
|
|
61
|
+
if (!r) return {
|
|
62
|
+
status: "success",
|
|
63
|
+
changed: !1
|
|
64
|
+
};
|
|
65
|
+
let [i] = r.getArguments();
|
|
66
|
+
if (!i || i.getKind() !== d.ObjectLiteralExpression) return {
|
|
67
|
+
status: "success",
|
|
68
|
+
changed: !1
|
|
69
|
+
};
|
|
70
|
+
let a = i.asKindOrThrow(d.ObjectLiteralExpression), o = a.getProperty("auth");
|
|
71
|
+
return o ? (o.remove(), a.getProperties().length === 0 && r.removeArgument(0), n.formatText(), n.saveSync(), {
|
|
72
|
+
status: "success",
|
|
73
|
+
changed: n.getFullText() !== t
|
|
74
|
+
}) : {
|
|
75
|
+
status: "success",
|
|
76
|
+
changed: !1
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/patterns/disable/auth/generate.runtime.ts
|
|
81
|
+
async function h(n) {
|
|
82
|
+
let r = e(n), i = [], a = (e) => {
|
|
83
|
+
e && i.push(e);
|
|
84
|
+
};
|
|
85
|
+
r.info("Reverting +layout.server.ts");
|
|
86
|
+
let s = l.join(n.root, "src", "routes", "+layout.server.ts");
|
|
87
|
+
a(o(s, f(s))), r.info("Reverting root layout");
|
|
88
|
+
let u = [
|
|
89
|
+
l.join(n.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
90
|
+
l.join(n.root, "src", "routes", "root-layout.svelte"),
|
|
91
|
+
l.join(n.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
92
|
+
l.join(n.root, "src", "routes", "+layout.svelte")
|
|
93
|
+
], d = u.find((e) => c.existsSync(e)) ?? u[0];
|
|
94
|
+
a(o(d, p(d))), r.info("Reverting hooks.server.ts");
|
|
95
|
+
let h = l.join(n.root, "src", "hooks.server.ts");
|
|
96
|
+
return a(o(h, m(h))), {
|
|
97
|
+
creates: [],
|
|
98
|
+
modifies: i,
|
|
99
|
+
deletes: [],
|
|
100
|
+
components: [],
|
|
101
|
+
packages: [],
|
|
102
|
+
collections: [],
|
|
103
|
+
collectionPatches: [],
|
|
104
|
+
collectionDrops: await t(["oauth_accounts"], n)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { h as generate };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=generate.runtime-gtpOuLNO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-gtpOuLNO.js","names":[],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeUnusedBindingElement } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.removeElement(\"AuthMenu.Root\");\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/auth-menu\");\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/avatar\");\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\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, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\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,SAAgB,EAAqB,GAAmC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAY,MAAM;CACzD,IAAI,CAAC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAM,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAU,GAEnD,IAAW,EAAW,qBAC1B,EAAW,uBACb;CACA,KAAK,IAAM,KAAO,GAAU;EAC1B,IAAM,IAAW,EAAI,YAAY,MAAM;EACnC,AAAC,KAAY,EAAS,QAAQ,MAAM,EAAW,sBAGpC,EACZ,eAAe,CAAC,EACf,QAAQ,MACE,gCACZ,EAAS,OAAO;CAEpB;CAQA,OALA,EAA2B,GAAY,QAAQ,GAE/C,EAAW,WAAW,GACtB,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAAS,EAAW,YAAY,MAAM;CACxC;AACF;;;ACnCA,SAAgB,EAAyB,GAAmC;CAC1E,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAS,EAAG,aAAa,GAAY,MAAM,GAC3C,IAAO,IAAI,EAAW,CAAM;CAClC,IAAI,CAAC,EAAK,WAAW,eAAe,GAClC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,EAAK,cAAc,eAAe;CAClC,IAAM,IAAS,EAAK,SAAS,CAAC,CAAC,QAAQ,8BAA8B,EAAE;CAavE,OAXA,EAAK,cAAc,MAAY;EAC7B,IAAM,EAAE,QAAQ,MAAQ,EAAmB,IAAU,MAAO;GAI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