@velastack/patterns 0.3.4 → 0.4.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.
Files changed (207) 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-Dz2fvKnz.js.map +1 -0
  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/dedent-Gq6Krl4n.js.map +1 -1
  13. package/dist/chunks/dispatch-CXOXPLFk.js +6 -0
  14. package/dist/chunks/dispatch-CXOXPLFk.js.map +1 -0
  15. package/dist/chunks/env-BPfk1VAw.js.map +1 -1
  16. package/dist/chunks/env-vars-C1NUX-bf.js +268 -0
  17. package/dist/chunks/env-vars-C1NUX-bf.js.map +1 -0
  18. package/dist/chunks/env-vars-Cr4lbMD_.js +21 -0
  19. package/dist/chunks/env-vars-Cr4lbMD_.js.map +1 -0
  20. package/dist/chunks/env-vars-De0Xs0L2.js +20 -0
  21. package/dist/chunks/env-vars-De0Xs0L2.js.map +1 -0
  22. package/dist/chunks/env-vars-file-B_6esJW3.js +34 -0
  23. package/dist/chunks/env-vars-file-B_6esJW3.js.map +1 -0
  24. package/dist/chunks/env-vars-mnRA0hOe.js +19 -0
  25. package/dist/chunks/env-vars-mnRA0hOe.js.map +1 -0
  26. package/dist/chunks/env.preview-uMRKT5Pc.js.map +1 -1
  27. package/dist/chunks/errors-DR3gF_7a.js.map +1 -1
  28. package/dist/chunks/format-result-DZ8De8KY.js.map +1 -1
  29. package/dist/chunks/generate-BW3l5Fxw.js +252 -0
  30. package/dist/chunks/generate-BW3l5Fxw.js.map +1 -0
  31. package/dist/chunks/{generate-CyuY2Ci7.js → generate-DeaBlnK6.js} +25 -24
  32. package/dist/chunks/generate-DeaBlnK6.js.map +1 -0
  33. package/dist/chunks/generate-DetW_gbr.js +68 -0
  34. package/dist/chunks/generate-DetW_gbr.js.map +1 -0
  35. package/dist/chunks/{generate-DwADTUob.js → generate-Gcc8iRkZ.js} +9 -6
  36. package/dist/chunks/generate-Gcc8iRkZ.js.map +1 -0
  37. package/dist/chunks/{generate-DQeWOEPY.js → generate-WMJo3QGZ.js} +9 -6
  38. package/dist/chunks/generate-WMJo3QGZ.js.map +1 -0
  39. package/dist/chunks/generate.runtime-1-91UmM8.js +85 -0
  40. package/dist/chunks/generate.runtime-1-91UmM8.js.map +1 -0
  41. package/dist/chunks/generate.runtime-6FXJM8hT.js +67 -0
  42. package/dist/chunks/generate.runtime-6FXJM8hT.js.map +1 -0
  43. package/dist/chunks/generate.runtime-B1jVAnDI.js +155 -0
  44. package/dist/chunks/generate.runtime-B1jVAnDI.js.map +1 -0
  45. package/dist/chunks/generate.runtime-BA3tDKnn.js +147 -0
  46. package/dist/chunks/generate.runtime-BA3tDKnn.js.map +1 -0
  47. package/dist/chunks/{generate.runtime-4FDxnvCl.js → generate.runtime-BO778G0r.js} +5 -5
  48. package/dist/chunks/generate.runtime-BO778G0r.js.map +1 -0
  49. package/dist/chunks/{generate.runtime-Um77JfwC.js → generate.runtime-B_UVGa3q.js} +7 -7
  50. package/dist/chunks/generate.runtime-B_UVGa3q.js.map +1 -0
  51. package/dist/chunks/{generate.runtime-BKiJvE8I.js → generate.runtime-BgTz41Zg.js} +105 -101
  52. package/dist/chunks/generate.runtime-BgTz41Zg.js.map +1 -0
  53. package/dist/chunks/{generate.runtime-FdZw277n.js → generate.runtime-C6bSvGMb.js} +108 -142
  54. package/dist/chunks/generate.runtime-C6bSvGMb.js.map +1 -0
  55. package/dist/chunks/generate.runtime-C8zJRNYG.js +124 -0
  56. package/dist/chunks/generate.runtime-C8zJRNYG.js.map +1 -0
  57. package/dist/chunks/generate.runtime-CCr1lvo4.js +43 -0
  58. package/dist/chunks/generate.runtime-CCr1lvo4.js.map +1 -0
  59. package/dist/chunks/generate.runtime-CYagyR5c.js +326 -0
  60. package/dist/chunks/generate.runtime-CYagyR5c.js.map +1 -0
  61. package/dist/chunks/{generate.runtime-n9AFWtPp.js → generate.runtime-Ce_rwzNa.js} +4 -4
  62. package/dist/chunks/generate.runtime-Ce_rwzNa.js.map +1 -0
  63. package/dist/chunks/{generate.runtime-cQGLxuZM.js → generate.runtime-CexC1Oky.js} +4 -4
  64. package/dist/chunks/generate.runtime-CexC1Oky.js.map +1 -0
  65. package/dist/chunks/{generate.runtime-AYQVW1S-.js → generate.runtime-CnPraLKv.js} +35 -31
  66. package/dist/chunks/generate.runtime-CnPraLKv.js.map +1 -0
  67. package/dist/chunks/generate.runtime-CslAvllQ.js +112 -0
  68. package/dist/chunks/generate.runtime-CslAvllQ.js.map +1 -0
  69. package/dist/chunks/{generate.runtime-onBnOiS7.js → generate.runtime-CuNhY5hn.js} +10 -10
  70. package/dist/chunks/generate.runtime-CuNhY5hn.js.map +1 -0
  71. package/dist/chunks/{generate.runtime-B45MvtYm.js → generate.runtime-DD51OSuL.js} +14 -14
  72. package/dist/chunks/generate.runtime-DD51OSuL.js.map +1 -0
  73. package/dist/chunks/generate.runtime-DHBRyMAq.js +65 -0
  74. package/dist/chunks/generate.runtime-DHBRyMAq.js.map +1 -0
  75. package/dist/chunks/{generate.runtime-D1DNAY6k.js → generate.runtime-DM4o_QYY.js} +9 -9
  76. package/dist/chunks/generate.runtime-DM4o_QYY.js.map +1 -0
  77. package/dist/chunks/generate.runtime-DV3WmZtb.js +35 -0
  78. package/dist/chunks/generate.runtime-DV3WmZtb.js.map +1 -0
  79. package/dist/chunks/generate.runtime-D_sQOeQa.js +164 -0
  80. package/dist/chunks/generate.runtime-D_sQOeQa.js.map +1 -0
  81. package/dist/chunks/{generate.runtime-ofdnLtxS.js → generate.runtime-DqD3PW-W.js} +3 -3
  82. package/dist/chunks/generate.runtime-DqD3PW-W.js.map +1 -0
  83. package/dist/chunks/{generate.runtime-VgVwRiiN.js → generate.runtime-Dtgw9IQO.js} +8 -8
  84. package/dist/chunks/generate.runtime-Dtgw9IQO.js.map +1 -0
  85. package/dist/chunks/{generate.runtime-CN5c2xH8.js → generate.runtime-IlBCcXvv.js} +14 -14
  86. package/dist/chunks/generate.runtime-IlBCcXvv.js.map +1 -0
  87. package/dist/chunks/{generate.runtime-BSRFv4cJ.js → generate.runtime-cwvAoKoH.js} +3 -3
  88. package/dist/chunks/generate.runtime-cwvAoKoH.js.map +1 -0
  89. package/dist/chunks/{generate.runtime-DG-3G00z.js → generate.runtime-kvxmTlQb.js} +3 -3
  90. package/dist/chunks/{generate.runtime-DG-3G00z.js.map → generate.runtime-kvxmTlQb.js.map} +1 -1
  91. package/dist/chunks/generate.runtime-pVLzzpUM.js +122 -0
  92. package/dist/chunks/generate.runtime-pVLzzpUM.js.map +1 -0
  93. package/dist/chunks/{generate.runtime-BFOXm2DD.js → generate.runtime-zJpEufTc.js} +10 -10
  94. package/dist/chunks/generate.runtime-zJpEufTc.js.map +1 -0
  95. package/dist/chunks/lib-specifier-Cngo1zF_.js +33 -0
  96. package/dist/chunks/lib-specifier-Cngo1zF_.js.map +1 -0
  97. package/dist/chunks/logger-CQONztPm.js.map +1 -1
  98. package/dist/chunks/{modify-file-Dwfv0dCI.js → modify-file-BlDeeurK.js} +3 -3
  99. package/dist/chunks/modify-file-BlDeeurK.js.map +1 -0
  100. package/dist/chunks/{modify-svelte-config-remote-BUU_EaDf.js → modify-svelte-config-remote-p0TfVzxm.js} +8 -10
  101. package/dist/chunks/modify-svelte-config-remote-p0TfVzxm.js.map +1 -0
  102. package/dist/chunks/modify-utils-Cw-on_cL.js.map +1 -1
  103. package/dist/chunks/nav-user-BRIHOOpG.js +6 -0
  104. package/dist/chunks/nav-user-BRIHOOpG.js.map +1 -0
  105. package/dist/chunks/package-imports-Bbw3iMPg.js +173 -0
  106. package/dist/chunks/package-imports-Bbw3iMPg.js.map +1 -0
  107. package/dist/chunks/pocketbase-C5GS-Dh5.js.map +1 -1
  108. package/dist/chunks/pocketbase-DpudAAmd.js.map +1 -1
  109. package/dist/chunks/{pocketbase-BkhUywtb.js → pocketbase-Dry6ry17.js} +2 -2
  110. package/dist/chunks/pocketbase-Dry6ry17.js.map +1 -0
  111. package/dist/chunks/{providers-BL9vJP_9.js → providers-BHR6-XZ7.js} +11 -4
  112. package/dist/chunks/providers-BHR6-XZ7.js.map +1 -0
  113. package/dist/chunks/{shared-C8GtNxpm.js → shared-CZC4d7Uj.js} +2 -2
  114. package/dist/chunks/shared-CZC4d7Uj.js.map +1 -0
  115. package/dist/chunks/{site-BdMX8qrH.js → site-BwCA18Sv.js} +2 -2
  116. package/dist/chunks/site-BwCA18Sv.js.map +1 -0
  117. package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -1
  118. package/dist/chunks/table-core-AjBpYi-y.js +127 -0
  119. package/dist/chunks/table-core-AjBpYi-y.js.map +1 -0
  120. package/dist/chunks/{taggedTemplateLiteral-Dx0fjWiw.js → taggedTemplateLiteral-CswN2AAa.js} +1 -1
  121. package/dist/chunks/{test-setup-DHEFKEHE.js → test-setup-DEmWd9Ul.js} +76 -67
  122. package/dist/chunks/test-setup-DEmWd9Ul.js.map +1 -0
  123. package/dist/chunks/{ts-morph-helpers-CeduA--o.js → ts-morph-helpers-CDW4lhox.js} +77 -63
  124. package/dist/chunks/ts-morph-helpers-CDW4lhox.js.map +1 -0
  125. package/dist/chunks/ui-DD4NltyN.js.map +1 -1
  126. package/dist/chunks/{ui-TlEuI2Sz.js → ui-X698F10c.js} +47 -47
  127. package/dist/chunks/ui-X698F10c.js.map +1 -0
  128. package/dist/chunks/{unmodify-load-jfdcVZ_a.js → unmodify-load-CyGzC1Hu.js} +2 -2
  129. package/dist/chunks/unmodify-load-CyGzC1Hu.js.map +1 -0
  130. package/dist/chunks/util-BLYliuUK.js.map +1 -1
  131. package/dist/chunks/write-result-B68lvI57.js +511 -0
  132. package/dist/chunks/write-result-B68lvI57.js.map +1 -0
  133. package/dist/index.d.ts +224 -1
  134. package/dist/index.js +2121 -2064
  135. package/dist/index.js.map +1 -1
  136. package/package.json +7 -7
  137. package/dist/chunks/_layout-B7ujvjnA.js +0 -55
  138. package/dist/chunks/_layout-B7ujvjnA.js.map +0 -1
  139. package/dist/chunks/collections-CrOvS2E7.js.map +0 -1
  140. package/dist/chunks/compose-handle-B-CkDcQD.js.map +0 -1
  141. package/dist/chunks/config-target-Bln26FJe.js.map +0 -1
  142. package/dist/chunks/constants-BYkd9jeJ.js +0 -6
  143. package/dist/chunks/constants-BYkd9jeJ.js.map +0 -1
  144. package/dist/chunks/dispatch-BRnt8PcW.js +0 -6
  145. package/dist/chunks/dispatch-BRnt8PcW.js.map +0 -1
  146. package/dist/chunks/generate-6snrlnpA.js +0 -64
  147. package/dist/chunks/generate-6snrlnpA.js.map +0 -1
  148. package/dist/chunks/generate-Ca_6FlPi.js +0 -252
  149. package/dist/chunks/generate-Ca_6FlPi.js.map +0 -1
  150. package/dist/chunks/generate-CyuY2Ci7.js.map +0 -1
  151. package/dist/chunks/generate-DQeWOEPY.js.map +0 -1
  152. package/dist/chunks/generate-DwADTUob.js.map +0 -1
  153. package/dist/chunks/generate.runtime-4FDxnvCl.js.map +0 -1
  154. package/dist/chunks/generate.runtime-AYQVW1S-.js.map +0 -1
  155. package/dist/chunks/generate.runtime-B2aFFaac.js +0 -117
  156. package/dist/chunks/generate.runtime-B2aFFaac.js.map +0 -1
  157. package/dist/chunks/generate.runtime-B45MvtYm.js.map +0 -1
  158. package/dist/chunks/generate.runtime-BFOXm2DD.js.map +0 -1
  159. package/dist/chunks/generate.runtime-BHkFmI2Y.js +0 -146
  160. package/dist/chunks/generate.runtime-BHkFmI2Y.js.map +0 -1
  161. package/dist/chunks/generate.runtime-BKiJvE8I.js.map +0 -1
  162. package/dist/chunks/generate.runtime-BSRFv4cJ.js.map +0 -1
  163. package/dist/chunks/generate.runtime-BUqsF3AF.js +0 -123
  164. package/dist/chunks/generate.runtime-BUqsF3AF.js.map +0 -1
  165. package/dist/chunks/generate.runtime-BsaSyTnU.js +0 -82
  166. package/dist/chunks/generate.runtime-BsaSyTnU.js.map +0 -1
  167. package/dist/chunks/generate.runtime-CMnvmeVt.js +0 -111
  168. package/dist/chunks/generate.runtime-CMnvmeVt.js.map +0 -1
  169. package/dist/chunks/generate.runtime-CN5c2xH8.js.map +0 -1
  170. package/dist/chunks/generate.runtime-CgoSrP55.js +0 -146
  171. package/dist/chunks/generate.runtime-CgoSrP55.js.map +0 -1
  172. package/dist/chunks/generate.runtime-D1DNAY6k.js.map +0 -1
  173. package/dist/chunks/generate.runtime-DQwSY6Nc.js +0 -38
  174. package/dist/chunks/generate.runtime-DQwSY6Nc.js.map +0 -1
  175. package/dist/chunks/generate.runtime-D_yqWLcI.js +0 -66
  176. package/dist/chunks/generate.runtime-D_yqWLcI.js.map +0 -1
  177. package/dist/chunks/generate.runtime-Drmahmdl.js +0 -313
  178. package/dist/chunks/generate.runtime-Drmahmdl.js.map +0 -1
  179. package/dist/chunks/generate.runtime-FdZw277n.js.map +0 -1
  180. package/dist/chunks/generate.runtime-Lh1cW9Tz.js +0 -94
  181. package/dist/chunks/generate.runtime-Lh1cW9Tz.js.map +0 -1
  182. package/dist/chunks/generate.runtime-QGHToXRY.js +0 -32
  183. package/dist/chunks/generate.runtime-QGHToXRY.js.map +0 -1
  184. package/dist/chunks/generate.runtime-Um77JfwC.js.map +0 -1
  185. package/dist/chunks/generate.runtime-VgVwRiiN.js.map +0 -1
  186. package/dist/chunks/generate.runtime-YyIVd4oy.js +0 -61
  187. package/dist/chunks/generate.runtime-YyIVd4oy.js.map +0 -1
  188. package/dist/chunks/generate.runtime-cQGLxuZM.js.map +0 -1
  189. package/dist/chunks/generate.runtime-n9AFWtPp.js.map +0 -1
  190. package/dist/chunks/generate.runtime-ofdnLtxS.js.map +0 -1
  191. package/dist/chunks/generate.runtime-onBnOiS7.js.map +0 -1
  192. package/dist/chunks/modify-file-Dwfv0dCI.js.map +0 -1
  193. package/dist/chunks/modify-svelte-config-remote-BUU_EaDf.js.map +0 -1
  194. package/dist/chunks/nav-user-BYI-h8Od.js +0 -6
  195. package/dist/chunks/nav-user-BYI-h8Od.js.map +0 -1
  196. package/dist/chunks/pocketbase-BkhUywtb.js.map +0 -1
  197. package/dist/chunks/providers-BL9vJP_9.js.map +0 -1
  198. package/dist/chunks/shared-C8GtNxpm.js.map +0 -1
  199. package/dist/chunks/site-BdMX8qrH.js.map +0 -1
  200. package/dist/chunks/table-core-G9Shld4F.js +0 -126
  201. package/dist/chunks/table-core-G9Shld4F.js.map +0 -1
  202. package/dist/chunks/test-setup-DHEFKEHE.js.map +0 -1
  203. package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +0 -1
  204. package/dist/chunks/ui-TlEuI2Sz.js.map +0 -1
  205. package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +0 -1
  206. package/dist/chunks/write-result-Djy0SZXX.js +0 -376
  207. package/dist/chunks/write-result-Djy0SZXX.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-Ce_rwzNa.js","names":["apiObj","getLogger","removeNavItemFromScript","formatLikeSource","SvelteFile","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","firstArg","apiProp","apiInit","apiKeysProp","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","generate","logger","options","modifies","pushResult","modifyOutcomeToFile","planDropsForCollections"],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/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 if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { 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(\"/api-keys\")) {\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 \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\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 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\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\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 const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],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,8 +1,8 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { a as n, i as r, n as i, o as a, r as o, s, t as c } from "./dispatch-BRnt8PcW.js";
4
- import { _ as l, o as u, r as d } from "./ts-morph-helpers-CeduA--o.js";
5
- import { modifyOutcomeToFile as f } from "./modify-file-Dwfv0dCI.js";
3
+ import { a as n, i as r, n as i, o as a, r as o, s, t as c } from "./dispatch-CXOXPLFk.js";
4
+ import { _ as l, o as u, r as d } from "./ts-morph-helpers-CDW4lhox.js";
5
+ import { modifyOutcomeToFile as f } from "./modify-file-BlDeeurK.js";
6
6
  import { t as p } from "./svelte-file-B3RfgVdt.js";
7
7
  import m from "node:fs";
8
8
  import h from "node:path";
@@ -266,4 +266,4 @@ async function B(e) {
266
266
  //#endregion
267
267
  export { B as generate };
268
268
 
269
- //# sourceMappingURL=generate.runtime-cQGLxuZM.js.map
269
+ //# sourceMappingURL=generate.runtime-CexC1Oky.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CexC1Oky.js","names":["FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","dedent","getLogger","_layout_server_default","_layout_default","_page_default","nav_user_default","_page_server_default","dispatch_default","withInMemoryScript","formatLikeSource","ensureImports","SvelteFile","fs","path","FAILURE_HINT$2","NOT_FOUND_HINT$6","SUBSCRIPTION_CASES_SNIPPET","modifyWebhookServer","filePath","original","addedCases","sf","switchStmt","SyntaxKind","stmt","clauses","defaultClause","c","prefix","last","source","modifyByTemplate","notFoundHint","current","idempotencyMarker","stripped","template","NOT_FOUND_HINT$5","modifyAppLayoutServer","FAILURE_HINT$1","NOT_FOUND_HINT$4","modifyAppLayoutSvelte","file","SUBSCRIPTION_TYPE","FAILURE_HINT","NOT_FOUND_HINT$3","updateScript","wasAdded","out","decl","init","nameNode","pattern","elements","typeNode","intersection","member","lit","propTexts","p","t","elementTexts","insertIdx","modifyAppSidebar","scriptChanged","src","templateChanged","NOT_FOUND_HINT$2","modifyNavUser","NOT_FOUND_HINT$1","modifyBillingPageServer","NOT_FOUND_HINT","modifyBillingPageSvelte","previewRaw","app_sidebar_default","content","relativePath","generate","logger","options","modifies","pushResult","webhookServerPath","modifyOutcomeToFile","appLayoutServerPath","appLayoutSveltePath","appSidebarPath","navUserPath","billingPageServerPath","billingPageSveltePath"],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/handlers/dispatch.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./subscription/created\";\n import { handleSubscriptionUpdated } from \"./subscription/updated\";\n import { handleSubscriptionDeleted } from \"./subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/handlers/dispatch.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(\n last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`,\n );\n } else {\n return;\n }\n\n formatLikeSource(sf);\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(\n filePath,\n template,\n \"loadActiveSubscription\",\n NOT_FOUND_HINT,\n );\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\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 withInMemoryScript,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\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 const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\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) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only 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 = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n formatLikeSource(sf);\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript((src) => updateScript(src).source);\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/lib/components/nav-user.svelte is missing.\",\n \"Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user.\",\n].join(\"\\n\");\n\nexport function modifyNavUser(\n filePath: string,\n template: string,\n): ModifyOutcome {\n // `planLabel` is unique to subscriptions — safe idempotency marker.\n return modifyByTemplate(filePath, template, \"planLabel\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"selectPlan\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"availablePlans\", NOT_FOUND_HINT);\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 { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\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.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n modifyNavUser(\n navUserPath,\n template(\"src/lib/components/nav-user.svelte\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAMA,IAAe,CAAM;;;;;;;;;;;;;;;;;;GAo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zE,EAAK,KAC1BkE,EAAQ,MACR,OACA,OACA,cACA,oBACF;CAKA,AAJAE,EACEE,EAAoBG,GAAgBvB,EAAiBuB,CAAc,CAAC,CACtE,GAEAR,EAAO,KAAK,2BAA2B;CACvC,IAAMS,IAAc1E,EAAK,KACvBkE,EAAQ,MACR,OACA,OACA,cACA,iBACF;CAWA,AAVAE,EACEE,EACEI,GACAnB,EACEmB,GACAnD,EAAS,oCAAoC,CAC/C,CACF,CACF,GAEA0C,EAAO,KAAK,mCAAmC;CAC/C,IAAMU,IAAwB3E,EAAK,KACjCkE,EAAQ,MACR,OACA,UACA,SACA,WACA,iBACF;CAWA,AAVAE,EACEE,EACEK,GACAlB,EACEkB,GACApD,EAAS,0CAA0C,CACrD,CACF,CACF,GAEA0C,EAAO,KAAK,gCAAgC;CAC5C,IAAMW,IAAwB5E,EAAK,KACjCkE,EAAQ,MACR,OACA,UACA,SACA,WACA,cACF;CAWA,OAVAE,EACEE,EACEM,GACAjB,EACEiB,GACArD,EAAS,uCAAuC,CAClD,CACF,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,32 +1,34 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { o as n } from "./ts-morph-helpers-CeduA--o.js";
4
- import { modifyOutcomeToFile as r } from "./modify-file-Dwfv0dCI.js";
5
- import i from "node:fs";
6
- import a from "node:path";
7
- import { Project as o, QuoteKind as s } from "ts-morph";
3
+ import { t as n } from "./env-vars-Cr4lbMD_.js";
4
+ import { o as r } from "./ts-morph-helpers-CDW4lhox.js";
5
+ import { modifyOutcomeToFile as i } from "./modify-file-BlDeeurK.js";
6
+ import { modifyEnvVarsFiles as a } from "./env-vars-C1NUX-bf.js";
7
+ import o from "node:fs";
8
+ import s from "node:path";
9
+ import { Project as c, QuoteKind as l } from "ts-morph";
8
10
  //#region src/patterns/enable/workflows/modifies/hooks.server.ts
9
- var c = e`
11
+ var u = e`
10
12
  // Runs once when the server starts: executes the workflows in src/lib/workflows.
11
13
  export const init: ServerInit = () => startWorker();
12
- `, l = e`
14
+ `, d = e`
13
15
  src/hooks.server.ts already exports an init hook. Start the workflow worker from it:
14
16
 
15
- import { startWorker } from '$lib/server/workflows';
17
+ import { startWorker } from '#lib/server/workflows.js';
16
18
 
17
19
  export const init: ServerInit = async () => {
18
20
  await startWorker();
19
21
  // ...the rest of your init
20
22
  };
21
- `, u = e`
23
+ `, f = e`
22
24
  Create src/hooks.server.ts and start the workflow worker from its init hook:
23
25
 
24
- import type { ServerInit } from '@sveltejs/kit';
25
- import { startWorker } from '$lib/server/workflows';
26
+ import type { ServerInit } from '@sveltejs/kit/hooks';
27
+ import { startWorker } from '#lib/server/workflows.js';
26
28
 
27
29
  export const init: ServerInit = () => startWorker();
28
30
  `;
29
- function d(e, t, n, r = !1) {
31
+ function p(e, t, n, r = !1) {
30
32
  let i = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t);
31
33
  if (!i) {
32
34
  e.addImportDeclaration({
@@ -41,39 +43,41 @@ function d(e, t, n, r = !1) {
41
43
  isTypeOnly: !0
42
44
  } : n);
43
45
  }
44
- function f(e) {
46
+ function m(e) {
45
47
  return e.getVariableDeclaration("init") || e.getFunction("init") ? !0 : e.getExportDeclarations().some((e) => e.getNamedExports().some((e) => e.getName() === "init"));
46
48
  }
47
- function p(e) {
48
- if (!i.existsSync(e)) return {
49
+ function h(e) {
50
+ if (!o.existsSync(e)) return {
49
51
  status: "not-found",
50
- message: u
52
+ message: f
51
53
  };
52
- if (i.readFileSync(e, "utf8").includes("startWorker")) return {
54
+ if (o.readFileSync(e, "utf8").includes("startWorker")) return {
53
55
  status: "success",
54
56
  changed: !1
55
57
  };
56
- let t = new o({
58
+ let t = new c({
57
59
  compilerOptions: { allowJs: !0 },
58
- manipulationSettings: { quoteKind: s.Single }
60
+ manipulationSettings: { quoteKind: l.Single }
59
61
  }).addSourceFileAtPath(e);
60
- return f(t) ? {
62
+ return m(t) ? {
61
63
  status: "failed",
62
- message: l
63
- } : (d(t, "@sveltejs/kit", "ServerInit", !0), d(t, "$lib/server/workflows", "startWorker"), t.addStatements(`\n${c}`), n(t), t.saveSync(), {
64
+ message: d
65
+ } : (p(t, "@sveltejs/kit/hooks", "ServerInit", !0), p(t, "#lib/server/workflows.js", "startWorker"), t.addStatements(`\n${u}`), r(t), t.saveSync(), {
64
66
  status: "success",
65
67
  changed: !0
66
68
  });
67
69
  }
68
70
  //#endregion
69
71
  //#region src/patterns/enable/workflows/generate.runtime.ts
70
- async function m(e) {
71
- let n = t(e), i = [];
72
- n.info("Modifying hooks.server.ts");
73
- let o = a.join(e.root, "src", "hooks.server.ts"), s = r(o, p(o));
74
- return s && i.push(s), {
75
- creates: [],
76
- modifies: i,
72
+ async function g(e) {
73
+ let r = t(e), o = [], c = [];
74
+ r.info("Modifying hooks.server.ts");
75
+ let l = s.join(e.root, "src", "hooks.server.ts"), u = i(l, h(l));
76
+ u && c.push(u), r.info("Declaring the workflow variables in src/env.ts");
77
+ let d = a(e.root, n);
78
+ return d.create && o.push(d.create), d.modify && c.push(d.modify), {
79
+ creates: o,
80
+ modifies: c,
77
81
  deletes: [],
78
82
  components: [],
79
83
  packages: [],
@@ -83,6 +87,6 @@ async function m(e) {
83
87
  };
84
88
  }
85
89
  //#endregion
86
- export { m as generate };
90
+ export { g as generate };
87
91
 
88
- //# sourceMappingURL=generate.runtime-AYQVW1S-.js.map
92
+ //# sourceMappingURL=generate.runtime-CnPraLKv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CnPraLKv.js","names":["dedent","getLogger","WORKFLOWS_ENV_VARS","formatLikeSource","fs","path","INIT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","ensureNamedImport","existing","sourceFile","d","moduleSpecifier","typeOnly","name","ni","hasInitExport","modifyHooksServerWorkflows","hooksServerPath","Project","QuoteKind","generate","logger","options","creates","modifies","hooksFile","modifyOutcomeToFile","envVars","modifyEnvVarsFiles"],"sources":["../../src/patterns/enable/workflows/modifies/hooks.server.ts","../../src/patterns/enable/workflows/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 { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst INIT_SNIPPET = dedent`\n // Runs once when the server starts: executes the workflows in src/lib/workflows.\n export const init: ServerInit = () => startWorker();\n`;\n\nconst FAILURE_HINT = dedent`\n src/hooks.server.ts already exports an init hook. Start the workflow worker from it:\n\n import { startWorker } from '#lib/server/workflows.js';\n\n export const init: ServerInit = async () => {\n await startWorker();\n // ...the rest of your init\n };\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts and start the workflow worker from its init hook:\n\n import type { ServerInit } from '@sveltejs/kit/hooks';\n import { startWorker } from '#lib/server/workflows.js';\n\n export const init: ServerInit = () => startWorker();\n`;\n\nfunction ensureNamedImport(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n name: string,\n typeOnly = false,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({\n isTypeOnly: typeOnly,\n namedImports: [name],\n moduleSpecifier,\n });\n return;\n }\n if (existing.getNamedImports().some((ni) => ni.getName() === name)) return;\n // A declaration that is already `import type` covers the new name; a value\n // import takes the name as an inline `type` specifier.\n existing.addNamedImport(\n typeOnly && !existing.isTypeOnly() ? { name, isTypeOnly: true } : name,\n );\n}\n\nfunction hasInitExport(sourceFile: SourceFile): boolean {\n if (sourceFile.getVariableDeclaration(\"init\")) return true;\n if (sourceFile.getFunction(\"init\")) return true;\n return sourceFile\n .getExportDeclarations()\n .some((d) => d.getNamedExports().some((e) => e.getName() === \"init\"));\n}\n\n/**\n * Adds the `init` hook that starts the workflow worker. Projects created from\n * the base template already have it; this is the upgrade path for older ones.\n */\nexport function modifyHooksServerWorkflows(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"startWorker\")) {\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 if (hasInitExport(sourceFile)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureNamedImport(sourceFile, \"@sveltejs/kit/hooks\", \"ServerInit\", true);\n ensureNamedImport(sourceFile, \"#lib/server/workflows.js\", \"startWorker\");\n\n // After everything else, so the hook reads as the last thing the server does on start.\n sourceFile.addStatements(`\\n${INIT_SNIPPET}`);\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\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 { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServerWorkflows } from \"./modifies/hooks.server\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { WORKFLOWS_ENV_VARS } from \"./env-vars\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksFile = modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerWorkflows(hooksServerPath),\n );\n if (hooksFile) modifies.push(hooksFile);\n\n // SvelteKit 3 exposes only declared variables; the template declares these\n // already, an older project gets whichever it is missing.\n logger.info(\"Declaring the workflow variables in src/env.ts\");\n const envVars = modifyEnvVarsFiles(options.root, WORKFLOWS_ENV_VARS);\n if (envVars.create) creates.push(envVars.create);\n if (envVars.modify) modifies.push(envVars.modify);\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,IAAMM,IAAe,CAAM;;;GAKrBC,IAAe,CAAM;;;;;;;;;GAWrBC,IAAiB,CAAM;;;;;;;;AAS7B,SAASC,EACP,GACA,GACA,GACA,IAAW,IACX;CACA,IAAMC,IAAWC,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,wBAAwB,MAAMC,CAAe;CAC9D,IAAI,CAACH,GAAU;EACb,EAAW,qBAAqB;GAC9B,YAAYI;GACZ,cAAc,CAACC,CAAI;GACnB;EACF,CAAC;EACD;CACF;CACA,AAAIL,EAAS,gBAAgB,CAAC,CAAC,MAAM,MAAOM,EAAG,QAAQ,MAAMD,CAAI,KAGjEL,EAAS,eACPI,KAAY,CAACJ,EAAS,WAAW,IAAI;EAAE;EAAM,YAAY;CAAK,IAAIK,CACpE;AACF;AAEA,SAASE,EAAc,GAAiC;CAGtD,OAFIN,EAAW,uBAAuB,MAAM,KACxCA,EAAW,YAAY,MAAM,IAAU,KACpCA,EACJ,sBAAsB,CAAC,CACvB,MAAM,MAAMC,EAAE,gBAAgB,CAAC,CAAC,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM,CAAC;AACxE;AAMA,SAAgBM,EACd,GACe;CACf,IAAI,CAACd,EAAG,WAAWe,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAa,SAASX;CAAe;CAIxD,IADiBJ,EAAG,aAAae,GAAiB,MAC9C,CAAA,CAAS,SAAS,aAAa,GACjC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAO7C,IAAMR,IAAa,IAJCS,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAAsB,EAAE,WAAWC,EAAU,OAAO;CACtD,CACmB,CAAA,CAAQ,oBAAoBF,CAAe;CAc9D,OAZIF,EAAcN,CAAU,IACnB;EAAE,QAAQ;EAAU,SAASJ;CAAa,KAGnDE,EAAkBE,GAAY,uBAAuB,cAAc,EAAI,GACvEF,EAAkBE,GAAY,4BAA4B,aAAa,GAGvEA,EAAW,cAAc,KAAKL,GAAc,GAE5CH,EAAiBQ,CAAU,GAC3BA,EAAW,SAAS,GACb;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;AC3FA,eAAsBW,EAAS,GAAkB;CAC/C,IAAMC,IAAStB,EAAUuB,CAAO,GAC1BC,IAAkB,CAAC,GACnBC,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAMP,IAAkBd,EAAK,KAAKmB,EAAQ,MAAM,OAAO,iBAAiB,GAClEG,IAAYC,EAChBT,GACAD,EAA2BC,CAAe,CAC5C;CAKA,AAJIQ,KAAWD,EAAS,KAAKC,CAAS,GAItCJ,EAAO,KAAK,gDAAgD;CAC5D,IAAMM,IAAUC,EAAmBN,EAAQ,MAAMtB,CAAkB;CAInE,OAHI2B,EAAQ,UAAQJ,EAAQ,KAAKI,EAAQ,MAAM,GAC3CA,EAAQ,UAAQH,EAAS,KAAKG,EAAQ,MAAM,GAEzC;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,112 @@
1
+ import { r as e } from "./lib-specifier-Cngo1zF_.js";
2
+ import { n as t } from "./logger-CQONztPm.js";
3
+ import { t as n } from "./shared-CZC4d7Uj.js";
4
+ import { _ as r, g as i, n as a, o, p as s, u as c } from "./ts-morph-helpers-CDW4lhox.js";
5
+ import { modifyOutcomeToFile as l } from "./modify-file-BlDeeurK.js";
6
+ import { t as u } from "./svelte-file-B3RfgVdt.js";
7
+ import d from "node:fs";
8
+ import f from "node:path";
9
+ import { Project as p, SyntaxKind as m } from "ts-morph";
10
+ //#region src/patterns/disable/auth/modifies/+layout.server.ts
11
+ function h(e) {
12
+ if (!d.existsSync(e)) return {
13
+ status: "success",
14
+ changed: !1
15
+ };
16
+ let t = d.readFileSync(e, "utf8");
17
+ if (!t.includes("locals.pb.authStore.record")) return {
18
+ status: "success",
19
+ changed: !1
20
+ };
21
+ let n = new p().addSourceFileAtPath(e), r = n.getDescendantsOfKind(m.ObjectLiteralExpression);
22
+ for (let e of r) {
23
+ let t = e.getProperty("user");
24
+ t && t.getKind() === m.PropertyAssignment && t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
25
+ }
26
+ return i(n, "locals"), o(n), n.saveSync(), {
27
+ status: "success",
28
+ changed: n.getFullText() !== t
29
+ };
30
+ }
31
+ //#endregion
32
+ //#region src/patterns/disable/auth/modifies/root-layout.svelte.ts
33
+ function g(t) {
34
+ if (!d.existsSync(t)) return {
35
+ status: "success",
36
+ changed: !1
37
+ };
38
+ let n = d.readFileSync(t, "utf8"), i = new u(n);
39
+ if (!i.hasElement("AuthMenu.Root")) return {
40
+ status: "success",
41
+ changed: !1
42
+ };
43
+ i.removeElement("AuthMenu.Root");
44
+ let o = i.toString().replace(/<script[\s\S]*?<\/script>/g, "");
45
+ return i.modifyScript((t) => {
46
+ let { source: n } = r(t, (t) => {
47
+ c(t, e("components/ui/auth-menu")), c(t, e("components/ui/avatar")), s(t, "data", o), a(t);
48
+ });
49
+ return n;
50
+ }), i.writeTo(t), {
51
+ status: "success",
52
+ changed: i.hasChanged()
53
+ };
54
+ }
55
+ //#endregion
56
+ //#region src/patterns/disable/auth/modifies/hooks.server.ts
57
+ function _(e) {
58
+ if (!d.existsSync(e)) return {
59
+ status: "success",
60
+ changed: !1
61
+ };
62
+ let t = d.readFileSync(e, "utf8"), n = new p().addSourceFileAtPath(e), r = n.getDescendantsOfKind(m.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
63
+ if (!r) return {
64
+ status: "success",
65
+ changed: !1
66
+ };
67
+ let [i] = r.getArguments();
68
+ if (!i || i.getKind() !== m.ObjectLiteralExpression) return {
69
+ status: "success",
70
+ changed: !1
71
+ };
72
+ let a = i.asKindOrThrow(m.ObjectLiteralExpression), s = a.getProperty("auth");
73
+ return s ? (s.remove(), a.getProperties().length === 0 && r.removeArgument(0), o(n), n.saveSync(), {
74
+ status: "success",
75
+ changed: n.getFullText() !== t
76
+ }) : {
77
+ status: "success",
78
+ changed: !1
79
+ };
80
+ }
81
+ //#endregion
82
+ //#region src/patterns/disable/auth/generate.runtime.ts
83
+ async function v(e) {
84
+ let r = t(e), i = [], a = (e) => {
85
+ e && i.push(e);
86
+ };
87
+ r.info("Reverting +layout.server.ts");
88
+ let o = f.join(e.root, "src", "routes", "+layout.server.ts");
89
+ a(l(o, h(o))), r.info("Reverting root layout");
90
+ let s = [
91
+ f.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
92
+ f.join(e.root, "src", "routes", "root-layout.svelte"),
93
+ f.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
94
+ f.join(e.root, "src", "routes", "+layout.svelte")
95
+ ], c = s.find((e) => d.existsSync(e)) ?? s[0];
96
+ a(l(c, g(c))), r.info("Reverting hooks.server.ts");
97
+ let u = f.join(e.root, "src", "hooks.server.ts");
98
+ return a(l(u, _(u))), {
99
+ creates: [],
100
+ modifies: i,
101
+ deletes: [],
102
+ components: [],
103
+ packages: [],
104
+ collections: [],
105
+ collectionPatches: [],
106
+ collectionDrops: await n(["oauth_accounts"], e)
107
+ };
108
+ }
109
+ //#endregion
110
+ export { v as generate };
111
+
112
+ //# sourceMappingURL=generate.runtime-CslAvllQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CslAvllQ.js","names":["libModule","getLogger","planDropsForCollections","withInMemoryScript","removeUnusedBindingElement","ensureBlankLineAfterImports","removePropsBindingIfUnused","removeImportByModuleSpecifier","SvelteFile","fs","path","unmodifyLayoutServer","layoutPath","originalSource","sourceFile","Project","literals","SyntaxKind","obj","userProp","formatLikeSource","unmodifyRootLayoutSvelte","source","file","markup","out","content","sf","unmodifyHooksServer","hooksServerPath","callExpr","ce","firstArg","optionsObj","authProp","generate","logger","options","modifies","pushResult","layoutServerFile","modifyOutcomeToFile","layoutCandidates","layoutFile","p","hooksServerFile"],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeUnusedBindingElement,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.removeElement(\"AuthMenu.Root\");\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/auth-menu\"));\n removeImportByModuleSpecifier(sf, libModule(\"components/ui/avatar\"));\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\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 if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n 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 fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgBW,EAAqB,GAAmC;CACtE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAY,MAAM;CACzD,IAAI,CAACC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAMC,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAU,GAEnDI,IAAWF,EAAW,qBAC1BG,EAAW,uBACb;CACA,KAAK,IAAMC,KAAOF,GAAU;EAC1B,IAAMG,IAAWD,EAAI,YAAY,MAAM;EACvC,AAAKC,KAAYA,EAAS,QAAQ,MAAMF,EAAW,sBAGpCE,EACZ,eAAe,CAAC,EACf,QAAQ,MACE,gCACZA,EAAS,OAAO;CAEpB;CAQA,OALAf,EAA2BU,GAAY,QAAQ,GAE/CM,EAAiBN,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC;AACF;;;ACpCA,SAAgBQ,EAAyB,GAAmC;CAC1E,IAAI,CAACZ,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMU,IAASb,EAAG,aAAaG,GAAY,MAAM,GAC3CW,IAAO,IAAIf,EAAWc,CAAM;CAClC,IAAI,CAACC,EAAK,WAAW,eAAe,GAClC,OA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  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { _ as n, a as r, o as i, r as a } from "./ts-morph-helpers-CeduA--o.js";
4
- import { modifyOutcomeToFile as o } from "./modify-file-Dwfv0dCI.js";
3
+ import { _ as n, a as r, o as i, r as a } from "./ts-morph-helpers-CDW4lhox.js";
4
+ import { modifyOutcomeToFile as o } from "./modify-file-BlDeeurK.js";
5
5
  import { t as s } from "./svelte-file-B3RfgVdt.js";
6
- import { i as c, n as l, t as u } from "./pocketbase-BkhUywtb.js";
7
- import { t as d } from "./site-BdMX8qrH.js";
8
- import { modifySvelteConfigRemote as f } from "./modify-svelte-config-remote-BUU_EaDf.js";
6
+ import { i as c, n as l, t as u } from "./pocketbase-Dry6ry17.js";
7
+ import { t as d } from "./site-BwCA18Sv.js";
8
+ import { modifySvelteConfigRemote as f } from "./modify-svelte-config-remote-p0TfVzxm.js";
9
9
  import p from "node:fs";
10
10
  import m from "node:path";
11
11
  import { Project as h, SyntaxKind as g } from "ts-morph";
@@ -120,8 +120,8 @@ function _(t) {
120
120
  //#endregion
121
121
  //#region src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts
122
122
  var v = "\n <Navbar.Item\n class=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n >\n <AuthMenu.Root>\n {#snippet user()}\n <AuthMenu.Trigger>\n <Avatar.Root>\n {#if data.user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n alt={data.user?.email}\n />\n {/if}\n <Avatar.Fallback>\n {data.user?.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n </AuthMenu.Trigger>\n\n <AuthMenu.Content align=\"end\">\n <AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n <AuthMenu.Group>\n <AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n <AuthMenu.Item>\n <form action=\"/logout\" method=\"post\">\n <button type=\"submit\" class=\"contents\">Logout</button>\n </form>\n </AuthMenu.Item>\n </AuthMenu.Group>\n </AuthMenu.Content>\n {/snippet}\n\n {#snippet guest()}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n href=\"/login\">Login</Button\n >\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"outline\"\n href=\"/signup\">Sign up</Button\n >\n {/snippet}\n </AuthMenu.Root>\n </Navbar.Item>\n ", y = e`
123
- import * as AuthMenu from '$lib/components/ui/auth-menu';
124
- import * as Avatar from '$lib/components/ui/avatar';
123
+ import * as AuthMenu from '#lib/components/ui/auth-menu/index.js';
124
+ import * as Avatar from '#lib/components/ui/avatar/index.js';
125
125
  `, b = [
126
126
  "Add the auth menu inside your <Navbar.List> in the root layout.",
127
127
  "",
@@ -154,10 +154,10 @@ function S(e) {
154
154
  let { source: t } = n(e, (e) => {
155
155
  a(e, [{
156
156
  namespaceImport: "AuthMenu",
157
- moduleSpecifier: "$lib/components/ui/auth-menu"
157
+ moduleSpecifier: "#lib/components/ui/auth-menu/index.js"
158
158
  }, {
159
159
  namespaceImport: "Avatar",
160
- moduleSpecifier: "$lib/components/ui/avatar"
160
+ moduleSpecifier: "#lib/components/ui/avatar/index.js"
161
161
  }]), r(e, "data");
162
162
  });
163
163
  return t;
@@ -325,4 +325,4 @@ async function O(e) {
325
325
  //#endregion
326
326
  export { O as generate };
327
327
 
328
- //# sourceMappingURL=generate.runtime-onBnOiS7.js.map
328
+ //# sourceMappingURL=generate.runtime-CuNhY5hn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CuNhY5hn.js","names":["FAILURE_HINT","NOT_FOUND_HINT","dedent","getLogger","withInMemoryScript","ensurePropsBinding","formatLikeSource","ensureImports","SvelteFile","withPocketbase","migrationDelay","getMigrationFile","ensureSiteFile","fs","path","modifyLayoutServer","layoutPath","snippet","originalSource","sourceFile","Project","addUserProp","obj","loadArrow","loadFn","varDecl","SyntaxKind","directArrow","init","innerArrow","innerFnExpr","maybeFn","fnLike","params","first","original","nameNode","obp","el","parts","tail","currentName","body","expr","ret","inner","bodyExpr","AUTH_MENU_NAVBAR_ITEM","IMPORT_SNIPPET","FAILURE_HINT$1","NOT_FOUND_HINT$1","modifyRootLayoutSvelte","file","out","source","sf","FAILURE_HINT","NOT_FOUND_HINT","modifyHooksServer","hooksServerPath","callExpr","ce","args","firstArg","optionsObj","authProp","authInit","authObj","prProp","prInit","arr","COOKIE_LOGIN","modifyTestSetup","setupPath","helper","generate","options","logger","creates","pb","input","userCollection","verificationTemplate","resetPasswordTemplate","confirmEmailChangeTemplate","migrationFile","modifies","pushResult","layoutServerFile","modifyOutcomeToFile","layoutCandidates","layoutFile","p","hooksServerFile","testSetupFile","remote","modifySvelteConfigRemote","siteFile"],"sources":["../../src/patterns/enable/auth-remote/modifies/+layout.server.ts","../../src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth-remote/modifies/hooks.server.ts","../../src/patterns/enable/auth-remote/modifies/test-setup.ts","../../src/patterns/enable/auth-remote/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function modifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n ensurePropsBinding,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst AUTH_MENU_NAVBAR_ITEM = `\n\t\t<Navbar.Item\n\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t>\n\t\t\t<AuthMenu.Root>\n\t\t\t\t{#snippet user()}\n\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t<Avatar.Root>\n\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t{data.user?.email?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t</Avatar.Root>\n\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t{/snippet}\n\n\t\t\t\t{#snippet guest()}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t>\n\t\t\t\t{/snippet}\n\t\t\t</AuthMenu.Root>\n\t\t</Navbar.Item>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import * as AuthMenu from '#lib/components/ui/auth-menu/index.js';\n import * as Avatar from '#lib/components/ui/avatar/index.js';\n`;\n\nconst FAILURE_HINT = [\n \"Add the auth menu inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes an auth menu inside <Navbar.List>.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nexport function modifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namespaceImport: \"AuthMenu\",\n moduleSpecifier: \"#lib/components/ui/auth-menu/index.js\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"#lib/components/ui/avatar/index.js\",\n },\n ]);\n // The menu reads `data.user`; the template's layout takes no props.\n ensurePropsBinding(sf, \"data\");\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"Navbar.List\", AUTH_MENU_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the auth option in hooks.server.ts:\n\n handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from '@velastack/pocketbase';\n\n export const handle = handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst COOKIE_LOGIN = dedent`\n // Login is a remote function, so there is no form action to post to: carry\n // the session the way the browser does, in the \\`pb_auth\\` cookie.\n async function authenticateUser(agent: Agent, user: { email: string }) {\n const client = new PocketBase(process.env.POCKETBASE_URL!);\n await client.collection(\"users\").authWithPassword(user.email, testUserPassword);\n agent.set(\"Cookie\", client.authStore.exportToCookie().split(\";\")[0]);\n }\n`;\n\n/**\n * The template's server-test helper logs in by posting the `/login` form\n * action, which this pattern replaces with a remote function. A project\n * without the helper (or with its own) has nothing to fix.\n */\nexport function modifyTestSetup(setupPath: string): ModifyOutcome {\n if (!fs.existsSync(setupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(setupPath);\n const helper = sourceFile.getFunction(\"authenticateUser\");\n\n if (!helper || !/\\.post\\(\\s*[\"'`]\\/login[\"'`]\\s*\\)/.test(helper.getText())) {\n return { status: \"success\", changed: false };\n }\n\n helper.replaceWithText(COOKIE_LOGIN);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { modifySvelteConfigRemote } from \"../../../runtime/modify-svelte-config-remote\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyTestSetup } from \"./modifies/test-setup\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n const logger = getLogger(options);\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n logger.info(\"Updating PocketBase mail settings\");\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n await migrationDelay();\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-reset/{TOKEN}\",\n \"{APP_URL}/confirm-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n logger.info(\"Locking down users collection rules and email templates\");\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n // Modify files\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerFile, modifyLayoutServer(layoutServerFile)),\n );\n\n logger.info(\"Modifying root layout\");\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, modifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, modifyHooksServer(hooksServerFile)),\n );\n\n logger.info(\"Modifying test/setup.ts\");\n const testSetupFile = path.join(options.root, \"test\", \"setup.ts\");\n pushResult(\n modifyOutcomeToFile(testSetupFile, modifyTestSetup(testSetupFile)),\n );\n\n logger.info(\"Modifying config for remote functions\");\n const remote = modifySvelteConfigRemote(options.root);\n pushResult(modifyOutcomeToFile(remote.filePath, remote.outcome));\n\n // The auth pages and the app sidebar show `site.name`.\n const siteFile = await ensureSiteFile(options);\n\n return {\n creates: siteFile ? [siteFile] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;AAMA,SAAgBe,EAAmB,GAAmC;CACpE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAAG;EAC9B,IAAMC,IAAU,CAAM;;;;;EAOtB,OADAJ,EAAG,cAAcG,GAAYC,CAAO,GAC7B;GAAE,QAAQ;GAAW,SAAS;EAAK;CAC5C;CAEA,IAAMC,IAAiBL,EAAG,aAAaG,GAAY,MAAM,GAEnDG,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBJ,CAAU,GAGnDK,KAAe,MAAoD;EAEvE,AADkBC,EAAI,YAAY,MAAM,KAEtCA,EAAI,sBAAsB;GACxB,MAAM;GACN,aAAa;EACf,CAAC;CAEL,GAGIC,GACAC,GAKEC,IAAUN,EAAW,uBAAuB,MAAM;CACxD,IAAIM,KACSA,EAAQ,uBAAuBC,EAAW,iBAChC,CAAA,EAAI,iBAAiB,GAC1B;EACd,IAAMC,IAAcF,EAAQ,qBAC1BC,EAAW,aACb;EACA,IAAIC,GACF,IAAYA;OACP;GACL,IAAMC,IAAOH,EAAQ,eAAe;GACpC,IAAIG,GAAM;IACR,IAAMC,IAAaD,EAAK,yBACtBF,EAAW,aACb;IACA,IAAIG,GACF,IAAYA;SACP;KACL,IAAMC,IAAcF,EAAK,yBACvBF,EAAW,kBACb;KACA,AAAII,MACF,IAASA;IAEb;GACF;EACF;CACF;CAGF,IAAI,CAACP,GAAW;EACd,IAAMQ,IAAUZ,EAAW,YAAY,MAAM;EAC7C,AAAIY,KAAWA,EAAQ,WAAW,MAChC,IAASA;CAEb;CAGA,IAAI,CAACR,KAAa,CAACC,GAUjB,OATAL,EAAW,YAAY;EACrB,YAAY;EACZ,SAAS;EACT,MAAM;EACN,YAAY,CAAC,EAAE,MAAM,aAAa,CAAC;EACnC,YAAY;CACd,CAAC,GACDb,EAAiBa,CAAU,GAC3BA,EAAW,SAAS,GACb;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CAE7C,OAAO;EACL,SAASqB,IAAW,CAACA,CAAQ,IAAI,CAAC;EAClC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import { n as t } from "./logger-CQONztPm.js";
3
- import { _ as n, o as r, r as i } from "./ts-morph-helpers-CeduA--o.js";
4
- import { modifyOutcomeToFile as a } from "./modify-file-Dwfv0dCI.js";
3
+ import { _ as n, o as r, r as i } from "./ts-morph-helpers-CDW4lhox.js";
4
+ import { modifyOutcomeToFile as a } from "./modify-file-BlDeeurK.js";
5
5
  import { t as o } from "./svelte-file-B3RfgVdt.js";
6
- import { t as s } from "./compose-handle-B-CkDcQD.js";
6
+ import { t as s } from "./compose-handle-D_Rz3Fzo.js";
7
7
  import c from "node:fs";
8
8
  import l from "node:path";
9
9
  import { Project as u, QuoteKind as d, SyntaxKind as f } from "ts-morph";
@@ -12,16 +12,16 @@ var p = e`
12
12
  Wrap your exported handle with the negotiation handler:
13
13
 
14
14
  import { sequence } from '@sveltejs/kit/hooks';
15
- import { handle as handleNegotiate } from '$lib/negotiate';
15
+ import { handle as handleNegotiate } from '#lib/negotiate.js';
16
16
 
17
17
  export const handle = sequence(handleNegotiate, /* your existing handle */);
18
18
  `, m = e`
19
- import { handle as handleNegotiate } from '$lib/negotiate';
19
+ import { handle as handleNegotiate } from '#lib/negotiate.js';
20
20
 
21
21
  export const handle = handleNegotiate;
22
22
  `;
23
23
  function h(e) {
24
- let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "$lib/negotiate");
24
+ let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "#lib/negotiate.js");
25
25
  if (t) {
26
26
  t.getNamedImports().some((e) => e.getName() === "handle" && e.getAliasNode()?.getText() === "handleNegotiate") || t.addNamedImport({
27
27
  name: "handle",
@@ -34,7 +34,7 @@ function h(e) {
34
34
  name: "handle",
35
35
  alias: "handleNegotiate"
36
36
  }],
37
- moduleSpecifier: "$lib/negotiate"
37
+ moduleSpecifier: "#lib/negotiate.js"
38
38
  });
39
39
  }
40
40
  function g(e) {
@@ -65,18 +65,18 @@ function g(e) {
65
65
  //#endregion
66
66
  //#region src/patterns/enable/content-negotiation/modifies/hooks.ts
67
67
  var _ = e`
68
- import { reroute as negotiateReroute } from '$lib/negotiate';
68
+ import { reroute as negotiateReroute } from '#lib/negotiate.js';
69
69
 
70
70
  export const reroute = ({ url }) => negotiateReroute(url.pathname);
71
71
  `, v = e`
72
72
  Compose your existing reroute in src/hooks.ts with the negotiation reroute:
73
73
 
74
- import { reroute as negotiateReroute } from '$lib/negotiate';
74
+ import { reroute as negotiateReroute } from '#lib/negotiate.js';
75
75
 
76
76
  export const reroute = ({ url }) => existingReroute(negotiateReroute(url.pathname));
77
77
  `;
78
78
  function y(e) {
79
- let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "$lib/negotiate");
79
+ let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "#lib/negotiate.js");
80
80
  if (t) {
81
81
  t.getNamedImports().some((e) => e.getName() === "reroute" && e.getAliasNode()?.getText() === "negotiateReroute") || t.addNamedImport({
82
82
  name: "reroute",
@@ -89,7 +89,7 @@ function y(e) {
89
89
  name: "reroute",
90
90
  alias: "negotiateReroute"
91
91
  }],
92
- moduleSpecifier: "$lib/negotiate"
92
+ moduleSpecifier: "#lib/negotiate.js"
93
93
  });
94
94
  }
95
95
  function b(e) {
@@ -130,7 +130,7 @@ function b(e) {
130
130
  //#endregion
131
131
  //#region src/patterns/enable/content-negotiation/modifies/root-layout.svelte.ts
132
132
  var x = e`
133
- import { Negotiate } from '$lib/negotiate';
133
+ import { Negotiate } from '#lib/negotiate.js';
134
134
  `, S = "\n<Negotiate />\n", C = [
135
135
  "Create the root +layout.svelte and mount <Negotiate /> inside it.",
136
136
  "",
@@ -154,7 +154,7 @@ function w(e) {
154
154
  let { source: t } = n(e, (e) => {
155
155
  i(e, [{
156
156
  namedImports: ["Negotiate"],
157
- moduleSpecifier: "$lib/negotiate"
157
+ moduleSpecifier: "#lib/negotiate.js"
158
158
  }]);
159
159
  });
160
160
  return t;
@@ -189,4 +189,4 @@ async function T(e) {
189
189
  //#endregion
190
190
  export { T as generate };
191
191
 
192
- //# sourceMappingURL=generate.runtime-B45MvtYm.js.map
192
+ //# sourceMappingURL=generate.runtime-DD51OSuL.js.map