@velastack/patterns 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +10 -1
  2. package/dist/chunks/{collections-DcnlHh80.js → collections-1Z0NCLM-.js} +3 -3
  3. package/dist/chunks/{collections-DcnlHh80.js.map → collections-1Z0NCLM-.js.map} +1 -1
  4. package/dist/chunks/errors-D6gyegUK.js +14 -0
  5. package/dist/chunks/errors-D6gyegUK.js.map +1 -0
  6. package/dist/chunks/{generate-3QOmCHGZ.js → generate-vRi-W3rL.js} +2 -2
  7. package/dist/chunks/{generate-3QOmCHGZ.js.map → generate-vRi-W3rL.js.map} +1 -1
  8. package/dist/chunks/{generate.runtime-DURymKCu.js → generate.runtime-BHoIbpFW.js} +2 -2
  9. package/dist/chunks/{generate.runtime-DURymKCu.js.map → generate.runtime-BHoIbpFW.js.map} +1 -1
  10. package/dist/chunks/{generate.runtime-CsGO0zuZ.js → generate.runtime-BhgkUhnZ.js} +2 -2
  11. package/dist/chunks/{generate.runtime-CsGO0zuZ.js.map → generate.runtime-BhgkUhnZ.js.map} +1 -1
  12. package/dist/chunks/{generate.runtime-4QI3es6J.js → generate.runtime-BiQzi7ie.js} +2 -2
  13. package/dist/chunks/{generate.runtime-4QI3es6J.js.map → generate.runtime-BiQzi7ie.js.map} +1 -1
  14. package/dist/chunks/{generate.runtime-CVc_YHTk.js → generate.runtime-C3kgmLls.js} +2 -2
  15. package/dist/chunks/{generate.runtime-CVc_YHTk.js.map → generate.runtime-C3kgmLls.js.map} +1 -1
  16. package/dist/chunks/{generate.runtime-Bhr2eJg6.js → generate.runtime-CbSifpZG.js} +3 -3
  17. package/dist/chunks/{generate.runtime-Bhr2eJg6.js.map → generate.runtime-CbSifpZG.js.map} +1 -1
  18. package/dist/chunks/{generate.runtime-CL7NYB3N.js → generate.runtime-CflCO_6s.js} +2 -2
  19. package/dist/chunks/{generate.runtime-CL7NYB3N.js.map → generate.runtime-CflCO_6s.js.map} +1 -1
  20. package/dist/chunks/{generate.runtime-CAEeX7Pf.js → generate.runtime-CqOjFGKT.js} +3 -3
  21. package/dist/chunks/{generate.runtime-CAEeX7Pf.js.map → generate.runtime-CqOjFGKT.js.map} +1 -1
  22. package/dist/chunks/{generate.runtime-D0D5jods.js → generate.runtime-DUFPsIYY.js} +3 -3
  23. package/dist/chunks/{generate.runtime-D0D5jods.js.map → generate.runtime-DUFPsIYY.js.map} +1 -1
  24. package/dist/chunks/{generate.runtime-CAzHPuHk.js → generate.runtime-DYySjH4f.js} +2 -2
  25. package/dist/chunks/{generate.runtime-CAzHPuHk.js.map → generate.runtime-DYySjH4f.js.map} +1 -1
  26. package/dist/chunks/{generate.runtime-B3IKmGyV.js → generate.runtime-DpgPAnEd.js} +2 -2
  27. package/dist/chunks/{generate.runtime-B3IKmGyV.js.map → generate.runtime-DpgPAnEd.js.map} +1 -1
  28. package/dist/chunks/{generate.runtime-CsBQGP_O.js → generate.runtime-JtRQn3Yl.js} +2 -2
  29. package/dist/chunks/{generate.runtime-CsBQGP_O.js.map → generate.runtime-JtRQn3Yl.js.map} +1 -1
  30. package/dist/chunks/pocketbase-059B1oot.js +228 -0
  31. package/dist/chunks/pocketbase-059B1oot.js.map +1 -0
  32. package/dist/chunks/{shared-ClWQZdMa.js → shared-CaHmNkZE.js} +2 -2
  33. package/dist/chunks/{shared-ClWQZdMa.js.map → shared-CaHmNkZE.js.map} +1 -1
  34. package/dist/chunks/ui-DAtVMiVs.js +173 -0
  35. package/dist/chunks/ui-DAtVMiVs.js.map +1 -0
  36. package/dist/chunks/write-result-BHCOxcsA.js +445 -0
  37. package/dist/chunks/write-result-BHCOxcsA.js.map +1 -0
  38. package/dist/index.d.ts +109 -1
  39. package/dist/index.js +1878 -1842
  40. package/dist/index.js.map +1 -1
  41. package/package.json +2 -1
  42. package/dist/chunks/errors-D3Zy3wCg.js +0 -10
  43. package/dist/chunks/errors-D3Zy3wCg.js.map +0 -1
  44. package/dist/chunks/pocketbase-fERkp8b8.js +0 -123
  45. package/dist/chunks/pocketbase-fERkp8b8.js.map +0 -1
  46. package/dist/chunks/write-result-8JW_vky2.js +0 -355
  47. package/dist/chunks/write-result-8JW_vky2.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-result-BHCOxcsA.js","names":[],"sources":["../../src/runtime/registry.ts","../../src/runtime/write-result.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { RegistryItem, WriteResultRuntime } from \"../core/types\";\nimport { RegistryUnavailableError } from \"../core/errors\";\n\n/**\n * shadcn-svelte's schema defaults. A `components.json` that names no `style`\n * resolves to `nova` (not `vega`, whatever `getRegistryUrl`'s fallback says),\n * which is why the CLI's templates write the key explicitly.\n */\nexport const DEFAULT_STYLE = \"nova\";\nexport const DEFAULT_REGISTRY = \"https://shadcn-svelte.com/registry\";\nexport const DEFAULT_CSS_PATH = \"src/app.css\";\n\nconst REGISTRY_TIMEOUT_MS = 10_000;\n\nexport interface ComponentsConfig {\n style: string;\n registry: string;\n baseColor?: string;\n iconLibrary?: string;\n menuColor?: string;\n menuAccent?: string;\n aliases: Record<string, string>;\n /** `tailwind.css`: the global stylesheet, relative to the root. */\n cssPath: string;\n}\n\ninterface RawComponentsConfig {\n style?: unknown;\n registry?: unknown;\n iconLibrary?: unknown;\n menuColor?: unknown;\n menuAccent?: unknown;\n tailwind?: { css?: unknown; baseColor?: unknown };\n aliases?: Record<string, unknown>;\n}\n\nfunction optionalString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\n/**\n * The project's `components.json` with the schema defaults filled in. A\n * missing or unreadable file behaves like an empty one, so callers can still\n * compute paths and the existence checks here agree with shadcn's own.\n */\nexport function readComponentsConfig(root: string): ComponentsConfig {\n let raw: RawComponentsConfig = {};\n const configPath = path.join(root, \"components.json\");\n if (existsSync(configPath)) {\n try {\n const parsed: unknown = JSON.parse(readFileSync(configPath, \"utf8\"));\n if (parsed && typeof parsed === \"object\") {\n raw = parsed as RawComponentsConfig;\n }\n } catch {\n raw = {};\n }\n }\n\n const aliases: Record<string, string> = {};\n for (const [key, value] of Object.entries(raw.aliases ?? {})) {\n const alias = optionalString(value);\n if (alias) aliases[key] = alias;\n }\n\n return {\n style: optionalString(raw.style) ?? DEFAULT_STYLE,\n registry: optionalString(raw.registry) ?? DEFAULT_REGISTRY,\n baseColor: optionalString(raw.tailwind?.baseColor),\n iconLibrary: optionalString(raw.iconLibrary),\n menuColor: optionalString(raw.menuColor),\n menuAccent: optionalString(raw.menuAccent),\n aliases,\n cssPath: optionalString(raw.tailwind?.css) ?? DEFAULT_CSS_PATH,\n };\n}\n\n/** `${registry}/styles/${style}/index.json`: the items one style offers. */\nexport function registryIndexUrl(registry: string, style: string): string {\n return `${registry.replace(/\\/+$/, \"\")}/styles/${encodeURIComponent(style)}/index.json`;\n}\n\n/**\n * One request per registry URL per process, keyed on the fetch implementation\n * so an injected test double never sees another test's answer and the real\n * `fetch` shares its answer across a style switch and the installs it runs.\n */\nconst indexCache = new WeakMap<\n typeof fetch,\n Map<string, Promise<RegistryItem[]>>\n>();\n\nfunction parseIndex(body: unknown): RegistryItem[] {\n if (!Array.isArray(body)) {\n throw new Error(\"the index is not a list\");\n }\n const items: RegistryItem[] = [];\n for (const entry of body) {\n if (!entry || typeof entry !== \"object\") continue;\n const { name, type } = entry as { name?: unknown; type?: unknown };\n if (typeof name === \"string\" && typeof type === \"string\") {\n items.push({ name, type });\n }\n }\n return items;\n}\n\nasync function requestIndex(\n url: string,\n fetchImpl: typeof fetch,\n): Promise<RegistryItem[]> {\n let response: Response;\n try {\n response = await fetchImpl(url, {\n signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS),\n });\n } catch (error) {\n const reason =\n error instanceof Error && error.name === \"TimeoutError\"\n ? `no answer within ${REGISTRY_TIMEOUT_MS / 1000}s`\n : error instanceof Error\n ? error.message\n : String(error);\n throw new RegistryUnavailableError(url, reason);\n }\n if (!response.ok) {\n throw new RegistryUnavailableError(url, `HTTP ${response.status}`);\n }\n try {\n return parseIndex(await response.json());\n } catch (error) {\n throw new RegistryUnavailableError(\n url,\n error instanceof Error ? error.message : String(error),\n );\n }\n}\n\n/**\n * The items the project's registry offers for a style: the configured one by\n * default, or `options.style` to look at the style a project is about to\n * switch to. Throws `RegistryUnavailableError` when the index cannot be read.\n */\nexport async function fetchRegistryIndex(\n root: string,\n options: { style?: string; runtime?: WriteResultRuntime } = {},\n): Promise<RegistryItem[]> {\n const config = readComponentsConfig(root);\n const url = registryIndexUrl(config.registry, options.style ?? config.style);\n const fetchImpl = options.runtime?.fetch ?? globalThis.fetch;\n\n let cache = indexCache.get(fetchImpl);\n if (!cache) {\n cache = new Map();\n indexCache.set(fetchImpl, cache);\n }\n let pending = cache.get(url);\n if (!pending) {\n pending = requestIndex(url, fetchImpl).catch((error: unknown) => {\n // A failed read is not worth remembering: the next command may be online.\n cache.delete(url);\n throw error;\n });\n cache.set(url, pending);\n }\n return pending;\n}\n","import {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\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 InstallComponentsOptions,\n InstallComponentsResult,\n Options,\n PackageManagerOperation,\n Result,\n WriteResultRuntime,\n} from \"../core/types\";\nimport { InvalidArgumentError, RegistryUnavailableError } from \"../core/errors\";\nimport { getLogger, NOOP_LOGGER, type Logger } from \"../core/logger\";\nimport { formatSource } from \"../core/format-result\";\nimport { FORMSNAP, TANSTACK_TABLE_CORE } from \"../core/constants\";\nimport { fetchRegistryIndex, readComponentsConfig } from \"./registry\";\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 `$lib/components/ui/<x>` import a component makes\n * must appear in `customDependencies`, and every npm package that no shadcn\n * item installs for it must appear in `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\nasync function executeWithDetectedPackageManager(\n cwd: string,\n operation: PackageManagerOperation,\n args: string[],\n): Promise<void> {\n const packageManager = (await detect({ cwd }))?.name ?? \"npm\";\n const resolved = resolveCommand(packageManager, operation, args);\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\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): Promise<void> {\n if (runtime?.executeCommand) {\n await runtime.executeCommand(cwd, operation, args);\n return;\n }\n\n await executeWithDetectedPackageManager(cwd, operation, args);\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\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 logger.info(`Installing packages: ${toInstall.join(\", \")}`);\n await executeCommand(root, \"install\", toInstall, runtime);\n return toInstall;\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 DEFAULT_UI_DIR = [\"src\", \"lib\", \"components\", \"ui\"];\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/**\n * Where shadcn-svelte writes items: `components.json` `aliases.ui`, resolved\n * the way SvelteKit resolves `$lib` (`src/lib`). Anything else (a custom\n * `kit.alias`, a missing or unreadable config) falls back to the default so\n * the existence check here and shadcn's own target agree for every project\n * the CLI creates.\n */\nexport function resolveUiDir(root: string): string {\n const alias = readComponentsConfig(root).aliases.ui;\n if (alias === \"$lib\") {\n return path.join(root, \"src\", \"lib\");\n }\n if (alias?.startsWith(\"$lib/\")) {\n return path.join(root, \"src\", \"lib\", ...alias.slice(5).split(\"/\"));\n }\n return path.join(root, ...DEFAULT_UI_DIR);\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 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 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 await executeCommand(\n root,\n \"execute\",\n [\"shadcn-svelte\", \"add\", \"--yes\", \"--overwrite\", ...publicList],\n runtime,\n );\n installed.push(...publicList);\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 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 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 (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 };\n}\n"],"mappings":";;;;;;;;;AAcA,IAAM,IAAsB;AAwB5B,SAAS,EAAe,GAAoC;CAC1D,OAAO,OAAO,KAAU,YAAY,EAAM,SAAS,IAAI,IAAQ,KAAA;AACjE;AAOA,SAAgB,EAAqB,GAAgC;CACnE,IAAI,IAA2B,CAAC,GAC1B,IAAa,EAAK,KAAK,GAAM,iBAAiB;CACpD,IAAI,EAAW,CAAU,GACvB,IAAI;EACF,IAAM,IAAkB,KAAK,MAAM,EAAa,GAAY,MAAM,CAAC;EACnE,AAAI,KAAU,OAAO,KAAW,aAC9B,IAAM;CAEV,QAAQ;EACN,IAAM,CAAC;CACT;CAGF,IAAM,IAAkC,CAAC;CACzC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,EAAI,WAAW,CAAC,CAAC,GAAG;EAC5D,IAAM,IAAQ,EAAe,CAAK;EAClC,AAAI,MAAO,EAAQ,KAAO;CAC5B;CAEA,OAAO;EACL,OAAO,EAAe,EAAI,KAAK,KAAA;EAC/B,UAAU,EAAe,EAAI,QAAQ,KAAA;EACrC,WAAW,EAAe,EAAI,UAAU,SAAS;EACjD,aAAa,EAAe,EAAI,WAAW;EAC3C,WAAW,EAAe,EAAI,SAAS;EACvC,YAAY,EAAe,EAAI,UAAU;EACzC;EACA,SAAS,EAAe,EAAI,UAAU,GAAG,KAAA;CAC3C;AACF;AAGA,SAAgB,EAAiB,GAAkB,GAAuB;CACxE,OAAO,GAAG,EAAS,QAAQ,QAAQ,EAAE,EAAE,UAAU,mBAAmB,CAAK,EAAE;AAC7E;AAOA,IAAM,o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ets the base palette through `shadcn-svelte apply`. */
2
+ export declare function applyBaseColor(options: ApplyBaseColorOptions, runtime?: WriteResultRuntime): Promise<ApplyColorsResult>;
3
+
4
+ export declare interface ApplyBaseColorOptions {
5
+ root: string;
6
+ /** One of shadcn-svelte's base colors: `neutral`, `stone`, `zinc`, `mauve`, `olive`, `mist`, `taupe`. */
7
+ color: string;
8
+ }
9
+
10
+ export declare interface ApplyColorsResult {
11
+ /** What `components.json` records after the run. */
12
+ baseColor: string;
13
+ /** The accent applied to the tokens; the base color itself for `applyBaseColor`. */
14
+ theme: string;
15
+ /** Relative paths written this run. */
16
+ filesModified: string[];
17
+ }
18
+
19
+ /** Sets the accent color through `shadcn-svelte apply`, keeping the base palette. */
20
+ export declare function applyTheme(options: ApplyThemeOptions, runtime?: WriteResultRuntime): Promise<ApplyColorsResult>;
21
+
22
+ export declare interface ApplyThemeOptions {
23
+ root: string;
24
+ /** A base color or an accent (`blue`, `rose`, `emerald`, ...). */
25
+ theme: string;
26
+ }
27
+
1
28
  export declare const byCategory: Record<"auth" | "content" | "generators" | "api" | "backend" | "i18n" | "payments", ({
2
29
  version: string;
3
30
  slug: "generate-form";
@@ -1267,6 +1294,30 @@ export declare class InvalidArgumentError extends Error {
1267
1294
  constructor(message: string);
1268
1295
  }
1269
1296
 
1297
+ /**
1298
+ * What a project has installed, what this package can copy in, and what the
1299
+ * configured style's registry offers. Node-only, loaded on first call like
1300
+ * `installComponents`.
1301
+ */
1302
+ export declare function listComponents(options: ListComponentsOptions, runtime?: WriteResultRuntime): Promise<ListComponentsResult>;
1303
+
1304
+ export declare interface ListComponentsOptions {
1305
+ root: string;
1306
+ }
1307
+
1308
+ export declare interface ListComponentsResult {
1309
+ /** The style `components.json` names (shadcn-svelte's default when it names none). */
1310
+ style: string;
1311
+ /** Directories under the project's ui directory, sorted. */
1312
+ installed: Component[];
1313
+ /** The components this package ships (`data-table`, `multiselect`, ...), sorted. */
1314
+ custom: Component[];
1315
+ /** Every item the style's registry index lists; empty when the registry could not be read. */
1316
+ registry: RegistryItem[];
1317
+ /** Why `registry` is empty, when the registry could not be read. */
1318
+ registryUnavailable?: string;
1319
+ }
1320
+
1270
1321
  declare interface Logger {
1271
1322
  info: (message: string) => void;
1272
1323
  }
@@ -2374,6 +2425,24 @@ export declare const patterns: ({
2374
2425
  generate: generate_33;
2375
2426
  })[];
2376
2427
 
2428
+ /** One entry of a style's registry index (`/registry/styles/<style>/index.json`). */
2429
+ export declare interface RegistryItem {
2430
+ name: string;
2431
+ /** `registry:ui`, `registry:block`, `registry:hook`, `registry:lib`, `registry:font`, ... */
2432
+ type: string;
2433
+ }
2434
+
2435
+ /**
2436
+ * The shadcn-svelte registry could not be read (offline, a proxy, an outage).
2437
+ * Callers that only need the registry for a nicety, such as name checks or a
2438
+ * listing, catch this and degrade; callers that cannot proceed without it let
2439
+ * it surface as-is.
2440
+ */
2441
+ export declare class RegistryUnavailableError extends Error {
2442
+ readonly url: string;
2443
+ constructor(url: string, reason: string);
2444
+ }
2445
+
2377
2446
  declare interface Result {
2378
2447
  creates: File_2[];
2379
2448
  modifies: File_2[];
@@ -2387,11 +2456,50 @@ declare interface Result {
2387
2456
 
2388
2457
  export declare type Slug = PatternEntry["slug"];
2389
2458
 
2459
+ /** Moves a project to another shadcn-svelte style, re-adding its registry components. */
2460
+ export declare function switchStyle(options: SwitchStyleOptions, runtime?: WriteResultRuntime): Promise<SwitchStyleResult>;
2461
+
2462
+ export declare interface SwitchStyleOptions {
2463
+ root: string;
2464
+ /** One of shadcn-svelte's styles: `nova`, `vega`, `maia`, ... */
2465
+ style: string;
2466
+ /**
2467
+ * Also apply the style's preset font (fontsource import, `--font-sans`,
2468
+ * `html { @apply font-sans }`), which is most of what makes a style look
2469
+ * as designed. Defaults to true.
2470
+ */
2471
+ font?: boolean;
2472
+ /**
2473
+ * Called with the components about to be re-added from the new style's
2474
+ * registry, before anything is written; return false to abort.
2475
+ */
2476
+ confirm?: (components: Component[]) => Promise<boolean> | boolean;
2477
+ logger?: Logger;
2478
+ }
2479
+
2480
+ export declare interface SwitchStyleResult {
2481
+ /** `unchanged` when the project already had the style, `cancelled` when `confirm` said no. */
2482
+ status: "switched" | "unchanged" | "cancelled";
2483
+ style: string;
2484
+ /** Registry components re-added from the new style, sorted. */
2485
+ reinstalled: Component[];
2486
+ /** Relative paths written this run. */
2487
+ filesModified: string[];
2488
+ /** Packages that appeared in `package.json` this run (the preset font). */
2489
+ packages: Package[];
2490
+ /** Things worth a look afterwards, such as a previous font import left in the stylesheet. */
2491
+ hints: string[];
2492
+ }
2493
+
2390
2494
  export declare const version: string;
2391
2495
 
2392
- /** Replaces the package-manager spawn; the test seam for anything that installs. */
2496
+ /**
2497
+ * The seams for anything that leaves the process: the package-manager spawn
2498
+ * and the HTTP client the shadcn-svelte registry is read with.
2499
+ */
2393
2500
  export declare interface WriteResultRuntime {
2394
2501
  executeCommand?: ExecuteCommand;
2502
+ fetch?: typeof fetch;
2395
2503
  }
2396
2504
 
2397
2505
  export { }