vextra 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.
Files changed (2) hide show
  1. package/dist/index.js +64 -0
  2. package/package.json +42 -0
package/dist/index.js ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var x=Object.create;var h=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var $=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of j(n))!k.call(e,r)&&r!==t&&h(e,r,{get:()=>n[r],enumerable:!(i=P(n,r))||i.enumerable});return e};var p=(e,n,t)=>(t=e!=null?x(b(e)):{},$(n||!e||!e.__esModule?h(t,"default",{value:e,enumerable:!0}):t,e));var y=require("commander"),o=require("kolorist"),w=require("child_process"),a=p(require("fs/promises")),l=p(require("path")),u=p(require("prompts")),v="https://raw.githubusercontent.com/vextra-ui/ui/main/registry/public",d=new y.Command;d.name("vextra").description("CLI for adding Vextra UI components").version("0.1.0");var C=`import { globalStyle } from '@vanilla-extract/css';
3
+
4
+ globalStyle(':root', {
5
+ vars: {
6
+ '--background': '0 0% 100%',
7
+ '--foreground': '240 10% 3.9%',
8
+ '--card': '0 0% 100%',
9
+ '--card-foreground': '240 10% 3.9%',
10
+ '--popover': '0 0% 100%',
11
+ '--popover-foreground': '240 10% 3.9%',
12
+ '--primary': '240 5.9% 10%',
13
+ '--primary-foreground': '0 0% 98%',
14
+ '--secondary': '240 4.8% 95.9%',
15
+ '--secondary-foreground': '240 5.9% 10%',
16
+ '--muted': '240 4.8% 95.9%',
17
+ '--muted-foreground': '240 3.8% 46.1%',
18
+ '--accent': '240 4.8% 95.9%',
19
+ '--accent-foreground': '240 5.9% 10%',
20
+ '--destructive': '0 84.2% 60.2%',
21
+ '--destructive-foreground': '0 0% 98%',
22
+ '--border': '240 5.9% 90%',
23
+ '--input': '240 5.9% 90%',
24
+ '--ring': '240 5.9% 10%',
25
+ '--radius': '0.5rem',
26
+ },
27
+ });
28
+
29
+ globalStyle('.dark', {
30
+ vars: {
31
+ '--background': '240 10% 3.9%',
32
+ '--foreground': '0 0% 98%',
33
+ '--card': '240 10% 3.9%',
34
+ '--card-foreground': '0 0% 98%',
35
+ '--popover': '240 10% 3.9%',
36
+ '--popover-foreground': '0 0% 98%',
37
+ '--primary': '0 0% 98%',
38
+ '--primary-foreground': '240 5.9% 10%',
39
+ '--secondary': '240 3.7% 15.9%',
40
+ '--secondary-foreground': '0 0% 98%',
41
+ '--muted': '240 3.7% 15.9%',
42
+ '--muted-foreground': '240 5% 64.9%',
43
+ '--accent': '240 3.7% 15.9%',
44
+ '--accent-foreground': '0 0% 98%',
45
+ '--destructive': '0 62.8% 30.6%',
46
+ '--destructive-foreground': '0 0% 98%',
47
+ '--border': '240 3.7% 15.9%',
48
+ '--input': '240 3.7% 15.9%',
49
+ '--ring': '240 4.9% 83.9%',
50
+ },
51
+ });
52
+ `;d.command("init").description("Initialize project and configure component paths").action(async()=>{console.log((0,o.blue)(`
53
+ Initializing Vextra UI...`));let e=await(0,u.default)([{type:"text",name:"componentsPath",message:"Where would you like to store your components?",initial:"components/ui"},{type:"text",name:"themePath",message:"Where would you like to store the theme file (vars.css.ts)?",initial:"styles/vars.css.ts"}]);(!e.componentsPath||!e.themePath)&&(console.log((0,o.red)(`
54
+ \u2716 Initialization cancelled.`)),process.exit(0));let n={components:e.componentsPath,theme:e.themePath},t=l.default.join(process.cwd(),"vextra.json");await a.default.writeFile(t,JSON.stringify(n,null,2),"utf-8"),console.log((0,o.green)("\u2713 Configuration saved to vextra.json"));let i=l.default.join(process.cwd(),e.themePath),r=l.default.dirname(i);await a.default.mkdir(r,{recursive:!0}),await a.default.writeFile(i,C,"utf-8"),console.log((0,o.green)(`\u2713 Theme file created at ${e.themePath}`)),console.log((0,o.blue)(`
55
+ Initialization complete! You can now run "vextra add" to install components.`))});async function I(e){console.log((0,o.blue)(`
56
+ Adding component: ${e}...`));try{let n=l.default.join(process.cwd(),"vextra.json"),t;try{let c=await a.default.readFile(n,"utf-8");t=JSON.parse(c)}catch{console.log((0,o.red)(`
57
+ \u2716 vextra.json not found.`)),console.log((0,o.yellow)('Please run "vextra init" first to configure your paths.'));return}let i=`${v}/${e}.json`,r=await fetch(i);if(!r.ok){console.log((0,o.red)(`
58
+ \u2716 Component "${e}" not found in registry (HTTP ${r.status}).`)),console.log((0,o.yellow)("Check if your code is pushed to GitHub and the URL is correct:")),console.log(i);return}let s=await r.json(),g=l.default.join(process.cwd(),t.components);await a.default.mkdir(g,{recursive:!0});for(let c of s.files){let m=l.default.join(g,c.name);await a.default.writeFile(m,c.content,"utf-8"),console.log((0,o.green)(`\u2713 Created ${c.name} in ${t.components}`))}s.dependencies&&s.dependencies.length>0&&(console.log((0,o.blue)(`
59
+ Installing dependencies for ${e}...`)),await new Promise((c,m)=>{(0,w.spawn)("pnpm",["add",...s.dependencies],{stdio:"inherit",shell:!0}).on("close",f=>{f===0?c(null):m(new Error(`Installation failed with code ${f}`))})})),console.log((0,o.green)(`
60
+ \u2713 Component ${e} successfully added!`))}catch(n){console.log((0,o.red)(`
61
+ \u2716 An error occurred while adding the component.`)),console.error(n)}}d.command("add").description("Add a component to your project").argument("[components...]","The components to add").action(async e=>{let n=e;if(n.length===0){console.log((0,o.blue)(`
62
+ Fetching available components...`));let t=[];try{let s=await fetch(`${v}/index.json`);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);t=await s.json()}catch{console.log((0,o.red)(`
63
+ \u2716 Could not fetch component list from registry.`)),console.log((0,o.yellow)("Please check your network connection or repository URL.")),process.exit(1)}let i=t.map(s=>({title:s.name,value:s.name})),r=await(0,u.default)({type:"multiselect",name:"selected",message:"Which components would you like to add?",choices:i,instructions:!1});(!r.selected||r.selected.length===0)&&(console.log((0,o.red)(`
64
+ \u2716 No components selected. Exiting.`)),process.exit(0)),n=r.selected}for(let t of n)await I(t)});d.parse();
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "vextra",
3
+ "version": "0.1.0",
4
+ "description": "CLI for Vextra UI",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "vextra": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "keywords": [
16
+ "react",
17
+ "ui",
18
+ "components",
19
+ "cli"
20
+ ],
21
+ "author": {
22
+ "name": "Aleksei Zhukov",
23
+ "email": "mr.alek3@gmail.com",
24
+ "url": "https://github.com/mralek3"
25
+ },
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "commander": "^15.0.0",
29
+ "kolorist": "^1.8.0",
30
+ "prompts": "^2.4.2"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^25.9.3",
34
+ "@types/prompts": "^2.4.9",
35
+ "tsup": "^8.5.1",
36
+ "typescript": "^6.0.3"
37
+ },
38
+ "scripts": {
39
+ "dev": "tsup src/index.ts --watch",
40
+ "build": "tsup src/index.ts --minify"
41
+ }
42
+ }