@velastack/patterns 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{_layout-D0OmzCu1.js → _layout-DqH4lA_r.js} +8 -8
- package/dist/chunks/{_layout-D0OmzCu1.js.map → _layout-DqH4lA_r.js.map} +1 -1
- package/dist/chunks/{collections-DDYlpDNO.js → collections-CcL5bbBk.js} +2 -2
- package/dist/chunks/{collections-DDYlpDNO.js.map → collections-CcL5bbBk.js.map} +1 -1
- package/dist/chunks/compose-handle-D16KmBVd.js +322 -0
- package/dist/chunks/compose-handle-D16KmBVd.js.map +1 -0
- package/dist/chunks/{config-target-DOi8kI_f.js → config-target-Co-ij8p3.js} +9 -9
- package/dist/chunks/{config-target-DOi8kI_f.js.map → config-target-Co-ij8p3.js.map} +1 -1
- package/dist/chunks/format-result-Cb2hWsb8.js +64 -0
- package/dist/chunks/format-result-Cb2hWsb8.js.map +1 -0
- package/dist/chunks/{generate.runtime-AjCpCfv3.js → generate.runtime-1gbaOucO.js} +144 -137
- package/dist/chunks/generate.runtime-1gbaOucO.js.map +1 -0
- package/dist/chunks/{generate.runtime-BpYOznG5.js → generate.runtime-A8wfItN7.js} +21 -21
- package/dist/chunks/{generate.runtime-BpYOznG5.js.map → generate.runtime-A8wfItN7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BtX_9lLk.js → generate.runtime-BL7uKgW7.js} +33 -33
- package/dist/chunks/{generate.runtime-BtX_9lLk.js.map → generate.runtime-BL7uKgW7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BYJZB1ad.js → generate.runtime-BX53l-rL.js} +37 -57
- package/dist/chunks/generate.runtime-BX53l-rL.js.map +1 -0
- package/dist/chunks/{generate.runtime-DEl6b1Ti.js → generate.runtime-Bb64J0ab.js} +15 -15
- package/dist/chunks/{generate.runtime-DEl6b1Ti.js.map → generate.runtime-Bb64J0ab.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DRcq4d5D.js → generate.runtime-BbNMkG4j.js} +27 -27
- package/dist/chunks/{generate.runtime-DRcq4d5D.js.map → generate.runtime-BbNMkG4j.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BgezGu15.js → generate.runtime-BdPtilz4.js} +94 -93
- package/dist/chunks/generate.runtime-BdPtilz4.js.map +1 -0
- package/dist/chunks/{generate.runtime-DH9o-888.js → generate.runtime-BqxVaq5P.js} +24 -24
- package/dist/chunks/{generate.runtime-DH9o-888.js.map → generate.runtime-BqxVaq5P.js.map} +1 -1
- package/dist/chunks/{generate.runtime-fSDNxfGG.js → generate.runtime-CJVy-mMN.js} +11 -11
- package/dist/chunks/{generate.runtime-fSDNxfGG.js.map → generate.runtime-CJVy-mMN.js.map} +1 -1
- package/dist/chunks/generate.runtime-CN3v78hx.js +82 -0
- package/dist/chunks/generate.runtime-CN3v78hx.js.map +1 -0
- package/dist/chunks/generate.runtime-CSXj-ebM.js +122 -0
- package/dist/chunks/generate.runtime-CSXj-ebM.js.map +1 -0
- package/dist/chunks/{generate.runtime-B6kxV3Bi.js → generate.runtime-CVLtEsXb.js} +28 -28
- package/dist/chunks/{generate.runtime-B6kxV3Bi.js.map → generate.runtime-CVLtEsXb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B_Fk1Jjs.js → generate.runtime-CiTmbkAk.js} +31 -34
- package/dist/chunks/{generate.runtime-B_Fk1Jjs.js.map → generate.runtime-CiTmbkAk.js.map} +1 -1
- package/dist/chunks/{generate.runtime-OjW1XETW.js → generate.runtime-CwzHEcKv.js} +33 -33
- package/dist/chunks/{generate.runtime-OjW1XETW.js.map → generate.runtime-CwzHEcKv.js.map} +1 -1
- package/dist/chunks/{generate.runtime-SQhCLSah.js → generate.runtime-DAkg7Fy5.js} +13 -13
- package/dist/chunks/{generate.runtime-SQhCLSah.js.map → generate.runtime-DAkg7Fy5.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DK7iXmAZ.js → generate.runtime-DPIH5sSI.js} +17 -17
- package/dist/chunks/{generate.runtime-DK7iXmAZ.js.map → generate.runtime-DPIH5sSI.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CTiJEVF2.js → generate.runtime-Dj22Kx0W.js} +31 -31
- package/dist/chunks/{generate.runtime-CTiJEVF2.js.map → generate.runtime-Dj22Kx0W.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CycY6kPr.js → generate.runtime-DnWw9tL1.js} +41 -41
- package/dist/chunks/{generate.runtime-CycY6kPr.js.map → generate.runtime-DnWw9tL1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DHRCNPVx.js → generate.runtime-Dx8Mcs2i.js} +27 -27
- package/dist/chunks/{generate.runtime-DHRCNPVx.js.map → generate.runtime-Dx8Mcs2i.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cq1gqxzg.js → generate.runtime-Dywp4xth.js} +22 -22
- package/dist/chunks/{generate.runtime-Cq1gqxzg.js.map → generate.runtime-Dywp4xth.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dmwhwgji.js → generate.runtime-T9DZJH8m.js} +65 -38
- package/dist/chunks/generate.runtime-T9DZJH8m.js.map +1 -0
- package/dist/chunks/{generate.runtime-vTneb2SY.js → generate.runtime-Zh5n8XpR.js} +45 -45
- package/dist/chunks/{generate.runtime-vTneb2SY.js.map → generate.runtime-Zh5n8XpR.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CZQoVNt3.js → generate.runtime-d9HT4v-7.js} +33 -33
- package/dist/chunks/{generate.runtime-CZQoVNt3.js.map → generate.runtime-d9HT4v-7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dtf2BI_5.js → generate.runtime-j1gfY6Xq.js} +9 -9
- package/dist/chunks/{generate.runtime-Dtf2BI_5.js.map → generate.runtime-j1gfY6Xq.js.map} +1 -1
- package/dist/chunks/generate.runtime-l-Tiahb2.js +170 -0
- package/dist/chunks/generate.runtime-l-Tiahb2.js.map +1 -0
- package/dist/chunks/modify-file-BlWTOkCH.js +212 -0
- package/dist/chunks/modify-file-BlWTOkCH.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js → modify-svelte-config-remote-CDKs_Qi0.js} +2 -2
- package/dist/chunks/{modify-svelte-config-remote-D3eBzcZc.js.map → modify-svelte-config-remote-CDKs_Qi0.js.map} +1 -1
- package/dist/chunks/{pocketbase-BerjVikJ.js → pocketbase-ewxQLtse.js} +16 -16
- package/dist/chunks/{pocketbase-BerjVikJ.js.map → pocketbase-ewxQLtse.js.map} +1 -1
- package/dist/chunks/{shared-Cmbzu7Od.js → shared-Bm3eMFy-.js} +2 -2
- package/dist/chunks/{shared-Cmbzu7Od.js.map → shared-Bm3eMFy-.js.map} +1 -1
- package/dist/chunks/svelte-file-B3RfgVdt.js +123 -0
- package/dist/chunks/svelte-file-B3RfgVdt.js.map +1 -0
- package/dist/chunks/{test-setup-DjbhQYZC.js → test-setup-B2hd8I-s.js} +15 -15
- package/dist/chunks/{test-setup-DjbhQYZC.js.map → test-setup-B2hd8I-s.js.map} +1 -1
- package/dist/chunks/{ui-BdkuOXPw.js → ui-CD-psDWi.js} +12 -12
- package/dist/chunks/{ui-BdkuOXPw.js.map → ui-CD-psDWi.js.map} +1 -1
- package/dist/chunks/ui-jhXrsw4T.js +12 -0
- package/dist/chunks/ui-jhXrsw4T.js.map +1 -0
- package/dist/chunks/{write-result-BVWPlGvE.js → write-result-DBKv-Q7J.js} +51 -51
- package/dist/chunks/{write-result-BVWPlGvE.js.map → write-result-DBKv-Q7J.js.map} +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1012 -1013
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/format-result-BdAy5M8C.js +0 -50
- package/dist/chunks/format-result-BdAy5M8C.js.map +0 -1
- package/dist/chunks/generate.runtime-AjCpCfv3.js.map +0 -1
- package/dist/chunks/generate.runtime-BYJZB1ad.js.map +0 -1
- package/dist/chunks/generate.runtime-BcVAKzoY.js +0 -138
- package/dist/chunks/generate.runtime-BcVAKzoY.js.map +0 -1
- package/dist/chunks/generate.runtime-BgezGu15.js.map +0 -1
- package/dist/chunks/generate.runtime-D2WfvXm2.js +0 -106
- package/dist/chunks/generate.runtime-D2WfvXm2.js.map +0 -1
- package/dist/chunks/generate.runtime-DaPNrIyg.js +0 -28
- package/dist/chunks/generate.runtime-DaPNrIyg.js.map +0 -1
- package/dist/chunks/generate.runtime-Dmwhwgji.js.map +0 -1
- package/dist/chunks/modify-file-Cgu_WeFk.js +0 -22
- package/dist/chunks/modify-file-Cgu_WeFk.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-teS3yXg-.js +0 -229
- package/dist/chunks/ts-morph-helpers-teS3yXg-.js.map +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { a as e } from "./util-BLYliuUK.js";
|
|
2
2
|
import { t } from "./dedent-Gq6Krl4n.js";
|
|
3
3
|
import { n } from "./logger-CQONztPm.js";
|
|
4
|
-
import { n as r } from "./shared-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
4
|
+
import { n as r } from "./shared-Bm3eMFy-.js";
|
|
5
|
+
import { c as i, d as a, f as o, modifyOutcomeToFile as s, n as c, revertOutcomeToFile as l, s as u } from "./modify-file-BlWTOkCH.js";
|
|
6
|
+
import { t as d } from "./svelte-file-B3RfgVdt.js";
|
|
7
|
+
import { n as f } from "./compose-handle-D16KmBVd.js";
|
|
8
|
+
import { a as p, i as m, t as h } from "./config-target-Co-ij8p3.js";
|
|
9
|
+
import { t as g } from "./_layout-DqH4lA_r.js";
|
|
10
|
+
import _ from "node:fs";
|
|
11
|
+
import v from "node:path";
|
|
12
|
+
import { Project as y, QuoteKind as b, SyntaxKind as x } from "ts-morph";
|
|
12
13
|
//#region src/patterns/disable/i18n/modifies/gitignore.ts
|
|
13
|
-
function
|
|
14
|
-
if (!
|
|
14
|
+
function S(e) {
|
|
15
|
+
if (!_.existsSync(e)) return {
|
|
15
16
|
status: "success",
|
|
16
17
|
changed: !1
|
|
17
18
|
};
|
|
18
|
-
let t =
|
|
19
|
+
let t = _.readFileSync(e, "utf8");
|
|
19
20
|
if (!t.includes("src/locales/.wuchale")) return {
|
|
20
21
|
status: "success",
|
|
21
22
|
changed: !1
|
|
@@ -37,30 +38,30 @@ function b(e) {
|
|
|
37
38
|
return i = i.replace(/\n{3,}/g, "\n\n"), i === t ? {
|
|
38
39
|
status: "success",
|
|
39
40
|
changed: !1
|
|
40
|
-
} : (
|
|
41
|
+
} : (_.writeFileSync(e, i), {
|
|
41
42
|
status: "success",
|
|
42
43
|
changed: !0
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
//#endregion
|
|
46
47
|
//#region src/patterns/disable/i18n/modifies/vite-config.ts
|
|
47
|
-
function
|
|
48
|
-
if (!
|
|
48
|
+
function C(e) {
|
|
49
|
+
if (!_.existsSync(e)) return {
|
|
49
50
|
status: "success",
|
|
50
51
|
changed: !1
|
|
51
52
|
};
|
|
52
|
-
let t =
|
|
53
|
+
let t = _.readFileSync(e, "utf8");
|
|
53
54
|
if (!t.includes("wuchale")) return {
|
|
54
55
|
status: "success",
|
|
55
56
|
changed: !1
|
|
56
57
|
};
|
|
57
|
-
let n = new
|
|
58
|
+
let n = new y({
|
|
58
59
|
compilerOptions: { allowJs: !0 },
|
|
59
|
-
manipulationSettings: { quoteKind:
|
|
60
|
+
manipulationSettings: { quoteKind: b.Single }
|
|
60
61
|
}).addSourceFileAtPath(e);
|
|
61
62
|
for (;;) {
|
|
62
63
|
let e = !1;
|
|
63
|
-
for (let t of n.getDescendantsOfKind(
|
|
64
|
+
for (let t of n.getDescendantsOfKind(x.ArrayLiteralExpression)) {
|
|
64
65
|
let n = t.getElements().findIndex((e) => e.getText().replace(/\s/g, "") === "wuchale()");
|
|
65
66
|
if (n >= 0) {
|
|
66
67
|
t.removeElement(n), e = !0;
|
|
@@ -69,26 +70,26 @@ function x(e) {
|
|
|
69
70
|
}
|
|
70
71
|
if (!e) break;
|
|
71
72
|
}
|
|
72
|
-
return
|
|
73
|
+
return u(n, "wuchale/vite"), n.formatText(), n.saveSync(), {
|
|
73
74
|
status: "success",
|
|
74
75
|
changed: n.getFullText() !== t
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
//#endregion
|
|
78
79
|
//#region src/patterns/disable/i18n/modifies/svelte-config.ts
|
|
79
|
-
var
|
|
80
|
+
var w = {
|
|
80
81
|
notFound: "No SvelteKit config to revert.",
|
|
81
82
|
failed: "Remove the $locales alias from the kit config by hand."
|
|
82
83
|
};
|
|
83
|
-
function
|
|
84
|
-
let t =
|
|
84
|
+
function T(e) {
|
|
85
|
+
let t = m(e, w, (e) => {
|
|
85
86
|
let t = e.kitContainer();
|
|
86
87
|
if (!t) return !0;
|
|
87
88
|
let n = t.getProperty("alias");
|
|
88
|
-
if (!n || n.getKind() !==
|
|
89
|
+
if (!n || n.getKind() !== x.PropertyAssignment) return !0;
|
|
89
90
|
let r = n.getInitializer();
|
|
90
|
-
if (!r || r.getKind() !==
|
|
91
|
-
let i = r.asKindOrThrow(
|
|
91
|
+
if (!r || r.getKind() !== x.ObjectLiteralExpression) return !0;
|
|
92
|
+
let i = r.asKindOrThrow(x.ObjectLiteralExpression), a = i.getProperties().find((e) => e.getText().replace(/['"]/g, "").startsWith("$locales"));
|
|
92
93
|
return !a || (a.remove(), i.getProperties().length === 0 && n.remove(), !0);
|
|
93
94
|
});
|
|
94
95
|
return t.outcome.status === "not-found" ? {
|
|
@@ -101,66 +102,66 @@ function C(e) {
|
|
|
101
102
|
}
|
|
102
103
|
//#endregion
|
|
103
104
|
//#region src/patterns/disable/i18n/modifies/hooks.server.ts
|
|
104
|
-
var
|
|
105
|
+
var E = "handleWuchale", D = t`
|
|
106
|
+
Take handleWuchale out of the exported handle in src/hooks.server.ts, then
|
|
107
|
+
remove its declaration, the loadLocales(...) calls and the wuchale and
|
|
108
|
+
$locales imports.
|
|
109
|
+
`, O = [
|
|
105
110
|
"wuchale/load-utils/server",
|
|
106
111
|
"$locales/main.url",
|
|
107
112
|
"$locales/data",
|
|
108
113
|
"$locales/main.loader.server.svelte.js",
|
|
109
114
|
"$locales/js.loader.server.js"
|
|
110
115
|
];
|
|
111
|
-
function
|
|
112
|
-
if (!
|
|
116
|
+
function k(e) {
|
|
117
|
+
if (!_.existsSync(e)) return {
|
|
113
118
|
status: "success",
|
|
114
119
|
changed: !1
|
|
115
120
|
};
|
|
116
|
-
let t =
|
|
117
|
-
if (!t.includes(
|
|
121
|
+
let t = _.readFileSync(e, "utf8");
|
|
122
|
+
if (!t.includes(E) && !t.includes("loadLocales(")) return {
|
|
118
123
|
status: "success",
|
|
119
124
|
changed: !1
|
|
120
125
|
};
|
|
121
|
-
let n = new
|
|
126
|
+
let n = new y({
|
|
122
127
|
compilerOptions: { allowJs: !0 },
|
|
123
|
-
manipulationSettings: { quoteKind:
|
|
128
|
+
manipulationSettings: { quoteKind: b.Single }
|
|
124
129
|
}).addSourceFileAtPath(e);
|
|
125
130
|
for (;;) {
|
|
126
|
-
let e = n.getStatements().find((e) => e.getKind() ===
|
|
131
|
+
let e = n.getStatements().find((e) => e.getKind() === x.ExpressionStatement && /^loadLocales\s*\(/.test(e.getText()));
|
|
127
132
|
if (!e) break;
|
|
128
133
|
e.remove();
|
|
129
134
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
u(n, w);
|
|
139
|
-
for (let e of T) s(n, e);
|
|
140
|
-
return a(n, "@sveltejs/kit/hooks", "sequence"), n.formatText(), l(n), n.saveSync(), {
|
|
135
|
+
if (f(n, E).status === "unsupported") return {
|
|
136
|
+
status: "failed",
|
|
137
|
+
message: D
|
|
138
|
+
};
|
|
139
|
+
a(n, E);
|
|
140
|
+
for (let e of O) u(n, e);
|
|
141
|
+
return i(n, "@sveltejs/kit/hooks", "sequence"), i(n, "@sveltejs/kit", "Handle"), n.formatText(), c(n), n.saveSync(), {
|
|
141
142
|
status: "success",
|
|
142
143
|
changed: n.getFullText() !== t
|
|
143
144
|
};
|
|
144
145
|
}
|
|
145
146
|
//#endregion
|
|
146
147
|
//#region src/patterns/disable/i18n/modifies/app-html.ts
|
|
147
|
-
function
|
|
148
|
-
if (!
|
|
148
|
+
function A(e) {
|
|
149
|
+
if (!_.existsSync(e)) return {
|
|
149
150
|
status: "success",
|
|
150
151
|
changed: !1
|
|
151
152
|
};
|
|
152
|
-
let t =
|
|
153
|
+
let t = _.readFileSync(e, "utf8"), n = t.replace(/lang\s*=\s*(?:"%sveltekit\.lang%"|'%sveltekit\.lang%')/g, "lang=\"en\"");
|
|
153
154
|
return n === t ? {
|
|
154
155
|
status: "success",
|
|
155
156
|
changed: !1
|
|
156
|
-
} : (
|
|
157
|
+
} : (_.writeFileSync(e, n, "utf8"), {
|
|
157
158
|
status: "success",
|
|
158
159
|
changed: !0
|
|
159
160
|
});
|
|
160
161
|
}
|
|
161
162
|
//#endregion
|
|
162
163
|
//#region src/patterns/disable/i18n/modifies/+layout.ts
|
|
163
|
-
var
|
|
164
|
+
var j = t`
|
|
164
165
|
src/routes/+layout.ts still loads wuchale locales. Remove these from it:
|
|
165
166
|
|
|
166
167
|
import { browser } from '$app/environment';
|
|
@@ -171,78 +172,78 @@ var O = t`
|
|
|
171
172
|
|
|
172
173
|
and the loadLocale(...) call inside load().
|
|
173
174
|
`;
|
|
174
|
-
function
|
|
175
|
+
function M(e) {
|
|
175
176
|
return e.replace(/["']/g, "'").replace(/\s+/g, "");
|
|
176
177
|
}
|
|
177
|
-
function
|
|
178
|
-
if (!
|
|
179
|
-
let t =
|
|
180
|
-
return !t.includes("loadLocale") && !t.includes("$locales") ? { action: "none" } :
|
|
178
|
+
function N(e) {
|
|
179
|
+
if (!_.existsSync(e)) return { action: "none" };
|
|
180
|
+
let t = _.readFileSync(e, "utf8");
|
|
181
|
+
return !t.includes("loadLocale") && !t.includes("$locales") ? { action: "none" } : M(t) === M(g) ? { action: "delete" } : {
|
|
181
182
|
action: "failed",
|
|
182
|
-
message:
|
|
183
|
+
message: j
|
|
183
184
|
};
|
|
184
185
|
}
|
|
185
186
|
//#endregion
|
|
186
187
|
//#region src/patterns/disable/i18n/modifies/root-layout.svelte.ts
|
|
187
|
-
function
|
|
188
|
-
if (!
|
|
188
|
+
function P(e) {
|
|
189
|
+
if (!_.existsSync(e)) return {
|
|
189
190
|
status: "success",
|
|
190
191
|
changed: !1
|
|
191
192
|
};
|
|
192
|
-
let t =
|
|
193
|
+
let t = _.readFileSync(e, "utf8");
|
|
193
194
|
if (!t.includes("LanguageSelect")) return {
|
|
194
195
|
status: "success",
|
|
195
196
|
changed: !1
|
|
196
197
|
};
|
|
197
|
-
let n =
|
|
198
|
+
let n = d.fromPath(e);
|
|
198
199
|
n.modifyScript((e) => {
|
|
199
200
|
let { source: t } = o(e, (e) => {
|
|
200
|
-
|
|
201
|
+
u(e, "$lib/components/language-select.svelte"), c(e);
|
|
201
202
|
});
|
|
202
203
|
return t;
|
|
203
204
|
});
|
|
204
205
|
let r = n.toString();
|
|
205
|
-
return r = r.replace(/[ \t]*<Navbar\.Item>\s*<LanguageSelect\s*\/>\s*<\/Navbar\.Item>[ \t]*\r?\n?/g, ""), r = r.replace(/[ \t]*<LanguageSelect\s*\/>[ \t]*\r?\n?/g, ""),
|
|
206
|
+
return r = r.replace(/[ \t]*<Navbar\.Item>\s*<LanguageSelect\s*\/>\s*<\/Navbar\.Item>[ \t]*\r?\n?/g, ""), r = r.replace(/[ \t]*<LanguageSelect\s*\/>[ \t]*\r?\n?/g, ""), _.writeFileSync(e, r, "utf8"), {
|
|
206
207
|
status: "success",
|
|
207
208
|
changed: r !== t
|
|
208
209
|
};
|
|
209
210
|
}
|
|
210
211
|
//#endregion
|
|
211
212
|
//#region src/patterns/disable/i18n/generate.runtime.ts
|
|
212
|
-
async function
|
|
213
|
-
let
|
|
214
|
-
e &&
|
|
213
|
+
async function F(t) {
|
|
214
|
+
let i = n(t), a = [], o = [], c = (e) => {
|
|
215
|
+
e && a.push(e);
|
|
215
216
|
};
|
|
216
|
-
|
|
217
|
-
let
|
|
218
|
-
c(
|
|
219
|
-
let
|
|
220
|
-
c(
|
|
221
|
-
let f =
|
|
222
|
-
c(
|
|
223
|
-
let
|
|
224
|
-
c(
|
|
225
|
-
let
|
|
226
|
-
|
|
227
|
-
path:
|
|
228
|
-
language: e(
|
|
229
|
-
content:
|
|
217
|
+
i.info("Reverting vite.config");
|
|
218
|
+
let u = p(t.root, h) ?? v.join(t.root, h[0]);
|
|
219
|
+
c(s(u, C(u))), i.info("Reverting the $locales alias");
|
|
220
|
+
let d = T(t.root);
|
|
221
|
+
c(s(d.filePath, d.outcome)), i.info("Reverting hooks.server.ts");
|
|
222
|
+
let f = v.join(t.root, "src", "hooks.server.ts"), m = l(f, k(f));
|
|
223
|
+
c(m.modify), m.delete && o.push(m.delete), i.info("Reverting app.html");
|
|
224
|
+
let g = v.join(t.root, "src", "app.html");
|
|
225
|
+
c(s(g, A(g))), i.info("Reverting root +layout.ts");
|
|
226
|
+
let y = v.join(t.root, "src", "routes", "+layout.ts"), b = N(y);
|
|
227
|
+
b.action === "delete" ? o.push(r(y)) : b.action === "failed" && a.push({
|
|
228
|
+
path: y,
|
|
229
|
+
language: e(y),
|
|
230
|
+
content: _.readFileSync(y, "utf8"),
|
|
230
231
|
status: "failed",
|
|
231
|
-
message:
|
|
232
|
-
}),
|
|
233
|
-
let
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
232
|
+
message: b.message
|
|
233
|
+
}), i.info("Reverting root layout language select");
|
|
234
|
+
let x = [
|
|
235
|
+
v.join(t.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
236
|
+
v.join(t.root, "src", "routes", "root-layout.svelte"),
|
|
237
|
+
v.join(t.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
238
|
+
v.join(t.root, "src", "routes", "+layout.svelte")
|
|
238
239
|
];
|
|
239
|
-
for (let e of
|
|
240
|
-
|
|
241
|
-
let
|
|
242
|
-
return c(
|
|
240
|
+
for (let e of x) _.existsSync(e) && c(s(e, P(e)));
|
|
241
|
+
i.info("Reverting .gitignore");
|
|
242
|
+
let w = v.join(t.root, ".gitignore");
|
|
243
|
+
return c(s(w, S(w))), {
|
|
243
244
|
creates: [],
|
|
244
|
-
modifies:
|
|
245
|
-
deletes:
|
|
245
|
+
modifies: a,
|
|
246
|
+
deletes: o,
|
|
246
247
|
components: [],
|
|
247
248
|
packages: [],
|
|
248
249
|
collections: [],
|
|
@@ -251,6 +252,6 @@ async function M(t) {
|
|
|
251
252
|
};
|
|
252
253
|
}
|
|
253
254
|
//#endregion
|
|
254
|
-
export {
|
|
255
|
+
export { F as generate };
|
|
255
256
|
|
|
256
|
-
//# sourceMappingURL=generate.runtime-
|
|
257
|
+
//# sourceMappingURL=generate.runtime-BdPtilz4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BdPtilz4.js","names":[],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/modifies/vite-config.ts","../../src/patterns/disable/i18n/modifies/svelte-config.ts","../../src/patterns/disable/i18n/modifies/hooks.server.ts","../../src/patterns/disable/i18n/modifies/app-html.ts","../../src/patterns/disable/i18n/modifies/+layout.ts","../../src/patterns/disable/i18n/modifies/root-layout.svelte.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 fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeImportByModuleSpecifier } from \"../../../../runtime/ts-morph-helpers\";\n\n/** Remove `wuchale()` from the Vite plugins and its import. */\nexport function unmodifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(viteConfigPath, \"utf8\");\n if (!original.includes(\"wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n // One removal at a time: manipulating the tree invalidates sibling nodes.\n for (;;) {\n let removed = false;\n for (const arr of sourceFile.getDescendantsOfKind(\n SyntaxKind.ArrayLiteralExpression,\n )) {\n const index = arr\n .getElements()\n .findIndex((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n if (index >= 0) {\n arr.removeElement(index);\n removed = true;\n break;\n }\n }\n if (!removed) break;\n }\n\n removeImportByModuleSpecifier(sourceFile, \"wuchale/vite\");\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import { SyntaxKind, type PropertyAssignment } from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\n\nconst HINTS = {\n notFound: \"No SvelteKit config to revert.\",\n failed: \"Remove the $locales alias from the kit config by hand.\",\n};\n\n/** Remove the `$locales` alias; drop `alias` too once it is empty. */\nexport function unmodifySvelteConfig(root: string): ConfigModifyResult {\n const result = modifyConfig(root, HINTS, (target) => {\n const kit = target.kitContainer();\n if (!kit) return true;\n\n const aliasProp = kit.getProperty(\"alias\");\n if (!aliasProp || aliasProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return true;\n }\n const aliasObj = (aliasProp as PropertyAssignment).getInitializer();\n if (\n !aliasObj ||\n aliasObj.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return true;\n }\n const obj = aliasObj.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const locales = obj\n .getProperties()\n .find((p) => p.getText().replace(/['\"]/g, \"\").startsWith(\"$locales\"));\n if (!locales) return true;\n\n locales.remove();\n if (obj.getProperties().length === 0) {\n aliasProp.remove();\n }\n return true;\n });\n\n // Nothing to revert in a project without a config.\n if (result.outcome.status === \"not-found\") {\n return { ...result, outcome: { status: \"success\", changed: false } };\n }\n return result;\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removeNamedImportIfUnused,\n removeTopLevelStatementByIdentifier,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\nconst FAILURE_HINT = dedent`\n Take handleWuchale out of the exported handle in src/hooks.server.ts, then\n remove its declaration, the loadLocales(...) calls and the wuchale and\n $locales imports.\n`;\n\nconst I18N_MODULES = [\n \"wuchale/load-utils/server\",\n \"$locales/main.url\",\n \"$locales/data\",\n \"$locales/main.loader.server.svelte.js\",\n \"$locales/js.loader.server.js\",\n];\n\n/**\n * Undo `modifyHooksServerI18n`: drop the locale bootstrap, the wuchale handle\n * and its imports, and unwrap `sequence(handleWuchale, ...)`. A file that\n * enable-i18n created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerI18n(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (!original.includes(I18N_HANDLE) && !original.includes(\"loadLocales(\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // loadLocales(...) bootstrap calls, one at a time (removal invalidates siblings).\n for (;;) {\n const stmt = sourceFile\n .getStatements()\n .find(\n (s) =>\n s.getKind() === SyntaxKind.ExpressionStatement &&\n /^loadLocales\\s*\\(/.test(s.getText()),\n );\n if (!stmt) break;\n stmt.remove();\n }\n\n // `export const handle = handleWuchale` goes altogether; a sequence loses\n // the argument, or unwraps to the handle it composed with.\n const removed = removeHandle(sourceFile, I18N_HANDLE);\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, I18N_HANDLE);\n for (const moduleSpecifier of I18N_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit\", \"Handle\");\n\n sourceFile.formatText();\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Put a real language back. `%sveltekit.lang%` is not a SvelteKit\n * placeholder; only the wuchale hook replaced it, so without that hook it\n * would be served literally.\n */\nexport function unmodifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n const updated = original.replace(\n /lang\\s*=\\s*(?:\"%sveltekit\\.lang%\"|'%sveltekit\\.lang%')/g,\n 'lang=\"en\"',\n );\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(appHtmlPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { LOAD_SNIPPET } from \"../../../enable/i18n/modifies/+layout\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.ts still loads wuchale locales. Remove these from it:\n\n import { browser } from '$app/environment';\n import { loadLocale } from 'wuchale/load-utils';\n import { getLocale } from '$locales/main.url';\n import '$locales/main.loader.svelte';\n import '$locales/js.loader';\n\n and the loadLocale(...) call inside load().\n`;\n\nfunction normalize(source: string): string {\n return source.replace(/[\"']/g, \"'\").replace(/\\s+/g, \"\");\n}\n\nexport type RootLayoutRevert =\n | { action: \"none\" }\n | { action: \"delete\" }\n | { action: \"failed\"; message: string };\n\n/**\n * enable-i18n wrote the whole file when no `+layout.ts` existed, so the\n * revert is to delete it; a file that grew other code needs a hand.\n */\nexport function planRootLayoutRevert(layoutPath: string): RootLayoutRevert {\n if (!fs.existsSync(layoutPath)) {\n return { action: \"none\" };\n }\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (!existing.includes(\"loadLocale\") && !existing.includes(\"$locales\")) {\n return { action: \"none\" };\n }\n if (normalize(existing) === normalize(LOAD_SNIPPET)) {\n return { action: \"delete\" };\n }\n return { action: \"failed\", message: FAILURE_HINT };\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Take the language select (and the nav item enable-i18n wrapped it in) back out. */\nexport function unmodifyRootLayoutLanguageSelect(\n layoutPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n \"$lib/components/language-select.svelte\",\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<LanguageSelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<LanguageSelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { languageFromPath } from \"../../../core/util\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\nimport { unmodifyViteConfig } from \"./modifies/vite-config\";\nimport { unmodifySvelteConfig } from \"./modifies/svelte-config\";\nimport { unmodifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { unmodifyAppHtml } from \"./modifies/app-html\";\nimport { planRootLayoutRevert } from \"./modifies/+layout\";\nimport { unmodifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, unmodifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Reverting the $locales alias\");\n const alias = unmodifySvelteConfig(options.root);\n pushResult(modifyOutcomeToFile(alias.filePath, alias.outcome));\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // enable-i18n may have created it; emptied, it goes.\n const hooksRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerI18n(hooksServerPath),\n );\n pushResult(hooksRevert.modify);\n if (hooksRevert.delete) deletes.push(hooksRevert.delete);\n\n logger.info(\"Reverting app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, unmodifyAppHtml(appHtmlPath)));\n\n logger.info(\"Reverting root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n const layoutRevert = planRootLayoutRevert(layoutPath);\n if (layoutRevert.action === \"delete\") {\n deletes.push(toDeleteEntry(layoutPath));\n } else if (layoutRevert.action === \"failed\") {\n modifies.push({\n path: layoutPath,\n language: languageFromPath(layoutPath),\n content: fs.readFileSync(layoutPath, \"utf8\"),\n status: \"failed\",\n message: layoutRevert.message,\n });\n }\n\n logger.info(\"Reverting root layout language select\");\n const rootLayoutCandidates = [\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 for (const candidate of rootLayoutCandidates) {\n if (!fs.existsSync(candidate)) continue;\n pushResult(\n modifyOutcomeToFile(\n candidate,\n unmodifyRootLayoutLanguageSelect(candidate),\n ),\n );\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 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,EAAS,SAAS,sBAAsB,GAC3C,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAQ,EAAS,MAAM,IAAI,GAC3B,IAAgB,CAAC;CACvB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;EACrC,IAAM,IAAO,EAAM;EACnB,IAAI,MAAS,aAAa;GACxB,IAAI,IAAI,IAAI,GACR,IAAa;GACjB,OAAO,IAAI,EAAM,UAAU,EAAM,EAAE,CAAC,KAAK,MAAM,KAI7C,AAHI,EAAM,OAAO,2BACf,IAAa,KAEf;GAEF,IAAI,GAAY;IACd,IAAI;IACJ;GACF;EACF;EACI,MAAS,0BACb,EAAI,KAAK,CAAI;CACf;CAEA,IAAI,IAAU,EAAI,KAAK,IAAI;CAQ3B,OAPA,IAAU,EAAQ,QAAQ,WAAW,MAAM,GAEvC,MAAY,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,c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AM,IAAa,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,GAClE,IAAe,EAAqB,CAAU;CAapD,AAZI,EAAa,WAAW,WAC1B,EAAQ,KAAK,EAAc,CAAU,CAAC,IAC7B,EAAa,WAAW,YACjC,EAAS,KAAK;EACZ,MAAM;EACN,UAAU,EAAiB,CAAU;EACrC,SAAS,EAAG,aAAa,GAAY,MAAM;EAC3C,QAAQ;EACR,SAAS,EAAa;CACxB,CAAC,GAGH,EAAO,KAAK,uCAAuC;CACnD,IAAM,IAAuB;EAC3B,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,oBAAoB;EACzE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,oBAAoB;EAC7D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,gBAAgB;EACrE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAC3D;CACA,KAAK,IAAM,KAAa,GACjB,EAAG,WAAW,CAAS,KAC5B,EACE,EACE,GACA,EAAiC,CAAS,CAC5C,CACF;CAGF,EAAO,KAAK,sBAAsB;CAClC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,YAAY;CAK1D,OAJA,EACE,EAAoB,GAAe,EAAkB,CAAa,CAAC,CACrE,GAEO;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { t } from "./shared-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { t } from "./shared-Bm3eMFy-.js";
|
|
3
|
+
import { l as n, modifyOutcomeToFile as r } from "./modify-file-BlWTOkCH.js";
|
|
4
|
+
import { t as i } from "./svelte-file-B3RfgVdt.js";
|
|
5
5
|
import { n as a } from "./env-BPfk1VAw.js";
|
|
6
|
-
import o from "node:
|
|
7
|
-
import s from "node:
|
|
6
|
+
import o from "node:fs";
|
|
7
|
+
import s from "node:path";
|
|
8
8
|
import { Project as c, QuoteKind as l, SyntaxKind as u } from "ts-morph";
|
|
9
9
|
//#region src/patterns/disable/payments/modifies/modify-nav-user.ts
|
|
10
10
|
function d(e) {
|
|
11
|
-
if (!
|
|
11
|
+
if (!o.existsSync(e)) return {
|
|
12
12
|
status: "success",
|
|
13
13
|
changed: !1
|
|
14
14
|
};
|
|
15
|
-
let t =
|
|
15
|
+
let t = o.readFileSync(e, "utf8");
|
|
16
16
|
if (!t.includes("/billing")) return {
|
|
17
17
|
status: "success",
|
|
18
18
|
changed: !1
|
|
19
19
|
};
|
|
20
|
-
let
|
|
20
|
+
let r = new i(t), a = !1, s = (e) => {
|
|
21
21
|
a || e((e) => {
|
|
22
|
-
let t =
|
|
22
|
+
let t = n(e, "Billing", "@lucide/svelte/icons/credit-card");
|
|
23
23
|
return t.wasRemoved && (a = !0), t.source;
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
return
|
|
26
|
+
return s((e) => r.modifyModuleScript(e)), a || s((e) => r.modifyScript(e)), a ? (o.writeFileSync(e, r.toString(), "utf8"), {
|
|
27
27
|
status: "success",
|
|
28
28
|
changed: !0
|
|
29
29
|
}) : {
|
|
@@ -35,11 +35,11 @@ function d(e) {
|
|
|
35
35
|
//#region src/patterns/disable/payments/modifies/modify-user-signup.ts
|
|
36
36
|
var f = /* @__PURE__ */ new Set(["linkStripeCustomer.run", "linkStripeCustomer"]);
|
|
37
37
|
function p(e) {
|
|
38
|
-
if (!
|
|
38
|
+
if (!o.existsSync(e)) return {
|
|
39
39
|
status: "success",
|
|
40
40
|
changed: !1
|
|
41
41
|
};
|
|
42
|
-
let t =
|
|
42
|
+
let t = o.readFileSync(e, "utf8");
|
|
43
43
|
if (!t.includes("linkStripeCustomer")) return {
|
|
44
44
|
status: "success",
|
|
45
45
|
changed: !1
|
|
@@ -63,11 +63,11 @@ function p(e) {
|
|
|
63
63
|
}
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/patterns/disable/payments/generate.runtime.ts
|
|
66
|
-
async function m(
|
|
67
|
-
let i =
|
|
66
|
+
async function m(n) {
|
|
67
|
+
let i = n.features.auth, o = e(n), c = [], l = (e) => {
|
|
68
68
|
e && c.push(e);
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
o.info("Stripping Stripe credentials from .env");
|
|
71
71
|
let u = [
|
|
72
72
|
{
|
|
73
73
|
type: "comment",
|
|
@@ -85,13 +85,13 @@ async function m(r) {
|
|
|
85
85
|
type: "var",
|
|
86
86
|
key: "STRIPE_WEBHOOK_SECRET"
|
|
87
87
|
}
|
|
88
|
-
], f =
|
|
89
|
-
if (l(
|
|
90
|
-
|
|
91
|
-
let e =
|
|
92
|
-
l(
|
|
93
|
-
let t =
|
|
94
|
-
l(
|
|
88
|
+
], f = s.join(n.root, ".env");
|
|
89
|
+
if (l(r(f, a(f, u))), i) {
|
|
90
|
+
o.info("Reverting nav-user.svelte");
|
|
91
|
+
let e = s.join(n.root, "src", "lib", "components", "nav-user.svelte");
|
|
92
|
+
l(r(e, d(e))), o.info("Reverting signup +page.server.ts");
|
|
93
|
+
let t = s.join(n.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
|
|
94
|
+
l(r(t, p(t)));
|
|
95
95
|
}
|
|
96
96
|
return {
|
|
97
97
|
creates: [],
|
|
@@ -107,10 +107,10 @@ async function m(r) {
|
|
|
107
107
|
"stripe_payment_methods",
|
|
108
108
|
"stripe_prices",
|
|
109
109
|
"stripe_products"
|
|
110
|
-
] : ["stripe_prices", "stripe_products"],
|
|
110
|
+
] : ["stripe_prices", "stripe_products"], n)
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
//#endregion
|
|
114
114
|
export { m as generate };
|
|
115
115
|
|
|
116
|
-
//# sourceMappingURL=generate.runtime-
|
|
116
|
+
//# sourceMappingURL=generate.runtime-BqxVaq5P.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-BqxVaq5P.js","names":[],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const specifier of [\n \"$lib/workflows/link-stripe-customer\",\n \"$lib/stripe\",\n ]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === specifier);\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n if (stmt) stmt.remove();\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnvRemove, type EnvEdit } from \"../../../runtime/env\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Stripping Stripe credentials from .env\");\n const envEdits: EnvEdit[] = [\n { type: \"comment\", key: \"Stripe credentials\" },\n { type: \"var\", key: \"STRIPE_SECRET_KEY\" },\n { type: \"var\", key: \"PUBLIC_STRIPE_PUBLISHABLE_KEY\" },\n { type: \"var\", key: \"STRIPE_WEBHOOK_SECRET\" },\n ];\n const envPath = path.join(options.root, \".env\");\n pushResult(modifyOutcomeToFile(envPath, modifyEnvRemove(envPath, envEdits)));\n\n if (isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n const collectionNames = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n ];\n const collectionDrops = await planDropsForCollections(\n isAppMode ? collectionNames : [\"stripe_prices\", \"stripe_products\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;AAKA,SAAgB,EAAgB,GAAoC;CAClE,IAAI,CAAC,EAAG,WAAW,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAS,EAAG,aAAa,GAAa,MAAM;CAClD,IAAI,CAAC,EAAO,SAAS,UAAU,GAC7B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,IAAI,EAAW,CAAM,GAC9B,IAAa,IAEX,KAAa,MAAgD;EAC7D,KACJ,GAAK,MAAQ;GACX,IAAM,IAAS,EACb,GACA,WACA,kCACF;GAEA,OADI,EAAO,eAAY,IAAa,KAC7B,EAAO;EAChB,CAAC;CACH;CAUA,OARA,GAAW,MAAO,EAAK,mBAAmB,CAAE,CAAC,GACxC,KAAY,GAAW,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;;;AC9CA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAY,EAAQ,SAAS,MAC7B,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,wCAAwC;CACpD,IAAM,IAAsB;EAC1B;GAAE,MAAM;GAAW,KAAK;EAAqB;EAC7C;GAAE,MAAM;GAAO,KAAK;EAAoB;EACxC;GAAE,MAAM;GAAO,KAAK;EAAgC;EACpD;GAAE,MAAM;GAAO,KAAK;EAAwB;CAC9C,GACM,IAAU,EAAK,KAAK,EAAQ,MAAM,MAAM;CAG9C,IAFA,EAAW,EAAoB,GAAS,EAAgB,GAAS,CAAQ,CAAC,CAAC,GAEvE,GAAW;EACb,EAAO,KAAK,2BAA2B;EACvC,IAAM,IAAc,EAAK,KACvB,EAAQ,MACR,OACA,OACA,cACA,iBACF;EAGA,AAFA,EAAW,EAAoB,GAAa,EAAgB,CAAW,CAAC,CAAC,GAEzE,EAAO,KAAK,kCAAkC;EAC9C,IAAM,IAAiB,EAAK,KAC1B,EAAQ,MACR,OACA,UACA,YACA,UACA,UACA,iBACF;EACA,EACE,EAAoB,GAAgB,EAAmB,CAAc,CAAC,CACxE;CACF;CAcA,OAAO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B,EAC5B,IAAY;GAPZ;GACA;GACA;GACA;GACA;EAGY,IAAkB,CAAC,iBAAiB,iBAAiB,GACjE,CACF;CAWA;AACF"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { modifyOutcomeToFile as t } from "./modify-file-
|
|
3
|
-
import n from "node:
|
|
4
|
-
import r from "node:
|
|
2
|
+
import { modifyOutcomeToFile as t } from "./modify-file-BlWTOkCH.js";
|
|
3
|
+
import n from "node:fs";
|
|
4
|
+
import r from "node:path";
|
|
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 (!n.existsSync(e)) return {
|
|
9
9
|
status: "success",
|
|
10
10
|
changed: !1
|
|
11
11
|
};
|
|
12
|
-
let t =
|
|
12
|
+
let t = n.readFileSync(e, "utf8"), r = new i().addSourceFileAtPath(e), o = r.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), r.formatText(), r.saveSync(), {
|
|
29
29
|
status: "success",
|
|
30
|
-
changed:
|
|
30
|
+
changed: r.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(n) {
|
|
39
|
+
let i = e(n), a = [];
|
|
40
40
|
i.info("Reverting hooks.server.ts");
|
|
41
|
-
let s =
|
|
41
|
+
let s = r.join(n.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(r) {
|
|
|
53
53
|
//#endregion
|
|
54
54
|
export { s as generate };
|
|
55
55
|
|
|
56
|
-
//# sourceMappingURL=generate.runtime-
|
|
56
|
+
//# sourceMappingURL=generate.runtime-CJVy-mMN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-CJVy-mMN.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;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