@velastack/patterns 0.0.56 → 0.0.58
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-BwO27pJg.js → collections-CkCADMyb.js} +2 -2
- package/dist/chunks/{collections-BwO27pJg.js.map → collections-CkCADMyb.js.map} +1 -1
- package/dist/chunks/config-target-C1u-fbTo.js +163 -0
- package/dist/chunks/config-target-C1u-fbTo.js.map +1 -0
- package/dist/chunks/{env-Bk-LRVos.js → env-BqHJ-kSa.js} +1 -1
- package/dist/chunks/{env-Bk-LRVos.js.map → env-BqHJ-kSa.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D1wqmaXU.js → generate.runtime-0SzpMzxU.js} +2 -2
- package/dist/chunks/{generate.runtime-D1wqmaXU.js.map → generate.runtime-0SzpMzxU.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CrAHzaEW.js → generate.runtime-B2Er8H7-.js} +2 -2
- package/dist/chunks/{generate.runtime-CrAHzaEW.js.map → generate.runtime-B2Er8H7-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BnkNmF1g.js → generate.runtime-BWDfruiV.js} +1 -1
- package/dist/chunks/{generate.runtime-BnkNmF1g.js.map → generate.runtime-BWDfruiV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DFDFxHih.js → generate.runtime-BitkLnIB.js} +2 -2
- package/dist/chunks/{generate.runtime-DFDFxHih.js.map → generate.runtime-BitkLnIB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DFG2C9gc.js → generate.runtime-Bkg4iGwz.js} +4 -4
- package/dist/chunks/generate.runtime-Bkg4iGwz.js.map +1 -0
- package/dist/chunks/{generate.runtime-Bpx69a8t.js → generate.runtime-BlAf07l8.js} +4 -4
- package/dist/chunks/{generate.runtime-Bpx69a8t.js.map → generate.runtime-BlAf07l8.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cb2vYF1l.js → generate.runtime-BlW1FmJq.js} +1 -1
- package/dist/chunks/{generate.runtime-Cb2vYF1l.js.map → generate.runtime-BlW1FmJq.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CEtVUz4k.js → generate.runtime-ByLGQwE6.js} +4 -4
- package/dist/chunks/{generate.runtime-CEtVUz4k.js.map → generate.runtime-ByLGQwE6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DjwRKg8K.js → generate.runtime-C22xL49X.js} +120 -194
- package/dist/chunks/generate.runtime-C22xL49X.js.map +1 -0
- package/dist/chunks/{generate.runtime-DPzrDUU7.js → generate.runtime-CFOYi6Sf.js} +2 -2
- package/dist/chunks/{generate.runtime-DPzrDUU7.js.map → generate.runtime-CFOYi6Sf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DQLmiRz6.js → generate.runtime-CMdKTf_0.js} +6 -6
- package/dist/chunks/generate.runtime-CMdKTf_0.js.map +1 -0
- package/dist/chunks/{generate.runtime-DnymXcvu.js → generate.runtime-CRovTioN.js} +2 -2
- package/dist/chunks/{generate.runtime-DnymXcvu.js.map → generate.runtime-CRovTioN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-M6LNL7Tq.js → generate.runtime-CUR-kles.js} +55 -80
- package/dist/chunks/generate.runtime-CUR-kles.js.map +1 -0
- package/dist/chunks/{generate.runtime-D6oE0Mmf.js → generate.runtime-CYp6zwqL.js} +4 -4
- package/dist/chunks/{generate.runtime-D6oE0Mmf.js.map → generate.runtime-CYp6zwqL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CUgleG0U.js → generate.runtime-DdjZK-Sk.js} +1 -1
- package/dist/chunks/{generate.runtime-CUgleG0U.js.map → generate.runtime-DdjZK-Sk.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bbf2YWaA.js → generate.runtime-HV5Dqu9a.js} +1 -1
- package/dist/chunks/{generate.runtime-Bbf2YWaA.js.map → generate.runtime-HV5Dqu9a.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BkvtIjgh.js → generate.runtime-cLVzf30y.js} +2 -2
- package/dist/chunks/{generate.runtime-BkvtIjgh.js.map → generate.runtime-cLVzf30y.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D1uQBjeg.js → generate.runtime-t6rqiv36.js} +72 -72
- package/dist/chunks/{generate.runtime-D1uQBjeg.js.map → generate.runtime-t6rqiv36.js.map} +1 -1
- package/dist/chunks/{generate2.runtime-yP14iPwX.js → generate2.runtime-DLe5zNsJ.js} +3 -3
- package/dist/chunks/{generate2.runtime-yP14iPwX.js.map → generate2.runtime-DLe5zNsJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cudp67b-.js → generate2.runtime-Dm_sXXFY.js} +1 -1
- package/dist/chunks/generate2.runtime-Dm_sXXFY.js.map +1 -0
- package/dist/chunks/modify-svelte-config-remote-DvpeGxB-.js +44 -0
- package/dist/chunks/modify-svelte-config-remote-DvpeGxB-.js.map +1 -0
- package/dist/chunks/{modify-utils-CZ9Auvp9.js → modify-utils-D5W--csL.js} +1 -1
- package/dist/chunks/{modify-utils-CZ9Auvp9.js.map → modify-utils-D5W--csL.js.map} +1 -1
- package/dist/chunks/{pocketbase-D7GjPuNu.js → pocketbase--poMYyvc.js} +1 -1
- package/dist/chunks/{pocketbase-D7GjPuNu.js.map → pocketbase--poMYyvc.js.map} +1 -1
- package/dist/chunks/{shared-C4wJ9sb0.js → shared-C_Bl1V62.js} +2 -2
- package/dist/chunks/{shared-C4wJ9sb0.js.map → shared-C_Bl1V62.js.map} +1 -1
- package/dist/chunks/{test-setup-C3gvjtTY.js → test-setup-BQFmAjD0.js} +86 -64
- package/dist/chunks/test-setup-BQFmAjD0.js.map +1 -0
- package/dist/chunks/{write-result-I15cELAq.js → write-result-B2ucfJ6m.js} +3 -3
- package/dist/chunks/{write-result-I15cELAq.js.map → write-result-B2ucfJ6m.js.map} +1 -1
- package/dist/index.js +184 -184
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/generate.runtime-Cudp67b-.js.map +0 -1
- package/dist/chunks/generate.runtime-DFG2C9gc.js.map +0 -1
- package/dist/chunks/generate.runtime-DQLmiRz6.js.map +0 -1
- package/dist/chunks/generate.runtime-DjwRKg8K.js.map +0 -1
- package/dist/chunks/generate.runtime-M6LNL7Tq.js.map +0 -1
- package/dist/chunks/modify-svelte-config-remote-C3g7Oi6_.js +0 -128
- package/dist/chunks/modify-svelte-config-remote-C3g7Oi6_.js.map +0 -1
- package/dist/chunks/test-setup-C3gvjtTY.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-HV5Dqu9a.js","names":[],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(gitignorePath, \"utf8\");\n if (!original.includes(\"src/locales/.wuchale\")) {\n return { status: \"success\", changed: false };\n }\n\n const lines = original.split(\"\\n\");\n const out: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line === \"# Wuchale\") {\n let j = i + 1;\n let hasWuchale = false;\n while (j < lines.length && lines[j].trim() !== \"\") {\n if (lines[j] === \"src/locales/.wuchale\") {\n hasWuchale = true;\n }\n j++;\n }\n if (hasWuchale) {\n i = j;\n continue;\n }\n }\n if (line === \"src/locales/.wuchale\") continue;\n out.push(line);\n }\n\n let updated = out.join(\"\\n\");\n updated = updated.replace(/\\n{3,}/g, \"\\n\\n\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\n\nconst MANUAL_REMEDIATION = [\n \"vite.config, svelte.config, hooks.server, app.html, and +layout.ts must be reverted manually.\",\n \"The i18n integration touches these files in ways that are not safely reversible by tooling.\",\n \"See the enable-i18n modifies for the blocks to remove.\",\n].join(\" \");\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, unmodifyGitignore(gitignorePath)),\n );\n\n logger.info(MANUAL_REMEDIATION);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;AAGA,SAAgB,EAAkB,GAAsC;AACtE,KAAI,CAAC,EAAG,WAAW,EAAc,CAC/B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAW,EAAG,aAAa,GAAe,OAAO;AACvD,KAAI,CAAC,EAAS,SAAS,uBAAuB,CAC5C,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAQ,EAAS,MAAM,KAAK,EAC5B,IAAgB,EAAE;AACxB,MAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAAK;EACrC,IAAM,IAAO,EAAM;AACnB,MAAI,MAAS,aAAa;GACxB,IAAI,IAAI,IAAI,GACR,IAAa;AACjB,UAAO,IAAI,EAAM,UAAU,EAAM,GAAG,MAAM,KAAK,IAI7C,CAHI,EAAM,OAAO,2BACf,IAAa,KAEf;AAEF,OAAI,GAAY;AACd,QAAI;AACJ;;;AAGA,QAAS,0BACb,EAAI,KAAK,EAAK;;CAGhB,IAAI,IAAU,EAAI,KAAK,KAAK;AAQ5B,QAPA,IAAU,EAAQ,QAAQ,WAAW,OAAO,EAExC,MAAY,IACP;EAAE,QAAQ;EAAW,SAAS;EAAO,IAG9C,EAAG,cAAc,GAAe,EAAQ,EACjC;EAAE,QAAQ;EAAW,SAAS;EAAM;;;;ACrC7C,IAAM,IAAqB;CACzB;CACA;CACA;CACD,CAAC,KAAK,IAAI;AAEX,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,uBAAuB;CACnC,IAAM,IAAgB,EAAK,KAAK,EAAQ,MAAM,aAAa;AAO3D,QANA,EACE,EAAoB,GAAe,EAAkB,EAAc,CAAC,CACrE,EAED,EAAO,KAAK,EAAmB,EAExB;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAE;EACpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./logger-BpgCb-ZG.js";
|
|
2
|
-
import { t } from "./shared-
|
|
2
|
+
import { t } from "./shared-C_Bl1V62.js";
|
|
3
3
|
import { modifyOutcomeToFile as n } from "./modify-file-DE7tPADZ.js";
|
|
4
4
|
import { i as r, o as i } from "./ts-morph-helpers-bR0-x04t.js";
|
|
5
5
|
import a from "node:fs";
|
|
@@ -57,4 +57,4 @@ async function l(r) {
|
|
|
57
57
|
//#endregion
|
|
58
58
|
export { l as generate };
|
|
59
59
|
|
|
60
|
-
//# sourceMappingURL=generate.runtime-
|
|
60
|
+
//# sourceMappingURL=generate.runtime-cLVzf30y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-cLVzf30y.js","names":[],"sources":["../../src/patterns/disable/teams/modifies/modify-nav-user.ts","../../src/patterns/disable/teams/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/teams\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Teams\",\n \"@lucide/svelte/icons/users\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\nconst MANUAL_REMEDIATION = [\n \"app-sidebar, +layout.server.ts (teams loader), and app-layout.svelte (AppSidebar team props) must be reverted manually.\",\n \"These edits are substantial and are not safely reversed by tooling.\",\n].join(\" \");\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserCandidates = [\n path.join(options.root, \"src\", \"lib\", \"components\", \"nav-user.svelte\"),\n ];\n const navUserPath =\n navUserCandidates.find((p) => fs.existsSync(p)) ?? navUserCandidates[0];\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(MANUAL_REMEDIATION);\n\n const collectionDrops = await planDropsForCollections(\n [\"team_invite_links\", \"team_invites\", \"team_memberships\", \"teams\"],\n options,\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,EAAgB,GAAoC;AAClE,KAAI,CAAC,EAAG,WAAW,EAAY,CAC7B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAS,EAAG,aAAa,GAAa,OAAO;AACnD,KAAI,CAAC,EAAO,SAAS,SAAS,CAC5B,QAAO;EAAE,QAAQ;EAAW,SAAS;EAAO;CAG9C,IAAM,IAAO,IAAI,EAAW,EAAO,EAC/B,IAAa,IAEX,KAAa,MAAgD;AAC7D,OACJ,GAAK,MAAQ;GACX,IAAM,IAAS,EACb,GACA,SACA,6BACD;AAED,UADI,EAAO,eAAY,IAAa,KAC7B,EAAO;IACd;;AAWJ,QARA,GAAW,MAAO,EAAK,mBAAmB,EAAG,CAAC,EACzC,KAAY,GAAW,MAAO,EAAK,aAAa,EAAG,CAAC,EAEpD,KAIL,EAAG,cAAc,GAAa,EAAK,UAAU,EAAE,OAAO,EAC/C;EAAE,QAAQ;EAAW,SAAS;EAAM,IAJlC;EAAE,QAAQ;EAAW,SAAS;EAAO;;;;AC3BhD,IAAM,IAAqB,CACzB,2HACA,sEACD,CAAC,KAAK,IAAI;AAEX,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,EAAQ,EAC3B,IAAmB,EAAE,EACrB,KAAc,MAAsB;AACxC,EAAI,KAAM,EAAS,KAAK,EAAK;;AAG/B,GAAO,KAAK,4BAA4B;CACxC,IAAM,IAAoB,CACxB,EAAK,KAAK,EAAQ,MAAM,OAAO,OAAO,cAAc,kBAAkB,CACvE,EACK,IACJ,EAAkB,MAAM,MAAM,EAAG,WAAW,EAAE,CAAC,IAAI,EAAkB;AAUvE,QATA,EAAW,EAAoB,GAAa,EAAgB,EAAY,CAAC,CAAC,EAE1E,EAAO,KAAK,EAAmB,EAOxB;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAbsB,MAAM,EAC5B;GAAC;GAAqB;GAAgB;GAAoB;GAAQ,EAClE,EACD;EAWA"}
|
|
@@ -2,40 +2,40 @@ import { t as e } from "./dedent-C4qKBQXh.js";
|
|
|
2
2
|
import { n as t } from "./logger-BpgCb-ZG.js";
|
|
3
3
|
import { modifyOutcomeToFile as n } from "./modify-file-DE7tPADZ.js";
|
|
4
4
|
import { a as r, n as i, o as a } from "./ts-morph-helpers-bR0-x04t.js";
|
|
5
|
-
import { getMigrationFile as o, migrationDelay as s, withPocketbase as c } from "./pocketbase
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { Project as
|
|
5
|
+
import { getMigrationFile as o, migrationDelay as s, withPocketbase as c } from "./pocketbase--poMYyvc.js";
|
|
6
|
+
import { modifySvelteConfigRemote as l } from "./modify-svelte-config-remote-DvpeGxB-.js";
|
|
7
|
+
import u from "node:fs";
|
|
8
|
+
import d from "node:path";
|
|
9
|
+
import { Project as f, SyntaxKind as p } from "ts-morph";
|
|
10
10
|
//#region src/patterns/enable/auth-remote/modifies/+layout.server.ts
|
|
11
|
-
function
|
|
12
|
-
if (!
|
|
11
|
+
function m(t) {
|
|
12
|
+
if (!u.existsSync(t)) {
|
|
13
13
|
let n = e`
|
|
14
14
|
export const load = async ({ locals }) => {
|
|
15
15
|
return { user: locals.pb.authStore.record };
|
|
16
16
|
};
|
|
17
17
|
`;
|
|
18
|
-
return
|
|
18
|
+
return u.writeFileSync(t, n), {
|
|
19
19
|
status: "success",
|
|
20
20
|
changed: !0
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
let n =
|
|
23
|
+
let n = u.readFileSync(t, "utf8"), r = new f().addSourceFileAtPath(t), i = (e) => {
|
|
24
24
|
e.getProperty("user") || e.addPropertyAssignment({
|
|
25
25
|
name: "user",
|
|
26
26
|
initializer: "locals.pb.authStore.record"
|
|
27
27
|
});
|
|
28
28
|
}, a, o, s = r.getVariableDeclaration("load");
|
|
29
|
-
if (s && s.getFirstAncestorByKind(
|
|
30
|
-
let e = s.getInitializerIfKind(
|
|
29
|
+
if (s && s.getFirstAncestorByKind(p.VariableStatement)?.hasExportKeyword()) {
|
|
30
|
+
let e = s.getInitializerIfKind(p.ArrowFunction);
|
|
31
31
|
if (e) a = e;
|
|
32
32
|
else {
|
|
33
33
|
let e = s.getInitializer();
|
|
34
34
|
if (e) {
|
|
35
|
-
let t = e.getFirstDescendantByKind(
|
|
35
|
+
let t = e.getFirstDescendantByKind(p.ArrowFunction);
|
|
36
36
|
if (t) a = t;
|
|
37
37
|
else {
|
|
38
|
-
let t = e.getFirstDescendantByKind(
|
|
38
|
+
let t = e.getFirstDescendantByKind(p.FunctionExpression);
|
|
39
39
|
t && (o = t);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -59,7 +59,7 @@ function h(t) {
|
|
|
59
59
|
if (l.length === 0) c.insertParameter(0, { name: "{ locals }" });
|
|
60
60
|
else {
|
|
61
61
|
let e = l[0], t = e.getStructure(), n = e.getNameNode();
|
|
62
|
-
if (n.getKind() ===
|
|
62
|
+
if (n.getKind() === p.ObjectBindingPattern) {
|
|
63
63
|
let r = n;
|
|
64
64
|
if (!r.getElements().some((e) => e.getName() === "locals")) {
|
|
65
65
|
let n = r.getElements().map((e) => e.getText()).filter(Boolean), i = n.length > 0 ? ", " + n.join(", ") : "";
|
|
@@ -80,32 +80,32 @@ function h(t) {
|
|
|
80
80
|
}
|
|
81
81
|
if (a) {
|
|
82
82
|
let e = a.getBody();
|
|
83
|
-
if (e.getKind() ===
|
|
83
|
+
if (e.getKind() === p.Block) e.getDescendantsOfKind(p.ReturnStatement).forEach((e) => {
|
|
84
84
|
let t = e.getExpression();
|
|
85
85
|
if (t) {
|
|
86
|
-
if (t.getKind() ===
|
|
87
|
-
else if (t.getKind() ===
|
|
86
|
+
if (t.getKind() === p.ObjectLiteralExpression) i(t);
|
|
87
|
+
else if (t.getKind() === p.ParenthesizedExpression) {
|
|
88
88
|
let e = t.getExpression();
|
|
89
|
-
e.getKind() ===
|
|
89
|
+
e.getKind() === p.ObjectLiteralExpression && i(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
93
|
else {
|
|
94
94
|
let t = e;
|
|
95
|
-
if (t.getKind() ===
|
|
95
|
+
if (t.getKind() === p.ParenthesizedExpression) {
|
|
96
96
|
let e = t.getExpression();
|
|
97
|
-
e.getKind() ===
|
|
98
|
-
} else t.getKind() ===
|
|
97
|
+
e.getKind() === p.ObjectLiteralExpression && i(e);
|
|
98
|
+
} else t.getKind() === p.ObjectLiteralExpression && i(t);
|
|
99
99
|
}
|
|
100
100
|
} else if (o) {
|
|
101
101
|
let e = o.getBody();
|
|
102
|
-
e && e.getDescendantsOfKind(
|
|
102
|
+
e && e.getDescendantsOfKind(p.ReturnStatement).forEach((e) => {
|
|
103
103
|
let t = e.getExpression();
|
|
104
104
|
if (t) {
|
|
105
|
-
if (t.getKind() ===
|
|
106
|
-
else if (t.getKind() ===
|
|
105
|
+
if (t.getKind() === p.ObjectLiteralExpression) i(t);
|
|
106
|
+
else if (t.getKind() === p.ParenthesizedExpression) {
|
|
107
107
|
let e = t.getExpression();
|
|
108
|
-
e.getKind() ===
|
|
108
|
+
e.getKind() === p.ObjectLiteralExpression && i(e);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
});
|
|
@@ -117,32 +117,32 @@ function h(t) {
|
|
|
117
117
|
}
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts
|
|
120
|
-
var
|
|
120
|
+
var h = "\n <Navbar.Item\n class=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n >\n <AuthMenu.Root>\n {#snippet user()}\n <AuthMenu.Trigger>\n <Avatar.Root>\n {#if data.user?.avatar}\n <Avatar.Image\n src=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n alt={data.user?.email}\n />\n {/if}\n <Avatar.Fallback>\n {data.user?.email?.charAt(0).toUpperCase()}\n </Avatar.Fallback>\n </Avatar.Root>\n </AuthMenu.Trigger>\n\n <AuthMenu.Content align=\"end\">\n <AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n <AuthMenu.Group>\n <AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n <AuthMenu.Item>\n <form action=\"/logout\" method=\"post\">\n <button type=\"submit\" class=\"contents\">Logout</button>\n </form>\n </AuthMenu.Item>\n </AuthMenu.Group>\n </AuthMenu.Content>\n {/snippet}\n\n {#snippet guest()}\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"ghost\"\n href=\"/login\">Login</Button\n >\n <Button\n class=\"w-full justify-start md:justify-center md:w-auto\"\n variant=\"outline\"\n href=\"/signup\">Sign up</Button\n >\n {/snippet}\n </AuthMenu.Root>\n </Navbar.Item>\n ", g = e`
|
|
121
121
|
import * as AuthMenu from '$lib/components/ui/auth-menu';
|
|
122
122
|
import * as Avatar from '$lib/components/ui/avatar';
|
|
123
|
-
`,
|
|
123
|
+
`, _ = [
|
|
124
124
|
"Add the auth menu inside your <Navbar.List> in the root layout.",
|
|
125
125
|
"",
|
|
126
126
|
"Imports to add to the <script> tag:",
|
|
127
127
|
"",
|
|
128
|
-
|
|
128
|
+
g,
|
|
129
129
|
"",
|
|
130
130
|
"Markup to add inside <Navbar.List>:",
|
|
131
|
-
|
|
132
|
-
].join("\n"),
|
|
131
|
+
h
|
|
132
|
+
].join("\n"), v = [
|
|
133
133
|
"Create a root layout that includes an auth menu inside <Navbar.List>.",
|
|
134
134
|
"",
|
|
135
135
|
"Imports for the <script> tag:",
|
|
136
136
|
"",
|
|
137
|
-
|
|
137
|
+
g,
|
|
138
138
|
"",
|
|
139
139
|
"Markup inside <Navbar.List>:",
|
|
140
|
-
|
|
140
|
+
h
|
|
141
141
|
].join("\n");
|
|
142
|
-
function
|
|
143
|
-
if (!
|
|
142
|
+
function y(e) {
|
|
143
|
+
if (!u.existsSync(e)) return {
|
|
144
144
|
status: "not-found",
|
|
145
|
-
message:
|
|
145
|
+
message: v
|
|
146
146
|
};
|
|
147
147
|
let t = a.fromPath(e);
|
|
148
148
|
return t.hasElement("Navbar.List") ? t.hasElement("AuthMenu.Root") ? {
|
|
@@ -159,23 +159,23 @@ function b(e) {
|
|
|
159
159
|
}]);
|
|
160
160
|
});
|
|
161
161
|
return t;
|
|
162
|
-
}), t.insertBeforeClosingTag("Navbar.List",
|
|
162
|
+
}), t.insertBeforeClosingTag("Navbar.List", h), t.writeTo(e), {
|
|
163
163
|
status: "success",
|
|
164
164
|
changed: t.hasChanged()
|
|
165
165
|
}) : {
|
|
166
166
|
status: "failed",
|
|
167
|
-
message:
|
|
167
|
+
message: _
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/patterns/enable/auth-remote/modifies/hooks.server.ts
|
|
172
|
-
var
|
|
172
|
+
var b = e`
|
|
173
173
|
Configure handlePocketbase() with the auth option in hooks.server.ts:
|
|
174
174
|
|
|
175
175
|
handlePocketbase({
|
|
176
176
|
auth: { protectedRoutes: ['/(app)'] },
|
|
177
177
|
});
|
|
178
|
-
`,
|
|
178
|
+
`, x = e`
|
|
179
179
|
Create src/hooks.server.ts with handlePocketbase:
|
|
180
180
|
|
|
181
181
|
import { handlePocketbase } from 'velastack/handle';
|
|
@@ -184,15 +184,15 @@ var x = e`
|
|
|
184
184
|
auth: { protectedRoutes: ['/(app)'] },
|
|
185
185
|
});
|
|
186
186
|
`;
|
|
187
|
-
function
|
|
188
|
-
if (!
|
|
187
|
+
function S(e) {
|
|
188
|
+
if (!u.existsSync(e)) return {
|
|
189
189
|
status: "not-found",
|
|
190
|
-
message:
|
|
190
|
+
message: x
|
|
191
191
|
};
|
|
192
|
-
let t =
|
|
192
|
+
let t = u.readFileSync(e, "utf8"), n = new f().addSourceFileAtPath(e), r = n.getDescendantsOfKind(p.CallExpression).find((e) => e.getExpression().getText() === "handlePocketbase");
|
|
193
193
|
if (!r) return {
|
|
194
194
|
status: "failed",
|
|
195
|
-
message:
|
|
195
|
+
message: b
|
|
196
196
|
};
|
|
197
197
|
let i = r.getArguments();
|
|
198
198
|
if (i.length === 0) return r.addArgument("{ auth: { protectedRoutes: ['/(app)'] } }"), n.formatText(), n.saveSync(), {
|
|
@@ -200,11 +200,11 @@ function C(e) {
|
|
|
200
200
|
changed: !0
|
|
201
201
|
};
|
|
202
202
|
let a = i[0];
|
|
203
|
-
if (a.getKind() !==
|
|
203
|
+
if (a.getKind() !== p.ObjectLiteralExpression) return r.insertArgument(0, "{ auth: { protectedRoutes: ['/(app)'] } }"), n.formatText(), n.saveSync(), {
|
|
204
204
|
status: "success",
|
|
205
205
|
changed: !0
|
|
206
206
|
};
|
|
207
|
-
let o = a.asKindOrThrow(
|
|
207
|
+
let o = a.asKindOrThrow(p.ObjectLiteralExpression), s = o.getProperty("auth");
|
|
208
208
|
if (!s) return o.addPropertyAssignment({
|
|
209
209
|
name: "auth",
|
|
210
210
|
initializer: "{ protectedRoutes: ['/(app)'] }"
|
|
@@ -212,17 +212,17 @@ function C(e) {
|
|
|
212
212
|
status: "success",
|
|
213
213
|
changed: !0
|
|
214
214
|
};
|
|
215
|
-
if (s.getKind() ===
|
|
215
|
+
if (s.getKind() === p.PropertyAssignment) {
|
|
216
216
|
let e = s.getInitializer();
|
|
217
|
-
if (e && e.getKind() ===
|
|
217
|
+
if (e && e.getKind() === p.ObjectLiteralExpression) {
|
|
218
218
|
let t = e, n = t.getProperty("protectedRoutes");
|
|
219
219
|
if (!n) t.addPropertyAssignment({
|
|
220
220
|
name: "protectedRoutes",
|
|
221
221
|
initializer: "['/(app)']"
|
|
222
222
|
});
|
|
223
|
-
else if (n.getKind() ===
|
|
223
|
+
else if (n.getKind() === p.PropertyAssignment) {
|
|
224
224
|
let e = n.getInitializer();
|
|
225
|
-
if (e && e.getKind() ===
|
|
225
|
+
if (e && e.getKind() === p.ArrayLiteralExpression) {
|
|
226
226
|
let t = e;
|
|
227
227
|
t.getElements().some((e) => e.getText().replace(/['"`]/g, "") === "/(app)") || t.addElement("'/(app)'");
|
|
228
228
|
} else n.setInitializer("['/(app)']");
|
|
@@ -236,7 +236,7 @@ function C(e) {
|
|
|
236
236
|
}
|
|
237
237
|
//#endregion
|
|
238
238
|
//#region src/patterns/enable/auth-remote/generate.runtime.ts
|
|
239
|
-
async function
|
|
239
|
+
async function C(e) {
|
|
240
240
|
let { input: r } = e, i = t(e), a = [];
|
|
241
241
|
await c(e.root, async (t) => {
|
|
242
242
|
i.info("Updating PocketBase mail settings"), await t.settings.update({ meta: {
|
|
@@ -245,7 +245,7 @@ async function w(e) {
|
|
|
245
245
|
} }), await s();
|
|
246
246
|
let n = await t.collections.getOne("users");
|
|
247
247
|
if (!n) throw Error("Users collection not found");
|
|
248
|
-
let c = n.verificationTemplate.body.replace("{APP_URL}/_/#/auth/confirm-verification/{TOKEN}", "{APP_URL}/confirm-verification/{TOKEN}"), l = n.resetPasswordTemplate.body.replace("{APP_URL}/_/#/auth/confirm-reset/{TOKEN}", "{APP_URL}/confirm-reset/{TOKEN}"),
|
|
248
|
+
let c = n.verificationTemplate.body.replace("{APP_URL}/_/#/auth/confirm-verification/{TOKEN}", "{APP_URL}/confirm-verification/{TOKEN}"), l = n.resetPasswordTemplate.body.replace("{APP_URL}/_/#/auth/confirm-reset/{TOKEN}", "{APP_URL}/confirm-reset/{TOKEN}"), d = n.confirmEmailChangeTemplate.body.replace("{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}", "{APP_URL}/confirm-email-change/{TOKEN}");
|
|
249
249
|
i.info("Locking down users collection rules and email templates"), await t.collections.update("users", {
|
|
250
250
|
listRule: "@request.auth.id = id",
|
|
251
251
|
viewRule: "@request.auth.id = id",
|
|
@@ -254,35 +254,35 @@ async function w(e) {
|
|
|
254
254
|
deleteRule: "@request.auth.id = id",
|
|
255
255
|
verificationTemplate: { body: c },
|
|
256
256
|
resetPasswordTemplate: { body: l },
|
|
257
|
-
confirmEmailChangeTemplate: { body:
|
|
257
|
+
confirmEmailChangeTemplate: { body: d }
|
|
258
258
|
}), await s();
|
|
259
259
|
let f = o("users", "updated", e);
|
|
260
260
|
f && a.push({
|
|
261
261
|
path: f,
|
|
262
262
|
language: "ts",
|
|
263
|
-
content:
|
|
263
|
+
content: u.readFileSync(f, "utf8"),
|
|
264
264
|
status: "success"
|
|
265
265
|
});
|
|
266
266
|
});
|
|
267
|
-
let
|
|
268
|
-
e &&
|
|
267
|
+
let f = [], p = (e) => {
|
|
268
|
+
e && f.push(e);
|
|
269
269
|
};
|
|
270
270
|
i.info("Modifying +layout.server.ts");
|
|
271
|
-
let
|
|
272
|
-
|
|
273
|
-
let
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
],
|
|
279
|
-
|
|
280
|
-
let
|
|
281
|
-
|
|
282
|
-
let
|
|
283
|
-
return
|
|
271
|
+
let h = d.join(e.root, "src", "routes", "+layout.server.ts");
|
|
272
|
+
p(n(h, m(h))), i.info("Modifying root layout");
|
|
273
|
+
let g = [
|
|
274
|
+
d.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
275
|
+
d.join(e.root, "src", "routes", "root-layout.svelte"),
|
|
276
|
+
d.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
277
|
+
d.join(e.root, "src", "routes", "+layout.svelte")
|
|
278
|
+
], _ = g.find((e) => u.existsSync(e)) ?? g[0];
|
|
279
|
+
p(n(_, y(_))), i.info("Modifying hooks.server.ts");
|
|
280
|
+
let v = d.join(e.root, "src", "hooks.server.ts");
|
|
281
|
+
p(n(v, S(v))), i.info("Modifying config for remote functions");
|
|
282
|
+
let b = l(e.root);
|
|
283
|
+
return p(n(b.filePath, b.outcome)), {
|
|
284
284
|
creates: [],
|
|
285
|
-
modifies:
|
|
285
|
+
modifies: f,
|
|
286
286
|
deletes: [],
|
|
287
287
|
components: [],
|
|
288
288
|
packages: [],
|
|
@@ -292,6 +292,6 @@ async function w(e) {
|
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
//#endregion
|
|
295
|
-
export {
|
|
295
|
+
export { C as generate };
|
|
296
296
|
|
|
297
|
-
//# sourceMappingURL=generate.runtime-
|
|
297
|
+
//# sourceMappingURL=generate.runtime-t6rqiv36.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-D1uQBjeg.js","names":[],"sources":["../../src/patterns/enable/auth-remote/modifies/+layout.server.ts","../../src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth-remote/modifies/hooks.server.ts","../../src/patterns/enable/auth-remote/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function modifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst AUTH_MENU_NAVBAR_ITEM = `\n\t\t<Navbar.Item\n\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t>\n\t\t\t<AuthMenu.Root>\n\t\t\t\t{#snippet user()}\n\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t<Avatar.Root>\n\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t{data.user?.email?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t</Avatar.Root>\n\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t{/snippet}\n\n\t\t\t\t{#snippet guest()}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t>\n\t\t\t\t{/snippet}\n\t\t\t</AuthMenu.Root>\n\t\t</Navbar.Item>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import * as AuthMenu from '$lib/components/ui/auth-menu';\n import * as Avatar from '$lib/components/ui/avatar';\n`;\n\nconst FAILURE_HINT = [\n \"Add the auth menu inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes an auth menu inside <Navbar.List>.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nexport function modifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namespaceImport: \"AuthMenu\",\n moduleSpecifier: \"$lib/components/ui/auth-menu\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"$lib/components/ui/avatar\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"Navbar.List\", AUTH_MENU_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the auth option in hooks.server.ts:\n\n handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n findSvelteConfigPath,\n modifySvelteConfigRemote,\n} from \"../../../runtime/modify-svelte-config-remote\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n const logger = getLogger(options);\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n logger.info(\"Updating PocketBase mail settings\");\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n await migrationDelay();\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-reset/{TOKEN}\",\n \"{APP_URL}/confirm-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n logger.info(\"Locking down users collection rules and email templates\");\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n // Modify files\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerFile, modifyLayoutServer(layoutServerFile)),\n );\n\n logger.info(\"Modifying root layout\");\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, modifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, modifyHooksServer(hooksServerFile)),\n );\n\n logger.info(\"Modifying svelte.config for remote\");\n const svelteConfigPath = findSvelteConfigPath(options.root);\n pushResult(\n modifyOutcomeToFile(\n svelteConfigPath,\n modifySvelteConfigRemote(svelteConfigPath),\n ),\n );\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAKA,SAAgB,EAAmB,GAAmC;AACpE,KAAI,CAAC,EAAG,WAAW,EAAW,EAAE;EAC9B,IAAM,IAAU,CAAM;;;;;AAOtB,SADA,EAAG,cAAc,GAAY,EAAQ,EAC9B;GAAE,QAAQ;GAAW,SAAS;GAAM;;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAY,OAAO,EAEpD,IADU,IAAI,GAAS,CACF,oBAAoB,EAAW,EAGpD,KAAe,MAAoD;AAEvE,EADkB,EAAI,YAAY,OAAO,IAEvC,EAAI,sBAAsB;GACxB,MAAM;GACN,aAAa;GACd,CAAC;IAKF,GACA,GAKE,IAAU,EAAW,uBAAuB,OAAO;AACzD,KAAI,KACS,EAAQ,uBAAuB,EAAW,kBAAkB,EAC9C,kBAAkB,EAC3B;EACd,IAAM,IAAc,EAAQ,qBAC1B,EAAW,cACZ;AACD,MAAI,EACF,KAAY;OACP;GACL,IAAM,IAAO,EAAQ,gBAAgB;AACrC,OAAI,GAAM;IACR,IAAM,IAAa,EAAK,yBACtB,EAAW,cACZ;AACD,QAAI,EACF,KAAY;SACP;KACL,IAAM,IAAc,EAAK,yBACvB,EAAW,mBACZ;AACD,KAAI,MACF,IAAS;;;;;AAQrB,KAAI,CAAC,GAAW;EACd,IAAM,IAAU,EAAW,YAAY,OAAO;AAC9C,EAAI,KAAW,EAAQ,YAAY,KACjC,IAAS;;AAKb,KAAI,CAAC,KAAa,CAAC,EAUjB,QATA,EAAW,YAAY;EACrB,YAAY;EACZ,SAAS;EACT,MAAM;EACN,YAAY,CAAC,EAAE,MAAM,cAAc,CAAC;EACpC,YAAY;EACb,CAAC,E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E;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAE;EACpB"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-t6rqiv36.js","names":[],"sources":["../../src/patterns/enable/auth-remote/modifies/+layout.server.ts","../../src/patterns/enable/auth-remote/modifies/root-layout.svelte.ts","../../src/patterns/enable/auth-remote/modifies/hooks.server.ts","../../src/patterns/enable/auth-remote/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function modifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n const snippet = dedent`\n\t\t\texport const load = async ({ locals }) => {\n\t\t\t\treturn { user: locals.pb.authStore.record };\n\t\t\t};\n\t\t`;\n\n fs.writeFileSync(layoutPath, snippet);\n return { status: \"success\", changed: true };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n // helper to add user property to an object literal if missing\n const addUserProp = (obj: import(\"ts-morph\").ObjectLiteralExpression) => {\n const hasUser = !!obj.getProperty(\"user\");\n if (!hasUser) {\n obj.addPropertyAssignment({\n name: \"user\",\n initializer: \"locals.pb.authStore.record\",\n });\n }\n };\n\n // find existing exported load (function or const with arrow)\n let loadArrow: import(\"ts-morph\").ArrowFunction | undefined;\n let loadFn:\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression\n | undefined;\n\n const varDecl = sourceFile.getVariableDeclaration(\"load\");\n if (varDecl) {\n const vs = varDecl.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n const isExported = !!vs?.hasExportKeyword();\n if (isExported) {\n const directArrow = varDecl.getInitializerIfKind(\n SyntaxKind.ArrowFunction,\n );\n if (directArrow) {\n loadArrow = directArrow;\n } else {\n const init = varDecl.getInitializer();\n if (init) {\n const innerArrow = init.getFirstDescendantByKind(\n SyntaxKind.ArrowFunction,\n );\n if (innerArrow) {\n loadArrow = innerArrow;\n } else {\n const innerFnExpr = init.getFirstDescendantByKind(\n SyntaxKind.FunctionExpression,\n );\n if (innerFnExpr) {\n loadFn = innerFnExpr;\n }\n }\n }\n }\n }\n }\n\n if (!loadArrow) {\n const maybeFn = sourceFile.getFunction(\"load\");\n if (maybeFn && maybeFn.isExported()) {\n loadFn = maybeFn;\n }\n }\n\n // if no load found, create one\n if (!loadArrow && !loadFn) {\n sourceFile.addFunction({\n isExported: true,\n isAsync: true,\n name: \"load\",\n parameters: [{ name: \"{ locals }\" }],\n statements: `return { user: locals.pb.authStore.record };`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // normalize function-like to a single handle\n const fnLike:\n | import(\"ts-morph\").ArrowFunction\n | import(\"ts-morph\").FunctionDeclaration\n | import(\"ts-morph\").FunctionExpression = (loadArrow ?? loadFn!) as any;\n\n // ensure first parameter destructures locals, preserving existing information\n const params = fnLike.getParameters();\n if (params.length === 0) {\n fnLike.insertParameter(0, { name: \"{ locals }\" });\n } else {\n const first = params[0];\n const original = first.getStructure();\n const nameNode = first.getNameNode();\n if (nameNode.getKind() === SyntaxKind.ObjectBindingPattern) {\n const obp = nameNode as import(\"ts-morph\").ObjectBindingPattern;\n const hasLocals = obp\n .getElements()\n .some((el) => el.getName() === \"locals\");\n if (!hasLocals) {\n const parts = obp\n .getElements()\n .map((el) => el.getText())\n .filter(Boolean);\n const tail = parts.length > 0 ? \", \" + parts.join(\", \") : \"\";\n first.set({\n name: `{ locals${tail} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n } else {\n const currentName = first.getName();\n if (currentName !== \"locals\") {\n first.set({\n name: `{ locals, ...${currentName} }`,\n type: original.type,\n initializer: (original as any).initializer,\n });\n }\n }\n }\n\n // add user to returned object literals without altering other properties\n if (loadArrow) {\n const body = loadArrow.getBody();\n if (body.getKind() === SyntaxKind.Block) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n } else {\n // concise body\n const bodyExpr = body as import(\"ts-morph\").Expression;\n if (bodyExpr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n bodyExpr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n } else if (bodyExpr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(bodyExpr as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n } else if (loadFn) {\n const body = loadFn.getBody();\n if (body) {\n const returns = body.getDescendantsOfKind(SyntaxKind.ReturnStatement);\n returns.forEach((ret) => {\n const expr = ret.getExpression();\n if (!expr) return;\n if (expr.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(expr as import(\"ts-morph\").ObjectLiteralExpression);\n } else if (expr.getKind() === SyntaxKind.ParenthesizedExpression) {\n const inner = (\n expr as import(\"ts-morph\").ParenthesizedExpression\n ).getExpression();\n if (inner.getKind() === SyntaxKind.ObjectLiteralExpression) {\n addUserProp(inner as import(\"ts-morph\").ObjectLiteralExpression);\n }\n }\n });\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst AUTH_MENU_NAVBAR_ITEM = `\n\t\t<Navbar.Item\n\t\t\tclass=\"flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4\"\n\t\t>\n\t\t\t<AuthMenu.Root>\n\t\t\t\t{#snippet user()}\n\t\t\t\t\t<AuthMenu.Trigger>\n\t\t\t\t\t\t<Avatar.Root>\n\t\t\t\t\t\t\t{#if data.user?.avatar}\n\t\t\t\t\t\t\t\t<Avatar.Image\n\t\t\t\t\t\t\t\t\tsrc=\"/api/files/users/{data.user?.id}/{data.user?.avatar}\"\n\t\t\t\t\t\t\t\t\talt={data.user?.email}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{/if}\n\t\t\t\t\t\t\t<Avatar.Fallback>\n\t\t\t\t\t\t\t\t{data.user?.email?.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t</Avatar.Fallback>\n\t\t\t\t\t\t</Avatar.Root>\n\t\t\t\t\t</AuthMenu.Trigger>\n\n\t\t\t\t\t<AuthMenu.Content align=\"end\">\n\t\t\t\t\t\t<AuthMenu.Item href=\"/dashboard\">Dashboard</AuthMenu.Item>\n\t\t\t\t\t\t<AuthMenu.Group>\n\t\t\t\t\t\t\t<AuthMenu.Item href=\"/settings\">Settings</AuthMenu.Item>\n\t\t\t\t\t\t\t<AuthMenu.Item>\n\t\t\t\t\t\t\t\t<form action=\"/logout\" method=\"post\">\n\t\t\t\t\t\t\t\t\t<button type=\"submit\" class=\"contents\">Logout</button>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t</AuthMenu.Item>\n\t\t\t\t\t\t</AuthMenu.Group>\n\t\t\t\t\t</AuthMenu.Content>\n\t\t\t\t{/snippet}\n\n\t\t\t\t{#snippet guest()}\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\thref=\"/login\">Login</Button\n\t\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclass=\"w-full justify-start md:justify-center md:w-auto\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\thref=\"/signup\">Sign up</Button\n\t\t\t\t\t>\n\t\t\t\t{/snippet}\n\t\t\t</AuthMenu.Root>\n\t\t</Navbar.Item>\n\t`;\n\nconst IMPORT_SNIPPET = dedent`\n import * as AuthMenu from '$lib/components/ui/auth-menu';\n import * as Avatar from '$lib/components/ui/avatar';\n`;\n\nconst FAILURE_HINT = [\n \"Add the auth menu inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Imports to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes an auth menu inside <Navbar.List>.\",\n \"\",\n \"Imports for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup inside <Navbar.List>:\",\n AUTH_MENU_NAVBAR_ITEM,\n].join(\"\\n\");\n\nexport function modifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n if (file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n namespaceImport: \"AuthMenu\",\n moduleSpecifier: \"$lib/components/ui/auth-menu\",\n },\n {\n namespaceImport: \"Avatar\",\n moduleSpecifier: \"$lib/components/ui/avatar\",\n },\n ]);\n });\n return out;\n });\n\n file.insertBeforeClosingTag(\"Navbar.List\", AUTH_MENU_NAVBAR_ITEM);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = dedent`\n Configure handlePocketbase() with the auth option in hooks.server.ts:\n\n handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nconst NOT_FOUND_HINT = dedent`\n Create src/hooks.server.ts with handlePocketbase:\n\n import { handlePocketbase } from 'velastack/handle';\n\n export const handle = handlePocketbase({\n auth: { protectedRoutes: ['/(app)'] },\n });\n`;\n\nexport function modifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(hooksServerPath);\n\n // Find the handlePocketbase(...) call\n const callExpr = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"handlePocketbase\");\n\n if (!callExpr) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n callExpr.addArgument(`{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n callExpr.insertArgument(0, `{ auth: { protectedRoutes: ['/(app)'] } }`);\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n\n // Ensure auth property exists\n const authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n optionsObj.addPropertyAssignment({\n name: \"auth\",\n initializer: `{ protectedRoutes: ['/(app)'] }`,\n });\n sourceFile.formatText();\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n // If auth exists, ensure protectedRoutes includes '/(app)'\n if (authProp.getKind() === SyntaxKind.PropertyAssignment) {\n const authInit = (\n authProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (authInit && authInit.getKind() === SyntaxKind.ObjectLiteralExpression) {\n const authObj = authInit as import(\"ts-morph\").ObjectLiteralExpression;\n const prProp = authObj.getProperty(\"protectedRoutes\");\n if (!prProp) {\n authObj.addPropertyAssignment({\n name: \"protectedRoutes\",\n initializer: `['/(app)']`,\n });\n } else if (prProp.getKind() === SyntaxKind.PropertyAssignment) {\n const prInit = (\n prProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (prInit && prInit.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const arr = prInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasApp = arr\n .getElements()\n .some((el) => el.getText().replace(/['\"`]/g, \"\") === \"/(app)\");\n if (!hasApp) {\n arr.addElement(`'/(app)'`);\n }\n } else {\n (prProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n `['/(app)']`,\n );\n }\n }\n }\n }\n\n sourceFile.formatText();\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { Options, Result, File } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifySvelteConfigRemote } from \"../../../runtime/modify-svelte-config-remote\";\n\nimport { modifyLayoutServer } from \"./modifies/+layout.server\";\nimport { modifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { modifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const { input } = options;\n const logger = getLogger(options);\n\n let creates: File[] = [];\n\n // Update PocketBase\n await withPocketbase(options.root, async (pb) => {\n logger.info(\"Updating PocketBase mail settings\");\n await pb.settings.update({\n meta: {\n senderName: input.senderName,\n senderAddress: input.senderAddress,\n },\n });\n await migrationDelay();\n\n const userCollection = await pb.collections.getOne(\"users\");\n\n if (!userCollection) {\n throw new Error(\"Users collection not found\");\n }\n\n const verificationTemplate =\n userCollection.verificationTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-verification/{TOKEN}\",\n \"{APP_URL}/confirm-verification/{TOKEN}\",\n );\n const resetPasswordTemplate =\n userCollection.resetPasswordTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-reset/{TOKEN}\",\n \"{APP_URL}/confirm-reset/{TOKEN}\",\n );\n const confirmEmailChangeTemplate =\n userCollection.confirmEmailChangeTemplate.body.replace(\n \"{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}\",\n \"{APP_URL}/confirm-email-change/{TOKEN}\",\n );\n\n logger.info(\"Locking down users collection rules and email templates\");\n // Update user auth rules to lock down access to the user's own account\n await pb.collections.update(\"users\", {\n listRule: \"@request.auth.id = id\",\n viewRule: \"@request.auth.id = id\",\n createRule: \"@request.auth.id = id\",\n updateRule: \"@request.auth.id = id\",\n deleteRule: \"@request.auth.id = id\",\n\n // Update email templates to VelaStack auth urls\n verificationTemplate: {\n body: verificationTemplate,\n },\n resetPasswordTemplate: {\n body: resetPasswordTemplate,\n },\n confirmEmailChangeTemplate: {\n body: confirmEmailChangeTemplate,\n },\n });\n await migrationDelay();\n\n const migrationFile = getMigrationFile(\"users\", \"updated\", options);\n if (migrationFile) {\n creates.push({\n path: migrationFile,\n language: \"ts\",\n content: fs.readFileSync(migrationFile, \"utf8\"),\n status: \"success\",\n });\n }\n });\n\n // Modify files\n const modifies: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(layoutServerFile, modifyLayoutServer(layoutServerFile)),\n );\n\n logger.info(\"Modifying root layout\");\n // TODO: make this more robust by searching for Navbar.Root > Navbar.List\n // src/routes/(public)/root-layout.svelte is what vela creates by default\n const layoutCandidates = [\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"root-layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"(public)\", \"+layout.svelte\"),\n path.join(options.root, \"src\", \"routes\", \"+layout.svelte\"),\n ];\n const layoutFile =\n layoutCandidates.find((p) => fs.existsSync(p)) ?? layoutCandidates[0];\n pushResult(\n modifyOutcomeToFile(layoutFile, modifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, modifyHooksServer(hooksServerFile)),\n );\n\n logger.info(\"Modifying config for remote functions\");\n const remote = modifySvelteConfigRemote(options.root);\n pushResult(modifyOutcomeToFile(remote.filePath, remote.outcome));\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;AAKA,SAAgB,EAAmB,GAAmC;AACpE,KAAI,CAAC,EAAG,WAAW,EAAW,EAAE;EAC9B,IAAM,IAAU,CAAM;;;;;AAOtB,SADA,EAAG,cAAc,GAAY,EAAQ,EAC9B;GAAE,QAAQ;GAAW,SAAS;GAAM;;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAY,OAAO,EAEpD,IADU,IAAI,GAAS,CACF,oBAAoB,EAAW,EAGpD,KAAe,MAAoD;AAEvE,EADkB,EAAI,YAAY,OAAO,IAEvC,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,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,qBAAqB;EAC1E,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,qBAAqB;EAC9D,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,YAAY,iBAAiB;EACtE,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,iBAAiB;EAC3D,EACK,IACJ,EAAiB,MAAM,MAAM,EAAG,WAAW,EAAE,CAAC,IAAI,EAAiB;AAKrE,CAJA,EACE,EAAoB,GAAY,EAAuB,EAAW,CAAC,CACpE,EAED,EAAO,KAAK,4BAA4B;CACxC,IAAM,IAAkB,EAAK,KAAK,EAAQ,MAAM,OAAO,kBAAkB;AAKzE,CAJA,EACE,EAAoB,GAAiB,EAAkB,EAAgB,CAAC,CACzE,EAED,EAAO,KAAK,wCAAwC;CACpD,IAAM,IAAS,EAAyB,EAAQ,KAAK;AAGrD,QAFA,EAAW,EAAoB,EAAO,UAAU,EAAO,QAAQ,CAAC,EAEzD;EACL,SAAS,EAAE;EACX;EACA,SAAS,EAAE;EACX,YAAY,EAAE;EACd,UAAU,EAAE;EACZ,aAAa,EAAE;EACf,mBAAmB,EAAE;EACrB,iBAAiB,EAAE;EACpB"}
|
|
@@ -4,8 +4,8 @@ import { n } from "./logger-BpgCb-ZG.js";
|
|
|
4
4
|
import { t as r } from "./pocketbase-Bj-cW2Zl.js";
|
|
5
5
|
import { modifyOutcomeToFile as i } from "./modify-file-DE7tPADZ.js";
|
|
6
6
|
import { a, n as o, o as s, t as c } from "./ts-morph-helpers-bR0-x04t.js";
|
|
7
|
-
import { getMigrationFile as l, migrationDelay as u, withPocketbase as d } from "./pocketbase
|
|
8
|
-
import { applyCollectionRulePatches as f, createCollectionIdempotent as p } from "./collections-
|
|
7
|
+
import { getMigrationFile as l, migrationDelay as u, withPocketbase as d } from "./pocketbase--poMYyvc.js";
|
|
8
|
+
import { applyCollectionRulePatches as f, createCollectionIdempotent as p } from "./collections-CkCADMyb.js";
|
|
9
9
|
import m from "node:fs";
|
|
10
10
|
import h from "node:path";
|
|
11
11
|
import { Project as g, SyntaxKind as _ } from "ts-morph";
|
|
@@ -605,4 +605,4 @@ async function P(e) {
|
|
|
605
605
|
//#endregion
|
|
606
606
|
export { P as generate };
|
|
607
607
|
|
|
608
|
-
//# sourceMappingURL=generate2.runtime-
|
|
608
|
+
//# sourceMappingURL=generate2.runtime-DLe5zNsJ.js.map
|