@velastack/patterns 0.10.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{collections-BYcVyY9O.js → collections-DzwWwFUQ.js} +2 -2
- package/dist/chunks/{collections-BYcVyY9O.js.map → collections-DzwWwFUQ.js.map} +1 -1
- package/dist/chunks/{constants-Bdx8mp7v.js → constants-8cLxGOB0.js} +3 -3
- package/dist/chunks/constants-8cLxGOB0.js.map +1 -0
- package/dist/chunks/{currency.server-Bb2Ndutg.js → currency.server-CzHS7Svd.js} +3 -3
- package/dist/chunks/{currency.server-Bb2Ndutg.js.map → currency.server-CzHS7Svd.js.map} +1 -1
- package/dist/chunks/{env-vars-0hvKe55u.js → env-vars-CNH-ItSY.js} +3 -3
- package/dist/chunks/{env-vars-0hvKe55u.js.map → env-vars-CNH-ItSY.js.map} +1 -1
- package/dist/chunks/{generate-B-cqjI-U.js → generate-BEc_h7OI.js} +2 -2
- package/dist/chunks/{generate-B-cqjI-U.js.map → generate-BEc_h7OI.js.map} +1 -1
- package/dist/chunks/{generate-DoHn_xJZ.js → generate-C3OaUggX.js} +2 -2
- package/dist/chunks/{generate-DoHn_xJZ.js.map → generate-C3OaUggX.js.map} +1 -1
- package/dist/chunks/{generate-l2JZTRKb.js → generate-CtQcmjPM.js} +2 -2
- package/dist/chunks/{generate-l2JZTRKb.js.map → generate-CtQcmjPM.js.map} +1 -1
- package/dist/chunks/{generate-Df7t5Nbk.js → generate-D21dCU-o.js} +3 -3
- package/dist/chunks/{generate-Df7t5Nbk.js.map → generate-D21dCU-o.js.map} +1 -1
- package/dist/chunks/{generate-CNabcEBx.js → generate-DiwvSC9c.js} +2 -2
- package/dist/chunks/{generate-CNabcEBx.js.map → generate-DiwvSC9c.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BnqS_Zq8.js → generate.runtime--VeSxyIm.js} +3 -3
- package/dist/chunks/{generate.runtime-BnqS_Zq8.js.map → generate.runtime--VeSxyIm.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cv3unKap.js → generate.runtime--yCjGZ6-.js} +3 -3
- package/dist/chunks/{generate.runtime-Cv3unKap.js.map → generate.runtime--yCjGZ6-.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BoYwV0nt.js → generate.runtime-B3yuIjJD.js} +2 -2
- package/dist/chunks/{generate.runtime-BoYwV0nt.js.map → generate.runtime-B3yuIjJD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-q17D7QUT.js → generate.runtime-BBfiR_Le.js} +3 -3
- package/dist/chunks/{generate.runtime-q17D7QUT.js.map → generate.runtime-BBfiR_Le.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Bvjj3zn0.js → generate.runtime-BK7x32md.js} +3 -3
- package/dist/chunks/{generate.runtime-Bvjj3zn0.js.map → generate.runtime-BK7x32md.js.map} +1 -1
- package/dist/chunks/{generate.runtime-gZ4wfYBP.js → generate.runtime-BL62aRng.js} +6 -6
- package/dist/chunks/{generate.runtime-gZ4wfYBP.js.map → generate.runtime-BL62aRng.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Du84quuK.js → generate.runtime-BTHuPon9.js} +5 -5
- package/dist/chunks/{generate.runtime-Du84quuK.js.map → generate.runtime-BTHuPon9.js.map} +1 -1
- package/dist/chunks/{generate.runtime-e_BkDyP0.js → generate.runtime-Brakd35X.js} +2 -2
- package/dist/chunks/{generate.runtime-e_BkDyP0.js.map → generate.runtime-Brakd35X.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B84ymwlD.js → generate.runtime-Bx_CaBZD.js} +2 -2
- package/dist/chunks/{generate.runtime-B84ymwlD.js.map → generate.runtime-Bx_CaBZD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-oUJUQRdg.js → generate.runtime-C8-mjcn8.js} +6 -6
- package/dist/chunks/{generate.runtime-oUJUQRdg.js.map → generate.runtime-C8-mjcn8.js.map} +1 -1
- package/dist/chunks/generate.runtime-CAO_SpsA.js +50 -0
- package/dist/chunks/generate.runtime-CAO_SpsA.js.map +1 -0
- package/dist/chunks/{generate.runtime-DJ5uF6EN.js → generate.runtime-CCE-9xQV.js} +2 -2
- package/dist/chunks/{generate.runtime-DJ5uF6EN.js.map → generate.runtime-CCE-9xQV.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C7tlPKH1.js → generate.runtime-CGJ_4VS_.js} +4 -4
- package/dist/chunks/{generate.runtime-C7tlPKH1.js.map → generate.runtime-CGJ_4VS_.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CVWCUn52.js → generate.runtime-CPDJolef.js} +4 -4
- package/dist/chunks/{generate.runtime-CVWCUn52.js.map → generate.runtime-CPDJolef.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DG9Lp3vR.js → generate.runtime-CaOO0281.js} +6 -6
- package/dist/chunks/{generate.runtime-DG9Lp3vR.js.map → generate.runtime-CaOO0281.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Dfz53sSK.js → generate.runtime-Ce2O5uWy.js} +3 -3
- package/dist/chunks/{generate.runtime-Dfz53sSK.js.map → generate.runtime-Ce2O5uWy.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DERcpgc-.js → generate.runtime-CeoqgxiO.js} +4 -4
- package/dist/chunks/{generate.runtime-DERcpgc-.js.map → generate.runtime-CeoqgxiO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-T7JLE4Wc.js → generate.runtime-CowdMKQs.js} +3 -3
- package/dist/chunks/{generate.runtime-T7JLE4Wc.js.map → generate.runtime-CowdMKQs.js.map} +1 -1
- package/dist/chunks/{generate.runtime-J2lLMjDn.js → generate.runtime-CtFCayo8.js} +7 -7
- package/dist/chunks/{generate.runtime-J2lLMjDn.js.map → generate.runtime-CtFCayo8.js.map} +1 -1
- package/dist/chunks/{generate.runtime-C4LUUuq7.js → generate.runtime-D34lCyet.js} +3 -3
- package/dist/chunks/{generate.runtime-C4LUUuq7.js.map → generate.runtime-D34lCyet.js.map} +1 -1
- package/dist/chunks/generate.runtime-DOWDoe6B.js +24 -0
- package/dist/chunks/generate.runtime-DOWDoe6B.js.map +1 -0
- package/dist/chunks/{generate.runtime-D677SB4v.js → generate.runtime-DOv-bhM6.js} +2 -2
- package/dist/chunks/{generate.runtime-D677SB4v.js.map → generate.runtime-DOv-bhM6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-WPq7bHRA.js → generate.runtime-DRuPb-67.js} +2 -2
- package/dist/chunks/{generate.runtime-WPq7bHRA.js.map → generate.runtime-DRuPb-67.js.map} +1 -1
- package/dist/chunks/{generate.runtime-ByPcr9vJ.js → generate.runtime-DUBOC6AA.js} +3 -3
- package/dist/chunks/{generate.runtime-ByPcr9vJ.js.map → generate.runtime-DUBOC6AA.js.map} +1 -1
- package/dist/chunks/{generate.runtime-CHUCMVa2.js → generate.runtime-DVwha8lZ.js} +2 -2
- package/dist/chunks/{generate.runtime-CHUCMVa2.js.map → generate.runtime-DVwha8lZ.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BP31tAcD.js → generate.runtime-D_HYO-mG.js} +4 -4
- package/dist/chunks/{generate.runtime-BP31tAcD.js.map → generate.runtime-D_HYO-mG.js.map} +1 -1
- package/dist/chunks/{generate.runtime-nyJ6v56q.js → generate.runtime-DbMDlglD.js} +4 -4
- package/dist/chunks/{generate.runtime-nyJ6v56q.js.map → generate.runtime-DbMDlglD.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BC6CBKh6.js → generate.runtime-DbSRJF-C.js} +3 -3
- package/dist/chunks/{generate.runtime-BC6CBKh6.js.map → generate.runtime-DbSRJF-C.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DuDcKDUl.js → generate.runtime-DlPeHx19.js} +2 -2
- package/dist/chunks/{generate.runtime-DuDcKDUl.js.map → generate.runtime-DlPeHx19.js.map} +1 -1
- package/dist/chunks/{generate.runtime-Cj-5fzbQ.js → generate.runtime-DroVnvQz.js} +4 -4
- package/dist/chunks/{generate.runtime-Cj-5fzbQ.js.map → generate.runtime-DroVnvQz.js.map} +1 -1
- package/dist/chunks/{generate.runtime-zr6uIHCd.js → generate.runtime-Drpy9sWO.js} +2 -2
- package/dist/chunks/{generate.runtime-zr6uIHCd.js.map → generate.runtime-Drpy9sWO.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BDbotRNZ.js → generate.runtime-Dy9uuf7M.js} +6 -6
- package/dist/chunks/{generate.runtime-BDbotRNZ.js.map → generate.runtime-Dy9uuf7M.js.map} +1 -1
- package/dist/chunks/{generate.runtime-B53OTMcE.js → generate.runtime-HkvT9gm6.js} +4 -4
- package/dist/chunks/{generate.runtime-B53OTMcE.js.map → generate.runtime-HkvT9gm6.js.map} +1 -1
- package/dist/chunks/{generate.runtime-DiqfbDfk.js → generate.runtime-kEHEiLBL.js} +2 -2
- package/dist/chunks/{generate.runtime-DiqfbDfk.js.map → generate.runtime-kEHEiLBL.js.map} +1 -1
- package/dist/chunks/{generate.runtime-BqCbJ-No.js → generate.runtime-r9Ouwr5B.js} +3 -3
- package/dist/chunks/{generate.runtime-BqCbJ-No.js.map → generate.runtime-r9Ouwr5B.js.map} +1 -1
- package/dist/chunks/{generate.runtime-rLlDp4R6.js → generate.runtime-sALBNh1T.js} +4 -4
- package/dist/chunks/{generate.runtime-rLlDp4R6.js.map → generate.runtime-sALBNh1T.js.map} +1 -1
- package/dist/chunks/layout.svelte-Cb12mxua.js +65 -0
- package/dist/chunks/layout.svelte-Cb12mxua.js.map +1 -0
- package/dist/chunks/{modify-file-B4uJzOEj.js → modify-file-DdXJCMHN.js} +2 -2
- package/dist/chunks/{modify-file-B4uJzOEj.js.map → modify-file-DdXJCMHN.js.map} +1 -1
- package/dist/chunks/{pocketbase-BtN-wL8f.js → pocketbase-uOpghyT5.js} +2 -2
- package/dist/chunks/{pocketbase-BtN-wL8f.js.map → pocketbase-uOpghyT5.js.map} +1 -1
- package/dist/chunks/{providers-DRwJnSzb.js → providers-ypCW70Mb.js} +2 -2
- package/dist/chunks/{providers-DRwJnSzb.js.map → providers-ypCW70Mb.js.map} +1 -1
- package/dist/chunks/{shared-BbxLil4g.js → shared-DIDAkVts.js} +2 -2
- package/dist/chunks/{shared-BbxLil4g.js.map → shared-DIDAkVts.js.map} +1 -1
- package/dist/chunks/{site-VrqOvuiU.js → site-CVtsbO_S.js} +2 -2
- package/dist/chunks/{site-VrqOvuiU.js.map → site-CVtsbO_S.js.map} +1 -1
- package/dist/chunks/{table-core-BHFT-uMX.js → table-core-CUGp4Rf2.js} +2 -2
- package/dist/chunks/{table-core-BHFT-uMX.js.map → table-core-CUGp4Rf2.js.map} +1 -1
- package/dist/chunks/test-setup-B37g3TRn.js +179 -0
- package/dist/chunks/test-setup-B37g3TRn.js.map +1 -0
- package/dist/chunks/{ui-gG8i_Mzk.js → ui-Ct_9B91R.js} +3 -3
- package/dist/chunks/{ui-gG8i_Mzk.js.map → ui-Ct_9B91R.js.map} +1 -1
- package/dist/chunks/{whatsapp-DbjOxHaZ.js → whatsapp-Dr29ohbb.js} +2 -2
- package/dist/chunks/{whatsapp-DbjOxHaZ.js.map → whatsapp-Dr29ohbb.js.map} +1 -1
- package/dist/chunks/{write-result-DcqMefuP.js → write-result-mtVbmDyQ.js} +12 -12
- package/dist/chunks/{write-result-DcqMefuP.js.map → write-result-mtVbmDyQ.js.map} +1 -1
- package/dist/index.d.ts +124 -0
- package/dist/index.js +2114 -1954
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/constants-Bdx8mp7v.js.map +0 -1
- package/dist/chunks/test-setup-BVJwm22s.js +0 -179
- package/dist/chunks/test-setup-BVJwm22s.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-gG8i_Mzk.js","names":["RegistryUnavailableError","installedComponents","formatPaths","getAllCustomComponents","isCustomComponent","executeCommand","readComponentsConfig","fetchRegistryIndex","path","loadPreset","resolved","createRequire","root","error","reason","pathToFileURL","STYLE_FONTS","presetFor","preset","config","current","encodePreset","overrides","applyPreset","code","only","runtime","COMPONENTS_JSON","listComponents","options","result","assertOneOf","value","InvalidArgumentError","kind","choices","writeStyle","configPath","existsSync","text","readFileSync","style","indent","registryUiNames","index","item","switchStyle","logger","getLogger","unchanged","offered","reinstall","component","packagesBefore","installedPackagesFromProject","filesModified","reinstalled","installComponents","hints","font","applyStyleFont","packages","name","FONTSOURCE_IMPORT","fontsourceImports","css","match","fonts","cssPath","cssFile","wanted","stale","family","f","applyColors","applyBaseColor","applyTheme"],"sources":["../../src/runtime/shadcn-preset.ts","../../src/runtime/ui.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { WriteResultRuntime } from \"../core/types\";\nimport { readComponentsConfig } from \"./registry\";\nimport { executeCommand, formatPaths } from \"./write-result\";\n\n/**\n * What a shadcn-svelte preset code carries. Mirrors `PresetConfig` from\n * `shadcn-svelte/preset` as plain strings, so this package's types do not\n * depend on a package its consumers may not have installed.\n */\nexport interface PresetConfig {\n style: string;\n baseColor: string;\n theme: string;\n chartColor?: string;\n iconLibrary: string;\n font: string;\n fontHeading: string;\n radius: string;\n menuAccent: string;\n menuColor: string;\n}\n\n/** The part of `shadcn-svelte/preset` this package uses. */\nexport interface ShadcnPreset {\n PRESET_STYLES: readonly string[];\n PRESET_BASE_COLOR_KEYS: readonly string[];\n PRESET_THEME_KEYS: readonly string[];\n PRESET_FONTS: readonly string[];\n PRESET_ICON_LIBRARIES: readonly string[];\n encodePreset(config: Partial<PresetConfig>): string;\n decodePreset(code: string): PresetConfig | null;\n}\n\nexport type PresetPart = \"theme\" | \"font\";\n\n/**\n * The encoder from the *project's* shadcn-svelte, so every preset code is\n * produced by the same version that consumes it and the value lists can\n * never drift from what `apply` accepts.\n */\nexport async function loadPreset(root: string): Promise<ShadcnPreset> {\n let resolved: string;\n try {\n resolved = createRequire(path.join(root, \"package.json\")).resolve(\n \"shadcn-svelte/preset\",\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Could not load shadcn-svelte/preset from ${root}: ${reason}\\n` +\n \"Install the project's dependencies (shadcn-svelte >= 1.6) and try again.\",\n );\n }\n const module: unknown = await import(\n /* @vite-ignore */ pathToFileURL(resolved).href\n );\n return module as ShadcnPreset;\n}\n\n/**\n * The font each style is designed with. shadcn-svelte keeps this table inside\n * its bundle (the `create` presets) without exporting it, so it is vendored\n * here; `shadcn-preset.test.ts` checks it still covers every style the\n * installed shadcn-svelte knows.\n */\nexport const STYLE_FONTS: Record<\n string,\n { font: string; fontHeading?: string }\n> = {\n nova: { font: \"geist\" },\n vega: { font: \"inter\" },\n maia: { font: \"figtree\" },\n lyra: { font: \"jetbrains-mono\" },\n mira: { font: \"inter\" },\n luma: { font: \"inter\" },\n sera: { font: \"noto-sans\", fontHeading: \"playfair-display\" },\n rhea: { font: \"inter\" },\n};\n\n/**\n * A preset code for the project as it is, with `overrides` on top: the style,\n * base color, icon library and menu settings come from `components.json` so\n * an `apply --only theme` keeps everything it does not mean to change.\n * Values shadcn-svelte does not know (a `slate` from an older template) fall\n * back to its defaults inside `encodePreset`.\n */\nexport async function presetFor(\n root: string,\n overrides: Partial<PresetConfig>,\n preset?: ShadcnPreset,\n): Promise<string> {\n const { encodePreset } = preset ?? (await loadPreset(root));\n const config = readComponentsConfig(root);\n const current: Partial<PresetConfig> = { style: config.style };\n if (config.baseColor) current.baseColor = config.baseColor;\n if (config.iconLibrary) current.iconLibrary = config.iconLibrary;\n if (config.menuColor) current.menuColor = config.menuColor;\n if (config.menuAccent) current.menuAccent = config.menuAccent;\n return encodePreset({ ...current, ...overrides });\n}\n\n/**\n * `shadcn-svelte apply --preset <code> --only <parts> --yes` through the\n * project's package manager. `theme` rewrites the token values in `:root` /\n * `.dark` and records the base color in `components.json`; `font` adds the\n * fontsource import, dependency and `--font-sans`. Both leave the rest of the\n * stylesheet alone but write it in the registry's formatting, so the file is\n * run through the project's prettier afterwards.\n */\nexport async function applyPreset(\n root: string,\n code: string,\n only: PresetPart[],\n runtime?: WriteResultRuntime,\n): Promise<void> {\n await executeCommand(\n root,\n \"execute\",\n [\"shadcn-svelte\", \"apply\", \"--preset\", code, \"--only\", ...only, \"--yes\"],\n runtime,\n );\n await formatPaths(root, [readComponentsConfig(root).cssPath]);\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n ApplyBaseColorOptions,\n ApplyColorsResult,\n ApplyThemeOptions,\n Component,\n ListComponentsOptions,\n ListComponentsResult,\n RegistryItem,\n SwitchStyleOptions,\n SwitchStyleResult,\n WriteResultRuntime,\n} from \"../core/types\";\nimport { InvalidArgumentError, RegistryUnavailableError } from \"../core/errors\";\nimport { getLogger } from \"../core/logger\";\nimport { fetchRegistryIndex, readComponentsConfig } from \"./registry\";\nimport {\n applyPreset,\n loadPreset,\n presetFor,\n STYLE_FONTS,\n type ShadcnPreset,\n} from \"./shadcn-preset\";\nimport {\n getAllCustomComponents,\n installComponents,\n installedComponents,\n installedPackagesFromProject,\n isCustomComponent,\n} from \"./write-result\";\n\nconst COMPONENTS_JSON = \"components.json\";\n\n/**\n * What a project has and what it could add: the ui directory, this package's\n * bundled components, and the registry index of the configured style. A\n * registry that cannot be read leaves the first two intact and says why.\n */\nexport async function listComponents(\n options: ListComponentsOptions,\n runtime?: WriteResultRuntime,\n): Promise<ListComponentsResult> {\n const { root } = options;\n const { style } = readComponentsConfig(root);\n const result: ListComponentsResult = {\n style,\n installed: installedComponents(root),\n custom: getAllCustomComponents(),\n registry: [],\n };\n try {\n result.registry = await fetchRegistryIndex(root, { runtime });\n } catch (error) {\n if (!(error instanceof RegistryUnavailableError)) throw error;\n result.registryUnavailable = error.message;\n }\n return result;\n}\n\nfunction assertOneOf(\n kind: string,\n value: string,\n choices: readonly string[],\n): void {\n if (choices.includes(value)) return;\n throw new InvalidArgumentError(\n `Unknown ${kind} \"${value}\". Choose one of: ${choices.join(\", \")}.`,\n );\n}\n\n/**\n * Rewrites `style` in `components.json` and nothing else, keeping the file's\n * indentation so the change reads as the one-line diff it is.\n */\nfunction writeStyle(root: string, style: string): void {\n const configPath = path.join(root, COMPONENTS_JSON);\n if (!existsSync(configPath)) {\n throw new Error(\n `${COMPONENTS_JSON} not found in ${root}; this does not look like a shadcn-svelte project.`,\n );\n }\n const text = readFileSync(configPath, \"utf8\");\n const config = JSON.parse(text) as Record<string, unknown>;\n config.style = style;\n const indent = text.includes(\"\\n\\t\") ? \"\\t\" : 2;\n writeFileSync(\n configPath,\n `${JSON.stringify(config, null, indent)}\\n`,\n \"utf8\",\n );\n}\n\nfunction registryUiNames(index: RegistryItem[]): Set<string> {\n return new Set(\n index\n .filter((item) => item.type === \"registry:ui\")\n .map((item) => item.name),\n );\n}\n\n/**\n * Moves a project to another shadcn-svelte style. Every installed component\n * the new style's registry also offers is re-added from there (their local\n * edits are lost, which is what `confirm` is for); this package's own\n * components and anything the registry does not know are left alone. The\n * style's preset font follows unless `font` is false.\n */\nexport async function switchStyle(\n options: SwitchStyleOptions,\n runtime?: WriteResultRuntime,\n): Promise<SwitchStyleResult> {\n const { root, style, font = true } = options;\n const logger = getLogger(options);\n const preset = await loadPreset(root);\n assertOneOf(\"style\", style, preset.PRESET_STYLES);\n\n const unchanged: SwitchStyleResult = {\n status: \"unchanged\",\n style,\n reinstalled: [],\n filesModified: [],\n packages: [],\n hints: [],\n };\n if (readComponentsConfig(root).style === style) {\n return unchanged;\n }\n\n const index = await fetchRegistryIndex(root, { style, runtime });\n const offered = registryUiNames(index);\n const reinstall = installedComponents(root).filter(\n (component) => offered.has(component) && !isCustomComponent(component),\n );\n\n if (options.confirm && !(await options.confirm(reinstall))) {\n return { ...unchanged, status: \"cancelled\" };\n }\n\n const packagesBefore = installedPackagesFromProject(root);\n writeStyle(root, style);\n const filesModified = [COMPONENTS_JSON];\n\n let reinstalled: Component[] = [];\n if (reinstall.length > 0) {\n const outcome = await installComponents(\n { root, components: reinstall, overwrite: true, logger },\n runtime,\n );\n reinstalled = outcome.installed;\n }\n\n const hints: string[] = [];\n if (font) {\n await applyStyleFont(\n root,\n style,\n preset,\n runtime,\n filesModified,\n hints,\n logger,\n );\n }\n\n const packages = [...installedPackagesFromProject(root)]\n .filter((name) => !packagesBefore.has(name))\n .sort();\n\n return {\n status: \"switched\",\n style,\n reinstalled,\n filesModified,\n packages,\n hints,\n };\n}\n\nconst FONTSOURCE_IMPORT =\n /@import\\s+[\"']@fontsource(?:-variable)?\\/([^\"']+)[\"']/g;\n\n/** The fontsource families a stylesheet imports, in order. */\nfunction fontsourceImports(css: string): string[] {\n return [...css.matchAll(FONTSOURCE_IMPORT)].map((match) => match[1]!);\n}\n\nasync function applyStyleFont(\n root: string,\n style: string,\n preset: ShadcnPreset,\n runtime: WriteResultRuntime | undefined,\n filesModified: string[],\n hints: string[],\n logger: ReturnType<typeof getLogger>,\n): Promise<void> {\n const fonts = STYLE_FONTS[style];\n if (!fonts) {\n logger.info(\n `No preset font is known for the ${style} style; leaving fonts unchanged.`,\n );\n return;\n }\n logger.info(`Applying the ${style} font (${fonts.font})`);\n const code = await presetFor(root, { style, ...fonts }, preset);\n await applyPreset(root, code, [\"font\"], runtime);\n\n const cssPath = readComponentsConfig(root).cssPath;\n filesModified.push(cssPath, \"package.json\");\n\n // `apply --only font` adds the new font beside whatever was imported before\n // and leaves it to the project to drop the old one; a font nobody uses\n // still ships to every visitor.\n const cssFile = path.join(root, cssPath);\n if (existsSync(cssFile)) {\n const wanted = new Set([fonts.font, fonts.fontHeading].filter(Boolean));\n const stale = fontsourceImports(readFileSync(cssFile, \"utf8\")).filter(\n (family) => !wanted.has(family),\n );\n if (stale.length > 0) {\n hints.push(\n `${cssPath} still imports ${stale.map((f) => `@fontsource-variable/${f}`).join(\", \")} from the previous style; remove the import and the package if nothing else uses them.`,\n );\n }\n }\n}\n\nasync function applyColors(\n root: string,\n overrides: { baseColor?: string; theme: string },\n runtime?: WriteResultRuntime,\n): Promise<ApplyColorsResult> {\n const preset = await loadPreset(root);\n if (overrides.baseColor) {\n assertOneOf(\n \"base color\",\n overrides.baseColor,\n preset.PRESET_BASE_COLOR_KEYS,\n );\n }\n assertOneOf(\"theme\", overrides.theme, preset.PRESET_THEME_KEYS);\n\n // Charts follow the accent, as shadcn-svelte's own presets do.\n const code = await presetFor(\n root,\n { ...overrides, chartColor: overrides.theme },\n preset,\n );\n await applyPreset(root, code, [\"theme\"], runtime);\n\n const config = readComponentsConfig(root);\n return {\n baseColor: config.baseColor ?? overrides.baseColor ?? \"\",\n theme: overrides.theme,\n filesModified: [config.cssPath, COMPONENTS_JSON],\n };\n}\n\n/**\n * Sets the base (gray) palette. The accent is reset to the base color as\n * well, since `components.json` records only the base color; `applyTheme`\n * puts an accent back on top.\n */\nexport async function applyBaseColor(\n options: ApplyBaseColorOptions,\n runtime?: WriteResultRuntime,\n): Promise<ApplyColorsResult> {\n return applyColors(\n options.root,\n { baseColor: options.color, theme: options.color },\n runtime,\n );\n}\n\n/** Sets the accent (primary, ring, charts) and keeps the base palette. */\nexport async function applyTheme(\n options: ApplyThemeOptions,\n runtime?: WriteResultRuntime,\n): Promise<ApplyColorsResult> {\n return applyColors(options.root, { theme: options.theme }, runtime);\n}\n"],"mappings":";;;;;;;;;AA2CA,eAAsBS,EAAW,GAAqC;CACpE,IAAIC;CACJ,IAAI;EACF,IAAWC,EAAcH,EAAK,KAAKI,GAAM,cAAc,CAAC,CAAC,CAAC,QACxD,sBACF;CACF,SAASC,GAAO;EACd,IAAMC,IAASD,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK;EACpE,MAAU,MACR,4CAA4CD,EAAK,IAAIE,EAAO,2EAE9D;CACF;CAIA,OAAO,MAHuB;;EACTC,EAAcL,CAAQ,CAAC,CAAC;;AAG/C;AAQA,IAAaM,IAGT;CACF,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,EAAE,MAAM,iBAAiB;CAC/B,MAAM,EAAE,MAA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CAACH,EAAM,MAAMA,EAAM,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,GAChEI,IAAQP,EAAkBxB,EAAa6B,GAAS,MAAM,CAAC,CAAC,CAAC,QAC5D,MAAW,CAACC,EAAO,IAAIE,CAAM,CAChC;EACA,AAAID,EAAM,SAAS,KACjBb,EAAM,KACJ,GAAGU,EAAQ,iBAAiBG,EAAM,KAAK,MAAM,wBAAwBE,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,uFACvF;CAEJ;AACF;AAEA,eAAeC,EACb,GACA,GACA,GAC4B;CAC5B,IAAMxD,IAAS,MAAMT,EAAWG,CAAI;CAgBpC,AAfIU,EAAU,aACZS,EACE,cACAT,EAAU,WACVJ,EAAO,sBACT,GAEFa,EAAY,SAAST,EAAU,OAAOJ,EAAO,iBAAiB,GAQ9D,MAAMK,EAAYX,GAAM,MALLK,EACjBL,GACA;EAAE,GAAGU;EAAW,YAAYA,EAAU;CAAM,GAC5CJ,CACF,GAC8B,CAAC,OAAO,GAAGQ,CAAO;CAEhD,IAAMP,IAASb,EAAqBM,CAAI;CACxC,OAAO;EACL,WAAWO,EAAO,aAAaG,EAAU,aAAa;EACtD,OAAOA,EAAU;EACjB,eAAe,CAACH,EAAO,SAASQ,CAAe;CACjD;AACF;AAOA,eAAsBgD,EACpB,GACA,GAC4B;CAC5B,OAAOD,EACL7C,EAAQ,MACR;EAAE,WAAWA,EAAQ;EAAO,OAAOA,EAAQ;CAAM,GACjDH,CACF;AACF;AAGA,eAAsBkD,EACpB,GACA,GAC4B;CAC5B,OAAOF,EAAY7C,EAAQ,MAAM,EAAE,OAAOA,EAAQ,MAAM,GAAGH,CAAO;AACpE"}
|
|
1
|
+
{"version":3,"file":"ui-Ct_9B91R.js","names":["RegistryUnavailableError","installedComponents","formatPaths","getAllCustomComponents","isCustomComponent","executeCommand","readComponentsConfig","fetchRegistryIndex","path","loadPreset","resolved","createRequire","root","error","reason","pathToFileURL","STYLE_FONTS","presetFor","preset","config","current","encodePreset","overrides","applyPreset","code","only","runtime","COMPONENTS_JSON","listComponents","options","result","assertOneOf","value","InvalidArgumentError","kind","choices","writeStyle","configPath","existsSync","text","readFileSync","style","indent","registryUiNames","index","item","switchStyle","logger","getLogger","unchanged","offered","reinstall","component","packagesBefore","installedPackagesFromProject","filesModified","reinstalled","installComponents","hints","font","applyStyleFont","packages","name","FONTSOURCE_IMPORT","fontsourceImports","css","match","fonts","cssPath","cssFile","wanted","stale","family","f","applyColors","applyBaseColor","applyTheme"],"sources":["../../src/runtime/shadcn-preset.ts","../../src/runtime/ui.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { WriteResultRuntime } from \"../core/types\";\nimport { readComponentsConfig } from \"./registry\";\nimport { executeCommand, formatPaths } from \"./write-result\";\n\n/**\n * What a shadcn-svelte preset code carries. Mirrors `PresetConfig` from\n * `shadcn-svelte/preset` as plain strings, so this package's types do not\n * depend on a package its consumers may not have installed.\n */\nexport interface PresetConfig {\n style: string;\n baseColor: string;\n theme: string;\n chartColor?: string;\n iconLibrary: string;\n font: string;\n fontHeading: string;\n radius: string;\n menuAccent: string;\n menuColor: string;\n}\n\n/** The part of `shadcn-svelte/preset` this package uses. */\nexport interface ShadcnPreset {\n PRESET_STYLES: readonly string[];\n PRESET_BASE_COLOR_KEYS: readonly string[];\n PRESET_THEME_KEYS: readonly string[];\n PRESET_FONTS: readonly string[];\n PRESET_ICON_LIBRARIES: readonly string[];\n encodePreset(config: Partial<PresetConfig>): string;\n decodePreset(code: string): PresetConfig | null;\n}\n\nexport type PresetPart = \"theme\" | \"font\";\n\n/**\n * The encoder from the *project's* shadcn-svelte, so every preset code is\n * produced by the same version that consumes it and the value lists can\n * never drift from what `apply` accepts.\n */\nexport async function loadPreset(root: string): Promise<ShadcnPreset> {\n let resolved: string;\n try {\n resolved = createRequire(path.join(root, \"package.json\")).resolve(\n \"shadcn-svelte/preset\",\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Could not load shadcn-svelte/preset from ${root}: ${reason}\\n` +\n \"Install the project's dependencies (shadcn-svelte >= 1.6) and try again.\",\n );\n }\n const module: unknown = await import(\n /* @vite-ignore */ pathToFileURL(resolved).href\n );\n return module as ShadcnPreset;\n}\n\n/**\n * The font each style is designed with. shadcn-svelte keeps this table inside\n * its bundle (the `create` presets) without exporting it, so it is vendored\n * here; `shadcn-preset.test.ts` checks it still covers every style the\n * installed shadcn-svelte knows.\n */\nexport const STYLE_FONTS: Record<\n string,\n { font: string; fontHeading?: string }\n> = {\n nova: { font: \"geist\" },\n vega: { font: \"inter\" },\n maia: { font: \"figtree\" },\n lyra: { font: \"jetbrains-mono\" },\n mira: { font: \"inter\" },\n luma: { font: \"inter\" },\n sera: { font: \"noto-sans\", fontHeading: \"playfair-display\" },\n rhea: { font: \"inter\" },\n};\n\n/**\n * A preset code for the project as it is, with `overrides` on top: the style,\n * base color, icon library and menu settings come from `components.json` so\n * an `apply --only theme` keeps everything it does not mean to change.\n * Values shadcn-svelte does not know (a `slate` from an older template) fall\n * back to its defaults inside `encodePreset`.\n */\nexport async function presetFor(\n root: string,\n overrides: Partial<PresetConfig>,\n preset?: ShadcnPreset,\n): Promise<string> {\n const { encodePreset } = preset ?? (await loadPreset(root));\n const config = readComponentsConfig(root);\n const current: Partial<PresetConfig> = { style: config.style };\n if (config.baseColor) current.baseColor = config.baseColor;\n if (config.iconLibrary) current.iconLibrary = config.iconLibrary;\n if (config.menuColor) current.menuColor = config.menuColor;\n if (config.menuAccent) current.menuAccent = config.menuAccent;\n return encodePreset({ ...current, ...overrides });\n}\n\n/**\n * `shadcn-svelte apply --preset <code> --only <parts> --yes` through the\n * project's package manager. `theme` rewrites the token values in `:root` /\n * `.dark` and records the base color in `components.json`; `font` adds the\n * fontsource import, dependency and `--font-sans`. Both leave the rest of the\n * stylesheet alone but write it in the registry's formatting, so the file is\n * run through the project's prettier afterwards.\n */\nexport async function applyPreset(\n root: string,\n code: string,\n only: PresetPart[],\n runtime?: WriteResultRuntime,\n): Promise<void> {\n await executeCommand(\n root,\n \"execute\",\n [\"shadcn-svelte\", \"apply\", \"--preset\", code, \"--only\", ...only, \"--yes\"],\n runtime,\n );\n await formatPaths(root, [readComponentsConfig(root).cssPath]);\n}\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n ApplyBaseColorOptions,\n ApplyColorsResult,\n ApplyThemeOptions,\n Component,\n ListComponentsOptions,\n ListComponentsResult,\n RegistryItem,\n SwitchStyleOptions,\n SwitchStyleResult,\n WriteResultRuntime,\n} from \"../core/types\";\nimport { InvalidArgumentError, RegistryUnavailableError } from \"../core/errors\";\nimport { getLogger } from \"../core/logger\";\nimport { fetchRegistryIndex, readComponentsConfig } from \"./registry\";\nimport {\n applyPreset,\n loadPreset,\n presetFor,\n STYLE_FONTS,\n type ShadcnPreset,\n} from \"./shadcn-preset\";\nimport {\n getAllCustomComponents,\n installComponents,\n installedComponents,\n installedPackagesFromProject,\n isCustomComponent,\n} from \"./write-result\";\n\nconst COMPONENTS_JSON = \"components.json\";\n\n/**\n * What a project has and what it could add: the ui directory, this package's\n * bundled components, and the registry index of the configured style. A\n * registry that cannot be read leaves the first two intact and says why.\n */\nexport async function listComponents(\n options: ListComponentsOptions,\n runtime?: WriteResultRuntime,\n): Promise<ListComponentsResult> {\n const { root } = options;\n const { style } = readComponentsConfig(root);\n const result: ListComponentsResult = {\n style,\n installed: installedComponents(root),\n custom: getAllCustomComponents(),\n registry: [],\n };\n try {\n result.registry = await fetchRegistryIndex(root, { runtime });\n } catch (error) {\n if (!(error instanceof RegistryUnavailableError)) throw error;\n result.registryUnavailable = error.message;\n }\n return result;\n}\n\nfunction assertOneOf(\n kind: string,\n value: string,\n choices: readonly string[],\n): void {\n if (choices.includes(value)) return;\n throw new InvalidArgumentError(\n `Unknown ${kind} \"${value}\". Choose one of: ${choices.join(\", \")}.`,\n );\n}\n\n/**\n * Rewrites `style` in `components.json` and nothing else, keeping the file's\n * indentation so the change reads as the one-line diff it is.\n */\nfunction writeStyle(root: string, style: string): void {\n const configPath = path.join(root, COMPONENTS_JSON);\n if (!existsSync(configPath)) {\n throw new Error(\n `${COMPONENTS_JSON} not found in ${root}; this does not look like a shadcn-svelte project.`,\n );\n }\n const text = readFileSync(configPath, \"utf8\");\n const config = JSON.parse(text) as Record<string, unknown>;\n config.style = style;\n const indent = text.includes(\"\\n\\t\") ? \"\\t\" : 2;\n writeFileSync(\n configPath,\n `${JSON.stringify(config, null, indent)}\\n`,\n \"utf8\",\n );\n}\n\nfunction registryUiNames(index: RegistryItem[]): Set<string> {\n return new Set(\n index\n .filter((item) => item.type === \"registry:ui\")\n .map((item) => item.name),\n );\n}\n\n/**\n * Moves a project to another shadcn-svelte style. Every installed component\n * the new style's registry also offers is re-added from there (their local\n * edits are lost, which is what `confirm` is for); this package's own\n * components and anything the registry does not know are left alone. The\n * style's preset font follows unless `font` is false.\n */\nexport async function switchStyle(\n options: SwitchStyleOptions,\n runtime?: WriteResultRuntime,\n): Promise<SwitchStyleResult> {\n const { root, style, font = true } = options;\n const logger = getLogger(options);\n const preset = await loadPreset(root);\n assertOneOf(\"style\", style, preset.PRESET_STYLES);\n\n const unchanged: SwitchStyleResult = {\n status: \"unchanged\",\n style,\n reinstalled: [],\n filesModified: [],\n packages: [],\n hints: [],\n };\n if (readComponentsConfig(root).style === style) {\n return unchanged;\n }\n\n const index = await fetchRegistryIndex(root, { style, runtime });\n const offered = registryUiNames(index);\n const reinstall = installedComponents(root).filter(\n (component) => offered.has(component) && !isCustomComponent(component),\n );\n\n if (options.confirm && !(await options.confirm(reinstall))) {\n return { ...unchanged, status: \"cancelled\" };\n }\n\n const packagesBefore = installedPackagesFromProject(root);\n writeStyle(root, style);\n const filesModified = [COMPONENTS_JSON];\n\n let reinstalled: Component[] = [];\n if (reinstall.length > 0) {\n const outcome = await installComponents(\n { root, components: reinstall, overwrite: true, logger },\n runtime,\n );\n reinstalled = outcome.installed;\n }\n\n const hints: string[] = [];\n if (font) {\n await applyStyleFont(\n root,\n style,\n preset,\n runtime,\n filesModified,\n hints,\n logger,\n );\n }\n\n const packages = [...installedPackagesFromProject(root)]\n .filter((name) => !packagesBefore.has(name))\n .sort();\n\n return {\n status: \"switched\",\n style,\n reinstalled,\n filesModified,\n packages,\n hints,\n };\n}\n\nconst FONTSOURCE_IMPORT =\n /@import\\s+[\"']@fontsource(?:-variable)?\\/([^\"']+)[\"']/g;\n\n/** The fontsource families a stylesheet imports, in order. */\nfunction fontsourceImports(css: string): string[] {\n return [...css.matchAll(FONTSOURCE_IMPORT)].map((match) => match[1]!);\n}\n\nasync function applyStyleFont(\n root: string,\n style: string,\n preset: ShadcnPreset,\n runtime: WriteResultRuntime | undefined,\n filesModified: string[],\n hints: string[],\n logger: ReturnType<typeof getLogger>,\n): Promise<void> {\n const fonts = STYLE_FONTS[style];\n if (!fonts) {\n logger.info(\n `No preset font is known for the ${style} style; leaving fonts unchanged.`,\n );\n return;\n }\n logger.info(`Applying the ${style} font (${fonts.font})`);\n const code = await presetFor(root, { style, ...fonts }, preset);\n await applyPreset(root, code, [\"font\"], runtime);\n\n const cssPath = readComponentsConfig(root).cssPath;\n filesModified.push(cssPath, \"package.json\");\n\n // `apply --only font` adds the new font beside whatever was imported before\n // and leaves it to the project to drop the old one; a font nobody uses\n // still ships to every visitor.\n const cssFile = path.join(root, cssPath);\n if (existsSync(cssFile)) {\n const wanted = new Set([fonts.font, fonts.fontHeading].filter(Boolean));\n const stale = fontsourceImports(readFileSync(cssFile, \"utf8\")).filter(\n (family) => !wanted.has(family),\n );\n if (stale.length > 0) {\n hints.push(\n `${cssPath} still imports ${stale.map((f) => `@fontsource-variable/${f}`).join(\", \")} from the previous style; remove the import and the package if nothing else uses them.`,\n );\n }\n }\n}\n\nasync function applyColors(\n root: string,\n overrides: { baseColor?: string; theme: string },\n runtime?: WriteResultRuntime,\n): Promise<ApplyColorsResult> {\n const preset = await loadPreset(root);\n if (overrides.baseColor) {\n assertOneOf(\n \"base color\",\n overrides.baseColor,\n preset.PRESET_BASE_COLOR_KEYS,\n );\n }\n assertOneOf(\"theme\", overrides.theme, preset.PRESET_THEME_KEYS);\n\n // Charts follow the accent, as shadcn-svelte's own presets do.\n const code = await presetFor(\n root,\n { ...overrides, chartColor: overrides.theme },\n preset,\n );\n await applyPreset(root, code, [\"theme\"], runtime);\n\n const config = readComponentsConfig(root);\n return {\n baseColor: config.baseColor ?? overrides.baseColor ?? \"\",\n theme: overrides.theme,\n filesModified: [config.cssPath, COMPONENTS_JSON],\n };\n}\n\n/**\n * Sets the base (gray) palette. The accent is reset to the base color as\n * well, since `components.json` records only the base color; `applyTheme`\n * puts an accent back on top.\n */\nexport async function applyBaseColor(\n options: ApplyBaseColorOptions,\n runtime?: WriteResultRuntime,\n): Promise<ApplyColorsResult> {\n return applyColors(\n options.root,\n { baseColor: options.color, theme: options.color },\n runtime,\n );\n}\n\n/** Sets the accent (primary, ring, charts) and keeps the base palette. */\nexport async function applyTheme(\n options: ApplyThemeOptions,\n runtime?: WriteResultRuntime,\n): Promise<ApplyColorsResult> {\n return applyColors(options.root, { theme: options.theme }, runtime);\n}\n"],"mappings":";;;;;;;;;AA2CA,eAAsBS,EAAW,GAAqC;CACpE,IAAIC;CACJ,IAAI;EACF,IAAWC,EAAcH,EAAK,KAAKI,GAAM,cAAc,CAAC,CAAC,CAAC,QACxD,sBACF;CACF,SAASC,GAAO;EACd,IAAMC,IAASD,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK;EACpE,MAAU,MACR,4CAA4CD,EAAK,IAAIE,EAAO,2EAE9D;CACF;CAIA,OAAO,MAHuB;;EACTC,EAAcL,CAAQ,CAAC,CAAC;;AAG/C;AAQA,IAAaM,IAGT;CACF,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,EAAE,MAAM,iBA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B,IAAMC,IAAS,IAAI,IAAI,CAACH,EAAM,MAAMA,EAAM,WAAW,CAAC,CAAC,OAAO,OAAO,CAAC,GAChEI,IAAQP,EAAkBxB,EAAa6B,GAAS,MAAM,CAAC,CAAC,CAAC,QAC5D,MAAW,CAACC,EAAO,IAAIE,CAAM,CAChC;EACA,AAAID,EAAM,SAAS,KACjBb,EAAM,KACJ,GAAGU,EAAQ,iBAAiBG,EAAM,KAAK,MAAM,wBAAwBE,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,uFACvF;CAEJ;AACF;AAEA,eAAeC,EACb,GACA,GACA,GAC4B;CAC5B,IAAMxD,IAAS,MAAMT,EAAWG,CAAI;CAgBpC,AAfIU,EAAU,aACZS,EACE,cACAT,EAAU,WACVJ,EAAO,sBACT,GAEFa,EAAY,SAAST,EAAU,OAAOJ,EAAO,iBAAiB,GAQ9D,MAAMK,EAAYX,GAAM,MALLK,EACjBL,GACA;EAAE,GAAGU;EAAW,YAAYA,EAAU;CAAM,GAC5CJ,CACF,GAC8B,CAAC,OAAO,GAAGQ,CAAO;CAEhD,IAAMP,IAASb,EAAqBM,CAAI;CACxC,OAAO;EACL,WAAWO,EAAO,aAAaG,EAAU,aAAa;EACtD,OAAOA,EAAU;EACjB,eAAe,CAACH,EAAO,SAASQ,CAAe;CACjD;AACF;AAOA,eAAsBgD,EACpB,GACA,GAC4B;CAC5B,OAAOD,EACL7C,EAAQ,MACR;EAAE,WAAWA,EAAQ;EAAO,OAAOA,EAAQ;CAAM,GACjDH,CACF;AACF;AAGA,eAAsBkD,EACpB,GACA,GAC4B;CAC5B,OAAOF,EAAY7C,EAAQ,MAAM,EAAE,OAAOA,EAAQ,MAAM,GAAGH,CAAO;AACpE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as e } from "./constants-
|
|
1
|
+
import { s as e } from "./constants-8cLxGOB0.js";
|
|
2
2
|
import t from "node:fs";
|
|
3
3
|
import n from "node:path";
|
|
4
4
|
//#region src/patterns/enable/whatsapp/runtime/whatsapp.ts
|
|
@@ -102,4 +102,4 @@ migrate(
|
|
|
102
102
|
//#endregion
|
|
103
103
|
export { o as a, a as i, c as n, u as o, s as r, i as t };
|
|
104
104
|
|
|
105
|
-
//# sourceMappingURL=whatsapp-
|
|
105
|
+
//# sourceMappingURL=whatsapp-Dr29ohbb.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp-
|
|
1
|
+
{"version":3,"file":"whatsapp-Dr29ohbb.js","names":["MIGRATIONS_DIR","fs","path","PHONE_PATTERN","MIN_POCKETBASE_SERVER","hasWhatsAppPlugin","pb","error","setupWhatsAppFields","users","has","f","name","changed","fields","field","indexes","index","enableWhatsAppAuth","disableWhatsAppAuth","CONFIG_MIGRATION","writeWhatsAppConfigMigration","dir","options","file","enabled","config","whatsappConfigMigration"],"sources":["../../src/patterns/enable/whatsapp/runtime/whatsapp.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type PocketBase from \"pocketbase\";\nimport type { Options } from \"../../../../core/types\";\nimport { MIGRATIONS_DIR } from \"../../../../core/constants\";\n\n/** pocketbase-whatsapp's `PhonePattern`: E.164. */\nconst PHONE_PATTERN = \"^\\\\+[1-9][0-9]{7,14}$\";\n\n/** The first pocketbase-server with the plugin and its env-only sender. */\nexport const MIN_POCKETBASE_SERVER = \"0.40.5-beta.5\";\n\n/**\n * Whether the server has the pocketbase-whatsapp plugin that velabase ships.\n * Vanilla PocketBase and older pocketbase-server answer 404.\n */\nexport async function hasWhatsAppPlugin(pb: PocketBase): Promise<boolean> {\n try {\n await pb.send(\"/api/whatsapp/collections\", { method: \"GET\" });\n return true;\n } catch (error: any) {\n if (error?.status === 404) return false;\n throw error;\n }\n}\n\n/**\n * Gets `users` ready for WhatsApp sign-in:\n *\n * - `phone`: E.164 text with a unique index, the number users sign in with;\n * - `phoneVerified`: set once a code proves the number (`verified` is about\n * the email);\n * - `email` optional, since a WhatsApp signup has none.\n *\n * Through the collections API, not the plugin's \"Create phone field\"\n * endpoint: automigrate only writes a migration for collection changes made\n * over the API, so a save from inside the plugin would never reach\n * production.\n *\n * Returns whether `users` changed (and so wrote a migration).\n */\nexport async function setupWhatsAppFields(pb: PocketBase): Promise<boolean> {\n const users = await pb.collections.getOne(\"users\");\n const has = (name: string) =>\n users.fields.some((f: { name: string }) => f.name === name);\n\n let changed = false;\n const fields: Record<string, unknown>[] = users.fields.map(\n (field: Record<string, unknown>) => {\n if (field.name === \"email\" && field.required) {\n changed = true;\n return { ...field, required: false };\n }\n return field;\n },\n );\n if (!has(\"phone\")) {\n changed = true;\n fields.push({\n name: \"phone\",\n type: \"text\",\n pattern: PHONE_PATTERN,\n max: 16,\n });\n }\n if (!has(\"phoneVerified\")) {\n changed = true;\n fields.push({ name: \"phoneVerified\", type: \"bool\" });\n }\n\n const indexes = [...users.indexes];\n if (!indexes.some((index) => /\\(\\s*`?phone`?\\s*\\)/.test(index))) {\n changed = true;\n // Unique among the numbers that are set: email-only users have none.\n indexes.push(\n \"CREATE UNIQUE INDEX `idx_users_phone` ON `users` (`phone`) WHERE `phone` != ''\",\n );\n }\n\n if (changed) {\n await pb.collections.update(\"users\", { fields, indexes });\n }\n return changed;\n}\n\n/**\n * Turns WhatsApp sign-in and signup on for `users` in this PocketBase. The\n * plugin keeps that in its own store, which automigrate does not see, so\n * deployments get it from `writeWhatsAppConfigMigration` instead.\n *\n * With no sender configured yet, the sender is `dev`: codes go to the\n * PocketBase log. A deployment's env credentials take precedence over it.\n */\nexport async function enableWhatsAppAuth(pb: PocketBase): Promise<void> {\n await pb.send(\"/api/whatsapp/collections/users\", {\n method: \"PATCH\",\n body: {\n enabled: true,\n allowSignup: true,\n phoneField: \"phone\",\n phoneVerifiedField: \"phoneVerified\",\n },\n });\n\n const response = await pb.send(\"/api/whatsapp/settings\", { method: \"GET\" });\n if (!response?.settings?.mode) {\n await pb.send(\"/api/whatsapp/settings\", {\n method: \"PATCH\",\n body: { mode: \"dev\" },\n });\n }\n}\n\n/** Turns WhatsApp sign-in off for `users` in this PocketBase. */\nexport async function disableWhatsAppAuth(pb: PocketBase): Promise<void> {\n await pb.send(\"/api/whatsapp/collections/users\", {\n method: \"PATCH\",\n body: { enabled: false },\n });\n}\n\nconst CONFIG_MIGRATION = /^\\d+_(enabled|disabled)_whatsapp_users\\.js$/;\n\n/**\n * A migration that sets the plugin's `users` config (`_whatsapp`, key\n * `collection:<id>`) on every PocketBase it runs on. The plugin's own system\n * migration creates `_whatsapp` before any app migration runs.\n *\n * Returns `null`, writing nothing, when the latest such migration already\n * leaves WhatsApp in that state, so a re-run adds no migration.\n */\nexport function writeWhatsAppConfigMigration(\n options: Options,\n enabled: boolean,\n): string | null {\n const dir = path.join(options.root, MIGRATIONS_DIR);\n const latest = fs\n .readdirSync(dir)\n .filter((file) => CONFIG_MIGRATION.test(file))\n .sort()\n .pop();\n if (latest?.includes(enabled ? \"_enabled_\" : \"_disabled_\")) return null;\n\n const config = enabled\n ? {\n enabled: true,\n allowSignup: true,\n phoneField: \"phone\",\n phoneVerifiedField: \"phoneVerified\",\n }\n : { enabled: false };\n const name = `${Math.floor(Date.now() / 1000)}_${enabled ? \"enabled\" : \"disabled\"}_whatsapp_users.js`;\n const file = path.join(dir, name);\n fs.writeFileSync(file, whatsappConfigMigration(config), \"utf8\");\n return file;\n}\n\nfunction whatsappConfigMigration(config: Record<string, unknown>): string {\n return `/// <reference path=\"../pb_data/types.d.ts\" />\n\n// WhatsApp sign-in for users (pocketbase-whatsapp). The plugin keeps this in\n// \\`_whatsapp\\`, which automigrate does not see, so this migration carries it\n// to every deployment. The sender comes from the env (VELASTACK_API_KEY, or\n// WHATSAPP_ACCESS_TOKEN and co.), or Settings > WhatsApp.\nconst CONFIG = ${JSON.stringify(config)};\n\nfunction setConfig(app, values) {\n const users = app.findCollectionByNameOrId(\"users\");\n const key = \"collection:\" + users.id;\n\n let record;\n try {\n record = app.findFirstRecordByData(\"_whatsapp\", \"key\", key);\n } catch {\n record = new Record(app.findCollectionByNameOrId(\"_whatsapp\"));\n record.set(\"key\", key);\n }\n\n let current = {};\n try {\n current = JSON.parse(record.getString(\"value\") || \"{}\");\n } catch {}\n\n record.set(\"value\", JSON.stringify(Object.assign(current, values)));\n app.save(record);\n}\n\nmigrate(\n (app) => setConfig(app, CONFIG),\n (app) => setConfig(app, { enabled: !CONFIG.enabled }),\n);\n`;\n}\n"],"mappings":";;;;AAOA,IAAMG,IAAgB,yBAGTC,IAAwB;AAMrC,eAAsBC,EAAkB,GAAkC;CACxE,IAAI;EAEF,OADA,MAAMC,EAAG,KAAK,6BAA6B,EAAE,QAAQ,MAAM,CAAC,GACrD;CACT,SAASC,GAAY;EACnB,IAAIA,GAAO,WAAW,KAAK,OAAO;EAClC,MAAMA;CACR;AACF;AAiBA,eAAsBC,EAAoB,GAAkC;CAC1E,IAAMC,IAAQ,MAAMH,EAAG,YAAY,OAAO,OAAO,GAC3CI,KAAO,MACXD,EAAM,OAAO,MAAM,MAAwBE,EAAE,SAASC,CAAI,GAExDC,IAAU,IACRC,IAAoCL,EAAM,OAAO,KACpD,MACKM,EAAM,SAAS,WAAWA,EAAM,YAClC,IAAU,IACH;EAAE,GAAGA;EAAO,UAAU;CAAM,KAE9BA,CAEX;CAUA,AATKL,EAAI,OAAO,MACd,IAAU,IACVI,EAAO,KAAK;EACV,MAAM;EACN,MAAM;EACN,SAASX;EACT,KAAK;CACP,CAAC,IAEEO,EAAI,eAAe,MACtB,IAAU,IACVI,EAAO,KAAK;EAAE,MAAM;EAAiB,MAAM;CAAO,CAAC;CAGrD,IAAME,IAAU,CAAC,GAAGP,EAAM,OAAO;CAYjC,OAXKO,EAAQ,MAAM,MAAU,sBAAsB,KAAKC,CAAK,CAAC,MAC5D,IAAU,IAEVD,EAAQ,KACN,gFACF,IAGEH,KACF,MAAMP,EAAG,YAAY,OAAO,SAAS;EAAE;EAAQ;CAAQ,CAAC,GAEnDO;AACT;AAUA,eAAsBK,EAAmB,GAA+B;CA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} from "./errors-DR3gF_7a.js";
|
|
3
|
-
import { d as i,
|
|
3
|
+
import { d as i, o as a, p as o } from "./constants-8cLxGOB0.js";
|
|
4
4
|
import { n as s } from "./format-result-BVoLVknk.js";
|
|
5
5
|
import { n as c, t as l } from "./logger-CQONztPm.js";
|
|
6
|
-
import { a as u, i as d, r as f, t as p } from "./table-core-
|
|
6
|
+
import { a as u, i as d, r as f, t as p } from "./table-core-CUGp4Rf2.js";
|
|
7
7
|
import { cpSync as m, existsSync as h, mkdirSync as g, mkdtempSync as _, readFileSync as v, readdirSync as y, rmSync as b, statSync as x, writeFileSync as S } from "node:fs";
|
|
8
8
|
import C from "node:path";
|
|
9
9
|
import { detect as w } from "package-manager-detector";
|
|
@@ -48,14 +48,14 @@ var te = "<script lang=\"ts\">\n import { cn } from '#lib/utils.js';\n import *
|
|
|
48
48
|
leaflet: [],
|
|
49
49
|
"auth-menu": ["dropdown-menu", "button"]
|
|
50
50
|
}, et = {
|
|
51
|
-
"file-form": [
|
|
52
|
-
multiselect: [
|
|
51
|
+
"file-form": [a],
|
|
52
|
+
multiselect: [a],
|
|
53
53
|
geopoint: [],
|
|
54
54
|
cells: [],
|
|
55
|
-
"data-table": [
|
|
56
|
-
"column-header": [
|
|
57
|
-
"faceted-filter": [
|
|
58
|
-
pagination: [
|
|
55
|
+
"data-table": [o],
|
|
56
|
+
"column-header": [o],
|
|
57
|
+
"faceted-filter": [o],
|
|
58
|
+
pagination: [o],
|
|
59
59
|
"row-actions": [],
|
|
60
60
|
leaflet: ["leaflet", "@types/leaflet"]
|
|
61
61
|
}, M = /* #__PURE__ */ Object.assign({
|
|
@@ -206,11 +206,11 @@ function V(e) {
|
|
|
206
206
|
return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(e.slice(t.length + 1));
|
|
207
207
|
}
|
|
208
208
|
function H(e, t, n, r) {
|
|
209
|
-
let
|
|
209
|
+
let o = new Set(n.map(B)), s = o.has("formsnap") || t.has("formsnap"), c = o.has("formsnap") || o.has("sveltekit-superforms");
|
|
210
210
|
if (!s || !c) return;
|
|
211
211
|
let l = C.join(e, "package.json");
|
|
212
212
|
if (!h(l)) return;
|
|
213
|
-
let u = v(l, "utf8"), d = JSON.parse(u), f = [], p =
|
|
213
|
+
let u = v(l, "utf8"), d = JSON.parse(u), f = [], p = a.slice(B(a).length + 1), m = G(p);
|
|
214
214
|
for (let e of W) {
|
|
215
215
|
let t = d[e];
|
|
216
216
|
if (!t) continue;
|
|
@@ -445,7 +445,7 @@ async function mt(e, t, n) {
|
|
|
445
445
|
collectionDrops: []
|
|
446
446
|
}, a = [];
|
|
447
447
|
if (e.collectionDrops.length > 0) {
|
|
448
|
-
let { dropCollections: n } = await import("./collections-
|
|
448
|
+
let { dropCollections: n } = await import("./collections-DzwWwFUQ.js").then((e) => e.n);
|
|
449
449
|
a = await n(e.collectionDrops, t);
|
|
450
450
|
}
|
|
451
451
|
let o = C.resolve(t.root, "package.json"), s = (e) => e.status === "success" && C.resolve(F(t.root, e.path)) === o;
|
|
@@ -496,4 +496,4 @@ async function mt(e, t, n) {
|
|
|
496
496
|
//#endregion
|
|
497
497
|
export { Q as a, B as c, $ as i, Qe as l, Z as n, z as o, N as r, X as s, R as t };
|
|
498
498
|
|
|
499
|
-
//# sourceMappingURL=write-result-
|
|
499
|
+
//# sourceMappingURL=write-result-mtVbmDyQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-result-DcqMefuP.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","SUPERFORMS_VERSION","TANSTACK_TABLE_CORE","formatSource","getLogger","NOOP_LOGGER","resolveUiDir","readComponentsConfig","fetchRegistryIndex","assertTableCorePackage","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","FORMSNAP","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","resolve","restoreTypes","preserveSvelteKitTypes","cwd","runtime","packageJsonPath","packageJson","readFileSync","at","spec","name","reconcileFormsnap","names","toInstall","formsnap","installed","touched","file","text","pkg","changed","formsnapRange","wantedFloor","rangeFloor","block","DEPENDENCY_BLOCKS","deps","floor","compareFloors","overrides","entry","_","rest","__","others","next","indent","logger","appDir","saved","mkdtempSync","cpSync","error","match","part","value","i","a","b","after","restored","previous","before","entries","old","oldFloor","newFloor","readPackageJson","installPackages","packages","exact","ranged","uninstallPackages","toRemove","component","customNpmPackagesFor","components","copyCustomComponent","targetDir","targetComponentsDir","relativePath","outputPath","FORMATTABLE_EXTENSIONS","filesUnder","target","statSync","context","paths","formatted","uiDir","BARE_ITEM_NAME","assertKnownRegistryItems","bare","known","item","unknown","style","requested","componentsDir","isPresent","skipped","overwrite","customToInstall","publicToInstall","dependency","customList","publicList","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 SUPERFORMS_VERSION,\n TANSTACK_TABLE_CORE,\n} from \"../core/constants\";\nimport {\n fetchRegistryIndex,\n readComponentsConfig,\n resolveUiDir,\n} from \"./registry\";\nimport { assertTableCorePackage } from \"./table-core\";\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`),\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.1 is the first release whose superforms peer admits 3.x, and\n * npm reads that `^3.0.0` peer as excluding `3.0.0-next.*`. Before an install\n * brings formsnap or superforms in next to the other, package.json is moved\n * to what resolves: a `3.0.0-next` superforms pin to the release, a formsnap\n * range below 2.1 to `FORMSNAP`, and the `overrides` entry earlier releases\n * wrote for formsnap 2.0 goes. Left as it is, `npm install` either stops with\n * ERESOLVE or keeps the formsnap 2.0 its lockfile holds, whose peer\n * superforms 3 does not meet.\n */\nfunction reconcileFormsnap(\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 file = path.join(root, \"package.json\");\n if (!existsSync(file)) {\n return;\n }\n const text = readFileSync(file, \"utf8\");\n const pkg = JSON.parse(text) as Record<string, unknown>;\n const changed: string[] = [];\n\n const formsnapRange = FORMSNAP.slice(packageName(FORMSNAP).length + 1);\n const wantedFloor = rangeFloor(formsnapRange)!;\n for (const block of DEPENDENCY_BLOCKS) {\n const deps = pkg[block] as Record<string, string> | undefined;\n if (!deps) {\n continue;\n }\n if (deps[\"sveltekit-superforms\"]?.startsWith(\"3.0.0-\")) {\n deps[\"sveltekit-superforms\"] = SUPERFORMS_VERSION;\n changed.push(`sveltekit-superforms → ${SUPERFORMS_VERSION}`);\n }\n const floor =\n deps.formsnap === undefined ? null : rangeFloor(deps.formsnap);\n if (floor && compareFloors(floor, wantedFloor) < 0) {\n deps.formsnap = formsnapRange;\n changed.push(`formsnap → ${formsnapRange}`);\n }\n }\n\n const overrides = pkg.overrides as Record<string, unknown> | undefined;\n const entry = overrides?.formsnap;\n if (\n typeof entry === \"object\" &&\n entry !== null &&\n \"sveltekit-superforms\" in entry\n ) {\n const { \"sveltekit-superforms\": _, ...rest } = entry as Record<\n string,\n unknown\n >;\n const { formsnap: __, ...others } = overrides!;\n const next =\n Object.keys(rest).length > 0 ? { ...others, formsnap: rest } : others;\n if (Object.keys(next).length > 0) {\n pkg.overrides = next;\n } else {\n delete pkg.overrides;\n }\n changed.push(\"dropped the overrides entry formsnap 2.0 needed\");\n }\n\n if (changed.length === 0) {\n return;\n }\n const indent = text.match(/^[{]\\s*\\n([\\t ]+)/)?.[1] ?? \"\\t\";\n writeFileSync(file, `${JSON.stringify(pkg, null, indent)}\\n`, \"utf8\");\n logger.info(`formsnap 2.1 peers superforms 3: ${changed.join(\", \")}`);\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 reconcileFormsnap(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 reconcileFormsnap(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":";;;;;;;;;;;;;;;;;;;;;;;;;;;A,IAyDM6I,KAA+C;CACnD,aAAa,CAAC,OAAO;CACrB,aAAa;EAAC;EAAW;EAAW;CAAQ;CAC5C,UAAU,CAAC,UAAU,SAAS;CAC9B,OAAO,CAAC,OAAO;CACf,cAAc,CAAC;CACf,iBAAiB,CAAC,iBAAiB,QAAQ;CAC3C,kB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9C,CAAC;CAGH,KAAK,IAAMA,KAAQqF,EAAO,SACxB,AAAIrF,EAAK,WAAW,YAOhBtC,EAAWT,EAAa0B,EAAQ,MAAMqB,EAAK,IAAI,CAAC,MAClDvC,GAAWR,EAAa0B,EAAQ,MAAMqB,EAAK,IAAI,GAAGrB,EAAQ,IAAI,GAC9DwG,EAAc,QAAQ,KAAK;EACzB,GAAGnF;EACH,MAAM5C,EAAeuB,EAAQ,MAAMqB,EAAK,IAAI;CAC9C,CAAC,KAXDmF,EAAc,QAAQ,KAAK;EACzB,GAAGnF;EACH,MAAM5C,EAAeuB,EAAQ,MAAMqB,EAAK,IAAI;CAC9C,CAAC;CAYL,OAAO;EACL,GAAGqF;EACH,SAASF,EAAc;EACvB,UAAUA,EAAc;EACxB,SAASA,EAAc;EACvB,YAAYO,EAAkB;EAC9B,UAAU,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAGD,GAAiB,GAAGC,EAAkB,QAAQ,CAAC,CAAC;EAC1E,GAAIC,EAAkB,SAAS,IAAI,EAAE,YAAYA,EAAkB,IAAI,CAAC;CAC1E;AACF"}
|
|
1
|
+
{"version":3,"file":"write-result-mtVbmDyQ.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","SUPERFORMS_VERSION","FORMSNAP","TANSTACK_TABLE_CORE","formatSource","getLogger","NOOP_LOGGER","resolveUiDir","readComponentsConfig","fetchRegistryIndex","assertTableCorePackage","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","resolve","restoreTypes","preserveSvelteKitTypes","cwd","runtime","packageJsonPath","packageJson","readFileSync","at","spec","name","reconcileFormsnap","names","toInstall","formsnap","installed","touched","file","text","pkg","changed","formsnapRange","wantedFloor","rangeFloor","block","DEPENDENCY_BLOCKS","deps","floor","compareFloors","overrides","entry","_","rest","__","others","next","indent","logger","appDir","saved","mkdtempSync","cpSync","error","match","part","value","i","a","b","after","restored","previous","before","entries","old","oldFloor","newFloor","readPackageJson","installPackages","packages","exact","ranged","uninstallPackages","toRemove","component","customNpmPackagesFor","components","copyCustomComponent","targetDir","targetComponentsDir","relativePath","outputPath","FORMATTABLE_EXTENSIONS","filesUnder","target","statSync","context","paths","formatted","uiDir","BARE_ITEM_NAME","assertKnownRegistryItems","bare","known","item","unknown","style","requested","componentsDir","isPresent","skipped","overwrite","customToInstall","publicToInstall","dependency","customList","publicList","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 SUPERFORMS_VERSION,\n TANSTACK_TABLE_CORE,\n} from \"../core/constants\";\nimport {\n fetchRegistryIndex,\n readComponentsConfig,\n resolveUiDir,\n} from \"./registry\";\nimport { assertTableCorePackage } from \"./table-core\";\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`),\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.1 is the first release whose superforms peer admits 3.x, and\n * npm reads that `^3.0.0` peer as excluding `3.0.0-next.*`. Before an install\n * brings formsnap or superforms in next to the other, package.json is moved\n * to what resolves: a `3.0.0-next` superforms pin to the release, a formsnap\n * range below 2.1 to `FORMSNAP`, and the `overrides` entry earlier releases\n * wrote for formsnap 2.0 goes. Left as it is, `npm install` either stops with\n * ERESOLVE or keeps the formsnap 2.0 its lockfile holds, whose peer\n * superforms 3 does not meet.\n */\nfunction reconcileFormsnap(\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 file = path.join(root, \"package.json\");\n if (!existsSync(file)) {\n return;\n }\n const text = readFileSync(file, \"utf8\");\n const pkg = JSON.parse(text) as Record<string, unknown>;\n const changed: string[] = [];\n\n const formsnapRange = FORMSNAP.slice(packageName(FORMSNAP).length + 1);\n const wantedFloor = rangeFloor(formsnapRange)!;\n for (const block of DEPENDENCY_BLOCKS) {\n const deps = pkg[block] as Record<string, string> | undefined;\n if (!deps) {\n continue;\n }\n if (deps[\"sveltekit-superforms\"]?.startsWith(\"3.0.0-\")) {\n deps[\"sveltekit-superforms\"] = SUPERFORMS_VERSION;\n changed.push(`sveltekit-superforms → ${SUPERFORMS_VERSION}`);\n }\n const floor =\n deps.formsnap === undefined ? null : rangeFloor(deps.formsnap);\n if (floor && compareFloors(floor, wantedFloor) < 0) {\n deps.formsnap = formsnapRange;\n changed.push(`formsnap → ${formsnapRange}`);\n }\n }\n\n const overrides = pkg.overrides as Record<string, unknown> | undefined;\n const entry = overrides?.formsnap;\n if (\n typeof entry === \"object\" &&\n entry !== null &&\n \"sveltekit-superforms\" in entry\n ) {\n const { \"sveltekit-superforms\": _, ...rest } = entry as Record<\n string,\n unknown\n >;\n const { formsnap: __, ...others } = overrides!;\n const next =\n Object.keys(rest).length > 0 ? { ...others, formsnap: rest } : others;\n if (Object.keys(next).length > 0) {\n pkg.overrides = next;\n } else {\n delete pkg.overrides;\n }\n changed.push(\"dropped the overrides entry formsnap 2.0 needed\");\n }\n\n if (changed.length === 0) {\n return;\n }\n const indent = text.match(/^[{]\\s*\\n([\\t ]+)/)?.[1] ?? \"\\t\";\n writeFileSync(file, `${JSON.stringify(pkg, null, indent)}\\n`, \"utf8\");\n logger.info(`formsnap 2.1 peers superforms 3: ${changed.join(\", \")}`);\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 reconcileFormsnap(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 reconcileFormsnap(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":";;;;;;;;;;;;;;;;;;;;;;;;;;;A,IAyDM8I,KAA+C;CACnD,aAAa,CAAC,OAAO;CACrB,aAAa;EAAC;EAAW;EAAW;CAAQ;CAC5C,UAAU,CAAC,UAAU,SAAS;CAC9B,OAAO,CAAC,OAAO;CACf,cAAc,CAAC;CACf,iBAAiB,CAAC,iBAAiB,QAAQ;CAC3C,kBAAkB;EAAC;EAAW;EAAW;EAAU;EAAa;CAAO;CACvE,YAAY,CAAC,UAAU,QAAQ;CAC/B,eAAe,CAAC,iBAAiB,QAAQ;CACzC,SAAS,CAAC;CACV,aAAa,CAAC,iBAAiB,QAAQ;AACzC,GAEMC,KAAuC;CAC3C,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