@velastack/patterns 0.3.1 → 0.3.3

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 (156) hide show
  1. package/README.md +42 -3
  2. package/dist/chunks/_layout-B7ujvjnA.js +55 -0
  3. package/dist/chunks/_layout-B7ujvjnA.js.map +1 -0
  4. package/dist/chunks/{collections-CgdvZXmh.js → collections-CrOvS2E7.js} +3 -3
  5. package/dist/chunks/{collections-CgdvZXmh.js.map → collections-CrOvS2E7.js.map} +1 -1
  6. package/dist/chunks/{compose-handle-Cg9jnCsS.js → compose-handle-B-CkDcQD.js} +23 -23
  7. package/dist/chunks/{compose-handle-Cg9jnCsS.js.map → compose-handle-B-CkDcQD.js.map} +1 -1
  8. package/dist/chunks/config-target-Bln26FJe.js +164 -0
  9. package/dist/chunks/config-target-Bln26FJe.js.map +1 -0
  10. package/dist/chunks/{constants-DSFKQwtP.js → constants-BYkd9jeJ.js} +2 -2
  11. package/dist/chunks/constants-BYkd9jeJ.js.map +1 -0
  12. package/dist/chunks/errors-DR3gF_7a.js +18 -0
  13. package/dist/chunks/errors-DR3gF_7a.js.map +1 -0
  14. package/dist/chunks/{format-result-Cb2hWsb8.js → format-result-DZ8De8KY.js} +19 -11
  15. package/dist/chunks/format-result-DZ8De8KY.js.map +1 -0
  16. package/dist/chunks/{generate-DRA63W0r.js → generate-6snrlnpA.js} +2 -2
  17. package/dist/chunks/{generate-DRA63W0r.js.map → generate-6snrlnpA.js.map} +1 -1
  18. package/dist/chunks/{generate-iQP31-m1.js → generate-Ca_6FlPi.js} +5 -5
  19. package/dist/chunks/{generate-iQP31-m1.js.map → generate-Ca_6FlPi.js.map} +1 -1
  20. package/dist/chunks/{generate-tOkjJFUf.js → generate-CyuY2Ci7.js} +4 -3
  21. package/dist/chunks/generate-CyuY2Ci7.js.map +1 -0
  22. package/dist/chunks/{generate-BkQ1xMDp.js → generate-DQeWOEPY.js} +4 -4
  23. package/dist/chunks/{generate-BkQ1xMDp.js.map → generate-DQeWOEPY.js.map} +1 -1
  24. package/dist/chunks/{generate-_LvrYK6i.js → generate-DwADTUob.js} +4 -4
  25. package/dist/chunks/{generate-_LvrYK6i.js.map → generate-DwADTUob.js.map} +1 -1
  26. package/dist/chunks/{generate.runtime-BbIN0tUZ.js → generate.runtime-4FDxnvCl.js} +67 -66
  27. package/dist/chunks/generate.runtime-4FDxnvCl.js.map +1 -0
  28. package/dist/chunks/{generate.runtime-B0hhtyAL.js → generate.runtime-AYQVW1S-.js} +27 -26
  29. package/dist/chunks/generate.runtime-AYQVW1S-.js.map +1 -0
  30. package/dist/chunks/{generate.runtime-wA1G3tQ4.js → generate.runtime-B2aFFaac.js} +38 -37
  31. package/dist/chunks/generate.runtime-B2aFFaac.js.map +1 -0
  32. package/dist/chunks/{generate.runtime-DhkaXTq3.js → generate.runtime-B45MvtYm.js} +61 -59
  33. package/dist/chunks/generate.runtime-B45MvtYm.js.map +1 -0
  34. package/dist/chunks/{generate.runtime-S5RIgbQx.js → generate.runtime-BFOXm2DD.js} +98 -92
  35. package/dist/chunks/generate.runtime-BFOXm2DD.js.map +1 -0
  36. package/dist/chunks/{generate.runtime-BnWE4qsu.js → generate.runtime-BHkFmI2Y.js} +55 -54
  37. package/dist/chunks/generate.runtime-BHkFmI2Y.js.map +1 -0
  38. package/dist/chunks/{generate.runtime-DNaQxed-.js → generate.runtime-BKiJvE8I.js} +84 -83
  39. package/dist/chunks/generate.runtime-BKiJvE8I.js.map +1 -0
  40. package/dist/chunks/{generate.runtime-DoZdSh9W.js → generate.runtime-BSRFv4cJ.js} +58 -57
  41. package/dist/chunks/generate.runtime-BSRFv4cJ.js.map +1 -0
  42. package/dist/chunks/{generate.runtime-B49wetSx.js → generate.runtime-BUqsF3AF.js} +43 -42
  43. package/dist/chunks/generate.runtime-BUqsF3AF.js.map +1 -0
  44. package/dist/chunks/{generate.runtime-acRmiU7e.js → generate.runtime-BsaSyTnU.js} +9 -8
  45. package/dist/chunks/{generate.runtime-acRmiU7e.js.map → generate.runtime-BsaSyTnU.js.map} +1 -1
  46. package/dist/chunks/generate.runtime-CMnvmeVt.js +111 -0
  47. package/dist/chunks/generate.runtime-CMnvmeVt.js.map +1 -0
  48. package/dist/chunks/{generate.runtime-BORbegw_.js → generate.runtime-CN5c2xH8.js} +123 -122
  49. package/dist/chunks/generate.runtime-CN5c2xH8.js.map +1 -0
  50. package/dist/chunks/{generate.runtime-flFRYzpi.js → generate.runtime-CgoSrP55.js} +62 -61
  51. package/dist/chunks/generate.runtime-CgoSrP55.js.map +1 -0
  52. package/dist/chunks/{generate.runtime-D0icLb5j.js → generate.runtime-D1DNAY6k.js} +12 -11
  53. package/dist/chunks/{generate.runtime-D0icLb5j.js.map → generate.runtime-D1DNAY6k.js.map} +1 -1
  54. package/dist/chunks/generate.runtime-DG-3G00z.js +87 -0
  55. package/dist/chunks/generate.runtime-DG-3G00z.js.map +1 -0
  56. package/dist/chunks/{generate.runtime-BKo-Nidn.js → generate.runtime-DQwSY6Nc.js} +6 -6
  57. package/dist/chunks/{generate.runtime-BKo-Nidn.js.map → generate.runtime-DQwSY6Nc.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-DSqkXvps.js → generate.runtime-D_yqWLcI.js} +15 -14
  59. package/dist/chunks/{generate.runtime-DSqkXvps.js.map → generate.runtime-D_yqWLcI.js.map} +1 -1
  60. package/dist/chunks/generate.runtime-Drmahmdl.js +313 -0
  61. package/dist/chunks/generate.runtime-Drmahmdl.js.map +1 -0
  62. package/dist/chunks/{generate.runtime-D8vgh5MH.js → generate.runtime-FdZw277n.js} +156 -76
  63. package/dist/chunks/generate.runtime-FdZw277n.js.map +1 -0
  64. package/dist/chunks/generate.runtime-Lh1cW9Tz.js +94 -0
  65. package/dist/chunks/generate.runtime-Lh1cW9Tz.js.map +1 -0
  66. package/dist/chunks/{generate.runtime-DAmYsIvF.js → generate.runtime-QGHToXRY.js} +5 -5
  67. package/dist/chunks/{generate.runtime-DAmYsIvF.js.map → generate.runtime-QGHToXRY.js.map} +1 -1
  68. package/dist/chunks/{generate.runtime-CRYjWJRe.js → generate.runtime-Um77JfwC.js} +89 -88
  69. package/dist/chunks/generate.runtime-Um77JfwC.js.map +1 -0
  70. package/dist/chunks/{generate.runtime-BwhGDnGu.js → generate.runtime-VgVwRiiN.js} +151 -150
  71. package/dist/chunks/generate.runtime-VgVwRiiN.js.map +1 -0
  72. package/dist/chunks/{generate.runtime-CcuAXuV2.js → generate.runtime-YyIVd4oy.js} +15 -14
  73. package/dist/chunks/{generate.runtime-CcuAXuV2.js.map → generate.runtime-YyIVd4oy.js.map} +1 -1
  74. package/dist/chunks/{generate.runtime-DOuufRLr.js → generate.runtime-cQGLxuZM.js} +82 -81
  75. package/dist/chunks/generate.runtime-cQGLxuZM.js.map +1 -0
  76. package/dist/chunks/generate.runtime-n9AFWtPp.js +94 -0
  77. package/dist/chunks/generate.runtime-n9AFWtPp.js.map +1 -0
  78. package/dist/chunks/generate.runtime-ofdnLtxS.js +57 -0
  79. package/dist/chunks/generate.runtime-ofdnLtxS.js.map +1 -0
  80. package/dist/chunks/generate.runtime-onBnOiS7.js +328 -0
  81. package/dist/chunks/generate.runtime-onBnOiS7.js.map +1 -0
  82. package/dist/chunks/modify-file-Dwfv0dCI.js +46 -0
  83. package/dist/chunks/modify-file-Dwfv0dCI.js.map +1 -0
  84. package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js → modify-svelte-config-remote-BUU_EaDf.js} +2 -2
  85. package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js.map → modify-svelte-config-remote-BUU_EaDf.js.map} +1 -1
  86. package/dist/chunks/{pocketbase-CeG5BMN2.js → pocketbase-BkhUywtb.js} +2 -2
  87. package/dist/chunks/{pocketbase-CeG5BMN2.js.map → pocketbase-BkhUywtb.js.map} +1 -1
  88. package/dist/chunks/{providers-DO9kMyzB.js → providers-BL9vJP_9.js} +2 -2
  89. package/dist/chunks/{providers-DO9kMyzB.js.map → providers-BL9vJP_9.js.map} +1 -1
  90. package/dist/chunks/{shared-BwHQM-a9.js → shared-C8GtNxpm.js} +2 -2
  91. package/dist/chunks/{shared-BwHQM-a9.js.map → shared-C8GtNxpm.js.map} +1 -1
  92. package/dist/chunks/{site-D027dpBm.js → site-BdMX8qrH.js} +2 -2
  93. package/dist/chunks/{site-D027dpBm.js.map → site-BdMX8qrH.js.map} +1 -1
  94. package/dist/chunks/table-core-G9Shld4F.js +126 -0
  95. package/dist/chunks/table-core-G9Shld4F.js.map +1 -0
  96. package/dist/chunks/{test-setup-B2hd8I-s.js → test-setup-DHEFKEHE.js} +23 -10
  97. package/dist/chunks/test-setup-DHEFKEHE.js.map +1 -0
  98. package/dist/chunks/ts-morph-helpers-CeduA--o.js +253 -0
  99. package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +1 -0
  100. package/dist/chunks/{ui-jhXrsw4T.js → ui-DD4NltyN.js} +2 -2
  101. package/dist/chunks/{ui-jhXrsw4T.js.map → ui-DD4NltyN.js.map} +1 -1
  102. package/dist/chunks/{ui-B4Tuit-7.js → ui-TlEuI2Sz.js} +50 -49
  103. package/dist/chunks/{ui-B4Tuit-7.js.map → ui-TlEuI2Sz.js.map} +1 -1
  104. package/dist/chunks/unmodify-load-jfdcVZ_a.js +81 -0
  105. package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +1 -0
  106. package/dist/chunks/write-result-Djy0SZXX.js +376 -0
  107. package/dist/chunks/write-result-Djy0SZXX.js.map +1 -0
  108. package/dist/index.d.ts +33 -1
  109. package/dist/index.js +2240 -2020
  110. package/dist/index.js.map +1 -1
  111. package/package.json +2 -2
  112. package/dist/chunks/_layout-DqH4lA_r.js +0 -47
  113. package/dist/chunks/_layout-DqH4lA_r.js.map +0 -1
  114. package/dist/chunks/config-target-Co-ij8p3.js +0 -163
  115. package/dist/chunks/config-target-Co-ij8p3.js.map +0 -1
  116. package/dist/chunks/constants-DSFKQwtP.js.map +0 -1
  117. package/dist/chunks/errors-D6gyegUK.js +0 -14
  118. package/dist/chunks/errors-D6gyegUK.js.map +0 -1
  119. package/dist/chunks/format-result-Cb2hWsb8.js.map +0 -1
  120. package/dist/chunks/generate-tOkjJFUf.js.map +0 -1
  121. package/dist/chunks/generate.runtime-B0hhtyAL.js.map +0 -1
  122. package/dist/chunks/generate.runtime-B49wetSx.js.map +0 -1
  123. package/dist/chunks/generate.runtime-B7LRx-BU.js +0 -86
  124. package/dist/chunks/generate.runtime-B7LRx-BU.js.map +0 -1
  125. package/dist/chunks/generate.runtime-BORbegw_.js.map +0 -1
  126. package/dist/chunks/generate.runtime-BbIN0tUZ.js.map +0 -1
  127. package/dist/chunks/generate.runtime-BnWE4qsu.js.map +0 -1
  128. package/dist/chunks/generate.runtime-BwhGDnGu.js.map +0 -1
  129. package/dist/chunks/generate.runtime-CCg2Pjcv.js +0 -257
  130. package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +0 -1
  131. package/dist/chunks/generate.runtime-CRYjWJRe.js.map +0 -1
  132. package/dist/chunks/generate.runtime-D2e_KRj0.js +0 -56
  133. package/dist/chunks/generate.runtime-D2e_KRj0.js.map +0 -1
  134. package/dist/chunks/generate.runtime-D44gjxRA.js +0 -332
  135. package/dist/chunks/generate.runtime-D44gjxRA.js.map +0 -1
  136. package/dist/chunks/generate.runtime-D8vgh5MH.js.map +0 -1
  137. package/dist/chunks/generate.runtime-DNaQxed-.js.map +0 -1
  138. package/dist/chunks/generate.runtime-DOuufRLr.js.map +0 -1
  139. package/dist/chunks/generate.runtime-DhkaXTq3.js.map +0 -1
  140. package/dist/chunks/generate.runtime-DoZdSh9W.js.map +0 -1
  141. package/dist/chunks/generate.runtime-S5RIgbQx.js.map +0 -1
  142. package/dist/chunks/generate.runtime-WmSMWL15.js +0 -82
  143. package/dist/chunks/generate.runtime-WmSMWL15.js.map +0 -1
  144. package/dist/chunks/generate.runtime-flFRYzpi.js.map +0 -1
  145. package/dist/chunks/generate.runtime-gtpOuLNO.js +0 -110
  146. package/dist/chunks/generate.runtime-gtpOuLNO.js.map +0 -1
  147. package/dist/chunks/generate.runtime-kLxeDGnS.js +0 -93
  148. package/dist/chunks/generate.runtime-kLxeDGnS.js.map +0 -1
  149. package/dist/chunks/generate.runtime-wA1G3tQ4.js.map +0 -1
  150. package/dist/chunks/modify-file-GQD6uNgI.js +0 -254
  151. package/dist/chunks/modify-file-GQD6uNgI.js.map +0 -1
  152. package/dist/chunks/test-setup-B2hd8I-s.js.map +0 -1
  153. package/dist/chunks/unmodify-load-W1ePZQHr.js +0 -80
  154. package/dist/chunks/unmodify-load-W1ePZQHr.js.map +0 -1
  155. package/dist/chunks/write-result-DewHCNhM.js +0 -451
  156. package/dist/chunks/write-result-DewHCNhM.js.map +0 -1
@@ -0,0 +1,111 @@
1
+ import { n as e } from "./logger-CQONztPm.js";
2
+ import { t } from "./shared-C8GtNxpm.js";
3
+ import { _ as n, g as r, n as i, o as a, p as o, u as s } from "./ts-morph-helpers-CeduA--o.js";
4
+ import { modifyOutcomeToFile as c } from "./modify-file-Dwfv0dCI.js";
5
+ import { t as l } from "./svelte-file-B3RfgVdt.js";
6
+ import u from "node:fs";
7
+ import d from "node:path";
8
+ import { Project as f, SyntaxKind as p } from "ts-morph";
9
+ //#region src/patterns/disable/auth/modifies/+layout.server.ts
10
+ function m(e) {
11
+ if (!u.existsSync(e)) return {
12
+ status: "success",
13
+ changed: !1
14
+ };
15
+ let t = u.readFileSync(e, "utf8");
16
+ if (!t.includes("locals.pb.authStore.record")) return {
17
+ status: "success",
18
+ changed: !1
19
+ };
20
+ let n = new f().addSourceFileAtPath(e), i = n.getDescendantsOfKind(p.ObjectLiteralExpression);
21
+ for (let e of i) {
22
+ let t = e.getProperty("user");
23
+ t && t.getKind() === p.PropertyAssignment && t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
24
+ }
25
+ return r(n, "locals"), a(n), n.saveSync(), {
26
+ status: "success",
27
+ changed: n.getFullText() !== t
28
+ };
29
+ }
30
+ //#endregion
31
+ //#region src/patterns/disable/auth/modifies/root-layout.svelte.ts
32
+ function h(e) {
33
+ if (!u.existsSync(e)) return {
34
+ status: "success",
35
+ changed: !1
36
+ };
37
+ let t = u.readFileSync(e, "utf8"), r = new l(t);
38
+ if (!r.hasElement("AuthMenu.Root")) return {
39
+ status: "success",
40
+ changed: !1
41
+ };
42
+ r.removeElement("AuthMenu.Root");
43
+ let a = r.toString().replace(/<script[\s\S]*?<\/script>/g, "");
44
+ return r.modifyScript((e) => {
45
+ let { source: t } = n(e, (e) => {
46
+ s(e, "$lib/components/ui/auth-menu"), s(e, "$lib/components/ui/avatar"), o(e, "data", a), i(e);
47
+ });
48
+ return t;
49
+ }), r.writeTo(e), {
50
+ status: "success",
51
+ changed: r.hasChanged()
52
+ };
53
+ }
54
+ //#endregion
55
+ //#region src/patterns/disable/auth/modifies/hooks.server.ts
56
+ function g(e) {
57
+ if (!u.existsSync(e)) return {
58
+ status: "success",
59
+ changed: !1
60
+ };
61
+ let t = u.readFileSync(e, "utf8"), n = new f().addSourceFileAtPath(e), r = n.getDescendantsOfKind(p.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
62
+ if (!r) return {
63
+ status: "success",
64
+ changed: !1
65
+ };
66
+ let [i] = r.getArguments();
67
+ if (!i || i.getKind() !== p.ObjectLiteralExpression) return {
68
+ status: "success",
69
+ changed: !1
70
+ };
71
+ let o = i.asKindOrThrow(p.ObjectLiteralExpression), s = o.getProperty("auth");
72
+ return s ? (s.remove(), o.getProperties().length === 0 && r.removeArgument(0), a(n), n.saveSync(), {
73
+ status: "success",
74
+ changed: n.getFullText() !== t
75
+ }) : {
76
+ status: "success",
77
+ changed: !1
78
+ };
79
+ }
80
+ //#endregion
81
+ //#region src/patterns/disable/auth/generate.runtime.ts
82
+ async function _(n) {
83
+ let r = e(n), i = [], a = (e) => {
84
+ e && i.push(e);
85
+ };
86
+ r.info("Reverting +layout.server.ts");
87
+ let o = d.join(n.root, "src", "routes", "+layout.server.ts");
88
+ a(c(o, m(o))), r.info("Reverting root layout");
89
+ let s = [
90
+ d.join(n.root, "src", "routes", "(public)", "root-layout.svelte"),
91
+ d.join(n.root, "src", "routes", "root-layout.svelte"),
92
+ d.join(n.root, "src", "routes", "(public)", "+layout.svelte"),
93
+ d.join(n.root, "src", "routes", "+layout.svelte")
94
+ ], l = s.find((e) => u.existsSync(e)) ?? s[0];
95
+ a(c(l, h(l))), r.info("Reverting hooks.server.ts");
96
+ let f = d.join(n.root, "src", "hooks.server.ts");
97
+ return a(c(f, g(f))), {
98
+ creates: [],
99
+ modifies: i,
100
+ deletes: [],
101
+ components: [],
102
+ packages: [],
103
+ collections: [],
104
+ collectionPatches: [],
105
+ collectionDrops: await t(["oauth_accounts"], n)
106
+ };
107
+ }
108
+ //#endregion
109
+ export { _ as generate };
110
+
111
+ //# sourceMappingURL=generate.runtime-CMnvmeVt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-CMnvmeVt.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 {\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\";\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 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":"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"}
@@ -2,30 +2,31 @@ import { a as e } from "./util-BLYliuUK.js";
2
2
  import { t } from "./dedent-Gq6Krl4n.js";
3
3
  import { n } from "./logger-CQONztPm.js";
4
4
  import { t as r } from "./pocketbase-C5GS-Dh5.js";
5
- import { h as i, modifyOutcomeToFile as a, r as o, t as s } from "./modify-file-GQD6uNgI.js";
6
- import { t as c } from "./svelte-file-B3RfgVdt.js";
7
- import { i as l, n as u, t as d } from "./pocketbase-CeG5BMN2.js";
8
- import { t as f } from "./site-D027dpBm.js";
9
- import { applyCollectionRulePatches as p, createCollectionIdempotent as m } from "./collections-CgdvZXmh.js";
10
- import h from "node:fs";
11
- import g from "node:path";
12
- import { Project as _, SyntaxKind as v } from "ts-morph";
5
+ import { _ as i, o as a, r as o, t as s } from "./ts-morph-helpers-CeduA--o.js";
6
+ import { modifyOutcomeToFile as c } from "./modify-file-Dwfv0dCI.js";
7
+ import { t as l } from "./svelte-file-B3RfgVdt.js";
8
+ import { i as u, n as d, t as f } from "./pocketbase-BkhUywtb.js";
9
+ import { t as p } from "./site-BdMX8qrH.js";
10
+ import { applyCollectionRulePatches as m, createCollectionIdempotent as h } from "./collections-CrOvS2E7.js";
11
+ import g from "node:fs";
12
+ import _ from "node:path";
13
+ import { Project as v, SyntaxKind as y } from "ts-morph";
13
14
  //#region src/patterns/enable/teams/modifies/modify-app-layout.ts
14
- var y = [
15
+ var b = [
15
16
  "Pass team props to <AppSidebar> in your app layout:",
16
17
  "",
17
18
  "<AppSidebar team={data.team} teams={data.teams ?? []} />"
18
- ].join("\n"), b = [
19
+ ].join("\n"), x = [
19
20
  "Create an app layout that renders <AppSidebar> with team props:",
20
21
  "",
21
22
  "<AppSidebar team={data.team} teams={data.teams ?? []} />"
22
23
  ].join("\n");
23
- function x(e) {
24
- if (!h.existsSync(e)) return {
24
+ function S(e) {
25
+ if (!g.existsSync(e)) return {
25
26
  status: "not-found",
26
- message: b
27
+ message: x
27
28
  };
28
- let t = c.fromPath(e);
29
+ let t = l.fromPath(e);
29
30
  return t.hasElement("AppSidebar") ? t.hasAttribute("AppSidebar", "teams") ? {
30
31
  status: "success",
31
32
  changed: !1
@@ -34,39 +35,39 @@ function x(e) {
34
35
  changed: t.hasChanged()
35
36
  }) : {
36
37
  status: "failed",
37
- message: y
38
+ message: b
38
39
  };
39
40
  }
40
41
  //#endregion
41
42
  //#region src/patterns/enable/teams/modifies/modify-app-sidebar.ts
42
- var S = "<Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>", C = [
43
+ var C = "<Sidebar.Header>\n <Sidebar.Menu>\n <TeamSwitcher {teams}>\n {#snippet children()}\n {@const activeTeam = teams.find((t) => t.id === team)}\n {#if activeTeam}\n <Avatar.Root class=\"size-8 rounded-lg\">\n <Avatar.Fallback class=\"rounded-lg bg-primary text-primary-foreground font-medium\">\n {activeTeam.name?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">\n {activeTeam.name}\n </span>\n </div>\n {:else}\n <div\n class=\"bg-sidebar-accent text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg\"\n >\n <img src={favicon} alt=\"logo\" class=\"size-6\" />\n </div>\n <div class=\"grid flex-1 text-left text-sm leading-tight\">\n <span class=\"truncate font-medium\">{site.name}</span>\n </div>\n {/if}\n <ChevronsUpDownIcon class=\"ml-auto\" />\n {/snippet}\n </TeamSwitcher>\n </Sidebar.Menu>\n </Sidebar.Header>", w = [
43
44
  "import favicon from '$lib/assets/favicon.svg';",
44
45
  "import TeamSwitcher from '$lib/components/team-switcher.svelte';",
45
46
  "import ChevronsUpDownIcon from '@lucide/svelte/icons/chevrons-up-down';",
46
47
  "import * as Avatar from '$lib/components/ui/avatar';",
47
48
  "import { site } from '$lib/site';"
48
- ].join("\n"), w = "{meta.appName}", T = [
49
+ ].join("\n"), T = "{meta.appName}", E = [
49
50
  "Replace the <Sidebar.Header> in your app sidebar with the team switcher.",
50
51
  "",
51
52
  "Imports to add to the <script> tag:",
52
53
  "",
53
- C,
54
+ w,
54
55
  "",
55
56
  "Props to destructure in $props(): team, teams = []",
56
57
  "",
57
58
  "Markup to use as the header:",
58
- S
59
- ].join("\n"), E = [
59
+ C
60
+ ].join("\n"), D = [
60
61
  "Create an app sidebar with a <Sidebar.Header> containing the team switcher.",
61
62
  "",
62
63
  "Imports:",
63
64
  "",
64
- C,
65
+ w,
65
66
  "",
66
67
  "Header markup:",
67
- S
68
+ C
68
69
  ].join("\n");
69
- function D(e, t) {
70
+ function O(e, t) {
70
71
  let { source: n } = i(e, (e) => {
71
72
  t || o(e, [{
72
73
  namedImports: ["site"],
@@ -93,15 +94,15 @@ function D(e, t) {
93
94
  let e = t.getInitializer();
94
95
  if (!e || e.getText() !== "$props()") continue;
95
96
  let n = t.getNameNode();
96
- if (n.getKind() !== v.ObjectBindingPattern) continue;
97
- let r = n.asKindOrThrow(v.ObjectBindingPattern), i = r.getElements();
97
+ if (n.getKind() !== y.ObjectBindingPattern) continue;
98
+ let r = n.asKindOrThrow(y.ObjectBindingPattern), i = r.getElements();
98
99
  if (i.some((e) => e.getName() === "team")) continue;
99
100
  let a = t.getTypeNode();
100
- if (a?.getKind() === v.IntersectionType) {
101
- let e = a.asKindOrThrow(v.IntersectionType);
101
+ if (a?.getKind() === y.IntersectionType) {
102
+ let e = a.asKindOrThrow(y.IntersectionType);
102
103
  for (let t of e.getTypeNodes()) {
103
- if (t.getKind() !== v.TypeLiteral) continue;
104
- let e = t.asKindOrThrow(v.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
104
+ if (t.getKind() !== y.TypeLiteral) continue;
105
+ let e = t.asKindOrThrow(y.TypeLiteral), n = e.getProperties().map((e) => e.getText().replace(/[;,]\s*$/, ""));
105
106
  if (n.some((e) => /^team\b/.test(e))) break;
106
107
  n.push("team?: string | undefined", "teams?: { id: string; name: string }[]"), e.replaceWithText(`{ ${n.join("; ")}; }`);
107
108
  break;
@@ -110,34 +111,34 @@ function D(e, t) {
110
111
  let o = i.map((e) => e.getText()), s = i.findIndex((e) => e.getDotDotDotToken() || e.getInitializer());
111
112
  s === -1 && (s = i.length), o.splice(s, 0, "team", "teams = []"), r.replaceWithText(`{ ${o.join(", ")} }`);
112
113
  }
113
- e.formatText();
114
+ a(e);
114
115
  });
115
116
  return n;
116
117
  }
117
- function O(e) {
118
- if (!h.existsSync(e)) return {
118
+ function k(e) {
119
+ if (!g.existsSync(e)) return {
119
120
  status: "not-found",
120
- message: E
121
+ message: D
121
122
  };
122
- let t = c.fromPath(e);
123
+ let t = l.fromPath(e);
123
124
  if (t.hasElement("TeamSwitcher")) return {
124
125
  status: "success",
125
126
  changed: !1
126
127
  };
127
128
  if (!t.hasElement("Sidebar.Header")) return {
128
129
  status: "failed",
129
- message: T
130
+ message: E
130
131
  };
131
- let n = t.toString().includes(w);
132
- return t.modifyScript((e) => D(e, n)), t.replaceElement("Sidebar.Header", n ? S.replace("{site.name}", w) : S), t.writeTo(e), {
132
+ let n = t.toString().includes(T);
133
+ return t.modifyScript((e) => O(e, n)), t.replaceElement("Sidebar.Header", n ? C.replace("{site.name}", T) : C), t.writeTo(e), {
133
134
  status: "success",
134
135
  changed: t.hasChanged()
135
136
  };
136
137
  }
137
138
  //#endregion
138
139
  //#region src/patterns/enable/teams/modifies/+layout.server.ts
139
- function k(e) {
140
- if (!h.existsSync(e)) {
140
+ function A(e) {
141
+ if (!g.existsSync(e)) {
141
142
  let n = t`
142
143
  export const load = async ({ locals, depends }) => {
143
144
  const user = locals.pb.authStore.record!;
@@ -149,37 +150,37 @@ function k(e) {
149
150
  return { user, team, teams, breadcrumbs };
150
151
  };
151
152
  `;
152
- return h.writeFileSync(e, n), {
153
+ return g.writeFileSync(e, n), {
153
154
  status: "success",
154
155
  changed: !0
155
156
  };
156
157
  }
157
- let n = h.readFileSync(e, "utf8"), r = new _().addSourceFileAtPath(e), i = (e, t, n) => {
158
+ let n = g.readFileSync(e, "utf8"), r = new v().addSourceFileAtPath(e), i = (e, t, n) => {
158
159
  e.getProperty(t) || (t === n ? e.addShorthandPropertyAssignment({ name: t }) : e.addPropertyAssignment({
159
160
  name: t,
160
161
  initializer: n
161
162
  }));
162
- }, a, o, s = r.getVariableDeclaration("load");
163
- if (s && s.getFirstAncestorByKind(v.VariableStatement)?.hasExportKeyword()) {
164
- let e = s.getInitializerIfKind(v.ArrowFunction);
165
- if (e) a = e;
163
+ }, o, s, c = r.getVariableDeclaration("load");
164
+ if (c && c.getFirstAncestorByKind(y.VariableStatement)?.hasExportKeyword()) {
165
+ let e = c.getInitializerIfKind(y.ArrowFunction);
166
+ if (e) o = e;
166
167
  else {
167
- let e = s.getInitializer();
168
+ let e = c.getInitializer();
168
169
  if (e) {
169
- let t = e.getFirstDescendantByKind(v.ArrowFunction);
170
- if (t) a = t;
170
+ let t = e.getFirstDescendantByKind(y.ArrowFunction);
171
+ if (t) o = t;
171
172
  else {
172
- let t = e.getFirstDescendantByKind(v.FunctionExpression);
173
- t && (o = t);
173
+ let t = e.getFirstDescendantByKind(y.FunctionExpression);
174
+ t && (s = t);
174
175
  }
175
176
  }
176
177
  }
177
178
  }
178
- if (!a) {
179
+ if (!o) {
179
180
  let e = r.getFunction("load");
180
- e && e.isExported() && (o = e);
181
+ e && e.isExported() && (s = e);
181
182
  }
182
- if (!a && !o) return r.addFunction({
183
+ if (!o && !s) return r.addFunction({
183
184
  isExported: !0,
184
185
  isAsync: !0,
185
186
  name: "load",
@@ -193,15 +194,15 @@ function k(e) {
193
194
  "const breadcrumbs = [{ title: \"Home\", url: \"/dashboard\" }];",
194
195
  "return { user, team, teams, breadcrumbs };"
195
196
  ]
196
- }), r.formatText(), r.saveSync(), {
197
+ }), a(r), r.saveSync(), {
197
198
  status: "success",
198
199
  changed: !0
199
200
  };
200
- let c = a ?? o, l = c.getParameters();
201
- if (l.length === 0) c.insertParameter(0, { name: "{ locals, depends }" });
201
+ let l = o ?? s, u = l.getParameters();
202
+ if (u.length === 0) l.insertParameter(0, { name: "{ locals, depends }" });
202
203
  else {
203
- let e = l[0], t = e.getStructure(), n = e.getNameNode();
204
- if (n.getKind() === v.ObjectBindingPattern) {
204
+ let e = u[0], t = e.getStructure(), n = e.getNameNode();
205
+ if (n.getKind() === y.ObjectBindingPattern) {
205
206
  let r = n, i = r.getElements().some((e) => e.getName() === "depends"), a = r.getElements().some((e) => e.getName() === "locals");
206
207
  if (!i) {
207
208
  let n = r.getElements().map((e) => e.getText()).filter(Boolean), i = n.length > 0 ? ", " + n.join(", ") : "";
@@ -228,27 +229,27 @@ function k(e) {
228
229
  });
229
230
  }
230
231
  }
231
- a && !a.isAsync() ? a.setIsAsync(!0) : o && !o.isAsync() && o.setIsAsync(!0);
232
- let u = c.getBody();
233
- if (u && u.getKind() === v.Block) {
234
- let e = u, t = e.getStatements(), n = t.some((e) => e.getKind() === v.VariableStatement && e.getDescendantsOfKind(v.Identifier).some((e) => e.getText() === "team")), r = t.some((e) => e.getKind() === v.VariableStatement && e.getDescendantsOfKind(v.Identifier).some((e) => e.getText() === "teams")), i = t.some((e) => e.getKind() === v.ExpressionStatement && e.getDescendantsOfKind(v.CallExpression).some((e) => {
232
+ o && !o.isAsync() ? o.setIsAsync(!0) : s && !s.isAsync() && s.setIsAsync(!0);
233
+ let d = l.getBody();
234
+ if (d && d.getKind() === y.Block) {
235
+ let e = d, t = e.getStatements(), n = t.some((e) => e.getKind() === y.VariableStatement && e.getDescendantsOfKind(y.Identifier).some((e) => e.getText() === "team")), r = t.some((e) => e.getKind() === y.VariableStatement && e.getDescendantsOfKind(y.Identifier).some((e) => e.getText() === "teams")), i = t.some((e) => e.getKind() === y.ExpressionStatement && e.getDescendantsOfKind(y.CallExpression).some((e) => {
235
236
  if (e.getExpression().getText() !== "depends") return !1;
236
237
  let t = e.getArguments(), n = t[0]?.getText() ?? "";
237
238
  return t.length === 1 && (n === "'app:team'" || n === "\"app:team\"");
238
239
  }));
239
240
  n || e.insertStatements(1, "const team = locals.team;"), r || e.insertStatements(2, "const teams = await locals.pb.collection(\"teams\").getFullList();"), i || e.insertStatements(3, "depends(\"app:team\");");
240
241
  }
241
- if (a) {
242
- let e = a.getBody();
243
- if (e.getKind() === v.Block) e.getDescendantsOfKind(v.ReturnStatement).forEach((e) => {
242
+ if (o) {
243
+ let e = o.getBody();
244
+ if (e.getKind() === y.Block) e.getDescendantsOfKind(y.ReturnStatement).forEach((e) => {
244
245
  let t = e.getExpression();
245
246
  if (t) {
246
- if (t.getKind() === v.ObjectLiteralExpression) {
247
+ if (t.getKind() === y.ObjectLiteralExpression) {
247
248
  let e = t;
248
249
  i(e, "team", "team"), i(e, "teams", "teams");
249
- } else if (t.getKind() === v.ParenthesizedExpression) {
250
+ } else if (t.getKind() === y.ParenthesizedExpression) {
250
251
  let e = t.getExpression();
251
- if (e.getKind() === v.ObjectLiteralExpression) {
252
+ if (e.getKind() === y.ObjectLiteralExpression) {
252
253
  let t = e;
253
254
  i(t, "team", "team"), i(t, "teams", "teams");
254
255
  }
@@ -257,28 +258,28 @@ function k(e) {
257
258
  });
258
259
  else {
259
260
  let t = e;
260
- if (t.getKind() === v.ParenthesizedExpression) {
261
+ if (t.getKind() === y.ParenthesizedExpression) {
261
262
  let e = t.getExpression();
262
- if (e.getKind() === v.ObjectLiteralExpression) {
263
+ if (e.getKind() === y.ObjectLiteralExpression) {
263
264
  let t = e;
264
265
  i(t, "team", "team"), i(t, "teams", "teams");
265
266
  }
266
- } else if (t.getKind() === v.ObjectLiteralExpression) {
267
+ } else if (t.getKind() === y.ObjectLiteralExpression) {
267
268
  let e = t;
268
269
  i(e, "team", "team"), i(e, "teams", "teams");
269
270
  }
270
271
  }
271
- } else if (o) {
272
- let e = o.getBody();
273
- e && e.getDescendantsOfKind(v.ReturnStatement).forEach((e) => {
272
+ } else if (s) {
273
+ let e = s.getBody();
274
+ e && e.getDescendantsOfKind(y.ReturnStatement).forEach((e) => {
274
275
  let t = e.getExpression();
275
276
  if (t) {
276
- if (t.getKind() === v.ObjectLiteralExpression) {
277
+ if (t.getKind() === y.ObjectLiteralExpression) {
277
278
  let e = t;
278
279
  i(e, "team", "team"), i(e, "teams", "teams");
279
- } else if (t.getKind() === v.ParenthesizedExpression) {
280
+ } else if (t.getKind() === y.ParenthesizedExpression) {
280
281
  let e = t.getExpression();
281
- if (e.getKind() === v.ObjectLiteralExpression) {
282
+ if (e.getKind() === y.ObjectLiteralExpression) {
282
283
  let t = e;
283
284
  i(t, "team", "team"), i(t, "teams", "teams");
284
285
  }
@@ -286,75 +287,75 @@ function k(e) {
286
287
  }
287
288
  });
288
289
  }
289
- return r.formatText(), r.saveSync(), {
290
+ return a(r), r.saveSync(), {
290
291
  status: "success",
291
292
  changed: r.getFullText() !== n
292
293
  };
293
294
  }
294
295
  //#endregion
295
296
  //#region src/patterns/enable/teams/modifies/modify-nav-user.ts
296
- var A = [
297
+ var j = [
297
298
  "import UsersIcon from '@lucide/svelte/icons/users';",
298
299
  "",
299
300
  "// Add to your navUser array:",
300
301
  "{ title: 'Teams', url: '/teams', icon: UsersIcon }"
301
- ].join("\n"), j = [
302
+ ].join("\n"), M = [
302
303
  "Add a Teams nav item to nav-user.svelte:",
303
304
  "",
304
- A
305
- ].join("\n"), M = [
305
+ j
306
+ ].join("\n"), N = [
306
307
  "Create nav-user.svelte with a Teams entry:",
307
308
  "",
308
- A
309
+ j
309
310
  ].join("\n");
310
- function N(e, t, n, r, i) {
311
- let a = new c(e), o = !1, l = (e) => {
311
+ function P(e, t, n, r, i) {
312
+ let a = new l(e), o = !1, c = (e) => {
312
313
  o || e((e) => {
313
314
  let a = s(e, t, n, r, i);
314
315
  return a.wasAdded && (o = !0), a.source;
315
316
  });
316
317
  };
317
- return l((e) => a.modifyModuleScript(e)), o || l((e) => a.modifyScript(e)), {
318
+ return c((e) => a.modifyModuleScript(e)), o || c((e) => a.modifyScript(e)), {
318
319
  newNavUserSnippet: a.toString(),
319
320
  wasAdded: o
320
321
  };
321
322
  }
322
- function P(e) {
323
- if (!h.existsSync(e)) return {
323
+ function F(e) {
324
+ if (!g.existsSync(e)) return {
324
325
  status: "not-found",
325
- message: M
326
+ message: N
326
327
  };
327
- let t = h.readFileSync(e, "utf8");
328
+ let t = g.readFileSync(e, "utf8");
328
329
  if (t.includes("/teams")) return {
329
330
  status: "success",
330
331
  changed: !1
331
332
  };
332
- let { newNavUserSnippet: n, wasAdded: r } = N(t, "Teams", "/teams", "UsersIcon", "@lucide/svelte/icons/users");
333
- return r ? (h.writeFileSync(e, n, "utf8"), {
333
+ let { newNavUserSnippet: n, wasAdded: r } = P(t, "Teams", "/teams", "UsersIcon", "@lucide/svelte/icons/users");
334
+ return r ? (g.writeFileSync(e, n, "utf8"), {
334
335
  status: "success",
335
336
  changed: !0
336
337
  }) : {
337
338
  status: "failed",
338
- message: j
339
+ message: M
339
340
  };
340
341
  }
341
342
  //#endregion
342
343
  //#region src/patterns/enable/teams/generate.runtime.ts
343
- async function F(t, n, r, i = !0) {
344
+ async function I(t, n, r, i = !0) {
344
345
  if (!i) return;
345
- await u();
346
- let a = d(n, "created", r);
346
+ await d();
347
+ let a = f(n, "created", r);
347
348
  a && t.push({
348
349
  path: a,
349
350
  language: e(a),
350
- content: h.readFileSync(a, "utf8"),
351
+ content: g.readFileSync(a, "utf8"),
351
352
  status: "success"
352
353
  });
353
354
  }
354
- async function I(e) {
355
+ async function L(e) {
355
356
  let t = n(e), i = [];
356
- await l(e.root, async (n) => {
357
- let a = await n.collections.getOne("users"), o = (e) => m(n, e, t);
357
+ await u(e.root, async (n) => {
358
+ let a = await n.collections.getOne("users"), o = (e) => h(n, e, t);
358
359
  t.info("Creating teams collection");
359
360
  let s = await o({
360
361
  name: "teams",
@@ -398,7 +399,7 @@ async function I(e) {
398
399
  }
399
400
  ]
400
401
  }), c = s.collection;
401
- await F(i, "teams", e, s.created), t.info("Creating team_memberships collection");
402
+ await I(i, "teams", e, s.created), t.info("Creating team_memberships collection");
402
403
  let l = await o({
403
404
  name: "team_memberships",
404
405
  type: "base",
@@ -456,7 +457,7 @@ async function I(e) {
456
457
  }
457
458
  ]
458
459
  }), u = l.collection;
459
- await F(i, "team_memberships", e, l.created), t.info("Creating team_users view");
460
+ await I(i, "team_memberships", e, l.created), t.info("Creating team_users view");
460
461
  let d = await o({
461
462
  name: "team_users",
462
463
  type: "view",
@@ -513,7 +514,7 @@ async function I(e) {
513
514
  ],
514
515
  viewQuery: "select users.id, users.email, users.name, team_memberships.id as membership_id, team_memberships.team, team_memberships.role from users join team_memberships on team_memberships.user = users.id;"
515
516
  });
516
- await F(i, "team_users", e, d.created), t.info("Creating team_invites collection");
517
+ await I(i, "team_users", e, d.created), t.info("Creating team_invites collection");
517
518
  let f = await o({
518
519
  name: "team_invites",
519
520
  type: "base",
@@ -556,8 +557,8 @@ async function I(e) {
556
557
  }
557
558
  ]
558
559
  });
559
- await F(i, "team_invites", e, f.created), t.info("Creating team_invite_links collection");
560
- let h = await o({
560
+ await I(i, "team_invites", e, f.created), t.info("Creating team_invite_links collection");
561
+ let p = await o({
561
562
  name: "team_invite_links",
562
563
  type: "base",
563
564
  fields: [
@@ -595,26 +596,26 @@ async function I(e) {
595
596
  ],
596
597
  indexes: ["CREATE UNIQUE INDEX `idx_9y3Oz1KVzz` ON `team_invite_links` (`team`)"]
597
598
  });
598
- await F(i, "team_invite_links", e, h.created), t.info("Applying team rule patches");
599
- let g = await p(n, r, e, t);
599
+ await I(i, "team_invite_links", e, p.created), t.info("Applying team rule patches");
600
+ let g = await m(n, r, e, t);
600
601
  i.push(...g);
601
602
  });
602
- let o = [], s = (e) => {
603
- e && o.push(e);
603
+ let a = [], o = (e) => {
604
+ e && a.push(e);
604
605
  };
605
606
  t.info("Modifying (app) +layout.server.ts");
606
- let c = g.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
607
- s(a(c, k(c))), t.info("Modifying (app) +layout.svelte");
608
- let u = g.join(e.root, "src", "routes", "(app)", "+layout.svelte");
609
- s(a(u, x(u))), t.info("Modifying app-sidebar");
610
- let d = g.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
611
- s(a(d, O(d))), t.info("Modifying nav-user");
612
- let h = g.join(e.root, "src", "lib", "components", "nav-user.svelte");
613
- s(a(h, P(h)));
614
- let _ = await f(e);
615
- return _ && i.push(_), {
607
+ let s = _.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
608
+ o(c(s, A(s))), t.info("Modifying (app) +layout.svelte");
609
+ let l = _.join(e.root, "src", "routes", "(app)", "+layout.svelte");
610
+ o(c(l, S(l))), t.info("Modifying app-sidebar");
611
+ let d = _.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
612
+ o(c(d, k(d))), t.info("Modifying nav-user");
613
+ let f = _.join(e.root, "src", "lib", "components", "nav-user.svelte");
614
+ o(c(f, F(f)));
615
+ let g = await p(e);
616
+ return g && i.push(g), {
616
617
  creates: i,
617
- modifies: o,
618
+ modifies: a,
618
619
  deletes: [],
619
620
  components: [],
620
621
  packages: [],
@@ -624,6 +625,6 @@ async function I(e) {
624
625
  };
625
626
  }
626
627
  //#endregion
627
- export { I as generate };
628
+ export { L as generate };
628
629
 
629
- //# sourceMappingURL=generate.runtime-BORbegw_.js.map
630
+ //# sourceMappingURL=generate.runtime-CN5c2xH8.js.map