@velastack/patterns 0.0.22 → 0.0.24
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 +9 -16
- package/dist/chunks/collections-Bzyt18yv.js +52 -0
- package/dist/chunks/collections-Bzyt18yv.js.map +1 -0
- package/dist/chunks/constants-B5Ub2oFy.js +6 -0
- package/dist/chunks/constants-B5Ub2oFy.js.map +1 -0
- package/dist/chunks/dedent-BFNYR8cb.js +87 -0
- package/dist/chunks/dedent-BFNYR8cb.js.map +1 -0
- package/dist/chunks/env.preview-Cpr4Im0G.js +19 -0
- package/dist/chunks/env.preview-Cpr4Im0G.js.map +1 -0
- package/dist/chunks/env.runtime-iw-bWvXM.js +32 -0
- package/dist/chunks/env.runtime-iw-bWvXM.js.map +1 -0
- package/dist/chunks/generate.runtime-BEuc5hDN.js +225 -0
- package/dist/chunks/generate.runtime-BEuc5hDN.js.map +1 -0
- package/dist/chunks/generate.runtime-CHmm4bBZ.js +154 -0
- package/dist/chunks/generate.runtime-CHmm4bBZ.js.map +1 -0
- package/dist/chunks/generate.runtime-DXkJgkP4.js +232 -0
- package/dist/chunks/generate.runtime-DXkJgkP4.js.map +1 -0
- package/dist/chunks/generate.runtime-egq8I3EA.js +61 -0
- package/dist/chunks/generate.runtime-egq8I3EA.js.map +1 -0
- package/dist/chunks/generate.runtime-uPCB71Ki.js +522 -0
- package/dist/chunks/generate.runtime-uPCB71Ki.js.map +1 -0
- package/dist/chunks/pocketbase-CPRrN7Qs.js +106 -0
- package/dist/chunks/pocketbase-CPRrN7Qs.js.map +1 -0
- package/dist/chunks/pocketbase-CSl9ydRr.js +47 -0
- package/dist/chunks/pocketbase-CSl9ydRr.js.map +1 -0
- package/dist/chunks/ts-morph-helpers-BiOU9sUx.js +150 -0
- package/dist/chunks/ts-morph-helpers-BiOU9sUx.js.map +1 -0
- package/dist/chunks/util-k-qPjL06.js +21 -0
- package/dist/chunks/util-k-qPjL06.js.map +1 -0
- package/dist/chunks/write-result-CSxmq40z.js +216 -0
- package/dist/chunks/write-result-CSxmq40z.js.map +1 -0
- package/dist/index.js +3533 -8
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/dist/chunks/collections-Ch4kZjuV.js +0 -67
- package/dist/chunks/collections-Ch4kZjuV.js.map +0 -1
- package/dist/chunks/env.preview-HlXZOEL4.js +0 -17
- package/dist/chunks/env.preview-HlXZOEL4.js.map +0 -1
- package/dist/chunks/env.runtime-BauEimvd.js +0 -36
- package/dist/chunks/env.runtime-BauEimvd.js.map +0 -1
- package/dist/chunks/generate.runtime-C7g-zL0o.js +0 -55
- package/dist/chunks/generate.runtime-C7g-zL0o.js.map +0 -1
- package/dist/chunks/generate.runtime-CnxTssBQ.js +0 -334
- package/dist/chunks/generate.runtime-CnxTssBQ.js.map +0 -1
- package/dist/chunks/generate.runtime-D5bvTbSL.js +0 -172
- package/dist/chunks/generate.runtime-D5bvTbSL.js.map +0 -1
- package/dist/chunks/generate.runtime-Tk3iuGQE.js +0 -259
- package/dist/chunks/generate.runtime-Tk3iuGQE.js.map +0 -1
- package/dist/chunks/generate.runtime-hZV63PD9.js +0 -610
- package/dist/chunks/generate.runtime-hZV63PD9.js.map +0 -1
- package/dist/chunks/index-CoeyNVkU.js +0 -9549
- package/dist/chunks/index-CoeyNVkU.js.map +0 -1
- package/dist/chunks/pocketbase-rvyHmLFw.js +0 -140
- package/dist/chunks/pocketbase-rvyHmLFw.js.map +0 -1
- package/dist/chunks/ts-morph-helpers-BNCluWTs.js +0 -166
- package/dist/chunks/ts-morph-helpers-BNCluWTs.js.map +0 -1
- package/dist/chunks/write-result-1Q3LB_k4.js +0 -1744
- package/dist/chunks/write-result-1Q3LB_k4.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,14 +13,7 @@ It also takes any additional wizard inputs from the CLI and passes the data as `
|
|
|
13
13
|
```ts
|
|
14
14
|
const pattern = await registry.loadPattern("generate-form", {
|
|
15
15
|
env: "runtime",
|
|
16
|
-
argv: [
|
|
17
|
-
"generate",
|
|
18
|
-
"form",
|
|
19
|
-
"contact",
|
|
20
|
-
"name:text",
|
|
21
|
-
"email:email",
|
|
22
|
-
"message:editor",
|
|
23
|
-
],
|
|
16
|
+
argv: ["contact", "name:text", "email:email", "message:editor"],
|
|
24
17
|
root: "/user/project",
|
|
25
18
|
features: {
|
|
26
19
|
auth: false,
|
|
@@ -38,14 +31,7 @@ is loaded like this:
|
|
|
38
31
|
```ts
|
|
39
32
|
const pattern = await registry.loadPattern("generate-form", {
|
|
40
33
|
env: "preview",
|
|
41
|
-
argv: [
|
|
42
|
-
"generate",
|
|
43
|
-
"form",
|
|
44
|
-
"contact",
|
|
45
|
-
"name:text",
|
|
46
|
-
"email:email",
|
|
47
|
-
"message:editor",
|
|
48
|
-
],
|
|
34
|
+
argv: ["contact", "name:text", "email:email", "message:editor"],
|
|
49
35
|
});
|
|
50
36
|
```
|
|
51
37
|
|
|
@@ -91,3 +77,10 @@ The `src/baselines/` directory contains template SvelteKit projects that pattern
|
|
|
91
77
|
Each baseline is a standalone project with its own `package.json`. When working with a baseline locally, run `npm install` inside its directory. The `node_modules` and `.svelte-kit` directories inside baselines are gitignored and must be installed locally before running or testing.
|
|
92
78
|
|
|
93
79
|
Baselines are not bundled into the published package — they are used by the VelaStack CLI's `create` command and by the velastack.dev website.
|
|
80
|
+
|
|
81
|
+
# Workflow for adding new patterns
|
|
82
|
+
|
|
83
|
+
- Develop the pattern in the `src/patterns` directory.
|
|
84
|
+
- Use the demo script to generate a temporary project with the pattern to see applied changes.
|
|
85
|
+
- In the temporary project, run `npm run test:server` to run the tests.
|
|
86
|
+
- Run `npm run lint` and `npm run check` to make sure the code is correct.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { n as e } from "./util-k-qPjL06.js";
|
|
2
|
+
import { n as t, r as n, t as r } from "./pocketbase-CPRrN7Qs.js";
|
|
3
|
+
import { readFileSync as i } from "node:fs";
|
|
4
|
+
//#region src/runtime/collections.ts
|
|
5
|
+
function a(e) {
|
|
6
|
+
if (e.response?.data?.name?.code === "validation_not_unique") return !0;
|
|
7
|
+
let t = e.message?.toLowerCase() ?? "";
|
|
8
|
+
return t.includes("already exists") || t.includes("must be unique");
|
|
9
|
+
}
|
|
10
|
+
function o(e) {
|
|
11
|
+
let t = {};
|
|
12
|
+
return e.listRule !== void 0 && (t.listRule = e.listRule), e.viewRule !== void 0 && (t.viewRule = e.viewRule), e.createRule !== void 0 && (t.createRule = e.createRule), e.updateRule !== void 0 && (t.updateRule = e.updateRule), e.deleteRule !== void 0 && (t.deleteRule = e.deleteRule), t;
|
|
13
|
+
}
|
|
14
|
+
async function s(n, a, s) {
|
|
15
|
+
let c = [];
|
|
16
|
+
for (let l of a) {
|
|
17
|
+
let a = l.collectionName.replace(/'/g, "''"), u = await n.collections.getFirstListItem(`name='${a}'`);
|
|
18
|
+
if (await n.collections.update(u.id, o(l)), await t(), s) {
|
|
19
|
+
let t = r(l.collectionName, "updated", s);
|
|
20
|
+
t && c.push({
|
|
21
|
+
path: t,
|
|
22
|
+
language: e(t),
|
|
23
|
+
content: i(t, "utf8")
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
async function c(o, s) {
|
|
30
|
+
if (o.length === 0) return [];
|
|
31
|
+
let c = [];
|
|
32
|
+
return await n(s.root, async (n) => {
|
|
33
|
+
for (let l of o) {
|
|
34
|
+
try {
|
|
35
|
+
await n.collections.create(l);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
throw a(e) ? Error(`Collection "${l.name}" already exists. Choose a different model name or remove the existing collection first.`) : e;
|
|
38
|
+
}
|
|
39
|
+
await t();
|
|
40
|
+
let o = r(l.name, "created", s);
|
|
41
|
+
o && c.push({
|
|
42
|
+
path: o,
|
|
43
|
+
language: e(o),
|
|
44
|
+
content: i(o, "utf8")
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}), c;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { s as applyCollectionRulePatches, c as createCollections };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=collections-Bzyt18yv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections-Bzyt18yv.js","names":[],"sources":["../../src/runtime/collections.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type {\n CollectionRulesPatch,\n CollectionSpec,\n File,\n Options,\n} from \"../core/types\";\nimport { languageFromPath } from \"../core/util\";\nimport { getMigrationFile, migrationDelay, withPocketbase } from \"./pocketbase\";\n\ninterface PocketBaseCollectionCreateError {\n response?: {\n data?: {\n name?: {\n code?: string;\n };\n };\n };\n message?: string;\n}\n\nfunction isCollectionAlreadyExistsError(\n error: PocketBaseCollectionCreateError,\n): boolean {\n if (error.response?.data?.name?.code === \"validation_not_unique\") {\n return true;\n }\n\n const message = error.message?.toLowerCase() ?? \"\";\n return (\n message.includes(\"already exists\") || message.includes(\"must be unique\")\n );\n}\n\nfunction rulePayloadFromPatch(\n patch: CollectionRulesPatch,\n): Record<string, unknown> {\n const payload: Record<string, unknown> = {};\n if (patch.listRule !== undefined) payload.listRule = patch.listRule;\n if (patch.viewRule !== undefined) payload.viewRule = patch.viewRule;\n if (patch.createRule !== undefined) payload.createRule = patch.createRule;\n if (patch.updateRule !== undefined) payload.updateRule = patch.updateRule;\n if (patch.deleteRule !== undefined) payload.deleteRule = patch.deleteRule;\n return payload;\n}\n\n/**\n * Applies API rule updates in array order. Call after all referenced collections exist.\n * Collects migration files produced by each update when `options` is provided.\n */\nexport async function applyCollectionRulePatches(\n pb: {\n collections: {\n getFirstListItem: (filter: string) => Promise<{ id: string }>;\n update: (id: string, body: Record<string, unknown>) => Promise<unknown>;\n };\n },\n patches: CollectionRulesPatch[],\n options?: Options,\n): Promise<File[]> {\n const migrations: File[] = [];\n\n for (const patch of patches) {\n const escaped = patch.collectionName.replace(/'/g, \"''\");\n const col = await pb.collections.getFirstListItem(`name='${escaped}'`);\n await pb.collections.update(col.id, rulePayloadFromPatch(patch));\n await migrationDelay();\n\n if (options) {\n const migrationFile = getMigrationFile(\n patch.collectionName,\n \"updated\",\n options,\n );\n if (migrationFile) {\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n });\n }\n }\n }\n\n return migrations;\n}\n\nexport async function createCollections(\n collections: CollectionSpec[],\n options: Options,\n): Promise<File[]> {\n if (collections.length === 0) {\n return [];\n }\n\n const migrations: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n for (const collection of collections) {\n try {\n await pb.collections.create(collection);\n } catch (error) {\n if (\n isCollectionAlreadyExistsError(\n error as PocketBaseCollectionCreateError,\n )\n ) {\n throw new Error(\n `Collection \"${collection.name}\" already exists. Choose a different model name or remove the existing collection first.`,\n );\n }\n throw error;\n }\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\n collection.name,\n \"created\",\n options,\n );\n if (!migrationFile) {\n continue;\n }\n\n migrations.push({\n path: migrationFile,\n language: languageFromPath(migrationFile),\n content: readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n return migrations;\n}\n"],"mappings":";;;;AAqBA,SAAS,EACP,GACS;AACT,KAAI,EAAM,UAAU,MAAM,MAAM,SAAS,wBACvC,QAAO;CAGT,IAAM,IAAU,EAAM,SAAS,aAAa,IAAI;AAChD,QACE,EAAQ,SAAS,iBAAiB,IAAI,EAAQ,SAAS,iBAAiB;;AAI5E,SAAS,EACP,GACyB;CACzB,IAAM,IAAmC,EAAE;AAM3C,QALI,EAAM,aAAa,KAAA,MAAW,EAAQ,WAAW,EAAM,WACvD,EAAM,aAAa,KAAA,MAAW,EAAQ,WAAW,EAAM,WACvD,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aAC3D,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aAC3D,EAAM,eAAe,KAAA,MAAW,EAAQ,aAAa,EAAM,aACxD;;AAOT,eAAsB,EACpB,GAMA,GACA,GACiB;CACjB,IAAM,IAAqB,EAAE;AAE7B,MAAK,IAAM,KAAS,GAAS;EAC3B,IAAM,IAAU,EAAM,eAAe,QAAQ,MAAM,KAAK,EAClD,IAAM,MAAM,EAAG,YAAY,iBAAiB,SAAS,EAAQ,GAAG;AAItE,MAHA,MAAM,EAAG,YAAY,OAAO,EAAI,IAAI,EAAqB,EAAM,CAAC,EAChE,MAAM,GAAgB,EAElB,GAAS;GACX,IAAM,IAAgB,EACpB,EAAM,gBACN,WACA,EACD;AACD,GAAI,KACF,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,EAAc;IACzC,SAAS,EAAa,GAAe,OAAO;IAC7C,CAAC;;;AAKR,QAAO;;AAGT,eAAsB,EACpB,GACA,GACiB;AACjB,KAAI,EAAY,WAAW,EACzB,QAAO,EAAE;CAGX,IAAM,IAAqB,EAAE;AAqC7B,QAnCA,MAAM,EAAe,EAAQ,MAAM,OAAO,MAAO;AAC/C,OAAK,IAAM,KAAc,GAAa;AACpC,OAAI;AACF,UAAM,EAAG,YAAY,OAAO,EAAW;YAChC,GAAO;AAUd,UARE,EACE,EACD,GAES,MACR,eAAe,EAAW,KAAK,0FAChC,GAEG;;AAER,SAAM,GAAgB;GAEtB,IAAM,IAAgB,EACpB,EAAW,MACX,WACA,EACD;AACI,QAIL,EAAW,KAAK;IACd,MAAM;IACN,UAAU,EAAiB,EAAc;IACzC,SAAS,EAAa,GAAe,OAAO;IAC7C,CAAC;;GAEJ,EAEK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-B5Ub2oFy.js","names":[],"sources":["../../src/core/constants.ts"],"sourcesContent":["export const DATA_DIR = \"data\";\nexport const MIGRATIONS_DIR = \"migrations\";\nexport const FIXTURE_PREFIX = \"vela\";\nexport const PUBLIC_DIR = \"(public)\";\nexport const APP_DIR = \"(app)\";\nexport const AUTHED_REDIRECT_PATH = \"/dashboard\";\nexport const API_URL = \"http://localhost:5173\";\n"],"mappings":";AAAA,IAAa,IAAW,QACX,IAAiB,cAEjB,IAAa,YACb,IAAU"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//#region node_modules/dedent/dist/dedent.mjs
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
var n = Object.keys(e);
|
|
4
|
+
if (Object.getOwnPropertySymbols) {
|
|
5
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
6
|
+
t && (r = r.filter(function(t) {
|
|
7
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
8
|
+
})), n.push.apply(n, r);
|
|
9
|
+
}
|
|
10
|
+
return n;
|
|
11
|
+
}
|
|
12
|
+
function t(t) {
|
|
13
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
14
|
+
var i = arguments[r] == null ? {} : arguments[r];
|
|
15
|
+
r % 2 ? e(Object(i), !0).forEach(function(e) {
|
|
16
|
+
n(t, e, i[e]);
|
|
17
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : e(Object(i)).forEach(function(e) {
|
|
18
|
+
Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
}
|
|
23
|
+
function n(e, t, n) {
|
|
24
|
+
return t = r(t), t in e ? Object.defineProperty(e, t, {
|
|
25
|
+
value: n,
|
|
26
|
+
enumerable: !0,
|
|
27
|
+
configurable: !0,
|
|
28
|
+
writable: !0
|
|
29
|
+
}) : e[t] = n, e;
|
|
30
|
+
}
|
|
31
|
+
function r(e) {
|
|
32
|
+
var t = i(e, "string");
|
|
33
|
+
return typeof t == "symbol" ? t : String(t);
|
|
34
|
+
}
|
|
35
|
+
function i(e, t) {
|
|
36
|
+
if (typeof e != "object" || !e) return e;
|
|
37
|
+
var n = e[Symbol.toPrimitive];
|
|
38
|
+
if (n !== void 0) {
|
|
39
|
+
var r = n.call(e, t || "default");
|
|
40
|
+
if (typeof r != "object") return r;
|
|
41
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
42
|
+
}
|
|
43
|
+
return (t === "string" ? String : Number)(e);
|
|
44
|
+
}
|
|
45
|
+
var a = o({});
|
|
46
|
+
function o(e) {
|
|
47
|
+
return n.withOptions = (n) => o(t(t({}, e), n)), n;
|
|
48
|
+
function n(t, ...n) {
|
|
49
|
+
let r = typeof t == "string" ? [t] : t.raw, { alignValues: i = !1, escapeSpecialCharacters: a = Array.isArray(t), trimWhitespace: o = !0 } = e, c = "";
|
|
50
|
+
for (let e = 0; e < r.length; e++) {
|
|
51
|
+
let t = r[e];
|
|
52
|
+
if (a && (t = t.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{")), c += t, e < n.length) {
|
|
53
|
+
let t = i ? s(n[e], c) : n[e];
|
|
54
|
+
c += t;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let l = c.split("\n"), u = null;
|
|
58
|
+
for (let e of l) {
|
|
59
|
+
let t = e.match(/^(\s+)\S+/);
|
|
60
|
+
if (t) {
|
|
61
|
+
let e = t[1].length;
|
|
62
|
+
u = u ? Math.min(u, e) : e;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (u !== null) {
|
|
66
|
+
let e = u;
|
|
67
|
+
c = l.map((t) => t[0] === " " || t[0] === " " ? t.slice(e) : t).join("\n");
|
|
68
|
+
}
|
|
69
|
+
return o && (c = c.trim()), a && (c = c.replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\r/g, "\r").replace(/\\v/g, "\v").replace(/\\b/g, "\b").replace(/\\f/g, "\f").replace(/\\0/g, "\0").replace(/\\x([\da-fA-F]{2})/g, (e, t) => String.fromCharCode(parseInt(t, 16))).replace(/\\u\{([\da-fA-F]{1,6})\}/g, (e, t) => String.fromCodePoint(parseInt(t, 16))).replace(/\\u([\da-fA-F]{4})/g, (e, t) => String.fromCharCode(parseInt(t, 16)))), typeof Bun < "u" && (c = c.replace(/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g, (e, t, n) => {
|
|
70
|
+
let r = t ?? n ?? "";
|
|
71
|
+
return String.fromCodePoint(parseInt(r, 16));
|
|
72
|
+
})), c;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function s(e, t) {
|
|
76
|
+
if (typeof e != "string" || !e.includes("\n")) return e;
|
|
77
|
+
let n = t.slice(t.lastIndexOf("\n") + 1).match(/^(\s+)/);
|
|
78
|
+
if (n) {
|
|
79
|
+
let t = n[1];
|
|
80
|
+
return e.replace(/\n/g, `\n${t}`);
|
|
81
|
+
}
|
|
82
|
+
return e;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { a as t };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=dedent-BFNYR8cb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedent-BFNYR8cb.js","names":[],"sources":["../../node_modules/dedent/dist/dedent.mjs"],"sourcesContent":["function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return typeof key === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (typeof input !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (typeof res !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nconst dedent = createDedent({});\nexport default dedent;\nfunction createDedent(options) {\n dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));\n return dedent;\n function dedent(strings, ...values) {\n const raw = typeof strings === \"string\" ? [strings] : strings.raw;\n const {\n alignValues = false,\n escapeSpecialCharacters = Array.isArray(strings),\n trimWhitespace = true\n } = options;\n\n // first, perform interpolation\n let result = \"\";\n for (let i = 0; i < raw.length; i++) {\n let next = raw[i];\n if (escapeSpecialCharacters) {\n // handle escaped newlines, backticks, and interpolation characters\n next = next.replace(/\\\\\\n[ \\t]*/g, \"\").replace(/\\\\`/g, \"`\").replace(/\\\\\\$/g, \"$\").replace(/\\\\\\{/g, \"{\");\n }\n result += next;\n if (i < values.length) {\n const value = alignValues ? alignValue(values[i], result) : values[i];\n\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n result += value;\n }\n }\n\n // now strip indentation\n const lines = result.split(\"\\n\");\n let mindent = null;\n for (const l of lines) {\n const m = l.match(/^(\\s+)\\S+/);\n if (m) {\n const indent = m[1].length;\n if (!mindent) {\n // this is the first indented line\n mindent = indent;\n } else {\n mindent = Math.min(mindent, indent);\n }\n }\n }\n if (mindent !== null) {\n const m = mindent; // appease TypeScript\n result = lines\n // https://github.com/typescript-eslint/typescript-eslint/issues/7140\n // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with\n .map(l => l[0] === \" \" || l[0] === \"\\t\" ? l.slice(m) : l).join(\"\\n\");\n }\n\n // dedent eats leading and trailing whitespace too\n if (trimWhitespace) {\n result = result.trim();\n }\n\n // Unescape escapes after trimming so sequences like `\\n`, `\\t`,\n // `\\xHH` and `\\u{...}` are preserved (fixes #24)\n if (escapeSpecialCharacters) {\n result = result.replace(/\\\\n/g, \"\\n\").replace(/\\\\t/g, \"\\t\").replace(/\\\\r/g, \"\\r\").replace(/\\\\v/g, \"\\v\").replace(/\\\\b/g, \"\\b\").replace(/\\\\f/g, \"\\f\").replace(/\\\\0/g, \"\\0\").replace(/\\\\x([\\da-fA-F]{2})/g, (_, h) => String.fromCharCode(parseInt(h, 16))).replace(/\\\\u\\{([\\da-fA-F]{1,6})\\}/g, (_, h) => String.fromCodePoint(parseInt(h, 16))).replace(/\\\\u([\\da-fA-F]{4})/g, (_, h) => String.fromCharCode(parseInt(h, 16)));\n }\n\n // Workaround for Bun issue with Unicode characters\n // https://github.com/oven-sh/bun/issues/8745\n if (typeof Bun !== \"undefined\") {\n result = result.replace(\n // Matches e.g. \\\\u{1f60a} or \\\\u5F1F\n /\\\\u(?:\\{([\\da-fA-F]{1,6})\\}|([\\da-fA-F]{4}))/g, (_, braced, unbraced) => {\n var _ref;\n const hex = (_ref = braced !== null && braced !== void 0 ? braced : unbraced) !== null && _ref !== void 0 ? _ref : \"\";\n return String.fromCodePoint(parseInt(hex, 16));\n });\n }\n return result;\n }\n}\n\n/**\n * Adjusts the indentation of a multi-line interpolated value to match the current line.\n */\nfunction alignValue(value, precedingText) {\n if (typeof value !== \"string\" || !value.includes(\"\\n\")) {\n return value;\n }\n const currentLine = precedingText.slice(precedingText.lastIndexOf(\"\\n\") + 1);\n const indentMatch = currentLine.match(/^(\\s+)/);\n if (indentMatch) {\n const indent = indentMatch[1];\n return value.replace(/\\n/g, `\\n${indent}`);\n }\n return value;\n}\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,EAAQ,GAAQ,GAAgB;CAAE,IAAI,IAAO,OAAO,KAAK,EAAO;AAAE,KAAI,OAAO,uBAAuB;EAAE,IAAI,IAAU,OAAO,sBA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,QAAQ,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,QAAQ,wBAAwB,GAAG,MAAM,OAAO,aAAa,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,8BAA8B,GAAG,MAAM,OAAO,cAAc,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,wBAAwB,GAAG,MAAM,OAAO,aAAa,SAAS,GAAG,GAAG,CAAC,CAAC,GAK3Z,OAAO,MAAQ,QACjB,IAAS,EAAO,QAEhB,kDAAkD,GAAG,GAAQ,MAAa;GAExE,IAAM,IAAc,KAAgD,KAA+C;AACnH,UAAO,OAAO,cAAc,SAAS,GAAK,GAAG,CAAC;IAC9C,GAEG;;;AAOX,SAAS,EAAW,GAAO,GAAe;AACxC,KAAI,OAAO,KAAU,YAAY,CAAC,EAAM,SAAS,KAAK,CACpD,QAAO;CAGT,IAAM,IADc,EAAc,MAAM,EAAc,YAAY,KAAK,GAAG,EAAE,CAC5C,MAAM,SAAS;AAC/C,KAAI,GAAa;EACf,IAAM,IAAS,EAAY;AAC3B,SAAO,EAAM,QAAQ,OAAO,KAAK,IAAS;;AAE5C,QAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/parse/env.preview.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e.features.auth ? [{
|
|
4
|
+
id: "users_preview",
|
|
5
|
+
name: "users",
|
|
6
|
+
type: "auth",
|
|
7
|
+
fields: [{
|
|
8
|
+
name: "email",
|
|
9
|
+
type: "email"
|
|
10
|
+
}, {
|
|
11
|
+
name: "name",
|
|
12
|
+
type: "text"
|
|
13
|
+
}]
|
|
14
|
+
}] : [];
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as getPreviewCollections };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=env.preview-Cpr4Im0G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.preview-Cpr4Im0G.js","names":[],"sources":["../../src/parse/env.preview.ts"],"sourcesContent":["import type { Options } from \"../core/types\";\nimport type { Collection } from \"./types\";\n\nexport function getPreviewCollections(\n options: Pick<Options, \"features\">,\n): Collection[] {\n if (options.features.auth) {\n return [\n {\n id: \"users_preview\",\n name: \"users\",\n type: \"auth\",\n fields: [\n { name: \"email\", type: \"email\" },\n { name: \"name\", type: \"text\" },\n ],\n },\n ];\n }\n return [];\n}\n"],"mappings":";AAGA,SAAgB,EACd,GACc;AAcd,QAbI,EAAQ,SAAS,OACZ,CACL;EACE,IAAI;EACJ,MAAM;EACN,MAAM;EACN,QAAQ,CACN;GAAE,MAAM;GAAS,MAAM;GAAS,EAChC;GAAE,MAAM;GAAQ,MAAM;GAAQ,CAC/B;EACF,CACF,GAEI,EAAE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { n as e } from "./constants-B5Ub2oFy.js";
|
|
2
|
+
import { getCollections as t } from "@velastack/pocketbase/internal";
|
|
3
|
+
import n from "node:fs";
|
|
4
|
+
import r from "node:path";
|
|
5
|
+
import i from "node:process";
|
|
6
|
+
//#region src/parse/env.runtime.ts
|
|
7
|
+
function a(e) {
|
|
8
|
+
return n.existsSync(r.join(e, "package.json")) && n.existsSync(r.join(e, "data"));
|
|
9
|
+
}
|
|
10
|
+
function o(t = i.cwd()) {
|
|
11
|
+
let n = r.resolve(t);
|
|
12
|
+
for (;;) {
|
|
13
|
+
if (a(n)) return n;
|
|
14
|
+
let e = r.dirname(n);
|
|
15
|
+
if (e === n) break;
|
|
16
|
+
n = e;
|
|
17
|
+
}
|
|
18
|
+
throw Error(`Could not resolve project root from "${t}". Expected package.json, and ${e}.`);
|
|
19
|
+
}
|
|
20
|
+
async function s() {
|
|
21
|
+
let e = o();
|
|
22
|
+
return t({
|
|
23
|
+
pocketbaseUrl: "",
|
|
24
|
+
superuserEmail: i.env.POCKETBASE_SUPERUSER_EMAIL,
|
|
25
|
+
superuserPassword: i.env.POCKETBASE_SUPERUSER_PASSWORD,
|
|
26
|
+
root: e
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { s as getCollections };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=env.runtime-iw-bWvXM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.runtime-iw-bWvXM.js","names":[],"sources":["../../src/parse/env.runtime.ts"],"sourcesContent":["import { getCollections as getCollectionsFromPB } from \"@velastack/pocketbase/internal\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport process from \"node:process\";\nimport { DATA_DIR } from \"../core/constants\";\nimport type { Collection } from \"./types\";\n\nfunction hasProjectMarkers(dir: string): boolean {\n return (\n fs.existsSync(path.join(dir, \"package.json\")) &&\n fs.existsSync(path.join(dir, DATA_DIR))\n );\n}\n\nexport function resolveProjectRoot(startDir = process.cwd()): string {\n let current = path.resolve(startDir);\n\n while (true) {\n if (hasProjectMarkers(current)) {\n return current;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n break;\n }\n current = parent;\n }\n\n throw new Error(\n `Could not resolve project root from \"${startDir}\". Expected package.json, and ${DATA_DIR}.`,\n );\n}\n\nexport async function getCollections(): Promise<Collection[]> {\n const root = resolveProjectRoot();\n\n return getCollectionsFromPB({\n pocketbaseUrl: \"\",\n superuserEmail: process.env.POCKETBASE_SUPERUSER_EMAIL!,\n superuserPassword: process.env.POCKETBASE_SUPERUSER_PASSWORD!,\n root,\n }) as Promise<Collection[]>;\n}\n"],"mappings":";;;;;;AAOA,SAAS,EAAkB,GAAsB;AAC/C,QACE,EAAG,WAAW,EAAK,KAAK,GAAK,eAAe,CAAC,IAC7C,EAAG,WAAW,EAAK,KAAK,GAAA,OAAc,CAAC;;AAI3C,SAAgB,EAAmB,IAAW,EAAQ,KAAK,EAAU;CACnE,IAAI,IAAU,EAAK,QAAQ,EAAS;AAEpC,UAAa;AACX,MAAI,EAAkB,EAAQ,CAC5B,QAAO;EAGT,IAAM,IAAS,EAAK,QAAQ,EAAQ;AACpC,MAAI,MAAW,EACb;AAEF,MAAU;;AAGZ,OAAU,MACR,wCAAwC,EAAS,gCAAgC,EAAS,GAC3F;;AAGH,eAAsB,IAAwC;CAC5D,IAAM,IAAO,GAAoB;AAEjC,QAAO,EAAqB;EAC1B,eAAe;EACf,gBAAgB,EAAQ,IAAI;EAC5B,mBAAmB,EAAQ,IAAI;EAC/B;EACD,CAAC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { t as e } from "./dedent-BFNYR8cb.js";
|
|
2
|
+
import t from "node:fs";
|
|
3
|
+
import n from "node:path";
|
|
4
|
+
import { Project as r, QuoteKind as i, SyntaxKind as a } from "ts-morph";
|
|
5
|
+
//#region src/patterns/enable/i18n/modifies/vite-config.ts
|
|
6
|
+
function o(e) {
|
|
7
|
+
if (!t.existsSync(e)) return !1;
|
|
8
|
+
let n = new r({
|
|
9
|
+
compilerOptions: { allowJs: !0 },
|
|
10
|
+
manipulationSettings: { quoteKind: i.Single }
|
|
11
|
+
}).addSourceFileAtPath(e), o = !1;
|
|
12
|
+
n.getImportDeclarations().some((e) => e.getModuleSpecifierValue() === "wuchale/vite") || (n.insertImportDeclaration(0, {
|
|
13
|
+
namedImports: ["wuchale"],
|
|
14
|
+
moduleSpecifier: "wuchale/vite"
|
|
15
|
+
}), o = !0);
|
|
16
|
+
let s = n.getDescendantsOfKind(a.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], c = s?.getKind() === a.ObjectLiteralExpression ? s : null;
|
|
17
|
+
if (!c) return o && (n.formatText(), n.saveSync()), o;
|
|
18
|
+
let l = c.getProperty("plugins");
|
|
19
|
+
if (!l) return c.addPropertyAssignment({
|
|
20
|
+
name: "plugins",
|
|
21
|
+
initializer: "[wuchale()]"
|
|
22
|
+
}), n.formatText(), n.saveSync(), !0;
|
|
23
|
+
if (l.getKind() !== a.PropertyAssignment) return o && (n.formatText(), n.saveSync()), o;
|
|
24
|
+
let u = l.getInitializer();
|
|
25
|
+
if (!u) return l.setInitializer("[wuchale()]"), n.formatText(), n.saveSync(), !0;
|
|
26
|
+
if (u.getKind() !== a.ArrayLiteralExpression) return o && (n.formatText(), n.saveSync()), o;
|
|
27
|
+
let d = u;
|
|
28
|
+
return d.getElements().some((e) => e.getText().replace(/\s/g, "") === "wuchale()") || (d.insertElement(0, "wuchale()"), o = !0), o && (n.formatText(), n.saveSync()), o;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/patterns/enable/i18n/modifies/svelte-config.ts
|
|
32
|
+
function s(e, t, n) {
|
|
33
|
+
let r = e.getProperty(t);
|
|
34
|
+
if (!r) {
|
|
35
|
+
e.addPropertyAssignment({
|
|
36
|
+
name: t,
|
|
37
|
+
initializer: n
|
|
38
|
+
});
|
|
39
|
+
let r = e.getProperty(t);
|
|
40
|
+
if (!r || r.getKind() !== a.PropertyAssignment) return null;
|
|
41
|
+
let i = r.getInitializer();
|
|
42
|
+
return !i || i.getKind() !== a.ObjectLiteralExpression ? null : i;
|
|
43
|
+
}
|
|
44
|
+
if (r.getKind() !== a.PropertyAssignment) return null;
|
|
45
|
+
let i = r.getInitializer();
|
|
46
|
+
if (!i) return null;
|
|
47
|
+
if (i.getKind() !== a.ObjectLiteralExpression) {
|
|
48
|
+
r.setInitializer(n);
|
|
49
|
+
let e = r.getInitializer();
|
|
50
|
+
return e && e.getKind() === a.ObjectLiteralExpression ? e : null;
|
|
51
|
+
}
|
|
52
|
+
return i;
|
|
53
|
+
}
|
|
54
|
+
function c(e) {
|
|
55
|
+
if (!t.existsSync(e)) return !1;
|
|
56
|
+
let n = new r({
|
|
57
|
+
compilerOptions: { allowJs: !0 },
|
|
58
|
+
manipulationSettings: { quoteKind: i.Single }
|
|
59
|
+
}).addSourceFileAtPath(e), o = n.getExportAssignment((e) => !e.isExportEquals())?.getExpression(), c = null;
|
|
60
|
+
if (o?.getKind() === a.ObjectLiteralExpression) c = o;
|
|
61
|
+
else if (o?.getKind() === a.Identifier) {
|
|
62
|
+
let e = o.getText(), t = n.getVariableDeclaration(e)?.getInitializer();
|
|
63
|
+
t?.getKind() === a.ObjectLiteralExpression && (c = t);
|
|
64
|
+
}
|
|
65
|
+
if (!c) return !1;
|
|
66
|
+
let l = s(c, "kit", "{}");
|
|
67
|
+
if (!l) return !1;
|
|
68
|
+
let u = s(l, "alias", "{}");
|
|
69
|
+
if (!u) return !1;
|
|
70
|
+
let d = u.getProperty("$locales");
|
|
71
|
+
return d ? d.getKind() !== a.PropertyAssignment || d.getInitializer()?.getText()?.replace(/['"`]/g, "") === "src/locales" ? !1 : (d.setInitializer("'src/locales'"), n.formatText(), n.saveSync(), !0) : (u.addPropertyAssignment({
|
|
72
|
+
name: "$locales",
|
|
73
|
+
initializer: "'src/locales'"
|
|
74
|
+
}), n.formatText(), n.saveSync(), !0);
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/patterns/enable/i18n/modifies/hooks.server.ts
|
|
78
|
+
function l(e, t, n) {
|
|
79
|
+
let r = e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t);
|
|
80
|
+
if (r) {
|
|
81
|
+
r.getNamedImports().some((e) => e.getName() === n) || r.addNamedImport(n);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
e.addImportDeclaration({
|
|
85
|
+
namedImports: [n],
|
|
86
|
+
moduleSpecifier: t
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function u(e, t, n) {
|
|
90
|
+
e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t) || e.addImportDeclaration({
|
|
91
|
+
namespaceImport: n,
|
|
92
|
+
moduleSpecifier: t
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function d(n) {
|
|
96
|
+
if (!t.existsSync(n)) return !1;
|
|
97
|
+
let o = t.readFileSync(n, "utf8");
|
|
98
|
+
if (o.includes("runWithLocale") || o.includes("loadLocales(")) return !1;
|
|
99
|
+
let s = new r({
|
|
100
|
+
compilerOptions: { allowJs: !0 },
|
|
101
|
+
manipulationSettings: { quoteKind: i.Single }
|
|
102
|
+
}).addSourceFileAtPath(n), c = s.getVariableDeclaration("handle");
|
|
103
|
+
if (!c) return !1;
|
|
104
|
+
let d = c.getFirstAncestorByKind(a.VariableStatement);
|
|
105
|
+
if (!d?.hasExportKeyword()) return !1;
|
|
106
|
+
l(s, "@sveltejs/kit/hooks", "sequence"), l(s, "wuchale/load-utils/server", "runWithLocale"), l(s, "wuchale/load-utils/server", "loadLocales"), l(s, "$locales/main.url", "getLocale"), l(s, "$locales/data", "locales"), u(s, "$locales/main.loader.server.svelte.js", "main"), u(s, "$locales/js.loader.server.js", "js");
|
|
107
|
+
let f = s.getStatements().findIndex((e) => e === d), p = "handleWuchale", m = e`
|
|
108
|
+
loadLocales(main.key, main.loadIDs, main.loadCatalog, locales);
|
|
109
|
+
loadLocales(js.key, js.loadIDs, js.loadCatalog, locales);
|
|
110
|
+
`, h = e`
|
|
111
|
+
const ${p} = async ({ event, resolve }: any) => {
|
|
112
|
+
const locale = getLocale(event.url);
|
|
113
|
+
return await runWithLocale(locale, () =>
|
|
114
|
+
resolve(event, {
|
|
115
|
+
transformPageChunk: ({ html }: { html: string }) =>
|
|
116
|
+
html.replace('%sveltekit.lang%', locale)
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
`;
|
|
121
|
+
f >= 0 ? s.insertStatements(f, `\n${m}\n\n${h}\n`) : s.addStatements(`\n${m}\n\n${h}\n`);
|
|
122
|
+
let g = c.getInitializer();
|
|
123
|
+
if (!g) return !1;
|
|
124
|
+
let _ = g.getText();
|
|
125
|
+
return _.includes(p) || _.includes("runWithLocale") ? !1 : (c.setInitializer(`sequence(${p}, ${_})`), s.formatText(), s.saveSync(), !0);
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/patterns/enable/i18n/modifies/app-html.ts
|
|
129
|
+
function f(e) {
|
|
130
|
+
if (!t.existsSync(e)) return !1;
|
|
131
|
+
let n = t.readFileSync(e, "utf8");
|
|
132
|
+
if (n.includes("lang=\"%sveltekit.lang%\"") || n.includes("lang='%sveltekit.lang%'")) return !1;
|
|
133
|
+
let r = n.replace(/<html(\s[^>]*?)?>/i, (e) => /lang\s*=/.test(e) ? e : e.replace(/<html/i, "<html lang=\"%sveltekit.lang%\""));
|
|
134
|
+
return r === n ? !1 : (t.writeFileSync(e, r), !0);
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/patterns/enable/i18n/modifies/gitignore.ts
|
|
138
|
+
function p(n) {
|
|
139
|
+
if (!t.existsSync(n)) return !1;
|
|
140
|
+
let r = t.readFileSync(n, "utf8");
|
|
141
|
+
if (r.includes("src/locales/.wuchale")) return !1;
|
|
142
|
+
let i = e`
|
|
143
|
+
# Wuchale
|
|
144
|
+
src/locales/.wuchale
|
|
145
|
+
`, a = r + (r.length > 0 && !r.endsWith("\n") ? "\n" : "") + "\n" + i + "\n";
|
|
146
|
+
return t.writeFileSync(n, a), !0;
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/patterns/enable/i18n/modifies/+layout.ts
|
|
150
|
+
function m(r) {
|
|
151
|
+
if (t.existsSync(r)) {
|
|
152
|
+
let e = t.readFileSync(r, "utf8");
|
|
153
|
+
if (e.includes("loadLocale") || e.includes("translateUrl") || /\bexport\s+(const|function)\s+load\b/.test(e)) return !1;
|
|
154
|
+
}
|
|
155
|
+
let i = e`
|
|
156
|
+
import { browser } from '$app/environment';
|
|
157
|
+
import { loadLocale } from 'wuchale/load-utils';
|
|
158
|
+
|
|
159
|
+
import { getLocale } from '$locales/main.url';
|
|
160
|
+
import '$locales/main.loader.svelte';
|
|
161
|
+
import '$locales/js.loader';
|
|
162
|
+
|
|
163
|
+
export const load = async ({ url, data }) => {
|
|
164
|
+
const locale = getLocale(url);
|
|
165
|
+
|
|
166
|
+
if (browser) {
|
|
167
|
+
await loadLocale(locale);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return data;
|
|
171
|
+
};
|
|
172
|
+
`;
|
|
173
|
+
return t.mkdirSync(n.dirname(r), { recursive: !0 }), t.writeFileSync(r, i + "\n"), !0;
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/patterns/enable/i18n/generate.runtime.ts
|
|
177
|
+
function h(e, r) {
|
|
178
|
+
for (let i of r) {
|
|
179
|
+
let r = n.join(e, i);
|
|
180
|
+
if (t.existsSync(r)) return r;
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
function g(e, n, r) {
|
|
185
|
+
!r || !t.existsSync(n) || e.push({
|
|
186
|
+
path: n,
|
|
187
|
+
language: n.endsWith(".svelte") ? "svelte" : n.endsWith(".ts") ? "ts" : n.endsWith(".js") ? "js" : "text",
|
|
188
|
+
content: t.readFileSync(n, "utf8")
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
async function _(e) {
|
|
192
|
+
let t = [], r = h(e.root, [
|
|
193
|
+
"vite.config.ts",
|
|
194
|
+
"vite.config.js",
|
|
195
|
+
"vite.config.mjs",
|
|
196
|
+
"vite.config.cjs"
|
|
197
|
+
]);
|
|
198
|
+
r && g(t, r, o(r));
|
|
199
|
+
let i = h(e.root, [
|
|
200
|
+
"svelte.config.ts",
|
|
201
|
+
"svelte.config.js",
|
|
202
|
+
"svelte.config.mjs",
|
|
203
|
+
"svelte.config.cjs"
|
|
204
|
+
]);
|
|
205
|
+
i && g(t, i, c(i));
|
|
206
|
+
let a = n.join(e.root, "src", "hooks.server.ts");
|
|
207
|
+
g(t, a, d(a));
|
|
208
|
+
let s = n.join(e.root, "src", "app.html");
|
|
209
|
+
g(t, s, f(s));
|
|
210
|
+
let l = n.join(e.root, "src", "routes", "+layout.ts");
|
|
211
|
+
g(t, l, m(l));
|
|
212
|
+
let u = n.join(e.root, ".gitignore");
|
|
213
|
+
return g(t, u, p(u)), {
|
|
214
|
+
creates: [],
|
|
215
|
+
modifies: t,
|
|
216
|
+
deletes: [],
|
|
217
|
+
components: [],
|
|
218
|
+
packages: [],
|
|
219
|
+
collections: []
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
export { _ as generate };
|
|
224
|
+
|
|
225
|
+
//# sourceMappingURL=generate.runtime-BEuc5hDN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-BEuc5hDN.js","names":[],"sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/svelte-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/+layout.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\n\nexport function modifyViteConfig(viteConfigPath: string) {\n if (!fs.existsSync(viteConfigPath)) return false;\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(viteConfigPath);\n\n let changed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as import(\"ts-morph\").ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n return changed;\n }\n\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: \"[wuchale()]\",\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n }\n\n if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n return changed;\n }\n\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n }\n\n if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n return changed;\n }\n\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n\n if (changed) {\n sourceFile.formatText();\n sourceFile.saveSync();\n }\n\n return changed;\n}\n","import fs from \"node:fs\";\nimport {\n Project,\n QuoteKind,\n SyntaxKind,\n type ObjectLiteralExpression,\n} from \"ts-morph\";\n\nfunction getOrCreateObjectLiteralProperty(\n obj: ObjectLiteralExpression,\n name: string,\n initializer: string,\n): ObjectLiteralExpression | null {\n const prop = obj.getProperty(name);\n if (!prop) {\n obj.addPropertyAssignment({ name, initializer });\n const added = obj.getProperty(name);\n if (!added || added.getKind() !== SyntaxKind.PropertyAssignment)\n return null;\n const init = (\n added as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!init || init.getKind() !== SyntaxKind.ObjectLiteralExpression)\n return null;\n return init as ObjectLiteralExpression;\n }\n\n if (prop.getKind() !== SyntaxKind.PropertyAssignment) return null;\n const init = (prop as import(\"ts-morph\").PropertyAssignment).getInitializer();\n if (!init) return null;\n if (init.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n (prop as import(\"ts-morph\").PropertyAssignment).setInitializer(initializer);\n const init2 = (\n prop as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n return init2 && init2.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (init2 as ObjectLiteralExpression)\n : null;\n }\n\n return init as ObjectLiteralExpression;\n}\n\nexport function modifySvelteConfig(svelteConfigPath: string) {\n if (!fs.existsSync(svelteConfigPath)) return false;\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(svelteConfigPath);\n\n const defaultExport = sourceFile.getExportAssignment(\n (ea) => !ea.isExportEquals(),\n );\n const exportedExpr = defaultExport?.getExpression();\n\n let configObj: ObjectLiteralExpression | null = null;\n if (exportedExpr?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObj = exportedExpr as ObjectLiteralExpression;\n } else if (exportedExpr?.getKind() === SyntaxKind.Identifier) {\n const ident = exportedExpr.getText();\n const varDecl = sourceFile.getVariableDeclaration(ident);\n const init = varDecl?.getInitializer();\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObj = init as ObjectLiteralExpression;\n }\n }\n\n if (!configObj) return false;\n\n const kitObj = getOrCreateObjectLiteralProperty(configObj, \"kit\", \"{}\");\n if (!kitObj) return false;\n\n const aliasObj = getOrCreateObjectLiteralProperty(kitObj, \"alias\", \"{}\");\n if (!aliasObj) return false;\n\n const existingLocales = aliasObj.getProperty(\"$locales\");\n if (!existingLocales) {\n aliasObj.addPropertyAssignment({\n name: \"$locales\",\n initializer: \"'src/locales'\",\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n }\n\n if (existingLocales.getKind() !== SyntaxKind.PropertyAssignment) return false;\n const init = (\n existingLocales as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n const current = init?.getText()?.replace(/['\"`]/g, \"\");\n if (current === \"src/locales\") return false;\n\n (existingLocales as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"'src/locales'\",\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\n\nfunction ensureNamedImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n name: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) {\n const has = existing.getNamedImports().some((ni) => ni.getName() === name);\n if (!has) existing.addNamedImport(name);\n return;\n }\n sourceFile.addImportDeclaration({ namedImports: [name], moduleSpecifier });\n}\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string) {\n if (!fs.existsSync(hooksServerPath)) return false;\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || original.includes(\"loadLocales(\")) {\n return false;\n }\n\n const project = new Project({\n compilerOptions: { allowJs: true },\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const handleDecl = sourceFile.getVariableDeclaration(\"handle\");\n if (!handleDecl) return false;\n\n const handleStmt = handleDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!handleStmt?.hasExportKeyword()) {\n return false;\n }\n\n ensureNamedImport(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"$locales/main.url\", \"getLocale\");\n ensureNamedImport(sourceFile, \"$locales/data\", \"locales\");\n ensureNamespaceImport(\n sourceFile,\n \"$locales/main.loader.server.svelte.js\",\n \"main\",\n );\n ensureNamespaceImport(sourceFile, \"$locales/js.loader.server.js\", \"js\");\n\n const statements = sourceFile.getStatements();\n const handleStmtIndex = statements.findIndex((s) => s === handleStmt);\n const i18nHandleName = \"handleWuchale\";\n\n const startupSnippet = dedent`\n loadLocales(main.key, main.loadIDs, main.loadCatalog, locales);\n loadLocales(js.key, js.loadIDs, js.loadCatalog, locales);\n `;\n\n const i18nHandleSnippet = dedent`\n const ${i18nHandleName} = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n `;\n\n if (handleStmtIndex >= 0) {\n sourceFile.insertStatements(\n handleStmtIndex,\n `\\n${startupSnippet}\\n\\n${i18nHandleSnippet}\\n`,\n );\n } else {\n sourceFile.addStatements(`\\n${startupSnippet}\\n\\n${i18nHandleSnippet}\\n`);\n }\n\n const init = handleDecl.getInitializer();\n if (!init) return false;\n\n const initText = init.getText();\n if (initText.includes(i18nHandleName) || initText.includes(\"runWithLocale\")) {\n return false;\n }\n\n handleDecl.setInitializer(`sequence(${i18nHandleName}, ${initText})`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return true;\n}\n","import fs from \"node:fs\";\n\nexport function modifyAppHtml(appHtmlPath: string) {\n if (!fs.existsSync(appHtmlPath)) return false;\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return false;\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n if (/lang\\s*=/.test(match)) {\n return match;\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) return false;\n fs.writeFileSync(appHtmlPath, updated);\n return true;\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\n\nexport function modifyGitignore(gitignorePath: string) {\n if (!fs.existsSync(gitignorePath)) return false;\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (original.includes(\"src/locales/.wuchale\")) return false;\n\n const block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\n return true;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\n\nexport function ensureRootLayoutI18n(layoutPath: string) {\n if (fs.existsSync(layoutPath)) {\n const existing = fs.readFileSync(layoutPath, \"utf8\");\n if (existing.includes(\"loadLocale\") || existing.includes(\"translateUrl\")) {\n return false;\n }\n\n if (/\\bexport\\s+(const|function)\\s+load\\b/.test(existing)) {\n return false;\n }\n }\n\n const snippet = dedent`\n import { browser } from '$app/environment';\n import { loadLocale } from 'wuchale/load-utils';\n\n import { getLocale } from '$locales/main.url';\n import '$locales/main.loader.svelte';\n import '$locales/js.loader';\n\n export const load = async ({ url, data }) => {\n const locale = getLocale(url);\n\n if (browser) {\n await loadLocale(locale);\n }\n\n return data;\n };\n `;\n\n fs.mkdirSync(path.dirname(layoutPath), { recursive: true });\n fs.writeFileSync(layoutPath, snippet + \"\\n\");\n return true;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifySvelteConfig } from \"./modifies/svelte-config\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\n\nfunction findFirstExistingFile(\n root: string,\n candidates: string[],\n): string | null {\n for (const relPath of candidates) {\n const absPath = path.join(root, relPath);\n if (fs.existsSync(absPath)) {\n return absPath;\n }\n }\n return null;\n}\n\nfunction pushIfChanged(modifies: File[], filePath: string, changed: boolean) {\n if (!changed || !fs.existsSync(filePath)) return;\n modifies.push({\n path: filePath,\n language: filePath.endsWith(\".svelte\")\n ? \"svelte\"\n : filePath.endsWith(\".ts\")\n ? \"ts\"\n : filePath.endsWith(\".js\")\n ? \"js\"\n : \"text\",\n content: fs.readFileSync(filePath, \"utf8\"),\n });\n}\n\nexport async function generate(options: Options) {\n const modifies: File[] = [];\n\n const viteConfigPath = findFirstExistingFile(options.root, [\n \"vite.config.ts\",\n \"vite.config.js\",\n \"vite.config.mjs\",\n \"vite.config.cjs\",\n ]);\n if (viteConfigPath) {\n pushIfChanged(modifies, viteConfigPath, modifyViteConfig(viteConfigPath));\n }\n\n const svelteConfigPath = findFirstExistingFile(options.root, [\n \"svelte.config.ts\",\n \"svelte.config.js\",\n \"svelte.config.mjs\",\n \"svelte.config.cjs\",\n ]);\n if (svelteConfigPath) {\n pushIfChanged(\n modifies,\n svelteConfigPath,\n modifySvelteConfig(svelteConfigPath),\n );\n }\n\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushIfChanged(\n modifies,\n hooksServerPath,\n modifyHooksServerI18n(hooksServerPath),\n );\n\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushIfChanged(modifies, appHtmlPath, modifyAppHtml(appHtmlPath));\n\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushIfChanged(modifies, layoutPath, ensureRootLayoutI18n(layoutPath));\n\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushIfChanged(modifies, gitignorePath, modifyGitignore(gitignorePath));\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } sat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