@velastack/patterns 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{collections-Bzyt18yv.js → collections-DdGJC7Ip.js} +5 -3
- package/dist/chunks/collections-DdGJC7Ip.js.map +1 -0
- package/dist/chunks/{generate.runtime-uPCB71Ki.js → generate.runtime-B0EfMNMf.js} +212 -134
- package/dist/chunks/generate.runtime-B0EfMNMf.js.map +1 -0
- package/dist/chunks/generate.runtime-Bt6kbkWX.js +289 -0
- package/dist/chunks/generate.runtime-Bt6kbkWX.js.map +1 -0
- package/dist/chunks/generate.runtime-BtGvtuWm.js +81 -0
- package/dist/chunks/generate.runtime-BtGvtuWm.js.map +1 -0
- package/dist/chunks/generate.runtime-CcKMIm9M.js +430 -0
- package/dist/chunks/generate.runtime-CcKMIm9M.js.map +1 -0
- package/dist/chunks/generate.runtime-DiJDMdAq.js +207 -0
- package/dist/chunks/generate.runtime-DiJDMdAq.js.map +1 -0
- package/dist/chunks/modify-file-Dxow9QKT.js +22 -0
- package/dist/chunks/modify-file-Dxow9QKT.js.map +1 -0
- package/dist/chunks/{ts-morph-helpers-BiOU9sUx.js → ts-morph-helpers-DmD7iwna.js} +1 -1
- package/dist/chunks/{ts-morph-helpers-BiOU9sUx.js.map → ts-morph-helpers-DmD7iwna.js.map} +1 -1
- package/dist/chunks/{write-result-CSxmq40z.js → write-result-DhQIE6kA.js} +4 -4
- package/dist/chunks/{write-result-CSxmq40z.js.map → write-result-DhQIE6kA.js.map} +1 -1
- package/dist/index.d.ts +50 -0
- package/dist/index.js +306 -227
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/collections-Bzyt18yv.js.map +0 -1
- package/dist/chunks/generate.runtime-BEuc5hDN.js +0 -225
- package/dist/chunks/generate.runtime-BEuc5hDN.js.map +0 -1
- package/dist/chunks/generate.runtime-CHmm4bBZ.js +0 -154
- package/dist/chunks/generate.runtime-CHmm4bBZ.js.map +0 -1
- package/dist/chunks/generate.runtime-DXkJgkP4.js +0 -232
- package/dist/chunks/generate.runtime-DXkJgkP4.js.map +0 -1
- package/dist/chunks/generate.runtime-egq8I3EA.js +0 -61
- package/dist/chunks/generate.runtime-egq8I3EA.js.map +0 -1
- package/dist/chunks/generate.runtime-uPCB71Ki.js.map +0 -1
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,225 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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 } satisfies Result;\n}\n"],"mappings":";;;;;AAGA,SAAgB,EAAiB,GAAwB;AACvD,KAAI,CAAC,EAAG,WAAW,EAAe,CAAE,QAAO;CAM3C,IAAM,IAJU,IAAI,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,IAAM;EAClC,sBAAsB,EAAE,WAAW,EAAU,QAAQ;EACtD,CAAC,CACyB,oBAAoB,EAAe,EAE1D,IAAU;AAMd,CAJkB,EACf,uBAAuB,CACvB,MAAM,MAAM,EAAE,yBAAyB,KAAK,eAAe,KAG5D,EAAW,wBAAwB,GAAG;EACpC,cAAc,CAAC,UAAU;EACzB,iBAAiB;EAClB,CAAC,EACF,IAAU;CAO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OAAO,WAAW;AAC9D,GAAc,GAAU,GAAa,EAAc,EAAY,CAAC;CAEhE,IAAM,IAAa,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,aAAa;AACzE,GAAc,GAAU,GAAY,EAAqB,EAAW,CAAC;CAErE,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,aAAa;AAG3D,QAFA,EAAc,GAAU,GAAe,EAAgB,EAAc,CAAC,EAE/D;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EAChB"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./pocketbase-CPRrN7Qs.js";
|
|
2
|
-
import { i as r, t as i } from "./ts-morph-helpers-BiOU9sUx.js";
|
|
3
|
-
import a from "node:fs";
|
|
4
|
-
import o from "node:path";
|
|
5
|
-
import { Project as s, SyntaxKind as c } from "ts-morph";
|
|
6
|
-
//#region src/patterns/enable/api-keys/modifies/hooks.server.ts
|
|
7
|
-
function l(e) {
|
|
8
|
-
let t = new s().addSourceFileAtPath(e), n = t.getDescendantsOfKind(c.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
|
|
9
|
-
if (!n) {
|
|
10
|
-
t.saveSync();
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
let r = n.getArguments();
|
|
14
|
-
if (r.length === 0) {
|
|
15
|
-
n.addArgument("{ api: { enabled: true, apiKeys: { enabled: true } } }"), t.formatText(), t.saveSync();
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
let i = r[0];
|
|
19
|
-
if (i.getKind() !== c.ObjectLiteralExpression) {
|
|
20
|
-
n.insertArgument(0, "{ api: { enabled: true, apiKeys: { enabled: true } } }"), t.formatText(), t.saveSync();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
let a = i.asKindOrThrow(c.ObjectLiteralExpression), o = a.getProperty("api");
|
|
24
|
-
if (!o) {
|
|
25
|
-
a.addPropertyAssignment({
|
|
26
|
-
name: "api",
|
|
27
|
-
initializer: "{ enabled: true, apiKeys: { enabled: true } }"
|
|
28
|
-
}), t.formatText(), t.saveSync();
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (o.getKind() === c.PropertyAssignment) {
|
|
32
|
-
let e = o.getInitializer();
|
|
33
|
-
if (e && e.getKind() === c.ObjectLiteralExpression) {
|
|
34
|
-
let t = e;
|
|
35
|
-
t.getProperty("enabled") || t.addPropertyAssignment({
|
|
36
|
-
name: "enabled",
|
|
37
|
-
initializer: "true"
|
|
38
|
-
});
|
|
39
|
-
let n = t.getProperty("apiKeys");
|
|
40
|
-
if (!n) t.addPropertyAssignment({
|
|
41
|
-
name: "apiKeys",
|
|
42
|
-
initializer: "{ enabled: true }"
|
|
43
|
-
});
|
|
44
|
-
else if (n.getKind() === c.PropertyAssignment) {
|
|
45
|
-
let e = n.getInitializer();
|
|
46
|
-
if (e && e.getKind() === c.ObjectLiteralExpression) {
|
|
47
|
-
let t = e;
|
|
48
|
-
t.getProperty("enabled") || t.addPropertyAssignment({
|
|
49
|
-
name: "enabled",
|
|
50
|
-
initializer: "true"
|
|
51
|
-
});
|
|
52
|
-
} else n.setInitializer("{ enabled: true }");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
t.formatText(), t.saveSync();
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/patterns/enable/api-keys/modifies/nav-user.svelte.ts
|
|
60
|
-
function u(e, t, n, a, o) {
|
|
61
|
-
let s = new r(e), c = !1, l = (e) => {
|
|
62
|
-
c || e((e) => {
|
|
63
|
-
let r = i(e, t, n, a, o);
|
|
64
|
-
return r.wasAdded && (c = !0), r.source;
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
return l((e) => s.modifyModuleScript(e)), c || l((e) => s.modifyScript(e)), {
|
|
68
|
-
newNavUserSnippet: s.toString(),
|
|
69
|
-
wasAdded: c
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function d(e) {
|
|
73
|
-
if (!a.existsSync(e)) return !1;
|
|
74
|
-
let { newNavUserSnippet: t, wasAdded: n } = u(a.readFileSync(e, "utf8"), "API Keys", "/api-keys", "KeyRoundIcon", "@lucide/svelte/icons/key-round");
|
|
75
|
-
return n && a.writeFileSync(e, t, "utf8"), n;
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/patterns/enable/api-keys/generate.runtime.ts
|
|
79
|
-
async function f(r) {
|
|
80
|
-
let i = [];
|
|
81
|
-
await t(r.root, async (t) => {
|
|
82
|
-
let o = await t.collections.getOne("users");
|
|
83
|
-
await t.collections.create({
|
|
84
|
-
listRule: "@request.auth.id = user.id",
|
|
85
|
-
viewRule: "@request.auth.id = user.id",
|
|
86
|
-
createRule: "@request.auth.id = user.id",
|
|
87
|
-
updateRule: "@request.auth.id = user.id",
|
|
88
|
-
deleteRule: "@request.auth.id = user.id",
|
|
89
|
-
name: "api_keys",
|
|
90
|
-
type: "base",
|
|
91
|
-
fields: [
|
|
92
|
-
{
|
|
93
|
-
collectionId: o.id,
|
|
94
|
-
maxSelect: 1,
|
|
95
|
-
name: "user",
|
|
96
|
-
type: "relation"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: "key_hash",
|
|
100
|
-
type: "text"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: "label",
|
|
104
|
-
type: "text"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: "last_used",
|
|
108
|
-
type: "date"
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
name: "created",
|
|
112
|
-
onCreate: !0,
|
|
113
|
-
onUpdate: !1,
|
|
114
|
-
type: "autodate"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: "updated",
|
|
118
|
-
onCreate: !0,
|
|
119
|
-
onUpdate: !0,
|
|
120
|
-
type: "autodate"
|
|
121
|
-
}
|
|
122
|
-
]
|
|
123
|
-
}), await e();
|
|
124
|
-
let s = n("api_keys", "created", r);
|
|
125
|
-
s && i.push({
|
|
126
|
-
path: s,
|
|
127
|
-
language: "ts",
|
|
128
|
-
content: a.readFileSync(s, "utf8")
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
let s = [], c = o.join(r.root, "src", "hooks.server.ts");
|
|
132
|
-
a.existsSync(c) && (l(c), s.push({
|
|
133
|
-
path: c,
|
|
134
|
-
language: "ts",
|
|
135
|
-
content: a.readFileSync(c, "utf8")
|
|
136
|
-
}));
|
|
137
|
-
let u = o.join(r.root, "src", "lib", "components", "nav-user.svelte");
|
|
138
|
-
return d(u) && s.push({
|
|
139
|
-
path: u,
|
|
140
|
-
language: "svelte",
|
|
141
|
-
content: a.readFileSync(u, "utf8")
|
|
142
|
-
}), {
|
|
143
|
-
creates: i,
|
|
144
|
-
modifies: s,
|
|
145
|
-
deletes: [],
|
|
146
|
-
components: [],
|
|
147
|
-
packages: [],
|
|
148
|
-
collections: []
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
//#endregion
|
|
152
|
-
export { f as generate };
|
|
153
|
-
|
|
154
|
-
//# sourceMappingURL=generate.runtime-CHmm4bBZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-CHmm4bBZ.js","names":[],"sources":["../../src/patterns/enable/api-keys/modifies/hooks.server.ts","../../src/patterns/enable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/enable/api-keys/generate.runtime.ts"],"sourcesContent":["import { Project, SyntaxKind } from \"ts-morph\";\n\nexport function modifyHooksServer(hooksServerPath: string) {\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n sourceFile.saveSync();\n return;\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(\n 0,\n `{ api: { enabled: true, apiKeys: { enabled: true } } }`,\n );\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n optionsObj.addPropertyAssignment({\n name: \"api\",\n initializer: `{ enabled: true, apiKeys: { enabled: true } }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return;\n }\n\n if (apiProp.getKind() === SyntaxKind.PropertyAssignment) {\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (apiInit && apiInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const enabledProp = apiObj.getProperty(\"enabled\");\n if (!enabledProp) {\n apiObj.addPropertyAssignment({ name: \"enabled\", initializer: \"true\" });\n }\n\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n apiObj.addPropertyAssignment({\n name: \"apiKeys\",\n initializer: `{ enabled: true }`,\n });\n } else if (apiKeysProp.getKind() === SyntaxKind.PropertyAssignment) {\n const keysInit = (\n apiKeysProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (\n keysInit &&\n keysInit.getKind() === SyntaxKind.ObjectLiteralExpression\n ) {\n const keysObj =\n keysInit as import(\"ts-morph\").ObjectLiteralExpression;\n const keysEnabled = keysObj.getProperty(\"enabled\");\n if (!keysEnabled) {\n keysObj.addPropertyAssignment({\n name: \"enabled\",\n initializer: \"true\",\n });\n }\n } else {\n (apiKeysProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `{ enabled: true }`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n}\n","import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { addNavItemToScript } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function addItemToNavUser(\n navUserSnippet: string,\n title: string,\n url: string,\n icon: string,\n iconImportPath: string,\n): { newNavUserSnippet: string; wasAdded: boolean } {\n const file = new SvelteFile(navUserSnippet);\n let wasAdded = false;\n\n const tryAdd = (run: (fn: (s: string) => string) => boolean) => {\n if (wasAdded) return;\n run((source) => {\n const result = addNavItemToScript(\n source,\n title,\n url,\n icon,\n iconImportPath,\n );\n if (result.wasAdded) wasAdded = true;\n return result.source;\n });\n };\n\n tryAdd((fn) => file.modifyModuleScript(fn));\n if (!wasAdded) tryAdd((fn) => file.modifyScript(fn));\n\n return { newNavUserSnippet: file.toString(), wasAdded };\n}\n\nexport function modifyNavUser(navUserPath: string): boolean {\n if (!fs.existsSync(navUserPath)) return false;\n\n const navUserSnippet = fs.readFileSync(navUserPath, \"utf8\");\n const { newNavUserSnippet, wasAdded } = addItemToNavUser(\n navUserSnippet,\n \"API Keys\",\n \"/api-keys\",\n \"KeyRoundIcon\",\n \"@lucide/svelte/icons/key-round\",\n );\n\n if (wasAdded) {\n fs.writeFileSync(navUserPath, newNavUserSnippet, \"utf8\");\n }\n\n return wasAdded;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\nimport { modifyNavUser } from \"./modifies/nav-user.svelte\";\n\nexport async function generate(options: Options) {\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n const userCollection = await pb.collections.getOne(\"users\");\n\n await pb.collections.create({\n listRule: \"@request.auth.id = user.id\",\n viewRule: \"@request.auth.id = user.id\",\n createRule: \"@request.auth.id = user.id\",\n updateRule: \"@request.auth.id = user.id\",\n deleteRule: \"@request.auth.id = user.id\",\n name: \"api_keys\",\n type: \"base\",\n fields: [\n {\n collectionId: userCollection.id,\n maxSelect: 1,\n name: \"user\",\n type: \"relation\",\n },\n {\n name: \"key_hash\",\n type: \"text\",\n },\n {\n name: \"label\",\n type: \"text\",\n },\n {\n name: \"last_used\",\n type: \"date\",\n },\n {\n name: \"created\",\n onCreate: true,\n onUpdate: false,\n type: \"autodate\",\n },\n {\n name: \"updated\",\n onCreate: true,\n onUpdate: true,\n type: \"autodate\",\n },\n ],\n });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"api_keys\", \"created\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n });\n }\n });\n\n const modifies: File[] = [];\n\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n if (fs.existsSync(hooksServerPath)) {\n modifyHooksServer(hooksServerPath);\n modifies.push({\n path: hooksServerPath,\n language: \"ts\",\n content: fs.readFileSync(hooksServerPath, \"utf8\"),\n });\n }\n\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n if (modifyNavUser(navUserPath)) {\n modifies.push({\n path: navUserPath,\n language: \"svelte\",\n content: fs.readFileSync(navUserPath, \"utf8\"),\n });\n }\n\n return {\n creates,\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;AAEA,SAAgB,EAAkB,GAAyB;CAEzD,IAAM,IADU,IAAI,GAAS,CACF,oBAAoB,EAAgB,EAEzD,IAAW,EACd,qBAAqB,EAAW,eAAe,CAC/C,MAAM,MAAO,EAAG,eAAe,CAAC,SAAS,KAAK,mBAAmB;AAEpE,KAAI,CAAC,GAAU;AACb,IAAW,UAAU;AACrB;;CAGF,IAAM,IAAO,EA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