raqeb-cli 1.3.0 → 1.3.2
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 +19 -3
- package/lib/interactive.js +73 -35
- package/package.json +1 -1
package/bin/raqeb.js
CHANGED
|
@@ -325,11 +325,11 @@ Examples:
|
|
|
325
325
|
$ raqeb -i
|
|
326
326
|
$ raqeb shell
|
|
327
327
|
`)
|
|
328
|
-
.action(() => {
|
|
328
|
+
.action(async () => {
|
|
329
329
|
const InteractiveShell = require('../lib/interactive');
|
|
330
330
|
const client = getClient();
|
|
331
331
|
const shell = new InteractiveShell(client);
|
|
332
|
-
shell.start();
|
|
332
|
+
await shell.start();
|
|
333
333
|
});
|
|
334
334
|
|
|
335
335
|
// Completion command
|
|
@@ -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.2')
|
|
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
|
@@ -84,35 +84,51 @@ class InteractiveShell {
|
|
|
84
84
|
showWelcome() {
|
|
85
85
|
console.clear();
|
|
86
86
|
|
|
87
|
-
// ASCII Logo
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
██████╔╝███████║██║ ██║█████╗ ██████╔╝
|
|
92
|
-
██╔══██╗██╔══██║██║▄▄ ██║██╔══╝ ██╔══██╗
|
|
93
|
-
██║ ██║██║ ██║╚██████╔╝███████╗██████╔╝
|
|
94
|
-
╚═╝ ╚═╝╚═╝ ╚═╝ ╚══▀▀═╝ ╚══════╝╚═════╝
|
|
95
|
-
`));
|
|
87
|
+
// Raqeb ASCII Logo with brand colors
|
|
88
|
+
const blue = chalk.hex('#3B82F6');
|
|
89
|
+
const green = chalk.hex('#10B981');
|
|
90
|
+
const cyan = chalk.hex('#06B6D4');
|
|
96
91
|
|
|
97
|
-
console.log(
|
|
98
|
-
console.log(
|
|
99
|
-
console.log(
|
|
92
|
+
console.log('');
|
|
93
|
+
console.log(blue(' ●'));
|
|
94
|
+
console.log(blue(' ╱'));
|
|
95
|
+
console.log(blue(' ╱'));
|
|
96
|
+
console.log(blue(' ╭──○'));
|
|
97
|
+
console.log(blue(' ╱') + ' ' + green('╱ ╲'));
|
|
98
|
+
console.log(blue(' ╱') + ' ' + green('╱ ╲'));
|
|
99
|
+
console.log(blue(' ╱') + ' ' + green('╱') + cyan(' ● ') + green('╲'));
|
|
100
|
+
console.log(blue(' │') + ' ' + green('│') + cyan(' ╱ ╲ ') + green('│'));
|
|
101
|
+
console.log(blue(' │') + ' ' + chalk.bold.white('RAQEB') + ' ' + green('│') + cyan('│ │') + green('│'));
|
|
102
|
+
console.log(blue(' │') + ' ' + green('│') + cyan(' ╲ ╱ ') + green('│'));
|
|
103
|
+
console.log(blue(' ╲') + ' ' + green('╲') + cyan(' ● ') + green('╱'));
|
|
104
|
+
console.log(blue(' ╲') + ' ' + green('╲ ╱'));
|
|
105
|
+
console.log(blue(' ╲') + ' ' + green('╲ ╱'));
|
|
106
|
+
console.log(blue(' ╰──○'));
|
|
107
|
+
console.log(blue(' ╲'));
|
|
108
|
+
console.log(blue(' ╲'));
|
|
109
|
+
console.log(blue(' ●'));
|
|
110
|
+
console.log('');
|
|
100
111
|
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
// Header box with user info
|
|
113
|
+
const userEmail = this.userInfo?.email || 'Not logged in';
|
|
114
|
+
const tenantName = this.userInfo?.tenant_name || this.userInfo?.tenant_id || 'Unknown';
|
|
115
|
+
const userRole = this.userInfo?.role || 'user';
|
|
116
|
+
|
|
117
|
+
console.log(blue('╔════════════════════════════════════════════════════════════════════════════╗'));
|
|
118
|
+
console.log(blue('║') + chalk.bold.white(' 🌐 Raqeb CLI - Interactive Mode v1.3.2 ') + blue('║'));
|
|
119
|
+
console.log(blue('╠════════════════════════════════════════════════════════════════════════════╣'));
|
|
120
|
+
console.log(blue('║ ') + chalk.gray('User: ') + green(userEmail.padEnd(64)) + blue(' ║'));
|
|
121
|
+
console.log(blue('║ ') + chalk.gray('Tenant: ') + green(tenantName.padEnd(64)) + blue(' ║'));
|
|
122
|
+
console.log(blue('║ ') + chalk.gray('Role: ') + chalk.hex('#F59E0B')(userRole.padEnd(64)) + blue(' ║'));
|
|
123
|
+
console.log(blue('╚════════════════════════════════════════════════════════════════════════════╝'));
|
|
108
124
|
|
|
109
|
-
console.log(
|
|
125
|
+
console.log(green('\n💡 Type / to see all commands, or /help for help\n'));
|
|
110
126
|
}
|
|
111
127
|
|
|
112
128
|
async handleCommand(input) {
|
|
113
129
|
try {
|
|
114
130
|
if (input === '/') {
|
|
115
|
-
this.
|
|
131
|
+
await this.showCommandMenu();
|
|
116
132
|
} else if (input === '/help') {
|
|
117
133
|
this.showHelp();
|
|
118
134
|
} else if (input === '/exit' || input === '/quit') {
|
|
@@ -137,16 +153,40 @@ class InteractiveShell {
|
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
155
|
|
|
156
|
+
async showCommandMenu() {
|
|
157
|
+
const commands = [
|
|
158
|
+
{ name: chalk.cyan('/db ') + chalk.gray('Database operations'), value: '/db' },
|
|
159
|
+
{ name: chalk.cyan('/secrets ') + chalk.gray('Secrets management'), value: '/secrets' },
|
|
160
|
+
{ name: chalk.cyan('/keys ') + chalk.gray('API keys management'), value: '/keys' },
|
|
161
|
+
{ name: chalk.cyan('/audit ') + chalk.gray('Audit logs'), value: '/audit' },
|
|
162
|
+
{ name: chalk.cyan('/help ') + chalk.gray('Show help'), value: '/help' },
|
|
163
|
+
{ name: chalk.cyan('/clear ') + chalk.gray('Clear screen'), value: '/clear' },
|
|
164
|
+
{ name: chalk.cyan('/exit ') + chalk.gray('Exit interactive mode'), value: '/exit' }
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
const answer = await inquirer.prompt([{
|
|
168
|
+
type: 'list',
|
|
169
|
+
name: 'command',
|
|
170
|
+
message: chalk.bold('📋 Available Commands:'),
|
|
171
|
+
choices: commands,
|
|
172
|
+
pageSize: 10
|
|
173
|
+
}]);
|
|
174
|
+
|
|
175
|
+
if (answer.command) {
|
|
176
|
+
await this.handleCommand(answer.command);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
140
180
|
showAllCommands() {
|
|
141
181
|
console.log(chalk.bold('\n📋 Available Commands:\n'));
|
|
142
|
-
console.log(chalk.cyan(' /db') + '
|
|
143
|
-
console.log(chalk.cyan(' /secrets') + '
|
|
144
|
-
console.log(chalk.cyan(' /keys') + '
|
|
145
|
-
console.log(chalk.cyan(' /audit') + '
|
|
146
|
-
console.log(chalk.cyan(' /help') + '
|
|
147
|
-
console.log(chalk.cyan(' /clear') + '
|
|
148
|
-
console.log(chalk.cyan(' /exit') + '
|
|
149
|
-
console.log();
|
|
182
|
+
console.log(chalk.cyan(' /db ') + 'Database operations');
|
|
183
|
+
console.log(chalk.cyan(' /secrets ') + 'Secrets management');
|
|
184
|
+
console.log(chalk.cyan(' /keys ') + 'API keys management');
|
|
185
|
+
console.log(chalk.cyan(' /audit ') + 'Audit logs');
|
|
186
|
+
console.log(chalk.cyan(' /help ') + 'Show this help');
|
|
187
|
+
console.log(chalk.cyan(' /clear ') + 'Clear screen');
|
|
188
|
+
console.log(chalk.cyan(' /exit ') + 'Exit interactive mode');
|
|
189
|
+
console.log('');
|
|
150
190
|
}
|
|
151
191
|
|
|
152
192
|
showHelp() {
|
|
@@ -368,7 +408,7 @@ class InteractiveShell {
|
|
|
368
408
|
|
|
369
409
|
async listSecrets() {
|
|
370
410
|
try {
|
|
371
|
-
const response = await this.client.get('/
|
|
411
|
+
const response = await this.client.get('/secrets');
|
|
372
412
|
const secrets = response.data;
|
|
373
413
|
|
|
374
414
|
if (!secrets || secrets.length === 0) {
|
|
@@ -405,9 +445,7 @@ class InteractiveShell {
|
|
|
405
445
|
}
|
|
406
446
|
|
|
407
447
|
try {
|
|
408
|
-
const response = await this.client.
|
|
409
|
-
params: { secret_id: secretId }
|
|
410
|
-
});
|
|
448
|
+
const response = await this.client.get(`/secrets/${secretId}`);
|
|
411
449
|
const data = response.data;
|
|
412
450
|
|
|
413
451
|
console.log(chalk.cyan(`\n🔐 Secret: ${data.name}`));
|
|
@@ -442,7 +480,7 @@ class InteractiveShell {
|
|
|
442
480
|
}
|
|
443
481
|
]);
|
|
444
482
|
|
|
445
|
-
await this.client.post('/
|
|
483
|
+
await this.client.post('/secrets', {
|
|
446
484
|
name: answers.name,
|
|
447
485
|
value: answers.value,
|
|
448
486
|
description: answers.description || undefined
|
|
@@ -474,7 +512,7 @@ class InteractiveShell {
|
|
|
474
512
|
return;
|
|
475
513
|
}
|
|
476
514
|
|
|
477
|
-
await this.client.delete(`/
|
|
515
|
+
await this.client.delete(`/secrets/${secretName}`);
|
|
478
516
|
console.log(chalk.green(`\n✓ Secret '${secretName}' deleted successfully\n`));
|
|
479
517
|
} catch (error) {
|
|
480
518
|
throw new Error(error.response?.data?.detail || error.message);
|