@velastack/patterns 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -3
- package/dist/chunks/_layout-B7ujvjnA.js +55 -0
- package/dist/chunks/_layout-B7ujvjnA.js.map +1 -0
- package/dist/chunks/{collections-CgdvZXmh.js → collections-CrOvS2E7.js} +3 -3
- package/dist/chunks/{collections-CgdvZXmh.js.map → collections-CrOvS2E7.js.map} +1 -1
- package/dist/chunks/{compose-handle-Cg9jnCsS.js → compose-handle-B-CkDcQD.js} +23 -23
- package/dist/chunks/{compose-handle-Cg9jnCsS.js.map → compose-handle-B-CkDcQD.js.map} +1 -1
- package/dist/chunks/config-target-Bln26FJe.js +164 -0
- package/dist/chunks/config-target-Bln26FJe.js.map +1 -0
- package/dist/chunks/{constants-DSFKQwtP.js → constants-BYkd9jeJ.js} +2 -2
- package/dist/chunks/constants-BYkd9jeJ.js.map +1 -0
- package/dist/chunks/errors-DR3gF_7a.js +18 -0
- package/dist/chunks/errors-DR3gF_7a.js.map +1 -0
- package/dist/chunks/{format-result-Cb2hWsb8.js → format-result-DZ8De8KY.js} +19 -11
- package/dist/chunks/format-result-DZ8De8KY.js.map +1 -0
- package/dist/chunks/{generate-DRA63W0r.js → generate-6snrlnpA.js} +2 -2
- package/dist/chunks/{generate-DRA63W0r.js.map → generate-6snrlnpA.js.map} +1 -1
- package/dist/chunks/{generate-iQP31-m1.js → generate-Ca_6FlPi.js} +5 -5
- package/dist/chunks/{generate-iQP31-m1.js.map → generate-Ca_6FlPi.js.map} +1 -1
- package/dist/chunks/{generate-tOkjJFUf.js → generate-CyuY2Ci7.js} +4 -3
- package/dist/chunks/generate-CyuY2Ci7.js.map +1 -0
- package/dist/chunks/{generate-BkQ1xMDp.js → generate-DQeWOEPY.js} +4 -4
- package/dist/chunks/{generate-BkQ1xMDp.js.map → generate-DQeWOEPY.js.map} +1 -1
- package/dist/chunks/{generate-_LvrYK6i.js → generate-DwADTUob.js} +4 -4
- package/dist/chunks/{generate-_LvrYK6i.js.map → generate-DwADTUob.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BbIN0tUZ.js → generate.runtime-4FDxnvCl.js} +67 -66
- package/dist/chunks/generate.runtime-4FDxnvCl.js.map +1 -0
- package/dist/chunks/{generate.runtime-B0hhtyAL.js → generate.runtime-AYQVW1S-.js} +27 -26
- package/dist/chunks/generate.runtime-AYQVW1S-.js.map +1 -0
- package/dist/chunks/{generate.runtime-wA1G3tQ4.js → generate.runtime-B2aFFaac.js} +38 -37
- package/dist/chunks/generate.runtime-B2aFFaac.js.map +1 -0
- package/dist/chunks/{generate.runtime-DhkaXTq3.js → generate.runtime-B45MvtYm.js} +61 -59
- package/dist/chunks/generate.runtime-B45MvtYm.js.map +1 -0
- package/dist/chunks/{generate.runtime-S5RIgbQx.js → generate.runtime-BFOXm2DD.js} +98 -92
- package/dist/chunks/generate.runtime-BFOXm2DD.js.map +1 -0
- package/dist/chunks/{generate.runtime-BnWE4qsu.js → generate.runtime-BHkFmI2Y.js} +55 -54
- package/dist/chunks/generate.runtime-BHkFmI2Y.js.map +1 -0
- package/dist/chunks/{generate.runtime-DNaQxed-.js → generate.runtime-BKiJvE8I.js} +84 -83
- package/dist/chunks/generate.runtime-BKiJvE8I.js.map +1 -0
- package/dist/chunks/{generate.runtime-DoZdSh9W.js → generate.runtime-BSRFv4cJ.js} +58 -57
- package/dist/chunks/generate.runtime-BSRFv4cJ.js.map +1 -0
- package/dist/chunks/{generate.runtime-B49wetSx.js → generate.runtime-BUqsF3AF.js} +43 -42
- package/dist/chunks/generate.runtime-BUqsF3AF.js.map +1 -0
- package/dist/chunks/{generate.runtime-acRmiU7e.js → generate.runtime-BsaSyTnU.js} +9 -8
- package/dist/chunks/{generate.runtime-acRmiU7e.js.map → generate.runtime-BsaSyTnU.js.map} +1 -1
- package/dist/chunks/generate.runtime-CMnvmeVt.js +111 -0
- package/dist/chunks/generate.runtime-CMnvmeVt.js.map +1 -0
- package/dist/chunks/{generate.runtime-BORbegw_.js → generate.runtime-CN5c2xH8.js} +123 -122
- package/dist/chunks/generate.runtime-CN5c2xH8.js.map +1 -0
- package/dist/chunks/{generate.runtime-flFRYzpi.js → generate.runtime-CgoSrP55.js} +62 -61
- package/dist/chunks/generate.runtime-CgoSrP55.js.map +1 -0
- package/dist/chunks/{generate.runtime-D0icLb5j.js → generate.runtime-D1DNAY6k.js} +12 -11
- package/dist/chunks/{generate.runtime-D0icLb5j.js.map → generate.runtime-D1DNAY6k.js.map} +1 -1
- package/dist/chunks/generate.runtime-DG-3G00z.js +87 -0
- package/dist/chunks/generate.runtime-DG-3G00z.js.map +1 -0
- package/dist/chunks/{generate.runtime-BKo-Nidn.js → generate.runtime-DQwSY6Nc.js} +6 -6
- package/dist/chunks/{generate.runtime-BKo-Nidn.js.map → generate.runtime-DQwSY6Nc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DSqkXvps.js → generate.runtime-D_yqWLcI.js} +15 -14
- package/dist/chunks/{generate.runtime-DSqkXvps.js.map → generate.runtime-D_yqWLcI.js.map} +1 -1
- package/dist/chunks/generate.runtime-Drmahmdl.js +313 -0
- package/dist/chunks/generate.runtime-Drmahmdl.js.map +1 -0
- package/dist/chunks/{generate.runtime-D8vgh5MH.js → generate.runtime-FdZw277n.js} +156 -76
- package/dist/chunks/generate.runtime-FdZw277n.js.map +1 -0
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js +94 -0
- package/dist/chunks/generate.runtime-Lh1cW9Tz.js.map +1 -0
- package/dist/chunks/{generate.runtime-DAmYsIvF.js → generate.runtime-QGHToXRY.js} +5 -5
- package/dist/chunks/{generate.runtime-DAmYsIvF.js.map → generate.runtime-QGHToXRY.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CRYjWJRe.js → generate.runtime-Um77JfwC.js} +89 -88
- package/dist/chunks/generate.runtime-Um77JfwC.js.map +1 -0
- package/dist/chunks/{generate.runtime-BwhGDnGu.js → generate.runtime-VgVwRiiN.js} +151 -150
- package/dist/chunks/generate.runtime-VgVwRiiN.js.map +1 -0
- package/dist/chunks/{generate.runtime-CcuAXuV2.js → generate.runtime-YyIVd4oy.js} +15 -14
- package/dist/chunks/{generate.runtime-CcuAXuV2.js.map → generate.runtime-YyIVd4oy.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DOuufRLr.js → generate.runtime-cQGLxuZM.js} +82 -81
- package/dist/chunks/generate.runtime-cQGLxuZM.js.map +1 -0
- package/dist/chunks/generate.runtime-n9AFWtPp.js +94 -0
- package/dist/chunks/generate.runtime-n9AFWtPp.js.map +1 -0
- package/dist/chunks/generate.runtime-ofdnLtxS.js +57 -0
- package/dist/chunks/generate.runtime-ofdnLtxS.js.map +1 -0
- package/dist/chunks/generate.runtime-onBnOiS7.js +328 -0
- package/dist/chunks/generate.runtime-onBnOiS7.js.map +1 -0
- package/dist/chunks/modify-file-Dwfv0dCI.js +46 -0
- package/dist/chunks/modify-file-Dwfv0dCI.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js → modify-svelte-config-remote-BUU_EaDf.js} +2 -2
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js.map → modify-svelte-config-remote-BUU_EaDf.js.map} +1 -1
- package/dist/chunks/{pocketbase-CeG5BMN2.js → pocketbase-BkhUywtb.js} +2 -2
- package/dist/chunks/{pocketbase-CeG5BMN2.js.map → pocketbase-BkhUywtb.js.map} +1 -1
- package/dist/chunks/{providers-DO9kMyzB.js → providers-BL9vJP_9.js} +2 -2
- package/dist/chunks/{providers-DO9kMyzB.js.map → providers-BL9vJP_9.js.map} +1 -1
- package/dist/chunks/{shared-BwHQM-a9.js → shared-C8GtNxpm.js} +2 -2
- package/dist/chunks/{shared-BwHQM-a9.js.map → shared-C8GtNxpm.js.map} +1 -1
- package/dist/chunks/{site-D027dpBm.js → site-BdMX8qrH.js} +2 -2
- package/dist/chunks/{site-D027dpBm.js.map → site-BdMX8qrH.js.map} +1 -1
- package/dist/chunks/table-core-G9Shld4F.js +126 -0
- package/dist/chunks/table-core-G9Shld4F.js.map +1 -0
- package/dist/chunks/{test-setup-B2hd8I-s.js → test-setup-DHEFKEHE.js} +23 -10
- package/dist/chunks/test-setup-DHEFKEHE.js.map +1 -0
- package/dist/chunks/ts-morph-helpers-CeduA--o.js +253 -0
- package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +1 -0
- package/dist/chunks/{ui-jhXrsw4T.js → ui-DD4NltyN.js} +2 -2
- package/dist/chunks/{ui-jhXrsw4T.js.map → ui-DD4NltyN.js.map} +1 -1
- package/dist/chunks/{ui-B4Tuit-7.js → ui-TlEuI2Sz.js} +50 -49
- package/dist/chunks/{ui-B4Tuit-7.js.map → ui-TlEuI2Sz.js.map} +1 -1
- package/dist/chunks/unmodify-load-jfdcVZ_a.js +81 -0
- package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +1 -0
- package/dist/chunks/write-result-Djy0SZXX.js +376 -0
- package/dist/chunks/write-result-Djy0SZXX.js.map +1 -0
- package/dist/index.d.ts +33 -1
- package/dist/index.js +2240 -2020
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/_layout-DqH4lA_r.js +0 -47
- package/dist/chunks/_layout-DqH4lA_r.js.map +0 -1
- package/dist/chunks/config-target-Co-ij8p3.js +0 -163
- package/dist/chunks/config-target-Co-ij8p3.js.map +0 -1
- package/dist/chunks/constants-DSFKQwtP.js.map +0 -1
- package/dist/chunks/errors-D6gyegUK.js +0 -14
- package/dist/chunks/errors-D6gyegUK.js.map +0 -1
- package/dist/chunks/format-result-Cb2hWsb8.js.map +0 -1
- package/dist/chunks/generate-tOkjJFUf.js.map +0 -1
- package/dist/chunks/generate.runtime-B0hhtyAL.js.map +0 -1
- package/dist/chunks/generate.runtime-B49wetSx.js.map +0 -1
- package/dist/chunks/generate.runtime-B7LRx-BU.js +0 -86
- package/dist/chunks/generate.runtime-B7LRx-BU.js.map +0 -1
- package/dist/chunks/generate.runtime-BORbegw_.js.map +0 -1
- package/dist/chunks/generate.runtime-BbIN0tUZ.js.map +0 -1
- package/dist/chunks/generate.runtime-BnWE4qsu.js.map +0 -1
- package/dist/chunks/generate.runtime-BwhGDnGu.js.map +0 -1
- package/dist/chunks/generate.runtime-CCg2Pjcv.js +0 -257
- package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +0 -1
- package/dist/chunks/generate.runtime-CRYjWJRe.js.map +0 -1
- package/dist/chunks/generate.runtime-D2e_KRj0.js +0 -56
- package/dist/chunks/generate.runtime-D2e_KRj0.js.map +0 -1
- package/dist/chunks/generate.runtime-D44gjxRA.js +0 -332
- package/dist/chunks/generate.runtime-D44gjxRA.js.map +0 -1
- package/dist/chunks/generate.runtime-D8vgh5MH.js.map +0 -1
- package/dist/chunks/generate.runtime-DNaQxed-.js.map +0 -1
- package/dist/chunks/generate.runtime-DOuufRLr.js.map +0 -1
- package/dist/chunks/generate.runtime-DhkaXTq3.js.map +0 -1
- package/dist/chunks/generate.runtime-DoZdSh9W.js.map +0 -1
- package/dist/chunks/generate.runtime-S5RIgbQx.js.map +0 -1
- package/dist/chunks/generate.runtime-WmSMWL15.js +0 -82
- package/dist/chunks/generate.runtime-WmSMWL15.js.map +0 -1
- package/dist/chunks/generate.runtime-flFRYzpi.js.map +0 -1
- package/dist/chunks/generate.runtime-gtpOuLNO.js +0 -110
- package/dist/chunks/generate.runtime-gtpOuLNO.js.map +0 -1
- package/dist/chunks/generate.runtime-kLxeDGnS.js +0 -93
- package/dist/chunks/generate.runtime-kLxeDGnS.js.map +0 -1
- package/dist/chunks/generate.runtime-wA1G3tQ4.js.map +0 -1
- package/dist/chunks/modify-file-GQD6uNgI.js +0 -254
- package/dist/chunks/modify-file-GQD6uNgI.js.map +0 -1
- package/dist/chunks/test-setup-B2hd8I-s.js.map +0 -1
- package/dist/chunks/unmodify-load-W1ePZQHr.js +0 -80
- package/dist/chunks/unmodify-load-W1ePZQHr.js.map +0 -1
- package/dist/chunks/write-result-DewHCNhM.js +0 -451
- package/dist/chunks/write-result-DewHCNhM.js.map +0 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { n } from "./generate-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import l from "
|
|
8
|
-
import u from "node:
|
|
9
|
-
import
|
|
3
|
+
import { n } from "./generate-CyuY2Ci7.js";
|
|
4
|
+
import { _ as r, o as i, r as a } from "./ts-morph-helpers-CeduA--o.js";
|
|
5
|
+
import { modifyOutcomeToFile as o } from "./modify-file-Dwfv0dCI.js";
|
|
6
|
+
import { t as s } from "./svelte-file-B3RfgVdt.js";
|
|
7
|
+
import { a as c, t as l } from "./config-target-Bln26FJe.js";
|
|
8
|
+
import u from "node:fs";
|
|
9
|
+
import d from "node:path";
|
|
10
|
+
import { Node as f, Project as p, QuoteKind as m, SyntaxKind as h } from "ts-morph";
|
|
10
11
|
//#region src/patterns/enable/cms/modifies/vite-config.ts
|
|
11
|
-
var
|
|
12
|
+
var g = [
|
|
12
13
|
"Add the CMS plugin to your Vite config, ahead of sveltekit():",
|
|
13
14
|
"",
|
|
14
15
|
"import { cms } from '@velastack/cms/vite';",
|
|
@@ -16,7 +17,7 @@ var h = [
|
|
|
16
17
|
"export default defineConfig({",
|
|
17
18
|
" plugins: [cms(), sveltekit(), /* ...existing plugins */],",
|
|
18
19
|
"});"
|
|
19
|
-
].join("\n"),
|
|
20
|
+
].join("\n"), _ = [
|
|
20
21
|
"Create a Vite config with the CMS plugin ahead of sveltekit():",
|
|
21
22
|
"",
|
|
22
23
|
"import { defineConfig } from 'vite';",
|
|
@@ -27,62 +28,62 @@ var h = [
|
|
|
27
28
|
" plugins: [cms(), sveltekit()],",
|
|
28
29
|
"});"
|
|
29
30
|
].join("\n");
|
|
30
|
-
function
|
|
31
|
+
function v(e) {
|
|
31
32
|
return e.replace(/\s/g, "");
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
+
function y(e, t = "") {
|
|
34
35
|
let n = `cms(${t})`;
|
|
35
|
-
if (!
|
|
36
|
+
if (!u.existsSync(e)) return {
|
|
36
37
|
status: "not-found",
|
|
37
|
-
message:
|
|
38
|
+
message: _
|
|
38
39
|
};
|
|
39
|
-
let r = new
|
|
40
|
+
let r = new p({
|
|
40
41
|
compilerOptions: { allowJs: !0 },
|
|
41
|
-
manipulationSettings: { quoteKind:
|
|
42
|
-
}).addSourceFileAtPath(e),
|
|
42
|
+
manipulationSettings: { quoteKind: m.Single }
|
|
43
|
+
}).addSourceFileAtPath(e), a = !1, o = !1;
|
|
43
44
|
r.getImportDeclarations().some((e) => e.getModuleSpecifierValue() === "@velastack/cms/vite") || (r.insertImportDeclaration(0, {
|
|
44
45
|
namedImports: ["cms"],
|
|
45
46
|
moduleSpecifier: "@velastack/cms/vite"
|
|
46
|
-
}),
|
|
47
|
-
let
|
|
48
|
-
if (!
|
|
47
|
+
}), a = !0);
|
|
48
|
+
let s = r.getDescendantsOfKind(h.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], c = s?.getKind() === h.ObjectLiteralExpression ? s : null;
|
|
49
|
+
if (!c) o = !0;
|
|
49
50
|
else {
|
|
50
|
-
let e =
|
|
51
|
-
if (!e)
|
|
51
|
+
let e = c.getProperty("plugins");
|
|
52
|
+
if (!e) c.addPropertyAssignment({
|
|
52
53
|
name: "plugins",
|
|
53
54
|
initializer: `[${n}]`
|
|
54
|
-
}),
|
|
55
|
-
else if (e.getKind() !==
|
|
55
|
+
}), a = !0;
|
|
56
|
+
else if (e.getKind() !== h.PropertyAssignment) o = !0;
|
|
56
57
|
else {
|
|
57
58
|
let t = e.getInitializer();
|
|
58
|
-
if (!t) e.setInitializer(`[${n}]`),
|
|
59
|
-
else if (t.getKind() !==
|
|
59
|
+
if (!t) e.setInitializer(`[${n}]`), a = !0;
|
|
60
|
+
else if (t.getKind() !== h.ArrayLiteralExpression) o = !0;
|
|
60
61
|
else {
|
|
61
62
|
let e = t, r = e.getElements();
|
|
62
|
-
if (!r.some((e) =>
|
|
63
|
-
let t = r.findIndex((e) =>
|
|
64
|
-
e.insertElement(t === -1 ? 0 : t, n),
|
|
63
|
+
if (!r.some((e) => v(e.getText()).startsWith("cms("))) {
|
|
64
|
+
let t = r.findIndex((e) => v(e.getText()).startsWith("sveltekit("));
|
|
65
|
+
e.insertElement(t === -1 ? 0 : t, n), a = !0;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
return
|
|
70
|
+
return a && (i(r), r.saveSync()), o ? {
|
|
70
71
|
status: "failed",
|
|
71
|
-
message:
|
|
72
|
+
message: g
|
|
72
73
|
} : {
|
|
73
74
|
status: "success",
|
|
74
|
-
changed:
|
|
75
|
+
changed: a
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
//#endregion
|
|
78
79
|
//#region src/patterns/enable/cms/modifies/load-function.ts
|
|
79
|
-
function
|
|
80
|
-
return new
|
|
80
|
+
function b() {
|
|
81
|
+
return new p({
|
|
81
82
|
compilerOptions: { allowJs: !0 },
|
|
82
|
-
manipulationSettings: { quoteKind:
|
|
83
|
+
manipulationSettings: { quoteKind: m.Single }
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
+
function x(e, t, n) {
|
|
86
87
|
let r = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t);
|
|
87
88
|
if (!r) {
|
|
88
89
|
e.addImportDeclaration({
|
|
@@ -93,60 +94,60 @@ function b(e, t, n) {
|
|
|
93
94
|
}
|
|
94
95
|
for (let e of n) r.getNamedImports().some((t) => t.getName() === e) || r.addNamedImport(e);
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
-
t.namedImports?.length &&
|
|
97
|
+
function S(e, t) {
|
|
98
|
+
t.namedImports?.length && x(e, t.moduleSpecifier, t.namedImports), !e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t.moduleSpecifier) && e.addImportDeclaration({
|
|
98
99
|
moduleSpecifier: t.moduleSpecifier,
|
|
99
100
|
defaultImport: t.defaultImport,
|
|
100
101
|
namespaceImport: t.namespaceImport
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
-
if (
|
|
105
|
-
if (
|
|
106
|
-
if (
|
|
107
|
-
let e =
|
|
104
|
+
function C(e) {
|
|
105
|
+
if (f.isArrowFunction(e) || f.isFunctionExpression(e)) return e;
|
|
106
|
+
if (f.isParenthesizedExpression(e) || f.isAsExpression(e) || f.isSatisfiesExpression(e)) return C(e.getExpression());
|
|
107
|
+
if (f.isCallExpression(e)) for (let t of e.getArguments()) {
|
|
108
|
+
let e = C(t);
|
|
108
109
|
if (e) return e;
|
|
109
110
|
}
|
|
110
111
|
return null;
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function w(e) {
|
|
113
114
|
let t = e.getFunction("load");
|
|
114
115
|
if (t) return t.isExported() ? t : null;
|
|
115
116
|
let n = e.getVariableDeclaration("load");
|
|
116
117
|
if (!n || !n.getVariableStatement()?.isExported()) return null;
|
|
117
118
|
let r = n.getInitializer();
|
|
118
|
-
return r ?
|
|
119
|
+
return r ? C(r) : null;
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
-
return
|
|
121
|
+
function T(e) {
|
|
122
|
+
return f.isArrowFunction(e) || f.isFunctionExpression(e) || f.isFunctionDeclaration(e) || f.isMethodDeclaration(e);
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
+
function E(e, t) {
|
|
124
125
|
let n = t.getStatements(), r = n[n.length - 1];
|
|
125
|
-
return !r || !
|
|
126
|
+
return !r || !f.isReturnStatement(r) || t.getDescendantsOfKind(h.ReturnStatement).filter((t) => t.getFirstAncestor(T) === e).length !== 1 ? null : r;
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
+
function D(e) {
|
|
128
129
|
let t = e.getExpression();
|
|
129
|
-
for (; t &&
|
|
130
|
-
return !t || !
|
|
131
|
-
}
|
|
132
|
-
function D(e, t) {
|
|
133
|
-
return e.getProperties().some((e) => d.isPropertyAssignment(e) || d.isShorthandPropertyAssignment(e) ? e.getName() === t : !1);
|
|
130
|
+
for (; t && f.isParenthesizedExpression(t);) t = t.getExpression();
|
|
131
|
+
return !t || !f.isObjectLiteralExpression(t) ? null : t;
|
|
134
132
|
}
|
|
135
133
|
function O(e, t) {
|
|
136
|
-
return e.getProperties().some((e) =>
|
|
134
|
+
return e.getProperties().some((e) => f.isPropertyAssignment(e) || f.isShorthandPropertyAssignment(e) ? e.getName() === t : !1);
|
|
137
135
|
}
|
|
138
|
-
function k(e) {
|
|
136
|
+
function k(e, t) {
|
|
137
|
+
return e.getProperties().some((e) => f.isSpreadAssignment(e) && e.getExpression().getText() === t);
|
|
138
|
+
}
|
|
139
|
+
function A(e) {
|
|
139
140
|
let t = e.getParameters();
|
|
140
141
|
if (t.length === 0) return { kind: "none" };
|
|
141
142
|
if (t.length > 1) return { kind: "unsupported" };
|
|
142
143
|
let n = t[0];
|
|
143
144
|
if (n.getInitializer() || n.isRestParameter()) return { kind: "unsupported" };
|
|
144
145
|
let r = n.getNameNode();
|
|
145
|
-
return
|
|
146
|
+
return f.isIdentifier(r) ? {
|
|
146
147
|
kind: "identifier",
|
|
147
148
|
name: r.getText(),
|
|
148
149
|
param: n
|
|
149
|
-
} :
|
|
150
|
+
} : f.isObjectBindingPattern(r) ? {
|
|
150
151
|
kind: "binding",
|
|
151
152
|
pattern: r,
|
|
152
153
|
param: n
|
|
@@ -154,14 +155,14 @@ function k(e) {
|
|
|
154
155
|
}
|
|
155
156
|
//#endregion
|
|
156
157
|
//#region src/patterns/enable/cms/modifies/layout.server.ts
|
|
157
|
-
var
|
|
158
|
+
var j = { expression: () => "'en'" }, M = {
|
|
158
159
|
expression: (e) => `getLocale(${e}.url)`,
|
|
159
160
|
imports: [{
|
|
160
161
|
namedImports: ["getLocale"],
|
|
161
162
|
moduleSpecifier: "$locales/main.url"
|
|
162
163
|
}]
|
|
163
164
|
};
|
|
164
|
-
function
|
|
165
|
+
function N(t, n) {
|
|
165
166
|
return e`
|
|
166
167
|
const { cms, notFound, gone, redirectTo } = await loadCms(${t}, { locale: ${n} });
|
|
167
168
|
if (redirectTo) redirect(308, redirectTo);
|
|
@@ -169,17 +170,17 @@ function M(t, n) {
|
|
|
169
170
|
if (notFound) error(404, 'Not found');
|
|
170
171
|
`;
|
|
171
172
|
}
|
|
172
|
-
function
|
|
173
|
+
function P(e) {
|
|
173
174
|
let t = [];
|
|
174
175
|
return e.defaultImport && t.push(e.defaultImport), e.namespaceImport && t.push(`* as ${e.namespaceImport}`), e.namedImports?.length && t.push(`{ ${e.namedImports.join(", ")} }`), `import ${t.join(", ")} from '${e.moduleSpecifier}';`;
|
|
175
176
|
}
|
|
176
|
-
function
|
|
177
|
+
function F(t) {
|
|
177
178
|
let n = [
|
|
178
179
|
"import { error, redirect } from '@sveltejs/kit';",
|
|
179
180
|
"import { loadCms } from '$lib/cms';",
|
|
180
|
-
...(t.imports ?? []).map(
|
|
181
|
+
...(t.imports ?? []).map(P),
|
|
181
182
|
"import type { LayoutServerLoad } from './$types';"
|
|
182
|
-
].join("\n"), r =
|
|
183
|
+
].join("\n"), r = N("event", t.expression("event")).split("\n").join("\n ");
|
|
183
184
|
return e`
|
|
184
185
|
${n}
|
|
185
186
|
|
|
@@ -190,65 +191,65 @@ function P(t) {
|
|
|
190
191
|
};
|
|
191
192
|
`.concat("\n");
|
|
192
193
|
}
|
|
193
|
-
var
|
|
194
|
+
var I = [
|
|
194
195
|
"Call loadCms from the root +layout.server.ts load and return `cms`:",
|
|
195
196
|
"",
|
|
196
|
-
|
|
197
|
+
F(j).trimEnd(),
|
|
197
198
|
"",
|
|
198
199
|
"loadCms needs the whole event, so a destructured parameter has to become",
|
|
199
200
|
"`event` with the destructuring moved into the body."
|
|
200
201
|
].join("\n");
|
|
201
|
-
function
|
|
202
|
-
if (!
|
|
202
|
+
function L(e, t = j) {
|
|
203
|
+
if (!u.existsSync(e)) return u.mkdirSync(d.dirname(e), { recursive: !0 }), u.writeFileSync(e, F(t)), {
|
|
203
204
|
status: "success",
|
|
204
205
|
changed: !0
|
|
205
206
|
};
|
|
206
|
-
if (
|
|
207
|
+
if (u.readFileSync(e, "utf8").includes("loadCms(")) return {
|
|
207
208
|
status: "success",
|
|
208
209
|
changed: !1
|
|
209
210
|
};
|
|
210
|
-
let n =
|
|
211
|
+
let n = b().addSourceFileAtPath(e), r = w(n);
|
|
211
212
|
if (!r) return {
|
|
212
213
|
status: "failed",
|
|
213
|
-
message:
|
|
214
|
+
message: I
|
|
214
215
|
};
|
|
215
|
-
let
|
|
216
|
-
if (!
|
|
216
|
+
let a = r.getBody();
|
|
217
|
+
if (!a || !f.isBlock(a)) return {
|
|
217
218
|
status: "failed",
|
|
218
|
-
message:
|
|
219
|
+
message: I
|
|
219
220
|
};
|
|
220
|
-
let
|
|
221
|
-
if (
|
|
221
|
+
let o = A(r);
|
|
222
|
+
if (o.kind === "unsupported") return {
|
|
222
223
|
status: "failed",
|
|
223
|
-
message:
|
|
224
|
+
message: I
|
|
224
225
|
};
|
|
225
|
-
let
|
|
226
|
-
if (!
|
|
226
|
+
let s = E(r, a), c = s && D(s);
|
|
227
|
+
if (!s || !c) return {
|
|
227
228
|
status: "failed",
|
|
228
|
-
message:
|
|
229
|
+
message: I
|
|
229
230
|
};
|
|
230
|
-
let
|
|
231
|
-
if (!
|
|
232
|
-
let e =
|
|
233
|
-
e === -1 ?
|
|
231
|
+
let l = o.kind === "identifier" ? o.name : "event";
|
|
232
|
+
if (!O(c, "cms")) {
|
|
233
|
+
let e = c.getProperties().findIndex((e) => f.isSpreadAssignment(e));
|
|
234
|
+
e === -1 ? c.addShorthandPropertyAssignment({ name: "cms" }) : c.insertShorthandPropertyAssignment(e, { name: "cms" });
|
|
234
235
|
}
|
|
235
|
-
let
|
|
236
|
-
if (
|
|
237
|
-
let e =
|
|
238
|
-
|
|
239
|
-
let t =
|
|
240
|
-
|
|
241
|
-
} else
|
|
242
|
-
r.isAsync() || r.setIsAsync(!0),
|
|
243
|
-
for (let e of t.imports ?? [])
|
|
244
|
-
return n
|
|
236
|
+
let p = a.getStatementsWithComments().indexOf(s);
|
|
237
|
+
if (a.insertStatements(p, `\n${N(l, t.expression(l))}\n`), o.kind === "binding") {
|
|
238
|
+
let e = o.pattern.getText();
|
|
239
|
+
a.insertStatements(0, `const ${e} = ${l};`);
|
|
240
|
+
let t = o.param.getTypeNode()?.getText();
|
|
241
|
+
o.param.replaceWithText(t ? `${l}: ${t}` : l);
|
|
242
|
+
} else o.kind === "none" && r.addParameter({ name: l });
|
|
243
|
+
r.isAsync() || r.setIsAsync(!0), x(n, "@sveltejs/kit", ["error", "redirect"]), x(n, "$lib/cms", ["loadCms"]);
|
|
244
|
+
for (let e of t.imports ?? []) S(n, e);
|
|
245
|
+
return i(n), n.saveSync(), {
|
|
245
246
|
status: "success",
|
|
246
247
|
changed: !0
|
|
247
248
|
};
|
|
248
249
|
}
|
|
249
250
|
//#endregion
|
|
250
251
|
//#region src/patterns/enable/cms/modifies/layout.ts
|
|
251
|
-
var
|
|
252
|
+
var R = e`
|
|
252
253
|
Forward the server load's data through the root +layout.ts, so \`cms\` reaches
|
|
253
254
|
the page:
|
|
254
255
|
|
|
@@ -257,85 +258,85 @@ var L = e`
|
|
|
257
258
|
return { ...data, /* existing keys */ };
|
|
258
259
|
};
|
|
259
260
|
`;
|
|
260
|
-
function
|
|
261
|
-
if (!
|
|
261
|
+
function z(e) {
|
|
262
|
+
if (!u.existsSync(e)) return {
|
|
262
263
|
status: "success",
|
|
263
264
|
changed: !1
|
|
264
265
|
};
|
|
265
|
-
let t =
|
|
266
|
+
let t = b().addSourceFileAtPath(e), n = w(t);
|
|
266
267
|
if (!n) return {
|
|
267
268
|
status: "success",
|
|
268
269
|
changed: !1
|
|
269
270
|
};
|
|
270
271
|
let r = n.getBody();
|
|
271
|
-
if (!r || !
|
|
272
|
+
if (!r || !f.isBlock(r)) return {
|
|
272
273
|
status: "failed",
|
|
273
|
-
message:
|
|
274
|
+
message: R
|
|
274
275
|
};
|
|
275
|
-
let
|
|
276
|
-
if (
|
|
276
|
+
let a = A(n);
|
|
277
|
+
if (a.kind === "unsupported") return {
|
|
277
278
|
status: "failed",
|
|
278
|
-
message:
|
|
279
|
+
message: R
|
|
279
280
|
};
|
|
280
|
-
let
|
|
281
|
-
if (!
|
|
281
|
+
let o = E(n, r);
|
|
282
|
+
if (!o) return {
|
|
282
283
|
status: "failed",
|
|
283
|
-
message:
|
|
284
|
+
message: R
|
|
284
285
|
};
|
|
285
|
-
let
|
|
286
|
-
if (
|
|
286
|
+
let s = a.kind === "identifier" ? `${a.name}.data` : "data", c = o.getExpression();
|
|
287
|
+
if (c && c.getText() === s) return {
|
|
287
288
|
status: "success",
|
|
288
289
|
changed: !1
|
|
289
290
|
};
|
|
290
|
-
let
|
|
291
|
-
if (!
|
|
291
|
+
let l = D(o);
|
|
292
|
+
if (!l) return {
|
|
292
293
|
status: "failed",
|
|
293
|
-
message:
|
|
294
|
+
message: R
|
|
294
295
|
};
|
|
295
|
-
if (
|
|
296
|
+
if (k(l, s)) return {
|
|
296
297
|
status: "success",
|
|
297
298
|
changed: !1
|
|
298
299
|
};
|
|
299
|
-
if (
|
|
300
|
-
if (!
|
|
301
|
-
let e =
|
|
302
|
-
|
|
300
|
+
if (l.insertSpreadAssignment(0, { expression: s }), a.kind === "binding") {
|
|
301
|
+
if (!a.pattern.getElements().some((e) => e.getName() === "data")) {
|
|
302
|
+
let e = a.pattern.getText();
|
|
303
|
+
a.pattern.replaceWithText(e.replace(/^\{\s*/, "{ data, "));
|
|
303
304
|
}
|
|
304
|
-
} else
|
|
305
|
-
return t
|
|
305
|
+
} else a.kind === "none" && n.addParameter({ name: "{ data }" });
|
|
306
|
+
return i(t), t.saveSync(), {
|
|
306
307
|
status: "success",
|
|
307
308
|
changed: !0
|
|
308
309
|
};
|
|
309
310
|
}
|
|
310
311
|
//#endregion
|
|
311
312
|
//#region src/patterns/enable/cms/modifies/layout.svelte.ts
|
|
312
|
-
var
|
|
313
|
+
var B = e`
|
|
313
314
|
import { AdminBar } from '@velastack/cms';
|
|
314
|
-
`,
|
|
315
|
+
`, V = "\n<AdminBar />\n", H = [
|
|
315
316
|
"Create the root src/routes/+layout.svelte and mount <AdminBar /> inside it.",
|
|
316
317
|
"",
|
|
317
318
|
"Import for the <script> tag:",
|
|
318
319
|
"",
|
|
319
|
-
|
|
320
|
+
B,
|
|
320
321
|
"",
|
|
321
322
|
"Markup to add at the top level of the layout, above {@render children()}:",
|
|
322
|
-
|
|
323
|
-
].join("\n"),
|
|
323
|
+
V.trim()
|
|
324
|
+
].join("\n"), U = [
|
|
324
325
|
"Mount <AdminBar /> in the root src/routes/+layout.svelte.",
|
|
325
326
|
"",
|
|
326
327
|
"Import for a <script lang=\"ts\"> tag:",
|
|
327
328
|
"",
|
|
328
|
-
|
|
329
|
+
B,
|
|
329
330
|
"",
|
|
330
331
|
"Markup to add at the top level of the layout, above {@render children()}:",
|
|
331
|
-
|
|
332
|
+
V.trim()
|
|
332
333
|
].join("\n");
|
|
333
|
-
function
|
|
334
|
-
if (!
|
|
334
|
+
function W(e) {
|
|
335
|
+
if (!u.existsSync(e)) return {
|
|
335
336
|
status: "not-found",
|
|
336
|
-
message:
|
|
337
|
+
message: H
|
|
337
338
|
};
|
|
338
|
-
let t =
|
|
339
|
+
let t = s.fromPath(e);
|
|
339
340
|
return t.hasElement("AdminBar") ? {
|
|
340
341
|
status: "success",
|
|
341
342
|
changed: !1
|
|
@@ -347,44 +348,44 @@ function U(e) {
|
|
|
347
348
|
}]);
|
|
348
349
|
});
|
|
349
350
|
return t;
|
|
350
|
-
}), t.insertBeforeChildren(
|
|
351
|
+
}), t.insertBeforeChildren(V) || t.appendMarkup(V), t.writeTo(e), {
|
|
351
352
|
status: "success",
|
|
352
353
|
changed: t.hasChanged()
|
|
353
354
|
}) : {
|
|
354
355
|
status: "failed",
|
|
355
|
-
message:
|
|
356
|
+
message: U
|
|
356
357
|
};
|
|
357
358
|
}
|
|
358
359
|
//#endregion
|
|
359
360
|
//#region src/patterns/enable/cms/generate.runtime.ts
|
|
360
|
-
function
|
|
361
|
-
let t =
|
|
362
|
-
if (!
|
|
363
|
-
let n =
|
|
361
|
+
function G(e) {
|
|
362
|
+
let t = d.join(e, "wuchale.config.js");
|
|
363
|
+
if (!u.existsSync(t)) return null;
|
|
364
|
+
let n = u.readFileSync(t, "utf8").match(/locales:\s*\[([^\]]*)\]/);
|
|
364
365
|
if (!n) return null;
|
|
365
366
|
let r = [...n[1].matchAll(/['"]([^'"]+)['"]/g)].map((e) => e[1]);
|
|
366
367
|
return r.length > 0 ? r : null;
|
|
367
368
|
}
|
|
368
|
-
function
|
|
369
|
+
function K(e, t) {
|
|
369
370
|
if (e.local) return "";
|
|
370
371
|
let n = t.map((e) => `'${e}'`).join(", ");
|
|
371
372
|
return `{ endpoint: '${e.endpoint}', locales: [${n}] }`;
|
|
372
373
|
}
|
|
373
|
-
async function
|
|
374
|
-
let r = t(e),
|
|
375
|
-
e &&
|
|
374
|
+
async function q(e) {
|
|
375
|
+
let r = t(e), i = [], a = n(e), s = e.features.i18n, u = (e) => {
|
|
376
|
+
e && i.push(e);
|
|
376
377
|
};
|
|
377
378
|
r.info("Modifying vite.config");
|
|
378
|
-
let f =
|
|
379
|
-
|
|
380
|
-
let m =
|
|
381
|
-
|
|
382
|
-
let h =
|
|
383
|
-
|
|
384
|
-
let g =
|
|
385
|
-
return
|
|
379
|
+
let f = c(e.root, l) ?? d.join(e.root, l[0]), p = s && G(e.root) || ["en"];
|
|
380
|
+
u(o(f, y(f, K(a, p)))), r.info("Modifying src/routes/+layout.server.ts");
|
|
381
|
+
let m = d.join(e.root, "src", "routes", "+layout.server.ts");
|
|
382
|
+
u(o(m, L(m, s ? M : j))), r.info("Modifying src/routes/+layout.ts");
|
|
383
|
+
let h = d.join(e.root, "src", "routes", "+layout.ts");
|
|
384
|
+
u(o(h, z(h))), r.info("Modifying src/routes/+layout.svelte");
|
|
385
|
+
let g = d.join(e.root, "src", "routes", "+layout.svelte");
|
|
386
|
+
return u(o(g, W(g))), {
|
|
386
387
|
creates: [],
|
|
387
|
-
modifies:
|
|
388
|
+
modifies: i,
|
|
388
389
|
deletes: [],
|
|
389
390
|
components: [],
|
|
390
391
|
packages: [],
|
|
@@ -394,6 +395,6 @@ async function K(e) {
|
|
|
394
395
|
};
|
|
395
396
|
}
|
|
396
397
|
//#endregion
|
|
397
|
-
export {
|
|
398
|
+
export { q as generate };
|
|
398
399
|
|
|
399
|
-
//# sourceMappingURL=generate.runtime-
|
|
400
|
+
//# sourceMappingURL=generate.runtime-VgVwRiiN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-VgVwRiiN.js","names":[],"sources":["../../src/patterns/enable/cms/modifies/vite-config.ts","../../src/patterns/enable/cms/modifies/load-function.ts","../../src/patterns/enable/cms/modifies/layout.server.ts","../../src/patterns/enable/cms/modifies/layout.ts","../../src/patterns/enable/cms/modifies/layout.svelte.ts","../../src/patterns/enable/cms/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n type PropertyAssignment,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the CMS plugin to your Vite config, ahead of sveltekit():\",\n \"\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the CMS plugin ahead of sveltekit():\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { sveltekit } from '@sveltejs/kit/vite';\",\n \"import { cms } from '@velastack/cms/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [cms(), sveltekit()],\",\n \"});\",\n].join(\"\\n\");\n\nfunction elementName(text: string): string {\n return text.replace(/\\s/g, \"\");\n}\n\n/**\n * Registers `cms(...)` from `@velastack/cms/vite` in the Vite plugin list, just\n * ahead of `sveltekit()`. Only the plugin array is touched, so the inline\n * `sveltekit({ ... })` shape the templates use is left alone.\n */\nexport function modifyViteConfig(\n viteConfigPath: string,\n pluginArgs = \"\",\n): ModifyOutcome {\n const call = `cms(${pluginArgs})`;\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"@velastack/cms/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"cms\"],\n moduleSpecifier: \"@velastack/cms/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: `[${call}]`,\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (pluginsProp as PropertyAssignment).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as PropertyAssignment).setInitializer(`[${call}]`);\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as ArrayLiteralExpression;\n const elements = arr.getElements();\n const hasCms = elements.some((el) =>\n elementName(el.getText()).startsWith(\"cms(\"),\n );\n\n if (!hasCms) {\n const sveltekitIndex = elements.findIndex((el) =>\n elementName(el.getText()).startsWith(\"sveltekit(\"),\n );\n arr.insertElement(sveltekitIndex === -1 ? 0 : sveltekitIndex, call);\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import {\n Node,\n Project,\n QuoteKind,\n SyntaxKind,\n type ArrowFunction,\n type Block,\n type FunctionDeclaration,\n type FunctionExpression,\n type ObjectLiteralExpression,\n type ParameterDeclaration,\n type ReturnStatement,\n type SourceFile,\n} from \"ts-morph\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\n\n/**\n * What the two layout modifiers have in common: finding a SvelteKit `load`,\n * working out how it receives its event, and locating the object it returns.\n */\n\nexport type LoadFunction =\n ArrowFunction | FunctionExpression | FunctionDeclaration;\n\nexport function newProject(): Project {\n return new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n}\n\nexport function ensureNamedImports(\n sourceFile: SourceFile,\n moduleSpecifier: string,\n names: string[],\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (!existing) {\n sourceFile.addImportDeclaration({ namedImports: names, moduleSpecifier });\n return;\n }\n for (const name of names) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n }\n}\n\nexport function ensureImportSpec(sourceFile: SourceFile, spec: ImportSpec) {\n if (spec.namedImports?.length) {\n ensureNamedImports(sourceFile, spec.moduleSpecifier, spec.namedImports);\n }\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === spec.moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({\n moduleSpecifier: spec.moduleSpecifier,\n defaultImport: spec.defaultImport,\n namespaceImport: spec.namespaceImport,\n });\n}\n\n/** Peel wrappers (`loadFlash(fn)`, `(fn)`, `fn satisfies X`) down to the function. */\nfunction unwrapFunction(node: Node): ArrowFunction | FunctionExpression | null {\n if (Node.isArrowFunction(node) || Node.isFunctionExpression(node)) {\n return node;\n }\n if (\n Node.isParenthesizedExpression(node) ||\n Node.isAsExpression(node) ||\n Node.isSatisfiesExpression(node)\n ) {\n return unwrapFunction(node.getExpression());\n }\n if (Node.isCallExpression(node)) {\n for (const arg of node.getArguments()) {\n const fn = unwrapFunction(arg);\n if (fn) return fn;\n }\n }\n return null;\n}\n\n/** The exported `load`, whether declared as a function or wrapped in a const. */\nexport function findLoadFunction(sourceFile: SourceFile): LoadFunction | null {\n const declaration = sourceFile.getFunction(\"load\");\n if (declaration) {\n return declaration.isExported() ? declaration : null;\n }\n\n const variable = sourceFile.getVariableDeclaration(\"load\");\n if (!variable) return null;\n if (!variable.getVariableStatement()?.isExported()) return null;\n\n const initializer = variable.getInitializer();\n return initializer ? unwrapFunction(initializer) : null;\n}\n\nfunction isFunctionNode(node: Node): boolean {\n return (\n Node.isArrowFunction(node) ||\n Node.isFunctionExpression(node) ||\n Node.isFunctionDeclaration(node) ||\n Node.isMethodDeclaration(node)\n );\n}\n\n/**\n * The single, final `return <expression>` of the load body, or null when the\n * body has early returns — those would need any insertion hoisted above them,\n * and guessing where is worse than refusing.\n */\nexport function findFinalReturn(\n fn: LoadFunction,\n body: Block,\n): ReturnStatement | null {\n const statements = body.getStatements();\n const last = statements[statements.length - 1];\n if (!last || !Node.isReturnStatement(last)) return null;\n\n const returns = body\n .getDescendantsOfKind(SyntaxKind.ReturnStatement)\n .filter((r) => r.getFirstAncestor(isFunctionNode) === fn);\n if (returns.length !== 1) return null;\n\n return last;\n}\n\n/** The object literal a return statement yields, unwrapping parentheses. */\nexport function returnedObject(\n statement: ReturnStatement,\n): ObjectLiteralExpression | null {\n let expression = statement.getExpression();\n while (expression && Node.isParenthesizedExpression(expression)) {\n expression = expression.getExpression();\n }\n if (!expression || !Node.isObjectLiteralExpression(expression)) return null;\n return expression;\n}\n\nexport function hasProperty(\n object: ObjectLiteralExpression,\n name: string,\n): boolean {\n return object.getProperties().some((property) => {\n if (\n Node.isPropertyAssignment(property) ||\n Node.isShorthandPropertyAssignment(property)\n ) {\n return property.getName() === name;\n }\n return false;\n });\n}\n\nexport function hasSpreadOf(\n object: ObjectLiteralExpression,\n expressionText: string,\n): boolean {\n return object\n .getProperties()\n .some(\n (property) =>\n Node.isSpreadAssignment(property) &&\n property.getExpression().getText() === expressionText,\n );\n}\n\n/** How a load receives its event: not at all, by name, or destructured. */\nexport type EventParameter =\n | { kind: \"none\" }\n | { kind: \"identifier\"; name: string; param: ParameterDeclaration }\n | {\n kind: \"binding\";\n pattern: import(\"ts-morph\").ObjectBindingPattern;\n param: ParameterDeclaration;\n }\n | { kind: \"unsupported\" };\n\nexport function inspectEventParameter(fn: LoadFunction): EventParameter {\n const params = fn.getParameters();\n if (params.length === 0) return { kind: \"none\" };\n if (params.length > 1) return { kind: \"unsupported\" };\n\n const param = params[0];\n if (param.getInitializer() || param.isRestParameter()) {\n return { kind: \"unsupported\" };\n }\n const nameNode = param.getNameNode();\n if (Node.isIdentifier(nameNode)) {\n return { kind: \"identifier\", name: nameNode.getText(), param };\n }\n if (Node.isObjectBindingPattern(nameNode)) {\n return { kind: \"binding\", pattern: nameNode, param };\n }\n return { kind: \"unsupported\" };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { ImportSpec } from \"../../../../runtime/ts-morph-helpers\";\nimport {\n ensureImportSpec,\n ensureNamedImports,\n findFinalReturn,\n findLoadFunction,\n hasProperty,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport interface LayoutServerLocale {\n /**\n * Expression passed as `locale` to `loadCms`, given the name of the load's\n * event parameter: `() => \"'en'\"` or `(event) => \\`getLocale(${event}.url)\\``.\n */\n expression: (eventName: string) => string;\n /** Imports the expression depends on. */\n imports?: ImportSpec[];\n}\n\n/** A single-locale site: the literal default locale. */\nexport const DEFAULT_LOCALE: LayoutServerLocale = {\n expression: () => \"'en'\",\n};\n\n/** A wuchale site: the locale enable-i18n's reroute already resolved from the URL. */\nexport const WUCHALE_LOCALE: LayoutServerLocale = {\n expression: (eventName) => `getLocale(${eventName}.url)`,\n imports: [\n { namedImports: [\"getLocale\"], moduleSpecifier: \"$locales/main.url\" },\n ],\n};\n\nfunction cmsSnippet(eventName: string, locale: string): string {\n return dedent`\n const { cms, notFound, gone, redirectTo } = await loadCms(${eventName}, { locale: ${locale} });\n if (redirectTo) redirect(308, redirectTo);\n if (gone) error(410, 'Gone');\n if (notFound) error(404, 'Not found');\n `;\n}\n\nfunction importLine(spec: ImportSpec): string {\n const parts: string[] = [];\n if (spec.defaultImport) parts.push(spec.defaultImport);\n if (spec.namespaceImport) parts.push(`* as ${spec.namespaceImport}`);\n if (spec.namedImports?.length)\n parts.push(`{ ${spec.namedImports.join(\", \")} }`);\n return `import ${parts.join(\", \")} from '${spec.moduleSpecifier}';`;\n}\n\n/**\n * A root `+layout.server.ts` written from scratch, for a project that has\n * none — the static template keeps its layout load universal.\n */\nexport function createdLayoutServer(locale: LayoutServerLocale): string {\n const imports = [\n \"import { error, redirect } from '@sveltejs/kit';\",\n \"import { loadCms } from '$lib/cms';\",\n ...(locale.imports ?? []).map(importLine),\n \"import type { LayoutServerLoad } from './$types';\",\n ].join(\"\\n\");\n const snippet = cmsSnippet(\"event\", locale.expression(\"event\"))\n .split(\"\\n\")\n .join(\"\\n\\t\");\n\n return dedent`\n ${imports}\n\n export const load: LayoutServerLoad = async (event) => {\n \t${snippet}\n\n \treturn { cms };\n };\n `.concat(\"\\n\");\n}\n\nconst FAILURE_HINT = [\n \"Call loadCms from the root +layout.server.ts load and return `cms`:\",\n \"\",\n createdLayoutServer(DEFAULT_LOCALE).trimEnd(),\n \"\",\n \"loadCms needs the whole event, so a destructured parameter has to become\",\n \"`event` with the destructuring moved into the body.\",\n].join(\"\\n\");\n\n/**\n * Wires `loadCms` into the root `+layout.server.ts`, creating the file when\n * the project has none:\n *\n * - `loadCms` needs the whole request event, so a destructured parameter is\n * renamed to `event` and the destructuring becomes the first statement.\n * - The tombstone triple (`redirectTo`, `gone`, `notFound`) is handled just\n * before the return.\n * - `cms` is added to the returned object, ahead of any spread so nothing\n * later can shadow it.\n *\n * Anything else — no exported `load`, an expression-bodied arrow, several\n * returns, a non-literal return — is reported as `failed` with the snippet to\n * paste, and the file is left exactly as it was.\n */\nexport function modifyLayoutServer(\n layoutServerPath: string,\n locale: LayoutServerLocale = DEFAULT_LOCALE,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n fs.mkdirSync(path.dirname(layoutServerPath), { recursive: true });\n fs.writeFileSync(layoutServerPath, createdLayoutServer(locale));\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (original.includes(\"loadCms(\")) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutServerPath);\n\n // --- Inspect everything before touching anything. ---\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"failed\", message: FAILURE_HINT };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n const object = returned && returnedObject(returned);\n if (!returned || !object) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const eventName = event.kind === \"identifier\" ? event.name : \"event\";\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n if (!hasProperty(object, \"cms\")) {\n const spreadIndex = object\n .getProperties()\n .findIndex((property) => Node.isSpreadAssignment(property));\n if (spreadIndex === -1) {\n object.addShorthandPropertyAssignment({ name: \"cms\" });\n } else {\n object.insertShorthandPropertyAssignment(spreadIndex, { name: \"cms\" });\n }\n }\n\n // insertStatements counts comment lines, which getStatements() skips.\n const returnIndex = body.getStatementsWithComments().indexOf(returned);\n body.insertStatements(\n returnIndex,\n `\\n${cmsSnippet(eventName, locale.expression(eventName))}\\n`,\n );\n\n if (event.kind === \"binding\") {\n const destructuring = event.pattern.getText();\n body.insertStatements(0, `const ${destructuring} = ${eventName};`);\n const typeText = event.param.getTypeNode()?.getText();\n event.param.replaceWithText(\n typeText ? `${eventName}: ${typeText}` : eventName,\n );\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: eventName });\n }\n\n if (!fn.isAsync()) fn.setIsAsync(true);\n\n ensureNamedImports(sourceFile, \"@sveltejs/kit\", [\"error\", \"redirect\"]);\n ensureNamedImports(sourceFile, \"$lib/cms\", [\"loadCms\"]);\n for (const spec of locale.imports ?? []) {\n ensureImportSpec(sourceFile, spec);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Node } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n findFinalReturn,\n findLoadFunction,\n hasSpreadOf,\n inspectEventParameter,\n newProject,\n returnedObject,\n} from \"./load-function\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Forward the server load's data through the root +layout.ts, so \\`cms\\` reaches\n the page:\n\n export const load = async ({ url, data }) => {\n // ...existing code...\n return { ...data, /* existing keys */ };\n };\n`;\n\n/**\n * Make a universal root \\`+layout.ts\\` forward its server load's data.\n *\n * SvelteKit hands a universal load the server load's result as \\`data\\`, and\n * only what the universal load returns reaches the page. A layout that\n * returns its own object without spreading \\`data\\` — the static template\n * does — would drop \\`cms\\` on the floor once \\`+layout.server.ts\\` exists.\n *\n * No file, or a file without a \\`load\\`, needs nothing: server data flows\n * through on its own.\n */\nexport function modifyLayoutUniversal(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const sourceFile = newProject().addSourceFileAtPath(layoutPath);\n\n const fn = findLoadFunction(sourceFile);\n if (!fn) return { status: \"success\", changed: false };\n\n const body = fn.getBody();\n if (!body || !Node.isBlock(body)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const event = inspectEventParameter(fn);\n if (event.kind === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const returned = findFinalReturn(fn, body);\n if (!returned) return { status: \"failed\", message: FAILURE_HINT };\n\n const dataExpression =\n event.kind === \"identifier\" ? `${event.name}.data` : \"data\";\n\n // `return data;` already forwards everything.\n const expression = returned.getExpression();\n if (expression && expression.getText() === dataExpression) {\n return { status: \"success\", changed: false };\n }\n\n const object = returnedObject(returned);\n if (!object) return { status: \"failed\", message: FAILURE_HINT };\n if (hasSpreadOf(object, dataExpression)) {\n return { status: \"success\", changed: false };\n }\n\n // --- Mutate bottom-up so earlier node references stay valid. ---\n // First, so the layout's own keys still win over anything the server sent.\n object.insertSpreadAssignment(0, { expression: dataExpression });\n\n if (event.kind === \"binding\") {\n const hasData = event.pattern\n .getElements()\n .some((element) => element.getName() === \"data\");\n if (!hasData) {\n const text = event.pattern.getText();\n event.pattern.replaceWithText(text.replace(/^\\{\\s*/, \"{ data, \"));\n }\n } else if (event.kind === \"none\") {\n fn.addParameter({ name: \"{ data }\" });\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst IMPORT_SNIPPET = dedent`\n import { AdminBar } from '@velastack/cms';\n`;\n\nconst MARKUP_SNIPPET = \"\\n<AdminBar />\\n\";\n\nconst NOT_FOUND_HINT = [\n \"Create the root src/routes/+layout.svelte and mount <AdminBar /> inside it.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\nconst FAILURE_HINT = [\n \"Mount <AdminBar /> in the root src/routes/+layout.svelte.\",\n \"\",\n 'Import for a <script lang=\"ts\"> tag:',\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the top level of the layout, above {@render children()}:\",\n MARKUP_SNIPPET.trim(),\n].join(\"\\n\");\n\n/**\n * Mounts `<AdminBar />` at the top level of the root layout, ahead of\n * `{@render children()}` so the bar is in the DOM before the page content.\n * Falls back to appending when the layout has no render tag or slot.\n */\nexport function modifyLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"AdminBar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.getScript()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n { namedImports: [\"AdminBar\"], moduleSpecifier: \"@velastack/cms\" },\n ]);\n });\n return out;\n });\n\n if (!file.insertBeforeChildren(MARKUP_SNIPPET)) {\n file.appendMarkup(MARKUP_SNIPPET);\n }\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\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 { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { resolveMode, type CmsMode } from \"./generate\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport {\n DEFAULT_LOCALE,\n WUCHALE_LOCALE,\n modifyLayoutServer,\n} from \"./modifies/layout.server\";\nimport { modifyLayoutUniversal } from \"./modifies/layout\";\nimport { modifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\n/** The locale list from `wuchale.config.js`, or null when it cannot be read. */\nexport function readWuchaleLocales(root: string): string[] | null {\n const configPath = path.join(root, \"wuchale.config.js\");\n if (!fs.existsSync(configPath)) return null;\n const match = fs\n .readFileSync(configPath, \"utf8\")\n .match(/locales:\\s*\\[([^\\]]*)\\]/);\n if (!match) return null;\n const locales = [...match[1].matchAll(/['\"]([^'\"]+)['\"]/g)].map((m) => m[1]);\n return locales.length > 0 ? locales : null;\n}\n\n/**\n * Arguments for the `cms()` Vite plugin.\n *\n * A hosted CMS needs the endpoint and locales at build time so media can be\n * downloaded into the prerendered site. An app hosting the backend itself\n * needs nothing: the media steps are no-ops without an endpoint.\n */\nexport function vitePluginArgs(mode: CmsMode, locales: string[]): string {\n if (mode.local) return \"\";\n const list = locales.map((locale) => `'${locale}'`).join(\", \");\n return `{ endpoint: '${mode.endpoint}', locales: [${list}] }`;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const mode = resolveMode(options);\n const i18n = options.features.i18n;\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n const locales = (i18n && readWuchaleLocales(options.root)) || [\"en\"];\n pushResult(\n modifyOutcomeToFile(\n viteConfigPath,\n modifyViteConfig(viteConfigPath, vitePluginArgs(mode, locales)),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const locale = i18n ? WUCHALE_LOCALE : DEFAULT_LOCALE;\n pushResult(\n modifyOutcomeToFile(\n layoutServerPath,\n modifyLayoutServer(layoutServerPath, locale),\n ),\n );\n\n // A universal root layout has to pass the server load's data along, or\n // `cms` never reaches the page. The static template has one.\n logger.info(\"Modifying src/routes/+layout.ts\");\n const layoutUniversalPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutUniversalPath,\n modifyLayoutUniversal(layoutUniversalPath),\n ),\n );\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const layoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(layoutSveltePath, modifyLayoutSvelte(layoutSveltePath)),\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":";;;;;;;;;;;AAYA,IAAM,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAS,EAAY,GAAsB;CACzC,OAAO,EAAK,QAAQ,OAAO,EAAE;AAC/B;AAOA,SAAgB,EACd,GACA,IAAa,IACE;CACf,IAAM,IAAO,OAAO,EAAW;CAC/B,IAAI,CAAC,EAAG,WAAW,CAAc,GAC/B,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