@velastack/patterns 0.14.3 → 0.15.1
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 +28 -0
- package/dist/chunks/_page-Cg7LjaOE.js +5 -0
- package/dist/chunks/{_page-44USwLXO.js.map → _page-Cg7LjaOE.js.map} +1 -1
- package/dist/chunks/auth-pages-DSBqKjO0.js +311 -0
- package/dist/chunks/auth-pages-DSBqKjO0.js.map +1 -0
- package/dist/chunks/{collections-B_-NTtLW.js → collections-D2_2cxWD.js} +70 -73
- package/dist/chunks/collections-D2_2cxWD.js.map +1 -0
- package/dist/chunks/{constants-CTp-0HKk.js → constants-DbpctM1D.js} +21 -21
- package/dist/chunks/constants-DbpctM1D.js.map +1 -0
- package/dist/chunks/{currency.server-DOX4Rzyb.js → currency.server-CFrwmYra.js} +4 -4
- package/dist/chunks/{currency.server-DOX4Rzyb.js.map → currency.server-CFrwmYra.js.map} +1 -1
- package/dist/chunks/{env-vars-BbS_mWyP.js → env-vars-Dm3Xy4rl.js} +4 -4
- package/dist/chunks/{env-vars-BbS_mWyP.js.map → env-vars-Dm3Xy4rl.js.map} +1 -1
- package/dist/chunks/{generate-CKuUg3p-.js → generate-BDGmczK8.js} +2 -2
- package/dist/chunks/{generate-CKuUg3p-.js.map → generate-BDGmczK8.js.map} +1 -1
- package/dist/chunks/{generate-Bwkx_usZ.js → generate-BMWoD9E2.js} +4 -4
- package/dist/chunks/{generate-Bwkx_usZ.js.map → generate-BMWoD9E2.js.map} +1 -1
- package/dist/chunks/{generate-4iujJNAW.js → generate-BRTIGlqT.js} +5 -5
- package/dist/chunks/{generate-4iujJNAW.js.map → generate-BRTIGlqT.js.map} +1 -1
- package/dist/chunks/{generate-DYq5Oj58.js → generate-BrO9MOgL.js} +2 -2
- package/dist/chunks/{generate-DYq5Oj58.js.map → generate-BrO9MOgL.js.map} +1 -1
- package/dist/chunks/{generate-BJY8AtAp.js → generate-BvQ6VwYH.js} +5 -5
- package/dist/chunks/{generate-BJY8AtAp.js.map → generate-BvQ6VwYH.js.map} +1 -1
- package/dist/chunks/{generate-B4uDCW5D.js → generate-Cs_fdfD7.js} +4 -4
- package/dist/chunks/{generate-B4uDCW5D.js.map → generate-Cs_fdfD7.js.map} +1 -1
- package/dist/chunks/{generate-JkvSNTy-.js → generate-DZ9kT3iC.js} +31 -188
- package/dist/chunks/generate-DZ9kT3iC.js.map +1 -0
- package/dist/chunks/{generate.runtime-D9OC1RXu.js → generate.runtime-1eTnPFmA.js} +3 -3
- package/dist/chunks/{generate.runtime-D9OC1RXu.js.map → generate.runtime-1eTnPFmA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-27KTIg_o.js → generate.runtime-B-H2F-sH.js} +48 -53
- package/dist/chunks/generate.runtime-B-H2F-sH.js.map +1 -0
- package/dist/chunks/{generate.runtime-DhSH1o8H.js → generate.runtime-B4mQEW54.js} +3 -3
- package/dist/chunks/{generate.runtime-DhSH1o8H.js.map → generate.runtime-B4mQEW54.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BFX_8erf.js → generate.runtime-B4rG6gSK.js} +10 -9
- package/dist/chunks/{generate.runtime-BFX_8erf.js.map → generate.runtime-B4rG6gSK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DuAYqKxl.js → generate.runtime-B9nVU5iO.js} +2 -2
- package/dist/chunks/{generate.runtime-DuAYqKxl.js.map → generate.runtime-B9nVU5iO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D6l6uLiY.js → generate.runtime-BC1GJUXE.js} +2 -2
- package/dist/chunks/{generate.runtime-D6l6uLiY.js.map → generate.runtime-BC1GJUXE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Duw_JI_b.js → generate.runtime-BJwSyslL.js} +2 -2
- package/dist/chunks/{generate.runtime-Duw_JI_b.js.map → generate.runtime-BJwSyslL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CBVcsole.js → generate.runtime-Bda2_WK7.js} +2 -2
- package/dist/chunks/{generate.runtime-CBVcsole.js.map → generate.runtime-Bda2_WK7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-sjFAWbZc.js → generate.runtime-BkQPchHe.js} +7 -7
- package/dist/chunks/{generate.runtime-sjFAWbZc.js.map → generate.runtime-BkQPchHe.js.map} +1 -1
- package/dist/chunks/{generate.runtime-bsuqrKOm.js → generate.runtime-BuQASx9Y.js} +2 -2
- package/dist/chunks/{generate.runtime-bsuqrKOm.js.map → generate.runtime-BuQASx9Y.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D77ueFKY.js → generate.runtime-BvHK8IN-.js} +118 -134
- package/dist/chunks/generate.runtime-BvHK8IN-.js.map +1 -0
- package/dist/chunks/{generate.runtime-BXNBWGYr.js → generate.runtime-C1HlZnLC.js} +2 -2
- package/dist/chunks/{generate.runtime-BXNBWGYr.js.map → generate.runtime-C1HlZnLC.js.map} +1 -1
- package/dist/chunks/{generate.runtime-wiWdXXPi.js → generate.runtime-C62ChKGg.js} +6 -6
- package/dist/chunks/{generate.runtime-wiWdXXPi.js.map → generate.runtime-C62ChKGg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B8-ORwxT.js → generate.runtime-CIOi-XSm.js} +6 -6
- package/dist/chunks/{generate.runtime-B8-ORwxT.js.map → generate.runtime-CIOi-XSm.js.map} +1 -1
- package/dist/chunks/{generate.runtime-nXjFqHyb.js → generate.runtime-CQ_U4YTJ.js} +4 -4
- package/dist/chunks/{generate.runtime-nXjFqHyb.js.map → generate.runtime-CQ_U4YTJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D0lI3Gt8.js → generate.runtime-CZA46Ghe.js} +5 -5
- package/dist/chunks/{generate.runtime-D0lI3Gt8.js.map → generate.runtime-CZA46Ghe.js.map} +1 -1
- package/dist/chunks/{generate.runtime-XT_JQlTk.js → generate.runtime-Cd742Yqf.js} +2 -2
- package/dist/chunks/{generate.runtime-XT_JQlTk.js.map → generate.runtime-Cd742Yqf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BlEy2fFF.js → generate.runtime-CfCDLJ6Y.js} +3 -3
- package/dist/chunks/{generate.runtime-BlEy2fFF.js.map → generate.runtime-CfCDLJ6Y.js.map} +1 -1
- package/dist/chunks/{generate.runtime-RTGpwxcS.js → generate.runtime-CjLath7N.js} +6 -12
- package/dist/chunks/generate.runtime-CjLath7N.js.map +1 -0
- package/dist/chunks/{generate.runtime-UtkANHk1.js → generate.runtime-CnNtG_x5.js} +3 -3
- package/dist/chunks/{generate.runtime-UtkANHk1.js.map → generate.runtime-CnNtG_x5.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CCaCaXNu.js → generate.runtime-D8G8cwCr.js} +2 -2
- package/dist/chunks/{generate.runtime-CCaCaXNu.js.map → generate.runtime-D8G8cwCr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cm75waRD.js → generate.runtime-DBQvnQmR.js} +2 -2
- package/dist/chunks/{generate.runtime-Cm75waRD.js.map → generate.runtime-DBQvnQmR.js.map} +1 -1
- package/dist/chunks/{generate.runtime-PDnSxiek.js → generate.runtime-DE-vPcn4.js} +6 -6
- package/dist/chunks/{generate.runtime-PDnSxiek.js.map → generate.runtime-DE-vPcn4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DLoYscQO.js → generate.runtime-DFSsgOmB.js} +3 -3
- package/dist/chunks/{generate.runtime-DLoYscQO.js.map → generate.runtime-DFSsgOmB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DiEiFoxR.js → generate.runtime-DNjyaFml.js} +3 -3
- package/dist/chunks/{generate.runtime-DiEiFoxR.js.map → generate.runtime-DNjyaFml.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CuvdtjKc.js → generate.runtime-DQI69jkX.js} +2 -2
- package/dist/chunks/{generate.runtime-CuvdtjKc.js.map → generate.runtime-DQI69jkX.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B7XOa9_A.js → generate.runtime-DQUZRJH8.js} +3 -3
- package/dist/chunks/{generate.runtime-B7XOa9_A.js.map → generate.runtime-DQUZRJH8.js.map} +1 -1
- package/dist/chunks/generate.runtime-DR8z6DyZ.js +169 -0
- package/dist/chunks/generate.runtime-DR8z6DyZ.js.map +1 -0
- package/dist/chunks/{generate.runtime-XpYi9SlM.js → generate.runtime-Diix70x4.js} +3 -3
- package/dist/chunks/{generate.runtime-XpYi9SlM.js.map → generate.runtime-Diix70x4.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BU-4sjyu.js → generate.runtime-Doumu0TL.js} +110 -113
- package/dist/chunks/generate.runtime-Doumu0TL.js.map +1 -0
- package/dist/chunks/{generate.runtime-TQmspB4Z.js → generate.runtime-Dtum580c.js} +27 -34
- package/dist/chunks/generate.runtime-Dtum580c.js.map +1 -0
- package/dist/chunks/{generate.runtime-BROXlbeJ.js → generate.runtime-GmsldrGj.js} +3 -3
- package/dist/chunks/{generate.runtime-BROXlbeJ.js.map → generate.runtime-GmsldrGj.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ZgLxGWuy.js → generate.runtime-lP4eoera.js} +3 -3
- package/dist/chunks/{generate.runtime-ZgLxGWuy.js.map → generate.runtime-lP4eoera.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dm7IEo2h.js → generate.runtime-liAz2TOE.js} +5 -5
- package/dist/chunks/{generate.runtime-Dm7IEo2h.js.map → generate.runtime-liAz2TOE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DxyQqNpu.js → generate.runtime-rxzMCECc.js} +5 -11
- package/dist/chunks/generate.runtime-rxzMCECc.js.map +1 -0
- package/dist/chunks/{generate.runtime-VMTLHWLk.js → generate.runtime-ufoTIUXA.js} +55 -60
- package/dist/chunks/generate.runtime-ufoTIUXA.js.map +1 -0
- package/dist/chunks/gitignore-2XpeEFmr.js +139 -0
- package/dist/chunks/gitignore-2XpeEFmr.js.map +1 -0
- package/dist/chunks/{i18n-mnzzcYhz.js → i18n-CxT1kz8Y.js} +3 -3
- package/dist/chunks/{i18n-mnzzcYhz.js.map → i18n-CxT1kz8Y.js.map} +1 -1
- package/dist/chunks/{modify-file-CgJIza72.js → modify-file-BX9-aZD1.js} +3 -3
- package/dist/chunks/{modify-file-CgJIza72.js.map → modify-file-BX9-aZD1.js.map} +1 -1
- package/dist/chunks/pocketbase-Dq9UdK_j.js +232 -0
- package/dist/chunks/pocketbase-Dq9UdK_j.js.map +1 -0
- package/dist/chunks/{providers-CDUFaOeQ.js → providers-2UgxXRJW.js} +3 -3
- package/dist/chunks/{providers-CDUFaOeQ.js.map → providers-2UgxXRJW.js.map} +1 -1
- package/dist/chunks/{providers-tjlFH5di.js → providers-DrK_hjSr.js} +2 -2
- package/dist/chunks/{providers-tjlFH5di.js.map → providers-DrK_hjSr.js.map} +1 -1
- package/dist/chunks/route-BDhlro0V.js +162 -0
- package/dist/chunks/route-BDhlro0V.js.map +1 -0
- package/dist/chunks/schema-2frI_BS2.js +116 -0
- package/dist/chunks/schema-2frI_BS2.js.map +1 -0
- package/dist/chunks/{shared-BjTRQ5QH.js → shared-BOFCKWJs.js} +3 -3
- package/dist/chunks/{shared-BjTRQ5QH.js.map → shared-BOFCKWJs.js.map} +1 -1
- package/dist/chunks/shared-DJ4KvhTb.js +1182 -0
- package/dist/chunks/shared-DJ4KvhTb.js.map +1 -0
- package/dist/chunks/{site-C8Wcg6LT.js → site-qASrdyUt.js} +3 -3
- package/dist/chunks/{site-C8Wcg6LT.js.map → site-qASrdyUt.js.map} +1 -1
- package/dist/chunks/{table-core-RvMjoXpT.js → table-core-s2xjYgRD.js} +3 -3
- package/dist/chunks/{table-core-RvMjoXpT.js.map → table-core-s2xjYgRD.js.map} +1 -1
- package/dist/chunks/test-setup-jqVMmL83.js +103 -0
- package/dist/chunks/test-setup-jqVMmL83.js.map +1 -0
- package/dist/chunks/{translations-CiJnl574.js → translations-B5hX0Qq-.js} +5 -2
- package/dist/chunks/{translations-CiJnl574.js.map → translations-B5hX0Qq-.js.map} +1 -1
- package/dist/chunks/{ui-CE-8llQS.js → ui-DZuwcswv.js} +3 -3
- package/dist/chunks/{ui-CE-8llQS.js.map → ui-DZuwcswv.js.map} +1 -1
- package/dist/chunks/{util-ILWdjRAd.js → util-mXrQ89nG.js} +8 -2
- package/dist/chunks/util-mXrQ89nG.js.map +1 -0
- package/dist/chunks/{whatsapp-DT10x76l.js → whatsapp-BytvTPlS.js} +2 -2
- package/dist/chunks/{whatsapp-DT10x76l.js.map → whatsapp-BytvTPlS.js.map} +1 -1
- package/dist/chunks/write-result-BhfLWAXf.js +539 -0
- package/dist/chunks/write-result-BhfLWAXf.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +2388 -3276
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunks/_page-44USwLXO.js +0 -5
- package/dist/chunks/auth-pages-BW3_yluN.js +0 -285
- package/dist/chunks/auth-pages-BW3_yluN.js.map +0 -1
- package/dist/chunks/collections-B_-NTtLW.js.map +0 -1
- package/dist/chunks/constants-CTp-0HKk.js.map +0 -1
- package/dist/chunks/generate-JkvSNTy-.js.map +0 -1
- package/dist/chunks/generate.runtime-27KTIg_o.js.map +0 -1
- package/dist/chunks/generate.runtime-BU-4sjyu.js.map +0 -1
- package/dist/chunks/generate.runtime-D77ueFKY.js.map +0 -1
- package/dist/chunks/generate.runtime-Dn0_y2iV.js +0 -161
- package/dist/chunks/generate.runtime-Dn0_y2iV.js.map +0 -1
- package/dist/chunks/generate.runtime-DxyQqNpu.js.map +0 -1
- package/dist/chunks/generate.runtime-RTGpwxcS.js.map +0 -1
- package/dist/chunks/generate.runtime-TQmspB4Z.js.map +0 -1
- package/dist/chunks/generate.runtime-VMTLHWLk.js.map +0 -1
- package/dist/chunks/pocketbase-S8lUt0nI.js +0 -219
- package/dist/chunks/pocketbase-S8lUt0nI.js.map +0 -1
- package/dist/chunks/test-setup-CpjhQSl-.js +0 -176
- package/dist/chunks/test-setup-CpjhQSl-.js.map +0 -1
- package/dist/chunks/util-ILWdjRAd.js.map +0 -1
- package/dist/chunks/write-result-BguSfKV-.js +0 -499
- package/dist/chunks/write-result-BguSfKV-.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { a as e, n as t, r as n, t as r } from "./currency.server-
|
|
1
|
+
import { a as e, n as t, r as n, t as r } from "./currency.server-CFrwmYra.js";
|
|
2
2
|
import { n as i } from "./logger-t1HxmpG2.js";
|
|
3
|
-
import { a, c as o, l as s } from "./providers-
|
|
4
|
-
import {
|
|
5
|
-
import { modifyEnvVarsFiles as
|
|
6
|
-
import { r as
|
|
7
|
-
import { t as
|
|
8
|
-
import { a as
|
|
9
|
-
import { a as
|
|
10
|
-
import { a as
|
|
11
|
-
import { t as
|
|
12
|
-
import { i as
|
|
13
|
-
import { i as A, r as j } from "./collections-
|
|
3
|
+
import { a, c as o, l as s } from "./providers-DrK_hjSr.js";
|
|
4
|
+
import { o as c, r as l } from "./util-mXrQ89nG.js";
|
|
5
|
+
import { modifyEnvVarsFiles as u } from "./env-vars-Dm3Xy4rl.js";
|
|
6
|
+
import { r as d } from "./modify-file-BX9-aZD1.js";
|
|
7
|
+
import { t as f } from "./env-AxyRWcC_.js";
|
|
8
|
+
import { a as p, i as m, r as h, s as g, t as _ } from "./site-qASrdyUt.js";
|
|
9
|
+
import { a as v, r as y, s as b, t as x } from "./root-layout.svelte-DE0c_y-T.js";
|
|
10
|
+
import { a as S, i as C, r as w } from "./collections-CFW9ZqUE.js";
|
|
11
|
+
import { t as T } from "./dedent-CCUOcPFW.js";
|
|
12
|
+
import { i as E, n as D, t as O } from "./pocketbase-Dq9UdK_j.js";
|
|
13
|
+
import { a as k, i as A, r as j } from "./collections-D2_2cxWD.js";
|
|
14
14
|
import { n as M } from "./modify-nav-user-D42kWyU6.js";
|
|
15
15
|
import { t as N } from "./modify-user-signup-ENhadGKH.js";
|
|
16
16
|
import { t as P } from "./taggedTemplateLiteral-CLenToGE.js";
|
|
@@ -25,7 +25,7 @@ async function V(e) {
|
|
|
25
25
|
return n && (t.info("Creating payment +page.svelte"), r.push({
|
|
26
26
|
path: "src/routes/(public)/payment/+page.svelte",
|
|
27
27
|
language: "svelte",
|
|
28
|
-
content:
|
|
28
|
+
content: S(n),
|
|
29
29
|
status: "success"
|
|
30
30
|
})), {
|
|
31
31
|
creates: r,
|
|
@@ -135,25 +135,20 @@ async function W(e, t) {
|
|
|
135
135
|
var G;
|
|
136
136
|
async function K(e, t, n, r, i = !0) {
|
|
137
137
|
if (!i) return;
|
|
138
|
-
await
|
|
139
|
-
let a =
|
|
140
|
-
a && e.push(
|
|
141
|
-
path: a,
|
|
142
|
-
language: c(a),
|
|
143
|
-
content: R.readFileSync(a, "utf8"),
|
|
144
|
-
status: "success"
|
|
145
|
-
});
|
|
138
|
+
await D();
|
|
139
|
+
let a = O(t, n, r);
|
|
140
|
+
a && e.push(await k(a, r));
|
|
146
141
|
}
|
|
147
142
|
function q(e) {
|
|
148
|
-
return
|
|
143
|
+
return T(G ||= P(["\n <script lang=\"ts\">\n import PaymentButton from '#lib/components/payments/payment-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"", "\" />\n </section>\n "]), e);
|
|
149
144
|
}
|
|
150
145
|
async function J(e) {
|
|
151
146
|
let t = s(e).STRIPE_SECRET_KEY ?? "", n = typeof e.input.demoId == "string" && e.input.demoId !== "" ? e.input.demoId : void 0, r = e.features.auth, a = i(e), o = [], c = [], l = (e) => {
|
|
152
147
|
e && c.push(e);
|
|
153
148
|
};
|
|
154
|
-
await
|
|
149
|
+
await E(e.root, async (n) => {
|
|
155
150
|
let i = (e) => j(n, e, a);
|
|
156
|
-
for (let t of [
|
|
151
|
+
for (let t of [C, w]) {
|
|
157
152
|
a.info(`Creating ${t.name} collection`);
|
|
158
153
|
let r = await i(t);
|
|
159
154
|
await K(o, t.name, "created", e, r.created), r.created || o.push(...await A(n, t, e, a));
|
|
@@ -363,8 +358,8 @@ async function J(e) {
|
|
|
363
358
|
a.info(`Synced ${d.total} users (created ${d.created}, reused ${d.reused}, skipped ${d.skipped})`);
|
|
364
359
|
}
|
|
365
360
|
}), n ? a.info(`Fetching Stripe product/price ${n}`) : a.info("Creating test Stripe product and price");
|
|
366
|
-
let { product: u, price:
|
|
367
|
-
if (p && a.info("Stripe product/price already exists, skipping creation"), a.info("Seeding Stripe product/price records"), await
|
|
361
|
+
let { product: u, price: f, existing: p } = n ? await W(t, n) : await U(t);
|
|
362
|
+
if (p && a.info("Stripe product/price already exists, skipping creation"), a.info("Seeding Stripe product/price records"), await E(e.root, async (e) => {
|
|
368
363
|
try {
|
|
369
364
|
await e.collection("stripe_products").getOne(u.id);
|
|
370
365
|
} catch {
|
|
@@ -376,30 +371,30 @@ async function J(e) {
|
|
|
376
371
|
});
|
|
377
372
|
}
|
|
378
373
|
try {
|
|
379
|
-
await e.collection("stripe_prices").getOne(
|
|
374
|
+
await e.collection("stripe_prices").getOne(f.id);
|
|
380
375
|
} catch {
|
|
381
376
|
await e.collection("stripe_prices").create({
|
|
382
|
-
id:
|
|
383
|
-
billing_scheme:
|
|
384
|
-
currency:
|
|
385
|
-
product:
|
|
386
|
-
recurring:
|
|
387
|
-
type:
|
|
388
|
-
unit_amount:
|
|
389
|
-
active:
|
|
377
|
+
id: f.id,
|
|
378
|
+
billing_scheme: f.billing_scheme,
|
|
379
|
+
currency: f.currency,
|
|
380
|
+
product: f.product,
|
|
381
|
+
recurring: f.recurring,
|
|
382
|
+
type: f.type,
|
|
383
|
+
unit_amount: f.unit_amount,
|
|
384
|
+
active: f.active
|
|
390
385
|
});
|
|
391
386
|
}
|
|
392
387
|
}), a.info("Creating payment +page.svelte"), o.push({
|
|
393
388
|
path: "src/routes/(public)/payment/+page.svelte",
|
|
394
389
|
language: "svelte",
|
|
395
|
-
content: q(
|
|
390
|
+
content: q(f.id),
|
|
396
391
|
status: "success"
|
|
397
392
|
}), r) {
|
|
398
393
|
a.info("Modifying nav-user.svelte");
|
|
399
394
|
let t = z.join(e.root, "src", "lib", "components", "nav-user.svelte");
|
|
400
|
-
l(
|
|
395
|
+
l(d(t, M(t))), a.info("Modifying signup +page.server.ts");
|
|
401
396
|
let n = z.join(e.root, "src", "routes", "(public)", "(auth)", "signup", "+page.server.ts");
|
|
402
|
-
l(
|
|
397
|
+
l(d(n, N(n)));
|
|
403
398
|
}
|
|
404
399
|
return {
|
|
405
400
|
creates: o,
|
|
@@ -421,7 +416,7 @@ async function Y(e, t) {
|
|
|
421
416
|
let n = [], r = z.join(e.root, "wuchale.config.js");
|
|
422
417
|
if (R.existsSync(r)) {
|
|
423
418
|
i(e).info("Adding src/lib/order.ts to wuchale's js adapter");
|
|
424
|
-
let t =
|
|
419
|
+
let t = d(r, I(r, L));
|
|
425
420
|
t && n.push(t);
|
|
426
421
|
}
|
|
427
422
|
return {
|
|
@@ -441,7 +436,7 @@ var X = /* #__PURE__ */ Object.assign({
|
|
|
441
436
|
"./creates-server/src/lib/currency.server.ts": r
|
|
442
437
|
});
|
|
443
438
|
function Z(e) {
|
|
444
|
-
return Object.values(
|
|
439
|
+
return Object.values(l(X, "./creates-server/")).filter((t) => e || !t.path.endsWith(".test.ts")).sort((e, t) => e.path.localeCompare(t.path));
|
|
445
440
|
}
|
|
446
441
|
function Q(e) {
|
|
447
442
|
try {
|
|
@@ -452,36 +447,36 @@ function Q(e) {
|
|
|
452
447
|
}
|
|
453
448
|
}
|
|
454
449
|
async function $(t) {
|
|
455
|
-
let r = i(t),
|
|
450
|
+
let r = i(t), l = o(n, t), S = [], C = [], w = (e) => {
|
|
456
451
|
e && C.push(e);
|
|
457
452
|
};
|
|
458
|
-
r.info(`Writing ${
|
|
453
|
+
r.info(`Writing ${l.label} credentials to .env`);
|
|
459
454
|
let T = z.join(t.root, ".env");
|
|
460
|
-
w(
|
|
461
|
-
let E =
|
|
462
|
-
E.create &&
|
|
463
|
-
let { currency: D, country: O, currencies: k } = t.input, A = R.existsSync(
|
|
464
|
-
currency:
|
|
465
|
-
country:
|
|
466
|
-
currencies:
|
|
455
|
+
w(d(T, f(T, e(l, s(t))))), r.info(`Declaring ${l.label} variables in src/env.ts`);
|
|
456
|
+
let E = u(t.root, a(l));
|
|
457
|
+
E.create && S.push(E.create), w(E.modify);
|
|
458
|
+
let { currency: D, country: O, currencies: k } = t.input, A = R.existsSync(g(t.root)), { file: j, business: M } = await _(t, {
|
|
459
|
+
currency: p(D) ?? void 0,
|
|
460
|
+
country: h(O) ?? void 0,
|
|
461
|
+
currencies: m(k, p(D) ?? void 0) ?? void 0
|
|
467
462
|
});
|
|
468
|
-
j && (A ? C :
|
|
463
|
+
j && (A ? C : S).push(j), r.info("Adding the currency select to the navbar");
|
|
469
464
|
let N = z.join(t.root, "src", "routes", "(public)", "root-layout.svelte");
|
|
470
|
-
w(
|
|
465
|
+
w(d(N, x(N)));
|
|
471
466
|
let P = z.join(t.root, "src", "routes", "+layout.server.ts");
|
|
472
467
|
if (R.existsSync(P)) {
|
|
473
468
|
r.info("Resolving the visitor's currency on the server");
|
|
474
|
-
let e =
|
|
475
|
-
if (w(
|
|
469
|
+
let e = v(P);
|
|
470
|
+
if (w(d(P, e)), e.status === "success") {
|
|
476
471
|
let e = z.join(t.root, "src", "hooks.server.ts");
|
|
477
|
-
w(
|
|
472
|
+
w(d(e, b(e)));
|
|
478
473
|
let n = z.join(t.root, "src", "routes", "+layout.svelte");
|
|
479
|
-
w(
|
|
480
|
-
for (let e of Z(Q(t.root)))
|
|
474
|
+
w(d(n, y(n)));
|
|
475
|
+
for (let e of Z(Q(t.root))) S.push(e);
|
|
481
476
|
}
|
|
482
477
|
}
|
|
483
478
|
let F = {
|
|
484
|
-
creates:
|
|
479
|
+
creates: S,
|
|
485
480
|
modifies: C,
|
|
486
481
|
deletes: [],
|
|
487
482
|
components: [],
|
|
@@ -489,9 +484,9 @@ async function $(t) {
|
|
|
489
484
|
collections: [],
|
|
490
485
|
collectionPatches: [],
|
|
491
486
|
collectionDrops: []
|
|
492
|
-
}, I =
|
|
493
|
-
return
|
|
487
|
+
}, I = l.id === "stripe" ? await J(t) : l.id === "shopify" ? await V(t) : await Y(t, M);
|
|
488
|
+
return c([F, I]);
|
|
494
489
|
}
|
|
495
490
|
export { $ as generate, Q as hasVitest };
|
|
496
491
|
|
|
497
|
-
//# sourceMappingURL=generate.runtime-
|
|
492
|
+
//# sourceMappingURL=generate.runtime-ufoTIUXA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-ufoTIUXA.js","names":["__import_glob__0_0_","__import_glob__0_1_","envEditsFor","currency_server_test_default","META","currency_server_default","getLogger","resolveProvider","suppliedProviderEnv","mergeResults","filesFromGlob","modifyOutcomeToFile","modifyEnv","normalizeCurrency","normalizeCurrencies","normalizeCountry","sitePath","ensureSiteBusiness","modifyLayoutServerCurrency","modifyLayoutSvelteCurrency","modifyHooksServerCurrency","modifyRootLayoutCurrencySelect","buyPageSnippet","STRIPE_PRODUCTS","STRIPE_PRICES","dedent","withPocketbase","migrationDelay","getMigrationFile","readMigration","ensureCollectionFields","createCollectionIdempotent","modifyNavUser","modifyUserSignup","_taggedTemplateLiteral","InvalidArgumentError","modifyWuchaleJsFiles","TRANSLATED_LIB_FILES","fs","path","Stripe","setupShopify","logger","options","variantId","creates","syncUsersToStripeCustomers","stripe","stripeSecretKey","users","pb","existing","linkedUserIds","c","result","user","matching","label","customer","isExistingCustomer","error","paymentMethods","paymentMethod","defaultPaymentMethod","createTestProductAndPrice","products","product","prices","getProductAndPriceById","price","priceId","_templateObject","pushMigrationCreates","created","migrationFile","collectionName","action","paymentPageSnippet","setupStripe","stripePriceId","isAppMode","modifies","pushResult","file","create","spec","customersResult","stripeCustomersCollection","paymentMethodsResult","stripePaymentMethodsCollection","transactionsResult","syncResult","navUserPath","userSignupPath","setupWhatsApp","business","given","wuchaleConfig","edit","createsServerRaw","serverCreates","unitTests","a","b","hasVitest","pkg","root","generate","provider","envPath","envVars","modifyEnvVarsFiles","providerEnvVars","siteExisted","siteFile","currency","country","currencies","layoutPath","layoutServerPath","layoutServer","hooksServerPath","rootLayoutPath","env","setup"],"sources":["../../src/patterns/enable/payments/runtime/setup-shopify.ts","../../src/patterns/enable/payments/runtime/stripe.ts","../../src/patterns/enable/payments/runtime/setup-stripe.ts","../../src/patterns/enable/payments/runtime/setup-whatsapp.ts","../../src/patterns/enable/payments/generate.runtime.ts"],"sourcesContent":["import type { Options, Result } from \"../../../../core/types\";\nimport { getLogger } from \"../../../../core/logger\";\nimport { buyPageSnippet } from \"../shopify-page\";\n\n/**\n * Shopify keeps products, customers and checkout on its side, so past the env\n * there is only the demo page, and only when a variant to sell was given.\n */\nexport async function setupShopify(options: Options) {\n const logger = getLogger(options);\n const variantId =\n typeof options.input.demoId === \"string\" ? options.input.demoId.trim() : \"\";\n\n const creates = [];\n if (variantId) {\n logger.info(\"Creating payment +page.svelte\");\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: buyPageSnippet(variantId),\n status: \"success\" as const,\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","import Stripe from \"stripe\";\nimport type PocketBase from \"pocketbase\";\nimport type { Logger } from \"../../../../core/logger\";\n\nexport interface StripeTestFixture {\n product: Stripe.Product;\n price: Stripe.Price;\n existing: boolean;\n}\n\nexport interface SyncUsersResult {\n total: number;\n linked: number;\n created: number;\n reused: number;\n skipped: number;\n}\n\nexport async function syncUsersToStripeCustomers(\n pb: PocketBase,\n stripeSecretKey: string,\n logger: Logger,\n): Promise<SyncUsersResult> {\n const stripe = new Stripe(stripeSecretKey);\n const users = await pb.collection(\"users\").getFullList<{\n id: string;\n email?: string;\n name?: string;\n phone?: string;\n }>();\n\n const existing = await pb\n .collection(\"stripe_customers\")\n .getFullList<{ id: string; user: string }>();\n const linkedUserIds = new Set(existing.map((c) => c.user));\n\n const result: SyncUsersResult = {\n total: users.length,\n linked: linkedUserIds.size,\n created: 0,\n reused: 0,\n skipped: 0,\n };\n\n for (const user of users) {\n if (linkedUserIds.has(user.id)) {\n result.skipped += 1;\n continue;\n }\n\n // A user made with a phone number may have no email to match on.\n const matching = user.email\n ? await stripe.customers.list({\n email: user.email,\n limit: 1,\n expand: [\"data.invoice_settings\"],\n })\n : { data: [] };\n const label = user.email || user.id;\n\n let customer: Stripe.Customer;\n let isExistingCustomer = false;\n\n if (matching.data.length > 0) {\n customer = matching.data[0];\n isExistingCustomer = true;\n result.reused += 1;\n logger.info(`Reusing Stripe customer ${customer.id} for ${label}`);\n } else {\n customer = await stripe.customers.create(\n user.email\n ? { email: user.email }\n : { name: user.name || undefined, phone: user.phone || undefined },\n );\n result.created += 1;\n logger.info(`Created Stripe customer ${customer.id} for ${label}`);\n }\n\n try {\n await pb.collection(\"stripe_customers\").create({\n id: customer.id,\n user: user.id,\n });\n } catch (error) {\n logger.info(\n `Failed to create stripe_customers row for ${label}: ${(error as Error).message}`,\n );\n continue;\n }\n\n if (!isExistingCustomer) {\n continue;\n }\n\n const paymentMethods = await stripe.customers.listPaymentMethods(\n customer.id,\n { type: \"card\", allow_redisplay: \"always\" },\n );\n\n for (const paymentMethod of paymentMethods.data) {\n if (paymentMethod.allow_redisplay === \"unspecified\") continue;\n try {\n await pb.collection(\"stripe_payment_methods\").create({\n id: paymentMethod.id,\n customer: customer.id,\n brand: paymentMethod.card?.brand,\n last4: paymentMethod.card?.last4,\n exp_month: paymentMethod.card?.exp_month,\n exp_year: paymentMethod.card?.exp_year,\n });\n } catch {}\n }\n\n const defaultPaymentMethod =\n customer.invoice_settings?.default_payment_method;\n if (defaultPaymentMethod) {\n try {\n await pb.collection(\"stripe_customers\").update(customer.id, {\n default_payment_method:\n typeof defaultPaymentMethod === \"string\"\n ? defaultPaymentMethod\n : defaultPaymentMethod.id,\n });\n } catch {}\n }\n }\n\n return result;\n}\n\nexport async function createTestProductAndPrice(\n stripeSecretKey: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n\n const products = await stripe.products.search({\n query: `name:\"Test Product\" AND metadata[\"test\"]:\"true\"`,\n limit: 1,\n });\n\n if (products.data.length > 0) {\n const product = products.data[0];\n const prices = await stripe.prices.list({\n product: product.id,\n active: true,\n limit: 1,\n });\n if (prices.data.length > 0) {\n return { product, price: prices.data[0], existing: true };\n }\n }\n\n const product = await stripe.products.create({\n name: \"Test Product\",\n metadata: { test: \"true\" },\n });\n\n const price = await stripe.prices.create({\n product: product.id,\n unit_amount: 1000,\n currency: \"usd\",\n });\n\n return { product, price, existing: false };\n}\n\nexport async function getProductAndPriceById(\n stripeSecretKey: string,\n priceId: string,\n): Promise<StripeTestFixture> {\n const stripe = new Stripe(stripeSecretKey);\n const price = await stripe.prices.retrieve(priceId, { expand: [\"product\"] });\n const product =\n typeof price.product === \"string\"\n ? await stripe.products.retrieve(price.product)\n : (price.product as Stripe.Product);\n price.product = product.id;\n return { product, price, existing: true };\n}\n","import path from \"node:path\";\nimport dedent from \"dedent\";\nimport type { File, Options, Result } from \"../../../../core/types\";\nimport { getLogger } from \"../../../../core/logger\";\nimport { suppliedProviderEnv } from \"../../../../core/providers\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../../runtime/pocketbase\";\nimport {\n createCollectionIdempotent,\n ensureCollectionFields,\n readMigration,\n} from \"../../../../runtime/collections\";\nimport { STRIPE_PRICES, STRIPE_PRODUCTS } from \"./collections\";\nimport { modifyOutcomeToFile } from \"../../../../runtime/modify-file\";\nimport { modifyNavUser } from \"../modifies/modify-nav-user\";\nimport { modifyUserSignup } from \"../modifies/modify-user-signup\";\nimport {\n createTestProductAndPrice,\n getProductAndPriceById,\n syncUsersToStripeCustomers,\n} from \"./stripe\";\n\nasync function pushMigrationCreates(\n creates: File[],\n collectionName: string,\n action: \"created\" | \"updated\",\n options: Options,\n created = true,\n) {\n if (!created) return;\n await migrationDelay();\n const migrationFile = getMigrationFile(collectionName, action, options);\n if (!migrationFile) return;\n creates.push(await readMigration(migrationFile, options));\n}\n\nfunction paymentPageSnippet(priceId: string): string {\n return dedent`\n <script lang=\"ts\">\n import PaymentButton from '#lib/components/payments/payment-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <PaymentButton priceId=\"${priceId}\" />\n </section>\n `;\n}\n\n/**\n * Everything Stripe needs past its env: the catalog and customer collections,\n * the existing users as Stripe customers, a product/price for the demo page,\n * and, with auth, the billing nav item and the signup link to Stripe.\n */\nexport async function setupStripe(options: Options) {\n const stripeSecretKey = suppliedProviderEnv(options).STRIPE_SECRET_KEY ?? \"\";\n const stripePriceId =\n typeof options.input.demoId === \"string\" && options.input.demoId !== \"\"\n ? options.input.demoId\n : undefined;\n\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n await withPocketbase(options.root, async (pb) => {\n const create = (spec: Parameters<typeof createCollectionIdempotent>[1]) =>\n createCollectionIdempotent(pb, spec, logger);\n\n // The catalog: created, or, when a project enabled payments before a\n // field existed, brought up to the spec (the next sync fills the field).\n for (const spec of [STRIPE_PRODUCTS, STRIPE_PRICES]) {\n logger.info(`Creating ${spec.name} collection`);\n const result = await create(spec);\n await pushMigrationCreates(\n creates,\n spec.name,\n \"created\",\n options,\n result.created,\n );\n if (!result.created) {\n creates.push(\n ...(await ensureCollectionFields(pb, spec, options, logger)),\n );\n }\n }\n\n if (isAppMode) {\n logger.info(\"Creating stripe_customers collection\");\n const customersResult = await create({\n name: \"stripe_customers\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const stripeCustomersCollection = customersResult.collection;\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"created\",\n options,\n customersResult.created,\n );\n\n logger.info(\"Creating stripe_payment_methods collection\");\n const paymentMethodsResult = await create({\n name: \"stripe_payment_methods\",\n type: \"base\",\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"exp_month\", required: true, type: \"number\" },\n { name: \"exp_year\", required: true, type: \"number\" },\n {\n collectionId: stripeCustomersCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"customer\",\n required: true,\n type: \"relation\",\n cascadeDelete: true,\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n const stripePaymentMethodsCollection = paymentMethodsResult.collection;\n await pushMigrationCreates(\n creates,\n \"stripe_payment_methods\",\n \"created\",\n options,\n paymentMethodsResult.created,\n );\n\n logger.info(\"Linking default_payment_method on stripe_customers\");\n await pb.collections.update(\"stripe_customers\", {\n fields: [\n {\n name: \"id\",\n pattern: \"^[a-zA-Z0-9_]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n {\n collectionId: stripePaymentMethodsCollection.id,\n maxSelect: 1,\n minSelect: 0,\n name: \"default_payment_method\",\n required: false,\n type: \"relation\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"stripe_customers\",\n \"updated\",\n options,\n );\n\n logger.info(\"Creating transactions collection\");\n const transactionsResult = await create({\n name: \"transactions\",\n type: \"base\",\n fields: [\n {\n autogeneratePattern: \"[a-z0-9]{15}\",\n max: 15,\n min: 15,\n name: \"id\",\n pattern: \"^[a-z0-9]+$\",\n primaryKey: true,\n required: true,\n system: true,\n type: \"text\",\n },\n { name: \"stripe_payment_intent\", required: true, type: \"text\" },\n { name: \"amount\", required: true, type: \"number\" },\n { name: \"currency\", required: true, type: \"text\" },\n { name: \"last4\", required: true, type: \"text\" },\n { name: \"brand\", required: true, type: \"text\" },\n { name: \"created\", required: true, type: \"date\" },\n { name: \"stripe_charge\", required: true, type: \"text\" },\n { name: \"stripe_customer\", required: true, type: \"text\" },\n {\n collectionId: \"_pb_users_auth_\",\n maxSelect: 1,\n minSelect: 0,\n name: \"user\",\n required: true,\n type: \"relation\",\n },\n { name: \"receipt_url\", required: true, type: \"url\" },\n ],\n });\n await pushMigrationCreates(\n creates,\n \"transactions\",\n \"created\",\n options,\n transactionsResult.created,\n );\n\n logger.info(\"Syncing existing PocketBase users to Stripe customers\");\n const syncResult = await syncUsersToStripeCustomers(\n pb,\n stripeSecretKey,\n logger,\n );\n logger.info(\n `Synced ${syncResult.total} users (created ${syncResult.created}, reused ${syncResult.reused}, skipped ${syncResult.skipped})`,\n );\n }\n });\n\n if (stripePriceId) {\n logger.info(`Fetching Stripe product/price ${stripePriceId}`);\n } else {\n logger.info(\"Creating test Stripe product and price\");\n }\n const { product, price, existing } = stripePriceId\n ? await getProductAndPriceById(stripeSecretKey, stripePriceId)\n : await createTestProductAndPrice(stripeSecretKey);\n\n if (existing) {\n logger.info(\"Stripe product/price already exists, skipping creation\");\n }\n\n logger.info(\"Seeding Stripe product/price records\");\n await withPocketbase(options.root, async (pb) => {\n try {\n await pb.collection(\"stripe_products\").getOne(product.id);\n } catch (error) {\n await pb.collection(\"stripe_products\").create({\n id: product.id,\n name: product.name,\n active: product.active,\n default_price: product.default_price,\n });\n }\n\n try {\n await pb.collection(\"stripe_prices\").getOne(price.id);\n } catch (error) {\n await pb.collection(\"stripe_prices\").create({\n id: price.id,\n billing_scheme: price.billing_scheme,\n currency: price.currency,\n product: price.product,\n recurring: price.recurring,\n type: price.type,\n unit_amount: price.unit_amount,\n active: price.active,\n });\n }\n });\n\n logger.info(\"Creating payment +page.svelte\");\n creates.push({\n path: \"src/routes/(public)/payment/+page.svelte\",\n language: \"svelte\",\n content: paymentPageSnippet(price.id),\n status: \"success\",\n });\n\n if (isAppMode) {\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(modifyOutcomeToFile(navUserPath, modifyNavUser(navUserPath)));\n\n logger.info(\"Modifying 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, modifyUserSignup(userSignupPath)),\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","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../../core/types\";\nimport { InvalidArgumentError } from \"../../../../core/errors\";\nimport { getLogger } from \"../../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../../runtime/modify-file\";\nimport type { SiteBusiness } from \"../../../../runtime/site\";\nimport {\n modifyWuchaleJsFiles,\n TRANSLATED_LIB_FILES,\n} from \"../../../../runtime/wuchale-config\";\n\n/**\n * WhatsApp keeps nothing past the env: orders go to the business's chat, and\n * the hosted form they are recorded to is created by the CLI. Every price is\n * in `site.currency`, so a project without one can't take orders: `business`\n * is what `src/lib/site.ts` declares after the shared step wrote it.\n */\nexport async function setupWhatsApp(options: Options, business: SiteBusiness) {\n if (!business.currency) {\n const given = options.input.currency;\n throw new InvalidArgumentError(\n given === undefined || given === \"\"\n ? \"Payments on WhatsApp need the business's currency, the one it prices in (an ISO 4217 code such as MXN or EUR). Pass --currency, or set `currency` in src/lib/site.ts.\"\n : `${String(given)} is not an ISO 4217 currency code, such as MXN or EUR.`,\n );\n }\n const modifies: File[] = [];\n\n // The order message is text a visitor sends, so with wuchale on it is\n // translated like the pages: the js adapter has to be told about the module.\n const wuchaleConfig = path.join(options.root, \"wuchale.config.js\");\n if (fs.existsSync(wuchaleConfig)) {\n getLogger(options).info(\"Adding src/lib/order.ts to wuchale's js adapter\");\n const edit = modifyOutcomeToFile(\n wuchaleConfig,\n modifyWuchaleJsFiles(wuchaleConfig, TRANSLATED_LIB_FILES),\n );\n if (edit) modifies.push(edit);\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","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n providerEnvVars,\n resolveProvider,\n suppliedProviderEnv,\n} from \"../../../core/providers\";\nimport { filesFromGlob, mergeResults } from \"../../../core/util\";\nimport { modifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnv } from \"../../../runtime/env\";\nimport {\n ensureSiteBusiness,\n normalizeCountry,\n normalizeCurrencies,\n normalizeCurrency,\n sitePath,\n} from \"../../../runtime/site\";\nimport { envEditsFor, META } from \"./generate\";\nimport { modifyHooksServerCurrency } from \"./modifies/hooks.server\";\nimport { modifyLayoutServerCurrency } from \"./modifies/layout.server\";\nimport { modifyLayoutSvelteCurrency } from \"./modifies/layout.svelte\";\nimport { modifyRootLayoutCurrencySelect } from \"./modifies/root-layout.svelte\";\nimport { setupShopify } from \"./runtime/setup-shopify\";\nimport { setupStripe } from \"./runtime/setup-stripe\";\nimport { setupWhatsApp } from \"./runtime/setup-whatsapp\";\n\nconst createsServerRaw = import.meta.glob<string>(\"./creates-server/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\n/** The server half of the currency store, for a project with a server load. */\nexport function serverCreates(unitTests: boolean): File[] {\n return Object.values(filesFromGlob(createsServerRaw, \"./creates-server/\"))\n .filter((file) => unitTests || !file.path.endsWith(\".test.ts\"))\n .sort((a, b) => a.path.localeCompare(b.path));\n}\n\n/** Whether the project can run a unit test (`vitest` in package.json). */\nexport function hasVitest(root: string): boolean {\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n return Boolean(pkg.devDependencies?.vitest || pkg.dependencies?.vitest);\n } catch {\n return false;\n }\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const provider = resolveProvider(META, options);\n const creates: File[] = [];\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(`Writing ${provider.label} credentials to .env`);\n const envPath = path.join(options.root, \".env\");\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnv(envPath, envEditsFor(provider, suppliedProviderEnv(options))),\n ),\n );\n\n // SvelteKit 3 exposes only declared variables, and only `public: true`\n // ones through `$app/env/public`.\n logger.info(`Declaring ${provider.label} variables in src/env.ts`);\n const envVars = modifyEnvVarsFiles(options.root, providerEnvVars(provider));\n if (envVars.create) creates.push(envVars.create);\n pushResult(envVars.modify);\n\n // What the business declares in src/lib/site.ts: the currency it prices\n // in, the country it is in, and the other currencies it shows prices in.\n // Asked for by the CLI; a value already there is kept.\n const { currency, country, currencies } = options.input;\n const siteExisted = fs.existsSync(sitePath(options.root));\n const { file: siteFile, business } = await ensureSiteBusiness(options, {\n currency: normalizeCurrency(currency) ?? undefined,\n country: normalizeCountry(country) ?? undefined,\n currencies:\n normalizeCurrencies(\n currencies,\n normalizeCurrency(currency) ?? undefined,\n ) ?? undefined,\n });\n if (siteFile) (siteExisted ? modifies : creates).push(siteFile);\n\n logger.info(\"Adding the currency select to the navbar\");\n const layoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"root-layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(layoutPath, modifyRootLayoutCurrencySelect(layoutPath)),\n );\n\n // With a server, the visitor's currency is decided per request and the\n // first render already shows it. A static site (a universal root load) keeps\n // the store's browser-side start.\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n if (fs.existsSync(layoutServerPath)) {\n logger.info(\"Resolving the visitor's currency on the server\");\n const layoutServer = modifyLayoutServerCurrency(layoutServerPath);\n pushResult(modifyOutcomeToFile(layoutServerPath, layoutServer));\n if (layoutServer.status === \"success\") {\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerCurrency(hooksServerPath),\n ),\n );\n const rootLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyLayoutSvelteCurrency(rootLayoutPath),\n ),\n );\n for (const file of serverCreates(hasVitest(options.root)))\n creates.push(file);\n }\n }\n\n const env: Result = {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n };\n\n const setup =\n provider.id === \"stripe\"\n ? await setupStripe(options)\n : provider.id === \"shopify\"\n ? await setupShopify(options)\n : await setupWhatsApp(options, business);\n\n return mergeResults([env, setup]) satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA,eAAsByC,EAAa,GAAkB;CACnD,IAAMC,IAASpC,EAAUqC,CAAO,GAC1BC,IACJ,OAAOD,EAAQ,MAAM,UAAW,WAAWA,EAAQ,MAAM,OAAO,KAAK,IAAI,IAErEE,IAAU,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O,iBAAiB;GACxE,EACEhC,EACE8G,GACArG,EAA0BqG,CAAe,CAC3C,CACF;GACA,IAAMC,IAAiBnF,EAAK,KAC1BI,EAAQ,MACR,OACA,UACA,gBACF;GACA,EACEhC,EACE+G,GACAvG,EAA2BuG,CAAc,CAC3C,CACF;GACA,KAAK,IAAMvC,KAAQiB,EAAcI,EAAU7D,EAAQ,IAAI,CAAC,GACtD,EAAQ,KAAKwC,CAAI;EACrB;CACF;CAEA,IAAMwC,IAAc;EAClB;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB,GAEMC,IACJhB,EAAS,OAAO,WACZ,MAAM9B,EAAYnC,CAAO,IACzBiE,EAAS,OAAO,YACd,MAAMnE,EAAaE,CAAO,IAC1B,MAAMmD,EAAcnD,GAASoD,CAAQ;CAE7C,OAAOtF,EAAa,CAACkH,GAAKC,CAAK,CAAC;AAClC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { n as e, t } from "./constants-DbpctM1D.js";
|
|
2
|
+
import { t as n } from "./dedent-CCUOcPFW.js";
|
|
3
|
+
import { o as r, s as i } from "./config-target-DJbVHwHl.js";
|
|
4
|
+
import { c as a } from "./write-result-BhfLWAXf.js";
|
|
5
|
+
import o from "node:fs";
|
|
6
|
+
import { SyntaxKind as s } from "ts-morph";
|
|
7
|
+
// src/patterns/enable/backend/modifies/svelte-config.ts
|
|
8
|
+
var c = a(t), l = a(e), u = "@sveltejs/adapter-auto", d = n`
|
|
9
|
+
Switch the SvelteKit adapter to ${c}:
|
|
10
|
+
|
|
11
|
+
import adapter from '${c}';
|
|
12
|
+
|
|
13
|
+
// ...
|
|
14
|
+
adapter: adapter()
|
|
15
|
+
`, f = n`
|
|
16
|
+
Configure ${c} via the sveltekit() plugin in vite.config.ts.
|
|
17
|
+
`;
|
|
18
|
+
function p(e) {
|
|
19
|
+
return e.getImportDeclarations().find((e) => [
|
|
20
|
+
l,
|
|
21
|
+
u,
|
|
22
|
+
c
|
|
23
|
+
].includes(e.getModuleSpecifierValue()));
|
|
24
|
+
}
|
|
25
|
+
function m(e) {
|
|
26
|
+
return e.getDescendantsOfKind(s.CallExpression).filter((e) => e.getExpression().getText() === "adapter");
|
|
27
|
+
}
|
|
28
|
+
function h(e) {
|
|
29
|
+
let t = r(e, {
|
|
30
|
+
notFound: f,
|
|
31
|
+
failed: d
|
|
32
|
+
});
|
|
33
|
+
if (t.status !== "resolved") return {
|
|
34
|
+
filePath: t.filePath,
|
|
35
|
+
outcome: {
|
|
36
|
+
status: t.status,
|
|
37
|
+
message: t.message
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
let { target: n } = t, a = p(n.sourceFile);
|
|
41
|
+
if (!a) return {
|
|
42
|
+
filePath: n.filePath,
|
|
43
|
+
outcome: {
|
|
44
|
+
status: "failed",
|
|
45
|
+
message: d
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
a.getModuleSpecifierValue() !== c && a.setModuleSpecifier(c);
|
|
49
|
+
for (let e of m(n.sourceFile)) {
|
|
50
|
+
let t = e.getArguments();
|
|
51
|
+
for (let n = t.length - 1; n >= 0; n--) e.removeArgument(n);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
filePath: n.filePath,
|
|
55
|
+
outcome: i(n)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function g(e) {
|
|
59
|
+
let t = r(e, {
|
|
60
|
+
notFound: f,
|
|
61
|
+
failed: d
|
|
62
|
+
});
|
|
63
|
+
if (t.status === "not-found") return {
|
|
64
|
+
filePath: t.filePath,
|
|
65
|
+
outcome: {
|
|
66
|
+
status: "success",
|
|
67
|
+
changed: !1
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (t.status === "failed") return {
|
|
71
|
+
filePath: t.filePath,
|
|
72
|
+
outcome: {
|
|
73
|
+
status: "failed",
|
|
74
|
+
message: t.message
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
let { target: n } = t, a = p(n.sourceFile);
|
|
78
|
+
if (!a) return {
|
|
79
|
+
filePath: n.filePath,
|
|
80
|
+
outcome: {
|
|
81
|
+
status: "success",
|
|
82
|
+
changed: !1
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
a.getModuleSpecifierValue() !== l && a.setModuleSpecifier(l);
|
|
86
|
+
for (let e of m(n.sourceFile)) e.getArguments().length === 0 && e.addArgument("{ fallback: '200.html' }");
|
|
87
|
+
return {
|
|
88
|
+
filePath: n.filePath,
|
|
89
|
+
outcome: i(n)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// src/patterns/enable/backend/modifies/gitignore.ts
|
|
93
|
+
var _ = "# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n", v = n`
|
|
94
|
+
Create a .gitignore at the project root with the PocketBase block:
|
|
95
|
+
|
|
96
|
+
# PocketBase
|
|
97
|
+
/data/*
|
|
98
|
+
!/data/fixtures
|
|
99
|
+
!/data/seeds
|
|
100
|
+
!/data/hooks
|
|
101
|
+
`;
|
|
102
|
+
function y(e) {
|
|
103
|
+
if (!o.existsSync(e)) return {
|
|
104
|
+
status: "not-found",
|
|
105
|
+
message: v
|
|
106
|
+
};
|
|
107
|
+
let t = o.readFileSync(e, "utf8");
|
|
108
|
+
if (t.includes("# PocketBase") && t.includes("/data/*")) return {
|
|
109
|
+
status: "success",
|
|
110
|
+
changed: !1
|
|
111
|
+
};
|
|
112
|
+
let n = t + (t.endsWith("\n") ? "\n" : "\n\n") + _;
|
|
113
|
+
return o.writeFileSync(e, n, "utf8"), {
|
|
114
|
+
status: "success",
|
|
115
|
+
changed: !0
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function b(e) {
|
|
119
|
+
if (!o.existsSync(e)) return {
|
|
120
|
+
status: "success",
|
|
121
|
+
changed: !1
|
|
122
|
+
};
|
|
123
|
+
let t = o.readFileSync(e, "utf8");
|
|
124
|
+
if (!t.includes("# PocketBase")) return {
|
|
125
|
+
status: "success",
|
|
126
|
+
changed: !1
|
|
127
|
+
};
|
|
128
|
+
let n = t.replace(/\n*# PocketBase\n\/data\/\*\n!\/data\/fixtures\n!\/data\/seeds\n!\/data\/hooks\n?/, "\n").replace(/\n{3,}$/, "\n");
|
|
129
|
+
return n === t ? {
|
|
130
|
+
status: "success",
|
|
131
|
+
changed: !1
|
|
132
|
+
} : (o.writeFileSync(e, n, "utf8"), {
|
|
133
|
+
status: "success",
|
|
134
|
+
changed: !0
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export { g as i, b as n, h as r, y as t };
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=gitignore-2XpeEFmr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitignore-2XpeEFmr.js","names":["ADAPTER_NODE_SPEC","ADAPTER_STATIC_SPEC","NOT_FOUND_HINT","ADAPTER_STATIC$1","dedent","resolveConfigTarget","saveTarget","packageName","fs","ADAPTER_NODE","ADAPTER_NODE$1","ADAPTER_STATIC","ADAPTER_AUTO","FAILURE_HINT","NOT_FOUND_HINT$1","findAdapterImport","sourceFile","decl","adapterCalls","SyntaxKind","ce","modifySvelteConfig","res","root","adapterImport","target","call","args","i","unmodifySvelteConfig","POCKETBASE_BLOCK","NOT_FOUND_HINT","modifyGitignore","gitignorePath","original","next","unmodifyGitignore","cleaned"],"sources":["../../src/patterns/enable/backend/modifies/svelte-config.ts","../../src/patterns/enable/backend/modifies/gitignore.ts"],"sourcesContent":["import dedent from \"dedent\";\nimport { SyntaxKind } from \"ts-morph\";\nimport {\n resolveConfigTarget,\n saveTarget,\n type ConfigModifyResult,\n type ConfigTarget,\n} from \"../../../../runtime/config-target\";\nimport { packageName } from \"../../../../runtime/write-result\";\nimport {\n ADAPTER_NODE as ADAPTER_NODE_SPEC,\n ADAPTER_STATIC as ADAPTER_STATIC_SPEC,\n} from \"../../../../core/constants\";\n\n// Imports name the package, not the versioned spec the constants install.\nconst ADAPTER_NODE = packageName(ADAPTER_NODE_SPEC);\nconst ADAPTER_STATIC = packageName(ADAPTER_STATIC_SPEC);\nconst ADAPTER_AUTO = \"@sveltejs/adapter-auto\";\n\nconst FAILURE_HINT = dedent`\n Switch the SvelteKit adapter to ${ADAPTER_NODE}:\n\n import adapter from '${ADAPTER_NODE}';\n\n // ...\n adapter: adapter()\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Configure ${ADAPTER_NODE} via the sveltekit() plugin in vite.config.ts.\n`;\n\n/**\n * The adapters this pattern moves between. adapter-auto is included because\n * that is what `sv create` ships, and a project that never chose is one the\n * backend is free to decide for.\n */\nfunction findAdapterImport(sourceFile: ConfigTarget[\"sourceFile\"]) {\n return sourceFile\n .getImportDeclarations()\n .find((decl) =>\n [ADAPTER_STATIC, ADAPTER_AUTO, ADAPTER_NODE].includes(\n decl.getModuleSpecifierValue(),\n ),\n );\n}\n\nfunction adapterCalls(sourceFile: ConfigTarget[\"sourceFile\"]) {\n return sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => ce.getExpression().getText() === \"adapter\");\n}\n\n/**\n * Switch the adapter to `@sveltejs/adapter-node` and drop its arguments in\n * vite.config, which holds the adapter import + `adapter()` call. A project with a\n * backend is served from a Node process, which is what `vela deploy` runs.\n * Operates on the import and call expression directly, so it never needs the\n * config object.\n */\nexport function modifySvelteConfig(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, {\n notFound: NOT_FOUND_HINT,\n failed: FAILURE_HINT,\n });\n if (res.status !== \"resolved\") {\n return {\n filePath: res.filePath,\n outcome: { status: res.status, message: res.message },\n };\n }\n const { target } = res;\n const adapterImport = findAdapterImport(target.sourceFile);\n if (!adapterImport) {\n return {\n filePath: target.filePath,\n outcome: { status: \"failed\", message: FAILURE_HINT },\n };\n }\n\n if (adapterImport.getModuleSpecifierValue() !== ADAPTER_NODE) {\n adapterImport.setModuleSpecifier(ADAPTER_NODE);\n }\n\n for (const call of adapterCalls(target.sourceFile)) {\n const args = call.getArguments();\n for (let i = args.length - 1; i >= 0; i--) {\n call.removeArgument(i);\n }\n }\n\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n\n/**\n * Reverse of {@link modifySvelteConfig}: switch back to\n * `@sveltejs/adapter-static` and restore the `{ fallback: '200.html' }` arg.\n * Lenient when there is no config or no adapter import: a no-op success. A\n * config that can't be edited (a leftover svelte.config) still fails.\n */\nexport function unmodifySvelteConfig(root: string): ConfigModifyResult {\n const res = resolveConfigTarget(root, {\n notFound: NOT_FOUND_HINT,\n failed: FAILURE_HINT,\n });\n if (res.status === \"not-found\") {\n // Nothing to revert.\n return {\n filePath: res.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n if (res.status === \"failed\") {\n return {\n filePath: res.filePath,\n outcome: { status: \"failed\", message: res.message },\n };\n }\n const { target } = res;\n const adapterImport = findAdapterImport(target.sourceFile);\n if (!adapterImport) {\n return {\n filePath: target.filePath,\n outcome: { status: \"success\", changed: false },\n };\n }\n\n if (adapterImport.getModuleSpecifierValue() !== ADAPTER_STATIC) {\n adapterImport.setModuleSpecifier(ADAPTER_STATIC);\n }\n\n for (const call of adapterCalls(target.sourceFile)) {\n if (call.getArguments().length === 0) {\n call.addArgument(\"{ fallback: '200.html' }\");\n }\n }\n\n return { filePath: target.filePath, outcome: saveTarget(target) };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst POCKETBASE_BLOCK = `# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create a .gitignore at the project root with the PocketBase block:\n\n # PocketBase\n /data/*\n !/data/fixtures\n !/data/seeds\n !/data/hooks\n`;\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n\n if (original.includes(\"# PocketBase\") && original.includes(\"/data/*\")) {\n return { status: \"success\", changed: false };\n }\n\n const separator = original.endsWith(\"\\n\") ? \"\\n\" : \"\\n\\n\";\n const next = original + separator + POCKETBASE_BLOCK;\n fs.writeFileSync(gitignorePath, next, \"utf8\");\n\n return { status: \"success\", changed: true };\n}\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\n if (!original.includes(\"# PocketBase\")) {\n return { status: \"success\", changed: false };\n }\n\n const withBlockRemoved = original.replace(\n /\\n*# PocketBase\\n\\/data\\/\\*\\n!\\/data\\/fixtures\\n!\\/data\\/seeds\\n!\\/data\\/hooks\\n?/,\n \"\\n\",\n );\n\n const cleaned = withBlockRemoved.replace(/\\n{3,}$/, \"\\n\");\n\n if (cleaned === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, cleaned, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;;;;AAeA,IAAMS,IAAeF,EAAYP,CAAiB,GAC5CW,IAAiBJ,EAAYN,CAAmB,GAChDW,IAAe,0BAEfC,IAAe,CAAM;oCACSJ,EAAa;;yBAExBA,EAAa;;;;GAMhCP,IAAiB,CAAM;cACfO,EAAa;;AAQ3B,SAASM,EAAkB,GAAwC;CACjE,OAAOC,EACJ,sBAAsB,CAAC,CACvB,MAAM,MACL;EAACL;EAAgBC;EAAcH;CAAY,CAAC,CAAC,SAC3CQ,EAAK,wBAAwB,CAC/B,CACF;AACJ;AAEA,SAASC,EAAa,GAAwC;CAC5D,OAAOF,EACJ,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,QAAQ,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,SAAS;AAC9D;AASA,SAAgBC,EAAmB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n, n as r, r as i, t as a } from "./translations-
|
|
2
|
+
import { r as t } from "./modify-file-BX9-aZD1.js";
|
|
3
|
+
import { i as n, n as r, r as i, t as a } from "./translations-B5hX0Qq-.js";
|
|
4
4
|
import { n as o, r as s } from "./app-layout.svelte-CZ0hw-pi.js";
|
|
5
5
|
import c from "node:fs";
|
|
6
6
|
import l from "node:path";
|
|
@@ -25,4 +25,4 @@ function u(u) {
|
|
|
25
25
|
}
|
|
26
26
|
export { u as localizeAuthPages };
|
|
27
27
|
|
|
28
|
-
//# sourceMappingURL=i18n-
|
|
28
|
+
//# sourceMappingURL=i18n-CxT1kz8Y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-
|
|
1
|
+
{"version":3,"file":"i18n-CxT1kz8Y.js","names":["getLogger","modifyOutcomeToFile","translateCatalog","entriesInProject","hasSpanish","AUTH_TRANSLATIONS","APP_LAYOUT_PATH","modifyAppLayoutLanguageSelect","fs","path","localizeAuthPages","logger","options","creates","modifies","appLayoutFile","select","translated"],"sources":["../../src/patterns/enable/auth/i18n.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n entriesInProject,\n hasSpanish,\n translateCatalog,\n} from \"../../../runtime/wuchale-catalog\";\nimport {\n APP_LAYOUT_PATH,\n modifyAppLayoutLanguageSelect,\n} from \"../i18n/modifies/app-layout.svelte\";\nimport { AUTH_TRANSLATIONS } from \"./translations\";\n\n/**\n * What enable-i18n would have done to the auth pages had they been in the\n * project when it ran: the language select in the signed-in layout, and the\n * pages' Spanish in the catalog. For enable-auth and enable-auth-remote, in a\n * project that already has i18n; nothing happens in one that does not.\n *\n * Reads the pages from disk, so it runs after the pattern's creates are\n * written. Detected by the files enable-i18n wrote rather than\n * `features.i18n`, so a project that dropped Spanish keeps its catalog as it\n * is.\n */\nexport function localizeAuthPages(options: Options): {\n creates: File[];\n modifies: File[];\n} {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n if (!fs.existsSync(path.join(options.root, \"wuchale.config.js\"))) {\n return { creates, modifies };\n }\n\n logger.info(\"Adding the language select to the signed-in layout\");\n const appLayoutFile = path.join(options.root, APP_LAYOUT_PATH);\n const select = modifyOutcomeToFile(\n appLayoutFile,\n modifyAppLayoutLanguageSelect(appLayoutFile),\n );\n if (select) modifies.push(select);\n\n if (hasSpanish(options.root)) {\n logger.info(\"Translating the sign-in pages into Spanish\");\n const translated = translateCatalog(\n options.root,\n entriesInProject(options.root, AUTH_TRANSLATIONS),\n );\n if (translated.create) creates.push(translated.create);\n if (translated.modify) modifies.push(translated.modify);\n }\n\n return { creates, modifies };\n}\n"],"mappings":";;;;;;;AA2BA,SAAgBU,EAAkB,GAGhC;CACA,IAAMC,IAASX,EAAUY,CAAO,GAC1BC,IAAkB,CAAC,GACnBC,IAAmB,CAAC;CAC1B,IAAI,CAACN,EAAG,WAAWC,EAAK,KAAKG,EAAQ,MAAM,mBAAmB,CAAC,GAC7D,OAAO;EAAE;EAAS;CAAS;CAG7B,EAAO,KAAK,oDAAoD;CAChE,IAAMG,IAAgBN,EAAK,KAAKG,EAAQ,MAAMN,CAAe,GACvDU,IAASf,EACbc,GACAR,EAA8BQ,CAAa,CAC7C;CAGA,IAFIC,KAAQF,EAAS,KAAKE,CAAM,GAE5BZ,EAAWQ,EAAQ,IAAI,GAAG;EAC5B,EAAO,KAAK,4CAA4C;EACxD,IAAMK,IAAaf,EACjBU,EAAQ,MACRT,EAAiBS,EAAQ,MAAMP,CAAiB,CAClD;EAEA,AADIY,EAAW,UAAQJ,EAAQ,KAAKI,EAAW,MAAM,GACjDA,EAAW,UAAQH,EAAS,KAAKG,EAAW,MAAM;CACxD;CAEA,OAAO;EAAE;EAAS;CAAS;AAC7B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-CwxnZyOB.js";
|
|
2
|
-
import { a as t } from "./util-
|
|
3
|
-
import { n } from "./shared-
|
|
2
|
+
import { a as t } from "./util-mXrQ89nG.js";
|
|
3
|
+
import { n } from "./shared-BOFCKWJs.js";
|
|
4
4
|
import { _ as r, s as i } from "./ts-morph-helpers-B4KZXP44.js";
|
|
5
5
|
import a from "node:fs";
|
|
6
6
|
import o from "node:path";
|
|
@@ -47,4 +47,4 @@ function d(e, t) {
|
|
|
47
47
|
}
|
|
48
48
|
export { l as a, s as i, d as n, c as r, u as t };
|
|
49
49
|
|
|
50
|
-
//# sourceMappingURL=modify-file-
|
|
50
|
+
//# sourceMappingURL=modify-file-BX9-aZD1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modify-file-
|
|
1
|
+
{"version":3,"file":"modify-file-BX9-aZD1.js","names":["__exportAll","languageFromPath","withInMemoryScript","isEffectivelyEmpty","fs","path","modify_file_exports","keepMissing","modifyOutcomeToFile","language","filePath","outcome","revertOutcomeToFile","toDeleteEntry","envRevertOutcomeToFile","envPath","creates","root","file"],"sources":["../../src/runtime/modify-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, ModifyOutcome } from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { toDeleteEntry } from \"../patterns/destroy/shared\";\nimport { isEffectivelyEmpty, withInMemoryScript } from \"./ts-morph-helpers\";\n\nexport function modifyOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): File | null {\n const language = languageFromPath(filePath);\n\n if (outcome.status === \"success\") {\n if (!outcome.changed) return null;\n return {\n path: filePath,\n language,\n content: fs.readFileSync(filePath, \"utf8\"),\n status: \"success\",\n };\n }\n\n const content =\n outcome.status === \"failed\" && fs.existsSync(filePath)\n ? fs.readFileSync(filePath, \"utf8\")\n : \"\";\n\n return {\n path: filePath,\n language,\n content,\n status: outcome.status,\n message: outcome.message,\n };\n}\n\n/**\n * `modifyOutcomeToFile` for a revert that may have taken out everything the\n * file held: a script left with no statements, only comments and whitespace,\n * is reported as a delete. For hooks files a pattern created, or that ended\n * up holding nothing but what patterns put there.\n */\nexport function revertOutcomeToFile(\n filePath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(filePath) &&\n withInMemoryScript(fs.readFileSync(filePath, \"utf8\"), isEffectivelyEmpty)\n .result\n ) {\n return { modify: null, delete: toDeleteEntry(filePath) };\n }\n return { modify: modifyOutcomeToFile(filePath, outcome), delete: null };\n}\n\n/**\n * `modifyOutcomeToFile` for a `.env` revert: a file the revert left empty is\n * reported as a delete. The enable pattern most likely created it, and an\n * empty `.env` holds nothing worth keeping.\n */\nexport function envRevertOutcomeToFile(\n envPath: string,\n outcome: ModifyOutcome,\n): { modify: File | null; delete: File | null } {\n if (\n outcome.status === \"success\" &&\n outcome.changed &&\n fs.existsSync(envPath) &&\n fs.readFileSync(envPath, \"utf8\").trim() === \"\"\n ) {\n return { modify: null, delete: toDeleteEntry(envPath) };\n }\n return { modify: modifyOutcomeToFile(envPath, outcome), delete: null };\n}\n\n/**\n * Drop any create that already exists on disk.\n *\n * `writeResult` overwrites an existing create whose content differs and\n * reports it as a modify, which would mean a re-run silently resetting a\n * developer's edits, or a create clobbering a file other patterns have\n * already written to. The file is theirs once it exists; a pattern that has\n * something to add to it does so with a modifier.\n */\nexport function keepMissing(creates: File[], root: string): File[] {\n return creates.filter((file) => !fs.existsSync(path.join(root, file.path)));\n}\n"],"mappings":";;;;;;;;;;;AAOA,SAAgBQ,EACd,GACA,GACa;CACb,IAAMC,IAAWR,EAAiBS,CAAQ;CAiB1C,OAfIC,EAAQ,WAAW,YAChBA,EAAQ,UACN;EACL,MAAMD;EACN;EACA,SAASN,EAAG,aAAaM,GAAU,MAAM;EACzC,QAAQ;CACV,IAN6B,OAcxB;EACL,MAAMA;EACN;EACA,SAPAC,EAAQ,WAAW,YAAYP,EAAG,WAAWM,CAAQ,IACjDN,EAAG,aAAaM,GAAU,MAAM,IAChC;EAMJ,QAAQC,EAAQ;EAChB,SAASA,EAAQ;CACnB;AACF;AAQA,SAAgBC,EACd,GACA,GAC8C;CAU9C,OARED,EAAQ,WAAW,aACnBA,EAAQ,WACRP,EAAG,WAAWM,CAAQ,KACtBR,EAAmBE,EAAG,aAAaM,GAAU,MAAM,GAAGP,CAAkB,CAAC,CACtE,SAEI;EAAE,QAAQ;EAAM,QAAQU,EAAcH,CAAQ;CAAE,IAElD;EAAE,QAAQF,EAAoBE,GAAUC,CAAO;EAAG,QAAQ;CAAK;AACxE;AAOA,SAAgBG,EACd,GACA,GAC8C;CAS9C,OAPEH,EAAQ,WAAW,aACnBA,EAAQ,WACRP,EAAG,WAAWW,CAAO,KACrBX,EAAG,aAAaW,GAAS,MAAM,CAAC,CAAC,KAAK,MAAM,KAErC;EAAE,QAAQ;EAAM,QAAQF,EAAcE,CAAO;CAAE,IAEjD;EAAE,QAAQP,EAAoBO,GAASJ,CAAO;EAAG,QAAQ;CAAK;AACvE;AAWA,SAAgBJ,EAAY,GAAiB,GAAsB;CACjE,OAAOS,EAAQ,QAAQ,MAAS,CAACZ,EAAG,WAAWC,EAAK,KAAKY,GAAMC,EAAK,IAAI,CAAC,CAAC;AAC5E"}
|