@create-ui/cli 0.5.8 → 0.5.9
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/{chunk-RMTTHCB3.js → chunk-2ELKDGGM.js} +3 -3
- package/dist/{chunk-RMTTHCB3.js.map → chunk-2ELKDGGM.js.map} +1 -1
- package/dist/chunk-643QI2I2.js +102 -0
- package/dist/chunk-643QI2I2.js.map +1 -0
- package/dist/{chunk-NQFMXHMH.js → chunk-KQTXDVKV.js} +3 -3
- package/dist/chunk-KQTXDVKV.js.map +1 -0
- package/dist/index.d.ts +360 -360
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +1 -1
- package/dist/schema/index.d.ts +715 -715
- package/dist/skills/createui/SKILL.md +201 -177
- package/dist/skills/createui/agents/openai.yml +1 -1
- package/dist/skills/createui/cli.md +42 -42
- package/dist/skills/createui/customization.md +20 -15
- package/dist/skills/createui/evals/evals.json +68 -5
- package/dist/skills/createui/mcp.md +14 -5
- package/dist/skills/createui/reference/accordion.md +127 -0
- package/dist/skills/createui/reference/app-store-badge.md +88 -0
- package/dist/skills/createui/reference/aspect-ratio.md +52 -0
- package/dist/skills/createui/reference/avatar.md +230 -0
- package/dist/skills/createui/reference/badge.md +110 -0
- package/dist/skills/createui/reference/breadcrumb.md +153 -0
- package/dist/skills/createui/reference/button-group.md +116 -0
- package/dist/skills/createui/reference/button.md +104 -0
- package/dist/skills/createui/reference/checkbox-group.md +118 -0
- package/dist/skills/createui/reference/checkbox.md +79 -0
- package/dist/skills/createui/reference/chip.md +115 -0
- package/dist/skills/createui/reference/close-button.md +83 -0
- package/dist/skills/createui/reference/command.md +69 -0
- package/dist/skills/createui/reference/country-flag.md +109 -0
- package/dist/skills/createui/reference/credit-card-input.md +76 -0
- package/dist/skills/createui/reference/date-input.md +71 -0
- package/dist/skills/createui/reference/dropdown-menu.md +164 -0
- package/dist/skills/createui/reference/field.md +186 -0
- package/dist/skills/createui/reference/info-tooltip.md +110 -0
- package/dist/skills/createui/reference/inline-alert.md +146 -0
- package/dist/skills/createui/reference/input-group.md +171 -0
- package/dist/skills/createui/reference/input-otp.md +130 -0
- package/dist/skills/createui/reference/input-stepper.md +120 -0
- package/dist/skills/createui/reference/input.md +118 -0
- package/dist/skills/createui/reference/label.md +121 -0
- package/dist/skills/createui/reference/pagination.md +157 -0
- package/dist/skills/createui/reference/password-strength.md +70 -0
- package/dist/skills/createui/reference/phone-input.md +77 -0
- package/dist/skills/createui/reference/progress.md +158 -0
- package/dist/skills/createui/reference/radio-group.md +133 -0
- package/dist/skills/createui/reference/radio.md +79 -0
- package/dist/skills/createui/reference/scroll-area.md +212 -0
- package/dist/skills/createui/reference/segmented-control.md +146 -0
- package/dist/skills/createui/reference/select.md +204 -0
- package/dist/skills/createui/reference/separator.md +99 -0
- package/dist/skills/createui/reference/social-login-button.md +130 -0
- package/dist/skills/createui/reference/spinner.md +68 -0
- package/dist/skills/createui/reference/status-badge.md +89 -0
- package/dist/skills/createui/reference/switch-group.md +122 -0
- package/dist/skills/createui/reference/switch.md +75 -0
- package/dist/skills/createui/reference/tab-menu.md +165 -0
- package/dist/skills/createui/reference/text-link.md +84 -0
- package/dist/skills/createui/reference/textarea.md +50 -0
- package/dist/skills/createui/reference/toast.md +162 -0
- package/dist/skills/createui/reference/tooltip.md +63 -0
- package/dist/skills/createui/rules/composition.md +41 -25
- package/dist/skills/createui/rules/design.md +266 -0
- package/dist/skills/createui/rules/forms.md +44 -15
- package/dist/skills/createui/rules/icons.md +64 -18
- package/dist/skills/createui/rules/styling.md +53 -14
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-M5DYT2NE.js +0 -64
- package/dist/chunk-M5DYT2NE.js.map +0 -1
- package/dist/chunk-NQFMXHMH.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b as b$1,a as a$2}from'./chunk-
|
|
2
|
+
import {b as b$1,a as a$2}from'./chunk-643QI2I2.js';import {a as a$3}from'./chunk-2ELKDGGM.js';import {a as a$4}from'./chunk-VQCXAURP.js';import {s,u,F,k,V as V$1,o,a as a$1,T,m,f,n,t,v,p,g,da,q,r,d,e,b,c,O,E as E$1,w,X,B,ba,D,ca,$,aa,A,N,P,Q,C,R,h,Z,l,S,j,i,x as x$1,z as z$1,y}from'./chunk-KQTXDVKV.js';export{$ as fetchTree,da as getFontVariants,aa as getItemTargetPath,ca as getPreset,ba as getPresets,U as getRegistry,Z as getRegistryIcons,V as getRegistryItems,Y as getRegistryStyles,X as getcreateuiRegistryIndex,W as resolveRegistryItems,_ as resolveTree}from'./chunk-KQTXDVKV.js';import {a,o as o$1,n as n$1}from'./chunk-Y7WZRQWW.js';import*as E from'path';import E__default,{join}from'path';import {promises,existsSync}from'fs';import x from'fs-extra';import v$1 from'postcss';import St,{z}from'zod';import {execa}from'execa';import ut from'prompts';import {Project,ScriptKind,SyntaxKind,VariableDeclarationKind}from'ts-morph';import ct,{tmpdir}from'os';import {parse,applyEdits,modify}from'jsonc-parser';import {Command}from'commander';import vr from'deepmerge';import*as J from'fs/promises';import J__default from'fs/promises';import wt from'dedent';import Pi from'validate-npm-package-name';import {diffLines}from'diff';import {HttpsProxyAgent}from'https-proxy-agent';import zi from'node-fetch';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {randomBytes}from'crypto';import no from'fast-glob';import {fileURLToPath}from'url';async function sr(e){let t={};if(!x.existsSync(e.cwd)||!x.existsSync(E__default.resolve(e.cwd,"package.json")))return t["1"]=true,{errors:t,projectInfo:null};let r=p("Preflight checks.",{silent:e.silent}).start();x.existsSync(E__default.resolve(e.cwd,"components.json"))&&!e.force&&(r?.fail(),o.break(),o.error(`A ${a$1.info("components.json")} file already exists at ${a$1.info(e.cwd)}.
|
|
3
3
|
To start over, remove the ${a$1.info("components.json")} file and run ${a$1.info("init")} again.`),o.break(),process.exit(1)),r?.succeed();let n=p("Verifying framework.",{silent:e.silent}).start(),i=await m(e.cwd);(!i||i?.framework.name==="manual")&&(t["7"]=true,n?.fail(),o.break(),i?.framework.links.installation&&o.error(`We could not detect a supported framework at ${a$1.info(e.cwd)}.
|
|
4
4
|
Visit ${a$1.info(i?.framework.links.installation)} to manually configure your project.
|
|
5
5
|
Once configured, you can use the cli to add components.`),o.break(),process.exit(1)),n?.succeed(`Verifying framework. Found ${a$1.info(i.framework.label)}.`);let o$1=i.tailwindVersion==="v4"?`Validating Tailwind CSS config. Found ${a$1.info("v4")}.`:"Validating Tailwind CSS.",s=p(o$1,{silent:e.silent}).start();i.tailwindVersion==="v4"&&!i?.tailwindCssFile||!i.tailwindVersion?(t["5"]=true,s?.fail()):s?.succeed();let a=p("Validating import alias.",{silent:e.silent}).start();return i?.aliasPrefix?a?.succeed():(t["6"]=true,a?.fail()),Object.keys(t).length>0&&(t["5"]&&(o.break(),o.error(`No Tailwind CSS configuration found at ${a$1.info(e.cwd)}.`),o.error("It is likely you do not have Tailwind CSS installed or have an invalid configuration."),o.error("Install Tailwind CSS then try again."),i?.framework.links.tailwind&&o.error(`Visit ${a$1.info(i?.framework.links.tailwind)} to get started.`)),t["6"]&&(o.break(),o.error("No import alias found in your tsconfig.json file."),i?.framework.links.installation&&o.error(`Visit ${a$1.info(i?.framework.links.installation)} to learn how to set an import alias.`)),o.break(),process.exit(1)),{errors:t,projectInfo:i}}function ar(e,t){if(e.includes("\0"))return false;let r;try{r=e;let u="";for(;r!==u&&r.includes("%");)u=r,r=decodeURIComponent(r);}catch{return false}let n=E__default.normalize(r.replace(/\\/g,"/")),i=E__default.normalize(t),o=u=>u.replace(/\[\.\.\..*?\]/g,"").includes("..");if(o(n)||o(r)||o(e))return false;let s=u=>u.replace(/\[\.\.\..*?\]/g,""),a=s(e),c=s(r);if([/\.\.[\/\\]/,/[\/\\]\.\./,/\.\./,/\.\.%/,/\x00/,/[\x01-\x1f]/].some(u=>u.test(a)||u.test(c))||(e.includes("~")||r.includes("~"))&&(e.includes("../")||r.includes("../")))return false;if(/^[a-zA-Z]:[\/\\]/.test(r))return process.platform==="win32"?r.toLowerCase().startsWith(t.toLowerCase()):false;if(E__default.isAbsolute(n))return n.startsWith(i+E__default.sep);let p=E__default.resolve(i,n);return p.startsWith(i+E__default.sep)||p===i}async function et(e,t,r){if(!t.resolvedPaths.tailwindCss||!e||Object.keys(e).length===0)return;r={silent:false,...r};let n=t.resolvedPaths.tailwindCss,i=E__default.relative(t.resolvedPaths.cwd,n),o=p(`Updating ${a$1.info(i)}`,{silent:r.silent}).start(),s=await promises.readFile(n,"utf8"),a=await wn(s,e);await promises.writeFile(n,a,"utf8"),o.succeed();}async function wn(e,t){let r=[yn(t)],n=await v$1(r).process(e,{from:void 0}),i=n.css,o=n.root;if(o.nodes&&o.nodes.length>0){let s=o.nodes[o.nodes.length-1];s.type==="atrule"&&!s.nodes&&!i.trimEnd().endsWith(";")&&(i=i.trimEnd()+";");}return i=i.replace(/\/\* ---break--- \*\//g,""),i=i.replace(/(\n\s*\n)+/g,`
|
|
@@ -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),Je=(ge.match(/"/g)||[]).length,un=(ge.match(/'/g)||[]).length;return Je%2!==0||un%2!==0?H:"__SLOT_PLACEHOLDER__"}),S=S.replace(/__SLOT_PLACEHOLDER__/g,"SlotPrimitive.Slot"),S}).join(`
|
|
88
88
|
`));let h=Array.from(new Set(i));return {content:a,replacedPackages:h}}async function qr(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 Hr=[{name:"icons",description:"migrate your ui components to a different icon library."},{name:"radix",description:"migrate to radix-ui."}],ho=z.object({cwd:z.string(),list:z.boolean(),yes:z.boolean(),migration:z.string().refine(e=>e&&Hr.some(t=>t.name===e),{message:"You must specify a valid migration. Run `createui migrate --list` to see available migrations."}).optional()}),Xr=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=ho.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 Hr)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:n,config:i}=await qr(r);if(n["1"]||n["3"])throw new Error("No `components.json` file found. Ensure you are at the root of your project.");if(!i)throw new Error("Something went wrong reading your `components.json` file. Please ensure you have a valid `components.json` file.");r.migration==="icons"&&await Jr(i),r.migration==="radix"&&await Kr(i,{yes:r.yes});}catch(r){o.break(),T(r);}});async function Qr(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 n=await f(e.cwd);return {errors:t,config:n,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 yo=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string(),verbose:z.boolean().optional().default(false)}),Zr=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 bo({cwd:E.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function bo(e){try{let t=yo.parse(e),[{errors:r,resolvePaths:n,config:i},o$2]=await Promise.all([Qr(t),m(t.cwd)]);(r["3"]||!i||!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"]||!n)&&(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(n.registryFile,"utf-8"),a=o$1.safeParse(JSON.parse(s));a.success||(o.error(`Invalid registry file found at ${a$1.info(n.registryFile)}.`),o.break(),process.exit(1));let c=p("Building registry..."),l=await xo(a.data,i,o$2);for(let f of l.items)f.files=f.files?.filter((p,u,h)=>u===h.findIndex(g=>g.path===p.path)),f.dependencies&&(f.dependencies=f.dependencies.filter((p,u,h)=>u===h.findIndex(g=>g===p)));for(let f of l.items){if(!f.files)continue;c.start(`Building ${f.name}...`),f.$schema="https://createui.co/schema/registry-item.json";for(let u of f.files){let h=E.resolve(n.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(f);if(!p.success){o.error(`Invalid registry item found for ${a$1.info(f.name)}.`);continue}await J.writeFile(E.resolve(n.outputDir,`${p.data.name}.json`),JSON.stringify(p.data,null,2));}if(await J.copyFile(n.registryFile,E.resolve(n.outputDir,"registry.json")),c.succeed("Building registry."),t.verbose){p(`The registry has ${a$1.info(l.items.length.toString())} items:`).succeed();for(let f of l.items){o.log(` - ${f.name} (${a$1.info(f.type)})`);for(let p of f.files??[])o.log(` - ${p.path}`);}}}catch(t){o.break(),T(t);}}async function xo(e,t,r){for(let n of e.items)if(n.files?.length)for(let i of n.files){let o=await C(i.path,t,r);o.files=o.files?.filter(s=>s.path!==i.path),o.files&&n.files.push(...o.files),o.dependencies&&(n.dependencies=n.dependencies?n.dependencies.concat(o.dependencies):o.dependencies);}return e}var en=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 Ro=z.object({cwd:z.string(),query:z.string().optional(),limit:z.number().optional(),offset:z.number().optional()}),nn=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=Ro.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 V(r.cwd);let n=k({resolvedPaths:{cwd:r.cwd}}),i=F(n),o=E__default.resolve(r.cwd,"components.json");if(x.existsSync(o)){let c=await x.readJson(o),l=a.partial().parse(c);i=F({...n,...l});}let s=i;try{let c=await f(r.cwd);c&&(s=F(c));}catch{}let a$1=await a$3(e,{query:r.query,limit:r.limit,offset:r.offset,config:s});console.log(JSON.stringify(a$1,null,2)),process.exit(0);}catch(r){T(r);}});var an="createui",Et={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")}},jo=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 Eo(){let e=E__default.dirname(fileURLToPath(import.meta.url));return E__default.join(e,"skills",an)}var cn=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(Et).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=jo.parse({...e}),r=E__default.resolve(t.cwd),n=Eo();existsSync(n)||(o.error(`Could not find the bundled Create UI skill at ${a$1.info(n)}.`),o.error("Please update createui to the latest version and try again."),process.exit(1));let i,o$1;if(t.path)i=E__default.resolve(r,t.path),o$1="custom path";else {let c=Et[t.client],l=t.project?r:ct.homedir();i=E__default.join(l,c.dir),o$1=`${c.label}, ${t.project?"project":"personal"}`;}let s=E__default.join(i,an);if(existsSync(s)&&!t.force&&!t.yes){let{overwrite:c}=await ut({type:"confirm",name:"overwrite",message:`The Create UI skill already exists at ${a$1.info(s)}. Overwrite?`,initial:!1});c||(o.info("Skill installation cancelled."),process.exit(0));}let a=p(`Installing the Create UI skill (${o$1})...`).start();await x.ensureDir(i),await x.copy(n,s,{overwrite:!0,filter:c=>!c.endsWith(".DS_Store")}),a.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(`${Et[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){T(t);}});var No=z.object({cwd:z.string()}),pn=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=No.parse({cwd:E__default.resolve(t.cwd)});await V(r.cwd);let n=F({}),i=E__default.resolve(r.cwd,"components.json");if(x.existsSync(i)){let a$1=await x.readJson(i),c=a.partial().parse(a$1);n=F(c);}let o=n;try{let a=await f(r.cwd);a&&(o=F(a));}catch{}let s=await V$1(e,{config:o});console.log(JSON.stringify(s,null,2)),process.exit(0);}catch(r){T(r);}});var dn={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 yo=z.object({cwd:z.string(),registryFile:z.string(),outputDir:z.string(),verbose:z.boolean().optional().default(false)}),Zr=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 bo({cwd:E.resolve(t.cwd),registryFile:e,outputDir:t.output,verbose:t.verbose});});async function bo(e){try{let t=yo.parse(e),[{errors:r,resolvePaths:n,config:i},o$2]=await Promise.all([Qr(t),m(t.cwd)]);(r["3"]||!i||!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"]||!n)&&(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(n.registryFile,"utf-8"),a=o$1.safeParse(JSON.parse(s));a.success||(o.error(`Invalid registry file found at ${a$1.info(n.registryFile)}.`),o.break(),process.exit(1));let c=p("Building registry..."),l=await xo(a.data,i,o$2);for(let f of l.items)f.files=f.files?.filter((p,u,h)=>u===h.findIndex(g=>g.path===p.path)),f.dependencies&&(f.dependencies=f.dependencies.filter((p,u,h)=>u===h.findIndex(g=>g===p)));for(let f of l.items){if(!f.files)continue;c.start(`Building ${f.name}...`),f.$schema="https://createui.co/schema/registry-item.json";for(let u of f.files){let h=E.resolve(n.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(f);if(!p.success){o.error(`Invalid registry item found for ${a$1.info(f.name)}.`);continue}await J.writeFile(E.resolve(n.outputDir,`${p.data.name}.json`),JSON.stringify(p.data,null,2));}if(await J.copyFile(n.registryFile,E.resolve(n.outputDir,"registry.json")),c.succeed("Building registry."),t.verbose){p(`The registry has ${a$1.info(l.items.length.toString())} items:`).succeed();for(let f of l.items){o.log(` - ${f.name} (${a$1.info(f.type)})`);for(let p of f.files??[])o.log(` - ${p.path}`);}}}catch(t){o.break(),T(t);}}async function xo(e,t,r){for(let n of e.items)if(n.files?.length)for(let i of n.files){let o=await C(i.path,t,r);o.files=o.files?.filter(s=>s.path!==i.path),o.files&&n.files.push(...o.files),o.dependencies&&(n.dependencies=n.dependencies?n.dependencies.concat(o.dependencies):o.dependencies);}return e}var en=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 Ro=z.object({cwd:z.string(),query:z.string().optional(),limit:z.number().optional(),offset:z.number().optional()}),nn=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=Ro.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 V(r.cwd);let n=k({resolvedPaths:{cwd:r.cwd}}),i=F(n),o=E__default.resolve(r.cwd,"components.json");if(x.existsSync(o)){let c=await x.readJson(o),l=a.partial().parse(c);i=F({...n,...l});}let s=i;try{let c=await f(r.cwd);c&&(s=F(c));}catch{}let a$1=await a$3(e,{query:r.query,limit:r.limit,offset:r.offset,config:s});console.log(JSON.stringify(a$1,null,2)),process.exit(0);}catch(r){T(r);}});var an="createui",Et={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")}},jo=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 Eo(){let e=E__default.dirname(fileURLToPath(import.meta.url));return E__default.join(e,"skills",an)}var cn=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(Et).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=jo.parse({...e}),r=E__default.resolve(t.cwd),n=Eo();existsSync(n)||(o.error(`Could not find the bundled Create UI skill at ${a$1.info(n)}.`),o.error("Please update createui to the latest version and try again."),process.exit(1));let i,o$1;if(t.path)i=E__default.resolve(r,t.path),o$1="custom path";else {let c=Et[t.client],l=t.project?r:ct.homedir();i=E__default.join(l,c.dir),o$1=`${c.label}, ${t.project?"project":"personal"}`;}let s=E__default.join(i,an);if(existsSync(s)&&!t.force&&!t.yes){let{overwrite:c}=await ut({type:"confirm",name:"overwrite",message:`The Create UI skill already exists at ${a$1.info(s)}. Overwrite?`,initial:!1});c||(o.info("Skill installation cancelled."),process.exit(0));}let a=p(`Installing the Create UI skill (${o$1})...`).start();await x.ensureDir(i),await x.copy(n,s,{overwrite:!0,filter:c=>!c.endsWith(".DS_Store")}),a.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(`${Et[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){T(t);}});var No=z.object({cwd:z.string()}),pn=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=No.parse({cwd:E__default.resolve(t.cwd)});await V(r.cwd);let n=F({}),i=E__default.resolve(r.cwd,"components.json");if(x.existsSync(i)){let a$1=await x.readJson(i),c=a.partial().parse(a$1);n=F(c);}let o=n;try{let a=await f(r.cwd);a&&(o=F(a));}catch{}let s=await V$1(e,{config:o});console.log(JSON.stringify(s,null,2)),process.exit(0);}catch(r){T(r);}});var dn={version:"0.5.9"};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function Fo(){let e=new Command().name("createui").description("add items from registries to your project").version(dn.version,"-v, --version","display the version number");e.addCommand(Rr).addCommand(Fr).addCommand(Er).addCommand(_r).addCommand(pn).addCommand(nn).addCommand(Xr).addCommand(Dr).addCommand(Mr).addCommand(Wr).addCommand(Or).addCommand(vt).addCommand(cn),e.addCommand(Zr).addCommand(en),e.parse();}Fo();//# sourceMappingURL=index.js.map
|
|
91
91
|
//# sourceMappingURL=index.js.map
|