purvex-ui 1.0.0 → 1.0.1
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/package.json +1 -1
- package/src/index.js +40 -31
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
const { Command } = require('commander');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const boxen = require('boxen');
|
|
6
|
+
const { readFileSync } = require('fs');
|
|
7
|
+
const { join } = require('path');
|
|
8
|
+
|
|
9
|
+
// Baca versi dari package.json
|
|
10
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
11
|
+
const VERSION = packageJson.version;
|
|
6
12
|
|
|
7
13
|
// Banner
|
|
8
|
-
const banner = boxen
|
|
9
|
-
chalk.green.bold(
|
|
10
|
-
chalk.white(' - React Component Generator
|
|
14
|
+
const banner = boxen(
|
|
15
|
+
chalk.green.bold(\`✨ Purvex UI v\${VERSION}\`) +
|
|
16
|
+
chalk.white(' - React Component Generator\\n') +
|
|
11
17
|
chalk.gray('Fast, customizable UI components for React + Tailwind'),
|
|
12
18
|
{
|
|
13
19
|
padding: 1,
|
|
@@ -25,7 +31,7 @@ const program = new Command();
|
|
|
25
31
|
program
|
|
26
32
|
.name('purvex-ui')
|
|
27
33
|
.description('CLI untuk Purvex UI - Generator komponen React dengan Tailwind CSS')
|
|
28
|
-
.version(
|
|
34
|
+
.version(VERSION);
|
|
29
35
|
|
|
30
36
|
// Command: init
|
|
31
37
|
program
|
|
@@ -55,28 +61,49 @@ program
|
|
|
55
61
|
const path = require('path');
|
|
56
62
|
|
|
57
63
|
try {
|
|
58
|
-
|
|
64
|
+
// Coba beberapa path untuk registry
|
|
65
|
+
const possiblePaths = [
|
|
66
|
+
path.join(__dirname, '..', 'registry', 'components.json'),
|
|
67
|
+
path.join(__dirname, 'registry', 'components.json'),
|
|
68
|
+
path.join(process.cwd(), 'node_modules', 'purvex-ui', 'registry', 'components.json')
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
let registryPath = null;
|
|
72
|
+
for (const p of possiblePaths) {
|
|
73
|
+
if (fs.existsSync(p)) {
|
|
74
|
+
registryPath = p;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
59
78
|
|
|
60
|
-
if (!
|
|
79
|
+
if (!registryPath) {
|
|
61
80
|
console.log(chalk.red('❌ Registry tidak ditemukan'));
|
|
81
|
+
console.log(chalk.yellow('\\nKomponen yang tersedia:'));
|
|
82
|
+
console.log(chalk.cyan(' • button'));
|
|
83
|
+
console.log(chalk.cyan(' • card'));
|
|
84
|
+
console.log(chalk.cyan(' • avatar'));
|
|
62
85
|
return;
|
|
63
86
|
}
|
|
64
87
|
|
|
65
88
|
const registryContent = fs.readFileSync(registryPath, 'utf-8');
|
|
66
89
|
const registry = JSON.parse(registryContent);
|
|
67
90
|
|
|
68
|
-
console.log(chalk.blue.bold('
|
|
91
|
+
console.log(chalk.blue.bold('\\n📦 Komponen yang tersedia:\\n'));
|
|
69
92
|
registry.components.forEach(comp => {
|
|
70
|
-
console.log(chalk.cyan(
|
|
93
|
+
console.log(chalk.cyan(\` • \${comp.name}\`));
|
|
71
94
|
});
|
|
72
|
-
console.log(chalk.gray(
|
|
95
|
+
console.log(chalk.gray(\`\\nTotal: \${registry.components.length} komponen\`));
|
|
73
96
|
|
|
74
97
|
} catch (error) {
|
|
75
98
|
console.error(chalk.red('❌ Error:'), error.message);
|
|
99
|
+
// Fallback
|
|
100
|
+
console.log(chalk.blue.bold('\\n📦 Komponen (fallback):\\n'));
|
|
101
|
+
console.log(chalk.cyan(' • button'));
|
|
102
|
+
console.log(chalk.cyan(' • card'));
|
|
103
|
+
console.log(chalk.cyan(' • avatar'));
|
|
76
104
|
}
|
|
77
105
|
});
|
|
78
106
|
|
|
79
|
-
|
|
80
107
|
// Command: setup
|
|
81
108
|
program
|
|
82
109
|
.command('setup')
|
|
@@ -86,25 +113,7 @@ program
|
|
|
86
113
|
await setupProject();
|
|
87
114
|
});
|
|
88
115
|
|
|
89
|
-
// Command:
|
|
90
|
-
program
|
|
91
|
-
.command('fix')
|
|
92
|
-
.description('Fix Purvex UI configuration (path alias, colors, etc)')
|
|
93
|
-
.action(async () => {
|
|
94
|
-
const { fixProject } = require('./commands/fix');
|
|
95
|
-
await fixProject();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// Command: update-colors
|
|
99
|
-
// program
|
|
100
|
-
// .command('update-colors')
|
|
101
|
-
// .description('Update color palette to Purple Elegant theme')
|
|
102
|
-
// .action(async () => {
|
|
103
|
-
// const { updateColors } = require('./commands/update-colors');
|
|
104
|
-
// await updateColors();
|
|
105
|
-
// });
|
|
106
|
-
|
|
107
|
-
// Command: install
|
|
116
|
+
// Command: install
|
|
108
117
|
program
|
|
109
118
|
.command('install')
|
|
110
119
|
.description('Install all required dependencies automatically')
|
|
@@ -113,7 +122,7 @@ program
|
|
|
113
122
|
await installDeps();
|
|
114
123
|
});
|
|
115
124
|
|
|
116
|
-
|
|
125
|
+
// Command: uninstall
|
|
117
126
|
program
|
|
118
127
|
.command('uninstall')
|
|
119
128
|
.description('Remove Purvex UI from your project')
|
|
@@ -123,4 +132,4 @@ program
|
|
|
123
132
|
});
|
|
124
133
|
|
|
125
134
|
// Parse arguments
|
|
126
|
-
program.parse();
|
|
135
|
+
program.parse();
|