nachui 1.0.0 → 1.0.2

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 +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import*as F from"@clack/prompts";import{Command as X}from"commander";import R from"kleur";import*as r from"@clack/prompts";import f from"kleur";import{execSync as Q}from"child_process";import I from"fs";import D from"path";var A="http://api.nach-ui.vercel.app/api/v1",h={async getComponents(){let e=await fetch(`${A}/registry`);if(!e.ok)throw new Error("Error connecting to the API.");return e.json()},async getComponent(e){let n=await fetch(`${A}/registry/${e}`);if(!n.ok)throw n.status===404?new Error(`Component "${e}" does not exist in the registry.`):new Error("Error connecting to the API.");return n.json()},async getTheme(e="default"){let n=await fetch(`${A}/themes/${e}`);if(!n.ok)throw new Error("Failed to fetch styles");return n.json()},async getThemes(){let e=await fetch(`${A}/themes`);if(!e.ok)throw new Error("Error connecting to the API.");return e.json()}};import M from"fs";import O from"path";function z(){let e=process.cwd();return M.existsSync(O.join(e,"pnpm-lock.yaml"))?"pnpm":M.existsSync(O.join(e,"yarn.lock"))?"yarn":M.existsSync(O.join(e,"bun.lockb"))?"bun":"npm"}function B(e,n){let t=n.join(" ");switch(e){case"pnpm":return`pnpm add ${t}`;case"yarn":return`yarn add ${t}`;case"bun":return`bun add ${t}`;default:return`npm install ${t}`}}async function V(e){let n=r.spinner(),t=D.join(process.cwd(),"nachui.json");if(!I.existsSync(t)){r.log.error(f.red("Error: nachui.json not found. Please run 'nachui init' first."));return}let U=JSON.parse(I.readFileSync(t,"utf-8"));n.start(`Searching for ${f.cyan(e)} in the registry...`);try{let a=await h.getComponent(e);n.stop(`Component ${f.green(e)} found.`);let l=U.aliases.components.replace("@/","src/"),o=D.join(process.cwd(),l),m=D.join(o,`${e}.tsx`);if(I.existsSync(o)||I.mkdirSync(o,{recursive:!0}),I.writeFileSync(m,a.code),r.note(f.gray(`Location: ${m}`),"Component installed"),a.dependencies&&a.dependencies.length>0){let d=D.join(process.cwd(),"package.json");if(I.existsSync(d)){let N=JSON.parse(I.readFileSync(d,"utf-8")),k={...N.dependencies,...N.devDependencies},T=a.dependencies.filter(x=>!k[x]);if(T.length>0){r.log.warn(`Missing dependencies: ${f.yellow(T.join(", "))}`);let x=await r.confirm({message:"Do you want to install missing dependencies?",initialValue:!0});if(x&&!r.isCancel(x)){let b=r.spinner();b.start("Installing dependencies...");try{let y=z(),K=B(y,T);Q(K,{stdio:"inherit"}),b.stop(f.green("Dependencies installed successfully."))}catch{b.stop(f.red("Failed to install dependencies.")),r.log.error("Please run the command manually.")}}}else r.log.info(f.green("\u2713 All dependencies are already present."))}}r.outro(f.bgGreen().black(" NachUI ")+" Component ready to use!")}catch{n.stop(f.red("Error getting the component.")),r.log.error("Make sure the slug is correct or the API is online.")}}import*as s from"@clack/prompts";import w from"kleur";import c from"fs";import u from"path";async function G(){s.intro(w.bgCyan().black(" NachUI - Initialization "));let e=s.spinner();try{e.start("Fetching available themes...");let n=await h.getThemes();e.stop(w.green("Themes loaded."));let t=await s.select({message:"Select a theme for your project:",options:n.map(y=>({value:y,label:y.charAt(0).toUpperCase()+y.slice(1)})),initialValue:"default"});if(s.isCancel(t)){s.cancel("Operation cancelled.");return}e.start(`Downloading ${w.cyan(t)} assets...`);let{css:U,config:a,utils:l}=await h.getTheme(t);e.stop(w.green(`Assets for ${t} ready.`));let o=process.cwd(),m=c.existsSync(u.join(o,"next.config.mjs"))||c.existsSync(u.join(o,"next.config.js")),d=m?"src/app/globals.css":"src/index.css";if(!c.existsSync(u.join(o,d))){let y=m?"app/globals.css":"index.css";c.existsSync(u.join(o,y))&&(d=y)}let N={...a,tailwind:{...a.tailwind,css:d}};c.writeFileSync(u.join(o,"nachui.json"),JSON.stringify(N,null,2));let k=u.join(o,d),T=U.replace(/@source\s+['"][^'"]+['"];\n/g,"");c.existsSync(k)?c.readFileSync(k,"utf8").includes("/* NachUI Tokens */")?s.log.warn("NachUI tokens already exist in your CSS. Skipping injection."):c.appendFileSync(k,`
2
+ import*as F from"@clack/prompts";import{Command as X}from"commander";import R from"kleur";import*as r from"@clack/prompts";import f from"kleur";import{execSync as Q}from"child_process";import I from"fs";import D from"path";var A="https://api-nach-ui.vercel.app/api/v1",h={async getComponents(){let e=await fetch(`${A}/registry`);if(!e.ok)throw new Error("Error connecting to the API.");return e.json()},async getComponent(e){let n=await fetch(`${A}/registry/${e}`);if(!n.ok)throw n.status===404?new Error(`Component "${e}" does not exist in the registry.`):new Error("Error connecting to the API.");return n.json()},async getTheme(e="default"){let n=await fetch(`${A}/themes/${e}`);if(!n.ok)throw new Error("Failed to fetch styles");return n.json()},async getThemes(){let e=await fetch(`${A}/themes`);if(!e.ok)throw new Error("Error connecting to the API.");return e.json()}};import M from"fs";import O from"path";function z(){let e=process.cwd();return M.existsSync(O.join(e,"pnpm-lock.yaml"))?"pnpm":M.existsSync(O.join(e,"yarn.lock"))?"yarn":M.existsSync(O.join(e,"bun.lockb"))?"bun":"npm"}function B(e,n){let t=n.join(" ");switch(e){case"pnpm":return`pnpm add ${t}`;case"yarn":return`yarn add ${t}`;case"bun":return`bun add ${t}`;default:return`npm install ${t}`}}async function V(e){let n=r.spinner(),t=D.join(process.cwd(),"nachui.json");if(!I.existsSync(t)){r.log.error(f.red("Error: nachui.json not found. Please run 'nachui init' first."));return}let U=JSON.parse(I.readFileSync(t,"utf-8"));n.start(`Searching for ${f.cyan(e)} in the registry...`);try{let a=await h.getComponent(e);n.stop(`Component ${f.green(e)} found.`);let l=U.aliases.components.replace("@/","src/"),o=D.join(process.cwd(),l),m=D.join(o,`${e}.tsx`);if(I.existsSync(o)||I.mkdirSync(o,{recursive:!0}),I.writeFileSync(m,a.code),r.note(f.gray(`Location: ${m}`),"Component installed"),a.dependencies&&a.dependencies.length>0){let d=D.join(process.cwd(),"package.json");if(I.existsSync(d)){let N=JSON.parse(I.readFileSync(d,"utf-8")),k={...N.dependencies,...N.devDependencies},T=a.dependencies.filter(x=>!k[x]);if(T.length>0){r.log.warn(`Missing dependencies: ${f.yellow(T.join(", "))}`);let x=await r.confirm({message:"Do you want to install missing dependencies?",initialValue:!0});if(x&&!r.isCancel(x)){let b=r.spinner();b.start("Installing dependencies...");try{let y=z(),K=B(y,T);Q(K,{stdio:"inherit"}),b.stop(f.green("Dependencies installed successfully."))}catch{b.stop(f.red("Failed to install dependencies.")),r.log.error("Please run the command manually.")}}}else r.log.info(f.green("\u2713 All dependencies are already present."))}}r.outro(f.bgGreen().black(" NachUI ")+" Component ready to use!")}catch{n.stop(f.red("Error getting the component.")),r.log.error("Make sure the slug is correct or the API is online.")}}import*as s from"@clack/prompts";import w from"kleur";import c from"fs";import u from"path";async function G(){s.intro(w.bgCyan().black(" NachUI - Initialization "));let e=s.spinner();try{e.start("Fetching available themes...");let n=await h.getThemes();e.stop(w.green("Themes loaded."));let t=await s.select({message:"Select a theme for your project:",options:n.map(y=>({value:y,label:y.charAt(0).toUpperCase()+y.slice(1)})),initialValue:"default"});if(s.isCancel(t)){s.cancel("Operation cancelled.");return}e.start(`Downloading ${w.cyan(t)} assets...`);let{css:U,config:a,utils:l}=await h.getTheme(t);e.stop(w.green(`Assets for ${t} ready.`));let o=process.cwd(),m=c.existsSync(u.join(o,"next.config.mjs"))||c.existsSync(u.join(o,"next.config.js")),d=m?"src/app/globals.css":"src/index.css";if(!c.existsSync(u.join(o,d))){let y=m?"app/globals.css":"index.css";c.existsSync(u.join(o,y))&&(d=y)}let N={...a,tailwind:{...a.tailwind,css:d}};c.writeFileSync(u.join(o,"nachui.json"),JSON.stringify(N,null,2));let k=u.join(o,d),T=U.replace(/@source\s+['"][^'"]+['"];\n/g,"");c.existsSync(k)?c.readFileSync(k,"utf8").includes("/* NachUI Tokens */")?s.log.warn("NachUI tokens already exist in your CSS. Skipping injection."):c.appendFileSync(k,`
3
3
 
4
4
  /* NachUI Tokens */
5
5
  ${T}`):(c.mkdirSync(u.dirname(k),{recursive:!0}),c.writeFileSync(k,`/* NachUI Tokens */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nachui",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Official CLI for NachUI",
6
6
  "main": "./dist/index.js",