neonblade 0.0.1 → 0.0.3

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/index.js +55 -97
  2. package/package.json +14 -11
package/index.js CHANGED
@@ -2,89 +2,72 @@
2
2
 
3
3
  const fs = require("fs")
4
4
  const path = require("path")
5
+ const axios = require("axios")
6
+ const { execSync } = require("child_process")
5
7
 
8
+ const BASE_URL = "https://neonbladeui-registry.vercel.app"
6
9
 
10
+ async function main() {
11
+ const projectRoot = process.cwd()
12
+ const targetAppPath = findAppPath(projectRoot)
7
13
 
8
- const projectRoot = process.cwd()
9
- const targetAppPath = findAppPath(projectRoot)
10
-
11
- const args = process.argv.slice(2)
12
-
13
- const command = args[0]
14
- const component = args[1]
15
-
16
- if (command !== "add") {
17
- console.log("Usage: neonblade add <component>")
18
- process.exit(1)
19
- }
20
-
21
- if (!component) {
22
- console.log("Please provide a component name")
23
- process.exit(1)
24
- }
25
-
26
- const componentDir = path.join(
27
- __dirname,
28
- "../registry/components",
29
- component
30
- )
14
+ const args = process.argv.slice(2)
15
+ const command = args[0]
16
+ const component = args[1]
31
17
 
32
- //log if component is not found
33
- if (!fs.existsSync(componentDir)) {
34
- logError(`${component} not found`)
35
- process.exit(1)
36
- }
18
+ if (command !== "add") {
19
+ console.log("Usage: neonblade add <component>")
20
+ process.exit(1)
21
+ }
37
22
 
38
- // Read metadata
39
- const metaPath = path.join(componentDir, "meta.json")
23
+ if (!component) {
24
+ console.log("Please provide a component name")
25
+ process.exit(1)
26
+ }
40
27
 
41
- if (!fs.existsSync(metaPath)) {
42
- console.log("Component metadata not found")
43
- process.exit(1)
44
- }
28
+ console.log("\n⚡ NeonBlade UI\n")
45
29
 
46
- const meta = JSON.parse(fs.readFileSync(metaPath, "utf-8"))
30
+ logStep(`Adding ${component}...`)
47
31
 
48
- console.log("\n⚡ NeonBlade UI\n")
32
+ const data = await fetchComponent(component)
49
33
 
50
- // Copy files
51
- logStep(`Adding ${component}...`)
52
- logStep("Copying files...")
34
+ logStep("Copying files...")
53
35
 
54
- meta.files.forEach((file) => {
55
- const sourcePath = path.join(componentDir, file)
36
+ for (const file of data.files) {
37
+ const fileRes = await axios.get(file.url)
56
38
 
57
- const targetPath = path.join(
58
- targetAppPath,
59
- "components/ui",
60
- toKebabCase(file)
61
- )
39
+ const targetPath = path.join(
40
+ targetAppPath,
41
+ file.path
42
+ )
62
43
 
63
- fs.mkdirSync(path.dirname(targetPath), { recursive: true })
64
- fs.copyFileSync(sourcePath, targetPath)
65
- })
44
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true })
45
+ fs.writeFileSync(targetPath, fileRes.data)
46
+ }
66
47
 
67
- const { execSync } = require("child_process")
48
+ if (data.dependencies && data.dependencies.length > 0) {
49
+ logStep("Installing dependencies...")
68
50
 
69
- // Install dependencies if any
70
- if (meta.dependencies && meta.dependencies.length > 0) {
71
- logStep("Installing dependencies...")
51
+ execSync(
52
+ `pnpm add ${data.dependencies.join(" ")}`,
53
+ {
54
+ stdio: "inherit",
55
+ cwd: targetAppPath,
56
+ }
57
+ )
58
+ }
72
59
 
73
- execSync(
74
- `pnpm add ${meta.dependencies.join(" ")}`,
75
- { stdio: "inherit", cwd: targetAppPath }
76
- )
60
+ logSuccess(`${component} added successfully`)
77
61
  }
78
62
 
79
- logSuccess(`${component} added successfully`)
63
+ main()
80
64
 
65
+ // ---------------- HELPERS ----------------
81
66
 
82
67
  function findAppPath(root) {
83
68
  const appsDir = path.join(root, "apps")
84
69
 
85
- if (!fs.existsSync(appsDir)) {
86
- return root
87
- }
70
+ if (!fs.existsSync(appsDir)) return root
88
71
 
89
72
  const apps = fs.readdirSync(appsDir)
90
73
 
@@ -104,10 +87,6 @@ function findAppPath(root) {
104
87
  return root
105
88
  }
106
89
 
107
- function toKebabCase(str) {
108
- return str.toLowerCase()
109
- }
110
-
111
90
  function logStep(message) {
112
91
  console.log(`📦 ${message}`)
113
92
  }
@@ -120,35 +99,14 @@ function logError(message) {
120
99
  console.log(`❌ ${message}`)
121
100
  }
122
101
 
123
- function gradientLog(text) {
124
-
125
-
126
- //yellow and blue gradient
127
- const colors = [
128
- "#ffff00",
129
- "#00ffff",
130
- "#0000ff",
131
- "#0080ff",
132
- "#00ff80",
133
- "#00ff00",
134
- "#80ff00",
135
- "#ffbf00",
136
- "#ff8000",
137
- "#ff4000",
138
- "#ff0000",
139
- ];
140
-
141
- const args = [];
142
- let format = '';
143
-
144
- [...text].forEach((char, i) => {
145
- const color = colors[i % colors.length];
146
- format += `%c${char}`;
147
- args.push(`color: ${color}; font-size: 16px; font-weight: bold;`);
148
- });
149
-
150
- console.log(format, ...args);
151
-
152
-
153
- }
154
-
102
+ async function fetchComponent(component) {
103
+ try {
104
+ const res = await axios.get(
105
+ `${BASE_URL}/components/${component}/index.json`
106
+ )
107
+ return res.data
108
+ } catch (err) {
109
+ logError(`Component "${component}" not found`)
110
+ process.exit(1)
111
+ }
112
+ }
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
- {
2
- "name": "neonblade",
3
- "version": "0.0.1",
4
- "description": "NeonBlade UI CLI",
5
-
6
- "bin": {
7
- "neonblade": "index.js"
8
- },
9
- "type": "commonjs"
10
-
11
- }
1
+ {
2
+ "name": "neonblade",
3
+ "version": "0.0.3",
4
+ "description": "NeonBlade UI CLI",
5
+ "bin": {
6
+ "neonblade": "index.js"
7
+ },
8
+ "type": "commonjs",
9
+ "dependencies": {
10
+ "axios": "^1.14.0",
11
+ "lucide-react": "^1.7.0",
12
+ "react-icons": "^5.6.0"
13
+ }
14
+ }