@velastack/patterns 0.6.0 → 0.7.1
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 +15 -3
- package/dist/chunks/{_layout-D-FzWqn0.js → _layout-DQhSAhfF.js} +3 -3
- package/dist/chunks/{_layout-D-FzWqn0.js.map → _layout-DQhSAhfF.js.map} +1 -1
- package/dist/chunks/{auth-pages-B52ei-4z.js → auth-pages-jsyDV1GR.js} +7 -10
- package/dist/chunks/{auth-pages-B52ei-4z.js.map → auth-pages-jsyDV1GR.js.map} +1 -1
- package/dist/chunks/{collections-B_DisSfA.js → collections-BYcVyY9O.js} +39 -35
- package/dist/chunks/collections-BYcVyY9O.js.map +1 -0
- package/dist/chunks/collections-BrEA7a62.js +309 -0
- package/dist/chunks/collections-BrEA7a62.js.map +1 -0
- package/dist/chunks/{compose-handle-BDlZ7Pif.js → compose-handle-BBlamPfx.js} +18 -22
- package/dist/chunks/{compose-handle-BDlZ7Pif.js.map → compose-handle-BBlamPfx.js.map} +1 -1
- package/dist/chunks/{config-target-rHgjaA8u.js → config-target-BgyFkbFL.js} +2 -2
- package/dist/chunks/{config-target-rHgjaA8u.js.map → config-target-BgyFkbFL.js.map} +1 -1
- package/dist/chunks/constants-Bdx8mp7v.js +6 -0
- package/dist/chunks/constants-Bdx8mp7v.js.map +1 -0
- package/dist/chunks/dedent-Gq6Krl4n.js.map +1 -1
- package/dist/chunks/{env-BPfk1VAw.js → env-BugddEjd.js} +5 -9
- package/dist/chunks/{env-BPfk1VAw.js.map → env-BugddEjd.js.map} +1 -1
- package/dist/chunks/{env-vars-cqQU0ECK.js → env-vars-0hvKe55u.js} +6 -11
- package/dist/chunks/{env-vars-cqQU0ECK.js.map → env-vars-0hvKe55u.js.map} +1 -1
- package/dist/chunks/generate-BOQA-Flq.js +171 -0
- package/dist/chunks/generate-BOQA-Flq.js.map +1 -0
- package/dist/chunks/{generate-CXoQPz7n.js → generate-CNabcEBx.js} +2 -2
- package/dist/chunks/{generate-CXoQPz7n.js.map → generate-CNabcEBx.js.map} +1 -1
- package/dist/chunks/{generate-jx5Iuq5w.js → generate-CO88bEvs.js} +54 -53
- package/dist/chunks/generate-CO88bEvs.js.map +1 -0
- package/dist/chunks/{generate-Bm_jOMtF.js → generate-Df7t5Nbk.js} +3 -3
- package/dist/chunks/{generate-Bm_jOMtF.js.map → generate-Df7t5Nbk.js.map} +1 -1
- package/dist/chunks/{generate-Cqwa8kD9.js → generate-DoHn_xJZ.js} +2 -2
- package/dist/chunks/{generate-Cqwa8kD9.js.map → generate-DoHn_xJZ.js.map} +1 -1
- package/dist/chunks/generate-DyV5R8NP.js.map +1 -1
- package/dist/chunks/{generate-D3mSFPdT.js → generate-l2JZTRKb.js} +2 -2
- package/dist/chunks/{generate-D3mSFPdT.js.map → generate-l2JZTRKb.js.map} +1 -1
- package/dist/chunks/{generate.runtime-FGYc365Q.js → generate.runtime-1ldXcpiD.js} +6 -6
- package/dist/chunks/{generate.runtime-FGYc365Q.js.map → generate.runtime-1ldXcpiD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B2r11K7S.js → generate.runtime-B53OTMcE.js} +6 -6
- package/dist/chunks/{generate.runtime-B2r11K7S.js.map → generate.runtime-B53OTMcE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DCqf7nYM.js → generate.runtime-B84ymwlD.js} +7 -7
- package/dist/chunks/{generate.runtime-DCqf7nYM.js.map → generate.runtime-B84ymwlD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dug2UIhV.js → generate.runtime-BOl3LpPB.js} +10 -13
- package/dist/chunks/{generate.runtime-Dug2UIhV.js.map → generate.runtime-BOl3LpPB.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BxDUtkpT.js → generate.runtime-BP31tAcD.js} +5 -5
- package/dist/chunks/{generate.runtime-BxDUtkpT.js.map → generate.runtime-BP31tAcD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DdcVnK8J.js → generate.runtime-BoYwV0nt.js} +133 -121
- package/dist/chunks/generate.runtime-BoYwV0nt.js.map +1 -0
- package/dist/chunks/{generate.runtime-wGRE1zwZ.js → generate.runtime-BqCbJ-No.js} +4 -4
- package/dist/chunks/{generate.runtime-wGRE1zwZ.js.map → generate.runtime-BqCbJ-No.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BVavIXtX.js → generate.runtime-Bvjj3zn0.js} +6 -6
- package/dist/chunks/{generate.runtime-BVavIXtX.js.map → generate.runtime-Bvjj3zn0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-_c7daMAw.js → generate.runtime-ByPcr9vJ.js} +4 -4
- package/dist/chunks/{generate.runtime-_c7daMAw.js.map → generate.runtime-ByPcr9vJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dmob2wFf.js → generate.runtime-C4LUUuq7.js} +5 -5
- package/dist/chunks/{generate.runtime-Dmob2wFf.js.map → generate.runtime-C4LUUuq7.js.map} +1 -1
- package/dist/chunks/{generate.runtime-wziCW3ct.js → generate.runtime-CGjDfO1P.js} +5 -5
- package/dist/chunks/{generate.runtime-wziCW3ct.js.map → generate.runtime-CGjDfO1P.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DYdkrHJ1.js → generate.runtime-CHQ_MQJQ.js} +6 -6
- package/dist/chunks/{generate.runtime-DYdkrHJ1.js.map → generate.runtime-CHQ_MQJQ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-aN5QWygO.js → generate.runtime-CHS5lyHL.js} +39 -36
- package/dist/chunks/generate.runtime-CHS5lyHL.js.map +1 -0
- package/dist/chunks/{generate.runtime-CyGR8VTx.js → generate.runtime-CHUCMVa2.js} +3 -3
- package/dist/chunks/{generate.runtime-CyGR8VTx.js.map → generate.runtime-CHUCMVa2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BxUGDXIK.js → generate.runtime-CVWCUn52.js} +6 -6
- package/dist/chunks/{generate.runtime-BxUGDXIK.js.map → generate.runtime-CVWCUn52.js.map} +1 -1
- package/dist/chunks/generate.runtime-C_5Ghjri.js +17 -0
- package/dist/chunks/generate.runtime-C_5Ghjri.js.map +1 -0
- package/dist/chunks/{generate.runtime-CRhD98rs.js → generate.runtime-Cv3unKap.js} +5 -5
- package/dist/chunks/{generate.runtime-CRhD98rs.js.map → generate.runtime-Cv3unKap.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CkmledBw.js → generate.runtime-D677SB4v.js} +12 -20
- package/dist/chunks/{generate.runtime-CkmledBw.js.map → generate.runtime-D677SB4v.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DeniHg8L.js → generate.runtime-DERcpgc-.js} +5 -5
- package/dist/chunks/{generate.runtime-DeniHg8L.js.map → generate.runtime-DERcpgc-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-x-o4LS8d.js → generate.runtime-DJ5uF6EN.js} +4 -4
- package/dist/chunks/{generate.runtime-x-o4LS8d.js.map → generate.runtime-DJ5uF6EN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CYBs0JgY.js → generate.runtime-Dfz53sSK.js} +5 -5
- package/dist/chunks/{generate.runtime-CYBs0JgY.js.map → generate.runtime-Dfz53sSK.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CWnIiXwV.js → generate.runtime-DiqfbDfk.js} +3 -3
- package/dist/chunks/{generate.runtime-CWnIiXwV.js.map → generate.runtime-DiqfbDfk.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CHb4znYx.js → generate.runtime-Dq6yS7tN.js} +6 -6
- package/dist/chunks/{generate.runtime-CHb4znYx.js.map → generate.runtime-Dq6yS7tN.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BRCzUO94.js → generate.runtime-T7JLE4Wc.js} +10 -14
- package/dist/chunks/{generate.runtime-BRCzUO94.js.map → generate.runtime-T7JLE4Wc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Du4uf98c.js → generate.runtime-WPq7bHRA.js} +3 -3
- package/dist/chunks/{generate.runtime-Du4uf98c.js.map → generate.runtime-WPq7bHRA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-kpqW3dVO.js → generate.runtime-WeDv05E2.js} +8 -8
- package/dist/chunks/{generate.runtime-kpqW3dVO.js.map → generate.runtime-WeDv05E2.js.map} +1 -1
- package/dist/chunks/{generate.runtime-N1KtAG8C.js → generate.runtime-aKNvrk3M.js} +90 -175
- package/dist/chunks/generate.runtime-aKNvrk3M.js.map +1 -0
- package/dist/chunks/{generate.runtime-Bh9Z2cRN.js → generate.runtime-e_BkDyP0.js} +3 -3
- package/dist/chunks/{generate.runtime-Bh9Z2cRN.js.map → generate.runtime-e_BkDyP0.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DY5vQ3aZ.js → generate.runtime-gZ4wfYBP.js} +8 -8
- package/dist/chunks/{generate.runtime-DY5vQ3aZ.js.map → generate.runtime-gZ4wfYBP.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DUo-pLRr.js → generate.runtime-oUJUQRdg.js} +7 -7
- package/dist/chunks/{generate.runtime-DUo-pLRr.js.map → generate.runtime-oUJUQRdg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-gFr2Gsjz.js → generate.runtime-q17D7QUT.js} +5 -5
- package/dist/chunks/{generate.runtime-gFr2Gsjz.js.map → generate.runtime-q17D7QUT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B4u9C2YH.js → generate.runtime-rLlDp4R6.js} +5 -5
- package/dist/chunks/{generate.runtime-B4u9C2YH.js.map → generate.runtime-rLlDp4R6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-bpH3DB0t.js → generate.runtime-zr6uIHCd.js} +3 -3
- package/dist/chunks/{generate.runtime-bpH3DB0t.js.map → generate.runtime-zr6uIHCd.js.map} +1 -1
- package/dist/chunks/{modify-file-289rStJ2.js → modify-file-B4uJzOEj.js} +4 -4
- package/dist/chunks/{modify-file-289rStJ2.js.map → modify-file-B4uJzOEj.js.map} +1 -1
- package/dist/chunks/{modify-nav-user-B8h8WTrM.js → modify-nav-user-CJ1LevSU.js} +2 -2
- package/dist/chunks/{modify-nav-user-B8h8WTrM.js.map → modify-nav-user-CJ1LevSU.js.map} +1 -1
- package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js → modify-svelte-config-remote-CEyYydL7.js} +2 -2
- package/dist/chunks/{modify-svelte-config-remote-DhuRX4FI.js.map → modify-svelte-config-remote-CEyYydL7.js.map} +1 -1
- package/dist/chunks/{modify-user-signup-BbqTiUuA.js → modify-user-signup-DLtopazD.js} +2 -2
- package/dist/chunks/{modify-user-signup-BbqTiUuA.js.map → modify-user-signup-DLtopazD.js.map} +1 -1
- package/dist/chunks/{package-imports-Bbw3iMPg.js → package-imports-B9Asv3ZH.js} +3 -3
- package/dist/chunks/{package-imports-Bbw3iMPg.js.map → package-imports-B9Asv3ZH.js.map} +1 -1
- package/dist/chunks/{pocketbase-B017Cqjq.js → pocketbase-BtN-wL8f.js} +9 -17
- package/dist/chunks/{pocketbase-B017Cqjq.js.map → pocketbase-BtN-wL8f.js.map} +1 -1
- package/dist/chunks/{providers-CN5J5_fY.js → providers-DRwJnSzb.js} +2 -2
- package/dist/chunks/{providers-CN5J5_fY.js.map → providers-DRwJnSzb.js.map} +1 -1
- package/dist/chunks/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-5HNE8Q1r.js} +1 -1
- package/dist/chunks/{shared-BPlAVf-T.js → shared-BbxLil4g.js} +2 -2
- package/dist/chunks/{shared-BPlAVf-T.js.map → shared-BbxLil4g.js.map} +1 -1
- package/dist/chunks/{site-DkU1-VRq.js → site-Dw2KIRJu.js} +2 -2
- package/dist/chunks/{site-DkU1-VRq.js.map → site-Dw2KIRJu.js.map} +1 -1
- package/dist/chunks/{table-core-vXEjJDYP.js → table-core-BHFT-uMX.js} +3 -3
- package/dist/chunks/{table-core-vXEjJDYP.js.map → table-core-BHFT-uMX.js.map} +1 -1
- package/dist/chunks/{taggedTemplateLiteral-CswN2AAa.js → taggedTemplateLiteral-KSUnuvOk.js} +1 -1
- package/dist/chunks/{test-setup-CAfgVlwc.js → test-setup-BVJwm22s.js} +5 -5
- package/dist/chunks/{test-setup-CAfgVlwc.js.map → test-setup-BVJwm22s.js.map} +1 -1
- package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js → ts-morph-helpers-CHI9wAil.js} +7 -11
- package/dist/chunks/{ts-morph-helpers-Bepc-Es2.js.map → ts-morph-helpers-CHI9wAil.js.map} +1 -1
- package/dist/chunks/{ui-CTdsenEv.js → ui-gG8i_Mzk.js} +3 -3
- package/dist/chunks/{ui-CTdsenEv.js.map → ui-gG8i_Mzk.js.map} +1 -1
- package/dist/chunks/{unmodify-load-Bl5vXQiL.js → unmodify-load-Buak-r1f.js} +2 -2
- package/dist/chunks/{unmodify-load-Bl5vXQiL.js.map → unmodify-load-Buak-r1f.js.map} +1 -1
- package/dist/chunks/{whatsapp-5qJ_xCV1.js → whatsapp-DbjOxHaZ.js} +2 -2
- package/dist/chunks/{whatsapp-5qJ_xCV1.js.map → whatsapp-DbjOxHaZ.js.map} +1 -1
- package/dist/chunks/write-result-DcqMefuP.js +499 -0
- package/dist/chunks/write-result-DcqMefuP.js.map +1 -0
- package/dist/chunks/wuchale-config-c3Q4JVSF.js +50 -0
- package/dist/chunks/wuchale-config-c3Q4JVSF.js.map +1 -0
- package/dist/index.d.ts +173 -19
- package/dist/index.js +2330 -2505
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/collections-B_DisSfA.js.map +0 -1
- package/dist/chunks/constants-iej3WkEa.js +0 -6
- package/dist/chunks/constants-iej3WkEa.js.map +0 -1
- package/dist/chunks/generate-8FS2ROOJ.js +0 -170
- package/dist/chunks/generate-8FS2ROOJ.js.map +0 -1
- package/dist/chunks/generate-jx5Iuq5w.js.map +0 -1
- package/dist/chunks/generate.runtime-DdcVnK8J.js.map +0 -1
- package/dist/chunks/generate.runtime-N1KtAG8C.js.map +0 -1
- package/dist/chunks/generate.runtime-aN5QWygO.js.map +0 -1
- package/dist/chunks/shopify-page-D-VFwGxI.js +0 -11
- package/dist/chunks/shopify-page-D-VFwGxI.js.map +0 -1
- package/dist/chunks/write-result-0HYIr5a6.js +0 -511
- package/dist/chunks/write-result-0HYIr5a6.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-
|
|
1
|
+
{"version":3,"file":"generate.runtime-BP31tAcD.js","names":["getLogger","withPocketbase","getMigrationFile","modifyOutcomeToFile","hasWhatsAppPlugin","writeWhatsAppConfigMigration","enableWhatsAppAuth","MIN_POCKETBASE_SERVER","fs","path","modifyTestSetup","setupPath","original","content","indent","head","tail","bodyIndent","value","fieldIndent","DOCS_URL","migrationCreate","file","generate","logger","options","creates","pb","setupWhatsAppFields","migrationDelay","configMigration","modifies","outcomes","swapAuthPages","filePath","outcome","testSetup","testSetupFile"],"sources":["../../src/patterns/enable/whatsapp/modifies/modify-test-setup.ts","../../src/patterns/enable/whatsapp/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\n/**\n * `email` turns optional on `users`, which the generated types follow, so a\n * test setup from before enable-backend handled that no longer type-checks:\n * its `authenticateUser` takes `{ email: string }` and it signs the test\n * user in with `context.user.email`. Brings those two spots up to the\n * current setup; anything else in the file is the project's own.\n */\nexport function modifyTestSetup(setupPath: string): ModifyOutcome {\n if (!fs.existsSync(setupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const original = fs.readFileSync(setupPath, \"utf8\");\n let content = original;\n\n content = content.replace(\n /^([ \\t]*)(async function authenticateUser\\(agent: Agent, user: \\{ )email: string( \\}\\) \\{\\n)([ \\t]*)/m,\n (_, indent, head, tail, bodyIndent) =>\n `${indent}${head}email?: string${tail}` +\n `${bodyIndent}// Logs in with the password, so it needs the email (made optional by\\n` +\n `${bodyIndent}// enable-whatsapp, for accounts that sign in with a phone number).\\n` +\n `${bodyIndent}if (!user.email) {\\n` +\n `${bodyIndent}${bodyIndent.includes(\"\\t\") ? \"\\t\" : \" \"}throw new Error('authenticateUser needs a user with an email');\\n` +\n `${bodyIndent}}\\n` +\n bodyIndent,\n );\n\n // The user is made with a known email: sign in with that.\n content = content.replace(\n /^([ \\t]*)context\\.user = await context\\.admin\\.collection\\('users'\\)\\.create\\(\\{\\n([ \\t]*)email: (`test-\\$\\{Math\\.random\\(\\)\\.toString\\(36\\)\\.slice\\(2\\)\\}@example\\.com`),/m,\n (_, indent, fieldIndent, value) =>\n `${indent}const email = ${value};\\n` +\n `${indent}context.user = await context.admin.collection('users').create({\\n` +\n `${fieldIndent}email,`,\n );\n if (content.includes(\"const email = `test-\")) {\n content = content.replace(\n \".authWithPassword(context.user.email, testUserPassword)\",\n \".authWithPassword(email, testUserPassword)\",\n );\n }\n\n if (content === original) {\n return { status: \"success\", changed: false };\n }\n fs.writeFileSync(setupPath, content, \"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 getMigrationFile,\n migrationDelay,\n withPocketbase,\n} from \"../../../runtime/pocketbase\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n MIN_POCKETBASE_SERVER,\n enableWhatsAppAuth,\n hasWhatsAppPlugin,\n setupWhatsAppFields,\n writeWhatsAppConfigMigration,\n} from \"./runtime/whatsapp\";\nimport { swapAuthPages } from \"./modifies/auth-pages\";\nimport { modifyTestSetup } from \"./modifies/modify-test-setup\";\n\nexport const DOCS_URL = \"https://velastack.dev/docs/enable/whatsapp\";\n\nfunction migrationCreate(file: string): File {\n return {\n path: file,\n language: \"js\",\n content: fs.readFileSync(file, \"utf8\"),\n status: \"success\",\n };\n}\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const creates: File[] = [];\n\n await withPocketbase(options.root, async (pb) => {\n if (!(await hasWhatsAppPlugin(pb))) {\n throw new Error(\n `This PocketBase has no WhatsApp sign-in. It comes with pocketbase-server ${MIN_POCKETBASE_SERVER} and later: run \\`npm install -D pocketbase-server@^${MIN_POCKETBASE_SERVER}\\`, then \\`vela enable whatsapp\\` again.`,\n );\n }\n\n logger.info(\"Adding the phone fields to users and making email optional\");\n if (await setupWhatsAppFields(pb)) {\n await migrationDelay();\n const file = getMigrationFile(\"users\", \"updated\", options);\n if (file) creates.push(migrationCreate(file));\n }\n\n logger.info(\"Turning on WhatsApp sign-in for users\");\n await enableWhatsAppAuth(pb);\n await migrationDelay();\n const configMigration = writeWhatsAppConfigMigration(options, true);\n if (configMigration) creates.push(migrationCreate(configMigration));\n });\n\n logger.info(\"Adding WhatsApp to the login and signup pages\");\n const modifies: File[] = [];\n const outcomes = await swapAuthPages(\n options.root,\n \"enable\",\n (filePath) =>\n `${path.relative(options.root, filePath)} is not the page enable-auth wrote, so it was left as it is. Add the WhatsApp option to it by hand: ${DOCS_URL}`,\n );\n for (const [filePath, outcome] of outcomes) {\n const file = modifyOutcomeToFile(filePath, outcome);\n if (file) modifies.push(file);\n }\n\n logger.info(\"Updating test/setup.ts for an optional email\");\n const testSetup = path.join(options.root, \"test\", \"setup.ts\");\n const testSetupFile = modifyOutcomeToFile(\n testSetup,\n modifyTestSetup(testSetup),\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":";;;;;;;;AAUA,SAAgBU,EAAgB,GAAkC;CAChE,IAAI,CAACF,EAAG,WAAWG,CAAS,GAC1B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAWJ,EAAG,aAAaG,GAAW,MAAM,GAC9CE,IAAUD;CAiCd,OA/BA,IAAUC,EAAQ,QAChB,0GACC,GAAG,GAAQ,GAAM,GAAM,MACtB,GAAGC,IAASC,EAAK,gBAAgBC,IAC9BC,EAAW,yEACXA,EAAW,uEACXA,EAAW,sBACXA,IAAaA,EAAW,SAAS,GAAI,IAAI,MAAO,KAAK,mEACrDA,EAAW,OACdA,CACJ,GAGA,IAAUJ,EAAQ,QAChB,gLACC,GAAG,GAAQ,GAAa,MACvB,GAAGC,EAAO,gBAAgBI,EAAM,KAC7BJ,EAAO,mEACPK,EAAY,OACnB,GACIN,EAAQ,SAAS,sBAAsB,MACzC,IAAUA,EAAQ,QAChB,2DACA,4CACF,IAGEA,MAAYD,IACP;EAAE,QAAQ;EAAW,SAAS;CAAM,KAE7CJ,EAAG,cAAcG,GAAWE,GAAS,MAAM,GACpC;EAAE,QAAQ;EAAW,SAAS;CAAK;AAC5C;;;AC9BA,IAAaO,IAAW;AAExB,SAASC,EAAgB,GAAoB;CAC3C,OAAO;EACL,MAAMC;EACN,UAAU;EACV,SAASd,EAAG,aAAac,GAAM,MAAM;EACrC,QAAQ;CACV;AACF;AAEA,eAAsBC,EAAS,GAAkB;CAC/C,IAAMC,IAASxB,EAAUyB,CAAO,GAC1BC,IAAkB,CAAC;CAuBzB,AArBA,MAAMzB,EAAewB,EAAQ,MAAM,OAAO,MAAO;EAC/C,IAAI,CAAE,MAAMrB,EAAkBuB,CAAE,GAC9B,MAAU,MACR,4EAA4EpB,EAAsB,sDAAsDA,EAAsB,yCAChL;EAIF,IADAiB,EAAO,KAAK,4DAA4D,GACpE,MAAMI,EAAoBD,CAAE,GAAG;GACjC,MAAME,EAAe;GACrB,IAAMP,IAAOpB,EAAiB,SAAS,WAAWuB,CAAO;GACzD,AAAIH,KAAMI,EAAQ,KAAKL,EAAgBC,CAAI,CAAC;EAC9C;EAIA,AAFAE,EAAO,KAAK,uCAAuC,GACnD,MAAMlB,EAAmBqB,CAAE,GAC3B,MAAME,EAAe;EACrB,IAAMC,IAAkBzB,EAA6BoB,GAAS,EAAI;EAClE,AAAIK,KAAiBJ,EAAQ,KAAKL,EAAgBS,CAAe,CAAC;CACpE,CAAC,GAEDN,EAAO,KAAK,+CAA+C;CAC3D,IAAMO,IAAmB,CAAC,GACpBC,IAAW,MAAMC,EACrBR,EAAQ,MACR,WACC,MACC,GAAGhB,EAAK,SAASgB,EAAQ,MAAMS,CAAQ,EAAE,sGAAsGd,GACnJ;CACA,KAAK,IAAM,CAACc,GAAUC,MAAYH,GAAU;EAC1C,IAAMV,IAAOnB,EAAoB+B,GAAUC,CAAO;EAClD,AAAIb,KAAMS,EAAS,KAAKT,CAAI;CAC9B;CAEA,EAAO,KAAK,8CAA8C;CAC1D,IAAMc,IAAY3B,EAAK,KAAKgB,EAAQ,MAAM,QAAQ,UAAU,GACtDY,IAAgBlC,EACpBiC,GACA1B,EAAgB0B,CAAS,CAC3B;CAGA,OAFIC,KAAeN,EAAS,KAAKM,CAAa,GAEvC;EACL;EACA;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
2
|
import { t } from "./ui-DD4NltyN.js";
|
|
3
3
|
import { n } from "./logger-CQONztPm.js";
|
|
4
|
-
import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-
|
|
5
|
-
import { r as s } from "./modify-file-
|
|
4
|
+
import { _ as r, i, o as a, r as o } from "./ts-morph-helpers-CHI9wAil.js";
|
|
5
|
+
import { r as s } from "./modify-file-B4uJzOEj.js";
|
|
6
6
|
import { t as c } from "./svelte-file-Dv5-bl79.js";
|
|
7
|
-
import { t as l } from "./compose-handle-
|
|
8
|
-
import { a as u, t as d } from "./config-target-
|
|
9
|
-
import { i as f, n as p } from "./_layout-
|
|
10
|
-
import m from "
|
|
11
|
-
import
|
|
12
|
-
import
|
|
7
|
+
import { t as l } from "./compose-handle-BBlamPfx.js";
|
|
8
|
+
import { a as u, t as d } from "./config-target-BgyFkbFL.js";
|
|
9
|
+
import { i as f, n as p } from "./_layout-DQhSAhfF.js";
|
|
10
|
+
import { r as m, t as h } from "./wuchale-config-c3Q4JVSF.js";
|
|
11
|
+
import g from "node:fs";
|
|
12
|
+
import _ from "node:path";
|
|
13
|
+
import { Project as v, QuoteKind as y, SyntaxKind as b } from "ts-morph";
|
|
13
14
|
//#region src/patterns/enable/i18n/modifies/vite-config.ts
|
|
14
|
-
var
|
|
15
|
+
var x = [
|
|
15
16
|
"Add the wuchale plugin to your Vite config:",
|
|
16
17
|
"",
|
|
17
18
|
"import { wuchale } from 'wuchale/vite';",
|
|
@@ -19,7 +20,7 @@ var y = [
|
|
|
19
20
|
"export default defineConfig({",
|
|
20
21
|
" plugins: [wuchale(), /* ...existing plugins */],",
|
|
21
22
|
"});"
|
|
22
|
-
].join("\n"),
|
|
23
|
+
].join("\n"), S = [
|
|
23
24
|
"Create a Vite config with the wuchale plugin:",
|
|
24
25
|
"",
|
|
25
26
|
"import { defineConfig } from 'vite';",
|
|
@@ -29,20 +30,20 @@ var y = [
|
|
|
29
30
|
" plugins: [wuchale()],",
|
|
30
31
|
"});"
|
|
31
32
|
].join("\n");
|
|
32
|
-
function
|
|
33
|
-
if (!
|
|
33
|
+
function C(e) {
|
|
34
|
+
if (!g.existsSync(e)) return {
|
|
34
35
|
status: "not-found",
|
|
35
|
-
message:
|
|
36
|
+
message: S
|
|
36
37
|
};
|
|
37
|
-
let t = new
|
|
38
|
+
let t = new v({
|
|
38
39
|
compilerOptions: { allowJs: !0 },
|
|
39
|
-
manipulationSettings: { quoteKind:
|
|
40
|
+
manipulationSettings: { quoteKind: y.Single }
|
|
40
41
|
}).addSourceFileAtPath(e), n = !1, r = !1;
|
|
41
42
|
t.getImportDeclarations().some((e) => e.getModuleSpecifierValue() === "wuchale/vite") || (t.insertImportDeclaration(0, {
|
|
42
43
|
namedImports: ["wuchale"],
|
|
43
44
|
moduleSpecifier: "wuchale/vite"
|
|
44
45
|
}), n = !0);
|
|
45
|
-
let i = t.getDescendantsOfKind(
|
|
46
|
+
let i = t.getDescendantsOfKind(b.CallExpression).find((e) => e.getExpression().getText() === "defineConfig")?.getArguments()?.[0], o = i?.getKind() === b.ObjectLiteralExpression ? i : null;
|
|
46
47
|
if (!o) r = !0;
|
|
47
48
|
else {
|
|
48
49
|
let e = o.getProperty("plugins");
|
|
@@ -50,11 +51,11 @@ function x(e) {
|
|
|
50
51
|
name: "plugins",
|
|
51
52
|
initializer: "[wuchale()]"
|
|
52
53
|
}), n = !0;
|
|
53
|
-
else if (e.getKind() !==
|
|
54
|
+
else if (e.getKind() !== b.PropertyAssignment) r = !0;
|
|
54
55
|
else {
|
|
55
56
|
let t = e.getInitializer();
|
|
56
57
|
if (!t) e.setInitializer("[wuchale()]"), n = !0;
|
|
57
|
-
else if (t.getKind() !==
|
|
58
|
+
else if (t.getKind() !== b.ArrayLiteralExpression) r = !0;
|
|
58
59
|
else {
|
|
59
60
|
let e = t;
|
|
60
61
|
e.getElements().some((e) => e.getText().replace(/\s/g, "") === "wuchale()") || (e.insertElement(0, "wuchale()"), n = !0);
|
|
@@ -63,7 +64,7 @@ function x(e) {
|
|
|
63
64
|
}
|
|
64
65
|
return n && (a(t), t.saveSync()), r ? {
|
|
65
66
|
status: "failed",
|
|
66
|
-
message:
|
|
67
|
+
message: x
|
|
67
68
|
} : {
|
|
68
69
|
status: "success",
|
|
69
70
|
changed: n
|
|
@@ -71,7 +72,7 @@ function x(e) {
|
|
|
71
72
|
}
|
|
72
73
|
//#endregion
|
|
73
74
|
//#region src/patterns/enable/i18n/modifies/hooks.server.ts
|
|
74
|
-
var
|
|
75
|
+
var w = "handleWuchale", T = e`
|
|
75
76
|
Wrap your exported handle with the wuchale i18n handler:
|
|
76
77
|
|
|
77
78
|
import { sequence } from '@sveltejs/kit/hooks';
|
|
@@ -95,7 +96,7 @@ var S = "handleWuchale", C = e`
|
|
|
95
96
|
};
|
|
96
97
|
|
|
97
98
|
export const handle = sequence(handleWuchale, /* your existing handle */);
|
|
98
|
-
`,
|
|
99
|
+
`, E = e`
|
|
99
100
|
import type { Handle } from '@sveltejs/kit/hooks';
|
|
100
101
|
import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';
|
|
101
102
|
import { getLocale } from '#locales/main.url.js';
|
|
@@ -117,40 +118,40 @@ var S = "handleWuchale", C = e`
|
|
|
117
118
|
|
|
118
119
|
export const handle = handleWuchale;
|
|
119
120
|
`;
|
|
120
|
-
function
|
|
121
|
+
function D(e, t, n) {
|
|
121
122
|
e.getImportDeclarations().find((e) => e.getModuleSpecifierValue() === t) || e.addImportDeclaration({
|
|
122
123
|
namespaceImport: n,
|
|
123
124
|
moduleSpecifier: t
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
-
if (!
|
|
127
|
+
function O(t) {
|
|
128
|
+
if (!g.existsSync(t)) return g.existsSync(t.replace(/\.ts$/, ".js")) ? {
|
|
128
129
|
status: "failed",
|
|
129
|
-
message:
|
|
130
|
-
} : (
|
|
130
|
+
message: T
|
|
131
|
+
} : (g.mkdirSync(_.dirname(t), { recursive: !0 }), g.writeFileSync(t, E + "\n"), {
|
|
131
132
|
status: "success",
|
|
132
133
|
changed: !0
|
|
133
134
|
});
|
|
134
|
-
let n =
|
|
135
|
+
let n = g.readFileSync(t, "utf8");
|
|
135
136
|
if (n.includes("runWithLocale") || n.includes("loadLocales(")) return {
|
|
136
137
|
status: "success",
|
|
137
138
|
changed: !1
|
|
138
139
|
};
|
|
139
|
-
let r = new
|
|
140
|
+
let r = new v({
|
|
140
141
|
compilerOptions: { allowJs: !0 },
|
|
141
|
-
manipulationSettings: { quoteKind:
|
|
142
|
-
}).addSourceFileAtPath(t), o = l(r, { expression:
|
|
142
|
+
manipulationSettings: { quoteKind: y.Single }
|
|
143
|
+
}).addSourceFileAtPath(t), o = l(r, { expression: w });
|
|
143
144
|
if (o.status === "unsupported" || !o.statement) return {
|
|
144
145
|
status: "failed",
|
|
145
|
-
message:
|
|
146
|
+
message: T
|
|
146
147
|
};
|
|
147
148
|
let s = o.statement;
|
|
148
|
-
i(r, "wuchale/load-utils/server", "runWithLocale"), i(r, "wuchale/load-utils/server", "loadLocales"), i(r, "#locales/main.url.js", "getLocale"), i(r, "#locales/data.js", "locales"),
|
|
149
|
+
i(r, "wuchale/load-utils/server", "runWithLocale"), i(r, "wuchale/load-utils/server", "loadLocales"), i(r, "#locales/main.url.js", "getLocale"), i(r, "#locales/data.js", "locales"), D(r, "#locales/main.loader.server.svelte.js", "main"), D(r, "#locales/js.loader.server.js", "js");
|
|
149
150
|
let c = e`
|
|
150
151
|
loadLocales(main.key, main.loadCount, main.loadCatalog, locales);
|
|
151
152
|
loadLocales(js.key, js.loadCount, js.loadCatalog, locales);
|
|
152
153
|
`, u = e`
|
|
153
|
-
const ${
|
|
154
|
+
const ${w} = async ({ event, resolve }: any) => {
|
|
154
155
|
const locale = getLocale(event.url);
|
|
155
156
|
return await runWithLocale(locale, () =>
|
|
156
157
|
resolve(event, {
|
|
@@ -167,13 +168,13 @@ function E(t) {
|
|
|
167
168
|
}
|
|
168
169
|
//#endregion
|
|
169
170
|
//#region src/patterns/enable/i18n/modifies/hooks.ts
|
|
170
|
-
var
|
|
171
|
+
var k = e`
|
|
171
172
|
const rerouteDeLocalize = (url: string) => {
|
|
172
173
|
const [upath, locale] = deLocalizeDefault(url, locales);
|
|
173
174
|
const { path } = matchUrl(upath, locale);
|
|
174
175
|
return path ?? url;
|
|
175
176
|
};
|
|
176
|
-
`,
|
|
177
|
+
`, A = e`
|
|
177
178
|
import { deLocalizeDefault } from 'wuchale/url';
|
|
178
179
|
import { matchUrl } from '#locales/main.url.js';
|
|
179
180
|
import { locales } from '#locales/data.js';
|
|
@@ -185,7 +186,7 @@ var D = e`
|
|
|
185
186
|
};
|
|
186
187
|
|
|
187
188
|
export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);
|
|
188
|
-
`,
|
|
189
|
+
`, j = e`
|
|
189
190
|
Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:
|
|
190
191
|
|
|
191
192
|
import { deLocalizeDefault } from 'wuchale/url';
|
|
@@ -199,56 +200,56 @@ var D = e`
|
|
|
199
200
|
};
|
|
200
201
|
|
|
201
202
|
export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));
|
|
202
|
-
`,
|
|
203
|
-
function
|
|
203
|
+
`, M = /^\(\s*\{\s*url\s*\}\s*\)\s*=>\s*negotiateReroute\(\s*url\.pathname\s*\)$/;
|
|
204
|
+
function N(e) {
|
|
204
205
|
return e.getFunction("reroute") ? !0 : e.getExportDeclarations().some((e) => e.getNamedExports().some((e) => (e.getAliasNode()?.getText() ?? e.getName()) === "reroute"));
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
+
function P(e) {
|
|
207
208
|
i(e, "wuchale/url", "deLocalizeDefault"), i(e, "#locales/main.url.js", "matchUrl"), i(e, "#locales/data.js", "locales");
|
|
208
209
|
}
|
|
209
|
-
function
|
|
210
|
-
if (!
|
|
210
|
+
function ee(e) {
|
|
211
|
+
if (!g.existsSync(e)) return g.mkdirSync(_.dirname(e), { recursive: !0 }), g.writeFileSync(e, A + "\n"), {
|
|
211
212
|
status: "success",
|
|
212
213
|
changed: !0
|
|
213
214
|
};
|
|
214
|
-
if (
|
|
215
|
+
if (g.readFileSync(e, "utf8").includes("rerouteDeLocalize")) return {
|
|
215
216
|
status: "success",
|
|
216
217
|
changed: !1
|
|
217
218
|
};
|
|
218
|
-
let t = new
|
|
219
|
+
let t = new v({
|
|
219
220
|
compilerOptions: { allowJs: !0 },
|
|
220
|
-
manipulationSettings: { quoteKind:
|
|
221
|
+
manipulationSettings: { quoteKind: y.Single }
|
|
221
222
|
}).addSourceFileAtPath(e), n = t.getVariableDeclaration("reroute");
|
|
222
|
-
if (!n) return
|
|
223
|
+
if (!n) return N(t) ? {
|
|
223
224
|
status: "failed",
|
|
224
|
-
message:
|
|
225
|
-
} : (
|
|
225
|
+
message: j
|
|
226
|
+
} : (P(t), t.addStatements(`\n${k}\n\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`), a(t), t.saveSync(), {
|
|
226
227
|
status: "success",
|
|
227
228
|
changed: !0
|
|
228
229
|
});
|
|
229
|
-
if (!n.getFirstAncestorByKind(
|
|
230
|
+
if (!n.getFirstAncestorByKind(b.VariableStatement)?.hasExportKeyword()) return {
|
|
230
231
|
status: "failed",
|
|
231
|
-
message:
|
|
232
|
+
message: j
|
|
232
233
|
};
|
|
233
234
|
let r = n.getInitializer();
|
|
234
|
-
if (!r || !
|
|
235
|
+
if (!r || !M.test(r.getText())) return {
|
|
235
236
|
status: "failed",
|
|
236
|
-
message:
|
|
237
|
+
message: j
|
|
237
238
|
};
|
|
238
|
-
|
|
239
|
+
P(t), n.setInitializer("({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))");
|
|
239
240
|
let i = t.getVariableStatements().find((e) => e.getDeclarations().some((e) => e.getName() === "reroute"));
|
|
240
|
-
return t.insertText(i.getStart(!0), `${
|
|
241
|
+
return t.insertText(i.getStart(!0), `${k}\n\n`), a(t), t.saveSync(), {
|
|
241
242
|
status: "success",
|
|
242
243
|
changed: !0
|
|
243
244
|
};
|
|
244
245
|
}
|
|
245
246
|
//#endregion
|
|
246
247
|
//#region src/patterns/enable/i18n/modifies/app-html.ts
|
|
247
|
-
var
|
|
248
|
+
var F = [
|
|
248
249
|
"Add the sveltekit lang placeholder to the <html> tag:",
|
|
249
250
|
"",
|
|
250
251
|
"<html lang=\"%sveltekit.lang%\">"
|
|
251
|
-
].join("\n"),
|
|
252
|
+
].join("\n"), I = [
|
|
252
253
|
"Create src/app.html with a lang placeholder:",
|
|
253
254
|
"",
|
|
254
255
|
"<!doctype html>",
|
|
@@ -262,12 +263,12 @@ var P = [
|
|
|
262
263
|
" </body>",
|
|
263
264
|
"</html>"
|
|
264
265
|
].join("\n");
|
|
265
|
-
function
|
|
266
|
-
if (!
|
|
266
|
+
function L(e) {
|
|
267
|
+
if (!g.existsSync(e)) return {
|
|
267
268
|
status: "not-found",
|
|
268
|
-
message:
|
|
269
|
+
message: I
|
|
269
270
|
};
|
|
270
|
-
let t =
|
|
271
|
+
let t = g.readFileSync(e, "utf8");
|
|
271
272
|
if (t.includes("lang=\"%sveltekit.lang%\"") || t.includes("lang='%sveltekit.lang%'")) return {
|
|
272
273
|
status: "success",
|
|
273
274
|
changed: !1
|
|
@@ -275,26 +276,26 @@ function I(e) {
|
|
|
275
276
|
let n = t.replace(/<html(\s[^>]*?)?>/i, (e) => /\slang\s*=/i.test(e) ? e.replace(/\slang\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/i, " lang=\"%sveltekit.lang%\"") : e.replace(/<html/i, "<html lang=\"%sveltekit.lang%\""));
|
|
276
277
|
return n === t ? {
|
|
277
278
|
status: "failed",
|
|
278
|
-
message:
|
|
279
|
-
} : (
|
|
279
|
+
message: F
|
|
280
|
+
} : (g.writeFileSync(e, n), {
|
|
280
281
|
status: "success",
|
|
281
282
|
changed: !0
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
//#endregion
|
|
285
286
|
//#region src/patterns/enable/i18n/modifies/gitignore.ts
|
|
286
|
-
var
|
|
287
|
+
var R = [
|
|
287
288
|
"Create a .gitignore with the wuchale cache ignored:",
|
|
288
289
|
"",
|
|
289
290
|
"# Wuchale",
|
|
290
291
|
"src/locales/.wuchale"
|
|
291
292
|
].join("\n");
|
|
292
|
-
function
|
|
293
|
-
if (!
|
|
293
|
+
function z(t) {
|
|
294
|
+
if (!g.existsSync(t)) return {
|
|
294
295
|
status: "not-found",
|
|
295
|
-
message:
|
|
296
|
+
message: R
|
|
296
297
|
};
|
|
297
|
-
let n =
|
|
298
|
+
let n = g.readFileSync(t, "utf8");
|
|
298
299
|
if (n.includes("src/locales/.wuchale")) return {
|
|
299
300
|
status: "success",
|
|
300
301
|
changed: !1
|
|
@@ -303,55 +304,55 @@ function R(t) {
|
|
|
303
304
|
# Wuchale
|
|
304
305
|
src/locales/.wuchale
|
|
305
306
|
`, i = n + (n.length > 0 && !n.endsWith("\n") ? "\n" : "") + "\n" + r + "\n";
|
|
306
|
-
return
|
|
307
|
+
return g.writeFileSync(t, i), {
|
|
307
308
|
status: "success",
|
|
308
309
|
changed: !0
|
|
309
310
|
};
|
|
310
311
|
}
|
|
311
312
|
//#endregion
|
|
312
313
|
//#region src/patterns/enable/i18n/modifies/root-layout.svelte.ts
|
|
313
|
-
var
|
|
314
|
+
var B = "<Navbar.Item>\n <LanguageSelect />\n </Navbar.Item>\n ", V = "<LanguageSelect />", H = e`
|
|
314
315
|
import LanguageSelect from '#lib/components/language-select.svelte';
|
|
315
|
-
`,
|
|
316
|
+
`, U = [
|
|
316
317
|
"Add the language select inside your <Navbar.List> in the root layout.",
|
|
317
318
|
"",
|
|
318
319
|
"Import to add to the <script> tag:",
|
|
319
320
|
"",
|
|
320
|
-
|
|
321
|
+
H,
|
|
321
322
|
"",
|
|
322
323
|
"Markup to add at the end of <Navbar.List>:",
|
|
323
|
-
|
|
324
|
-
].join("\n"),
|
|
324
|
+
B
|
|
325
|
+
].join("\n"), W = [
|
|
325
326
|
"Create a root layout that includes a language select inside <Navbar.List>.",
|
|
326
327
|
"",
|
|
327
328
|
"Import for the <script> tag:",
|
|
328
329
|
"",
|
|
329
|
-
|
|
330
|
+
H,
|
|
330
331
|
"",
|
|
331
332
|
"Markup at the end of <Navbar.List>:",
|
|
332
|
-
|
|
333
|
-
].join("\n"),
|
|
333
|
+
B
|
|
334
|
+
].join("\n"), G = [
|
|
334
335
|
"Add the language select to your root layout.",
|
|
335
336
|
"",
|
|
336
337
|
"Import to add to the <script> tag:",
|
|
337
338
|
"",
|
|
338
|
-
|
|
339
|
+
H,
|
|
339
340
|
"",
|
|
340
341
|
"Markup to add wherever it should render, e.g. above {@render children()}:",
|
|
341
342
|
"",
|
|
342
|
-
|
|
343
|
-
].join("\n"),
|
|
343
|
+
V
|
|
344
|
+
].join("\n"), K = [
|
|
344
345
|
"Create a root layout that includes the language select.",
|
|
345
346
|
"",
|
|
346
347
|
"Import for the <script> tag:",
|
|
347
348
|
"",
|
|
348
|
-
|
|
349
|
+
H,
|
|
349
350
|
"",
|
|
350
351
|
"Markup above {@render children()}:",
|
|
351
352
|
"",
|
|
352
|
-
|
|
353
|
+
V
|
|
353
354
|
].join("\n");
|
|
354
|
-
function
|
|
355
|
+
function q(e) {
|
|
355
356
|
e.modifyScript((e) => {
|
|
356
357
|
let { source: t } = r(e, (e) => {
|
|
357
358
|
o(e, [{
|
|
@@ -362,45 +363,45 @@ function K(e) {
|
|
|
362
363
|
return t;
|
|
363
364
|
});
|
|
364
365
|
}
|
|
365
|
-
function
|
|
366
|
+
function J(e, t = "shadcn") {
|
|
366
367
|
let n = t === "plain";
|
|
367
|
-
if (!
|
|
368
|
+
if (!g.existsSync(e)) return {
|
|
368
369
|
status: "not-found",
|
|
369
|
-
message: n ?
|
|
370
|
+
message: n ? K : W
|
|
370
371
|
};
|
|
371
372
|
let r = c.fromPath(e);
|
|
372
373
|
return r.hasElement("LanguageSelect") ? {
|
|
373
374
|
status: "success",
|
|
374
375
|
changed: !1
|
|
375
|
-
} : n ? !r.getScript() || !r.insertBeforeChildren(
|
|
376
|
+
} : n ? !r.getScript() || !r.insertBeforeChildren(V) ? {
|
|
376
377
|
status: "failed",
|
|
377
|
-
message:
|
|
378
|
-
} : (
|
|
378
|
+
message: G
|
|
379
|
+
} : (q(r), r.writeTo(e), {
|
|
379
380
|
status: "success",
|
|
380
381
|
changed: r.hasChanged()
|
|
381
|
-
}) : r.hasElement("Navbar.List") ? (
|
|
382
|
+
}) : r.hasElement("Navbar.List") ? (q(r), r.insertBeforeClosingTag("Navbar.List", B), r.writeTo(e), {
|
|
382
383
|
status: "success",
|
|
383
384
|
changed: r.hasChanged()
|
|
384
385
|
}) : {
|
|
385
386
|
status: "failed",
|
|
386
|
-
message:
|
|
387
|
+
message: U
|
|
387
388
|
};
|
|
388
389
|
}
|
|
389
390
|
//#endregion
|
|
390
391
|
//#region src/patterns/enable/i18n/welcome-catalog.ts
|
|
391
|
-
var
|
|
392
|
-
reference:
|
|
392
|
+
var Y = "src/routes/+page.svelte", X = "src/locales/es.po", Z = ["<h1>Welcome to SvelteKit</h1>", "<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>"].join("\n"), Q = [{
|
|
393
|
+
reference: Y,
|
|
393
394
|
msgid: "Welcome to SvelteKit",
|
|
394
395
|
msgstr: "Bienvenido a SvelteKit"
|
|
395
396
|
}, {
|
|
396
|
-
reference:
|
|
397
|
+
reference: Y,
|
|
397
398
|
msgid: "Visit <0>svelte.dev/docs/kit</0> to read the documentation",
|
|
398
399
|
msgstr: "Visita <0>svelte.dev/docs/kit</0> para leer la documentación"
|
|
399
|
-
}],
|
|
400
|
+
}], te = {
|
|
400
401
|
reference: "src/lib/components/language-select.svelte",
|
|
401
402
|
msgid: "Language",
|
|
402
403
|
msgstr: "Idioma"
|
|
403
|
-
},
|
|
404
|
+
}, ne = [
|
|
404
405
|
"msgid \"\"",
|
|
405
406
|
"msgstr \"\"",
|
|
406
407
|
"\"Source-Language: en\\n\"",
|
|
@@ -411,13 +412,13 @@ var J = "src/routes/+page.svelte", Y = "src/locales/es.po", X = ["<h1>Welcome to
|
|
|
411
412
|
"\"Plural-Forms: nplurals=3\\n\"",
|
|
412
413
|
"\"X-Plurals-Order: one, many, other\\n\""
|
|
413
414
|
].join("\n"), $ = (e) => e.replace(/\s+/g, "");
|
|
414
|
-
function
|
|
415
|
-
if (
|
|
416
|
-
let n =
|
|
417
|
-
return !
|
|
418
|
-
path:
|
|
415
|
+
function re(e, t) {
|
|
416
|
+
if (g.existsSync(_.join(e, X))) return null;
|
|
417
|
+
let n = _.join(e, Y);
|
|
418
|
+
return !g.existsSync(n) || $(g.readFileSync(n, "utf8")) !== $(Z) ? null : {
|
|
419
|
+
path: X,
|
|
419
420
|
language: "text",
|
|
420
|
-
content: [
|
|
421
|
+
content: [ne, ...(t === "plain" ? [...Q, te] : Q).map((e) => [
|
|
421
422
|
`#: ${e.reference}`,
|
|
422
423
|
`msgid "${e.msgid}"`,
|
|
423
424
|
`msgstr "${e.msgstr}"`
|
|
@@ -427,33 +428,44 @@ function te(e, t) {
|
|
|
427
428
|
}
|
|
428
429
|
//#endregion
|
|
429
430
|
//#region src/patterns/enable/i18n/generate.runtime.ts
|
|
430
|
-
|
|
431
|
+
function ie(e, t) {
|
|
432
|
+
let n = h.filter((t) => g.existsSync(_.join(e, t)));
|
|
433
|
+
return n.length === 0 ? t : t.map((e) => {
|
|
434
|
+
if (!e.path.endsWith("wuchale.config.js")) return e;
|
|
435
|
+
let t = m(e.content, n);
|
|
436
|
+
return t?.changed ? {
|
|
437
|
+
...e,
|
|
438
|
+
content: t.source
|
|
439
|
+
} : e;
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
async function ae(e) {
|
|
431
443
|
let r = n(e), i = [], a = (e) => {
|
|
432
444
|
e && i.push(e);
|
|
433
445
|
};
|
|
434
446
|
r.info("Modifying vite.config");
|
|
435
|
-
let o = u(e.root, d) ??
|
|
436
|
-
a(s(o,
|
|
447
|
+
let o = u(e.root, d) ?? _.join(e.root, d[0]);
|
|
448
|
+
a(s(o, C(o))), r.info("Adding #locales to package.json imports");
|
|
437
449
|
let c = f(e.root);
|
|
438
450
|
a(s(c.filePath, c.outcome)), r.info("Modifying hooks.server.ts");
|
|
439
|
-
let l =
|
|
440
|
-
a(s(l,
|
|
441
|
-
let
|
|
442
|
-
a(s(
|
|
443
|
-
let
|
|
444
|
-
a(s(
|
|
445
|
-
let v =
|
|
451
|
+
let l = _.join(e.root, "src", "hooks.server.ts");
|
|
452
|
+
a(s(l, O(l))), r.info("Modifying hooks.ts");
|
|
453
|
+
let m = _.join(e.root, "src", "hooks.ts");
|
|
454
|
+
a(s(m, ee(m))), r.info("Modifying app.html");
|
|
455
|
+
let h = _.join(e.root, "src", "app.html");
|
|
456
|
+
a(s(h, L(h))), r.info("Modifying root +layout.ts");
|
|
457
|
+
let v = _.join(e.root, "src", "routes", "+layout.ts");
|
|
446
458
|
a(s(v, p(v))), r.info("Modifying root layout language select");
|
|
447
459
|
let y = [
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
], b = t(e),
|
|
453
|
-
a(s(
|
|
454
|
-
let
|
|
455
|
-
a(s(
|
|
456
|
-
let w =
|
|
460
|
+
_.join(e.root, "src", "routes", "(public)", "root-layout.svelte"),
|
|
461
|
+
_.join(e.root, "src", "routes", "root-layout.svelte"),
|
|
462
|
+
_.join(e.root, "src", "routes", "(public)", "+layout.svelte"),
|
|
463
|
+
_.join(e.root, "src", "routes", "+layout.svelte")
|
|
464
|
+
], b = t(e), x = y.find((e) => g.existsSync(e)) ?? (b === "plain" ? y[3] : y[0]);
|
|
465
|
+
a(s(x, J(x, b))), r.info("Updating .gitignore");
|
|
466
|
+
let S = _.join(e.root, ".gitignore");
|
|
467
|
+
a(s(S, z(S)));
|
|
468
|
+
let w = re(e.root, b);
|
|
457
469
|
return w && r.info("Translating the welcome page into Spanish"), {
|
|
458
470
|
creates: w ? [w] : [],
|
|
459
471
|
modifies: i,
|
|
@@ -466,6 +478,6 @@ async function ne(e) {
|
|
|
466
478
|
};
|
|
467
479
|
}
|
|
468
480
|
//#endregion
|
|
469
|
-
export {
|
|
481
|
+
export { ae as generate, ie as withLibraryTexts };
|
|
470
482
|
|
|
471
|
-
//# sourceMappingURL=generate.runtime-
|
|
483
|
+
//# sourceMappingURL=generate.runtime-BoYwV0nt.js.map
|