@velastack/patterns 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/chunks/{collections-B3lAtPlQ.js → collections-DDYlpDNO.js} +38 -22
- package/dist/chunks/collections-DDYlpDNO.js.map +1 -0
- package/dist/chunks/constants-DSFKQwtP.js +6 -0
- package/dist/chunks/{constants-PBCzh8eY.js.map → constants-DSFKQwtP.js.map} +1 -1
- package/dist/chunks/dispatch-B5PfQ2CA.js +6 -0
- package/dist/chunks/dispatch-B5PfQ2CA.js.map +1 -0
- package/dist/chunks/{generate.runtime-BKb9thdE.js → generate.runtime-AjCpCfv3.js} +2 -2
- package/dist/chunks/{generate.runtime-BKb9thdE.js.map → generate.runtime-AjCpCfv3.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DCvLLO7w.js → generate.runtime-B6kxV3Bi.js} +67 -124
- package/dist/chunks/generate.runtime-B6kxV3Bi.js.map +1 -0
- package/dist/chunks/{generate.runtime-CXXwLatT.js → generate.runtime-BYJZB1ad.js} +2 -2
- package/dist/chunks/{generate.runtime-CXXwLatT.js.map → generate.runtime-BYJZB1ad.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BsuyMwoj.js → generate.runtime-B_Fk1Jjs.js} +2 -2
- package/dist/chunks/{generate.runtime-BsuyMwoj.js.map → generate.runtime-B_Fk1Jjs.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BjULAL3h.js → generate.runtime-BcVAKzoY.js} +3 -3
- package/dist/chunks/{generate.runtime-BjULAL3h.js.map → generate.runtime-BcVAKzoY.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dc98DCsh.js → generate.runtime-BgezGu15.js} +3 -3
- package/dist/chunks/{generate.runtime-Dc98DCsh.js.map → generate.runtime-BgezGu15.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BdTCMGGB.js → generate.runtime-BpYOznG5.js} +3 -3
- package/dist/chunks/{generate.runtime-BdTCMGGB.js.map → generate.runtime-BpYOznG5.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DKJaYtVZ.js → generate.runtime-BtX_9lLk.js} +42 -66
- package/dist/chunks/generate.runtime-BtX_9lLk.js.map +1 -0
- package/dist/chunks/{generate.runtime-lqPPXQyS.js → generate.runtime-CTiJEVF2.js} +4 -4
- package/dist/chunks/{generate.runtime-lqPPXQyS.js.map → generate.runtime-CTiJEVF2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BlQ1vx8j.js → generate.runtime-CZQoVNt3.js} +97 -138
- package/dist/chunks/generate.runtime-CZQoVNt3.js.map +1 -0
- package/dist/chunks/{generate.runtime-B9gdCz4t.js → generate.runtime-Cq1gqxzg.js} +2 -2
- package/dist/chunks/{generate.runtime-B9gdCz4t.js.map → generate.runtime-Cq1gqxzg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-FMYR64DL.js → generate.runtime-CycY6kPr.js} +3 -3
- package/dist/chunks/{generate.runtime-FMYR64DL.js.map → generate.runtime-CycY6kPr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CGkVUKvz.js → generate.runtime-D2WfvXm2.js} +2 -2
- package/dist/chunks/{generate.runtime-CGkVUKvz.js.map → generate.runtime-D2WfvXm2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-4Iplvp8f.js → generate.runtime-DEl6b1Ti.js} +2 -2
- package/dist/chunks/{generate.runtime-4Iplvp8f.js.map → generate.runtime-DEl6b1Ti.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Wssys8A0.js → generate.runtime-DH9o-888.js} +18 -18
- package/dist/chunks/generate.runtime-DH9o-888.js.map +1 -0
- package/dist/chunks/{generate.runtime-kH6XaWQz.js → generate.runtime-DHRCNPVx.js} +3 -3
- package/dist/chunks/{generate.runtime-kH6XaWQz.js.map → generate.runtime-DHRCNPVx.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BltGUllM.js → generate.runtime-DK7iXmAZ.js} +3 -3
- package/dist/chunks/{generate.runtime-BltGUllM.js.map → generate.runtime-DK7iXmAZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-tAbxWeq-.js → generate.runtime-DRcq4d5D.js} +4 -4
- package/dist/chunks/{generate.runtime-tAbxWeq-.js.map → generate.runtime-DRcq4d5D.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C-Val7lP.js → generate.runtime-Dmwhwgji.js} +3 -3
- package/dist/chunks/{generate.runtime-C-Val7lP.js.map → generate.runtime-Dmwhwgji.js.map} +1 -1
- package/dist/chunks/generate.runtime-Dtf2BI_5.js +87 -0
- package/dist/chunks/generate.runtime-Dtf2BI_5.js.map +1 -0
- package/dist/chunks/{generate.runtime-DWeiewRj.js → generate.runtime-OjW1XETW.js} +3 -3
- package/dist/chunks/{generate.runtime-DWeiewRj.js.map → generate.runtime-OjW1XETW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-QmFJI7G1.js → generate.runtime-vTneb2SY.js} +4 -4
- package/dist/chunks/{generate.runtime-QmFJI7G1.js.map → generate.runtime-vTneb2SY.js.map} +1 -1
- package/dist/chunks/nav-user-BYI-h8Od.js +6 -0
- package/dist/chunks/nav-user-BYI-h8Od.js.map +1 -0
- package/dist/chunks/{pocketbase-059B1oot.js → pocketbase-BerjVikJ.js} +2 -2
- package/dist/chunks/{pocketbase-059B1oot.js.map → pocketbase-BerjVikJ.js.map} +1 -1
- package/dist/chunks/{shared--_BWnGsc.js → shared-Cmbzu7Od.js} +2 -2
- package/dist/chunks/{shared--_BWnGsc.js.map → shared-Cmbzu7Od.js.map} +1 -1
- package/dist/chunks/{taggedTemplateLiteral-CPUMuLtk.js → taggedTemplateLiteral-Dx0fjWiw.js} +1 -1
- package/dist/chunks/{ts-morph-helpers-Bf5iuQW8.js → ts-morph-helpers-teS3yXg-.js} +2 -2
- package/dist/chunks/{ts-morph-helpers-Bf5iuQW8.js.map → ts-morph-helpers-teS3yXg-.js.map} +1 -1
- package/dist/chunks/{ui-BsG60gQg.js → ui-BdkuOXPw.js} +2 -2
- package/dist/chunks/{ui-BsG60gQg.js.map → ui-BdkuOXPw.js.map} +1 -1
- package/dist/chunks/{write-result-BN7Ff0rF.js → write-result-BVWPlGvE.js} +9 -9
- package/dist/chunks/{write-result-BN7Ff0rF.js.map → write-result-BVWPlGvE.js.map} +1 -1
- package/dist/index.d.ts +218 -64
- package/dist/index.js +2186 -1702
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunks/_server-BSm1eAiY.js +0 -6
- package/dist/chunks/_server-BSm1eAiY.js.map +0 -1
- package/dist/chunks/collections-B3lAtPlQ.js.map +0 -1
- package/dist/chunks/constants-PBCzh8eY.js +0 -6
- package/dist/chunks/generate.runtime-BlQ1vx8j.js.map +0 -1
- package/dist/chunks/generate.runtime-DCvLLO7w.js.map +0 -1
- package/dist/chunks/generate.runtime-DKJaYtVZ.js.map +0 -1
- package/dist/chunks/generate.runtime-Wssys8A0.js.map +0 -1
- package/dist/chunks/nav-user-CndUO69x.js +0 -6
- package/dist/chunks/nav-user-CndUO69x.js.map +0 -1
|
@@ -1,41 +1,19 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { n, r, t as i } from "./nav-user-
|
|
4
|
-
import { t as a } from "./shared
|
|
3
|
+
import { n, r, t as i } from "./nav-user-BYI-h8Od.js";
|
|
4
|
+
import { t as a } from "./shared-Cmbzu7Od.js";
|
|
5
5
|
import { modifyOutcomeToFile as o } from "./modify-file-Cgu_WeFk.js";
|
|
6
|
-
import { c as s, i as c, l } from "./ts-morph-helpers-
|
|
6
|
+
import { c as s, i as c, l } from "./ts-morph-helpers-teS3yXg-.js";
|
|
7
7
|
import u from "node:path";
|
|
8
8
|
import d from "node:fs";
|
|
9
9
|
import { SyntaxKind as f } from "ts-morph";
|
|
10
|
-
//#region src/patterns/disable/subscriptions/modifies/modify-stripe-hooks.ts
|
|
11
|
-
var p = /\n*cronAdd\(\s*["']stripe-subscriptions["'][\s\S]*?\}\s*\)\s*;?\s*\n?/m;
|
|
12
|
-
function m(e) {
|
|
13
|
-
if (!d.existsSync(e)) return {
|
|
14
|
-
status: "success",
|
|
15
|
-
changed: !1
|
|
16
|
-
};
|
|
17
|
-
let t = d.readFileSync(e, "utf8");
|
|
18
|
-
if (!t.includes("stripe-subscriptions")) return {
|
|
19
|
-
status: "success",
|
|
20
|
-
changed: !1
|
|
21
|
-
};
|
|
22
|
-
let n = t.replace(p, "\n");
|
|
23
|
-
return n === t ? {
|
|
24
|
-
status: "success",
|
|
25
|
-
changed: !1
|
|
26
|
-
} : (d.writeFileSync(e, n, "utf8"), {
|
|
27
|
-
status: "success",
|
|
28
|
-
changed: !0
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
10
|
//#region src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts
|
|
33
|
-
var
|
|
11
|
+
var p = /* @__PURE__ */ new Set([
|
|
34
12
|
"customer.subscription.created",
|
|
35
13
|
"customer.subscription.updated",
|
|
36
14
|
"customer.subscription.deleted"
|
|
37
15
|
]);
|
|
38
|
-
function
|
|
16
|
+
function m(e) {
|
|
39
17
|
if (!d.existsSync(e)) return {
|
|
40
18
|
status: "success",
|
|
41
19
|
changed: !1
|
|
@@ -46,28 +24,28 @@ function g(e) {
|
|
|
46
24
|
changed: !1
|
|
47
25
|
};
|
|
48
26
|
let { source: n } = s(t, (e) => {
|
|
49
|
-
c(e, "./
|
|
27
|
+
c(e, "./subscription/created"), c(e, "./subscription/updated"), c(e, "./subscription/deleted");
|
|
50
28
|
let t = e.getDescendantsOfKind(f.SwitchStatement).find((e) => e.getExpression().getText().includes("event.type"));
|
|
51
29
|
if (!t) return;
|
|
52
30
|
let n = t.getCaseBlock().getClauses().filter((e) => {
|
|
53
31
|
if (e.getKind() !== f.CaseClause) return !1;
|
|
54
32
|
let t = e.asKindOrThrow(f.CaseClause).getExpression(), n = t.asKind(f.StringLiteral) ?? t.asKind(f.NoSubstitutionTemplateLiteral);
|
|
55
|
-
return n ?
|
|
33
|
+
return n ? p.has(n.getLiteralValue()) : !1;
|
|
56
34
|
}).map((e) => e.asKindOrThrow(f.CaseClause));
|
|
57
35
|
for (let e of n.reverse()) e.remove();
|
|
58
36
|
e.formatText();
|
|
59
|
-
});
|
|
60
|
-
return
|
|
37
|
+
}), r = n.replace(/(break;)\n(\s*default:)/, "$1\n\n$2");
|
|
38
|
+
return r === t ? {
|
|
61
39
|
status: "success",
|
|
62
40
|
changed: !1
|
|
63
|
-
} : (d.writeFileSync(e,
|
|
41
|
+
} : (d.writeFileSync(e, r, "utf8"), {
|
|
64
42
|
status: "success",
|
|
65
43
|
changed: !0
|
|
66
44
|
});
|
|
67
45
|
}
|
|
68
46
|
//#endregion
|
|
69
47
|
//#region src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts
|
|
70
|
-
function
|
|
48
|
+
function h(e) {
|
|
71
49
|
if (!d.existsSync(e)) return {
|
|
72
50
|
status: "success",
|
|
73
51
|
changed: !1
|
|
@@ -83,7 +61,7 @@ function _(e) {
|
|
|
83
61
|
}
|
|
84
62
|
//#endregion
|
|
85
63
|
//#region src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts
|
|
86
|
-
function
|
|
64
|
+
function g(e) {
|
|
87
65
|
let { source: t } = s(e, (e) => {
|
|
88
66
|
for (let t of e.getVariableDeclarations()) {
|
|
89
67
|
let e = t.getInitializer();
|
|
@@ -109,7 +87,7 @@ function v(e) {
|
|
|
109
87
|
});
|
|
110
88
|
return t;
|
|
111
89
|
}
|
|
112
|
-
function
|
|
90
|
+
function _(e) {
|
|
113
91
|
if (!d.existsSync(e)) return {
|
|
114
92
|
status: "success",
|
|
115
93
|
changed: !1
|
|
@@ -118,14 +96,14 @@ function y(e) {
|
|
|
118
96
|
return !n && !r && !a ? {
|
|
119
97
|
status: "success",
|
|
120
98
|
changed: !1
|
|
121
|
-
} : ((n || r) && i.modifyScript(
|
|
99
|
+
} : ((n || r) && i.modifyScript(g), a && i.removeAttribute("NavUser", "subscription"), i.writeTo(e), {
|
|
122
100
|
status: "success",
|
|
123
101
|
changed: i.hasChanged()
|
|
124
102
|
});
|
|
125
103
|
}
|
|
126
104
|
//#endregion
|
|
127
105
|
//#region src/patterns/disable/subscriptions/modifies/revert-by-template.ts
|
|
128
|
-
function
|
|
106
|
+
function v(e, t, n) {
|
|
129
107
|
if (!d.existsSync(e)) return {
|
|
130
108
|
status: "success",
|
|
131
109
|
changed: !1
|
|
@@ -146,7 +124,7 @@ function b(e, t, n) {
|
|
|
146
124
|
}
|
|
147
125
|
//#endregion
|
|
148
126
|
//#region src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts
|
|
149
|
-
var
|
|
127
|
+
var y = e`
|
|
150
128
|
export const load = ({ locals }) => {
|
|
151
129
|
\tconst user = locals.pb.authStore.record!;
|
|
152
130
|
\tconst breadcrumbs = [{ title: 'Home', url: '/dashboard' }];
|
|
@@ -154,47 +132,45 @@ var x = e`
|
|
|
154
132
|
\treturn { user, breadcrumbs };
|
|
155
133
|
};
|
|
156
134
|
` + "\n";
|
|
157
|
-
function
|
|
158
|
-
return
|
|
135
|
+
function b(e) {
|
|
136
|
+
return v(e, y, "loadActiveSubscription");
|
|
159
137
|
}
|
|
160
138
|
//#endregion
|
|
161
139
|
//#region src/patterns/disable/subscriptions/modifies/modify-nav-user.ts
|
|
162
|
-
function
|
|
163
|
-
return
|
|
140
|
+
function x(e, t) {
|
|
141
|
+
return v(e, t, "planLabel");
|
|
164
142
|
}
|
|
165
143
|
//#endregion
|
|
166
144
|
//#region src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts
|
|
167
|
-
function
|
|
168
|
-
return
|
|
145
|
+
function S(e, t) {
|
|
146
|
+
return v(e, t, "selectPlan");
|
|
169
147
|
}
|
|
170
148
|
//#endregion
|
|
171
149
|
//#region src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts
|
|
172
|
-
function
|
|
173
|
-
return
|
|
150
|
+
function C(e, t) {
|
|
151
|
+
return v(e, t, "availablePlans");
|
|
174
152
|
}
|
|
175
153
|
//#endregion
|
|
176
154
|
//#region src/patterns/disable/subscriptions/generate.runtime.ts
|
|
177
|
-
async function
|
|
155
|
+
async function w(e) {
|
|
178
156
|
let s = t(e), c = [], l = (e) => {
|
|
179
157
|
e && c.push(e);
|
|
180
158
|
};
|
|
181
|
-
s.info("Reverting
|
|
182
|
-
let d = u.join(e.root, "
|
|
183
|
-
l(o(d, m(d))), s.info("Reverting
|
|
184
|
-
let f = u.join(e.root, "src", "routes", "
|
|
185
|
-
l(o(f,
|
|
186
|
-
let p = u.join(e.root, "src", "routes", "(app)", "+layout.
|
|
187
|
-
l(o(p,
|
|
188
|
-
let
|
|
189
|
-
l(o(
|
|
190
|
-
let v = u.join(e.root, "src", "lib", "components", "
|
|
191
|
-
l(o(v,
|
|
192
|
-
let
|
|
193
|
-
l(o(
|
|
194
|
-
let
|
|
195
|
-
l(o(
|
|
196
|
-
let E = u.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
|
|
197
|
-
return l(o(E, T(E, n))), {
|
|
159
|
+
s.info("Reverting webhooks/stripe/handlers/dispatch.ts");
|
|
160
|
+
let d = u.join(e.root, "src", "routes", "webhooks", "stripe", "handlers", "dispatch.ts");
|
|
161
|
+
l(o(d, m(d))), s.info("Reverting (app)/+layout.server.ts");
|
|
162
|
+
let f = u.join(e.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
163
|
+
l(o(f, b(f))), s.info("Reverting (app)/+layout.svelte");
|
|
164
|
+
let p = u.join(e.root, "src", "routes", "(app)", "+layout.svelte");
|
|
165
|
+
l(o(p, h(p))), s.info("Reverting app-sidebar.svelte");
|
|
166
|
+
let g = u.join(e.root, "src", "lib", "components", "app-sidebar.svelte");
|
|
167
|
+
l(o(g, _(g))), s.info("Reverting nav-user.svelte");
|
|
168
|
+
let v = u.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
169
|
+
l(o(v, x(v, i))), s.info("Reverting billing/+page.server.ts");
|
|
170
|
+
let y = u.join(e.root, "src", "routes", "(app)", "billing", "+page.server.ts");
|
|
171
|
+
l(o(y, S(y, r))), s.info("Reverting billing/+page.svelte");
|
|
172
|
+
let w = u.join(e.root, "src", "routes", "(app)", "billing", "+page.svelte");
|
|
173
|
+
return l(o(w, C(w, n))), {
|
|
198
174
|
creates: [],
|
|
199
175
|
modifies: c,
|
|
200
176
|
deletes: [],
|
|
@@ -206,6 +182,6 @@ async function E(e) {
|
|
|
206
182
|
};
|
|
207
183
|
}
|
|
208
184
|
//#endregion
|
|
209
|
-
export {
|
|
185
|
+
export { w as generate };
|
|
210
186
|
|
|
211
|
-
//# sourceMappingURL=generate.runtime-
|
|
187
|
+
//# sourceMappingURL=generate.runtime-BtX_9lLk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BtX_9lLk.js","names":[],"sources":["../../src/patterns/disable/subscriptions/modifies/modify-webhook-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-svelte.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-sidebar.ts","../../src/patterns/disable/subscriptions/modifies/revert-by-template.ts","../../src/patterns/disable/subscriptions/modifies/modify-app-layout-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-nav-user.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-server.ts","../../src/patterns/disable/subscriptions/modifies/modify-billing-page-svelte.ts","../../src/patterns/disable/subscriptions/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst SUBSCRIPTION_CASE_VALUES = new Set([\n \"customer.subscription.created\",\n \"customer.subscription.updated\",\n \"customer.subscription.deleted\",\n]);\n\nexport function unmodifyWebhookServer(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const original = fs.readFileSync(filePath, \"utf8\");\n if (!original.includes(\"handleSubscriptionCreated\")) {\n return { status: \"success\", changed: false };\n }\n\n const { source } = withInMemoryScript(original, (sf) => {\n removeImportByModuleSpecifier(sf, \"./subscription/created\");\n removeImportByModuleSpecifier(sf, \"./subscription/updated\");\n removeImportByModuleSpecifier(sf, \"./subscription/deleted\");\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 // Collect matching case clauses first — removing invalidates node refs.\n const toRemove = caseBlock\n .getClauses()\n .filter((clause) => {\n if (clause.getKind() !== SyntaxKind.CaseClause) return false;\n const caseClause = clause.asKindOrThrow(SyntaxKind.CaseClause);\n const expr = caseClause.getExpression();\n const literal =\n expr.asKind(SyntaxKind.StringLiteral) ??\n expr.asKind(SyntaxKind.NoSubstitutionTemplateLiteral);\n if (!literal) return false;\n return SUBSCRIPTION_CASE_VALUES.has(literal.getLiteralValue());\n })\n .map((c) => c.asKindOrThrow(SyntaxKind.CaseClause));\n\n for (const clause of toRemove.reverse()) {\n clause.remove();\n }\n\n sf.formatText();\n });\n\n // Removing the clauses takes the blank line before `default:` with them.\n const spaced = source.replace(/(break;)\\n(\\s*default:)/, \"$1\\n\\n$2\");\n\n if (spaced === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(filePath, spaced, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyAppLayoutSvelte(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(filePath);\n if (!file.hasElement(\"AppSidebar\")) {\n return { status: \"success\", changed: false };\n }\n if (!file.hasAttribute(\"AppSidebar\", \"subscription\")) {\n return { status: \"success\", changed: false };\n }\n\n const removed = file.removeAttribute(\"AppSidebar\", \"subscription\");\n if (!removed) {\n return { status: \"success\", changed: false };\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\nfunction updateScript(source: string): string {\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 const hasSub = elements.some((e) => e.getName() === \"subscription\");\n\n // Strip subscription from the props type literal (the specific type\n // added by enable-subscriptions — leave unrelated `subscription` props\n // alone).\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 .filter((t) => !/^\\s*subscription\\??\\s*:/.test(t));\n lit.replaceWithText(\n propTexts.length ? `{ ${propTexts.join(\"; \")}; }` : \"{}\",\n );\n break;\n }\n }\n\n if (hasSub) {\n const remaining = elements\n .filter((e) => e.getName() !== \"subscription\")\n .map((e) => e.getText());\n pattern.replaceWithText(`{ ${remaining.join(\", \")} }`);\n }\n }\n sf.formatText();\n });\n return out;\n}\n\nexport function unmodifyAppSidebar(filePath: string): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(filePath, \"utf8\");\n const hasSubPropType = /subscription\\??\\s*:\\s*\\{/.test(source);\n const hasSubProp = /\\bsubscription\\s*=\\s*null\\b/.test(source);\n\n const file = new SvelteFile(source);\n const hasNavUserSubAttr =\n file.hasElement(\"NavUser\") && file.hasAttribute(\"NavUser\", \"subscription\");\n\n if (!hasSubPropType && !hasSubProp && !hasNavUserSubAttr) {\n return { status: \"success\", changed: false };\n }\n\n if (hasSubPropType || hasSubProp) {\n file.modifyScript(updateScript);\n }\n if (hasNavUserSubAttr) {\n file.removeAttribute(\"NavUser\", \"subscription\");\n }\n\n file.writeTo(filePath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Rewrites a file to the given `template` if the current content still shows\n * the `enabledMarker` (meaning enable-subscriptions is applied). If the marker\n * is absent (already reverted or never applied), it's a no-op.\n *\n * Strips leading `// [!code highlight:N]` / `<!-- [!code highlight:N] -->`\n * lines so templates can be pulled from `preview-modifies/` directories which\n * use those for documentation highlighting.\n */\nexport function revertByTemplate(\n filePath: string,\n template: string,\n enabledMarker: string,\n): ModifyOutcome {\n if (!fs.existsSync(filePath)) {\n return { status: \"success\", changed: false };\n }\n const current = fs.readFileSync(filePath, \"utf8\");\n if (!current.includes(enabledMarker)) {\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 dedent from \"dedent\";\nimport { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Baseline velastack-auth (app)/+layout.server.ts — the state of the file\n// before enable-subscriptions wrapped it with loadActiveSubscription.\nconst BASELINE =\n dedent`\n export const load = ({ locals }) => {\n \\tconst user = locals.pb.authStore.record!;\n \\tconst breadcrumbs = [{ title: 'Home', url: '/dashboard' }];\n\n \\treturn { user, breadcrumbs };\n };\n` + \"\\n\";\n\nexport function unmodifyAppLayoutServer(filePath: string): ModifyOutcome {\n return revertByTemplate(filePath, BASELINE, \"loadActiveSubscription\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(\n filePath: string,\n paymentsNavUserTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(filePath, paymentsNavUserTemplate, \"planLabel\");\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageServer(\n filePath: string,\n paymentsBillingPageServerTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageServerTemplate,\n \"selectPlan\",\n );\n}\n","import { revertByTemplate } from \"./revert-by-template\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyBillingPageSvelte(\n filePath: string,\n paymentsBillingPageSvelteTemplate: string,\n): ModifyOutcome {\n return revertByTemplate(\n filePath,\n paymentsBillingPageSvelteTemplate,\n \"availablePlans\",\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 { planDropsForCollections } from \"../../destroy/shared\";\nimport { unmodifyWebhookServer } from \"./modifies/modify-webhook-server\";\nimport { unmodifyAppLayoutSvelte } from \"./modifies/modify-app-layout-svelte\";\nimport { unmodifyAppSidebar } from \"./modifies/modify-app-sidebar\";\nimport { unmodifyAppLayoutServer } from \"./modifies/modify-app-layout-server\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyBillingPageServer } from \"./modifies/modify-billing-page-server\";\nimport { unmodifyBillingPageSvelte } from \"./modifies/modify-billing-page-svelte\";\n\n// Pull the \"post-payments\" state of files that enable-subscriptions fully\n// overwrote. For the billing pages, that's exactly what enable-payments\n// writes in creates-app-mode; for nav-user it's the payments preview-modifies\n// snapshot (with highlight annotations stripped by the revert helper).\nimport paymentsNavUserTemplate from \"../../enable/payments/preview-modifies/src/lib/components/nav-user.svelte?raw\";\nimport paymentsBillingPageServerTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.server.ts?raw\";\nimport paymentsBillingPageSvelteTemplate from \"../../enable/payments/creates-app-mode/src/routes/(app)/billing/+page.svelte?raw\";\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 webhooks/stripe/handlers/dispatch.ts\");\n const webhookServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"webhooks\",\n \"stripe\",\n \"handlers\",\n \"dispatch.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n webhookServerPath,\n unmodifyWebhookServer(webhookServerPath),\n ),\n );\n\n logger.info(\"Reverting (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 unmodifyAppLayoutServer(appLayoutServerPath),\n ),\n );\n\n logger.info(\"Reverting (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 unmodifyAppLayoutSvelte(appLayoutSveltePath),\n ),\n );\n\n logger.info(\"Reverting 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, unmodifyAppSidebar(appSidebarPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n navUserPath,\n unmodifyNavUser(navUserPath, paymentsNavUserTemplate),\n ),\n );\n\n logger.info(\"Reverting 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 unmodifyBillingPageServer(\n billingPageServerPath,\n paymentsBillingPageServerTemplate,\n ),\n ),\n );\n\n logger.info(\"Reverting 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 unmodifyBillingPageSvelte(\n billingPageSveltePath,\n paymentsBillingPageSvelteTemplate,\n ),\n ),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"stripe_subscriptions\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAQA,IAAM,oBAA2B,IAAI,IAAI;CACvC;CACA;CACA;AACF,CAAC;AAED,SAAgB,EAAsB,GAAiC;CACrE,IAAI,CAAC,EAAG,WAAW,CAAQ,GACzB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAE7C,IAAM,IAAW,EAAG,aAAa,GAAU,MAAM;CACjD,IAAI,CAAC,EAAS,S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ACA,UACA,SACA,WACA,cACF;CAgBA,OAfA,EACE,EACE,GACA,EACE,GACA,CACF,CACF,CACF,GAOO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B,EAC5B,CAAC,sBAAsB,GACvB,CACF;CAWA;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { t } from "./shared
|
|
2
|
+
import { t } from "./shared-Cmbzu7Od.js";
|
|
3
3
|
import { modifyOutcomeToFile as n } from "./modify-file-Cgu_WeFk.js";
|
|
4
|
-
import { c as r, i, l as a } from "./ts-morph-helpers-
|
|
4
|
+
import { c as r, i, l as a } from "./ts-morph-helpers-teS3yXg-.js";
|
|
5
5
|
import o from "node:path";
|
|
6
6
|
import s from "node:fs";
|
|
7
7
|
import { Project as c, SyntaxKind as l } from "ts-morph";
|
|
@@ -19,7 +19,7 @@ function u(e) {
|
|
|
19
19
|
let n = new c().addSourceFileAtPath(e), r = n.getDescendantsOfKind(l.ObjectLiteralExpression);
|
|
20
20
|
for (let e of r) {
|
|
21
21
|
let t = e.getProperty("user");
|
|
22
|
-
|
|
22
|
+
t && t.getKind() === l.PropertyAssignment && t.getInitializer()?.getText() === "locals.pb.authStore.record" && t.remove();
|
|
23
23
|
}
|
|
24
24
|
return n.formatText(), n.saveSync(), {
|
|
25
25
|
status: "success",
|
|
@@ -104,4 +104,4 @@ async function p(r) {
|
|
|
104
104
|
//#endregion
|
|
105
105
|
export { p as generate };
|
|
106
106
|
|
|
107
|
-
//# sourceMappingURL=generate.runtime-
|
|
107
|
+
//# sourceMappingURL=generate.runtime-CTiJEVF2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-CTiJEVF2.js","names":[],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.removeElement(\"AuthMenu.Root\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/auth-menu\");\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/avatar\");\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.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 fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\n const layoutCandidates = [\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 path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,EAAqB,GAAmC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAY,MAAM;CACzD,IAAI,CAAC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAM,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAU,GAEnD,IAAW,EAAW,qBAC1B,EAAW,uBACb;CACA,KAAK,IAAM,KAAO,GAAU;EAC1B,IAAM,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