@velastack/patterns 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -2
- package/dist/chunks/_layout-B7ujvjnA.js +55 -0
- package/dist/chunks/_layout-B7ujvjnA.js.map +1 -0
- package/dist/chunks/{collections-CgdvZXmh.js → collections-UPqYto13.js} +2 -2
- package/dist/chunks/{collections-CgdvZXmh.js.map → collections-UPqYto13.js.map} +1 -1
- package/dist/chunks/{compose-handle-Cg9jnCsS.js → compose-handle-B-CkDcQD.js} +23 -23
- package/dist/chunks/{compose-handle-Cg9jnCsS.js.map → compose-handle-B-CkDcQD.js.map} +1 -1
- package/dist/chunks/config-target-Bln26FJe.js +164 -0
- package/dist/chunks/config-target-Bln26FJe.js.map +1 -0
- package/dist/chunks/errors-DR3gF_7a.js +18 -0
- package/dist/chunks/errors-DR3gF_7a.js.map +1 -0
- package/dist/chunks/{generate-DRA63W0r.js → generate-6snrlnpA.js} +2 -2
- package/dist/chunks/{generate-DRA63W0r.js.map → generate-6snrlnpA.js.map} +1 -1
- package/dist/chunks/{generate-BkQ1xMDp.js → generate-C6xi5S5L.js} +4 -4
- package/dist/chunks/{generate-BkQ1xMDp.js.map → generate-C6xi5S5L.js.map} +1 -1
- package/dist/chunks/{generate-tOkjJFUf.js → generate-CyuY2Ci7.js} +4 -3
- package/dist/chunks/generate-CyuY2Ci7.js.map +1 -0
- package/dist/chunks/{generate-iQP31-m1.js → generate-DHgKgHb7.js} +4 -4
- package/dist/chunks/{generate-iQP31-m1.js.map → generate-DHgKgHb7.js.map} +1 -1
- package/dist/chunks/{generate-_LvrYK6i.js → generate-jsB_oO0b.js} +4 -4
- package/dist/chunks/{generate-_LvrYK6i.js.map → generate-jsB_oO0b.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DAmYsIvF.js → generate.runtime-9R2AUKLS.js} +5 -5
- package/dist/chunks/{generate.runtime-DAmYsIvF.js.map → generate.runtime-9R2AUKLS.js.map} +1 -1
- package/dist/chunks/generate.runtime-B3yX6kl2.js +87 -0
- package/dist/chunks/generate.runtime-B3yX6kl2.js.map +1 -0
- package/dist/chunks/{generate.runtime-BKo-Nidn.js → generate.runtime-B7wkyj-8.js} +6 -6
- package/dist/chunks/{generate.runtime-BKo-Nidn.js.map → generate.runtime-B7wkyj-8.js.map} +1 -1
- package/dist/chunks/generate.runtime-BHf8p_3K.js +94 -0
- package/dist/chunks/generate.runtime-BHf8p_3K.js.map +1 -0
- package/dist/chunks/{generate.runtime-BbIN0tUZ.js → generate.runtime-BSFIwX58.js} +67 -66
- package/dist/chunks/generate.runtime-BSFIwX58.js.map +1 -0
- package/dist/chunks/{generate.runtime-BnWE4qsu.js → generate.runtime-Bb9CCwQm.js} +55 -54
- package/dist/chunks/generate.runtime-Bb9CCwQm.js.map +1 -0
- package/dist/chunks/{generate.runtime-D8vgh5MH.js → generate.runtime-BjciAjq7.js} +156 -76
- package/dist/chunks/generate.runtime-BjciAjq7.js.map +1 -0
- package/dist/chunks/{generate.runtime-BwhGDnGu.js → generate.runtime-BpTpRBdH.js} +151 -150
- package/dist/chunks/generate.runtime-BpTpRBdH.js.map +1 -0
- package/dist/chunks/{generate.runtime-D0icLb5j.js → generate.runtime-Brf08fMW.js} +11 -10
- package/dist/chunks/{generate.runtime-D0icLb5j.js.map → generate.runtime-Brf08fMW.js.map} +1 -1
- package/dist/chunks/{generate.runtime-S5RIgbQx.js → generate.runtime-C6DfW_NO.js} +98 -92
- package/dist/chunks/generate.runtime-C6DfW_NO.js.map +1 -0
- package/dist/chunks/{generate.runtime-DhkaXTq3.js → generate.runtime-C9fSqy6a.js} +61 -59
- package/dist/chunks/generate.runtime-C9fSqy6a.js.map +1 -0
- package/dist/chunks/{generate.runtime-CRYjWJRe.js → generate.runtime-CawvLUoV.js} +89 -88
- package/dist/chunks/generate.runtime-CawvLUoV.js.map +1 -0
- package/dist/chunks/{generate.runtime-DNaQxed-.js → generate.runtime-CzS7PuPN.js} +84 -83
- package/dist/chunks/generate.runtime-CzS7PuPN.js.map +1 -0
- package/dist/chunks/{generate.runtime-B0hhtyAL.js → generate.runtime-D1NZPV6C.js} +27 -26
- package/dist/chunks/generate.runtime-D1NZPV6C.js.map +1 -0
- package/dist/chunks/generate.runtime-D3baqo6a.js +111 -0
- package/dist/chunks/generate.runtime-D3baqo6a.js.map +1 -0
- package/dist/chunks/{generate.runtime-DSqkXvps.js → generate.runtime-D47djbeG.js} +15 -14
- package/dist/chunks/{generate.runtime-DSqkXvps.js.map → generate.runtime-D47djbeG.js.map} +1 -1
- package/dist/chunks/generate.runtime-D72UBiwD.js +313 -0
- package/dist/chunks/generate.runtime-D72UBiwD.js.map +1 -0
- package/dist/chunks/{generate.runtime-CcuAXuV2.js → generate.runtime-DDPoXmqN.js} +15 -14
- package/dist/chunks/{generate.runtime-CcuAXuV2.js.map → generate.runtime-DDPoXmqN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-acRmiU7e.js → generate.runtime-DEnn0HKw.js} +9 -8
- package/dist/chunks/{generate.runtime-acRmiU7e.js.map → generate.runtime-DEnn0HKw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-wA1G3tQ4.js → generate.runtime-DHXkw2gf.js} +38 -37
- package/dist/chunks/generate.runtime-DHXkw2gf.js.map +1 -0
- package/dist/chunks/{generate.runtime-DOuufRLr.js → generate.runtime-DIuCrH6l.js} +82 -81
- package/dist/chunks/generate.runtime-DIuCrH6l.js.map +1 -0
- package/dist/chunks/generate.runtime-DOB4U-Sa.js +57 -0
- package/dist/chunks/generate.runtime-DOB4U-Sa.js.map +1 -0
- package/dist/chunks/generate.runtime-DPAy7Cav.js +328 -0
- package/dist/chunks/generate.runtime-DPAy7Cav.js.map +1 -0
- package/dist/chunks/{generate.runtime-BORbegw_.js → generate.runtime-D_ZqiYt-.js} +123 -122
- package/dist/chunks/generate.runtime-D_ZqiYt-.js.map +1 -0
- package/dist/chunks/{generate.runtime-B49wetSx.js → generate.runtime-Dm7g_WTN.js} +43 -42
- package/dist/chunks/generate.runtime-Dm7g_WTN.js.map +1 -0
- package/dist/chunks/{generate.runtime-DoZdSh9W.js → generate.runtime-HE9rzfXz.js} +58 -57
- package/dist/chunks/generate.runtime-HE9rzfXz.js.map +1 -0
- package/dist/chunks/{generate.runtime-flFRYzpi.js → generate.runtime-ejrt1o6M.js} +62 -61
- package/dist/chunks/generate.runtime-ejrt1o6M.js.map +1 -0
- package/dist/chunks/generate.runtime-l6I-St2R.js +94 -0
- package/dist/chunks/generate.runtime-l6I-St2R.js.map +1 -0
- package/dist/chunks/modify-file-DGe7MJu_.js +46 -0
- package/dist/chunks/modify-file-DGe7MJu_.js.map +1 -0
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js → modify-svelte-config-remote-BUU_EaDf.js} +2 -2
- package/dist/chunks/{modify-svelte-config-remote-CDKs_Qi0.js.map → modify-svelte-config-remote-BUU_EaDf.js.map} +1 -1
- package/dist/chunks/{providers-DO9kMyzB.js → providers-BL9vJP_9.js} +2 -2
- package/dist/chunks/{providers-DO9kMyzB.js.map → providers-BL9vJP_9.js.map} +1 -1
- package/dist/chunks/{shared-BwHQM-a9.js → shared-DkGfltvn.js} +2 -2
- package/dist/chunks/{shared-BwHQM-a9.js.map → shared-DkGfltvn.js.map} +1 -1
- package/dist/chunks/{test-setup-B2hd8I-s.js → test-setup-DHEFKEHE.js} +23 -10
- package/dist/chunks/test-setup-DHEFKEHE.js.map +1 -0
- package/dist/chunks/ts-morph-helpers-CeduA--o.js +253 -0
- package/dist/chunks/ts-morph-helpers-CeduA--o.js.map +1 -0
- package/dist/chunks/{ui-B4Tuit-7.js → ui-B3-B3sE2.js} +3 -3
- package/dist/chunks/{ui-B4Tuit-7.js.map → ui-B3-B3sE2.js.map} +1 -1
- package/dist/chunks/{ui-jhXrsw4T.js → ui-DD4NltyN.js} +2 -2
- package/dist/chunks/{ui-jhXrsw4T.js.map → ui-DD4NltyN.js.map} +1 -1
- package/dist/chunks/unmodify-load-jfdcVZ_a.js +81 -0
- package/dist/chunks/unmodify-load-jfdcVZ_a.js.map +1 -0
- package/dist/chunks/write-result-DRwceOV3.js +452 -0
- package/dist/chunks/write-result-DRwceOV3.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1918 -1901
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/_layout-DqH4lA_r.js +0 -47
- package/dist/chunks/_layout-DqH4lA_r.js.map +0 -1
- package/dist/chunks/config-target-Co-ij8p3.js +0 -163
- package/dist/chunks/config-target-Co-ij8p3.js.map +0 -1
- package/dist/chunks/errors-D6gyegUK.js +0 -14
- package/dist/chunks/errors-D6gyegUK.js.map +0 -1
- package/dist/chunks/generate-tOkjJFUf.js.map +0 -1
- package/dist/chunks/generate.runtime-B0hhtyAL.js.map +0 -1
- package/dist/chunks/generate.runtime-B49wetSx.js.map +0 -1
- package/dist/chunks/generate.runtime-B7LRx-BU.js +0 -86
- package/dist/chunks/generate.runtime-B7LRx-BU.js.map +0 -1
- package/dist/chunks/generate.runtime-BORbegw_.js.map +0 -1
- package/dist/chunks/generate.runtime-BbIN0tUZ.js.map +0 -1
- package/dist/chunks/generate.runtime-BnWE4qsu.js.map +0 -1
- package/dist/chunks/generate.runtime-BwhGDnGu.js.map +0 -1
- package/dist/chunks/generate.runtime-CCg2Pjcv.js +0 -257
- package/dist/chunks/generate.runtime-CCg2Pjcv.js.map +0 -1
- package/dist/chunks/generate.runtime-CRYjWJRe.js.map +0 -1
- package/dist/chunks/generate.runtime-D2e_KRj0.js +0 -56
- package/dist/chunks/generate.runtime-D2e_KRj0.js.map +0 -1
- package/dist/chunks/generate.runtime-D44gjxRA.js +0 -332
- package/dist/chunks/generate.runtime-D44gjxRA.js.map +0 -1
- package/dist/chunks/generate.runtime-D8vgh5MH.js.map +0 -1
- package/dist/chunks/generate.runtime-DNaQxed-.js.map +0 -1
- package/dist/chunks/generate.runtime-DOuufRLr.js.map +0 -1
- package/dist/chunks/generate.runtime-DhkaXTq3.js.map +0 -1
- package/dist/chunks/generate.runtime-DoZdSh9W.js.map +0 -1
- package/dist/chunks/generate.runtime-S5RIgbQx.js.map +0 -1
- package/dist/chunks/generate.runtime-WmSMWL15.js +0 -82
- package/dist/chunks/generate.runtime-WmSMWL15.js.map +0 -1
- package/dist/chunks/generate.runtime-flFRYzpi.js.map +0 -1
- package/dist/chunks/generate.runtime-gtpOuLNO.js +0 -110
- package/dist/chunks/generate.runtime-gtpOuLNO.js.map +0 -1
- package/dist/chunks/generate.runtime-kLxeDGnS.js +0 -93
- package/dist/chunks/generate.runtime-kLxeDGnS.js.map +0 -1
- package/dist/chunks/generate.runtime-wA1G3tQ4.js.map +0 -1
- package/dist/chunks/modify-file-GQD6uNgI.js +0 -254
- package/dist/chunks/modify-file-GQD6uNgI.js.map +0 -1
- package/dist/chunks/test-setup-B2hd8I-s.js.map +0 -1
- package/dist/chunks/unmodify-load-W1ePZQHr.js +0 -80
- package/dist/chunks/unmodify-load-W1ePZQHr.js.map +0 -1
- package/dist/chunks/write-result-DewHCNhM.js +0 -451
- package/dist/chunks/write-result-DewHCNhM.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-D3baqo6a.js","names":[],"sources":["../../src/patterns/disable/auth/modifies/+layout.server.ts","../../src/patterns/disable/auth/modifies/root-layout.svelte.ts","../../src/patterns/disable/auth/modifies/hooks.server.ts","../../src/patterns/disable/auth/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeUnusedBindingElement,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nexport function unmodifyLayoutServer(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(layoutPath, \"utf8\");\n if (!originalSource.includes(\"locals.pb.authStore.record\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project();\n const sourceFile = project.addSourceFileAtPath(layoutPath);\n\n const literals = sourceFile.getDescendantsOfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n for (const obj of literals) {\n const userProp = obj.getProperty(\"user\");\n if (!userProp || userProp.getKind() !== SyntaxKind.PropertyAssignment) {\n continue;\n }\n const value = (userProp as import(\"ts-morph\").PropertyAssignment)\n .getInitializer()\n ?.getText();\n if (value === \"locals.pb.authStore.record\") {\n userProp.remove();\n }\n }\n // `user` was often the layout's only use of `locals`, which enable-auth\n // destructured for it.\n removeUnusedBindingElement(sourceFile, \"locals\");\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 {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removePropsBindingIfUnused,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyRootLayoutSvelte(layoutPath: string): ModifyOutcome {\n if (!fs.existsSync(layoutPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(layoutPath, \"utf8\");\n const file = new SvelteFile(source);\n if (!file.hasElement(\"AuthMenu.Root\")) {\n return { status: \"success\", changed: false };\n }\n\n file.removeElement(\"AuthMenu.Root\");\n const markup = file.toString().replace(/<script[\\s\\S]*?<\\/script>/g, \"\");\n\n file.modifyScript((content) => {\n const { source: out } = withInMemoryScript(content, (sf) => {\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/auth-menu\");\n removeImportByModuleSpecifier(sf, \"$lib/components/ui/avatar\");\n // enable-auth added `data` for the menu's `data.user`.\n removePropsBindingIfUnused(sf, \"data\", markup);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","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 authProp = optionsObj.getProperty(\"auth\");\n if (!authProp) {\n return { status: \"success\", changed: false };\n }\n\n authProp.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 fs from \"node:fs\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { unmodifyLayoutServer } from \"./modifies/+layout.server\";\nimport { unmodifyRootLayoutSvelte } from \"./modifies/root-layout.svelte\";\nimport { unmodifyHooksServer } from \"./modifies/hooks.server\";\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 +layout.server.ts\");\n const layoutServerFile = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"+layout.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(\n layoutServerFile,\n unmodifyLayoutServer(layoutServerFile),\n ),\n );\n\n logger.info(\"Reverting root layout\");\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, unmodifyRootLayoutSvelte(layoutFile)),\n );\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerFile = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(hooksServerFile, unmodifyHooksServer(hooksServerFile)),\n );\n\n const collectionDrops = await planDropsForCollections(\n [\"oauth_accounts\"],\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":";;;;;;;;;AAQA,SAAgB,EAAqB,GAAmC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAiB,EAAG,aAAa,GAAY,MAAM;CACzD,IAAI,CAAC,EAAe,SAAS,4BAA4B,GACvD,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAI7C,IAAM,IAAa,IADC,EACD,CAAA,CAAQ,oBAAoB,CAAU,GAEnD,IAAW,EAAW,qBAC1B,EAAW,uBACb;CACA,KAAK,IAAM,KAAO,GAAU;EAC1B,IAAM,IAAW,EAAI,YAAY,MAAM;EACnC,AAAC,KAAY,EAAS,QAAQ,MAAM,EAAW,sBAGpC,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AAiB,EAAoB,CAAe,CAAC,CAC3E,GAOO;EACL,SAAS,CAAC;EACV;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAA,MAb4B,EAC5B,CAAC,gBAAgB,GACjB,CACF;CAWA;AACF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { n as e } from "./logger-CQONztPm.js";
|
|
2
|
-
import { t } from "./shared-
|
|
3
|
-
import {
|
|
2
|
+
import { t } from "./shared-DkGfltvn.js";
|
|
3
|
+
import { _ as n, n as r, u as i } from "./ts-morph-helpers-CeduA--o.js";
|
|
4
|
+
import { modifyOutcomeToFile as a } from "./modify-file-DGe7MJu_.js";
|
|
4
5
|
import { t as o } from "./svelte-file-B3RfgVdt.js";
|
|
5
|
-
import { t as s } from "./unmodify-load-
|
|
6
|
+
import { t as s } from "./unmodify-load-jfdcVZ_a.js";
|
|
6
7
|
import c from "node:fs";
|
|
7
8
|
import l from "node:path";
|
|
8
9
|
//#region src/patterns/disable/notifications/modifies/modify-app-layout.ts
|
|
@@ -16,14 +17,14 @@ function u(e) {
|
|
|
16
17
|
status: "success",
|
|
17
18
|
changed: !1
|
|
18
19
|
};
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
let { source: t } =
|
|
22
|
-
|
|
20
|
+
let a = o.fromPath(e);
|
|
21
|
+
a.modifyScript((e) => {
|
|
22
|
+
let { source: t } = n(e, (e) => {
|
|
23
|
+
i(e, "$lib/components/notifications-bell.svelte"), r(e);
|
|
23
24
|
});
|
|
24
25
|
return t;
|
|
25
26
|
});
|
|
26
|
-
let s =
|
|
27
|
+
let s = a.toString();
|
|
27
28
|
return s = s.replace(/\n*[ \t]*<div class="ml-auto px-4">\s*<NotificationsBell\s*\/>\s*<\/div>[ \t]*/g, ""), s = s.replace(/[ \t]*<NotificationsBell\s*\/>[ \t]*\r?\n?/g, ""), c.writeFileSync(e, s, "utf8"), {
|
|
28
29
|
status: "success",
|
|
29
30
|
changed: s !== t
|
|
@@ -41,16 +42,16 @@ function d(e) {
|
|
|
41
42
|
//#endregion
|
|
42
43
|
//#region src/patterns/disable/notifications/generate.runtime.ts
|
|
43
44
|
async function f(n) {
|
|
44
|
-
let r = e(n),
|
|
45
|
-
e &&
|
|
45
|
+
let r = e(n), i = [], o = (e) => {
|
|
46
|
+
e && i.push(e);
|
|
46
47
|
};
|
|
47
48
|
r.info("Reverting (app) +layout.svelte");
|
|
48
49
|
let s = l.join(n.root, "src", "routes", "(app)", "+layout.svelte");
|
|
49
|
-
o(
|
|
50
|
+
o(a(s, u(s))), r.info("Reverting (app) +layout.server.ts");
|
|
50
51
|
let c = l.join(n.root, "src", "routes", "(app)", "+layout.server.ts");
|
|
51
|
-
return o(
|
|
52
|
+
return o(a(c, d(c))), {
|
|
52
53
|
creates: [],
|
|
53
|
-
modifies:
|
|
54
|
+
modifies: i,
|
|
54
55
|
deletes: [],
|
|
55
56
|
components: [],
|
|
56
57
|
packages: [],
|
|
@@ -62,4 +63,4 @@ async function f(n) {
|
|
|
62
63
|
//#endregion
|
|
63
64
|
export { f as generate };
|
|
64
65
|
|
|
65
|
-
//# sourceMappingURL=generate.runtime-
|
|
66
|
+
//# sourceMappingURL=generate.runtime-D47djbeG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-D47djbeG.js","names":[],"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\";\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 \"$lib/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 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":";;;;;;;;;AAUA,SAAgB,EAAkB,GAAmC;CACnE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAY,MAAM;CACnD,IAAI,CAAC,EAAS,SAAS,mBAAmB,GACxC,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,EAAW,SAAS,CAAU;CAC3C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQ,MAAQ,EAAmB,IAAS,MAAO;GAKzD,AAJA,EACE,GACA,2CACF,GACA,EAA4B,CAAE;EAChC,CAAC;EACD,OAAO;CACT,CAAC;CAED,IAAI,IAAU,EAAK,SAAS;CAQ5B,OAPA,IAAU,EAAQ,QAChB,mFACA,EACF,GACA,IAAU,EAAQ,QAAQ,+CAA+C,EAAE,GAE3E,EAAG,cAAc,GAAY,GAAS,MAAM,GACrC;EAAE,QAAQ;EAAW,SAAS,MAAY;CAAS;AAC5D;;;ACrCA,SAAgB,EAAqB,GAAyC;CAC5E,OAAO,EAAe,GAAkB;EACtC,WAAW,CAAC,qBAAqB,eAAe;EAChD,aAAa,CAAC,mBAAmB;EACjC,aAAa,CAAC,eAAe;CAC/B,CAAC;AACH;;;ACFA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,gCAAgC;CAC5C,IAAM,IAAgB,EAAK,KACzB,EAAQ,MACR,OACA,UACA,SACA,gBACF;CAKA,AAJA,EACE,EAAoB,GAAe,EAAkB,CAAa,CAAC,CACrE,GAEA,EAAO,KAAK,mCAAmC;CAC/C,IAAM,IAAsB,EAAK,KAC/B,EAAQ,MACR,OACA,UACA,SACA,mBACF;CAgBA,OAfA,EACE,EACE,GACA,EAAqB,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,MAb4B,EAC5B,CAAC,eAAe,GAChB,CACF;CAWA;AACF"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
+
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
+
import { _ as n, c as r, d as i, h as a, m as o, n as s, o as c, s as l, u } from "./ts-morph-helpers-CeduA--o.js";
|
|
4
|
+
import { modifyOutcomeToFile as d, revertOutcomeToFile as f } from "./modify-file-DGe7MJu_.js";
|
|
5
|
+
import { t as p } from "./svelte-file-B3RfgVdt.js";
|
|
6
|
+
import { n as m } from "./compose-handle-B-CkDcQD.js";
|
|
7
|
+
import { a as h, i as g, t as _ } from "./config-target-Bln26FJe.js";
|
|
8
|
+
import { t as v } from "./_layout-B7ujvjnA.js";
|
|
9
|
+
import y from "node:fs";
|
|
10
|
+
import b from "node:path";
|
|
11
|
+
import { Project as x, QuoteKind as S, SyntaxKind as C } from "ts-morph";
|
|
12
|
+
//#region src/patterns/disable/i18n/modifies/gitignore.ts
|
|
13
|
+
function w(e) {
|
|
14
|
+
if (!y.existsSync(e)) return {
|
|
15
|
+
status: "success",
|
|
16
|
+
changed: !1
|
|
17
|
+
};
|
|
18
|
+
let t = y.readFileSync(e, "utf8");
|
|
19
|
+
if (!t.includes("src/locales/.wuchale")) return {
|
|
20
|
+
status: "success",
|
|
21
|
+
changed: !1
|
|
22
|
+
};
|
|
23
|
+
let n = t.split("\n"), r = [];
|
|
24
|
+
for (let e = 0; e < n.length; e++) {
|
|
25
|
+
let t = n[e];
|
|
26
|
+
if (t === "# Wuchale") {
|
|
27
|
+
let t = e + 1, r = !1;
|
|
28
|
+
for (; t < n.length && n[t].trim() !== "";) n[t] === "src/locales/.wuchale" && (r = !0), t++;
|
|
29
|
+
if (r) {
|
|
30
|
+
e = t;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
t !== "src/locales/.wuchale" && r.push(t);
|
|
35
|
+
}
|
|
36
|
+
let i = r.join("\n");
|
|
37
|
+
return i = i.replace(/\n{3,}/g, "\n\n"), i === t ? {
|
|
38
|
+
status: "success",
|
|
39
|
+
changed: !1
|
|
40
|
+
} : (y.writeFileSync(e, i), {
|
|
41
|
+
status: "success",
|
|
42
|
+
changed: !0
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/patterns/disable/i18n/modifies/vite-config.ts
|
|
47
|
+
function T(e) {
|
|
48
|
+
if (!y.existsSync(e)) return {
|
|
49
|
+
status: "success",
|
|
50
|
+
changed: !1
|
|
51
|
+
};
|
|
52
|
+
let t = y.readFileSync(e, "utf8");
|
|
53
|
+
if (!t.includes("wuchale")) return {
|
|
54
|
+
status: "success",
|
|
55
|
+
changed: !1
|
|
56
|
+
};
|
|
57
|
+
let n = new x({
|
|
58
|
+
compilerOptions: { allowJs: !0 },
|
|
59
|
+
manipulationSettings: { quoteKind: S.Single }
|
|
60
|
+
}).addSourceFileAtPath(e);
|
|
61
|
+
for (;;) {
|
|
62
|
+
let e = !1;
|
|
63
|
+
for (let t of n.getDescendantsOfKind(C.ArrayLiteralExpression)) {
|
|
64
|
+
let n = t.getElements().findIndex((e) => e.getText().replace(/\s/g, "") === "wuchale()");
|
|
65
|
+
if (n >= 0) {
|
|
66
|
+
t.removeElement(n), e = !0;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!e) break;
|
|
71
|
+
}
|
|
72
|
+
return u(n, "wuchale/vite"), c(n), n.saveSync(), {
|
|
73
|
+
status: "success",
|
|
74
|
+
changed: n.getFullText() !== t
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/patterns/disable/i18n/modifies/svelte-config.ts
|
|
79
|
+
var E = {
|
|
80
|
+
notFound: "No SvelteKit config to revert.",
|
|
81
|
+
failed: "Remove the $locales alias from the kit config by hand."
|
|
82
|
+
};
|
|
83
|
+
function D(e) {
|
|
84
|
+
let t = g(e, E, (e) => {
|
|
85
|
+
let t = e.kitContainer();
|
|
86
|
+
if (!t) return !0;
|
|
87
|
+
let n = t.getProperty("alias");
|
|
88
|
+
if (!n || n.getKind() !== C.PropertyAssignment) return !0;
|
|
89
|
+
let r = n.getInitializer();
|
|
90
|
+
if (!r || r.getKind() !== C.ObjectLiteralExpression) return !0;
|
|
91
|
+
let i = r.asKindOrThrow(C.ObjectLiteralExpression), a = i.getProperties().find((e) => e.getText().replace(/['"]/g, "").startsWith("$locales"));
|
|
92
|
+
return !a || (a.remove(), i.getProperties().length === 0 && n.remove(), !0);
|
|
93
|
+
});
|
|
94
|
+
return t.outcome.status === "not-found" ? {
|
|
95
|
+
...t,
|
|
96
|
+
outcome: {
|
|
97
|
+
status: "success",
|
|
98
|
+
changed: !1
|
|
99
|
+
}
|
|
100
|
+
} : t;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/patterns/disable/i18n/modifies/hooks.server.ts
|
|
104
|
+
var O = "handleWuchale", k = e`
|
|
105
|
+
Take handleWuchale out of the exported handle in src/hooks.server.ts, then
|
|
106
|
+
remove its declaration, the loadLocales(...) calls and the wuchale and
|
|
107
|
+
$locales imports.
|
|
108
|
+
`, A = [
|
|
109
|
+
"wuchale/load-utils/server",
|
|
110
|
+
"$locales/main.url",
|
|
111
|
+
"$locales/data",
|
|
112
|
+
"$locales/main.loader.server.svelte.js",
|
|
113
|
+
"$locales/js.loader.server.js"
|
|
114
|
+
];
|
|
115
|
+
function j(e) {
|
|
116
|
+
if (!y.existsSync(e)) return {
|
|
117
|
+
status: "success",
|
|
118
|
+
changed: !1
|
|
119
|
+
};
|
|
120
|
+
let t = y.readFileSync(e, "utf8");
|
|
121
|
+
if (!t.includes(O) && !t.includes("loadLocales(")) return {
|
|
122
|
+
status: "success",
|
|
123
|
+
changed: !1
|
|
124
|
+
};
|
|
125
|
+
let n = new x({
|
|
126
|
+
compilerOptions: { allowJs: !0 },
|
|
127
|
+
manipulationSettings: { quoteKind: S.Single }
|
|
128
|
+
}).addSourceFileAtPath(e);
|
|
129
|
+
for (;;) {
|
|
130
|
+
let e = n.getStatements().find((e) => e.getKind() === C.ExpressionStatement && /^loadLocales\s*\(/.test(e.getText()));
|
|
131
|
+
if (!e) break;
|
|
132
|
+
e.remove();
|
|
133
|
+
}
|
|
134
|
+
if (m(n, O).status === "unsupported") return {
|
|
135
|
+
status: "failed",
|
|
136
|
+
message: k
|
|
137
|
+
};
|
|
138
|
+
a(n, O);
|
|
139
|
+
for (let e of A) u(n, e);
|
|
140
|
+
return i(n, "@sveltejs/kit/hooks", "sequence"), i(n, "@sveltejs/kit", "Handle"), c(n), s(n), n.saveSync(), {
|
|
141
|
+
status: "success",
|
|
142
|
+
changed: n.getFullText() !== t
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/patterns/disable/i18n/modifies/hooks.ts
|
|
147
|
+
var M = "rerouteDeLocalize", N = e`
|
|
148
|
+
Take rerouteDeLocalize out of the exported reroute in src/hooks.ts, then
|
|
149
|
+
remove its declaration and the wuchale and $locales imports.
|
|
150
|
+
`, P = [
|
|
151
|
+
"wuchale/url",
|
|
152
|
+
"$locales/main.url",
|
|
153
|
+
"$locales/data"
|
|
154
|
+
], F = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*rerouteDeLocalize\(\s*url\.pathname\s*\)$/, I = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*rerouteDeLocalize\(\s*negotiateReroute\(\s*url\.pathname\s*\)\s*\)$/;
|
|
155
|
+
function L(e) {
|
|
156
|
+
if (!y.existsSync(e)) return {
|
|
157
|
+
status: "success",
|
|
158
|
+
changed: !1
|
|
159
|
+
};
|
|
160
|
+
let t = y.readFileSync(e, "utf8");
|
|
161
|
+
if (!t.includes(M)) return {
|
|
162
|
+
status: "success",
|
|
163
|
+
changed: !1
|
|
164
|
+
};
|
|
165
|
+
let n = new x({
|
|
166
|
+
compilerOptions: { allowJs: !0 },
|
|
167
|
+
manipulationSettings: { quoteKind: S.Single }
|
|
168
|
+
}).addSourceFileAtPath(e), i = n.getVariableDeclaration(M)?.getFirstAncestorByKind(C.VariableStatement), o = n.getVariableDeclaration("reroute"), u = o?.getInitializer()?.getText() ?? "", d = I.test(u), f = d || F.test(u) ? o?.getFirstAncestorByKind(C.VariableStatement) : void 0;
|
|
169
|
+
return n.getStatements().filter((e) => e !== i && e !== f && e.getText().includes(M)).length > 0 ? {
|
|
170
|
+
status: "failed",
|
|
171
|
+
message: N
|
|
172
|
+
} : (d ? o?.setInitializer("({ url }) => negotiateReroute(url.pathname)") : f && a(n, "reroute"), a(n, M), r(n, P), l(n) ? (y.writeFileSync(e, "", "utf8"), {
|
|
173
|
+
status: "success",
|
|
174
|
+
changed: !0
|
|
175
|
+
}) : (c(n), s(n), n.saveSync(), {
|
|
176
|
+
status: "success",
|
|
177
|
+
changed: n.getFullText() !== t
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/patterns/disable/i18n/modifies/app-html.ts
|
|
182
|
+
function R(e) {
|
|
183
|
+
if (!y.existsSync(e)) return {
|
|
184
|
+
status: "success",
|
|
185
|
+
changed: !1
|
|
186
|
+
};
|
|
187
|
+
let t = y.readFileSync(e, "utf8"), n = t.replace(/lang\s*=\s*(?:"%sveltekit\.lang%"|'%sveltekit\.lang%')/g, "lang=\"en\"");
|
|
188
|
+
return n === t ? {
|
|
189
|
+
status: "success",
|
|
190
|
+
changed: !1
|
|
191
|
+
} : (y.writeFileSync(e, n, "utf8"), {
|
|
192
|
+
status: "success",
|
|
193
|
+
changed: !0
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/patterns/disable/i18n/modifies/+layout.ts
|
|
198
|
+
var z = e`
|
|
199
|
+
src/routes/+layout.ts still loads wuchale locales. Remove these from it:
|
|
200
|
+
|
|
201
|
+
import { browser } from '$app/environment';
|
|
202
|
+
import { loadLocale } from 'wuchale/load-utils';
|
|
203
|
+
import { getLocale } from '$locales/main.url';
|
|
204
|
+
import '$locales/main.loader.svelte';
|
|
205
|
+
import '$locales/js.loader';
|
|
206
|
+
|
|
207
|
+
and the loadLocale(...) call inside load().
|
|
208
|
+
`, B = ["$locales/main.loader.svelte", "$locales/js.loader"], V = [
|
|
209
|
+
"$app/environment",
|
|
210
|
+
"wuchale/load-utils",
|
|
211
|
+
"$locales/main.url"
|
|
212
|
+
];
|
|
213
|
+
function H(e) {
|
|
214
|
+
return e.replace(/["']/g, "'").replace(/\s+/g, "");
|
|
215
|
+
}
|
|
216
|
+
function U(e) {
|
|
217
|
+
if (!y.existsSync(e)) return {
|
|
218
|
+
status: "success",
|
|
219
|
+
changed: !1
|
|
220
|
+
};
|
|
221
|
+
let t = y.readFileSync(e, "utf8");
|
|
222
|
+
if (!t.includes("loadLocale") && !t.includes("$locales")) return {
|
|
223
|
+
status: "success",
|
|
224
|
+
changed: !1
|
|
225
|
+
};
|
|
226
|
+
let n = new x({
|
|
227
|
+
compilerOptions: { allowJs: !0 },
|
|
228
|
+
manipulationSettings: { quoteKind: S.Single }
|
|
229
|
+
}).addSourceFileAtPath(e), i = n.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "load")) ?? n.getFunction("load");
|
|
230
|
+
if (i) {
|
|
231
|
+
if (H(i.getText()) !== H(v)) return {
|
|
232
|
+
status: "failed",
|
|
233
|
+
message: z
|
|
234
|
+
};
|
|
235
|
+
o(n, i);
|
|
236
|
+
}
|
|
237
|
+
for (let e of B) u(n, e);
|
|
238
|
+
return r(n, V), l(n) ? (y.writeFileSync(e, "", "utf8"), {
|
|
239
|
+
status: "success",
|
|
240
|
+
changed: !0
|
|
241
|
+
}) : (c(n), s(n), n.saveSync(), {
|
|
242
|
+
status: "success",
|
|
243
|
+
changed: n.getFullText() !== t
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/patterns/disable/i18n/modifies/root-layout.svelte.ts
|
|
248
|
+
function W(e) {
|
|
249
|
+
if (!y.existsSync(e)) return {
|
|
250
|
+
status: "success",
|
|
251
|
+
changed: !1
|
|
252
|
+
};
|
|
253
|
+
let t = y.readFileSync(e, "utf8");
|
|
254
|
+
if (!t.includes("LanguageSelect")) return {
|
|
255
|
+
status: "success",
|
|
256
|
+
changed: !1
|
|
257
|
+
};
|
|
258
|
+
let r = p.fromPath(e);
|
|
259
|
+
r.modifyScript((e) => {
|
|
260
|
+
let { source: t } = n(e, (e) => {
|
|
261
|
+
u(e, "$lib/components/language-select.svelte"), s(e);
|
|
262
|
+
});
|
|
263
|
+
return t;
|
|
264
|
+
});
|
|
265
|
+
let i = r.toString();
|
|
266
|
+
return i = i.replace(/[ \t]*<Navbar\.Item>\s*<LanguageSelect\s*\/>\s*<\/Navbar\.Item>[ \t]*\r?\n?/g, ""), i = i.replace(/[ \t]*<LanguageSelect\s*\/>[ \t]*\r?\n?/g, ""), y.writeFileSync(e, i, "utf8"), {
|
|
267
|
+
status: "success",
|
|
268
|
+
changed: i !== t
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/patterns/disable/i18n/generate.runtime.ts
|
|
273
|
+
async function G(e) {
|
|
274
|
+
let n = t(e), r = [], i = [], a = (e) => {
|
|
275
|
+
e && r.push(e);
|
|
276
|
+
};
|
|
277
|
+
n.info("Reverting vite.config");
|
|
278
|
+
let o = h(e.root, _) ?? b.join(e.root, _[0]);
|
|
279
|
+
a(d(o, T(o))), n.info("Reverting the $locales alias");
|
|
280
|
+
let s = D(e.root);
|
|
281
|
+
a(d(s.filePath, s.outcome)), n.info("Reverting hooks.server.ts");
|
|
282
|
+
let c = b.join(e.root, "src", "hooks.server.ts"), l = f(c, j(c));
|
|
283
|
+
a(l.modify), l.delete && i.push(l.delete), n.info("Reverting hooks.ts");
|
|
284
|
+
let u = b.join(e.root, "src", "hooks.ts"), p = f(u, L(u));
|
|
285
|
+
a(p.modify), p.delete && i.push(p.delete), n.info("Reverting app.html");
|
|
286
|
+
let m = b.join(e.root, "src", "app.html");
|
|
287
|
+
a(d(m, R(m))), n.info("Reverting root +layout.ts");
|
|
288
|
+
let g = b.join(e.root, "src", "routes", "+layout.ts"), v = f(g, U(g));
|
|
289
|
+
a(v.modify), v.delete && i.push(v.delete), n.info("Reverting root layout language select");
|
|
290
|
+
let x = [
|
|
291
|
+
b.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
292
|
+
b.join(e.root, "src", "routes", "root-layout.svelte"),
|
|
293
|
+
b.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
294
|
+
b.join(e.root, "src", "routes", "+layout.svelte")
|
|
295
|
+
];
|
|
296
|
+
for (let e of x) y.existsSync(e) && a(d(e, W(e)));
|
|
297
|
+
n.info("Reverting .gitignore");
|
|
298
|
+
let S = b.join(e.root, ".gitignore");
|
|
299
|
+
return a(d(S, w(S))), {
|
|
300
|
+
creates: [],
|
|
301
|
+
modifies: r,
|
|
302
|
+
deletes: i,
|
|
303
|
+
components: [],
|
|
304
|
+
packages: [],
|
|
305
|
+
collections: [],
|
|
306
|
+
collectionPatches: [],
|
|
307
|
+
collectionDrops: []
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
export { G as generate };
|
|
312
|
+
|
|
313
|
+
//# sourceMappingURL=generate.runtime-D72UBiwD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.runtime-D72UBiwD.js","names":[],"sources":["../../src/patterns/disable/i18n/modifies/gitignore.ts","../../src/patterns/disable/i18n/modifies/vite-config.ts","../../src/patterns/disable/i18n/modifies/svelte-config.ts","../../src/patterns/disable/i18n/modifies/hooks.server.ts","../../src/patterns/disable/i18n/modifies/hooks.ts","../../src/patterns/disable/i18n/modifies/app-html.ts","../../src/patterns/disable/i18n/modifies/+layout.ts","../../src/patterns/disable/i18n/modifies/root-layout.svelte.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 fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n removeImportByModuleSpecifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\n/** Remove `wuchale()` from the Vite plugins and its import. */\nexport function unmodifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(viteConfigPath, \"utf8\");\n if (!original.includes(\"wuchale\")) {\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(viteConfigPath);\n\n // One removal at a time: manipulating the tree invalidates sibling nodes.\n for (;;) {\n let removed = false;\n for (const arr of sourceFile.getDescendantsOfKind(\n SyntaxKind.ArrayLiteralExpression,\n )) {\n const index = arr\n .getElements()\n .findIndex((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n if (index >= 0) {\n arr.removeElement(index);\n removed = true;\n break;\n }\n }\n if (!removed) break;\n }\n\n removeImportByModuleSpecifier(sourceFile, \"wuchale/vite\");\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== original,\n };\n}\n","import { SyntaxKind, type PropertyAssignment } from \"ts-morph\";\nimport {\n modifyConfig,\n type ConfigModifyResult,\n} from \"../../../../runtime/config-target\";\n\nconst HINTS = {\n notFound: \"No SvelteKit config to revert.\",\n failed: \"Remove the $locales alias from the kit config by hand.\",\n};\n\n/** Remove the `$locales` alias; drop `alias` too once it is empty. */\nexport function unmodifySvelteConfig(root: string): ConfigModifyResult {\n const result = modifyConfig(root, HINTS, (target) => {\n const kit = target.kitContainer();\n if (!kit) return true;\n\n const aliasProp = kit.getProperty(\"alias\");\n if (!aliasProp || aliasProp.getKind() !== SyntaxKind.PropertyAssignment) {\n return true;\n }\n const aliasObj = (aliasProp as PropertyAssignment).getInitializer();\n if (\n !aliasObj ||\n aliasObj.getKind() !== SyntaxKind.ObjectLiteralExpression\n ) {\n return true;\n }\n const obj = aliasObj.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);\n const locales = obj\n .getProperties()\n .find((p) => p.getText().replace(/['\"]/g, \"\").startsWith(\"$locales\"));\n if (!locales) return true;\n\n locales.remove();\n if (obj.getProperties().length === 0) {\n aliasProp.remove();\n }\n return true;\n });\n\n // Nothing to revert in a project without a config.\n if (result.outcome.status === \"not-found\") {\n return { ...result, outcome: { status: \"success\", changed: false } };\n }\n return result;\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { removeHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n removeNamedImportIfUnused,\n removeTopLevelStatementByIdentifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\nconst FAILURE_HINT = dedent`\n Take handleWuchale out of the exported handle in src/hooks.server.ts, then\n remove its declaration, the loadLocales(...) calls and the wuchale and\n $locales imports.\n`;\n\nconst I18N_MODULES = [\n \"wuchale/load-utils/server\",\n \"$locales/main.url\",\n \"$locales/data\",\n \"$locales/main.loader.server.svelte.js\",\n \"$locales/js.loader.server.js\",\n];\n\n/**\n * Undo `modifyHooksServerI18n`: drop the locale bootstrap, the wuchale handle\n * and its imports, and unwrap `sequence(handleWuchale, ...)`. A file that\n * enable-i18n created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksServerI18n(\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 (!original.includes(I18N_HANDLE) && !original.includes(\"loadLocales(\")) {\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 // loadLocales(...) bootstrap calls, one at a time (removal invalidates siblings).\n for (;;) {\n const stmt = sourceFile\n .getStatements()\n .find(\n (s) =>\n s.getKind() === SyntaxKind.ExpressionStatement &&\n /^loadLocales\\s*\\(/.test(s.getText()),\n );\n if (!stmt) break;\n stmt.remove();\n }\n\n // `export const handle = handleWuchale` goes altogether; a sequence loses\n // the argument, or unwraps to the handle it composed with.\n const removed = removeHandle(sourceFile, I18N_HANDLE);\n if (removed.status === \"unsupported\") {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, I18N_HANDLE);\n for (const moduleSpecifier of I18N_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit/hooks\", \"sequence\");\n removeNamedImportIfUnused(sourceFile, \"@sveltejs/kit\", \"Handle\");\n\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 { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureBlankLineAfterImports,\n isEffectivelyEmpty,\n pruneUnusedImports,\n removeTopLevelStatementByIdentifier,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst DELOCALIZE_HELPER = \"rerouteDeLocalize\";\n\nconst FAILURE_HINT = dedent`\n Take rerouteDeLocalize out of the exported reroute in src/hooks.ts, then\n remove its declaration and the wuchale and $locales imports.\n`;\n\nconst I18N_MODULES = [\"wuchale/url\", \"$locales/main.url\", \"$locales/data\"];\n\n/** The two reroutes `modifyHooksI18n` writes: on its own, and composed. */\nconst I18N_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*rerouteDeLocalize\\(\\s*url\\.pathname\\s*\\)$/;\nconst COMPOSED_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*rerouteDeLocalize\\(\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)\\s*\\)$/;\n\n/**\n * Undo `modifyHooksI18n`: drop the de-localizer and its imports, leaving the\n * negotiation reroute it may have been composed with. A file that enable-i18n\n * created comes out empty, for the caller to delete.\n */\nexport function unmodifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (!original.includes(DELOCALIZE_HELPER)) {\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(hooksPath);\n\n const helperStatement = sourceFile\n .getVariableDeclaration(DELOCALIZE_HELPER)\n ?.getFirstAncestorByKind(SyntaxKind.VariableStatement);\n\n const rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n const initText = rerouteDecl?.getInitializer()?.getText() ?? \"\";\n const composed = COMPOSED_REROUTE.test(initText);\n const rerouteStatement =\n composed || I18N_ONLY_REROUTE.test(initText)\n ? rerouteDecl?.getFirstAncestorByKind(SyntaxKind.VariableStatement)\n : undefined;\n\n // Anything else reading the de-localizer is code enable-i18n did not write,\n // so undoing it is the developer's call.\n const otherReaders = sourceFile\n .getStatements()\n .filter(\n (s) =>\n s !== helperStatement &&\n s !== rerouteStatement &&\n s.getText().includes(DELOCALIZE_HELPER),\n );\n if (otherReaders.length > 0) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n if (composed) {\n // content-negotiation's reroute is underneath; it stays.\n rerouteDecl?.setInitializer(\"({ url }) => negotiateReroute(url.pathname)\");\n } else if (rerouteStatement) {\n removeTopLevelStatementByIdentifier(sourceFile, \"reroute\");\n }\n\n removeTopLevelStatementByIdentifier(sourceFile, DELOCALIZE_HELPER);\n pruneUnusedImports(sourceFile, I18N_MODULES);\n\n if (isEffectivelyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty hooks.ts into a\n // delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(hooksPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\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 type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * Put a real language back. `%sveltekit.lang%` is not a SvelteKit\n * placeholder; only the wuchale hook replaced it, so without that hook it\n * would be served literally.\n */\nexport function unmodifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n const updated = original.replace(\n /lang\\s*=\\s*(?:\"%sveltekit\\.lang%\"|'%sveltekit\\.lang%')/g,\n 'lang=\"en\"',\n );\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(appHtmlPath, updated, \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, type Statement } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { LOAD_STATEMENT } from \"../../../enable/i18n/modifies/+layout\";\nimport {\n ensureBlankLineAfterImports,\n isEffectivelyEmpty,\n pruneUnusedImports,\n removeImportByModuleSpecifier,\n removeStatementWithComments,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = dedent`\n src/routes/+layout.ts still loads wuchale locales. Remove these from it:\n\n import { browser } from '$app/environment';\n import { loadLocale } from 'wuchale/load-utils';\n import { getLocale } from '$locales/main.url';\n import '$locales/main.loader.svelte';\n import '$locales/js.loader';\n\n and the loadLocale(...) call inside load().\n`;\n\nconst SIDE_EFFECT_MODULES = [\n \"$locales/main.loader.svelte\",\n \"$locales/js.loader\",\n];\nconst BINDING_MODULES = [\n \"$app/environment\",\n \"wuchale/load-utils\",\n \"$locales/main.url\",\n];\n\nfunction normalize(source: string): string {\n return source.replace(/[\"']/g, \"'\").replace(/\\s+/g, \"\");\n}\n\n/**\n * Undo `ensureRootLayoutI18n`: drop the wuchale load and its imports, leaving\n * whatever else the file holds. A file enable-i18n wrote whole comes out\n * empty, for the caller to delete.\n */\nexport function unmodifyRootLayoutI18n(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(\"loadLocale\") && !original.includes(\"$locales\")) {\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(layoutPath);\n\n const loadStatement: Statement | undefined =\n sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"load\")) ??\n sourceFile.getFunction(\"load\");\n\n if (loadStatement) {\n // A load that grew code of its own needs a hand; only the one enable-i18n\n // wrote is safe to take out wholesale.\n if (normalize(loadStatement.getText()) !== normalize(LOAD_STATEMENT)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n removeStatementWithComments(sourceFile, loadStatement);\n }\n\n for (const moduleSpecifier of SIDE_EFFECT_MODULES) {\n removeImportByModuleSpecifier(sourceFile, moduleSpecifier);\n }\n pruneUnusedImports(sourceFile, BINDING_MODULES);\n\n if (isEffectivelyEmpty(sourceFile)) {\n // Emptied rather than removed: the runtime turns an empty +layout.ts into\n // a delete entry, so the removal is written and reported like any other.\n fs.writeFileSync(layoutPath, \"\", \"utf8\");\n return { status: \"success\", changed: true };\n }\n\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 { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureBlankLineAfterImports,\n removeImportByModuleSpecifier,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/** Take the language select (and the nav item enable-i18n wrapped it in) back out. */\nexport function unmodifyRootLayoutLanguageSelect(\n layoutPath: string,\n): 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(\"LanguageSelect\")) {\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 \"$lib/components/language-select.svelte\",\n );\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n let updated = file.toString();\n updated = updated.replace(\n /[ \\t]*<Navbar\\.Item>\\s*<LanguageSelect\\s*\\/>\\s*<\\/Navbar\\.Item>[ \\t]*\\r?\\n?/g,\n \"\",\n );\n updated = updated.replace(/[ \\t]*<LanguageSelect\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n fs.writeFileSync(layoutPath, updated, \"utf8\");\n return { status: \"success\", changed: updated !== original };\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 {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { unmodifyGitignore } from \"./modifies/gitignore\";\nimport { unmodifyViteConfig } from \"./modifies/vite-config\";\nimport { unmodifySvelteConfig } from \"./modifies/svelte-config\";\nimport { unmodifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { unmodifyHooksI18n } from \"./modifies/hooks\";\nimport { unmodifyAppHtml } from \"./modifies/app-html\";\nimport { unmodifyRootLayoutI18n } from \"./modifies/+layout\";\nimport { unmodifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting vite.config\");\n const viteConfigPath =\n probeFirstExisting(options.root, VITE_CONFIG_CANDIDATES) ??\n path.join(options.root, VITE_CONFIG_CANDIDATES[0]);\n pushResult(\n modifyOutcomeToFile(viteConfigPath, unmodifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Reverting the $locales alias\");\n const alias = unmodifySvelteConfig(options.root);\n pushResult(modifyOutcomeToFile(alias.filePath, alias.outcome));\n\n logger.info(\"Reverting hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n // enable-i18n may have created it; emptied, it goes.\n const hooksServerRevert = revertOutcomeToFile(\n hooksServerPath,\n unmodifyHooksServerI18n(hooksServerPath),\n );\n pushResult(hooksServerRevert.modify);\n if (hooksServerRevert.delete) deletes.push(hooksServerRevert.delete);\n\n logger.info(\"Reverting hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n // The de-localizing reroute may be all it holds; emptied, it goes.\n const hooksRevert = revertOutcomeToFile(\n hooksPath,\n unmodifyHooksI18n(hooksPath),\n );\n pushResult(hooksRevert.modify);\n if (hooksRevert.delete) deletes.push(hooksRevert.delete);\n\n logger.info(\"Reverting app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, unmodifyAppHtml(appHtmlPath)));\n\n logger.info(\"Reverting root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n // enable-i18n may have written the whole file; emptied, it goes.\n const layoutRevert = revertOutcomeToFile(\n layoutPath,\n unmodifyRootLayoutI18n(layoutPath),\n );\n pushResult(layoutRevert.modify);\n if (layoutRevert.delete) deletes.push(layoutRevert.delete);\n\n logger.info(\"Reverting root layout language select\");\n const rootLayoutCandidates = [\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 for (const candidate of rootLayoutCandidates) {\n if (!fs.existsSync(candidate)) continue;\n pushResult(\n modifyOutcomeToFile(\n candidate,\n unmodifyRootLayoutLanguageSelect(candidate),\n ),\n );\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 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;CACtE,IAAI,CAAC,EAAG,WAAW,CAAa,GAC9B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAe,MAAM;CACtD,IAAI,CAAC,EAAS,SAAS,sBAAsB,GAC3C,OAAO;EAAE,QAAQ;E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-BPfk1VAw.js";
|
|
4
|
-
import {
|
|
4
|
+
import { _ as r, n as i, u as a } from "./ts-morph-helpers-CeduA--o.js";
|
|
5
|
+
import { envRevertOutcomeToFile as o, modifyOutcomeToFile as s } from "./modify-file-DGe7MJu_.js";
|
|
5
6
|
import { t as c } from "./svelte-file-B3RfgVdt.js";
|
|
6
7
|
import l from "node:fs";
|
|
7
8
|
import u from "node:path";
|
|
@@ -19,16 +20,16 @@ function f(e) {
|
|
|
19
20
|
};
|
|
20
21
|
let n = c.fromPath(e);
|
|
21
22
|
n.modifyScript((e) => {
|
|
22
|
-
let { source: t } =
|
|
23
|
-
|
|
23
|
+
let { source: t } = r(e, (e) => {
|
|
24
|
+
a(e, d), i(e);
|
|
24
25
|
});
|
|
25
26
|
return t;
|
|
26
27
|
});
|
|
27
|
-
let
|
|
28
|
-
return
|
|
28
|
+
let o = n.toString().replace(/[ \t]*<Analytics\s*\/>[ \t]*\r?\n?/g, "");
|
|
29
|
+
return o === t ? {
|
|
29
30
|
status: "success",
|
|
30
31
|
changed: !1
|
|
31
|
-
} : (l.writeFileSync(e,
|
|
32
|
+
} : (l.writeFileSync(e, o, "utf8"), {
|
|
32
33
|
status: "success",
|
|
33
34
|
changed: !0
|
|
34
35
|
});
|
|
@@ -36,16 +37,16 @@ function f(e) {
|
|
|
36
37
|
//#endregion
|
|
37
38
|
//#region src/patterns/disable/analytics/generate.runtime.ts
|
|
38
39
|
async function p(r) {
|
|
39
|
-
let
|
|
40
|
-
e &&
|
|
40
|
+
let i = e(r), a = [], c = [], l = (e) => {
|
|
41
|
+
e && a.push(e);
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
+
i.info("Reverting src/routes/+layout.svelte");
|
|
43
44
|
let d = u.join(r.root, "src", "routes", "+layout.svelte");
|
|
44
|
-
l(
|
|
45
|
-
let p = u.join(r.root, ".env"), m =
|
|
45
|
+
l(s(d, f(d))), i.info("Removing analytics variables from .env");
|
|
46
|
+
let p = u.join(r.root, ".env"), m = o(p, n(p, t()));
|
|
46
47
|
return l(m.modify), m.delete && c.push(m.delete), {
|
|
47
48
|
creates: [],
|
|
48
|
-
modifies:
|
|
49
|
+
modifies: a,
|
|
49
50
|
deletes: c,
|
|
50
51
|
components: [],
|
|
51
52
|
packages: [],
|
|
@@ -57,4 +58,4 @@ async function p(r) {
|
|
|
57
58
|
//#endregion
|
|
58
59
|
export { p as generate };
|
|
59
60
|
|
|
60
|
-
//# sourceMappingURL=generate.runtime-
|
|
61
|
+
//# sourceMappingURL=generate.runtime-DDPoXmqN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-DDPoXmqN.js","names":[],"sources":["../../src/patterns/disable/analytics/modifies/layout.svelte.ts","../../src/patterns/disable/analytics/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\";\n\nconst MODULE_SPECIFIER = \"$lib/components/analytics/analytics.svelte\";\n\n/**\n * Takes `<Analytics />` and its import back out of the root layout. The\n * element goes with its whole line, since enable-analytics put it on one of\n * its own. A layout without it, or no layout at all, is left alone.\n */\nexport function unmodifyLayoutSvelte(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 (\n !original.includes(MODULE_SPECIFIER) &&\n !original.includes(\"<Analytics\")\n ) {\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(sf, MODULE_SPECIFIER);\n ensureBlankLineAfterImports(sf);\n });\n return out;\n });\n\n const updated = file\n .toString()\n .replace(/[ \\t]*<Analytics\\s*\\/>[ \\t]*\\r?\\n?/g, \"\");\n\n if (updated === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(layoutPath, updated, \"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 { modifyEnvRemove } from \"../../../runtime/env\";\nimport {\n envRevertOutcomeToFile,\n modifyOutcomeToFile,\n} from \"../../../runtime/modify-file\";\nimport { allEnvEdits } from \"./generate\";\nimport { unmodifyLayoutSvelte } from \"./modifies/layout.svelte\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Reverting src/routes/+layout.svelte\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.svelte\");\n pushResult(modifyOutcomeToFile(layoutPath, unmodifyLayoutSvelte(layoutPath)));\n\n logger.info(\"Removing analytics variables from .env\");\n const envPath = path.join(options.root, \".env\");\n const env = envRevertOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, allEnvEdits()),\n );\n pushResult(env.modify);\n if (env.delete) deletes.push(env.delete);\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":";;;;;;;;;AASA,IAAM,IAAmB;AAOzB,SAAgB,EAAqB,GAAmC;CACtE,IAAI,CAAC,EAAG,WAAW,CAAU,GAC3B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAW,EAAG,aAAa,GAAY,MAAM;CACnD,IACE,CAAC,EAAS,SAAS,CAAgB,KACnC,CAAC,EAAS,SAAS,YAAY,GAE/B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAM,IAAO,EAAW,SAAS,CAAU;CAC3C,EAAK,cAAc,MAAW;EAC5B,IAAM,EAAE,QAAQ,MAAQ,EAAmB,IAAS,MAAO;GAEzD,AADA,EAA8B,GAAI,CAAgB,GAClD,EAA4B,CAAE;EAChC,CAAC;EACD,OAAO;CACT,CAAC;CAED,IAAM,IAAU,EACb,SAAS,CAAC,CACV,QAAQ,uCAAuC,EAAE;CAMpD,OAJI,MAAY,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAE7C,EAAG,cAAc,GAAY,GAAS,MAAM,GACrC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;ACpCA,eAAsB,EAAS,GAAkB;CAC/C,IAAM,IAAS,EAAU,CAAO,GAC1B,IAAmB,CAAC,GACpB,IAAkB,CAAC,GACnB,KAAc,MAAsB;EACxC,AAAI,KAAM,EAAS,KAAK,CAAI;CAC9B;CAEA,EAAO,KAAK,qCAAqC;CACjD,IAAM,IAAa,EAAK,KAAK,EAAQ,MAAM,OAAO,UAAU,gBAAgB;CAG5E,AAFA,EAAW,EAAoB,GAAY,EAAqB,CAAU,CAAC,CAAC,GAE5E,EAAO,KAAK,wCAAwC;CACpD,IAAM,IAAU,EAAK,KAAK,EAAQ,MAAM,MAAM,GACxC,IAAM,EACV,GACA,EAAgB,GAAS,EAAY,CAAC,CACxC;CAIA,OAHA,EAAW,EAAI,MAAM,GACjB,EAAI,UAAQ,EAAQ,KAAK,EAAI,MAAM,GAEhC;EACL,SAAS,CAAC;EACV;EACA;EACA,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { a as e, o as t } from "./providers-
|
|
1
|
+
import { a as e, o as t } from "./providers-BL9vJP_9.js";
|
|
2
2
|
import { t as n } from "./dedent-Gq6Krl4n.js";
|
|
3
3
|
import { n as r } from "./logger-CQONztPm.js";
|
|
4
|
-
import { r as i, t as a } from "./generate-
|
|
4
|
+
import { r as i, t as a } from "./generate-6snrlnpA.js";
|
|
5
5
|
import { t as o } from "./env-BPfk1VAw.js";
|
|
6
|
-
import {
|
|
6
|
+
import { _ as s, r as c } from "./ts-morph-helpers-CeduA--o.js";
|
|
7
|
+
import { modifyOutcomeToFile as l } from "./modify-file-DGe7MJu_.js";
|
|
7
8
|
import { t as u } from "./svelte-file-B3RfgVdt.js";
|
|
8
9
|
import d from "node:fs";
|
|
9
10
|
import f from "node:path";
|
|
@@ -40,7 +41,7 @@ function v(e) {
|
|
|
40
41
|
changed: !1
|
|
41
42
|
} : t.getScript() ? (t.modifyScript((e) => {
|
|
42
43
|
let { source: t } = s(e, (e) => {
|
|
43
|
-
|
|
44
|
+
c(e, [{
|
|
44
45
|
defaultImport: "Analytics",
|
|
45
46
|
moduleSpecifier: p
|
|
46
47
|
}]);
|
|
@@ -57,14 +58,14 @@ function v(e) {
|
|
|
57
58
|
//#endregion
|
|
58
59
|
//#region src/patterns/enable/analytics/generate.runtime.ts
|
|
59
60
|
async function y(n) {
|
|
60
|
-
let s = r(n),
|
|
61
|
+
let s = r(n), c = e(a, n), u = [], d = (e) => {
|
|
61
62
|
e && u.push(e);
|
|
62
63
|
};
|
|
63
64
|
s.info("Modifying src/routes/+layout.svelte");
|
|
64
65
|
let p = f.join(n.root, "src", "routes", "+layout.svelte");
|
|
65
|
-
d(
|
|
66
|
+
d(l(p, v(p))), s.info("Updating .env");
|
|
66
67
|
let m = f.join(n.root, ".env");
|
|
67
|
-
return d(
|
|
68
|
+
return d(l(m, o(m, i(c, t(n))))), {
|
|
68
69
|
creates: [],
|
|
69
70
|
modifies: u,
|
|
70
71
|
deletes: [],
|
|
@@ -78,4 +79,4 @@ async function y(n) {
|
|
|
78
79
|
//#endregion
|
|
79
80
|
export { y as generate };
|
|
80
81
|
|
|
81
|
-
//# sourceMappingURL=generate.runtime-
|
|
82
|
+
//# sourceMappingURL=generate.runtime-DEnn0HKw.js.map
|