@velastack/patterns 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{collections-Cpjo2OiQ.js → collections-B_DisSfA.js} +2 -2
- package/dist/chunks/{collections-Cpjo2OiQ.js.map → collections-B_DisSfA.js.map} +1 -1
- package/dist/chunks/{constants-Rq8SCXwH.js → constants-iej3WkEa.js} +3 -3
- package/dist/chunks/constants-iej3WkEa.js.map +1 -0
- package/dist/chunks/{env-vars-Bj41Nccm.js → env-vars-cqQU0ECK.js} +3 -3
- package/dist/chunks/{env-vars-Bj41Nccm.js.map → env-vars-cqQU0ECK.js.map} +1 -1
- package/dist/chunks/generate-8FS2ROOJ.js +170 -0
- package/dist/chunks/generate-8FS2ROOJ.js.map +1 -0
- package/dist/chunks/{generate-yi8AP3xH.js → generate-Bm_jOMtF.js} +3 -3
- package/dist/chunks/{generate-yi8AP3xH.js.map → generate-Bm_jOMtF.js.map} +1 -1
- package/dist/chunks/{generate-dNlBII84.js → generate-CXoQPz7n.js} +2 -2
- package/dist/chunks/{generate-dNlBII84.js.map → generate-CXoQPz7n.js.map} +1 -1
- package/dist/chunks/{generate-B6Odfk5f.js → generate-Cqwa8kD9.js} +2 -2
- package/dist/chunks/{generate-B6Odfk5f.js.map → generate-Cqwa8kD9.js.map} +1 -1
- package/dist/chunks/{generate-DjBMRzsB.js → generate-D3mSFPdT.js} +2 -2
- package/dist/chunks/{generate-DjBMRzsB.js.map → generate-D3mSFPdT.js.map} +1 -1
- package/dist/chunks/{generate-ZIOVLH6Q.js → generate-jx5Iuq5w.js} +53 -50
- package/dist/chunks/generate-jx5Iuq5w.js.map +1 -0
- package/dist/chunks/{generate.runtime-DlbG-8Xm.js → generate.runtime-B2r11K7S.js} +4 -4
- package/dist/chunks/{generate.runtime-DlbG-8Xm.js.map → generate.runtime-B2r11K7S.js.map} +1 -1
- package/dist/chunks/{generate.runtime-pMpn0Pbf.js → generate.runtime-B4u9C2YH.js} +9 -9
- package/dist/chunks/{generate.runtime-pMpn0Pbf.js.map → generate.runtime-B4u9C2YH.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DetYynf4.js → generate.runtime-BRCzUO94.js} +3 -3
- package/dist/chunks/{generate.runtime-DetYynf4.js.map → generate.runtime-BRCzUO94.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CcPCAEV0.js → generate.runtime-BVavIXtX.js} +3 -3
- package/dist/chunks/{generate.runtime-CcPCAEV0.js.map → generate.runtime-BVavIXtX.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BdHv7Jp1.js → generate.runtime-Bh9Z2cRN.js} +2 -2
- package/dist/chunks/{generate.runtime-BdHv7Jp1.js.map → generate.runtime-Bh9Z2cRN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D-qtaVdq.js → generate.runtime-BxDUtkpT.js} +12 -12
- package/dist/chunks/{generate.runtime-D-qtaVdq.js.map → generate.runtime-BxDUtkpT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BYfyZHhs.js → generate.runtime-BxUGDXIK.js} +4 -4
- package/dist/chunks/{generate.runtime-BYfyZHhs.js.map → generate.runtime-BxUGDXIK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DRRyPa-e.js → generate.runtime-CHb4znYx.js} +66 -66
- package/dist/chunks/{generate.runtime-DRRyPa-e.js.map → generate.runtime-CHb4znYx.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DBBtYTAa.js → generate.runtime-CRhD98rs.js} +3 -3
- package/dist/chunks/{generate.runtime-DBBtYTAa.js.map → generate.runtime-CRhD98rs.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bdpu4rX0.js → generate.runtime-CWnIiXwV.js} +2 -2
- package/dist/chunks/{generate.runtime-Bdpu4rX0.js.map → generate.runtime-CWnIiXwV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-b2RtuPy4.js → generate.runtime-CYBs0JgY.js} +3 -3
- package/dist/chunks/{generate.runtime-b2RtuPy4.js.map → generate.runtime-CYBs0JgY.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BXZDKLbA.js → generate.runtime-CkmledBw.js} +2 -2
- package/dist/chunks/{generate.runtime-BXZDKLbA.js.map → generate.runtime-CkmledBw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-NaSIZlP5.js → generate.runtime-CyGR8VTx.js} +2 -2
- package/dist/chunks/{generate.runtime-NaSIZlP5.js.map → generate.runtime-CyGR8VTx.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DjCzW3zU.js → generate.runtime-DCqf7nYM.js} +2 -2
- package/dist/chunks/{generate.runtime-DjCzW3zU.js.map → generate.runtime-DCqf7nYM.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C7s1Mx5L.js → generate.runtime-DUo-pLRr.js} +6 -6
- package/dist/chunks/{generate.runtime-C7s1Mx5L.js.map → generate.runtime-DUo-pLRr.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B4QoBn5v.js → generate.runtime-DY5vQ3aZ.js} +6 -6
- package/dist/chunks/{generate.runtime-B4QoBn5v.js.map → generate.runtime-DY5vQ3aZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CCV4O6_I.js → generate.runtime-DYdkrHJ1.js} +70 -70
- package/dist/chunks/{generate.runtime-CCV4O6_I.js.map → generate.runtime-DYdkrHJ1.js.map} +1 -1
- package/dist/chunks/{generate.runtime-utFLS6Jz.js → generate.runtime-DdcVnK8J.js} +2 -2
- package/dist/chunks/{generate.runtime-utFLS6Jz.js.map → generate.runtime-DdcVnK8J.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CV4soy2n.js → generate.runtime-DeniHg8L.js} +47 -47
- package/dist/chunks/{generate.runtime-CV4soy2n.js.map → generate.runtime-DeniHg8L.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BavEh01F.js → generate.runtime-Dmob2wFf.js} +3 -3
- package/dist/chunks/{generate.runtime-BavEh01F.js.map → generate.runtime-Dmob2wFf.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CWgZhxQt.js → generate.runtime-Du4uf98c.js} +2 -2
- package/dist/chunks/{generate.runtime-CWgZhxQt.js.map → generate.runtime-Du4uf98c.js.map} +1 -1
- package/dist/chunks/{generate.runtime-MjWwR2Bd.js → generate.runtime-Dug2UIhV.js} +3 -3
- package/dist/chunks/{generate.runtime-MjWwR2Bd.js.map → generate.runtime-Dug2UIhV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-QbmCPT42.js → generate.runtime-FGYc365Q.js} +15 -15
- package/dist/chunks/{generate.runtime-QbmCPT42.js.map → generate.runtime-FGYc365Q.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DaRVyiSg.js → generate.runtime-N1KtAG8C.js} +116 -97
- package/dist/chunks/generate.runtime-N1KtAG8C.js.map +1 -0
- package/dist/chunks/{generate.runtime-DmsOEsJV.js → generate.runtime-_c7daMAw.js} +3 -3
- package/dist/chunks/{generate.runtime-DmsOEsJV.js.map → generate.runtime-_c7daMAw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-azOvp6tl.js → generate.runtime-aN5QWygO.js} +6 -6
- package/dist/chunks/{generate.runtime-azOvp6tl.js.map → generate.runtime-aN5QWygO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-OEgsdWRP.js → generate.runtime-bpH3DB0t.js} +2 -2
- package/dist/chunks/{generate.runtime-OEgsdWRP.js.map → generate.runtime-bpH3DB0t.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BdmoAVJK.js → generate.runtime-gFr2Gsjz.js} +3 -3
- package/dist/chunks/{generate.runtime-BdmoAVJK.js.map → generate.runtime-gFr2Gsjz.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CSUnP0l-.js → generate.runtime-kpqW3dVO.js} +26 -26
- package/dist/chunks/{generate.runtime-CSUnP0l-.js.map → generate.runtime-kpqW3dVO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BKTkVCEm.js → generate.runtime-wGRE1zwZ.js} +3 -3
- package/dist/chunks/{generate.runtime-BKTkVCEm.js.map → generate.runtime-wGRE1zwZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BKINIJ2c.js → generate.runtime-wziCW3ct.js} +69 -69
- package/dist/chunks/{generate.runtime-BKINIJ2c.js.map → generate.runtime-wziCW3ct.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BcgjZJug.js → generate.runtime-x-o4LS8d.js} +2 -2
- package/dist/chunks/{generate.runtime-BcgjZJug.js.map → generate.runtime-x-o4LS8d.js.map} +1 -1
- package/dist/chunks/{modify-file-Bbhyfiy_.js → modify-file-289rStJ2.js} +2 -2
- package/dist/chunks/{modify-file-Bbhyfiy_.js.map → modify-file-289rStJ2.js.map} +1 -1
- package/dist/chunks/{pocketbase-CgwbH1gI.js → pocketbase-B017Cqjq.js} +2 -2
- package/dist/chunks/{pocketbase-CgwbH1gI.js.map → pocketbase-B017Cqjq.js.map} +1 -1
- package/dist/chunks/{providers-DwbwccSW.js → providers-CN5J5_fY.js} +2 -2
- package/dist/chunks/{providers-DwbwccSW.js.map → providers-CN5J5_fY.js.map} +1 -1
- package/dist/chunks/{shared-D5GOS97l.js → shared-BPlAVf-T.js} +2 -2
- package/dist/chunks/{shared-D5GOS97l.js.map → shared-BPlAVf-T.js.map} +1 -1
- package/dist/chunks/site-DkU1-VRq.js +108 -0
- package/dist/chunks/site-DkU1-VRq.js.map +1 -0
- package/dist/chunks/{table-core-DhDqT03G.js → table-core-vXEjJDYP.js} +2 -2
- package/dist/chunks/{table-core-DhDqT03G.js.map → table-core-vXEjJDYP.js.map} +1 -1
- package/dist/chunks/{test-setup-DZoyF8Ak.js → test-setup-CAfgVlwc.js} +3 -3
- package/dist/chunks/{test-setup-DZoyF8Ak.js.map → test-setup-CAfgVlwc.js.map} +1 -1
- package/dist/chunks/{ui-BuocThuh.js → ui-CTdsenEv.js} +3 -3
- package/dist/chunks/{ui-BuocThuh.js.map → ui-CTdsenEv.js.map} +1 -1
- package/dist/chunks/{whatsapp-CguKGTtw.js → whatsapp-5qJ_xCV1.js} +2 -2
- package/dist/chunks/{whatsapp-CguKGTtw.js.map → whatsapp-5qJ_xCV1.js.map} +1 -1
- package/dist/chunks/{write-result-Cq-9A7Zy.js → write-result-0HYIr5a6.js} +4 -4
- package/dist/chunks/{write-result-Cq-9A7Zy.js.map → write-result-0HYIr5a6.js.map} +1 -1
- package/dist/index.js +1924 -1886
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/constants-Rq8SCXwH.js.map +0 -1
- package/dist/chunks/generate-BClgUH4J.js +0 -137
- package/dist/chunks/generate-BClgUH4J.js.map +0 -1
- package/dist/chunks/generate-ZIOVLH6Q.js.map +0 -1
- package/dist/chunks/generate.runtime-DaRVyiSg.js.map +0 -1
- package/dist/chunks/site-lj0CDdQ1.js +0 -55
- package/dist/chunks/site-lj0CDdQ1.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
2
|
import { o as t } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
3
|
-
import { r as n } from "./modify-file-
|
|
3
|
+
import { r as n } from "./modify-file-289rStJ2.js";
|
|
4
4
|
import r from "node:fs";
|
|
5
5
|
import i from "node:path";
|
|
6
6
|
import { Project as a, SyntaxKind as o } from "ts-morph";
|
|
@@ -54,4 +54,4 @@ async function c(t) {
|
|
|
54
54
|
//#endregion
|
|
55
55
|
export { c as generate };
|
|
56
56
|
|
|
57
|
-
//# sourceMappingURL=generate.runtime-
|
|
57
|
+
//# sourceMappingURL=generate.runtime-bpH3DB0t.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-bpH3DB0t.js","names":["getLogger","formatLikeSource","modifyOutcomeToFile","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","args","firstArg","optionsObj","apiProp","generate","logger","options","modifies","file"],"sources":["../../src/patterns/disable/api/modifies/hooks.server.ts","../../src/patterns/disable/api/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\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 return { status: \"success\", changed: false };\n }\n\n const args = callExpr.getArguments();\n if (args.length === 0) {\n return { status: \"success\", changed: false };\n }\n\n const firstArg = args[0];\n if (firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp) {\n return { status: \"success\", changed: false };\n }\n\n apiProp.remove();\n\n if (optionsObj.getProperties().length === 0) {\n callExpr.removeArgument(0);\n }\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\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 { unmodifyHooksServer } from \"./modifies/hooks.server\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const file = modifyOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServer(hooksServerPath),\n );\n if (file) modifies.push(file);\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,SAAgBK,EAAoB,GAAwC;CAC1E,IAAI,CAACF,EAAG,WAAWG,CAAe,GAChC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAiBJ,EAAG,aAAaG,GAAiB,MAAM,GAExDE,IAAa,IADCC,EACD,CAAA,CAAQ,oBAAoBH,CAAe,GAExDI,IAAWF,EACd,qBAAqBG,EAAW,cAAc,CAAC,CAC/C,MAAM,MAAOC,EAAG,cAAc,CAAC,CAAC,QAAQ,MAAM,kBAAkB;CAEnE,IAAI,CAACF,GACH,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMG,IAAOH,EAAS,aAAa;CACnC,IAAIG,EAAK,WAAW,GAClB,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWD,EAAK;CACtB,IAAIC,EAAS,QAAQ,MAAMH,EAAW,yBACpC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMI,IAAaD,EAAS,cAAcH,EAAW,uBAAuB,GACtEK,IAAUD,EAAW,YAAY,KAAK;CAc5C,OAbKC,KAILA,EAAQ,OAAO,GAEXD,EAAW,cAAc,CAAC,CAAC,WAAW,KACxCL,EAAS,eAAe,CAAC,GAG3BT,EAAiBO,CAAU,GAC3BA,EAAW,SAAS,GAEb;EACL,QAAQ;EACR,SAASA,EAAW,YAAY,MAAMD;CACxC,KAfS;EAAE,QAAQ;EAAW,SAAS;CAAM;AAgB/C;;;AC7CA,eAAsBU,EAAS,GAAkB;CAC/C,IAAMC,IAASlB,EAAUmB,CAAO,GAC1BC,IAAmB,CAAC;CAE1B,EAAO,KAAK,2BAA2B;CACvC,IAAMd,IAAkBF,EAAK,KAAKe,EAAQ,MAAM,OAAO,iBAAiB,GAClEE,IAAOnB,EACXI,GACAD,EAAoBC,CAAe,CACrC;CAGA,OAFIe,KAAMD,EAAS,KAAKC,CAAI,GAErB;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as e } from "./lib-specifier-Cngo1zF_.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { t as n } from "./shared-
|
|
3
|
+
import { t as n } from "./shared-BPlAVf-T.js";
|
|
4
4
|
import { _ as r, n as i, u as a } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
5
|
-
import { r as o } from "./modify-file-
|
|
5
|
+
import { r as o } from "./modify-file-289rStJ2.js";
|
|
6
6
|
import { t as s } from "./svelte-file-Dv5-bl79.js";
|
|
7
7
|
import { t as c } from "./unmodify-load-Bl5vXQiL.js";
|
|
8
8
|
import l from "node:fs";
|
|
@@ -64,4 +64,4 @@ async function p(e) {
|
|
|
64
64
|
//#endregion
|
|
65
65
|
export { p as generate };
|
|
66
66
|
|
|
67
|
-
//# sourceMappingURL=generate.runtime-
|
|
67
|
+
//# sourceMappingURL=generate.runtime-gFr2Gsjz.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-gFr2Gsjz.js","names":["libModule","getLogger","planDropsForCollections","withInMemoryScript","ensureBlankLineAfterImports","removeImportByModuleSpecifier","modifyOutcomeToFile","SvelteFile","removeFromLoad","fs","path","unmodifyAppLayout","layoutPath","original","file","out","source","sf","updated","unmodifyLayoutServer","layoutServerPath","generate","logger","options","modifies","pushResult","appLayoutPath","appLayoutServerPath"],"sources":["../../src/patterns/disable/notifications/modifies/modify-app-layout.ts","../../src/patterns/disable/notifications/modifies/+layout.server.ts","../../src/patterns/disable/notifications/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\n/** Take the bell (and the wrapper enable-notifications put it in) out of the header. */\nexport function unmodifyAppLayout(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutPath, \"utf8\");\n if (!original.includes(\"NotificationsBell\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n removeImportByModuleSpecifier(\n sf,\n libModule(\"components/notifications-bell.svelte\"),\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n let updated = file.toString();\n updated = updated.replace(\n /\\n*[ \\t]*<div class=\"ml-auto px-4\">\\s*<NotificationsBell\\s*\\/>\\s*<\\/div>[ \\t]*/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<NotificationsBell\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\n}\n","import type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeFromLoad } from \"../../../../runtime/unmodify-load\";\n\n/** Take the unread-notifications query back out of the (app) layout's load. */\nexport function unmodifyLayoutServer(layoutServerPath: string): ModifyOutcome {\n return removeFromLoad(layoutServerPath, {\n variables: [\"notificationsList\", \"notifications\"],\n dependsKeys: [\"app:notifications\"],\n returnProps: [\"notifications\"],\n });\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 { planDropsForCollections } from \"../../destroy/shared\";\nimport { unmodifyAppLayout } from \"./modifies/modify-app-layout\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\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 (app) +layout.svelte\");\n const appLayoutPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.svelte\",\n );\n pushResult(\n modifyOutcomeToFile(appLayoutPath, unmodifyAppLayout(appLayoutPath)),\n );\n\n logger.info(\"Reverting (app) +layout.server.ts\");\n const appLayoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(app)\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n appLayoutServerPath,\n unmodifyLayoutServer(appLayoutServerPath),\n ),\n );\n\n // The timeAgo helper enable-notifications added to #lib/utils.js stays: it is\n // generic, and other code may have started using it.\n\n const collectionDrops = await planDropsForCollections(\n [\"notifications\"],\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":";;;;;;;;;;AAWA,SAAgBW,EAAkB,GAAmC;CACnE,IAAI,CAACF,EAAG,WAAWG,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWJ,EAAG,aAAaG,GAAY,MAAM;CACnD,IAAI,CAACC,EAAS,SAAS,mBAAmB,GACxC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAOP,EAAW,SAASK,CAAU;CAC3C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQG,MAAQZ,EAAmBa,IAAS,MAAO;GAKzD,AAJAX,EACEY,GACAjB,EAAU,sCAAsC,CAClD,GACAI,EAA4Ba,CAAE;EAChC,CAAC;EACD,OAAOF;CACT,CAAC;CAED,IAAIG,IAAUJ,EAAK,SAAS;CAQ5B,OAPA,IAAUI,EAAQ,QAChB,mFACA,EACF,GACA,IAAUA,EAAQ,QAAQ,+CAA+C,EAAE,GAE3ET,EAAG,cAAcG,GAAYM,GAAS,MAAM,GACrC;EAAE,QAAQ;EAAW,SAASA,MAAYL;CAAS;AAC5D;;;ACtCA,SAAgBM,EAAqB,GAAyC;CAC5E,OAAOX,EAAeY,GAAkB;EACtC,WAAW,CAAC,qBAAqB,eAAe;EAChD,aAAa,CAAC,mBAAmB;EACjC,aAAa,CAAC,eAAe;CAC/B,CAAC;AACH;;;ACFA,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASrB,EAAUsB,CAAO,GAC1BC,IAAmB,CAAC,GACpBC,KAAc,MAAsB;EACxC,AAAIX,KAAMU,EAAS,KAAKV,CAAI;CAC9B;CAEA,EAAO,KAAK,gCAAgC;CAC5C,IAAMY,IAAgBhB,EAAK,KACzBa,EAAQ,MACR,OACA,UACA,SACA,gBACF;CAKA,AAJAE,EACEnB,EAAoBoB,GAAef,EAAkBe,CAAa,CAAC,CACrE,GAEAJ,EAAO,KAAK,mCAAmC;CAC/C,IAAMK,IAAsBjB,EAAK,KAC/Ba,EAAQ,MACR,OACA,UACA,SACA,mBACF;CAgBA,OAfAE,EACEnB,EACEqB,GACAR,EAAqBQ,CAAmB,CAC1C,CACF,GAUO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4BzB,EAC5B,CAAC,eAAe,GAChBqB,CACF;CAWA;AACF"}
|
|
@@ -2,14 +2,14 @@ import { r as e, t } from "./lib-specifier-Cngo1zF_.js";
|
|
|
2
2
|
import { t as n } from "./dedent-Gq6Krl4n.js";
|
|
3
3
|
import { n as r } from "./logger-CQONztPm.js";
|
|
4
4
|
import { t as i } from "./env-vars-mnRA0hOe.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { n as a } from "./site-DkU1-VRq.js";
|
|
6
|
+
import { t as o } from "./env-vars-Cr4lbMD_.js";
|
|
7
|
+
import { n as s } from "./shared-BPlAVf-T.js";
|
|
8
|
+
import { c, m as l, n as u, o as d } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
9
|
+
import { a as f, r as p } from "./modify-file-289rStJ2.js";
|
|
10
|
+
import { unmodifyEnvVarsFiles as m } from "./env-vars-cqQU0ECK.js";
|
|
11
11
|
import { n as h } from "./compose-handle-BDlZ7Pif.js";
|
|
12
|
-
import { a as g, l as _, s as v } from "./test-setup-
|
|
12
|
+
import { a as g, l as _, s as v } from "./test-setup-CAfgVlwc.js";
|
|
13
13
|
import y from "node:fs";
|
|
14
14
|
import b from "node:path";
|
|
15
15
|
import { Node as x, Project as S, QuoteKind as C } from "ts-morph";
|
|
@@ -68,7 +68,7 @@ function A(e) {
|
|
|
68
68
|
message: w
|
|
69
69
|
};
|
|
70
70
|
let r = k(n);
|
|
71
|
-
return r && r !== "custom" &&
|
|
71
|
+
return r && r !== "custom" && l(n, r), c(n, E), d(n), u(n), n.saveSync(), {
|
|
72
72
|
status: "success",
|
|
73
73
|
changed: n.getFullText() !== t
|
|
74
74
|
};
|
|
@@ -118,30 +118,30 @@ function N(e) {
|
|
|
118
118
|
return t;
|
|
119
119
|
}
|
|
120
120
|
async function P(e) {
|
|
121
|
-
let t = r(e), n = [],
|
|
121
|
+
let t = r(e), n = [], c = [], l = [];
|
|
122
122
|
t.info("Reverting adapter config");
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
let h = b.join(e.root, "src", "hooks.server.ts"), x =
|
|
126
|
-
x.modify &&
|
|
123
|
+
let u = _(e.root), d = p(u.filePath, u.outcome);
|
|
124
|
+
d && c.push(d), t.info("Reverting hooks.server.ts");
|
|
125
|
+
let h = b.join(e.root, "src", "hooks.server.ts"), x = f(h, A(h));
|
|
126
|
+
x.modify && c.push(x.modify), x.delete && l.push(x.delete);
|
|
127
127
|
let S = y.existsSync(b.join(e.root, "src", "lib", "server", "workflows.ts"));
|
|
128
128
|
t.info(S ? "Removing the PocketBase and workflow variables from src/env.ts" : "Removing the PocketBase variables from src/env.ts");
|
|
129
|
-
let C =
|
|
130
|
-
C.modify &&
|
|
131
|
-
let w = b.join(e.root, ".gitignore"), T =
|
|
132
|
-
T &&
|
|
133
|
-
let E = b.join(e.root, "src", "routes", "+layout.server.ts"), D =
|
|
134
|
-
if (D &&
|
|
135
|
-
let t = await
|
|
129
|
+
let C = m(e.root, (S ? o : i).map((e) => e.name));
|
|
130
|
+
C.modify && c.push(C.modify), C.delete && l.push(C.delete), t.info("Reverting .gitignore");
|
|
131
|
+
let w = b.join(e.root, ".gitignore"), T = p(w, v(w));
|
|
132
|
+
T && c.push(T), t.info("Reverting src/routes/+layout.server.ts");
|
|
133
|
+
let E = b.join(e.root, "src", "routes", "+layout.server.ts"), D = p(E, M(E));
|
|
134
|
+
if (D && c.push(D), D?.status === "success") {
|
|
135
|
+
let t = await a(e);
|
|
136
136
|
t && n.push(t);
|
|
137
137
|
}
|
|
138
|
-
for (let n of N(b.join(e.root, "src"))) t.info(`Removing ${b.relative(e.root, n)}`),
|
|
138
|
+
for (let n of N(b.join(e.root, "src"))) t.info(`Removing ${b.relative(e.root, n)}`), l.push(s(n));
|
|
139
139
|
t.info("Reverting test/setup.ts");
|
|
140
|
-
let O = b.join(e.root, "test", "setup.ts"), k =
|
|
141
|
-
return k &&
|
|
140
|
+
let O = b.join(e.root, "test", "setup.ts"), k = p(O, g(O));
|
|
141
|
+
return k && c.push(k), {
|
|
142
142
|
creates: n,
|
|
143
|
-
modifies:
|
|
144
|
-
deletes:
|
|
143
|
+
modifies: c,
|
|
144
|
+
deletes: l,
|
|
145
145
|
components: [],
|
|
146
146
|
packages: [],
|
|
147
147
|
collections: [],
|
|
@@ -152,4 +152,4 @@ async function P(e) {
|
|
|
152
152
|
//#endregion
|
|
153
153
|
export { P as generate };
|
|
154
154
|
|
|
155
|
-
//# sourceMappingURL=generate.runtime-
|
|
155
|
+
//# sourceMappingURL=generate.runtime-kpqW3dVO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-CSUnP0l-.js","names":["libModule","dedent","getLogger","BACKEND_ENV_VARS","WORKFLOWS_ENV_VARS","toDeleteEntry","pruneUnusedImports","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","revertOutcomeToFile","modifyOutcomeToFile","ensureSiteFile","removeHandle","unmodifyTestSetup","unmodifySvelteConfig","unmodifyGitignore","fs","path","HANDLE_HINT","INIT_HINT","BACKEND_MODULES","isStartWorkerCall","node","Node","onlyStartsWorker","fn","body","statements","workerInit","sf","decl","target","unmodifyHooksServerBackend","hooksServerPath","original","sourceFile","Project","QuoteKind","init","FAILURE_HINT","unmodifyLayoutServerMeta","layoutServerPath","updated","withoutParam","isLibSpecifier","m","serverTestFiles","dir","found","entry","full","generate","logger","options","creates","modifies","deletes","revert","svelteConfigFile","hooksServerRevert","hasWorkflows","envVars","unmodifyEnvVarsFiles","spec","gitignorePath","gitignoreFile","layoutServerFile","siteFile","testFile","testSetupPath","testSetupFile"],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n formatLikeSource,\n type ModuleMatch,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$app/env/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '#lib/server/workflows.js';\n`;\n\n/**\n * Modules only the backend's handle and init import from. An import nothing\n * references any more is dropped; a variable other code still reads stays.\n * `$env/dynamic/private` is the `env` object hooks written before SvelteKit 3\n * read the PocketBase variables from.\n */\nconst BACKEND_MODULES: ModuleMatch[] = [\n \"@velastack/pocketbase\",\n \"$app/env/private\",\n \"$env/dynamic/private\",\n libModule(\"server/workflows\"),\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\n return { status: \"success\", changed: 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 // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '#lib/site.js';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point an older root layout's meta at `#lib/site.js` instead of `locals.meta`.\n * Templates from before `src/lib/site.ts` read the app name and URL off the\n * PocketBase hook; without the backend nothing sets them, and `App.Locals` no\n * longer declares them. Current templates read `#lib/site.js` already, so this\n * leaves them alone.\n */\nexport function unmodifyLayoutServerMeta(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n const importsSite = [...updated.matchAll(/from\\s+['\"]([^'\"]+)['\"]/g)].some(\n (m) => isLibSpecifier(m[1], \"site\"),\n );\n if (!importsSite) {\n updated = \"import { site } from '#lib/site.js';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\nimport { BACKEND_ENV_VARS } from \"../../enable/backend/env-vars\";\nimport { WORKFLOWS_ENV_VARS } from \"../../enable/workflows/env-vars\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n // The file goes when these were all it declared. The workflow runtime\n // (deleted with the backend) is the only reader of its switches, so they\n // go too, but only from a project that has it: `TEST` is a common name.\n const hasWorkflows = fs.existsSync(\n path.join(options.root, \"src\", \"lib\", \"server\", \"workflows.ts\"),\n );\n logger.info(\n hasWorkflows\n ? \"Removing the PocketBase and workflow variables from src/env.ts\"\n : \"Removing the PocketBase variables from src/env.ts\",\n );\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n (hasWorkflows ? WORKFLOWS_ENV_VARS : BACKEND_ENV_VARS).map(\n (spec) => spec.name,\n ),\n );\n if (envVars.modify) modifies.push(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n // The converted layout reads `src/lib/site.ts`. Every template ships it; a\n // project from before that gets one here, named as PocketBase knew it.\n if (layoutServerFile?.status === \"success\") {\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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":";;;;;;;;;;;;;;;;AAoBA,IAAMmB,IAAc,CAAM;;;GAKpBC,IAAY,CAAM;;;;;GAalBC,IAAiC;CACrC;CACA;CACA;CACArB,EAAU,kBAAkB;CAC5B;CACA;AACF;AAGA,SAASsB,EAAkB,GAAiC;CAO1D,OANKC,IACDC,EAAK,kBAAkBD,CAAI,KAE3BC,EAAK,sBAAsBD,CAAI,KAAKC,EAAK,kBAAkBD,CAAI,IAC1DD,EAAkBC,EAAK,cAAc,CAAC,IAG7CC,EAAK,iBAAiBD,CAAI,KAC1BA,EAAK,cAAc,CAAC,CAAC,QAAQ,MAAM,iBACnCA,EAAK,aAAa,CAAC,CAAC,WAAW,IATf;AAWpB;AAGA,SAASE,EAAiB,GAA+B;CACvD,IACE,CAACD,EAAK,gBAAgBE,CAAE,KACxB,CAACF,EAAK,qBAAqBE,CAAE,KAC7B,CAACF,EAAK,sBAAsBE,CAAE,GAE9B,OAAO;CAET,IAAMC,IAAOD,EAAG,QAAQ;CACxB,IAAI,CAACC,GAAM,OAAO;CAClB,IAAI,CAACH,EAAK,QAAQG,CAAI,GAAG,OAAOL,EAAkBK,CAAI;CACtD,IAAMC,IAAaD,EAAK,cAAc;CACtC,OAAOC,EAAW,WAAW,KAAKN,EAAkBM,EAAW,EAAE;AACnE;AAOA,SAASC,EAAW,GAA6C;CAC/D,IAAMH,IAAKI,EAAG,YAAY,MAAM,GAC1BC,IAAOD,EAAG,uBAAuB,MAAM,GACvCE,IAASN,KAAMK,GAAM,qBAAqB;CAMhD,OALI,CAACC,KAAU,CAACA,EAAO,QAAQ,CAAC,CAAC,SAAS,aAAa,IAAU,QAC9CN,IACfD,EAAiBC,CAAE,IACnBK,GAAM,qBAAqB,CAAC,EAAE,gBAAgB,CAAC,CAAC,WAAW,KAC3DN,EAAiBM,EAAK,eAAe,CAAC,KAC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,KAAKoC,EAAQ,MAAM,QAAQ,UAAU,GAC1DiB,IAAgB5D,EACpB2D,GACAxD,EAAkBwD,CAAa,CACjC;CAGA,OAFIC,KAAef,EAAS,KAAKe,CAAa,GAEvC;EACL;EACA;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"generate.runtime-kpqW3dVO.js","names":["libModule","dedent","getLogger","BACKEND_ENV_VARS","ensureSiteFile","WORKFLOWS_ENV_VARS","toDeleteEntry","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","revertOutcomeToFile","modifyOutcomeToFile","removeHandle","unmodifyTestSetup","unmodifySvelteConfig","unmodifyGitignore","fs","path","HANDLE_HINT","INIT_HINT","BACKEND_MODULES","isStartWorkerCall","node","Node","onlyStartsWorker","fn","body","statements","workerInit","sf","decl","target","unmodifyHooksServerBackend","hooksServerPath","original","sourceFile","Project","QuoteKind","init","pruneUnusedImports","FAILURE_HINT","unmodifyLayoutServerMeta","layoutServerPath","updated","withoutParam","isLibSpecifier","m","serverTestFiles","dir","found","entry","full","generate","logger","options","creates","modifies","deletes","revert","svelteConfigFile","hooksServerRevert","hasWorkflows","envVars","unmodifyEnvVarsFiles","spec","gitignorePath","gitignoreFile","layoutServerFile","siteFile","testFile","testSetupPath","testSetupFile"],"sources":["../../src/patterns/disable/backend/modifies/hooks.server.ts","../../src/patterns/disable/backend/modifies/layout-server.ts","../../src/patterns/disable/backend/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport {\n Node,\n Project,\n QuoteKind,\n type SourceFile,\n type Statement,\n} from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n pruneUnusedImports,\n removeStatementWithComments,\n formatLikeSource,\n type ModuleMatch,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { libModule } from \"../../../../runtime/lib-specifier\";\n\nconst HANDLE_HINT = dedent`\n Take handlePocketbase(...) out of the exported handle in src/hooks.server.ts,\n and its imports from '@velastack/pocketbase' and '$app/env/private'.\n`;\n\nconst INIT_HINT = dedent`\n The workflows are removed with the backend. Take the startWorker() call out\n of the init hook in src/hooks.server.ts, and its import:\n\n import { startWorker } from '#lib/server/workflows.js';\n`;\n\n/**\n * Modules only the backend's handle and init import from. An import nothing\n * references any more is dropped; a variable other code still reads stays.\n * `$env/dynamic/private` is the `env` object hooks written before SvelteKit 3\n * read the PocketBase variables from.\n */\nconst BACKEND_MODULES: ModuleMatch[] = [\n \"@velastack/pocketbase\",\n \"$app/env/private\",\n \"$env/dynamic/private\",\n libModule(\"server/workflows\"),\n \"@sveltejs/kit\",\n \"@sveltejs/kit/hooks\",\n];\n\n/** `startWorker()`, `await startWorker()` or `return startWorker()`. */\nfunction isStartWorkerCall(node: Node | undefined): boolean {\n if (!node) return false;\n if (Node.isAwaitExpression(node))\n return isStartWorkerCall(node.getExpression());\n if (Node.isExpressionStatement(node) || Node.isReturnStatement(node)) {\n return isStartWorkerCall(node.getExpression());\n }\n return (\n Node.isCallExpression(node) &&\n node.getExpression().getText() === \"startWorker\" &&\n node.getArguments().length === 0\n );\n}\n\n/** A function whose whole body starts the worker. */\nfunction onlyStartsWorker(fn: Node | undefined): boolean {\n if (\n !Node.isArrowFunction(fn) &&\n !Node.isFunctionExpression(fn) &&\n !Node.isFunctionDeclaration(fn)\n ) {\n return false;\n }\n const body = fn.getBody();\n if (!body) return false;\n if (!Node.isBlock(body)) return isStartWorkerCall(body);\n const statements = body.getStatements();\n return statements.length === 1 && isStartWorkerCall(statements[0]);\n}\n\n/**\n * The `init` export when all it does is start the workflow worker, the way\n * the minimal template and enable-workflows write it. `\"custom\"` when an init\n * starts the worker among other things; null when there is nothing to do.\n */\nfunction workerInit(sf: SourceFile): Statement | \"custom\" | null {\n const fn = sf.getFunction(\"init\");\n const decl = sf.getVariableDeclaration(\"init\");\n const target = fn ?? decl?.getVariableStatement();\n if (!target || !target.getText().includes(\"startWorker\")) return null;\n const onlyWorker = fn\n ? onlyStartsWorker(fn)\n : decl?.getVariableStatement()?.getDeclarations().length === 1 &&\n onlyStartsWorker(decl.getInitializer());\n return onlyWorker ? target : \"custom\";\n}\n\n/**\n * Undo what the backend put in `hooks.server.ts`: the PocketBase handle, and\n * the `init` that starts the workflow worker, which is deleted along with the\n * backend. Whatever else the file holds (i18n, content negotiation) stays; a\n * file with nothing else comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerBackend(\n hooksServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (\n !original.includes(\"handlePocketbase\") &&\n !original.includes(\"startWorker\")\n ) {\n return { status: \"success\", changed: 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 // Checked before anything changes, so a failure leaves the file as it was.\n if (workerInit(sourceFile) === \"custom\") {\n return { status: \"failed\", message: INIT_HINT };\n }\n\n const removed = removeHandle(sourceFile, \"handlePocketbase\");\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: HANDLE_HINT };\n }\n // Looked up again: edits to the file forget the nodes found before them.\n const init = workerInit(sourceFile);\n if (init && init !== \"custom\") removeStatementWithComments(sourceFile, init);\n\n pruneUnusedImports(sourceFile, BACKEND_MODULES);\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.server.ts still reads locals.meta, which only the\n PocketBase hook provides. Read the values from a static module instead:\n\n import { site } from '#lib/site.js';\n\n // locals.meta.appName -> site.name\n // locals.meta.appURL -> site.url\n // meta: locals.meta -> meta: { appName: site.name, appURL: site.url }\n`;\n\n/**\n * Point an older root layout's meta at `#lib/site.js` instead of `locals.meta`.\n * Templates from before `src/lib/site.ts` read the app name and URL off the\n * PocketBase hook; without the backend nothing sets them, and `App.Locals` no\n * longer declares them. Current templates read `#lib/site.js` already, so this\n * leaves them alone.\n */\nexport function unmodifyLayoutServerMeta(\n layoutServerPath: string,\n): ModifyOutcome {\n if (!fs.existsSync(layoutServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(layoutServerPath, \"utf8\");\n if (!original.includes(\"locals.meta\")) {\n return { status: \"success\", changed: false };\n }\n\n let updated = original\n .replace(/\\blocals\\.meta\\.appName\\b/g, \"site.name\")\n .replace(/\\blocals\\.meta\\.appURL\\b/g, \"site.url\")\n .replace(\n /\\bmeta:\\s*locals\\.meta\\b/g,\n \"meta: { appName: site.name, appURL: site.url }\",\n );\n\n if (updated.includes(\"locals.meta\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n // `locals` usually only carried meta; drop it from the destructuring when\n // nothing else reads it.\n const withoutParam = updated\n .replace(/\\(\\{\\s*locals\\s*,\\s*/g, \"({ \")\n .replace(/,\\s*locals\\s*\\}/g, \" }\");\n if (!/\\blocals\\b/.test(withoutParam)) {\n updated = withoutParam;\n }\n\n const importsSite = [...updated.matchAll(/from\\s+['\"]([^'\"]+)['\"]/g)].some(\n (m) => isLibSpecifier(m[1], \"site\"),\n );\n if (!importsSite) {\n updated = \"import { site } from '#lib/site.js';\\n\" + updated;\n }\n\n fs.writeFileSync(layoutServerPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport {\n modifyOutcomeToFile,\n revertOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { toDeleteEntry } from \"../../destroy/shared\";\nimport { ensureSiteFile } from \"../../../runtime/site\";\nimport { unmodifyHooksServerBackend } from \"./modifies/hooks.server\";\nimport { unmodifyLayoutServerMeta } from \"./modifies/layout-server\";\nimport { unmodifySvelteConfig } from \"../../enable/backend/modifies/svelte-config\";\nimport { unmodifyGitignore } from \"../../enable/backend/modifies/gitignore\";\nimport { unmodifyTestSetup } from \"../../enable/backend/modifies/test-setup\";\nimport { BACKEND_ENV_VARS } from \"../../enable/backend/env-vars\";\nimport { WORKFLOWS_ENV_VARS } from \"../../enable/workflows/env-vars\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\n\n/** Every server test under a directory; they need the PocketBase test context. */\nfunction serverTestFiles(dir: string): string[] {\n if (!fs.existsSync(dir)) return [];\n const found: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) found.push(...serverTestFiles(full));\n else if (entry.name === \"server.test.ts\") found.push(full);\n }\n return found;\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n const modifies: File[] = [];\n const deletes: File[] = [];\n\n logger.info(\"Reverting adapter config\");\n const revert = unmodifySvelteConfig(options.root);\n const svelteConfigFile = modifyOutcomeToFile(revert.filePath, revert.outcome);\n if (svelteConfigFile) modifies.push(svelteConfigFile);\n\n // Only the backend's handle and worker come out; handles other patterns\n // composed in stay. The file goes when nothing else was in it.\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerBackend(hooksServerPath),\n );\n if (hooksServerRevert.modify) modifies.push(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n // The file goes when these were all it declared. The workflow runtime\n // (deleted with the backend) is the only reader of its switches, so they\n // go too, but only from a project that has it: `TEST` is a common name.\n const hasWorkflows = fs.existsSync(\n path.join(options.root, \"src\", \"lib\", \"server\", \"workflows.ts\"),\n );\n logger.info(\n hasWorkflows\n ? \"Removing the PocketBase and workflow variables from src/env.ts\"\n : \"Removing the PocketBase variables from src/env.ts\",\n );\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n (hasWorkflows ? WORKFLOWS_ENV_VARS : BACKEND_ENV_VARS).map(\n (spec) => spec.name,\n ),\n );\n if (envVars.modify) modifies.push(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n logger.info(\"Reverting .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n const gitignoreFile = modifyOutcomeToFile(\n gitignorePath,\n unmodifyGitignore(gitignorePath),\n );\n if (gitignoreFile) modifies.push(gitignoreFile);\n\n logger.info(\"Reverting src/routes/+layout.server.ts\");\n const layoutServerPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n const layoutServerFile = modifyOutcomeToFile(\n layoutServerPath,\n unmodifyLayoutServerMeta(layoutServerPath),\n );\n if (layoutServerFile) modifies.push(layoutServerFile);\n\n // The converted layout reads `src/lib/site.ts`. Every template ships it; a\n // project from before that gets one here, named as PocketBase knew it.\n if (layoutServerFile?.status === \"success\") {\n const siteFile = await ensureSiteFile(options);\n if (siteFile) creates.push(siteFile);\n }\n\n // Server tests run against the PocketBase-backed test context that the\n // backend's test/setup.ts provides; without it they neither type-check nor\n // run.\n for (const testFile of serverTestFiles(path.join(options.root, \"src\"))) {\n logger.info(`Removing ${path.relative(options.root, testFile)}`);\n deletes.push(toDeleteEntry(testFile));\n }\n\n logger.info(\"Reverting test/setup.ts\");\n const testSetupPath = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetupPath,\n unmodifyTestSetup(testSetupPath),\n );\n if (testSetupFile) modifies.push(testSetupFile);\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":";;;;;;;;;;;;;;;;AAoBA,IAAMkB,IAAc,CAAM;;;GAKpBC,IAAY,CAAM;;;;;GAalBC,IAAiC;CACrC;CACA;CACA;CACApB,EAAU,kBAAkB;CAC5B;CACA;AACF;AAGA,SAASqB,EAAkB,GAAiC;CAO1D,OANKC,IACDC,EAAK,kBAAkBD,CAAI,KAE3BC,EAAK,sBAAsBD,CAAI,KAAKC,EAAK,kBAAkBD,CAAI,IAC1DD,EAAkBC,EAAK,cAAc,CAAC,IAG7CC,EAAK,iBAAiBD,CAAI,KAC1BA,EAAK,cAAc,CAAC,CAAC,QAAQ,MAAM,iBACnCA,EAAK,aAAa,CAAC,CAAC,WAAW,IATf;AAWpB;AAGA,SAASE,EAAiB,GAA+B;CACvD,IACE,CAACD,EAAK,gBAAgBE,CAAE,KACxB,CAACF,EAAK,qBAAqBE,CAAE,KAC7B,CAACF,EAAK,sBAAsBE,CAAE,GAE9B,OAAO;CAET,IAAMC,IAAOD,EAAG,QAAQ;CACxB,IAAI,CAACC,GAAM,OAAO;CAClB,IAAI,CAACH,EAAK,QAAQG,CAAI,GAAG,OAAOL,EAAkBK,CAAI;CACtD,IAAMC,IAAaD,EAAK,cAAc;CACtC,OAAOC,EAAW,WAAW,KAAKN,EAAkBM,EAAW,EAAE;AACnE;AAOA,SAASC,EAAW,GAA6C;CAC/D,IAAMH,IAAKI,EAAG,YAAY,MAAM,GAC1BC,IAAOD,EAAG,uBAAuB,MAAM,GACvCE,IAASN,KAAMK,GAAM,qBAAqB;CAMhD,OALI,CAACC,KAAU,CAACA,EAAO,QAAQ,CAAC,CAAC,SAAS,aAAa,IAAU,QAC9CN,IACfD,EAAiBC,CAAE,IACnBK,GAAM,qBAAqB,CAAC,EAAE,gBAAgB,CAAC,CAAC,WAAW,KAC3DN,EAAiBM,EAAK,eA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D,EAAK,KAAKqC,EAAQ,MAAM,QAAQ,UAAU,GAC1DiB,IAAgB5D,EACpB2D,GACAzD,EAAkByD,CAAa,CACjC;CAGA,OAFIC,KAAef,EAAS,KAAKe,CAAa,GAEvC;EACL;EACA;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { t } from "./shared-
|
|
2
|
+
import { t } from "./shared-BPlAVf-T.js";
|
|
3
3
|
import { f as n, o as r } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
4
|
-
import { r as i } from "./modify-file-
|
|
4
|
+
import { r as i } from "./modify-file-289rStJ2.js";
|
|
5
5
|
import { t as a } from "./svelte-file-Dv5-bl79.js";
|
|
6
6
|
import o from "node:fs";
|
|
7
7
|
import s from "node:path";
|
|
@@ -91,4 +91,4 @@ async function f(n) {
|
|
|
91
91
|
//#endregion
|
|
92
92
|
export { f as generate };
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=generate.runtime-
|
|
94
|
+
//# sourceMappingURL=generate.runtime-wGRE1zwZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-wGRE1zwZ.js","names":["apiObj","getLogger","removeNavItemFromScript","formatLikeSource","modifyOutcomeToFile","SvelteFile","fs","path","unmodifyHooksServer","hooksServerPath","originalSource","sourceFile","Project","callExpr","SyntaxKind","ce","firstArg","apiProp","apiInit","apiKeysProp","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","generate","logger","options","modifies","pushResult","planDropsForCollections"],"sources":["../../src/patterns/disable/api-keys/modifies/hooks.server.ts","../../src/patterns/disable/api-keys/modifies/nav-user.svelte.ts","../../src/patterns/disable/api-keys/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyHooksServer(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(hooksServerPath, \"utf8\");\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 if (!callExpr) return { status: \"success\", changed: false };\n\n const [firstArg] = callExpr.getArguments();\n if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const optionsObj = firstArg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const apiProp = optionsObj.getProperty(\"api\");\n if (!apiProp || apiProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return { status: \"success\", changed: false };\n }\n\n const apiInit = (\n apiProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n if (!apiInit || apiInit.getKind() !== SyntaxKind.ObjectLiteralExpression) {\n return { status: \"success\", changed: false };\n }\n\n const apiObj = apiInit as import(\"ts-morph\").ObjectLiteralExpression;\n const apiKeysProp = apiObj.getProperty(\"apiKeys\");\n if (!apiKeysProp) {\n return { status: \"success\", changed: false };\n }\n\n apiKeysProp.remove();\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","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(\"/api-keys\")) {\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 \"API Keys\",\n \"@lucide/svelte/icons/key-round\",\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 type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\nimport { unmodifyNavUser } from \"./modifies/nav-user.svelte\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\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 hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerPath, unmodifyHooksServer(hooksServerPath)),\n );\n\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n const collectionDrops = await planDropsForCollections([\"api_keys\"], options);\n\n return {\n creates: [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies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1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as d } from "./
|
|
3
|
+
import { i as n, n as r, t as i } from "./pocketbase-B017Cqjq.js";
|
|
4
|
+
import { n as a } from "./site-DkU1-VRq.js";
|
|
5
|
+
import { _ as o, a as s, o as c, r as l } from "./ts-morph-helpers-Bepc-Es2.js";
|
|
6
|
+
import { r as u } from "./modify-file-289rStJ2.js";
|
|
7
|
+
import { t as d } from "./svelte-file-Dv5-bl79.js";
|
|
8
8
|
import f from "node:fs";
|
|
9
9
|
import p from "node:path";
|
|
10
10
|
import { Project as m, SyntaxKind as h } from "ts-morph";
|
|
@@ -21,42 +21,42 @@ function g(t) {
|
|
|
21
21
|
changed: !0
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
let n = f.readFileSync(t, "utf8"), r = new m().addSourceFileAtPath(t),
|
|
24
|
+
let n = f.readFileSync(t, "utf8"), r = new m().addSourceFileAtPath(t), i = (e) => {
|
|
25
25
|
e.getProperty("user") || e.addPropertyAssignment({
|
|
26
26
|
name: "user",
|
|
27
27
|
initializer: "locals.pb.authStore.record"
|
|
28
28
|
});
|
|
29
|
-
}, o, s
|
|
30
|
-
if (
|
|
31
|
-
let e =
|
|
32
|
-
if (e)
|
|
29
|
+
}, a, o, s = r.getVariableDeclaration("load");
|
|
30
|
+
if (s && s.getFirstAncestorByKind(h.VariableStatement)?.hasExportKeyword()) {
|
|
31
|
+
let e = s.getInitializerIfKind(h.ArrowFunction);
|
|
32
|
+
if (e) a = e;
|
|
33
33
|
else {
|
|
34
|
-
let e =
|
|
34
|
+
let e = s.getInitializer();
|
|
35
35
|
if (e) {
|
|
36
36
|
let t = e.getFirstDescendantByKind(h.ArrowFunction);
|
|
37
|
-
if (t)
|
|
37
|
+
if (t) a = t;
|
|
38
38
|
else {
|
|
39
39
|
let t = e.getFirstDescendantByKind(h.FunctionExpression);
|
|
40
|
-
t && (
|
|
40
|
+
t && (o = t);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
if (!
|
|
45
|
+
if (!a) {
|
|
46
46
|
let e = r.getFunction("load");
|
|
47
|
-
e && e.isExported() && (
|
|
47
|
+
e && e.isExported() && (o = e);
|
|
48
48
|
}
|
|
49
|
-
if (!
|
|
49
|
+
if (!a && !o) return r.addFunction({
|
|
50
50
|
isExported: !0,
|
|
51
51
|
isAsync: !0,
|
|
52
52
|
name: "load",
|
|
53
53
|
parameters: [{ name: "{ locals }" }],
|
|
54
54
|
statements: "return { user: locals.pb.authStore.record };"
|
|
55
|
-
}),
|
|
55
|
+
}), c(r), r.saveSync(), {
|
|
56
56
|
status: "success",
|
|
57
57
|
changed: !0
|
|
58
58
|
};
|
|
59
|
-
let l =
|
|
59
|
+
let l = a ?? o, u = l.getParameters();
|
|
60
60
|
if (u.length === 0) l.insertParameter(0, { name: "{ locals }" });
|
|
61
61
|
else {
|
|
62
62
|
let e = u[0], t = e.getStructure(), n = e.getNameNode();
|
|
@@ -79,15 +79,15 @@ function g(t) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
if (
|
|
83
|
-
let e =
|
|
82
|
+
if (a) {
|
|
83
|
+
let e = a.getBody();
|
|
84
84
|
if (e.getKind() === h.Block) e.getDescendantsOfKind(h.ReturnStatement).forEach((e) => {
|
|
85
85
|
let t = e.getExpression();
|
|
86
86
|
if (t) {
|
|
87
|
-
if (t.getKind() === h.ObjectLiteralExpression)
|
|
87
|
+
if (t.getKind() === h.ObjectLiteralExpression) i(t);
|
|
88
88
|
else if (t.getKind() === h.ParenthesizedExpression) {
|
|
89
89
|
let e = t.getExpression();
|
|
90
|
-
e.getKind() === h.ObjectLiteralExpression &&
|
|
90
|
+
e.getKind() === h.ObjectLiteralExpression && i(e);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -95,23 +95,23 @@ function g(t) {
|
|
|
95
95
|
let t = e;
|
|
96
96
|
if (t.getKind() === h.ParenthesizedExpression) {
|
|
97
97
|
let e = t.getExpression();
|
|
98
|
-
e.getKind() === h.ObjectLiteralExpression &&
|
|
99
|
-
} else t.getKind() === h.ObjectLiteralExpression &&
|
|
98
|
+
e.getKind() === h.ObjectLiteralExpression && i(e);
|
|
99
|
+
} else t.getKind() === h.ObjectLiteralExpression && i(t);
|
|
100
100
|
}
|
|
101
|
-
} else if (
|
|
102
|
-
let e =
|
|
101
|
+
} else if (o) {
|
|
102
|
+
let e = o.getBody();
|
|
103
103
|
e && e.getDescendantsOfKind(h.ReturnStatement).forEach((e) => {
|
|
104
104
|
let t = e.getExpression();
|
|
105
105
|
if (t) {
|
|
106
|
-
if (t.getKind() === h.ObjectLiteralExpression)
|
|
106
|
+
if (t.getKind() === h.ObjectLiteralExpression) i(t);
|
|
107
107
|
else if (t.getKind() === h.ParenthesizedExpression) {
|
|
108
108
|
let e = t.getExpression();
|
|
109
|
-
e.getKind() === h.ObjectLiteralExpression &&
|
|
109
|
+
e.getKind() === h.ObjectLiteralExpression && i(e);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
return
|
|
114
|
+
return c(r), r.saveSync(), {
|
|
115
115
|
status: "success",
|
|
116
116
|
changed: r.getFullText() !== n
|
|
117
117
|
};
|
|
@@ -145,19 +145,19 @@ function x(e) {
|
|
|
145
145
|
status: "not-found",
|
|
146
146
|
message: b
|
|
147
147
|
};
|
|
148
|
-
let t =
|
|
148
|
+
let t = d.fromPath(e);
|
|
149
149
|
return t.hasElement("Navbar.List") ? t.hasElement("AuthMenu.Root") ? {
|
|
150
150
|
status: "success",
|
|
151
151
|
changed: !1
|
|
152
152
|
} : (t.modifyScript((e) => {
|
|
153
|
-
let { source: t } =
|
|
154
|
-
|
|
153
|
+
let { source: t } = o(e, (e) => {
|
|
154
|
+
l(e, [{
|
|
155
155
|
namespaceImport: "AuthMenu",
|
|
156
156
|
moduleSpecifier: "#lib/components/ui/auth-menu/index.js"
|
|
157
157
|
}, {
|
|
158
158
|
defaultImport: "UserAvatar",
|
|
159
159
|
moduleSpecifier: "#lib/components/user-avatar.svelte"
|
|
160
|
-
}]),
|
|
160
|
+
}]), s(e, "data");
|
|
161
161
|
});
|
|
162
162
|
return t;
|
|
163
163
|
}), t.insertBeforeClosingTag("Navbar.List", _), t.writeTo(e), {
|
|
@@ -195,26 +195,26 @@ function w(e) {
|
|
|
195
195
|
status: "failed",
|
|
196
196
|
message: S
|
|
197
197
|
};
|
|
198
|
-
let
|
|
199
|
-
if (
|
|
198
|
+
let i = r.getArguments();
|
|
199
|
+
if (i.length === 0) return r.addArgument("{ auth: { protectedRoutes: ['/(app)'] } }"), c(n), n.saveSync(), {
|
|
200
200
|
status: "success",
|
|
201
201
|
changed: !0
|
|
202
202
|
};
|
|
203
|
-
let
|
|
204
|
-
if (
|
|
203
|
+
let a = i[0];
|
|
204
|
+
if (a.getKind() !== h.ObjectLiteralExpression) return r.insertArgument(0, "{ auth: { protectedRoutes: ['/(app)'] } }"), c(n), n.saveSync(), {
|
|
205
205
|
status: "success",
|
|
206
206
|
changed: !0
|
|
207
207
|
};
|
|
208
|
-
let
|
|
209
|
-
if (!
|
|
208
|
+
let o = a.asKindOrThrow(h.ObjectLiteralExpression), s = o.getProperty("auth");
|
|
209
|
+
if (!s) return o.addPropertyAssignment({
|
|
210
210
|
name: "auth",
|
|
211
211
|
initializer: "{ protectedRoutes: ['/(app)'] }"
|
|
212
|
-
}),
|
|
212
|
+
}), c(n), n.saveSync(), {
|
|
213
213
|
status: "success",
|
|
214
214
|
changed: !0
|
|
215
215
|
};
|
|
216
|
-
if (
|
|
217
|
-
let e =
|
|
216
|
+
if (s.getKind() === h.PropertyAssignment) {
|
|
217
|
+
let e = s.getInitializer();
|
|
218
218
|
if (e && e.getKind() === h.ObjectLiteralExpression) {
|
|
219
219
|
let t = e, n = t.getProperty("protectedRoutes");
|
|
220
220
|
if (!n) t.addPropertyAssignment({
|
|
@@ -230,7 +230,7 @@ function w(e) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
return
|
|
233
|
+
return c(n), n.saveSync(), {
|
|
234
234
|
status: "success",
|
|
235
235
|
changed: n.getFullText() !== t
|
|
236
236
|
};
|
|
@@ -271,54 +271,54 @@ function D(e) {
|
|
|
271
271
|
//#endregion
|
|
272
272
|
//#region src/patterns/enable/auth/generate.runtime.ts
|
|
273
273
|
async function O(e) {
|
|
274
|
-
let { input:
|
|
275
|
-
await
|
|
276
|
-
|
|
277
|
-
senderName:
|
|
278
|
-
senderAddress:
|
|
279
|
-
} }), await
|
|
280
|
-
let
|
|
281
|
-
if (!
|
|
282
|
-
let
|
|
283
|
-
|
|
274
|
+
let { input: o } = e, s = t(e), c = [];
|
|
275
|
+
await n(e.root, async (t) => {
|
|
276
|
+
s.info("Updating PocketBase mail settings"), await t.settings.update({ meta: {
|
|
277
|
+
senderName: o.senderName,
|
|
278
|
+
senderAddress: o.senderAddress
|
|
279
|
+
} }), await r();
|
|
280
|
+
let n = await t.collections.getOne("users");
|
|
281
|
+
if (!n) throw Error("Users collection not found");
|
|
282
|
+
let a = 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}"), u = n.confirmEmailChangeTemplate.body.replace("{APP_URL}/_/#/auth/confirm-email-change/{TOKEN}", "{APP_URL}/confirm-email-change/{TOKEN}");
|
|
283
|
+
s.info("Locking down users collection rules and email templates"), await t.collections.update("users", {
|
|
284
284
|
listRule: "@request.auth.id = id",
|
|
285
285
|
viewRule: "@request.auth.id = id",
|
|
286
286
|
createRule: "@request.auth.id = id",
|
|
287
287
|
updateRule: "@request.auth.id = id",
|
|
288
288
|
deleteRule: "@request.auth.id = id",
|
|
289
|
-
verificationTemplate: { body:
|
|
290
|
-
resetPasswordTemplate: { body:
|
|
291
|
-
confirmEmailChangeTemplate: { body:
|
|
292
|
-
}), await
|
|
293
|
-
let d =
|
|
294
|
-
d &&
|
|
289
|
+
verificationTemplate: { body: a },
|
|
290
|
+
resetPasswordTemplate: { body: l },
|
|
291
|
+
confirmEmailChangeTemplate: { body: u }
|
|
292
|
+
}), await r();
|
|
293
|
+
let d = i("users", "updated", e);
|
|
294
|
+
d && c.push({
|
|
295
295
|
path: d,
|
|
296
296
|
language: "ts",
|
|
297
297
|
content: f.readFileSync(d, "utf8"),
|
|
298
298
|
status: "success"
|
|
299
299
|
});
|
|
300
300
|
});
|
|
301
|
-
let
|
|
302
|
-
e &&
|
|
301
|
+
let l = [], d = (e) => {
|
|
302
|
+
e && l.push(e);
|
|
303
303
|
};
|
|
304
|
-
|
|
304
|
+
s.info("Modifying +layout.server.ts");
|
|
305
305
|
let m = p.join(e.root, "src", "routes", "+layout.server.ts");
|
|
306
|
-
|
|
306
|
+
d(u(m, g(m))), s.info("Modifying root layout");
|
|
307
307
|
let h = [
|
|
308
308
|
p.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
309
309
|
p.join(e.root, "src", "routes", "root-layout.svelte"),
|
|
310
310
|
p.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
311
311
|
p.join(e.root, "src", "routes", "+layout.svelte")
|
|
312
312
|
], _ = h.find((e) => f.existsSync(e)) ?? h[0];
|
|
313
|
-
|
|
313
|
+
d(u(_, x(_))), s.info("Modifying hooks.server.ts");
|
|
314
314
|
let v = p.join(e.root, "src", "hooks.server.ts");
|
|
315
|
-
|
|
315
|
+
d(u(v, w(v))), s.info("Modifying sidebar-menu-button.svelte");
|
|
316
316
|
let y = p.join(e.root, "src", "lib", "components", "ui", "sidebar", "sidebar-menu-button.svelte");
|
|
317
|
-
|
|
318
|
-
let b = await
|
|
317
|
+
d(u(y, D(y)));
|
|
318
|
+
let b = await a(e);
|
|
319
319
|
return {
|
|
320
320
|
creates: b ? [b] : [],
|
|
321
|
-
modifies:
|
|
321
|
+
modifies: l,
|
|
322
322
|
deletes: [],
|
|
323
323
|
components: [],
|
|
324
324
|
packages: [],
|
|
@@ -330,4 +330,4 @@ async function O(e) {
|
|
|
330
330
|
//#endregion
|
|
331
331
|
export { O as generate };
|
|
332
332
|
|
|
333
|
-
//# sourceMappingURL=generate.runtime-
|
|
333
|
+
//# sourceMappingURL=generate.runtime-wziCW3ct.js.map
|