@create-ui/cli 0.5.3 → 0.5.4
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/index.d.ts +364 -364
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/schema/index.d.ts +716 -716
- package/dist/skills/createui/assets/createui-small.png +0 -0
- package/dist/skills/createui/assets/createui.png +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87,5 +87,5 @@ args = ["${se}", "mcp"]`),o.break(),o.info("3. Restart Codex to load the MCP ser
|
|
|
87
87
|
`).map(R=>{if(R.trim().startsWith("import "))return R;let S=R;return S=S.replace(/\b(asChild\s*\?\s*)Slot(\s*:)/g,"$1__SLOT_PLACEHOLDER__$2"),S=S.replace(/\bReact\.ComponentProps<typeof\s+Slot>/g,"React.ComponentProps<typeof __SLOT_PLACEHOLDER__>"),S=S.replace(/\bComponentProps<typeof\s+Slot>/g,"ComponentProps<typeof __SLOT_PLACEHOLDER__>"),S=S.replace(/(<\/?)Slot(\s*\/?>)/g,"$1__SLOT_PLACEHOLDER__$2"),S=S.replace(/\bSlot\b/g,(H,F,W)=>{let ge=W.substring(0,F),Be=(ge.match(/"/g)||[]).length,ni=(ge.match(/'/g)||[]).length;return Be%2!==0||ni%2!==0?H:"__SLOT_PLACEHOLDER__"}),S=S.replace(/__SLOT_PLACEHOLDER__/g,"SlotPrimitive.Slot"),S}).join(`
|
|
88
88
|
`));let h=Array.from(new Set(n));return {content:c,replacedPackages:h}}async function Mr(e){let t={};if(!x.existsSync(e.cwd)||!x.existsSync(E__default.resolve(e.cwd,"package.json")))return t["1"]=true,{errors:t,config:null};if(!x.existsSync(E__default.resolve(e.cwd,"components.json")))return t["3"]=true,{errors:t,config:null};try{let r=await f(e.cwd);return {errors:t,config:r}}catch{o.break(),o.error(`An invalid ${a$1.info("components.json")} file was found at ${a$1.info(e.cwd)}.
|
|
89
89
|
Before you can run a migration, you must create a valid ${a$1.info("components.json")} file by running the ${a$1.info("init")} command.`),o.error(`Learn more at ${a$1.info("https://createui.co/docs/components-json")}.`),o.break(),process.exit(1);}}var Wr=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."}],Zn=z.object({cwd:z.string(),list:z.boolean(),yes:z.boolean(),migration:z.string().refine(e=>e&&Wr.some(t=>t.name===e),{message:"You must specify a valid migration. Run `createui migrate --list` to see available migrations."}).optional()}),zr=new Command().name("migrate").description("run a migration.").argument("[migration]","the migration to run.").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-l, --list","list all migrations.",false).option("-y, --yes","skip confirmation prompt.",false).action(async(e,t)=>{try{let r=Zn.parse({cwd:E__default.resolve(t.cwd),migration:e,list:t.list,yes:t.yes});if(r.list||!r.migration){o.info("Available migrations:");for(let o$1 of Wr)o.info(`- ${o$1.name}: ${o$1.description}`);return}if(!r.migration)throw new Error("You must specify a migration. Run `createui migrate --list` to see available migrations.");let{errors:i,config:n}=await Mr(r);if(i["1"]||i["3"])throw new Error("No `components.json` file found. Ensure you are at the root of your project.");if(!n)throw new Error("Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file.");r.migration==="icons"&&await Dr(n),r.migration==="radix"&&await Vr(n,{yes:r.yes});}catch(r){o.break(),Q(r);}});async function Ur(e){let t={},r={cwd:e.cwd,registryFile:E__default.resolve(e.cwd,e.registryFile),outputDir:E__default.resolve(e.cwd,e.outputDir)};if(!x.existsSync(r.registryFile))return t["13"]=true,{errors:t,resolvePaths:null,config:null};if(!x.existsSync(E__default.resolve(e.cwd,"components.json")))return t["3"]=true,{errors:t,resolvePaths:null,config:null};await x.mkdir(r.outputDir,{recursive:true});try{let i=await f(e.cwd);return {errors:t,config:i,resolvePaths:r}}catch{o.break(),o.error(`An invalid ${a$1.info("components.json")} file was found at ${a$1.info(e.cwd)}.
|
|
90
|
-
Before you can build the registry, you must create a valid ${a$1.info("components.json")} file by running the ${a$1.info("init")} command.`),o.break(),process.exit(1);}}var to=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string(),verbose:z.boolean().optional().default(false)}),Br=new Command().name("registry:build").description("builds the registry [EXPERIMENTAL]").argument("[registry]","path to registry.json file","./registry.json").option("-o, --output <path>","destination directory for json files","./public/r").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-v, --verbose","verbose output").action(async(e,t)=>{await ro({cwd:E.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function ro(e){try{let t=to.parse(e),[{errors:r,resolvePaths:i,config:n},o$2]=await Promise.all([Ur(t),m(t.cwd)]);(r["3"]||!n||!o$2)&&(o.error(`A ${a$1.info("components.json")} file is required to build the registry. Run ${a$1.info("createui init")} to create one.`),o.break(),process.exit(1)),(r["13"]||!i)&&(o.error(`We could not find a registry file at ${a$1.info(E.resolve(t.cwd,t.registryFile))}.`),o.break(),process.exit(1));let s=await J.readFile(i.registryFile,"utf-8"),c=o$1.safeParse(JSON.parse(s));c.success||(o.error(`Invalid registry file found at ${a$1.info(i.registryFile)}.`),o.break(),process.exit(1));let a=p("Building registry..."),l=await io(c.data,n,o$2);for(let m of l.items)m.files=m.files?.filter((p,u,h)=>u===h.findIndex(g=>g.path===p.path)),m.dependencies&&(m.dependencies=m.dependencies.filter((p,u,h)=>u===h.findIndex(g=>g===p)));for(let m of l.items){if(!m.files)continue;a.start(`Building ${m.name}...`),m.$schema="https://createui.co/schema/registry-item.json";for(let u of m.files){let h=E.resolve(i.cwd,u.path);try{if(!(await J.stat(h)).isFile())continue;u.content=await J.readFile(h,"utf-8");}catch(g){console.error("Error reading file in registry build:",h,g);continue}}let p=n$1.safeParse(m);if(!p.success){o.error(`Invalid registry item found for ${a$1.info(m.name)}.`);continue}await J.writeFile(E.resolve(i.outputDir,`${p.data.name}.json`),JSON.stringify(p.data,null,2));}if(await J.copyFile(i.registryFile,E.resolve(i.outputDir,"registry.json")),a.succeed("Building registry."),t.verbose){p(`The registry has ${a$1.info(l.items.length.toString())} items:`).succeed();for(let m of l.items){o.log(` - ${m.name} (${a$1.info(m.type)})`);for(let p of m.files??[])o.log(` - ${p.path}`);}}}catch(t){o.break(),Q(t);}}async function io(e,t,r){for(let i of e.items)if(i.files?.length)for(let n of i.files){let o=await D(n.path,t,r);o.files=o.files?.filter(s=>s.path!==n.path),o.files&&i.files.push(...o.files),o.dependencies&&(i.dependencies=i.dependencies?i.dependencies.concat(o.dependencies):o.dependencies);}return e}var Gr=new Command().name("registry:mcp").description("starts the registry MCP server [DEPRECATED]").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async()=>{o.warn(`The ${a$1.info("createui registry:mcp")} command is deprecated. Use the ${a$1.info("createui mcp")} command instead.`),o.break();});var so=z.object({cwd:z.string(),query:z.string().optional(),limit:z.number().optional(),offset:z.number().optional()}),Yr=new Command().name("search").alias("list").description("search items from registries").argument("<registries...>","the registry names or urls to search items from. Names must be prefixed with @.").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-q, --query <query>","query string").option("-l, --limit <number>","maximum number of items to display per registry","100").option("-o, --offset <number>","number of items to skip","0").action(async(e,t)=>{try{let r=so.parse({cwd:E__default.resolve(t.cwd),query:t.query,limit:t.limit?parseInt(t.limit,10):void 0,offset:t.offset?parseInt(t.offset,10):void 0});await L(r.cwd);let i=k({resolvedPaths:{cwd:r.cwd}}),n=G(i),o=E__default.resolve(r.cwd,"components.json");if(x.existsSync(o)){let a$1=await x.readJson(o),l=a.partial().parse(a$1);n=G({...i,...l});}let s=n;try{let a=await f(r.cwd);a&&(s=G(a));}catch{}let c=await a$3(e,{query:r.query,limit:r.limit,offset:r.offset,config:s});console.log(JSON.stringify(c,null,2)),process.exit(0);}catch(r){Q(r);}});var Xr="createui",Pt={claude:{label:"Claude Code",dir:E__default.join(".claude","skills")},gemini:{label:"Gemini CLI",dir:E__default.join(".gemini","skills")},codex:{label:"OpenAI Codex",dir:E__default.join(".agents","skills")},agents:{label:"Agent Skills standard (.agents/skills)",dir:E__default.join(".agents","skills")}},fo=z.object({cwd:z.string(),client:z.enum(["claude","gemini","codex","agents"]),project:z.boolean(),path:z.string().optional(),force:z.boolean(),yes:z.boolean()});function po(){let e=E__default.dirname(fileURLToPath(import.meta.url));return E__default.join(e,"skills",Xr)}var Qr=new Command().name("skill").description("install the Create UI agent skill for your AI coding agent").option("--client <client>",`the agent to install for (${Object.keys(Pt).join(", ")}).`,"claude").option("--project","install into the project instead of your home directory.",false).option("-p, --path <path>","install into an explicit skills directory (for other agents).").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-f, --force","overwrite an existing skill installation.",false).option("-y, --yes","skip the overwrite confirmation prompt.",false).action(async e=>{try{let t=fo.parse({...e}),r=E__default.resolve(t.cwd),i=po();existsSync(i)||(o.error(`Could not find the bundled Create UI skill at ${a$1.info(i)}.`),o.error("Please update createui to the latest version and try again."),process.exit(1));let n,o$1;if(t.path)n=E__default.resolve(r,t.path),o$1="custom path";else {let a=Pt[t.client],l=t.project?r:st.homedir();n=E__default.join(l,a.dir),o$1=`${a.label}, ${t.project?"project":"personal"}`;}let s=E__default.join(n,Xr);if(existsSync(s)&&!t.force&&!t.yes){let{overwrite:a}=await pt({type:"confirm",name:"overwrite",message:`The Create UI skill already exists at ${a$1.info(s)}. Overwrite?`,initial:!1});a||(o.info("Skill installation cancelled."),process.exit(0));}let c=p(`Installing the Create UI skill (${o$1})...`).start();await x.ensureDir(n),await x.copy(i,s,{overwrite:!0,filter:a=>!a.endsWith(".DS_Store")}),c.succeed(`Installed the Create UI skill (${o$1}).`),o.break(),o.success(`Skill installed at ${a$1.info(s)}`),o.break(),t.path?(o.log("Point your AI agent at this folder (or import it from your agent's"),o.log(`rules file, e.g. ${a$1.info("AGENTS.md")} or ${a$1.info(".cursor/rules")}). Then try asking:`)):o.log(`${Pt[t.client].label} loads it automatically \u2014 no restart needed. Try asking:`),o.log(` ${a$1.info('"Add a Create UI login form"')}`),!t.path&&!t.project&&(o.break(),o.log(`Tip: run ${a$1.info(`createui skill --client ${t.client} --project`)} inside a repo to commit the skill for your whole team.`)),o.break();}catch(t){Q(t);}});var go=z.object({cwd:z.string()}),ri=new Command().name("view").description("view items from the registry").argument("<items...>","the item names or URLs to view").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let r=go.parse({cwd:E__default.resolve(t.cwd)});await L(r.cwd);let i=G({}),n=E__default.resolve(r.cwd,"components.json");if(x.existsSync(n)){let c=await x.readJson(n),a$1=a.partial().parse(c);i=G(a$1);}let o=i;try{let c=await f(r.cwd);c&&(o=G(c));}catch{}let s=await S(e,{config:o});console.log(JSON.stringify(s,null,2)),process.exit(0);}catch(r){Q(r);}});var ii={version:"0.5.
|
|
90
|
+
Before you can build the registry, you must create a valid ${a$1.info("components.json")} file by running the ${a$1.info("init")} command.`),o.break(),process.exit(1);}}var to=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string(),verbose:z.boolean().optional().default(false)}),Br=new Command().name("registry:build").description("builds the registry [EXPERIMENTAL]").argument("[registry]","path to registry.json file","./registry.json").option("-o, --output <path>","destination directory for json files","./public/r").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-v, --verbose","verbose output").action(async(e,t)=>{await ro({cwd:E.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function ro(e){try{let t=to.parse(e),[{errors:r,resolvePaths:i,config:n},o$2]=await Promise.all([Ur(t),m(t.cwd)]);(r["3"]||!n||!o$2)&&(o.error(`A ${a$1.info("components.json")} file is required to build the registry. Run ${a$1.info("createui init")} to create one.`),o.break(),process.exit(1)),(r["13"]||!i)&&(o.error(`We could not find a registry file at ${a$1.info(E.resolve(t.cwd,t.registryFile))}.`),o.break(),process.exit(1));let s=await J.readFile(i.registryFile,"utf-8"),c=o$1.safeParse(JSON.parse(s));c.success||(o.error(`Invalid registry file found at ${a$1.info(i.registryFile)}.`),o.break(),process.exit(1));let a=p("Building registry..."),l=await io(c.data,n,o$2);for(let m of l.items)m.files=m.files?.filter((p,u,h)=>u===h.findIndex(g=>g.path===p.path)),m.dependencies&&(m.dependencies=m.dependencies.filter((p,u,h)=>u===h.findIndex(g=>g===p)));for(let m of l.items){if(!m.files)continue;a.start(`Building ${m.name}...`),m.$schema="https://createui.co/schema/registry-item.json";for(let u of m.files){let h=E.resolve(i.cwd,u.path);try{if(!(await J.stat(h)).isFile())continue;u.content=await J.readFile(h,"utf-8");}catch(g){console.error("Error reading file in registry build:",h,g);continue}}let p=n$1.safeParse(m);if(!p.success){o.error(`Invalid registry item found for ${a$1.info(m.name)}.`);continue}await J.writeFile(E.resolve(i.outputDir,`${p.data.name}.json`),JSON.stringify(p.data,null,2));}if(await J.copyFile(i.registryFile,E.resolve(i.outputDir,"registry.json")),a.succeed("Building registry."),t.verbose){p(`The registry has ${a$1.info(l.items.length.toString())} items:`).succeed();for(let m of l.items){o.log(` - ${m.name} (${a$1.info(m.type)})`);for(let p of m.files??[])o.log(` - ${p.path}`);}}}catch(t){o.break(),Q(t);}}async function io(e,t,r){for(let i of e.items)if(i.files?.length)for(let n of i.files){let o=await D(n.path,t,r);o.files=o.files?.filter(s=>s.path!==n.path),o.files&&i.files.push(...o.files),o.dependencies&&(i.dependencies=i.dependencies?i.dependencies.concat(o.dependencies):o.dependencies);}return e}var Gr=new Command().name("registry:mcp").description("starts the registry MCP server [DEPRECATED]").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async()=>{o.warn(`The ${a$1.info("createui registry:mcp")} command is deprecated. Use the ${a$1.info("createui mcp")} command instead.`),o.break();});var so=z.object({cwd:z.string(),query:z.string().optional(),limit:z.number().optional(),offset:z.number().optional()}),Yr=new Command().name("search").alias("list").description("search items from registries").argument("<registries...>","the registry names or urls to search items from. Names must be prefixed with @.").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-q, --query <query>","query string").option("-l, --limit <number>","maximum number of items to display per registry","100").option("-o, --offset <number>","number of items to skip","0").action(async(e,t)=>{try{let r=so.parse({cwd:E__default.resolve(t.cwd),query:t.query,limit:t.limit?parseInt(t.limit,10):void 0,offset:t.offset?parseInt(t.offset,10):void 0});await L(r.cwd);let i=k({resolvedPaths:{cwd:r.cwd}}),n=G(i),o=E__default.resolve(r.cwd,"components.json");if(x.existsSync(o)){let a$1=await x.readJson(o),l=a.partial().parse(a$1);n=G({...i,...l});}let s=n;try{let a=await f(r.cwd);a&&(s=G(a));}catch{}let c=await a$3(e,{query:r.query,limit:r.limit,offset:r.offset,config:s});console.log(JSON.stringify(c,null,2)),process.exit(0);}catch(r){Q(r);}});var Xr="createui",Pt={claude:{label:"Claude Code",dir:E__default.join(".claude","skills")},gemini:{label:"Gemini CLI",dir:E__default.join(".gemini","skills")},codex:{label:"OpenAI Codex",dir:E__default.join(".agents","skills")},agents:{label:"Agent Skills standard (.agents/skills)",dir:E__default.join(".agents","skills")}},fo=z.object({cwd:z.string(),client:z.enum(["claude","gemini","codex","agents"]),project:z.boolean(),path:z.string().optional(),force:z.boolean(),yes:z.boolean()});function po(){let e=E__default.dirname(fileURLToPath(import.meta.url));return E__default.join(e,"skills",Xr)}var Qr=new Command().name("skill").description("install the Create UI agent skill for your AI coding agent").option("--client <client>",`the agent to install for (${Object.keys(Pt).join(", ")}).`,"claude").option("--project","install into the project instead of your home directory.",false).option("-p, --path <path>","install into an explicit skills directory (for other agents).").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-f, --force","overwrite an existing skill installation.",false).option("-y, --yes","skip the overwrite confirmation prompt.",false).action(async e=>{try{let t=fo.parse({...e}),r=E__default.resolve(t.cwd),i=po();existsSync(i)||(o.error(`Could not find the bundled Create UI skill at ${a$1.info(i)}.`),o.error("Please update createui to the latest version and try again."),process.exit(1));let n,o$1;if(t.path)n=E__default.resolve(r,t.path),o$1="custom path";else {let a=Pt[t.client],l=t.project?r:st.homedir();n=E__default.join(l,a.dir),o$1=`${a.label}, ${t.project?"project":"personal"}`;}let s=E__default.join(n,Xr);if(existsSync(s)&&!t.force&&!t.yes){let{overwrite:a}=await pt({type:"confirm",name:"overwrite",message:`The Create UI skill already exists at ${a$1.info(s)}. Overwrite?`,initial:!1});a||(o.info("Skill installation cancelled."),process.exit(0));}let c=p(`Installing the Create UI skill (${o$1})...`).start();await x.ensureDir(n),await x.copy(i,s,{overwrite:!0,filter:a=>!a.endsWith(".DS_Store")}),c.succeed(`Installed the Create UI skill (${o$1}).`),o.break(),o.success(`Skill installed at ${a$1.info(s)}`),o.break(),t.path?(o.log("Point your AI agent at this folder (or import it from your agent's"),o.log(`rules file, e.g. ${a$1.info("AGENTS.md")} or ${a$1.info(".cursor/rules")}). Then try asking:`)):o.log(`${Pt[t.client].label} loads it automatically \u2014 no restart needed. Try asking:`),o.log(` ${a$1.info('"Add a Create UI login form"')}`),!t.path&&!t.project&&(o.break(),o.log(`Tip: run ${a$1.info(`createui skill --client ${t.client} --project`)} inside a repo to commit the skill for your whole team.`)),o.break();}catch(t){Q(t);}});var go=z.object({cwd:z.string()}),ri=new Command().name("view").description("view items from the registry").argument("<items...>","the item names or URLs to view").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).action(async(e,t)=>{try{let r=go.parse({cwd:E__default.resolve(t.cwd)});await L(r.cwd);let i=G({}),n=E__default.resolve(r.cwd,"components.json");if(x.existsSync(n)){let c=await x.readJson(n),a$1=a.partial().parse(c);i=G(a$1);}let o=i;try{let c=await f(r.cwd);c&&(o=G(c));}catch{}let s=await S(e,{config:o});console.log(JSON.stringify(s,null,2)),process.exit(0);}catch(r){Q(r);}});var ii={version:"0.5.4"};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function yo(){let e=new Command().name("createui").description("add items from registries to your project").version(ii.version,"-v, --version","display the version number");e.addCommand(yr).addCommand(Er).addCommand(Ir).addCommand(Nr).addCommand(ri).addCommand(Yr).addCommand(zr).addCommand(Tr).addCommand(jr).addCommand(xt).addCommand(Qr),e.addCommand(Br).addCommand(Gr),e.parse();}yo();//# sourceMappingURL=index.js.map
|
|
91
91
|
//# sourceMappingURL=index.js.map
|