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.
- package/index.js +55 -97
- 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
|
|
9
|
-
const
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
18
|
+
if (command !== "add") {
|
|
19
|
+
console.log("Usage: neonblade add <component>")
|
|
20
|
+
process.exit(1)
|
|
21
|
+
}
|
|
37
22
|
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
if (!component) {
|
|
24
|
+
console.log("Please provide a component name")
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
40
27
|
|
|
41
|
-
|
|
42
|
-
console.log("Component metadata not found")
|
|
43
|
-
process.exit(1)
|
|
44
|
-
}
|
|
28
|
+
console.log("\n⚡ NeonBlade UI\n")
|
|
45
29
|
|
|
46
|
-
|
|
30
|
+
logStep(`Adding ${component}...`)
|
|
47
31
|
|
|
48
|
-
|
|
32
|
+
const data = await fetchComponent(component)
|
|
49
33
|
|
|
50
|
-
|
|
51
|
-
logStep(`Adding ${component}...`)
|
|
52
|
-
logStep("Copying files...")
|
|
34
|
+
logStep("Copying files...")
|
|
53
35
|
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
for (const file of data.files) {
|
|
37
|
+
const fileRes = await axios.get(file.url)
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
39
|
+
const targetPath = path.join(
|
|
40
|
+
targetAppPath,
|
|
41
|
+
file.path
|
|
42
|
+
)
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
44
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true })
|
|
45
|
+
fs.writeFileSync(targetPath, fileRes.data)
|
|
46
|
+
}
|
|
66
47
|
|
|
67
|
-
|
|
48
|
+
if (data.dependencies && data.dependencies.length > 0) {
|
|
49
|
+
logStep("Installing dependencies...")
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
execSync(
|
|
52
|
+
`pnpm add ${data.dependencies.join(" ")}`,
|
|
53
|
+
{
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
cwd: targetAppPath,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
}
|
|
72
59
|
|
|
73
|
-
|
|
74
|
-
`pnpm add ${meta.dependencies.join(" ")}`,
|
|
75
|
-
{ stdio: "inherit", cwd: targetAppPath }
|
|
76
|
-
)
|
|
60
|
+
logSuccess(`${component} added successfully`)
|
|
77
61
|
}
|
|
78
62
|
|
|
79
|
-
|
|
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
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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.
|
|
4
|
-
"description": "NeonBlade UI CLI",
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
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
|
+
}
|