raqeb-cli 1.3.1 → 1.3.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/bin/raqeb.js +17 -1
- package/lib/interactive.js +85 -19
- package/package.json +1 -1
package/bin/raqeb.js
CHANGED
|
@@ -360,6 +360,22 @@ Installation:
|
|
|
360
360
|
program
|
|
361
361
|
.name('raqeb')
|
|
362
362
|
.description('Raqeb CLI - Database PAM and Secrets Management')
|
|
363
|
-
.version('1.
|
|
363
|
+
.version('1.3.3')
|
|
364
|
+
.option('-i, --interactive', 'Launch interactive mode')
|
|
365
|
+
.hook('preAction', async (thisCommand, actionCommand) => {
|
|
366
|
+
// Handle -i flag
|
|
367
|
+
if (thisCommand.opts().interactive) {
|
|
368
|
+
const InteractiveShell = require('../lib/interactive');
|
|
369
|
+
const client = getClient();
|
|
370
|
+
const shell = new InteractiveShell(client);
|
|
371
|
+
await shell.start();
|
|
372
|
+
process.exit(0);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
364
375
|
|
|
365
376
|
program.parse();
|
|
377
|
+
|
|
378
|
+
// If no command specified and no -i flag, show help
|
|
379
|
+
if (!process.argv.slice(2).length) {
|
|
380
|
+
program.outputHelp();
|
|
381
|
+
}
|
package/lib/interactive.js
CHANGED
|
@@ -31,8 +31,15 @@ class InteractiveShell {
|
|
|
31
31
|
try {
|
|
32
32
|
const response = await this.client.get('/auth/me');
|
|
33
33
|
this.userInfo = response.data;
|
|
34
|
+
console.log('User info loaded:', this.userInfo); // Debug
|
|
34
35
|
} catch (error) {
|
|
35
|
-
|
|
36
|
+
console.error('Failed to load user info:', error.message); // Debug
|
|
37
|
+
this.userInfo = {
|
|
38
|
+
email: 'Not logged in',
|
|
39
|
+
tenant_name: 'Unknown',
|
|
40
|
+
tenant_id: 'Unknown',
|
|
41
|
+
role: 'user'
|
|
42
|
+
};
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -84,26 +91,47 @@ class InteractiveShell {
|
|
|
84
91
|
showWelcome() {
|
|
85
92
|
console.clear();
|
|
86
93
|
|
|
87
|
-
//
|
|
94
|
+
// Raqeb ASCII Logo - Custom design from user
|
|
95
|
+
const blue = chalk.hex('#0066cc');
|
|
96
|
+
const green = chalk.hex('#00aa80');
|
|
97
|
+
const cyan = chalk.hex('#00ccaa');
|
|
98
|
+
|
|
99
|
+
console.log('');
|
|
100
|
+
console.log(' ' + blue('●'));
|
|
101
|
+
console.log(' ' + blue('╱'));
|
|
102
|
+
console.log(' ' + blue('╭──○'));
|
|
103
|
+
console.log(' ' + blue('╱') + ' ' + green('╱ ╲'));
|
|
104
|
+
console.log(' ' + blue('╱') + ' ' + green('╱') + cyan(' ● ') + green('╲'));
|
|
105
|
+
console.log(' ' + blue('│') + ' ' + green('│') + cyan('╱ ╲') + green('│'));
|
|
106
|
+
console.log(' ' + blue('│') + ' ' + chalk.bold.white('RAQEB') + green('│') + cyan(' ● ') + green('│'));
|
|
107
|
+
console.log(' ' + blue('│') + ' ' + green('│') + cyan('╲ ╱') + green('│'));
|
|
108
|
+
console.log(' ' + blue('╲') + ' ' + green('╲') + cyan(' ● ') + green('╱'));
|
|
109
|
+
console.log(' ' + blue('╲') + ' ' + green('╲ ╱'));
|
|
110
|
+
console.log(' ' + blue('╰──○'));
|
|
111
|
+
console.log(' ' + blue('╲'));
|
|
112
|
+
console.log(' ' + blue('●'));
|
|
113
|
+
console.log('');
|
|
114
|
+
|
|
115
|
+
// Header box with user info
|
|
88
116
|
const userEmail = this.userInfo?.email || 'Not logged in';
|
|
89
117
|
const tenantName = this.userInfo?.tenant_name || this.userInfo?.tenant_id || 'Unknown';
|
|
90
118
|
const userRole = this.userInfo?.role || 'user';
|
|
91
119
|
|
|
92
|
-
console.log(
|
|
93
|
-
console.log(
|
|
94
|
-
console.log(
|
|
95
|
-
console.log(
|
|
96
|
-
console.log(
|
|
97
|
-
console.log(
|
|
98
|
-
console.log(
|
|
120
|
+
console.log(blue('╔════════════════════════════════════════════════════════════════════════════╗'));
|
|
121
|
+
console.log(blue('║') + chalk.bold.white(' 🌐 Raqeb CLI - Interactive Mode v1.3.3 ') + blue('║'));
|
|
122
|
+
console.log(blue('╠════════════════════════════════════════════════════════════════════════════╣'));
|
|
123
|
+
console.log(blue('║ ') + chalk.gray('User: ') + green(userEmail.padEnd(64)) + blue(' ║'));
|
|
124
|
+
console.log(blue('║ ') + chalk.gray('Tenant: ') + green(tenantName.padEnd(64)) + blue(' ║'));
|
|
125
|
+
console.log(blue('║ ') + chalk.gray('Role: ') + chalk.hex('#F59E0B')(userRole.padEnd(64)) + blue(' ║'));
|
|
126
|
+
console.log(blue('╚════════════════════════════════════════════════════════════════════════════╝'));
|
|
99
127
|
|
|
100
|
-
console.log(
|
|
128
|
+
console.log(green('\n💡 Type / to see all commands, or /help for help\n'));
|
|
101
129
|
}
|
|
102
130
|
|
|
103
131
|
async handleCommand(input) {
|
|
104
132
|
try {
|
|
105
133
|
if (input === '/') {
|
|
106
|
-
this.
|
|
134
|
+
await this.showCommandMenu();
|
|
107
135
|
} else if (input === '/help') {
|
|
108
136
|
this.showHelp();
|
|
109
137
|
} else if (input === '/exit' || input === '/quit') {
|
|
@@ -128,16 +156,54 @@ class InteractiveShell {
|
|
|
128
156
|
}
|
|
129
157
|
}
|
|
130
158
|
|
|
159
|
+
async showCommandMenu() {
|
|
160
|
+
const commands = [
|
|
161
|
+
{ name: chalk.cyan('/db ') + chalk.gray('Database operations'), value: '/db' },
|
|
162
|
+
{ name: chalk.cyan('/secrets ') + chalk.gray('Secrets management'), value: '/secrets' },
|
|
163
|
+
{ name: chalk.cyan('/keys ') + chalk.gray('API keys management'), value: '/keys' },
|
|
164
|
+
{ name: chalk.cyan('/audit ') + chalk.gray('Audit logs'), value: '/audit' },
|
|
165
|
+
{ name: chalk.cyan('/help ') + chalk.gray('Show help'), value: '/help' },
|
|
166
|
+
{ name: chalk.cyan('/clear ') + chalk.gray('Clear screen'), value: '/clear' },
|
|
167
|
+
{ name: chalk.cyan('/exit ') + chalk.gray('Exit interactive mode'), value: '/exit' }
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
const answer = await inquirer.prompt([{
|
|
171
|
+
type: 'list',
|
|
172
|
+
name: 'command',
|
|
173
|
+
message: chalk.bold('📋 Available Commands:'),
|
|
174
|
+
choices: commands,
|
|
175
|
+
pageSize: 10
|
|
176
|
+
}]);
|
|
177
|
+
|
|
178
|
+
// Just show the submenu, don't execute
|
|
179
|
+
if (answer.command === '/db') {
|
|
180
|
+
this.showDatabaseCommands();
|
|
181
|
+
} else if (answer.command === '/secrets') {
|
|
182
|
+
this.showSecretsCommands();
|
|
183
|
+
} else if (answer.command === '/keys') {
|
|
184
|
+
this.showKeysCommands();
|
|
185
|
+
} else if (answer.command === '/audit') {
|
|
186
|
+
this.showAuditCommands();
|
|
187
|
+
} else if (answer.command === '/help') {
|
|
188
|
+
this.showHelp();
|
|
189
|
+
} else if (answer.command === '/clear') {
|
|
190
|
+
console.clear();
|
|
191
|
+
this.showWelcome();
|
|
192
|
+
} else if (answer.command === '/exit') {
|
|
193
|
+
this.rl.close();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
131
197
|
showAllCommands() {
|
|
132
198
|
console.log(chalk.bold('\n📋 Available Commands:\n'));
|
|
133
|
-
console.log(chalk.cyan(' /db') + '
|
|
134
|
-
console.log(chalk.cyan(' /secrets') + '
|
|
135
|
-
console.log(chalk.cyan(' /keys') + '
|
|
136
|
-
console.log(chalk.cyan(' /audit') + '
|
|
137
|
-
console.log(chalk.cyan(' /help') + '
|
|
138
|
-
console.log(chalk.cyan(' /clear') + '
|
|
139
|
-
console.log(chalk.cyan(' /exit') + '
|
|
140
|
-
console.log();
|
|
199
|
+
console.log(chalk.cyan(' /db ') + 'Database operations');
|
|
200
|
+
console.log(chalk.cyan(' /secrets ') + 'Secrets management');
|
|
201
|
+
console.log(chalk.cyan(' /keys ') + 'API keys management');
|
|
202
|
+
console.log(chalk.cyan(' /audit ') + 'Audit logs');
|
|
203
|
+
console.log(chalk.cyan(' /help ') + 'Show this help');
|
|
204
|
+
console.log(chalk.cyan(' /clear ') + 'Clear screen');
|
|
205
|
+
console.log(chalk.cyan(' /exit ') + 'Exit interactive mode');
|
|
206
|
+
console.log('');
|
|
141
207
|
}
|
|
142
208
|
|
|
143
209
|
showHelp() {
|