@velastack/patterns 0.2.12 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/chunks/{collections-CcL5bbBk.js → collections-CgdvZXmh.js} +17 -17
- package/dist/chunks/{collections-CcL5bbBk.js.map → collections-CgdvZXmh.js.map} +1 -1
- package/dist/chunks/{compose-handle-D16KmBVd.js → compose-handle-Cg9jnCsS.js} +21 -21
- package/dist/chunks/{compose-handle-D16KmBVd.js.map → compose-handle-Cg9jnCsS.js.map} +1 -1
- package/dist/chunks/dispatch-BRnt8PcW.js +6 -0
- package/dist/chunks/dispatch-BRnt8PcW.js.map +1 -0
- package/dist/chunks/generate-BkQ1xMDp.js +30 -0
- package/dist/chunks/generate-BkQ1xMDp.js.map +1 -0
- package/dist/chunks/{generate-Va1sxVPG.js → generate-DRA63W0r.js} +17 -64
- package/dist/chunks/generate-DRA63W0r.js.map +1 -0
- package/dist/chunks/generate-_LvrYK6i.js +55 -0
- package/dist/chunks/generate-_LvrYK6i.js.map +1 -0
- package/dist/chunks/generate-iQP31-m1.js +252 -0
- package/dist/chunks/generate-iQP31-m1.js.map +1 -0
- package/dist/chunks/{generate.runtime-j1gfY6Xq.js → generate.runtime-B0hhtyAL.js} +2 -2
- package/dist/chunks/{generate.runtime-j1gfY6Xq.js.map → generate.runtime-B0hhtyAL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CSXj-ebM.js → generate.runtime-B49wetSx.js} +12 -12
- package/dist/chunks/{generate.runtime-CSXj-ebM.js.map → generate.runtime-B49wetSx.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DAkg7Fy5.js → generate.runtime-B7LRx-BU.js} +2 -2
- package/dist/chunks/{generate.runtime-DAkg7Fy5.js.map → generate.runtime-B7LRx-BU.js.map} +1 -1
- package/dist/chunks/generate.runtime-BKo-Nidn.js +38 -0
- package/dist/chunks/generate.runtime-BKo-Nidn.js.map +1 -0
- package/dist/chunks/{generate.runtime-Zh5n8XpR.js → generate.runtime-BORbegw_.js} +106 -96
- package/dist/chunks/generate.runtime-BORbegw_.js.map +1 -0
- package/dist/chunks/{generate.runtime-BL7uKgW7.js → generate.runtime-BbIN0tUZ.js} +16 -16
- package/dist/chunks/{generate.runtime-BL7uKgW7.js.map → generate.runtime-BbIN0tUZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CwzHEcKv.js → generate.runtime-BnWE4qsu.js} +24 -24
- package/dist/chunks/generate.runtime-BnWE4qsu.js.map +1 -0
- package/dist/chunks/{generate.runtime-CiTmbkAk.js → generate.runtime-BwhGDnGu.js} +3 -3
- package/dist/chunks/generate.runtime-BwhGDnGu.js.map +1 -0
- package/dist/chunks/{generate.runtime-BdPtilz4.js → generate.runtime-CCg2Pjcv.js} +13 -13
- package/dist/chunks/{generate.runtime-BdPtilz4.js.map → generate.runtime-CCg2Pjcv.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BbNMkG4j.js → generate.runtime-CRYjWJRe.js} +9 -9
- package/dist/chunks/{generate.runtime-BbNMkG4j.js.map → generate.runtime-CRYjWJRe.js.map} +1 -1
- package/dist/chunks/generate.runtime-CcuAXuV2.js +60 -0
- package/dist/chunks/generate.runtime-CcuAXuV2.js.map +1 -0
- package/dist/chunks/{generate.runtime-DPIH5sSI.js → generate.runtime-D0icLb5j.js} +51 -48
- package/dist/chunks/{generate.runtime-DPIH5sSI.js.map → generate.runtime-D0icLb5j.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CJVy-mMN.js → generate.runtime-D2e_KRj0.js} +2 -2
- package/dist/chunks/{generate.runtime-CJVy-mMN.js.map → generate.runtime-D2e_KRj0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DnWw9tL1.js → generate.runtime-D44gjxRA.js} +105 -102
- package/dist/chunks/generate.runtime-D44gjxRA.js.map +1 -0
- package/dist/chunks/{generate.runtime-1gbaOucO.js → generate.runtime-D8vgh5MH.js} +48 -7
- package/dist/chunks/generate.runtime-D8vgh5MH.js.map +1 -0
- package/dist/chunks/generate.runtime-DAmYsIvF.js +32 -0
- package/dist/chunks/generate.runtime-DAmYsIvF.js.map +1 -0
- package/dist/chunks/{generate.runtime-CVLtEsXb.js → generate.runtime-DNaQxed-.js} +35 -35
- package/dist/chunks/{generate.runtime-CVLtEsXb.js.map → generate.runtime-DNaQxed-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-d9HT4v-7.js → generate.runtime-DOuufRLr.js} +4 -4
- package/dist/chunks/generate.runtime-DOuufRLr.js.map +1 -0
- package/dist/chunks/{generate.runtime-A8wfItN7.js → generate.runtime-DSqkXvps.js} +12 -12
- package/dist/chunks/{generate.runtime-A8wfItN7.js.map → generate.runtime-DSqkXvps.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BX53l-rL.js → generate.runtime-DhkaXTq3.js} +3 -3
- package/dist/chunks/{generate.runtime-BX53l-rL.js.map → generate.runtime-DhkaXTq3.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dywp4xth.js → generate.runtime-DoZdSh9W.js} +2 -2
- package/dist/chunks/{generate.runtime-Dywp4xth.js.map → generate.runtime-DoZdSh9W.js.map} +1 -1
- package/dist/chunks/{generate.runtime-T9DZJH8m.js → generate.runtime-S5RIgbQx.js} +103 -100
- package/dist/chunks/generate.runtime-S5RIgbQx.js.map +1 -0
- package/dist/chunks/{generate.runtime-CN3v78hx.js → generate.runtime-WmSMWL15.js} +17 -17
- package/dist/chunks/{generate.runtime-CN3v78hx.js.map → generate.runtime-WmSMWL15.js.map} +1 -1
- package/dist/chunks/generate.runtime-acRmiU7e.js +81 -0
- package/dist/chunks/generate.runtime-acRmiU7e.js.map +1 -0
- package/dist/chunks/{generate.runtime-l-Tiahb2.js → generate.runtime-flFRYzpi.js} +34 -59
- package/dist/chunks/generate.runtime-flFRYzpi.js.map +1 -0
- package/dist/chunks/generate.runtime-gtpOuLNO.js +110 -0
- package/dist/chunks/generate.runtime-gtpOuLNO.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dx8Mcs2i.js → generate.runtime-kLxeDGnS.js} +13 -13
- package/dist/chunks/{generate.runtime-Dx8Mcs2i.js.map → generate.runtime-kLxeDGnS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BqxVaq5P.js → generate.runtime-wA1G3tQ4.js} +18 -18
- package/dist/chunks/{generate.runtime-BqxVaq5P.js.map → generate.runtime-wA1G3tQ4.js.map} +1 -1
- package/dist/chunks/{modify-file-BlWTOkCH.js → modify-file-GQD6uNgI.js} +52 -10
- package/dist/chunks/modify-file-GQD6uNgI.js.map +1 -0
- package/dist/chunks/{pocketbase-ewxQLtse.js → pocketbase-CeG5BMN2.js} +59 -52
- package/dist/chunks/{pocketbase-ewxQLtse.js.map → pocketbase-CeG5BMN2.js.map} +1 -1
- package/dist/chunks/providers-DO9kMyzB.js +69 -0
- package/dist/chunks/providers-DO9kMyzB.js.map +1 -0
- package/dist/chunks/rolldown-runtime-DArdT4gl.js +23 -0
- package/dist/chunks/{shared-Bm3eMFy-.js → shared-BwHQM-a9.js} +2 -2
- package/dist/chunks/{shared-Bm3eMFy-.js.map → shared-BwHQM-a9.js.map} +1 -1
- package/dist/chunks/site-D027dpBm.js +55 -0
- package/dist/chunks/site-D027dpBm.js.map +1 -0
- package/dist/chunks/{ui-CD-psDWi.js → ui-B4Tuit-7.js} +2 -2
- package/dist/chunks/{ui-CD-psDWi.js.map → ui-B4Tuit-7.js.map} +1 -1
- package/dist/chunks/{write-result-DBKv-Q7J.js → write-result-DewHCNhM.js} +2 -2
- package/dist/chunks/{write-result-DBKv-Q7J.js.map → write-result-DewHCNhM.js.map} +1 -1
- package/dist/index.d.ts +268 -62
- package/dist/index.js +2263 -2244
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/dispatch-B5PfQ2CA.js +0 -6
- package/dist/chunks/dispatch-B5PfQ2CA.js.map +0 -1
- package/dist/chunks/generate-Va1sxVPG.js.map +0 -1
- package/dist/chunks/generate.runtime-1gbaOucO.js.map +0 -1
- package/dist/chunks/generate.runtime-Bb64J0ab.js +0 -87
- package/dist/chunks/generate.runtime-Bb64J0ab.js.map +0 -1
- package/dist/chunks/generate.runtime-CiTmbkAk.js.map +0 -1
- package/dist/chunks/generate.runtime-CwzHEcKv.js.map +0 -1
- package/dist/chunks/generate.runtime-Dj22Kx0W.js +0 -107
- package/dist/chunks/generate.runtime-Dj22Kx0W.js.map +0 -1
- package/dist/chunks/generate.runtime-DnWw9tL1.js.map +0 -1
- package/dist/chunks/generate.runtime-T9DZJH8m.js.map +0 -1
- package/dist/chunks/generate.runtime-Zh5n8XpR.js.map +0 -1
- package/dist/chunks/generate.runtime-d9HT4v-7.js.map +0 -1
- package/dist/chunks/generate.runtime-l-Tiahb2.js.map +0 -1
- package/dist/chunks/modify-file-BlWTOkCH.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { t } from "./shared-
|
|
3
|
-
import {
|
|
2
|
+
import { t } from "./shared-BwHQM-a9.js";
|
|
3
|
+
import { modifyOutcomeToFile as n, u as r } from "./modify-file-GQD6uNgI.js";
|
|
4
4
|
import { t as i } from "./svelte-file-B3RfgVdt.js";
|
|
5
5
|
import a from "node:fs";
|
|
6
6
|
import o from "node:path";
|
|
@@ -52,13 +52,13 @@ function u(e) {
|
|
|
52
52
|
status: "success",
|
|
53
53
|
changed: !1
|
|
54
54
|
};
|
|
55
|
-
let
|
|
55
|
+
let n = new i(t), o = !1, s = (e) => {
|
|
56
56
|
o || e((e) => {
|
|
57
|
-
let t =
|
|
57
|
+
let t = r(e, "API Keys", "@lucide/svelte/icons/key-round");
|
|
58
58
|
return t.wasRemoved && (o = !0), t.source;
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
|
-
return s((e) =>
|
|
61
|
+
return s((e) => n.modifyModuleScript(e)), o || s((e) => n.modifyScript(e)), o ? (a.writeFileSync(e, n.toString(), "utf8"), {
|
|
62
62
|
status: "success",
|
|
63
63
|
changed: !0
|
|
64
64
|
}) : {
|
|
@@ -68,15 +68,15 @@ function u(e) {
|
|
|
68
68
|
}
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/patterns/disable/api-keys/generate.runtime.ts
|
|
71
|
-
async function d(
|
|
72
|
-
let i = e(
|
|
71
|
+
async function d(r) {
|
|
72
|
+
let i = e(r), a = [], s = (e) => {
|
|
73
73
|
e && a.push(e);
|
|
74
74
|
};
|
|
75
75
|
i.info("Reverting hooks.server.ts");
|
|
76
|
-
let c = o.join(
|
|
77
|
-
s(
|
|
78
|
-
let d = o.join(
|
|
79
|
-
return s(
|
|
76
|
+
let c = o.join(r.root, "src", "hooks.server.ts");
|
|
77
|
+
s(n(c, l(c))), i.info("Reverting nav-user.svelte");
|
|
78
|
+
let d = o.join(r.root, "src", "lib", "components", "nav-user.svelte");
|
|
79
|
+
return s(n(d, u(d))), {
|
|
80
80
|
creates: [],
|
|
81
81
|
modifies: a,
|
|
82
82
|
deletes: [],
|
|
@@ -84,10 +84,10 @@ async function d(n) {
|
|
|
84
84
|
packages: [],
|
|
85
85
|
collections: [],
|
|
86
86
|
collectionPatches: [],
|
|
87
|
-
collectionDrops: await t(["api_keys"],
|
|
87
|
+
collectionDrops: await t(["api_keys"], r)
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
91
91
|
export { d as generate };
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=generate.runtime-
|
|
93
|
+
//# sourceMappingURL=generate.runtime-kLxeDGnS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-kLxeDGnS.js","names":[],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/api-keys\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,EAAoB,GAAwC;CAC1E,IAAI,CAAC,EAAG,WAAW,CAAe,GAChC,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EAC7D,KACJ,GAAK,MAAQ;GACX,IAAM,IAAS,EACb,GACA,YACA,gCACF;GAEA,OADI,EAAO,eAAY,IAAa,KAC7B,EAAO;EAChB,CAAC;CACH;CAUA,OARA,GAAW,MAAO,EAAK,mBAAmB,CAAE,CAAC,GACxC,KAAY,GAAW,MAAO,EAAK,aAAa,CAAE,CAAC,GAEnD,KAIL,EAAG,cAAc,GAAa,EAAK,SAAS,GAAG,MAAM,GAC9C;EAAE,QAAQ;EAAW,SAAS;CAAK,KAJjC;EAAE,QAAQ;EAAW,SAAS;CAAM;AAK/C;;;AChCA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,iBAAiB;CAKxE,AAJA,EACE,EAAoB,GAAiB,EAAoB,CAAe,CAAC,CAC3E,GAEA,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,iBACF;CAKA,OAJA,EAAW,EAAoB,GAAa,EAAgB,CAAW,CAAC,CAAC,GAIlE;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAV4B,EAAwB,CAAC,UAAU,GAAG,CAAO;CAW3E;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { t } from "./shared-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { t } from "./shared-BwHQM-a9.js";
|
|
3
|
+
import { n } from "./env-BPfk1VAw.js";
|
|
4
|
+
import { modifyOutcomeToFile as r, u as i } from "./modify-file-GQD6uNgI.js";
|
|
5
|
+
import { t as a } from "./svelte-file-B3RfgVdt.js";
|
|
6
6
|
import o from "node:fs";
|
|
7
7
|
import s from "node:path";
|
|
8
8
|
import { Project as c, QuoteKind as l, SyntaxKind as u } from "ts-morph";
|
|
@@ -17,13 +17,13 @@ function d(e) {
|
|
|
17
17
|
status: "success",
|
|
18
18
|
changed: !1
|
|
19
19
|
};
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
let t =
|
|
23
|
-
return t.wasRemoved && (
|
|
20
|
+
let n = new a(t), r = !1, s = (e) => {
|
|
21
|
+
r || e((e) => {
|
|
22
|
+
let t = i(e, "Billing", "@lucide/svelte/icons/credit-card");
|
|
23
|
+
return t.wasRemoved && (r = !0), t.source;
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
return s((e) =>
|
|
26
|
+
return s((e) => n.modifyModuleScript(e)), r || s((e) => n.modifyScript(e)), r ? (o.writeFileSync(e, n.toString(), "utf8"), {
|
|
27
27
|
status: "success",
|
|
28
28
|
changed: !0
|
|
29
29
|
}) : {
|
|
@@ -63,8 +63,8 @@ function p(e) {
|
|
|
63
63
|
}
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/patterns/disable/payments/generate.runtime.ts
|
|
66
|
-
async function m(
|
|
67
|
-
let
|
|
66
|
+
async function m(i) {
|
|
67
|
+
let a = i.features.auth, o = e(i), c = [], l = (e) => {
|
|
68
68
|
e && c.push(e);
|
|
69
69
|
};
|
|
70
70
|
o.info("Stripping Stripe credentials from .env");
|
|
@@ -85,12 +85,12 @@ async function m(n) {
|
|
|
85
85
|
type: "var",
|
|
86
86
|
key: "STRIPE_WEBHOOK_SECRET"
|
|
87
87
|
}
|
|
88
|
-
], f = s.join(
|
|
89
|
-
if (l(r(f,
|
|
88
|
+
], f = s.join(i.root, ".env");
|
|
89
|
+
if (l(r(f, n(f, u))), a) {
|
|
90
90
|
o.info("Reverting nav-user.svelte");
|
|
91
|
-
let e = s.join(
|
|
91
|
+
let e = s.join(i.root, "src", "lib", "components", "nav-user.svelte");
|
|
92
92
|
l(r(e, d(e))), o.info("Reverting signup +page.server.ts");
|
|
93
|
-
let t = s.join(
|
|
93
|
+
let t = s.join(i.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
|
|
94
94
|
l(r(t, p(t)));
|
|
95
95
|
}
|
|
96
96
|
return {
|
|
@@ -101,16 +101,16 @@ async function m(n) {
|
|
|
101
101
|
packages: [],
|
|
102
102
|
collections: [],
|
|
103
103
|
collectionPatches: [],
|
|
104
|
-
collectionDrops: await t(
|
|
104
|
+
collectionDrops: await t(a ? [
|
|
105
105
|
"transactions",
|
|
106
106
|
"stripe_customers",
|
|
107
107
|
"stripe_payment_methods",
|
|
108
108
|
"stripe_prices",
|
|
109
109
|
"stripe_products"
|
|
110
|
-
] : ["stripe_prices", "stripe_products"],
|
|
110
|
+
] : ["stripe_prices", "stripe_products"], i)
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
//#endregion
|
|
114
114
|
export { m as generate };
|
|
115
115
|
|
|
116
|
-
//# sourceMappingURL=generate.runtime-
|
|
116
|
+
//# sourceMappingURL=generate.runtime-wA1G3tQ4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-wA1G3tQ4.js","names":[],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const specifier of [\n \"$lib/workflows/link-stripe-customer\",\n \"$lib/stripe\",\n ]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === specifier);\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n if (stmt) stmt.remove();\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnvRemove, type EnvEdit } from \"../../../runtime/env\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Stripping Stripe credentials from .env\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\" },\n { type: \"var\", key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\" },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\" },\n ];\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnvRemove(envPath, envEdits)));\n\n if (isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n const collectionNames = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n ];\n const collectionDrops = await planDropsForCollections(\n isAppMode ? collectionNames : [\"stripe_prices\", \"stripe_products\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAKA,SAAgB,EAAgB,GAAoC;CAClE,IAAI,CAAC,EAAG,WAAW,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAS,EAAG,aAAa,GAAa,MAAM;CAClD,IAAI,CAAC,EAAO,SAAS,UAAU,GAC7B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,IAAI,EAAW,CAAM,GAC9B,IAAa,IAEX,KAAa,MAAgD;EAC7D,KACJ,GAAK,MAAQ;GACX,IAAM,IAAS,EACb,GACA,WACA,kCACF;GAEA,OADI,EAAO,eAAY,IAAa,KAC7B,EAAO;EAChB,CAAC;CACH;CAUA,OARA,GAAW,MAAO,EAAK,mBAAmB,CAAE,CAAC,GACxC,KAAY,GAAW,MAAO,EAAK,aAAa,CAAE,CAAC,GAEnD,KAIL,EAAG,cAAc,GAAa,EAAK,SAAS,GAAG,MAAM,GAC9C;EAAE,QAAQ;EAAW,SAAS;CAAK,KAJjC;EAAE,QAAQ;EAAW,SAAS;CAAM;AAK/C;;;ACpCA,IAAM,oBAAmB,IAAI,IAAI,CAC/B,0BAEA,oBACF,CAAC;AAED,SAAgB,EAAmB,GAAuC;CACxE,IAAI,CAAC,EAAG,WAAW,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAgB,MAAM;CAC7D,IAAI,CAAC,EAAe,SAAS,oBAAoB,GAC/C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAM7C,IAAM,IAAa,IAHC,EAAQ,EAC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O,KAAK,2BAA2B;EACvC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,iBACF;EAGA,AAFA,EAAW,EAAoB,GAAa,EAAgB,CAAW,CAAC,CAAC,GAEzE,EAAO,KAAK,kCAAkC;EAC9C,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,YACA,UACA,UACA,iBACF;EACA,EACE,EAAoB,GAAgB,EAAmB,CAAc,CAAC,CACxE;CACF;CAcA,OAAO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B,EAC5B,IAAY;GAPZ;GACA;GACA;GACA;GACA;EAGY,IAAkB,CAAC,iBAAiB,iBAAiB,GACjE,CACF;CAWA;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as e } from "./util-BLYliuUK.js";
|
|
2
|
-
import { n as t } from "./shared-
|
|
2
|
+
import { n as t } from "./shared-BwHQM-a9.js";
|
|
3
3
|
import n from "node:fs";
|
|
4
4
|
import r from "node:path";
|
|
5
5
|
import { Node as i, Project as a, QuoteKind as o, SyntaxKind as s } from "ts-morph";
|
|
@@ -110,13 +110,46 @@ function S(e) {
|
|
|
110
110
|
let t = e.getImportDeclarations(), n = t[t.length - 1], r = n?.getNextSibling();
|
|
111
111
|
n && r && ((e.getFullText().slice(n.getEnd(), r.getStart(!0)).match(/\n/g) ?? []).length >= 2 || e.insertText(n.getEnd(), "\n"));
|
|
112
112
|
}
|
|
113
|
-
function C(e
|
|
113
|
+
function C(e) {
|
|
114
|
+
return e.getVariableDeclarations().find((e) => e.getInitializer()?.getText() === "$props()" && i.isObjectBindingPattern(e.getNameNode()));
|
|
115
|
+
}
|
|
116
|
+
function w(e) {
|
|
117
|
+
return C(e)?.getNameNode().asKind(s.ObjectBindingPattern);
|
|
118
|
+
}
|
|
119
|
+
function T(e, t) {
|
|
120
|
+
let n = w(e);
|
|
121
|
+
if (!n) {
|
|
122
|
+
e.addStatements(`let { ${t} } = $props();`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
let r = n.getElements();
|
|
126
|
+
if (r.some((e) => e.getName() === t)) return;
|
|
127
|
+
let i = r.map((e) => e.getText()), a = r.findIndex((e) => e.getDotDotDotToken());
|
|
128
|
+
i.splice(a === -1 ? i.length : a, 0, t), n.replaceWithText(`{ ${i.join(", ")} }`);
|
|
129
|
+
}
|
|
130
|
+
function E(e, t, n) {
|
|
131
|
+
let r = RegExp(`(?<![\\w$.])${t}(?![\\w$])`);
|
|
132
|
+
if ((n.replace(/<style[\s\S]*?<\/style>/g, "").match(/\{[^{}]*\}/g) ?? []).some((e) => r.test(e))) return;
|
|
133
|
+
let i = C(e), a = w(e), o = a?.getElements().find((e) => e.getName() === t && !e.getPropertyNameNode());
|
|
134
|
+
if (!i || !a || !o || e.getDescendantsOfKind(s.Identifier).some((e) => e.getText() === t && !i.containsRange(e.getPos(), e.getEnd()))) return;
|
|
135
|
+
let c = a.getElements().filter((e) => e !== o).map((e) => e.getText());
|
|
136
|
+
a.replaceWithText(`{ ${c.join(", ")} }`);
|
|
137
|
+
}
|
|
138
|
+
function D(e, t) {
|
|
139
|
+
let n = e.getDescendantsOfKind(s.BindingElement).find((e) => e.getName() === t && !e.getPropertyNameNode() && !e.getDotDotDotToken());
|
|
140
|
+
if (!n) return;
|
|
141
|
+
let r = n.getNameNode();
|
|
142
|
+
if (e.getDescendantsOfKind(s.Identifier).some((e) => e.getText() === t && e !== r)) return;
|
|
143
|
+
let a = n.getParentIfKindOrThrow(s.ObjectBindingPattern), o = a.getElements().filter((e) => e !== n).map((e) => e.getText()), c = a.getParent();
|
|
144
|
+
o.length === 0 && i.isParameterDeclaration(c) ? c.remove() : o.length === 0 && i.isVariableDeclaration(c) ? c.getVariableStatement()?.remove() : a.replaceWithText(`{ ${o.join(", ")} }`);
|
|
145
|
+
}
|
|
146
|
+
function O(e, t) {
|
|
114
147
|
let n = e.getFunction(t);
|
|
115
148
|
if (n) return n.remove(), { wasRemoved: !0 };
|
|
116
149
|
let r = e.getVariableStatements().flatMap((e) => e.getDeclarations()).find((e) => e.getName() === t);
|
|
117
150
|
return r ? (r.remove(), { wasRemoved: !0 }) : { wasRemoved: !1 };
|
|
118
151
|
}
|
|
119
|
-
function
|
|
152
|
+
function k(e, t, n, r, i) {
|
|
120
153
|
let a = `
|
|
121
154
|
{
|
|
122
155
|
title: '${t}',
|
|
@@ -147,7 +180,7 @@ function w(e, t, n, r, i) {
|
|
|
147
180
|
wasAdded: u.wasAdded
|
|
148
181
|
};
|
|
149
182
|
}
|
|
150
|
-
function
|
|
183
|
+
function A(e, t, n) {
|
|
151
184
|
let { source: r, result: i } = c(e, (e) => {
|
|
152
185
|
let r = e.getVariableDeclarations().find((e) => e.getName() === "data")?.getInitializer();
|
|
153
186
|
if (!r || r.getKind() !== s.ObjectLiteralExpression) return { wasRemoved: !1 };
|
|
@@ -179,7 +212,7 @@ function T(e, t, n) {
|
|
|
179
212
|
}
|
|
180
213
|
//#endregion
|
|
181
214
|
//#region src/runtime/modify-file.ts
|
|
182
|
-
function
|
|
215
|
+
function j(t, r) {
|
|
183
216
|
let i = e(t);
|
|
184
217
|
return r.status === "success" ? r.changed ? {
|
|
185
218
|
path: t,
|
|
@@ -194,19 +227,28 @@ function E(t, r) {
|
|
|
194
227
|
message: r.message
|
|
195
228
|
};
|
|
196
229
|
}
|
|
197
|
-
function
|
|
230
|
+
function M(e, r) {
|
|
198
231
|
return r.status === "success" && r.changed && n.existsSync(e) && c(n.readFileSync(e, "utf8"), x).result ? {
|
|
199
232
|
modify: null,
|
|
200
233
|
delete: t(e)
|
|
201
234
|
} : {
|
|
202
|
-
modify:
|
|
235
|
+
modify: j(e, r),
|
|
203
236
|
delete: null
|
|
204
237
|
};
|
|
205
238
|
}
|
|
206
|
-
function
|
|
239
|
+
function N(e, r) {
|
|
240
|
+
return r.status === "success" && r.changed && n.existsSync(e) && n.readFileSync(e, "utf8").trim() === "" ? {
|
|
241
|
+
modify: null,
|
|
242
|
+
delete: t(e)
|
|
243
|
+
} : {
|
|
244
|
+
modify: j(e, r),
|
|
245
|
+
delete: null
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function P(e, t) {
|
|
207
249
|
return e.filter((e) => !n.existsSync(r.join(t, e.path)));
|
|
208
250
|
}
|
|
209
251
|
//#endregion
|
|
210
|
-
export {
|
|
252
|
+
export { T as a, u as c, E as d, N as envRevertOutcomeToFile, y as f, c as h, m as i, P as keepMissing, f as l, D as m, j as modifyOutcomeToFile, S as n, p as o, O as p, l as r, M as revertOutcomeToFile, v as s, k as t, A as u };
|
|
211
253
|
|
|
212
|
-
//# sourceMappingURL=modify-file-
|
|
254
|
+
//# sourceMappingURL=modify-file-GQD6uNgI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modify-file-GQD6uNgI.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/** A component's `let { ... } = $props()` declaration, if it destructures. */\nfunction propsDeclaration(sf: SourceFile) {\n return sf\n .getVariableDeclarations()\n .find(\n (decl) =>\n decl.getInitializer()?.getText() === \"$props()\" &&\n Node.isObjectBindingPattern(decl.getNameNode()),\n );\n}\n\n/** The `{ ... }` of a component's `let { ... } = $props()`, if it has one. */\nfunction propsBinding(sf: SourceFile) {\n return propsDeclaration(sf)\n ?.getNameNode()\n .asKind(SyntaxKind.ObjectBindingPattern);\n}\n\n/**\n * Make sure a Svelte component's `$props()` destructures `name`, for markup a\n * modifier inserts that reads it. Adds a `$props()` declaration when the\n * component has none.\n */\nexport function ensurePropsBinding(sf: SourceFile, name: string): void {\n const binding = propsBinding(sf);\n if (!binding) {\n sf.addStatements(`let { ${name} } = $props();`);\n return;\n }\n const elements = binding.getElements();\n if (elements.some((e) => e.getName() === name)) return;\n const texts = elements.map((e) => e.getText());\n const rest = elements.findIndex((e) => e.getDotDotDotToken());\n texts.splice(rest === -1 ? texts.length : rest, 0, name);\n binding.replaceWithText(`{ ${texts.join(\", \")} }`);\n}\n\n/**\n * Drop `name` from a Svelte component's `$props()` once neither the script\n * nor `markup` reads it, undoing `ensurePropsBinding`. The declaration stays\n * even when it empties, as `let {} = $props()` is harmless.\n */\nexport function removePropsBindingIfUnused(\n sf: SourceFile,\n name: string,\n markup: string,\n): void {\n // Only expressions read it: `{data.user}`, `{data}`, `x={data.y}`. A bare\n // word match would also catch `data-role` attributes and body text.\n const reads = new RegExp(`(?<![\\\\w$.])${name}(?![\\\\w$])`);\n const expressions =\n markup.replace(/<style[\\s\\S]*?<\\/style>/g, \"\").match(/\\{[^{}]*\\}/g) ?? [];\n if (expressions.some((expression) => reads.test(expression))) return;\n const decl = propsDeclaration(sf);\n const binding = propsBinding(sf);\n const element = binding\n ?.getElements()\n .find((e) => e.getName() === name && !e.getPropertyNameNode());\n if (!decl || !binding || !element) return;\n // Outside the declaration itself, whose type may name the prop too.\n const usedInScript = sf\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some(\n (id) =>\n id.getText() === name && !decl.containsRange(id.getPos(), id.getEnd()),\n );\n if (usedInScript) return;\n const kept = binding\n .getElements()\n .filter((e) => e !== element)\n .map((e) => e.getText());\n binding.replaceWithText(`{ ${kept.join(\", \")} }`);\n}\n\n/**\n * Drop a destructured `name` (as in `({ locals, url })`) that nothing in the\n * file reads any more, for reverting an edit that was its last use. A\n * parameter left as a bare `{}` goes, as does a `const {} = ...` statement.\n * Conservative: any other identifier spelled `name` keeps it.\n */\nexport function removeUnusedBindingElement(sf: SourceFile, name: string): void {\n const element = sf\n .getDescendantsOfKind(SyntaxKind.BindingElement)\n .find(\n (e) =>\n e.getName() === name &&\n !e.getPropertyNameNode() &&\n !e.getDotDotDotToken(),\n );\n if (!element) return;\n const nameNode = element.getNameNode();\n const referenced = sf\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id) => id.getText() === name && id !== nameNode);\n if (referenced) return;\n\n const pattern = element.getParentIfKindOrThrow(\n SyntaxKind.ObjectBindingPattern,\n );\n const kept = pattern\n .getElements()\n .filter((e) => e !== element)\n .map((e) => e.getText());\n const owner = pattern.getParent();\n if (kept.length === 0 && Node.isParameterDeclaration(owner)) {\n owner.remove();\n } else if (kept.length === 0 && Node.isVariableDeclaration(owner)) {\n owner.getVariableStatement()?.remove();\n } else {\n pattern.replaceWithText(`{ ${kept.join(\", \")} }`);\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 * `modifyOutcomeToFile` for a `.env` revert: a file the revert left empty is\n * reported as a delete. The enable pattern most likely created it, and an\n * empty `.env` holds nothing worth keeping.\n */\nexport function envRevertOutcomeToFile(\n envPath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(envPath) &&\n fs.readFileSync(envPath, \"utf8\").trim() === \"\"\n ) {\n return { modify: null, delete: toDeleteEntry(envPath) };\n }\n return { modify: modifyOutcomeToFile(envPath, 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,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Ac,CAAO;CAAE,IAEjD;EAAE,QAAQ,EAAoB,GAAS,CAAO;EAAG,QAAQ;CAAK;AACvE;AAWA,SAAgB,EAAY,GAAiB,GAAsB;CACjE,OAAO,EAAQ,QAAQ,MAAS,CAAC,EAAG,WAAW,EAAK,KAAK,GAAM,EAAK,IAAI,CAAC,CAAC;AAC5E"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import a from "node:
|
|
4
|
-
import o from "
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import l from "
|
|
8
|
-
import u from "
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DArdT4gl.js";
|
|
2
|
+
import { i as t, n } from "./constants-DSFKQwtP.js";
|
|
3
|
+
import { existsSync as r, readFileSync as i, readdirSync as a } from "node:fs";
|
|
4
|
+
import o from "node:path";
|
|
5
|
+
import s from "pocketbase";
|
|
6
|
+
import { detect as c } from "package-manager-detector";
|
|
7
|
+
import { resolveCommand as l } from "package-manager-detector/commands";
|
|
8
|
+
import u from "cross-spawn";
|
|
9
|
+
import d from "node:net";
|
|
9
10
|
//#region src/runtime/net.ts
|
|
10
|
-
var
|
|
11
|
+
var f = /* @__PURE__ */ new Set([
|
|
11
12
|
1,
|
|
12
13
|
7,
|
|
13
14
|
9,
|
|
@@ -91,26 +92,26 @@ var d = /* @__PURE__ */ new Set([
|
|
|
91
92
|
6697,
|
|
92
93
|
10080
|
|
93
94
|
]);
|
|
94
|
-
function
|
|
95
|
+
function p(e) {
|
|
95
96
|
return new Promise((t, n) => {
|
|
96
|
-
let r =
|
|
97
|
+
let r = d.createServer();
|
|
97
98
|
r.unref(), r.once("error", n), r.listen(0, e, () => {
|
|
98
99
|
let { port: e } = r.address();
|
|
99
100
|
r.close(() => t(e));
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
|
-
async function
|
|
104
|
+
async function m(e) {
|
|
104
105
|
for (;;) {
|
|
105
|
-
let t = await
|
|
106
|
-
if (!
|
|
106
|
+
let t = await p(e);
|
|
107
|
+
if (!f.has(t)) return t;
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
+
function h(e, t, n = 60) {
|
|
110
111
|
return new Promise((r, i) => {
|
|
111
112
|
let a = 0, o = () => {
|
|
112
113
|
a++;
|
|
113
|
-
let s = new
|
|
114
|
+
let s = new d.Socket();
|
|
114
115
|
s.once("error", () => {
|
|
115
116
|
if (s.destroy(), a === n) {
|
|
116
117
|
i(/* @__PURE__ */ Error(`Timed out waiting for port ${e} to be available`));
|
|
@@ -124,12 +125,12 @@ function m(e, t, n = 60) {
|
|
|
124
125
|
o();
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
+
function g(e) {
|
|
128
129
|
if (!(e instanceof Error)) return String(e);
|
|
129
130
|
let { cause: t } = e;
|
|
130
131
|
return t instanceof Error ? t.code || t.message || e.message : t === void 0 ? e.message : String(t);
|
|
131
132
|
}
|
|
132
|
-
function
|
|
133
|
+
function _(e, t = 60) {
|
|
133
134
|
return new Promise((n, r) => {
|
|
134
135
|
let i = 0, a = "no attempt made", o = async () => {
|
|
135
136
|
i++;
|
|
@@ -141,7 +142,7 @@ function g(e, t = 60) {
|
|
|
141
142
|
}
|
|
142
143
|
a = `HTTP ${t.status}`;
|
|
143
144
|
} catch (e) {
|
|
144
|
-
a =
|
|
145
|
+
a = g(e);
|
|
145
146
|
}
|
|
146
147
|
if (i === t) {
|
|
147
148
|
r(/* @__PURE__ */ Error(`Timed out waiting for health check at ${e}/api/health (last attempt: ${a})`));
|
|
@@ -154,19 +155,25 @@ function g(e, t = 60) {
|
|
|
154
155
|
}
|
|
155
156
|
//#endregion
|
|
156
157
|
//#region src/runtime/pocketbase.ts
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
var v = /* @__PURE__ */ e({
|
|
159
|
+
authWithRetries: () => C,
|
|
160
|
+
getMigrationFile: () => x,
|
|
161
|
+
getPocketbaseMetadata: () => S,
|
|
162
|
+
migrationDelay: () => b,
|
|
163
|
+
withPocketbase: () => w
|
|
164
|
+
}), y = 1100;
|
|
165
|
+
function b() {
|
|
166
|
+
return new Promise((e) => setTimeout(e, y));
|
|
160
167
|
}
|
|
161
|
-
function
|
|
162
|
-
let
|
|
163
|
-
if (s) return
|
|
168
|
+
function x(e, n, r) {
|
|
169
|
+
let i = `${n}_${e}.js`, s = a(o.join(r.root, t)).filter((e) => e.endsWith(i)).sort().pop();
|
|
170
|
+
if (s) return o.join(r.root, t, s);
|
|
164
171
|
}
|
|
165
|
-
function
|
|
166
|
-
let t =
|
|
167
|
-
return
|
|
172
|
+
function S(e) {
|
|
173
|
+
let t = o.join(e, "node_modules", ".vite", "_pocketbase_metadata.json");
|
|
174
|
+
return r(t) ? JSON.parse(i(t, "utf8")) : null;
|
|
168
175
|
}
|
|
169
|
-
async function
|
|
176
|
+
async function C(e, t, n) {
|
|
170
177
|
let r = !1;
|
|
171
178
|
for (let i = 1; i <= 3; i++) try {
|
|
172
179
|
await e.collection("_superusers").authWithPassword(t, n), r = !0;
|
|
@@ -176,46 +183,46 @@ async function x(e, t, n) {
|
|
|
176
183
|
}
|
|
177
184
|
if (!r) throw Error("Failed to authenticate with PocketBase. Check your superuser credentials.");
|
|
178
185
|
}
|
|
179
|
-
async function
|
|
180
|
-
let
|
|
181
|
-
if (!
|
|
182
|
-
let
|
|
183
|
-
if (
|
|
184
|
-
let e = new
|
|
185
|
-
await
|
|
186
|
+
async function w(e, i) {
|
|
187
|
+
let a = o.join(e, n), d = o.join(e, t), f = "localhost";
|
|
188
|
+
if (!r(a)) throw Error("PocketBase data directory does not exist");
|
|
189
|
+
let p = S(e);
|
|
190
|
+
if (p && p.pocketbaseUrl) {
|
|
191
|
+
let e = new s(p.pocketbaseUrl);
|
|
192
|
+
await C(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await i(e);
|
|
186
193
|
return;
|
|
187
194
|
}
|
|
188
|
-
let
|
|
195
|
+
let g = await m(f), v = [
|
|
189
196
|
"pocketbase-server",
|
|
190
197
|
"serve",
|
|
191
198
|
"--dir",
|
|
192
|
-
|
|
199
|
+
a,
|
|
193
200
|
"--migrationsDir",
|
|
194
201
|
d,
|
|
195
202
|
"--http",
|
|
196
|
-
`${f}:${
|
|
197
|
-
], y = (await
|
|
198
|
-
y === "npm" &&
|
|
199
|
-
let
|
|
200
|
-
cwd:
|
|
203
|
+
`${f}:${g}`
|
|
204
|
+
], y = (await c({ cwd: e }))?.name ?? "npm", { command: b, args: x } = l(y, "execute", v);
|
|
205
|
+
y === "npm" && x.unshift("--yes");
|
|
206
|
+
let w = process.platform !== "win32", E = u(b, x, {
|
|
207
|
+
cwd: e,
|
|
201
208
|
stdio: "ignore",
|
|
202
|
-
detached:
|
|
209
|
+
detached: w
|
|
203
210
|
}), D = new Promise((e, t) => {
|
|
204
211
|
E.once("exit", (e, n) => {
|
|
205
|
-
t(/* @__PURE__ */ Error(`pocketbase-server exited before listening on ${f}:${
|
|
212
|
+
t(/* @__PURE__ */ Error(`pocketbase-server exited before listening on ${f}:${g} (${n ?? `code ${e}`})`));
|
|
206
213
|
}), E.once("error", t);
|
|
207
214
|
});
|
|
208
215
|
try {
|
|
209
216
|
await Promise.race([(async () => {
|
|
210
|
-
await
|
|
217
|
+
await h(g, f), await _(`http://${f}:${g}`);
|
|
211
218
|
})(), D]);
|
|
212
|
-
let e = new
|
|
213
|
-
await
|
|
219
|
+
let e = new s(`http://${f}:${g}`);
|
|
220
|
+
await C(e, process.env.POCKETBASE_SUPERUSER_EMAIL, process.env.POCKETBASE_SUPERUSER_PASSWORD), await i(e);
|
|
214
221
|
} finally {
|
|
215
|
-
|
|
222
|
+
T(E, w);
|
|
216
223
|
}
|
|
217
224
|
}
|
|
218
|
-
function
|
|
225
|
+
function T(e, t) {
|
|
219
226
|
if (t && e.pid) try {
|
|
220
227
|
process.kill(-e.pid, "SIGTERM");
|
|
221
228
|
return;
|
|
@@ -223,6 +230,6 @@ function C(e, t) {
|
|
|
223
230
|
e.kill();
|
|
224
231
|
}
|
|
225
232
|
//#endregion
|
|
226
|
-
export {
|
|
233
|
+
export { w as i, b as n, v as r, x as t };
|
|
227
234
|
|
|
228
|
-
//# sourceMappingURL=pocketbase-
|
|
235
|
+
//# sourceMappingURL=pocketbase-CeG5BMN2.js.map
|