@velastack/patterns 0.0.36 → 0.0.38

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 (74) hide show
  1. package/dist/chunks/_server-BCbQIYCn.js +6 -0
  2. package/dist/chunks/_server-BCbQIYCn.js.map +1 -0
  3. package/dist/chunks/{collections-DcCZ0dam.js → collections-RlxhqXdR.js} +2 -2
  4. package/dist/chunks/{collections-DcCZ0dam.js.map → collections-RlxhqXdR.js.map} +1 -1
  5. package/dist/chunks/{env-DfA_NCKk.js → env-CDsRI_A5.js} +1 -1
  6. package/dist/chunks/{env-DfA_NCKk.js.map → env-CDsRI_A5.js.map} +1 -1
  7. package/dist/chunks/{env.preview-7Cc9KCgc.js → env.preview-Ds0NigL8.js} +1 -1
  8. package/dist/chunks/{env.preview-7Cc9KCgc.js.map → env.preview-Ds0NigL8.js.map} +1 -1
  9. package/dist/chunks/{env.runtime-l1ssTZog.js → env.runtime-BGmr1gQZ.js} +1 -1
  10. package/dist/chunks/{env.runtime-l1ssTZog.js.map → env.runtime-BGmr1gQZ.js.map} +1 -1
  11. package/dist/chunks/{generate.runtime-mPNuFTCh.js → generate.runtime-7N_86Kl1.js} +6 -6
  12. package/dist/chunks/{generate.runtime-mPNuFTCh.js.map → generate.runtime-7N_86Kl1.js.map} +1 -1
  13. package/dist/chunks/{generate.runtime-NdlYevoh.js → generate.runtime-B_NxLFKW.js} +2 -2
  14. package/dist/chunks/{generate.runtime-NdlYevoh.js.map → generate.runtime-B_NxLFKW.js.map} +1 -1
  15. package/dist/chunks/generate.runtime-B_Z_225G.js +107 -0
  16. package/dist/chunks/generate.runtime-B_Z_225G.js.map +1 -0
  17. package/dist/chunks/generate.runtime-BllWzqI_.js +211 -0
  18. package/dist/chunks/generate.runtime-BllWzqI_.js.map +1 -0
  19. package/dist/chunks/{generate.runtime-GmszNklA.js → generate.runtime-C8Wbgx77.js} +2 -2
  20. package/dist/chunks/{generate.runtime-GmszNklA.js.map → generate.runtime-C8Wbgx77.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-Bu5bO86n.js → generate.runtime-CFH03New.js} +4 -4
  22. package/dist/chunks/{generate.runtime-Bu5bO86n.js.map → generate.runtime-CFH03New.js.map} +1 -1
  23. package/dist/chunks/{generate.runtime-D8DxU99S.js → generate.runtime-CZwuYNbQ.js} +4 -4
  24. package/dist/chunks/{generate.runtime-D8DxU99S.js.map → generate.runtime-CZwuYNbQ.js.map} +1 -1
  25. package/dist/chunks/generate.runtime-CdawV-C4.js +309 -0
  26. package/dist/chunks/generate.runtime-CdawV-C4.js.map +1 -0
  27. package/dist/chunks/{generate.runtime-eYyscad0.js → generate.runtime-CojXsWmJ.js} +5 -5
  28. package/dist/chunks/{generate.runtime-eYyscad0.js.map → generate.runtime-CojXsWmJ.js.map} +1 -1
  29. package/dist/chunks/generate.runtime-CsFOIAEO.js +224 -0
  30. package/dist/chunks/generate.runtime-CsFOIAEO.js.map +1 -0
  31. package/dist/chunks/{generate.runtime-CS55berV.js → generate.runtime-DgYEht-Z.js} +3 -3
  32. package/dist/chunks/{generate.runtime-CS55berV.js.map → generate.runtime-DgYEht-Z.js.map} +1 -1
  33. package/dist/chunks/{generate.runtime-CKouBODu.js → generate.runtime-DgoCWziW.js} +4 -4
  34. package/dist/chunks/{generate.runtime-CKouBODu.js.map → generate.runtime-DgoCWziW.js.map} +1 -1
  35. package/dist/chunks/{generate.runtime-DV9S4KW_.js → generate.runtime-DhbtqZYL.js} +87 -31
  36. package/dist/chunks/generate.runtime-DhbtqZYL.js.map +1 -0
  37. package/dist/chunks/generate.runtime-DlJPYj_8.js +135 -0
  38. package/dist/chunks/generate.runtime-DlJPYj_8.js.map +1 -0
  39. package/dist/chunks/{generate.runtime-DPbHzukR.js → generate.runtime-DmU6R2Ez.js} +6 -6
  40. package/dist/chunks/{generate.runtime-DPbHzukR.js.map → generate.runtime-DmU6R2Ez.js.map} +1 -1
  41. package/dist/chunks/{generate.runtime-BB0XISiq.js → generate.runtime-MNNdJitS.js} +2 -2
  42. package/dist/chunks/{generate.runtime-BB0XISiq.js.map → generate.runtime-MNNdJitS.js.map} +1 -1
  43. package/dist/chunks/{generate.runtime-D3H_yNZA.js → generate.runtime-mjs_qfUh.js} +3 -3
  44. package/dist/chunks/{generate.runtime-D3H_yNZA.js.map → generate.runtime-mjs_qfUh.js.map} +1 -1
  45. package/dist/chunks/{modify-file-Bi-4GRwL.js → modify-file-DGBe3ycw.js} +1 -1
  46. package/dist/chunks/{modify-file-Bi-4GRwL.js.map → modify-file-DGBe3ycw.js.map} +1 -1
  47. package/dist/chunks/{modify-svelte-config-remote-B-jnjYqs.js → modify-svelte-config-remote-C-Wl2nk1.js} +1 -1
  48. package/dist/chunks/{modify-svelte-config-remote-B-jnjYqs.js.map → modify-svelte-config-remote-C-Wl2nk1.js.map} +1 -1
  49. package/dist/chunks/nav-user-Jp5yYtw5.js +6 -0
  50. package/dist/chunks/nav-user-Jp5yYtw5.js.map +1 -0
  51. package/dist/chunks/{pocketbase-CT78tKFG.js → pocketbase-CEhGbssT.js} +1 -1
  52. package/dist/chunks/{pocketbase-CT78tKFG.js.map → pocketbase-CEhGbssT.js.map} +1 -1
  53. package/dist/chunks/{pocketbase-BiRWz-OQ.js → pocketbase-D5p0NSdu.js} +1 -1
  54. package/dist/chunks/{pocketbase-BiRWz-OQ.js.map → pocketbase-D5p0NSdu.js.map} +1 -1
  55. package/dist/chunks/{shared-D9iYuKxV.js → shared-CG8Qf95D.js} +2 -2
  56. package/dist/chunks/{shared-D9iYuKxV.js.map → shared-CG8Qf95D.js.map} +1 -1
  57. package/dist/chunks/{ts-morph-helpers-B0oxeDUU.js → ts-morph-helpers-DjpZhZ7I.js} +10 -1
  58. package/dist/chunks/ts-morph-helpers-DjpZhZ7I.js.map +1 -0
  59. package/dist/chunks/{write-result-CRq0kUvL.js → write-result-CjSxx3ZD.js} +2 -2
  60. package/dist/chunks/{write-result-CRq0kUvL.js.map → write-result-CjSxx3ZD.js.map} +1 -1
  61. package/dist/index.d.ts +142 -30
  62. package/dist/index.js +1631 -1249
  63. package/dist/index.js.map +1 -1
  64. package/package.json +1 -1
  65. package/dist/chunks/generate.runtime-Bag8x62P.js +0 -37
  66. package/dist/chunks/generate.runtime-Bag8x62P.js.map +0 -1
  67. package/dist/chunks/generate.runtime-CVsBIZm4.js +0 -37
  68. package/dist/chunks/generate.runtime-CVsBIZm4.js.map +0 -1
  69. package/dist/chunks/generate.runtime-Cy56Ypws.js +0 -215
  70. package/dist/chunks/generate.runtime-Cy56Ypws.js.map +0 -1
  71. package/dist/chunks/generate.runtime-DV9S4KW_.js.map +0 -1
  72. package/dist/chunks/hooks.server-CPVyj3rv.js +0 -75
  73. package/dist/chunks/hooks.server-CPVyj3rv.js.map +0 -1
  74. package/dist/chunks/ts-morph-helpers-B0oxeDUU.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velastack/patterns",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -1,37 +0,0 @@
1
- import { n as e } from "./logger-BpgCb-ZG.js";
2
- import { t } from "./shared-D9iYuKxV.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-Bi-4GRwL.js";
4
- import { n as r, r as i, t as a } from "./hooks.server-CPVyj3rv.js";
5
- import o from "node:fs";
6
- import s from "node:path";
7
- //#region src/patterns/disable/auth/generate.runtime.ts
8
- async function c(c) {
9
- let l = e(c), u = [], d = (e) => {
10
- e && u.push(e);
11
- };
12
- l.info("Reverting +layout.server.ts");
13
- let f = s.join(c.root, "src", "routes", "+layout.server.ts");
14
- d(n(f, i(f))), l.info("Reverting root layout");
15
- let p = [
16
- s.join(c.root, "src", "routes", "(public)", "root-layout.svelte"),
17
- s.join(c.root, "src", "routes", "root-layout.svelte"),
18
- s.join(c.root, "src", "routes", "(public)", "+layout.svelte"),
19
- s.join(c.root, "src", "routes", "+layout.svelte")
20
- ], m = p.find((e) => o.existsSync(e)) ?? p[0];
21
- d(n(m, r(m))), l.info("Reverting hooks.server.ts");
22
- let h = s.join(c.root, "src", "hooks.server.ts");
23
- return d(n(h, a(h))), {
24
- creates: [],
25
- modifies: u,
26
- deletes: [],
27
- components: [],
28
- packages: [],
29
- collections: [],
30
- collectionPatches: [],
31
- collectionDrops: await t(["oauth_accounts"], c)
32
- };
33
- }
34
- //#endregion
35
- export { c as generate };
36
-
37
- //# sourceMappingURL=generate.runtime-Bag8x62P.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-Bag8x62P.js","names":[],"sources":["../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["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":";;;;;;;AAUA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,8BAA8B;CAC1C,IAAM,IAAmB,EAAK,KAC5B,EAAQ,MACR,OACA,UACA,oBACD;AAQD,CAPA,EACE,EACE,GACA,EAAqB,EAAiB,CACvC,CACF,EAED,EAAO,KAAK,wBAAwB;CACpC,IAAM,IAAmB;EACvB,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,qBAAqB;EAC1E,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,qBAAqB;EAC9D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,iBAAiB;EACtE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,iBAAiB;EAC3D,EACK,IACJ,EAAiB,MAAM,MAAM,EAAG,WAAW,EAAE,CAAC,IAAI,EAAiB;AAKrE,CAJA,EACE,EAAoB,GAAY,EAAyB,EAAW,CAAC,CACtE,EAED,EAAO,KAAK,4BAA4B;CACxC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB;AAUzE,QATA,EACE,EAAoB,GAAiB,EAAoB,EAAgB,CAAC,CAC3E,EAOM;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B,CAAC,iBAAiB,EAClB,EACD;EAWA"}
@@ -1,37 +0,0 @@
1
- import { n as e } from "./logger-BpgCb-ZG.js";
2
- import { t } from "./shared-D9iYuKxV.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-Bi-4GRwL.js";
4
- import { n as r, r as i, t as a } from "./hooks.server-CPVyj3rv.js";
5
- import o from "node:fs";
6
- import s from "node:path";
7
- //#region src/patterns/disable/auth-remote/generate.runtime.ts
8
- async function c(c) {
9
- let l = e(c), u = [], d = (e) => {
10
- e && u.push(e);
11
- };
12
- l.info("Reverting +layout.server.ts");
13
- let f = s.join(c.root, "src", "routes", "+layout.server.ts");
14
- d(n(f, i(f))), l.info("Reverting root layout");
15
- let p = [
16
- s.join(c.root, "src", "routes", "(public)", "root-layout.svelte"),
17
- s.join(c.root, "src", "routes", "root-layout.svelte"),
18
- s.join(c.root, "src", "routes", "(public)", "+layout.svelte"),
19
- s.join(c.root, "src", "routes", "+layout.svelte")
20
- ], m = p.find((e) => o.existsSync(e)) ?? p[0];
21
- d(n(m, r(m))), l.info("Reverting hooks.server.ts");
22
- let h = s.join(c.root, "src", "hooks.server.ts");
23
- return d(n(h, a(h))), {
24
- creates: [],
25
- modifies: u,
26
- deletes: [],
27
- components: [],
28
- packages: [],
29
- collections: [],
30
- collectionPatches: [],
31
- collectionDrops: await t(["oauth_accounts"], c)
32
- };
33
- }
34
- //#endregion
35
- export { c as generate };
36
-
37
- //# sourceMappingURL=generate.runtime-CVsBIZm4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-CVsBIZm4.js","names":[],"sources":["../../src/patterns/disable/auth-remote/generate.runtime.ts"],"sourcesContent":["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 \"../auth/modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"../auth/modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"../auth/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":";;;;;;;AAUA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,8BAA8B;CAC1C,IAAM,IAAmB,EAAK,KAC5B,EAAQ,MACR,OACA,UACA,oBACD;AAQD,CAPA,EACE,EACE,GACA,EAAqB,EAAiB,CACvC,CACF,EAED,EAAO,KAAK,wBAAwB;CACpC,IAAM,IAAmB;EACvB,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,qBAAqB;EAC1E,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,qBAAqB;EAC9D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,iBAAiB;EACtE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,iBAAiB;EAC3D,EACK,IACJ,EAAiB,MAAM,MAAM,EAAG,WAAW,EAAE,CAAC,IAAI,EAAiB;AAKrE,CAJA,EACE,EAAoB,GAAY,EAAyB,EAAW,CAAC,CACtE,EAED,EAAO,KAAK,4BAA4B;CACxC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB;AAUzE,QATA,EACE,EAAoB,GAAiB,EAAoB,EAAgB,CAAC,CAC3E,EAOM;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B,CAAC,iBAAiB,EAClB,EACD;EAWA"}
@@ -1,215 +0,0 @@
1
- import { t as e } from "./dedent-C4qKBQXh.js";
2
- import { n as t } from "./logger-BpgCb-ZG.js";
3
- import { modifyOutcomeToFile as n } from "./modify-file-Bi-4GRwL.js";
4
- import { o as r, t as i } from "./ts-morph-helpers-B0oxeDUU.js";
5
- import { getMigrationFile as a, migrationDelay as o, withPocketbase as s } from "./pocketbase-CT78tKFG.js";
6
- import { createCollectionIdempotent as c } from "./collections-DcCZ0dam.js";
7
- import l from "node:fs";
8
- import u from "node:path";
9
- import { Project as d, SyntaxKind as f } from "ts-morph";
10
- //#region src/patterns/enable/api-keys/modifies/hooks.server.ts
11
- var p = e`
12
- Configure handlePocketbase() with API keys in hooks.server.ts:
13
-
14
- handlePocketbase({
15
- api: {
16
- enabled: true,
17
- apiKeys: { enabled: true },
18
- },
19
- });
20
- `, m = e`
21
- Create src/hooks.server.ts with handlePocketbase:
22
-
23
- import { handlePocketbase } from 'velastack/handle';
24
-
25
- export const handle = handlePocketbase({
26
- api: {
27
- enabled: true,
28
- apiKeys: { enabled: true },
29
- },
30
- });
31
- `;
32
- function h(e) {
33
- if (!l.existsSync(e)) return {
34
- status: "not-found",
35
- message: m
36
- };
37
- let t = l.readFileSync(e, "utf8"), n = new d().addSourceFileAtPath(e), r = n.getDescendantsOfKind(f.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
38
- if (!r) return {
39
- status: "failed",
40
- message: p
41
- };
42
- let i = r.getArguments();
43
- if (i.length === 0) return r.addArgument("{ api: { enabled: true, apiKeys: { enabled: true } } }"), n.formatText(), n.saveSync(), {
44
- status: "success",
45
- changed: !0
46
- };
47
- let a = i[0];
48
- if (a.getKind() !== f.ObjectLiteralExpression) return r.insertArgument(0, "{ api: { enabled: true, apiKeys: { enabled: true } } }"), n.formatText(), n.saveSync(), {
49
- status: "success",
50
- changed: !0
51
- };
52
- let o = a.asKindOrThrow(f.ObjectLiteralExpression), s = o.getProperty("api");
53
- if (!s) return o.addPropertyAssignment({
54
- name: "api",
55
- initializer: "{ enabled: true, apiKeys: { enabled: true } }"
56
- }), n.formatText(), n.saveSync(), {
57
- status: "success",
58
- changed: !0
59
- };
60
- if (s.getKind() === f.PropertyAssignment) {
61
- let e = s.getInitializer();
62
- if (e && e.getKind() === f.ObjectLiteralExpression) {
63
- let t = e;
64
- t.getProperty("enabled") || t.addPropertyAssignment({
65
- name: "enabled",
66
- initializer: "true"
67
- });
68
- let n = t.getProperty("apiKeys");
69
- if (!n) t.addPropertyAssignment({
70
- name: "apiKeys",
71
- initializer: "{ enabled: true }"
72
- });
73
- else if (n.getKind() === f.PropertyAssignment) {
74
- let e = n.getInitializer();
75
- if (e && e.getKind() === f.ObjectLiteralExpression) {
76
- let t = e;
77
- t.getProperty("enabled") || t.addPropertyAssignment({
78
- name: "enabled",
79
- initializer: "true"
80
- });
81
- } else n.setInitializer("{ enabled: true }");
82
- }
83
- }
84
- }
85
- return n.formatText(), n.saveSync(), {
86
- status: "success",
87
- changed: n.getFullText() !== t
88
- };
89
- }
90
- //#endregion
91
- //#region src/patterns/enable/api-keys/modifies/nav-user.svelte.ts
92
- var g = [
93
- "import KeyRoundIcon from '@lucide/svelte/icons/key-round';",
94
- "",
95
- "// Add to your navUser array:",
96
- "{ title: 'API Keys', url: '/api-keys', icon: KeyRoundIcon }"
97
- ].join("\n"), _ = [
98
- "Add an API Keys nav item to nav-user.svelte:",
99
- "",
100
- g
101
- ].join("\n"), v = [
102
- "Create nav-user.svelte with an API Keys entry:",
103
- "",
104
- g
105
- ].join("\n");
106
- function y(e, t, n, a, o) {
107
- let s = new r(e), c = !1, l = (e) => {
108
- c || e((e) => {
109
- let r = i(e, t, n, a, o);
110
- return r.wasAdded && (c = !0), r.source;
111
- });
112
- };
113
- return l((e) => s.modifyModuleScript(e)), c || l((e) => s.modifyScript(e)), {
114
- newNavUserSnippet: s.toString(),
115
- wasAdded: c
116
- };
117
- }
118
- function b(e) {
119
- if (!l.existsSync(e)) return {
120
- status: "not-found",
121
- message: v
122
- };
123
- let t = l.readFileSync(e, "utf8");
124
- if (t.includes("/api-keys")) return {
125
- status: "success",
126
- changed: !1
127
- };
128
- let { newNavUserSnippet: n, wasAdded: r } = y(t, "API Keys", "/api-keys", "KeyRoundIcon", "@lucide/svelte/icons/key-round");
129
- return r ? (l.writeFileSync(e, n, "utf8"), {
130
- status: "success",
131
- changed: !0
132
- }) : {
133
- status: "failed",
134
- message: _
135
- };
136
- }
137
- //#endregion
138
- //#region src/patterns/enable/api-keys/generate.runtime.ts
139
- async function x(e) {
140
- let r = t(e), i = [];
141
- await s(e.root, async (t) => {
142
- let n = await t.collections.getOne("users");
143
- if (r.info("Creating api_keys collection"), (await c(t, {
144
- listRule: "@request.auth.id = user.id",
145
- viewRule: "@request.auth.id = user.id",
146
- createRule: "@request.auth.id = user.id",
147
- updateRule: "@request.auth.id = user.id",
148
- deleteRule: "@request.auth.id = user.id",
149
- name: "api_keys",
150
- type: "base",
151
- fields: [
152
- {
153
- collectionId: n.id,
154
- maxSelect: 1,
155
- name: "user",
156
- type: "relation"
157
- },
158
- {
159
- name: "key_hash",
160
- type: "text"
161
- },
162
- {
163
- name: "label",
164
- type: "text"
165
- },
166
- {
167
- name: "last_used",
168
- type: "date"
169
- },
170
- {
171
- name: "created",
172
- onCreate: !0,
173
- onUpdate: !1,
174
- type: "autodate"
175
- },
176
- {
177
- name: "updated",
178
- onCreate: !0,
179
- onUpdate: !0,
180
- type: "autodate"
181
- }
182
- ]
183
- })).created) {
184
- await o();
185
- let t = a("api_keys", "created", e);
186
- t && i.push({
187
- path: t,
188
- language: "ts",
189
- content: l.readFileSync(t, "utf8"),
190
- status: "success"
191
- });
192
- }
193
- });
194
- let d = [], f = (e) => {
195
- e && d.push(e);
196
- };
197
- r.info("Modifying hooks.server.ts");
198
- let p = u.join(e.root, "src", "hooks.server.ts");
199
- f(n(p, h(p))), r.info("Modifying nav-user");
200
- let m = u.join(e.root, "src", "lib", "components", "nav-user.svelte");
201
- return f(n(m, b(m))), {
202
- creates: i,
203
- modifies: d,
204
- deletes: [],
205
- components: [],
206
- packages: [],
207
- collections: [],
208
- collectionPatches: [],
209
- collectionDrops: []
210
- };
211
- }
212
- //#endregion
213
- export { x as generate };
214
-
215
- //# sourceMappingURL=generate.runtime-Cy56Ypws.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-Cy56Ypws.js","names":[],"sources":["../../src/patterns/enable/api-keys/modifies/hooks.server.ts","../../src/patterns/enable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/enable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with API keys in hooks.server.ts:\n\n handlePocketbase({\n api: {\n enabled: true,\n apiKeys: { enabled: true },\n },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n api: {\n enabled: true,\n apiKeys: { enabled: true },\n },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(\n 0,\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true, apiKeys: { enabled: true } }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n apiObj.addPropertyAssignment({\n name: \"apiKeys\",\n initializer: `{ enabled: true }`,\n });\n } else if (apiKeysProp.getKind() === SyntaxKind.PropertyAssignment) {\n const keysInit = (\n apiKeysProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (\n keysInit &&\n keysInit.getKind() === SyntaxKind.ObjectLiteralExpression\n ) {\n const keysObj =\n keysInit as import(\"ts-morph\").ObjectLiteralExpression;\n const keysEnabled = keysObj.getProperty(\"enabled\");\n if (!keysEnabled) {\n keysObj.addPropertyAssignment({\n name: \"enabled\",\n initializer: \"true\",\n });\n }\n } else {\n (apiKeysProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `{ enabled: true }`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst API_KEYS_NAV_SNIPPET = [\n \"import KeyRoundIcon from '@lucide/svelte/icons/key-round';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'API Keys', url: '/api-keys', icon: KeyRoundIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add an API Keys nav item to nav-user.svelte:\",\n \"\",\n API_KEYS_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with an API Keys entry:\",\n \"\",\n API_KEYS_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"API Keys\",\n \"/api-keys\",\n \"KeyRoundIcon\",\n \"@lucide/svelte/icons/key-round\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { createCollectionIdempotent } from \"../../../runtime/collections\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyNavUser } from \"./modifies/nav-user.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n\n logger.info(\"Creating api_keys collection\");\n const apiKeysResult = await createCollectionIdempotent(pb, {\n listRule: \"@request.auth.id = user.id\",\n viewRule: \"@request.auth.id = user.id\",\n createRule: \"@request.auth.id = user.id\",\n updateRule: \"@request.auth.id = user.id\",\n deleteRule: \"@request.auth.id = user.id\",\n name: \"api_keys\",\n type: \"base\",\n fields: [\n {\n collectionId: userCollection.id,\n maxSelect: 1,\n name: \"user\",\n type: \"relation\",\n },\n {\n name: \"key_hash\",\n type: \"text\",\n },\n {\n name: \"label\",\n type: \"text\",\n },\n {\n name: \"last_used\",\n type: \"date\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n if (apiKeysResult.created) {\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"api_keys\", \"created\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n }\n });\n\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, modifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Modifying nav-user\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collect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B,EAAgB,CAAC,CACzE,EAED,EAAO,KAAK,qBAAqB;CACjC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,kBACD;AAGD,QAFA,EAAW,EAAoB,GAAa,EAAc,EAAY,CAAC,CAAC,EAEjE;EACL;EACA;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAE;EACpB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.runtime-DV9S4KW_.js","names":[],"sources":["../../src/patterns/enable/payments/modifies/modify-nav-user.ts","../../src/patterns/enable/payments/modifies/modify-user-signup.ts","../../src/patterns/enable/payments/runtime/stripe.ts","../../src/patterns/enable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BILLING_NAV_SNIPPET = [\n \"import CreditCardIcon from '@lucide/svelte/icons/credit-card';\",\n \"\",\n \"// Add to your navUser array:\",\n \"{ title: 'Billing', url: '/billing', icon: CreditCardIcon }\",\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Add a Billing nav item to nav-user.svelte:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create nav-user.svelte with a Billing entry:\",\n \"\",\n BILLING_NAV_SNIPPET,\n].join(\"\\n\");\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n if (navUserSnippet.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"Billing\",\n \"/billing\",\n \"CreditCardIcon\",\n \"@lucide/svelte/icons/credit-card\",\n );\n\n if (!wasAdded) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst LINK_STRIPE_CUSTOMER_SNIPPET = dedent`\n const linkStripeCustomer = async (email: string, user: { id: string }, locals: App.Locals) => {\n const matchingCustomer = await stripe.customers.list({\n email: email,\n limit: 1,\n expand: ['data.invoice_settings']\n });\n\n let customer;\n let isExistingCustomer = false;\n\n if (matchingCustomer.data.length > 0) {\n isExistingCustomer = true;\n customer = matchingCustomer.data[0];\n } else {\n customer = await stripe.customers.create({\n email: email\n });\n }\n\n await locals.admin.collection('stripe_customers').create({\n id: customer.id,\n user: user.id\n });\n\n if (!isExistingCustomer) {\n return;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(customer.id, {\n type: 'card',\n allow_redisplay: 'always'\n });\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === 'unspecified') {\n continue;\n }\n\n await locals.admin.collection('stripe_payment_methods').create({\n id: paymentMethod.id,\n customer: customer.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year\n });\n }\n\n const defaultPaymentMethod = customer.invoice_settings?.default_payment_method;\n\n if (defaultPaymentMethod) {\n try {\n await locals.admin.collection('stripe_customers').update(customer.id, {\n default_payment_method: defaultPaymentMethod\n });\n } catch {}\n }\n };\n`;\n\nconst FAILURE_HINT = [\n \"Could not locate the requestVerification call in signup +page.server.ts.\",\n \"Add a linkStripeCustomer helper and call it before requestVerification().\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(public)/signup/+page.server.ts before enabling payments.\",\n].join(\"\\n\");\n\nexport function modifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n const hasStripeImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"$lib/stripe\");\n\n if (hasStripeImport) {\n return { status: \"success\", changed: false };\n }\n\n sourceFile.addImportDeclaration({\n defaultImport: \"stripe\",\n moduleSpecifier: \"$lib/stripe\",\n });\n\n const requestVerificationCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => {\n const expr = ce.getExpression();\n return (\n expr.getKind() === SyntaxKind.PropertyAccessExpression &&\n expr.getText().includes(\"requestVerification\")\n );\n });\n\n if (!requestVerificationCall) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const statement = requestVerificationCall.getFirstAncestorByKind(\n SyntaxKind.ExpressionStatement,\n );\n\n if (!statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n sourceFile.addStatements(LINK_STRIPE_CUSTOMER_SNIPPET);\n\n const stripeCall = dedent`\n await linkStripeCustomer(form.data.email, user, locals);\n `;\n\n statement.replaceWithText(stripeCall + \"\\n\\n\" + statement.getText());\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import Stripe from \"stripe\";\n\nexport interface StripeTestFixture {\n product: Stripe.Product;\n price: Stripe.Price;\n existing: boolean;\n}\n\nexport async function createTestProductAndPrice(\n stripeSecretKey: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n\n const products = await stripe.products.search({\n query: `name:\"Test Product\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n const product = products.data[0];\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n if (prices.data.length > 0) {\n return { product, price: prices.data[0], existing: true };\n }\n }\n\n const product = await stripe.products.create({\n name: \"Test Product\",\n metadata: { test: \"true\" },\n });\n\n const price = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n });\n\n return { product, price, existing: false };\n}\n\nexport async function getProductAndPriceById(\n stripeSecretKey: string,\n priceId: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n const price = await stripe.prices.retrieve(priceId, { expand: [\"product\"] });\n const product =\n typeof price.product === \"string\"\n ? await stripe.products.retrieve(price.product)\n : (price.product as Stripe.Product);\n price.product = product.id;\n return { product, price, existing: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { randomBytes } from \"node:crypto\";\nimport dedent from \"dedent\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { createCollectionIdempotent } from \"../../../runtime/collections\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { modifyEnv, type EnvEdit } from \"./modifies/modify-env\";\nimport {\n createTestProductAndPrice,\n getProductAndPriceById,\n} from \"./runtime/stripe\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n action: \"created\" | \"updated\",\n options: Options,\n created = true,\n) {\n if (!created) return;\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, action, options);\n if (!migrationFile) return;\n creates.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n}\n\nfunction paymentPageSnippet(priceId: string): string {\n return dedent`\n <script lang=\"ts\">\n import PaymentButton from '$lib/components/payments/payment-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"${priceId}\" />\n </section>\n `;\n}\n\nexport async function generate(options: Options) {\n const {\n stripeSecretKey,\n stripePublishableKey,\n stripeWebhookSecret,\n stripePriceId,\n } = options.input as {\n stripeSecretKey: string;\n stripePublishableKey: string;\n stripeWebhookSecret: string;\n stripePriceId?: string;\n };\n\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Writing Stripe credentials to .env\");\n const internalJobSecret = randomBytes(16).toString(\"hex\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\", value: stripeSecretKey },\n {\n type: \"var\",\n key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\",\n value: stripePublishableKey,\n },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\", value: stripeWebhookSecret },\n { type: \"var\", key: \"INTERNAL_JOB_SECRET\", value: internalJobSecret },\n ];\n\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnv(envPath, envEdits)));\n\n await withPocketbase(options.root, async (pb) => {\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n logger.info(\"Creating stripe_products collection\");\n const productsResult = await create({\n name: \"stripe_products\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"name\", required: false, type: \"text\" },\n { name: \"active\", required: false, type: \"text\" },\n { name: \"default_price\", required: false, type: \"text\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_products\",\n \"created\",\n options,\n productsResult.created,\n );\n\n logger.info(\"Creating stripe_prices collection\");\n const pricesResult = await create({\n name: \"stripe_prices\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"billing_scheme\", required: false, type: \"text\" },\n { name: \"currency\", required: false, type: \"text\" },\n { name: \"product\", required: false, type: \"text\" },\n { name: \"recurring\", required: false, type: \"text\" },\n { name: \"type\", required: false, type: \"text\" },\n { name: \"unit_amount\", required: false, type: \"number\" },\n { name: \"active\", required: false, type: \"bool\" },\n { name: \"created\", onCreate: true, onUpdate: false, type: \"autodate\" },\n { name: \"updated\", onCreate: true, onUpdate: true, type: \"autodate\" },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_prices\",\n \"created\",\n options,\n pricesResult.created,\n );\n\n if (isAppMode) {\n logger.info(\"Creating stripe_customers collection\");\n const customersResult = await create({\n name: \"stripe_customers\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const stripeCustomersCollection = customersResult.collection;\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"created\",\n options,\n customersResult.created,\n );\n\n logger.info(\"Creating stripe_payment_methods collection\");\n const paymentMethodsResult = await create({\n name: \"stripe_payment_methods\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"exp_month\", required: true, type: \"number\" },\n { name: \"exp_year\", required: true, type: \"number\" },\n {\n collectionId: stripeCustomersCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"customer\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const stripePaymentMethodsCollection = paymentMethodsResult.collection;\n await pushMigrationCreates(\n creates,\n \"stripe_payment_methods\",\n \"created\",\n options,\n paymentMethodsResult.created,\n );\n\n logger.info(\"Linking default_payment_method on stripe_customers\");\n await pb.collections.update(\"stripe_customers\", {\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n collectionId: stripePaymentMethodsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"default_payment_method\",\n required: false,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"updated\",\n options,\n );\n\n logger.info(\"Creating transactions collection\");\n const transactionsResult = await create({\n name: \"transactions\",\n type: \"base\",\n fields: [\n {\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"stripe_payment_intent\", required: true, type: \"text\" },\n { name: \"amount\", required: true, type: \"number\" },\n { name: \"currency\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"created\", required: true, type: \"date\" },\n { name: \"stripe_charge\", required: true, type: \"text\" },\n { name: \"stripe_customer\", required: true, type: \"text\" },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n { name: \"receipt_url\", required: true, type: \"url\" },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"transactions\",\n \"created\",\n options,\n transactionsResult.created,\n );\n }\n });\n\n if (stripePriceId) {\n logger.info(`Fetching Stripe product/price ${stripePriceId}`);\n } else {\n logger.info(\"Creating test Stripe product and price\");\n }\n const { product, price, existing } = stripePriceId\n ? await getProductAndPriceById(stripeSecretKey, stripePriceId)\n : await createTestProductAndPrice(stripeSecretKey);\n\n if (existing) {\n logger.info(\"Stripe product/price already exists, skipping creation\");\n }\n\n logger.info(\"Seeding Stripe product/price records\");\n await withPocketbase(options.root, async (pb) => {\n try {\n await pb.collection(\"stripe_products\").getOne(product.id);\n } catch (error) {\n await pb.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n }\n\n try {\n await pb.collection(\"stripe_prices\").getOne(price.id);\n } catch (error) {\n await pb.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n }\n });\n\n logger.info(\"Creating payment +page.svelte\");\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: paymentPageSnippet(price.id),\n status: \"success\",\n });\n\n if (isAppMode) {\n logger.info(\"Modifying nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n logger.info(\"Modifying signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, modifyUserSignup(userSignupPath)),\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":";;;;;;;;;;;;;;;AAKA,IAAM,IAAsB;CAC1B;CACA;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAe;CACnB;CACA;CACA;CACD,CAAC,KAAK,KAAK,EAEN,IAAiB;CACrB;CACA;CACA;CACD,CAAC,KAAK,KAAK;AAEZ,SAAgB,EACd,GACA,GACA,GACA,GACA,GACkD;CAClD,IAAM,IAAO,IAAI,EAAW,EAAe,EACvC,IAAW,IAET,KAAU,MAAgD;AAC1D,OACJ,GAAK,MAAW;GACd,IAAM,IAAS,EACb,GACA,GACA,GACA,GACA,EACD;AAED,UADI,EAAO,aAAU,IAAW,KACzB,EAAO;IACd;;AAMJ,QAHA,GAAQ,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACtC,KAAU,GAAQ,MAAO,EAAK,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0,0 @@
1
- import { a as e, o as t, r as n } from "./ts-morph-helpers-B0oxeDUU.js";
2
- import r from "node:fs";
3
- import { Project as i, SyntaxKind as a } from "ts-morph";
4
- //#region src/patterns/disable/auth/modifies/+layout.server.ts
5
- function o(e) {
6
- if (!r.existsSync(e)) return {
7
- status: "success",
8
- changed: !1
9
- };
10
- let t = r.readFileSync(e, "utf8");
11
- if (!t.includes("locals.pb.authStore.record")) return {
12
- status: "success",
13
- changed: !1
14
- };
15
- let n = new i().addSourceFileAtPath(e), o = n.getDescendantsOfKind(a.ObjectLiteralExpression);
16
- for (let e of o) {
17
- let t = e.getProperty("user");
18
- !t || t.getKind() !== a.PropertyAssignment || t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
19
- }
20
- return n.formatText(), n.saveSync(), {
21
- status: "success",
22
- changed: n.getFullText() !== t
23
- };
24
- }
25
- //#endregion
26
- //#region src/patterns/disable/auth/modifies/root-layout.svelte.ts
27
- function s(i) {
28
- if (!r.existsSync(i)) return {
29
- status: "success",
30
- changed: !1
31
- };
32
- let a = new t(r.readFileSync(i, "utf8"));
33
- return a.hasElement("AuthMenu.Root") ? (a.removeElement("AuthMenu.Root"), a.modifyScript((t) => {
34
- let { source: r } = e(t, (e) => {
35
- n(e, "$lib/components/ui/auth-menu"), n(e, "$lib/components/ui/avatar");
36
- });
37
- return r;
38
- }), a.writeTo(i), {
39
- status: "success",
40
- changed: a.hasChanged()
41
- }) : {
42
- status: "success",
43
- changed: !1
44
- };
45
- }
46
- //#endregion
47
- //#region src/patterns/disable/auth/modifies/hooks.server.ts
48
- function c(e) {
49
- if (!r.existsSync(e)) return {
50
- status: "success",
51
- changed: !1
52
- };
53
- let t = r.readFileSync(e, "utf8"), n = new i().addSourceFileAtPath(e), o = n.getDescendantsOfKind(a.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
54
- if (!o) return {
55
- status: "success",
56
- changed: !1
57
- };
58
- let [s] = o.getArguments();
59
- if (!s || s.getKind() !== a.ObjectLiteralExpression) return {
60
- status: "success",
61
- changed: !1
62
- };
63
- let c = s.asKindOrThrow(a.ObjectLiteralExpression), l = c.getProperty("auth");
64
- return l ? (l.remove(), c.getProperties().length === 0 && o.removeArgument(0), n.formatText(), n.saveSync(), {
65
- status: "success",
66
- changed: n.getFullText() !== t
67
- }) : {
68
- status: "success",
69
- changed: !1
70
- };
71
- }
72
- //#endregion
73
- export { s as n, o as r, c as t };
74
-
75
- //# sourceMappingURL=hooks.server-CPVyj3rv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.server-CPVyj3rv.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"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\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\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 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\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 });\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.get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;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAiB,EAAG,aAAa,GAAiB,OAAO,EAEzD,IADU,IAAI,GAAS,CACF,oBAAoB,EAAgB,EAEzD,IAAW,EACd,qBAAqB,EAAW,eAAe,CAC/C,MAAM,MAAO,EAAG,eAAe,CAAC,SAAS,KAAK,mBAAmB;AACpE,KAAI,CAAC,EAAU,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAE3D,IAAM,CAAC,KAAY,EAAS,cAAc;AAC1C,KAAI,CAAC,KAAY,EAAS,SAAS,KAAK,EAAW,wBACjD,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAa,EAAS,cAAc,EAAW,wBAAwB,EACvE,IAAW,EAAW,YAAY,OAAO;AAc/C,QAbK,KAIL,EAAS,QAAQ,EAEb,EAAW,eAAe,CAAC,WAAW,KACxC,EAAS,eAAe,EAAE,EAG5B,EAAW,YAAY,EACvB,EAAW,UAAU,EAEd;EACL,QAAQ;EACR,SAAS,EAAW,aAAa,KAAK;EACvC,IAfQ;EAAE,QAAQ;EAAW,SAAS;EAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ts-morph-helpers-B0oxeDUU.js","names":[],"sources":["../../src/runtime/svelte-file.ts","../../src/runtime/ts-morph-helpers.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { parse, type AST } from \"svelte/compiler\";\nimport MagicString from \"magic-string\";\n\ntype SvelteAst = AST.Root;\ntype SvelteNode = any;\n\ninterface ScriptBlock {\n content: string;\n start: number;\n end: number;\n}\n\n/**\n * Surgical, AST-aware editing of .svelte files.\n *\n * Parses the source with svelte/compiler to discover precise character offsets,\n * then applies edits via magic-string so untouched regions remain byte-for-byte\n * identical to the original. Script-block contents are exposed as plain strings\n * so callers can hand them to ts-morph.\n */\nexport class SvelteFile {\n private readonly source: string;\n private readonly ast: SvelteAst;\n private readonly s: MagicString;\n\n constructor(source: string) {\n this.source = source;\n this.ast = parse(source, { modern: true });\n this.s = new MagicString(source);\n }\n\n static fromPath(filePath: string): SvelteFile {\n return new SvelteFile(fs.readFileSync(filePath, \"utf8\"));\n }\n\n getScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).instance);\n }\n\n getModuleScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).module);\n }\n\n private scriptInner(script: SvelteNode | null): ScriptBlock | null {\n if (!script) return null;\n const start = script.content.start as number;\n const end = script.content.end as number;\n return { content: this.source.slice(start, end), start, end };\n }\n\n /**\n * Replace the inner contents of <script>. Use for ts-morph round-trips.\n * Returns true when an edit was made.\n */\n modifyScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getScript(), fn);\n }\n\n modifyModuleScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getModuleScript(), fn);\n }\n\n private modifyScriptBlock(\n block: ScriptBlock | null,\n fn: (content: string) => string,\n ): boolean {\n if (!block) return false;\n const next = fn(block.content);\n if (next === block.content) return false;\n this.s.overwrite(block.start, block.end, next);\n return true;\n }\n\n /** First Component or RegularElement node with the given name. */\n findElement(name: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n (node.type === \"Component\" || node.type === \"RegularElement\") &&\n node.name === name,\n );\n }\n\n hasElement(name: string): boolean {\n return this.findElement(name) !== null;\n }\n\n hasAttribute(componentName: string, attrName: string): boolean {\n const node = this.findElement(componentName);\n if (!node) return false;\n return (node.attributes ?? []).some(\n (attr: SvelteNode) => attr.type === \"Attribute\" && attr.name === attrName,\n );\n }\n\n /**\n * Insert content at the end of <ComponentName>'s children, just before the\n * closing tag. No-op if the element is not found.\n */\n insertBeforeClosingTag(name: string, content: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const closingTag = `</${name}>`;\n const closingPos = this.source.lastIndexOf(closingTag, node.end);\n if (closingPos === -1) return false;\n this.s.appendLeft(closingPos, content);\n return true;\n }\n\n /** Replace the element entirely (start tag through close tag). */\n replaceElement(name: string, newContent: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n this.s.overwrite(node.start, node.end, newContent);\n return true;\n }\n\n /** Remove the element (start tag through close tag). */\n removeElement(name: string): boolean {\n return this.replaceElement(name, \"\");\n }\n\n /** Append raw markup to the end of the source file. */\n appendMarkup(content: string): void {\n this.s.append(content);\n }\n\n /**\n * Append attribute text (e.g. \" team={data.team}\") just after the last\n * existing attribute on the element's start tag.\n */\n appendToAttributes(name: string, attrs: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const last = (node.attributes ?? []).at(-1) as SvelteNode | undefined;\n const insertAt = last\n ? (last.end as number)\n : (node.start as number) + `<${name}`.length;\n this.s.appendLeft(insertAt, attrs);\n return true;\n }\n\n hasChanged(): boolean {\n return this.s.hasChanged();\n }\n\n toString(): string {\n return this.s.toString();\n }\n\n writeTo(filePath: string): void {\n if (this.hasChanged()) {\n fs.writeFileSync(filePath, this.toString(), \"utf8\");\n }\n }\n}\n\nfunction findNode(\n root: unknown,\n predicate: (node: any) => boolean,\n): any | null {\n const seen = new WeakSet<object>();\n function visit(node: unknown): any | null {\n if (!node || typeof node !== \"object\" || seen.has(node as object)) {\n return null;\n }\n seen.add(node as object);\n if (predicate(node as any)) return node;\n for (const key of Object.keys(node as Record<string, unknown>)) {\n if (key === \"parent\") continue;\n const child = (node as Record<string, unknown>)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n const found = visit(item);\n if (found) return found;\n }\n } else if (\n child &&\n typeof child === \"object\" &&\n \"type\" in (child as object)\n ) {\n const found = visit(child);\n if (found) return found;\n }\n }\n return null;\n }\n return visit(root);\n}\n","import {\n Project,\n QuoteKind,\n SyntaxKind,\n type ImportDeclarationStructure,\n type OptionalKind,\n type SourceFile,\n type StringLiteral,\n} from \"ts-morph\";\n\nexport interface ImportSpec {\n defaultImport?: string;\n namespaceImport?: string;\n namedImports?: string[];\n moduleSpecifier: string;\n}\n\n/**\n * Run a function with an in-memory ts-morph SourceFile and return the resulting\n * source plus whatever the callback returned.\n */\nexport function withInMemoryScript<T>(\n source: string,\n fn: (sf: SourceFile) => T,\n): { source: string; result: T } {\n const project = new Project({\n useInMemoryFileSystem: true,\n skipFileDependencyResolution: true,\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sf = project.createSourceFile(\"script.ts\", source, { overwrite: true });\n const result = fn(sf);\n return { source: sf.getFullText(), result };\n}\n\n/** Add the given imports to the source file, skipping any whose module specifier already exists. */\nexport function ensureImports(sf: SourceFile, imports: ImportSpec[]): void {\n for (const spec of imports) {\n const existing = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) continue;\n\n const structure: OptionalKind<ImportDeclarationStructure> = {\n moduleSpecifier: spec.moduleSpecifier,\n };\n if (spec.defaultImport) structure.defaultImport = spec.defaultImport;\n if (spec.namespaceImport) structure.namespaceImport = spec.namespaceImport;\n if (spec.namedImports) structure.namedImports = spec.namedImports;\n sf.addImportDeclaration(structure);\n }\n}\n\n/** Remove the import declaration for the given module specifier, if present. */\nexport function removeImportByModuleSpecifier(\n sf: SourceFile,\n moduleSpecifier: string,\n): { wasRemoved: boolean } {\n const decl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!decl) return { wasRemoved: false };\n decl.remove();\n return { wasRemoved: true };\n}\n\n/** Remove a top-level function or variable declaration by name, if present. */\nexport function removeTopLevelStatementByIdentifier(\n sf: SourceFile,\n name: string,\n): { wasRemoved: boolean } {\n const fn = sf.getFunction(name);\n if (fn) {\n fn.remove();\n return { wasRemoved: true };\n }\n const vs = sf\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === name));\n if (vs) {\n vs.remove();\n return { wasRemoved: true };\n }\n return { wasRemoved: false };\n}\n\n/**\n * Add an item to the `data.navUser` array in a Svelte component's script body.\n * Idempotent: if an entry with the same `title` already exists, no-op.\n */\nexport function addNavItemToScript(\n scriptSource: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { source: string; wasAdded: boolean } {\n const newNavItemSnippet = `\n {\n title: '${title}',\n url: '${url}',\n icon: ${icon}\n }\n `.trim();\n\n const { source, result } = withInMemoryScript(scriptSource, (sf) => {\n const dataDecl = sf\n .getVariableDeclarations()\n .find((d) => d.getName() === \"data\");\n const dataInit = dataDecl?.getInitializer();\n if (\n !dataInit ||\n dataInit.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return { wasAdded: false };\n }\n\n const obj = dataInit.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const navProp = obj.getProperty(\"navUser\");\n if (!navProp || navProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { wasAdded: false };\n }\n\n const init = navProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return { wasAdded: false };\n }\n\n const arr = init.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n const exists = arr.getElements().some((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const titleProp = o.getProperty(\"title\");\n if (!titleProp || titleProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n const value = titleProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n return (\n value?.getKind() === SyntaxKind.StringLiteral &&\n (value as StringLiteral).getLiteralText() === title\n );\n });\n\n if (exists) return { wasAdded: false };\n\n ensureImports(sf, [\n { defaultImport: icon, moduleSpecifier: iconImportPath },\n ]);\n arr.addElement(newNavItemSnippet);\n sf.formatText();\n return { wasAdded: true };\n });\n\n return { source, wasAdded: result.wasAdded };\n}\n\n/**\n * Remove the entry with the given `title` from the `data.navUser` array in a\n * Svelte component's script body. Also removes the icon import if supplied and\n * no other navUser entry references it. Idempotent: no-op if the entry or\n * navUser structure is missing.\n */\nexport function removeNavItemFromScript(\n scriptSource: string,\n title: string,\n iconImportPath?: string,\n): { source: string; wasRemoved: boolean } {\n const { source, result } = withInMemoryScript(scriptSource, (sf) => {\n const dataDecl = sf\n .getVariableDeclarations()\n .find((d) => d.getName() === \"data\");\n const dataInit = dataDecl?.getInitializer();\n if (\n !dataInit ||\n dataInit.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return { wasRemoved: false };\n }\n\n const obj = dataInit.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const navProp = obj.getProperty(\"navUser\");\n if (!navProp || navProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { wasRemoved: false };\n }\n\n const init = navProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n return { wasRemoved: false };\n }\n\n const arr = init.asKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n const elements = arr.getElements();\n const index = elements.findIndex((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const titleProp = o.getProperty(\"title\");\n if (!titleProp || titleProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n const value = titleProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer();\n return (\n value?.getKind() === SyntaxKind.StringLiteral &&\n (value as StringLiteral).getLiteralText() === title\n );\n });\n\n if (index === -1) return { wasRemoved: false };\n\n arr.removeElement(index);\n\n if (iconImportPath) {\n const remainingRefs = arr.getElements().some((el) => {\n if (el.getKind() !== SyntaxKind.ObjectLiteralExpression) return false;\n const o = el.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const iconProp = o.getProperty(\"icon\");\n if (!iconProp || iconProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return false;\n }\n return iconProp\n .asKindOrThrow(SyntaxKind.PropertyAssignment)\n .getInitializer()\n ?.getText() !== undefined;\n });\n const importDecl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === iconImportPath);\n if (importDecl && !remainingRefs) {\n const importName = importDecl.getDefaultImport()?.getText();\n const stillUsed =\n importName &&\n sf\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some(\n (id) =>\n id.getText() === importName &&\n id.getParent()?.getKind() !==\n SyntaxKind.ImportClause &&\n id.getParent()?.getKind() !==\n SyntaxKind.ImportSpecifier,\n );\n if (!stillUsed) {\n importDecl.remove();\n }\n }\n }\n\n sf.formatText();\n return { wasRemoved: true };\n });\n\n return { source, wasRemoved: result.wasRemoved };\n}\n"],"mappings":";;;;;AAqBA,IAAa,IAAb,MAAa,EAAW;CAKtB,YAAY,GAAgB;AAG1B,EAFA,KAAK,SAAS,GACd,KAAK,MAAM,EAAM,GAAQ,EAAE,QAAQ,IAAM,CAAC,EAC1C,KAAK,IAAI,IAAI,EAAY,EAAO;;CAGlC,OAAO,SAAS,GAA8B;AAC5C,SAAO,IAAI,EAAW,EAAG,aAAa,GAAU,OAAO,CAAC;;CAG1D,YAAgC;AAC9B,SAAO,KAAK,YAAa,KAAK,IAAY,SAAS;;CAGrD,kBAAsC;AACpC,SAAO,KAAK,YAAa,KAAK,IAAY,OAAO;;CAGnD,YAAoB,GAA+C;AACjE,MAAI,CAAC,EAAQ,QAAO;EACpB,IAAM,IAAQ,EAAO,QAAQ,OACvB,IAAM,EAAO,QAAQ;AAC3B,SAAO;GAAE,SAAS,KAAK,OAAO,MAAM,GAAO,EAAI;GAAE;GAAO;GAAK;;CAO/D,aAAa,GAA0C;AACrD,SAAO,KAAK,kBAAkB,KAAK,WAAW,EAAE,EAAG;;CAGrD,mBAAmB,GAA0C;AAC3D,SAAO,KAAK,kBAAkB,KAAK,iBAAiB,EAAE,EAAG;;CAG3D,kBACE,GACA,GACS;AACT,MAAI,CAAC,EAAO,QAAO;EACnB,IAAM,IAAO,EAAG,EAAM,QAAQ;AAG9B,SAFI,MAAS,EAAM,UAAgB,MACnC,KAAK,EAAE,UAAU,EAAM,OAAO,EAAM,KAAK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