@velastack/patterns 0.0.60 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{collections-DZOoJLVj.js → collections-DgZjDXef.js} +2 -2
- package/dist/chunks/{collections-DZOoJLVj.js.map → collections-DgZjDXef.js.map} +1 -1
- package/dist/chunks/{config-target-Co-ij8p3.js → config-target-DOi8kI_f.js} +9 -9
- package/dist/chunks/{config-target-Co-ij8p3.js.map → config-target-DOi8kI_f.js.map} +1 -1
- package/dist/chunks/{generate.runtime-6qpoLA04.js → generate.runtime--0bYEUP_.js} +19 -19
- package/dist/chunks/{generate.runtime-6qpoLA04.js.map → generate.runtime--0bYEUP_.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DBG6kEKb.js → generate.runtime-677mL0-8.js} +17 -17
- package/dist/chunks/{generate.runtime-DBG6kEKb.js.map → generate.runtime-677mL0-8.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CtzHFod-.js → generate.runtime-B4wtZqNB.js} +23 -23
- package/dist/chunks/{generate.runtime-CtzHFod-.js.map → generate.runtime-B4wtZqNB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DfqzMG8Z.js → generate.runtime-BgW9zLGZ.js} +2 -2
- package/dist/chunks/{generate.runtime-DfqzMG8Z.js.map → generate.runtime-BgW9zLGZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CYmjlSQp.js → generate.runtime-C52G7ZnV.js} +15 -15
- package/dist/chunks/{generate.runtime-CYmjlSQp.js.map → generate.runtime-C52G7ZnV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-a5PXS1Kd.js → generate.runtime-CDSkTWtx.js} +10 -10
- package/dist/chunks/{generate.runtime-a5PXS1Kd.js.map → generate.runtime-CDSkTWtx.js.map} +1 -1
- package/dist/chunks/{generate.runtime-AmiNbSR3.js → generate.runtime-CFKrhkAA.js} +12 -12
- package/dist/chunks/{generate.runtime-AmiNbSR3.js.map → generate.runtime-CFKrhkAA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BnnsaLsg.js → generate.runtime-CFwzS666.js} +12 -12
- package/dist/chunks/{generate.runtime-BnnsaLsg.js.map → generate.runtime-CFwzS666.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CRS9C9xX.js → generate.runtime-CG0gMypH.js} +14 -14
- package/dist/chunks/{generate.runtime-CRS9C9xX.js.map → generate.runtime-CG0gMypH.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BT_bwAtt.js → generate.runtime-CNwy0UB2.js} +36 -36
- package/dist/chunks/generate.runtime-CNwy0UB2.js.map +1 -0
- package/dist/chunks/{generate.runtime-D9t6eaQd.js → generate.runtime-Cc1SG-nN.js} +20 -20
- package/dist/chunks/{generate.runtime-D9t6eaQd.js.map → generate.runtime-Cc1SG-nN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Di0p-J8l.js → generate.runtime-CfclK4xT.js} +12 -12
- package/dist/chunks/{generate.runtime-Di0p-J8l.js.map → generate.runtime-CfclK4xT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CtS6qa_1.js → generate.runtime-Coi_Y6nm.js} +22 -22
- package/dist/chunks/generate.runtime-Coi_Y6nm.js.map +1 -0
- package/dist/chunks/{generate.runtime-EokncTLy.js → generate.runtime-Dad9oAKS.js} +27 -27
- package/dist/chunks/{generate.runtime-EokncTLy.js.map → generate.runtime-Dad9oAKS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CNxgU9v1.js → generate.runtime-Dbhctzy1.js} +17 -17
- package/dist/chunks/{generate.runtime-CNxgU9v1.js.map → generate.runtime-Dbhctzy1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-P8IVwJLB.js → generate.runtime-DpV_oOT7.js} +23 -23
- package/dist/chunks/{generate.runtime-P8IVwJLB.js.map → generate.runtime-DpV_oOT7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CINxHRnJ.js → generate.runtime-PtDQdWNY.js} +11 -11
- package/dist/chunks/{generate.runtime-CINxHRnJ.js.map → generate.runtime-PtDQdWNY.js.map} +1 -1
- package/dist/chunks/{generate.runtime-qZhYdFI1.js → generate.runtime-WaqVbEPP.js} +19 -19
- package/dist/chunks/{generate.runtime-qZhYdFI1.js.map → generate.runtime-WaqVbEPP.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DsLlDfIo.js → generate.runtime-lvraqNgB.js} +25 -25
- package/dist/chunks/{generate.runtime-DsLlDfIo.js.map → generate.runtime-lvraqNgB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CGtKTfYU.js → generate.runtime-qsPylve5.js} +2 -2
- package/dist/chunks/{generate.runtime-CGtKTfYU.js.map → generate.runtime-qsPylve5.js.map} +1 -1
- package/dist/chunks/{generate.runtime-6TJoTPg9.js → generate.runtime-yddwyo5X.js} +19 -19
- package/dist/chunks/{generate.runtime-6TJoTPg9.js.map → generate.runtime-yddwyo5X.js.map} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js → modify-svelte-config-remote-D3eBzcZc.js} +2 -2
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js.map → modify-svelte-config-remote-D3eBzcZc.js.map} +1 -1
- package/dist/chunks/{pocketbase-BbFvZ4HI.js → pocketbase-BPwW3TWr.js} +15 -15
- package/dist/chunks/{pocketbase-BbFvZ4HI.js.map → pocketbase-BPwW3TWr.js.map} +1 -1
- package/dist/chunks/{shared-C4-NNykV.js → shared-BGvy1V-z.js} +2 -2
- package/dist/chunks/{shared-C4-NNykV.js.map → shared-BGvy1V-z.js.map} +1 -1
- package/dist/chunks/{test-setup-CcD8wSRD.js → test-setup-BGhcb0Qm.js} +3 -3
- package/dist/chunks/{test-setup-CcD8wSRD.js.map → test-setup-BGhcb0Qm.js.map} +1 -1
- package/dist/chunks/{write-result-DtTqt0Cs.js → write-result-BhULcFGo.js} +45 -45
- package/dist/chunks/{write-result-DtTqt0Cs.js.map → write-result-BhULcFGo.js.map} +1 -1
- package/dist/index.d.ts +22 -0
- package/dist/index.js +78 -68
- package/dist/index.js.map +1 -1
- package/package.json +13 -3
- package/dist/chunks/env.runtime-BVage9Kk.js +0 -31
- package/dist/chunks/env.runtime-BVage9Kk.js.map +0 -1
- package/dist/chunks/generate.runtime-BT_bwAtt.js.map +0 -1
- package/dist/chunks/generate.runtime-CtS6qa_1.js.map +0 -1
|
@@ -3,8 +3,8 @@ 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-Cie287JZ.js";
|
|
4
4
|
import { modifyOutcomeToFile as u } from "./modify-file-PVKmDJHk.js";
|
|
5
5
|
import { a as d, n as f, o as p } from "./ts-morph-helpers-Bk82Z2n7.js";
|
|
6
|
-
import m from "node:
|
|
7
|
-
import h from "node:
|
|
6
|
+
import m from "node:path";
|
|
7
|
+
import h from "node:fs";
|
|
8
8
|
import { SyntaxKind as g } from "ts-morph";
|
|
9
9
|
//#region src/patterns/enable/subscriptions/modifies/modify-stripe-hooks.ts
|
|
10
10
|
var _ = e`
|
|
@@ -24,11 +24,11 @@ var _ = e`
|
|
|
24
24
|
_
|
|
25
25
|
].join("\n");
|
|
26
26
|
function b(e) {
|
|
27
|
-
if (!
|
|
27
|
+
if (!h.existsSync(e)) return {
|
|
28
28
|
status: "not-found",
|
|
29
29
|
message: y
|
|
30
30
|
};
|
|
31
|
-
let t =
|
|
31
|
+
let t = h.readFileSync(e, "utf8");
|
|
32
32
|
if (t.includes("stripe-subscriptions")) return {
|
|
33
33
|
status: "success",
|
|
34
34
|
changed: !1
|
|
@@ -38,7 +38,7 @@ function b(e) {
|
|
|
38
38
|
message: v
|
|
39
39
|
};
|
|
40
40
|
let n = `${t}${t.endsWith("\n") ? "" : "\n"}\n${_}\n`;
|
|
41
|
-
return
|
|
41
|
+
return h.writeFileSync(e, n, "utf8"), {
|
|
42
42
|
status: "success",
|
|
43
43
|
changed: !0
|
|
44
44
|
};
|
|
@@ -77,11 +77,11 @@ var x = e`
|
|
|
77
77
|
break;
|
|
78
78
|
`;
|
|
79
79
|
function w(e) {
|
|
80
|
-
if (!
|
|
80
|
+
if (!h.existsSync(e)) return {
|
|
81
81
|
status: "not-found",
|
|
82
82
|
message: S
|
|
83
83
|
};
|
|
84
|
-
let t =
|
|
84
|
+
let t = h.readFileSync(e, "utf8");
|
|
85
85
|
if (t.includes("handleSubscriptionCreated")) return {
|
|
86
86
|
status: "success",
|
|
87
87
|
changed: !1
|
|
@@ -111,7 +111,7 @@ function w(e) {
|
|
|
111
111
|
} else return;
|
|
112
112
|
e.formatText(), n = !0;
|
|
113
113
|
});
|
|
114
|
-
return n ? (
|
|
114
|
+
return n ? (h.writeFileSync(e, r, "utf8"), {
|
|
115
115
|
status: "success",
|
|
116
116
|
changed: !0
|
|
117
117
|
}) : {
|
|
@@ -122,11 +122,11 @@ function w(e) {
|
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/patterns/enable/subscriptions/modifies/modify-by-template.ts
|
|
124
124
|
function T(e, t, n, r) {
|
|
125
|
-
if (!
|
|
125
|
+
if (!h.existsSync(e)) return {
|
|
126
126
|
status: "not-found",
|
|
127
127
|
message: r
|
|
128
128
|
};
|
|
129
|
-
let i =
|
|
129
|
+
let i = h.readFileSync(e, "utf8");
|
|
130
130
|
if (i.includes(n)) return {
|
|
131
131
|
status: "success",
|
|
132
132
|
changed: !1
|
|
@@ -135,7 +135,7 @@ function T(e, t, n, r) {
|
|
|
135
135
|
return i === a ? {
|
|
136
136
|
status: "success",
|
|
137
137
|
changed: !1
|
|
138
|
-
} : (
|
|
138
|
+
} : (h.writeFileSync(e, a, "utf8"), {
|
|
139
139
|
status: "success",
|
|
140
140
|
changed: !0
|
|
141
141
|
});
|
|
@@ -154,7 +154,7 @@ var O = [
|
|
|
154
154
|
"<AppSidebar user={data.user} meta={data.meta} subscription={data.subscription} />"
|
|
155
155
|
].join("\n"), k = ["Create src/routes/(app)/+layout.svelte with an <AppSidebar /> that receives the subscription prop."].join("\n");
|
|
156
156
|
function A(e) {
|
|
157
|
-
if (!
|
|
157
|
+
if (!h.existsSync(e)) return {
|
|
158
158
|
status: "not-found",
|
|
159
159
|
message: k
|
|
160
160
|
};
|
|
@@ -214,11 +214,11 @@ function P(e) {
|
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
function F(e) {
|
|
217
|
-
if (!
|
|
217
|
+
if (!h.existsSync(e)) return {
|
|
218
218
|
status: "not-found",
|
|
219
219
|
message: N
|
|
220
220
|
};
|
|
221
|
-
let t =
|
|
221
|
+
let t = h.readFileSync(e, "utf8");
|
|
222
222
|
if (t.includes("subscription?: {") || t.includes("subscription={subscription}") || t.includes("{subscription}")) return {
|
|
223
223
|
status: "success",
|
|
224
224
|
changed: !1
|
|
@@ -277,21 +277,21 @@ async function W(e) {
|
|
|
277
277
|
e && r.push(e);
|
|
278
278
|
};
|
|
279
279
|
n.info("Modifying data/hooks/stripe.pb.js");
|
|
280
|
-
let a =
|
|
280
|
+
let a = m.join(e.root, "data", "hooks", "stripe.pb.js");
|
|
281
281
|
i(u(a, b(a))), n.info("Modifying webhooks/stripe/+server.ts");
|
|
282
|
-
let o =
|
|
282
|
+
let o = m.join(e.root, "src", "routes", "webhooks", "stripe", "+server.ts");
|
|
283
283
|
i(u(o, w(o))), n.info("Modifying (app)/+layout.server.ts");
|
|
284
|
-
let s =
|
|
284
|
+
let s = m.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
285
285
|
i(u(s, D(s, U("src/routes/(app)/+layout.server.ts")))), n.info("Modifying (app)/+layout.svelte");
|
|
286
|
-
let c =
|
|
286
|
+
let c = m.join(e.root, "src", "routes", "(app)", "+layout.svelte");
|
|
287
287
|
i(u(c, A(c))), n.info("Modifying app-sidebar.svelte");
|
|
288
|
-
let l =
|
|
288
|
+
let l = m.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
289
289
|
i(u(l, F(l))), n.info("Modifying nav-user.svelte");
|
|
290
|
-
let d =
|
|
290
|
+
let d = m.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
291
291
|
i(u(d, L(d, U("src/lib/components/nav-user.svelte")))), n.info("Modifying billing/+page.server.ts");
|
|
292
|
-
let f =
|
|
292
|
+
let f = m.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
|
|
293
293
|
i(u(f, z(f, U("src/routes/(app)/billing/+page.server.ts")))), n.info("Modifying billing/+page.svelte");
|
|
294
|
-
let p =
|
|
294
|
+
let p = m.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
|
|
295
295
|
return i(u(p, V(p, U("src/routes/(app)/billing/+page.svelte")))), {
|
|
296
296
|
creates: [],
|
|
297
297
|
modifies: r,
|
|
@@ -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-B4wtZqNB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-CtzHFod-.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;\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{"version":3,"file":"generate.runtime-B4wtZqNB.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,SA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AAK,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,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
2
|
import { modifyOutcomeToFile as t } from "./modify-file-PVKmDJHk.js";
|
|
3
|
-
import { a as n, r, t as i } from "./test-setup-
|
|
3
|
+
import { a as n, r, t as i } from "./test-setup-BGhcb0Qm.js";
|
|
4
4
|
import a from "node:path";
|
|
5
5
|
//#region src/patterns/enable/backend/generate.runtime.ts
|
|
6
6
|
async function o(o) {
|
|
@@ -25,4 +25,4 @@ async function o(o) {
|
|
|
25
25
|
//#endregion
|
|
26
26
|
export { o as generate };
|
|
27
27
|
|
|
28
|
-
//# sourceMappingURL=generate.runtime-
|
|
28
|
+
//# sourceMappingURL=generate.runtime-BgW9zLGZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-BgW9zLGZ.js","names":[],"sources":["../../src/patterns/enable/backend/generate.runtime.ts"],"sourcesContent":["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 { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { modifyTestSetup } from \"./modifies/test-setup\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Modifying adapter config\");\n const adapter = modifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(\n adapter.filePath,\n adapter.outcome,\n );\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n logger.info(\"Modifying .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n modifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Modifying test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n modifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;AAQA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC;CAE1B,EAAO,KAAK,0BAA0B;CACtC,IAAM,IAAU,EAAmB,EAAQ,IAAI,GACzC,IAAmB,EACvB,EAAQ,UACR,EAAQ,OACV;CAGA,AAFI,KAAkB,EAAS,KAAK,CAAgB,GAEpD,EAAO,KAAK,sBAAsB;CAClC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,YAAY,GACpD,IAAgB,EACpB,GACA,EAAgB,CAAa,CAC/B;CAGA,AAFI,KAAe,EAAS,KAAK,CAAa,GAE9C,EAAO,KAAK,yBAAyB;CACrC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,QAAQ,UAAU,GAC1D,IAAgB,EACpB,GACA,EAAgB,CAAa,CAC/B;CAGA,OAFI,KAAe,EAAS,KAAK,CAAa,GAEvC;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,25 +1,25 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
2
|
import { modifyOutcomeToFile as t } from "./modify-file-PVKmDJHk.js";
|
|
3
|
-
import n from "node:
|
|
4
|
-
import r from "node:
|
|
3
|
+
import n from "node:path";
|
|
4
|
+
import r from "node:fs";
|
|
5
5
|
//#region src/patterns/disable/i18n/modifies/gitignore.ts
|
|
6
6
|
function i(e) {
|
|
7
|
-
if (!
|
|
7
|
+
if (!r.existsSync(e)) return {
|
|
8
8
|
status: "success",
|
|
9
9
|
changed: !1
|
|
10
10
|
};
|
|
11
|
-
let t =
|
|
11
|
+
let t = r.readFileSync(e, "utf8");
|
|
12
12
|
if (!t.includes("src/locales/.wuchale")) return {
|
|
13
13
|
status: "success",
|
|
14
14
|
changed: !1
|
|
15
15
|
};
|
|
16
|
-
let
|
|
17
|
-
for (let e = 0; e <
|
|
18
|
-
let t =
|
|
16
|
+
let n = t.split("\n"), i = [];
|
|
17
|
+
for (let e = 0; e < n.length; e++) {
|
|
18
|
+
let t = n[e];
|
|
19
19
|
if (t === "# Wuchale") {
|
|
20
|
-
let t = e + 1,
|
|
21
|
-
for (; t <
|
|
22
|
-
if (
|
|
20
|
+
let t = e + 1, r = !1;
|
|
21
|
+
for (; t < n.length && n[t].trim() !== "";) n[t] === "src/locales/.wuchale" && (r = !0), t++;
|
|
22
|
+
if (r) {
|
|
23
23
|
e = t;
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
@@ -30,7 +30,7 @@ function i(e) {
|
|
|
30
30
|
return a = a.replace(/\n{3,}/g, "\n\n"), a === t ? {
|
|
31
31
|
status: "success",
|
|
32
32
|
changed: !1
|
|
33
|
-
} : (
|
|
33
|
+
} : (r.writeFileSync(e, a), {
|
|
34
34
|
status: "success",
|
|
35
35
|
changed: !0
|
|
36
36
|
});
|
|
@@ -42,12 +42,12 @@ var a = [
|
|
|
42
42
|
"The i18n integration touches these files in ways that are not safely reversible by tooling.",
|
|
43
43
|
"See the enable-i18n modifies for the blocks to remove."
|
|
44
44
|
].join(" ");
|
|
45
|
-
async function o(
|
|
46
|
-
let o = e(
|
|
45
|
+
async function o(r) {
|
|
46
|
+
let o = e(r), s = [], c = (e) => {
|
|
47
47
|
e && s.push(e);
|
|
48
48
|
};
|
|
49
49
|
o.info("Reverting .gitignore");
|
|
50
|
-
let l =
|
|
50
|
+
let l = n.join(r.root, ".gitignore");
|
|
51
51
|
return c(t(l, i(l))), o.info(a), {
|
|
52
52
|
creates: [],
|
|
53
53
|
modifies: s,
|
|
@@ -62,4 +62,4 @@ async function o(n) {
|
|
|
62
62
|
//#endregion
|
|
63
63
|
export { o as generate };
|
|
64
64
|
|
|
65
|
-
//# sourceMappingURL=generate.runtime-
|
|
65
|
+
//# sourceMappingURL=generate.runtime-C52G7ZnV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-C52G7ZnV.js","names":[],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (!original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const lines = original.split(\"\\n\");\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === \"# Wuchale\") {\n let j = i + 1;\n let hasWuchale = false;\n while (j < lines.length && lines[j].trim() !== \"\") {\n if (lines[j] === \"src/locales/.wuchale\") {\n hasWuchale = true;\n }\n j++;\n }\n if (hasWuchale) {\n i = j;\n continue;\n }\n }\n if (line === \"src/locales/.wuchale\") continue;\n out.push(line);\n }\n\n let updated = out.join(\"\\n\");\n updated = updated.replace(/\\n{3,}/g, \"\\n\\n\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\n\nconst MANUAL_REMEDIATION = [\n \"vite.config, svelte.config, hooks.server, app.html, and +layout.ts must be reverted manually.\",\n \"The i18n integration touches these files in ways that are not safely reversible by tooling.\",\n \"See the enable-i18n modifies for the blocks to remove.\",\n].join(\" \");\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, unmodifyGitignore(gitignorePath)),\n );\n\n logger.info(MANUAL_REMEDIATION);\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":";;;;;AAGA,SAAgB,EAAkB,GAAsC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAa,GAC9B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAe,MAAM;CACtD,IAAI,CAAC,E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.js";
|
|
2
2
|
import { modifyOutcomeToFile as t } from "./modify-file-PVKmDJHk.js";
|
|
3
|
-
import n from "node:
|
|
4
|
-
import r from "node:
|
|
3
|
+
import n from "node:path";
|
|
4
|
+
import r from "node:fs";
|
|
5
5
|
import { Project as i, SyntaxKind as a } from "ts-morph";
|
|
6
6
|
//#region src/patterns/disable/api/modifies/hooks.server.ts
|
|
7
7
|
function o(e) {
|
|
8
|
-
if (!
|
|
8
|
+
if (!r.existsSync(e)) return {
|
|
9
9
|
status: "success",
|
|
10
10
|
changed: !1
|
|
11
11
|
};
|
|
12
|
-
let t =
|
|
12
|
+
let t = r.readFileSync(e, "utf8"), n = new i().addSourceFileAtPath(e), o = n.getDescendantsOfKind(a.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
|
|
13
13
|
if (!o) return {
|
|
14
14
|
status: "success",
|
|
15
15
|
changed: !1
|
|
@@ -25,9 +25,9 @@ function o(e) {
|
|
|
25
25
|
changed: !1
|
|
26
26
|
};
|
|
27
27
|
let l = c.asKindOrThrow(a.ObjectLiteralExpression), u = l.getProperty("api");
|
|
28
|
-
return u ? (u.remove(), l.getProperties().length === 0 && o.removeArgument(0),
|
|
28
|
+
return u ? (u.remove(), l.getProperties().length === 0 && o.removeArgument(0), n.formatText(), n.saveSync(), {
|
|
29
29
|
status: "success",
|
|
30
|
-
changed:
|
|
30
|
+
changed: n.getFullText() !== t
|
|
31
31
|
}) : {
|
|
32
32
|
status: "success",
|
|
33
33
|
changed: !1
|
|
@@ -35,10 +35,10 @@ function o(e) {
|
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/patterns/disable/api/generate.runtime.ts
|
|
38
|
-
async function s(
|
|
39
|
-
let i = e(
|
|
38
|
+
async function s(r) {
|
|
39
|
+
let i = e(r), a = [];
|
|
40
40
|
i.info("Reverting hooks.server.ts");
|
|
41
|
-
let s =
|
|
41
|
+
let s = n.join(r.root, "src", "hooks.server.ts"), c = t(s, o(s));
|
|
42
42
|
return c && a.push(c), {
|
|
43
43
|
creates: [],
|
|
44
44
|
modifies: a,
|
|
@@ -53,4 +53,4 @@ async function s(n) {
|
|
|
53
53
|
//#endregion
|
|
54
54
|
export { s as generate };
|
|
55
55
|
|
|
56
|
-
//# sourceMappingURL=generate.runtime-
|
|
56
|
+
//# sourceMappingURL=generate.runtime-CDSkTWtx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-CDSkTWtx.js","names":[],"sources":["../../src/patterns/disable/api/modifies/hooks.server.ts","../../src/patterns/disable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"success\", changed: false };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n return { status: \"success\", changed: false };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n return { status: \"success\", changed: false };\n }\n\n apiProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;AAIA,SAAgB,EAAoB,GAAwC;CAC1E,IAAI,CAAC,EAAG,WAAW,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAiB,MAAM,GAExD,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAe,GAExD,IAAW,EACd,qBAAqB,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAAC,GACH,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,EAAS,aAAa;CACnC,IAAI,EAAK,WAAW,GAClB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAK;CACtB,IAAI,EAAS,QAAQ,MAAM,EAAW,yBACpC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAa,EAAS,cAAc,EAAW,uBAAuB,GACtE,IAAU,EAAW,YAAY,KAAK;CAc5C,OAbK,KAIL,EAAQ,OAAO,GAEX,EAAW,cAAc,CAAC,CAAC,WAAW,KACxC,EAAS,eAAe,CAAC,GAG3B,EAAW,WAAW,GACtB,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAAS,EAAW,YAAY,MAAM;CACxC,KAfS;EAAE,QAAQ;EAAW,SAAS;CAAM;AAgB/C;;;AC5CA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,iBAAiB,GAClE,IAAO,EACX,GACA,EAAoB,CAAe,CACrC;CAGA,OAFI,KAAM,EAAS,KAAK,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -3,9 +3,9 @@ import { t } from "./taggedTemplateLiteral-CPUMuLtk.js";
|
|
|
3
3
|
import { n } from "./logger-CQONztPm.js";
|
|
4
4
|
import { modifyOutcomeToFile as r } from "./modify-file-PVKmDJHk.js";
|
|
5
5
|
import { n as i, o as a } from "./ts-morph-helpers-Bk82Z2n7.js";
|
|
6
|
-
import { i as o } from "./config-target-
|
|
7
|
-
import s from "node:
|
|
8
|
-
import c from "node:
|
|
6
|
+
import { i as o } from "./config-target-DOi8kI_f.js";
|
|
7
|
+
import s from "node:path";
|
|
8
|
+
import c from "node:fs";
|
|
9
9
|
import { SyntaxKind as l } from "ts-morph";
|
|
10
10
|
//#region src/patterns/enable/blog/modifies/svelte.config.ts
|
|
11
11
|
var u = e`
|
|
@@ -78,7 +78,7 @@ var h, g = "import '../css/prism-vsc-dark-plus.css';", _ = e(h ||= t(["\n Creat
|
|
|
78
78
|
${g}
|
|
79
79
|
`;
|
|
80
80
|
function y(e) {
|
|
81
|
-
if (!
|
|
81
|
+
if (!c.existsSync(e)) return {
|
|
82
82
|
status: "not-found",
|
|
83
83
|
message: _
|
|
84
84
|
};
|
|
@@ -121,7 +121,7 @@ var b = "\n <Navbar.Item>\n <Button class=\"w-full justify-start md:justify-c
|
|
|
121
121
|
</Navbar.Item>
|
|
122
122
|
`;
|
|
123
123
|
function C(e) {
|
|
124
|
-
if (!
|
|
124
|
+
if (!c.existsSync(e)) return {
|
|
125
125
|
status: "not-found",
|
|
126
126
|
message: S
|
|
127
127
|
};
|
|
@@ -130,7 +130,7 @@ function C(e) {
|
|
|
130
130
|
status: "failed",
|
|
131
131
|
message: x
|
|
132
132
|
};
|
|
133
|
-
let n =
|
|
133
|
+
let n = c.readFileSync(e, "utf8");
|
|
134
134
|
return /href=["']\/blog["']/.test(n) ? {
|
|
135
135
|
status: "success",
|
|
136
136
|
changed: !1
|
|
@@ -148,13 +148,13 @@ async function w(e) {
|
|
|
148
148
|
t.info("Modifying config for mdsvex");
|
|
149
149
|
let o = m(e.root);
|
|
150
150
|
a(r(o.filePath, o.outcome)), t.info("Modifying src/routes/+layout.svelte");
|
|
151
|
-
let l =
|
|
151
|
+
let l = s.join(e.root, "src", "routes", "+layout.svelte");
|
|
152
152
|
a(r(l, y(l))), t.info("Modifying public root layout");
|
|
153
153
|
let u = [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
], d = u.find((e) =>
|
|
154
|
+
s.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
155
|
+
s.join(e.root, "src", "routes", "root-layout.svelte"),
|
|
156
|
+
s.join(e.root, "src", "routes", "(public)", "+layout.svelte")
|
|
157
|
+
], d = u.find((e) => c.existsSync(e)) ?? u[0];
|
|
158
158
|
return a(r(d, C(d))), {
|
|
159
159
|
creates: [],
|
|
160
160
|
modifies: i,
|
|
@@ -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-CFKrhkAA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-AmiNbSR3.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,EAAW,wBAIzC,OAHA,EAAoD,eAClD,qBACF,GACO;CAET,IAAM,IAAM;CAMZ,OAFA,CAHe,EACZ,YAAY,CAAC,CACb,MAAM,MAAO,EAAG,QAAQ,CAAC,CAAC,QAAQ,UAAU,EAAE,MAAM,MACnD,MACJ,EAAI,WAAW,QAAQ,GAChB;AACT;AAEA,SAAS,EAAuB,GAAuC;CACrE,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,GAIH,OAHA,EAAoD,eAClD,YACF,GACO;CAET,IAAI,EAAK,QAAQ,MAAM,EAAW,wBAAwB;E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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-CFKrhkAA.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,EAAW,wBAIzC,OAHA,EAAoD,eAClD,qBACF,GACO;CAET,IAAM,IAAM;CAMZ,OAFA,CAHe,EACZ,YAAY,CAAC,CACb,MAAM,MAAO,EAAG,QAAQ,CAAC,CAAC,QAAQ,UAAU,EAAE,MAAM,MACnD,MACJ,EAAI,WAAW,QAAQ,GAChB;AACT;AAEA,SA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