neonblade 0.0.2 → 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 +42 -124
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,116 +3,71 @@
|
|
|
3
3
|
const fs = require("fs")
|
|
4
4
|
const path = require("path")
|
|
5
5
|
const axios = require("axios")
|
|
6
|
+
const { execSync } = require("child_process")
|
|
6
7
|
|
|
7
8
|
const BASE_URL = "https://neonbladeui-registry.vercel.app"
|
|
8
9
|
|
|
10
|
+
async function main() {
|
|
11
|
+
const projectRoot = process.cwd()
|
|
12
|
+
const targetAppPath = findAppPath(projectRoot)
|
|
9
13
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const args = process.argv.slice(2)
|
|
14
|
-
|
|
15
|
-
const command = args[0]
|
|
16
|
-
const component = args[1]
|
|
17
|
-
|
|
18
|
-
if (command !== "add") {
|
|
19
|
-
console.log("Usage: neonblade add <component>")
|
|
20
|
-
process.exit(1)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!component) {
|
|
24
|
-
console.log("Please provide a component name")
|
|
25
|
-
process.exit(1)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const componentDir = path.join(
|
|
29
|
-
__dirname,
|
|
30
|
-
"../registry/components",
|
|
31
|
-
component
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
//log if component is not found
|
|
35
|
-
if (!fs.existsSync(componentDir)) {
|
|
36
|
-
logError(`${component} not found`)
|
|
37
|
-
process.exit(1)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Read metadata
|
|
41
|
-
// const metaPath = path.join(componentDir, "meta.json")
|
|
42
|
-
|
|
43
|
-
// if (!fs.existsSync(metaPath)) {
|
|
44
|
-
// console.log("Component metadata not found")
|
|
45
|
-
// process.exit(1)
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
|
-
// const meta = JSON.parse(fs.readFileSync(metaPath, "utf-8"))
|
|
49
|
-
|
|
50
|
-
const data = await fetchComponent(component)
|
|
51
|
-
|
|
52
|
-
console.log("\n⚡ NeonBlade UI\n")
|
|
14
|
+
const args = process.argv.slice(2)
|
|
15
|
+
const command = args[0]
|
|
16
|
+
const component = args[1]
|
|
53
17
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
18
|
+
if (command !== "add") {
|
|
19
|
+
console.log("Usage: neonblade add <component>")
|
|
20
|
+
process.exit(1)
|
|
21
|
+
}
|
|
57
22
|
|
|
58
|
-
|
|
59
|
-
|
|
23
|
+
if (!component) {
|
|
24
|
+
console.log("Please provide a component name")
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
60
27
|
|
|
61
|
-
|
|
62
|
-
// targetAppPath,
|
|
63
|
-
// "components/ui",
|
|
64
|
-
// toKebabCase(file)
|
|
65
|
-
// )
|
|
28
|
+
console.log("\n⚡ NeonBlade UI\n")
|
|
66
29
|
|
|
67
|
-
|
|
68
|
-
// fs.copyFileSync(sourcePath, targetPath)
|
|
69
|
-
// })
|
|
30
|
+
logStep(`Adding ${component}...`)
|
|
70
31
|
|
|
71
|
-
|
|
72
|
-
const fileRes = await axios.get(file.url)
|
|
32
|
+
const data = await fetchComponent(component)
|
|
73
33
|
|
|
74
|
-
|
|
75
|
-
targetAppPath,
|
|
76
|
-
file.path
|
|
77
|
-
)
|
|
34
|
+
logStep("Copying files...")
|
|
78
35
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
36
|
+
for (const file of data.files) {
|
|
37
|
+
const fileRes = await axios.get(file.url)
|
|
82
38
|
|
|
83
|
-
const
|
|
39
|
+
const targetPath = path.join(
|
|
40
|
+
targetAppPath,
|
|
41
|
+
file.path
|
|
42
|
+
)
|
|
84
43
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
44
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true })
|
|
45
|
+
fs.writeFileSync(targetPath, fileRes.data)
|
|
46
|
+
}
|
|
88
47
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// { stdio: "inherit", cwd: targetAppPath }
|
|
92
|
-
// )
|
|
93
|
-
// }
|
|
48
|
+
if (data.dependencies && data.dependencies.length > 0) {
|
|
49
|
+
logStep("Installing dependencies...")
|
|
94
50
|
|
|
95
|
-
|
|
96
|
-
|
|
51
|
+
execSync(
|
|
52
|
+
`pnpm add ${data.dependencies.join(" ")}`,
|
|
53
|
+
{
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
cwd: targetAppPath,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
}
|
|
97
59
|
|
|
98
|
-
|
|
99
|
-
`pnpm add ${data.dependencies.join(" ")}`,
|
|
100
|
-
{
|
|
101
|
-
stdio: "inherit",
|
|
102
|
-
cwd: targetAppPath,
|
|
103
|
-
}
|
|
104
|
-
)
|
|
60
|
+
logSuccess(`${component} added successfully`)
|
|
105
61
|
}
|
|
106
62
|
|
|
107
|
-
|
|
63
|
+
main()
|
|
108
64
|
|
|
65
|
+
// ---------------- HELPERS ----------------
|
|
109
66
|
|
|
110
67
|
function findAppPath(root) {
|
|
111
68
|
const appsDir = path.join(root, "apps")
|
|
112
69
|
|
|
113
|
-
if (!fs.existsSync(appsDir))
|
|
114
|
-
return root
|
|
115
|
-
}
|
|
70
|
+
if (!fs.existsSync(appsDir)) return root
|
|
116
71
|
|
|
117
72
|
const apps = fs.readdirSync(appsDir)
|
|
118
73
|
|
|
@@ -132,10 +87,6 @@ function findAppPath(root) {
|
|
|
132
87
|
return root
|
|
133
88
|
}
|
|
134
89
|
|
|
135
|
-
function toKebabCase(str) {
|
|
136
|
-
return str.toLowerCase()
|
|
137
|
-
}
|
|
138
|
-
|
|
139
90
|
function logStep(message) {
|
|
140
91
|
console.log(`📦 ${message}`)
|
|
141
92
|
}
|
|
@@ -148,39 +99,6 @@ function logError(message) {
|
|
|
148
99
|
console.log(`❌ ${message}`)
|
|
149
100
|
}
|
|
150
101
|
|
|
151
|
-
function gradientLog(text) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
//yellow and blue gradient
|
|
155
|
-
const colors = [
|
|
156
|
-
"#ffff00",
|
|
157
|
-
"#00ffff",
|
|
158
|
-
"#0000ff",
|
|
159
|
-
"#0080ff",
|
|
160
|
-
"#00ff80",
|
|
161
|
-
"#00ff00",
|
|
162
|
-
"#80ff00",
|
|
163
|
-
"#ffbf00",
|
|
164
|
-
"#ff8000",
|
|
165
|
-
"#ff4000",
|
|
166
|
-
"#ff0000",
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
const args = [];
|
|
170
|
-
let format = '';
|
|
171
|
-
|
|
172
|
-
[...text].forEach((char, i) => {
|
|
173
|
-
const color = colors[i % colors.length];
|
|
174
|
-
format += `%c${char}`;
|
|
175
|
-
args.push(`color: ${color}; font-size: 16px; font-weight: bold;`);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
console.log(format, ...args);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
102
|
async function fetchComponent(component) {
|
|
185
103
|
try {
|
|
186
104
|
const res = await axios.get(
|