@velastack/patterns 0.2.10 → 0.2.12

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 (98) hide show
  1. package/dist/chunks/{_layout-D0OmzCu1.js → _layout-DqH4lA_r.js} +8 -8
  2. package/dist/chunks/{_layout-D0OmzCu1.js.map → _layout-DqH4lA_r.js.map} +1 -1
  3. package/dist/chunks/{collections-DDYlpDNO.js → collections-CcL5bbBk.js} +2 -2
  4. package/dist/chunks/{collections-DDYlpDNO.js.map → collections-CcL5bbBk.js.map} +1 -1
  5. package/dist/chunks/compose-handle-D16KmBVd.js +322 -0
  6. package/dist/chunks/compose-handle-D16KmBVd.js.map +1 -0
  7. package/dist/chunks/{config-target-DOi8kI_f.js → config-target-Co-ij8p3.js} +9 -9
  8. package/dist/chunks/{config-target-DOi8kI_f.js.map → config-target-Co-ij8p3.js.map} +1 -1
  9. package/dist/chunks/format-result-Cb2hWsb8.js +64 -0
  10. package/dist/chunks/format-result-Cb2hWsb8.js.map +1 -0
  11. package/dist/chunks/{generate.runtime-AjCpCfv3.js → generate.runtime-1gbaOucO.js} +144 -137
  12. package/dist/chunks/generate.runtime-1gbaOucO.js.map +1 -0
  13. package/dist/chunks/{generate.runtime-BpYOznG5.js → generate.runtime-A8wfItN7.js} +21 -21
  14. package/dist/chunks/{generate.runtime-BpYOznG5.js.map → generate.runtime-A8wfItN7.js.map} +1 -1
  15. package/dist/chunks/{generate.runtime-BtX_9lLk.js → generate.runtime-BL7uKgW7.js} +33 -33
  16. package/dist/chunks/{generate.runtime-BtX_9lLk.js.map → generate.runtime-BL7uKgW7.js.map} +1 -1
  17. package/dist/chunks/{generate.runtime-BYJZB1ad.js → generate.runtime-BX53l-rL.js} +37 -57
  18. package/dist/chunks/generate.runtime-BX53l-rL.js.map +1 -0
  19. package/dist/chunks/{generate.runtime-DEl6b1Ti.js → generate.runtime-Bb64J0ab.js} +15 -15
  20. package/dist/chunks/{generate.runtime-DEl6b1Ti.js.map → generate.runtime-Bb64J0ab.js.map} +1 -1
  21. package/dist/chunks/{generate.runtime-DRcq4d5D.js → generate.runtime-BbNMkG4j.js} +27 -27
  22. package/dist/chunks/{generate.runtime-DRcq4d5D.js.map → generate.runtime-BbNMkG4j.js.map} +1 -1
  23. package/dist/chunks/{generate.runtime-BgezGu15.js → generate.runtime-BdPtilz4.js} +94 -93
  24. package/dist/chunks/generate.runtime-BdPtilz4.js.map +1 -0
  25. package/dist/chunks/{generate.runtime-DH9o-888.js → generate.runtime-BqxVaq5P.js} +24 -24
  26. package/dist/chunks/{generate.runtime-DH9o-888.js.map → generate.runtime-BqxVaq5P.js.map} +1 -1
  27. package/dist/chunks/{generate.runtime-fSDNxfGG.js → generate.runtime-CJVy-mMN.js} +11 -11
  28. package/dist/chunks/{generate.runtime-fSDNxfGG.js.map → generate.runtime-CJVy-mMN.js.map} +1 -1
  29. package/dist/chunks/generate.runtime-CN3v78hx.js +82 -0
  30. package/dist/chunks/generate.runtime-CN3v78hx.js.map +1 -0
  31. package/dist/chunks/generate.runtime-CSXj-ebM.js +122 -0
  32. package/dist/chunks/generate.runtime-CSXj-ebM.js.map +1 -0
  33. package/dist/chunks/{generate.runtime-B6kxV3Bi.js → generate.runtime-CVLtEsXb.js} +28 -28
  34. package/dist/chunks/{generate.runtime-B6kxV3Bi.js.map → generate.runtime-CVLtEsXb.js.map} +1 -1
  35. package/dist/chunks/{generate.runtime-B_Fk1Jjs.js → generate.runtime-CiTmbkAk.js} +31 -34
  36. package/dist/chunks/{generate.runtime-B_Fk1Jjs.js.map → generate.runtime-CiTmbkAk.js.map} +1 -1
  37. package/dist/chunks/{generate.runtime-OjW1XETW.js → generate.runtime-CwzHEcKv.js} +33 -33
  38. package/dist/chunks/{generate.runtime-OjW1XETW.js.map → generate.runtime-CwzHEcKv.js.map} +1 -1
  39. package/dist/chunks/{generate.runtime-SQhCLSah.js → generate.runtime-DAkg7Fy5.js} +13 -13
  40. package/dist/chunks/{generate.runtime-SQhCLSah.js.map → generate.runtime-DAkg7Fy5.js.map} +1 -1
  41. package/dist/chunks/{generate.runtime-DK7iXmAZ.js → generate.runtime-DPIH5sSI.js} +17 -17
  42. package/dist/chunks/{generate.runtime-DK7iXmAZ.js.map → generate.runtime-DPIH5sSI.js.map} +1 -1
  43. package/dist/chunks/{generate.runtime-CTiJEVF2.js → generate.runtime-Dj22Kx0W.js} +31 -31
  44. package/dist/chunks/{generate.runtime-CTiJEVF2.js.map → generate.runtime-Dj22Kx0W.js.map} +1 -1
  45. package/dist/chunks/{generate.runtime-CycY6kPr.js → generate.runtime-DnWw9tL1.js} +41 -41
  46. package/dist/chunks/{generate.runtime-CycY6kPr.js.map → generate.runtime-DnWw9tL1.js.map} +1 -1
  47. package/dist/chunks/{generate.runtime-DHRCNPVx.js → generate.runtime-Dx8Mcs2i.js} +27 -27
  48. package/dist/chunks/{generate.runtime-DHRCNPVx.js.map → generate.runtime-Dx8Mcs2i.js.map} +1 -1
  49. package/dist/chunks/{generate.runtime-Cq1gqxzg.js → generate.runtime-Dywp4xth.js} +22 -22
  50. package/dist/chunks/{generate.runtime-Cq1gqxzg.js.map → generate.runtime-Dywp4xth.js.map} +1 -1
  51. package/dist/chunks/{generate.runtime-Dmwhwgji.js → generate.runtime-T9DZJH8m.js} +65 -38
  52. package/dist/chunks/generate.runtime-T9DZJH8m.js.map +1 -0
  53. package/dist/chunks/{generate.runtime-vTneb2SY.js → generate.runtime-Zh5n8XpR.js} +45 -45
  54. package/dist/chunks/{generate.runtime-vTneb2SY.js.map → generate.runtime-Zh5n8XpR.js.map} +1 -1
  55. package/dist/chunks/{generate.runtime-CZQoVNt3.js → generate.runtime-d9HT4v-7.js} +33 -33
  56. package/dist/chunks/{generate.runtime-CZQoVNt3.js.map → generate.runtime-d9HT4v-7.js.map} +1 -1
  57. package/dist/chunks/{generate.runtime-Dtf2BI_5.js → generate.runtime-j1gfY6Xq.js} +9 -9
  58. package/dist/chunks/{generate.runtime-Dtf2BI_5.js.map → generate.runtime-j1gfY6Xq.js.map} +1 -1
  59. package/dist/chunks/generate.runtime-l-Tiahb2.js +170 -0
  60. package/dist/chunks/generate.runtime-l-Tiahb2.js.map +1 -0
  61. package/dist/chunks/modify-file-BlWTOkCH.js +212 -0
  62. package/dist/chunks/modify-file-BlWTOkCH.js.map +1 -0
  63. package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js → modify-svelte-config-remote-CDKs_Qi0.js} +2 -2
  64. package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js.map → modify-svelte-config-remote-CDKs_Qi0.js.map} +1 -1
  65. package/dist/chunks/{pocketbase-BerjVikJ.js → pocketbase-ewxQLtse.js} +16 -16
  66. package/dist/chunks/{pocketbase-BerjVikJ.js.map → pocketbase-ewxQLtse.js.map} +1 -1
  67. package/dist/chunks/{shared-Cmbzu7Od.js → shared-Bm3eMFy-.js} +2 -2
  68. package/dist/chunks/{shared-Cmbzu7Od.js.map → shared-Bm3eMFy-.js.map} +1 -1
  69. package/dist/chunks/svelte-file-B3RfgVdt.js +123 -0
  70. package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -0
  71. package/dist/chunks/{test-setup-DjbhQYZC.js → test-setup-B2hd8I-s.js} +15 -15
  72. package/dist/chunks/{test-setup-DjbhQYZC.js.map → test-setup-B2hd8I-s.js.map} +1 -1
  73. package/dist/chunks/{ui-BdkuOXPw.js → ui-CD-psDWi.js} +12 -12
  74. package/dist/chunks/{ui-BdkuOXPw.js.map → ui-CD-psDWi.js.map} +1 -1
  75. package/dist/chunks/ui-jhXrsw4T.js +12 -0
  76. package/dist/chunks/ui-jhXrsw4T.js.map +1 -0
  77. package/dist/chunks/{write-result-BVWPlGvE.js → write-result-DBKv-Q7J.js} +51 -51
  78. package/dist/chunks/{write-result-BVWPlGvE.js.map → write-result-DBKv-Q7J.js.map} +1 -1
  79. package/dist/index.d.ts +4 -3
  80. package/dist/index.js +1012 -1013
  81. package/dist/index.js.map +1 -1
  82. package/package.json +1 -1
  83. package/dist/chunks/format-result-BdAy5M8C.js +0 -50
  84. package/dist/chunks/format-result-BdAy5M8C.js.map +0 -1
  85. package/dist/chunks/generate.runtime-AjCpCfv3.js.map +0 -1
  86. package/dist/chunks/generate.runtime-BYJZB1ad.js.map +0 -1
  87. package/dist/chunks/generate.runtime-BcVAKzoY.js +0 -138
  88. package/dist/chunks/generate.runtime-BcVAKzoY.js.map +0 -1
  89. package/dist/chunks/generate.runtime-BgezGu15.js.map +0 -1
  90. package/dist/chunks/generate.runtime-D2WfvXm2.js +0 -106
  91. package/dist/chunks/generate.runtime-D2WfvXm2.js.map +0 -1
  92. package/dist/chunks/generate.runtime-DaPNrIyg.js +0 -28
  93. package/dist/chunks/generate.runtime-DaPNrIyg.js.map +0 -1
  94. package/dist/chunks/generate.runtime-Dmwhwgji.js.map +0 -1
  95. package/dist/chunks/modify-file-Cgu_WeFk.js +0 -22
  96. package/dist/chunks/modify-file-Cgu_WeFk.js.map +0 -1
  97. package/dist/chunks/ts-morph-helpers-teS3yXg-.js +0 -229
  98. package/dist/chunks/ts-morph-helpers-teS3yXg-.js.map +0 -1
@@ -0,0 +1,170 @@
1
+ import { a as e } from "./util-BLYliuUK.js";
2
+ import { t } from "./dedent-Gq6Krl4n.js";
3
+ import { n } from "./logger-CQONztPm.js";
4
+ import { n as r } from "./shared-Bm3eMFy-.js";
5
+ import { a as i, modifyOutcomeToFile as a, n as o, revertOutcomeToFile as s, u as c } from "./modify-file-BlWTOkCH.js";
6
+ import { n as l } from "./compose-handle-D16KmBVd.js";
7
+ import { i as u, n as d, o as f } from "./test-setup-B2hd8I-s.js";
8
+ import p from "node:fs";
9
+ import m from "node:path";
10
+ import { Node as h, Project as g, QuoteKind as _ } from "ts-morph";
11
+ //#region src/patterns/disable/backend/modifies/hooks.server.ts
12
+ var v = t`
13
+ Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,
14
+ and its imports from '@velastack/pocketbase' and '$env/dynamic/private'.
15
+ `, y = t`
16
+ The workflows are removed with the backend. Take the startWorker() call out
17
+ of the init hook in src/hooks.server.ts, and its import:
18
+
19
+ import { startWorker } from '$lib/server/workflows';
20
+ `, b = [
21
+ "@velastack/pocketbase",
22
+ "$env/dynamic/private",
23
+ "$lib/server/workflows",
24
+ "@sveltejs/kit",
25
+ "@sveltejs/kit/hooks"
26
+ ];
27
+ function x(e) {
28
+ return e ? h.isAwaitExpression(e) || h.isExpressionStatement(e) || h.isReturnStatement(e) ? x(e.getExpression()) : h.isCallExpression(e) && e.getExpression().getText() === "startWorker" && e.getArguments().length === 0 : !1;
29
+ }
30
+ function S(e) {
31
+ if (!h.isArrowFunction(e) && !h.isFunctionExpression(e) && !h.isFunctionDeclaration(e)) return !1;
32
+ let t = e.getBody();
33
+ if (!t) return !1;
34
+ if (!h.isBlock(t)) return x(t);
35
+ let n = t.getStatements();
36
+ return n.length === 1 && x(n[0]);
37
+ }
38
+ function C(e) {
39
+ let t = e.getFunction("init"), n = e.getVariableDeclaration("init"), r = t ?? n?.getVariableStatement();
40
+ return !r || !r.getText().includes("startWorker") ? null : (t ? S(t) : n?.getVariableStatement()?.getDeclarations().length === 1 && S(n.getInitializer())) ? r : "custom";
41
+ }
42
+ function w(e) {
43
+ if (!p.existsSync(e)) return {
44
+ status: "success",
45
+ changed: !1
46
+ };
47
+ let t = p.readFileSync(e, "utf8");
48
+ if (!t.includes("handlePocketbase") && !t.includes("startWorker")) return {
49
+ status: "success",
50
+ changed: !1
51
+ };
52
+ let n = new g({
53
+ compilerOptions: { allowJs: !0 },
54
+ manipulationSettings: { quoteKind: _.Single }
55
+ }).addSourceFileAtPath(e);
56
+ if (C(n) === "custom") return {
57
+ status: "failed",
58
+ message: y
59
+ };
60
+ if (l(n, "handlePocketbase").status === "unsupported") return {
61
+ status: "failed",
62
+ message: v
63
+ };
64
+ let r = C(n);
65
+ return r && r !== "custom" && c(n, r), i(n, b), n.formatText(), o(n), n.saveSync(), {
66
+ status: "success",
67
+ changed: n.getFullText() !== t
68
+ };
69
+ }
70
+ //#endregion
71
+ //#region src/patterns/disable/backend/modifies/layout-server.ts
72
+ var T = t`
73
+ src/routes/+layout.server.ts still reads locals.meta, which only the
74
+ PocketBase hook provides. Read the values from a static module instead:
75
+
76
+ import { site } from '$lib/site';
77
+
78
+ // locals.meta.appName -> site.name
79
+ // locals.meta.appURL -> site.url
80
+ // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }
81
+ `;
82
+ function E(e) {
83
+ if (!p.existsSync(e)) return {
84
+ status: "success",
85
+ changed: !1
86
+ };
87
+ let t = p.readFileSync(e, "utf8");
88
+ if (!t.includes("locals.meta")) return {
89
+ status: "success",
90
+ changed: !1
91
+ };
92
+ let n = t.replace(/\blocals\.meta\.appName\b/g, "site.name").replace(/\blocals\.meta\.appURL\b/g, "site.url").replace(/\bmeta:\s*locals\.meta\b/g, "meta: { appName: site.name, appURL: site.url }");
93
+ if (n.includes("locals.meta")) return {
94
+ status: "failed",
95
+ message: T
96
+ };
97
+ let r = n.replace(/\(\{\s*locals\s*,\s*/g, "({ ").replace(/,\s*locals\s*\}/g, " }");
98
+ return /\blocals\b/.test(r) || (n = r), /from\s+['"]\$lib\/site['"]/.test(n) || (n = "import { site } from '$lib/site';\n" + n), p.writeFileSync(e, n, "utf8"), {
99
+ status: "success",
100
+ changed: !0
101
+ };
102
+ }
103
+ //#endregion
104
+ //#region src/patterns/disable/backend/generate.runtime.ts
105
+ function D(e) {
106
+ let t = "My App";
107
+ try {
108
+ let n = JSON.parse(p.readFileSync(m.join(e, "package.json"), "utf8"));
109
+ n.name && (t = n.name);
110
+ } catch {}
111
+ return [
112
+ "/**",
113
+ " * Site-wide metadata.",
114
+ " *",
115
+ " * Without a backend there is nothing to read this from at runtime, so this",
116
+ " * file is the source of truth. Set `url` to where the site is deployed:",
117
+ " * canonical links and Open Graph image URLs are built from it.",
118
+ " */",
119
+ "export const site = {",
120
+ `\tname: ${JSON.stringify(t)},`,
121
+ " url: 'http://localhost:5173'",
122
+ "};",
123
+ ""
124
+ ].join("\n");
125
+ }
126
+ function O(e) {
127
+ if (!p.existsSync(e)) return [];
128
+ let t = [];
129
+ for (let n of p.readdirSync(e, { withFileTypes: !0 })) {
130
+ let r = m.join(e, n.name);
131
+ n.isDirectory() ? t.push(...O(r)) : n.name === "server.test.ts" && t.push(r);
132
+ }
133
+ return t;
134
+ }
135
+ async function k(t) {
136
+ let i = n(t), o = [], c = [], l = [];
137
+ i.info("Reverting adapter config");
138
+ let h = f(t.root), g = a(h.filePath, h.outcome);
139
+ g && c.push(g), i.info("Reverting hooks.server.ts");
140
+ let _ = m.join(t.root, "src", "hooks.server.ts"), v = s(_, w(_));
141
+ v.modify && c.push(v.modify), v.delete && l.push(v.delete), i.info("Reverting .gitignore");
142
+ let y = m.join(t.root, ".gitignore"), b = a(y, u(y));
143
+ b && c.push(b), i.info("Reverting src/routes/+layout.server.ts");
144
+ let x = m.join(t.root, "src", "routes", "+layout.server.ts"), S = a(x, E(x));
145
+ S && c.push(S);
146
+ let C = m.join(t.root, "src", "lib", "site.ts");
147
+ S?.status === "success" && !p.existsSync(C) && (i.info("Creating src/lib/site.ts"), o.push({
148
+ path: C,
149
+ language: e(C),
150
+ content: D(t.root),
151
+ status: "success"
152
+ }));
153
+ for (let e of O(m.join(t.root, "src"))) i.info(`Removing ${m.relative(t.root, e)}`), l.push(r(e));
154
+ i.info("Reverting test/setup.ts");
155
+ let T = m.join(t.root, "test", "setup.ts"), k = a(T, d(T));
156
+ return k && c.push(k), {
157
+ creates: o,
158
+ modifies: c,
159
+ deletes: l,
160
+ components: [],
161
+ packages: [],
162
+ collections: [],
163
+ collectionPatches: [],
164
+ collectionDrops: []
165
+ };
166
+ }
167
+ //#endregion
168
+ export { k as generate };
169
+
170
+ //# sourceMappingURL=generate.runtime-l-Tiahb2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.runtime-l-Tiahb2.js","names":[],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$env/dynamic/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '$lib/server/workflows';\n`;\n\n/** Modules only the backend's handle and init import from. */\nconst BACKEND_MODULES = [\n \"@velastack/pocketbase\",\n \"$env/dynamic/private\",\n \"$lib/server/workflows\",\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n sourceFile.formatText();\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '$lib/site';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point the root layout's meta at `$lib/site` instead of `locals.meta`. The\n * minimal template reads app name and URL off the PocketBase hook; without\n * the backend nothing sets them, and `App.Locals` no longer declares them.\n */\nexport function unmodifyLayoutServerMeta(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n if (!/from\\s+['\"]\\$lib\\/site['\"]/.test(updated)) {\n updated = \"import { site } from '$lib/site';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\n\n/** `src/lib/site.ts` as the static template ships it, named after the package. */\nfunction siteModule(root: string): string {\n let name = \"My App\";\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as { name?: string };\n if (pkg.name) name = pkg.name;\n } catch {\n // No package.json to name the site after; the placeholder stands.\n }\n return [\n \"/**\",\n \" * Site-wide metadata.\",\n \" *\",\n \" * Without a backend there is nothing to read this from at runtime, so this\",\n \" * file is the source of truth. Set `url` to where the site is deployed:\",\n \" * canonical links and Open Graph image URLs are built from it.\",\n \" */\",\n \"export const site = {\",\n `\\tname: ${JSON.stringify(name)},`,\n \"\\turl: 'http://localhost:5173'\",\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n const sitePath = path.join(options.root, \"src\", \"lib\", \"site.ts\");\n if (layoutServerFile?.status === \"success\" && !fs.existsSync(sitePath)) {\n logger.info(\"Creating src/lib/site.ts\");\n creates.push({\n path: sitePath,\n language: languageFromPath(sitePath),\n content: siteModule(options.root),\n status: \"success\",\n });\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n\n return {\n creates,\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;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 import r from "node:path";
5
+ import { Node as i, Project as a, QuoteKind as o, SyntaxKind as s } from "ts-morph";
6
+ //#region src/runtime/ts-morph-helpers.ts
7
+ function c(e, t) {
8
+ let n = new a({
9
+ useInMemoryFileSystem: !0,
10
+ skipFileDependencyResolution: !0,
11
+ manipulationSettings: { quoteKind: o.Single }
12
+ }).createSourceFile("script.ts", e, { overwrite: !0 }), r = t(n);
13
+ return {
14
+ source: n.getFullText(),
15
+ result: r
16
+ };
17
+ }
18
+ function l(e, t) {
19
+ for (let n of t) {
20
+ if (e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === n.moduleSpecifier)) continue;
21
+ let t = { moduleSpecifier: n.moduleSpecifier };
22
+ n.defaultImport && (t.defaultImport = n.defaultImport), n.namespaceImport && (t.namespaceImport = n.namespaceImport), n.namedImports && (t.namedImports = n.namedImports), e.addImportDeclaration(t);
23
+ }
24
+ }
25
+ function u(e, t) {
26
+ let n = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t);
27
+ return n ? (n.remove(), { wasRemoved: !0 }) : { wasRemoved: !1 };
28
+ }
29
+ function d(e, t) {
30
+ return e.getDescendantsOfKind(s.Identifier).some((e) => {
31
+ if (e.getText() !== t) return !1;
32
+ let n = e.getParent()?.getKind();
33
+ return n !== s.ImportSpecifier && n !== s.ImportClause && n !== s.NamespaceImport;
34
+ });
35
+ }
36
+ function f(e, t, n) {
37
+ let r = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t);
38
+ if (!r) return { wasRemoved: !1 };
39
+ let i = r.getNamedImports().find((e) => e.getName() === n);
40
+ return !i || d(e, i.getAliasNode()?.getText() ?? n) ? { wasRemoved: !1 } : (r.getNamedImports().length === 1 && !r.getDefaultImport() ? r.remove() : i.remove(), { wasRemoved: !0 });
41
+ }
42
+ function p(e, t) {
43
+ let n = [];
44
+ for (let r of e.getImportDeclarations()) {
45
+ if (!t.includes(r.getModuleSpecifierValue()) || !r.getImportClause()) continue;
46
+ for (let t of r.getNamedImports()) {
47
+ let r = t.getAliasNode()?.getText() ?? t.getName();
48
+ d(e, r) || (t.remove(), n.push(r));
49
+ }
50
+ let i = r.getDefaultImport();
51
+ i && !d(e, i.getText()) && (n.push(i.getText()), r.removeDefaultImport());
52
+ let a = r.getNamespaceImport();
53
+ a && !d(e, a.getText()) && (n.push(a.getText()), r.removeNamespaceImport()), r.getNamedImports().length === 0 && !r.getDefaultImport() && !r.getNamespaceImport() && r.remove();
54
+ }
55
+ return { removed: n };
56
+ }
57
+ function m(e, t, n, r = !1) {
58
+ let i = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t && !e.getNamespaceImport() && (r || !e.isTypeOnly()));
59
+ if (!i) {
60
+ e.addImportDeclaration({
61
+ isTypeOnly: r,
62
+ namedImports: [n],
63
+ moduleSpecifier: t
64
+ });
65
+ return;
66
+ }
67
+ i.getNamedImports().some((e) => e.getName() === n) || i.addNamedImport(r && !i.isTypeOnly() ? {
68
+ name: n,
69
+ isTypeOnly: !0
70
+ } : n);
71
+ }
72
+ function h(e) {
73
+ let t = e.getKind();
74
+ return t === s.SingleLineCommentTrivia || t === s.MultiLineCommentTrivia;
75
+ }
76
+ function g(e) {
77
+ return (e.match(/\n/g) ?? []).length;
78
+ }
79
+ function _(e, t) {
80
+ let n = e.getStatementsWithComments(), r = e.getFullText(), i = [], a = t.getStart(!0);
81
+ for (let e = n.indexOf(t) - 1; e >= 0; e--) {
82
+ let t = n[e];
83
+ if (!h(t) || g(r.slice(t.getEnd(), a)) > 1) break;
84
+ i.unshift(t), a = t.getStart();
85
+ }
86
+ return i;
87
+ }
88
+ function v(e, t) {
89
+ let n = _(e, t), r = b(e, n[0] ?? t);
90
+ if (i.isJSDocable(t)) for (let e of t.getJsDocs()) e.remove();
91
+ for (let e of n.reverse()) e.remove();
92
+ r.restore(t);
93
+ }
94
+ function y(e, t) {
95
+ let n = _(e, t), r = e.getStatementsWithComments(), i = r[r.indexOf(t) + 1], a = b(e, n[0] ?? t);
96
+ t.remove();
97
+ for (let e of n.reverse()) e.remove();
98
+ i && a.restore(i);
99
+ }
100
+ function b(e, t) {
101
+ let n = e.getStatementsWithComments(), r = n[n.indexOf(t) - 1], i = r !== void 0 && g(e.getFullText().slice(r.getEnd(), t.getStart(!0))) > 1;
102
+ return { restore(t) {
103
+ i && r && g(e.getFullText().slice(r.getEnd(), t.getStart(!0))) < 2 && e.insertText(r.getEnd(), "\n");
104
+ } };
105
+ }
106
+ function x(e) {
107
+ return e.compilerNode.statements.every((e) => e.kind === s.EmptyStatement);
108
+ }
109
+ function S(e) {
110
+ let t = e.getImportDeclarations(), n = t[t.length - 1], r = n?.getNextSibling();
111
+ n && r && ((e.getFullText().slice(n.getEnd(), r.getStart(!0)).match(/\n/g) ?? []).length >= 2 || e.insertText(n.getEnd(), "\n"));
112
+ }
113
+ function C(e, t) {
114
+ let n = e.getFunction(t);
115
+ if (n) return n.remove(), { wasRemoved: !0 };
116
+ let r = e.getVariableStatements().flatMap((e) => e.getDeclarations()).find((e) => e.getName() === t);
117
+ return r ? (r.remove(), { wasRemoved: !0 }) : { wasRemoved: !1 };
118
+ }
119
+ function w(e, t, n, r, i) {
120
+ let a = `
121
+ {
122
+ title: '${t}',
123
+ url: '${n}',
124
+ icon: ${r}
125
+ }
126
+ `.trim(), { source: o, result: u } = c(e, (e) => {
127
+ let n = e.getVariableDeclarations().find((e) => e.getName() === "data")?.getInitializer();
128
+ if (!n || n.getKind() !== s.ObjectLiteralExpression) return { wasAdded: !1 };
129
+ let o = n.asKindOrThrow(s.ObjectLiteralExpression).getProperty("navUser");
130
+ if (!o || o.getKind() !== s.PropertyAssignment) return { wasAdded: !1 };
131
+ let c = o.asKindOrThrow(s.PropertyAssignment).getInitializer();
132
+ if (!c || c.getKind() !== s.ArrayLiteralExpression) return { wasAdded: !1 };
133
+ let u = c.asKindOrThrow(s.ArrayLiteralExpression);
134
+ return u.getElements().some((e) => {
135
+ if (e.getKind() !== s.ObjectLiteralExpression) return !1;
136
+ let n = e.asKindOrThrow(s.ObjectLiteralExpression).getProperty("title");
137
+ if (!n || n.getKind() !== s.PropertyAssignment) return !1;
138
+ let r = n.asKindOrThrow(s.PropertyAssignment).getInitializer();
139
+ return r?.getKind() === s.StringLiteral && r.getLiteralText() === t;
140
+ }) ? { wasAdded: !1 } : (l(e, [{
141
+ defaultImport: r,
142
+ moduleSpecifier: i
143
+ }]), u.addElement(a), e.formatText(), { wasAdded: !0 });
144
+ });
145
+ return {
146
+ source: o,
147
+ wasAdded: u.wasAdded
148
+ };
149
+ }
150
+ function T(e, t, n) {
151
+ let { source: r, result: i } = c(e, (e) => {
152
+ let r = e.getVariableDeclarations().find((e) => e.getName() === "data")?.getInitializer();
153
+ if (!r || r.getKind() !== s.ObjectLiteralExpression) return { wasRemoved: !1 };
154
+ let i = r.asKindOrThrow(s.ObjectLiteralExpression).getProperty("navUser");
155
+ if (!i || i.getKind() !== s.PropertyAssignment) return { wasRemoved: !1 };
156
+ let a = i.asKindOrThrow(s.PropertyAssignment).getInitializer();
157
+ if (!a || a.getKind() !== s.ArrayLiteralExpression) return { wasRemoved: !1 };
158
+ let o = a.asKindOrThrow(s.ArrayLiteralExpression), c = o.getElements().findIndex((e) => {
159
+ if (e.getKind() !== s.ObjectLiteralExpression) return !1;
160
+ let n = e.asKindOrThrow(s.ObjectLiteralExpression).getProperty("title");
161
+ if (!n || n.getKind() !== s.PropertyAssignment) return !1;
162
+ let r = n.asKindOrThrow(s.PropertyAssignment).getInitializer();
163
+ return r?.getKind() === s.StringLiteral && r.getLiteralText() === t;
164
+ });
165
+ if (c === -1) return { wasRemoved: !1 };
166
+ if (o.removeElement(c), n) {
167
+ let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === n);
168
+ if (t) {
169
+ let n = t.getDefaultImport()?.getText();
170
+ n && e.getDescendantsOfKind(s.Identifier).some((e) => e.getText() === n && e.getParent()?.getKind() !== s.ImportClause && e.getParent()?.getKind() !== s.ImportSpecifier) || t.remove();
171
+ }
172
+ }
173
+ return e.formatText(), { wasRemoved: !0 };
174
+ });
175
+ return {
176
+ source: r,
177
+ wasRemoved: i.wasRemoved
178
+ };
179
+ }
180
+ //#endregion
181
+ //#region src/runtime/modify-file.ts
182
+ function E(t, r) {
183
+ let i = e(t);
184
+ return r.status === "success" ? r.changed ? {
185
+ path: t,
186
+ language: i,
187
+ content: n.readFileSync(t, "utf8"),
188
+ status: "success"
189
+ } : null : {
190
+ path: t,
191
+ language: i,
192
+ content: r.status === "failed" && n.existsSync(t) ? n.readFileSync(t, "utf8") : "",
193
+ status: r.status,
194
+ message: r.message
195
+ };
196
+ }
197
+ function D(e, r) {
198
+ return r.status === "success" && r.changed && n.existsSync(e) && c(n.readFileSync(e, "utf8"), x).result ? {
199
+ modify: null,
200
+ delete: t(e)
201
+ } : {
202
+ modify: E(e, r),
203
+ delete: null
204
+ };
205
+ }
206
+ function O(e, t) {
207
+ return e.filter((e) => !n.existsSync(r.join(t, e.path)));
208
+ }
209
+ //#endregion
210
+ export { p as a, f as c, C as d, c as f, m as i, O as keepMissing, T as l, E as modifyOutcomeToFile, S as n, v as o, l as r, D as revertOutcomeToFile, u as s, w as t, y as u };
211
+
212
+ //# sourceMappingURL=modify-file-BlWTOkCH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modify-file-BlWTOkCH.js","names":[],"sources":["../../src/runtime/ts-morph-helpers.ts","../../src/runtime/modify-file.ts"],"sourcesContent":["import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ImportDeclarationStructure,\n type OptionalKind,\n type SourceFile,\n type Statement,\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/**\n * Whether `local` is used anywhere other than the import that binds it.\n * Conservative: a same-named property counts, which only ever keeps an import.\n */\nexport function isReferenced(sf: SourceFile, local: string): boolean {\n return sf.getDescendantsOfKind(SyntaxKind.Identifier).some((id) => {\n if (id.getText() !== local) return false;\n const kind = id.getParent()?.getKind();\n return (\n kind !== SyntaxKind.ImportSpecifier &&\n kind !== SyntaxKind.ImportClause &&\n kind !== SyntaxKind.NamespaceImport\n );\n });\n}\n\n/**\n * Drop `name` from the import of `moduleSpecifier` once nothing else in the\n * file references it; the whole declaration goes when `name` was its only\n * import. For unwrapping `sequence(...)` and the like after a revert. An\n * aliased import (`sequence as seq`) is checked by its local name.\n */\nexport function removeNamedImportIfUnused(\n sf: SourceFile,\n moduleSpecifier: string,\n name: string,\n): { wasRemoved: boolean } {\n const decl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!decl) return { wasRemoved: false };\n\n const named = decl.getNamedImports().find((ni) => ni.getName() === name);\n if (!named) return { wasRemoved: false };\n\n const local = named.getAliasNode()?.getText() ?? name;\n if (isReferenced(sf, local)) return { wasRemoved: false };\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return { wasRemoved: true };\n}\n\n/**\n * Drop every binding imported from `moduleSpecifiers` that nothing references\n * any more, and the declaration once it binds nothing. Side-effect imports\n * (`import 'x'`) bind nothing to begin with and are left alone.\n */\nexport function pruneUnusedImports(\n sf: SourceFile,\n moduleSpecifiers: string[],\n): { removed: string[] } {\n const removed: string[] = [];\n for (const decl of sf.getImportDeclarations()) {\n if (!moduleSpecifiers.includes(decl.getModuleSpecifierValue())) continue;\n if (!decl.getImportClause()) continue;\n\n for (const named of decl.getNamedImports()) {\n const local = named.getAliasNode()?.getText() ?? named.getName();\n if (isReferenced(sf, local)) continue;\n named.remove();\n removed.push(local);\n }\n const defaultImport = decl.getDefaultImport();\n if (defaultImport && !isReferenced(sf, defaultImport.getText())) {\n removed.push(defaultImport.getText());\n decl.removeDefaultImport();\n }\n const namespaceImport = decl.getNamespaceImport();\n if (namespaceImport && !isReferenced(sf, namespaceImport.getText())) {\n removed.push(namespaceImport.getText());\n decl.removeNamespaceImport();\n }\n\n if (\n decl.getNamedImports().length === 0 &&\n !decl.getDefaultImport() &&\n !decl.getNamespaceImport()\n ) {\n decl.remove();\n }\n }\n return { removed };\n}\n\n/**\n * Import `name` from `moduleSpecifier`, joining an existing import of that\n * module. A type-only name joins a value import as an inline `type`\n * specifier; an `import type` declaration already covers it.\n */\nexport function ensureNamedImport(\n sf: SourceFile,\n moduleSpecifier: string,\n name: string,\n typeOnly = false,\n): void {\n const existing = sf\n .getImportDeclarations()\n .find(\n (d) =>\n d.getModuleSpecifierValue() === moduleSpecifier &&\n !d.getNamespaceImport() &&\n (typeOnly || !d.isTypeOnly()),\n );\n if (!existing) {\n sf.addImportDeclaration({\n isTypeOnly: typeOnly,\n namedImports: [name],\n moduleSpecifier,\n });\n return;\n }\n if (existing.getNamedImports().some((ni) => ni.getName() === name)) return;\n existing.addNamedImport(\n typeOnly && !existing.isTypeOnly() ? { name, isTypeOnly: true } : name,\n );\n}\n\nfunction isCommentNode(node: Node): boolean {\n const kind = node.getKind();\n return (\n kind === SyntaxKind.SingleLineCommentTrivia ||\n kind === SyntaxKind.MultiLineCommentTrivia\n );\n}\n\nfunction newlines(text: string): number {\n return (text.match(/\\n/g) ?? []).length;\n}\n\n/**\n * The comment lines directly above a top-level statement, up to the first\n * blank line. ts-morph parses them as statements of their own; the JSDoc is\n * not among them, it belongs to the statement.\n */\nfunction commentsAbove(sf: SourceFile, statement: Statement): Statement[] {\n const siblings = sf.getStatementsWithComments();\n const text = sf.getFullText();\n const comments: Statement[] = [];\n let cursor = statement.getStart(true);\n for (let i = siblings.indexOf(statement) - 1; i >= 0; i--) {\n const node = siblings[i];\n if (!isCommentNode(node)) break;\n if (newlines(text.slice(node.getEnd(), cursor)) > 1) break;\n comments.unshift(node);\n cursor = node.getStart();\n }\n return comments;\n}\n\n/**\n * Remove the JSDoc and comment lines directly above a top-level statement,\n * leaving the statement. For a statement whose comment describes something\n * that has just been swapped out.\n */\nexport function removeAttachedComments(\n sf: SourceFile,\n statement: Statement,\n): void {\n const comments = commentsAbove(sf, statement);\n const spacing = spacingAround(sf, comments[0] ?? statement);\n if (Node.isJSDocable(statement)) {\n for (const doc of statement.getJsDocs()) doc.remove();\n }\n for (const comment of comments.reverse()) comment.remove();\n spacing.restore(statement);\n}\n\n/**\n * Remove a top-level statement together with its JSDoc, the comment lines\n * directly above it and a comment trailing its last line. ts-morph's own\n * `remove()` leaves the comment lines behind as orphans.\n */\nexport function removeStatementWithComments(\n sf: SourceFile,\n statement: Statement,\n): void {\n const comments = commentsAbove(sf, statement);\n const siblings = sf.getStatementsWithComments();\n const next = siblings[siblings.indexOf(statement) + 1];\n const spacing = spacingAround(sf, comments[0] ?? statement);\n statement.remove();\n for (const comment of comments.reverse()) comment.remove();\n if (next) spacing.restore(next);\n}\n\n/**\n * ts-morph takes the blank line before a removed statement or comment with\n * it. Note whether `first` (the start of what is about to go) was set off by\n * one, so `restore` can put it back before whatever follows.\n */\nfunction spacingAround(sf: SourceFile, first: Statement) {\n const siblings = sf.getStatementsWithComments();\n const prev = siblings[siblings.indexOf(first) - 1];\n const setOff =\n prev !== undefined &&\n newlines(sf.getFullText().slice(prev.getEnd(), first.getStart(true))) > 1;\n return {\n restore(next: Statement) {\n if (!setOff || !prev) return;\n const gap = sf.getFullText().slice(prev.getEnd(), next.getStart(true));\n if (newlines(gap) < 2) sf.insertText(prev.getEnd(), \"\\n\");\n },\n };\n}\n\n/**\n * True when the file has no statements left: only comments and whitespace,\n * or nothing at all. A revert that empties a file it once created reports\n * the file as a delete instead.\n */\nexport function isEffectivelyEmpty(sf: SourceFile): boolean {\n return sf.compilerNode.statements.every(\n (s) => s.kind === SyntaxKind.EmptyStatement,\n );\n}\n\n/**\n * Keep one blank line between the import block and what follows. Removing\n * statements right after the imports takes the separating blank line with\n * them, and prettier preserves whichever spacing it finds.\n */\nexport function ensureBlankLineAfterImports(sf: SourceFile): void {\n const imports = sf.getImportDeclarations();\n const last = imports[imports.length - 1];\n const next = last?.getNextSibling();\n if (!last || !next) return;\n // Up to the next statement's JSDoc, whose own newlines are no blank line.\n const between = sf.getFullText().slice(last.getEnd(), next.getStart(true));\n if ((between.match(/\\n/g) ?? []).length >= 2) return;\n sf.insertText(last.getEnd(), \"\\n\");\n}\n\n/**\n * Remove a top-level function or variable declaration by name, if present.\n * In a statement that declares several variables only `name`'s declarator\n * goes; the statement goes with its last one.\n */\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 decl = sf\n .getVariableStatements()\n .flatMap((s) => s.getDeclarations())\n .find((d) => d.getName() === name);\n if (decl) {\n decl.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 importDecl = sf\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === iconImportPath);\n if (importDecl) {\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() !== SyntaxKind.ImportClause &&\n id.getParent()?.getKind() !== 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","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { toDeleteEntry } from \"../patterns/destroy/shared\";\nimport { isEffectivelyEmpty, withInMemoryScript } from \"./ts-morph-helpers\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n\n/**\n * `modifyOutcomeToFile` for a revert that may have taken out everything the\n * file held: a script left with no statements, only comments and whitespace,\n * is reported as a delete. For hooks files a pattern created, or that ended\n * up holding nothing but what patterns put there.\n */\nexport function revertOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(filePath) &&\n withInMemoryScript(fs.readFileSync(filePath, \"utf8\"), isEffectivelyEmpty)\n .result\n ) {\n return { modify: null, delete: toDeleteEntry(filePath) };\n }\n return { modify: modifyOutcomeToFile(filePath, outcome), delete: null };\n}\n\n/**\n * Drop any create that already exists on disk.\n *\n * `writeResult` overwrites an existing create whose content differs and\n * reports it as a modify, which would mean a re-run silently resetting a\n * developer's edits, or a create clobbering a file other patterns have\n * already written to. The file is theirs once it exists; a pattern that has\n * something to add to it does so with a modifier.\n */\nexport function keepMissing(creates: File[], root: string): File[] {\n return creates.filter((file) => !fs.existsSync(path.join(root, file.path)));\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,EACd,GACA,GAC+B;CAM/B,IAAM,IAAK,IALS,EAAQ;EAC1B,uBAAuB;EACvB,8BAA8B;EAC9B,sBAAsB,EAAE,WAAW,EAAU,OAAO;CACtD,CACW,CAAA,CAAQ,iBAAiB,aAAa,GAAQ,EAAE,WAAW,GAAK,CAAC,GACtE,IAAS,EAAG,CAAE;CACpB,OAAO;EAAE,QAAQ,EAAG,YAAY;EAAG;CAAO;AAC5C;AAGA,SAAgB,EAAc,GAAgB,GAA6B;CACzE,KAAK,IAAM,KAAQ,GAAS;EAI1B,IAHiB,EACd,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,EAAK,eAChD,GAAU;EAEd,IAAM,IAAsD,EAC1D,iBAAiB,EAAK,gBACxB;EAIA,AAHI,EAAK,kBAAe,EAAU,gBAAgB,EAAK,gBACnD,EAAK,oBAAiB,EAAU,kBAAkB,EAAK,kBACvD,EAAK,iBAAc,EAAU,eAAe,EAAK,eACrD,EAAG,qBAAqB,CAAS;CACnC;AACF;AAGA,SAAgB,EACd,GACA,GACyB;CACzB,IAAM,IAAO,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,CAAe;CAG9D,OAFK,KACL,EAAK,OAAO,GACL,EAAE,YAAY,GAAK,KAFR,EAAE,YAAY,GAAM;AAGxC;AAMA,SAAgB,EAAa,GAAgB,GAAwB;CACnE,OAAO,EAAG,qBAAqB,EAAW,UAAU,CAAC,CAAC,MAAM,MAAO;EACjE,IAAI,EAAG,QAAQ,MAAM,GAAO,OAAO;EACnC,IAAM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EAAQ;CACnB;AACF;AAQA,SAAgB,EACd,GACA,GAC8C;CAU9C,OARE,EAAQ,WAAW,aACnB,EAAQ,WACR,EAAG,WAAW,CAAQ,KACtB,EAAmB,EAAG,aAAa,GAAU,MAAM,GAAG,CAAkB,CAAC,CACtE,SAEI;EAAE,QAAQ;EAAM,QAAQ,EAAc,CAAQ;CAAE,IAElD;EAAE,QAAQ,EAAoB,GAAU,CAAO;EAAG,QAAQ;CAAK;AACxE;AAWA,SAAgB,EAAY,GAAiB,GAAsB;CACjE,OAAO,EAAQ,QAAQ,MAAS,CAAC,EAAG,WAAW,EAAK,KAAK,GAAM,EAAK,IAAI,CAAC,CAAC;AAC5E"}
@@ -1,4 +1,4 @@
1
- import { i as e, n as t, r as n } from "./config-target-DOi8kI_f.js";
1
+ import { i as e, n as t, r as n } from "./config-target-Co-ij8p3.js";
2
2
  //#region src/runtime/modify-svelte-config-remote.ts
3
3
  var r = [
4
4
  "Enable SvelteKit remote functions and Svelte async in your config",
@@ -41,4 +41,4 @@ function a(a) {
41
41
  //#endregion
42
42
  export { a as modifySvelteConfigRemote };
43
43
 
44
- //# sourceMappingURL=modify-svelte-config-remote-D3eBzcZc.js.map
44
+ //# sourceMappingURL=modify-svelte-config-remote-CDKs_Qi0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modify-svelte-config-remote-D3eBzcZc.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
+ {"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,6 +1,6 @@
1
1
  import { i as e, n as t } from "./constants-DSFKQwtP.js";
2
- import n from "node:path";
3
- import { existsSync as r, readFileSync as i, readdirSync as a } from "node:fs";
2
+ import { existsSync as n, readFileSync as r, readdirSync as i } from "node:fs";
3
+ import a from "node:path";
4
4
  import o from "pocketbase";
5
5
  import { detect as s } from "package-manager-detector";
6
6
  import { resolveCommand as c } from "package-manager-detector/commands";
@@ -158,13 +158,13 @@ var _ = 1100;
158
158
  function v() {
159
159
  return new Promise((e) => setTimeout(e, _));
160
160
  }
161
- function y(t, r, i) {
162
- let o = `${r}_${t}.js`, s = a(n.join(i.root, e)).filter((e) => e.endsWith(o)).sort().pop();
163
- if (s) return n.join(i.root, e, s);
161
+ function y(t, n, r) {
162
+ let o = `${n}_${t}.js`, s = i(a.join(r.root, e)).filter((e) => e.endsWith(o)).sort().pop();
163
+ if (s) return a.join(r.root, e, s);
164
164
  }
165
165
  function b(e) {
166
- let t = n.join(e, "node_modules", ".vite", "_pocketbase_metadata.json");
167
- return r(t) ? JSON.parse(i(t, "utf8")) : null;
166
+ let t = a.join(e, "node_modules", ".vite", "_pocketbase_metadata.json");
167
+ return n(t) ? JSON.parse(r(t, "utf8")) : null;
168
168
  }
169
169
  async function x(e, t, n) {
170
170
  let r = !1;
@@ -176,13 +176,13 @@ async function x(e, t, n) {
176
176
  }
177
177
  if (!r) throw Error("Failed to authenticate with PocketBase. Check your superuser credentials.");
178
178
  }
179
- async function S(i, a) {
180
- let u = n.join(i, t), d = n.join(i, e), f = "localhost";
181
- if (!r(u)) throw Error("PocketBase data directory does not exist");
182
- let h = b(i);
179
+ async function S(r, i) {
180
+ let u = a.join(r, t), d = a.join(r, e), f = "localhost";
181
+ if (!n(u)) throw Error("PocketBase data directory does not exist");
182
+ let h = b(r);
183
183
  if (h && h.pocketbaseUrl) {
184
184
  let e = new o(h.pocketbaseUrl);
185
- await x(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await a(e);
185
+ await x(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await i(e);
186
186
  return;
187
187
  }
188
188
  let _ = await p(f), v = [
@@ -194,10 +194,10 @@ async function S(i, a) {
194
194
  d,
195
195
  "--http",
196
196
  `${f}:${_}`
197
- ], y = (await s({ cwd: i }))?.name ?? "npm", { command: S, args: w } = c(y, "execute", v);
197
+ ], y = (await s({ cwd: r }))?.name ?? "npm", { command: S, args: w } = c(y, "execute", v);
198
198
  y === "npm" && w.unshift("--yes");
199
199
  let T = process.platform !== "win32", E = l(S, w, {
200
- cwd: i,
200
+ cwd: r,
201
201
  stdio: "ignore",
202
202
  detached: T
203
203
  }), D = new Promise((e, t) => {
@@ -210,7 +210,7 @@ async function S(i, a) {
210
210
  await m(_, f), await g(`http://${f}:${_}`);
211
211
  })(), D]);
212
212
  let e = new o(`http://${f}:${_}`);
213
- await x(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await a(e);
213
+ await x(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await i(e);
214
214
  } finally {
215
215
  C(E, T);
216
216
  }
@@ -225,4 +225,4 @@ function C(e, t) {
225
225
  //#endregion
226
226
  export { y as getMigrationFile, v as migrationDelay, S as withPocketbase };
227
227
 
228
- //# sourceMappingURL=pocketbase-BerjVikJ.js.map
228
+ //# sourceMappingURL=pocketbase-ewxQLtse.js.map