@velastack/patterns 0.2.11 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- 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-CgdvZXmh.js} +17 -17
- package/dist/chunks/{collections-DDYlpDNO.js.map → collections-CgdvZXmh.js.map} +1 -1
- package/dist/chunks/compose-handle-Cg9jnCsS.js +322 -0
- package/dist/chunks/compose-handle-Cg9jnCsS.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/dispatch-BRnt8PcW.js +6 -0
- package/dist/chunks/dispatch-BRnt8PcW.js.map +1 -0
- package/dist/chunks/format-result-Cb2hWsb8.js +64 -0
- package/dist/chunks/format-result-Cb2hWsb8.js.map +1 -0
- package/dist/chunks/generate-BkQ1xMDp.js +30 -0
- package/dist/chunks/generate-BkQ1xMDp.js.map +1 -0
- package/dist/chunks/{generate-Va1sxVPG.js → generate-DRA63W0r.js} +17 -64
- package/dist/chunks/generate-DRA63W0r.js.map +1 -0
- package/dist/chunks/generate-_LvrYK6i.js +55 -0
- package/dist/chunks/generate-_LvrYK6i.js.map +1 -0
- package/dist/chunks/generate-iQP31-m1.js +252 -0
- package/dist/chunks/generate-iQP31-m1.js.map +1 -0
- package/dist/chunks/{generate.runtime-Dtf2BI_5.js → generate.runtime-B0hhtyAL.js} +9 -9
- package/dist/chunks/{generate.runtime-Dtf2BI_5.js.map → generate.runtime-B0hhtyAL.js.map} +1 -1
- package/dist/chunks/generate.runtime-B49wetSx.js +122 -0
- package/dist/chunks/generate.runtime-B49wetSx.js.map +1 -0
- package/dist/chunks/{generate.runtime-SQhCLSah.js → generate.runtime-B7LRx-BU.js} +13 -13
- package/dist/chunks/{generate.runtime-SQhCLSah.js.map → generate.runtime-B7LRx-BU.js.map} +1 -1
- package/dist/chunks/generate.runtime-BKo-Nidn.js +38 -0
- package/dist/chunks/generate.runtime-BKo-Nidn.js.map +1 -0
- package/dist/chunks/{generate.runtime-vTneb2SY.js → generate.runtime-BORbegw_.js} +111 -101
- package/dist/chunks/generate.runtime-BORbegw_.js.map +1 -0
- package/dist/chunks/{generate.runtime-BtX_9lLk.js → generate.runtime-BbIN0tUZ.js} +34 -34
- package/dist/chunks/{generate.runtime-BtX_9lLk.js.map → generate.runtime-BbIN0tUZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-OjW1XETW.js → generate.runtime-BnWE4qsu.js} +42 -42
- package/dist/chunks/generate.runtime-BnWE4qsu.js.map +1 -0
- package/dist/chunks/{generate.runtime-B_Fk1Jjs.js → generate.runtime-BwhGDnGu.js} +32 -35
- package/dist/chunks/generate.runtime-BwhGDnGu.js.map +1 -0
- package/dist/chunks/{generate.runtime-BgezGu15.js → generate.runtime-CCg2Pjcv.js} +95 -94
- package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +1 -0
- package/dist/chunks/{generate.runtime-DRcq4d5D.js → generate.runtime-CRYjWJRe.js} +31 -31
- package/dist/chunks/{generate.runtime-DRcq4d5D.js.map → generate.runtime-CRYjWJRe.js.map} +1 -1
- package/dist/chunks/generate.runtime-CcuAXuV2.js +60 -0
- package/dist/chunks/generate.runtime-CcuAXuV2.js.map +1 -0
- package/dist/chunks/{generate.runtime-DK7iXmAZ.js → generate.runtime-D0icLb5j.js} +50 -47
- package/dist/chunks/{generate.runtime-DK7iXmAZ.js.map → generate.runtime-D0icLb5j.js.map} +1 -1
- package/dist/chunks/{generate.runtime-fSDNxfGG.js → generate.runtime-D2e_KRj0.js} +11 -11
- package/dist/chunks/{generate.runtime-fSDNxfGG.js.map → generate.runtime-D2e_KRj0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CycY6kPr.js → generate.runtime-D44gjxRA.js} +102 -99
- package/dist/chunks/generate.runtime-D44gjxRA.js.map +1 -0
- package/dist/chunks/{generate.runtime-AjCpCfv3.js → generate.runtime-D8vgh5MH.js} +186 -138
- package/dist/chunks/generate.runtime-D8vgh5MH.js.map +1 -0
- package/dist/chunks/generate.runtime-DAmYsIvF.js +32 -0
- package/dist/chunks/generate.runtime-DAmYsIvF.js.map +1 -0
- package/dist/chunks/{generate.runtime-B6kxV3Bi.js → generate.runtime-DNaQxed-.js} +45 -45
- package/dist/chunks/{generate.runtime-B6kxV3Bi.js.map → generate.runtime-DNaQxed-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CZQoVNt3.js → generate.runtime-DOuufRLr.js} +35 -35
- package/dist/chunks/generate.runtime-DOuufRLr.js.map +1 -0
- package/dist/chunks/{generate.runtime-BpYOznG5.js → generate.runtime-DSqkXvps.js} +21 -21
- package/dist/chunks/{generate.runtime-BpYOznG5.js.map → generate.runtime-DSqkXvps.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BYJZB1ad.js → generate.runtime-DhkaXTq3.js} +37 -57
- package/dist/chunks/generate.runtime-DhkaXTq3.js.map +1 -0
- package/dist/chunks/{generate.runtime-Cq1gqxzg.js → generate.runtime-DoZdSh9W.js} +22 -22
- package/dist/chunks/{generate.runtime-Cq1gqxzg.js.map → generate.runtime-DoZdSh9W.js.map} +1 -1
- package/dist/chunks/{generate.runtime-qjsxSPaH.js → generate.runtime-S5RIgbQx.js} +102 -99
- package/dist/chunks/generate.runtime-S5RIgbQx.js.map +1 -0
- package/dist/chunks/generate.runtime-WmSMWL15.js +82 -0
- package/dist/chunks/generate.runtime-WmSMWL15.js.map +1 -0
- package/dist/chunks/generate.runtime-acRmiU7e.js +81 -0
- package/dist/chunks/generate.runtime-acRmiU7e.js.map +1 -0
- package/dist/chunks/generate.runtime-flFRYzpi.js +145 -0
- package/dist/chunks/generate.runtime-flFRYzpi.js.map +1 -0
- package/dist/chunks/generate.runtime-gtpOuLNO.js +110 -0
- package/dist/chunks/generate.runtime-gtpOuLNO.js.map +1 -0
- package/dist/chunks/{generate.runtime-DHRCNPVx.js → generate.runtime-kLxeDGnS.js} +23 -23
- package/dist/chunks/{generate.runtime-DHRCNPVx.js.map → generate.runtime-kLxeDGnS.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DH9o-888.js → generate.runtime-wA1G3tQ4.js} +27 -27
- package/dist/chunks/{generate.runtime-DH9o-888.js.map → generate.runtime-wA1G3tQ4.js.map} +1 -1
- package/dist/chunks/modify-file-GQD6uNgI.js +254 -0
- package/dist/chunks/modify-file-GQD6uNgI.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-CeG5BMN2.js} +57 -50
- package/dist/chunks/{pocketbase-BerjVikJ.js.map → pocketbase-CeG5BMN2.js.map} +1 -1
- package/dist/chunks/providers-DO9kMyzB.js +69 -0
- package/dist/chunks/providers-DO9kMyzB.js.map +1 -0
- package/dist/chunks/rolldown-runtime-DArdT4gl.js +23 -0
- package/dist/chunks/{shared-Cmbzu7Od.js → shared-BwHQM-a9.js} +2 -2
- package/dist/chunks/{shared-Cmbzu7Od.js.map → shared-BwHQM-a9.js.map} +1 -1
- package/dist/chunks/site-D027dpBm.js +55 -0
- package/dist/chunks/site-D027dpBm.js.map +1 -0
- 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-B4Tuit-7.js} +12 -12
- package/dist/chunks/{ui-BdkuOXPw.js.map → ui-B4Tuit-7.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-DewHCNhM.js} +51 -51
- package/dist/chunks/{write-result-BVWPlGvE.js.map → write-result-DewHCNhM.js.map} +1 -1
- package/dist/index.d.ts +272 -65
- package/dist/index.js +2279 -2268
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/dispatch-B5PfQ2CA.js +0 -6
- package/dist/chunks/dispatch-B5PfQ2CA.js.map +0 -1
- package/dist/chunks/format-result-BdAy5M8C.js +0 -50
- package/dist/chunks/format-result-BdAy5M8C.js.map +0 -1
- package/dist/chunks/generate-Va1sxVPG.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-B_Fk1Jjs.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-CTiJEVF2.js +0 -107
- package/dist/chunks/generate.runtime-CTiJEVF2.js.map +0 -1
- package/dist/chunks/generate.runtime-CZQoVNt3.js.map +0 -1
- package/dist/chunks/generate.runtime-CycY6kPr.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-DEl6b1Ti.js +0 -87
- package/dist/chunks/generate.runtime-DEl6b1Ti.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-OjW1XETW.js.map +0 -1
- package/dist/chunks/generate.runtime-qjsxSPaH.js.map +0 -1
- package/dist/chunks/generate.runtime-vTneb2SY.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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { t as e } from "./errors-D6gyegUK.js";
|
|
2
|
+
import { i as t } from "./util-BLYliuUK.js";
|
|
3
|
+
//#region src/core/providers.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
return e.replace(/^enable-/, "");
|
|
6
|
+
}
|
|
7
|
+
function r(e) {
|
|
8
|
+
for (let t = 0; t < e.length; t++) {
|
|
9
|
+
let n = e[t];
|
|
10
|
+
if (n === "--provider") return e[t + 1];
|
|
11
|
+
if (n.startsWith("--provider=")) return n.slice(11);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function i(e, t, n) {
|
|
15
|
+
return [
|
|
16
|
+
`Unknown provider "${t}" for ${e}.`,
|
|
17
|
+
"",
|
|
18
|
+
"Available providers:",
|
|
19
|
+
...n.map((e) => ` ${e.id}`)
|
|
20
|
+
].join("\n");
|
|
21
|
+
}
|
|
22
|
+
function a(e) {
|
|
23
|
+
return `--provider <${e.map((e) => e.id).join("|")}>`;
|
|
24
|
+
}
|
|
25
|
+
function o(t, o) {
|
|
26
|
+
let s = t.providers ?? [], c = n(t.slug);
|
|
27
|
+
if (s.length === 0) throw Error(`${t.slug} declares no providers.`);
|
|
28
|
+
let l = typeof o.input.provider == "string" ? o.input.provider : r(o.argv);
|
|
29
|
+
if (l === void 0 || l === "") {
|
|
30
|
+
if (o.env === "preview") return s[0];
|
|
31
|
+
throw new e(`Choose a provider for ${c}: ${a(s)}`);
|
|
32
|
+
}
|
|
33
|
+
let u = s.find((e) => e.id === l);
|
|
34
|
+
if (!u) throw new e(i(c, l, s));
|
|
35
|
+
return u;
|
|
36
|
+
}
|
|
37
|
+
function s(e, t, n = {}) {
|
|
38
|
+
return [{
|
|
39
|
+
type: "comment",
|
|
40
|
+
key: t
|
|
41
|
+
}, ...(e.env ?? []).map((e) => ({
|
|
42
|
+
type: "var",
|
|
43
|
+
key: e.key,
|
|
44
|
+
value: n[e.key]?.trim() || e.default || ""
|
|
45
|
+
}))];
|
|
46
|
+
}
|
|
47
|
+
function c(e) {
|
|
48
|
+
let t = e.input.providerEnv;
|
|
49
|
+
if (!t || typeof t != "object") return {};
|
|
50
|
+
let n = {};
|
|
51
|
+
for (let [e, r] of Object.entries(t)) typeof r == "string" && (n[e] = r);
|
|
52
|
+
return n;
|
|
53
|
+
}
|
|
54
|
+
function l(e) {
|
|
55
|
+
let t = /* @__PURE__ */ new Set();
|
|
56
|
+
for (let n of Object.keys(e)) {
|
|
57
|
+
let e = n.match(/\/providers\/[^/]+\/(.+)$/);
|
|
58
|
+
e && t.add(e[1]);
|
|
59
|
+
}
|
|
60
|
+
return [...t].sort();
|
|
61
|
+
}
|
|
62
|
+
function u(e, n) {
|
|
63
|
+
let r = t(e, `./providers/${n}/`);
|
|
64
|
+
return Object.values(r).sort((e, t) => e.path.localeCompare(t.path));
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { o as a, r as i, u as n, c as o, s as r, i as s, l as t };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=providers-DO9kMyzB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers-DO9kMyzB.js","names":[],"sources":["../../src/core/providers.ts"],"sourcesContent":["import type { EnvEdit } from \"../runtime/env\";\nimport { InvalidArgumentError } from \"./errors\";\nimport type { File, Options, Pattern, Provider } from \"./types\";\nimport { filesUnderPrefix } from \"./util\";\n\ntype ProviderPattern = Pick<Pattern, \"slug\" | \"providers\">;\n\n/** `analytics` for `enable-analytics`: how the capability is named to users. */\nexport function capabilityName(slug: string): string {\n return slug.replace(/^enable-/, \"\");\n}\n\n/** `--provider <id>` or `--provider=<id>`, for callers that hand flags through in argv. */\nexport function providerFromArgv(argv: string[]): string | undefined {\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i];\n if (arg === \"--provider\") return argv[i + 1];\n if (arg.startsWith(\"--provider=\")) return arg.slice(\"--provider=\".length);\n }\n return undefined;\n}\n\nexport function unknownProviderMessage(\n name: string,\n raw: string,\n providers: Provider[],\n): string {\n return [\n `Unknown provider \"${raw}\" for ${name}.`,\n \"\",\n \"Available providers:\",\n ...providers.map((provider) => ` ${provider.id}`),\n ].join(\"\\n\");\n}\n\nexport function providerChoices(providers: Provider[]): string {\n return `--provider <${providers.map((provider) => provider.id).join(\"|\")}>`;\n}\n\n/**\n * The provider a generate call should produce, from `input.provider` or\n * `--provider` in argv.\n *\n * An unknown id is rejected with the list of known ones. With no provider at\n * all, a runtime call is rejected too: the CLI always supplies one, so this\n * is a caller bug. A preview call falls back to the first declared provider,\n * because the website loads patterns with argv only.\n */\nexport function resolveProvider(\n pattern: ProviderPattern,\n options: Pick<Options, \"input\" | \"argv\" | \"env\">,\n): Provider {\n const providers = pattern.providers ?? [];\n const name = capabilityName(pattern.slug);\n if (providers.length === 0) {\n throw new Error(`${pattern.slug} declares no providers.`);\n }\n\n const raw =\n typeof options.input.provider === \"string\"\n ? options.input.provider\n : providerFromArgv(options.argv);\n\n if (raw === undefined || raw === \"\") {\n if (options.env === \"preview\") return providers[0];\n throw new InvalidArgumentError(\n `Choose a provider for ${name}: ${providerChoices(providers)}`,\n );\n }\n\n const provider = providers.find((candidate) => candidate.id === raw);\n if (!provider) {\n throw new InvalidArgumentError(\n unknownProviderMessage(name, raw, providers),\n );\n }\n return provider;\n}\n\n/**\n * The `.env` lines for a provider: `# heading`, then one `KEY=value` per\n * declared env var. `supplied` holds what the CLI collected; a blank value\n * falls back to the provider's default, else an empty assignment the\n * developer fills in later. Prompt placeholders are never written.\n */\nexport function providerEnvEdits(\n provider: Provider,\n heading: string,\n supplied: Record<string, string> = {},\n): EnvEdit[] {\n return [\n { type: \"comment\", key: heading },\n ...(provider.env ?? []).map((variable): EnvEdit => ({\n type: \"var\",\n key: variable.key,\n value: supplied[variable.key]?.trim() || variable.default || \"\",\n })),\n ];\n}\n\n/** The string values of `input.providerEnv`, as the CLI collected them. */\nexport function suppliedProviderEnv(\n options: Pick<Options, \"input\">,\n): Record<string, string> {\n const raw = options.input.providerEnv;\n if (!raw || typeof raw !== \"object\") return {};\n const values: Record<string, string> = {};\n for (const [key, value] of Object.entries(raw)) {\n if (typeof value === \"string\") values[key] = value;\n }\n return values;\n}\n\n/**\n * Every app-relative path any provider creates, sorted, for a disable pattern\n * that removes the files whichever provider was chosen. Works on a glob taken\n * from anywhere (`../../enable/<x>/providers/**`): only the part after\n * `providers/<id>/` counts.\n */\nexport function allProviderPaths(\n providersRaw: Record<string, string>,\n): string[] {\n const paths = new Set<string>();\n for (const key of Object.keys(providersRaw)) {\n const match = key.match(/\\/providers\\/[^/]+\\/(.+)$/);\n if (match) paths.add(match[1]);\n }\n return [...paths].sort();\n}\n\n/**\n * The files under `providers/<id>/**` of a pattern, as creates. The glob map\n * is one `import.meta.glob(\"./providers/**\")` covering every provider.\n */\nexport function providerCreates(\n providersRaw: Record<string, string>,\n id: string,\n): File[] {\n const files = filesUnderPrefix(providersRaw, `./providers/${id}/`);\n return Object.values(files).sort((a, b) => a.path.localeCompare(b.path));\n}\n"],"mappings":";;;AAQA,SAAgB,EAAe,GAAsB;CACnD,OAAO,EAAK,QAAQ,YAAY,EAAE;AACpC;AAGA,SAAgB,EAAiB,GAAoC;CACnE,KAAK,IAAI,IAAI,GAAG,IAAI,EAAK,QAAQ,KAAK;EACpC,IAAM,IAAM,EAAK;EACjB,IAAI,MAAQ,cAAc,OAAO,EAAK,IAAI;EAC1C,IAAI,EAAI,WAAW,aAAa,GAAG,OAAO,EAAI,MAAM,EAAoB;CAC1E;AAEF;AAEA,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C;CACxC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAG,GAC3C,AAAI,OAAO,KAAU,aAAU,EAAO,KAAO;CAE/C,OAAO;AACT;AAQA,SAAgB,EACd,GACU;CACV,IAAM,oBAAQ,IAAI,IAAY;CAC9B,KAAK,IAAM,KAAO,OAAO,KAAK,CAAY,GAAG;EAC3C,IAAM,IAAQ,EAAI,MAAM,2BAA2B;EACnD,AAAI,KAAO,EAAM,IAAI,EAAM,EAAE;CAC/B;CACA,OAAO,CAAC,GAAG,CAAK,CAAC,CAAC,KAAK;AACzB;AAMA,SAAgB,EACd,GACA,GACQ;CACR,IAAM,IAAQ,EAAiB,GAAc,eAAe,EAAG,EAAE;CACjE,OAAO,OAAO,OAAO,CAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AACzE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in e) t(r, i, {
|
|
5
|
+
get: e[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, c = (e, i, o, s) => {
|
|
10
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
+
get: ((e) => i[e]).bind(null, d),
|
|
12
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
+
});
|
|
14
|
+
return e;
|
|
15
|
+
}, l = (n, r, o) => (o = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
|
|
16
|
+
value: n,
|
|
17
|
+
enumerable: !0
|
|
18
|
+
}) : o, n)), u = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
19
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
20
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
21
|
+
});
|
|
22
|
+
//#endregion
|
|
23
|
+
export { l as i, s as n, u as r, o as t };
|
|
@@ -15,7 +15,7 @@ async function n(e, t) {
|
|
|
15
15
|
exists: !0,
|
|
16
16
|
rowCount: 0
|
|
17
17
|
}));
|
|
18
|
-
let { withPocketbase: n } = await import("./pocketbase-
|
|
18
|
+
let { withPocketbase: n } = await import("./pocketbase-CeG5BMN2.js").then((e) => e.r), { planCollectionDrops: r } = await import("./collections-CgdvZXmh.js"), i = [];
|
|
19
19
|
return await n(t.root, async (t) => {
|
|
20
20
|
let n = await r(t, e);
|
|
21
21
|
i.push(...n);
|
|
@@ -24,4 +24,4 @@ async function n(e, t) {
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { t as n, n as t };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=shared-
|
|
27
|
+
//# sourceMappingURL=shared-BwHQM-a9.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-BwHQM-a9.js","names":[],"sources":["../../src/patterns/destroy/shared.ts"],"sourcesContent":["import type { CollectionDropSpec, File, Options } from \"../../core/types\";\nimport { languageFromPath } from \"../../core/util\";\n\nexport function toDeleteEntry(path: string): File {\n return {\n path,\n language: languageFromPath(path),\n content: \"\",\n status: \"success\",\n };\n}\n\n/**\n * Build `CollectionDropSpec` entries for each collection name, with live row\n * counts from PocketBase when `env === \"runtime\"`. In preview mode, returns\n * `{ exists: true, rowCount: 0 }` placeholders.\n */\nexport async function planDropsForCollections(\n collectionNames: string[],\n options: Options,\n): Promise<CollectionDropSpec[]> {\n if (collectionNames.length === 0) return [];\n\n if (options.env !== \"runtime\") {\n return collectionNames.map((name) => ({\n name,\n exists: true,\n rowCount: 0,\n }));\n }\n\n const { withPocketbase } = await import(\"../../runtime/pocketbase\");\n const { planCollectionDrops } = await import(\"../../runtime/collections\");\n const drops: CollectionDropSpec[] = [];\n await withPocketbase(options.root, async (pb) => {\n const plans = await planCollectionDrops(pb, collectionNames);\n drops.push(...plans);\n });\n return drops;\n}\n"],"mappings":";;AAGA,SAAgB,EAAc,GAAoB;CAChD,OAAO;EACL;EACA,UAAU,EAAiB,CAAI;EAC/B,SAAS;EACT,QAAQ;CACV;AACF;AAOA,eAAsB,EACpB,GACA,GAC+B;CAC/B,IAAI,EAAgB,WAAW,GAAG,OAAO,CAAC;CAE1C,IAAI,EAAQ,QAAQ,WAClB,OAAO,EAAgB,KAAK,OAAU;EACpC;EACA,QAAQ;EACR,UAAU;CACZ,EAAE;CAGJ,IAAM,EAAE,sBAAmB,MAAM,OAAO,2BAAA,CAAA,MAAA,MAAA,EAAA,CAAA,GAClC,EAAE,2BAAwB,MAAM,OAAO,8BACvC,IAA8B,CAAC;CAKrC,OAJA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAM,IAAQ,MAAM,EAAoB,GAAI,CAAe;EAC3D,EAAM,KAAK,GAAG,CAAK;CACrB,CAAC,GACM;AACT"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { a as e } from "./util-BLYliuUK.js";
|
|
2
|
+
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
+
import { i as n } from "./pocketbase-CeG5BMN2.js";
|
|
4
|
+
import r from "node:fs";
|
|
5
|
+
import i from "node:path";
|
|
6
|
+
//#region src/runtime/site.ts
|
|
7
|
+
function a(e) {
|
|
8
|
+
return i.join(e, "src", "lib", "site.ts");
|
|
9
|
+
}
|
|
10
|
+
function o(e, t = "http://localhost:5173") {
|
|
11
|
+
return [
|
|
12
|
+
"/**",
|
|
13
|
+
" * Site-wide metadata, and the one place the app's name and public URL live.",
|
|
14
|
+
" *",
|
|
15
|
+
" * Set `url` to where the site is deployed: canonical links, Open Graph images",
|
|
16
|
+
" * and feeds are built from it, including in prerendered pages. With a backend,",
|
|
17
|
+
" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name",
|
|
18
|
+
" * for the emails it sends, so change it here rather than in the admin panel.",
|
|
19
|
+
" */",
|
|
20
|
+
"export const site = {",
|
|
21
|
+
`\tname: ${s(e)},`,
|
|
22
|
+
`\turl: ${s(t)}`,
|
|
23
|
+
"};",
|
|
24
|
+
""
|
|
25
|
+
].join("\n");
|
|
26
|
+
}
|
|
27
|
+
function s(e) {
|
|
28
|
+
return `'${e.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
29
|
+
}
|
|
30
|
+
async function c(e) {
|
|
31
|
+
if (e.features.backend) try {
|
|
32
|
+
let t;
|
|
33
|
+
if (await n(e.root, async (e) => {
|
|
34
|
+
t = (await e.settings.getAll()).meta?.appName;
|
|
35
|
+
}), typeof t == "string" && t.trim()) return t;
|
|
36
|
+
} catch {}
|
|
37
|
+
try {
|
|
38
|
+
let t = JSON.parse(r.readFileSync(i.join(e.root, "package.json"), "utf8"));
|
|
39
|
+
if (typeof t.name == "string" && t.name.trim()) return t.name;
|
|
40
|
+
} catch {}
|
|
41
|
+
return "My App";
|
|
42
|
+
}
|
|
43
|
+
async function l(n) {
|
|
44
|
+
let i = a(n.root);
|
|
45
|
+
return r.existsSync(i) ? null : (t(n).info("Creating src/lib/site.ts"), {
|
|
46
|
+
path: i,
|
|
47
|
+
language: e(i),
|
|
48
|
+
content: o(await c(n)),
|
|
49
|
+
status: "success"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { l as t };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=site-D027dpBm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-D027dpBm.js","names":[],"sources":["../../src/runtime/site.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 { languageFromPath } from \"../core/util\";\nimport { withPocketbase } from \"./pocketbase\";\n\n/** Where every VelaStack app keeps its name and public URL. */\nexport function sitePath(root: string): string {\n return path.join(root, \"src\", \"lib\", \"site.ts\");\n}\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n): string {\n return [\n \"/**\",\n \" * Site-wide metadata, and the one place the app's name and public URL live.\",\n \" *\",\n \" * Set `url` to where the site is deployed: canonical links, Open Graph images\",\n \" * and feeds are built from it, including in prerendered pages. With a backend,\",\n \" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name\",\n \" * for the emails it sends, so change it here rather than in the admin panel.\",\n \" */\",\n \"export const site = {\",\n `\\tname: ${quote(name)},`,\n `\\turl: ${quote(url)}`,\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\n/** Single-quoted, as the templates write their strings. */\nfunction quote(value: string): string {\n return `'${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")}'`;\n}\n\n/**\n * The name a project created before `site.ts` existed already goes by.\n *\n * Those projects kept it in PocketBase's settings, so that is asked first; the\n * package name is the fallback for a project without a backend, or one whose\n * database can't be reached.\n */\nasync function existingName(options: Options): Promise<string> {\n if (options.features.backend) {\n try {\n let appName: unknown;\n await withPocketbase(options.root, async (pb) => {\n const settings = (await pb.settings.getAll()) as {\n meta?: { appName?: unknown };\n };\n appName = settings.meta?.appName;\n });\n if (typeof appName === \"string\" && appName.trim()) return appName;\n } catch {\n // No database to ask; fall through to package.json.\n }\n }\n\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(options.root, \"package.json\"), \"utf8\"),\n ) as { name?: unknown };\n if (typeof pkg.name === \"string\" && pkg.name.trim()) return pkg.name;\n } catch {\n // No package.json to name the site after; the placeholder stands.\n }\n return \"My App\";\n}\n\n/**\n * Create `src/lib/site.ts` for a pattern whose files import `$lib/site`, when\n * the project doesn't have one yet. Every template ships it; projects created\n * before that read the app name from `locals.meta` instead.\n *\n * Returns null when the file exists, so an existing one is never overwritten.\n */\nexport async function ensureSiteFile(options: Options): Promise<File | null> {\n const file = sitePath(options.root);\n if (fs.existsSync(file)) return null;\n\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options)),\n status: \"success\",\n };\n}\n"],"mappings":";;;;;;AAQA,SAAgB,EAAS,GAAsB;CAC7C,OAAO,EAAK,KAAK,GAAM,OAAO,OAAO,SAAS;AAChD;AAMA,SAAgB,EACd,GACA,IAAM,yBACE;CACR,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW,EAAM,CAAI,EAAE;EACvB,UAAU,EAAM,CAAG;EACnB;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAGA,SAAS,EAAM,GAAuB;CACpC,OAAO,IAAI,EAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,KAAK,EAAE;AAC/D;AASA,eAAe,EAAa,GAAmC;CAC7D,IAAI,EAAQ,SAAS,SACnB,IAAI;EACF,IAAI;EAOJ,IANA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;GAI/C,KAAU,MAHc,EAAG,SAAS,OAAO,EAAA,CAGxB,MAAM;EAC3B,CAAC,GACG,OAAO,KAAY,YAAY,EAAQ,KAAK,GAAG,OAAO;CAC5D,QAAQ,CAER;CAGF,IAAI;EACF,IAAM,IAAM,KAAK,MACf,EAAG,aAAa,EAAK,KAAK,EAAQ,MAAM,cAAc,GAAG,MAAM,CACjE;EACA,IAAI,OAAO,EAAI,QAAS,YAAY,EAAI,KAAK,KAAK,GAAG,OAAO,EAAI;CAClE,QAAQ,CAER;CACA,OAAO;AACT;AASA,eAAsB,EAAe,GAAwC;CAC3E,IAAM,IAAO,EAAS,EAAQ,IAAI;CAIlC,OAHI,EAAG,WAAW,CAAI,IAAU,QAEhC,EAAU,CAAO,CAAC,CAAC,KAAK,0BAA0B,GAC3C;EACL,MAAM;EACN,UAAU,EAAiB,CAAI;EAC/B,SAAS,EAAW,MAAM,EAAa,CAAO,CAAC;EAC/C,QAAQ;CACV;AACF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import e from "node:fs";
|
|
2
|
+
import { parse as t } from "svelte/compiler";
|
|
3
|
+
import n from "magic-string";
|
|
4
|
+
//#region src/runtime/svelte-file.ts
|
|
5
|
+
var r = class r {
|
|
6
|
+
constructor(e) {
|
|
7
|
+
this.source = e, this.ast = t(e, { modern: !0 }), this.s = new n(e);
|
|
8
|
+
}
|
|
9
|
+
static fromPath(t) {
|
|
10
|
+
return new r(e.readFileSync(t, "utf8"));
|
|
11
|
+
}
|
|
12
|
+
getScript() {
|
|
13
|
+
return this.scriptInner(this.ast.instance);
|
|
14
|
+
}
|
|
15
|
+
getModuleScript() {
|
|
16
|
+
return this.scriptInner(this.ast.module);
|
|
17
|
+
}
|
|
18
|
+
scriptInner(e) {
|
|
19
|
+
if (!e) return null;
|
|
20
|
+
let t = e.content.start, n = e.content.end;
|
|
21
|
+
return {
|
|
22
|
+
content: this.source.slice(t, n),
|
|
23
|
+
start: t,
|
|
24
|
+
end: n
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
modifyScript(e) {
|
|
28
|
+
return this.modifyScriptBlock(this.getScript(), e);
|
|
29
|
+
}
|
|
30
|
+
modifyModuleScript(e) {
|
|
31
|
+
return this.modifyScriptBlock(this.getModuleScript(), e);
|
|
32
|
+
}
|
|
33
|
+
modifyScriptBlock(e, t) {
|
|
34
|
+
if (!e) return !1;
|
|
35
|
+
let n = t(e.content);
|
|
36
|
+
return n !== e.content && (this.s.overwrite(e.start, e.end, n), !0);
|
|
37
|
+
}
|
|
38
|
+
findElement(e) {
|
|
39
|
+
return i(this.ast.fragment, (t) => (t.type === "Component" || t.type === "RegularElement") && t.name === e);
|
|
40
|
+
}
|
|
41
|
+
hasElement(e) {
|
|
42
|
+
return this.findElement(e) !== null;
|
|
43
|
+
}
|
|
44
|
+
hasAttribute(e, t) {
|
|
45
|
+
let n = this.findElement(e);
|
|
46
|
+
return n ? (n.attributes ?? []).some((e) => e.type === "Attribute" && e.name === t) : !1;
|
|
47
|
+
}
|
|
48
|
+
insertBeforeClosingTag(e, t) {
|
|
49
|
+
let n = this.findElement(e);
|
|
50
|
+
if (!n) return !1;
|
|
51
|
+
let r = `</${e}>`, i = this.source.lastIndexOf(r, n.end);
|
|
52
|
+
return i !== -1 && (this.s.appendLeft(i, t), !0);
|
|
53
|
+
}
|
|
54
|
+
replaceElement(e, t) {
|
|
55
|
+
let n = this.findElement(e);
|
|
56
|
+
return n ? (this.s.overwrite(n.start, n.end, t), !0) : !1;
|
|
57
|
+
}
|
|
58
|
+
removeElement(e) {
|
|
59
|
+
return this.replaceElement(e, "");
|
|
60
|
+
}
|
|
61
|
+
appendMarkup(e) {
|
|
62
|
+
this.s.append(e);
|
|
63
|
+
}
|
|
64
|
+
insertBeforeChildren(e) {
|
|
65
|
+
let t = this.ast.fragment?.nodes ?? [], n = t.findIndex((e) => e.type === "RenderTag" || e.type === "SlotElement" || e.type === "RegularElement" && e.name === "slot");
|
|
66
|
+
if (n === -1) return !1;
|
|
67
|
+
let r = e.trim();
|
|
68
|
+
for (let e = n - 1; e >= 0; e--) {
|
|
69
|
+
let n = t[e];
|
|
70
|
+
if (n.type !== "Text" || n.data.trim() !== "") return this.s.appendLeft(n.end, `\n${r}`), !0;
|
|
71
|
+
}
|
|
72
|
+
return this.s.appendLeft(t[n].start, `${r}\n\n`), !0;
|
|
73
|
+
}
|
|
74
|
+
appendToAttributes(e, t) {
|
|
75
|
+
let n = this.findElement(e);
|
|
76
|
+
if (!n) return !1;
|
|
77
|
+
let r = (n.attributes ?? []).at(-1), i = r ? r.end : n.start + `<${e}`.length;
|
|
78
|
+
return this.s.appendLeft(i, t), !0;
|
|
79
|
+
}
|
|
80
|
+
removeAttribute(e, t) {
|
|
81
|
+
let n = this.findElement(e);
|
|
82
|
+
if (!n) return !1;
|
|
83
|
+
let r = (n.attributes ?? []).find((e) => e.type === "Attribute" && e.name === t);
|
|
84
|
+
if (!r) return !1;
|
|
85
|
+
let i = r.start;
|
|
86
|
+
for (; i > 0 && /\s/.test(this.source[i - 1]);) i--;
|
|
87
|
+
return this.s.remove(i, r.end), !0;
|
|
88
|
+
}
|
|
89
|
+
hasChanged() {
|
|
90
|
+
return this.s.hasChanged();
|
|
91
|
+
}
|
|
92
|
+
toString() {
|
|
93
|
+
return this.s.toString();
|
|
94
|
+
}
|
|
95
|
+
writeTo(t) {
|
|
96
|
+
this.hasChanged() && e.writeFileSync(t, this.toString(), "utf8");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function i(e, t) {
|
|
100
|
+
let n = /* @__PURE__ */ new WeakSet();
|
|
101
|
+
function r(e) {
|
|
102
|
+
if (!e || typeof e != "object" || n.has(e)) return null;
|
|
103
|
+
if (n.add(e), t(e)) return e;
|
|
104
|
+
for (let t of Object.keys(e)) {
|
|
105
|
+
if (t === "parent") continue;
|
|
106
|
+
let n = e[t];
|
|
107
|
+
if (Array.isArray(n)) for (let e of n) {
|
|
108
|
+
let t = r(e);
|
|
109
|
+
if (t) return t;
|
|
110
|
+
}
|
|
111
|
+
else if (n && typeof n == "object" && "type" in n) {
|
|
112
|
+
let e = r(n);
|
|
113
|
+
if (e) return e;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
return r(e);
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { r as t };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=svelte-file-B3RfgVdt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte-file-B3RfgVdt.js","names":[],"sources":["../../src/runtime/svelte-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { parse, type AST } from \"svelte/compiler\";\nimport MagicString from \"magic-string\";\n\ntype SvelteAst = AST.Root;\ntype SvelteNode = any;\n\ninterface ScriptBlock {\n content: string;\n start: number;\n end: number;\n}\n\n/**\n * Surgical, AST-aware editing of .svelte files.\n *\n * Parses the source with svelte/compiler to discover precise character offsets,\n * then applies edits via magic-string so untouched regions remain byte-for-byte\n * identical to the original. Script-block contents are exposed as plain strings\n * so callers can hand them to ts-morph.\n */\nexport class SvelteFile {\n private readonly source: string;\n private readonly ast: SvelteAst;\n private readonly s: MagicString;\n\n constructor(source: string) {\n this.source = source;\n this.ast = parse(source, { modern: true });\n this.s = new MagicString(source);\n }\n\n static fromPath(filePath: string): SvelteFile {\n return new SvelteFile(fs.readFileSync(filePath, \"utf8\"));\n }\n\n getScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).instance);\n }\n\n getModuleScript(): ScriptBlock | null {\n return this.scriptInner((this.ast as any).module);\n }\n\n private scriptInner(script: SvelteNode | null): ScriptBlock | null {\n if (!script) return null;\n const start = script.content.start as number;\n const end = script.content.end as number;\n return { content: this.source.slice(start, end), start, end };\n }\n\n /**\n * Replace the inner contents of <script>. Use for ts-morph round-trips.\n * Returns true when an edit was made.\n */\n modifyScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getScript(), fn);\n }\n\n modifyModuleScript(fn: (content: string) => string): boolean {\n return this.modifyScriptBlock(this.getModuleScript(), fn);\n }\n\n private modifyScriptBlock(\n block: ScriptBlock | null,\n fn: (content: string) => string,\n ): boolean {\n if (!block) return false;\n const next = fn(block.content);\n if (next === block.content) return false;\n this.s.overwrite(block.start, block.end, next);\n return true;\n }\n\n /** First Component or RegularElement node with the given name. */\n findElement(name: string): SvelteNode | null {\n return findNode(\n (this.ast as any).fragment,\n (node) =>\n (node.type === \"Component\" || node.type === \"RegularElement\") &&\n node.name === name,\n );\n }\n\n hasElement(name: string): boolean {\n return this.findElement(name) !== null;\n }\n\n hasAttribute(componentName: string, attrName: string): boolean {\n const node = this.findElement(componentName);\n if (!node) return false;\n return (node.attributes ?? []).some(\n (attr: SvelteNode) => attr.type === \"Attribute\" && attr.name === attrName,\n );\n }\n\n /**\n * Insert content at the end of <ComponentName>'s children, just before the\n * closing tag. No-op if the element is not found.\n */\n insertBeforeClosingTag(name: string, content: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const closingTag = `</${name}>`;\n const closingPos = this.source.lastIndexOf(closingTag, node.end);\n if (closingPos === -1) return false;\n this.s.appendLeft(closingPos, content);\n return true;\n }\n\n /** Replace the element entirely (start tag through close tag). */\n replaceElement(name: string, newContent: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n this.s.overwrite(node.start, node.end, newContent);\n return true;\n }\n\n /** Remove the element (start tag through close tag). */\n removeElement(name: string): boolean {\n return this.replaceElement(name, \"\");\n }\n\n /** Append raw markup to the end of the source file. */\n appendMarkup(content: string): void {\n this.s.append(content);\n }\n\n /**\n * Insert markup so it renders before the layout's children — i.e. ahead of\n * the top-level `{@render children()}` (or legacy `<slot />`). The markup\n * lands on its own line directly after the preceding sibling, so\n *\n * <Toaster />\n *\n * {@render children?.()}\n *\n * becomes `<Toaster />\\n<AdminBar />\\n\\n{@render children?.()}`. When the\n * render tag is the first node the markup goes immediately before it.\n * Returns false (and changes nothing) if no such tag exists.\n */\n insertBeforeChildren(content: string): boolean {\n const nodes: SvelteNode[] = (this.ast as any).fragment?.nodes ?? [];\n const index = nodes.findIndex(\n (node) =>\n node.type === \"RenderTag\" ||\n node.type === \"SlotElement\" ||\n (node.type === \"RegularElement\" && node.name === \"slot\"),\n );\n if (index === -1) return false;\n\n const trimmed = content.trim();\n for (let i = index - 1; i >= 0; i--) {\n const prev = nodes[i]!;\n if (prev.type === \"Text\" && prev.data.trim() === \"\") continue;\n this.s.appendLeft(prev.end as number, `\\n${trimmed}`);\n return true;\n }\n this.s.appendLeft(nodes[index]!.start as number, `${trimmed}\\n\\n`);\n return true;\n }\n\n /**\n * Append attribute text (e.g. \" team={data.team}\") just after the last\n * existing attribute on the element's start tag.\n */\n appendToAttributes(name: string, attrs: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const last = (node.attributes ?? []).at(-1) as SvelteNode | undefined;\n const insertAt = last\n ? (last.end as number)\n : (node.start as number) + `<${name}`.length;\n this.s.appendLeft(insertAt, attrs);\n return true;\n }\n\n /**\n * Remove a named attribute from a component's start tag, including the\n * leading whitespace. No-op if the element or attribute isn't present.\n */\n removeAttribute(name: string, attrName: string): boolean {\n const node = this.findElement(name);\n if (!node) return false;\n const attr = (node.attributes ?? []).find(\n (a: SvelteNode) => a.type === \"Attribute\" && a.name === attrName,\n );\n if (!attr) return false;\n // Extend the removal backwards over the whitespace between the previous\n // token and this attribute so the tag doesn't collapse `<Foo />`.\n let start = attr.start as number;\n while (start > 0 && /\\s/.test(this.source[start - 1]!)) start--;\n this.s.remove(start, attr.end as number);\n return true;\n }\n\n hasChanged(): boolean {\n return this.s.hasChanged();\n }\n\n toString(): string {\n return this.s.toString();\n }\n\n writeTo(filePath: string): void {\n if (this.hasChanged()) {\n fs.writeFileSync(filePath, this.toString(), \"utf8\");\n }\n }\n}\n\nfunction findNode(\n root: unknown,\n predicate: (node: any) => boolean,\n): any | null {\n const seen = new WeakSet<object>();\n function visit(node: unknown): any | null {\n if (!node || typeof node !== \"object\" || seen.has(node as object)) {\n return null;\n }\n seen.add(node as object);\n if (predicate(node as any)) return node;\n for (const key of Object.keys(node as Record<string, unknown>)) {\n if (key === \"parent\") continue;\n const child = (node as Record<string, unknown>)[key];\n if (Array.isArray(child)) {\n for (const item of child) {\n const found = visit(item);\n if (found) return found;\n }\n } else if (\n child &&\n typeof child === \"object\" &&\n \"type\" in (child as object)\n ) {\n const found = visit(child);\n if (found) return found;\n }\n }\n return null;\n }\n return visit(root);\n}\n"],"mappings":";;;;AAqBA,IAAa,IAAb,MAAa,EAAW;CAKtB,YAAY,GAAgB;EAG1B,AAFA,KAAK,SAAS,GACd,KAAK,MAAM,EAAM,GAAQ,EAAE,QAAQ,GAAK,CAAC,GACzC,KAAK,IAAI,IAAI,EAAY,CAAM;CACjC;CAEA,OAAO,SAAS,GAA8B;EAC5C,OAAO,IAAI,EAAW,EAAG,aAAa,GAAU,MAAM,CAAC;CACzD;CAEA,YAAgC;EAC9B,OAAO,KAAK,YAAa,KAAK,IAAY,QAAQ;CACpD;CAEA,kBAAsC;EACpC,OAAO,KAAK,YAAa,KAAK,IAAY,MAAM;CAClD;CAEA,YAAoB,GAA+C;EACjE,IAAI,CAAC,GAAQ,OAAO;EACpB,IAAM,IAAQ,EAAO,QAAQ,OACvB,IAAM,EAAO,QAAQ;EAC3B,OAAO;GAAE,SAAS,KAAK,OAAO,MAAM,GAAO,CAAG;GAAG;GAAO;EAAI;CAC9D;CAMA,aAAa,GAA0C;EACrD,OAAO,KAAK,kBAAkB,KAAK,UAAU,GAAG,CAAE;CACpD;CAEA,mBAAmB,GAA0C;EAC3D,OAAO,KAAK,kBAAkB,KAAK,gBAAgB,GAAG,CAAE;CAC1D;CAEA,kBACE,GACA,GACS;EACT,IAAI,CAAC,GAAO,OAAO;EACnB,IAAM,IAAO,EAAG,EAAM,OAAO;EAG7B,OAFI,MAAS,EAAM,YACnB,KAAK,EAAE,UAAU,EAAM,OAAO,EAAM,KAAK,CAAI,GACtC;CACT;CAGA,YAAY,GAAiC;EAC3C,OAAO,EACJ,KAAK,IAAY,WACjB,OACE,EAAK,SAAS,eAAe,EAAK,SAAS,qBAC5C,EAAK,SAAS,CAClB;CACF;CAEA,WAAW,GAAuB;EAChC,OAAO,KAAK,YAAY,CAAI,MAAM;CACpC;CAEA,aAAa,GA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GACpB;QACK,IACL,KACA,OAAO,KAAU,YACjB,UAAW,GACX;IACA,IAAM,IAAQ,EAAM,CAAK;IACzB,IAAI,GAAO,OAAO;GACpB;EACF;EACA,OAAO;CACT;CACA,OAAO,EAAM,CAAI;AACnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
-
import { o as t, s as n } from "./config-target-
|
|
3
|
-
import r from "node:
|
|
4
|
-
import i from "node:
|
|
2
|
+
import { o as t, s as n } from "./config-target-Co-ij8p3.js";
|
|
3
|
+
import r from "node:fs";
|
|
4
|
+
import i from "node:path";
|
|
5
5
|
import { SyntaxKind as a } from "ts-morph";
|
|
6
6
|
//#region src/patterns/enable/backend/modifies/svelte-config.ts
|
|
7
7
|
var o = "@sveltejs/adapter-node", s = "@sveltejs/adapter-static", c = "@sveltejs/adapter-auto", l = e`
|
|
@@ -93,27 +93,27 @@ var h = "# PocketBase\n/data/*\n!/data/fixtures\n!/data/seeds\n!/data/hooks\n",
|
|
|
93
93
|
!/data/hooks
|
|
94
94
|
`;
|
|
95
95
|
function _(e) {
|
|
96
|
-
if (!
|
|
96
|
+
if (!r.existsSync(e)) return {
|
|
97
97
|
status: "not-found",
|
|
98
98
|
message: g
|
|
99
99
|
};
|
|
100
|
-
let t =
|
|
100
|
+
let t = r.readFileSync(e, "utf8");
|
|
101
101
|
if (t.includes("# PocketBase") && t.includes("/data/*")) return {
|
|
102
102
|
status: "success",
|
|
103
103
|
changed: !1
|
|
104
104
|
};
|
|
105
105
|
let n = t + (t.endsWith("\n") ? "\n" : "\n\n") + h;
|
|
106
|
-
return
|
|
106
|
+
return r.writeFileSync(e, n, "utf8"), {
|
|
107
107
|
status: "success",
|
|
108
108
|
changed: !0
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
function v(e) {
|
|
112
|
-
if (!
|
|
112
|
+
if (!r.existsSync(e)) return {
|
|
113
113
|
status: "success",
|
|
114
114
|
changed: !1
|
|
115
115
|
};
|
|
116
|
-
let t =
|
|
116
|
+
let t = r.readFileSync(e, "utf8");
|
|
117
117
|
if (!t.includes("# PocketBase")) return {
|
|
118
118
|
status: "success",
|
|
119
119
|
changed: !1
|
|
@@ -122,7 +122,7 @@ function v(e) {
|
|
|
122
122
|
return n === t ? {
|
|
123
123
|
status: "success",
|
|
124
124
|
changed: !1
|
|
125
|
-
} : (
|
|
125
|
+
} : (r.writeFileSync(e, n, "utf8"), {
|
|
126
126
|
status: "success",
|
|
127
127
|
changed: !0
|
|
128
128
|
});
|
|
@@ -131,22 +131,22 @@ function v(e) {
|
|
|
131
131
|
//#region src/patterns/enable/backend/modifies/test-setup.ts
|
|
132
132
|
var y = "import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase/testing';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n await agent.post('/login').type('form').send({\n type: 'password',\n email: user.email,\n password: testUserPassword\n });\n}\n\nbeforeAll(async () => {\n await admin\n // @ts-ignore\n .collection('_superusers')\n .authWithPassword(\n process.env.POCKETBASE_SUPERUSER_EMAIL!,\n process.env.POCKETBASE_SUPERUSER_PASSWORD!\n );\n});\n\nbeforeEach(async (context: TestContext) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n context.admin = admin;\n context.pb = pb;\n context.user = await context.admin.collection('users').create({\n email: `test-${Math.random().toString(36).slice(2)}@example.com`,\n password: testUserPassword,\n passwordConfirm: testUserPassword\n });\n context.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n await context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n await context.pb.authStore.clear();\n await context.admin.collection('users').delete(context.user.id);\n});\n", b = "import { beforeEach } from 'vitest';\nimport supertest from 'supertest';\n\nbeforeEach(async (context: any) => {\n context.request = supertest(process.env.VITE_TEST_URL!);\n context.agent = supertest.agent(process.env.VITE_TEST_URL!);\n});\n";
|
|
133
133
|
function x(e) {
|
|
134
|
-
return
|
|
134
|
+
return r.existsSync(e) ? r.readFileSync(e, "utf8") === y ? {
|
|
135
135
|
status: "success",
|
|
136
136
|
changed: !1
|
|
137
|
-
} : (
|
|
137
|
+
} : (r.writeFileSync(e, y, "utf8"), {
|
|
138
138
|
status: "success",
|
|
139
139
|
changed: !0
|
|
140
|
-
}) : (
|
|
140
|
+
}) : (r.mkdirSync(i.dirname(e), { recursive: !0 }), r.writeFileSync(e, y, "utf8"), {
|
|
141
141
|
status: "success",
|
|
142
142
|
changed: !0
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
function S(e) {
|
|
146
|
-
return !
|
|
146
|
+
return !r.existsSync(e) || r.readFileSync(e, "utf8") === b ? {
|
|
147
147
|
status: "success",
|
|
148
148
|
changed: !1
|
|
149
|
-
} : (
|
|
149
|
+
} : (r.writeFileSync(e, b, "utf8"), {
|
|
150
150
|
status: "success",
|
|
151
151
|
changed: !0
|
|
152
152
|
});
|
|
@@ -154,4 +154,4 @@ function S(e) {
|
|
|
154
154
|
//#endregion
|
|
155
155
|
export { p as a, v as i, S as n, m as o, _ as r, x as t };
|
|
156
156
|
|
|
157
|
-
//# sourceMappingURL=test-setup-
|
|
157
|
+
//# sourceMappingURL=test-setup-B2hd8I-s.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-setup-DjbhQYZC.js","names":[],"sources":["../../src/patterns/enable/backend/modifies/svelte-config.ts","../../src/patterns/enable/backend/modifies/gitignore.ts","../../src/patterns/enable/backend/modifies/test-setup.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\";\n\nconst ADAPTER_NODE = \"@sveltejs/adapter-node\";\nconst ADAPTER_STATIC = \"@sveltejs/adapter-static\";\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 * whichever file holds the adapter import + `adapter()` call (vite.config when\n * the project uses inline config, else svelte.config). 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 — if no config or no adapter import is found, it's a no-op success.\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 !== \"resolved\") {\n // Nothing to revert — treat missing/unparseable config as a no-op.\n return {\n filePath: res.filePath,\n outcome: { status: \"success\", changed: false },\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","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Source of truth: velastack-cli/templates/minimal/test/setup.ts\nconst WITH_BACKEND = `import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase/testing';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n\\tawait agent.post('/login').type('form').send({\n\\t\\ttype: 'password',\n\\t\\temail: user.email,\n\\t\\tpassword: testUserPassword\n\\t});\n}\n\nbeforeAll(async () => {\n\\tawait admin\n\\t\\t// @ts-ignore\n\\t\\t.collection('_superusers')\n\\t\\t.authWithPassword(\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_EMAIL!,\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_PASSWORD!\n\\t\\t);\n});\n\nbeforeEach(async (context: TestContext) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n\\tcontext.admin = admin;\n\\tcontext.pb = pb;\n\\tcontext.user = await context.admin.collection('users').create({\n\\t\\temail: \\`test-\\${Math.random().toString(36).slice(2)}@example.com\\`,\n\\t\\tpassword: testUserPassword,\n\\t\\tpasswordConfirm: testUserPassword\n\\t});\n\\tcontext.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n\\tawait context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n\\tawait context.pb.authStore.clear();\n\\tawait context.admin.collection('users').delete(context.user.id);\n});\n`;\n\n// The static template ships no test setup at all; this is the backend-free\n// subset of the minimal one, kept so existing tests keep their agents.\nconst WITHOUT_BACKEND = `import { beforeEach } from 'vitest';\nimport supertest from 'supertest';\n\nbeforeEach(async (context: any) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!);\n});\n`;\n\nexport function modifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n // The static template has no test/ directory; a backend brings server\n // tests with it, so the setup is created rather than reported missing.\n fs.mkdirSync(path.dirname(testSetupPath), { recursive: true });\n fs.writeFileSync(testSetupPath, WITH_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITH_BACKEND) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(testSetupPath, WITH_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\nexport function unmodifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITHOUT_BACKEND) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(testSetupPath, WITHOUT_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;;;AASA,IAAM,IAAe,0BACf,IAAiB,4BACjB,IAAe,0BAEf,IAAe,CAAM;oCACS,EAAa;;yBAExB,EAAa;;;;GAMhC,IAAiB,CAAM;cACf,EAAa;;AAQ3B,SAAS,EAAkB,GAAwC;CACjE,OAAO,EACJ,sBAAsB,CAAC,CACvB,MAAM,MACL;EAAC;EAAgB;EAAc;CAAY,CAAC,CAAC,SAC3C,EAAK,wBAAwB,CAC/B,CACF;AACJ;AAEA,SAAS,EAAa,GAAwC;CAC5D,OAAO,EACJ,qBAAqB,EAAW,cAAc,CAAC,CAC/C,QAAQ,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,SAAS;AAC9D;AAUA,SAAgB,EAAmB,GAAkC;CACnE,IAAM,IAAM,EAAoB,GAAM;EACpC,UAAU;EACV,QAAQ;CACV,CAAC;CACD,IAAI,EAAI,WAAW,YACjB,OAAO;EACL,UAAU,EAAI;EACd,SAAS;GAAE,QAAQ,EAAI;GAAQ,SAAS,EAAI;EAAQ;CACtD;CAEF,IAAM,EAAE,cAAW,GACb,IAAgB,EAAkB,EAAO,UAAU;CACzD,IAAI,CAAC,GACH,OAAO;EACL,UAAU,EAAO;EACjB,SAAS;GAAE,QAAQ;GAAU,SAAS;EAAa;CACrD;CAGF,AAAI,EAAc,wBAAwB,MAAM,KAC9C,EAAc,mBAAmB,CAAY;CAG/C,KAAK,IAAM,KAAQ,EAAa,EAAO,UAAU,GAAG;EAClD,IAAM,IAAO,EAAK,aAAa;EAC/B,KAAK,IAAI,IAAI,EAAK,SAAS,GAAG,KAAK,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Q;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAe,MAAM;CAEtD,IAAI,CAAC,EAAS,SAAS,cAAc,GACnC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAQ7C,IAAM,IALmB,EAAS,QAChC,qFACA,IAGc,CAAA,CAAiB,QAAQ,WAAW,IAAI;CAOxD,OALI,MAAY,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAS,MAAM,GACxC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;AC1DA,IAAM,IAAe,6mDAkDf,IAAkB;AASxB,SAAgB,EAAgB,GAAsC;CAepE,OAdK,EAAG,WAAW,CAAa,IAQf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAc,MAAM,GAC7C;EAAE,QAAQ;EAAW,SAAS;CAAK,MAXxC,EAAG,UAAU,EAAK,QAAQ,CAAa,GAAG,EAAE,WAAW,GAAK,CAAC,GAC7D,EAAG,cAAc,GAAe,GAAc,MAAM,GAC7C;EAAE,QAAQ;EAAW,SAAS;CAAK;AAU9C;AAEA,SAAgB,EAAkB,GAAsC;CAWtE,OAVI,CAAC,EAAG,WAAW,CAAa,KAIf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAiB,MAAM,GAChD;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
|
|
1
|
+
{"version":3,"file":"test-setup-B2hd8I-s.js","names":[],"sources":["../../src/patterns/enable/backend/modifies/svelte-config.ts","../../src/patterns/enable/backend/modifies/gitignore.ts","../../src/patterns/enable/backend/modifies/test-setup.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\";\n\nconst ADAPTER_NODE = \"@sveltejs/adapter-node\";\nconst ADAPTER_STATIC = \"@sveltejs/adapter-static\";\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 * whichever file holds the adapter import + `adapter()` call (vite.config when\n * the project uses inline config, else svelte.config). 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 — if no config or no adapter import is found, it's a no-op success.\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 !== \"resolved\") {\n // Nothing to revert — treat missing/unparseable config as a no-op.\n return {\n filePath: res.filePath,\n outcome: { status: \"success\", changed: false },\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","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n// Source of truth: velastack-cli/templates/minimal/test/setup.ts\nconst WITH_BACKEND = `import { beforeEach, afterEach, beforeAll } from 'vitest';\nimport supertest, { type Agent } from 'supertest';\nimport PocketBase from 'pocketbase-sveltekit';\nimport type { TestContext } from '@velastack/pocketbase/testing';\n\nconst admin = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['admin'];\nconst pb = new PocketBase(process.env.POCKETBASE_URL!) as App.Locals['pb'];\n\nconst testUserPassword = 'password';\n\nasync function authenticateUser(agent: Agent, user: { email: string }) {\n\\tawait agent.post('/login').type('form').send({\n\\t\\ttype: 'password',\n\\t\\temail: user.email,\n\\t\\tpassword: testUserPassword\n\\t});\n}\n\nbeforeAll(async () => {\n\\tawait admin\n\\t\\t// @ts-ignore\n\\t\\t.collection('_superusers')\n\\t\\t.authWithPassword(\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_EMAIL!,\n\\t\\t\\tprocess.env.POCKETBASE_SUPERUSER_PASSWORD!\n\\t\\t);\n});\n\nbeforeEach(async (context: TestContext) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!) as TestContext['agent'];\n\\tcontext.admin = admin;\n\\tcontext.pb = pb;\n\\tcontext.user = await context.admin.collection('users').create({\n\\t\\temail: \\`test-\\${Math.random().toString(36).slice(2)}@example.com\\`,\n\\t\\tpassword: testUserPassword,\n\\t\\tpasswordConfirm: testUserPassword\n\\t});\n\\tcontext.agent.authenticateUser = () => authenticateUser(context.agent, context.user);\n\\tawait context.pb.collection('users').authWithPassword(context.user.email, testUserPassword);\n});\n\nafterEach(async (context: TestContext) => {\n\\tawait context.pb.authStore.clear();\n\\tawait context.admin.collection('users').delete(context.user.id);\n});\n`;\n\n// The static template ships no test setup at all; this is the backend-free\n// subset of the minimal one, kept so existing tests keep their agents.\nconst WITHOUT_BACKEND = `import { beforeEach } from 'vitest';\nimport supertest from 'supertest';\n\nbeforeEach(async (context: any) => {\n\\tcontext.request = supertest(process.env.VITE_TEST_URL!);\n\\tcontext.agent = supertest.agent(process.env.VITE_TEST_URL!);\n});\n`;\n\nexport function modifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n // The static template has no test/ directory; a backend brings server\n // tests with it, so the setup is created rather than reported missing.\n fs.mkdirSync(path.dirname(testSetupPath), { recursive: true });\n fs.writeFileSync(testSetupPath, WITH_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITH_BACKEND) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(testSetupPath, WITH_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n}\n\nexport function unmodifyTestSetup(testSetupPath: string): ModifyOutcome {\n if (!fs.existsSync(testSetupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(testSetupPath, \"utf8\");\n if (original === WITHOUT_BACKEND) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(testSetupPath, WITHOUT_BACKEND, \"utf8\");\n return { status: \"success\", changed: true };\n}\n"],"mappings":";;;;;;AASA,IAAM,IAAe,0BACf,IAAiB,4BACjB,IAAe,0BAEf,IAAe,CAAM;oCACS,EAAa;;yBAExB,EAAa;;;;GAMhC,IAAiB,CAAM;cACf,EAAa;;AAQ3B,SAAS,EAAkB,GAAwC;CACjE,OAAO,EACJ,sBAAsB,CAAC,CACvB,MAAM,MACL;EAAC;EAAgB;EAAc;CAAY,CAAC,CAAC,SAC3C,EAAK,wBAAwB,CAC/B,CACF;AACJ;AAEA,SAAS,EAAa,GAAwC;CAC5D,OAAO,EACJ,qBAAqB,EAAW,cAAc,CAAC,CAC/C,QAAQ,MAAO,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,SAAS;AAC9D;AAUA,SAAgB,EAAmB,GAAkC;CACnE,IAAM,IAAM,EAAoB,GAAM;EACpC,UAAU;EACV,QAAQ;CACV,CAAC;CACD,IAAI,EAAI,WAAW,YACjB,OAAO;EACL,UAAU,EAAI;EACd,SAAS;GAAE,QAAQ,EAAI;GAAQ,SAAS,EAAI;EAAQ;CACtD;CAEF,IAAM,EAAE,cAAW,GACb,IAAgB,EAAkB,EAAO,UAAU;CACzD,IAAI,CAAC,GACH,OAAO;EACL,UAAU,EAAO;EACjB,SAAS;GAAE,QAAQ;GAAU,SAAS;EAAa;CACrD;CAGF,AAAI,EAAc,wBAAwB,MAAM,KAC9C,EAAc,mBAAmB,CAAY;CAG/C,KAAK,IAAM,KAAQ,EAAa,EAAO,UAAU,GAAG;EAClD,IAAM,IAAO,EAAK,aAAa;EAC/B,KAAK,IAAI,IAAI,EAAK,SAAS,GAAG,KAAK,GAAG,KACpC,EAAK,eAAe,CAAC;CAEzB;CAEA,OAAO;EAAE,U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e,MAAM;CAEtD,IAAI,CAAC,EAAS,SAAS,cAAc,GACnC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAQ7C,IAAM,IALmB,EAAS,QAChC,qFACA,IAGc,CAAA,CAAiB,QAAQ,WAAW,IAAI;CAOxD,OALI,MAAY,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAS,MAAM,GACxC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;AC1DA,IAAM,IAAe,6mDAkDf,IAAkB;AASxB,SAAgB,EAAgB,GAAsC;CAepE,OAdK,EAAG,WAAW,CAAa,IAQf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAc,MAAM,GAC7C;EAAE,QAAQ;EAAW,SAAS;CAAK,MAXxC,EAAG,UAAU,EAAK,QAAQ,CAAa,GAAG,EAAE,WAAW,GAAK,CAAC,GAC7D,EAAG,cAAc,GAAe,GAAc,MAAM,GAC7C;EAAE,QAAQ;EAAW,SAAS;CAAK;AAU9C;AAEA,SAAgB,EAAkB,GAAsC;CAWtE,OAVI,CAAC,EAAG,WAAW,CAAa,KAIf,EAAG,aAAa,GAAe,MAC5C,MAAa,IACR;EAAE,QAAQ;EAAW,SAAS;CAAM,KAG7C,EAAG,cAAc,GAAe,GAAiB,MAAM,GAChD;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { n as e, t } from "./errors-D6gyegUK.js";
|
|
2
2
|
import { n } from "./logger-CQONztPm.js";
|
|
3
|
-
import { executeCommand as r, formatPaths as i, getAllCustomComponents as a, installComponents as o, installedComponents as s, installedPackagesFromProject as c, isCustomComponent as l, n as u, t as d } from "./write-result-
|
|
4
|
-
import f from "node:
|
|
5
|
-
import
|
|
3
|
+
import { executeCommand as r, formatPaths as i, getAllCustomComponents as a, installComponents as o, installedComponents as s, installedPackagesFromProject as c, isCustomComponent as l, n as u, t as d } from "./write-result-DewHCNhM.js";
|
|
4
|
+
import { existsSync as f, readFileSync as p, writeFileSync as m } from "node:fs";
|
|
5
|
+
import h from "node:path";
|
|
6
6
|
import { createRequire as g } from "node:module";
|
|
7
7
|
import { pathToFileURL as _ } from "node:url";
|
|
8
8
|
//#region src/runtime/shadcn-preset.ts
|
|
9
9
|
async function v(e) {
|
|
10
10
|
let t;
|
|
11
11
|
try {
|
|
12
|
-
t = g(
|
|
12
|
+
t = g(h.join(e, "package.json")).resolve("shadcn-svelte/preset");
|
|
13
13
|
} catch (t) {
|
|
14
14
|
let n = t instanceof Error ? t.message : String(t);
|
|
15
15
|
throw Error(`Could not load shadcn-svelte/preset from ${e}: ${n}\nInstall the project's dependencies (shadcn-svelte >= 1.6) and try again.`);
|
|
@@ -72,12 +72,12 @@ function w(e, n, r) {
|
|
|
72
72
|
if (!r.includes(n)) throw new t(`Unknown ${e} "${n}". Choose one of: ${r.join(", ")}.`);
|
|
73
73
|
}
|
|
74
74
|
function T(e, t) {
|
|
75
|
-
let n =
|
|
76
|
-
if (!
|
|
77
|
-
let r =
|
|
75
|
+
let n = h.join(e, S);
|
|
76
|
+
if (!f(n)) throw Error(`${S} not found in ${e}; this does not look like a shadcn-svelte project.`);
|
|
77
|
+
let r = p(n, "utf8"), i = JSON.parse(r);
|
|
78
78
|
i.style = t;
|
|
79
79
|
let a = r.includes("\n ") ? " " : 2;
|
|
80
|
-
|
|
80
|
+
m(n, `${JSON.stringify(i, null, a)}\n`, "utf8");
|
|
81
81
|
}
|
|
82
82
|
function E(e) {
|
|
83
83
|
return new Set(e.filter((e) => e.type === "registry:ui").map((e) => e.name));
|
|
@@ -139,9 +139,9 @@ async function A(e, t, n, r, i, a, o) {
|
|
|
139
139
|
}, n), ["font"], r);
|
|
140
140
|
let c = u(e).cssPath;
|
|
141
141
|
i.push(c, "package.json");
|
|
142
|
-
let l =
|
|
143
|
-
if (
|
|
144
|
-
let e = new Set([s.font, s.fontHeading].filter(Boolean)), t = k(
|
|
142
|
+
let l = h.join(e, c);
|
|
143
|
+
if (f(l)) {
|
|
144
|
+
let e = new Set([s.font, s.fontHeading].filter(Boolean)), t = k(p(l, "utf8")).filter((t) => !e.has(t));
|
|
145
145
|
t.length > 0 && a.push(`${c} still imports ${t.map((e) => `@fontsource-variable/${e}`).join(", ")} from the previous style; remove the import and the package if nothing else uses them.`);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -170,4 +170,4 @@ async function N(e, t) {
|
|
|
170
170
|
//#endregion
|
|
171
171
|
export { M as applyBaseColor, N as applyTheme, C as listComponents, D as switchStyle };
|
|
172
172
|
|
|
173
|
-
//# sourceMappingURL=ui-
|
|
173
|
+
//# sourceMappingURL=ui-B4Tuit-7.js.map
|