@velastack/patterns 0.2.11 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +4 -3
  2. package/dist/chunks/{_layout-D0OmzCu1.js → _layout-DqH4lA_r.js} +8 -8
  3. package/dist/chunks/{_layout-D0OmzCu1.js.map → _layout-DqH4lA_r.js.map} +1 -1
  4. package/dist/chunks/{collections-DDYlpDNO.js → collections-CgdvZXmh.js} +17 -17
  5. package/dist/chunks/{collections-DDYlpDNO.js.map → collections-CgdvZXmh.js.map} +1 -1
  6. package/dist/chunks/compose-handle-Cg9jnCsS.js +322 -0
  7. package/dist/chunks/compose-handle-Cg9jnCsS.js.map +1 -0
  8. package/dist/chunks/{config-target-DOi8kI_f.js → config-target-Co-ij8p3.js} +9 -9
  9. package/dist/chunks/{config-target-DOi8kI_f.js.map → config-target-Co-ij8p3.js.map} +1 -1
  10. package/dist/chunks/dispatch-BRnt8PcW.js +6 -0
  11. package/dist/chunks/dispatch-BRnt8PcW.js.map +1 -0
  12. package/dist/chunks/format-result-Cb2hWsb8.js +64 -0
  13. package/dist/chunks/format-result-Cb2hWsb8.js.map +1 -0
  14. package/dist/chunks/generate-BkQ1xMDp.js +30 -0
  15. package/dist/chunks/generate-BkQ1xMDp.js.map +1 -0
  16. package/dist/chunks/{generate-Va1sxVPG.js → generate-DRA63W0r.js} +17 -64
  17. package/dist/chunks/generate-DRA63W0r.js.map +1 -0
  18. package/dist/chunks/generate-_LvrYK6i.js +55 -0
  19. package/dist/chunks/generate-_LvrYK6i.js.map +1 -0
  20. package/dist/chunks/generate-iQP31-m1.js +252 -0
  21. package/dist/chunks/generate-iQP31-m1.js.map +1 -0
  22. package/dist/chunks/{generate.runtime-Dtf2BI_5.js → generate.runtime-B0hhtyAL.js} +9 -9
  23. package/dist/chunks/{generate.runtime-Dtf2BI_5.js.map → generate.runtime-B0hhtyAL.js.map} +1 -1
  24. package/dist/chunks/generate.runtime-B49wetSx.js +122 -0
  25. package/dist/chunks/generate.runtime-B49wetSx.js.map +1 -0
  26. package/dist/chunks/{generate.runtime-SQhCLSah.js → generate.runtime-B7LRx-BU.js} +13 -13
  27. package/dist/chunks/{generate.runtime-SQhCLSah.js.map → generate.runtime-B7LRx-BU.js.map} +1 -1
  28. package/dist/chunks/generate.runtime-BKo-Nidn.js +38 -0
  29. package/dist/chunks/generate.runtime-BKo-Nidn.js.map +1 -0
  30. package/dist/chunks/{generate.runtime-vTneb2SY.js → generate.runtime-BORbegw_.js} +111 -101
  31. package/dist/chunks/generate.runtime-BORbegw_.js.map +1 -0
  32. package/dist/chunks/{generate.runtime-BtX_9lLk.js → generate.runtime-BbIN0tUZ.js} +34 -34
  33. package/dist/chunks/{generate.runtime-BtX_9lLk.js.map → generate.runtime-BbIN0tUZ.js.map} +1 -1
  34. package/dist/chunks/{generate.runtime-OjW1XETW.js → generate.runtime-BnWE4qsu.js} +42 -42
  35. package/dist/chunks/generate.runtime-BnWE4qsu.js.map +1 -0
  36. package/dist/chunks/{generate.runtime-B_Fk1Jjs.js → generate.runtime-BwhGDnGu.js} +32 -35
  37. package/dist/chunks/generate.runtime-BwhGDnGu.js.map +1 -0
  38. package/dist/chunks/{generate.runtime-BgezGu15.js → generate.runtime-CCg2Pjcv.js} +95 -94
  39. package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +1 -0
  40. package/dist/chunks/{generate.runtime-DRcq4d5D.js → generate.runtime-CRYjWJRe.js} +31 -31
  41. package/dist/chunks/{generate.runtime-DRcq4d5D.js.map → generate.runtime-CRYjWJRe.js.map} +1 -1
  42. package/dist/chunks/generate.runtime-CcuAXuV2.js +60 -0
  43. package/dist/chunks/generate.runtime-CcuAXuV2.js.map +1 -0
  44. package/dist/chunks/{generate.runtime-DK7iXmAZ.js → generate.runtime-D0icLb5j.js} +50 -47
  45. package/dist/chunks/{generate.runtime-DK7iXmAZ.js.map → generate.runtime-D0icLb5j.js.map} +1 -1
  46. package/dist/chunks/{generate.runtime-fSDNxfGG.js → generate.runtime-D2e_KRj0.js} +11 -11
  47. package/dist/chunks/{generate.runtime-fSDNxfGG.js.map → generate.runtime-D2e_KRj0.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-CycY6kPr.js → generate.runtime-D44gjxRA.js} +102 -99
  49. package/dist/chunks/generate.runtime-D44gjxRA.js.map +1 -0
  50. package/dist/chunks/{generate.runtime-AjCpCfv3.js → generate.runtime-D8vgh5MH.js} +186 -138
  51. package/dist/chunks/generate.runtime-D8vgh5MH.js.map +1 -0
  52. package/dist/chunks/generate.runtime-DAmYsIvF.js +32 -0
  53. package/dist/chunks/generate.runtime-DAmYsIvF.js.map +1 -0
  54. package/dist/chunks/{generate.runtime-B6kxV3Bi.js → generate.runtime-DNaQxed-.js} +45 -45
  55. package/dist/chunks/{generate.runtime-B6kxV3Bi.js.map → generate.runtime-DNaQxed-.js.map} +1 -1
  56. package/dist/chunks/{generate.runtime-CZQoVNt3.js → generate.runtime-DOuufRLr.js} +35 -35
  57. package/dist/chunks/generate.runtime-DOuufRLr.js.map +1 -0
  58. package/dist/chunks/{generate.runtime-BpYOznG5.js → generate.runtime-DSqkXvps.js} +21 -21
  59. package/dist/chunks/{generate.runtime-BpYOznG5.js.map → generate.runtime-DSqkXvps.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-BYJZB1ad.js → generate.runtime-DhkaXTq3.js} +37 -57
  61. package/dist/chunks/generate.runtime-DhkaXTq3.js.map +1 -0
  62. package/dist/chunks/{generate.runtime-Cq1gqxzg.js → generate.runtime-DoZdSh9W.js} +22 -22
  63. package/dist/chunks/{generate.runtime-Cq1gqxzg.js.map → generate.runtime-DoZdSh9W.js.map} +1 -1
  64. package/dist/chunks/{generate.runtime-qjsxSPaH.js → generate.runtime-S5RIgbQx.js} +102 -99
  65. package/dist/chunks/generate.runtime-S5RIgbQx.js.map +1 -0
  66. package/dist/chunks/generate.runtime-WmSMWL15.js +82 -0
  67. package/dist/chunks/generate.runtime-WmSMWL15.js.map +1 -0
  68. package/dist/chunks/generate.runtime-acRmiU7e.js +81 -0
  69. package/dist/chunks/generate.runtime-acRmiU7e.js.map +1 -0
  70. package/dist/chunks/generate.runtime-flFRYzpi.js +145 -0
  71. package/dist/chunks/generate.runtime-flFRYzpi.js.map +1 -0
  72. package/dist/chunks/generate.runtime-gtpOuLNO.js +110 -0
  73. package/dist/chunks/generate.runtime-gtpOuLNO.js.map +1 -0
  74. package/dist/chunks/{generate.runtime-DHRCNPVx.js → generate.runtime-kLxeDGnS.js} +23 -23
  75. package/dist/chunks/{generate.runtime-DHRCNPVx.js.map → generate.runtime-kLxeDGnS.js.map} +1 -1
  76. package/dist/chunks/{generate.runtime-DH9o-888.js → generate.runtime-wA1G3tQ4.js} +27 -27
  77. package/dist/chunks/{generate.runtime-DH9o-888.js.map → generate.runtime-wA1G3tQ4.js.map} +1 -1
  78. package/dist/chunks/modify-file-GQD6uNgI.js +254 -0
  79. package/dist/chunks/modify-file-GQD6uNgI.js.map +1 -0
  80. package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js → modify-svelte-config-remote-CDKs_Qi0.js} +2 -2
  81. package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js.map → modify-svelte-config-remote-CDKs_Qi0.js.map} +1 -1
  82. package/dist/chunks/{pocketbase-BerjVikJ.js → pocketbase-CeG5BMN2.js} +57 -50
  83. package/dist/chunks/{pocketbase-BerjVikJ.js.map → pocketbase-CeG5BMN2.js.map} +1 -1
  84. package/dist/chunks/providers-DO9kMyzB.js +69 -0
  85. package/dist/chunks/providers-DO9kMyzB.js.map +1 -0
  86. package/dist/chunks/rolldown-runtime-DArdT4gl.js +23 -0
  87. package/dist/chunks/{shared-Cmbzu7Od.js → shared-BwHQM-a9.js} +2 -2
  88. package/dist/chunks/{shared-Cmbzu7Od.js.map → shared-BwHQM-a9.js.map} +1 -1
  89. package/dist/chunks/site-D027dpBm.js +55 -0
  90. package/dist/chunks/site-D027dpBm.js.map +1 -0
  91. package/dist/chunks/svelte-file-B3RfgVdt.js +123 -0
  92. package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -0
  93. package/dist/chunks/{test-setup-DjbhQYZC.js → test-setup-B2hd8I-s.js} +15 -15
  94. package/dist/chunks/{test-setup-DjbhQYZC.js.map → test-setup-B2hd8I-s.js.map} +1 -1
  95. package/dist/chunks/{ui-BdkuOXPw.js → ui-B4Tuit-7.js} +12 -12
  96. package/dist/chunks/{ui-BdkuOXPw.js.map → ui-B4Tuit-7.js.map} +1 -1
  97. package/dist/chunks/ui-jhXrsw4T.js +12 -0
  98. package/dist/chunks/ui-jhXrsw4T.js.map +1 -0
  99. package/dist/chunks/{write-result-BVWPlGvE.js → write-result-DewHCNhM.js} +51 -51
  100. package/dist/chunks/{write-result-BVWPlGvE.js.map → write-result-DewHCNhM.js.map} +1 -1
  101. package/dist/index.d.ts +272 -65
  102. package/dist/index.js +2279 -2268
  103. package/dist/index.js.map +1 -1
  104. package/package.json +1 -1
  105. package/dist/chunks/dispatch-B5PfQ2CA.js +0 -6
  106. package/dist/chunks/dispatch-B5PfQ2CA.js.map +0 -1
  107. package/dist/chunks/format-result-BdAy5M8C.js +0 -50
  108. package/dist/chunks/format-result-BdAy5M8C.js.map +0 -1
  109. package/dist/chunks/generate-Va1sxVPG.js.map +0 -1
  110. package/dist/chunks/generate.runtime-AjCpCfv3.js.map +0 -1
  111. package/dist/chunks/generate.runtime-BYJZB1ad.js.map +0 -1
  112. package/dist/chunks/generate.runtime-B_Fk1Jjs.js.map +0 -1
  113. package/dist/chunks/generate.runtime-BcVAKzoY.js +0 -138
  114. package/dist/chunks/generate.runtime-BcVAKzoY.js.map +0 -1
  115. package/dist/chunks/generate.runtime-BgezGu15.js.map +0 -1
  116. package/dist/chunks/generate.runtime-CTiJEVF2.js +0 -107
  117. package/dist/chunks/generate.runtime-CTiJEVF2.js.map +0 -1
  118. package/dist/chunks/generate.runtime-CZQoVNt3.js.map +0 -1
  119. package/dist/chunks/generate.runtime-CycY6kPr.js.map +0 -1
  120. package/dist/chunks/generate.runtime-D2WfvXm2.js +0 -106
  121. package/dist/chunks/generate.runtime-D2WfvXm2.js.map +0 -1
  122. package/dist/chunks/generate.runtime-DEl6b1Ti.js +0 -87
  123. package/dist/chunks/generate.runtime-DEl6b1Ti.js.map +0 -1
  124. package/dist/chunks/generate.runtime-DaPNrIyg.js +0 -28
  125. package/dist/chunks/generate.runtime-DaPNrIyg.js.map +0 -1
  126. package/dist/chunks/generate.runtime-OjW1XETW.js.map +0 -1
  127. package/dist/chunks/generate.runtime-qjsxSPaH.js.map +0 -1
  128. package/dist/chunks/generate.runtime-vTneb2SY.js.map +0 -1
  129. package/dist/chunks/modify-file-Cgu_WeFk.js +0 -22
  130. package/dist/chunks/modify-file-Cgu_WeFk.js.map +0 -1
  131. package/dist/chunks/ts-morph-helpers-teS3yXg-.js +0 -229
  132. package/dist/chunks/ts-morph-helpers-teS3yXg-.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-acRmiU7e.js","names":[],"sources":["../../src/patterns/enable/analytics/modifies/layout.svelte.ts","../../src/patterns/enable/analytics/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst MODULE_SPECIFIER = \"$lib/components/analytics/analytics.svelte\";\n\nconst IMPORT_SNIPPET = dedent`\n import Analytics from '${MODULE_SPECIFIER}';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<Analytics />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <Analytics /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <Analytics /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<Analytics />` at the top level of the root layout, ahead of\n * `{@render children()}`. The component is the same path for every provider,\n * so this modifier is provider-agnostic and a re-run with another provider\n * leaves the layout alone.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"Analytics\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { defaultImport: \"Analytics\", moduleSpecifier: MODULE_SPECIFIER },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { resolveProvider, suppliedProviderEnv } from \"../../../core/providers\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, modifyLayoutSvelte(layoutPath)));\n\n logger.info(\"Updating .env\");\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AASA,IAAM,IAAmB,8CAEnB,IAAiB,CAAM;2BACF,EAAiB;GAGtC,IAAiB,qBAEjB,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA,EAAe,KAAK;AACtB,CAAC,CAAC,KAAK,IAAI,GAEL,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA,EAAe,KAAK;AACtB,CAAC,CAAC,KAAK,IAAI;AAQX,SAAgB,EAAmB,GAAmC;CACpE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAa,SAAS;CAAe;CAGxD,IAAM,IAAO,EAAW,SAAS,CAAU;CAqB3C,OApBI,EAAK,WAAW,WAAW,IACtB;EAAE,QAAQ;EAAW,SAAS;CAAM,IAExC,EAAK,UAAU,KAIpB,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQ,MAAQ,EAAmB,IAAS,MAAO;GACzD,EAAc,GAAI,CAChB;IAAE,eAAe;IAAa,iBAAiB;GAAiB,CAClE,CAAC;EACH,CAAC;EACD,OAAO;CACT,CAAC,GAEI,EAAK,qBAAqB,CAAc,KAC3C,EAAK,aAAa,CAAc,GAElC,EAAK,QAAQ,CAAU,GAChB;EAAE,QAAQ;EAAW,SAAS,EAAK,WAAW;CAAE,KAhB9C;EAAE,QAAQ;EAAU,SAAS;CAAa;AAiBrD;;;AC/DA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAW,EAAgB,GAAM,CAAO,GACxC,IAAmB,CAAC,GAEpB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,qCAAqC;CACjD,IAAM,IAAa,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAG5E,AAFA,EAAW,EAAoB,GAAY,EAAmB,CAAU,CAAC,CAAC,GAE1E,EAAO,KAAK,eAAe;CAC3B,IAAM,IAAU,EAAK,KAAK,EAAQ,MAAM,MAAM;CAQ9C,OAPA,EACE,EACE,GACA,EAAU,GAAS,EAAY,GAAU,EAAoB,CAAO,CAAC,CAAC,CACxE,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,145 @@
1
+ import { t as e } from "./dedent-Gq6Krl4n.js";
2
+ import { n as t } from "./logger-CQONztPm.js";
3
+ import { n } from "./shared-BwHQM-a9.js";
4
+ import { f as r, modifyOutcomeToFile as i, n as a, o, revertOutcomeToFile as s } from "./modify-file-GQD6uNgI.js";
5
+ import { t as c } from "./site-D027dpBm.js";
6
+ import { n as l } from "./compose-handle-Cg9jnCsS.js";
7
+ import { i as u, n as d, o as f } from "./test-setup-B2hd8I-s.js";
8
+ import p from "node:fs";
9
+ import m from "node:path";
10
+ import { Node as h, Project as g, QuoteKind as _ } from "ts-morph";
11
+ //#region src/patterns/disable/backend/modifies/hooks.server.ts
12
+ var v = e`
13
+ Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,
14
+ and its imports from '@velastack/pocketbase' and '$env/dynamic/private'.
15
+ `, y = e`
16
+ The workflows are removed with the backend. Take the startWorker() call out
17
+ of the init hook in src/hooks.server.ts, and its import:
18
+
19
+ import { startWorker } from '$lib/server/workflows';
20
+ `, b = [
21
+ "@velastack/pocketbase",
22
+ "$env/dynamic/private",
23
+ "$lib/server/workflows",
24
+ "@sveltejs/kit",
25
+ "@sveltejs/kit/hooks"
26
+ ];
27
+ function x(e) {
28
+ return e ? h.isAwaitExpression(e) || h.isExpressionStatement(e) || h.isReturnStatement(e) ? x(e.getExpression()) : h.isCallExpression(e) && e.getExpression().getText() === "startWorker" && e.getArguments().length === 0 : !1;
29
+ }
30
+ function S(e) {
31
+ if (!h.isArrowFunction(e) && !h.isFunctionExpression(e) && !h.isFunctionDeclaration(e)) return !1;
32
+ let t = e.getBody();
33
+ if (!t) return !1;
34
+ if (!h.isBlock(t)) return x(t);
35
+ let n = t.getStatements();
36
+ return n.length === 1 && x(n[0]);
37
+ }
38
+ function C(e) {
39
+ let t = e.getFunction("init"), n = e.getVariableDeclaration("init"), r = t ?? n?.getVariableStatement();
40
+ return !r || !r.getText().includes("startWorker") ? null : (t ? S(t) : n?.getVariableStatement()?.getDeclarations().length === 1 && S(n.getInitializer())) ? r : "custom";
41
+ }
42
+ function w(e) {
43
+ if (!p.existsSync(e)) return {
44
+ status: "success",
45
+ changed: !1
46
+ };
47
+ let t = p.readFileSync(e, "utf8");
48
+ if (!t.includes("handlePocketbase") && !t.includes("startWorker")) return {
49
+ status: "success",
50
+ changed: !1
51
+ };
52
+ let n = new g({
53
+ compilerOptions: { allowJs: !0 },
54
+ manipulationSettings: { quoteKind: _.Single }
55
+ }).addSourceFileAtPath(e);
56
+ if (C(n) === "custom") return {
57
+ status: "failed",
58
+ message: y
59
+ };
60
+ if (l(n, "handlePocketbase").status === "unsupported") return {
61
+ status: "failed",
62
+ message: v
63
+ };
64
+ let i = C(n);
65
+ return i && i !== "custom" && r(n, i), o(n, b), n.formatText(), a(n), n.saveSync(), {
66
+ status: "success",
67
+ changed: n.getFullText() !== t
68
+ };
69
+ }
70
+ //#endregion
71
+ //#region src/patterns/disable/backend/modifies/layout-server.ts
72
+ var T = e`
73
+ src/routes/+layout.server.ts still reads locals.meta, which only the
74
+ PocketBase hook provides. Read the values from a static module instead:
75
+
76
+ import { site } from '$lib/site';
77
+
78
+ // locals.meta.appName -> site.name
79
+ // locals.meta.appURL -> site.url
80
+ // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }
81
+ `;
82
+ function E(e) {
83
+ if (!p.existsSync(e)) return {
84
+ status: "success",
85
+ changed: !1
86
+ };
87
+ let t = p.readFileSync(e, "utf8");
88
+ if (!t.includes("locals.meta")) return {
89
+ status: "success",
90
+ changed: !1
91
+ };
92
+ let n = t.replace(/\blocals\.meta\.appName\b/g, "site.name").replace(/\blocals\.meta\.appURL\b/g, "site.url").replace(/\bmeta:\s*locals\.meta\b/g, "meta: { appName: site.name, appURL: site.url }");
93
+ if (n.includes("locals.meta")) return {
94
+ status: "failed",
95
+ message: T
96
+ };
97
+ let r = n.replace(/\(\{\s*locals\s*,\s*/g, "({ ").replace(/,\s*locals\s*\}/g, " }");
98
+ return /\blocals\b/.test(r) || (n = r), /from\s+['"]\$lib\/site['"]/.test(n) || (n = "import { site } from '$lib/site';\n" + n), p.writeFileSync(e, n, "utf8"), {
99
+ status: "success",
100
+ changed: !0
101
+ };
102
+ }
103
+ //#endregion
104
+ //#region src/patterns/disable/backend/generate.runtime.ts
105
+ function D(e) {
106
+ if (!p.existsSync(e)) return [];
107
+ let t = [];
108
+ for (let n of p.readdirSync(e, { withFileTypes: !0 })) {
109
+ let r = m.join(e, n.name);
110
+ n.isDirectory() ? t.push(...D(r)) : n.name === "server.test.ts" && t.push(r);
111
+ }
112
+ return t;
113
+ }
114
+ async function O(e) {
115
+ let r = t(e), a = [], o = [], l = [];
116
+ r.info("Reverting adapter config");
117
+ let p = f(e.root), h = i(p.filePath, p.outcome);
118
+ h && o.push(h), r.info("Reverting hooks.server.ts");
119
+ let g = m.join(e.root, "src", "hooks.server.ts"), _ = s(g, w(g));
120
+ _.modify && o.push(_.modify), _.delete && l.push(_.delete), r.info("Reverting .gitignore");
121
+ let v = m.join(e.root, ".gitignore"), y = i(v, u(v));
122
+ y && o.push(y), r.info("Reverting src/routes/+layout.server.ts");
123
+ let b = m.join(e.root, "src", "routes", "+layout.server.ts"), x = i(b, E(b));
124
+ if (x && o.push(x), x?.status === "success") {
125
+ let t = await c(e);
126
+ t && a.push(t);
127
+ }
128
+ for (let t of D(m.join(e.root, "src"))) r.info(`Removing ${m.relative(e.root, t)}`), l.push(n(t));
129
+ r.info("Reverting test/setup.ts");
130
+ let S = m.join(e.root, "test", "setup.ts"), C = i(S, d(S));
131
+ return C && o.push(C), {
132
+ creates: a,
133
+ modifies: o,
134
+ deletes: l,
135
+ components: [],
136
+ packages: [],
137
+ collections: [],
138
+ collectionPatches: [],
139
+ collectionDrops: []
140
+ };
141
+ }
142
+ //#endregion
143
+ export { O as generate };
144
+
145
+ //# sourceMappingURL=generate.runtime-flFRYzpi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-flFRYzpi.js","names":[],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$env/dynamic/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '$lib/server/workflows';\n`;\n\n/** Modules only the backend's handle and init import from. */\nconst BACKEND_MODULES = [\n \"@velastack/pocketbase\",\n \"$env/dynamic/private\",\n \"$lib/server/workflows\",\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n sourceFile.formatText();\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '$lib/site';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point an older root layout's meta at `$lib/site` instead of `locals.meta`.\n * Templates from before `src/lib/site.ts` read the app name and URL off the\n * PocketBase hook; without the backend nothing sets them, and `App.Locals` no\n * longer declares them. Current templates read `$lib/site` already, so this\n * leaves them alone.\n */\nexport function unmodifyLayoutServerMeta(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n if (!/from\\s+['\"]\\$lib\\/site['\"]/.test(updated)) {\n updated = \"import { site } from '$lib/site';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n // The converted layout reads `src/lib/site.ts`. Every template ships it; a\n // project from before that gets one here, named as PocketBase knew it.\n if (layoutServerFile?.status === \"success\") {\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n\n return {\n creates,\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;AAiBA,IAAM,IAAc,CAAM;;;GAKpB,IAAY,CAAM;;;;;GAQlB,IAAkB;CACtB;CACA;CACA;CACA;CACA;AACF;AAGA,SAAS,EAAkB,GAAiC;CAO1D,OANK,IACD,EAAK,kBAAkB,CAAI,KAE3B,EAAK,sBAAsB,CAAI,KAAK,EAAK,kBAAkB,CAAI,IAC1D,EAAkB,EAAK,cAAc,CAAC,IAG7C,EAAK,iBAAiB,CAAI,KAC1B,EAAK,cAAc,CAAC,CAAC,QAAQ,MAAM,iBACnC,EAAK,aAAa,CAAC,CAAC,WAAW,IATf;AAWpB;AAGA,SAAS,EAAiB,GAA+B;CACvD,IACE,CAAC,EAAK,gBAAgB,CAAE,KACxB,CAAC,EAAK,qBAAqB,CAAE,KAC7B,CAAC,EAAK,sBAAsB,CAAE,GAE9B,OAAO;CAET,IAAM,IAAO,EAAG,QAAQ;CACxB,IAAI,CAAC,GAAM,OAAO;CAClB,IAAI,CAAC,EAAK,QAAQ,CAAI,GAAG,OAAO,EAAkB,CAAI;CACtD,IAAM,IAAa,EAAK,cAAc;CACtC,OAAO,EAAW,WAAW,KAAK,EAAkB,EAAW,EAAE;AACnE;AAOA,SAAS,EAAW,GAA6C;CAC/D,IAAM,IAAK,EAAG,YAAY,MAAM,GAC1B,IAAO,EAAG,uBAAuB,MAAM,GACvC,IAAS,KAAM,GAAM,qBAAqB;CAMhD,OALI,CAAC,KAAU,CAAC,EAAO,QAAQ,CAAC,CAAC,SAAS,aAAa,IAAU,QAC9C,IACf,EAAiB,CAAE,IACnB,GAAM,qBAAqB,CAAC,EAAE,gBAAgB,CAAC,CAAC,WAAW,KAC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AAK,EAAQ,MAAM,YAAY,GACpD,IAAgB,EACpB,GACA,EAAkB,CAAa,CACjC;CAGA,AAFI,KAAe,EAAS,KAAK,CAAa,GAE9C,EAAO,KAAK,wCAAwC;CACpD,IAAM,IAAmB,EAAK,KAC5B,EAAQ,MACR,OACA,UACA,mBACF,GACM,IAAmB,EACvB,GACA,EAAyB,CAAgB,CAC3C;CAKA,IAJI,KAAkB,EAAS,KAAK,CAAgB,GAIhD,GAAkB,WAAW,WAAW;EAC1C,IAAM,IAAW,MAAM,EAAe,CAAO;EAC7C,AAAI,KAAU,EAAQ,KAAK,CAAQ;CACrC;CAKA,KAAK,IAAM,KAAY,EAAgB,EAAK,KAAK,EAAQ,MAAM,KAAK,CAAC,GAEnE,AADA,EAAO,KAAK,YAAY,EAAK,SAAS,EAAQ,MAAM,CAAQ,GAAG,GAC/D,EAAQ,KAAK,EAAc,CAAQ,CAAC;CAGtC,EAAO,KAAK,yBAAyB;CACrC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,QAAQ,UAAU,GAC1D,IAAgB,EACpB,GACA,EAAkB,CAAa,CACjC;CAGA,OAFI,KAAe,EAAS,KAAK,CAAa,GAEvC;EACL;EACA;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
@@ -0,0 +1,110 @@
1
+ import { n as e } from "./logger-CQONztPm.js";
2
+ import { t } from "./shared-BwHQM-a9.js";
3
+ import { c as n, d as r, h as i, m as a, modifyOutcomeToFile as o } from "./modify-file-GQD6uNgI.js";
4
+ import { t as s } from "./svelte-file-B3RfgVdt.js";
5
+ import c from "node:fs";
6
+ import l from "node:path";
7
+ import { Project as u, SyntaxKind as d } from "ts-morph";
8
+ //#region src/patterns/disable/auth/modifies/+layout.server.ts
9
+ function f(e) {
10
+ if (!c.existsSync(e)) return {
11
+ status: "success",
12
+ changed: !1
13
+ };
14
+ let t = c.readFileSync(e, "utf8");
15
+ if (!t.includes("locals.pb.authStore.record")) return {
16
+ status: "success",
17
+ changed: !1
18
+ };
19
+ let n = new u().addSourceFileAtPath(e), r = n.getDescendantsOfKind(d.ObjectLiteralExpression);
20
+ for (let e of r) {
21
+ let t = e.getProperty("user");
22
+ t && t.getKind() === d.PropertyAssignment && t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
23
+ }
24
+ return a(n, "locals"), n.formatText(), n.saveSync(), {
25
+ status: "success",
26
+ changed: n.getFullText() !== t
27
+ };
28
+ }
29
+ //#endregion
30
+ //#region src/patterns/disable/auth/modifies/root-layout.svelte.ts
31
+ function p(e) {
32
+ if (!c.existsSync(e)) return {
33
+ status: "success",
34
+ changed: !1
35
+ };
36
+ let t = c.readFileSync(e, "utf8"), a = new s(t);
37
+ if (!a.hasElement("AuthMenu.Root")) return {
38
+ status: "success",
39
+ changed: !1
40
+ };
41
+ a.removeElement("AuthMenu.Root");
42
+ let o = a.toString().replace(/<script[\s\S]*?<\/script>/g, "");
43
+ return a.modifyScript((e) => {
44
+ let { source: t } = i(e, (e) => {
45
+ n(e, "$lib/components/ui/auth-menu"), n(e, "$lib/components/ui/avatar"), r(e, "data", o);
46
+ });
47
+ return t;
48
+ }), a.writeTo(e), {
49
+ status: "success",
50
+ changed: a.hasChanged()
51
+ };
52
+ }
53
+ //#endregion
54
+ //#region src/patterns/disable/auth/modifies/hooks.server.ts
55
+ function m(e) {
56
+ if (!c.existsSync(e)) return {
57
+ status: "success",
58
+ changed: !1
59
+ };
60
+ let t = c.readFileSync(e, "utf8"), n = new u().addSourceFileAtPath(e), r = n.getDescendantsOfKind(d.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
61
+ if (!r) return {
62
+ status: "success",
63
+ changed: !1
64
+ };
65
+ let [i] = r.getArguments();
66
+ if (!i || i.getKind() !== d.ObjectLiteralExpression) return {
67
+ status: "success",
68
+ changed: !1
69
+ };
70
+ let a = i.asKindOrThrow(d.ObjectLiteralExpression), o = a.getProperty("auth");
71
+ return o ? (o.remove(), a.getProperties().length === 0 && r.removeArgument(0), n.formatText(), n.saveSync(), {
72
+ status: "success",
73
+ changed: n.getFullText() !== t
74
+ }) : {
75
+ status: "success",
76
+ changed: !1
77
+ };
78
+ }
79
+ //#endregion
80
+ //#region src/patterns/disable/auth/generate.runtime.ts
81
+ async function h(n) {
82
+ let r = e(n), i = [], a = (e) => {
83
+ e && i.push(e);
84
+ };
85
+ r.info("Reverting +layout.server.ts");
86
+ let s = l.join(n.root, "src", "routes", "+layout.server.ts");
87
+ a(o(s, f(s))), r.info("Reverting root layout");
88
+ let u = [
89
+ l.join(n.root, "src", "routes", "(public)", "root-layout.svelte"),
90
+ l.join(n.root, "src", "routes", "root-layout.svelte"),
91
+ l.join(n.root, "src", "routes", "(public)", "+layout.svelte"),
92
+ l.join(n.root, "src", "routes", "+layout.svelte")
93
+ ], d = u.find((e) => c.existsSync(e)) ?? u[0];
94
+ a(o(d, p(d))), r.info("Reverting hooks.server.ts");
95
+ let h = l.join(n.root, "src", "hooks.server.ts");
96
+ return a(o(h, m(h))), {
97
+ creates: [],
98
+ modifies: i,
99
+ deletes: [],
100
+ components: [],
101
+ packages: [],
102
+ collections: [],
103
+ collectionPatches: [],
104
+ collectionDrops: await t(["oauth_accounts"], n)
105
+ };
106
+ }
107
+ //#endregion
108
+ export { h as generate };
109
+
110
+ //# sourceMappingURL=generate.runtime-gtpOuLNO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-gtpOuLNO.js","names":[],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeUnusedBindingElement } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.removeElement(\"AuthMenu.Root\");\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/auth-menu\");\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/avatar\");\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,EAAqB,GAAmC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAY,MAAM;CACzD,IAAI,CAAC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAM,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAU,GAEnD,IAAW,EAAW,qBAC1B,EAAW,uBACb;CACA,KAAK,IAAM,KAAO,GAAU;EAC1B,IAAM,IAAW,EAAI,YAAY,MAAM;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;CAUxE,OATA,EACE,EAAoB,GAAiB,EAAoB,CAAe,CAAC,CAC3E,GAOO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B,EAC5B,CAAC,gBAAgB,GACjB,CACF;CAWA;AACF"}
@@ -1,17 +1,17 @@
1
1
  import { n as e } from "./logger-CQONztPm.js";
2
- import { t } from "./shared-Cmbzu7Od.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-Cgu_WeFk.js";
4
- import { l as r, o as i } from "./ts-morph-helpers-teS3yXg-.js";
5
- import a from "node:path";
6
- import o from "node:fs";
2
+ import { t } from "./shared-BwHQM-a9.js";
3
+ import { modifyOutcomeToFile as n, u as r } from "./modify-file-GQD6uNgI.js";
4
+ import { t as i } from "./svelte-file-B3RfgVdt.js";
5
+ import a from "node:fs";
6
+ import o from "node:path";
7
7
  import { Project as s, SyntaxKind as c } from "ts-morph";
8
8
  //#region src/patterns/disable/api-keys/modifies/hooks.server.ts
9
9
  function l(e) {
10
- if (!o.existsSync(e)) return {
10
+ if (!a.existsSync(e)) return {
11
11
  status: "success",
12
12
  changed: !1
13
13
  };
14
- let t = o.readFileSync(e, "utf8"), n = new s().addSourceFileAtPath(e), r = n.getDescendantsOfKind(c.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
14
+ let t = a.readFileSync(e, "utf8"), n = new s().addSourceFileAtPath(e), r = n.getDescendantsOfKind(c.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
15
15
  if (!r) return {
16
16
  status: "success",
17
17
  changed: !1
@@ -21,12 +21,12 @@ function l(e) {
21
21
  status: "success",
22
22
  changed: !1
23
23
  };
24
- let a = i.asKindOrThrow(c.ObjectLiteralExpression).getProperty("api");
25
- if (!a || a.getKind() !== c.PropertyAssignment) return {
24
+ let o = i.asKindOrThrow(c.ObjectLiteralExpression).getProperty("api");
25
+ if (!o || o.getKind() !== c.PropertyAssignment) return {
26
26
  status: "success",
27
27
  changed: !1
28
28
  };
29
- let l = a.getInitializer();
29
+ let l = o.getInitializer();
30
30
  if (!l || l.getKind() !== c.ObjectLiteralExpression) return {
31
31
  status: "success",
32
32
  changed: !1
@@ -43,22 +43,22 @@ function l(e) {
43
43
  //#endregion
44
44
  //#region src/patterns/disable/api-keys/modifies/nav-user.svelte.ts
45
45
  function u(e) {
46
- if (!o.existsSync(e)) return {
46
+ if (!a.existsSync(e)) return {
47
47
  status: "success",
48
48
  changed: !1
49
49
  };
50
- let t = o.readFileSync(e, "utf8");
50
+ let t = a.readFileSync(e, "utf8");
51
51
  if (!t.includes("/api-keys")) return {
52
52
  status: "success",
53
53
  changed: !1
54
54
  };
55
- let n = new r(t), a = !1, s = (e) => {
56
- a || e((e) => {
57
- let t = i(e, "API Keys", "@lucide/svelte/icons/key-round");
58
- return t.wasRemoved && (a = !0), t.source;
55
+ let n = new i(t), o = !1, s = (e) => {
56
+ o || e((e) => {
57
+ let t = r(e, "API Keys", "@lucide/svelte/icons/key-round");
58
+ return t.wasRemoved && (o = !0), t.source;
59
59
  });
60
60
  };
61
- return s((e) => n.modifyModuleScript(e)), a || s((e) => n.modifyScript(e)), a ? (o.writeFileSync(e, n.toString(), "utf8"), {
61
+ return s((e) => n.modifyModuleScript(e)), o || s((e) => n.modifyScript(e)), o ? (a.writeFileSync(e, n.toString(), "utf8"), {
62
62
  status: "success",
63
63
  changed: !0
64
64
  }) : {
@@ -69,16 +69,16 @@ function u(e) {
69
69
  //#endregion
70
70
  //#region src/patterns/disable/api-keys/generate.runtime.ts
71
71
  async function d(r) {
72
- let i = e(r), o = [], s = (e) => {
73
- e && o.push(e);
72
+ let i = e(r), a = [], s = (e) => {
73
+ e && a.push(e);
74
74
  };
75
75
  i.info("Reverting hooks.server.ts");
76
- let c = a.join(r.root, "src", "hooks.server.ts");
76
+ let c = o.join(r.root, "src", "hooks.server.ts");
77
77
  s(n(c, l(c))), i.info("Reverting nav-user.svelte");
78
- let d = a.join(r.root, "src", "lib", "components", "nav-user.svelte");
78
+ let d = o.join(r.root, "src", "lib", "components", "nav-user.svelte");
79
79
  return s(n(d, u(d))), {
80
80
  creates: [],
81
- modifies: o,
81
+ modifies: a,
82
82
  deletes: [],
83
83
  components: [],
84
84
  packages: [],
@@ -90,4 +90,4 @@ async function d(r) {
90
90
  //#endregion
91
91
  export { d as generate };
92
92
 
93
- //# sourceMappingURL=generate.runtime-DHRCNPVx.js.map
93
+ //# sourceMappingURL=generate.runtime-kLxeDGnS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-DHRCNPVx.js","names":[],"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\";\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 sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { 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: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,EAAoB,GAAwC;CAC1E,IAAI,CAAC,EAAG,WAAW,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAiB,MAAM,GAExD,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAe,GAExD,IAAW,EACd,qBAAqB,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CACnE,IAAI,CAAC,GAAU,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE1D,IAAM,CAAC,KAAY,EAAS,aAAa;CACzC,IAAI,CAAC,KAAY,EAAS,QAAQ,MAAM,EAAW,yBACjD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAM,IADa,EAAS,cAAc,EAAW,uBACrC,CAAA,CAAW,YAAY,KAAK;CAC5C,IAAI,CAAC,KAAW,EAAQ,QAAQ,MAAM,EAAW,oBAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IACJ,EACA,eAAe;CACjB,IAAI,CAAC,KAAW,EAAQ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,KAAK,2BAA2B;CACvC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,iBACF;CAKA,OAJA,EAAW,EAAoB,GAAa,EAAgB,CAAW,CAAC,CAAC,GAIlE;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAV4B,EAAwB,CAAC,UAAU,GAAG,CAAO;CAW3E;AACF"}
1
+ {"version":3,"file":"generate.runtime-kLxeDGnS.js","names":[],"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\";\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 sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { 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: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,EAAoB,GAAwC;CAC1E,IAAI,CAAC,EAAG,WAAW,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAiB,MAAM,GAExD,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAe,GAExD,IAAW,EACd,qBAAqB,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CACnE,IAAI,CAAC,GAAU,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE1D,IAAM,CAAC,KAAY,EAAS,aAAa;CACzC,IAAI,CAAC,KAAY,EAAS,QAAQ,MAAM,EAAW,yBACjD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAM,IADa,EAAS,cAAc,EAAW,uBACrC,CAAA,CAAW,YAAY,KAAK;CAC5C,IAAI,CAAC,KAAW,EAAQ,QAAQ,MAAM,EAAW,oBAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IACJ,EACA,eAAe;CACjB,IAAI,CAAC,KAAW,EAAQ,QAAQ,MAAM,EAAW,yBAC/C,OAAO;EAAE,QAAQ;EAA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,MACR,OACA,OACA,cACA,iBACF;CAKA,OAJA,EAAW,EAAoB,GAAa,EAAgB,CAAW,CAAC,CAAC,GAIlE;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAV4B,EAAwB,CAAC,UAAU,GAAG,CAAO;CAW3E;AACF"}
@@ -1,29 +1,29 @@
1
1
  import { n as e } from "./logger-CQONztPm.js";
2
- import { t } from "./shared-Cmbzu7Od.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-Cgu_WeFk.js";
4
- import { l as r, o as i } from "./ts-morph-helpers-teS3yXg-.js";
5
- import { n as a } from "./env-BPfk1VAw.js";
6
- import o from "node:path";
7
- import s from "node:fs";
2
+ import { t } from "./shared-BwHQM-a9.js";
3
+ import { n } from "./env-BPfk1VAw.js";
4
+ import { modifyOutcomeToFile as r, u as i } from "./modify-file-GQD6uNgI.js";
5
+ import { t as a } from "./svelte-file-B3RfgVdt.js";
6
+ import o from "node:fs";
7
+ import s from "node:path";
8
8
  import { Project as c, QuoteKind as l, SyntaxKind as u } from "ts-morph";
9
9
  //#region src/patterns/disable/payments/modifies/modify-nav-user.ts
10
10
  function d(e) {
11
- if (!s.existsSync(e)) return {
11
+ if (!o.existsSync(e)) return {
12
12
  status: "success",
13
13
  changed: !1
14
14
  };
15
- let t = s.readFileSync(e, "utf8");
15
+ let t = o.readFileSync(e, "utf8");
16
16
  if (!t.includes("/billing")) return {
17
17
  status: "success",
18
18
  changed: !1
19
19
  };
20
- let n = new r(t), a = !1, o = (e) => {
21
- a || e((e) => {
20
+ let n = new a(t), r = !1, s = (e) => {
21
+ r || e((e) => {
22
22
  let t = i(e, "Billing", "@lucide/svelte/icons/credit-card");
23
- return t.wasRemoved && (a = !0), t.source;
23
+ return t.wasRemoved && (r = !0), t.source;
24
24
  });
25
25
  };
26
- return o((e) => n.modifyModuleScript(e)), a || o((e) => n.modifyScript(e)), a ? (s.writeFileSync(e, n.toString(), "utf8"), {
26
+ return s((e) => n.modifyModuleScript(e)), r || s((e) => n.modifyScript(e)), r ? (o.writeFileSync(e, n.toString(), "utf8"), {
27
27
  status: "success",
28
28
  changed: !0
29
29
  }) : {
@@ -35,11 +35,11 @@ function d(e) {
35
35
  //#region src/patterns/disable/payments/modifies/modify-user-signup.ts
36
36
  var f = /* @__PURE__ */ new Set(["linkStripeCustomer.run", "linkStripeCustomer"]);
37
37
  function p(e) {
38
- if (!s.existsSync(e)) return {
38
+ if (!o.existsSync(e)) return {
39
39
  status: "success",
40
40
  changed: !1
41
41
  };
42
- let t = s.readFileSync(e, "utf8");
42
+ let t = o.readFileSync(e, "utf8");
43
43
  if (!t.includes("linkStripeCustomer")) return {
44
44
  status: "success",
45
45
  changed: !1
@@ -63,11 +63,11 @@ function p(e) {
63
63
  }
64
64
  //#endregion
65
65
  //#region src/patterns/disable/payments/generate.runtime.ts
66
- async function m(r) {
67
- let i = r.features.auth, s = e(r), c = [], l = (e) => {
66
+ async function m(i) {
67
+ let a = i.features.auth, o = e(i), c = [], l = (e) => {
68
68
  e && c.push(e);
69
69
  };
70
- s.info("Stripping Stripe credentials from .env");
70
+ o.info("Stripping Stripe credentials from .env");
71
71
  let u = [
72
72
  {
73
73
  type: "comment",
@@ -85,13 +85,13 @@ async function m(r) {
85
85
  type: "var",
86
86
  key: "STRIPE_WEBHOOK_SECRET"
87
87
  }
88
- ], f = o.join(r.root, ".env");
89
- if (l(n(f, a(f, u))), i) {
90
- s.info("Reverting nav-user.svelte");
91
- let e = o.join(r.root, "src", "lib", "components", "nav-user.svelte");
92
- l(n(e, d(e))), s.info("Reverting signup +page.server.ts");
93
- let t = o.join(r.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
94
- l(n(t, p(t)));
88
+ ], f = s.join(i.root, ".env");
89
+ if (l(r(f, n(f, u))), a) {
90
+ o.info("Reverting nav-user.svelte");
91
+ let e = s.join(i.root, "src", "lib", "components", "nav-user.svelte");
92
+ l(r(e, d(e))), o.info("Reverting signup +page.server.ts");
93
+ let t = s.join(i.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
94
+ l(r(t, p(t)));
95
95
  }
96
96
  return {
97
97
  creates: [],
@@ -101,16 +101,16 @@ async function m(r) {
101
101
  packages: [],
102
102
  collections: [],
103
103
  collectionPatches: [],
104
- collectionDrops: await t(i ? [
104
+ collectionDrops: await t(a ? [
105
105
  "transactions",
106
106
  "stripe_customers",
107
107
  "stripe_payment_methods",
108
108
  "stripe_prices",
109
109
  "stripe_products"
110
- ] : ["stripe_prices", "stripe_products"], r)
110
+ ] : ["stripe_prices", "stripe_products"], i)
111
111
  };
112
112
  }
113
113
  //#endregion
114
114
  export { m as generate };
115
115
 
116
- //# sourceMappingURL=generate.runtime-DH9o-888.js.map
116
+ //# sourceMappingURL=generate.runtime-wA1G3tQ4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.runtime-DH9o-888.js","names":[],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const specifier of [\n \"$lib/workflows/link-stripe-customer\",\n \"$lib/stripe\",\n ]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === specifier);\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n if (stmt) stmt.remove();\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnvRemove, type EnvEdit } from \"../../../runtime/env\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\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(\"Stripping Stripe credentials from .env\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\" },\n { type: \"var\", key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\" },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\" },\n ];\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnvRemove(envPath, envEdits)));\n\n if (isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n const collectionNames = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n ];\n const collectionDrops = await planDropsForCollections(\n isAppMode ? collectionNames : [\"stripe_prices\", \"stripe_products\"],\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":";;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A,UACA,iBACF;EACA,EACE,EAAoB,GAAgB,EAAmB,CAAc,CAAC,CACxE;CACF;CAcA,OAAO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B,EAC5B,IAAY;GAPZ;GACA;GACA;GACA;GACA;EAGY,IAAkB,CAAC,iBAAiB,iBAAiB,GACjE,CACF;CAWA;AACF"}
1
+ {"version":3,"file":"generate.runtime-wA1G3tQ4.js","names":[],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const specifier of [\n \"$lib/workflows/link-stripe-customer\",\n \"$lib/stripe\",\n ]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === specifier);\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n if (stmt) stmt.remove();\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnvRemove, type EnvEdit } from \"../../../runtime/env\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\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(\"Stripping Stripe credentials from .env\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\" },\n { type: \"var\", key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\" },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\" },\n ];\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnvRemove(envPath, envEdits)));\n\n if (isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n const collectionNames = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n ];\n const collectionDrops = await planDropsForCollections(\n isAppMode ? collectionNames : [\"stripe_prices\", \"stripe_products\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAKA,SAAgB,EAAgB,GAAoC;CAClE,IAAI,CAAC,EAAG,WAAW,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAS,EAAG,aAAa,GAAa,MAAM;CAClD,IAAI,CAAC,EAAO,SAAS,UAAU,GAC7B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,IAAI,EAAW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