reacticx 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +11 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import{Command as J}from"commander";import C from"fs-extra";import j from"path";import n from"chalk";import A from"ora";var $="https://reacticx-ui-components.pages.dev";async function u(){let o=await fetch(`${$}/registry.json`);if(!o.ok)throw new Error("Failed to fetch registry");return o.json()}async function D(o,t){let e=o.replace(/^src\/components\//,""),s=`${$}/${e}/${t}`,i=await fetch(s);if(!i.ok)throw new Error(`Failed to fetch ${t}`);return i.text()}import m from"fs-extra";import h from"path";import w from"chalk";var x="component.config.json";async function O(){let o=h.join(process.cwd(),x);if(!await m.pathExists(o))return null;let t=await m.readJson(o);return t.outDir||(console.log(w.red(`
3
- \u274C Invalid ${x}: missing "outDir" field`)),console.log(w.dim(`
4
- Example config:`)),console.log(w.dim(JSON.stringify({outDir:"src/shared/ui"},null,2))),process.exit(1)),t}async function R(o){let t=h.join(process.cwd(),o);await m.pathExists(t)||await m.ensureDir(t)}async function b(o="src/shared/ui"){let t=h.join(process.cwd(),x),e={outDir:o};await m.writeJson(t,e,{spaces:2})}async function E(o,t){let e=await O();!e&&!t.dir&&(console.log(n.red(`
2
+ import{Command as U}from"commander";import f from"fs-extra";import d from"path";import n from"chalk";import L from"ora";var O="https://reacticx-ui-components.pages.dev";async function h(){let o=await fetch(`${O}/registry.json`);if(!o.ok)throw new Error("Failed to fetch registry");return o.json()}async function j(o,t){let e=o.replace(/^src\/components\//,""),s=`${O}/${e}/${t}`,i=await fetch(s);if(!i.ok)throw new Error(`Failed to fetch ${t}`);return i.text()}import y from"fs-extra";import D from"path";import v from"chalk";var $="component.config.json";async function R(){let o=D.join(process.cwd(),$);if(!await y.pathExists(o))return null;let t=await y.readJson(o);return t.outDir||(console.log(v.red(`
3
+ \u274C Invalid ${$}: missing "outDir" field`)),console.log(v.dim(`
4
+ Example config:`)),console.log(v.dim(JSON.stringify({outDir:"src/shared/ui"},null,2))),process.exit(1)),t}async function b(o){let t=D.join(process.cwd(),o);await y.pathExists(t)||await y.ensureDir(t)}async function F(o="src/shared/ui"){let t=D.join(process.cwd(),$),e={outDir:o};await y.writeJson(t,e,{spaces:2})}async function P(o,t){let e=await R();!e&&!t.dir&&(console.log(n.red(`
5
5
  \u274C No component.config.json found`)),console.log(n.dim(`
6
6
  Create one in your project root:`)),console.log(n.cyan(JSON.stringify({outDir:"src/shared/ui"},null,2))),console.log(n.dim(`
7
- Or use --dir flag:`)),console.log(n.cyan(` npx reacticx add ${o} --dir src/components`)),process.exit(1));let s=t.dir||e.outDir,i=A(`Fetching ${o}...`).start();try{let r=await u(),c=r.components[o];if(!c){i.fail(n.red(`Component "${o}" not found`)),console.log(n.yellow(`
8
- Available components:`));let a=Object.keys(r.components).sort().filter(l=>l.toLowerCase().includes(o.toLowerCase()));a.length>0?(console.log(n.dim("Did you mean:")),a.slice(0,5).forEach(l=>console.log(` - ${l}`))):console.log(n.dim('Run "npx reacticx list" to see all components')),process.exit(1)}i.text=`Adding ${o}...`,await R(s);let y=j.join(process.cwd(),s,c.category,o);await C.pathExists(y)&&!t.overwrite&&(i.warn(n.yellow(`${o} already exists. Use --overwrite to replace.`)),process.exit(1)),await C.ensureDir(y);let v=[];for(let g of c.files){let a=await D(c.path,g),l=j.join(y,g);await C.writeFile(l,a,"utf-8"),v.push(l)}i.succeed(n.green(`Added ${o}!`)),console.log(n.dim(`
9
- Files created:`)),v.forEach(g=>{let a=j.relative(process.cwd(),g);console.log(n.dim(` ${a}`))}),console.log()}catch(r){i.fail(n.red(`Failed to add ${o}`)),console.error(r),process.exit(1)}}import p from"chalk";import I from"ora";async function F(o){let t=I("Fetching components...").start();try{let e=await u();t.stop(),console.log(p.bold(`
7
+ Or use --dir flag:`)),console.log(n.cyan(` npx reacticx add ${o} --dir src/components`)),process.exit(1));let s=t.dir||e.outDir,i=L(`Fetching ${o}...`).start();try{let r=await h(),c=r.components[o];if(!c){i.fail(n.red(`Component "${o}" not found`)),console.log(n.yellow(`
8
+ Available components:`));let p=Object.keys(r.components).sort().filter(l=>l.toLowerCase().includes(o.toLowerCase()));p.length>0?(console.log(n.dim("Did you mean:")),p.slice(0,5).forEach(l=>console.log(` - ${l}`))):console.log(n.dim('Run "npx reacticx list" to see all components')),process.exit(1)}i.text=`Adding ${o}...`,await b(s);let u=t.dir?d.join(process.cwd(),s):d.join(process.cwd(),s,c.category,o);await f.pathExists(u)&&!t.overwrite&&(i.warn(n.yellow(`${o} already exists. Use --overwrite to replace.`)),process.exit(1)),await f.ensureDir(u);let x=[];for(let a of c.files){let p=await j(c.path,a),l=d.join(u,a);await f.writeFile(l,p,"utf-8"),x.push(l)}if(c.folders&&c.folders.length>0)for(let a of c.folders){let p=d.join(u,a.name);await f.ensureDir(p);for(let l of a.files){let I=await j(c.path,`${a.name}/${l}`),C=d.join(u,a.name,l);await f.ensureDir(d.dirname(C)),await f.writeFile(C,I,"utf-8"),x.push(C)}}i.succeed(n.green(`Added ${o}!`)),console.log(n.dim(`
9
+ Files created:`)),x.forEach(a=>{let p=d.relative(process.cwd(),a);console.log(n.dim(` ${p}`))}),console.log()}catch(r){i.fail(n.red(`Failed to add ${o}`)),console.error(r),process.exit(1)}}import m from"chalk";import T from"ora";async function E(o){let t=T("Fetching components...").start();try{let e=await h();t.stop(),console.log(m.bold(`
10
10
  \u{1F4E6} Reacticx UI Components (v${e.version})
11
- `)),console.log(p.dim(`Total: ${e.totalComponents} components
12
- `));let s={};for(let[i,r]of Object.entries(e.components))o.category&&r.category!==o.category||(s[r.category]||(s[r.category]=[]),s[r.category].push(i));for(let[i,r]of Object.entries(s).sort())console.log(p.cyan.bold(`${i}/`)),r.sort().forEach(c=>{console.log(p.white(` ${c}`))}),console.log();console.log(p.dim("Run `npx reacticx add <component>` to add a component\n"))}catch(e){t.fail(p.red("Failed to fetch components")),console.error(e),process.exit(1)}}import d from"chalk";import P from"prompts";import L from"fs-extra";import T from"path";async function k(){console.log(d.bold(`
11
+ `)),console.log(m.dim(`Total: ${e.totalComponents} components
12
+ `));let s={};for(let[i,r]of Object.entries(e.components))o.category&&r.category!==o.category||(s[r.category]||(s[r.category]=[]),s[r.category].push(i));for(let[i,r]of Object.entries(s).sort())console.log(m.cyan.bold(`${i}/`)),r.sort().forEach(c=>{console.log(m.white(` ${c}`))}),console.log();console.log(m.dim("Run `npx reacticx add <component>` to add a component\n"))}catch(e){t.fail(m.red("Failed to fetch components")),console.error(e),process.exit(1)}}import g from"chalk";import k from"prompts";import J from"fs-extra";import S from"path";async function A(){console.log(g.bold(`
13
13
  \u{1F680} Initialize Reacticx
14
- `));let o=T.join(process.cwd(),"component.config.json");if(await L.pathExists(o)){let{overwrite:e}=await P({type:"confirm",name:"overwrite",message:"component.config.json already exists. Overwrite?",initial:!1});e||(console.log(d.yellow("Cancelled")),process.exit(0))}let t=await P([{type:"text",name:"outDir",message:"Where do you want to install components?",initial:"src/shared/ui"}]);t.outDir||(console.log(d.yellow("Cancelled")),process.exit(0)),await b(t.outDir),console.log(d.green(`
15
- \u2705 Created component.config.json`)),console.log(d.dim(`
16
- You can now run:`)),console.log(d.cyan(" npx reacticx add button")),console.log()}var f=new J;f.name("reacticx").description("Add beautiful React Native components to your project").version("0.1.0");f.command("init").description("Initialize reacticx in your project").action(k);f.command("list").description("List all available components").option("-c, --category <category>","Filter by category").action(F);f.command("add").description("Add a component to your project").argument("<component>","Component name to add").option("-o, --overwrite","Overwrite existing files",!1).option("-d, --dir <directory>","Target directory").action(E);f.parse();
14
+ `));let o=S.join(process.cwd(),"component.config.json");if(await J.pathExists(o)){let{overwrite:e}=await k({type:"confirm",name:"overwrite",message:"component.config.json already exists. Overwrite?",initial:!1});e||(console.log(g.yellow("Cancelled")),process.exit(0))}let t=await k([{type:"text",name:"outDir",message:"Where do you want to install components?",initial:"src/shared/ui"}]);t.outDir||(console.log(g.yellow("Cancelled")),process.exit(0)),await F(t.outDir),console.log(g.green(`
15
+ \u2705 Created component.config.json`)),console.log(g.dim(`
16
+ You can now run:`)),console.log(g.cyan(" npx reacticx add button")),console.log()}var w=new U;w.name("reacticx").description("Add beautiful React Native components to your project").version("0.1.0");w.command("init").description("Initialize reacticx in your project").action(A);w.command("list").description("List all available components").option("-c, --category <category>","Filter by category").action(E);w.command("add").description("Add a component to your project").argument("<component>","Component name to add").option("-o, --overwrite","Overwrite existing files",!1).option("-d, --dir <directory>","Target directory").action(P);w.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reacticx",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "💅 Add beautiful React Native components to your project",
5
5
  "homepage": "https://www.reacticx.com/",
6
6
  "type": "module",