@velastack/patterns 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +44 -2
  2. package/dist/chunks/_layout-kkgN0IF7.js +62 -0
  3. package/dist/chunks/_layout-kkgN0IF7.js.map +1 -0
  4. package/dist/chunks/{collections-CrOvS2E7.js → collections-Dz2fvKnz.js} +2 -2
  5. package/dist/chunks/{collections-CrOvS2E7.js.map → collections-Dz2fvKnz.js.map} +1 -1
  6. package/dist/chunks/{compose-handle-B-CkDcQD.js → compose-handle-D_Rz3Fzo.js} +10 -4
  7. package/dist/chunks/compose-handle-D_Rz3Fzo.js.map +1 -0
  8. package/dist/chunks/{config-target-Bln26FJe.js → config-target-Dx3w6WSk.js} +59 -70
  9. package/dist/chunks/config-target-Dx3w6WSk.js.map +1 -0
  10. package/dist/chunks/constants-BjyMU5s8.js +6 -0
  11. package/dist/chunks/constants-BjyMU5s8.js.map +1 -0
  12. package/dist/chunks/dispatch-CXOXPLFk.js +6 -0
  13. package/dist/chunks/dispatch-CXOXPLFk.js.map +1 -0
  14. package/dist/chunks/env-vars-C1NUX-bf.js +268 -0
  15. package/dist/chunks/env-vars-C1NUX-bf.js.map +1 -0
  16. package/dist/chunks/env-vars-Cr4lbMD_.js +21 -0
  17. package/dist/chunks/env-vars-Cr4lbMD_.js.map +1 -0
  18. package/dist/chunks/env-vars-De0Xs0L2.js +20 -0
  19. package/dist/chunks/env-vars-De0Xs0L2.js.map +1 -0
  20. package/dist/chunks/env-vars-file-B_6esJW3.js +34 -0
  21. package/dist/chunks/env-vars-file-B_6esJW3.js.map +1 -0
  22. package/dist/chunks/env-vars-mnRA0hOe.js +19 -0
  23. package/dist/chunks/env-vars-mnRA0hOe.js.map +1 -0
  24. package/dist/chunks/generate-BW3l5Fxw.js +252 -0
  25. package/dist/chunks/{generate-Ca_6FlPi.js.map → generate-BW3l5Fxw.js.map} +1 -1
  26. package/dist/chunks/{generate-CyuY2Ci7.js → generate-DeaBlnK6.js} +25 -24
  27. package/dist/chunks/generate-DeaBlnK6.js.map +1 -0
  28. package/dist/chunks/generate-DetW_gbr.js +68 -0
  29. package/dist/chunks/generate-DetW_gbr.js.map +1 -0
  30. package/dist/chunks/{generate-DwADTUob.js → generate-Gcc8iRkZ.js} +9 -6
  31. package/dist/chunks/{generate-DwADTUob.js.map → generate-Gcc8iRkZ.js.map} +1 -1
  32. package/dist/chunks/{generate-DQeWOEPY.js → generate-WMJo3QGZ.js} +9 -6
  33. package/dist/chunks/generate-WMJo3QGZ.js.map +1 -0
  34. package/dist/chunks/generate.runtime-1-91UmM8.js +85 -0
  35. package/dist/chunks/generate.runtime-1-91UmM8.js.map +1 -0
  36. package/dist/chunks/generate.runtime-6FXJM8hT.js +67 -0
  37. package/dist/chunks/generate.runtime-6FXJM8hT.js.map +1 -0
  38. package/dist/chunks/generate.runtime-B1jVAnDI.js +155 -0
  39. package/dist/chunks/generate.runtime-B1jVAnDI.js.map +1 -0
  40. package/dist/chunks/generate.runtime-BA3tDKnn.js +147 -0
  41. package/dist/chunks/generate.runtime-BA3tDKnn.js.map +1 -0
  42. package/dist/chunks/{generate.runtime-4FDxnvCl.js → generate.runtime-BO778G0r.js} +5 -5
  43. package/dist/chunks/{generate.runtime-4FDxnvCl.js.map → generate.runtime-BO778G0r.js.map} +1 -1
  44. package/dist/chunks/{generate.runtime-D1DNAY6k.js → generate.runtime-BXkZob1O.js} +8 -8
  45. package/dist/chunks/generate.runtime-BXkZob1O.js.map +1 -0
  46. package/dist/chunks/{generate.runtime-Um77JfwC.js → generate.runtime-B_UVGa3q.js} +7 -7
  47. package/dist/chunks/{generate.runtime-Um77JfwC.js.map → generate.runtime-B_UVGa3q.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-FdZw277n.js → generate.runtime-C6bSvGMb.js} +108 -142
  49. package/dist/chunks/generate.runtime-C6bSvGMb.js.map +1 -0
  50. package/dist/chunks/generate.runtime-C8zJRNYG.js +124 -0
  51. package/dist/chunks/generate.runtime-C8zJRNYG.js.map +1 -0
  52. package/dist/chunks/{generate.runtime-BKiJvE8I.js → generate.runtime-CA7Ofjlx.js} +104 -100
  53. package/dist/chunks/generate.runtime-CA7Ofjlx.js.map +1 -0
  54. package/dist/chunks/generate.runtime-CCr1lvo4.js +43 -0
  55. package/dist/chunks/generate.runtime-CCr1lvo4.js.map +1 -0
  56. package/dist/chunks/generate.runtime-CYagyR5c.js +326 -0
  57. package/dist/chunks/generate.runtime-CYagyR5c.js.map +1 -0
  58. package/dist/chunks/{generate.runtime-n9AFWtPp.js → generate.runtime-Ce_rwzNa.js} +4 -4
  59. package/dist/chunks/{generate.runtime-n9AFWtPp.js.map → generate.runtime-Ce_rwzNa.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-cQGLxuZM.js → generate.runtime-CexC1Oky.js} +4 -4
  61. package/dist/chunks/{generate.runtime-cQGLxuZM.js.map → generate.runtime-CexC1Oky.js.map} +1 -1
  62. package/dist/chunks/{generate.runtime-AYQVW1S-.js → generate.runtime-CnPraLKv.js} +35 -31
  63. package/dist/chunks/generate.runtime-CnPraLKv.js.map +1 -0
  64. package/dist/chunks/generate.runtime-CslAvllQ.js +112 -0
  65. package/dist/chunks/generate.runtime-CslAvllQ.js.map +1 -0
  66. package/dist/chunks/{generate.runtime-onBnOiS7.js → generate.runtime-CuNhY5hn.js} +10 -10
  67. package/dist/chunks/generate.runtime-CuNhY5hn.js.map +1 -0
  68. package/dist/chunks/{generate.runtime-B45MvtYm.js → generate.runtime-DD51OSuL.js} +14 -14
  69. package/dist/chunks/generate.runtime-DD51OSuL.js.map +1 -0
  70. package/dist/chunks/generate.runtime-DHBRyMAq.js +65 -0
  71. package/dist/chunks/generate.runtime-DHBRyMAq.js.map +1 -0
  72. package/dist/chunks/generate.runtime-DV3WmZtb.js +35 -0
  73. package/dist/chunks/generate.runtime-DV3WmZtb.js.map +1 -0
  74. package/dist/chunks/generate.runtime-D_sQOeQa.js +164 -0
  75. package/dist/chunks/generate.runtime-D_sQOeQa.js.map +1 -0
  76. package/dist/chunks/{generate.runtime-ofdnLtxS.js → generate.runtime-DqD3PW-W.js} +3 -3
  77. package/dist/chunks/{generate.runtime-ofdnLtxS.js.map → generate.runtime-DqD3PW-W.js.map} +1 -1
  78. package/dist/chunks/{generate.runtime-VgVwRiiN.js → generate.runtime-Dtgw9IQO.js} +8 -8
  79. package/dist/chunks/generate.runtime-Dtgw9IQO.js.map +1 -0
  80. package/dist/chunks/{generate.runtime-CN5c2xH8.js → generate.runtime-IlBCcXvv.js} +14 -14
  81. package/dist/chunks/generate.runtime-IlBCcXvv.js.map +1 -0
  82. package/dist/chunks/{generate.runtime-BSRFv4cJ.js → generate.runtime-cwvAoKoH.js} +3 -3
  83. package/dist/chunks/{generate.runtime-BSRFv4cJ.js.map → generate.runtime-cwvAoKoH.js.map} +1 -1
  84. package/dist/chunks/{generate.runtime-DG-3G00z.js → generate.runtime-kvxmTlQb.js} +3 -3
  85. package/dist/chunks/{generate.runtime-DG-3G00z.js.map → generate.runtime-kvxmTlQb.js.map} +1 -1
  86. package/dist/chunks/generate.runtime-pVLzzpUM.js +122 -0
  87. package/dist/chunks/generate.runtime-pVLzzpUM.js.map +1 -0
  88. package/dist/chunks/{generate.runtime-BFOXm2DD.js → generate.runtime-zJpEufTc.js} +10 -10
  89. package/dist/chunks/generate.runtime-zJpEufTc.js.map +1 -0
  90. package/dist/chunks/lib-specifier-Cngo1zF_.js +33 -0
  91. package/dist/chunks/lib-specifier-Cngo1zF_.js.map +1 -0
  92. package/dist/chunks/{modify-file-Dwfv0dCI.js → modify-file-BlDeeurK.js} +3 -3
  93. package/dist/chunks/{modify-file-Dwfv0dCI.js.map → modify-file-BlDeeurK.js.map} +1 -1
  94. package/dist/chunks/{modify-svelte-config-remote-BUU_EaDf.js → modify-svelte-config-remote-p0TfVzxm.js} +8 -10
  95. package/dist/chunks/modify-svelte-config-remote-p0TfVzxm.js.map +1 -0
  96. package/dist/chunks/nav-user-BRIHOOpG.js +6 -0
  97. package/dist/chunks/nav-user-BRIHOOpG.js.map +1 -0
  98. package/dist/chunks/package-imports-Bbw3iMPg.js +173 -0
  99. package/dist/chunks/package-imports-Bbw3iMPg.js.map +1 -0
  100. package/dist/chunks/{pocketbase-BkhUywtb.js → pocketbase-Dry6ry17.js} +2 -2
  101. package/dist/chunks/{pocketbase-BkhUywtb.js.map → pocketbase-Dry6ry17.js.map} +1 -1
  102. package/dist/chunks/{providers-BL9vJP_9.js → providers-BHR6-XZ7.js} +11 -4
  103. package/dist/chunks/providers-BHR6-XZ7.js.map +1 -0
  104. package/dist/chunks/{shared-C8GtNxpm.js → shared-CZC4d7Uj.js} +2 -2
  105. package/dist/chunks/{shared-C8GtNxpm.js.map → shared-CZC4d7Uj.js.map} +1 -1
  106. package/dist/chunks/{site-BdMX8qrH.js → site-BwCA18Sv.js} +2 -2
  107. package/dist/chunks/{site-BdMX8qrH.js.map → site-BwCA18Sv.js.map} +1 -1
  108. package/dist/chunks/table-core-AjBpYi-y.js +127 -0
  109. package/dist/chunks/table-core-AjBpYi-y.js.map +1 -0
  110. package/dist/chunks/{test-setup-DHEFKEHE.js → test-setup-DEmWd9Ul.js} +76 -67
  111. package/dist/chunks/test-setup-DEmWd9Ul.js.map +1 -0
  112. package/dist/chunks/{ts-morph-helpers-CeduA--o.js → ts-morph-helpers-CDW4lhox.js} +77 -63
  113. package/dist/chunks/ts-morph-helpers-CDW4lhox.js.map +1 -0
  114. package/dist/chunks/ui-DD4NltyN.js.map +1 -1
  115. package/dist/chunks/{ui-TlEuI2Sz.js → ui-X698F10c.js} +47 -47
  116. package/dist/chunks/{ui-TlEuI2Sz.js.map → ui-X698F10c.js.map} +1 -1
  117. package/dist/chunks/{unmodify-load-jfdcVZ_a.js → unmodify-load-CyGzC1Hu.js} +2 -2
  118. package/dist/chunks/{unmodify-load-jfdcVZ_a.js.map → unmodify-load-CyGzC1Hu.js.map} +1 -1
  119. package/dist/chunks/write-result-B68lvI57.js +511 -0
  120. package/dist/chunks/write-result-B68lvI57.js.map +1 -0
  121. package/dist/index.d.ts +224 -1
  122. package/dist/index.js +2121 -2064
  123. package/dist/index.js.map +1 -1
  124. package/package.json +7 -7
  125. package/dist/chunks/_layout-B7ujvjnA.js +0 -55
  126. package/dist/chunks/_layout-B7ujvjnA.js.map +0 -1
  127. package/dist/chunks/compose-handle-B-CkDcQD.js.map +0 -1
  128. package/dist/chunks/config-target-Bln26FJe.js.map +0 -1
  129. package/dist/chunks/constants-BYkd9jeJ.js +0 -6
  130. package/dist/chunks/constants-BYkd9jeJ.js.map +0 -1
  131. package/dist/chunks/dispatch-BRnt8PcW.js +0 -6
  132. package/dist/chunks/dispatch-BRnt8PcW.js.map +0 -1
  133. package/dist/chunks/generate-6snrlnpA.js +0 -64
  134. package/dist/chunks/generate-6snrlnpA.js.map +0 -1
  135. package/dist/chunks/generate-Ca_6FlPi.js +0 -252
  136. package/dist/chunks/generate-CyuY2Ci7.js.map +0 -1
  137. package/dist/chunks/generate-DQeWOEPY.js.map +0 -1
  138. package/dist/chunks/generate.runtime-AYQVW1S-.js.map +0 -1
  139. package/dist/chunks/generate.runtime-B2aFFaac.js +0 -117
  140. package/dist/chunks/generate.runtime-B2aFFaac.js.map +0 -1
  141. package/dist/chunks/generate.runtime-B45MvtYm.js.map +0 -1
  142. package/dist/chunks/generate.runtime-BFOXm2DD.js.map +0 -1
  143. package/dist/chunks/generate.runtime-BHkFmI2Y.js +0 -146
  144. package/dist/chunks/generate.runtime-BHkFmI2Y.js.map +0 -1
  145. package/dist/chunks/generate.runtime-BKiJvE8I.js.map +0 -1
  146. package/dist/chunks/generate.runtime-BUqsF3AF.js +0 -123
  147. package/dist/chunks/generate.runtime-BUqsF3AF.js.map +0 -1
  148. package/dist/chunks/generate.runtime-BsaSyTnU.js +0 -82
  149. package/dist/chunks/generate.runtime-BsaSyTnU.js.map +0 -1
  150. package/dist/chunks/generate.runtime-CMnvmeVt.js +0 -111
  151. package/dist/chunks/generate.runtime-CMnvmeVt.js.map +0 -1
  152. package/dist/chunks/generate.runtime-CN5c2xH8.js.map +0 -1
  153. package/dist/chunks/generate.runtime-CgoSrP55.js +0 -146
  154. package/dist/chunks/generate.runtime-CgoSrP55.js.map +0 -1
  155. package/dist/chunks/generate.runtime-D1DNAY6k.js.map +0 -1
  156. package/dist/chunks/generate.runtime-DQwSY6Nc.js +0 -38
  157. package/dist/chunks/generate.runtime-DQwSY6Nc.js.map +0 -1
  158. package/dist/chunks/generate.runtime-D_yqWLcI.js +0 -66
  159. package/dist/chunks/generate.runtime-D_yqWLcI.js.map +0 -1
  160. package/dist/chunks/generate.runtime-Drmahmdl.js +0 -313
  161. package/dist/chunks/generate.runtime-Drmahmdl.js.map +0 -1
  162. package/dist/chunks/generate.runtime-FdZw277n.js.map +0 -1
  163. package/dist/chunks/generate.runtime-Lh1cW9Tz.js +0 -94
  164. package/dist/chunks/generate.runtime-Lh1cW9Tz.js.map +0 -1
  165. package/dist/chunks/generate.runtime-QGHToXRY.js +0 -32
  166. package/dist/chunks/generate.runtime-QGHToXRY.js.map +0 -1
  167. package/dist/chunks/generate.runtime-VgVwRiiN.js.map +0 -1
  168. package/dist/chunks/generate.runtime-YyIVd4oy.js +0 -61
  169. package/dist/chunks/generate.runtime-YyIVd4oy.js.map +0 -1
  170. package/dist/chunks/generate.runtime-onBnOiS7.js.map +0 -1
  171. package/dist/chunks/modify-svelte-config-remote-BUU_EaDf.js.map +0 -1
  172. package/dist/chunks/nav-user-BYI-h8Od.js +0 -6
  173. package/dist/chunks/nav-user-BYI-h8Od.js.map +0 -1
  174. package/dist/chunks/providers-BL9vJP_9.js.map +0 -1
  175. package/dist/chunks/table-core-G9Shld4F.js +0 -126
  176. package/dist/chunks/table-core-G9Shld4F.js.map +0 -1
  177. package/dist/chunks/test-setup-DHEFKEHE.js.map +0 -1
  178. package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +0 -1
  179. package/dist/chunks/write-result-Djy0SZXX.js +0 -376
  180. package/dist/chunks/write-result-Djy0SZXX.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-DD51OSuL.js","names":[],"sources":["../../src/patterns/enable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/enable/content-negotiation/modifies/hooks.ts","../../src/patterns/enable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/enable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the negotiation handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = sequence(handleNegotiate, /* your existing handle */);\n`;\n\nconst HOOKS_SERVER_SNIPPET = dedent`\n import { handle as handleNegotiate } from '#lib/negotiate.js';\n\n export const handle = handleNegotiate;\n`;\n\nfunction ensureNegotiateHandleImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n if (!has)\n existing.addNamedImport({ name: \"handle\", alias: \"handleNegotiate\" });\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"handle\", alias: \"handleNegotiate\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksServerNegotiate(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"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 composed = addHandle(sourceFile, { expression: \"handleNegotiate\" });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureNegotiateHandleImport(sourceFile);\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 path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst NEGOTIATE_ONLY_SNIPPET = dedent`\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => negotiateReroute(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the negotiation reroute:\n\n import { reroute as negotiateReroute } from '#lib/negotiate.js';\n\n export const reroute = ({ url }) => existingReroute(negotiateReroute(url.pathname));\n`;\n\nfunction ensureNegotiateImport(sourceFile: SourceFile) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"#lib/negotiate.js\");\n if (existing) {\n const has = existing.getNamedImports().some((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!has) {\n existing.addNamedImport({ name: \"reroute\", alias: \"negotiateReroute\" });\n }\n return;\n }\n sourceFile.addImportDeclaration({\n namedImports: [{ name: \"reroute\", alias: \"negotiateReroute\" }],\n moduleSpecifier: \"#lib/negotiate.js\",\n });\n}\n\nexport function modifyHooksNegotiate(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, NEGOTIATE_ONLY_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\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\n if (!rerouteDecl) {\n ensureNegotiateImport(sourceFile);\n sourceFile.addStatements(\n `\\nexport const reroute = ({ url }) => negotiateReroute(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n const initText = init.getText();\n\n if (hasI18nHelper && initText.includes(\"rerouteDeLocalize\")) {\n ensureNegotiateImport(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n return { status: \"failed\", message: FAILURE_HINT };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { Negotiate } from '#lib/negotiate.js';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Negotiate />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root +layout.svelte and mount <Negotiate /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nexport function modifyRootLayoutNegotiate(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(\"Negotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"Negotiate\"],\n moduleSpecifier: \"#lib/negotiate.js\",\n },\n ]);\n });\n return out;\n });\n\n file.appendMarkup(MARKUP_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { modifyHooksNegotiate } from \"./modifies/hooks\";\nimport { modifyRootLayoutNegotiate } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerNegotiate(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksNegotiate(hooksPath)));\n\n logger.info(\"Modifying 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 modifyRootLayoutNegotiate(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":";;;;;;;;;;AAQA,IAAM,IAAe,CAAM;;;;;;;GASrB,IAAuB,CAAM;;;;;AAMnC,SAAS,EAA4B,GAAwB;CAC3D,IAAM,IAAW,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,mBAAmB;CAClE,IAAI,GAAU;EAOZ,AANY,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAEzC,EAAG,QAAQ,MAAM,YACjB,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAGhC,KACH,EAAS,eAAe;GAAE,MAAM;GAAU,OAAO;EAAkB,CAAC;EACtE;CACF;CACA,EAAW,qBAAqB;EAC9B,cAAc,CAAC;GAAE,MAAM;GAAU,OAAO;EAAkB,CAAC;EAC3D,iBAAiB;CACnB,CAAC;AACH;AAEA,SAAgB,EACd,GACe;CACf,IAAI,CAAC,EAAG,WAAW,CAAe,GAQhC,OALI,EAAG,WAAW,EAAgB,QAAQ,SAAS,KAAK,CAAC,IAChD;EAAE,QAAQ;EAAU,SAAS;CAAa,KAEnD,EAAG,UAAU,EA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Pm.js";
3
+ import { n, t as r } from "./generate-WMJo3QGZ.js";
4
+ import { n as i } from "./env-BPfk1VAw.js";
5
+ import { _ as a, n as o, u as s } from "./ts-morph-helpers-CDW4lhox.js";
6
+ import { envRevertOutcomeToFile as c, modifyOutcomeToFile as l } from "./modify-file-BlDeeurK.js";
7
+ import { unmodifyEnvVarsFiles as u } from "./env-vars-C1NUX-bf.js";
8
+ import { t as d } from "./svelte-file-B3RfgVdt.js";
9
+ import f from "node:fs";
10
+ import p from "node:path";
11
+ //#region src/patterns/disable/analytics/modifies/layout.svelte.ts
12
+ var m = "components/analytics/analytics.svelte";
13
+ function h(t) {
14
+ if (!f.existsSync(t)) return {
15
+ status: "success",
16
+ changed: !1
17
+ };
18
+ let n = f.readFileSync(t, "utf8");
19
+ if (!n.includes(m) && !n.includes("<Analytics")) return {
20
+ status: "success",
21
+ changed: !1
22
+ };
23
+ let r = d.fromPath(t);
24
+ r.modifyScript((t) => {
25
+ let { source: n } = a(t, (t) => {
26
+ s(t, e(m)), o(t);
27
+ });
28
+ return n;
29
+ });
30
+ let i = r.toString().replace(/[ \t]*<Analytics\s*\/>[ \t]*\r?\n?/g, "");
31
+ return i === n ? {
32
+ status: "success",
33
+ changed: !1
34
+ } : (f.writeFileSync(t, i, "utf8"), {
35
+ status: "success",
36
+ changed: !0
37
+ });
38
+ }
39
+ //#endregion
40
+ //#region src/patterns/disable/analytics/generate.runtime.ts
41
+ async function g(e) {
42
+ let a = t(e), o = [], s = [], d = (e) => {
43
+ e && o.push(e);
44
+ };
45
+ a.info("Reverting src/routes/+layout.svelte");
46
+ let f = p.join(e.root, "src", "routes", "+layout.svelte");
47
+ d(l(f, h(f))), a.info("Removing analytics variables from src/env.ts");
48
+ let m = u(e.root, n());
49
+ d(m.modify), m.delete && s.push(m.delete), a.info("Removing analytics variables from .env");
50
+ let g = p.join(e.root, ".env"), _ = c(g, i(g, r()));
51
+ return d(_.modify), _.delete && s.push(_.delete), {
52
+ creates: [],
53
+ modifies: o,
54
+ deletes: s,
55
+ components: [],
56
+ packages: [],
57
+ collections: [],
58
+ collectionPatches: [],
59
+ collectionDrops: []
60
+ };
61
+ }
62
+ //#endregion
63
+ export { g as generate };
64
+
65
+ //# sourceMappingURL=generate.runtime-DHBRyMAq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-DHBRyMAq.js","names":[],"sources":["../../src/patterns/disable/analytics/modifies/layout.svelte.ts","../../src/patterns/disable/analytics/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nconst MODULE = \"components/analytics/analytics.svelte\";\n\n/**\n * Takes `<Analytics />` and its import back out of the root layout. The\n * element goes with its whole line, since enable-analytics put it on one of\n * its own. A layout without it, or no layout at all, is left alone.\n */\nexport function unmodifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(MODULE) && !original.includes(\"<Analytics\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(MODULE));\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n const updated = file\n .toString()\n .replace(/[ \\t]*<Analytics\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(layoutPath, updated, \"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 { modifyEnvRemove } from \"../../../runtime/env\";\nimport {\n envRevertOutcomeToFile,\n modifyOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { allEnvEdits, allEnvNames } from \"./generate\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { unmodifyLayoutSvelte } from \"./modifies/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 src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, unmodifyLayoutSvelte(layoutPath)));\n\n // Which provider was chosen is not recorded, so every one's variables go;\n // the file goes too when these were all it declared.\n logger.info(\"Removing analytics variables from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(options.root, allEnvNames());\n pushResult(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Removing analytics variables from .env\");\n const envPath = path.join(options.root, \".env\");\n const env = envRevertOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, allEnvEdits()),\n );\n pushResult(env.modify);\n if (env.delete) deletes.push(env.delete);\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":";;;;;;;;;;;AAUA,IAAM,IAAS;AAOf,SAAgB,EAAqB,GAAmC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAY,MAAM;CACnD,IAAI,CAAC,EAAS,SAAS,CAAM,KAAK,CAAC,EAAS,SAAS,YAAY,GAC/D,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,EAAW,SAAS,CAAU;CAC3C,EA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 import { n as t } from "./logger-CQONztPm.js";
3
+ import { n } from "./shared-CZC4d7Uj.js";
4
+ import { n as r, r as i, t as a } from "./generate-Gcc8iRkZ.js";
5
+ import { n as o } from "./env-BPfk1VAw.js";
6
+ import { envRevertOutcomeToFile as s } from "./modify-file-BlDeeurK.js";
7
+ import { unmodifyEnvVarsFiles as c } from "./env-vars-C1NUX-bf.js";
8
+ import l from "node:fs";
9
+ import u from "node:path";
10
+ //#region src/patterns/disable/ai/generate.runtime.ts
11
+ async function d(d) {
12
+ let f = t(d), p = [], m = [], h = e(d);
13
+ for (let e of i(d)) {
14
+ let t = `${e}/+page.svelte`;
15
+ e !== h && l.existsSync(u.join(d.root, t)) && m.push(n(t));
16
+ }
17
+ f.info("Removing the AI provider's API key from src/env.ts");
18
+ let g = c(d.root, r());
19
+ g.modify && p.push(g.modify), g.delete && m.push(g.delete), f.info("Removing the AI provider's API key from .env");
20
+ let _ = u.join(d.root, ".env"), v = s(_, o(_, a()));
21
+ return v.modify && p.push(v.modify), v.delete && m.push(v.delete), {
22
+ creates: [],
23
+ modifies: p,
24
+ deletes: m,
25
+ components: [],
26
+ packages: [],
27
+ collections: [],
28
+ collectionPatches: [],
29
+ collectionDrops: []
30
+ };
31
+ }
32
+ //#endregion
33
+ export { d as generate };
34
+
35
+ //# sourceMappingURL=generate.runtime-DV3WmZtb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-DV3WmZtb.js","names":[],"sources":["../../src/patterns/disable/ai/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyEnvRemove } from \"../../../runtime/env\";\nimport { envRevertOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { demoDir } from \"../../enable/ai/generate\";\nimport { allEnvEdits, allEnvNames, demoDirs } from \"./generate\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n // The base result names the page in the current default group; a page\n // generated before auth was enabled sits in the other one.\n const current = demoDir(options);\n for (const dir of demoDirs(options)) {\n const page = `${dir}/+page.svelte`;\n if (dir !== current && fs.existsSync(path.join(options.root, page))) {\n deletes.push(toDeleteEntry(page));\n }\n }\n\n // Which provider was chosen is not recorded, so every one's key goes; the\n // file goes too when these were all it declared.\n logger.info(\"Removing the AI provider's API key from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(options.root, allEnvNames());\n if (envVars.modify) modifies.push(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Removing the AI provider's API key from .env\");\n const envPath = path.join(options.root, \".env\");\n const env = envRevertOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, allEnvEdits()),\n );\n if (env.modify) modifies.push(env.modify);\n if (env.delete) deletes.push(env.delete);\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":";;;;;;;;;;AAWA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,IAAkB,CAAC,GAInB,IAAU,EAAQ,CAAO;CAC/B,KAAK,IAAM,KAAO,EAAS,CAAO,GAAG;EACnC,IAAM,IAAO,GAAG,EAAI;EACpB,AAAI,MAAQ,KAAW,EAAG,WAAW,EAAK,KAAK,EAAQ,MAAM,CAAI,CAAC,KAChE,EAAQ,KAAK,EAAc,CAAI,CAAC;CAEpC;CAIA,EAAO,KAAK,oDAAoD;CAChE,IAAM,IAAU,EAAqB,EAAQ,MAAM,EAAY,CAAC;CAIhE,AAHI,EAAQ,UAAQ,EAAS,KAAK,EAAQ,MAAM,GAC5C,EAAQ,UAAQ,EAAQ,KAAK,EAAQ,MAAM,GAE/C,EAAO,KAAK,8CAA8C;CAC1D,IAAM,IAAU,EAAK,KAAK,EAAQ,MAAM,MAAM,GACxC,IAAM,EACV,GACA,EAAgB,GAAS,EAAY,CAAC,CACxC;CAIA,OAHI,EAAI,UAAQ,EAAS,KAAK,EAAI,MAAM,GACpC,EAAI,UAAQ,EAAQ,KAAK,EAAI,MAAM,GAEhC;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,164 @@
1
+ import { a as e } from "./util-BLYliuUK.js";
2
+ import { t } from "./dedent-Gq6Krl4n.js";
3
+ import { n } from "./logger-CQONztPm.js";
4
+ import { t as r } from "./env-vars-mnRA0hOe.js";
5
+ import { c as i, i as a, n as o, o as s } from "./ts-morph-helpers-CDW4lhox.js";
6
+ import { modifyOutcomeToFile as c } from "./modify-file-BlDeeurK.js";
7
+ import { modifyEnvVarsFiles as l } from "./env-vars-C1NUX-bf.js";
8
+ import { r as u } from "./compose-handle-D_Rz3Fzo.js";
9
+ import { c as d, i as f, n as p, o as m, r as h, t as g } from "./test-setup-DEmWd9Ul.js";
10
+ import _ from "node:fs";
11
+ import v from "node:path";
12
+ import { Node as y, Project as b, QuoteKind as x } from "ts-morph";
13
+ //#region src/patterns/enable/backend/modifies/tsconfig.ts
14
+ var S = ".svelte-kit/types/pocketbase/*.d.ts", C = [
15
+ "ts",
16
+ "mts",
17
+ "js",
18
+ "mjs"
19
+ ].map((e) => `vitest.config.${e}`);
20
+ function w(e) {
21
+ let t = v.join(e, "tsconfig.json");
22
+ if (!_.existsSync(t)) return {
23
+ status: "success",
24
+ changed: !1
25
+ };
26
+ let n = _.readFileSync(t, "utf8"), r = C.find((t) => _.existsSync(v.join(e, t))) ?? "vitest.config.ts", i = [
27
+ "test",
28
+ r,
29
+ S
30
+ ], a;
31
+ try {
32
+ a = JSON.parse(n);
33
+ } catch {
34
+ return {
35
+ status: "failed",
36
+ message: `Add these to the "include" array of tsconfig.json: ${i.map((e) => JSON.stringify(e)).join(", ")}`
37
+ };
38
+ }
39
+ let o = a.include;
40
+ if (o === void 0) return {
41
+ status: "success",
42
+ changed: !1
43
+ };
44
+ if (!Array.isArray(o)) return {
45
+ status: "failed",
46
+ message: `tsconfig.json "include" is not an array; it needs ${i.join(", ")}`
47
+ };
48
+ let s = (e) => typeof e == "string" ? e.replace(/^\.\//, "") : e, c = (e) => o.some((t) => s(t) === e), l = [...o], u = (e, t) => {
49
+ if (c(e)) return;
50
+ let n = -1;
51
+ l.forEach((e, r) => {
52
+ t(e) && (n = r);
53
+ }), l.splice(n === -1 ? l.length : n + 1, 0, e);
54
+ };
55
+ if (u("test", (e) => s(e) === "src"), u(r, (e) => /^vite\.config\.[cm]?[jt]s$/.test(String(s(e)))), u(S, () => !1), l.length === o.length) return {
56
+ status: "success",
57
+ changed: !1
58
+ };
59
+ a.include = l;
60
+ let d = n.match(/^\{\s*\n([\t ]+)/)?.[1] ?? " ";
61
+ return _.writeFileSync(t, `${JSON.stringify(a, null, d)}\n`), {
62
+ status: "success",
63
+ changed: !0
64
+ };
65
+ }
66
+ //#endregion
67
+ //#region src/patterns/enable/backend/modifies/hooks.server.ts
68
+ var T = [
69
+ "POCKETBASE_URL",
70
+ "POCKETBASE_SUPERUSER_EMAIL",
71
+ "POCKETBASE_SUPERUSER_PASSWORD"
72
+ ], E = t`
73
+ handlePocketbase({
74
+ pocketbaseUrl: POCKETBASE_URL,
75
+ superuserEmail: POCKETBASE_SUPERUSER_EMAIL,
76
+ superuserPassword: POCKETBASE_SUPERUSER_PASSWORD
77
+ })
78
+ `, D = t`
79
+ Add the PocketBase handle to the exported handle in src/hooks.server.ts:
80
+
81
+ import { sequence } from '@sveltejs/kit/hooks';
82
+ import {
83
+ POCKETBASE_URL,
84
+ POCKETBASE_SUPERUSER_EMAIL,
85
+ POCKETBASE_SUPERUSER_PASSWORD
86
+ } from '$app/env/private';
87
+ import { handlePocketbase } from '@velastack/pocketbase';
88
+
89
+ export const handle = sequence(
90
+ /* your existing handle */,
91
+ ${E.replace(/\n/g, "\n ")}
92
+ );
93
+ `;
94
+ function O(e) {
95
+ if (!_.existsSync(e)) return {
96
+ status: "success",
97
+ changed: !1
98
+ };
99
+ let t = _.readFileSync(e, "utf8"), n = new b({
100
+ compilerOptions: { allowJs: !0 },
101
+ manipulationSettings: { quoteKind: x.Single }
102
+ }).addSourceFileAtPath(e), r = u(n, "handleStatic", {
103
+ expression: E,
104
+ name: "handlePocketbase",
105
+ position: "last"
106
+ });
107
+ if (r.status === "unsupported") return {
108
+ status: "failed",
109
+ message: D
110
+ };
111
+ if (r.status === "unchanged") return {
112
+ status: "success",
113
+ changed: !1
114
+ };
115
+ let c = r.statement;
116
+ if (c && y.isJSDocable(c)) for (let e of c.getJsDocs()) e.getText().includes("vela legal") && e.remove();
117
+ i(n, ["@velastack/kit"]);
118
+ for (let e of T) a(n, "$app/env/private", e);
119
+ return a(n, "@velastack/pocketbase", "handlePocketbase"), s(n), o(n), n.saveSync(), {
120
+ status: "success",
121
+ changed: n.getFullText() !== t
122
+ };
123
+ }
124
+ //#endregion
125
+ //#region src/patterns/enable/backend/generate.runtime.ts
126
+ async function k(t) {
127
+ let i = n(t), a = [], o = [], s = (t, n) => o.push({
128
+ path: t,
129
+ language: e(t),
130
+ content: n,
131
+ status: "success"
132
+ });
133
+ i.info("Modifying adapter config");
134
+ let u = d(t.root), y = c(u.filePath, u.outcome);
135
+ y && a.push(y);
136
+ let b = v.join(t.root, "src", "hooks.server.ts"), x = c(b, O(b));
137
+ x && (i.info("Modifying hooks.server.ts"), a.push(x)), i.info("Declaring the PocketBase variables in src/env.ts");
138
+ let S = l(t.root, r);
139
+ S.create && o.push(S.create), S.modify && a.push(S.modify), i.info("Modifying .gitignore");
140
+ let C = v.join(t.root, ".gitignore"), T = c(C, m(C));
141
+ T && a.push(T);
142
+ let E = v.join(t.root, "test", "setup.ts");
143
+ if (_.existsSync(E)) {
144
+ i.info("Modifying test/setup.ts");
145
+ let e = c(E, f(E));
146
+ e && a.push(e);
147
+ } else i.info("Creating test/setup.ts"), s("test/setup.ts", p);
148
+ h(t.root) || (i.info("Creating vitest.config.ts"), s("vitest.config.ts", g));
149
+ let D = v.join(t.root, "tsconfig.json"), k = c(D, w(t.root));
150
+ return k && (i.info("Modifying tsconfig.json"), a.push(k)), {
151
+ creates: o,
152
+ modifies: a,
153
+ deletes: [],
154
+ components: [],
155
+ packages: [],
156
+ collections: [],
157
+ collectionPatches: [],
158
+ collectionDrops: []
159
+ };
160
+ }
161
+ //#endregion
162
+ export { k as generate };
163
+
164
+ //# sourceMappingURL=generate.runtime-D_sQOeQa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-D_sQOeQa.js","names":[],"sources":["../../src/patterns/enable/backend/modifies/tsconfig.ts","../../src/patterns/enable/backend/modifies/hooks.server.ts","../../src/patterns/enable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Where `vela sync` writes PocketBase's generated types (`Schemas`, the typed client). */\nexport const POCKETBASE_TYPES = \".svelte-kit/types/pocketbase/*.d.ts\";\n\nconst VITEST_CONFIGS = [\"ts\", \"mts\", \"js\", \"mjs\"].map(\n (ext) => `vitest.config.${ext}`,\n);\n\n/**\n * SvelteKit 3's `$app/tsconfig` lists no files: the project's own `include`\n * decides what is type-checked, and `sv create` writes `[\"src\",\n * \"vite.config.ts\"]`. A backend adds three things that have to be in it, as\n * they are in vela's minimal template: `test` (the server-test context that\n * every `server.test.ts` reads), the vitest config, and PocketBase's generated\n * types, without which `Schemas` is missing from `@velastack/pocketbase`.\n *\n * Entries already there stay, in their order. A tsconfig with no `include`\n * checks everything already; one that is not plain JSON (comments) is left\n * alone with the entries to add.\n */\nexport function modifyTsconfigBackend(root: string): ModifyOutcome {\n const filePath = path.join(root, \"tsconfig.json\");\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n const vitestConfig =\n VITEST_CONFIGS.find((name) => fs.existsSync(path.join(root, name))) ??\n \"vitest.config.ts\";\n const wanted = [\"test\", vitestConfig, POCKETBASE_TYPES];\n\n let config: Record<string, unknown>;\n try {\n config = JSON.parse(original) as Record<string, unknown>;\n } catch {\n return {\n status: \"failed\",\n message: `Add these to the \"include\" array of tsconfig.json: ${wanted\n .map((entry) => JSON.stringify(entry))\n .join(\", \")}`,\n };\n }\n const include = config.include;\n if (include === undefined) {\n return { status: \"success\", changed: false };\n }\n if (!Array.isArray(include)) {\n return {\n status: \"failed\",\n message: `tsconfig.json \"include\" is not an array; it needs ${wanted.join(\", \")}`,\n };\n }\n\n const normalize = (entry: unknown) =>\n typeof entry === \"string\" ? entry.replace(/^\\.\\//, \"\") : entry;\n const has = (entry: string) =>\n include.some((existing) => normalize(existing) === entry);\n const next = [...include] as unknown[];\n const insertAfter = (entry: string, after: (e: unknown) => boolean) => {\n if (has(entry)) return;\n let index = -1;\n next.forEach((e, i) => {\n if (after(e)) index = i;\n });\n next.splice(index === -1 ? next.length : index + 1, 0, entry);\n };\n insertAfter(\"test\", (e) => normalize(e) === \"src\");\n insertAfter(vitestConfig, (e) =>\n /^vite\\.config\\.[cm]?[jt]s$/.test(String(normalize(e))),\n );\n insertAfter(POCKETBASE_TYPES, () => false);\n\n if (next.length === include.length) {\n return { status: \"success\", changed: false };\n }\n config.include = next;\n const indent = original.match(/^\\{\\s*\\n([\\t ]+)/)?.[1] ?? \"\\t\";\n fs.writeFileSync(filePath, `${JSON.stringify(config, null, indent)}\\n`);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node, Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { replaceHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n ensureNamedImport,\n pruneUnusedImports,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** The variables the handle reads, imported from `$app/env/private`. */\nexport const POCKETBASE_ENV_NAMES = [\n \"POCKETBASE_URL\",\n \"POCKETBASE_SUPERUSER_EMAIL\",\n \"POCKETBASE_SUPERUSER_PASSWORD\",\n] as const;\n\n/** The handle `creates/src/hooks.server.ts` exports, for a file that already exists. */\nexport const POCKETBASE_HANDLE = dedent`\n handlePocketbase({\n \tpocketbaseUrl: POCKETBASE_URL,\n \tsuperuserEmail: POCKETBASE_SUPERUSER_EMAIL,\n \tsuperuserPassword: POCKETBASE_SUPERUSER_PASSWORD\n })\n`;\n\nconst FAILURE_HINT = dedent`\n Add the PocketBase handle to the exported handle in src/hooks.server.ts:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import {\n \tPOCKETBASE_URL,\n \tPOCKETBASE_SUPERUSER_EMAIL,\n \tPOCKETBASE_SUPERUSER_PASSWORD\n } from '$app/env/private';\n import { handlePocketbase } from '@velastack/pocketbase';\n\n export const handle = sequence(\n \t/* your existing handle */,\n \t${POCKETBASE_HANDLE.replace(/\\n/g, \"\\n\\t\")}\n );\n`;\n\n/**\n * Compose the PocketBase handle into a `hooks.server.ts` the project already\n * has, instead of the create overwriting it: a static site's, or one i18n or\n * content negotiation wrote. It takes `handleStatic()`'s place, since\n * `handlePocketbase` does what that did and more; otherwise it goes last, so\n * the handles already there keep running first.\n */\nexport function modifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // The create writes it.\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const composed = replaceHandle(sourceFile, \"handleStatic\", {\n expression: POCKETBASE_HANDLE,\n name: \"handlePocketbase\",\n position: \"last\",\n });\n if (composed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (composed.status === \"unchanged\") {\n return { status: \"success\", changed: false };\n }\n\n // The static template's comment explains handleStatic(). Where that was the\n // whole handle, replaceHandle already dropped it; in a sequence (i18n or\n // negotiation composed in since) it is still there, describing a handle\n // that is gone.\n const statement = composed.statement;\n if (statement && Node.isJSDocable(statement)) {\n for (const doc of statement.getJsDocs()) {\n if (doc.getText().includes(\"vela legal\")) doc.remove();\n }\n }\n\n pruneUnusedImports(sourceFile, [\"@velastack/kit\"]);\n for (const name of POCKETBASE_ENV_NAMES) {\n ensureNamedImport(sourceFile, \"$app/env/private\", name);\n }\n ensureNamedImport(sourceFile, \"@velastack/pocketbase\", \"handlePocketbase\");\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { modifyTsconfigBackend } from \"./modifies/tsconfig\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n hasVitestConfig,\n modifyTestSetup,\n VITEST_CONFIG,\n WITH_BACKEND,\n} from \"./modifies/test-setup\";\nimport { modifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { BACKEND_ENV_VARS } from \"./env-vars\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const creates: File[] = [];\n const create = (filePath: string, content: string) =>\n creates.push({\n path: filePath,\n language: languageFromPath(filePath),\n content,\n status: \"success\",\n });\n\n logger.info(\"Modifying adapter config\");\n const adapter = modifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(\n adapter.filePath,\n adapter.outcome,\n );\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // A hooks.server.ts the project already has keeps its handles; the create\n // only writes the file where there is none (see `keepMissing` in index.ts).\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerFile = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerFile) {\n logger.info(\"Modifying hooks.server.ts\");\n modifies.push(hooksServerFile);\n }\n\n // SvelteKit 3 exposes only declared variables: the handle above reads\n // these three from `$app/env/private`.\n logger.info(\"Declaring the PocketBase variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, BACKEND_ENV_VARS);\n if (envVars.create) creates.push(envVars.create);\n if (envVars.modify) modifies.push(envVars.modify);\n\n logger.info(\"Modifying .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n modifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n // A backend brings server tests with it. The static template and a project\n // vela did not create have no harness at all, so what is missing is created:\n // the setup file, and the vitest config that loads it.\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n if (fs.existsSync(testSetupPath)) {\n logger.info(\"Modifying test/setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n modifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n } else {\n logger.info(\"Creating test/setup.ts\");\n create(\"test/setup.ts\", WITH_BACKEND);\n }\n\n if (!hasVitestConfig(options.root)) {\n logger.info(\"Creating vitest.config.ts\");\n create(\"vitest.config.ts\", VITEST_CONFIG);\n }\n\n // Kit 3's tsconfig lists no files, so the test harness and PocketBase's\n // generated types are type-checked only when the project's include names them.\n const tsconfigPath = path.join(options.root, \"tsconfig.json\");\n const tsconfigFile = modifyOutcomeToFile(\n tsconfigPath,\n modifyTsconfigBackend(options.root),\n );\n if (tsconfigFile) {\n logger.info(\"Modifying tsconfig.json\");\n modifies.push(tsconfigFile);\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,IAAa,IAAmB,uCAE1B,IAAiB;CAAC;CAAM;CAAO;CAAM;AAAK,CAAC,CAAC,KAC/C,MAAQ,iBAAiB,GAC5B;AAcA,SAAgB,EAAsB,GAA6B;CACjE,IAAM,IAAW,EAAK,KAAK,GAAM,eAAe;CAChD,IAAI,CAAC,EAAG,WAAW,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAM,IAAW,EAAG,aAAa,GAAU,MAAM,GAC3C,IACJ,EAAe,MAAM,MAAS,EAAG,WAAW,EAAK,KAAK,GAAM,CAAI,CAAC,CAAC,KAClE,oBACI,IAAS;EAAC;EAAQ;EAAc;CAAgB,GAElD;CACJ,IAAI;EACF,IAAS,KAAK,MAAM,CAAQ;CAC9B,QAAQ;EACN,OAAO;GACL,QAAQ;GACR,SAAS,sDAAsD,EAC5D,KAAK,MAAU,KAAK,UAAU,CAAK,CAAC,CAAC,CACrC,KAAK,IAAI;EACd;CACF;CACA,IAAM,IAAU,EAAO;CACvB,IAAI,MAAY,KAAA,GACd,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAI,CAAC,MAAM,QAAQ,CAAO,GACxB,OAAO;EACL,QAAQ;EACR,SAAS,qDAAqD,EAAO,KAAK,IAAI;CAChF;CAGF,IAAM,KAAa,MACjB,OAAO,KAAU,WAAW,EAAM,QAAQ,SAAS,EAAE,IAAI,GACrD,KAAO,MACX,EAAQ,MAAM,MAAa,EAAU,CAAQ,MAAM,CAAK,GACpD,IAAO,CAAC,GAAG,CAAO,GAClB,KAAe,GAAe,MAAmC;EACrE,IA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D,IAAgB,EACpB,GACA,EAAgB,CAAa,CAC/B;CACA,AAAI,KAAe,EAAS,KAAK,CAAa;CAK9C,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,QAAQ,UAAU;CAChE,IAAI,EAAG,WAAW,CAAa,GAAG;EAChC,EAAO,KAAK,yBAAyB;EACrC,IAAM,IAAgB,EACpB,GACA,EAAgB,CAAa,CAC/B;EACA,AAAI,KAAe,EAAS,KAAK,CAAa;CAChD,OAEE,AADA,EAAO,KAAK,wBAAwB,GACpC,EAAO,iBAAiB,CAAY;CAGtC,AAAK,EAAgB,EAAQ,IAAI,MAC/B,EAAO,KAAK,2BAA2B,GACvC,EAAO,oBAAoB,CAAa;CAK1C,IAAM,IAAe,EAAK,KAAK,EAAQ,MAAM,eAAe,GACtD,IAAe,EACnB,GACA,EAAsB,EAAQ,IAAI,CACpC;CAMA,OALI,MACF,EAAO,KAAK,yBAAyB,GACrC,EAAS,KAAK,CAAY,IAGrB;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { n as e } from "./logger-CQONztPm.js";
2
- import { o as t } from "./ts-morph-helpers-CeduA--o.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-Dwfv0dCI.js";
2
+ import { o as t } from "./ts-morph-helpers-CDW4lhox.js";
3
+ import { modifyOutcomeToFile as n } from "./modify-file-BlDeeurK.js";
4
4
  import r from "node:fs";
5
5
  import i from "node:path";
6
6
  import { Project as a, SyntaxKind as o } from "ts-morph";
@@ -54,4 +54,4 @@ async function c(t) {
54
54
  //#endregion
55
55
  export { c as generate };
56
56
 
57
- //# sourceMappingURL=generate.runtime-ofdnLtxS.js.map
57
+ //# sourceMappingURL=generate.runtime-DqD3PW-W.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-ofdnLtxS.js","names":[],"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,SAAgB,EAAoB,GAAwC;CAC1E,IAAI,CAAC,EAAG,WAAW,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAiB,MAAM,GAExD,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAe,GAExD,IAAW,EACd,qBAAqB,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAAC,GACH,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,EAAS,aAAa;CACnC,IAAI,EAAK,WAAW,GAClB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAK;CACtB,IAAI,EAAS,QAAQ,MAAM,EAAW,yBACpC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAa,EAAS,cAAc,EAAW,uBAAuB,GACtE,IAAU,EAAW,YAAY,KAAK;CAc5C,OAbK,KAIL,EAAQ,OAAO,GAEX,EAAW,cAAc,CAAC,CAAC,WAAW,KACxC,EAAS,eAAe,CAAC,GAG3B,EAAiB,CAAU,GAC3B,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAAS,EAAW,YAAY,MAAM;CACxC,KAfS;EAAE,QAAQ;EAAW,SAAS;CAAM;AAgB/C;;;AC7CA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,iBAAiB,GAClE,IAAO,EACX,GACA,EAAoB,CAAe,CACrC;CAGA,OAFI,KAAM,EAAS,KAAK,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
+ {"version":3,"file":"generate.runtime-DqD3PW-W.js","names":[],"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,SAAgB,EAAoB,GAAwC;CAC1E,IAAI,CAAC,EAAG,WAAW,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAiB,MAAM,GAExD,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAe,GAExD,IAAW,EACd,qBAAqB,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAAC,GACH,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,EAAS,aAAa;CACnC,IAAI,EAAK,WAAW,GAClB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAK;CACtB,IAAI,EAAS,QAAQ,MAAM,EAAW,yBACpC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAa,EAAS,cAAc,EAAW,uBAAuB,GACtE,IAAU,EAAW,YAAY,KAAK;CAc5C,OAbK,KAIL,EAAQ,OAAO,GAEX,EAAW,cAAc,CAAC,CAAC,WAAW,KACxC,EAAS,eAAe,CAAC,GAG3B,EAAiB,CAAU,GAC3B,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAAS,EAAW,YAAY,MAAM;CACxC,KAfS;EAAE,QAAQ;EAAW,SAAS;CAAM;AAgB/C;;;AC7CA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,iBAAiB,GAClE,IAAO,EACX,GACA,EAAoB,CAAe,CACrC;CAGA,OAFI,KAAM,EAAS,KAAK,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,10 +1,10 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { n } from "./generate-CyuY2Ci7.js";
4
- import { _ as r, o as i, r as a } from "./ts-morph-helpers-CeduA--o.js";
5
- import { modifyOutcomeToFile as o } from "./modify-file-Dwfv0dCI.js";
3
+ import { n } from "./generate-DeaBlnK6.js";
4
+ import { _ as r, o as i, r as a } from "./ts-morph-helpers-CDW4lhox.js";
5
+ import { modifyOutcomeToFile as o } from "./modify-file-BlDeeurK.js";
6
6
  import { t as s } from "./svelte-file-B3RfgVdt.js";
7
- import { a as c, t as l } from "./config-target-Bln26FJe.js";
7
+ import { a as c, t as l } from "./config-target-Dx3w6WSk.js";
8
8
  import u from "node:fs";
9
9
  import d from "node:path";
10
10
  import { Node as f, Project as p, QuoteKind as m, SyntaxKind as h } from "ts-morph";
@@ -159,7 +159,7 @@ var j = { expression: () => "'en'" }, M = {
159
159
  expression: (e) => `getLocale(${e}.url)`,
160
160
  imports: [{
161
161
  namedImports: ["getLocale"],
162
- moduleSpecifier: "$locales/main.url"
162
+ moduleSpecifier: "#locales/main.url.js"
163
163
  }]
164
164
  };
165
165
  function N(t, n) {
@@ -177,7 +177,7 @@ function P(e) {
177
177
  function F(t) {
178
178
  let n = [
179
179
  "import { error, redirect } from '@sveltejs/kit';",
180
- "import { loadCms } from '$lib/cms';",
180
+ "import { loadCms } from '#lib/cms.js';",
181
181
  ...(t.imports ?? []).map(P),
182
182
  "import type { LayoutServerLoad } from './$types';"
183
183
  ].join("\n"), r = N("event", t.expression("event")).split("\n").join("\n ");
@@ -240,7 +240,7 @@ function L(e, t = j) {
240
240
  let t = o.param.getTypeNode()?.getText();
241
241
  o.param.replaceWithText(t ? `${l}: ${t}` : l);
242
242
  } else o.kind === "none" && r.addParameter({ name: l });
243
- r.isAsync() || r.setIsAsync(!0), x(n, "@sveltejs/kit", ["error", "redirect"]), x(n, "$lib/cms", ["loadCms"]);
243
+ r.isAsync() || r.setIsAsync(!0), x(n, "@sveltejs/kit", ["error", "redirect"]), x(n, "#lib/cms.js", ["loadCms"]);
244
244
  for (let e of t.imports ?? []) S(n, e);
245
245
  return i(n), n.saveSync(), {
246
246
  status: "success",
@@ -397,4 +397,4 @@ async function q(e) {
397
397
  //#endregion
398
398
  export { q as generate };
399
399
 
400
- //# sourceMappingURL=generate.runtime-VgVwRiiN.js.map
400
+ //# sourceMappingURL=generate.runtime-Dtgw9IQO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-Dtgw9IQO.js","names":[],"sources":["../../src/patterns/enable/cms/modifies/vite-config.ts","../../src/patterns/enable/cms/modifies/load-function.ts","../../src/patterns/enable/cms/modifies/layout.server.ts","../../src/patterns/enable/cms/modifies/layout.ts","../../src/patterns/enable/cms/modifies/layout.svelte.ts","../../src/patterns/enable/cms/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n type PropertyAssignment,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the CMS plugin to your Vite config, ahead of sveltekit():\",\n \"\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the CMS plugin ahead of sveltekit():\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit()],\",\n \"});\",\n].join(\"\\n\");\n\nfunction elementName(text: string): string {\n return text.replace(/\\s/g, \"\");\n}\n\n/**\n * Registers `cms(...)` from `@velastack/cms/vite` in the Vite plugin list, just\n * ahead of `sveltekit()`. Only the plugin array is touched, so the inline\n * `sveltekit({ ... })` shape the templates use is left alone.\n */\nexport function modifyViteConfig(\n viteConfigPath: string,\n pluginArgs = \"\",\n): ModifyOutcome {\n const call = `cms(${pluginArgs})`;\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"@velastack/cms/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"cms\"],\n moduleSpecifier: \"@velastack/cms/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: `[${call}]`,\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (pluginsProp as PropertyAssignment).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as PropertyAssignment).setInitializer(`[${call}]`);\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as ArrayLiteralExpression;\n const elements = arr.getElements();\n const hasCms = elements.some((el) =>\n elementName(el.getText()).startsWith(\"cms(\"),\n );\n\n if (!hasCms) {\n const sveltekitIndex = elements.findIndex((el) =>\n elementName(el.getText()).startsWith(\"sveltekit(\"),\n );\n arr.insertElement(sveltekitIndex === -1 ? 0 : sveltekitIndex, call);\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\nimport {\n ensureImportSpec,\n ensureNamedImports,\n findFinalReturn,\n findLoadFunction,\n hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport interface LayoutServerLocale {\n /**\n * Expression passed as `locale` to `loadCms`, given the name of the load's\n * event parameter: `() => \"'en'\"` or `(event) => \\`getLocale(${event}.url)\\``.\n */\n expression: (eventName: string) => string;\n /** Imports the expression depends on. */\n imports?: ImportSpec[];\n}\n\n/** A single-locale site: the literal default locale. */\nexport const DEFAULT_LOCALE: LayoutServerLocale = {\n expression: () => \"'en'\",\n};\n\n/** A wuchale site: the locale enable-i18n's reroute already resolved from the URL. */\nexport const WUCHALE_LOCALE: LayoutServerLocale = {\n expression: (eventName) => `getLocale(${eventName}.url)`,\n imports: [\n { namedImports: [\"getLocale\"], moduleSpecifier: \"#locales/main.url.js\" },\n ],\n};\n\nfunction cmsSnippet(eventName: string, locale: string): string {\n return dedent`\n const { cms, notFound, gone, redirectTo } = await loadCms(${eventName}, { locale: ${locale} });\n if (redirectTo) redirect(308, redirectTo);\n if (gone) error(410, 'Gone');\n if (notFound) error(404, 'Not found');\n `;\n}\n\nfunction importLine(spec: ImportSpec): string {\n const parts: string[] = [];\n if (spec.defaultImport) parts.push(spec.defaultImport);\n if (spec.namespaceImport) parts.push(`* as ${spec.namespaceImport}`);\n if (spec.namedImports?.length)\n parts.push(`{ ${spec.namedImports.join(\", \")} }`);\n return `import ${parts.join(\", \")} from '${spec.moduleSpecifier}';`;\n}\n\n/**\n * A root `+layout.server.ts` written from scratch, for a project that has\n * none — the static template keeps its layout load universal.\n */\nexport function createdLayoutServer(locale: LayoutServerLocale): string {\n const imports = [\n \"import { error, redirect } from '@sveltejs/kit';\",\n \"import { loadCms } from '#lib/cms.js';\",\n ...(locale.imports ?? []).map(importLine),\n \"import type { LayoutServerLoad } from './$types';\",\n ].join(\"\\n\");\n const snippet = cmsSnippet(\"event\", locale.expression(\"event\"))\n .split(\"\\n\")\n .join(\"\\n\\t\");\n\n return dedent`\n ${imports}\n\n export const load: LayoutServerLoad = async (event) => {\n \t${snippet}\n\n \treturn { cms };\n };\n `.concat(\"\\n\");\n}\n\nconst FAILURE_HINT = [\n \"Call loadCms from the root +layout.server.ts load and return `cms`:\",\n \"\",\n createdLayoutServer(DEFAULT_LOCALE).trimEnd(),\n \"\",\n \"loadCms needs the whole event, so a destructured parameter has to become\",\n \"`event` with the destructuring moved into the body.\",\n].join(\"\\n\");\n\n/**\n * Wires `loadCms` into the root `+layout.server.ts`, creating the file when\n * the project has none:\n *\n * - `loadCms` needs the whole request event, so a destructured parameter is\n * renamed to `event` and the destructuring becomes the first statement.\n * - The tombstone triple (`redirectTo`, `gone`, `notFound`) is handled just\n * before the return.\n * - `cms` is added to the returned object, ahead of any spread so nothing\n * later can shadow it.\n *\n * Anything else — no exported `load`, an expression-bodied arrow, several\n * returns, a non-literal return — is reported as `failed` with the snippet to\n * paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServer(\n layoutServerPath: string,\n locale: LayoutServerLocale = DEFAULT_LOCALE,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n fs.mkdirSync(path.dirname(layoutServerPath), { recursive: true });\n fs.writeFileSync(layoutServerPath, createdLayoutServer(locale));\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"loadCms(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n\n // --- Inspect everything before touching anything. ---\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n const object = returned && returnedObject(returned);\n if (!returned || !object) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const eventName = event.kind === \"identifier\" ? event.name : \"event\";\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n if (!hasProperty(object, \"cms\")) {\n const spreadIndex = object\n .getProperties()\n .findIndex((property) => Node.isSpreadAssignment(property));\n if (spreadIndex === -1) {\n object.addShorthandPropertyAssignment({ name: \"cms\" });\n } else {\n object.insertShorthandPropertyAssignment(spreadIndex, { name: \"cms\" });\n }\n }\n\n // insertStatements counts comment lines, which getStatements() skips.\n const returnIndex = body.getStatementsWithComments().indexOf(returned);\n body.insertStatements(\n returnIndex,\n `\\n${cmsSnippet(eventName, locale.expression(eventName))}\\n`,\n );\n\n if (event.kind === \"binding\") {\n const destructuring = event.pattern.getText();\n body.insertStatements(0, `const ${destructuring} = ${eventName};`);\n const typeText = event.param.getTypeNode()?.getText();\n event.param.replaceWithText(\n typeText ? `${eventName}: ${typeText}` : eventName,\n );\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: eventName });\n }\n\n if (!fn.isAsync()) fn.setIsAsync(true);\n\n ensureNamedImports(sourceFile, \"@sveltejs/kit\", [\"error\", \"redirect\"]);\n ensureNamedImports(sourceFile, \"#lib/cms.js\", [\"loadCms\"]);\n for (const spec of locale.imports ?? []) {\n ensureImportSpec(sourceFile, spec);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n findFinalReturn,\n findLoadFunction,\n hasSpreadOf,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Forward the server load's data through the root +layout.ts, so \\`cms\\` reaches\n the page:\n\n export const load = async ({ url, data }) => {\n // ...existing code...\n return { ...data, /* existing keys */ };\n };\n`;\n\n/**\n * Make a universal root \\`+layout.ts\\` forward its server load's data.\n *\n * SvelteKit hands a universal load the server load's result as \\`data\\`, and\n * only what the universal load returns reaches the page. A layout that\n * returns its own object without spreading \\`data\\` — the static template\n * does — would drop \\`cms\\` on the floor once \\`+layout.server.ts\\` exists.\n *\n * No file, or a file without a \\`load\\`, needs nothing: server data flows\n * through on its own.\n */\nexport function modifyLayoutUniversal(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutPath);\n\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"success\", changed: false };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n if (!returned) return { status: \"failed\", message: FAILURE_HINT };\n\n const dataExpression =\n event.kind === \"identifier\" ? `${event.name}.data` : \"data\";\n\n // `return data;` already forwards everything.\n const expression = returned.getExpression();\n if (expression && expression.getText() === dataExpression) {\n return { status: \"success\", changed: false };\n }\n\n const object = returnedObject(returned);\n if (!object) return { status: \"failed\", message: FAILURE_HINT };\n if (hasSpreadOf(object, dataExpression)) {\n return { status: \"success\", changed: false };\n }\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n // First, so the layout's own keys still win over anything the server sent.\n object.insertSpreadAssignment(0, { expression: dataExpression });\n\n if (event.kind === \"binding\") {\n const hasData = event.pattern\n .getElements()\n .some((element) => element.getName() === \"data\");\n if (!hasData) {\n const text = event.pattern.getText();\n event.pattern.replaceWithText(text.replace(/^\\{\\s*/, \"{ data, \"));\n }\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: \"{ data }\" });\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { AdminBar } from '@velastack/cms';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<AdminBar />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <AdminBar /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <AdminBar /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<AdminBar />` at the top level of the root layout, ahead of\n * `{@render children()}` so the bar is in the DOM before the page content.\n * Falls back to appending when the layout has no render tag or slot.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"AdminBar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { namedImports: [\"AdminBar\"], moduleSpecifier: \"@velastack/cms\" },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { resolveMode, type CmsMode } from \"./generate\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport {\n DEFAULT_LOCALE,\n WUCHALE_LOCALE,\n modifyLayoutServer,\n} from \"./modifies/layout.server\";\nimport { modifyLayoutUniversal } from \"./modifies/layout\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\n/** The locale list from `wuchale.config.js`, or null when it cannot be read. */\nexport function readWuchaleLocales(root: string): string[] | null {\n const configPath = path.join(root, \"wuchale.config.js\");\n if (!fs.existsSync(configPath)) return null;\n const match = fs\n .readFileSync(configPath, \"utf8\")\n .match(/locales:\\s*\\[([^\\]]*)\\]/);\n if (!match) return null;\n const locales = [...match[1].matchAll(/['\"]([^'\"]+)['\"]/g)].map((m) => m[1]);\n return locales.length > 0 ? locales : null;\n}\n\n/**\n * Arguments for the `cms()` Vite plugin.\n *\n * A hosted CMS needs the endpoint and locales at build time so media can be\n * downloaded into the prerendered site. An app hosting the backend itself\n * needs nothing: the media steps are no-ops without an endpoint.\n */\nexport function vitePluginArgs(mode: CmsMode, locales: string[]): string {\n if (mode.local) return \"\";\n const list = locales.map((locale) => `'${locale}'`).join(\", \");\n return `{ endpoint: '${mode.endpoint}', locales: [${list}] }`;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const mode = resolveMode(options);\n const i18n = options.features.i18n;\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n const locales = (i18n && readWuchaleLocales(options.root)) || [\"en\"];\n pushResult(\n modifyOutcomeToFile(\n viteConfigPath,\n modifyViteConfig(viteConfigPath, vitePluginArgs(mode, locales)),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const locale = i18n ? WUCHALE_LOCALE : DEFAULT_LOCALE;\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServer(layoutServerPath, locale),\n ),\n );\n\n // A universal root layout has to pass the server load's data along, or\n // `cms` never reaches the page. The static template has one.\n logger.info(\"Modifying src/routes/+layout.ts\");\n const layoutUniversalPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutUniversalPath,\n modifyLayoutUniversal(layoutUniversalPath),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(layoutSveltePath, modifyLayoutSvelte(layoutSveltePath)),\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,IAAM,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACr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AY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -2,12 +2,12 @@ import { a as e } from "./util-BLYliuUK.js";
2
2
  import { t } from "./dedent-Gq6Krl4n.js";
3
3
  import { n } from "./logger-CQONztPm.js";
4
4
  import { t as r } from "./pocketbase-C5GS-Dh5.js";
5
- import { _ as i, o as a, r as o, t as s } from "./ts-morph-helpers-CeduA--o.js";
6
- import { modifyOutcomeToFile as c } from "./modify-file-Dwfv0dCI.js";
5
+ import { _ as i, o as a, r as o, t as s } from "./ts-morph-helpers-CDW4lhox.js";
6
+ import { modifyOutcomeToFile as c } from "./modify-file-BlDeeurK.js";
7
7
  import { t as l } from "./svelte-file-B3RfgVdt.js";
8
- import { i as u, n as d, t as f } from "./pocketbase-BkhUywtb.js";
9
- import { t as p } from "./site-BdMX8qrH.js";
10
- import { applyCollectionRulePatches as m, createCollectionIdempotent as h } from "./collections-CrOvS2E7.js";
8
+ import { i as u, n as d, t as f } from "./pocketbase-Dry6ry17.js";
9
+ import { t as p } from "./site-BwCA18Sv.js";
10
+ import { applyCollectionRulePatches as m, createCollectionIdempotent as h } from "./collections-Dz2fvKnz.js";
11
11
  import g from "node:fs";
12
12
  import _ from "node:path";
13
13
  import { Project as v, SyntaxKind as y } from "ts-morph";
@@ -41,11 +41,11 @@ function S(e) {
41
41
  //#endregion
42
42
  //#region src/patterns/enable/teams/modifies/modify-app-sidebar.ts
43
43
  var C = "<Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>", w = [
44
- "import favicon from '$lib/assets/favicon.svg';",
45
- "import TeamSwitcher from '$lib/components/team-switcher.svelte';",
44
+ "import favicon from '#lib/assets/favicon.svg';",
45
+ "import TeamSwitcher from '#lib/components/team-switcher.svelte';",
46
46
  "import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';",
47
- "import * as Avatar from '$lib/components/ui/avatar';",
48
- "import { site } from '$lib/site';"
47
+ "import * as Avatar from '#lib/components/ui/avatar/index.js';",
48
+ "import { site } from '#lib/site.js';"
49
49
  ].join("\n"), T = "{meta.appName}", E = [
50
50
  "Replace the <Sidebar.Header> in your app sidebar with the team switcher.",
51
51
  "",
@@ -71,15 +71,15 @@ function O(e, t) {
71
71
  let { source: n } = i(e, (e) => {
72
72
  t || o(e, [{
73
73
  namedImports: ["site"],
74
- moduleSpecifier: "$lib/site"
74
+ moduleSpecifier: "#lib/site.js"
75
75
  }]), o(e, [
76
76
  {
77
77
  defaultImport: "favicon",
78
- moduleSpecifier: "$lib/assets/favicon.svg"
78
+ moduleSpecifier: "#lib/assets/favicon.svg"
79
79
  },
80
80
  {
81
81
  defaultImport: "TeamSwitcher",
82
- moduleSpecifier: "$lib/components/team-switcher.svelte"
82
+ moduleSpecifier: "#lib/components/team-switcher.svelte"
83
83
  },
84
84
  {
85
85
  defaultImport: "ChevronsUpDownIcon",
@@ -87,7 +87,7 @@ function O(e, t) {
87
87
  },
88
88
  {
89
89
  namespaceImport: "Avatar",
90
- moduleSpecifier: "$lib/components/ui/avatar"
90
+ moduleSpecifier: "#lib/components/ui/avatar/index.js"
91
91
  }
92
92
  ]);
93
93
  for (let t of e.getVariableDeclarations()) {
@@ -627,4 +627,4 @@ async function L(e) {
627
627
  //#endregion
628
628
  export { L as generate };
629
629
 
630
- //# sourceMappingURL=generate.runtime-CN5c2xH8.js.map
630
+ //# sourceMappingURL=generate.runtime-IlBCcXvv.js.map