@velastack/patterns 0.15.0 → 0.15.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/dist/chunks/_page-Cg7LjaOE.js +5 -0
- package/dist/chunks/{_page-6d3DCr0p.js.map → _page-Cg7LjaOE.js.map} +1 -1
- package/dist/chunks/auth-pages-DSBqKjO0.js +311 -0
- package/dist/chunks/auth-pages-DSBqKjO0.js.map +1 -0
- package/dist/chunks/{collections-FKsKGtaH.js → collections-D2_2cxWD.js} +2 -2
- package/dist/chunks/{collections-FKsKGtaH.js.map → collections-D2_2cxWD.js.map} +1 -1
- package/dist/chunks/{constants-BHuzzsKu.js → constants-DbpctM1D.js} +4 -4
- package/dist/chunks/{constants-BHuzzsKu.js.map → constants-DbpctM1D.js.map} +1 -1
- package/dist/chunks/{currency.server-DRuEFc6D.js → currency.server-CFrwmYra.js} +2 -2
- package/dist/chunks/{currency.server-DRuEFc6D.js.map → currency.server-CFrwmYra.js.map} +1 -1
- package/dist/chunks/{env-vars-BcHu8247.js → env-vars-Dm3Xy4rl.js} +3 -3
- package/dist/chunks/{env-vars-BcHu8247.js.map → env-vars-Dm3Xy4rl.js.map} +1 -1
- package/dist/chunks/{generate-CXAKf1Hh.js → generate-BMWoD9E2.js} +2 -2
- package/dist/chunks/{generate-CXAKf1Hh.js.map → generate-BMWoD9E2.js.map} +1 -1
- package/dist/chunks/{generate-CkfJrlEg.js → generate-BRTIGlqT.js} +3 -3
- package/dist/chunks/{generate-CkfJrlEg.js.map → generate-BRTIGlqT.js.map} +1 -1
- package/dist/chunks/{generate-a3U8uDzW.js → generate-BvQ6VwYH.js} +2 -2
- package/dist/chunks/{generate-a3U8uDzW.js.map → generate-BvQ6VwYH.js.map} +1 -1
- package/dist/chunks/{generate-9O0VdZOl.js → generate-Cs_fdfD7.js} +2 -2
- package/dist/chunks/{generate-9O0VdZOl.js.map → generate-Cs_fdfD7.js.map} +1 -1
- package/dist/chunks/{generate-rcDj36TD.js → generate-DZ9kT3iC.js} +3 -3
- package/dist/chunks/{generate-rcDj36TD.js.map → generate-DZ9kT3iC.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BmdO8oKV.js → generate.runtime-1eTnPFmA.js} +3 -3
- package/dist/chunks/{generate.runtime-BmdO8oKV.js.map → generate.runtime-1eTnPFmA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DtcKbzOm.js → generate.runtime-B-H2F-sH.js} +3 -3
- package/dist/chunks/{generate.runtime-DtcKbzOm.js.map → generate.runtime-B-H2F-sH.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BKsrh3ZN.js → generate.runtime-B4mQEW54.js} +3 -3
- package/dist/chunks/{generate.runtime-BKsrh3ZN.js.map → generate.runtime-B4mQEW54.js.map} +1 -1
- package/dist/chunks/{generate.runtime-As1It8o7.js → generate.runtime-B4rG6gSK.js} +6 -6
- package/dist/chunks/{generate.runtime-As1It8o7.js.map → generate.runtime-B4rG6gSK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CGbSe_nd.js → generate.runtime-B9nVU5iO.js} +2 -2
- package/dist/chunks/{generate.runtime-CGbSe_nd.js.map → generate.runtime-B9nVU5iO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DcBEbV-k.js → generate.runtime-BC1GJUXE.js} +2 -2
- package/dist/chunks/{generate.runtime-DcBEbV-k.js.map → generate.runtime-BC1GJUXE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dp3x08St.js → generate.runtime-BJwSyslL.js} +2 -2
- package/dist/chunks/{generate.runtime-Dp3x08St.js.map → generate.runtime-BJwSyslL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BGLekCHZ.js → generate.runtime-Bda2_WK7.js} +2 -2
- package/dist/chunks/{generate.runtime-BGLekCHZ.js.map → generate.runtime-Bda2_WK7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cqbsn5Ov.js → generate.runtime-BkQPchHe.js} +6 -6
- package/dist/chunks/{generate.runtime-Cqbsn5Ov.js.map → generate.runtime-BkQPchHe.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BY5VmBG4.js → generate.runtime-BuQASx9Y.js} +2 -2
- package/dist/chunks/{generate.runtime-BY5VmBG4.js.map → generate.runtime-BuQASx9Y.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DsW0Q5S5.js → generate.runtime-BvHK8IN-.js} +5 -5
- package/dist/chunks/{generate.runtime-DsW0Q5S5.js.map → generate.runtime-BvHK8IN-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BL7O2fy8.js → generate.runtime-C1HlZnLC.js} +2 -2
- package/dist/chunks/{generate.runtime-BL7O2fy8.js.map → generate.runtime-C1HlZnLC.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CFSBH8yG.js → generate.runtime-C62ChKGg.js} +4 -4
- package/dist/chunks/{generate.runtime-CFSBH8yG.js.map → generate.runtime-C62ChKGg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DiAnQ9MW.js → generate.runtime-CIOi-XSm.js} +6 -6
- package/dist/chunks/{generate.runtime-DiAnQ9MW.js.map → generate.runtime-CIOi-XSm.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DaJ4gLPv.js → generate.runtime-CQ_U4YTJ.js} +4 -4
- package/dist/chunks/{generate.runtime-DaJ4gLPv.js.map → generate.runtime-CQ_U4YTJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-4gS2ZHpj.js → generate.runtime-CZA46Ghe.js} +5 -5
- package/dist/chunks/{generate.runtime-4gS2ZHpj.js.map → generate.runtime-CZA46Ghe.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B5SP9iyN.js → generate.runtime-Cd742Yqf.js} +2 -2
- package/dist/chunks/{generate.runtime-B5SP9iyN.js.map → generate.runtime-Cd742Yqf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D7EETq9M.js → generate.runtime-CfCDLJ6Y.js} +3 -3
- package/dist/chunks/{generate.runtime-D7EETq9M.js.map → generate.runtime-CfCDLJ6Y.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BDVPJJbh.js → generate.runtime-CjLath7N.js} +5 -5
- package/dist/chunks/{generate.runtime-BDVPJJbh.js.map → generate.runtime-CjLath7N.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cxa24AOd.js → generate.runtime-CnNtG_x5.js} +3 -3
- package/dist/chunks/{generate.runtime-Cxa24AOd.js.map → generate.runtime-CnNtG_x5.js.map} +1 -1
- package/dist/chunks/{generate.runtime-COo85dGX.js → generate.runtime-D8G8cwCr.js} +2 -2
- package/dist/chunks/{generate.runtime-COo85dGX.js.map → generate.runtime-D8G8cwCr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CtV9Gn9T.js → generate.runtime-DBQvnQmR.js} +2 -2
- package/dist/chunks/{generate.runtime-CtV9Gn9T.js.map → generate.runtime-DBQvnQmR.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BKA41qV0.js → generate.runtime-DE-vPcn4.js} +6 -6
- package/dist/chunks/{generate.runtime-BKA41qV0.js.map → generate.runtime-DE-vPcn4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CTQvLaU0.js → generate.runtime-DFSsgOmB.js} +3 -3
- package/dist/chunks/{generate.runtime-CTQvLaU0.js.map → generate.runtime-DFSsgOmB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B8t8HtB6.js → generate.runtime-DNjyaFml.js} +3 -3
- package/dist/chunks/{generate.runtime-B8t8HtB6.js.map → generate.runtime-DNjyaFml.js.map} +1 -1
- package/dist/chunks/{generate.runtime-SZInujfP.js → generate.runtime-DQI69jkX.js} +2 -2
- package/dist/chunks/{generate.runtime-SZInujfP.js.map → generate.runtime-DQI69jkX.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CnGVlvxN.js → generate.runtime-DQUZRJH8.js} +3 -3
- package/dist/chunks/{generate.runtime-CnGVlvxN.js.map → generate.runtime-DQUZRJH8.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CyteiEzT.js → generate.runtime-DR8z6DyZ.js} +5 -5
- package/dist/chunks/{generate.runtime-CyteiEzT.js.map → generate.runtime-DR8z6DyZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B9U3kzHD.js → generate.runtime-Diix70x4.js} +2 -2
- package/dist/chunks/{generate.runtime-B9U3kzHD.js.map → generate.runtime-Diix70x4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CI_rUVZo.js → generate.runtime-Doumu0TL.js} +6 -6
- package/dist/chunks/{generate.runtime-CI_rUVZo.js.map → generate.runtime-Doumu0TL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cc5Aw1zc.js → generate.runtime-Dtum580c.js} +6 -6
- package/dist/chunks/{generate.runtime-Cc5Aw1zc.js.map → generate.runtime-Dtum580c.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C7NexMXs.js → generate.runtime-GmsldrGj.js} +3 -3
- package/dist/chunks/{generate.runtime-C7NexMXs.js.map → generate.runtime-GmsldrGj.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CG3udLj8.js → generate.runtime-lP4eoera.js} +3 -3
- package/dist/chunks/{generate.runtime-CG3udLj8.js.map → generate.runtime-lP4eoera.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BYhWm9JA.js → generate.runtime-liAz2TOE.js} +3 -3
- package/dist/chunks/{generate.runtime-BYhWm9JA.js.map → generate.runtime-liAz2TOE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ICaKVEuW.js → generate.runtime-rxzMCECc.js} +4 -4
- package/dist/chunks/{generate.runtime-ICaKVEuW.js.map → generate.runtime-rxzMCECc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BOtYaNA5.js → generate.runtime-ufoTIUXA.js} +7 -7
- package/dist/chunks/{generate.runtime-BOtYaNA5.js.map → generate.runtime-ufoTIUXA.js.map} +1 -1
- package/dist/chunks/{gitignore-CPardo4E.js → gitignore-2XpeEFmr.js} +3 -3
- package/dist/chunks/{gitignore-CPardo4E.js.map → gitignore-2XpeEFmr.js.map} +1 -1
- package/dist/chunks/{i18n-C8OfN_nr.js → i18n-CxT1kz8Y.js} +3 -3
- package/dist/chunks/{i18n-C8OfN_nr.js.map → i18n-CxT1kz8Y.js.map} +1 -1
- package/dist/chunks/{modify-file-DvIwtj4o.js → modify-file-BX9-aZD1.js} +2 -2
- package/dist/chunks/{modify-file-DvIwtj4o.js.map → modify-file-BX9-aZD1.js.map} +1 -1
- package/dist/chunks/{pocketbase-Ir-TPv7H.js → pocketbase-Dq9UdK_j.js} +2 -2
- package/dist/chunks/{pocketbase-Ir-TPv7H.js.map → pocketbase-Dq9UdK_j.js.map} +1 -1
- package/dist/chunks/{providers-B386TYCN.js → providers-2UgxXRJW.js} +2 -2
- package/dist/chunks/{providers-B386TYCN.js.map → providers-2UgxXRJW.js.map} +1 -1
- package/dist/chunks/{route-BJBV1DtX.js → route-BDhlro0V.js} +2 -2
- package/dist/chunks/{route-BJBV1DtX.js.map → route-BDhlro0V.js.map} +1 -1
- package/dist/chunks/{schema-DSNYWlel.js → schema-2frI_BS2.js} +3 -3
- package/dist/chunks/{schema-DSNYWlel.js.map → schema-2frI_BS2.js.map} +1 -1
- package/dist/chunks/{shared-CZHopdly.js → shared-BOFCKWJs.js} +2 -2
- package/dist/chunks/{shared-CZHopdly.js.map → shared-BOFCKWJs.js.map} +1 -1
- package/dist/chunks/{shared-BofFBVmT.js → shared-DJ4KvhTb.js} +2 -2
- package/dist/chunks/{shared-BofFBVmT.js.map → shared-DJ4KvhTb.js.map} +1 -1
- package/dist/chunks/{site-B9-emR6D.js → site-qASrdyUt.js} +2 -2
- package/dist/chunks/{site-B9-emR6D.js.map → site-qASrdyUt.js.map} +1 -1
- package/dist/chunks/{table-core-CHsfbi-n.js → table-core-s2xjYgRD.js} +2 -2
- package/dist/chunks/{table-core-CHsfbi-n.js.map → table-core-s2xjYgRD.js.map} +1 -1
- package/dist/chunks/{translations-CiJnl574.js → translations-B5hX0Qq-.js} +5 -2
- package/dist/chunks/{translations-CiJnl574.js.map → translations-B5hX0Qq-.js.map} +1 -1
- package/dist/chunks/{ui-BUhkIHse.js → ui-DZuwcswv.js} +3 -3
- package/dist/chunks/{ui-BUhkIHse.js.map → ui-DZuwcswv.js.map} +1 -1
- package/dist/chunks/{whatsapp-DFZUsKWe.js → whatsapp-BytvTPlS.js} +2 -2
- package/dist/chunks/{whatsapp-DFZUsKWe.js.map → whatsapp-BytvTPlS.js.map} +1 -1
- package/dist/chunks/{write-result-Bkdkp7u2.js → write-result-BhfLWAXf.js} +4 -4
- package/dist/chunks/{write-result-Bkdkp7u2.js.map → write-result-BhfLWAXf.js.map} +1 -1
- package/dist/index.js +116 -116
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/_page-6d3DCr0p.js +0 -5
- package/dist/chunks/auth-pages-DHzh31mw.js +0 -285
- package/dist/chunks/auth-pages-DHzh31mw.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-BDVPJJbh.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","NOT_FOUND_HINT","getLogger","readMigration","createCollectionIdempotent","applyCollectionRulePatches","migrationDelay","getMigrationFile","modifyOutcomeToFile","ensureSiteFile","SvelteFile","withInMemoryScript","formatLikeSource","ensureImports","addNavItemToScript","dedent","TEAM_RULE_PATCHES","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$2","modifyAppLayoutSvelte","layoutPath","file","NEW_HEADER","IMPORT_SNIPPET","LEGACY_NAME","FAILURE_HINT$1","NOT_FOUND_HINT$1","updateAppSidebarScript","out","source","legacyName","sf","decl","init","nameNode","SyntaxKind","pattern","elements","typeNode","intersection","member","lit","propTexts","p","t","elementTexts","insertIdx","modifyAppSidebar","appSidebarPath","modifyLayoutServer","layoutServerPath","snippet","originalSource","sourceFile","Project","addProperty","obj","name","initializer","loadArrow","loadFn","varDecl","directArrow","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","obp","hasDepends","el","hasLocals","parts","tail","currentName","body","blockBody","statements","hasTeam","stmt","id","hasTeams","hasDependsTeam","ce","args","argText","expr","ret","inner","bodyExpr","fnBody","TEAMS_NAV_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","addItemToNavUser","navUserSnippet","wasAdded","tryAdd","run","result","title","url","icon","iconImportPath","fn","modifyNavUser","navUserPath","newNavUserSnippet","pushMigrationCreates","created","migrationFile","collectionName","options","creates","generate","logger","withPocketbase","userCollection","pb","create","spec","teamsResult","teamsCollection","teamMembershipsResult","teamMembershipsCollection","teamUsersResult","teamInvitesResult","teamInviteLinksResult","ruleMigrations","modifies","pushResult","appLayoutPath","siteFile"],"sources":["../../src/patterns/enable/teams/modifies/modify-app-layout.ts","../../src/patterns/enable/teams/modifies/modify-app-sidebar.ts","../../src/patterns/enable/teams/modifies/+layout.server.ts","../../src/patterns/enable/teams/modifies/modify-nav-user.ts","../../src/patterns/enable/teams/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass team props to <AppSidebar> in your app layout:\",\n \"\",\n \"<AppSidebar team={data.team} teams={data.teams ?? []} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create an app layout that renders <AppSidebar> with team props:\",\n \"\",\n \"<AppSidebar team={data.team} teams={data.teams ?? []} />\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(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(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"teams\")) {\n return { status: \"success\", changed: false };\n }\n\n file.appendToAttributes(\n \"AppSidebar\",\n \" team={data.team} teams={data.teams ?? []}\",\n );\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NEW_HEADER = `<Sidebar.Header>\n\t\t<Sidebar.Menu>\n\t\t\t<TeamSwitcher {teams}>\n\t\t\t\t{#snippet children()}\n\t\t\t\t\t{@const activeTeam = teams.find((t) => t.id === team)}\n\t\t\t\t\t{#if activeTeam}\n\t\t\t\t\t\t<Avatar.Root class=\"size-8 rounded-lg\">\n\t\t\t\t\t\t\t<Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n\t\t\t\t\t\t\t\t{activeTeam.name?.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\t<div class=\"grid flex-1 text-left text-sm leading-tight\">\n\t\t\t\t\t\t\t<span class=\"truncate font-medium\">\n\t\t\t\t\t\t\t\t{activeTeam.name}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{:else}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclass=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<img src={favicon} alt=\"logo\" class=\"size-6\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"grid flex-1 text-left text-sm leading-tight\">\n\t\t\t\t\t\t\t<span class=\"truncate font-medium\">{site.name}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t\t<ChevronsUpDownIcon class=\"ml-auto\" />\n\t\t\t\t{/snippet}\n\t\t\t</TeamSwitcher>\n\t\t</Sidebar.Menu>\n\t</Sidebar.Header>`;\n\nconst IMPORT_SNIPPET = [\n \"import favicon from '#lib/assets/favicon.svg';\",\n \"import TeamSwitcher from '#lib/components/team-switcher.svelte';\",\n \"import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\",\n \"import * as Avatar from '#lib/components/ui/avatar/index.js';\",\n \"import { site } from '#lib/site.js';\",\n].join(\"\\n\");\n\n/**\n * A sidebar from before `#lib/site.js` names the app with a `meta` prop. Keep\n * whichever the header already uses, so an older project stays consistent.\n */\nconst LEGACY_NAME = \"{meta.appName}\";\n\nconst FAILURE_HINT = [\n \"Replace the <Sidebar.Header> in your app sidebar with the team switcher.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Props to destructure in $props(): team, teams = []\",\n \"\",\n \"Markup to use as the header:\",\n NEW_HEADER,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create an app sidebar with a <Sidebar.Header> containing the team switcher.\",\n \"\",\n \"Imports:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Header markup:\",\n NEW_HEADER,\n].join(\"\\n\");\n\nfunction updateAppSidebarScript(source: string, legacyName: boolean): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n if (!legacyName) {\n ensureImports(sf, [\n { namedImports: [\"site\"], moduleSpecifier: \"#lib/site.js\" },\n ]);\n }\n ensureImports(sf, [\n {\n defaultImport: \"favicon\",\n moduleSpecifier: \"#lib/assets/favicon.svg\",\n },\n {\n defaultImport: \"TeamSwitcher\",\n moduleSpecifier: \"#lib/components/team-switcher.svelte\",\n },\n {\n defaultImport: \"ChevronsUpDownIcon\",\n moduleSpecifier: \"@lucide/svelte/icons/chevrons-up-down\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"#lib/components/ui/avatar/index.js\",\n },\n ]);\n\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n\n if (elements.some((e) => e.getName() === \"team\")) continue;\n\n // Type changes first — name change can shift positions and invalidate type node refs.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^team\\b/.test(t))) break;\n propTexts.push(\n \"team?: string | undefined\",\n \"teams?: { id: string; name: string }[]\",\n );\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Rebuild binding pattern: insert team, teams = [] before first rest/initializer element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elements.length;\n elementTexts.splice(insertIdx, 0, \"team\", \"teams = []\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n }\n formatLikeSource(sf);\n });\n return out;\n}\n\nexport function modifyAppSidebar(appSidebarPath: string): ModifyOutcome {\n if (!fs.existsSync(appSidebarPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(appSidebarPath);\n if (file.hasElement(\"TeamSwitcher\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasElement(\"Sidebar.Header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const legacyName = file.toString().includes(LEGACY_NAME);\n file.modifyScript((source) => updateAppSidebarScript(source, legacyName));\n file.replaceElement(\n \"Sidebar.Header\",\n legacyName ? NEW_HEADER.replace(\"{site.name}\", LEGACY_NAME) : NEW_HEADER,\n );\n file.writeTo(appSidebarPath);\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\nexport function modifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n const snippet = dedent`\n export const load = async ({ locals, depends }) => {\n const user = locals.pb.authStore.record!;\n const team = locals.team;\n const teams = await locals.pb.collection(\"teams\").getFullList();\n depends(\"app:team\");\n\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n return { user, team, teams, breadcrumbs };\n };\n `;\n\n fs.writeFileSync(layoutServerPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutServerPath);\n\n const addProperty = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n name: string,\n initializer: string,\n ) => {\n const hasProperty = !!obj.getProperty(name);\n if (!hasProperty) {\n if (name === initializer) {\n obj.addShorthandPropertyAssignment({ name });\n } else {\n obj.addPropertyAssignment({ name, initializer });\n }\n }\n };\n\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 (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals, depends }\" }],\n statements: [\n \"const user = locals.pb.authStore.record!;\",\n \"const team = locals.team;\",\n 'const teams = await locals.pb.collection(\"teams\").getFullList();',\n 'depends(\"app:team\");',\n \"\",\n 'const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];',\n \"return { user, team, teams, breadcrumbs };\",\n ],\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals, depends }\" });\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 hasDepends = obp\n .getElements()\n .some((el) => el.getName() === \"depends\");\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n\n if (!hasDepends) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n\n if (hasLocals) {\n first.set({\n name: `{ depends${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, depends, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n if (loadArrow && !loadArrow.isAsync()) {\n loadArrow.setIsAsync(true);\n } else if (loadFn && !loadFn.isAsync()) {\n loadFn.setIsAsync(true);\n }\n\n const body = fnLike.getBody();\n if (body && body.getKind() === SyntaxKind.Block) {\n const blockBody = body as import(\"ts-morph\").Block;\n const statements = blockBody.getStatements();\n\n const hasTeam = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.VariableStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id: import(\"ts-morph\").Identifier) => id.getText() === \"team\"),\n );\n\n const hasTeams = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.VariableStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some(\n (id: import(\"ts-morph\").Identifier) => id.getText() === \"teams\",\n ),\n );\n\n const hasDependsTeam = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.ExpressionStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .some((ce: import(\"ts-morph\").CallExpression) => {\n const expr = ce.getExpression();\n if (expr.getText() !== \"depends\") return false;\n const args = ce.getArguments();\n const argText = args[0]?.getText() ?? \"\";\n return (\n args.length === 1 &&\n (argText === \"'app:team'\" || argText === '\"app:team\"')\n );\n }),\n );\n\n if (!hasTeam) {\n blockBody.insertStatements(1, \"const team = locals.team;\");\n }\n\n if (!hasTeams) {\n blockBody.insertStatements(\n 2,\n 'const teams = await locals.pb.collection(\"teams\").getFullList();',\n );\n }\n\n if (!hasDependsTeam) {\n blockBody.insertStatements(3, 'depends(\"app:team\");');\n }\n }\n\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 const obj = expr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\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 const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n }\n });\n } else {\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 const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = bodyExpr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n }\n } else if (loadFn) {\n const fnBody = loadFn.getBody();\n if (fnBody) {\n const returns = fnBody.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = expr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\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 const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\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 { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst TEAMS_NAV_SNIPPET = [\n \"import UsersIcon from '@lucide/svelte/icons/users';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Teams', url: '/teams', icon: UsersIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Teams nav item to nav-user.svelte:\",\n \"\",\n TEAMS_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Teams entry:\",\n \"\",\n TEAMS_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/teams\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Teams\",\n \"/teams\",\n \"UsersIcon\",\n \"@lucide/svelte/icons/users\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n applyCollectionRulePatches,\n createCollectionIdempotent,\n readMigration,\n} from \"../../../runtime/collections\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { TEAM_RULE_PATCHES } from \"./runtime/pocketbase\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n options: Options,\n created = true,\n) {\n if (!created) return;\n // Wait so the next schema op lands in a different PocketBase timestamp second.\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, \"created\", options);\n if (!migrationFile) {\n return;\n }\n creates.push(await readMigration(migrationFile, options));\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating teams collection\");\n const teamsResult = await create({\n name: \"teams\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"name\",\n type: \"text\",\n required: true,\n },\n {\n name: \"owner\",\n type: \"relation\",\n cascadeDelete: false,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"created\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: false,\n },\n {\n name: \"updated\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: true,\n },\n ],\n });\n const teamsCollection = teamsResult.collection;\n await pushMigrationCreates(creates, \"teams\", options, teamsResult.created);\n\n logger.info(\"Creating team_memberships collection\");\n const teamMembershipsResult = await create({\n name: \"team_memberships\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"user\",\n cascadeDelete: true,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"role\",\n maxSelect: 1,\n required: true,\n type: \"select\",\n values: [\"owner\", \"admin\", \"member\"],\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const teamMembershipsCollection = teamMembershipsResult.collection;\n await pushMigrationCreates(\n creates,\n \"team_memberships\",\n options,\n teamMembershipsResult.created,\n );\n\n logger.info(\"Creating team_users view\");\n const teamUsersResult = await create({\n name: \"team_users\",\n type: \"view\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"email\",\n exceptDomains: null,\n onlyDomains: null,\n // Accounts made with a phone number may have no email.\n required: false,\n type: \"email\",\n },\n {\n name: \"name\",\n max: 255,\n required: false,\n type: \"text\",\n },\n {\n name: \"membership_id\",\n cascadeDelete: false,\n collectionId: teamMembershipsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: false,\n type: \"relation\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"role\",\n maxSelect: 1,\n required: true,\n type: \"select\",\n values: [\"owner\", \"admin\", \"member\"],\n },\n ],\n viewQuery:\n \"select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;\",\n });\n await pushMigrationCreates(\n creates,\n \"team_users\",\n options,\n teamUsersResult.created,\n );\n\n logger.info(\"Creating team_invites collection\");\n const teamInvitesResult = await create({\n name: \"team_invites\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"team\",\n type: \"relation\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"email\",\n type: \"email\",\n required: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"team_invites\",\n options,\n teamInvitesResult.created,\n );\n\n logger.info(\"Creating team_invite_links collection\");\n const teamInviteLinksResult = await create({\n name: \"team_invite_links\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n indexes: [\n \"CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)\",\n ],\n });\n await pushMigrationCreates(\n creates,\n \"team_invite_links\",\n options,\n teamInviteLinksResult.created,\n );\n\n logger.info(\"Applying team rule patches\");\n const ruleMigrations = await applyCollectionRulePatches(\n pb,\n TEAM_RULE_PATCHES,\n options,\n logger,\n );\n creates.push(...ruleMigrations);\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying (app) +layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerPath, modifyLayoutServer(layoutServerPath)),\n );\n\n logger.info(\"Modifying (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, modifyAppLayoutSvelte(appLayoutPath)),\n );\n\n logger.info(\"Modifying app-sidebar\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n // The invite and join pages and the sidebar header show `site.name`.\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\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":";;;;;;;;;;;;;AAIA,IAAMA,IAAe,mHAMfC,IAAiB;AAMvB,SAAgBsB,EAAsB,GAAmC;CACvE,IAAI,CAACJ,EAAG,WAAWK,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAASvB;CAAe;CAGxD,IAAMwB,IAAOb,EAAW,SAASY,CAAU;CAa3C,OAZKC,EAAK,WAAW,YAAY,IAG7BA,EAAK,aAAa,cAAc,OAAO,IAClC;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7CA,EAAK,mBACH,cACA,4CACF,GACAA,EAAK,QAAQD,CAAU,GAChB;EAAE,QAAQ;EAAW,SAASC,EAAK,WAAW;CAAE,KAX9C;EAAE,QAAQ;EAAU,SAASzB;CAAa;AAYrD;;ACzBA,IAAM0B,IAAa,ulCAgCbC,IAAiB,kSAYjBC,IAAc,kBAEd1B,IAAe;CACnB;CACA;CACA;CACA;CACAyB;CACA;CACA;CACA;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI,GAELvB,IAAiB;CACrB;CACA;CACA;CACA;CACAwB;CACA;CACA;CACAD;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAASK,EAAuB,GAAgB,GAA6B;CAC3E,IAAM,EAAE,QAAQC,MAAQnB,EAAmBoB,IAAS,MAAO;EAMzD,AALKC,KACHnB,EAAcoB,GAAI,CAChB;GAAE,cAAc,CAAC,MAAM;GAAG,iBAAiB;EAAe,CAC5D,CAAC,GAEHpB,EAAcoB,GAAI;GAChB;IACE,eAA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A,cACA,iBACF;CACA,EAAW5G,EAAoBsG,GAAaD,EAAcC,CAAW,CAAC,CAAC;CAGvE,IAAM0B,IAAW,MAAM/H,EAAe2G,CAAO;CAG7C,OAFIoB,KAAUnB,EAAQ,KAAKmB,CAAQ,GAE5B;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-CjLath7N.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","NOT_FOUND_HINT","getLogger","readMigration","createCollectionIdempotent","applyCollectionRulePatches","migrationDelay","getMigrationFile","modifyOutcomeToFile","ensureSiteFile","SvelteFile","withInMemoryScript","formatLikeSource","ensureImports","addNavItemToScript","dedent","TEAM_RULE_PATCHES","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$2","modifyAppLayoutSvelte","layoutPath","file","NEW_HEADER","IMPORT_SNIPPET","LEGACY_NAME","FAILURE_HINT$1","NOT_FOUND_HINT$1","updateAppSidebarScript","out","source","legacyName","sf","decl","init","nameNode","SyntaxKind","pattern","elements","typeNode","intersection","member","lit","propTexts","p","t","elementTexts","insertIdx","modifyAppSidebar","appSidebarPath","modifyLayoutServer","layoutServerPath","snippet","originalSource","sourceFile","Project","addProperty","obj","name","initializer","loadArrow","loadFn","varDecl","directArrow","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","obp","hasDepends","el","hasLocals","parts","tail","currentName","body","blockBody","statements","hasTeam","stmt","id","hasTeams","hasDependsTeam","ce","args","argText","expr","ret","inner","bodyExpr","fnBody","TEAMS_NAV_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","addItemToNavUser","navUserSnippet","wasAdded","tryAdd","run","result","title","url","icon","iconImportPath","fn","modifyNavUser","navUserPath","newNavUserSnippet","pushMigrationCreates","created","migrationFile","collectionName","options","creates","generate","logger","withPocketbase","userCollection","pb","create","spec","teamsResult","teamsCollection","teamMembershipsResult","teamMembershipsCollection","teamUsersResult","teamInvitesResult","teamInviteLinksResult","ruleMigrations","modifies","pushResult","appLayoutPath","siteFile"],"sources":["../../src/patterns/enable/teams/modifies/modify-app-layout.ts","../../src/patterns/enable/teams/modifies/modify-app-sidebar.ts","../../src/patterns/enable/teams/modifies/+layout.server.ts","../../src/patterns/enable/teams/modifies/modify-nav-user.ts","../../src/patterns/enable/teams/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass team props to <AppSidebar> in your app layout:\",\n \"\",\n \"<AppSidebar team={data.team} teams={data.teams ?? []} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create an app layout that renders <AppSidebar> with team props:\",\n \"\",\n \"<AppSidebar team={data.team} teams={data.teams ?? []} />\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(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(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"teams\")) {\n return { status: \"success\", changed: false };\n }\n\n file.appendToAttributes(\n \"AppSidebar\",\n \" team={data.team} teams={data.teams ?? []}\",\n );\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NEW_HEADER = `<Sidebar.Header>\n\t\t<Sidebar.Menu>\n\t\t\t<TeamSwitcher {teams}>\n\t\t\t\t{#snippet children()}\n\t\t\t\t\t{@const activeTeam = teams.find((t) => t.id === team)}\n\t\t\t\t\t{#if activeTeam}\n\t\t\t\t\t\t<Avatar.Root class=\"size-8 rounded-lg\">\n\t\t\t\t\t\t\t<Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n\t\t\t\t\t\t\t\t{activeTeam.name?.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\t<div class=\"grid flex-1 text-left text-sm leading-tight\">\n\t\t\t\t\t\t\t<span class=\"truncate font-medium\">\n\t\t\t\t\t\t\t\t{activeTeam.name}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{:else}\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclass=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<img src={favicon} alt=\"logo\" class=\"size-6\" />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"grid flex-1 text-left text-sm leading-tight\">\n\t\t\t\t\t\t\t<span class=\"truncate font-medium\">{site.name}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t{/if}\n\t\t\t\t\t<ChevronsUpDownIcon class=\"ml-auto\" />\n\t\t\t\t{/snippet}\n\t\t\t</TeamSwitcher>\n\t\t</Sidebar.Menu>\n\t</Sidebar.Header>`;\n\nconst IMPORT_SNIPPET = [\n \"import favicon from '#lib/assets/favicon.svg';\",\n \"import TeamSwitcher from '#lib/components/team-switcher.svelte';\",\n \"import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';\",\n \"import * as Avatar from '#lib/components/ui/avatar/index.js';\",\n \"import { site } from '#lib/site.js';\",\n].join(\"\\n\");\n\n/**\n * A sidebar from before `#lib/site.js` names the app with a `meta` prop. Keep\n * whichever the header already uses, so an older project stays consistent.\n */\nconst LEGACY_NAME = \"{meta.appName}\";\n\nconst FAILURE_HINT = [\n \"Replace the <Sidebar.Header> in your app sidebar with the team switcher.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Props to destructure in $props(): team, teams = []\",\n \"\",\n \"Markup to use as the header:\",\n NEW_HEADER,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create an app sidebar with a <Sidebar.Header> containing the team switcher.\",\n \"\",\n \"Imports:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Header markup:\",\n NEW_HEADER,\n].join(\"\\n\");\n\nfunction updateAppSidebarScript(source: string, legacyName: boolean): string {\n const { source: out } = withInMemoryScript(source, (sf) => {\n if (!legacyName) {\n ensureImports(sf, [\n { namedImports: [\"site\"], moduleSpecifier: \"#lib/site.js\" },\n ]);\n }\n ensureImports(sf, [\n {\n defaultImport: \"favicon\",\n moduleSpecifier: \"#lib/assets/favicon.svg\",\n },\n {\n defaultImport: \"TeamSwitcher\",\n moduleSpecifier: \"#lib/components/team-switcher.svelte\",\n },\n {\n defaultImport: \"ChevronsUpDownIcon\",\n moduleSpecifier: \"@lucide/svelte/icons/chevrons-up-down\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"#lib/components/ui/avatar/index.js\",\n },\n ]);\n\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n\n if (elements.some((e) => e.getName() === \"team\")) continue;\n\n // Type changes first — name change can shift positions and invalidate type node refs.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^team\\b/.test(t))) break;\n propTexts.push(\n \"team?: string | undefined\",\n \"teams?: { id: string; name: string }[]\",\n );\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Rebuild binding pattern: insert team, teams = [] before first rest/initializer element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elements.length;\n elementTexts.splice(insertIdx, 0, \"team\", \"teams = []\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n }\n formatLikeSource(sf);\n });\n return out;\n}\n\nexport function modifyAppSidebar(appSidebarPath: string): ModifyOutcome {\n if (!fs.existsSync(appSidebarPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(appSidebarPath);\n if (file.hasElement(\"TeamSwitcher\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasElement(\"Sidebar.Header\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const legacyName = file.toString().includes(LEGACY_NAME);\n file.modifyScript((source) => updateAppSidebarScript(source, legacyName));\n file.replaceElement(\n \"Sidebar.Header\",\n legacyName ? NEW_HEADER.replace(\"{site.name}\", LEGACY_NAME) : NEW_HEADER,\n );\n file.writeTo(appSidebarPath);\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\nexport function modifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n const snippet = dedent`\n export const load = async ({ locals, depends }) => {\n const user = locals.pb.authStore.record!;\n const team = locals.team;\n const teams = await locals.pb.collection(\"teams\").getFullList();\n depends(\"app:team\");\n\n const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];\n return { user, team, teams, breadcrumbs };\n };\n `;\n\n fs.writeFileSync(layoutServerPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutServerPath);\n\n const addProperty = (\n obj: import(\"ts-morph\").ObjectLiteralExpression,\n name: string,\n initializer: string,\n ) => {\n const hasProperty = !!obj.getProperty(name);\n if (!hasProperty) {\n if (name === initializer) {\n obj.addShorthandPropertyAssignment({ name });\n } else {\n obj.addPropertyAssignment({ name, initializer });\n }\n }\n };\n\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 (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals, depends }\" }],\n statements: [\n \"const user = locals.pb.authStore.record!;\",\n \"const team = locals.team;\",\n 'const teams = await locals.pb.collection(\"teams\").getFullList();',\n 'depends(\"app:team\");',\n \"\",\n 'const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];',\n \"return { user, team, teams, breadcrumbs };\",\n ],\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals, depends }\" });\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 hasDepends = obp\n .getElements()\n .some((el) => el.getName() === \"depends\");\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n\n if (!hasDepends) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n\n if (hasLocals) {\n first.set({\n name: `{ depends${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, depends, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n } else {\n first.set({\n name: `{ locals, depends }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n if (loadArrow && !loadArrow.isAsync()) {\n loadArrow.setIsAsync(true);\n } else if (loadFn && !loadFn.isAsync()) {\n loadFn.setIsAsync(true);\n }\n\n const body = fnLike.getBody();\n if (body && body.getKind() === SyntaxKind.Block) {\n const blockBody = body as import(\"ts-morph\").Block;\n const statements = blockBody.getStatements();\n\n const hasTeam = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.VariableStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id: import(\"ts-morph\").Identifier) => id.getText() === \"team\"),\n );\n\n const hasTeams = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.VariableStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some(\n (id: import(\"ts-morph\").Identifier) => id.getText() === \"teams\",\n ),\n );\n\n const hasDependsTeam = statements.some(\n (stmt: import(\"ts-morph\").Statement) =>\n stmt.getKind() === SyntaxKind.ExpressionStatement &&\n stmt\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .some((ce: import(\"ts-morph\").CallExpression) => {\n const expr = ce.getExpression();\n if (expr.getText() !== \"depends\") return false;\n const args = ce.getArguments();\n const argText = args[0]?.getText() ?? \"\";\n return (\n args.length === 1 &&\n (argText === \"'app:team'\" || argText === '\"app:team\"')\n );\n }),\n );\n\n if (!hasTeam) {\n blockBody.insertStatements(1, \"const team = locals.team;\");\n }\n\n if (!hasTeams) {\n blockBody.insertStatements(\n 2,\n 'const teams = await locals.pb.collection(\"teams\").getFullList();',\n );\n }\n\n if (!hasDependsTeam) {\n blockBody.insertStatements(3, 'depends(\"app:team\");');\n }\n }\n\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 const obj = expr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\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 const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n }\n });\n } else {\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 const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = bodyExpr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\n }\n }\n } else if (loadFn) {\n const fnBody = loadFn.getBody();\n if (fnBody) {\n const returns = fnBody.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const obj = expr as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\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 const obj = inner as import(\"ts-morph\").ObjectLiteralExpression;\n addProperty(obj, \"team\", \"team\");\n addProperty(obj, \"teams\", \"teams\");\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 { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst TEAMS_NAV_SNIPPET = [\n \"import UsersIcon from '@lucide/svelte/icons/users';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Teams', url: '/teams', icon: UsersIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Teams nav item to nav-user.svelte:\",\n \"\",\n TEAMS_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Teams entry:\",\n \"\",\n TEAMS_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/teams\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Teams\",\n \"/teams\",\n \"UsersIcon\",\n \"@lucide/svelte/icons/users\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n applyCollectionRulePatches,\n createCollectionIdempotent,\n readMigration,\n} from \"../../../runtime/collections\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { TEAM_RULE_PATCHES } from \"./runtime/pocketbase\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n options: Options,\n created = true,\n) {\n if (!created) return;\n // Wait so the next schema op lands in a different PocketBase timestamp second.\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, \"created\", options);\n if (!migrationFile) {\n return;\n }\n creates.push(await readMigration(migrationFile, options));\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating teams collection\");\n const teamsResult = await create({\n name: \"teams\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"name\",\n type: \"text\",\n required: true,\n },\n {\n name: \"owner\",\n type: \"relation\",\n cascadeDelete: false,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"created\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: false,\n },\n {\n name: \"updated\",\n type: \"autodate\",\n onCreate: true,\n onUpdate: true,\n },\n ],\n });\n const teamsCollection = teamsResult.collection;\n await pushMigrationCreates(creates, \"teams\", options, teamsResult.created);\n\n logger.info(\"Creating team_memberships collection\");\n const teamMembershipsResult = await create({\n name: \"team_memberships\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"user\",\n cascadeDelete: true,\n collectionId: userCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"role\",\n maxSelect: 1,\n required: true,\n type: \"select\",\n values: [\"owner\", \"admin\", \"member\"],\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const teamMembershipsCollection = teamMembershipsResult.collection;\n await pushMigrationCreates(\n creates,\n \"team_memberships\",\n options,\n teamMembershipsResult.created,\n );\n\n logger.info(\"Creating team_users view\");\n const teamUsersResult = await create({\n name: \"team_users\",\n type: \"view\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"email\",\n exceptDomains: null,\n onlyDomains: null,\n // Accounts made with a phone number may have no email.\n required: false,\n type: \"email\",\n },\n {\n name: \"name\",\n max: 255,\n required: false,\n type: \"text\",\n },\n {\n name: \"membership_id\",\n cascadeDelete: false,\n collectionId: teamMembershipsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: false,\n type: \"relation\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"role\",\n maxSelect: 1,\n required: true,\n type: \"select\",\n values: [\"owner\", \"admin\", \"member\"],\n },\n ],\n viewQuery:\n \"select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;\",\n });\n await pushMigrationCreates(\n creates,\n \"team_users\",\n options,\n teamUsersResult.created,\n );\n\n logger.info(\"Creating team_invites collection\");\n const teamInvitesResult = await create({\n name: \"team_invites\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n type: \"text\",\n primaryKey: true,\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n required: true,\n },\n {\n name: \"team\",\n type: \"relation\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n },\n {\n name: \"email\",\n type: \"email\",\n required: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"team_invites\",\n options,\n teamInvitesResult.created,\n );\n\n logger.info(\"Creating team_invite_links collection\");\n const teamInviteLinksResult = await create({\n name: \"team_invite_links\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n type: \"text\",\n },\n {\n name: \"team\",\n cascadeDelete: true,\n collectionId: teamsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n indexes: [\n \"CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)\",\n ],\n });\n await pushMigrationCreates(\n creates,\n \"team_invite_links\",\n options,\n teamInviteLinksResult.created,\n );\n\n logger.info(\"Applying team rule patches\");\n const ruleMigrations = await applyCollectionRulePatches(\n pb,\n TEAM_RULE_PATCHES,\n options,\n logger,\n );\n creates.push(...ruleMigrations);\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying (app) +layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerPath, modifyLayoutServer(layoutServerPath)),\n );\n\n logger.info(\"Modifying (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, modifyAppLayoutSvelte(appLayoutPath)),\n );\n\n logger.info(\"Modifying app-sidebar\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n // The invite and join pages and the sidebar header show `site.name`.\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: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iB,CAAC;CACpB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as e } from "./shared-
|
|
1
|
+
import { n as e } from "./shared-BOFCKWJs.js";
|
|
2
2
|
import { n as t } from "./logger-t1HxmpG2.js";
|
|
3
|
-
import { a as n, r } from "./modify-file-
|
|
3
|
+
import { a as n, r } from "./modify-file-BX9-aZD1.js";
|
|
4
4
|
import { t as i } from "./dedent-CCUOcPFW.js";
|
|
5
5
|
import { n as a } from "./compose-handle-Da7m6lV_.js";
|
|
6
6
|
import { _ as o, d as s, n as c, o as l, u } from "./ts-morph-helpers-B4KZXP44.js";
|
|
@@ -117,4 +117,4 @@ async function E(i) {
|
|
|
117
117
|
}
|
|
118
118
|
export { E as generate };
|
|
119
119
|
|
|
120
|
-
//# sourceMappingURL=generate.runtime-
|
|
120
|
+
//# sourceMappingURL=generate.runtime-CnNtG_x5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-Cxa24AOd.js","names":["removeNegotiateImport","toDeleteEntry","getLogger","revertOutcomeToFile","dedent","removeHandle","withInMemoryScript","removeNamedImportIfUnused","ensureBlankLineAfterImports","formatLikeSource","libModule","isLibSpecifier","SvelteFile","fs","path","FAILURE_HINT","removeNegotiateImport$1","decl","sourceFile","d","named","ni","unmodifyHooksServerNegotiate","hooksServerPath","original","Project","QuoteKind","removeNegotiateImport","isMeaningfullyEmpty","s","SyntaxKind","unmodifyHooksNegotiate","hooksPath","rerouteDecl","initText","hasI18nHelper","unmodifyRootLayoutNegotiate","layoutPath","file","hasElement","out","source","sf","generate","logger","options","modifies","deletes","pushResult","hooksServerRevert","hooksOutcome","modifyOutcomeToFile","rootLayoutPath"],"sources":["../../src/patterns/disable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/disable/content-negotiation/modifies/hooks.ts","../../src/patterns/disable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/disable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeNamedImportIfUnused,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n Take handleNegotiate out of the exported handle in src/hooks.server.ts, then\n remove its import:\n\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n`;\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\n/**\n * Undo `modifyHooksServerNegotiate`: take `handleNegotiate` out of the\n * exported handle and drop its import. A file that held nothing else comes\n * out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerNegotiate(\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(\"handleNegotiate\")) {\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 const removed = removeHandle(sourceFile, \"handleNegotiate\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n removeNegotiateImport(sourceFile);\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction isMeaningfullyEmpty(sourceFile: SourceFile): boolean {\n return sourceFile\n .getStatements()\n .every((s) => s.getKind() === SyntaxKind.EmptyStatement);\n}\n\nexport function unmodifyHooksNegotiate(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(\"negotiateReroute\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const init = rerouteDecl?.getInitializer();\n const initText = init?.getText() ?? \"\";\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n\n if (\n rerouteDecl &&\n hasI18nHelper &&\n initText.includes(\"rerouteDeLocalize\") &&\n initText.includes(\"negotiateReroute\")\n ) {\n rerouteDecl.setInitializer(\"({ url }) => rerouteDeLocalize(url.pathname)\");\n } else if (rerouteDecl && initText.includes(\"negotiateReroute\")) {\n const stmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n stmt?.remove();\n }\n\n removeNegotiateImport(sourceFile);\n\n if (isMeaningfullyEmpty(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 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 removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutNegotiate(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const hasElement = file.hasElement(\"Negotiate\");\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"negotiate\"));\n });\n return out;\n });\n\n if (hasElement) {\n file.removeElement(\"Negotiate\");\n }\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { unmodifyHooksNegotiate } from \"./modifies/hooks\";\nimport { unmodifyRootLayoutNegotiate } from \"./modifies/root-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 hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // Emptied once the negotiation handle was all it held, it goes.\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerNegotiate(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 const hooksOutcome = unmodifyHooksNegotiate(hooksPath);\n if (\n fs.existsSync(hooksPath) &&\n fs.readFileSync(hooksPath, \"utf8\").trim() === \"\"\n ) {\n // The reroute was all it contained; the file goes with it.\n deletes.push(toDeleteEntry(hooksPath));\n } else {\n pushResult(modifyOutcomeToFile(hooksPath, hooksOutcome));\n }\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyRootLayoutNegotiate(rootLayoutPath),\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":";;;;;;;;;;;;AAYA,IAAMe,IAAe,CAAM;;;;;;AAO3B,SAASf,EAAsB,GAAiC;CAC9D,IAAMiB,IAAOC,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAMP,EAAeQ,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACvE,IAAI,CAACF,GAAM,OAAO;CAElB,IAAMG,IAAQH,EAAK,gBA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A,UACA,gBACF;CAQA,OAPAG,EACEG,EACEC,GACAhB,EAA4BgB,CAAc,CAC5C,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-CnNtG_x5.js","names":["removeNegotiateImport","toDeleteEntry","getLogger","revertOutcomeToFile","dedent","removeHandle","withInMemoryScript","removeNamedImportIfUnused","ensureBlankLineAfterImports","formatLikeSource","libModule","isLibSpecifier","SvelteFile","fs","path","FAILURE_HINT","removeNegotiateImport$1","decl","sourceFile","d","named","ni","unmodifyHooksServerNegotiate","hooksServerPath","original","Project","QuoteKind","removeNegotiateImport","isMeaningfullyEmpty","s","SyntaxKind","unmodifyHooksNegotiate","hooksPath","rerouteDecl","initText","hasI18nHelper","unmodifyRootLayoutNegotiate","layoutPath","file","hasElement","out","source","sf","generate","logger","options","modifies","deletes","pushResult","hooksServerRevert","hooksOutcome","modifyOutcomeToFile","rootLayoutPath"],"sources":["../../src/patterns/disable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/disable/content-negotiation/modifies/hooks.ts","../../src/patterns/disable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/disable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeNamedImportIfUnused,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n Take handleNegotiate out of the exported handle in src/hooks.server.ts, then\n remove its import:\n\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n`;\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\n/**\n * Undo `modifyHooksServerNegotiate`: take `handleNegotiate` out of the\n * exported handle and drop its import. A file that held nothing else comes\n * out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerNegotiate(\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(\"handleNegotiate\")) {\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 const removed = removeHandle(sourceFile, \"handleNegotiate\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n removeNegotiateImport(sourceFile);\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), \"negotiate\"));\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction isMeaningfullyEmpty(sourceFile: SourceFile): boolean {\n return sourceFile\n .getStatements()\n .every((s) => s.getKind() === SyntaxKind.EmptyStatement);\n}\n\nexport function unmodifyHooksNegotiate(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(\"negotiateReroute\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const init = rerouteDecl?.getInitializer();\n const initText = init?.getText() ?? \"\";\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n\n if (\n rerouteDecl &&\n hasI18nHelper &&\n initText.includes(\"rerouteDeLocalize\") &&\n initText.includes(\"negotiateReroute\")\n ) {\n rerouteDecl.setInitializer(\"({ url }) => rerouteDeLocalize(url.pathname)\");\n } else if (rerouteDecl && initText.includes(\"negotiateReroute\")) {\n const stmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n stmt?.remove();\n }\n\n removeNegotiateImport(sourceFile);\n\n if (isMeaningfullyEmpty(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 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 removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutNegotiate(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const hasElement = file.hasElement(\"Negotiate\");\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"negotiate\"));\n });\n return out;\n });\n\n if (hasElement) {\n file.removeElement(\"Negotiate\");\n }\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { unmodifyHooksNegotiate } from \"./modifies/hooks\";\nimport { unmodifyRootLayoutNegotiate } from \"./modifies/root-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 hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // Emptied once the negotiation handle was all it held, it goes.\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerNegotiate(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 const hooksOutcome = unmodifyHooksNegotiate(hooksPath);\n if (\n fs.existsSync(hooksPath) &&\n fs.readFileSync(hooksPath, \"utf8\").trim() === \"\"\n ) {\n // The reroute was all it contained; the file goes with it.\n deletes.push(toDeleteEntry(hooksPath));\n } else {\n pushResult(modifyOutcomeToFile(hooksPath, hooksOutcome));\n }\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyRootLayoutNegotiate(rootLayoutPath),\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":";;;;;;;;;;;;AAYA,IAAMe,IAAe,CAAM;;;;;;AAO3B,SAASf,EAAsB,GAAiC;CAC9D,IAAMiB,IAAOC,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAMP,EAAeQ,EAAE,wBAAwB,GAAG,WAAW,CAAC;CACvE,IAAI,CAACF,GAAM,OAAO;CAElB,IAAMG,IAAQH,EAAK,gBAAgB,CAAC,CAAC,MAAM,MAEvCI,EAAG,QAAQ,MAAM,YACjBA,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAEpC;CASD,OAPKD,KAEDH,EAAK,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAACA,EAAK,iBAAiB,IAChEA,EAAK,OAAO,IAEZG,EAAM,OAAO,GAER,MAPY;AAQrB;AAOA,SAAgBE,EACd,GACe;CACf,IAAI,CAACT,EAAG,WAAWU,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWX,EAAG,a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AAQD,CAAU,GAChB;EAAE,QAAQ;EAAW,SAASC,EAAK,WAAW;CAAE;AACzD;;ACjBA,eAAsBK,EAAS,GAAkB;CAC/C,IAAMC,IAAS1C,EAAU2C,CAAO,GAC1BC,IAAmB,CAAC,GACpBC,IAAkB,CAAC,GACnBC,KAAc,MAAsB;EACxC,AAAIV,KAAMQ,EAAS,KAAKR,CAAI;CAC9B;CAEA,EAAO,KAAK,2BAA2B;CACvC,IAAMf,IAAkBT,EAAK,KAAK+B,EAAQ,MAAM,OAAO,iBAAiB,GAElEI,IAAoB9C,EACxBoB,GACAD,EAA6BC,CAAe,CAC9C;CAIA,AAHAyB,EAAWC,EAAkB,MAAM,GAC/BA,EAAkB,UAAQF,EAAQ,KAAKE,EAAkB,MAAM,GAEnEL,EAAO,KAAK,oBAAoB;CAChC,IAAMZ,IAAYlB,EAAK,KAAK+B,EAAQ,MAAM,OAAO,UAAU,GACrDK,IAAenB,EAAuBC,CAAS;CAWrD,AATEnB,EAAG,WAAWmB,CAAS,KACvBnB,EAAG,aAAamB,GAAW,MAAM,CAAC,CAAC,KAAK,MAAM,KAG9Ce,EAAQ,KAAK9C,EAAc+B,CAAS,CAAC,IAErCgB,EAAWG,EAAoBnB,GAAWkB,CAAY,CAAC,GAGzDN,EAAO,KAAK,qCAAqC;CACjD,IAAMQ,IAAiBtC,EAAK,KAC1B+B,EAAQ,MACR,OACA,UACA,gBACF;CAQA,OAPAG,EACEG,EACEC,GACAhB,EAA4BgB,CAAc,CAC5C,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./logger-t1HxmpG2.js";
|
|
2
|
-
import { r as t } from "./modify-file-
|
|
2
|
+
import { r as t } from "./modify-file-BX9-aZD1.js";
|
|
3
3
|
import { r as n } from "./layout.svelte-B6wOQ7SM.js";
|
|
4
4
|
import r from "node:path";
|
|
5
5
|
// src/patterns/enable/og/generate.runtime.ts
|
|
@@ -20,4 +20,4 @@ async function i(i) {
|
|
|
20
20
|
}
|
|
21
21
|
export { i as generate };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=generate.runtime-
|
|
23
|
+
//# sourceMappingURL=generate.runtime-D8G8cwCr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-D8G8cwCr.js","names":["getLogger","modifyOutcomeToFile","modifyLayoutSvelte","path","generate","logger","options","modifies","layoutPath","file"],"sources":["../../src/patterns/enable/og/generate.runtime.ts"],"sourcesContent":["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 { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n const file = modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath));\n if (file) modifies.push(file);\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":";;;;;AAMA,eAAsBI,EAAS,GAAkB;CAC/C,IAAMC,IAASL,EAAUM,CAAO,GAC1BC,IAAmB,CAAC;CAE1B,EAAO,KAAK,qCAAqC;CACjD,IAAMC,IAAaL,EAAK,KAAKG,EAAQ,MAAM,OAAO,UAAU,gBAAgB,GACtEG,IAAOR,EAAoBO,GAAYN,EAAmBM,CAAU,CAAC;CAG3E,OAFIC,KAAMF,EAAS,KAAKE,CAAI,GAErB;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,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./logger-t1HxmpG2.js";
|
|
2
|
-
import { r as t } from "./modify-file-
|
|
2
|
+
import { r as t } from "./modify-file-BX9-aZD1.js";
|
|
3
3
|
import { o as n } from "./ts-morph-helpers-B4KZXP44.js";
|
|
4
4
|
import r from "node:fs";
|
|
5
5
|
import i from "node:path";
|
|
@@ -52,4 +52,4 @@ async function c(n) {
|
|
|
52
52
|
}
|
|
53
53
|
export { c as generate };
|
|
54
54
|
|
|
55
|
-
//# sourceMappingURL=generate.runtime-
|
|
55
|
+
//# sourceMappingURL=generate.runtime-DBQvnQmR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-DBQvnQmR.js","names":["getLogger","modifyOutcomeToFile","formatLikeSource","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","generate","logger","options","modifies","file"],"sources":["../../src/patterns/disable/api/modifies/hooks.server.ts","../../src/patterns/disable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\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\n if (!callExpr) {\n return { status: \"success\", changed: false };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n return { status: \"success\", changed: false };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n return { status: \"success\", changed: false };\n }\n\n apiProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\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 { unmodifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\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,SAAgBK,EAAoB,GAAwC;CAC1E,IAAI,CAACF,EAAG,WAAWG,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAACF,GACH,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMG,IAAOH,EAAS,aAAa;CACnC,IAAIG,EAAK,WAAW,GAClB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWD,EAAK;CACtB,IAAIC,EAAS,QAAQ,MAAMH,EAAW,yBACpC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMI,IAAaD,EAAS,cAAcH,EAAW,uBAAuB,GACtEK,IAAUD,EAAW,YAAY,KAAK;CAc5C,OAbKC,KAILA,EAAQ,OAAO,GAEXD,EAAW,cAAc,CAAC,CAAC,WAAW,KACxCL,EAAS,eAAe,CAAC,GAG3BR,EAAiBM,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC,KAfS;EAAE,QAAQ;EAAW,SAAS;CAAM;AAgB/C;;AC7CA,eAAsBU,EAAS,GAAkB;CAC/C,IAAMC,IAASlB,EAAUmB,CAAO,GAC1BC,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAMd,IAAkBF,EAAK,KAAKe,EAAQ,MAAM,OAAO,iBAAiB,GAClEE,IAAOpB,EACXK,GACAD,EAAoBC,CAAe,CACrC;CAGA,OAFIe,KAAMD,EAAS,KAAKC,CAAI,GAErB;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,14 +1,14 @@
|
|
|
1
1
|
import { n as e } from "./logger-t1HxmpG2.js";
|
|
2
|
-
import { r as t } from "./modify-file-
|
|
2
|
+
import { r as t } from "./modify-file-BX9-aZD1.js";
|
|
3
3
|
import { n } from "./env-AxyRWcC_.js";
|
|
4
|
-
import { unmodifyEnvVarsFiles as r } from "./env-vars-
|
|
5
|
-
import { a as i } from "./currency.server-
|
|
6
|
-
import { n as a } from "./generate-
|
|
4
|
+
import { unmodifyEnvVarsFiles as r } from "./env-vars-Dm3Xy4rl.js";
|
|
5
|
+
import { a as i } from "./currency.server-CFrwmYra.js";
|
|
6
|
+
import { n as a } from "./generate-Cs_fdfD7.js";
|
|
7
7
|
import { t as o } from "./svelte-file-DfplF3BU.js";
|
|
8
8
|
import { f as s, m as c, n as l, o as u } from "./ts-morph-helpers-B4KZXP44.js";
|
|
9
9
|
import { c as d, i as f, n as p, o as m } from "./root-layout.svelte-DE0c_y-T.js";
|
|
10
10
|
import { t as h } from "./lib-specifier-C3M0WTev.js";
|
|
11
|
-
import { t as g } from "./shared-
|
|
11
|
+
import { t as g } from "./shared-BOFCKWJs.js";
|
|
12
12
|
import { n as _, t as v } from "./wuchale-config-CNXoq4rc.js";
|
|
13
13
|
import y from "node:fs";
|
|
14
14
|
import b from "node:path";
|
|
@@ -108,4 +108,4 @@ async function O(o) {
|
|
|
108
108
|
}
|
|
109
109
|
export { O as generate };
|
|
110
110
|
|
|
111
|
-
//# sourceMappingURL=generate.runtime-
|
|
111
|
+
//# sourceMappingURL=generate.runtime-DE-vPcn4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-BKA41qV0.js","names":["getLogger","modifyOutcomeToFile","envEditsFor","providersToRemove","SvelteFile","removeNavItemFromScript","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","unmodifyHooksServerCurrency","unmodifyLayoutSvelteCurrency","unmodifyRootLayoutCurrencySelect","unmodifyLayoutServerCurrency","isLibSpecifier","planDropsForCollections","modifyWuchaleJsFiles","TRANSLATED_LIB_FILES","fs","path","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","CALL_EXPRESSIONS","unmodifyUserSignup","userSignupPath","originalSource","sourceFile","Project","QuoteKind","module","decl","d","linkFn","s","callStatements","SyntaxKind","ce","call","stmt","STRIPE_COLLECTIONS","generate","isAppMode","options","logger","providers","isStripe","provider","modifies","deletes","pushResult","envPath","modifyEnvRemove","layoutPath","hooksServerPath","layoutServerPath","rootLayoutPath","envVars","unmodifyEnvVarsFiles","variable","wuchaleConfig"],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\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 ensureBlankLineAfterImports,\n formatLikeSource,\n removeStatementWithComments,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const module of [\"workflows/link-stripe-customer\", \"stripe\"]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), module));\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n // With the two comment lines enable-payments put above it: left behind,\n // they keep the file from matching the stock signup, and enable-whatsapp\n // then refuses to swap it.\n if (stmt) removeStatementWithComments(sourceFile, stmt);\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\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 { modifyEnvRemove } from \"../../../runtime/env\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { envEditsFor } from \"../../enable/payments/generate\";\nimport { providersToRemove } from \"./generate\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyHooksServerCurrency } from \"../../enable/payments/modifies/hooks.server\";\nimport { unmodifyLayoutServerCurrency } from \"../../enable/payments/modifies/layout.server\";\nimport { unmodifyLayoutSvelteCurrency } from \"../../enable/payments/modifies/layout.svelte\";\nimport { unmodifyRootLayoutCurrencySelect } from \"../../enable/payments/modifies/root-layout.svelte\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\nimport fs from \"node:fs\";\nimport {\n modifyWuchaleJsFiles,\n TRANSLATED_LIB_FILES,\n} from \"../../../runtime/wuchale-config\";\n\n/** Everything enable-payments creates in PocketBase for Stripe. */\nconst STRIPE_COLLECTIONS = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n];\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const providers = providersToRemove(options);\n const isStripe = providers.some((provider) => provider.id === \"stripe\");\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n const envPath = path.join(options.root, \".env\");\n for (const provider of providers) {\n logger.info(`Stripping ${provider.label} credentials from .env`);\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, envEditsFor(provider)),\n ),\n );\n }\n\n logger.info(\"Removing the currency select from the navbar\");\n const layoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutPath,\n unmodifyRootLayoutCurrencySelect(layoutPath),\n ),\n );\n\n // The server half of the store, where enable-payments added it.\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n if (fs.existsSync(layoutServerPath)) {\n logger.info(\"Removing the visitor's currency from the server\");\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyLayoutSvelteCurrency(rootLayoutPath),\n ),\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerCurrency(layoutServerPath),\n ),\n );\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerCurrency(hooksServerPath),\n ),\n );\n }\n\n logger.info(\"Removing payment variables from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n providers.flatMap((provider) =>\n (provider.env ?? []).map((variable) => variable.key),\n ),\n );\n pushResult(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n // WhatsApp's order message was listed for wuchale; the module goes, so the\n // entry does too.\n const wuchaleConfig = path.join(options.root, \"wuchale.config.js\");\n if (\n providers.some((provider) => provider.id === \"whatsapp\") &&\n fs.existsSync(wuchaleConfig)\n ) {\n logger.info(\"Removing src/lib/order.ts from wuchale's js adapter\");\n pushResult(\n modifyOutcomeToFile(\n wuchaleConfig,\n modifyWuchaleJsFiles(wuchaleConfig, TRANSLATED_LIB_FILES, \"remove\"),\n ),\n );\n }\n\n // The nav item and the signup link exist only in auth's files, which\n // enable-payments edits for Stripe alone.\n if (isStripe && isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n // Every Stripe collection is planned, whatever auth is now; one that was\n // never created is planned as missing and left alone. Without a backend\n // (no provider detected, on a Shopify project) there is nothing to drop.\n const collectionDrops =\n isStripe && options.features.backend\n ? await planDropsForCollections(STRIPE_COLLECTIONS, 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,SAAgBmB,EAAgB,GAAoC;CAClE,IAAI,CAACF,EAAG,WAAWG,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAASJ,EAAG,aAAaG,GAAa,MAAM;CAClD,IAAI,CAACC,EAAO,SAAS,UAAU,GAC7B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAO,IAAIlB,EAAWiB,CAAM,GAC9BE,IAAa,IAEXC,KAAa,MAAgD;EACjE,AAAID,KACJE,GAAK,MAAQ;GACX,IAAMC,IAASrB,EACbsB,GACA,WACA,kCACF;GAEA,OADID,EAAO,eAAY,IAAa,KAC7BA,EAAO;EAChB,CAAC;CACH;CAUA,OARAF,GAAW,MAAOF,EAAK,mBAAmBM,CAAE,CAAC,GACxCL,KAAYC,GAAW,MAAOF,EAAK,aAAaM,CAAE,CAAC,GAEnDL,KAILN,EAAG,cAAcG,GAAaE,EAAK,SAAS,GAAG,MAAM,GAC9C;EAAE,QAAQ;EAAW,SAAS;CAAK,KAJjC;EAAE,QAAQ;EAAW,SAAS;CAAM;AAK/C;;AC9BA,IAAMO,oBAAmB,IAAI,IAAI,CAC/B,0BAEA,oBACF,CAAC;AAED,SAAgBC,EAAmB,GAAuC;CACxE,IAAI,CAACb,EAAG,WAAWc,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBf,EAAG,aAAac,GAAgB,MAAM;CAC7D,IAAI,CAACC,EAAe,SAAS,oBAAoB,GAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAM7C,IAAMC,IAAa,IAHCC,EAAQ,EA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AA2B;EACvC,IAAM5B,IAAcF,EAAK,KACvB+B,EAAQ,MACR,OACA,OACA,cACA,iBACF;EAGA,AAFAO,EAAWvD,EAAoBmB,GAAaD,EAAgBC,CAAW,CAAC,CAAC,GAEzE8B,EAAO,KAAK,kCAAkC;EAC9C,IAAMnB,IAAiBb,EAAK,KAC1B+B,EAAQ,MACR,OACA,UACA,YACA,UACA,UACA,iBACF;EACA,EACEhD,EAAoB8B,GAAgBD,EAAmBC,CAAc,CAAC,CACxE;CACF;CAUA,OAAO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAZAqB,KAAYH,EAAQ,SAAS,UACzB,MAAMnC,EAAwBgC,GAAoBG,CAAO,IACzD,CAAC;CAWP;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-DE-vPcn4.js","names":["getLogger","modifyOutcomeToFile","envEditsFor","providersToRemove","SvelteFile","removeNavItemFromScript","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","unmodifyHooksServerCurrency","unmodifyLayoutSvelteCurrency","unmodifyRootLayoutCurrencySelect","unmodifyLayoutServerCurrency","isLibSpecifier","planDropsForCollections","modifyWuchaleJsFiles","TRANSLATED_LIB_FILES","fs","path","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","CALL_EXPRESSIONS","unmodifyUserSignup","userSignupPath","originalSource","sourceFile","Project","QuoteKind","module","decl","d","linkFn","s","callStatements","SyntaxKind","ce","call","stmt","STRIPE_COLLECTIONS","generate","isAppMode","options","logger","providers","isStripe","provider","modifies","deletes","pushResult","envPath","modifyEnvRemove","layoutPath","hooksServerPath","layoutServerPath","rootLayoutPath","envVars","unmodifyEnvVarsFiles","variable","wuchaleConfig"],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\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 ensureBlankLineAfterImports,\n formatLikeSource,\n removeStatementWithComments,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const module of [\"workflows/link-stripe-customer\", \"stripe\"]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), module));\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n // With the two comment lines enable-payments put above it: left behind,\n // they keep the file from matching the stock signup, and enable-whatsapp\n // then refuses to swap it.\n if (stmt) removeStatementWithComments(sourceFile, stmt);\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\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 { modifyEnvRemove } from \"../../../runtime/env\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { envEditsFor } from \"../../enable/payments/generate\";\nimport { providersToRemove } from \"./generate\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyHooksServerCurrency } from \"../../enable/payments/modifies/hooks.server\";\nimport { unmodifyLayoutServerCurrency } from \"../../enable/payments/modifies/layout.server\";\nimport { unmodifyLayoutSvelteCurrency } from \"../../enable/payments/modifies/layout.svelte\";\nimport { unmodifyRootLayoutCurrencySelect } from \"../../enable/payments/modifies/root-layout.svelte\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\nimport fs from \"node:fs\";\nimport {\n modifyWuchaleJsFiles,\n TRANSLATED_LIB_FILES,\n} from \"../../../runtime/wuchale-config\";\n\n/** Everything enable-payments creates in PocketBase for Stripe. */\nconst STRIPE_COLLECTIONS = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n];\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const providers = providersToRemove(options);\n const isStripe = providers.some((provider) => provider.id === \"stripe\");\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n const envPath = path.join(options.root, \".env\");\n for (const provider of providers) {\n logger.info(`Stripping ${provider.label} credentials from .env`);\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, envEditsFor(provider)),\n ),\n );\n }\n\n logger.info(\"Removing the currency select from the navbar\");\n const layoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutPath,\n unmodifyRootLayoutCurrencySelect(layoutPath),\n ),\n );\n\n // The server half of the store, where enable-payments added it.\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n if (fs.existsSync(layoutServerPath)) {\n logger.info(\"Removing the visitor's currency from the server\");\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyLayoutSvelteCurrency(rootLayoutPath),\n ),\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerCurrency(layoutServerPath),\n ),\n );\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerCurrency(hooksServerPath),\n ),\n );\n }\n\n logger.info(\"Removing payment variables from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n providers.flatMap((provider) =>\n (provider.env ?? []).map((variable) => variable.key),\n ),\n );\n pushResult(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n // WhatsApp's order message was listed for wuchale; the module goes, so the\n // entry does too.\n const wuchaleConfig = path.join(options.root, \"wuchale.config.js\");\n if (\n providers.some((provider) => provider.id === \"whatsapp\") &&\n fs.existsSync(wuchaleConfig)\n ) {\n logger.info(\"Removing src/lib/order.ts from wuchale's js adapter\");\n pushResult(\n modifyOutcomeToFile(\n wuchaleConfig,\n modifyWuchaleJsFiles(wuchaleConfig, TRANSLATED_LIB_FILES, \"remove\"),\n ),\n );\n }\n\n // The nav item and the signup link exist only in auth's files, which\n // enable-payments edits for Stripe alone.\n if (isStripe && isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n // Every Stripe collection is planned, whatever auth is now; one that was\n // never created is planned as missing and left alone. Without a backend\n // (no provider detected, on a Shopify project) there is nothing to drop.\n const collectionDrops =\n isStripe && options.features.backend\n ? await planDropsForCollections(STRIPE_COLLECTIONS, 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,SAAgBmB,EAAgB,GAAoC;CAClE,IAAI,CAACF,EAAG,WAAWG,CAAW,GAC5B,OAAO;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B,GAAgBD,EAAmBC,CAAc,CAAC,CACxE;CACF;CAUA,OAAO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAZAqB,KAAYH,EAAQ,SAAS,UACzB,MAAMnC,EAAwBgC,GAAoBG,CAAO,IACzD,CAAC;CAWP;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./logger-t1HxmpG2.js";
|
|
2
|
-
import { r as t } from "./modify-file-
|
|
2
|
+
import { r as t } from "./modify-file-BX9-aZD1.js";
|
|
3
3
|
import { a as n, t as r } from "./config-target-DJbVHwHl.js";
|
|
4
|
-
import { n as i } from "./generate-
|
|
4
|
+
import { n as i } from "./generate-BvQ6VwYH.js";
|
|
5
5
|
import { _ as a, o, r as s } from "./ts-morph-helpers-B4KZXP44.js";
|
|
6
6
|
import { t as c } from "./dedent-CCUOcPFW.js";
|
|
7
7
|
import { a as l, c as u, i as d, l as f, n as p, o as m, r as h, s as g, t as _ } from "./load-function-BFvIVsh7.js";
|
|
@@ -297,4 +297,4 @@ async function K(a) {
|
|
|
297
297
|
}
|
|
298
298
|
export { K as generate };
|
|
299
299
|
|
|
300
|
-
//# sourceMappingURL=generate.runtime-
|
|
300
|
+
//# sourceMappingURL=generate.runtime-DFSsgOmB.js.map
|