nachui 0.0.5 → 0.0.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 +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import*as u from"@clack/prompts";import{Command as x}from"commander";import y from"kleur";import*as r from"@clack/prompts";import m from"kleur";import f from"fs";import $ from"path";var w=process.env.NODE_ENV==="production"?"https://api-nach-ui.vercel.app/api/v1":"http://localhost:3001/api/v1",p={async getComponent(o){let e=await fetch(`${w}/registry/${o}`);if(!e.ok)throw e.status===404?new Error(`Component "${o}" does not exist in the registry.`):new Error("Error connecting to the API.");return e.json()},async getComponents(){let o=await fetch(`${w}/registry`);if(!o.ok)throw new Error("Error connecting to the API.");return o.json()}};async function I(o){let e=r.spinner();e.start(`Searching for ${m.cyan(o)} in the registry...`);try{let n=await p.getComponent(o);e.stop(`Component ${m.green(o)} found.`);let a=$.join(process.cwd(),"src/components/ui"),d=$.join(a,`${o}.tsx`);f.existsSync(a)||f.mkdirSync(a,{recursive:!0}),f.writeFileSync(d,n.code),r.note(m.gray(`File created at: ${d}`),"Installation successful"),n.dependencies&&n.dependencies.length>0&&(r.log.warn(`This component requires: ${m.yellow(n.dependencies.join(", "))}`),r.log.info("I will enable automatic installation soon.")),r.outro(m.bgGreen().black(" NachUI ")+" Process finished.")}catch{e.stop(m.red("Error getting the component.")),r.log.error("Check that the API is running and that the slug is correct.")}}import*as s from"@clack/prompts";import c from"kleur";async function b(){let o=s.spinner();o.start("Consulting NachUI registry...");try{let e=await p.getComponents();if(o.stop("Registry loaded successfully."),e.length===0){s.log.warn("There are no components in the registry yet.");return}console.log(""),s.log.step(c.cyan("Available components:")),e.forEach(n=>{console.log(` ${c.green("\u2192")} ${c.bold(n.name)} ${c.gray(`(${n.slug})`)}`),n.dependencies.length>0&&console.log(` ${c.dim(`Deps: ${n.dependencies.join(", ")}`)}`)}),console.log(""),s.note(`To install one, run:
3
- ${c.cyan("pnpm dlx nachui add <slug>")}`,"Tip")}catch{o.stop(c.red("Error connecting to the API.")),s.log.error("Make sure the API is running on the correct port.")}}import*as t from"@clack/prompts";import i from"kleur";import k from"fs";import P from"path";async function v(o){let e=t.spinner(),n=P.join(process.cwd(),"src/components/ui"),a=P.join(n,`${o}.tsx`);if(!k.existsSync(a)){t.log.error(i.red(`The component "${o}" is not installed in your project.`)),t.log.info(`Try using: ${i.cyan(`pnpm dlx nachui add ${o}`)}`);return}e.start(`Searching for updates for ${i.cyan(o)}...`);try{let d=await p.getComponent(o);e.stop(`Latest version of ${i.green(o)} obtained.`);let C=await t.confirm({message:`Are you sure you want to update ${i.bold(o)}? This will overwrite your local changes.`,initialValue:!1});if(t.isCancel(C)||!C){t.outro(i.yellow("Update cancelled."));return}k.writeFileSync(a,d.code),t.note(i.gray(`File updated at: ${a}`),"Update successful"),t.outro(i.bgBlue().white(" NachUI ")+" Component updated to the latest version.")}catch{e.stop(i.red("Error updating.")),t.log.error("Make sure you have a connection and that the API is active.")}}var l=new x;l.name("nachui").description("CLI de NachUI").version("0.0.1");l.command("add").description("Add a component to your project").argument("<component>","component slug").action(async o=>{console.log(""),u.intro(y.bgCyan().black(" NachUI CLI ")),await I(o)});l.command("list").description("List all available components").action(async()=>{console.log(""),u.intro(y.bgCyan().black(" NachUI CLI ")),await b()});l.command("update").description("Update an installed component").argument("<component>","component slug").action(async o=>{console.log(""),u.intro(y.bgCyan().black(" NachUI CLI ")),await v(o)});l.parse();
2
+ import*as u from"@clack/prompts";import{Command as v}from"commander";import y from"kleur";import*as r from"@clack/prompts";import m from"kleur";import f from"fs";import $ from"path";var w="https://api-nach-ui.vercel.app/api/v1",p={async getComponent(o){let e=await fetch(`${w}/registry/${o}`);if(!e.ok)throw e.status===404?new Error(`Component "${o}" does not exist in the registry.`):new Error("Error connecting to the API.");return e.json()},async getComponents(){let o=await fetch(`${w}/registry`);if(!o.ok)throw new Error("Error connecting to the API.");return o.json()}};async function I(o){let e=r.spinner();e.start(`Searching for ${m.cyan(o)} in the registry...`);try{let n=await p.getComponent(o);e.stop(`Component ${m.green(o)} found.`);let a=$.join(process.cwd(),"src/components/ui"),d=$.join(a,`${o}.tsx`);f.existsSync(a)||f.mkdirSync(a,{recursive:!0}),f.writeFileSync(d,n.code),r.note(m.gray(`File created at: ${d}`),"Installation successful"),n.dependencies&&n.dependencies.length>0&&(r.log.warn(`This component requires: ${m.yellow(n.dependencies.join(", "))}`),r.log.info("I will enable automatic installation soon.")),r.outro(m.bgGreen().black(" NachUI ")+" Process finished.")}catch{e.stop(m.red("Error getting the component.")),r.log.error("Check that the API is running and that the slug is correct.")}}import*as s from"@clack/prompts";import c from"kleur";async function b(){let o=s.spinner();o.start("Consulting NachUI registry...");try{let e=await p.getComponents();if(o.stop("Registry loaded successfully."),e.length===0){s.log.warn("There are no components in the registry yet.");return}console.log(""),s.log.step(c.cyan("Available components:")),e.forEach(n=>{console.log(` ${c.green("\u2192")} ${c.bold(n.name)} ${c.gray(`(${n.slug})`)}`),n.dependencies.length>0&&console.log(` ${c.dim(`Deps: ${n.dependencies.join(", ")}`)}`)}),console.log(""),s.note(`To install one, run:
3
+ ${c.cyan("pnpm dlx nachui add <slug>")}`,"Tip")}catch{o.stop(c.red("Error connecting to the API.")),s.log.error("Make sure the API is running on the correct port.")}}import*as t from"@clack/prompts";import i from"kleur";import k from"fs";import P from"path";async function x(o){let e=t.spinner(),n=P.join(process.cwd(),"src/components/ui"),a=P.join(n,`${o}.tsx`);if(!k.existsSync(a)){t.log.error(i.red(`The component "${o}" is not installed in your project.`)),t.log.info(`Try using: ${i.cyan(`pnpm dlx nachui add ${o}`)}`);return}e.start(`Searching for updates for ${i.cyan(o)}...`);try{let d=await p.getComponent(o);e.stop(`Latest version of ${i.green(o)} obtained.`);let C=await t.confirm({message:`Are you sure you want to update ${i.bold(o)}? This will overwrite your local changes.`,initialValue:!1});if(t.isCancel(C)||!C){t.outro(i.yellow("Update cancelled."));return}k.writeFileSync(a,d.code),t.note(i.gray(`File updated at: ${a}`),"Update successful"),t.outro(i.bgBlue().white(" NachUI ")+" Component updated to the latest version.")}catch{e.stop(i.red("Error updating.")),t.log.error("Make sure you have a connection and that the API is active.")}}var l=new v;l.name("nachui").description("CLI de NachUI").version("0.0.1");l.command("add").description("Add a component to your project").argument("<component>","component slug").action(async o=>{console.log(""),u.intro(y.bgCyan().black(" NachUI CLI ")),await I(o)});l.command("list").description("List all available components").action(async()=>{console.log(""),u.intro(y.bgCyan().black(" NachUI CLI ")),await b()});l.command("update").description("Update an installed component").argument("<component>","component slug").action(async o=>{console.log(""),u.intro(y.bgCyan().black(" NachUI CLI ")),await x(o)});l.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nachui",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "description": "Official CLI for NachUI",
6
6
  "main": "./dist/index.js",