smart-registry 0.6.5 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -10
- package/dist/bin/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,10 +76,8 @@ Manual maintenance of `registry.json` files can lead to errors due to missing de
|
|
|
76
76
|
## Table of Contents
|
|
77
77
|
|
|
78
78
|
- [Usage](#usage)
|
|
79
|
-
- [Configure Alias](#configure-alias)
|
|
80
79
|
- [Automatic Detection](#automatic-detection)
|
|
81
|
-
- [
|
|
82
|
-
- [From Specific Directories](#from-specific-directories)
|
|
80
|
+
- [Advanced Usage](#advanced-usage)
|
|
83
81
|
- [How it Works](#how-it-works)
|
|
84
82
|
- [Extending Properties](#extending-properties)
|
|
85
83
|
- [With zero-configuration](#with-zero-configuration)
|
|
@@ -88,6 +86,10 @@ Manual maintenance of `registry.json` files can lead to errors due to missing de
|
|
|
88
86
|
- [External registry dependencies](#external-registry-dependencies)
|
|
89
87
|
- [Specify dependency version](#specify-dependency-version)
|
|
90
88
|
- [Directory Structure](#directory-structure)
|
|
89
|
+
- [For `registry` directory](#for-registry-directory)
|
|
90
|
+
- [For `registry` directory with multiple registries](#for-registry-directory-with-multiple-registries)
|
|
91
|
+
- [For `components` directory](#for-components-directory)
|
|
92
|
+
- [For `components` directory with multiple registries](#for-components-directory-with-multiple-registries)
|
|
91
93
|
|
|
92
94
|
## Usage
|
|
93
95
|
|
|
@@ -99,12 +101,16 @@ If your project contains a `registry`, `components`, or `src/components` directo
|
|
|
99
101
|
npx smart-registry
|
|
100
102
|
```
|
|
101
103
|
|
|
104
|
+
### Advanced Usage
|
|
105
|
+
|
|
106
|
+
You can customize the output directory, working directory, and provide files or directories to build the registry from.
|
|
107
|
+
|
|
102
108
|
```plaintext
|
|
103
109
|
Version:
|
|
104
|
-
|
|
110
|
+
smart-registry@x.y.z
|
|
105
111
|
|
|
106
112
|
Usage:
|
|
107
|
-
$
|
|
113
|
+
$ smart-registry [files/directories] ... [options]
|
|
108
114
|
|
|
109
115
|
Arguments:
|
|
110
116
|
files/directories files or directories to build the registry from (optional)
|
|
@@ -119,14 +125,14 @@ Author:
|
|
|
119
125
|
${author.name} <${author.email}> (${author.url})
|
|
120
126
|
```
|
|
121
127
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
If you want to generate the registry from specific files or directories, you can pass them as arguments.
|
|
128
|
+
e.g. To generate the registry in the `json` directory from some file and directory at the working directory (`apps/www`).
|
|
125
129
|
|
|
126
130
|
```bash
|
|
127
|
-
npx smart-registry path/to/file.
|
|
131
|
+
npx smart-registry path/to/file.ext path/to/directory ... --output json --cwd apps/www
|
|
128
132
|
```
|
|
129
133
|
|
|
134
|
+
- cwd is useful when working with monorepos or multiple projects.
|
|
135
|
+
|
|
130
136
|
## How it Works
|
|
131
137
|
|
|
132
138
|
Let's take the following directory structure to understand how `Smart Registry` works.
|
|
@@ -157,7 +163,7 @@ public/
|
|
|
157
163
|
|
|
158
164
|
## Extending Properties
|
|
159
165
|
|
|
160
|
-
You can add/extend the generated `public/registry.json` and `public/r/<registry-item>.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.
|
|
166
|
+
You can add/extend the generated `public/r/registry.json` and `public/r/<registry-item>.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.
|
|
161
167
|
|
|
162
168
|
We will consider the dialog component with the following directory structure to demonstrate the extension of properties.
|
|
163
169
|
|
package/dist/bin/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Q=Object.defineProperty,X=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var J=(i,t,s)=>t in i?Q(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s,u=(i,t)=>{for(var s in t||(t={}))Z.call(t,s)&&J(i,s,t[s]);if(I)for(var s of I(t))C.call(t,s)&&J(i,s,t[s]);return i},F=(i,t)=>X(i,Y(t));import _ from"node:fs";import h from"node:path";import{parseArgs as oe}from"node:util";var M=["registry/**",["blocks/**","components/**","helpers/**","hooks/**","lib/**","ui/**","utils/**"],["src/blocks/**","src/components/**","src/helpers/**","src/hooks/**","src/lib/**","src/ui/**","src/utils/**"]],j={default:["$schema","name","homepage","items"],items:{default:["$schema","name","type","description","title","author","dependencies","devDependencies","registryDependencies","files","tailwind","cssVars","meta","docs","categories"],type:{default:["registry:ui","registry:hook","registry:lib","registry:theme","registry:page","registry:file","registry:component","registry:block"]},files:{default:["type","target","content","path"],type:{default:["registry:block","registry:component","registry:file","registry:page","registry:theme","registry:lib","registry:hook","registry:ui"]}}}};import S from"node:fs";import E from"node:path";import ee from"strip-json-comments";var V=async i=>{let t={},s=["tsconfig.json","jsconfig.json"].find(n=>S.existsSync(E.resolve(i,n)));if(s){let n=await S.promises.readFile(E.resolve(i,s),"utf8"),{compilerOptions:e}=JSON.parse(ee(n,{trailingCommas:!0}));e.paths&&(t=Object.entries(e.paths).reduce((r,[o,[a]])=>(o.endsWith("*")&&a.endsWith("*")&&(r[o.replace(/\*$/,"")]=a.replace(/\*$/,"")),r),{}))}return t["@/"]||(t["@/"]=S.existsSync(E.resolve(i,"src"))?"./src/":"./"),t=Object.entries(t).sort(([n],[e])=>e.length-n.length).reduce((n,[e,r])=>(n[e]=r,n),{}),t};import B from"node:fs";import te from"node:path";var q=async i=>{let t=te.resolve(i,"registry.json"),s={$schema:"https://ui.shadcn.com/schema/registry.json",name:"nrjdalal",homepage:"https://nrjdalal.com",items:[]};return B.existsSync(t)&&(s=u({},JSON.parse(await B.promises.readFile(t,"utf8")))),s};import z from"node:fs";import T from"node:path";import{glob as se}from"tinyglobby";var v=async({cwd:i,patterns:t=["**",".**"],ignore:s=[]})=>{t=Array.isArray(t)?t:[t],t=t.map(e=>e.replace(/^'|'$/g,"").replace(/^"|"$/g,"").trim()),t=[...t,...t.flatMap(e=>e.includes("*")?[]:[e+".**",e+"**"])],t=t.filter(Boolean),s=typeof s=="string"?s.split(",").map(e=>e.trim()):s,s=s.filter(Boolean);let n=await se(t,{cwd:i,ignore:s.filter(e=>!t.includes(e))});if(!n.length)for(let e of t)try{let r=T.resolve(i,e),o=await z.promises.stat(r);if(o.isDirectory()){let a=(await z.promises.readdir(r)).map(g=>T.resolve(e,g));n.push(...a)}else o.isFile()&&n.push(e)}catch(r){continue}return n};var U=async({cwd:i,patterns:t,ignore:s})=>{let n=[];if(t.length)n=await v({cwd:i,patterns:t,ignore:s});else for(let e of M)if(n=await v({cwd:i,patterns:e,ignore:s}),n.length)break;if(!n.length)throw new Error("No files/directories found to build the registry from!");return n};import G from"node:fs";import H from"node:path";var k={imports:/import\s+type\s+[\s\S]+?from\s+['"][^'"]+['"]|import\s+['"][^'"]+['"]|import\s+[\s\S]+?from\s+['"][^'"]+['"]/g};var W=async({cwd:i,aliases:t,filepaths:s,resolved:n})=>{n=n!=null?n:new Set;let e={dependencies:[],files:[],content:{}};for(let r of s){if(n.has(r))continue;n.add(r),e.files.push(r),e.content[r]||(e.content[r]=await G.promises.readFile(H.resolve(i,r),"utf8"));let{dependencies:o,files:a,transformations:g}=await K({cwd:i,aliases:t,filepath:r,content:e.content[r]});e.content[r]=e.content[r].replace(k.imports,c=>{let y=c.match(/['"](.*)['"]/);return y&&g[y[1]]?c.replace(y[1],g[y[1]].import):c}),a.forEach(c=>e.files.push(c)),o.forEach(c=>e.dependencies.push(c))}for(let r of e.files){let{dependencies:o,files:a,content:g}=await W({cwd:i,aliases:t,filepaths:[r],resolved:n});e.content[r]||(e.content[r]=g[r]||await G.promises.readFile(H.resolve(i,r),"utf8")),a.forEach(c=>e.files.push(c)),o.forEach(c=>e.dependencies.push(c))}return e.dependencies=[...new Set(e.dependencies)].sort(),e.files=[...new Set(e.files)].sort(),e};import A from"node:path";import re from"node:path";var f=({cwd:i,aliases:t,filepath:s})=>{var r;let n=s;for(let o in t)s=s.replace(t[o].replaceAll("./","").replaceAll("../",""),"");let e=s.startsWith("registry/")?s.replace(/^registry\//,"").replace(/^(?:([^\/]*)\/)?blocks\//,(o,a)=>`blocks/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?components\/ui\//,(o,a)=>`${a?a+"/":""}ui/`).replace(/^(?:([^\/]*)\/)?components\//,(o,a)=>`components/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?hooks\//,(o,a)=>`hooks/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?lib\//,(o,a)=>`lib/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?ui\//,(o,a)=>`components/ui/${a?a+"/":""}`).replace(/\/default\//,"/").replace(/\.\.\//g,"").replace(/\.\//g,""):s.replace(/\/default\//,"/").replace(/\.\.\//g,"").replace(/\.\//g,"");return{type:e.endsWith("page.tsx")?"registry:page":((r=e.match(/^(blocks|components\/ui|components|hooks|lib|utils|helpers)/))==null?void 0:r[1].replace("blocks","registry:block").replace("components/ui","registry:ui").replace("components","registry:component").replace("hooks","registry:hook").replace("lib","registry:lib").replace("utils","registry:lib").replace("helpers","registry:lib"))||"registry:file",name:e.replace(/^(blocks|components\/ui|components|hooks|lib|utils|helpers)\//,"").replace(/\.[^\/.]+$/,"").replace(/\/index$/,"").replace(/\/route$/,"").replace(/\/\[.*\]$/,""),import:"@/"+e.replace(i+re.sep,"").replace(/\.[^/.]+$/,"").replace(/\/index$/,""),target:n.split("/").length>1?e:`~/${e}`,path:s}};var ie=async({cwd:i,current:t,aliases:s})=>{t=t.replace(new RegExp(`^${Object.keys(s).find(e=>t.startsWith(e.replace(/\.\//g,"").replace(/\.\.\//g,"")))}`),s[Object.keys(s).find(e=>t.startsWith(e.replace(/\.\//g,"").replace(/\.\.\//g,"")))]),t=t.replace(/\.\//g,"").replace(/\.\.\//g,"");let n=await v({cwd:i,patterns:t});return t=n.find(e=>e.startsWith(t+"."))||n.find(e=>e.startsWith(t+"/index"))||t,t.replace(i+"/","")},ne=async({cwd:i,filepath:t,current:s})=>{s=A.relative(i,A.resolve(i,A.dirname(t),s));let n=await v({cwd:i,patterns:s});return s=n.find(e=>e.startsWith(s+"."))||n.find(e=>e.startsWith(s+"/index"))||s,s.replace(i+"/","")},K=async({cwd:i,aliases:t,filepath:s,content:n})=>{let e={dependencies:[],files:[],transformations:{}},r=n.match(k.imports)||[];if(!r.length)return e;r=r.map(o=>{var a;return(a=o.match(/['"](.*)['"]/))==null?void 0:a[1].replace(/\/\//g,"/")});for(let o of r){let a=o;Object.keys(t).some(c=>o.startsWith(c.replace(/\.\//g,"").replace(/\.\.\//g,"")))?(o=await ie({cwd:i,aliases:t,current:o}),e.transformations[a]=f({cwd:i,aliases:t,filepath:o}),e.files.push(o)):o.startsWith(".")?(o=await ne({cwd:i,filepath:s,current:o}),e.transformations[a]=f({cwd:i,aliases:t,filepath:o}),e.files.push(o)):o.startsWith("@")?e.dependencies.push(o.split("/").slice(0,2).join("/")):e.dependencies.push(o.replace(/\/.*/,""))}return e};var R="smart-registry",P="0.
|
|
2
|
+
var Q=Object.defineProperty,X=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var J=(i,t,s)=>t in i?Q(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s,u=(i,t)=>{for(var s in t||(t={}))Z.call(t,s)&&J(i,s,t[s]);if(I)for(var s of I(t))C.call(t,s)&&J(i,s,t[s]);return i},F=(i,t)=>X(i,Y(t));import _ from"node:fs";import h from"node:path";import{parseArgs as oe}from"node:util";var M=["registry/**",["blocks/**","components/**","helpers/**","hooks/**","lib/**","ui/**","utils/**"],["src/blocks/**","src/components/**","src/helpers/**","src/hooks/**","src/lib/**","src/ui/**","src/utils/**"]],j={default:["$schema","name","homepage","items"],items:{default:["$schema","name","type","description","title","author","dependencies","devDependencies","registryDependencies","files","tailwind","cssVars","meta","docs","categories"],type:{default:["registry:ui","registry:hook","registry:lib","registry:theme","registry:page","registry:file","registry:component","registry:block"]},files:{default:["type","target","content","path"],type:{default:["registry:block","registry:component","registry:file","registry:page","registry:theme","registry:lib","registry:hook","registry:ui"]}}}};import S from"node:fs";import E from"node:path";import ee from"strip-json-comments";var V=async i=>{let t={},s=["tsconfig.json","jsconfig.json"].find(n=>S.existsSync(E.resolve(i,n)));if(s){let n=await S.promises.readFile(E.resolve(i,s),"utf8"),{compilerOptions:e}=JSON.parse(ee(n,{trailingCommas:!0}));e.paths&&(t=Object.entries(e.paths).reduce((r,[o,[a]])=>(o.endsWith("*")&&a.endsWith("*")&&(r[o.replace(/\*$/,"")]=a.replace(/\*$/,"")),r),{}))}return t["@/"]||(t["@/"]=S.existsSync(E.resolve(i,"src"))?"./src/":"./"),t=Object.entries(t).sort(([n],[e])=>e.length-n.length).reduce((n,[e,r])=>(n[e]=r,n),{}),t};import B from"node:fs";import te from"node:path";var q=async i=>{let t=te.resolve(i,"registry.json"),s={$schema:"https://ui.shadcn.com/schema/registry.json",name:"nrjdalal",homepage:"https://nrjdalal.com",items:[]};return B.existsSync(t)&&(s=u({},JSON.parse(await B.promises.readFile(t,"utf8")))),s};import z from"node:fs";import T from"node:path";import{glob as se}from"tinyglobby";var v=async({cwd:i,patterns:t=["**",".**"],ignore:s=[]})=>{t=Array.isArray(t)?t:[t],t=t.map(e=>e.replace(/^'|'$/g,"").replace(/^"|"$/g,"").trim()),t=[...t,...t.flatMap(e=>e.includes("*")?[]:[e+".**",e+"**"])],t=t.filter(Boolean),s=typeof s=="string"?s.split(",").map(e=>e.trim()):s,s=s.filter(Boolean);let n=await se(t,{cwd:i,ignore:s.filter(e=>!t.includes(e))});if(!n.length)for(let e of t)try{let r=T.resolve(i,e),o=await z.promises.stat(r);if(o.isDirectory()){let a=(await z.promises.readdir(r)).map(g=>T.resolve(e,g));n.push(...a)}else o.isFile()&&n.push(e)}catch(r){continue}return n};var U=async({cwd:i,patterns:t,ignore:s})=>{let n=[];if(t.length)n=await v({cwd:i,patterns:t,ignore:s});else for(let e of M)if(n=await v({cwd:i,patterns:e,ignore:s}),n.length)break;if(!n.length)throw new Error("No files/directories found to build the registry from!");return n};import G from"node:fs";import H from"node:path";var k={imports:/import\s+type\s+[\s\S]+?from\s+['"][^'"]+['"]|import\s+['"][^'"]+['"]|import\s+[\s\S]+?from\s+['"][^'"]+['"]/g};var W=async({cwd:i,aliases:t,filepaths:s,resolved:n})=>{n=n!=null?n:new Set;let e={dependencies:[],files:[],content:{}};for(let r of s){if(n.has(r))continue;n.add(r),e.files.push(r),e.content[r]||(e.content[r]=await G.promises.readFile(H.resolve(i,r),"utf8"));let{dependencies:o,files:a,transformations:g}=await K({cwd:i,aliases:t,filepath:r,content:e.content[r]});e.content[r]=e.content[r].replace(k.imports,c=>{let y=c.match(/['"](.*)['"]/);return y&&g[y[1]]?c.replace(y[1],g[y[1]].import):c}),a.forEach(c=>e.files.push(c)),o.forEach(c=>e.dependencies.push(c))}for(let r of e.files){let{dependencies:o,files:a,content:g}=await W({cwd:i,aliases:t,filepaths:[r],resolved:n});e.content[r]||(e.content[r]=g[r]||await G.promises.readFile(H.resolve(i,r),"utf8")),a.forEach(c=>e.files.push(c)),o.forEach(c=>e.dependencies.push(c))}return e.dependencies=[...new Set(e.dependencies)].sort(),e.files=[...new Set(e.files)].sort(),e};import A from"node:path";import re from"node:path";var f=({cwd:i,aliases:t,filepath:s})=>{var r;let n=s;for(let o in t)s=s.replace(t[o].replaceAll("./","").replaceAll("../",""),"");let e=s.startsWith("registry/")?s.replace(/^registry\//,"").replace(/^(?:([^\/]*)\/)?blocks\//,(o,a)=>`blocks/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?components\/ui\//,(o,a)=>`${a?a+"/":""}ui/`).replace(/^(?:([^\/]*)\/)?components\//,(o,a)=>`components/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?hooks\//,(o,a)=>`hooks/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?lib\//,(o,a)=>`lib/${a?a+"/":""}`).replace(/^(?:([^\/]*)\/)?ui\//,(o,a)=>`components/ui/${a?a+"/":""}`).replace(/\/default\//,"/").replace(/\.\.\//g,"").replace(/\.\//g,""):s.replace(/\/default\//,"/").replace(/\.\.\//g,"").replace(/\.\//g,"");return{type:e.endsWith("page.tsx")?"registry:page":((r=e.match(/^(blocks|components\/ui|components|hooks|lib|utils|helpers)/))==null?void 0:r[1].replace("blocks","registry:block").replace("components/ui","registry:ui").replace("components","registry:component").replace("hooks","registry:hook").replace("lib","registry:lib").replace("utils","registry:lib").replace("helpers","registry:lib"))||"registry:file",name:e.replace(/^(blocks|components\/ui|components|hooks|lib|utils|helpers)\//,"").replace(/\.[^\/.]+$/,"").replace(/\/index$/,"").replace(/\/route$/,"").replace(/\/\[.*\]$/,""),import:"@/"+e.replace(i+re.sep,"").replace(/\.[^/.]+$/,"").replace(/\/index$/,""),target:n.split("/").length>1?e:`~/${e}`,path:s}};var ie=async({cwd:i,current:t,aliases:s})=>{t=t.replace(new RegExp(`^${Object.keys(s).find(e=>t.startsWith(e.replace(/\.\//g,"").replace(/\.\.\//g,"")))}`),s[Object.keys(s).find(e=>t.startsWith(e.replace(/\.\//g,"").replace(/\.\.\//g,"")))]),t=t.replace(/\.\//g,"").replace(/\.\.\//g,"");let n=await v({cwd:i,patterns:t});return t=n.find(e=>e.startsWith(t+"."))||n.find(e=>e.startsWith(t+"/index"))||t,t.replace(i+"/","")},ne=async({cwd:i,filepath:t,current:s})=>{s=A.relative(i,A.resolve(i,A.dirname(t),s));let n=await v({cwd:i,patterns:s});return s=n.find(e=>e.startsWith(s+"."))||n.find(e=>e.startsWith(s+"/index"))||s,s.replace(i+"/","")},K=async({cwd:i,aliases:t,filepath:s,content:n})=>{let e={dependencies:[],files:[],transformations:{}},r=n.match(k.imports)||[];if(!r.length)return e;r=r.map(o=>{var a;return(a=o.match(/['"](.*)['"]/))==null?void 0:a[1].replace(/\/\//g,"/")});for(let o of r){let a=o;Object.keys(t).some(c=>o.startsWith(c.replace(/\.\//g,"").replace(/\.\.\//g,"")))?(o=await ie({cwd:i,aliases:t,current:o}),e.transformations[a]=f({cwd:i,aliases:t,filepath:o}),e.files.push(o)):o.startsWith(".")?(o=await ne({cwd:i,filepath:s,current:o}),e.transformations[a]=f({cwd:i,aliases:t,filepath:o}),e.files.push(o)):o.startsWith("@")?e.dependencies.push(o.split("/").slice(0,2).join("/")):e.dependencies.push(o.replace(/\/.*/,""))}return e};var R="smart-registry",P="0.7.0";var O={name:"Neeraj Dalal",email:"admin@nrjdalal.com",url:"https://nrjdalal.com"};var L=`Version:
|
|
3
3
|
${R}@${P}
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
6
|
-
$ ${R} [
|
|
6
|
+
$ ${R} [files/directories] ... [options]
|
|
7
7
|
|
|
8
8
|
Arguments:
|
|
9
9
|
files/directories files or directories to build the registry from (optional)
|
|
@@ -15,7 +15,7 @@ Options:
|
|
|
15
15
|
-h, --help display help
|
|
16
16
|
|
|
17
17
|
Author:
|
|
18
|
-
${O.name} <${O.email}> (${O.url})`,ae=i=>{try{return oe(i)}catch(t){throw new Error(`Error parsing arguments: ${t.message}`)}},pe=async()=>{var i,t,s;try{let{positionals:n,values:e}=ae({allowPositionals:!0,options:{
|
|
18
|
+
${O.name} <${O.email}> (${O.url})`,ae=i=>{try{return oe(i)}catch(t){throw new Error(`Error parsing arguments: ${t.message}`)}},pe=async()=>{var i,t,s;try{let{positionals:n,values:e}=ae({allowPositionals:!0,options:{output:{type:"string",short:"o",default:"public/r"},cwd:{type:"string",short:"c"},ignore:{type:"string",short:"i",default:""},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}});n.length||(e.version&&(console.log(`${R}@${P}`),process.exit(0)),e.help&&(console.log(L),process.exit(0)));let r=h.resolve((i=e.cwd)!=null?i:process.cwd()),o=await V(r),a=await q(r),g=await U({cwd:r,patterns:n,ignore:e.ignore}),c=[],y=F(u({},a),{items:[]});for(let m of g)try{let l=((t=a.items)==null?void 0:t.find(p=>p.name===f({cwd:r,aliases:o,filepath:m}).name))||{},d=await W({cwd:r,aliases:o,filepaths:[m,...((s=l==null?void 0:l.files)==null?void 0:s.map(p=>p.path))||[]]}),w={dependencies:[...new Set([...d.dependencies,...(l==null?void 0:l.dependencies)||[]])].sort(),devDependencies:[...new Set([...(l==null?void 0:l.devDependencies)||[]])].sort(),registryDependencies:[...new Set([...(l==null?void 0:l.registryDependencies)||[]])].sort()},b=u(F(u(u(u({$schema:"https://ui.shadcn.com/schema/registry-item.json",name:f({cwd:r,aliases:o,filepath:m}).name,type:f({cwd:r,aliases:o,filepath:m}).type||"registry:file"},w.dependencies.length&&{dependencies:w.dependencies}),w.devDependencies.length&&{devDependencies:w.devDependencies}),w.registryDependencies.length&&{registryDependencies:w.registryDependencies}),{files:d.files.map(p=>({type:f({cwd:r,aliases:o,filepath:p}).type||"registry:file",target:f({cwd:r,aliases:o,filepath:p}).target||p,content:d.content[p],path:p})).sort((p,x)=>{let $=j.items.files.type.default;return $.indexOf(p.type)-$.indexOf(x.type)})}),Object.fromEntries(Object.entries(l).filter(([p])=>!["$schema","name","type","dependencies","devDependencies","registryDependencies","files"].includes(p))));b=Object.keys(b).sort((p,x)=>{let $=j.items.default;return $.indexOf(p)-$.indexOf(x)}).reduce((p,x)=>(p[x]=b[x],p),{});let D=h.resolve(r,e.output,b.name+".json");console.log(`- ${h.relative(process.cwd(),h.resolve(r,m)).padEnd(Math.max(...g.map(p=>h.relative(process.cwd(),h.resolve(r,p)).length))+2," ")} ${d.dependencies.length?"\u{1F4E6}"+String(d.dependencies.length).padEnd(2," "):" "} ${d.files.length-1?"\u{1F4C4}"+String(d.files.length).padEnd(2," "):" "} ${h.relative(process.cwd(),D)}`),await _.promises.mkdir(h.dirname(D),{recursive:!0}),await _.promises.writeFile(D,JSON.stringify(b,null,2)+`
|
|
19
19
|
`),b.files.forEach(p=>delete p.content),y.items.push(b)}catch(l){c.push(m+": "+l.message);continue}y.items.sort((m,l)=>m.name.localeCompare(l.name)).sort((m,l)=>{let d=j.items.type.default;return d.indexOf(m.type)-d.indexOf(l.type)}),await _.promises.writeFile(h.resolve(r,e.output,"registry.json"),JSON.stringify(y,null,2)+`
|
|
20
20
|
`),c.length&&(console.log(),c.forEach(m=>console.error(`\x1B[31m- ${m}\x1B[0m`))),process.exit(0)}catch(n){console.error(L),console.error(`
|
|
21
21
|
${n.message}
|