gladvn 0.2.26 → 0.2.29
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/bin/cli.js +46 -23
- package/package.json +1 -1
- package/src/styles/gladvn.css +0 -1
package/bin/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
|
16
16
|
console.log(`
|
|
17
17
|
Usage:
|
|
18
18
|
npx gladvn init [destination]
|
|
19
|
-
npx gladvn add <component> [destination]
|
|
19
|
+
npx gladvn add <component | --all> [destination]
|
|
20
20
|
npx gladvn add-block <block> [destination]
|
|
21
21
|
|
|
22
22
|
Options:
|
|
@@ -254,29 +254,52 @@ async function main() {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
if (command === "add") {
|
|
257
|
-
console.log(`\x1b[36mAdding ${componentToAdd} to ${userDest}...\x1b[0m`);
|
|
258
|
-
const compMatches = availableComponents.filter(c => c.endsWith(`/${componentToAdd}.tsx`) || c.endsWith(`/${componentToAdd}.ts`));
|
|
259
|
-
if (compMatches.length === 0) {
|
|
260
|
-
console.error(`\x1b[31m✖ Component "${componentToAdd}" not found.\x1b[0m`);
|
|
261
|
-
process.exit(1);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
257
|
if (!fs.existsSync(destPath)) {
|
|
265
258
|
fs.mkdirSync(destPath, { recursive: true });
|
|
266
259
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
260
|
+
|
|
261
|
+
if (componentToAdd === "--all") {
|
|
262
|
+
console.log(`\x1b[36mAdding all components to ${userDest}...\x1b[0m`);
|
|
263
|
+
let addedCount = 0;
|
|
264
|
+
for (const comp of availableComponents) {
|
|
265
|
+
const sourcePath = path.join(componentsDir, comp);
|
|
266
|
+
const targetPath = path.join(destPath, 'components', comp);
|
|
267
|
+
const targetDir = path.dirname(targetPath);
|
|
268
|
+
if (!fs.existsSync(targetDir)) {
|
|
269
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
fs.cpSync(sourcePath, targetPath, { force: true });
|
|
273
|
+
console.log(`\x1b[32m✔ Added ${comp}\x1b[0m`);
|
|
274
|
+
addedCount++;
|
|
275
|
+
} catch (err) {
|
|
276
|
+
console.error(`\x1b[31m✖ Failed to add ${comp}: ${err.message}\x1b[0m`);
|
|
277
|
+
hasErrors = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
console.log(`\x1b[32m✔ Successfully added ${addedCount} components!\x1b[0m`);
|
|
281
|
+
} else {
|
|
282
|
+
console.log(`\x1b[36mAdding ${componentToAdd} to ${userDest}...\x1b[0m`);
|
|
283
|
+
const compMatches = availableComponents.filter(c => c.endsWith(`/${componentToAdd}.tsx`) || c.endsWith(`/${componentToAdd}.ts`));
|
|
284
|
+
if (compMatches.length === 0) {
|
|
285
|
+
console.error(`\x1b[31m✖ Component "${componentToAdd}" not found.\x1b[0m`);
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const comp = compMatches[0];
|
|
290
|
+
const sourcePath = path.join(componentsDir, comp);
|
|
291
|
+
const targetPath = path.join(destPath, 'components', comp);
|
|
292
|
+
const targetDir = path.dirname(targetPath);
|
|
293
|
+
if (!fs.existsSync(targetDir)) {
|
|
294
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
295
|
+
}
|
|
296
|
+
try {
|
|
297
|
+
fs.cpSync(sourcePath, targetPath, { force: true });
|
|
298
|
+
console.log(`\x1b[32m✔ Added ${comp}\x1b[0m`);
|
|
299
|
+
} catch (err) {
|
|
300
|
+
console.error(`\x1b[31m✖ Failed to add ${comp}: ${err.message}\x1b[0m`);
|
|
301
|
+
hasErrors = true;
|
|
302
|
+
}
|
|
280
303
|
}
|
|
281
304
|
} else if (command === "add-block") {
|
|
282
305
|
console.log(`\x1b[36mAdding block ${componentToAdd} to ${userDest}...\x1b[0m`);
|
|
@@ -362,7 +385,7 @@ async function main() {
|
|
|
362
385
|
|
|
363
386
|
// Always copy core directories
|
|
364
387
|
|
|
365
|
-
const coreDirs = ['hooks', 'lib', 'styles'];
|
|
388
|
+
const coreDirs = ['hooks', 'lib', 'styles', 'components', 'blocks'];
|
|
366
389
|
for (const dir of coreDirs) {
|
|
367
390
|
const sourcePath = path.join(srcDir, dir);
|
|
368
391
|
const targetPath = path.join(destPath, dir);
|
|
@@ -375,7 +398,7 @@ async function main() {
|
|
|
375
398
|
}
|
|
376
399
|
}
|
|
377
400
|
}
|
|
378
|
-
console.log(`\x1b[32m✔ Copied core files (lib, hooks, styles)\x1b[0m`);
|
|
401
|
+
console.log(`\x1b[32m✔ Copied core files and all components (lib, hooks, styles, components, blocks)\x1b[0m`);
|
|
379
402
|
|
|
380
403
|
// 2. Inject CSS
|
|
381
404
|
if (cssFilePath && fs.existsSync(cssFilePath)) {
|
package/package.json
CHANGED
package/src/styles/gladvn.css
CHANGED