simpyui 0.1.0
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.js +13 -0
- package/package.json +36 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{existsSync as W,mkdirSync as Y,writeFileSync as V}from"node:fs";import{join as z,dirname as ee}from"node:path";import{existsSync as y,readFileSync as N,writeFileSync as q}from"node:fs";import{execSync as K}from"node:child_process";import{join as u}from"node:path";var c=e=>`\x1B[1m${e}\x1B[0m`,m=e=>`\x1B[32m${e}\x1B[0m`,i=e=>`\x1B[36m${e}\x1B[0m`,S=e=>`\x1B[33m${e}\x1B[0m`,p=e=>`\x1B[31m${e}\x1B[0m`,n=e=>`\x1B[2m${e}\x1B[0m`;var T="simpyui.json";function D(){let e=u(process.cwd(),T);if(!y(e))return null;try{return JSON.parse(N(e,"utf-8"))}catch{return null}}function E(e){let o=u(process.cwd(),T);q(o,JSON.stringify(e,null,2)+`
|
|
3
|
+
`)}function I(){let e=D();return e||(console.log(p("\u2717 No simpyui.json found. Run ")+c("simpyui init")+p(" first.")),process.exit(1)),e}function Q(){let e=process.cwd();return y(u(e,"bun.lockb"))||y(u(e,"bun.lock"))?"bun":y(u(e,"pnpm-lock.yaml"))?"pnpm":y(u(e,"yarn.lock"))?"yarn":"npm"}function X(e,o){let t=o.join(" ");switch(e){case"bun":return`bun add ${t}`;case"pnpm":return`pnpm add ${t}`;case"yarn":return`yarn add ${t}`;default:return`npm install ${t}`}}function G(e){if(e.length===0)return;let o=Q(),t=X(o,e);console.log(n(` $ ${t}`));try{K(t,{stdio:"pipe",cwd:process.cwd()})}catch{console.log(S(` \u26A0 Failed to install. Run manually: ${t}`))}}function j(){let e=u(process.cwd(),"package.json");if(!y(e))return new Set;try{let o=JSON.parse(N(e,"utf-8"));return new Set([...Object.keys(o.dependencies||{}),...Object.keys(o.devDependencies||{})])}catch{return new Set}}async function H(e){let o=await fetch(e);if(!o.ok)throw new Error(`Failed to fetch ${e} (${o.status})`);return o.text()}function L(e){let o=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],t=0,r=setInterval(()=>{process.stdout.write(`\r${i(o[t++%o.length])} ${e}`)},80);return{stop(s){clearInterval(r),process.stdout.write(`\r${s||""}
|
|
4
|
+
`)}}}async function P(e,o=""){let t=o?` ${n(`(${o})`)}`:"";return process.stdout.write(`${e}${t}: `),new Promise(r=>{let s="";process.stdin.setEncoding("utf-8"),process.stdin.resume(),process.stdin.once("data",g=>{s=g.trim(),process.stdin.pause(),r(s||o)})})}async function F(e,o=!0){let r=await P(`${e} ${n(`[${o?"Y/n":"y/N"}]`)}`);return r?r.toLowerCase().startsWith("y"):o}var B="https://raw.githubusercontent.com/AbhishekS04/SimpyUI/main/src/registry",d={button:{name:"Button",slug:"button",files:["button/button.tsx"],dependencies:["framer-motion"],internal:[],description:"Animated button with multiple variants and sizes."},card:{name:"Card",slug:"card",files:["card/card.tsx"],dependencies:["framer-motion"],internal:[],description:"Versatile card container with hover and glow effects."},badge:{name:"Badge",slug:"badge",files:["badge/badge.tsx"],dependencies:["framer-motion"],internal:[],description:"Small status indicators with colorful variants."},avatar:{name:"Avatar",slug:"avatar",files:["avatar/avatar.tsx"],dependencies:["framer-motion"],internal:[],description:"User avatar with image support and fallback initials."},input:{name:"Input",slug:"input",files:["input/input.tsx"],dependencies:[],internal:[],description:"Styled text input with label and error states."},toggle:{name:"Toggle",slug:"toggle",files:["toggle/toggle.tsx"],dependencies:["framer-motion"],internal:[],description:"Smooth animated toggle switch."},accordion:{name:"Accordion",slug:"accordion",files:["accordion/accordion.tsx"],dependencies:["framer-motion","react-icons"],internal:[],description:"Collapsible content sections with smooth animations."},tabs:{name:"Tabs",slug:"tabs",files:["tabs/tabs.tsx"],dependencies:["framer-motion"],internal:[],description:"Animated tab navigation with smooth underline indicator."},progress:{name:"Progress",slug:"progress",files:["progress/progress.tsx"],dependencies:["framer-motion"],internal:[],description:"Animated progress bar with multiple colors and sizes."},skeleton:{name:"Skeleton",slug:"skeleton",files:["skeleton/skeleton.tsx"],dependencies:["framer-motion"],internal:[],description:"Animated loading placeholder with pulsing effect."},modal:{name:"Modal",slug:"modal",files:["modal/modal.tsx"],dependencies:["framer-motion","react-icons"],internal:[],description:"Animated dialog with backdrop blur."},toast:{name:"Toast",slug:"toast",files:["toast/toast.tsx"],dependencies:["framer-motion","react-icons"],internal:[],description:"Notification toast with animated entrance."},alert:{name:"Alert",slug:"alert",files:["alert/alert.tsx"],dependencies:["framer-motion","react-icons"],internal:[],description:"Contextual alert banners with icons."},tooltip:{name:"Tooltip",slug:"tooltip",files:["tooltip/tooltip.tsx"],dependencies:[],internal:[],description:"Hover tooltip with multiple positions."},"social-stories":{name:"Social Stories",slug:"social-stories",files:["social-stories/social-stories.tsx"],dependencies:["framer-motion","lucide-react"],internal:[],description:"Instagram/LinkedIn-style stories viewer with progress bars and video support."}},R=Object.keys(d);function b(){console.log(),console.log(c(i(" \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E"))),console.log(c(i(" \u2502 SimpyUI CLI \u2502"))),console.log(c(i(" \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F"))),console.log()}async function oe(){b(),D()&&(await F(S(" simpyui.json already exists. Overwrite?"),!1)||(console.log(n(" Cancelled.")),process.exit(0))),console.log(n(` Configure where SimpyUI components will be installed.
|
|
5
|
+
`));let o=await P(` ${c("Component directory")}`,"src/components/ui"),t=await F(` ${c("Use TypeScript?")}`,!0);E({componentDir:o,typescript:t}),console.log(),console.log(m(" \u2713 Created simpyui.json")),console.log(n(` Components will be added to: ${o}/`)),console.log(),console.log(` ${c("Next step:")} Run ${i("npx simpyui add button")} to add your first component.`),console.log()}function ne(){b(),console.log(` ${c("Available components:")}
|
|
6
|
+
`);let e={};for(let o of Object.values(d)){let t=te(o.slug);e[t]||(e[t]=[]),e[t].push(o)}for(let[o,t]of Object.entries(e)){console.log(` ${c(i(o))}`);for(let r of t){let s=r.dependencies.length?n(` \u2192 ${r.dependencies.join(", ")}`):"";console.log(` ${m("\u2022")} ${c(r.slug.padEnd(16))} ${n(r.description)}${s}`)}console.log()}console.log(n(` Total: ${R.length} components`)),console.log(),console.log(` ${n("Usage:")} ${i("npx simpyui add <name>")}`),console.log()}function te(e){return{button:"General",card:"General",badge:"General",avatar:"General",input:"Inputs",toggle:"Inputs",accordion:"Data Display",tabs:"Data Display",progress:"Data Display",skeleton:"Data Display",modal:"Feedback",toast:"Feedback",alert:"Feedback",tooltip:"Overlay","social-stories":"Animation"}[e]||"Other"}async function M(e){b();let o=I(),t=e.includes("--all"),r=e.filter(l=>!l.startsWith("-")),s=[];if(t)s=[...R],console.log(` Adding ${c("all")} ${i(String(s.length))} components...
|
|
7
|
+
`);else if(r.length===0)console.log(p(" \u2717 Please specify component name(s).")),console.log(),console.log(` ${n("Usage:")} ${i("npx simpyui add button card modal")}`),console.log(` ${n(" ")} ${i("npx simpyui add --all")}`),console.log(),console.log(` ${n("Run")} ${i("npx simpyui list")} ${n("to see all available components.")}`),console.log(),process.exit(1);else{let l=r.filter(a=>!d[a]);l.length>0&&(console.log(p(` \u2717 Unknown component(s): ${l.join(", ")}`)),console.log(),console.log(` ${n("Run")} ${i("npx simpyui list")} ${n("to see all available components.")}`),console.log(),process.exit(1)),s=r}let g=new Set;function h(l){if(g.has(l))return;let a=d[l];if(a){for(let f of a.internal)h(f);g.add(l)}}for(let l of s)h(l);s=[...g];let $=new Set;for(let l of s)for(let a of d[l].dependencies)$.add(a);let x=j(),k=[...$].filter(l=>!x.has(l)),O=L("Downloading components..."),U=0,C=0;for(let l of s){let a=d[l];for(let f of a.files){let J=`${B}/${f}`,v=f.split("/").pop(),le=o.typescript?"":v.replace(".tsx",".jsx"),Z=o.typescript?v:v.replace(".tsx",".jsx"),A=z(process.cwd(),o.componentDir,Z);if(W(A)){C++;continue}try{let w=await H(J);o.typescript||(w=se(w)),Y(ee(A),{recursive:!0}),V(A,w),U++}catch(w){O.stop(p(` \u2717 Failed to download ${f}`)),console.log(n(` ${w.message}`))}}}O.stop(m(` \u2713 Downloaded ${U} file(s)`)+(C?n(` (${C} already existed)`):"")),k.length>0?(console.log(),console.log(` ${c("Installing dependencies:")} ${i(k.join(", "))}`),G(k),console.log(m(" \u2713 Dependencies installed"))):$.size>0&&console.log(n(" \u2713 All dependencies already installed")),console.log(),console.log(m(" Done! ")+n("Components added:"));for(let l of s){let a=d[l],f=a.files[0].split("/").pop();console.log(` ${m("\u2022")} ${c(a.name)} \u2192 ${n(`${o.componentDir}/${f}`)}`)}console.log(),s.includes("button")&&(console.log(n(" Import example:")),console.log(i(` import Button from './${o.componentDir}/button'`)),console.log())}function se(e){return e.replace(/: string/g,"").replace(/: number/g,"").replace(/: boolean/g,"").replace(/: ReactNode/g,"").replace(/: React\.ReactNode/g,"").replace(/<[A-Z]\w+Props>/g,"").replace(/interface \w+ \{[^}]*\}/gs,"").replace(/type \w+ = [^;\n]+;?/g,"").replace(/export type \w+ = [^;\n]+;?/g,"").replace(/export interface \w+ \{[^}]*\}/gs,"").replace(/import \{ type \w+[\s\S]*?\} from/g,"import {").replace(/import type \{[^}]*\} from '[^']+'\n?/g,"").replace(/, type \w+/g,"").replace(/as const/g,"").replace(/<HTMLMotionProps<'[^']*'>>/g,"").replace(/Omit<\w+<'[^']*'>,\s*'[^']*'>/g,"").replace(/Record<\w+,\s*\w+>/g,"").replace(/\.tsx/g,".jsx").replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`)}function ie(e){b();let o=I(),t=e.filter(r=>!r.startsWith("-"));t.length===0&&(console.log(p(" \u2717 Specify a component name.")),process.exit(1));for(let r of t){let s=d[r];if(!s){console.log(p(` \u2717 Unknown component: ${r}`));continue}let g=s.files[0].split("/").pop(),h=z(process.cwd(),o.componentDir,g);if(W(h)?console.log(S(` \u25CF ${s.name}`),n("\u2014 already exists")):console.log(m(` + ${s.name}`),n(`\u2192 ${o.componentDir}/${g}`)),s.dependencies.length>0){let $=j();for(let x of s.dependencies)$.has(x)?console.log(n(` \u2713 ${x} (installed)`)):console.log(i(` + ${x} (will install)`))}console.log()}}function _(){b(),console.log(` ${c("Usage:")} simpyui ${i("<command>")} ${n("[options]")}`),console.log(),console.log(` ${c("Commands:")}`),console.log(` ${i("init")} Configure SimpyUI for your project`),console.log(` ${i("add")} ${n("<name>")} Add component(s) to your project`),console.log(` ${i("add --all")} Add all components at once`),console.log(` ${i("list")} List all available components`),console.log(` ${i("diff")} ${n("<name>")} Preview what would be added`),console.log(` ${i("help")} Show this help message`),console.log(),console.log(` ${c("Examples:")}`),console.log(n(" $ npx simpyui init")),console.log(n(" $ npx simpyui add button")),console.log(n(" $ npx simpyui add button card modal toast")),console.log(n(" $ npx simpyui add --all")),console.log()}async function re(){let e=process.argv.slice(2),o=e[0];switch(o){case"init":await oe();break;case"add":await M(e.slice(1));break;case"list":case"ls":ne();break;case"diff":ie(e.slice(1));break;case"help":case"--help":case"-h":case void 0:_();break;default:d[o]?await M(e):(console.log(p(`
|
|
10
|
+
Unknown command: ${o}
|
|
11
|
+
`)),_())}}re().catch(e=>{console.error(p(`
|
|
12
|
+
Error: ${e.message}
|
|
13
|
+
`)),process.exit(1)});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simpyui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI to add SimpyUI components to your project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"simpyui": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "node scripts/build.js",
|
|
11
|
+
"dev": "node scripts/build.js --watch",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"simpyui",
|
|
19
|
+
"react",
|
|
20
|
+
"components",
|
|
21
|
+
"ui",
|
|
22
|
+
"cli",
|
|
23
|
+
"tailwindcss",
|
|
24
|
+
"framer-motion"
|
|
25
|
+
],
|
|
26
|
+
"author": "Abhishek Singh",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/AbhishekS04/SimpyUI.git"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^25.2.3",
|
|
34
|
+
"esbuild": "^0.20.0"
|
|
35
|
+
}
|
|
36
|
+
}
|