{"id":26293908,"url":"https://github.com/nrjdalal/smart-registry","last_synced_at":"2025-06-23T01:41:35.058Z","repository":{"id":279520378,"uuid":"939103947","full_name":"nrjdalal/smart-registry","owner":"nrjdalal","description":"A zero-configuration (no registry.json required), shadcn add / open in v0 compatible registry builder. With amazing visual feedback like how many dependencies and files are being added to a file/component and much more.","archived":false,"fork":false,"pushed_at":"2025-06-16T00:36:16.000Z","size":18664,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-16T01:33:09.862Z","etag":null,"topics":["components","nextjs","radix-ui","react","registry","shadcn","smart","tailwind","ui","v0"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/smart-registry","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nrjdalal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-26T01:58:53.000Z","updated_at":"2025-06-12T19:15:48.000Z","dependencies_parsed_at":"2025-06-08T01:35:36.181Z","dependency_job_id":null,"html_url":"https://github.com/nrjdalal/smart-registry","commit_stats":null,"previous_names":["nrjdalal/smart-registry"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nrjdalal/smart-registry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjdalal%2Fsmart-registry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjdalal%2Fsmart-registry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjdalal%2Fsmart-registry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjdalal%2Fsmart-registry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nrjdalal","download_url":"https://codeload.github.com/nrjdalal/smart-registry/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrjdalal%2Fsmart-registry/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260083145,"owners_count":22956385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["components","nextjs","radix-ui","react","registry","shadcn","smart","tailwind","ui","v0"],"created_at":"2025-03-15T02:35:08.782Z","updated_at":"2025-06-23T01:41:30.034Z","avatar_url":"https://github.com/nrjdalal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Smart Registry\n\nDrop-in replacement for `shadcn build`, generate non-error prone registry with automatic detection of dependencies and files.\n\n[![Twitter](https://img.shields.io/twitter/follow/nrjdalal_com?label=%40nrjdalal_com)](https://twitter.com/nrjdalal_com)\n[![npm](https://img.shields.io/npm/v/smart-registry?color=red\u0026logo=npm)](https://www.npmjs.com/package/smart-registry)\n[![npm](https://img.shields.io/npm/dt/smart-registry?color=red\u0026logo=npm)](https://www.npmjs.com/package/smart-registry)\n[![GitHub](https://img.shields.io/github/stars/nrjdalal/smart-registry?color=blue)](https://github.com/nrjdalal/smart-registry)\n\nA `zero-configuration` (no registry.json required), [shadcn add](https://ui.shadcn.com/docs/cli#add) / [open in v0](https://ui.shadcn.com/docs/registry/open-in-v0) compatible registry builder. With amazing visual feedback like how many dependencies and files are being added to a file/component and much more.\n\n\u003e The best configuration is no configuration. Focus on developing building blocks, components, pages, etc rather than spending time configuring the registry.\n\n\u003cimg width=\"800\" alt=\"Demo Image\" src=\"https://github.com/user-attachments/assets/3e1e5bd4-1e3e-4aab-924f-70e1d68519ab\" /\u003e\n\n## What is Zero-Configuration?\n\nSimplify your `registry.json` by removing properties like `dependencies`, `devDependencies`, `registryDependencies`, and `files`.\n\nIf you don't need to add custom properties or extend default ones, you can even delete the `registry.json` file entirely.\n\n```diff\n{\n  \"items\": [\n    {\n      \"name\": \"dialog\",\n      \"type\": \"registry:ui\",\n-      \"registryDependencies\": [\n-        \"button\"\n-      ],\n-      \"dependencies\": [\n-        \"@radix-ui/react-dialog\"\n-      ],\n-      \"files\": [\n-        {\n-          \"path\": \"registry/default/ui/dialog.tsx\",\n-          \"type\": \"registry:ui\"\n-        }\n-      ]\n-    }\n  ]\n}\n```\n\nOr delete the `registry.json` file entirely. No changes will be made to the generated `public/r/dialog.json` file. Smart, right?\n\n```bash\nrm registry.json \u0026\u0026 npx smart-registry\n```\n\n\u003cdetails\u003e\u003csummary\u003eGenerated public/r/dialog.json\u003c/summary\u003e\u003cbr/\u003e\n\n```json\n{\n  \"$schema\": \"https://ui.shadcn.com/schema/registry-item.json\",\n  \"name\": \"dialog\",\n  \"type\": \"registry:ui\",\n  \"dependencies\": [\"@radix-ui/react-dialog\"],\n  \"files\": [\n    {\n      \"type\": \"registry:ui\",\n      \"target\": \"components/ui/button.tsx\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/ui/button.tsx\"\n    },\n    {\n      \"type\": \"registry:ui\",\n      \"target\": \"components/ui/dialog.tsx\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/ui/dialog.tsx\"\n    },\n    {\n      \"type\": \"registry:lib\",\n      \"target\": \"lib/utils.ts\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/lib/utils.ts\"\n    }\n  ]\n}\n```\n\n\u003c/details\u003e\n\n\u003cbr/\u003e\n\nManual maintenance of `registry.json` files can lead to errors due to missing dependencies or files, or wrongful addition of unnecessary ones. `Smart Registry` reduces these risks by automating the detection and generation of the all-in-one `r/registry.json` and `r/\u003cregistry-item\u003e.json` entries, making registry management more efficient.\n\n## Table of Contents\n\n- [Usage](#usage)\n  - [Automatic Detection](#automatic-detection)\n  - [Advanced Usage](#advanced-usage)\n- [How it Works](#how-it-works)\n- [Extending Properties](#extending-properties)\n  - [With Zero-Configuration](#with-zero-configuration)\n  - [Add Custom Properties](#add-custom-properties)\n  - [Additional Files to Include](#additional-files-to-include)\n  - [External Registry Dependencies](#external-registry-dependencies)\n  - [Specify Dependency Version](#specify-dependency-version)\n- [Directory Structure](#directory-structure)\n  - [For `registry` Directory](#for-registry-directory)\n  - [For `registry` Directory with Multiple Registries](#for-registry-directory-with-multiple-registries)\n  - [For `components` Directory](#for-components-directory)\n  - [For `components` Directory with Multiple Registries](#for-components-directory-with-multiple-registries)\n\n## Usage\n\n### Automatic Detection\n\nIf your project contains a `registry`, `components`, or `src/components` directory, `Smart Registry` will automatically detect and generate the necessary registry files.\n\nFor more details, refer to the [directory structure](#directory-structure) section.\n\n```bash\nnpx smart-registry\n```\n\nYeah, that's it! You don't need to do anything else (not even registry.json). `Smart Registry` has the word `smart` in it for a reason.\n\n### Advanced Usage\n\nIf you want, you can customize the output directory, working directory, and provide additional files or directories to build the registry from.\n\n```plaintext\nVersion:\n  smart-registry@0.17.2\n\nUsage:\n  $ smart-registry [files/directories] ... [options]\n\nArguments:\n  files/directories       files or directories to extend the registry (optional)\n\nOptions:\n  -o, --output \u003cpath\u003e     destination directory for json files (default: \"./public/r\")\n  -c, --cwd \u003ccwd\u003e         the working directory (default: \"./\")\n  -i, --ignore \u003cpattern\u003e  ignore files matching the pattern (default: none)\n  -u, --with-utils        include @/lib/utils in the registry items if exists (default: false)\n  -v, --version           display version\n  -h, --help              display help\n\nWith disabled automatic detection:\n  -p, --patterns-only     generate registry items for only given files/directories (default: false)\n  -r, --registry-only     generate registry items for only given registry.json (default: false)\n\nCodemods:\n  --codemod-radix         migrate to unify \"@radix-ui/react-*\" imports to \"radix-ui\"\n\nCleanup:\n  --remove-prefix         remove given prefix from the registry item names (default: none)\n\nAuthor:\n  Neeraj Dalal \u003cadmin@nrjdalal.com\u003e (https://nrjdalal.com)\n```\n\ne.g. to generate the registry in the `json` directory from some file and directory at the working directory (`apps/www`).\n\n```bash\nnpx smart-registry path/to/file.ext path/to/directory ... --output json --cwd apps/www\n```\n\n- `cwd` is useful when working with monorepos or multiple projects.\n\n## How it Works\n\nLet's take the following directory structure to understand how `Smart Registry` works.\n\n```plaintext\nregistry/\n└── default/\n    ├── lib/\n    │   └── utils.ts\n    └── ui/\n        ├── button.tsx\n        └── dialog.tsx\n```\n\n1. `Smart Registry` will scan the `registry` directory and its sub-directories to find all the files (if no `registry` directory is found, it will scan the `components` or `src/components` directory).\n2. For each file, it will generate a `\u003cregistry-item\u003e.json` file by reading the file's content and extracting the imports for registry dependencies, dependencies, and files recursively.\n3. It will then generate a `registry.json` file by combining all the `\u003cregistry-item\u003e.json` files with all the properties required for `shadcn add` or `open in v0`.\n\n```plaintext\npublic/\n└── r/\n    ├── button.json\n    ├── dialog.json\n    ├── registry.json\n    └── utils.json\n```\n\n## Extending Properties\n\nYou can add/extend the generated `public/r/registry.json` and `public/r/\u003cregistry-item\u003e.json` files by creating a `registry.json` file in the root of your project. The properties in this file will be merged with the generated properties.\n\nWe will consider the dialog component with the following directory structure to demonstrate the extension of properties.\n\n```plaintext\nregistry/\n└── default/\n    ├── lib/\n    │   └── utils.ts\n    └── ui/\n        └── dialog.tsx\n```\n\n### With Zero-Configuration\n\n\u003cdetails\u003e\u003csummary\u003eGenerated public/r/dialog.json\u003c/summary\u003e\u003cbr/\u003e\n\n```diff\n{\n  \"$schema\": \"https://ui.shadcn.com/schema/registry-item.json\",\n  \"name\": \"dialog\",\n  \"type\": \"registry:ui\",\n  \"dependencies\": [\"@radix-ui/react-dialog\"],\n  \"files\": [\n    {\n      \"type\": \"registry:ui\",\n      \"target\": \"components/ui/dialog.tsx\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/ui/dialog.tsx\"\n    },\n    {\n      \"type\": \"registry:lib\",\n      \"target\": \"lib/utils.ts\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/lib/utils.ts\"\n    }\n  ]\n}\n```\n\n\u003c/details\u003e\n\n### Add Custom Properties\n\n```diff\n{\n  \"items\": [\n    {\n      \"name\": \"dialog\",\n      \"type\": \"registry:ui\",\n+      \"meta\": {\n+        \"tags\": [\"dialog\", \"modal\"]\n+      }\n    }\n  ]\n}\n```\n\n\u003cdetails\u003e\u003csummary\u003eGenerated public/r/dialog.json\u003c/summary\u003e\u003cbr/\u003e\n\n```diff\n{\n  \"$schema\": \"https://ui.shadcn.com/schema/registry-item.json\",\n  \"name\": \"dialog\",\n  \"type\": \"registry:ui\",\n  \"dependencies\": [\"@radix-ui/react-dialog\"],\n  \"files\": [\n    {\n      \"type\": \"registry:ui\",\n      \"target\": \"components/ui/dialog.tsx\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/ui/dialog.tsx\"\n    },\n    {\n      \"type\": \"registry:lib\",\n      \"target\": \"lib/utils.ts\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/lib/utils.ts\"\n    }\n  ],\n+  \"meta\": {\n+    \"tags\": [\"dialog\", \"modal\"]\n+  }\n}\n```\n\n\u003c/details\u003e\n\n### Additional Files to Include\n\n```diff\n{\n  \"items\": [\n    {\n      \"name\": \"dialog\",\n      \"type\": \"registry:ui\",\n+      \"files\": [\n+        {\n+          \"type\": \"registry:ui\",\n+          \"path\": \"registry/default/ui/button.tsx\"\n+        }\n+      ]\n    }\n  ]\n}\n```\n\n\u003cdetails\u003e\u003csummary\u003eGenerated public/r/dialog.json\u003c/summary\u003e\u003cbr/\u003e\n\n```diff\n{\n  \"$schema\": \"https://ui.shadcn.com/schema/registry-item.json\",\n  \"name\": \"dialog\",\n  \"type\": \"registry:ui\",\n  \"dependencies\": [\"@radix-ui/react-dialog\"],\n  \"files\": [\n+    {\n+      \"type\": \"registry:ui\",\n+      \"target\": \"components/ui/button.tsx\",\n+      \"content\": \"...\",\n+      \"path\": \"registry/default/ui/button.tsx\"\n+    },\n    {\n      \"type\": \"registry:ui\",\n      \"target\": \"components/ui/dialog.tsx\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/ui/dialog.tsx\"\n    },\n    {\n      \"type\": \"registry:lib\",\n      \"target\": \"lib/utils.ts\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/lib/utils.ts\"\n    }\n  ]\n}\n```\n\n\u003c/details\u003e\n\n### External Registry Dependencies\n\n```diff\n{\n  \"items\": [\n    {\n      \"name\": \"dialog\",\n      \"type\": \"registry:ui\",\n+      \"registryDependencies\": [\"button\"]\n    }\n  ]\n}\n```\n\n\u003cdetails\u003e\u003csummary\u003eGenerated public/r/dialog.json\u003c/summary\u003e\u003cbr/\u003e\n\n```diff\n{\n  \"$schema\": \"https://ui.shadcn.com/schema/registry-item.json\",\n  \"name\": \"dialog\",\n  \"type\": \"registry:ui\",\n  \"dependencies\": [\"@radix-ui/react-dialog\"],\n  \"files\": [\n    {\n      \"type\": \"registry:ui\",\n      \"target\": \"components/ui/dialog.tsx\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/ui/dialog.tsx\"\n    },\n    {\n      \"type\": \"registry:lib\",\n      \"target\": \"lib/utils.ts\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/lib/utils.ts\"\n    }\n  ],\n+  \"registryDependencies\": [\"button\"]\n}\n```\n\n\u003c/details\u003e\n\n### Specify Dependency Version\n\nNote: Only add the dependency that you want to specify the version for. The rest of the dependencies will be automatically added.\n\n```diff\n{\n  \"items\": [\n    {\n      \"name\": \"dialog\",\n      \"type\": \"registry:ui\",\n+      \"dependencies\": [\"@radix-ui/react-dialog@1.0.0\"]\n    }\n  ]\n}\n```\n\n\u003cdetails\u003e\u003csummary\u003eGenerated public/r/dialog.json\u003c/summary\u003e\u003cbr/\u003e\n\n```diff\n{\n  \"$schema\": \"https://ui.shadcn.com/schema/registry-item.json\",\n  \"name\": \"dialog\",\n  \"type\": \"registry:ui\",\n-  \"dependencies\": [\"@radix-ui/react-dialog\"],\n+  \"dependencies\": [\"@radix-ui/react-dialog@1.0.0\"],\n  \"files\": [\n    {\n      \"type\": \"registry:ui\",\n      \"target\": \"components/ui/dialog.tsx\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/ui/dialog.tsx\"\n    },\n    {\n      \"type\": \"registry:lib\",\n      \"target\": \"lib/utils.ts\",\n      \"content\": \"...\",\n      \"path\": \"registry/default/lib/utils.ts\"\n    }\n  ]\n}\n```\n\n\u003c/details\u003e\n\n## Directory Structure\n\n### For `registry` Directory\n\n- Use direct name for default registry.\n\n```plaintext\nregistry/\n├── blocks/\n│   └── toasty.tsx\n├── components/\n│   └── toaster.tsx\n├── hooks/\n│   └── use-toast.ts\n├── lib/\n│   └── utils.ts\n└── ui/\n    └── toast.tsx\n```\n\n- Or use `default` sub-directory for default registry.\n\n```plaintext\nregistry/\n└── default/\n    ├── blocks/\n    │   └── toasty.tsx\n    ├── components/\n    │   └── toaster.tsx\n    ├── hooks/\n    │   └── use-toast.ts\n    ├── lib/\n    │   └── utils.ts\n    └── ui/\n        └── toast.tsx\n```\n\nBoth generate the following items in `public/r` directory.\n\n```plaintext\npublic/\n└── r/\n    ├── toasty.json     name: toasty     target: blocks/toasty.tsx\n    ├── component.json  name: toaster    target: components/toaster.tsx\n    ├── use-toast.json  name: use-toast  target: hooks/use-toast.ts\n    ├── utils.json      name: utils      target: lib/utils.ts\n    └── toast.json      name: toast      target: components/ui/toast.tsx\n```\n\n### For `registry` Directory with Multiple Registries\n\n- Use `\u003cregistry-name\u003e` sub-directory for named registry.\n\n```plaintext\nregistry/\n├── default/\n└── new-york/\n    ├── blocks/\n    │   └── toasty.tsx\n    ├── components/\n    │   └── toaster.tsx\n    ├── hooks/\n    │   └── use-toast.ts\n    ├── lib/\n    │   └── utils.ts\n    └── ui/\n        └── toast.tsx\n```\n\nGenerates the following items in `public/r` directory.\n\n```plaintext\npublic/\n└── r/\n    ├── registry.json\n    └── new-york/\n        ├── toasty.json     name: new-york-toasty     target: blocks/new-york/toasty.tsx\n        ├── toaster.json    name: new-york-toaster    target: components/new-york/toaster.tsx\n        ├── use-toast.json  name: new-york-use-toast  target: hooks/new-york/use-toast.ts\n        ├── utils.json      name: new-york-utils      target: lib/new-york/utils.ts\n        └── toast.json      name: new-york-toast      target: components/ui/new-york/toast.tsx\n```\n\n### For `components` Directory\n\n- Use direct name for default registry.\n\n```plaintext\nblocks/\n└── toasty.tsx\ncomponents/\n├── ui/\n│   └── dialog.tsx\n└── toaster.tsx\nhooks/\n└── use-toast.ts\nlib/\n└── utils.ts\n```\n\nGenerates the following items in `public/r` directory.\n\n```plaintext\npublic/\n└── r/\n    ├── registry.json\n    ├── toasty.json     name: toasty     target: blocks/toasty.tsx\n    ├── component.json  name: toaster    target: components/toaster.tsx\n    ├── use-toast.json  name: use-toast  target: hooks/use-toast.ts\n    ├── utils.json      name: utils      target: lib/utils.ts\n    └── toast.json      name: toast      target: components/ui/toast.tsx\n```\n\n### For `components` Directory with Multiple Registries\n\n- Use `\u003cregistry-name\u003e` sub-directory for named registry.\n\n```plaintext\nblocks/\n└── new-york/\n    └── toasty.tsx\ncomponents/\n├── new-york/\n│   └── toaster.tsx\n└── ui/\n    └── new-york/\n        └── toast.tsx\nhooks/\n└── new-york/\n    └── use-toast.ts\nlib/\n└── new-york/\n    └── utils.ts\n```\n\nGenerates the following items in `public/r` directory.\n\n```plaintext\npublic/\n└── r/\n    ├── registry.json\n    └── new-york/\n        ├── toasty.json     name: new-york-toasty     target: blocks/new-york/toasty.tsx\n        ├── toaster.json    name: new-york-toaster    target: components/new-york/toaster.tsx\n        ├── use-toast.json  name: new-york-use-toast  target: hooks/new-york/use-toast.ts\n        ├── utils.json      name: new-york-utils      target: lib/new-york/utils.ts\n        └── toast.json      name: new-york-toast      target: components/ui/new-york/toast.tsx\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrjdalal%2Fsmart-registry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnrjdalal%2Fsmart-registry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrjdalal%2Fsmart-registry/lists"}