@velastack/patterns 0.2.5 → 0.2.7
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/dist/chunks/_layout-D0OmzCu1.js +47 -0
- package/dist/chunks/_layout-D0OmzCu1.js.map +1 -0
- package/dist/chunks/{collections-B-yQ1qt6.js → collections-B3lAtPlQ.js} +2 -2
- package/dist/chunks/{collections-B-yQ1qt6.js.map → collections-B3lAtPlQ.js.map} +1 -1
- package/dist/chunks/{generate-BoEG6Rb-.js → generate-Va1sxVPG.js} +2 -2
- package/dist/chunks/{generate-BoEG6Rb-.js.map → generate-Va1sxVPG.js.map} +1 -1
- package/dist/chunks/{generate-BCBS08AS.js → generate-tOkjJFUf.js} +2 -2
- package/dist/chunks/{generate-BCBS08AS.js.map → generate-tOkjJFUf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-_VsM0zBS.js → generate.runtime-4Iplvp8f.js} +6 -6
- package/dist/chunks/{generate.runtime-_VsM0zBS.js.map → generate.runtime-4Iplvp8f.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ByASCDoo.js → generate.runtime-B9gdCz4t.js} +3 -3
- package/dist/chunks/{generate.runtime-ByASCDoo.js.map → generate.runtime-B9gdCz4t.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CIuSkWtY.js → generate.runtime-BKb9thdE.js} +91 -131
- package/dist/chunks/generate.runtime-BKb9thdE.js.map +1 -0
- package/dist/chunks/generate.runtime-BdTCMGGB.js +65 -0
- package/dist/chunks/generate.runtime-BdTCMGGB.js.map +1 -0
- package/dist/chunks/{generate.runtime-CRgw-aja.js → generate.runtime-BjULAL3h.js} +47 -46
- package/dist/chunks/generate.runtime-BjULAL3h.js.map +1 -0
- package/dist/chunks/{generate.runtime-C6qZUlN-.js → generate.runtime-BlQ1vx8j.js} +6 -6
- package/dist/chunks/{generate.runtime-C6qZUlN-.js.map → generate.runtime-BlQ1vx8j.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CghBFVEf.js → generate.runtime-BltGUllM.js} +6 -6
- package/dist/chunks/{generate.runtime-CghBFVEf.js.map → generate.runtime-BltGUllM.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CwaPHcYP.js → generate.runtime-BsuyMwoj.js} +6 -6
- package/dist/chunks/{generate.runtime-CwaPHcYP.js.map → generate.runtime-BsuyMwoj.js.map} +1 -1
- package/dist/chunks/{generate.runtime-PjMBpjkG.js → generate.runtime-C-Val7lP.js} +5 -5
- package/dist/chunks/{generate.runtime-PjMBpjkG.js.map → generate.runtime-C-Val7lP.js.map} +1 -1
- package/dist/chunks/generate.runtime-CGkVUKvz.js +106 -0
- package/dist/chunks/generate.runtime-CGkVUKvz.js.map +1 -0
- package/dist/chunks/{generate.runtime-BBOWWrZv.js → generate.runtime-CXXwLatT.js} +5 -5
- package/dist/chunks/{generate.runtime-BBOWWrZv.js.map → generate.runtime-CXXwLatT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CrrAzNZS.js → generate.runtime-DCvLLO7w.js} +5 -5
- package/dist/chunks/{generate.runtime-CrrAzNZS.js.map → generate.runtime-DCvLLO7w.js.map} +1 -1
- package/dist/chunks/{generate.runtime-WwZt9Mu5.js → generate.runtime-DKJaYtVZ.js} +7 -7
- package/dist/chunks/{generate.runtime-WwZt9Mu5.js.map → generate.runtime-DKJaYtVZ.js.map} +1 -1
- package/dist/chunks/generate.runtime-DWeiewRj.js +145 -0
- package/dist/chunks/generate.runtime-DWeiewRj.js.map +1 -0
- package/dist/chunks/{generate.runtime-CUtOhlNA.js → generate.runtime-DaPNrIyg.js} +3 -3
- package/dist/chunks/{generate.runtime-CUtOhlNA.js.map → generate.runtime-DaPNrIyg.js.map} +1 -1
- package/dist/chunks/generate.runtime-Dc98DCsh.js +256 -0
- package/dist/chunks/generate.runtime-Dc98DCsh.js.map +1 -0
- package/dist/chunks/{generate.runtime-DercL_qN.js → generate.runtime-FMYR64DL.js} +5 -5
- package/dist/chunks/{generate.runtime-DercL_qN.js.map → generate.runtime-FMYR64DL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Biy8wuHU.js → generate.runtime-QmFJI7G1.js} +13 -13
- package/dist/chunks/{generate.runtime-Biy8wuHU.js.map → generate.runtime-QmFJI7G1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dlokr7A0.js → generate.runtime-SQhCLSah.js} +2 -2
- package/dist/chunks/{generate.runtime-Dlokr7A0.js.map → generate.runtime-SQhCLSah.js.map} +1 -1
- package/dist/chunks/{generate.runtime-UIN_TkYo.js → generate.runtime-Wssys8A0.js} +6 -6
- package/dist/chunks/{generate.runtime-UIN_TkYo.js.map → generate.runtime-Wssys8A0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-nyMB57Tf.js → generate.runtime-fSDNxfGG.js} +2 -2
- package/dist/chunks/{generate.runtime-nyMB57Tf.js.map → generate.runtime-fSDNxfGG.js.map} +1 -1
- package/dist/chunks/{generate.runtime-XpQGIrOx.js → generate.runtime-kH6XaWQz.js} +6 -6
- package/dist/chunks/{generate.runtime-XpQGIrOx.js.map → generate.runtime-kH6XaWQz.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C6RhVu5K.js → generate.runtime-lqPPXQyS.js} +6 -6
- package/dist/chunks/{generate.runtime-C6RhVu5K.js.map → generate.runtime-lqPPXQyS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-JWURZXj-.js → generate.runtime-tAbxWeq-.js} +7 -7
- package/dist/chunks/{generate.runtime-JWURZXj-.js.map → generate.runtime-tAbxWeq-.js.map} +1 -1
- package/dist/chunks/{modify-file-Dgd_PzRG.js → modify-file-Cgu_WeFk.js} +2 -2
- package/dist/chunks/{modify-file-Dgd_PzRG.js.map → modify-file-Cgu_WeFk.js.map} +1 -1
- package/dist/chunks/{shared-cFKFtcgw.js → shared--_BWnGsc.js} +3 -3
- package/dist/chunks/{shared-cFKFtcgw.js.map → shared--_BWnGsc.js.map} +1 -1
- package/dist/chunks/{test-setup-BBb4kcoO.js → test-setup-DjbhQYZC.js} +49 -58
- package/dist/chunks/test-setup-DjbhQYZC.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-7qF9S2k7.js → ts-morph-helpers-Bf5iuQW8.js} +28 -12
- package/dist/chunks/ts-morph-helpers-Bf5iuQW8.js.map +1 -0
- package/dist/chunks/{ui-X12f0xKA.js → ui-BsG60gQg.js} +2 -2
- package/dist/chunks/{ui-X12f0xKA.js.map → ui-BsG60gQg.js.map} +1 -1
- package/dist/chunks/unmodify-load-W1ePZQHr.js +80 -0
- package/dist/chunks/unmodify-load-W1ePZQHr.js.map +1 -0
- package/dist/chunks/{util-Bq_Mh6IQ.js → util-BLYliuUK.js} +2 -2
- package/dist/chunks/{util-Bq_Mh6IQ.js.map → util-BLYliuUK.js.map} +1 -1
- package/dist/chunks/write-result-BN7Ff0rF.js +451 -0
- package/dist/chunks/write-result-BN7Ff0rF.js.map +1 -0
- package/dist/index.d.ts +77 -7
- package/dist/index.js +630 -542
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/generate.runtime-ArKscTs9.js +0 -65
- package/dist/chunks/generate.runtime-ArKscTs9.js.map +0 -1
- package/dist/chunks/generate.runtime-BpvwX9CL.js +0 -28
- package/dist/chunks/generate.runtime-BpvwX9CL.js.map +0 -1
- package/dist/chunks/generate.runtime-BtL9FPuW.js +0 -60
- package/dist/chunks/generate.runtime-BtL9FPuW.js.map +0 -1
- package/dist/chunks/generate.runtime-CIuSkWtY.js.map +0 -1
- package/dist/chunks/generate.runtime-CRgw-aja.js.map +0 -1
- package/dist/chunks/test-setup-BBb4kcoO.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-7qF9S2k7.js.map +0 -1
- package/dist/chunks/write-result-DgFUKxhP.js +0 -445
- package/dist/chunks/write-result-DgFUKxhP.js.map +0 -1
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import a from "
|
|
5
|
-
import o from "node:
|
|
6
|
-
import
|
|
2
|
+
import { n as t } from "./shared--_BWnGsc.js";
|
|
3
|
+
import { modifyOutcomeToFile as n } from "./modify-file-Cgu_WeFk.js";
|
|
4
|
+
import { c as r, i, l as a } from "./ts-morph-helpers-Bf5iuQW8.js";
|
|
5
|
+
import o from "node:path";
|
|
6
|
+
import s from "node:fs";
|
|
7
|
+
import { Project as c, QuoteKind as l, SyntaxKind as u } from "ts-morph";
|
|
7
8
|
//#region src/patterns/disable/content-negotiation/modifies/hooks.server.ts
|
|
8
|
-
function
|
|
9
|
+
function d(e) {
|
|
9
10
|
let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "$lib/negotiate");
|
|
10
11
|
if (!t) return !1;
|
|
11
12
|
let n = t.getNamedImports().find((e) => e.getName() === "handle" && e.getAliasNode()?.getText() === "handleNegotiate");
|
|
12
13
|
return n ? (t.getNamedImports().length === 1 && !t.getDefaultImport() ? t.remove() : n.remove(), !0) : !1;
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function f(e) {
|
|
15
16
|
let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "@sveltejs/kit/hooks");
|
|
16
|
-
if (!t || e.getDescendantsOfKind(
|
|
17
|
+
if (!t || e.getDescendantsOfKind(u.Identifier).some((e) => {
|
|
17
18
|
if (e.getText() !== "sequence") return !1;
|
|
18
19
|
let t = e.getParent()?.getKind();
|
|
19
|
-
return t !==
|
|
20
|
+
return t !== u.ImportSpecifier && t !== u.ImportClause;
|
|
20
21
|
})) return;
|
|
21
22
|
let n = t.getNamedImports().find((e) => e.getName() === "sequence");
|
|
22
23
|
n && (t.getNamedImports().length === 1 && !t.getDefaultImport() ? t.remove() : n.remove());
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
if (!
|
|
25
|
+
function p(e) {
|
|
26
|
+
if (!s.existsSync(e)) return {
|
|
26
27
|
status: "success",
|
|
27
28
|
changed: !1
|
|
28
29
|
};
|
|
29
|
-
let t =
|
|
30
|
+
let t = s.readFileSync(e, "utf8");
|
|
30
31
|
if (!t.includes("handleNegotiate")) return {
|
|
31
32
|
status: "success",
|
|
32
33
|
changed: !1
|
|
33
34
|
};
|
|
34
|
-
let n = new
|
|
35
|
+
let n = new c({
|
|
35
36
|
compilerOptions: { allowJs: !0 },
|
|
36
|
-
manipulationSettings: { quoteKind:
|
|
37
|
+
manipulationSettings: { quoteKind: l.Single }
|
|
37
38
|
}).addSourceFileAtPath(e), r = n.getVariableDeclaration("handle");
|
|
38
|
-
if (!r) return
|
|
39
|
+
if (!r) return d(n), f(n), n.formatText(), n.saveSync(), {
|
|
39
40
|
status: "success",
|
|
40
41
|
changed: n.getFullText() !== t
|
|
41
42
|
};
|
|
42
43
|
let i = r.getInitializer();
|
|
43
|
-
if (i?.getKind() ===
|
|
44
|
-
let e = i.asKindOrThrow(
|
|
44
|
+
if (i?.getKind() === u.CallExpression) {
|
|
45
|
+
let e = i.asKindOrThrow(u.CallExpression);
|
|
45
46
|
if (e.getExpression().getText() === "sequence") {
|
|
46
47
|
let t = e.getArguments(), n = t.findIndex((e) => e.getText() === "handleNegotiate");
|
|
47
48
|
if (n >= 0) {
|
|
@@ -52,37 +53,37 @@ function f(e) {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
return
|
|
56
|
+
return d(n), f(n), n.formatText(), n.saveSync(), {
|
|
56
57
|
status: "success",
|
|
57
58
|
changed: n.getFullText() !== t
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
//#endregion
|
|
61
62
|
//#region src/patterns/disable/content-negotiation/modifies/hooks.ts
|
|
62
|
-
function
|
|
63
|
+
function m(e) {
|
|
63
64
|
let t = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === "$lib/negotiate");
|
|
64
65
|
if (!t) return !1;
|
|
65
66
|
let n = t.getNamedImports().find((e) => e.getName() === "reroute" && e.getAliasNode()?.getText() === "negotiateReroute");
|
|
66
67
|
return n ? (t.getNamedImports().length === 1 && !t.getDefaultImport() ? t.remove() : n.remove(), !0) : !1;
|
|
67
68
|
}
|
|
68
|
-
function m(e) {
|
|
69
|
-
return e.getStatements().every((e) => e.getKind() === l.EmptyStatement);
|
|
70
|
-
}
|
|
71
69
|
function h(e) {
|
|
72
|
-
|
|
70
|
+
return e.getStatements().every((e) => e.getKind() === u.EmptyStatement);
|
|
71
|
+
}
|
|
72
|
+
function g(e) {
|
|
73
|
+
if (!s.existsSync(e)) return {
|
|
73
74
|
status: "success",
|
|
74
75
|
changed: !1
|
|
75
76
|
};
|
|
76
|
-
let t =
|
|
77
|
+
let t = s.readFileSync(e, "utf8");
|
|
77
78
|
if (!t.includes("negotiateReroute")) return {
|
|
78
79
|
status: "success",
|
|
79
80
|
changed: !1
|
|
80
81
|
};
|
|
81
|
-
let n = new
|
|
82
|
+
let n = new c({
|
|
82
83
|
compilerOptions: { allowJs: !0 },
|
|
83
|
-
manipulationSettings: { quoteKind:
|
|
84
|
+
manipulationSettings: { quoteKind: l.Single }
|
|
84
85
|
}).addSourceFileAtPath(e), r = n.getVariableDeclaration("reroute"), i = (r?.getInitializer())?.getText() ?? "", a = n.getVariableDeclarations().some((e) => e.getName() === "rerouteDeLocalize");
|
|
85
|
-
return r && a && i.includes("rerouteDeLocalize") && i.includes("negotiateReroute") ? r.setInitializer("({ url }) => rerouteDeLocalize(url.pathname)") : r && i.includes("negotiateReroute") && r.getFirstAncestorByKind(
|
|
86
|
+
return r && a && i.includes("rerouteDeLocalize") && i.includes("negotiateReroute") ? r.setInitializer("({ url }) => rerouteDeLocalize(url.pathname)") : r && i.includes("negotiateReroute") && r.getFirstAncestorByKind(u.VariableStatement)?.remove(), m(n), h(n) ? (s.writeFileSync(e, "", "utf8"), {
|
|
86
87
|
status: "success",
|
|
87
88
|
changed: !0
|
|
88
89
|
}) : (n.formatText(), n.saveSync(), {
|
|
@@ -92,38 +93,38 @@ function h(e) {
|
|
|
92
93
|
}
|
|
93
94
|
//#endregion
|
|
94
95
|
//#region src/patterns/disable/content-negotiation/modifies/root-layout.svelte.ts
|
|
95
|
-
function
|
|
96
|
-
if (!
|
|
96
|
+
function _(e) {
|
|
97
|
+
if (!s.existsSync(e)) return {
|
|
97
98
|
status: "success",
|
|
98
99
|
changed: !1
|
|
99
100
|
};
|
|
100
|
-
let t =
|
|
101
|
+
let t = a.fromPath(e), n = t.hasElement("Negotiate");
|
|
101
102
|
return t.modifyScript((e) => {
|
|
102
|
-
let { source: t } =
|
|
103
|
+
let { source: t } = r(e, (e) => {
|
|
103
104
|
i(e, "$lib/negotiate");
|
|
104
105
|
});
|
|
105
106
|
return t;
|
|
106
|
-
}),
|
|
107
|
+
}), n && t.removeElement("Negotiate"), t.writeTo(e), {
|
|
107
108
|
status: "success",
|
|
108
109
|
changed: t.hasChanged()
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
//#endregion
|
|
112
113
|
//#region src/patterns/disable/content-negotiation/generate.runtime.ts
|
|
113
|
-
async function
|
|
114
|
-
let
|
|
115
|
-
e &&
|
|
114
|
+
async function v(r) {
|
|
115
|
+
let i = e(r), a = [], c = [], l = (e) => {
|
|
116
|
+
e && a.push(e);
|
|
116
117
|
};
|
|
117
|
-
|
|
118
|
-
let
|
|
119
|
-
|
|
120
|
-
let
|
|
121
|
-
|
|
122
|
-
let
|
|
123
|
-
return
|
|
118
|
+
i.info("Reverting hooks.server.ts");
|
|
119
|
+
let u = o.join(r.root, "src", "hooks.server.ts");
|
|
120
|
+
l(n(u, p(u))), i.info("Reverting hooks.ts");
|
|
121
|
+
let d = o.join(r.root, "src", "hooks.ts"), f = g(d);
|
|
122
|
+
s.existsSync(d) && s.readFileSync(d, "utf8").trim() === "" ? c.push(t(d)) : l(n(d, f)), i.info("Reverting src/routes/+layout.svelte");
|
|
123
|
+
let m = o.join(r.root, "src", "routes", "+layout.svelte");
|
|
124
|
+
return l(n(m, _(m))), {
|
|
124
125
|
creates: [],
|
|
125
|
-
modifies:
|
|
126
|
-
deletes:
|
|
126
|
+
modifies: a,
|
|
127
|
+
deletes: c,
|
|
127
128
|
components: [],
|
|
128
129
|
packages: [],
|
|
129
130
|
collections: [],
|
|
@@ -132,6 +133,6 @@ async function _(n) {
|
|
|
132
133
|
};
|
|
133
134
|
}
|
|
134
135
|
//#endregion
|
|
135
|
-
export {
|
|
136
|
+
export { v as generate };
|
|
136
137
|
|
|
137
|
-
//# sourceMappingURL=generate.runtime-
|
|
138
|
+
//# sourceMappingURL=generate.runtime-BjULAL3h.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BjULAL3h.js","names":[],"sources":["../../src/patterns/disable/content-negotiation/modifies/hooks.server.ts","../../src/patterns/disable/content-negotiation/modifies/hooks.ts","../../src/patterns/disable/content-negotiation/modifies/root-layout.svelte.ts","../../src/patterns/disable/content-negotiation/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"$lib/negotiate\");\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"handle\" &&\n ni.getAliasNode()?.getText() === \"handleNegotiate\"\n );\n });\n\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction removeSequenceImportIfUnused(sourceFile: SourceFile): void {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"@sveltejs/kit/hooks\");\n if (!decl) return;\n\n const stillReferenced = sourceFile\n .getDescendantsOfKind(SyntaxKind.Identifier)\n .some((id) => {\n if (id.getText() !== \"sequence\") return false;\n const parent = id.getParent();\n const kind = parent?.getKind();\n return (\n kind !== SyntaxKind.ImportSpecifier && kind !== SyntaxKind.ImportClause\n );\n });\n\n if (stillReferenced) return;\n\n const named = decl\n .getNamedImports()\n .find((ni) => ni.getName() === \"sequence\");\n if (!named) return;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n}\n\nexport function unmodifyHooksServerNegotiate(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(\"handleNegotiate\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const handleDecl = sourceFile.getVariableDeclaration(\"handle\");\n if (!handleDecl) {\n removeNegotiateImport(sourceFile);\n removeSequenceImportIfUnused(sourceFile);\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n }\n\n const init = handleDecl.getInitializer();\n if (init?.getKind() === SyntaxKind.CallExpression) {\n const call = init.asKindOrThrow(SyntaxKind.CallExpression);\n if (call.getExpression().getText() === \"sequence\") {\n const args = call.getArguments();\n const idx = args.findIndex((arg) => arg.getText() === \"handleNegotiate\");\n if (idx >= 0) {\n if (args.length === 2) {\n const keepText = args[idx === 0 ? 1 : 0].getText();\n handleDecl.setInitializer(keepText);\n } else {\n call.removeArgument(idx);\n }\n }\n }\n }\n\n removeNegotiateImport(sourceFile);\n removeSequenceImportIfUnused(sourceFile);\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nfunction removeNegotiateImport(sourceFile: SourceFile): boolean {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === \"$lib/negotiate\");\n if (!decl) return false;\n\n const named = decl.getNamedImports().find((ni) => {\n return (\n ni.getName() === \"reroute\" &&\n ni.getAliasNode()?.getText() === \"negotiateReroute\"\n );\n });\n if (!named) return false;\n\n if (decl.getNamedImports().length === 1 && !decl.getDefaultImport()) {\n decl.remove();\n } else {\n named.remove();\n }\n return true;\n}\n\nfunction isMeaningfullyEmpty(sourceFile: SourceFile): boolean {\n return sourceFile\n .getStatements()\n .every((s) => s.getKind() === SyntaxKind.EmptyStatement);\n}\n\nexport function unmodifyHooksNegotiate(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (!original.includes(\"negotiateReroute\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksPath);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const init = rerouteDecl?.getInitializer();\n const initText = init?.getText() ?? \"\";\n\n const hasI18nHelper = sourceFile\n .getVariableDeclarations()\n .some((d) => d.getName() === \"rerouteDeLocalize\");\n\n if (\n rerouteDecl &&\n hasI18nHelper &&\n initText.includes(\"rerouteDeLocalize\") &&\n initText.includes(\"negotiateReroute\")\n ) {\n rerouteDecl.setInitializer(\"({ url }) => rerouteDeLocalize(url.pathname)\");\n } else if (rerouteDecl && initText.includes(\"negotiateReroute\")) {\n const stmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n stmt?.remove();\n }\n\n removeNegotiateImport(sourceFile);\n\n if (isMeaningfullyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty hooks.ts into a\n // delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(hooksPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyRootLayoutNegotiate(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n const hasElement = file.hasElement(\"Negotiate\");\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(sf, \"$lib/negotiate\");\n });\n return out;\n });\n\n if (hasElement) {\n file.removeElement(\"Negotiate\");\n }\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 { toDeleteEntry } from \"../../destroy/shared\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServerNegotiate } from \"./modifies/hooks.server\";\nimport { unmodifyHooksNegotiate } from \"./modifies/hooks\";\nimport { unmodifyRootLayoutNegotiate } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: 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(\n hooksServerPath,\n unmodifyHooksServerNegotiate(hooksServerPath),\n ),\n );\n\n logger.info(\"Reverting hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n const hooksOutcome = unmodifyHooksNegotiate(hooksPath);\n if (\n fs.existsSync(hooksPath) &&\n fs.readFileSync(hooksPath, \"utf8\").trim() === \"\"\n ) {\n // The reroute was all it contained; the file goes with it.\n deletes.push(toDeleteEntry(hooksPath));\n } else {\n pushResult(modifyOutcomeToFile(hooksPath, hooksOutcome));\n }\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n unmodifyRootLayoutNegotiate(rootLayoutPath),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAIA,SAAS,EAAsB,GAAiC;CAC9D,IAAM,IAAO,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,gBAAgB;CAC/D,IAAI,CAAC,GAAM,OAAO;CAElB,IAAM,IAAQ,EAAK,gBAAgB,CAAC,CAAC,MAAM,MAEvC,EAAG,QAAQ,MAAM,YACjB,EAAG,aAAa,CAAC,EAAE,QAAQ,MAAM,iBAEpC;CASD,OAPK,KAED,EAAK,gBAAgB,CAAC,CAAC,WAAW,KAAK,CAAC,EAAK,iBAAiB,IAChE,EAAK,OAAO,IAEZ,EAAM,OAAO,GAER,MAPY;AAQrB;AAEA,SAAS,EAA6B,GAA8B;CAClE,IAAM,IAAO,EACV,sBAAsB,CAAC,CACvB,MAAM,MAAM,EAAE,wBAAwB,MAAM,qBAAqB;CAcpE,IAbI,CAAC,KAEmB,EACrB,qBAAqB,EAAW,UAAU,CAAC,CAC3C,MAAM,MAAO;EACZ,IAAI,EAAG,QAAQ,MAAM,YAAY,OAAO;EAExC,IAAM,IADS,EAAG,UACL,CAAA,EAAQ,QAAQ;EAC7B,OACE,MAAS,EAAW,mBAA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KACvB,EAAG,aAAa,GAAW,MAAM,CAAC,CAAC,KAAK,MAAM,KAG9C,EAAQ,KAAK,EAAc,CAAS,CAAC,IAErC,EAAW,EAAoB,GAAW,CAAY,CAAC,GAGzD,EAAO,KAAK,qCAAqC;CACjD,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,gBACF;CAQA,OAPA,EACE,EACE,GACA,EAA4B,CAAc,CAC5C,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
3
|
import { a as n, c as r, i, n as a, o, r as s, s as c, t as l } from "./_server-BSm1eAiY.js";
|
|
4
|
-
import { modifyOutcomeToFile as u } from "./modify-file-
|
|
5
|
-
import {
|
|
4
|
+
import { modifyOutcomeToFile as u } from "./modify-file-Cgu_WeFk.js";
|
|
5
|
+
import { c as d, l as f, r as p } from "./ts-morph-helpers-Bf5iuQW8.js";
|
|
6
6
|
import m from "node:path";
|
|
7
7
|
import h from "node:fs";
|
|
8
8
|
import { SyntaxKind as g } from "ts-morph";
|
|
@@ -87,7 +87,7 @@ function w(e) {
|
|
|
87
87
|
changed: !1
|
|
88
88
|
};
|
|
89
89
|
let n = !1, { source: r } = d(t, (e) => {
|
|
90
|
-
|
|
90
|
+
p(e, [
|
|
91
91
|
{
|
|
92
92
|
namedImports: ["handleSubscriptionCreated"],
|
|
93
93
|
moduleSpecifier: "./handlers/subscription/created"
|
|
@@ -158,7 +158,7 @@ function A(e) {
|
|
|
158
158
|
status: "not-found",
|
|
159
159
|
message: k
|
|
160
160
|
};
|
|
161
|
-
let t =
|
|
161
|
+
let t = f.fromPath(e);
|
|
162
162
|
return t.hasElement("AppSidebar") ? t.hasAttribute("AppSidebar", "subscription") ? {
|
|
163
163
|
status: "success",
|
|
164
164
|
changed: !1
|
|
@@ -223,7 +223,7 @@ function F(e) {
|
|
|
223
223
|
status: "success",
|
|
224
224
|
changed: !1
|
|
225
225
|
};
|
|
226
|
-
let n = new
|
|
226
|
+
let n = new f(t);
|
|
227
227
|
if (!n.hasElement("NavUser")) return {
|
|
228
228
|
status: "failed",
|
|
229
229
|
message: M
|
|
@@ -306,4 +306,4 @@ async function W(e) {
|
|
|
306
306
|
//#endregion
|
|
307
307
|
export { W as generate };
|
|
308
308
|
|
|
309
|
-
//# sourceMappingURL=generate.runtime-
|
|
309
|
+
//# sourceMappingURL=generate.runtime-BlQ1vx8j.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-C6qZUlN-.js","names":[],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-stripe-hooks.ts","../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst CRON_SNIPPET = dedent`\n cronAdd(\"stripe-subscriptions\", \"*/2 * * * *\", () => {\n const utils = require(\\`\\${__hooks}/utils.js\\`);\n utils.triggerJob(\"/api/stripe/sync/subscriptions\");\n });\n`;\n\nconst FAILURE_HINT = [\n \"Append the stripe-subscriptions cron to data/hooks/stripe.pb.js:\",\n \"\",\n CRON_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Enable payments first — data/hooks/stripe.pb.js is created by enable-payments.\",\n \"\",\n \"Once present, append:\",\n \"\",\n CRON_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyStripeHooks(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(\"stripe-subscriptions\")) {\n return { status: \"success\", changed: false };\n }\n if (!current.includes(\"cronAdd(\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const trailing = current.endsWith(\"\\n\") ? \"\" : \"\\n\";\n const next = `${current}${trailing}\\n${CRON_SNIPPET}\\n`;\n fs.writeFileSync(filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/+server.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./handlers/subscription/created\";\n import { handleSubscriptionUpdated } from \"./handlers/subscription/updated\";\n import { handleSubscriptionDeleted } from \"./handlers/subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/+server.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./handlers/subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./handlers/subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./handlers/subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(\n last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`,\n );\n } else {\n return;\n }\n\n sf.formatText();\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(\n filePath,\n template,\n \"loadActiveSubscription\",\n NOT_FOUND_HINT,\n );\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} meta={data.meta} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n sf.formatText();\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript((src) => updateScript(src).source);\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/lib/components/nav-user.svelte is missing.\",\n \"Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user.\",\n].join(\"\\n\");\n\nexport function modifyNavUser(\n filePath: string,\n template: string,\n): ModifyOutcome {\n // `planLabel` is unique to subscriptions — safe idempotency marker.\n return modifyByTemplate(filePath, template, \"planLabel\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"selectPlan\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"availablePlans\", NOT_FOUND_HINT);\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 { modifyStripeHooks } from \"./modifies/modify-stripe-hooks\";\nimport { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\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(\"Modifying data/hooks/stripe.pb.js\");\n const stripeHooksPath = path.join(\n options.root,\n \"data\",\n \"hooks\",\n \"stripe.pb.js\",\n );\n pushResult(\n modifyOutcomeToFile(stripeHooksPath, modifyStripeHooks(stripeHooksPath)),\n );\n\n logger.info(\"Modifying webhooks/stripe/+server.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"+server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n modifyNavUser(\n navUserPath,\n template(\"src/lib/components/nav-user.svelte\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAIA,IAAM,IAAe,CAAM;;;;;GAOrB,IAAe;CACnB;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;AACF,CA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CAAmC;CAC/C,IAAM,IAAsB,EAAK,KAC/B,EAAQ,MACR,OACA,UACA,SACA,mBACF;CAWA,AAVA,EACE,EACE,GACA,EACE,GACA,EAAS,oCAAoC,CAC/C,CACF,CACF,GAEA,EAAO,KAAK,gCAAgC;CAC5C,IAAM,IAAsB,EAAK,KAC/B,EAAQ,MACR,OACA,UACA,SACA,gBACF;CAQA,AAPA,EACE,EACE,GACA,EAAsB,CAAmB,CAC3C,CACF,GAEA,EAAO,KAAK,8BAA8B;CAC1C,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,OACA,cACA,oBACF;CAKA,AAJA,EACE,EAAoB,GAAgB,EAAiB,CAAc,CAAC,CACtE,GAEA,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,iBACF;CAWA,AAVA,EACE,EACE,GACA,EACE,GACA,EAAS,oCAAoC,CAC/C,CACF,CACF,GAEA,EAAO,KAAK,mCAAmC;CAC/C,IAAM,IAAwB,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,iBACF;CAWA,AAVA,EACE,EACE,GACA,EACE,GACA,EAAS,0CAA0C,CACrD,CACF,CACF,GAEA,EAAO,KAAK,gCAAgC;CAC5C,IAAM,IAAwB,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,cACF;CAWA,OAVA,EACE,EACE,GACA,EACE,GACA,EAAS,uCAAuC,CAClD,CACF,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-BlQ1vx8j.js","names":[],"sources":["../../src/patterns/enable/subscriptions/modifies/modify-stripe-hooks.ts","../../src/patterns/enable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-by-template.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/enable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/enable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/enable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/enable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst CRON_SNIPPET = dedent`\n cronAdd(\"stripe-subscriptions\", \"*/2 * * * *\", () => {\n const utils = require(\\`\\${__hooks}/utils.js\\`);\n utils.triggerJob(\"/api/stripe/sync/subscriptions\");\n });\n`;\n\nconst FAILURE_HINT = [\n \"Append the stripe-subscriptions cron to data/hooks/stripe.pb.js:\",\n \"\",\n CRON_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Enable payments first — data/hooks/stripe.pb.js is created by enable-payments.\",\n \"\",\n \"Once present, append:\",\n \"\",\n CRON_SNIPPET,\n].join(\"\\n\");\n\nexport function modifyStripeHooks(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(\"stripe-subscriptions\")) {\n return { status: \"success\", changed: false };\n }\n if (!current.includes(\"cronAdd(\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const trailing = current.endsWith(\"\\n\") ? \"\" : \"\\n\";\n const next = `${current}${trailing}\\n${CRON_SNIPPET}\\n`;\n fs.writeFileSync(filePath, next, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Wire the subscription event handlers into src/routes/webhooks/stripe/+server.ts:\n\n Add imports:\n import { handleSubscriptionCreated } from \"./handlers/subscription/created\";\n import { handleSubscriptionUpdated } from \"./handlers/subscription/updated\";\n import { handleSubscriptionDeleted } from \"./handlers/subscription/deleted\";\n\n Add switch cases inside the event.type switch:\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nconst NOT_FOUND_HINT =\n \"Enable payments first — src/routes/webhooks/stripe/+server.ts is created by enable-payments.\";\n\nconst SUBSCRIPTION_CASES_SNIPPET = dedent`\n case \"customer.subscription.created\":\n await handleSubscriptionCreated(event.data.object, locals);\n break;\n\n case \"customer.subscription.updated\":\n await handleSubscriptionUpdated(event.data.object, locals);\n break;\n\n case \"customer.subscription.deleted\":\n await handleSubscriptionDeleted(event.data.object, locals);\n break;\n`;\n\nexport function modifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n let addedCases = false;\n const { source } = withInMemoryScript(original, (sf) => {\n ensureImports(sf, [\n {\n namedImports: [\"handleSubscriptionCreated\"],\n moduleSpecifier: \"./handlers/subscription/created\",\n },\n {\n namedImports: [\"handleSubscriptionUpdated\"],\n moduleSpecifier: \"./handlers/subscription/updated\",\n },\n {\n namedImports: [\"handleSubscriptionDeleted\"],\n moduleSpecifier: \"./handlers/subscription/deleted\",\n },\n ]);\n\n const switchStmt = sf\n .getDescendantsOfKind(SyntaxKind.SwitchStatement)\n .find((stmt) => stmt.getExpression().getText().includes(\"event.type\"));\n if (!switchStmt) return;\n\n const caseBlock = switchStmt.getCaseBlock();\n const clauses = caseBlock.getClauses();\n const defaultClause = clauses.find(\n (c) => c.getKind() === SyntaxKind.DefaultClause,\n );\n\n // Prepend subscription cases in front of the default clause, or append\n // before the closing brace of the case block if there's no default.\n const prefix = `${SUBSCRIPTION_CASES_SNIPPET}\\n\\n`;\n if (defaultClause) {\n defaultClause.replaceWithText(prefix + defaultClause.getText());\n } else if (clauses.length > 0) {\n const last = clauses[clauses.length - 1];\n last.replaceWithText(\n last.getText() + `\\n\\n${SUBSCRIPTION_CASES_SNIPPET}`,\n );\n } else {\n return;\n }\n\n sf.formatText();\n addedCases = true;\n });\n\n if (!addedCases) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n fs.writeFileSync(filePath, source, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Overwrites a file with the given template content, guarded by an idempotency\n * marker: if the current file already contains the marker, the modify is a\n * no-op. Used for complex rewrites where surgical AST changes aren't worth it\n * (e.g. pages that are largely replaced).\n *\n * Strips leading `// [!code highlight:N]` and `<!-- [!code highlight:N] -->`\n * lines so the same content can be shared with preview-modifies, which uses\n * those comments for documentation highlighting.\n */\nexport function modifyByTemplate(\n filePath: string,\n template: string,\n idempotencyMarker: string,\n notFoundHint: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: notFoundHint };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (current.includes(idempotencyMarker)) {\n return { status: \"success\", changed: false };\n }\n const stripped = template\n .replace(/^[ \\t]*\\/\\/[ \\t]*\\[!code highlight:\\d+\\][ \\t]*\\r?\\n/gm, \"\")\n .replace(\n /^[ \\t]*<!--[ \\t]*\\[!code highlight:\\d+\\][ \\t]*-->[ \\t]*\\r?\\n/gm,\n \"\",\n );\n if (current === stripped) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, stripped, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.server.ts before enabling subscriptions.\",\n \"Enable auth first — the (app) layout is provided by the velastack-auth baseline.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(\n filePath,\n template,\n \"loadActiveSubscription\",\n NOT_FOUND_HINT,\n );\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Pass the subscription prop to <AppSidebar> in src/routes/(app)/+layout.svelte:\",\n \"\",\n \"<AppSidebar user={data.user} meta={data.meta} subscription={data.subscription} />\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop.\",\n].join(\"\\n\");\n\nexport function modifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const appended = file.appendToAttributes(\n \"AppSidebar\",\n \" subscription={data.subscription}\",\n );\n if (!appended) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { withInMemoryScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst SUBSCRIPTION_TYPE = \"{ id: string; productName: string | null } | null\";\n\nconst FAILURE_HINT = [\n \"Update src/lib/components/app-sidebar.svelte to forward a subscription prop:\",\n \"\",\n \"1. Add `subscription = null` to the destructured $props() call.\",\n `2. Add \\`subscription?: ${SUBSCRIPTION_TYPE}\\` to the props type.`,\n \"3. Pass `{subscription}` to <NavUser>.\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/lib/components/app-sidebar.svelte before enabling subscriptions.\",\n].join(\"\\n\");\n\nfunction updateScript(source: string): {\n source: string;\n wasAdded: boolean;\n} {\n let wasAdded = false;\n const { source: out } = withInMemoryScript(source, (sf) => {\n for (const decl of sf.getVariableDeclarations()) {\n const init = decl.getInitializer();\n if (!init || init.getText() !== \"$props()\") continue;\n\n const nameNode = decl.getNameNode();\n if (nameNode.getKind() !== SyntaxKind.ObjectBindingPattern) continue;\n const pattern = nameNode.asKindOrThrow(SyntaxKind.ObjectBindingPattern);\n const elements = pattern.getElements();\n if (elements.some((e) => e.getName() === \"subscription\")) {\n // Already has subscription prop — no-op.\n return;\n }\n\n // Insert subscription?: ... into the props type literal if present.\n const typeNode = decl.getTypeNode();\n if (typeNode?.getKind() === SyntaxKind.IntersectionType) {\n const intersection = typeNode.asKindOrThrow(\n SyntaxKind.IntersectionType,\n );\n for (const member of intersection.getTypeNodes()) {\n if (member.getKind() !== SyntaxKind.TypeLiteral) continue;\n const lit = member.asKindOrThrow(SyntaxKind.TypeLiteral);\n const propTexts = lit\n .getProperties()\n .map((p) => p.getText().replace(/[;,]\\s*$/, \"\"));\n if (propTexts.some((t) => /^\\s*subscription\\??\\s*:/.test(t))) {\n continue;\n }\n propTexts.push(`subscription?: ${SUBSCRIPTION_TYPE}`);\n lit.replaceWithText(`{ ${propTexts.join(\"; \")}; }`);\n break;\n }\n }\n\n // Insert `subscription = null` before the first rest/default-only element.\n const elementTexts = elements.map((e) => e.getText());\n let insertIdx = elements.findIndex(\n (e) => e.getDotDotDotToken() || e.getInitializer(),\n );\n if (insertIdx === -1) insertIdx = elementTexts.length;\n elementTexts.splice(insertIdx, 0, \"subscription = null\");\n pattern.replaceWithText(`{ ${elementTexts.join(\", \")} }`);\n wasAdded = true;\n }\n sf.formatText();\n });\n return { source: out, wasAdded };\n}\n\nexport function modifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(filePath, \"utf8\");\n if (\n original.includes(\"subscription?: {\") ||\n original.includes(\"subscription={subscription}\") ||\n original.includes(\"{subscription}\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(original);\n if (!file.hasElement(\"NavUser\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const scriptChanged = file.modifyScript((src) => updateScript(src).source);\n\n const templateChanged = !file.hasAttribute(\"NavUser\", \"subscription\")\n ? file.appendToAttributes(\"NavUser\", \" {subscription}\")\n : false;\n\n if (!scriptChanged && !templateChanged) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/lib/components/nav-user.svelte is missing.\",\n \"Enable auth and payments first; subscriptions layers a plan label on top of the existing nav-user.\",\n].join(\"\\n\");\n\nexport function modifyNavUser(\n filePath: string,\n template: string,\n): ModifyOutcome {\n // `planLabel` is unique to subscriptions — safe idempotency marker.\n return modifyByTemplate(filePath, template, \"planLabel\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.server.ts is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageServer(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"selectPlan\", NOT_FOUND_HINT);\n}\n","import { modifyByTemplate } from \"./modify-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"src/routes/(app)/billing/+page.svelte is missing.\",\n \"Enable payments first — subscriptions extends the billing page with plan management.\",\n].join(\"\\n\");\n\nexport function modifyBillingPageSvelte(\n filePath: string,\n template: string,\n): ModifyOutcome {\n return modifyByTemplate(filePath, template, \"availablePlans\", NOT_FOUND_HINT);\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 { modifyStripeHooks } from \"./modifies/modify-stripe-hooks\";\nimport { modifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { modifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { modifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { modifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { modifyNavUser } from \"./modifies/modify-nav-user\";\nimport { modifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { modifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Share the final-state files between preview (rendered as-is) and runtime\n// (used as overwrite templates for modifies that amount to full rewrites).\nconst previewRaw = import.meta.glob<string>(\"./preview-modifies/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\nfunction template(relativePath: string): string {\n const key = `./preview-modifies/${relativePath}`;\n const content = previewRaw[key];\n if (content === undefined) {\n throw new Error(\n `Missing template for ${relativePath} in subscriptions preview-modifies`,\n );\n }\n return content;\n}\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(\"Modifying data/hooks/stripe.pb.js\");\n const stripeHooksPath = path.join(\n options.root,\n \"data\",\n \"hooks\",\n \"stripe.pb.js\",\n );\n pushResult(\n modifyOutcomeToFile(stripeHooksPath, modifyStripeHooks(stripeHooksPath)),\n );\n\n logger.info(\"Modifying webhooks/stripe/+server.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"+server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n modifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n modifyAppLayoutServer(\n appLayoutServerPath,\n template(\"src/routes/(app)/+layout.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying (app)/+layout.svelte\");\n const appLayoutSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutSveltePath,\n modifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Modifying app-sidebar.svelte\");\n const appSidebarPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"app-sidebar.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appSidebarPath, modifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Modifying nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n modifyNavUser(\n navUserPath,\n template(\"src/lib/components/nav-user.svelte\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.server.ts\");\n const billingPageServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageServerPath,\n modifyBillingPageServer(\n billingPageServerPath,\n template(\"src/routes/(app)/billing/+page.server.ts\"),\n ),\n ),\n );\n\n logger.info(\"Modifying billing/+page.svelte\");\n const billingPageSveltePath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"billing\",\n \"+page.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n billingPageSveltePath,\n modifyBillingPageSvelte(\n billingPageSveltePath,\n template(\"src/routes/(app)/billing/+page.svelte\"),\n ),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAIA,IAAM,IAAe,CAAM;;;;;GAOrB,IAAe;CACnB;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAEL,IAAiB;CACrB;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgB,EAAkB,GAAiC;CACjE,IAAI,CAAC,EAAG,WAAW,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAa,SAAS;CAAe;CAExD,IAAM,IAAU,EAAG,aAAa,GAAU,MAAM;CAChD,IAAI,EAAQ,SAAS,sBAAsB,GACzC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAI,CAAC,EAAQ,SAAS,UAAU,GAC9B,OAAO;EAAE,QAAQ;EAAU,SAAS;CAAa;CAGnD,IAAM,IAAO,GAAG,IADC,EAAQ,SAAS,IAAI,IAAI,KAAK,KACZ,IAAI,EAAa;CAEpD,OADA,EAAG,cAAc,GAAU,GAAM,MAAM,GAChC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;AC/BA,IAAM,IAAe,CAAM;;;;;;;;;;;;;;;;;;GAoBrB,IACJ,gGAEI,IAA6B,CAAM;;;;;;;;;;;;;AAczC,SAAgB,EAAoB,GAAiC;CACnE,IAAI,C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B,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,iBACF;CAWA,AAVA,EACE,EACE,GACA,EACE,GACA,EAAS,0CAA0C,CACrD,CACF,CACF,GAEA,EAAO,KAAK,gCAAgC;CAC5C,IAAM,IAAwB,EAAK,KACjC,EAAQ,MACR,OACA,UACA,SACA,WACA,cACF;CAWA,OAVA,EACE,EACE,GACA,EACE,GACA,EAAS,uCAAuC,CAClD,CACF,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { t } from "./taggedTemplateLiteral-CPUMuLtk.js";
|
|
3
3
|
import { n } from "./logger-CQONztPm.js";
|
|
4
|
-
import { modifyOutcomeToFile as r } from "./modify-file-
|
|
5
|
-
import {
|
|
4
|
+
import { modifyOutcomeToFile as r } from "./modify-file-Cgu_WeFk.js";
|
|
5
|
+
import { l as i, r as a } from "./ts-morph-helpers-Bf5iuQW8.js";
|
|
6
6
|
import { i as o } from "./config-target-DOi8kI_f.js";
|
|
7
7
|
import s from "node:path";
|
|
8
8
|
import c from "node:fs";
|
|
@@ -64,7 +64,7 @@ function m(e) {
|
|
|
64
64
|
return o(e, {
|
|
65
65
|
notFound: d,
|
|
66
66
|
failed: u
|
|
67
|
-
}, (e) => (f(e.configObject), p(e.configObject),
|
|
67
|
+
}, (e) => (f(e.configObject), p(e.configObject), a(e.sourceFile, [{
|
|
68
68
|
namedImports: ["mdsvex"],
|
|
69
69
|
moduleSpecifier: "mdsvex"
|
|
70
70
|
}]), !0));
|
|
@@ -82,7 +82,7 @@ function y(e) {
|
|
|
82
82
|
status: "not-found",
|
|
83
83
|
message: _
|
|
84
84
|
};
|
|
85
|
-
let t =
|
|
85
|
+
let t = i.fromPath(e), n = t.getScript();
|
|
86
86
|
return n ? n.content.includes("prism-vsc-dark-plus.css") ? {
|
|
87
87
|
status: "success",
|
|
88
88
|
changed: !1
|
|
@@ -125,7 +125,7 @@ function C(e) {
|
|
|
125
125
|
status: "not-found",
|
|
126
126
|
message: S
|
|
127
127
|
};
|
|
128
|
-
let t =
|
|
128
|
+
let t = i.fromPath(e);
|
|
129
129
|
if (!t.hasElement("Navbar.List")) return {
|
|
130
130
|
status: "failed",
|
|
131
131
|
message: x
|
|
@@ -169,4 +169,4 @@ async function w(e) {
|
|
|
169
169
|
//#endregion
|
|
170
170
|
export { w as generate };
|
|
171
171
|
|
|
172
|
-
//# sourceMappingURL=generate.runtime-
|
|
172
|
+
//# sourceMappingURL=generate.runtime-BltGUllM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-CghBFVEf.js","names":[],"sources":["../../src/patterns/enable/blog/modifies/svelte.config.ts","../../src/patterns/enable/blog/modifies/root-layout-svelte.ts","../../src/patterns/enable/blog/modifies/public-root-layout-svelte.ts","../../src/patterns/enable/blog/generate.runtime.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport {\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n} from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\nimport { ensureImports } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Enable mdsvex in your config (sveltekit() arg in vite.config, or svelte.config):\n\n import { mdsvex } from 'mdsvex';\n\n // ...\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Enable mdsvex by passing config to the sveltekit() plugin in vite.config.ts:\n\n import { sveltekit } from '@sveltejs/kit/vite';\n import { mdsvex } from 'mdsvex';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n plugins: [\n sveltekit({\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n }),\n ],\n });\n`;\n\nfunction ensureExtensionsSvx(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"extensions\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"extensions\",\n initializer: \"['.svelte', '.svx']\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"['.svelte', '.svx']\",\n );\n return true;\n }\n const arr = init as ArrayLiteralExpression;\n const hasSvx = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \".svx\");\n if (hasSvx) return false;\n arr.addElement(\"'.svx'\");\n return true;\n}\n\nfunction ensurePreprocessMdsvex(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"preprocess\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"preprocess\",\n initializer: \"[mdsvex()]\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[mdsvex()]\",\n );\n return true;\n }\n if (init.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = init as ArrayLiteralExpression;\n const hasMdsvex = arr\n .getElements()\n .some((el) => /\\bmdsvex\\s*\\(/.test(el.getText()));\n if (hasMdsvex) return false;\n arr.addElement(\"mdsvex()\");\n return true;\n }\n const text = init.getText();\n if (/\\bmdsvex\\s*\\(/.test(text)) return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `[${text}, mdsvex()]`,\n );\n return true;\n}\n\n/**\n * Enable mdsvex: ensure `extensions` includes `.svx`, `preprocess` includes\n * `mdsvex()`, and the `mdsvex` import is present. All root-level, so they apply\n * identically to svelte.config and the inline sveltekit() arg; the import lands\n * in whichever file was resolved.\n */\nexport function modifySvelteConfigMdsvex(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n ensureExtensionsSvx(target.configObject);\n ensurePreprocessMdsvex(target.configObject);\n ensureImports(target.sourceFile, [\n { namedImports: [\"mdsvex\"], moduleSpecifier: \"mdsvex\" },\n ]);\n return true;\n },\n );\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst PRISM_IMPORT = `import '../css/prism-vsc-dark-plus.css';`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ${PRISM_IMPORT}\n </script>\n`;\n\nconst FAILURE_HINT = dedent`\n Import the Prism theme in your root +layout.svelte for blog code\n block highlighting:\n\n ${PRISM_IMPORT}\n`;\n\nexport function modifyRootLayoutSvelte(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 const script = file.getScript();\n if (!script) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (script.content.includes(\"prism-vsc-dark-plus.css\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const appCssMatch = source.match(\n /^(\\s*)import\\s+['\"][^'\"]*app\\.css['\"];?\\s*$/m,\n );\n if (appCssMatch) {\n const indent = appCssMatch[1] ?? \"\";\n const insertion = `\\n${indent}${PRISM_IMPORT}`;\n const end = (appCssMatch.index ?? 0) + appCssMatch[0].length;\n return source.slice(0, end) + insertion + source.slice(end);\n }\n return source.replace(/^/, `\\n\\t${PRISM_IMPORT}\\n`);\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BLOG_NAVBAR_ITEM = `\n\t\t<Navbar.Item>\n\t\t\t<Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n\t\t\t\tBlog\n\t\t\t</Button>\n\t\t</Navbar.Item>\n\t`;\n\nconst FAILURE_HINT = dedent`\n Add a Blog link inside <Navbar.List> in the public root layout:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a public root layout with a Blog link in its Navbar.List:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nexport function modifyPublicRootLayout(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(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const raw = fs.readFileSync(layoutPath, \"utf8\");\n if (/href=[\"']\\/blog[\"']/.test(raw)) {\n return { status: \"success\", changed: false };\n }\n\n file.insertBeforeClosingTag(\"Navbar.List\", BLOG_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifySvelteConfigMdsvex } from \"./modifies/svelte.config\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout-svelte\";\nimport { modifyPublicRootLayout } from \"./modifies/public-root-layout-svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying config for mdsvex\");\n const mdsvex = modifySvelteConfigMdsvex(options.root);\n pushResult(modifyOutcomeToFile(mdsvex.filePath, mdsvex.outcome));\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(rootLayoutPath, modifyRootLayoutSvelte(rootLayoutPath)),\n );\n\n logger.info(\"Modifying public root layout\");\n const publicLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n ];\n const publicLayoutPath =\n publicLayoutCandidates.find((p) => fs.existsSync(p)) ??\n publicLayoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(\n publicLayoutPath,\n modifyPublicRootLayout(publicLayoutPath),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAM,IAAe,CAAM;;;;;;;;GAUrB,IAAiB,CAAM;;;;;;;;;;;;;;;;AAiB7B,SAAS,EAAoB,GAAuC;CAClE,IAAM,IAAW,EAAI,YAAY,YAAY;CAC7C,IAAI,CAAC,GAKH,OAJA,EAAI,sBAAsB;EACxB,MAAM;EACN,aAAa;CACf,CAAC,GACM;CAET,IAAI,EAAS,QAAQ,MAAM,EAAW,oBAAoB,OAAO;CACjE,IAAM,IACJ,EACA,eAAe;CACjB,IAAI,CAAC,KAAQ,EAAK,QAAQ,MAAM,EA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AC,GAEpB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,6BAA6B;CACzC,IAAM,IAAS,EAAyB,EAAQ,IAAI;CAGpD,AAFA,EAAW,EAAoB,EAAO,UAAU,EAAO,OAAO,CAAC,GAE/D,EAAO,KAAK,qCAAqC;CACjD,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,gBACF;CAKA,AAJA,EACE,EAAoB,GAAgB,EAAuB,CAAc,CAAC,CAC5E,GAEA,EAAO,KAAK,8BAA8B;CAC1C,IAAM,IAAyB;EAC7B,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;CACvE,GACM,IACJ,EAAuB,MAAM,MAAM,EAAG,WAAW,CAAC,CAAC,KACnD,EAAuB;CAQzB,OAPA,EACE,EACE,GACA,EAAuB,CAAgB,CACzC,CACF,GAEO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-BltGUllM.js","names":[],"sources":["../../src/patterns/enable/blog/modifies/svelte.config.ts","../../src/patterns/enable/blog/modifies/root-layout-svelte.ts","../../src/patterns/enable/blog/modifies/public-root-layout-svelte.ts","../../src/patterns/enable/blog/generate.runtime.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport {\n SyntaxKind,\n type ArrayLiteralExpression,\n type ObjectLiteralExpression,\n} from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\nimport { ensureImports } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n Enable mdsvex in your config (sveltekit() arg in vite.config, or svelte.config):\n\n import { mdsvex } from 'mdsvex';\n\n // ...\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Enable mdsvex by passing config to the sveltekit() plugin in vite.config.ts:\n\n import { sveltekit } from '@sveltejs/kit/vite';\n import { mdsvex } from 'mdsvex';\n import { defineConfig } from 'vite';\n\n export default defineConfig({\n plugins: [\n sveltekit({\n extensions: ['.svelte', '.svx'],\n preprocess: [mdsvex()],\n }),\n ],\n });\n`;\n\nfunction ensureExtensionsSvx(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"extensions\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"extensions\",\n initializer: \"['.svelte', '.svx']\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"['.svelte', '.svx']\",\n );\n return true;\n }\n const arr = init as ArrayLiteralExpression;\n const hasSvx = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \".svx\");\n if (hasSvx) return false;\n arr.addElement(\"'.svx'\");\n return true;\n}\n\nfunction ensurePreprocessMdsvex(obj: ObjectLiteralExpression): boolean {\n const existing = obj.getProperty(\"preprocess\");\n if (!existing) {\n obj.addPropertyAssignment({\n name: \"preprocess\",\n initializer: \"[mdsvex()]\",\n });\n return true;\n }\n if (existing.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existing as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init) {\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[mdsvex()]\",\n );\n return true;\n }\n if (init.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = init as ArrayLiteralExpression;\n const hasMdsvex = arr\n .getElements()\n .some((el) => /\\bmdsvex\\s*\\(/.test(el.getText()));\n if (hasMdsvex) return false;\n arr.addElement(\"mdsvex()\");\n return true;\n }\n const text = init.getText();\n if (/\\bmdsvex\\s*\\(/.test(text)) return false;\n (existing as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `[${text}, mdsvex()]`,\n );\n return true;\n}\n\n/**\n * Enable mdsvex: ensure `extensions` includes `.svx`, `preprocess` includes\n * `mdsvex()`, and the `mdsvex` import is present. All root-level, so they apply\n * identically to svelte.config and the inline sveltekit() arg; the import lands\n * in whichever file was resolved.\n */\nexport function modifySvelteConfigMdsvex(root: string): ConfigModifyResult {\n return modifyConfig(\n root,\n { notFound: NOT_FOUND_HINT, failed: FAILURE_HINT },\n (target) => {\n ensureExtensionsSvx(target.configObject);\n ensurePreprocessMdsvex(target.configObject);\n ensureImports(target.sourceFile, [\n { namedImports: [\"mdsvex\"], moduleSpecifier: \"mdsvex\" },\n ]);\n return true;\n },\n );\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst PRISM_IMPORT = `import '../css/prism-vsc-dark-plus.css';`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/routes/+layout.svelte and import the Prism theme for\n code block highlighting in blog posts:\n\n <script lang=\"ts\">\n import '../app.css';\n ${PRISM_IMPORT}\n </script>\n`;\n\nconst FAILURE_HINT = dedent`\n Import the Prism theme in your root +layout.svelte for blog code\n block highlighting:\n\n ${PRISM_IMPORT}\n`;\n\nexport function modifyRootLayoutSvelte(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 const script = file.getScript();\n if (!script) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (script.content.includes(\"prism-vsc-dark-plus.css\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const appCssMatch = source.match(\n /^(\\s*)import\\s+['\"][^'\"]*app\\.css['\"];?\\s*$/m,\n );\n if (appCssMatch) {\n const indent = appCssMatch[1] ?? \"\";\n const insertion = `\\n${indent}${PRISM_IMPORT}`;\n const end = (appCssMatch.index ?? 0) + appCssMatch[0].length;\n return source.slice(0, end) + insertion + source.slice(end);\n }\n return source.replace(/^/, `\\n\\t${PRISM_IMPORT}\\n`);\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst BLOG_NAVBAR_ITEM = `\n\t\t<Navbar.Item>\n\t\t\t<Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n\t\t\t\tBlog\n\t\t\t</Button>\n\t\t</Navbar.Item>\n\t`;\n\nconst FAILURE_HINT = dedent`\n Add a Blog link inside <Navbar.List> in the public root layout:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a public root layout with a Blog link in its Navbar.List:\n\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-center md:w-auto\" href=\"/blog\" variant=\"ghost\">\n Blog\n </Button>\n </Navbar.Item>\n`;\n\nexport function modifyPublicRootLayout(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(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const raw = fs.readFileSync(layoutPath, \"utf8\");\n if (/href=[\"']\\/blog[\"']/.test(raw)) {\n return { status: \"success\", changed: false };\n }\n\n file.insertBeforeClosingTag(\"Navbar.List\", BLOG_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifySvelteConfigMdsvex } from \"./modifies/svelte.config\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout-svelte\";\nimport { modifyPublicRootLayout } from \"./modifies/public-root-layout-svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying config for mdsvex\");\n const mdsvex = modifySvelteConfigMdsvex(options.root);\n pushResult(modifyOutcomeToFile(mdsvex.filePath, mdsvex.outcome));\n\n logger.info(\"Modifying src/routes/+layout.svelte\");\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(rootLayoutPath, modifyRootLayoutSvelte(rootLayoutPath)),\n );\n\n logger.info(\"Modifying public root layout\");\n const publicLayoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n ];\n const publicLayoutPath =\n publicLayoutCandidates.find((p) => fs.existsSync(p)) ??\n publicLayoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(\n publicLayoutPath,\n modifyPublicRootLayout(publicLayoutPath),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAYA,IAAM,IAAe,CAAM;;;;;;;;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logger-CQONztPm.js";
|
|
3
|
-
import { n } from "./generate-
|
|
4
|
-
import { modifyOutcomeToFile as r } from "./modify-file-
|
|
5
|
-
import {
|
|
3
|
+
import { n } from "./generate-tOkjJFUf.js";
|
|
4
|
+
import { modifyOutcomeToFile as r } from "./modify-file-Cgu_WeFk.js";
|
|
5
|
+
import { c as i, l as a, r as o } from "./ts-morph-helpers-Bf5iuQW8.js";
|
|
6
6
|
import { a as s, t as c } from "./config-target-DOi8kI_f.js";
|
|
7
7
|
import l from "node:path";
|
|
8
8
|
import u from "node:fs";
|
|
@@ -335,13 +335,13 @@ function U(e) {
|
|
|
335
335
|
status: "not-found",
|
|
336
336
|
message: V
|
|
337
337
|
};
|
|
338
|
-
let t =
|
|
338
|
+
let t = a.fromPath(e);
|
|
339
339
|
return t.hasElement("AdminBar") ? {
|
|
340
340
|
status: "success",
|
|
341
341
|
changed: !1
|
|
342
342
|
} : t.getScript() ? (t.modifyScript((e) => {
|
|
343
343
|
let { source: t } = i(e, (e) => {
|
|
344
|
-
|
|
344
|
+
o(e, [{
|
|
345
345
|
namedImports: ["AdminBar"],
|
|
346
346
|
moduleSpecifier: "@velastack/cms"
|
|
347
347
|
}]);
|
|
@@ -399,4 +399,4 @@ async function q(e) {
|
|
|
399
399
|
//#endregion
|
|
400
400
|
export { q as generate, W as keepMissing };
|
|
401
401
|
|
|
402
|
-
//# sourceMappingURL=generate.runtime-
|
|
402
|
+
//# sourceMappingURL=generate.runtime-BsuyMwoj.js.map
|