@velastack/patterns 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/chunks/{_layout-D-FzWqn0.js → _layout-Bsx3eNrC.js} +3 -3
- package/dist/chunks/{_layout-D-FzWqn0.js.map → _layout-Bsx3eNrC.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-BrEA7a62.js +309 -0
- package/dist/chunks/collections-BrEA7a62.js.map +1 -0
- package/dist/chunks/{collections-Cpjo2OiQ.js → collections-DrUG8ngq.js} +39 -35
- package/dist/chunks/collections-DrUG8ngq.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-Rq8SCXwH.js → constants-iej3WkEa.js} +3 -3
- package/dist/chunks/constants-iej3WkEa.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-Bj41Nccm.js → env-vars-CdarYsrc.js} +6 -11
- package/dist/chunks/{env-vars-Bj41Nccm.js.map → env-vars-CdarYsrc.js.map} +1 -1
- package/dist/chunks/{generate-dNlBII84.js → generate-27CjLiGW.js} +2 -2
- package/dist/chunks/{generate-dNlBII84.js.map → generate-27CjLiGW.js.map} +1 -1
- package/dist/chunks/{generate-yi8AP3xH.js → generate-BFcy2wrS.js} +3 -3
- package/dist/chunks/{generate-yi8AP3xH.js.map → generate-BFcy2wrS.js.map} +1 -1
- package/dist/chunks/generate-BxOzEdc_.js +171 -0
- package/dist/chunks/generate-BxOzEdc_.js.map +1 -0
- package/dist/chunks/{generate-B6Odfk5f.js → generate-Cqwa8kD9.js} +2 -2
- package/dist/chunks/{generate-B6Odfk5f.js.map → generate-Cqwa8kD9.js.map} +1 -1
- package/dist/chunks/{generate-DjBMRzsB.js → generate-D3mSFPdT.js} +2 -2
- package/dist/chunks/{generate-DjBMRzsB.js.map → generate-D3mSFPdT.js.map} +1 -1
- package/dist/chunks/{generate-ZIOVLH6Q.js → generate-DdLwP0E7.js} +51 -47
- package/dist/chunks/generate-DdLwP0E7.js.map +1 -0
- package/dist/chunks/generate-DyV5R8NP.js.map +1 -1
- package/dist/chunks/{generate.runtime-MjWwR2Bd.js → generate.runtime-9KuMcI5r.js} +10 -13
- package/dist/chunks/{generate.runtime-MjWwR2Bd.js.map → generate.runtime-9KuMcI5r.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BKINIJ2c.js → generate.runtime-B10-KA87.js} +69 -69
- package/dist/chunks/{generate.runtime-BKINIJ2c.js.map → generate.runtime-B10-KA87.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DaRVyiSg.js → generate.runtime-B8-GLMkk.js} +131 -197
- package/dist/chunks/generate.runtime-B8-GLMkk.js.map +1 -0
- package/dist/chunks/{generate.runtime-Bdpu4rX0.js → generate.runtime-BGuXHl5o.js} +3 -3
- package/dist/chunks/{generate.runtime-Bdpu4rX0.js.map → generate.runtime-BGuXHl5o.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DjCzW3zU.js → generate.runtime-BJxM7FNA.js} +7 -7
- package/dist/chunks/{generate.runtime-DjCzW3zU.js.map → generate.runtime-BJxM7FNA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BdmoAVJK.js → generate.runtime-BWRtyQeD.js} +5 -5
- package/dist/chunks/{generate.runtime-BdmoAVJK.js.map → generate.runtime-BWRtyQeD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CV4soy2n.js → generate.runtime-B_tWu-Bw.js} +47 -47
- package/dist/chunks/{generate.runtime-CV4soy2n.js.map → generate.runtime-B_tWu-Bw.js.map} +1 -1
- package/dist/chunks/{generate.runtime-NaSIZlP5.js → generate.runtime-BdghkfNp.js} +3 -3
- package/dist/chunks/{generate.runtime-NaSIZlP5.js.map → generate.runtime-BdghkfNp.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B4QoBn5v.js → generate.runtime-Blb6QPZn.js} +8 -8
- package/dist/chunks/{generate.runtime-B4QoBn5v.js.map → generate.runtime-Blb6QPZn.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DRRyPa-e.js → generate.runtime-CEexT8cJ.js} +66 -66
- package/dist/chunks/{generate.runtime-DRRyPa-e.js.map → generate.runtime-CEexT8cJ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BKTkVCEm.js → generate.runtime-CIZO2XO9.js} +4 -4
- package/dist/chunks/{generate.runtime-BKTkVCEm.js.map → generate.runtime-CIZO2XO9.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DmsOEsJV.js → generate.runtime-CK0MTeqc.js} +4 -4
- package/dist/chunks/{generate.runtime-DmsOEsJV.js.map → generate.runtime-CK0MTeqc.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BavEh01F.js → generate.runtime-CMO-Skpk.js} +5 -5
- package/dist/chunks/{generate.runtime-BavEh01F.js.map → generate.runtime-CMO-Skpk.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BXZDKLbA.js → generate.runtime-CVDb-yLt.js} +12 -20
- package/dist/chunks/{generate.runtime-BXZDKLbA.js.map → generate.runtime-CVDb-yLt.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-CWgZhxQt.js → generate.runtime-CbOMXQSo.js} +3 -3
- package/dist/chunks/{generate.runtime-CWgZhxQt.js.map → generate.runtime-CbOMXQSo.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DBBtYTAa.js → generate.runtime-CbT-EbQT.js} +5 -5
- package/dist/chunks/{generate.runtime-DBBtYTAa.js.map → generate.runtime-CbT-EbQT.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CSUnP0l-.js → generate.runtime-Cxr15Y5H.js} +27 -27
- package/dist/chunks/{generate.runtime-CSUnP0l-.js.map → generate.runtime-Cxr15Y5H.js.map} +1 -1
- package/dist/chunks/{generate.runtime-pMpn0Pbf.js → generate.runtime-CyTxBcX3.js} +10 -10
- package/dist/chunks/{generate.runtime-pMpn0Pbf.js.map → generate.runtime-CyTxBcX3.js.map} +1 -1
- package/dist/chunks/{generate.runtime-azOvp6tl.js → generate.runtime-D5HxAups.js} +39 -36
- package/dist/chunks/generate.runtime-D5HxAups.js.map +1 -0
- package/dist/chunks/{generate.runtime-b2RtuPy4.js → generate.runtime-D6vhkGs8.js} +5 -5
- package/dist/chunks/{generate.runtime-b2RtuPy4.js.map → generate.runtime-D6vhkGs8.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DlbG-8Xm.js → generate.runtime-DIeAeOJg.js} +6 -6
- package/dist/chunks/{generate.runtime-DlbG-8Xm.js.map → generate.runtime-DIeAeOJg.js.map} +1 -1
- package/dist/chunks/{generate.runtime-QbmCPT42.js → generate.runtime-DMTAocSE.js} +17 -17
- package/dist/chunks/{generate.runtime-QbmCPT42.js.map → generate.runtime-DMTAocSE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-utFLS6Jz.js → generate.runtime-DlLwmjGF.js} +133 -121
- package/dist/chunks/generate.runtime-DlLwmjGF.js.map +1 -0
- package/dist/chunks/{generate.runtime-BYfyZHhs.js → generate.runtime-DtCaz98N.js} +6 -6
- package/dist/chunks/{generate.runtime-BYfyZHhs.js.map → generate.runtime-DtCaz98N.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BcgjZJug.js → generate.runtime-HSZD935T.js} +4 -4
- package/dist/chunks/{generate.runtime-BcgjZJug.js.map → generate.runtime-HSZD935T.js.map} +1 -1
- package/dist/chunks/{generate.runtime-OEgsdWRP.js → generate.runtime-Nnk5E8Pi.js} +3 -3
- package/dist/chunks/{generate.runtime-OEgsdWRP.js.map → generate.runtime-Nnk5E8Pi.js.map} +1 -1
- package/dist/chunks/{generate.runtime-D-qtaVdq.js → generate.runtime-NxuWvkKt.js} +13 -13
- package/dist/chunks/{generate.runtime-D-qtaVdq.js.map → generate.runtime-NxuWvkKt.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CCV4O6_I.js → generate.runtime-dFTOU_KE.js} +71 -71
- package/dist/chunks/{generate.runtime-CCV4O6_I.js.map → generate.runtime-dFTOU_KE.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C7s1Mx5L.js → generate.runtime-m0m43lkL.js} +7 -7
- package/dist/chunks/{generate.runtime-C7s1Mx5L.js.map → generate.runtime-m0m43lkL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BdHv7Jp1.js → generate.runtime-si5Za61F.js} +3 -3
- package/dist/chunks/{generate.runtime-BdHv7Jp1.js.map → generate.runtime-si5Za61F.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DetYynf4.js → generate.runtime-tGKorg85.js} +10 -14
- package/dist/chunks/{generate.runtime-DetYynf4.js.map → generate.runtime-tGKorg85.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CcPCAEV0.js → generate.runtime-ww3-1FWf.js} +6 -6
- package/dist/chunks/{generate.runtime-CcPCAEV0.js.map → generate.runtime-ww3-1FWf.js.map} +1 -1
- package/dist/chunks/{modify-file-Bbhyfiy_.js → modify-file-COBp4eCh.js} +4 -4
- package/dist/chunks/{modify-file-Bbhyfiy_.js.map → modify-file-COBp4eCh.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-Dx05A-4S.js} +2 -2
- package/dist/chunks/{package-imports-Bbw3iMPg.js.map → package-imports-Dx05A-4S.js.map} +1 -1
- package/dist/chunks/{pocketbase-CgwbH1gI.js → pocketbase-DL02rq73.js} +5 -13
- package/dist/chunks/{pocketbase-CgwbH1gI.js.map → pocketbase-DL02rq73.js.map} +1 -1
- package/dist/chunks/{providers-DwbwccSW.js → providers-CAehyySB.js} +2 -2
- package/dist/chunks/{providers-DwbwccSW.js.map → providers-CAehyySB.js.map} +1 -1
- package/dist/chunks/{rolldown-runtime-DArdT4gl.js → rolldown-runtime-5HNE8Q1r.js} +1 -1
- package/dist/chunks/{shared-D5GOS97l.js → shared-C_Fr8wph.js} +2 -2
- package/dist/chunks/{shared-D5GOS97l.js.map → shared-C_Fr8wph.js.map} +1 -1
- package/dist/chunks/site-BoujshKo.js +108 -0
- package/dist/chunks/site-BoujshKo.js.map +1 -0
- package/dist/chunks/{table-core-DhDqT03G.js → table-core-BPv_RYgD.js} +3 -3
- package/dist/chunks/{table-core-DhDqT03G.js.map → table-core-BPv_RYgD.js.map} +1 -1
- package/dist/chunks/{taggedTemplateLiteral-CswN2AAa.js → taggedTemplateLiteral-KSUnuvOk.js} +1 -1
- package/dist/chunks/{test-setup-DZoyF8Ak.js → test-setup-pYUIfWb2.js} +5 -5
- package/dist/chunks/{test-setup-DZoyF8Ak.js.map → test-setup-pYUIfWb2.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-BuocThuh.js → ui-B2yn8c_-.js} +3 -3
- package/dist/chunks/{ui-BuocThuh.js.map → ui-B2yn8c_-.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-CguKGTtw.js → whatsapp-5qJ_xCV1.js} +2 -2
- package/dist/chunks/{whatsapp-CguKGTtw.js.map → whatsapp-5qJ_xCV1.js.map} +1 -1
- package/dist/chunks/{write-result-Cq-9A7Zy.js → write-result-Bn4bnrBI.js} +20 -50
- package/dist/chunks/write-result-Bn4bnrBI.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 +162 -1
- package/dist/index.js +2193 -2330
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/collections-Cpjo2OiQ.js.map +0 -1
- package/dist/chunks/constants-Rq8SCXwH.js.map +0 -1
- package/dist/chunks/generate-BClgUH4J.js +0 -137
- package/dist/chunks/generate-BClgUH4J.js.map +0 -1
- package/dist/chunks/generate-ZIOVLH6Q.js.map +0 -1
- package/dist/chunks/generate.runtime-DaRVyiSg.js.map +0 -1
- package/dist/chunks/generate.runtime-azOvp6tl.js.map +0 -1
- package/dist/chunks/generate.runtime-utFLS6Jz.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/site-lj0CDdQ1.js +0 -55
- package/dist/chunks/site-lj0CDdQ1.js.map +0 -1
- package/dist/chunks/write-result-Cq-9A7Zy.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-azOvp6tl.js","names":["isLibSpecifier","getLogger","envEditsFor","planDropsForCollections","providersToRemove","modifyEnvRemove","removeNavItemFromScript","removeStatementWithComments","ensureBlankLineAfterImports","formatLikeSource","modifyOutcomeToFile","SvelteFile","fs","path","unmodifyNavUser","navUserPath","source","file","wasRemoved","tryRemove","run","result","src","fn","CALL_EXPRESSIONS","unmodifyUserSignup","userSignupPath","originalSource","sourceFile","Project","QuoteKind","module","decl","d","linkFn","s","callStatements","SyntaxKind","ce","call","stmt","STRIPE_COLLECTIONS","generate","isAppMode","options","logger","providers","isStripe","provider","modifies","deletes","pushResult","envPath","envVars","unmodifyEnvVarsFiles","variable"],"sources":["../../src/patterns/disable/payments/modifies/modify-nav-user.ts","../../src/patterns/disable/payments/modifies/modify-user-signup.ts","../../src/patterns/disable/payments/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport { removeNavItemFromScript } from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nexport function unmodifyNavUser(navUserPath: string): ModifyOutcome {\n if (!fs.existsSync(navUserPath)) {\n return { status: \"success\", changed: false };\n }\n\n const source = fs.readFileSync(navUserPath, \"utf8\");\n if (!source.includes(\"/billing\")) {\n return { status: \"success\", changed: false };\n }\n\n const file = new SvelteFile(source);\n let wasRemoved = false;\n\n const tryRemove = (run: (fn: (s: string) => string) => boolean) => {\n if (wasRemoved) return;\n run((src) => {\n const result = removeNavItemFromScript(\n src,\n \"Billing\",\n \"@lucide/svelte/icons/credit-card\",\n );\n if (result.wasRemoved) wasRemoved = true;\n return result.source;\n });\n };\n\n tryRemove((fn) => file.modifyModuleScript(fn));\n if (!wasRemoved) tryRemove((fn) => file.modifyScript(fn));\n\n if (!wasRemoved) {\n return { status: \"success\", changed: false };\n }\n\n fs.writeFileSync(navUserPath, file.toString(), \"utf8\");\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureBlankLineAfterImports,\n formatLikeSource,\n removeStatementWithComments,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport { isLibSpecifier } from \"../../../../runtime/lib-specifier\";\n\nconst CALL_EXPRESSIONS = new Set([\n \"linkStripeCustomer.run\",\n // Projects from before the workflow: an inline helper called directly.\n \"linkStripeCustomer\",\n]);\n\nexport function unmodifyUserSignup(userSignupPath: string): ModifyOutcome {\n if (!fs.existsSync(userSignupPath)) {\n return { status: \"success\", changed: false };\n }\n\n const originalSource = fs.readFileSync(userSignupPath, \"utf8\");\n if (!originalSource.includes(\"linkStripeCustomer\")) {\n return { status: \"success\", changed: false };\n }\n\n const project = new Project({\n manipulationSettings: { quoteKind: QuoteKind.Single },\n });\n const sourceFile = project.addSourceFileAtPath(userSignupPath);\n\n for (const module of [\"workflows/link-stripe-customer\", \"stripe\"]) {\n const decl = sourceFile\n .getImportDeclarations()\n .find((d) => isLibSpecifier(d.getModuleSpecifierValue(), module));\n if (decl) decl.remove();\n }\n\n const linkFn = sourceFile.getVariableStatement((s) =>\n s.getDeclarations().some((d) => d.getName() === \"linkStripeCustomer\"),\n );\n if (linkFn) linkFn.remove();\n\n const callStatements = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .filter((ce) => CALL_EXPRESSIONS.has(ce.getExpression().getText()));\n for (const call of callStatements) {\n const stmt = call.getFirstAncestorByKind(SyntaxKind.ExpressionStatement);\n // With the two comment lines enable-payments put above it: left behind,\n // they keep the file from matching the stock signup, and enable-whatsapp\n // then refuses to swap it.\n if (stmt) removeStatementWithComments(sourceFile, stmt);\n }\n\n formatLikeSource(sourceFile);\n ensureBlankLineAfterImports(sourceFile);\n sourceFile.saveSync();\n\n return {\n status: \"success\",\n changed: sourceFile.getFullText() !== originalSource,\n };\n}\n","import path from \"node:path\";\nimport type { File, Options, Result } from \"../../../core/types\";\nimport { getLogger } from \"../../../core/logger\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport { modifyEnvRemove } from \"../../../runtime/env\";\nimport { unmodifyEnvVarsFiles } from \"../../../runtime/env-vars\";\nimport { envEditsFor } from \"../../enable/payments/generate\";\nimport { providersToRemove } from \"./generate\";\nimport { unmodifyNavUser } from \"./modifies/modify-nav-user\";\nimport { unmodifyUserSignup } from \"./modifies/modify-user-signup\";\nimport { planDropsForCollections } from \"../../destroy/shared\";\n\n/** Everything enable-payments creates in PocketBase for Stripe. */\nconst STRIPE_COLLECTIONS = [\n \"transactions\",\n \"stripe_customers\",\n \"stripe_payment_methods\",\n \"stripe_prices\",\n \"stripe_products\",\n];\n\nexport async function generate(options: Options) {\n const isAppMode = options.features.auth;\n const logger = getLogger(options);\n const providers = providersToRemove(options);\n const isStripe = providers.some((provider) => provider.id === \"stripe\");\n const modifies: File[] = [];\n const deletes: File[] = [];\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n const envPath = path.join(options.root, \".env\");\n for (const provider of providers) {\n logger.info(`Stripping ${provider.label} credentials from .env`);\n pushResult(\n modifyOutcomeToFile(\n envPath,\n modifyEnvRemove(envPath, envEditsFor(provider)),\n ),\n );\n }\n\n logger.info(\"Removing payment variables from src/env.ts\");\n const envVars = unmodifyEnvVarsFiles(\n options.root,\n providers.flatMap((provider) =>\n (provider.env ?? []).map((variable) => variable.key),\n ),\n );\n pushResult(envVars.modify);\n if (envVars.delete) deletes.push(envVars.delete);\n\n // The nav item and the signup link exist only in auth's files, which\n // enable-payments edits for Stripe alone.\n if (isStripe && isAppMode) {\n logger.info(\"Reverting nav-user.svelte\");\n const navUserPath = path.join(\n options.root,\n \"src\",\n \"lib\",\n \"components\",\n \"nav-user.svelte\",\n );\n pushResult(modifyOutcomeToFile(navUserPath, unmodifyNavUser(navUserPath)));\n\n logger.info(\"Reverting signup +page.server.ts\");\n const userSignupPath = path.join(\n options.root,\n \"src\",\n \"routes\",\n \"(public)\",\n \"(auth)\",\n \"signup\",\n \"+page.server.ts\",\n );\n pushResult(\n modifyOutcomeToFile(userSignupPath, unmodifyUserSignup(userSignupPath)),\n );\n }\n\n // Every Stripe collection is planned, whatever auth is now; one that was\n // never created is planned as missing and left alone. Without a backend\n // (no provider detected, on a Shopify project) there is nothing to drop.\n const collectionDrops =\n isStripe && options.features.backend\n ? await planDropsForCollections(STRIPE_COLLECTIONS, options)\n : [];\n\n return {\n creates: [],\n modifies,\n deletes,\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops,\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,SAAgBc,EAAgB,GAAoC;CAClE,IAAI,CAACF,EAAG,WAAWG,CAAW,GAC5B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAASJ,EAAG,aAAaG,GAAa,MAAM;CAClD,IAAI,CAACC,EAAO,SAAS,UAAU,GAC7B,OAAO;EAAE,QAAQ;EAAW,SAAS;CAAM;CAG7C,IAAMC,IAAO,IAAIN,EAAWK,CAAM,GAC9BE,IAAa,IAEXC,KAAa,MAAgD;EACjE,AAAID,KACJE,GAAK,MAAQ;GACX,IAAMC,IAASf,EACbgB,GACA,WACA,kCACF;GAEA,OADID,EAAO,eAAY,IAAa,KAC7BA,EAAO;EAChB,CAAC;CACH;CAUA,OARAF,GAAW,MAAOF,EAAK,mBAAmBM,CAAE,CAAC,GACxCL,KAAYC,GAAW,MAAOF,EAAK,aAAaM,CAAE,CAAC,GAEnDL,KAILN,EAAG,cAAcG,GAAaE,EAAK,SAAS,GAAG,MAAM,GAC9C;EAAE,QAAQ;EAAW,SAAS;CAAK,KAJjC;EAAE,QAAQ;EAAW,SAAS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,SAAS,UACzB,MAAMzC,EAAwBsC,GAAoBG,CAAO,IACzD,CAAC;CAWP;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.runtime-utFLS6Jz.js","names":["FAILURE_HINT","NOT_FOUND_HINT","FAILURE_HINT","FAILURE_HINT","FAILURE_HINT","NOT_FOUND_HINT","NOT_FOUND_HINT","dedent","withInMemoryScript","formatLikeSource","ensureImports","modifyOutcomeToFile","SvelteFile","addHandle","probeFirstExisting","VITE_CONFIG_CANDIDATES","modifyPackageImportsI18n","ensureRootLayoutI18n","fs","path","FAILURE_HINT$4","NOT_FOUND_HINT$3","modifyViteConfig","viteConfigPath","sourceFile","Project","QuoteKind","changed","failed","d","configArg","SyntaxKind","ce","configObj","pluginsProp","pluginsInit","arr","el","I18N_HANDLE","FAILURE_HINT$3","HOOKS_SERVER_SNIPPET","ensureNamespaceImport","moduleSpecifier","ns","modifyHooksServerI18n","hooksServerPath","original","composed","handleStmt","ensureNamedImport","startupSnippet","i18nHandleSnippet","DELOCALIZE_HELPER","HOOKS_SNIPPET","FAILURE_HINT$2","NEGOTIATE_ONLY_REROUTE","hasOtherReroute","n","ensureDeLocalizeImports","modifyHooksI18n","hooksPath","rerouteDecl","init","target","s","FAILURE_HINT$1","NOT_FOUND_HINT$2","modifyAppHtml","appHtmlPath","updated","match","NOT_FOUND_HINT$1","modifyGitignore","gitignorePath","block","LANGUAGE_SELECT_SNIPPET","PLAIN_LANGUAGE_SELECT_SNIPPET","IMPORT_SNIPPET","FAILURE_HINT","NOT_FOUND_HINT","PLAIN_FAILURE_HINT","PLAIN_NOT_FOUND_HINT","addImport","out","source","sf","modifyRootLayoutLanguageSelect","plain","ui","layoutPath","file","PAGE_PATH","CATALOG_PATH","WELCOME_PAGE","PAGE_ENTRIES","PLAIN_SELECT_ENTRY","HEADER","normalize","welcomePageCatalog","root","pagePath","entry","generate","logger","getLogger","options","modifies","pushResult","imports","rootLayoutCandidates","resolveUi","rootLayoutPath","p","catalog"],"sources":["../../src/patterns/enable/i18n/modifies/vite-config.ts","../../src/patterns/enable/i18n/modifies/hooks.server.ts","../../src/patterns/enable/i18n/modifies/hooks.ts","../../src/patterns/enable/i18n/modifies/app-html.ts","../../src/patterns/enable/i18n/modifies/gitignore.ts","../../src/patterns/enable/i18n/modifies/root-layout.svelte.ts","../../src/patterns/enable/i18n/welcome-catalog.ts","../../src/patterns/enable/i18n/generate.runtime.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport { Project, QuoteKind, SyntaxKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { formatLikeSource } from \"../../../../runtime/ts-morph-helpers\";\n\nconst FAILURE_HINT = [\n \"Add the wuchale plugin to your Vite config:\",\n \"\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale(), /* ...existing plugins */],\",\n \"});\",\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a Vite config with the wuchale plugin:\",\n \"\",\n \"import { defineConfig } from 'vite';\",\n \"import { wuchale } from 'wuchale/vite';\",\n \"\",\n \"export default defineConfig({\",\n \" plugins: [wuchale()],\",\n \"});\",\n].join(\"\\n\");\n\nexport function modifyViteConfig(viteConfigPath: string): ModifyOutcome {\n if (!fs.existsSync(viteConfigPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\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 let changed = false;\n let failed = false;\n\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((d) => d.getModuleSpecifierValue() === \"wuchale/vite\");\n\n if (!hasImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"wuchale\"],\n moduleSpecifier: \"wuchale/vite\",\n });\n changed = true;\n }\n\n const defineConfigCall = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .find((ce) => ce.getExpression().getText() === \"defineConfig\");\n\n const configArg = defineConfigCall?.getArguments()?.[0];\n const configObj =\n configArg?.getKind() === SyntaxKind.ObjectLiteralExpression\n ? (configArg as import(\"ts-morph\").ObjectLiteralExpression)\n : null;\n\n if (!configObj) {\n failed = true;\n } else {\n const pluginsProp = configObj.getProperty(\"plugins\");\n if (!pluginsProp) {\n configObj.addPropertyAssignment({\n name: \"plugins\",\n initializer: \"[wuchale()]\",\n });\n changed = true;\n } else if (pluginsProp.getKind() !== SyntaxKind.PropertyAssignment) {\n failed = true;\n } else {\n const pluginsInit = (\n pluginsProp as import(\"ts-morph\").PropertyAssignment\n ).getInitializer();\n\n if (!pluginsInit) {\n (pluginsProp as import(\"ts-morph\").PropertyAssignment).setInitializer(\n \"[wuchale()]\",\n );\n changed = true;\n } else if (pluginsInit.getKind() !== SyntaxKind.ArrayLiteralExpression) {\n failed = true;\n } else {\n const arr = pluginsInit as import(\"ts-morph\").ArrayLiteralExpression;\n const hasWuchale = arr\n .getElements()\n .some((el) => el.getText().replace(/\\s/g, \"\") === \"wuchale()\");\n\n if (!hasWuchale) {\n arr.insertElement(0, \"wuchale()\");\n changed = true;\n }\n }\n }\n }\n\n if (changed) {\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n }\n\n if (failed) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n return { status: \"success\", changed };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport { addHandle } from \"../../../../runtime/compose-handle\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst I18N_HANDLE = \"handleWuchale\";\n\nconst FAILURE_HINT = dedent`\n Wrap your exported handle with the wuchale i18n handler:\n\n import { sequence } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale),\n }),\n );\n };\n\n export const handle = sequence(handleWuchale, /* your existing handle */);\n`;\n\n/**\n * The whole file, for a project that had no server hooks: a fresh `sv create`\n * app or a static site. `disable-i18n` deletes it again once the i18n handle\n * is all that is left.\n */\nexport const HOOKS_SERVER_SNIPPET = dedent`\n import type { Handle } from '@sveltejs/kit/hooks';\n import { runWithLocale, loadLocales } from 'wuchale/load-utils/server';\n import { getLocale } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n import * as main from '#locales/main.loader.server.svelte.js';\n import * as js from '#locales/js.loader.server.js';\n\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n\n const handleWuchale: Handle = async ({ event, resolve }) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }) => html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n\n export const handle = handleWuchale;\n`;\n\nfunction ensureNamespaceImport(\n sourceFile: import(\"ts-morph\").SourceFile,\n moduleSpecifier: string,\n ns: string,\n) {\n const existing = sourceFile\n .getImportDeclarations()\n .find((d) => d.getModuleSpecifierValue() === moduleSpecifier);\n if (existing) return;\n sourceFile.addImportDeclaration({ namespaceImport: ns, moduleSpecifier });\n}\n\nexport function modifyHooksServerI18n(hooksServerPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksServerPath)) {\n // SvelteKit loads the first `hooks.server.*` it finds, and `.js` sorts\n // first, so a new `.ts` beside it would never run.\n if (fs.existsSync(hooksServerPath.replace(/\\.ts$/, \".js\"))) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.mkdirSync(path.dirname(hooksServerPath), { recursive: true });\n fs.writeFileSync(hooksServerPath, HOOKS_SERVER_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksServerPath, \"utf8\");\n if (original.includes(\"runWithLocale\") || 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 // Composed first: an unsupported handle leaves the file untouched.\n const composed = addHandle(sourceFile, { expression: I18N_HANDLE });\n if (composed.status === \"unsupported\" || !composed.statement) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n const handleStmt = composed.statement;\n\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"runWithLocale\");\n ensureNamedImport(sourceFile, \"wuchale/load-utils/server\", \"loadLocales\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"getLocale\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n ensureNamespaceImport(\n sourceFile,\n \"#locales/main.loader.server.svelte.js\",\n \"main\",\n );\n ensureNamespaceImport(sourceFile, \"#locales/js.loader.server.js\", \"js\");\n\n const startupSnippet = dedent`\n loadLocales(main.key, main.loadCount, main.loadCatalog, locales);\n loadLocales(js.key, js.loadCount, js.loadCatalog, locales);\n `;\n\n const i18nHandleSnippet = dedent`\n const ${I18N_HANDLE} = async ({ event, resolve }: any) => {\n const locale = getLocale(event.url);\n return await runWithLocale(locale, () =>\n resolve(event, {\n transformPageChunk: ({ html }: { html: string }) =>\n html.replace('%sveltekit.lang%', locale)\n })\n );\n };\n `;\n\n // Above the handle and its JSDoc, so `handleWuchale` is declared before\n // the handle reads it.\n sourceFile.insertText(\n handleStmt.getStart(true),\n `${startupSnippet}\\n\\n${i18nHandleSnippet}\\n\\n`,\n );\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport dedent from \"dedent\";\nimport { Project, QuoteKind, SyntaxKind, type SourceFile } from \"ts-morph\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport {\n ensureNamedImport,\n formatLikeSource,\n} from \"../../../../runtime/ts-morph-helpers\";\n\nconst DELOCALIZE_HELPER = dedent`\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n`;\n\n/**\n * The whole file, for a project that had no universal hooks. `disable-i18n`\n * deletes it again once the de-localizing reroute is all that is left.\n */\nexport const HOOKS_SNIPPET = dedent`\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\n`;\n\nconst FAILURE_HINT = dedent`\n Compose your existing reroute in src/hooks.ts with the wuchale de-localizer:\n\n import { deLocalizeDefault } from 'wuchale/url';\n import { matchUrl } from '#locales/main.url.js';\n import { locales } from '#locales/data.js';\n\n const rerouteDeLocalize = (url: string) => {\n const [upath, locale] = deLocalizeDefault(url, locales);\n const { path } = matchUrl(upath, locale);\n return path ?? url;\n };\n\n export const reroute = ({ url }) => rerouteDeLocalize(existingReroute(url.pathname));\n`;\n\n/** What `enable-content-negotiation` leaves behind, to the whitespace. */\nconst NEGOTIATE_ONLY_REROUTE =\n /^\\(\\s*\\{\\s*url\\s*\\}\\s*\\)\\s*=>\\s*negotiateReroute\\(\\s*url\\.pathname\\s*\\)$/;\n\n/** A `reroute` this modifier cannot compose with: not a variable declaration. */\nfunction hasOtherReroute(sourceFile: SourceFile): boolean {\n if (sourceFile.getFunction(\"reroute\")) return true;\n return sourceFile\n .getExportDeclarations()\n .some((d) =>\n d\n .getNamedExports()\n .some(\n (n) => (n.getAliasNode()?.getText() ?? n.getName()) === \"reroute\",\n ),\n );\n}\n\nfunction ensureDeLocalizeImports(sourceFile: SourceFile) {\n ensureNamedImport(sourceFile, \"wuchale/url\", \"deLocalizeDefault\");\n ensureNamedImport(sourceFile, \"#locales/main.url.js\", \"matchUrl\");\n ensureNamedImport(sourceFile, \"#locales/data.js\", \"locales\");\n}\n\n/**\n * Add the de-localizing reroute to `src/hooks.ts`, composing with the one\n * `enable-content-negotiation` wrote rather than replacing the file: either\n * pattern may be enabled first, and negotiation's `modifyHooksNegotiate`\n * composes the other way round.\n */\nexport function modifyHooksI18n(hooksPath: string): ModifyOutcome {\n if (!fs.existsSync(hooksPath)) {\n fs.mkdirSync(path.dirname(hooksPath), { recursive: true });\n fs.writeFileSync(hooksPath, HOOKS_SNIPPET + \"\\n\");\n return { status: \"success\", changed: true };\n }\n\n const original = fs.readFileSync(hooksPath, \"utf8\");\n if (original.includes(\"rerouteDeLocalize\")) {\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 rerouteDecl = sourceFile.getVariableDeclaration(\"reroute\");\n\n if (!rerouteDecl) {\n // A reroute in a shape ts-morph cannot rewrite (a function declaration,\n // a re-export) would collide with the one added below.\n if (hasOtherReroute(sourceFile)) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n ensureDeLocalizeImports(sourceFile);\n sourceFile.addStatements(\n `\\n${DELOCALIZE_HELPER}\\n\\nexport const reroute = ({ url }) => rerouteDeLocalize(url.pathname);\\n`,\n );\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n }\n\n const rerouteStmt = rerouteDecl.getFirstAncestorByKind(\n SyntaxKind.VariableStatement,\n );\n if (!rerouteStmt?.hasExportKeyword()) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n const init = rerouteDecl.getInitializer();\n if (!init || !NEGOTIATE_ONLY_REROUTE.test(init.getText())) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n ensureDeLocalizeImports(sourceFile);\n rerouteDecl.setInitializer(\n \"({ url }) => rerouteDeLocalize(negotiateReroute(url.pathname))\",\n );\n\n // Last: inserting text forgets the nodes above, and the helper has to be\n // declared before the reroute that reads it.\n const target = sourceFile\n .getVariableStatements()\n .find((s) => s.getDeclarations().some((d) => d.getName() === \"reroute\"))!;\n sourceFile.insertText(target.getStart(true), `${DELOCALIZE_HELPER}\\n\\n`);\n\n formatLikeSource(sourceFile);\n sourceFile.saveSync();\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst FAILURE_HINT = [\n \"Add the sveltekit lang placeholder to the <html> tag:\",\n \"\",\n '<html lang=\"%sveltekit.lang%\">',\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create src/app.html with a lang placeholder:\",\n \"\",\n \"<!doctype html>\",\n '<html lang=\"%sveltekit.lang%\">',\n \" <head>\",\n ' <meta charset=\"utf-8\" />',\n \" %sveltekit.head%\",\n \" </head>\",\n ' <body data-sveltekit-preload-data=\"hover\">',\n ' <div style=\"display: contents\">%sveltekit.body%</div>',\n \" </body>\",\n \"</html>\",\n].join(\"\\n\");\n\nexport function modifyAppHtml(appHtmlPath: string): ModifyOutcome {\n if (!fs.existsSync(appHtmlPath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\n }\n\n const original = fs.readFileSync(appHtmlPath, \"utf8\");\n if (\n original.includes('lang=\"%sveltekit.lang%\"') ||\n original.includes(\"lang='%sveltekit.lang%'\")\n ) {\n return { status: \"success\", changed: false };\n }\n\n const updated = original.replace(/<html(\\s[^>]*?)?>/i, (match) => {\n // A static lang (the templates ship lang=\"en\") is replaced by the\n // placeholder so the server hook can fill in the negotiated locale.\n if (/\\slang\\s*=/i.test(match)) {\n return match.replace(\n /\\slang\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+)/i,\n ' lang=\"%sveltekit.lang%\"',\n );\n }\n return match.replace(/<html/i, '<html lang=\"%sveltekit.lang%\"');\n });\n\n if (updated === original) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n fs.writeFileSync(appHtmlPath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\n\nconst NOT_FOUND_HINT = [\n \"Create a .gitignore with the wuchale cache ignored:\",\n \"\",\n \"# Wuchale\",\n \"src/locales/.wuchale\",\n].join(\"\\n\");\n\nexport function modifyGitignore(gitignorePath: string): ModifyOutcome {\n if (!fs.existsSync(gitignorePath)) {\n return { status: \"not-found\", message: NOT_FOUND_HINT };\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 block = dedent`\n # Wuchale\n src/locales/.wuchale\n `;\n\n const needsNewline = original.length > 0 && !original.endsWith(\"\\n\");\n const updated = original + (needsNewline ? \"\\n\" : \"\") + \"\\n\" + block + \"\\n\";\n fs.writeFileSync(gitignorePath, updated);\n return { status: \"success\", changed: true };\n}\n","import fs from \"node:fs\";\nimport dedent from \"dedent\";\nimport { SvelteFile } from \"../../../../runtime/svelte-file\";\nimport {\n ensureImports,\n withInMemoryScript,\n} from \"../../../../runtime/ts-morph-helpers\";\nimport type { ModifyOutcome } from \"../../../../core/types\";\nimport type { Ui } from \"../../../../core/field/ui\";\n\nconst LANGUAGE_SELECT_SNIPPET = `<Navbar.Item>\n\t\t\t\t<LanguageSelect />\n\t\t\t</Navbar.Item>\n\t\t\t`;\n\nconst PLAIN_LANGUAGE_SELECT_SNIPPET = \"<LanguageSelect />\";\n\nconst IMPORT_SNIPPET = dedent`\n import LanguageSelect from '#lib/components/language-select.svelte';\n`;\n\nconst FAILURE_HINT = [\n \"Add the language select inside your <Navbar.List> in the root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst NOT_FOUND_HINT = [\n \"Create a root layout that includes a language select inside <Navbar.List>.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup at the end of <Navbar.List>:\",\n LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_FAILURE_HINT = [\n \"Add the language select to your root layout.\",\n \"\",\n \"Import to add to the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup to add wherever it should render, e.g. above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nconst PLAIN_NOT_FOUND_HINT = [\n \"Create a root layout that includes the language select.\",\n \"\",\n \"Import for the <script> tag:\",\n \"\",\n IMPORT_SNIPPET,\n \"\",\n \"Markup above {@render children()}:\",\n \"\",\n PLAIN_LANGUAGE_SELECT_SNIPPET,\n].join(\"\\n\");\n\nfunction addImport(file: SvelteFile): void {\n file.modifyScript((source) => {\n const { source: out } = withInMemoryScript(source, (sf) => {\n ensureImports(sf, [\n {\n defaultImport: \"LanguageSelect\",\n moduleSpecifier: \"#lib/components/language-select.svelte\",\n },\n ]);\n });\n return out;\n });\n}\n\n/**\n * A vela layout gets the select as the last `<Navbar.List>` item. A plain one\n * (a project vela did not create) has no navbar, so the select goes above the\n * layout's children.\n */\nexport function modifyRootLayoutLanguageSelect(\n layoutPath: string,\n ui: Ui = \"shadcn\",\n): ModifyOutcome {\n const plain = ui === \"plain\";\n if (!fs.existsSync(layoutPath)) {\n return {\n status: \"not-found\",\n message: plain ? PLAIN_NOT_FOUND_HINT : NOT_FOUND_HINT,\n };\n }\n\n const file = SvelteFile.fromPath(layoutPath);\n if (file.hasElement(\"LanguageSelect\")) {\n return { status: \"success\", changed: false };\n }\n\n if (plain) {\n // Without a <script> the import has nowhere to go, and the markup alone\n // would not compile.\n if (!file.getScript()) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n if (!file.insertBeforeChildren(PLAIN_LANGUAGE_SELECT_SNIPPET)) {\n return { status: \"failed\", message: PLAIN_FAILURE_HINT };\n }\n addImport(file);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n }\n\n if (!file.hasElement(\"Navbar.List\")) {\n return { status: \"failed\", message: FAILURE_HINT };\n }\n\n addImport(file);\n file.insertBeforeClosingTag(\"Navbar.List\", LANGUAGE_SELECT_SNIPPET);\n file.writeTo(layoutPath);\n return { status: \"success\", changed: file.hasChanged() };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File } from \"../../../core/types\";\nimport type { Ui } from \"../../../core/field/ui\";\n\nconst PAGE_PATH = \"src/routes/+page.svelte\";\nconst CATALOG_PATH = \"src/locales/es.po\";\n\n/** `src/routes/+page.svelte` as `sv create` writes it. */\nconst WELCOME_PAGE = [\n \"<h1>Welcome to SvelteKit</h1>\",\n '<p>Visit <a href=\"https://svelte.dev/docs/kit\">svelte.dev/docs/kit</a> to read the documentation</p>',\n].join(\"\\n\");\n\ninterface Entry {\n reference: string;\n msgid: string;\n msgstr: string;\n}\n\nconst PAGE_ENTRIES: Entry[] = [\n {\n reference: PAGE_PATH,\n msgid: \"Welcome to SvelteKit\",\n msgstr: \"Bienvenido a SvelteKit\",\n },\n {\n reference: PAGE_PATH,\n msgid: \"Visit <0>svelte.dev/docs/kit</0> to read the documentation\",\n msgstr: \"Visita <0>svelte.dev/docs/kit</0> para leer la documentación\",\n },\n];\n\n// The native <select>'s aria-label. The shadcn select has no text of its own:\n// locale names come from Intl.DisplayNames.\nconst PLAIN_SELECT_ENTRY: Entry = {\n reference: \"src/lib/components/language-select.svelte\",\n msgid: \"Language\",\n msgstr: \"Idioma\",\n};\n\n// What wuchale writes for `es`. It rewrites the file on the first extraction,\n// keeping these translations and adding the source locale's catalog.\nconst HEADER = [\n 'msgid \"\"',\n 'msgstr \"\"',\n '\"Source-Language: en\\\\n\"',\n '\"Language: es\\\\n\"',\n '\"MIME-Version: 1.0\\\\n\"',\n '\"Content-Type: text/plain; charset=utf-8\\\\n\"',\n '\"Content-Transfer-Encoding: 8bit\\\\n\"',\n '\"Plural-Forms: nplurals=3\\\\n\"',\n '\"X-Plurals-Order: one, many, other\\\\n\"',\n].join(\"\\n\");\n\n// Whitespace is ignored so a page prettier has rewrapped still counts.\nconst normalize = (source: string) => source.replace(/\\s+/g, \"\");\n\n/**\n * A Spanish catalog for the `sv create` welcome page, so the language select\n * visibly does something on a fresh project. Anything else in the project is\n * left for the user to translate. Null unless the page is untouched, and never\n * over an existing catalog.\n */\nexport function welcomePageCatalog(root: string, ui: Ui): File | null {\n if (fs.existsSync(path.join(root, CATALOG_PATH))) return null;\n\n const pagePath = path.join(root, PAGE_PATH);\n if (!fs.existsSync(pagePath)) return null;\n const page = fs.readFileSync(pagePath, \"utf8\");\n if (normalize(page) !== normalize(WELCOME_PAGE)) return null;\n\n const entries =\n ui === \"plain\" ? [...PAGE_ENTRIES, PLAIN_SELECT_ENTRY] : PAGE_ENTRIES;\n const blocks = entries.map((entry) =>\n [\n `#: ${entry.reference}`,\n `msgid \"${entry.msgid}\"`,\n `msgstr \"${entry.msgstr}\"`,\n ].join(\"\\n\"),\n );\n\n return {\n path: CATALOG_PATH,\n language: \"text\",\n content: [HEADER, ...blocks].join(\"\\n\\n\") + \"\\n\",\n status: \"success\",\n };\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 { resolveUi } from \"../../../core/field/ui\";\nimport { modifyOutcomeToFile } from \"../../../runtime/modify-file\";\nimport {\n probeFirstExisting,\n VITE_CONFIG_CANDIDATES,\n} from \"../../../runtime/config-target\";\nimport { modifyViteConfig } from \"./modifies/vite-config\";\nimport { modifyPackageImportsI18n } from \"./modifies/package-imports\";\nimport { modifyHooksServerI18n } from \"./modifies/hooks.server\";\nimport { modifyHooksI18n } from \"./modifies/hooks\";\nimport { modifyAppHtml } from \"./modifies/app-html\";\nimport { modifyGitignore } from \"./modifies/gitignore\";\nimport { ensureRootLayoutI18n } from \"./modifies/+layout\";\nimport { modifyRootLayoutLanguageSelect } from \"./modifies/root-layout.svelte\";\nimport { welcomePageCatalog } from \"./welcome-catalog\";\n\nexport async function generate(options: Options) {\n const logger = getLogger(options);\n const modifies: File[] = [];\n\n const pushResult = (file: File | null) => {\n if (file) modifies.push(file);\n };\n\n logger.info(\"Modifying 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, modifyViteConfig(viteConfigPath)),\n );\n\n logger.info(\"Adding #locales to package.json imports\");\n const imports = modifyPackageImportsI18n(options.root);\n pushResult(modifyOutcomeToFile(imports.filePath, imports.outcome));\n\n logger.info(\"Modifying hooks.server.ts\");\n const hooksServerPath = path.join(options.root, \"src\", \"hooks.server.ts\");\n pushResult(\n modifyOutcomeToFile(\n hooksServerPath,\n modifyHooksServerI18n(hooksServerPath),\n ),\n );\n\n logger.info(\"Modifying hooks.ts\");\n const hooksPath = path.join(options.root, \"src\", \"hooks.ts\");\n pushResult(modifyOutcomeToFile(hooksPath, modifyHooksI18n(hooksPath)));\n\n logger.info(\"Modifying app.html\");\n const appHtmlPath = path.join(options.root, \"src\", \"app.html\");\n pushResult(modifyOutcomeToFile(appHtmlPath, modifyAppHtml(appHtmlPath)));\n\n logger.info(\"Modifying root +layout.ts\");\n const layoutPath = path.join(options.root, \"src\", \"routes\", \"+layout.ts\");\n pushResult(modifyOutcomeToFile(layoutPath, ensureRootLayoutI18n(layoutPath)));\n\n logger.info(\"Modifying 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 const ui = resolveUi(options);\n // With no layout at all, a plain project's not-found hint names the\n // +layout.svelte it would have rather than vela's root-layout.svelte.\n const rootLayoutPath =\n rootLayoutCandidates.find((p) => fs.existsSync(p)) ??\n (ui === \"plain\" ? rootLayoutCandidates[3] : rootLayoutCandidates[0]);\n pushResult(\n modifyOutcomeToFile(\n rootLayoutPath,\n modifyRootLayoutLanguageSelect(rootLayoutPath, ui),\n ),\n );\n\n logger.info(\"Updating .gitignore\");\n const gitignorePath = path.join(options.root, \".gitignore\");\n pushResult(\n modifyOutcomeToFile(gitignorePath, modifyGitignore(gitignorePath)),\n );\n\n const catalog = welcomePageCatalog(options.root, ui);\n if (catalog) logger.info(\"Translating the welcome page into Spanish\");\n\n return {\n creates: catalog ? [catalog] : [],\n modifies,\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n } satisfies Result;\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,IAAMA,IAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI,GAELC,IAAiB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;AAEX,SAAgBqB,EAAiB,GAAuC;CACtE,IAAI,CAACJ,EAAG,WAAWK,CAAc,GAC/B,OAAO;EAAE,QAAQ;EAAa,SAAStB;CAAe;CAOxD,IAAMuB,IAAa,IAJCC,EAAQ;EAC1B,iBAAiB,EAAE,SAAS,GAAK;EACjC,sBAA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AAM9B,IAAgBtD,EAAK,KAAKsF,EAAQ,MAAM,YAAY;CAC1D,EACE9F,EAAoB8D,GAAeD,EAAgBC,CAAa,CAAC,CACnE;CAEA,IAAMwC,IAAUf,GAAmBO,EAAQ,MAAMjB,CAAE;CAGnD,OAFIyB,KAASV,EAAO,KAAK,2CAA2C,GAE7D;EACL,SAASU,IAAU,CAACA,CAAO,IAAI,CAAC;EAChC;EACA,SAAS,CAAC;EACV,YAAY,CAAC;EACb,UAAU,CAAC;EACX,aAAa,CAAC;EACd,mBAAmB,CAAC;EACpB,iBAAiB,CAAC;CACpB;AACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./dedent-Gq6Krl4n.js";
|
|
2
|
-
import { t } from "./taggedTemplateLiteral-CswN2AAa.js";
|
|
3
|
-
//#region src/patterns/enable/payments/shopify-page.ts
|
|
4
|
-
var n;
|
|
5
|
-
function r(r) {
|
|
6
|
-
return e(n ||= t(["\n <script lang=\"ts\">\n import BuyButton from '#lib/components/payments/buy-button.svelte';\n <\/script>\n\n <section data-role=\"content\">\n <BuyButton variantId=\"", "\" />\n </section>\n "]), r);
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { r as t };
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=shopify-page-D-VFwGxI.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-page-D-VFwGxI.js","names":["dedent","_templateObject","buyPageSnippet","_taggedTemplateLiteral","variantId"],"sources":["../../src/patterns/enable/payments/shopify-page.ts"],"sourcesContent":["import dedent from \"dedent\";\n\n/** The demo page: one Buy button for the variant named on the command line. */\nexport function buyPageSnippet(variantId: string): string {\n return dedent`\n <script lang=\"ts\">\n import BuyButton from '#lib/components/payments/buy-button.svelte';\n </script>\n\n <section data-role=\"content\">\n <BuyButton variantId=\"${variantId}\" />\n </section>\n `;\n}\n"],"mappings":";;;;AAGA,SAAgBE,EAAe,GAA2B;CACxD,OAAOF,EAAA,AAAAC,MAAAE,EAAA,CAAA,+LAAA,2BAAA,CAAA,GAMqBC,CAE5B;AACF"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { a as e } from "./util-BLYliuUK.js";
|
|
2
|
-
import { n as t } from "./logger-CQONztPm.js";
|
|
3
|
-
import { i as n } from "./pocketbase-CgwbH1gI.js";
|
|
4
|
-
import r from "node:fs";
|
|
5
|
-
import i from "node:path";
|
|
6
|
-
//#region src/runtime/site.ts
|
|
7
|
-
function a(e) {
|
|
8
|
-
return i.join(e, "src", "lib", "site.ts");
|
|
9
|
-
}
|
|
10
|
-
function o(e, t = "http://localhost:5173") {
|
|
11
|
-
return [
|
|
12
|
-
"/**",
|
|
13
|
-
" * Site-wide metadata, and the one place the app's name and public URL live.",
|
|
14
|
-
" *",
|
|
15
|
-
" * Set `url` to where the site is deployed: canonical links, Open Graph images",
|
|
16
|
-
" * and feeds are built from it, including in prerendered pages. With a backend,",
|
|
17
|
-
" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name",
|
|
18
|
-
" * for the emails it sends, so change it here rather than in the admin panel.",
|
|
19
|
-
" */",
|
|
20
|
-
"export const site = {",
|
|
21
|
-
`\tname: ${s(e)},`,
|
|
22
|
-
`\turl: ${s(t)}`,
|
|
23
|
-
"};",
|
|
24
|
-
""
|
|
25
|
-
].join("\n");
|
|
26
|
-
}
|
|
27
|
-
function s(e) {
|
|
28
|
-
return `'${e.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
29
|
-
}
|
|
30
|
-
async function c(e) {
|
|
31
|
-
if (e.features.backend) try {
|
|
32
|
-
let t;
|
|
33
|
-
if (await n(e.root, async (e) => {
|
|
34
|
-
t = (await e.settings.getAll()).meta?.appName;
|
|
35
|
-
}), typeof t == "string" && t.trim()) return t;
|
|
36
|
-
} catch {}
|
|
37
|
-
try {
|
|
38
|
-
let t = JSON.parse(r.readFileSync(i.join(e.root, "package.json"), "utf8"));
|
|
39
|
-
if (typeof t.name == "string" && t.name.trim()) return t.name;
|
|
40
|
-
} catch {}
|
|
41
|
-
return "My App";
|
|
42
|
-
}
|
|
43
|
-
async function l(n) {
|
|
44
|
-
let i = a(n.root);
|
|
45
|
-
return r.existsSync(i) ? null : (t(n).info("Creating src/lib/site.ts"), {
|
|
46
|
-
path: i,
|
|
47
|
-
language: e(i),
|
|
48
|
-
content: o(await c(n)),
|
|
49
|
-
status: "success"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
export { l as t };
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=site-lj0CDdQ1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"site-lj0CDdQ1.js","names":["languageFromPath","getLogger","withPocketbase","fs","path","sitePath","root","siteModule","quote","name","url","value","existingName","options","appName","pb","pkg","ensureSiteFile","file"],"sources":["../../src/runtime/site.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { File, Options } from \"../core/types\";\nimport { getLogger } from \"../core/logger\";\nimport { languageFromPath } from \"../core/util\";\nimport { withPocketbase } from \"./pocketbase\";\n\n/** Where every VelaStack app keeps its name and public URL. */\nexport function sitePath(root: string): string {\n return path.join(root, \"src\", \"lib\", \"site.ts\");\n}\n\n/**\n * `src/lib/site.ts` as the CLI templates ship it (`site.template.ts`), with\n * the placeholders filled in.\n */\nexport function siteModule(\n name: string,\n url = \"http://localhost:5173\",\n): string {\n return [\n \"/**\",\n \" * Site-wide metadata, and the one place the app's name and public URL live.\",\n \" *\",\n \" * Set `url` to where the site is deployed: canonical links, Open Graph images\",\n \" * and feeds are built from it, including in prerendered pages. With a backend,\",\n \" * `vela dev` and `vela deploy` copy `name` into PocketBase's application name\",\n \" * for the emails it sends, so change it here rather than in the admin panel.\",\n \" */\",\n \"export const site = {\",\n `\\tname: ${quote(name)},`,\n `\\turl: ${quote(url)}`,\n \"};\",\n \"\",\n ].join(\"\\n\");\n}\n\n/** Single-quoted, as the templates write their strings. */\nfunction quote(value: string): string {\n return `'${value.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")}'`;\n}\n\n/**\n * The name a project created before `site.ts` existed already goes by.\n *\n * Those projects kept it in PocketBase's settings, so that is asked first; the\n * package name is the fallback for a project without a backend, or one whose\n * database can't be reached.\n */\nasync function existingName(options: Options): Promise<string> {\n if (options.features.backend) {\n try {\n let appName: unknown;\n await withPocketbase(options.root, async (pb) => {\n const settings = (await pb.settings.getAll()) as {\n meta?: { appName?: unknown };\n };\n appName = settings.meta?.appName;\n });\n if (typeof appName === \"string\" && appName.trim()) return appName;\n } catch {\n // No database to ask; fall through to package.json.\n }\n }\n\n try {\n const pkg = JSON.parse(\n fs.readFileSync(path.join(options.root, \"package.json\"), \"utf8\"),\n ) as { name?: unknown };\n if (typeof pkg.name === \"string\" && pkg.name.trim()) return pkg.name;\n } catch {\n // No package.json to name the site after; the placeholder stands.\n }\n return \"My App\";\n}\n\n/**\n * Create `src/lib/site.ts` for a pattern whose files import `#lib/site.js`, when\n * the project doesn't have one yet. Every template ships it; projects created\n * before that read the app name from `locals.meta` instead.\n *\n * Returns null when the file exists, so an existing one is never overwritten.\n */\nexport async function ensureSiteFile(options: Options): Promise<File | null> {\n const file = sitePath(options.root);\n if (fs.existsSync(file)) return null;\n\n getLogger(options).info(\"Creating src/lib/site.ts\");\n return {\n path: file,\n language: languageFromPath(file),\n content: siteModule(await existingName(options)),\n status: \"success\",\n };\n}\n"],"mappings":";;;;;;AAQA,SAAgBK,EAAS,GAAsB;CAC7C,OAAOD,EAAK,KAAKE,GAAM,OAAO,OAAO,SAAS;AAChD;AAMA,SAAgBC,EACd,GACA,IAAM,yBACE;CACR,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAWC,EAAMC,CAAI,EAAE;EACvB,UAAUD,EAAME,CAAG;EACnB;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;AAGA,SAASF,EAAM,GAAuB;CACpC,OAAO,IAAIG,EAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,KAAK,EAAE;AAC/D;AASA,eAAeC,EAAa,GAAmC;CAC7D,IAAIC,EAAQ,SAAS,SACnB,IAAI;EACF,IAAIC;EAOJ,IANA,MAAMZ,EAAeW,EAAQ,MAAM,OAAO,MAAO;GAI/C,KAAU,MAHcE,EAAG,SAAS,OAAO,EAAA,CAGxB,MAAM;EAC3B,CAAC,GACG,OAAOD,KAAY,YAAYA,EAAQ,KAAK,GAAG,OAAOA;CAC5D,QAAQ,CAER;CAGF,IAAI;EACF,IAAME,IAAM,KAAK,MACfb,EAAG,aAAaC,EAAK,KAAKS,EAAQ,MAAM,cAAc,GAAG,MAAM,CACjE;EACA,IAAI,OAAOG,EAAI,QAAS,YAAYA,EAAI,KAAK,KAAK,GAAG,OAAOA,EAAI;CAClE,QAAQ,CAER;CACA,OAAO;AACT;AASA,eAAsBC,EAAe,GAAwC;CAC3E,IAAMC,IAAOb,EAASQ,EAAQ,IAAI;CAIlC,OAHIV,EAAG,WAAWe,CAAI,IAAU,QAEhCjB,EAAUY,CAAO,CAAC,CAAC,KAAK,0BAA0B,GAC3C;EACL,MAAMK;EACN,UAAUlB,EAAiBkB,CAAI;EAC/B,SAASX,EAAW,MAAMK,EAAaC,CAAO,CAAC;EAC/C,QAAQ;CACV;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write-result-Cq-9A7Zy.js","names":["__import_glob__0_0_","__import_glob__0_1_","__import_glob__0_2_","__import_glob__0_3_","__import_glob__0_4_","__import_glob__0_5_","__import_glob__0_6_","__import_glob__0_7_","__import_glob__0_8_","__import_glob__0_9_","__import_glob__0_10_","__import_glob__0_11_","__import_glob__0_12_","__import_glob__0_13_","__import_glob__0_14_","__import_glob__0_15_","__import_glob__0_16_","__import_glob__0_17_","__import_glob__0_18_","__import_glob__0_19_","__import_glob__0_20_","__import_glob__0_21_","__import_glob__0_22_","__import_glob__0_23_","__import_glob__0_24_","__import_glob__0_25_","__import_glob__0_26_","__import_glob__0_27_","__import_glob__0_28_","__import_glob__0_29_","__import_glob__0_30_","__import_glob__0_31_","__import_glob__0_32_","__import_glob__0_33_","__import_glob__0_34_","__import_glob__0_35_","__import_glob__0_36_","__import_glob__0_37_","__import_glob__0_38_","__import_glob__0_39_","__import_glob__0_40_","__import_glob__0_41_","__import_glob__0_42_","__import_glob__0_43_","__import_glob__0_44_","__import_glob__0_45_","__import_glob__0_46_","__import_glob__0_47_","__import_glob__0_48_","__import_glob__0_49_","__import_glob__0_50_","__import_glob__0_51_","__import_glob__0_52_","__import_glob__0_53_","__import_glob__0_54_","__import_glob__0_55_","__exportAll","MissingShadcnError","RegistryUnavailableError","InvalidArgumentError","FORMSNAP","TANSTACK_TABLE_CORE","FORMSNAP_OVERRIDES","formatSource","getLogger","NOOP_LOGGER","resolveUiDir","readComponentsConfig","fetchRegistryIndex","assertTableCorePackage","ensurePackageOverrides","path","spawn","os","auth_menu_content_default","auth_menu_group_default","auth_menu_item_default","auth_menu_label_default","auth_menu_separator_default","auth_menu_trigger_default","auth_menu_default$1","context_default","auth_menu_default","autodate_default","bool_default","date_default","editor_default","email_default","file_default","geoPoint_default","cells_default","json_default","number_default","password_default","relation_default","select_default","text_default","url_default","column_header_default$1","column_header_default","data_table_svelte_default","flex_render_default","data_table_default","render_helpers_default","faceted_filter_default$1","faceted_filter_default","file_field_default","file_input_default","file_multiple_default","file_single_default","file_thumb_default","file_form_default","shared_default","coordinate_default","geopoint_default","input_default$1","toggle_map_default","leaflet_default$1","leaflet_default","chip_default","content_default","field_default","multiselect_default","input_default","item_default","trigger_default","pagination_default$1","pagination_default","row_actions_default$1","row_actions_default","write_result_exports","ensureSvelteKitSync","executeCommand","formatPaths","getAllCustomComponents","installComponents","installedComponents","installedPackagesFromProject","isCustomComponent","isExactSpec","packageName","restoreDowngradedDependencies","writeResult","customDependencies","customNpmPackages","customComponentAssets","componentNameFromAssetPath","parts","assetPath","componentRelativeAssetPath","index","toTargetPath","filePath","root","toRelativePath","writeFile","mkdirSync","writeFileSync","content","removeFile","existsSync","rmSync","pruneEmptyDirectories","stop","current","dir","readdirSync","EXACT_FLAG","executeWithDetectedPackageManager","packageManager","detect","resolved","resolveCommand","operation","args","commandArgs","exactFlag","options","child","reject","code","restoreTypes","preserveSvelteKitTypes","cwd","runtime","packageJsonPath","packageJson","readFileSync","at","spec","name","ensureFormsnapOverride","names","toInstall","formsnap","installed","touched","outcome","logger","appDir","saved","mkdtempSync","cpSync","error","DEPENDENCY_BLOCKS","rangeFloor","match","part","value","compareFloors","i","a","b","pkg","after","restored","previous","block","before","entries","old","oldFloor","newFloor","readPackageJson","file","installPackages","packages","exact","ranged","uninstallPackages","toRemove","component","customNpmPackagesFor","components","copyCustomComponent","targetDir","targetComponentsDir","relativePath","outputPath","FORMATTABLE_EXTENSIONS","filesUnder","target","statSync","entry","context","changed","paths","formatted","uiDir","BARE_ITEM_NAME","assertKnownRegistryItems","bare","known","item","unknown","style","requested","componentsDir","isPresent","skipped","overwrite","customToInstall","publicToInstall","dependency","customList","publicList","indent","recorded","had","installedList","writtenResult","dropMigrationCreates","result","n","dropCollections","isPackageJson","packageInstalls","componentInstalls","packageUninstalls"],"sources":["../../src/runtime/write-result.ts"],"sourcesContent":["import {\n cpSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { detect } from \"package-manager-detector\";\nimport { resolveCommand } from \"package-manager-detector/commands\";\nimport spawn from \"cross-spawn\";\nimport type {\n Component,\n ExecuteCommandOptions,\n InstallComponentsOptions,\n InstallComponentsResult,\n Options,\n PackageManagerOperation,\n Result,\n WriteResultRuntime,\n} from \"../core/types\";\nimport {\n InvalidArgumentError,\n MissingShadcnError,\n RegistryUnavailableError,\n} from \"../core/errors\";\nimport { getLogger, NOOP_LOGGER, type Logger } from \"../core/logger\";\nimport { formatSource } from \"../core/format-result\";\nimport {\n FORMSNAP,\n FORMSNAP_OVERRIDES,\n TANSTACK_TABLE_CORE,\n} from \"../core/constants\";\nimport {\n fetchRegistryIndex,\n readComponentsConfig,\n resolveUiDir,\n} from \"./registry\";\nimport { assertTableCorePackage } from \"./table-core\";\nimport { ensurePackageOverrides } from \"./package-imports\";\n\nexport { resolveUiDir };\n\ntype CustomNpmPackages = Record<string, string[]>;\n\n/**\n * The components under `src/ui/components` are copied into a project rather\n * than fetched from the shadcn-svelte registry, so their dependencies have to\n * be declared here: every shadcn-svelte component a bundled one imports\n * (`#lib/components/ui/<x>/index.js`) must appear in `customDependencies`, and\n * every npm package that no shadcn item installs for it must appear in\n * `customNpmPackages`.\n */\nconst customDependencies: Record<string, string[]> = {\n \"file-form\": [\"input\"],\n multiselect: [\"command\", \"popover\", \"button\"],\n geopoint: [\"button\", \"leaflet\"],\n cells: [\"badge\"],\n \"data-table\": [],\n \"column-header\": [\"dropdown-menu\", \"button\"],\n \"faceted-filter\": [\"command\", \"popover\", \"button\", \"separator\", \"badge\"],\n pagination: [\"button\", \"select\"],\n \"row-actions\": [\"dropdown-menu\", \"button\"],\n leaflet: [],\n \"auth-menu\": [\"dropdown-menu\", \"button\"],\n};\n\nconst customNpmPackages: CustomNpmPackages = {\n \"file-form\": [FORMSNAP],\n multiselect: [FORMSNAP],\n geopoint: [],\n cells: [],\n // shadcn-svelte >= 1.2.0 resolves items from the style-scoped registry\n // (/registry/styles/<style>/), which has no `data-table` item, so the\n // TanStack helpers ship from here instead.\n \"data-table\": [TANSTACK_TABLE_CORE],\n \"column-header\": [TANSTACK_TABLE_CORE],\n \"faceted-filter\": [TANSTACK_TABLE_CORE],\n pagination: [TANSTACK_TABLE_CORE],\n \"row-actions\": [],\n leaflet: [\"leaflet\", \"@types/leaflet\"],\n};\n\nconst customComponentAssets = import.meta.glob<string>(\"../ui/components/**\", {\n query: \"?raw\",\n import: \"default\",\n eager: true,\n});\n\n/** The components this package ships, by directory name, sorted. */\nexport function getAllCustomComponents(): Component[] {\n return [\n ...new Set(\n Object.keys(customComponentAssets).map(componentNameFromAssetPath),\n ),\n ]\n .filter(Boolean)\n .sort();\n}\n\nfunction componentNameFromAssetPath(assetPath: string): string {\n const parts = assetPath.split(\"/\");\n const index = parts.indexOf(\"components\");\n return parts[index + 1] ?? \"\";\n}\n\nfunction componentRelativeAssetPath(assetPath: string): string {\n const parts = assetPath.split(\"/\");\n const index = parts.indexOf(\"components\");\n return parts.slice(index + 2).join(\"/\");\n}\n\nfunction toTargetPath(root: string, filePath: string): string {\n if (path.isAbsolute(filePath)) {\n return filePath;\n }\n return path.join(root, filePath);\n}\n\nfunction toRelativePath(root: string, filePath: string): string {\n if (path.isAbsolute(filePath)) {\n return path.relative(root, filePath);\n }\n return filePath;\n}\n\nfunction writeFile(filePath: string, content: string): void {\n mkdirSync(path.dirname(filePath), { recursive: true });\n writeFileSync(filePath, content, \"utf8\");\n}\n\nfunction removeFile(filePath: string, root: string): void {\n if (!existsSync(filePath)) {\n return;\n }\n\n rmSync(filePath, { force: true, recursive: true });\n pruneEmptyDirectories(path.dirname(filePath), root);\n}\n\n/**\n * Deleting a feature's files must also delete the directories it added, up\n * to the first one that still has content. The CLI detects features by\n * directory (`src/routes/(app)` means auth is on), so an empty leftover\n * directory keeps a disabled feature \"enabled\".\n */\nfunction pruneEmptyDirectories(dir: string, root: string): void {\n const stop = path.resolve(root);\n let current = path.resolve(dir);\n while (current !== stop && current.startsWith(stop)) {\n if (!existsSync(current) || readdirSync(current).length > 0) {\n return;\n }\n rmSync(current, { recursive: true, force: true });\n current = path.dirname(current);\n }\n}\n\n/** Each package manager's flag for saving the exact version instead of a range. */\nconst EXACT_FLAG: Record<string, string> = {\n npm: \"--save-exact\",\n pnpm: \"--save-exact\",\n yarn: \"--exact\",\n bun: \"--exact\",\n};\n\nasync function executeWithDetectedPackageManager(\n cwd: string,\n operation: PackageManagerOperation,\n args: string[],\n options: ExecuteCommandOptions = {},\n): Promise<void> {\n const packageManager = (await detect({ cwd }))?.name ?? \"npm\";\n // Adding named packages is `add` (`npm i`, `pnpm add`, `yarn add`):\n // `yarn install <pkg>` is an error.\n const resolved = resolveCommand(\n packageManager,\n operation === \"install\" && args.length > 0 ? \"add\" : operation,\n args,\n );\n if (!resolved) {\n throw new Error(\n `Unable to resolve ${operation} command for ${packageManager}`,\n );\n }\n\n const commandArgs = [...resolved.args];\n if (packageManager === \"npm\") {\n commandArgs.unshift(\"--yes\");\n }\n const exactFlag = EXACT_FLAG[packageManager];\n if (options.exact && exactFlag) {\n commandArgs.push(exactFlag);\n }\n\n await new Promise<void>((resolve, reject) => {\n const child = spawn(resolved.command, commandArgs, {\n cwd,\n stdio: \"inherit\",\n });\n child.on(\"error\", reject);\n child.on(\"exit\", (code) => {\n if (code === 0) {\n resolve();\n return;\n }\n reject(\n new Error(`${resolved.command} exited with code ${code ?? \"unknown\"}`),\n );\n });\n });\n}\n\nexport async function executeCommand(\n cwd: string,\n operation: PackageManagerOperation,\n args: string[],\n runtime?: WriteResultRuntime,\n options?: ExecuteCommandOptions,\n): Promise<void> {\n const restoreTypes =\n operation === \"execute\" ? null : preserveSvelteKitTypes(cwd);\n try {\n if (runtime?.executeCommand) {\n await (options\n ? runtime.executeCommand(cwd, operation, args, options)\n : runtime.executeCommand(cwd, operation, args));\n return;\n }\n\n await executeWithDetectedPackageManager(cwd, operation, args, options);\n } finally {\n restoreTypes?.();\n }\n}\n\n/** Package names `package.json` records, whichever dependency block they sit in. */\nexport function installedPackagesFromProject(root: string): Set<string> {\n const packageJsonPath = path.join(root, \"package.json\");\n if (!existsSync(packageJsonPath)) {\n return new Set();\n }\n\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n };\n\n return new Set([\n ...Object.keys(packageJson.dependencies ?? {}),\n ...Object.keys(packageJson.devDependencies ?? {}),\n ...Object.keys(packageJson.optionalDependencies ?? {}),\n ...Object.keys(packageJson.peerDependencies ?? {}),\n ]);\n}\n\n/**\n * Splits an npm install spec into its package name, dropping any range.\n * `wuchale@^0.26.3` -> `wuchale`, `@wuchale/svelte@^0.21.1` -> `@wuchale/svelte`.\n *\n * The name is what `package.json` records, so it -- not the full spec -- is what\n * the already-installed check has to compare against.\n */\nexport function packageName(spec: string): string {\n const at = spec.indexOf(\"@\", spec.startsWith(\"@\") ? 1 : 0);\n return at === -1 ? spec : spec.slice(0, at);\n}\n\n/**\n * A spec naming one exact version (`sveltekit-superforms@3.0.0-next.1`),\n * which is saved as written. Package managers otherwise save a caret, and a\n * caret on a prerelease follows every later `next` build.\n */\nexport function isExactSpec(spec: string): boolean {\n const name = packageName(spec);\n return /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(\n spec.slice(name.length + 1),\n );\n}\n\n/**\n * formsnap 2 peers superforms ^2 and projects run superforms 3, so the\n * override has to be in package.json before an install that brings either in\n * next to formsnap, or npm stops with ERESOLVE.\n */\nfunction ensureFormsnapOverride(\n root: string,\n installed: Set<string>,\n toInstall: string[],\n logger: Logger,\n): void {\n const names = new Set(toInstall.map(packageName));\n const formsnap = names.has(\"formsnap\") || installed.has(\"formsnap\");\n const touched = names.has(\"formsnap\") || names.has(\"sveltekit-superforms\");\n if (!formsnap || !touched) {\n return;\n }\n const { outcome } = ensurePackageOverrides(root, FORMSNAP_OVERRIDES);\n if (outcome.status === \"failed\") {\n logger.info(outcome.message);\n } else if (outcome.status === \"success\" && outcome.changed) {\n logger.info(\"Added the formsnap override for sveltekit-superforms\");\n }\n}\n\n/**\n * SvelteKit 3's tsconfig extends `$app/tsconfig`, which `svelte-kit sync`\n * writes to `node_modules/$app`. A package-manager install prunes that folder\n * (it is no package) and only an argument-less npm install's `prepare` writes\n * it back, so after `npm install <pkg>` every tool that reads the tsconfig\n * (shadcn-svelte, svelte-check without sync, the editor) fails on the missing\n * `extends`. Syncing again is no fix mid-pattern: it loads vite.config, which\n * may already name a plugin whose own config the pattern has not written yet.\n * So the folder is copied aside before an install and put back after.\n */\nfunction preserveSvelteKitTypes(root: string): (() => void) | null {\n const appDir = path.join(root, \"node_modules\", \"$app\");\n if (!existsSync(appDir)) {\n return null;\n }\n const saved = mkdtempSync(path.join(os.tmpdir(), \"vela-app-types-\"));\n cpSync(appDir, path.join(saved, \"$app\"), { recursive: true });\n return () => {\n try {\n if (!existsSync(appDir) && existsSync(path.join(root, \"node_modules\"))) {\n cpSync(path.join(saved, \"$app\"), appDir, { recursive: true });\n }\n } finally {\n rmSync(saved, { recursive: true, force: true });\n }\n };\n}\n\n/**\n * Run `svelte-kit sync` when SvelteKit is installed but `node_modules/$app`\n * is missing (a fresh copy of `node_modules`, or an install made outside\n * vela), so shadcn-svelte can read the tsconfig. Best effort: a sync that\n * fails is reported and left to shadcn-svelte to complain about.\n */\nexport async function ensureSvelteKitSync(\n root: string,\n runtime?: WriteResultRuntime,\n logger: Logger = NOOP_LOGGER,\n): Promise<boolean> {\n if (!existsSync(path.join(root, \"node_modules\", \"@sveltejs\", \"kit\"))) {\n return false;\n }\n if (existsSync(path.join(root, \"node_modules\", \"$app\", \"tsconfig.json\"))) {\n return false;\n }\n try {\n await executeCommand(root, \"execute\", [\"svelte-kit\", \"sync\"], runtime);\n return true;\n } catch (error) {\n logger.info(\n `svelte-kit sync failed (${error instanceof Error ? error.message : String(error)}); node_modules/$app is missing`,\n );\n return false;\n }\n}\n\ntype DependencyBlocks = Record<string, Record<string, string> | undefined>;\n\nconst DEPENDENCY_BLOCKS = [\n \"dependencies\",\n \"devDependencies\",\n \"optionalDependencies\",\n] as const;\n\n/** The lowest version a range names, as numbers, or null when it is no semver range. */\nfunction rangeFloor(spec: string): number[] | null {\n const match = spec\n .trim()\n .match(\n /^(?:[\\^~=v]|>=?)?\\s*(\\d+)(?:\\.(\\d+|[xX*]))?(?:\\.(\\d+|[xX*]))?(-[0-9A-Za-z.-]+)?$/,\n );\n if (!match) {\n return null;\n }\n const part = (value: string | undefined) =>\n value === undefined || /[xX*]/.test(value) ? 0 : Number(value);\n // A prerelease sorts below its release.\n return [part(match[1]), part(match[2]), part(match[3]), match[4] ? 0 : 1];\n}\n\nfunction compareFloors(a: number[], b: number[]): number {\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return a[i]! - b[i]!;\n }\n }\n return 0;\n}\n\n/**\n * The dependency entries `shadcn-svelte add` changed that have to go back:\n * shadcn replaces any range its registry item's own range does not cover,\n * downgrades included. The form item still asks for `sveltekit-superforms`\n * ^2, which SvelteKit 3 cannot install, over the project's 3.x pin. So an\n * entry the project already had is restored when shadcn moved it below\n * where it was, or when it is not a semver range at all (file:, git,\n * workspace:). A raised floor and every new entry are kept.\n */\nexport function restoreDowngradedDependencies(\n before: DependencyBlocks,\n after: DependencyBlocks,\n): { pkg: DependencyBlocks; restored: string[] } {\n const pkg: DependencyBlocks = { ...after };\n const restored: string[] = [];\n const previous = new Map<string, string>();\n for (const block of DEPENDENCY_BLOCKS) {\n for (const [name, spec] of Object.entries(before[block] ?? {})) {\n previous.set(name, spec);\n }\n }\n for (const block of DEPENDENCY_BLOCKS) {\n const entries = after[block];\n if (!entries) {\n continue;\n }\n for (const [name, spec] of Object.entries(entries)) {\n const old = previous.get(name);\n if (old === undefined || old === spec) {\n continue;\n }\n const oldFloor = rangeFloor(old);\n const newFloor = rangeFloor(spec);\n const keep =\n oldFloor !== null &&\n newFloor !== null &&\n compareFloors(newFloor, oldFloor) >= 0;\n if (keep) {\n continue;\n }\n pkg[block] = { ...(pkg[block] as Record<string, string>), [name]: old };\n restored.push(`${name}@${old}`);\n }\n }\n return { pkg, restored };\n}\n\nfunction readPackageJson(root: string): Record<string, unknown> | null {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) {\n return null;\n }\n return JSON.parse(readFileSync(file, \"utf8\")) as Record<string, unknown>;\n}\n\nasync function installPackages(\n root: string,\n packages: string[],\n runtime?: WriteResultRuntime,\n logger: Logger = NOOP_LOGGER,\n): Promise<string[]> {\n if (packages.length === 0) {\n return [];\n }\n\n const installed = installedPackagesFromProject(root);\n const toInstall = [...new Set(packages)].filter(\n (pkg) => !installed.has(packageName(pkg)),\n );\n if (toInstall.length === 0) {\n return [];\n }\n\n ensureFormsnapOverride(root, installed, toInstall, logger);\n\n logger.info(`Installing packages: ${toInstall.join(\", \")}`);\n // `--save-exact` applies to a whole command, so exact pins go in their own.\n const exact = toInstall.filter(isExactSpec);\n const ranged = toInstall.filter((spec) => !isExactSpec(spec));\n if (exact.length > 0) {\n await executeCommand(root, \"install\", exact, runtime, { exact: true });\n }\n if (ranged.length > 0) {\n await executeCommand(root, \"install\", ranged, runtime);\n }\n return toInstall;\n}\n\n/**\n * `npm uninstall` for the listed packages that `package.json` records. The\n * inverse of `installPackages`: names not present are skipped, so a disable\n * pattern can name everything its enable counterpart installed.\n */\nasync function uninstallPackages(\n root: string,\n packages: string[],\n runtime?: WriteResultRuntime,\n logger: Logger = NOOP_LOGGER,\n): Promise<string[]> {\n if (packages.length === 0) {\n return [];\n }\n\n const installed = installedPackagesFromProject(root);\n const toRemove = [...new Set(packages.map(packageName))].filter((pkg) =>\n installed.has(pkg),\n );\n if (toRemove.length === 0) {\n return [];\n }\n\n logger.info(`Removing packages: ${toRemove.join(\", \")}`);\n await executeCommand(root, \"uninstall\", toRemove, runtime);\n return toRemove;\n}\n\nexport function isCustomComponent(component: string): boolean {\n return getAllCustomComponents().includes(component);\n}\n\nfunction customNpmPackagesFor(components: string[]): string[] {\n return [\n ...new Set(\n components.flatMap((component) => customNpmPackages[component] ?? []),\n ),\n ];\n}\n\nfunction copyCustomComponent(\n component: string,\n targetComponentsDir: string,\n): void {\n const targetDir = path.join(targetComponentsDir, component);\n mkdirSync(targetDir, { recursive: true });\n\n for (const [assetPath, content] of Object.entries(customComponentAssets)) {\n if (componentNameFromAssetPath(assetPath) !== component) {\n continue;\n }\n const relativePath = componentRelativeAssetPath(assetPath);\n if (!relativePath) {\n continue;\n }\n\n const outputPath = path.join(targetDir, relativePath);\n mkdirSync(path.dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, content, \"utf8\");\n }\n}\n\nconst FORMATTABLE_EXTENSIONS = new Set([\n \".ts\",\n \".js\",\n \".svelte\",\n \".json\",\n \".css\",\n]);\n\nfunction* filesUnder(target: string): Generator<string> {\n if (!existsSync(target)) {\n return;\n }\n if (statSync(target).isFile()) {\n yield target;\n return;\n }\n const entries = readdirSync(target, { recursive: true, withFileTypes: true });\n for (const entry of entries) {\n if (entry.isFile()) {\n yield path.join(entry.parentPath, entry.name);\n }\n }\n}\n\n/**\n * `shadcn-svelte add` and `apply` write files in the registry's style and the\n * bundled components carry this repo's; the project's `npm run lint` expects\n * its own. Runs the project's prettier over the given files and directories\n * (relative to the root or absolute) and returns the relative paths it\n * changed. Paths that do not exist are skipped.\n */\nexport async function formatPaths(\n root: string,\n paths: string[],\n): Promise<string[]> {\n const context = { env: \"runtime\" as const, root };\n const changed: string[] = [];\n for (const target of paths) {\n for (const filePath of filesUnder(toTargetPath(root, target))) {\n if (!FORMATTABLE_EXTENSIONS.has(path.extname(filePath))) {\n continue;\n }\n const content = readFileSync(filePath, \"utf8\");\n const formatted = await formatSource(content, filePath, context);\n if (formatted !== content) {\n writeFileSync(filePath, formatted, \"utf8\");\n changed.push(path.relative(root, filePath));\n }\n }\n }\n return changed;\n}\n\n/** The component directories a project has, sorted. */\nexport function installedComponents(root: string): Component[] {\n const uiDir = resolveUiDir(root);\n if (!existsSync(uiDir)) {\n return [];\n }\n return readdirSync(uiDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n}\n\n/** Bare item names are checked against the index; URLs and `@scope/item` are shadcn's to resolve. */\nconst BARE_ITEM_NAME = /^[a-z0-9][a-z0-9-]*$/i;\n\n/**\n * A name the style's registry does not list would otherwise reach\n * `shadcn-svelte add`, which fails after a fetch with a message that never\n * mentions the style. Skipped when the registry cannot be read: shadcn will\n * report that itself.\n */\nasync function assertKnownRegistryItems(\n root: string,\n components: Component[],\n runtime: WriteResultRuntime | undefined,\n logger: Logger,\n): Promise<void> {\n const bare = components.filter((component) => BARE_ITEM_NAME.test(component));\n if (bare.length === 0) {\n return;\n }\n let known: Set<string>;\n try {\n const index = await fetchRegistryIndex(root, { runtime });\n known = new Set(index.map((item) => item.name));\n } catch (error) {\n if (!(error instanceof RegistryUnavailableError)) throw error;\n logger.info(`${error.message}; leaving component names to shadcn-svelte`);\n return;\n }\n const unknown = bare.filter((component) => !known.has(component));\n if (unknown.length === 0) {\n return;\n }\n const { style } = readComponentsConfig(root);\n const names = unknown.map((component) => `\"${component}\"`).join(\", \");\n throw new InvalidArgumentError(\n `Unknown component${unknown.length > 1 ? \"s\" : \"\"} ${names} for style ${style}. Run \\`vela ui list\\` to see what is available.`,\n );\n}\n\nexport async function installComponents(\n options: InstallComponentsOptions,\n runtime?: WriteResultRuntime,\n): Promise<InstallComponentsResult> {\n const { root, components, overwrite = false } = options;\n const logger = getLogger(options);\n\n const requested = [...new Set(components)];\n if (requested.length === 0) {\n return { installed: [], skipped: [], packages: [] };\n }\n\n // `shadcn-svelte add` exits 1 without a `components.json`, after the custom\n // components and their packages are already in. Checked first, so a project\n // without shadcn-svelte is refused whole rather than left half-written.\n if (!existsSync(path.join(root, \"components.json\"))) {\n throw new MissingShadcnError(\n `Adding ${requested.length > 1 ? \"components\" : \"a component\"} (${requested.join(\", \")})`,\n );\n }\n\n const componentsDir = resolveUiDir(root);\n mkdirSync(componentsDir, { recursive: true });\n const isPresent = (component: string) =>\n existsSync(path.join(componentsDir, component));\n\n const skipped = overwrite ? [] : requested.filter(isPresent);\n const toInstall = requested.filter(\n (component) => !skipped.includes(component),\n );\n if (skipped.length > 0) {\n logger.info(`Already present: ${skipped.join(\", \")}`);\n }\n if (toInstall.length === 0) {\n return { installed: [], skipped, packages: [] };\n }\n\n const customToInstall = new Set(toInstall.filter(isCustomComponent));\n const publicToInstall = new Set(\n toInstall.filter((component) => !isCustomComponent(component)),\n );\n\n // Dependencies are added only when missing, even under `overwrite`:\n // re-adding `button` because `pagination` was re-added would clobber edits\n // the user never asked to lose.\n for (const component of [...customToInstall]) {\n for (const dependency of customDependencies[component] ?? []) {\n if (isPresent(dependency)) {\n continue;\n }\n if (isCustomComponent(dependency)) {\n customToInstall.add(dependency);\n } else {\n publicToInstall.add(dependency);\n }\n }\n }\n\n // `installPackages` keeps an existing @tanstack/table-core whatever its range.\n assertTableCorePackage(root, [...customToInstall]);\n\n const installed: string[] = [];\n const customList = [...customToInstall].sort();\n if (customList.length > 0) {\n logger.info(`Installing custom components: ${customList.join(\", \")}`);\n }\n for (const component of customList) {\n copyCustomComponent(component, componentsDir);\n installed.push(component);\n publicToInstall.delete(component);\n }\n\n const packages = await installPackages(\n root,\n customNpmPackagesFor(customList),\n runtime,\n logger,\n );\n\n const publicList = [...publicToInstall].sort();\n if (publicList.length > 0) {\n await assertKnownRegistryItems(root, publicList, runtime, logger);\n logger.info(\n `Installing shadcn-svelte components: ${publicList.join(\", \")}`,\n );\n // shadcn-svelte reads the tsconfig, whose `extends` an install may have pruned.\n await ensureSvelteKitSync(root, runtime, logger);\n // shadcn only records its packages; they are installed below, once any\n // pin it moved backwards is put back.\n const before = readPackageJson(root);\n await executeCommand(\n root,\n \"execute\",\n [\n \"shadcn-svelte\",\n \"add\",\n \"--yes\",\n \"--overwrite\",\n \"--no-deps-install\",\n ...publicList,\n ],\n runtime,\n );\n installed.push(...publicList);\n const after = readPackageJson(root);\n if (before && after && JSON.stringify(before) !== JSON.stringify(after)) {\n const { pkg, restored } = restoreDowngradedDependencies(\n before as DependencyBlocks,\n after as DependencyBlocks,\n );\n if (restored.length > 0) {\n logger.info(\n `Kept ${restored.join(\", \")} (shadcn-svelte asked for an older range)`,\n );\n const file = path.join(root, \"package.json\");\n const indent =\n readFileSync(file, \"utf8\").match(/^[{]\\s*\\n([\\t ]+)/)?.[1] ?? \"\\t\";\n writeFileSync(file, `${JSON.stringify(pkg, null, indent)}\\n`, \"utf8\");\n }\n const recorded = (pkg: Record<string, unknown>) =>\n new Set(\n DEPENDENCY_BLOCKS.flatMap((block) =>\n Object.keys((pkg[block] as Record<string, string>) ?? {}),\n ),\n );\n const had = recorded(before);\n const added = [...recorded(after)].filter((name) => !had.has(name));\n ensureFormsnapOverride(root, had, added, logger);\n await executeCommand(root, \"install\", [], runtime);\n }\n }\n\n const installedList = [...new Set(installed)].sort();\n await formatPaths(\n root,\n installedList.map((component) => path.join(componentsDir, component)),\n );\n\n return { installed: installedList, skipped, packages };\n}\n\nexport async function writeResult(\n result: Result,\n options: Options,\n runtime?: WriteResultRuntime,\n): Promise<Result> {\n const logger = getLogger(options);\n\n const writtenResult: Result = {\n creates: [],\n modifies: [],\n deletes: [],\n components: [],\n packages: [],\n collections: [],\n collectionPatches: [],\n collectionDrops: [],\n };\n\n let dropMigrationCreates: Result[\"creates\"] = [];\n if (result.collectionDrops.length > 0) {\n const { dropCollections } = await import(\"./collections\");\n dropMigrationCreates = await dropCollections(\n result.collectionDrops,\n options,\n );\n }\n\n // A package.json edit lands before the package manager runs, so the install\n // builds on it. Written after, its content (read before the install) would\n // take back every dependency the install just recorded.\n const packageJsonPath = path.resolve(options.root, \"package.json\");\n const isPackageJson = (file: Result[\"modifies\"][number]) =>\n file.status === \"success\" &&\n path.resolve(toTargetPath(options.root, file.path)) === packageJsonPath;\n for (const file of result.modifies.filter(isPackageJson)) {\n writeFile(packageJsonPath, file.content);\n }\n\n const packageInstalls = await installPackages(\n options.root,\n result.packages,\n runtime,\n logger,\n );\n\n const componentInstalls = await installComponents(\n { root: options.root, components: result.components, logger },\n runtime,\n );\n\n const packageUninstalls = await uninstallPackages(\n options.root,\n result.uninstalls ?? [],\n runtime,\n logger,\n );\n\n for (const file of [...result.creates, ...dropMigrationCreates]) {\n if (file.status !== \"success\") {\n // A modifier that could not recognise the file it was asked to edit\n // reports `failed` / `not-found` with a paste-ready remediation snippet.\n // Nothing is written, but the entry has to survive into the result: this\n // loop used to `continue` before pushing, so the entry never reached the\n // caller at all and the snippet was lost. The pattern reported success\n // and simply said nothing about the file it had given up on.\n writtenResult.creates.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n continue;\n }\n const target = toTargetPath(options.root, file.path);\n if (!existsSync(target)) {\n writeFile(target, file.content);\n writtenResult.creates.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n continue;\n }\n if (readFileSync(target, \"utf8\") !== file.content) {\n writeFile(target, file.content);\n writtenResult.modifies.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n }\n }\n\n for (const file of result.modifies) {\n if (isPackageJson(file)) {\n writtenResult.modifies.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n continue;\n }\n if (file.status !== \"success\") {\n // Carried through unwritten, so the caller can report the failure. See\n // the note in the creates loop above.\n writtenResult.modifies.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n continue;\n }\n writeFile(toTargetPath(options.root, file.path), file.content);\n writtenResult.modifies.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n }\n\n for (const file of result.deletes) {\n if (file.status !== \"success\") {\n writtenResult.deletes.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n continue;\n }\n if (existsSync(toTargetPath(options.root, file.path))) {\n removeFile(toTargetPath(options.root, file.path), options.root);\n writtenResult.deletes.push({\n ...file,\n path: toRelativePath(options.root, file.path),\n });\n }\n }\n\n return {\n ...result,\n creates: writtenResult.creates,\n modifies: writtenResult.modifies,\n deletes: writtenResult.deletes,\n components: componentInstalls.installed,\n packages: [...new Set([...packageInstalls, ...componentInstalls.packages])],\n ...(packageUninstalls.length > 0 ? { uninstalls: packageUninstalls } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0DM+I,KAA+C;CACnD,aAAa,CAAC,OAAO;CACrB,aAAa;EA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