@velastack/patterns 0.0.57 → 0.0.59

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 (102) hide show
  1. package/README.md +0 -12
  2. package/dist/chunks/{_server-Cv3bTkG0.js → _server-Cie287JZ.js} +1 -1
  3. package/dist/chunks/_server-Cie287JZ.js.map +1 -0
  4. package/dist/chunks/{collections-BwO27pJg.js → collections-DZOoJLVj.js} +5 -5
  5. package/dist/chunks/{collections-BwO27pJg.js.map → collections-DZOoJLVj.js.map} +1 -1
  6. package/dist/chunks/config-target-Co-ij8p3.js +163 -0
  7. package/dist/chunks/config-target-Co-ij8p3.js.map +1 -0
  8. package/dist/chunks/{constants-BMZmCRiI.js → constants-qmioN-7W.js} +1 -1
  9. package/dist/chunks/{constants-BMZmCRiI.js.map → constants-qmioN-7W.js.map} +1 -1
  10. package/dist/chunks/{dedent-C4qKBQXh.js → dedent-Gq6Krl4n.js} +1 -1
  11. package/dist/chunks/{dedent-C4qKBQXh.js.map → dedent-Gq6Krl4n.js.map} +1 -1
  12. package/dist/chunks/{env-Bk-LRVos.js → env-BPfk1VAw.js} +1 -1
  13. package/dist/chunks/{env-Bk-LRVos.js.map → env-BPfk1VAw.js.map} +1 -1
  14. package/dist/chunks/{env.preview-DoY1CJwL.js → env.preview-uMRKT5Pc.js} +1 -1
  15. package/dist/chunks/{env.preview-DoY1CJwL.js.map → env.preview-uMRKT5Pc.js.map} +1 -1
  16. package/dist/chunks/{env.runtime-D46GCIKe.js → env.runtime-BVage9Kk.js} +1 -1
  17. package/dist/chunks/{env.runtime-D46GCIKe.js.map → env.runtime-BVage9Kk.js.map} +1 -1
  18. package/dist/chunks/{errors-Co77I4oK.js → errors-D3Zy3wCg.js} +1 -1
  19. package/dist/chunks/{errors-Co77I4oK.js.map → errors-D3Zy3wCg.js.map} +1 -1
  20. package/dist/chunks/{generate2.runtime-yP14iPwX.js → generate.runtime-6TJoTPg9.js} +21 -15
  21. package/dist/chunks/generate.runtime-6TJoTPg9.js.map +1 -0
  22. package/dist/chunks/{generate.runtime-BnkNmF1g.js → generate.runtime-6qpoLA04.js} +10 -8
  23. package/dist/chunks/{generate.runtime-BnkNmF1g.js.map → generate.runtime-6qpoLA04.js.map} +1 -1
  24. package/dist/chunks/generate.runtime-AmiNbSR3.js +172 -0
  25. package/dist/chunks/generate.runtime-AmiNbSR3.js.map +1 -0
  26. package/dist/chunks/{generate.runtime-DjwRKg8K.js → generate.runtime-BT_bwAtt.js} +124 -198
  27. package/dist/chunks/generate.runtime-BT_bwAtt.js.map +1 -0
  28. package/dist/chunks/{generate.runtime-Cb2vYF1l.js → generate.runtime-BnnsaLsg.js} +5 -5
  29. package/dist/chunks/{generate.runtime-Cb2vYF1l.js.map → generate.runtime-BnnsaLsg.js.map} +1 -1
  30. package/dist/chunks/{generate.runtime-D6oE0Mmf.js → generate.runtime-CGtKTfYU.js} +6 -6
  31. package/dist/chunks/{generate.runtime-D6oE0Mmf.js.map → generate.runtime-CGtKTfYU.js.map} +1 -1
  32. package/dist/chunks/{generate.runtime-BkvtIjgh.js → generate.runtime-CINxHRnJ.js} +5 -5
  33. package/dist/chunks/{generate.runtime-BkvtIjgh.js.map → generate.runtime-CINxHRnJ.js.map} +1 -1
  34. package/dist/chunks/{generate.runtime-DnymXcvu.js → generate.runtime-CNxgU9v1.js} +6 -6
  35. package/dist/chunks/{generate.runtime-DnymXcvu.js.map → generate.runtime-CNxgU9v1.js.map} +1 -1
  36. package/dist/chunks/{generate.runtime-Bpx69a8t.js → generate.runtime-CRS9C9xX.js} +18 -16
  37. package/dist/chunks/{generate.runtime-Bpx69a8t.js.map → generate.runtime-CRS9C9xX.js.map} +1 -1
  38. package/dist/chunks/{generate.runtime-Bbf2YWaA.js → generate.runtime-CYmjlSQp.js} +3 -3
  39. package/dist/chunks/{generate.runtime-Bbf2YWaA.js.map → generate.runtime-CYmjlSQp.js.map} +1 -1
  40. package/dist/chunks/{generate.runtime-D1uQBjeg.js → generate.runtime-CtS6qa_1.js} +76 -76
  41. package/dist/chunks/{generate.runtime-D1uQBjeg.js.map → generate.runtime-CtS6qa_1.js.map} +1 -1
  42. package/dist/chunks/{generate.runtime-Cudp67b-.js → generate.runtime-CtzHFod-.js} +8 -8
  43. package/dist/chunks/{generate.runtime-Cudp67b-.js.map → generate.runtime-CtzHFod-.js.map} +1 -1
  44. package/dist/chunks/{generate.runtime-D1wqmaXU.js → generate.runtime-D9t6eaQd.js} +5 -5
  45. package/dist/chunks/{generate.runtime-D1wqmaXU.js.map → generate.runtime-D9t6eaQd.js.map} +1 -1
  46. package/dist/chunks/{generate.runtime-D8RXOVVA.js → generate.runtime-DBG6kEKb.js} +6 -6
  47. package/dist/chunks/{generate.runtime-D8RXOVVA.js.map → generate.runtime-DBG6kEKb.js.map} +1 -1
  48. package/dist/chunks/{generate.runtime-DFG2C9gc.js → generate.runtime-DfqzMG8Z.js} +6 -6
  49. package/dist/chunks/generate.runtime-DfqzMG8Z.js.map +1 -0
  50. package/dist/chunks/{generate.runtime-CUgleG0U.js → generate.runtime-Di0p-J8l.js} +4 -4
  51. package/dist/chunks/{generate.runtime-CUgleG0U.js.map → generate.runtime-Di0p-J8l.js.map} +1 -1
  52. package/dist/chunks/{generate.runtime-CrAHzaEW.js → generate.runtime-DsLlDfIo.js} +8 -8
  53. package/dist/chunks/{generate.runtime-CrAHzaEW.js.map → generate.runtime-DsLlDfIo.js.map} +1 -1
  54. package/dist/chunks/{generate.runtime-DFDFxHih.js → generate.runtime-EokncTLy.js} +6 -6
  55. package/dist/chunks/{generate.runtime-DFDFxHih.js.map → generate.runtime-EokncTLy.js.map} +1 -1
  56. package/dist/chunks/{generate.runtime-D_JOcL6A.js → generate.runtime-P8IVwJLB.js} +23 -17
  57. package/dist/chunks/{generate.runtime-D_JOcL6A.js.map → generate.runtime-P8IVwJLB.js.map} +1 -1
  58. package/dist/chunks/{generate.runtime-CZALdXt6.js → generate.runtime-a5PXS1Kd.js} +3 -3
  59. package/dist/chunks/{generate.runtime-CZALdXt6.js.map → generate.runtime-a5PXS1Kd.js.map} +1 -1
  60. package/dist/chunks/{generate.runtime-DPzrDUU7.js → generate.runtime-qZhYdFI1.js} +9 -9
  61. package/dist/chunks/{generate.runtime-DPzrDUU7.js.map → generate.runtime-qZhYdFI1.js.map} +1 -1
  62. package/dist/chunks/{logger-BpgCb-ZG.js → logger-CQONztPm.js} +1 -1
  63. package/dist/chunks/{logger-BpgCb-ZG.js.map → logger-CQONztPm.js.map} +1 -1
  64. package/dist/chunks/{modify-file-DE7tPADZ.js → modify-file-PVKmDJHk.js} +2 -2
  65. package/dist/chunks/{modify-file-DE7tPADZ.js.map → modify-file-PVKmDJHk.js.map} +1 -1
  66. package/dist/chunks/modify-svelte-config-remote-CDKs_Qi0.js +44 -0
  67. package/dist/chunks/modify-svelte-config-remote-CDKs_Qi0.js.map +1 -0
  68. package/dist/chunks/{modify-utils-CZ9Auvp9.js → modify-utils-Cw-on_cL.js} +13 -13
  69. package/dist/chunks/{modify-utils-CZ9Auvp9.js.map → modify-utils-Cw-on_cL.js.map} +1 -1
  70. package/dist/chunks/{nav-user-_VheJA6n.js → nav-user-CndUO69x.js} +1 -1
  71. package/dist/chunks/nav-user-CndUO69x.js.map +1 -0
  72. package/dist/chunks/{pocketbase-D7GjPuNu.js → pocketbase-BbFvZ4HI.js} +2 -2
  73. package/dist/chunks/{pocketbase-D7GjPuNu.js.map → pocketbase-BbFvZ4HI.js.map} +1 -1
  74. package/dist/chunks/{pocketbase-Bj-cW2Zl.js → pocketbase-C5GS-Dh5.js} +1 -1
  75. package/dist/chunks/{pocketbase-Bj-cW2Zl.js.map → pocketbase-C5GS-Dh5.js.map} +1 -1
  76. package/dist/chunks/{pocketbase-Dm2SF3vM.js → pocketbase-DpudAAmd.js} +1 -1
  77. package/dist/chunks/{pocketbase-Dm2SF3vM.js.map → pocketbase-DpudAAmd.js.map} +1 -1
  78. package/dist/chunks/{shared-C4wJ9sb0.js → shared-C4-NNykV.js} +3 -3
  79. package/dist/chunks/{shared-C4wJ9sb0.js.map → shared-C4-NNykV.js.map} +1 -1
  80. package/dist/chunks/{taggedTemplateLiteral-Bfbldyfk.js → taggedTemplateLiteral-CPUMuLtk.js} +1 -1
  81. package/dist/chunks/{test-setup-C3gvjtTY.js → test-setup-CcD8wSRD.js} +87 -65
  82. package/dist/chunks/test-setup-CcD8wSRD.js.map +1 -0
  83. package/dist/chunks/{ts-morph-helpers-bR0-x04t.js → ts-morph-helpers-Bk82Z2n7.js} +3 -3
  84. package/dist/chunks/{ts-morph-helpers-bR0-x04t.js.map → ts-morph-helpers-Bk82Z2n7.js.map} +1 -1
  85. package/dist/chunks/{util-BNtpm1tP.js → util-Bk7aQQJR.js} +1 -1
  86. package/dist/chunks/{util-BNtpm1tP.js.map → util-Bk7aQQJR.js.map} +1 -1
  87. package/dist/chunks/{write-result-CLSL_F-E.js → write-result-DtTqt0Cs.js} +6 -6
  88. package/dist/chunks/write-result-DtTqt0Cs.js.map +1 -0
  89. package/dist/index.js +406 -360
  90. package/dist/index.js.map +1 -1
  91. package/package.json +8 -8
  92. package/dist/chunks/_server-Cv3bTkG0.js.map +0 -1
  93. package/dist/chunks/generate.runtime-DFG2C9gc.js.map +0 -1
  94. package/dist/chunks/generate.runtime-DjwRKg8K.js.map +0 -1
  95. package/dist/chunks/generate.runtime-M6LNL7Tq.js +0 -197
  96. package/dist/chunks/generate.runtime-M6LNL7Tq.js.map +0 -1
  97. package/dist/chunks/generate2.runtime-yP14iPwX.js.map +0 -1
  98. package/dist/chunks/modify-svelte-config-remote-C3g7Oi6_.js +0 -128
  99. package/dist/chunks/modify-svelte-config-remote-C3g7Oi6_.js.map +0 -1
  100. package/dist/chunks/nav-user-_VheJA6n.js.map +0 -1
  101. package/dist/chunks/test-setup-C3gvjtTY.js.map +0 -1
  102. package/dist/chunks/write-result-CLSL_F-E.js.map +0 -1
@@ -0,0 +1,44 @@
1
+ import { i as e, n as t, r as n } from "./config-target-Co-ij8p3.js";
2
+ //#region src/runtime/modify-svelte-config-remote.ts
3
+ var r = [
4
+ "Enable SvelteKit remote functions and Svelte async in your config",
5
+ "(the sveltekit() plugin arg in vite.config, or svelte.config):",
6
+ "",
7
+ "experimental: { remoteFunctions: true },",
8
+ "compilerOptions: { experimental: { async: true } },"
9
+ ].join("\n"), i = [
10
+ "Enable SvelteKit remote functions and Svelte async by passing config to the",
11
+ "sveltekit() plugin in vite.config.ts:",
12
+ "",
13
+ "import { sveltekit } from '@sveltejs/kit/vite';",
14
+ "import { defineConfig } from 'vite';",
15
+ "",
16
+ "export default defineConfig({",
17
+ " plugins: [",
18
+ " sveltekit({",
19
+ " experimental: { remoteFunctions: true },",
20
+ " compilerOptions: { experimental: { async: true } },",
21
+ " }),",
22
+ " ],",
23
+ "});"
24
+ ].join("\n");
25
+ function a(a) {
26
+ return e(a, {
27
+ notFound: i,
28
+ failed: r
29
+ }, (e) => {
30
+ let r = e.kitContainer();
31
+ if (!r) return !1;
32
+ let i = n(r, "experimental", "{}");
33
+ if (!i) return !1;
34
+ t(i, "remoteFunctions");
35
+ let a = n(e.configObject, "compilerOptions", "{}");
36
+ if (!a) return !1;
37
+ let o = n(a, "experimental", "{}");
38
+ return o ? (t(o, "async"), !0) : !1;
39
+ });
40
+ }
41
+ //#endregion
42
+ export { a as modifySvelteConfigRemote };
43
+
44
+ //# sourceMappingURL=modify-svelte-config-remote-CDKs_Qi0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modify-svelte-config-remote-CDKs_Qi0.js","names":[],"sources":["../../src/runtime/modify-svelte-config-remote.ts"],"sourcesContent":["import {\n ensureBooleanTrue,\n getOrCreateObjectLiteralProperty,\n modifyConfig,\n type ConfigModifyResult,\n} from \"./config-target\";\n\nconst FAILURE_HINT = [\n \"Enable SvelteKit remote functions and Svelte async in your config\",\n \"(the sveltekit() plugin arg in vite.config, or svelte.config):\",\n \"\",\n \"experimental: { remoteFunctions: true },\",\n \"compilerOptions: { experimental: { async: true } },\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Enable SvelteKit remote functions and Svelte async by passing config to the\",\n \"sveltekit() plugin in vite.config.ts:\",\n \"\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { defineConfig } from 'vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [\",\n \" sveltekit({\",\n \" experimental: { remoteFunctions: true },\",\n \" compilerOptions: { experimental: { async: true } },\",\n \" }),\",\n \" ],\",\n \"});\",\n].join(\"\\n\");\n\n/**\n * Enable SvelteKit remote functions (`experimental.remoteFunctions`) and Svelte\n * async (`compilerOptions.experimental.async`) in whichever config the project\n * uses — the inline `sveltekit()` arg in vite.config, or svelte.config.\n *\n * `remoteFunctions` is kit-namespaced (→ `kitContainer()`); `async` is a\n * root-level compiler option (→ `configObject`).\n */\nexport function modifySvelteConfigRemote(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n const kit = target.kitContainer();\n if (!kit) return false;\n const kitExperimental = getOrCreateObjectLiteralProperty(\n kit,\n \"experimental\",\n \"{}\",\n );\n if (!kitExperimental) return false;\n ensureBooleanTrue(kitExperimental, \"remoteFunctions\");\n\n const compilerObj = getOrCreateObjectLiteralProperty(\n target.configObject,\n \"compilerOptions\",\n \"{}\",\n );\n if (!compilerObj) return false;\n const compilerExperimental = getOrCreateObjectLiteralProperty(\n compilerObj,\n \"experimental\",\n \"{}\",\n );\n if (!compilerExperimental) return false;\n ensureBooleanTrue(compilerExperimental, \"async\");\n\n return true;\n },\n );\n}\n"],"mappings":";;AAOA,IAAM,IAAe;CACnB;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAUX,SAAgB,EAAyB,GAAkC;CACzE,OAAO,EACL,GACA;EAAE,UAAU;EAAgB,QAAQ;CAAa,IAChD,MAAW;EACV,IAAM,IAAM,EAAO,aAAa;EAChC,IAAI,CAAC,GAAK,OAAO;EACjB,IAAM,IAAkB,EACtB,GACA,gBACA,IACF;EACA,IAAI,CAAC,GAAiB,OAAO;EAC7B,EAAkB,GAAiB,iBAAiB;EAEpD,IAAM,IAAc,EAClB,EAAO,cACP,mBACA,IACF;EACA,IAAI,CAAC,GAAa,OAAO;EACzB,IAAM,IAAuB,EAC3B,GACA,gBACA,IACF;EAIA,OAHK,KACL,EAAkB,GAAsB,OAAO,GAExC,MAH2B;CAIpC,CACF;AACF"}
@@ -1,11 +1,8 @@
1
- import { t as e } from "./dedent-C4qKBQXh.js";
1
+ import { t as e } from "./dedent-Gq6Krl4n.js";
2
2
  import t from "node:fs";
3
3
  import { Project as n, QuoteKind as r } from "ts-morph";
4
4
  //#region src/runtime/modify-utils.ts
5
5
  var i = e`
6
- Create src/lib/utils.ts with a timeAgo helper:
7
-
8
- ${e`
9
6
  const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [
10
7
  ['year', 60 * 60 * 24 * 365],
11
8
  ['month', 60 * 60 * 24 * 30],
@@ -25,8 +22,11 @@ var i = e`
25
22
  }
26
23
  }
27
24
  }
28
- `}
29
25
  `, a = e`
26
+ Create src/lib/utils.ts with a timeAgo helper:
27
+
28
+ ${i}
29
+ `, o = e`
30
30
  const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [
31
31
  ['year', 60 * 60 * 24 * 365],
32
32
  ['month', 60 * 60 * 24 * 30],
@@ -35,7 +35,7 @@ var i = e`
35
35
  ['minute', 60],
36
36
  ['second', 1]
37
37
  ];
38
- `, o = e`
38
+ `, s = e`
39
39
  export function timeAgo(date: Date | string | number, locale?: string) {
40
40
  const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
41
41
  const diff = (new Date(date).getTime() - Date.now()) / 1000;
@@ -47,23 +47,23 @@ var i = e`
47
47
  }
48
48
  }
49
49
  `;
50
- function s(e) {
50
+ function c(e) {
51
51
  if (!t.existsSync(e)) return {
52
52
  status: "not-found",
53
- message: i
53
+ message: a
54
54
  };
55
- let s = t.readFileSync(e, "utf8"), c = new n({ manipulationSettings: { quoteKind: r.Single } }).addSourceFileAtPath(e), l = c.getFunction("timeAgo") !== void 0 || c.getVariableDeclaration("timeAgo") !== void 0, u = c.getVariableDeclaration("TIME_AGO_UNITS") !== void 0;
55
+ let i = t.readFileSync(e, "utf8"), c = new n({ manipulationSettings: { quoteKind: r.Single } }).addSourceFileAtPath(e), l = c.getFunction("timeAgo") !== void 0 || c.getVariableDeclaration("timeAgo") !== void 0, u = c.getVariableDeclaration("TIME_AGO_UNITS") !== void 0;
56
56
  if (l && u) return {
57
57
  status: "success",
58
58
  changed: !1
59
59
  };
60
60
  let d = [];
61
- return u || d.push(a), l || d.push(o), c.addStatements("\n" + d.join("\n\n") + "\n"), c.saveSync(), {
61
+ return u || d.push(o), l || d.push(s), c.addStatements("\n" + d.join("\n\n") + "\n"), c.saveSync(), {
62
62
  status: "success",
63
- changed: c.getFullText() !== s
63
+ changed: c.getFullText() !== i
64
64
  };
65
65
  }
66
66
  //#endregion
67
- export { s as t };
67
+ export { c as t };
68
68
 
69
- //# sourceMappingURL=modify-utils-CZ9Auvp9.js.map
69
+ //# sourceMappingURL=modify-utils-Cw-on_cL.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modify-utils-CZ9Auvp9.js","names":[],"sources":["../../src/runtime/modify-utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nconst TIME_AGO_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/lib/utils.ts with a timeAgo helper:\n\n ${TIME_AGO_SNIPPET}\n`;\n\nconst UNITS_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n`;\n\nconst FUNCTION_SNIPPET = dedent`\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nexport function modifyUtils(utilsPath: string): ModifyOutcome {\n if (!fs.existsSync(utilsPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(utilsPath, \"utf8\");\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(utilsPath);\n\n const hasTimeAgo =\n sourceFile.getFunction(\"timeAgo\") !== undefined ||\n sourceFile.getVariableDeclaration(\"timeAgo\") !== undefined;\n const hasUnits =\n sourceFile.getVariableDeclaration(\"TIME_AGO_UNITS\") !== undefined;\n\n if (hasTimeAgo && hasUnits) {\n return { status: \"success\", changed: false };\n }\n\n const toAppend: string[] = [];\n if (!hasUnits) toAppend.push(UNITS_SNIPPET);\n if (!hasTimeAgo) toAppend.push(FUNCTION_SNIPPET);\n\n sourceFile.addStatements(\"\\n\" + toAppend.join(\"\\n\\n\") + \"\\n\");\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n"],"mappings":";;;;AA2BA,IAAM,IAAiB,CAAM;;;IAtBJ,CAAM;;;;;;;;;;;;;;;;;;;;EAyBV;GAGf,IAAgB,CAAM;;;;;;;;;GAWtB,IAAmB,CAAM;;;;;;;;;;;;AAa/B,SAAgB,EAAY,GAAkC;AAC5D,KAAI,CAAC,EAAG,WAAW,EAAU,CAC3B,QAAO;EAAE,QAAQ;EAAa,SAAS;EAAgB;CAGzD,IAAM,IAAiB,EAAG,aAAa,GAAW,OAAO,EAInD,IAHU,IAAI,EAAQ,EAC1B,sBAAsB,EAAE,WAAW,EAAU,QAAQ,EACtD,CAAC,CACyB,oBAAoB,EAAU,EAEnD,IACJ,EAAW,YAAY,UAAU,KAAK,KAAA,KACtC,EAAW,uBAAuB,UAAU,KAAK,KAAA,GAC7C,IACJ,EAAW,uBAAuB,iBAAiB,KAAK,KAAA;AAE1D,KAAI,KAAc,EAChB,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAqB,EAAE;AAO7B,QANK,KAAU,EAAS,KAAK,EAAc,EACtC,KAAY,EAAS,KAAK,EAAiB,EAEhD,EAAW,cAAc,OAAO,EAAS,KAAK,OAAO,GAAG,KAAK,EAC7D,EAAW,UAAU,EAEd;EACL,QAAQ;EACR,SAAS,EAAW,aAAa,KAAK;EACvC"}
1
+ {"version":3,"file":"modify-utils-Cw-on_cL.js","names":[],"sources":["../../src/runtime/modify-utils.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../core/types\";\n\nconst TIME_AGO_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/lib/utils.ts with a timeAgo helper:\n\n ${TIME_AGO_SNIPPET}\n`;\n\nconst UNITS_SNIPPET = dedent`\n const TIME_AGO_UNITS: [Intl.RelativeTimeFormatUnit, number][] = [\n ['year', 60 * 60 * 24 * 365],\n ['month', 60 * 60 * 24 * 30],\n ['day', 60 * 60 * 24],\n ['hour', 60 * 60],\n ['minute', 60],\n ['second', 1]\n ];\n`;\n\nconst FUNCTION_SNIPPET = dedent`\n export function timeAgo(date: Date | string | number, locale?: string) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n const diff = (new Date(date).getTime() - Date.now()) / 1000;\n\n for (const [unit, secs] of TIME_AGO_UNITS) {\n if (Math.abs(diff) >= secs || unit === 'second') {\n return rtf.format(Math.round(diff / secs), unit);\n }\n }\n }\n`;\n\nexport function modifyUtils(utilsPath: string): ModifyOutcome {\n if (!fs.existsSync(utilsPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(utilsPath, \"utf8\");\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(utilsPath);\n\n const hasTimeAgo =\n sourceFile.getFunction(\"timeAgo\") !== undefined ||\n sourceFile.getVariableDeclaration(\"timeAgo\") !== undefined;\n const hasUnits =\n sourceFile.getVariableDeclaration(\"TIME_AGO_UNITS\") !== undefined;\n\n if (hasTimeAgo && hasUnits) {\n return { status: \"success\", changed: false };\n }\n\n const toAppend: string[] = [];\n if (!hasUnits) toAppend.push(UNITS_SNIPPET);\n if (!hasTimeAgo) toAppend.push(FUNCTION_SNIPPET);\n\n sourceFile.addStatements(\"\\n\" + toAppend.join(\"\\n\\n\") + \"\\n\");\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n"],"mappings":";;;;AAKA,IAAM,IAAmB,CAAM;;;;;;;;;;;;;;;;;;;;GAsBzB,IAAiB,CAAM;;;IAGzB,EAAiB;GAGf,IAAgB,CAAM;;;;;;;;;GAWtB,IAAmB,CAAM;;;;;;;;;;;;AAa/B,SAAgB,EAAY,GAAkC;CAC5D,IAAI,CAAC,EAAG,WAAW,CAAS,GAC1B,OAAO;EAAE,QAAQ;EAAa,SAAS;CAAe;CAGxD,IAAM,IAAiB,EAAG,aAAa,GAAW,MAAM,GAIlD,IAAa,IAHC,EAAQ,EAC1B,sBAAsB,EAAE,WAAW,EAAU,OAAO,EACtD,CACmB,CAAA,CAAQ,oBAAoB,CAAS,GAElD,IACJ,EAAW,YAAY,SAAS,MAAM,KAAA,KACtC,EAAW,uBAAuB,SAAS,MAAM,KAAA,GAC7C,IACJ,EAAW,uBAAuB,gBAAgB,MAAM,KAAA;CAE1D,IAAI,KAAc,GAChB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAqB,CAAC;CAO5B,OANK,KAAU,EAAS,KAAK,CAAa,GACrC,KAAY,EAAS,KAAK,CAAgB,GAE/C,EAAW,cAAc,OAAO,EAAS,KAAK,MAAM,IAAI,IAAI,GAC5D,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAAS,EAAW,YAAY,MAAM;CACxC;AACF"}
@@ -3,4 +3,4 @@ var e = "import { error } from \"@sveltejs/kit\";\nimport stripe from \"$lib/str
3
3
  //#endregion
4
4
  export { t as n, e as r, n as t };
5
5
 
6
- //# sourceMappingURL=nav-user-_VheJA6n.js.map
6
+ //# sourceMappingURL=nav-user-CndUO69x.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav-user-CndUO69x.js","names":[],"sources":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { n as e, r as t } from "./constants-BMZmCRiI.js";
1
+ import { n as e, r as t } from "./constants-qmioN-7W.js";
2
2
  import { existsSync as n, readFileSync as r, readdirSync as i } from "node:fs";
3
3
  import a from "node:path";
4
4
  import o from "pocketbase";
@@ -103,4 +103,4 @@ async function y(r, i) {
103
103
  //#endregion
104
104
  export { g as getMigrationFile, h as migrationDelay, y as withPocketbase };
105
105
 
106
- //# sourceMappingURL=pocketbase-D7GjPuNu.js.map
106
+ //# sourceMappingURL=pocketbase-BbFvZ4HI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pocketbase-D7GjPuNu.js","names":[],"sources":["../../src/runtime/net.ts","../../src/runtime/pocketbase.ts"],"sourcesContent":["import net from \"node:net\";\n\n// Generate a random port\nexport function randomPort() {\n return Math.floor(Math.random() * 10000) + 10000;\n}\n\n// Wait for the port to be available\nexport function waitForPort(\n port: number,\n host: string,\n maxAttempts = 10,\n): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryConnect = () => {\n attempts++;\n\n const socket = new net.Socket();\n\n const onError = () => {\n socket.destroy();\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for port ${port} to be available`),\n );\n return;\n }\n\n setTimeout(tryConnect, 500);\n };\n\n socket.once(\"error\", onError);\n\n socket.connect(port, host, () => {\n socket.destroy();\n resolve();\n });\n };\n\n tryConnect();\n });\n}\n\n// Wait for the health check to be successful\nexport function waitForHealth(url: string, maxAttempts = 10): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryHealth = async () => {\n attempts++;\n\n try {\n const response = await fetch(`${url}/api/health`);\n if (response.status === 200) {\n resolve();\n return;\n }\n } catch {\n // Ignore fetch errors and continue retrying\n }\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for health check at ${url}/api/health`),\n );\n return;\n }\n\n setTimeout(tryHealth, 500);\n };\n\n tryHealth();\n });\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport PocketBase from \"pocketbase\";\nimport { detect } from \"package-manager-detector\";\nimport { resolveCommand } from \"package-manager-detector/commands\";\nimport spawn from \"cross-spawn\";\nimport { randomPort, waitForPort, waitForHealth } from \"./net\";\nimport type { Options } from \"../core/types\";\nimport { DATA_DIR, MIGRATIONS_DIR } from \"../core/constants\";\n\n/**\n * PocketBase names migration files with a 1-second-resolution Unix timestamp\n * (e.g. `1776099881_created_users.js`). Two schema operations issued in the\n * same wall-clock second produce files that sort alphabetically by their\n * action/collection suffix — which reverses the intended order whenever a\n * later migration depends on an earlier one. Wait out the full second between\n * migration-producing calls so the timestamps stay distinct.\n */\nconst MIGRATION_DELAY_MS = 1100;\n\nexport function migrationDelay(): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, MIGRATION_DELAY_MS));\n}\n\nexport function getMigrationFile(\n collectionName: string,\n action: \"created\" | \"deleted\" | \"updated\",\n options: Options,\n): string | undefined {\n const ending = `${action}_${collectionName}.js`;\n\n // find last file with ending in migrations dir\n const migrationFiles = readdirSync(\n path.join(options.root, MIGRATIONS_DIR),\n ).filter((file) => file.endsWith(ending));\n\n const migrationFile = migrationFiles.sort().pop();\n\n if (!migrationFile) {\n return undefined;\n }\n\n return path.join(options.root, MIGRATIONS_DIR, migrationFile);\n}\n\nexport function getPocketbaseMetadata(cwd: string): {\n pocketbaseUrl: string;\n vitePort: number;\n} | null {\n const metadataPath = path.join(\n cwd,\n \"node_modules\",\n \".vite\",\n \"_pocketbase_metadata.json\",\n );\n if (existsSync(metadataPath)) {\n return JSON.parse(readFileSync(metadataPath, \"utf8\"));\n }\n return null;\n}\n\nexport async function authWithRetries(\n pb: PocketBase,\n email: string,\n password: string,\n) {\n // Retry authentication up to 3 times with 100ms backoff\n let authSuccess = false;\n for (let attempt = 1; attempt <= 3; attempt++) {\n try {\n await pb.collection(\"_superusers\").authWithPassword(email, password);\n authSuccess = true;\n break;\n } catch {\n if (attempt < 3) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n }\n\n if (!authSuccess) {\n throw new Error(\n \"Failed to authenticate with PocketBase. Check your superuser credentials.\",\n );\n }\n}\n\nexport async function withPocketbase(\n cwd: string,\n fn: (pb: PocketBase) => Promise<void>,\n) {\n const dir = path.join(cwd, DATA_DIR);\n const migrationsDir = path.join(cwd, MIGRATIONS_DIR);\n const host = \"localhost\";\n\n if (!existsSync(dir)) {\n throw new Error(\"PocketBase data directory does not exist\");\n }\n\n // First check if the server is already running by reading node_modules/.vite/_pocketbase_metadata.json\n const metadata = getPocketbaseMetadata(cwd);\n if (metadata) {\n if (metadata.pocketbaseUrl) {\n const pb = new PocketBase(metadata.pocketbaseUrl);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n return;\n }\n }\n\n const port = randomPort();\n const commandArgs = [\n \"pocketbase-server\",\n \"serve\",\n \"--dir\",\n dir,\n \"--migrationsDir\",\n migrationsDir,\n \"--http\",\n `${host}:${port}`,\n ];\n\n const packageManager = (await detect({ cwd }))?.name ?? \"npm\";\n const { command, args } = resolveCommand(\n packageManager,\n \"execute\",\n commandArgs,\n )!;\n\n // adding --yes as the first parameter helps avoiding the \"Need to install the following packages:\" message\n if (packageManager === \"npm\") args.unshift(\"--yes\");\n\n // Start the PocketBase server process\n const serverProcess = spawn(command, args, {\n stdio: \"ignore\",\n });\n\n try {\n // Wait for the server to be ready\n await waitForPort(port, host);\n await waitForHealth(`http://${host}:${port}`);\n\n const pb = new PocketBase(`http://${host}:${port}`);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n } finally {\n // Ensure we always clean up the process\n serverProcess.kill();\n }\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB,IAAa;AAC3B,QAAO,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAM,GAAG;;AAI7C,SAAgB,EACd,GACA,GACA,IAAc,IACC;AACf,QAAO,IAAI,SAAS,GAAS,MAAW;EACtC,IAAI,IAAW,GAET,UAAmB;AACvB;GAEA,IAAM,IAAS,IAAI,EAAI,QAAQ;AAiB/B,GAFA,EAAO,KAAK,eAbU;AAGpB,QAFA,EAAO,SAAS,EAEZ,MAAa,GAAa;AAC5B,OACE,gBAAI,MAAM,8BAA8B,EAAK,kBAAkB,CAChE;AACD;;AAGF,eAAW,GAAY,IAAI;KAGA,EAE7B,EAAO,QAAQ,GAAM,SAAY;AAE/B,IADA,EAAO,SAAS,EAChB,GAAS;KACT;;AAGJ,KAAY;GACZ;;AAIJ,SAAgB,EAAc,GAAa,IAAc,IAAmB;AAC1E,QAAO,IAAI,SAAS,GAAS,MAAW;EACtC,IAAI,IAAW,GAET,IAAY,YAAY;AAC5B;AAEA,OAAI;AAEF,SADiB,MAAM,MAAM,GAAG,EAAI,aAAa,EACpC,WAAW,KAAK;AAC3B,QAAS;AACT;;WAEI;AAIR,OAAI,MAAa,GAAa;AAC5B,MACE,gBAAI,MAAM,yCAAyC,EAAI,aAAa,CACrE;AACD;;AAGF,cAAW,GAAW,IAAI;;AAG5B,KAAW;GACX;;;;ACzDJ,IAAM,IAAqB;AAE3B,SAAgB,IAAgC;AAC9C,QAAO,IAAI,SAAS,MAAY,WAAW,GAAS,EAAmB,CAAC;;AAG1E,SAAgB,EACd,GACA,GACA,GACoB;CACpB,IAAM,IAAS,GAAG,EAAO,GAAG,EAAe,MAOrC,IAJiB,EACrB,EAAK,KAAK,EAAQ,MAAM,EAAe,CACxC,CAAC,QAAQ,MAAS,EAAK,SAAS,EAAO,CAAC,C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AEF,KAAI;AAGF,EADA,MAAM,EAAY,GAAM,EAAK,EAC7B,MAAM,EAAc,UAAU,EAAK,GAAG,IAAO;EAE7C,IAAM,IAAK,IAAI,EAAW,UAAU,EAAK,GAAG,IAAO;AAMnD,EALA,MAAM,EACJ,GACA,QAAQ,IAAI,4BACZ,QAAQ,IAAI,8BACb,EACD,MAAM,EAAG,EAAG;WACJ;AAER,IAAc,MAAM"}
1
+ {"version":3,"file":"pocketbase-BbFvZ4HI.js","names":[],"sources":["../../src/runtime/net.ts","../../src/runtime/pocketbase.ts"],"sourcesContent":["import net from \"node:net\";\n\n// Generate a random port\nexport function randomPort() {\n return Math.floor(Math.random() * 10000) + 10000;\n}\n\n// Wait for the port to be available\nexport function waitForPort(\n port: number,\n host: string,\n maxAttempts = 10,\n): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryConnect = () => {\n attempts++;\n\n const socket = new net.Socket();\n\n const onError = () => {\n socket.destroy();\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for port ${port} to be available`),\n );\n return;\n }\n\n setTimeout(tryConnect, 500);\n };\n\n socket.once(\"error\", onError);\n\n socket.connect(port, host, () => {\n socket.destroy();\n resolve();\n });\n };\n\n tryConnect();\n });\n}\n\n// Wait for the health check to be successful\nexport function waitForHealth(url: string, maxAttempts = 10): Promise<void> {\n return new Promise((resolve, reject) => {\n let attempts = 0;\n\n const tryHealth = async () => {\n attempts++;\n\n try {\n const response = await fetch(`${url}/api/health`);\n if (response.status === 200) {\n resolve();\n return;\n }\n } catch {\n // Ignore fetch errors and continue retrying\n }\n\n if (attempts === maxAttempts) {\n reject(\n new Error(`Timed out waiting for health check at ${url}/api/health`),\n );\n return;\n }\n\n setTimeout(tryHealth, 500);\n };\n\n tryHealth();\n });\n}\n","import { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport PocketBase from \"pocketbase\";\nimport { detect } from \"package-manager-detector\";\nimport { resolveCommand } from \"package-manager-detector/commands\";\nimport spawn from \"cross-spawn\";\nimport { randomPort, waitForPort, waitForHealth } from \"./net\";\nimport type { Options } from \"../core/types\";\nimport { DATA_DIR, MIGRATIONS_DIR } from \"../core/constants\";\n\n/**\n * PocketBase names migration files with a 1-second-resolution Unix timestamp\n * (e.g. `1776099881_created_users.js`). Two schema operations issued in the\n * same wall-clock second produce files that sort alphabetically by their\n * action/collection suffix — which reverses the intended order whenever a\n * later migration depends on an earlier one. Wait out the full second between\n * migration-producing calls so the timestamps stay distinct.\n */\nconst MIGRATION_DELAY_MS = 1100;\n\nexport function migrationDelay(): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, MIGRATION_DELAY_MS));\n}\n\nexport function getMigrationFile(\n collectionName: string,\n action: \"created\" | \"deleted\" | \"updated\",\n options: Options,\n): string | undefined {\n const ending = `${action}_${collectionName}.js`;\n\n // find last file with ending in migrations dir\n const migrationFiles = readdirSync(\n path.join(options.root, MIGRATIONS_DIR),\n ).filter((file) => file.endsWith(ending));\n\n const migrationFile = migrationFiles.sort().pop();\n\n if (!migrationFile) {\n return undefined;\n }\n\n return path.join(options.root, MIGRATIONS_DIR, migrationFile);\n}\n\nexport function getPocketbaseMetadata(cwd: string): {\n pocketbaseUrl: string;\n vitePort: number;\n} | null {\n const metadataPath = path.join(\n cwd,\n \"node_modules\",\n \".vite\",\n \"_pocketbase_metadata.json\",\n );\n if (existsSync(metadataPath)) {\n return JSON.parse(readFileSync(metadataPath, \"utf8\"));\n }\n return null;\n}\n\nexport async function authWithRetries(\n pb: PocketBase,\n email: string,\n password: string,\n) {\n // Retry authentication up to 3 times with 100ms backoff\n let authSuccess = false;\n for (let attempt = 1; attempt <= 3; attempt++) {\n try {\n await pb.collection(\"_superusers\").authWithPassword(email, password);\n authSuccess = true;\n break;\n } catch {\n if (attempt < 3) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n }\n }\n\n if (!authSuccess) {\n throw new Error(\n \"Failed to authenticate with PocketBase. Check your superuser credentials.\",\n );\n }\n}\n\nexport async function withPocketbase(\n cwd: string,\n fn: (pb: PocketBase) => Promise<void>,\n) {\n const dir = path.join(cwd, DATA_DIR);\n const migrationsDir = path.join(cwd, MIGRATIONS_DIR);\n const host = \"localhost\";\n\n if (!existsSync(dir)) {\n throw new Error(\"PocketBase data directory does not exist\");\n }\n\n // First check if the server is already running by reading node_modules/.vite/_pocketbase_metadata.json\n const metadata = getPocketbaseMetadata(cwd);\n if (metadata) {\n if (metadata.pocketbaseUrl) {\n const pb = new PocketBase(metadata.pocketbaseUrl);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n return;\n }\n }\n\n const port = randomPort();\n const commandArgs = [\n \"pocketbase-server\",\n \"serve\",\n \"--dir\",\n dir,\n \"--migrationsDir\",\n migrationsDir,\n \"--http\",\n `${host}:${port}`,\n ];\n\n const packageManager = (await detect({ cwd }))?.name ?? \"npm\";\n const { command, args } = resolveCommand(\n packageManager,\n \"execute\",\n commandArgs,\n )!;\n\n // adding --yes as the first parameter helps avoiding the \"Need to install the following packages:\" message\n if (packageManager === \"npm\") args.unshift(\"--yes\");\n\n // Start the PocketBase server process\n const serverProcess = spawn(command, args, {\n stdio: \"ignore\",\n });\n\n try {\n // Wait for the server to be ready\n await waitForPort(port, host);\n await waitForHealth(`http://${host}:${port}`);\n\n const pb = new PocketBase(`http://${host}:${port}`);\n await authWithRetries(\n pb,\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n );\n await fn(pb);\n } finally {\n // Ensure we always clean up the process\n serverProcess.kill();\n }\n}\n"],"mappings":";;;;;;;;;AAGA,SAAgB,IAAa;CAC3B,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,GAAK,IAAI;AAC7C;AAGA,SAAgB,EACd,GACA,GACA,IAAc,IACC;CACf,OAAO,IAAI,SAAS,GAAS,M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,GAAM;EAMlD,AALA,MAAM,EACJ,GACA,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BACd,GACA,MAAM,EAAG,CAAE;CACb,UAAU;EAER,EAAc,KAAK;CACrB;AACF"}
@@ -44,4 +44,4 @@ var e = [
44
44
  //#endregion
45
45
  export { e as t };
46
46
 
47
- //# sourceMappingURL=pocketbase-Bj-cW2Zl.js.map
47
+ //# sourceMappingURL=pocketbase-C5GS-Dh5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pocketbase-Bj-cW2Zl.js","names":[],"sources":["../../src/patterns/enable/teams/runtime/pocketbase.ts"],"sourcesContent":["import type { CollectionRulesPatch } from \"../../../../core/types\";\n\n/** Applied after all team collections are created (create-time rules are omitted). */\nexport const TEAM_RULE_PATCHES: CollectionRulesPatch[] = [\n {\n collectionName: \"teams\",\n listRule:\n \"team_memberships_via_team.user ?= @request.auth.id || owner = @request.auth.id\",\n viewRule: '@request.auth.id != \"\"',\n createRule: \"owner = @request.auth.id\",\n updateRule: \"owner = @request.auth.id\",\n deleteRule: \"owner = @request.auth.id\",\n },\n {\n collectionName: \"team_memberships\",\n listRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n deleteRule:\n \"user = @request.auth.id || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_users\",\n listRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n {\n collectionName: \"team_invites\",\n listRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n viewRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n createRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n updateRule: null,\n deleteRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_invite_links\",\n listRule: null,\n viewRule: '@request.auth.id != \"\"',\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n];\n"],"mappings":";AAGA,IAAa,IAA4C;CACvD;EACE,gBAAgB;EAChB,UACE;EACF,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,YAAY;EACb;CACD;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YAAY;EACZ,YACE;EACF,YACE;EACH;CACD;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YAAY;EACZ,YAAY;EACZ,YAAY;EACb;CACD;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YACE;EACF,YAAY;EACZ,YACE;EACH;CACD;EACE,gBAAgB;EAChB,UAAU;EACV,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,YAAY;EACb;CACF"}
1
+ {"version":3,"file":"pocketbase-C5GS-Dh5.js","names":[],"sources":["../../src/patterns/enable/teams/runtime/pocketbase.ts"],"sourcesContent":["import type { CollectionRulesPatch } from \"../../../../core/types\";\n\n/** Applied after all team collections are created (create-time rules are omitted). */\nexport const TEAM_RULE_PATCHES: CollectionRulesPatch[] = [\n {\n collectionName: \"teams\",\n listRule:\n \"team_memberships_via_team.user ?= @request.auth.id || owner = @request.auth.id\",\n viewRule: '@request.auth.id != \"\"',\n createRule: \"owner = @request.auth.id\",\n updateRule: \"owner = @request.auth.id\",\n deleteRule: \"owner = @request.auth.id\",\n },\n {\n collectionName: \"team_memberships\",\n listRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"user = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n deleteRule:\n \"user = @request.auth.id || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_users\",\n listRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n viewRule:\n \"id = @request.auth.id || team.team_memberships_via_team.user ?= @request.auth.id\",\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n {\n collectionName: \"team_invites\",\n listRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n viewRule:\n \"email = @request.auth.email || ((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n createRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n updateRule: null,\n deleteRule:\n \"((team.team_memberships_via_team.role ?= 'owner' || team.team_memberships_via_team.role ?= 'admin') && team.team_memberships_via_team.user ?= @request.auth.id)\",\n },\n {\n collectionName: \"team_invite_links\",\n listRule: null,\n viewRule: '@request.auth.id != \"\"',\n createRule: null,\n updateRule: null,\n deleteRule: null,\n },\n];\n"],"mappings":";AAGA,IAAa,IAA4C;CACvD;EACE,gBAAgB;EAChB,UACE;EACF,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,YAAY;CACd;CACA;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YAAY;EACZ,YACE;EACF,YACE;CACJ;CACA;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YAAY;EACZ,YAAY;EACZ,YAAY;CACd;CACA;EACE,gBAAgB;EAChB,UACE;EACF,UACE;EACF,YACE;EACF,YAAY;EACZ,YACE;CACJ;CACA;EACE,gBAAgB;EAChB,UAAU;EACV,UAAU;EACV,YAAY;EACZ,YAAY;EACZ,YAAY;CACd;AACF"}
@@ -10,4 +10,4 @@ var e = [{
10
10
  //#endregion
11
11
  export { e as t };
12
12
 
13
- //# sourceMappingURL=pocketbase-Dm2SF3vM.js.map
13
+ //# sourceMappingURL=pocketbase-DpudAAmd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pocketbase-Dm2SF3vM.js","names":[],"sources":["../../src/patterns/enable/notifications/runtime/pocketbase.ts"],"sourcesContent":["import type { CollectionRulesPatch } from \"../../../../core/types\";\n\n/**\n * Applied after the notifications collection is created. The update rule\n * restricts non-superuser writes to flipping `read`: any attempt to set\n * `user`, `title`, or `body` in the request body is rejected, so users can\n * mark their own notifications read but can't tamper with content.\n */\nexport const NOTIFICATION_RULE_PATCHES: CollectionRulesPatch[] = [\n {\n collectionName: \"notifications\",\n listRule: \"user = @request.auth.id\",\n viewRule: \"user = @request.auth.id\",\n createRule: null,\n updateRule:\n \"user = @request.auth.id && @request.body.user:isset = false && @request.body.title:isset = false && @request.body.body:isset = false\",\n deleteRule: \"user = @request.auth.id\",\n },\n];\n"],"mappings":";AAQA,IAAa,IAAoD,CAC/D;CACE,gBAAgB;CAChB,UAAU;CACV,UAAU;CACV,YAAY;CACZ,YACE;CACF,YAAY;CACb,CACF"}
1
+ {"version":3,"file":"pocketbase-DpudAAmd.js","names":[],"sources":["../../src/patterns/enable/notifications/runtime/pocketbase.ts"],"sourcesContent":["import type { CollectionRulesPatch } from \"../../../../core/types\";\n\n/**\n * Applied after the notifications collection is created. The update rule\n * restricts non-superuser writes to flipping `read`: any attempt to set\n * `user`, `title`, or `body` in the request body is rejected, so users can\n * mark their own notifications read but can't tamper with content.\n */\nexport const NOTIFICATION_RULE_PATCHES: CollectionRulesPatch[] = [\n {\n collectionName: \"notifications\",\n listRule: \"user = @request.auth.id\",\n viewRule: \"user = @request.auth.id\",\n createRule: null,\n updateRule:\n \"user = @request.auth.id && @request.body.user:isset = false && @request.body.title:isset = false && @request.body.body:isset = false\",\n deleteRule: \"user = @request.auth.id\",\n },\n];\n"],"mappings":";AAQA,IAAa,IAAoD,CAC/D;CACE,gBAAgB;CAChB,UAAU;CACV,UAAU;CACV,YAAY;CACZ,YACE;CACF,YAAY;AACd,CACF"}
@@ -1,4 +1,4 @@
1
- import { i as e } from "./util-BNtpm1tP.js";
1
+ import { i as e } from "./util-Bk7aQQJR.js";
2
2
  //#region src/patterns/destroy/shared.ts
3
3
  function t(t) {
4
4
  return {
@@ -15,7 +15,7 @@ async function n(e, t) {
15
15
  exists: !0,
16
16
  rowCount: 0
17
17
  }));
18
- let { withPocketbase: n } = await import("./pocketbase-D7GjPuNu.js"), { planCollectionDrops: r } = await import("./collections-BwO27pJg.js"), i = [];
18
+ let { withPocketbase: n } = await import("./pocketbase-BbFvZ4HI.js"), { planCollectionDrops: r } = await import("./collections-DZOoJLVj.js"), i = [];
19
19
  return await n(t.root, async (t) => {
20
20
  let n = await r(t, e);
21
21
  i.push(...n);
@@ -24,4 +24,4 @@ async function n(e, t) {
24
24
  //#endregion
25
25
  export { t as n, n as t };
26
26
 
27
- //# sourceMappingURL=shared-C4wJ9sb0.js.map
27
+ //# sourceMappingURL=shared-C4-NNykV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-C4wJ9sb0.js","names":[],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgB,EAAc,GAAoB;AAChD,QAAO;EACL;EACA,UAAU,EAAiB,EAAK;EAChC,SAAS;EACT,QAAQ;EACT;;AAQH,eAAsB,EACpB,GACA,GAC+B;AAC/B,KAAI,EAAgB,WAAW,EAAG,QAAO,EAAE;AAE3C,KAAI,EAAQ,QAAQ,UAClB,QAAO,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;EACX,EAAE;CAGL,IAAM,EAAE,sBAAmB,MAAM,OAAO,6BAClC,EAAE,2BAAwB,MAAM,OAAO,8BACvC,IAA8B,EAAE;AAKtC,QAJA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAM,IAAQ,MAAM,EAAoB,GAAI,EAAgB;AAC5D,IAAM,KAAK,GAAG,EAAM;GACpB,EACK"}
1
+ {"version":3,"file":"shared-C4-NNykV.js","names":[],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgB,EAAc,GAAoB;CAChD,OAAO;EACL;EACA,UAAU,EAAiB,CAAI;EAC/B,SAAS;EACT,QAAQ;CACV;AACF;AAOA,eAAsB,EACpB,GACA,GAC+B;CAC/B,IAAI,EAAgB,WAAW,GAAG,OAAO,CAAC;CAE1C,IAAI,EAAQ,QAAQ,WAClB,OAAO,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;CACZ,EAAE;CAGJ,IAAM,EAAE,sBAAmB,MAAM,OAAO,6BAClC,EAAE,2BAAwB,MAAM,OAAO,8BACvC,IAA8B,CAAC;CAKrC,OAJA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAM,IAAQ,MAAM,EAAoB,GAAI,CAAe;EAC3D,EAAM,KAAK,GAAG,CAAK;CACrB,CAAC,GACM;AACT"}
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.124.0/helpers/taggedTemplateLiteral.js
1
+ //#region \0@oxc-project+runtime@0.146.0/helpers/esm/taggedTemplateLiteral.js
2
2
  function e(e, t) {
3
3
  return t ||= e.slice(0), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
4
4
  }
@@ -1,62 +1,84 @@
1
- import { t as e } from "./dedent-C4qKBQXh.js";
2
- import t from "node:fs";
3
- import { Project as n, SyntaxKind as r } from "ts-morph";
1
+ import { t as e } from "./dedent-Gq6Krl4n.js";
2
+ import { o as t, s as n } from "./config-target-Co-ij8p3.js";
3
+ import r from "node:fs";
4
+ import { SyntaxKind as i } from "ts-morph";
4
5
  //#region src/patterns/enable/backend/modifies/svelte-config.ts
5
- var i = e`
6
- Switch the SvelteKit adapter to @sveltejs/adapter-auto in svelte.config.js:
6
+ var a = e`
7
+ Switch the SvelteKit adapter to @sveltejs/adapter-auto:
7
8
 
8
9
  import adapter from '@sveltejs/adapter-auto';
9
10
 
10
- export default {
11
- kit: {
12
- adapter: adapter()
13
- }
14
- };
15
- `, a = e`
16
- Create svelte.config.js using @sveltejs/adapter-auto.
11
+ // ...
12
+ adapter: adapter()
13
+ `, o = e`
14
+ Configure @sveltejs/adapter-auto via the sveltekit() plugin in vite.config.ts.
17
15
  `;
18
- function o(e) {
19
- if (!t.existsSync(e)) return {
20
- status: "not-found",
21
- message: a
16
+ function s(e) {
17
+ return e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "@sveltejs/adapter-static" || e.getModuleSpecifierValue() === "@sveltejs/adapter-auto");
18
+ }
19
+ function c(e) {
20
+ return e.getDescendantsOfKind(i.CallExpression).filter((e) => e.getExpression().getText() === "adapter");
21
+ }
22
+ function l(e) {
23
+ let r = t(e, {
24
+ notFound: o,
25
+ failed: a
26
+ });
27
+ if (r.status !== "resolved") return {
28
+ filePath: r.filePath,
29
+ outcome: {
30
+ status: r.status,
31
+ message: r.message
32
+ }
22
33
  };
23
- let o = t.readFileSync(e, "utf8"), s = new n({ useInMemoryFileSystem: !1 }).addSourceFileAtPath(e), c = s.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "@sveltejs/adapter-static" || e.getModuleSpecifierValue() === "@sveltejs/adapter-auto");
24
- if (!c) return {
25
- status: "failed",
26
- message: i
34
+ let { target: i } = r, l = s(i.sourceFile);
35
+ if (!l) return {
36
+ filePath: i.filePath,
37
+ outcome: {
38
+ status: "failed",
39
+ message: a
40
+ }
27
41
  };
28
- c.getModuleSpecifierValue() === "@sveltejs/adapter-static" && c.setModuleSpecifier("@sveltejs/adapter-auto");
29
- let l = s.getDescendantsOfKind(r.CallExpression).filter((e) => e.getExpression().getText() === "adapter");
30
- for (let e of l) {
42
+ l.getModuleSpecifierValue() === "@sveltejs/adapter-static" && l.setModuleSpecifier("@sveltejs/adapter-auto");
43
+ for (let e of c(i.sourceFile)) {
31
44
  let t = e.getArguments();
32
45
  for (let n = t.length - 1; n >= 0; n--) e.removeArgument(n);
33
46
  }
34
- return s.formatText(), s.saveSync(), {
35
- status: "success",
36
- changed: s.getFullText() !== o
47
+ return {
48
+ filePath: i.filePath,
49
+ outcome: n(i)
37
50
  };
38
51
  }
39
- function s(e) {
40
- if (!t.existsSync(e)) return {
41
- status: "success",
42
- changed: !1
52
+ function u(e) {
53
+ let r = t(e, {
54
+ notFound: o,
55
+ failed: a
56
+ });
57
+ if (r.status !== "resolved") return {
58
+ filePath: r.filePath,
59
+ outcome: {
60
+ status: "success",
61
+ changed: !1
62
+ }
43
63
  };
44
- let i = t.readFileSync(e, "utf8"), a = new n({ useInMemoryFileSystem: !1 }).addSourceFileAtPath(e), o = a.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "@sveltejs/adapter-auto" || e.getModuleSpecifierValue() === "@sveltejs/adapter-static");
45
- if (!o) return {
46
- status: "success",
47
- changed: !1
64
+ let { target: i } = r, l = s(i.sourceFile);
65
+ if (!l) return {
66
+ filePath: i.filePath,
67
+ outcome: {
68
+ status: "success",
69
+ changed: !1
70
+ }
48
71
  };
49
- o.getModuleSpecifierValue() === "@sveltejs/adapter-auto" && o.setModuleSpecifier("@sveltejs/adapter-static");
50
- let s = a.getDescendantsOfKind(r.CallExpression).filter((e) => e.getExpression().getText() === "adapter");
51
- for (let e of s) e.getArguments().length === 0 && e.addArgument("{ fallback: '200.html' }");
52
- return a.formatText(), a.saveSync(), {
53
- status: "success",
54
- changed: a.getFullText() !== i
72
+ l.getModuleSpecifierValue() === "@sveltejs/adapter-auto" && l.setModuleSpecifier("@sveltejs/adapter-static");
73
+ for (let e of c(i.sourceFile)) e.getArguments().length === 0 && e.addArgument("{ fallback: '200.html' }");
74
+ return {
75
+ filePath: i.filePath,
76
+ outcome: n(i)
55
77
  };
56
78
  }
57
79
  //#endregion
58
80
  //#region src/patterns/enable/backend/modifies/gitignore.ts
59
- var c = "# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n", l = e`
81
+ var d = "# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n", f = e`
60
82
  Create a .gitignore at the project root with the PocketBase block:
61
83
 
62
84
  # PocketBase
@@ -65,44 +87,44 @@ var c = "# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n",
65
87
  !/data/seeds
66
88
  !/data/hooks
67
89
  `;
68
- function u(e) {
69
- if (!t.existsSync(e)) return {
90
+ function p(e) {
91
+ if (!r.existsSync(e)) return {
70
92
  status: "not-found",
71
- message: l
93
+ message: f
72
94
  };
73
- let n = t.readFileSync(e, "utf8");
74
- if (n.includes("# PocketBase") && n.includes("/data/*")) return {
95
+ let t = r.readFileSync(e, "utf8");
96
+ if (t.includes("# PocketBase") && t.includes("/data/*")) return {
75
97
  status: "success",
76
98
  changed: !1
77
99
  };
78
- let r = n + (n.endsWith("\n") ? "\n" : "\n\n") + c;
79
- return t.writeFileSync(e, r, "utf8"), {
100
+ let n = t + (t.endsWith("\n") ? "\n" : "\n\n") + d;
101
+ return r.writeFileSync(e, n, "utf8"), {
80
102
  status: "success",
81
103
  changed: !0
82
104
  };
83
105
  }
84
- function d(e) {
85
- if (!t.existsSync(e)) return {
106
+ function m(e) {
107
+ if (!r.existsSync(e)) return {
86
108
  status: "success",
87
109
  changed: !1
88
110
  };
89
- let n = t.readFileSync(e, "utf8");
90
- if (!n.includes("# PocketBase")) return {
111
+ let t = r.readFileSync(e, "utf8");
112
+ if (!t.includes("# PocketBase")) return {
91
113
  status: "success",
92
114
  changed: !1
93
115
  };
94
- let r = n.replace(/\n*# PocketBase\n\/data\/\*\n!\/data\/fixtures\n!\/data\/seeds\n!\/data\/hooks\n?/, "\n").replace(/\n{3,}$/, "\n");
95
- return r === n ? {
116
+ let n = t.replace(/\n*# PocketBase\n\/data\/\*\n!\/data\/fixtures\n!\/data\/seeds\n!\/data\/hooks\n?/, "\n").replace(/\n{3,}$/, "\n");
117
+ return n === t ? {
96
118
  status: "success",
97
119
  changed: !1
98
- } : (t.writeFileSync(e, r, "utf8"), {
120
+ } : (r.writeFileSync(e, n, "utf8"), {
99
121
  status: "success",
100
122
  changed: !0
101
123
  });
102
124
  }
103
125
  //#endregion
104
126
  //#region src/patterns/enable/backend/modifies/test-setup.ts
105
- var f = "import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n await agent.post('/login').type('form').send({\n type: 'password',\n email: user.email,\n password: testUserPassword\n });\n}\n\nbeforeAll(async () => {\n await admin\n // @ts-ignore\n .collection('_superusers')\n .authWithPassword(\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!\n );\n});\n\nbeforeEach(async (context: TestContext) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n context.admin = admin;\n context.pb = pb;\n context.user = await context.admin.collection('users').create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: testUserPassword,\n passwordConfirm: testUserPassword\n });\n context.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n await context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n await context.pb.authStore.clear();\n await context.admin.collection('users').delete(context.user.id);\n});\n", p = "import { beforeEach } from 'vitest';\nimport supertest from 'supertest';\n\nbeforeEach(async (context: any) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!);\n});\n", m = e`
127
+ var h = "import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n await agent.post('/login').type('form').send({\n type: 'password',\n email: user.email,\n password: testUserPassword\n });\n}\n\nbeforeAll(async () => {\n await admin\n // @ts-ignore\n .collection('_superusers')\n .authWithPassword(\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!\n );\n});\n\nbeforeEach(async (context: TestContext) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n context.admin = admin;\n context.pb = pb;\n context.user = await context.admin.collection('users').create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: testUserPassword,\n passwordConfirm: testUserPassword\n });\n context.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n await context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n await context.pb.authStore.clear();\n await context.admin.collection('users').delete(context.user.id);\n});\n", g = "import { beforeEach } from 'vitest';\nimport supertest from 'supertest';\n\nbeforeEach(async (context: any) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!);\n});\n", _ = e`
106
128
  Create test/setup.ts. The default minimal-template setup wires supertest:
107
129
 
108
130
  import { beforeEach } from 'vitest';
@@ -113,28 +135,28 @@ var f = "import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supe
113
135
  context.agent = supertest.agent(process.env.VITE_TEST_URL!);
114
136
  });
115
137
  `;
116
- function h(e) {
117
- return t.existsSync(e) ? t.readFileSync(e, "utf8") === f ? {
138
+ function v(e) {
139
+ return r.existsSync(e) ? r.readFileSync(e, "utf8") === h ? {
118
140
  status: "success",
119
141
  changed: !1
120
- } : (t.writeFileSync(e, f, "utf8"), {
142
+ } : (r.writeFileSync(e, h, "utf8"), {
121
143
  status: "success",
122
144
  changed: !0
123
145
  }) : {
124
146
  status: "not-found",
125
- message: m
147
+ message: _
126
148
  };
127
149
  }
128
- function g(e) {
129
- return !t.existsSync(e) || t.readFileSync(e, "utf8") === p ? {
150
+ function y(e) {
151
+ return !r.existsSync(e) || r.readFileSync(e, "utf8") === g ? {
130
152
  status: "success",
131
153
  changed: !1
132
- } : (t.writeFileSync(e, p, "utf8"), {
154
+ } : (r.writeFileSync(e, g, "utf8"), {
133
155
  status: "success",
134
156
  changed: !0
135
157
  });
136
158
  }
137
159
  //#endregion
138
- export { o as a, d as i, g as n, s as o, u as r, h as t };
160
+ export { l as a, m as i, y as n, u as o, p as r, v as t };
139
161
 
140
- //# sourceMappingURL=test-setup-C3gvjtTY.js.map
162
+ //# sourceMappingURL=test-setup-CcD8wSRD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-setup-CcD8wSRD.js","names":[],"sources":["../../src/patterns/enable/backend/modifies/svelte-config.ts","../../src/patterns/enable/backend/modifies/gitignore.ts","../../src/patterns/enable/backend/modifies/test-setup.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport { SyntaxKind } from \"ts-morph\";\nimport {\n resolveConfigTarget,\n saveTarget,\n type ConfigModifyResult,\n type ConfigTarget,\n} from \"../../../../runtime/config-target\";\n\nconst FAILURE_HINT = dedent`\n Switch the SvelteKit adapter to @sveltejs/adapter-auto:\n\n import adapter from '@sveltejs/adapter-auto';\n\n // ...\n adapter: adapter()\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Configure @sveltejs/adapter-auto via the sveltekit() plugin in vite.config.ts.\n`;\n\nfunction findAdapterImport(sourceFile: ConfigTarget[\"sourceFile\"]) {\n return sourceFile\n .getImportDeclarations()\n .find(\n (decl) =>\n decl.getModuleSpecifierValue() === \"@sveltejs/adapter-static\" ||\n decl.getModuleSpecifierValue() === \"@sveltejs/adapter-auto\",\n );\n}\n\nfunction adapterCalls(sourceFile: ConfigTarget[\"sourceFile\"]) {\n return sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => ce.getExpression().getText() === \"adapter\");\n}\n\n/**\n * Switch the adapter to `@sveltejs/adapter-auto` and drop its arguments, in\n * whichever file holds the adapter import + `adapter()` call (vite.config when\n * the project uses inline config, else svelte.config). Operates on the import\n * and call expression directly, so it never needs the config object.\n */\nexport function modifySvelteConfig(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, {\n notFound: NOT_FOUND_HINT,\n failed: FAILURE_HINT,\n });\n if (res.status !== \"resolved\") {\n return {\n filePath: res.filePath,\n outcome: { status: res.status, message: res.message },\n };\n }\n const { target } = res;\n const adapterImport = findAdapterImport(target.sourceFile);\n if (!adapterImport) {\n return {\n filePath: target.filePath,\n outcome: { status: \"failed\", message: FAILURE_HINT },\n };\n }\n\n if (adapterImport.getModuleSpecifierValue() === \"@sveltejs/adapter-static\") {\n adapterImport.setModuleSpecifier(\"@sveltejs/adapter-auto\");\n }\n\n for (const call of adapterCalls(target.sourceFile)) {\n const args = call.getArguments();\n for (let i = args.length - 1; i >= 0; i--) {\n call.removeArgument(i);\n }\n }\n\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n\n/**\n * Reverse of {@link modifySvelteConfig}: switch back to\n * `@sveltejs/adapter-static` and restore the `{ fallback: '200.html' }` arg.\n * Lenient — if no config or no adapter import is found, it's a no-op success.\n */\nexport function unmodifySvelteConfig(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, {\n notFound: NOT_FOUND_HINT,\n failed: FAILURE_HINT,\n });\n if (res.status !== \"resolved\") {\n // Nothing to revert — treat missing/unparseable config as a no-op.\n return {\n filePath: res.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n const { target } = res;\n const adapterImport = findAdapterImport(target.sourceFile);\n if (!adapterImport) {\n return {\n filePath: target.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n\n if (adapterImport.getModuleSpecifierValue() === \"@sveltejs/adapter-auto\") {\n adapterImport.setModuleSpecifier(\"@sveltejs/adapter-static\");\n }\n\n for (const call of adapterCalls(target.sourceFile)) {\n if (call.getArguments().length === 0) {\n call.addArgument(\"{ fallback: '200.html' }\");\n }\n }\n\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst POCKETBASE_BLOCK = `# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a .gitignore at the project root with the PocketBase block:\n\n # PocketBase\n /data/*\n !/data/fixtures\n !/data/seeds\n !/data/hooks\n`;\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n\n if (original.includes(\"# PocketBase\") && original.includes(\"/data/*\")) {\n return { status: \"success\", changed: false };\n }\n\n const separator = original.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n const next = original + separator + POCKETBASE_BLOCK;\n fs.writeFileSync(gitignorePath, next, \"utf8\");\n\n return { status: \"success\", changed: true };\n}\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n\n if (!original.includes(\"# PocketBase\")) {\n return { status: \"success\", changed: false };\n }\n\n const withBlockRemoved = original.replace(\n /\\n*# PocketBase\\n\\/data\\/\\*\\n!\\/data\\/fixtures\\n!\\/data\\/seeds\\n!\\/data\\/hooks\\n?/,\n \"\\n\",\n );\n\n const cleaned = withBlockRemoved.replace(/\\n{3,}$/, \"\\n\");\n\n if (cleaned === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, cleaned, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Source of truth: velastack-cli/templates/minimal/test/setup.ts\nconst WITH_BACKEND = `import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n\\tawait agent.post('/login').type('form').send({\n\\t\\ttype: 'password',\n\\t\\temail: user.email,\n\\t\\tpassword: testUserPassword\n\\t});\n}\n\nbeforeAll(async () => {\n\\tawait admin\n\\t\\t// @ts-ignore\n\\t\\t.collection('_superusers')\n\\t\\t.authWithPassword(\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_EMAIL!,\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_PASSWORD!\n\\t\\t);\n});\n\nbeforeEach(async (context: TestContext) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n\\tcontext.admin = admin;\n\\tcontext.pb = pb;\n\\tcontext.user = await context.admin.collection('users').create({\n\\t\\temail: \\`test-\\${Math.random().toString(36).slice(2)}@example.com\\`,\n\\t\\tpassword: testUserPassword,\n\\t\\tpasswordConfirm: testUserPassword\n\\t});\n\\tcontext.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n\\tawait context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n\\tawait context.pb.authStore.clear();\n\\tawait context.admin.collection('users').delete(context.user.id);\n});\n`;\n\n// Source of truth: velastack-cli/templates/static/test/setup.ts\nconst WITHOUT_BACKEND = `import { beforeEach } from 'vitest';\nimport supertest from 'supertest';\n\nbeforeEach(async (context: any) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!);\n});\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create test/setup.ts. The default minimal-template setup wires supertest:\n\n import { beforeEach } from 'vitest';\n import supertest from 'supertest';\n\n beforeEach(async (context: any) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!);\n });\n`;\n\nexport function modifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITH_BACKEND) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(testSetupPath, WITH_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\nexport function unmodifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITHOUT_BACKEND) {\n return { status: \"success\", changed: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,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAS,MAAM,GACxC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;AC1DA,IAAM,IAAe,qmDAiDf,IAAkB,qPASlB,IAAiB,CAAM;;;;;;;;;;;AAY7B,SAAgB,EAAgB,GAAsC;CAWpE,OAVK,EAAG,WAAW,CAAa,IAIf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAc,MAAM,GAC7C;EAAE,QAAQ;EAAW,SAAS;CAAK,KATjC;EAAE,QAAQ;EAAa,SAAS;CAAe;AAU1D;AAEA,SAAgB,EAAkB,GAAsC;CAWtE,OAVI,CAAC,EAAG,WAAW,CAAa,KAIf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAiB,MAAM,GAChD;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
@@ -34,7 +34,7 @@ var o = class t {
34
34
  modifyScriptBlock(e, t) {
35
35
  if (!e) return !1;
36
36
  let n = t(e.content);
37
- return n === e.content ? !1 : (this.s.overwrite(e.start, e.end, n), !0);
37
+ return n !== e.content && (this.s.overwrite(e.start, e.end, n), !0);
38
38
  }
39
39
  findElement(e) {
40
40
  return s(this.ast.fragment, (t) => (t.type === "Component" || t.type === "RegularElement") && t.name === e);
@@ -50,7 +50,7 @@ var o = class t {
50
50
  let n = this.findElement(e);
51
51
  if (!n) return !1;
52
52
  let r = `</${e}>`, i = this.source.lastIndexOf(r, n.end);
53
- return i === -1 ? !1 : (this.s.appendLeft(i, t), !0);
53
+ return i !== -1 && (this.s.appendLeft(i, t), !0);
54
54
  }
55
55
  replaceElement(e, t) {
56
56
  let n = this.findElement(e);
@@ -200,4 +200,4 @@ function f(e, t, n) {
200
200
  //#endregion
201
201
  export { c as a, f as i, l as n, o, u as r, d as t };
202
202
 
203
- //# sourceMappingURL=ts-morph-helpers-bR0-x04t.js.map
203
+ //# sourceMappingURL=ts-morph-helpers-Bk82Z2n7.js.map