@riventa/cli 1.1.1 → 1.2.0
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/dist/chunk-BMS2NG3R.js +1282 -0
- package/dist/index.js +363 -23
- package/dist/repl-OYJ3XUWI.js +134 -0
- package/dist/repl.d.ts +3 -0
- package/dist/repl.js +1351 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import ora from "ora";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __esm = (fn, res) => function __init() {
|
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
};
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
12
11
|
|
|
13
12
|
// src/utils/api.ts
|
|
14
13
|
import Conf from "conf";
|
|
15
14
|
import chalk from "chalk";
|
|
16
|
-
var config = new Conf({ projectName: "riventa-cli" });
|
|
17
15
|
function getApiKey() {
|
|
18
16
|
return config.get("apiKey");
|
|
19
17
|
}
|
|
@@ -69,8 +67,41 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
69
67
|
}
|
|
70
68
|
return response.json();
|
|
71
69
|
}
|
|
70
|
+
var config;
|
|
71
|
+
var init_api = __esm({
|
|
72
|
+
"src/utils/api.ts"() {
|
|
73
|
+
"use strict";
|
|
74
|
+
config = new Conf({ projectName: "riventa-cli" });
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// src/utils/browser.ts
|
|
79
|
+
import open from "open";
|
|
80
|
+
import { exec } from "child_process";
|
|
81
|
+
import { readFileSync, existsSync } from "fs";
|
|
82
|
+
function openUrl(url) {
|
|
83
|
+
const isWSL = existsSync("/proc/version") && readFileSync("/proc/version", "utf-8").toLowerCase().includes("microsoft");
|
|
84
|
+
if (isWSL) {
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
exec(`cmd.exe /c start "" "${url.replace(/&/g, "^&")}"`, (err) => {
|
|
87
|
+
if (err) reject(err);
|
|
88
|
+
else resolve();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return open(url).then(() => {
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
var init_browser = __esm({
|
|
96
|
+
"src/utils/browser.ts"() {
|
|
97
|
+
"use strict";
|
|
98
|
+
}
|
|
99
|
+
});
|
|
72
100
|
|
|
73
101
|
// src/commands/login.ts
|
|
102
|
+
import chalk2 from "chalk";
|
|
103
|
+
import inquirer from "inquirer";
|
|
104
|
+
import ora from "ora";
|
|
74
105
|
async function loginCommand() {
|
|
75
106
|
const existingKey = getApiKey();
|
|
76
107
|
if (existingKey) {
|
|
@@ -137,7 +168,7 @@ async function deviceFlowLogin() {
|
|
|
137
168
|
console.log(chalk2.gray(` Opening ${verificationUrl}`));
|
|
138
169
|
console.log(chalk2.gray(" Enter the code above to authorize this device.\n"));
|
|
139
170
|
try {
|
|
140
|
-
await
|
|
171
|
+
await openUrl(verificationUrl);
|
|
141
172
|
} catch {
|
|
142
173
|
console.log(chalk2.yellow(` Could not open browser automatically.`));
|
|
143
174
|
console.log(chalk2.yellow(` Please visit: ${chalk2.white(verificationUrl)}
|
|
@@ -241,6 +272,13 @@ async function verifyAndSaveKey(apiKey) {
|
|
|
241
272
|
function sleep(ms) {
|
|
242
273
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
243
274
|
}
|
|
275
|
+
var init_login = __esm({
|
|
276
|
+
"src/commands/login.ts"() {
|
|
277
|
+
"use strict";
|
|
278
|
+
init_api();
|
|
279
|
+
init_browser();
|
|
280
|
+
}
|
|
281
|
+
});
|
|
244
282
|
|
|
245
283
|
// src/commands/init.ts
|
|
246
284
|
import chalk3 from "chalk";
|
|
@@ -249,7 +287,6 @@ import fs from "fs";
|
|
|
249
287
|
import path from "path";
|
|
250
288
|
import Conf2 from "conf";
|
|
251
289
|
import ora2 from "ora";
|
|
252
|
-
var config2 = new Conf2({ projectName: "riventa-cli" });
|
|
253
290
|
function analyzeLocalProject() {
|
|
254
291
|
const analysis = {
|
|
255
292
|
name: path.basename(process.cwd())
|
|
@@ -486,6 +523,14 @@ async function createNewProject() {
|
|
|
486
523
|
spinner.succeed(`Created project: ${project.name}`);
|
|
487
524
|
return project.id;
|
|
488
525
|
}
|
|
526
|
+
var config2;
|
|
527
|
+
var init_init = __esm({
|
|
528
|
+
"src/commands/init.ts"() {
|
|
529
|
+
"use strict";
|
|
530
|
+
init_api();
|
|
531
|
+
config2 = new Conf2({ projectName: "riventa-cli" });
|
|
532
|
+
}
|
|
533
|
+
});
|
|
489
534
|
|
|
490
535
|
// src/commands/deploy.ts
|
|
491
536
|
import chalk4 from "chalk";
|
|
@@ -528,6 +573,12 @@ async function deployCommand(options) {
|
|
|
528
573
|
process.exit(1);
|
|
529
574
|
}
|
|
530
575
|
}
|
|
576
|
+
var init_deploy = __esm({
|
|
577
|
+
"src/commands/deploy.ts"() {
|
|
578
|
+
"use strict";
|
|
579
|
+
init_api();
|
|
580
|
+
}
|
|
581
|
+
});
|
|
531
582
|
|
|
532
583
|
// src/commands/review.ts
|
|
533
584
|
import chalk5 from "chalk";
|
|
@@ -624,6 +675,12 @@ function getScoreEmoji(score) {
|
|
|
624
675
|
if (score >= 50) return "\u{1F7E0}";
|
|
625
676
|
return "\u{1F534}";
|
|
626
677
|
}
|
|
678
|
+
var init_review = __esm({
|
|
679
|
+
"src/commands/review.ts"() {
|
|
680
|
+
"use strict";
|
|
681
|
+
init_api();
|
|
682
|
+
}
|
|
683
|
+
});
|
|
627
684
|
|
|
628
685
|
// src/commands/status.ts
|
|
629
686
|
import chalk6 from "chalk";
|
|
@@ -699,6 +756,12 @@ function getStatusIcon(status) {
|
|
|
699
756
|
return "\u{1F535}";
|
|
700
757
|
}
|
|
701
758
|
}
|
|
759
|
+
var init_status = __esm({
|
|
760
|
+
"src/commands/status.ts"() {
|
|
761
|
+
"use strict";
|
|
762
|
+
init_api();
|
|
763
|
+
}
|
|
764
|
+
});
|
|
702
765
|
|
|
703
766
|
// src/commands/logs.ts
|
|
704
767
|
import chalk7 from "chalk";
|
|
@@ -784,6 +847,12 @@ async function followLogs(deploymentId) {
|
|
|
784
847
|
};
|
|
785
848
|
await poll();
|
|
786
849
|
}
|
|
850
|
+
var init_logs = __esm({
|
|
851
|
+
"src/commands/logs.ts"() {
|
|
852
|
+
"use strict";
|
|
853
|
+
init_api();
|
|
854
|
+
}
|
|
855
|
+
});
|
|
787
856
|
|
|
788
857
|
// src/commands/rollback.ts
|
|
789
858
|
import chalk8 from "chalk";
|
|
@@ -869,6 +938,12 @@ async function rollbackCommand(options) {
|
|
|
869
938
|
process.exit(1);
|
|
870
939
|
}
|
|
871
940
|
}
|
|
941
|
+
var init_rollback = __esm({
|
|
942
|
+
"src/commands/rollback.ts"() {
|
|
943
|
+
"use strict";
|
|
944
|
+
init_api();
|
|
945
|
+
}
|
|
946
|
+
});
|
|
872
947
|
|
|
873
948
|
// src/commands/config.ts
|
|
874
949
|
import chalk9 from "chalk";
|
|
@@ -1009,6 +1084,12 @@ function formatValue(value) {
|
|
|
1009
1084
|
}
|
|
1010
1085
|
return String(value);
|
|
1011
1086
|
}
|
|
1087
|
+
var init_config = __esm({
|
|
1088
|
+
"src/commands/config.ts"() {
|
|
1089
|
+
"use strict";
|
|
1090
|
+
init_api();
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1012
1093
|
|
|
1013
1094
|
// src/commands/projects.ts
|
|
1014
1095
|
import chalk10 from "chalk";
|
|
@@ -1077,6 +1158,12 @@ async function projectsCommand() {
|
|
|
1077
1158
|
process.exit(1);
|
|
1078
1159
|
}
|
|
1079
1160
|
}
|
|
1161
|
+
var init_projects = __esm({
|
|
1162
|
+
"src/commands/projects.ts"() {
|
|
1163
|
+
"use strict";
|
|
1164
|
+
init_api();
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1080
1167
|
|
|
1081
1168
|
// src/commands/whoami.ts
|
|
1082
1169
|
import chalk11 from "chalk";
|
|
@@ -1107,6 +1194,12 @@ async function whoamiCommand() {
|
|
|
1107
1194
|
`));
|
|
1108
1195
|
}
|
|
1109
1196
|
}
|
|
1197
|
+
var init_whoami = __esm({
|
|
1198
|
+
"src/commands/whoami.ts"() {
|
|
1199
|
+
"use strict";
|
|
1200
|
+
init_api();
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1110
1203
|
|
|
1111
1204
|
// src/commands/security.ts
|
|
1112
1205
|
import chalk12 from "chalk";
|
|
@@ -1204,6 +1297,12 @@ function getSeverityIcon(severity) {
|
|
|
1204
1297
|
return chalk12.gray("INFO");
|
|
1205
1298
|
}
|
|
1206
1299
|
}
|
|
1300
|
+
var init_security = __esm({
|
|
1301
|
+
"src/commands/security.ts"() {
|
|
1302
|
+
"use strict";
|
|
1303
|
+
init_api();
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1207
1306
|
|
|
1208
1307
|
// src/commands/health.ts
|
|
1209
1308
|
import chalk13 from "chalk";
|
|
@@ -1232,25 +1331,259 @@ async function healthCommand() {
|
|
|
1232
1331
|
`));
|
|
1233
1332
|
}
|
|
1234
1333
|
}
|
|
1334
|
+
var init_health = __esm({
|
|
1335
|
+
"src/commands/health.ts"() {
|
|
1336
|
+
"use strict";
|
|
1337
|
+
init_api();
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
|
|
1341
|
+
// src/commands/dashboard.ts
|
|
1342
|
+
import chalk14 from "chalk";
|
|
1343
|
+
async function dashboardCommand(options) {
|
|
1344
|
+
const page = options.page || "home";
|
|
1345
|
+
const path3 = pages[page];
|
|
1346
|
+
if (!path3) {
|
|
1347
|
+
console.log(chalk14.red(`
|
|
1348
|
+
Unknown page: ${page}`));
|
|
1349
|
+
console.log(chalk14.gray(" Available pages: ") + chalk14.white(Object.keys(pages).join(", ")));
|
|
1350
|
+
console.log();
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
const url = `${BASE}${path3}`;
|
|
1354
|
+
console.log(chalk14.gray(`
|
|
1355
|
+
Opening ${url}
|
|
1356
|
+
`));
|
|
1357
|
+
try {
|
|
1358
|
+
await openUrl(url);
|
|
1359
|
+
} catch {
|
|
1360
|
+
console.log(chalk14.yellow(` Could not open browser. Visit: ${chalk14.white(url)}
|
|
1361
|
+
`));
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
var BASE, pages;
|
|
1365
|
+
var init_dashboard = __esm({
|
|
1366
|
+
"src/commands/dashboard.ts"() {
|
|
1367
|
+
"use strict";
|
|
1368
|
+
init_browser();
|
|
1369
|
+
BASE = "https://app.riventa.dev";
|
|
1370
|
+
pages = {
|
|
1371
|
+
home: "/dashboard",
|
|
1372
|
+
reviews: "/ci-cd?tab=reviews",
|
|
1373
|
+
deployments: "/deployments",
|
|
1374
|
+
analytics: "/analytics",
|
|
1375
|
+
security: "/code-quality?tab=security",
|
|
1376
|
+
settings: "/settings",
|
|
1377
|
+
"api-keys": "/settings?tab=api-keys",
|
|
1378
|
+
flags: "/flags",
|
|
1379
|
+
monitoring: "/monitoring"
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
// src/banner.ts
|
|
1385
|
+
import chalk15 from "chalk";
|
|
1386
|
+
function printBanner(version, email) {
|
|
1387
|
+
console.log();
|
|
1388
|
+
console.log(
|
|
1389
|
+
chalk15.bold.white("RIVENTA") + chalk15.bold.hex("#2563EB")(".DEV")
|
|
1390
|
+
);
|
|
1391
|
+
console.log(
|
|
1392
|
+
chalk15.gray(`Riventa CLI v${version} \xB7 AI-powered DevOps`)
|
|
1393
|
+
);
|
|
1394
|
+
if (email) {
|
|
1395
|
+
console.log(chalk15.gray(`Logged in as `) + chalk15.white(email));
|
|
1396
|
+
}
|
|
1397
|
+
console.log();
|
|
1398
|
+
}
|
|
1399
|
+
var init_banner = __esm({
|
|
1400
|
+
"src/banner.ts"() {
|
|
1401
|
+
"use strict";
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
// src/repl.ts
|
|
1406
|
+
var repl_exports = {};
|
|
1407
|
+
__export(repl_exports, {
|
|
1408
|
+
startRepl: () => startRepl
|
|
1409
|
+
});
|
|
1410
|
+
import { createInterface } from "readline";
|
|
1411
|
+
import chalk16 from "chalk";
|
|
1412
|
+
function showHelp() {
|
|
1413
|
+
console.log();
|
|
1414
|
+
console.log(chalk16.bold(" Available commands:"));
|
|
1415
|
+
console.log();
|
|
1416
|
+
const maxLen = Math.max(...Object.keys(commands).map((k) => k.length));
|
|
1417
|
+
for (const [name, cmd] of Object.entries(commands)) {
|
|
1418
|
+
console.log(chalk16.cyan(` ${name.padEnd(maxLen + 2)}`) + chalk16.gray(cmd.description));
|
|
1419
|
+
}
|
|
1420
|
+
console.log();
|
|
1421
|
+
console.log(chalk16.gray(" help") + chalk16.gray("".padEnd(maxLen - 2)) + chalk16.gray("Show this help"));
|
|
1422
|
+
console.log(chalk16.gray(" clear") + chalk16.gray("".padEnd(maxLen - 3)) + chalk16.gray("Clear the screen"));
|
|
1423
|
+
console.log(chalk16.gray(" exit") + chalk16.gray("".padEnd(maxLen - 2)) + chalk16.gray("Exit the CLI"));
|
|
1424
|
+
console.log();
|
|
1425
|
+
}
|
|
1426
|
+
async function startRepl() {
|
|
1427
|
+
const user = getConfig("user");
|
|
1428
|
+
printBanner(VERSION, user?.email);
|
|
1429
|
+
const cwd = process.cwd().split("/").pop() || "~";
|
|
1430
|
+
const rl = createInterface({
|
|
1431
|
+
input: process.stdin,
|
|
1432
|
+
output: process.stdout,
|
|
1433
|
+
prompt: chalk16.hex("#2563EB")("riventa") + chalk16.gray(`:${cwd}`) + chalk16.white("> "),
|
|
1434
|
+
completer: (line) => {
|
|
1435
|
+
const completions = [...Object.keys(commands), "help", "clear", "exit"];
|
|
1436
|
+
const hits = completions.filter((c) => c.startsWith(line.trim()));
|
|
1437
|
+
return [hits.length ? hits : completions, line];
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
rl.prompt();
|
|
1441
|
+
rl.on("line", async (line) => {
|
|
1442
|
+
const input = line.trim();
|
|
1443
|
+
const [cmd, ...args2] = input.split(/\s+/);
|
|
1444
|
+
if (!cmd) {
|
|
1445
|
+
rl.prompt();
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
if (cmd === "exit" || cmd === "quit") {
|
|
1449
|
+
console.log(chalk16.gray("\n Goodbye!\n"));
|
|
1450
|
+
process.exit(0);
|
|
1451
|
+
}
|
|
1452
|
+
if (cmd === "help") {
|
|
1453
|
+
showHelp();
|
|
1454
|
+
rl.prompt();
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
if (cmd === "clear") {
|
|
1458
|
+
console.clear();
|
|
1459
|
+
const u = getConfig("user");
|
|
1460
|
+
printBanner(VERSION, u?.email);
|
|
1461
|
+
rl.prompt();
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
if (cmd === "version") {
|
|
1465
|
+
console.log(chalk16.gray(`
|
|
1466
|
+
v${VERSION}
|
|
1467
|
+
`));
|
|
1468
|
+
rl.prompt();
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
const command = commands[cmd];
|
|
1472
|
+
if (!command) {
|
|
1473
|
+
console.log(chalk16.red(`
|
|
1474
|
+
Unknown command: ${cmd}`));
|
|
1475
|
+
console.log(chalk16.gray(" Type ") + chalk16.cyan("help") + chalk16.gray(" to see available commands.\n"));
|
|
1476
|
+
rl.prompt();
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
try {
|
|
1480
|
+
const originalExit = process.exit;
|
|
1481
|
+
process.exit = (() => {
|
|
1482
|
+
throw new Error("__REPL_EXIT__");
|
|
1483
|
+
});
|
|
1484
|
+
await command.action({ ...Object.fromEntries(args2.map((a, i) => [i, a])) });
|
|
1485
|
+
process.exit = originalExit;
|
|
1486
|
+
} catch (err) {
|
|
1487
|
+
if (err?.message !== "__REPL_EXIT__") {
|
|
1488
|
+
console.log(chalk16.red(`
|
|
1489
|
+
Error: ${err.message}
|
|
1490
|
+
`));
|
|
1491
|
+
}
|
|
1492
|
+
process.exit = (await import("process")).exit;
|
|
1493
|
+
}
|
|
1494
|
+
console.log();
|
|
1495
|
+
rl.prompt();
|
|
1496
|
+
});
|
|
1497
|
+
rl.on("close", () => {
|
|
1498
|
+
console.log(chalk16.gray("\n Goodbye!\n"));
|
|
1499
|
+
process.exit(0);
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
var VERSION, commands;
|
|
1503
|
+
var init_repl = __esm({
|
|
1504
|
+
"src/repl.ts"() {
|
|
1505
|
+
"use strict";
|
|
1506
|
+
init_api();
|
|
1507
|
+
init_banner();
|
|
1508
|
+
init_login();
|
|
1509
|
+
init_init();
|
|
1510
|
+
init_deploy();
|
|
1511
|
+
init_review();
|
|
1512
|
+
init_status();
|
|
1513
|
+
init_logs();
|
|
1514
|
+
init_rollback();
|
|
1515
|
+
init_config();
|
|
1516
|
+
init_projects();
|
|
1517
|
+
init_whoami();
|
|
1518
|
+
init_security();
|
|
1519
|
+
init_health();
|
|
1520
|
+
init_dashboard();
|
|
1521
|
+
VERSION = "1.2.0";
|
|
1522
|
+
commands = {
|
|
1523
|
+
login: { description: "Sign in via browser", action: loginCommand },
|
|
1524
|
+
logout: { description: "Log out and clear credentials", action: async () => {
|
|
1525
|
+
const Conf3 = (await import("conf")).default;
|
|
1526
|
+
const config3 = new Conf3({ projectName: "riventa-cli" });
|
|
1527
|
+
config3.clear();
|
|
1528
|
+
console.log(chalk16.green("\n Logged out successfully. Credentials cleared.\n"));
|
|
1529
|
+
} },
|
|
1530
|
+
whoami: { description: "Show current authenticated user", action: whoamiCommand },
|
|
1531
|
+
init: { description: "Initialize Riventa in current directory", action: initCommand },
|
|
1532
|
+
projects: { description: "List and switch between projects", action: projectsCommand },
|
|
1533
|
+
deploy: { description: "Deploy current branch", action: deployCommand },
|
|
1534
|
+
status: { description: "View project and deployment status", action: statusCommand },
|
|
1535
|
+
logs: { description: "View deployment logs", action: logsCommand },
|
|
1536
|
+
rollback: { description: "Rollback to a previous deployment", action: rollbackCommand },
|
|
1537
|
+
review: { description: "Run AI code review on changes", action: reviewCommand },
|
|
1538
|
+
security: { description: "Security scanning and score", action: securityCommand },
|
|
1539
|
+
config: { description: "Manage CLI configuration", action: configCommand },
|
|
1540
|
+
health: { description: "Check API connectivity and status", action: healthCommand },
|
|
1541
|
+
dashboard: { description: "Open dashboard in browser", action: dashboardCommand },
|
|
1542
|
+
open: { description: "Open dashboard in browser", action: () => dashboardCommand({}) }
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1235
1546
|
|
|
1236
1547
|
// src/index.ts
|
|
1548
|
+
init_login();
|
|
1549
|
+
init_init();
|
|
1550
|
+
init_deploy();
|
|
1551
|
+
init_review();
|
|
1552
|
+
init_status();
|
|
1553
|
+
init_logs();
|
|
1554
|
+
init_rollback();
|
|
1555
|
+
init_config();
|
|
1556
|
+
init_projects();
|
|
1557
|
+
init_whoami();
|
|
1558
|
+
init_security();
|
|
1559
|
+
init_health();
|
|
1560
|
+
init_dashboard();
|
|
1561
|
+
init_api();
|
|
1562
|
+
init_banner();
|
|
1563
|
+
import { Command } from "commander";
|
|
1564
|
+
import chalk17 from "chalk";
|
|
1565
|
+
var VERSION2 = "1.2.0";
|
|
1237
1566
|
var program = new Command();
|
|
1238
|
-
program.name("riventa").description(
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1567
|
+
program.name("riventa").description(chalk17.cyan("Riventa.Dev CLI") + chalk17.gray(" \u2014 AI-powered DevOps automation")).version(VERSION2).addHelpText("beforeAll", () => {
|
|
1568
|
+
const user = getConfig("user");
|
|
1569
|
+
printBanner(VERSION2, user?.email);
|
|
1570
|
+
return "";
|
|
1571
|
+
}).addHelpText("after", `
|
|
1572
|
+
${chalk17.bold("Quick Start:")}
|
|
1573
|
+
${chalk17.gray("$")} riventa login Sign in via browser
|
|
1574
|
+
${chalk17.gray("$")} riventa init Initialize a project
|
|
1575
|
+
${chalk17.gray("$")} riventa review Run AI code review
|
|
1576
|
+
${chalk17.gray("$")} riventa deploy Deploy to production
|
|
1244
1577
|
|
|
1245
|
-
${
|
|
1246
|
-
${
|
|
1578
|
+
${chalk17.bold("Documentation:")}
|
|
1579
|
+
${chalk17.gray("https://riventa.dev/developers/cli")}
|
|
1247
1580
|
`);
|
|
1248
1581
|
program.command("login").description("Authenticate with Riventa.Dev").action(loginCommand);
|
|
1249
1582
|
program.command("logout").description("Log out and clear credentials").action(async () => {
|
|
1250
1583
|
const Conf3 = (await import("conf")).default;
|
|
1251
1584
|
const config3 = new Conf3({ projectName: "riventa-cli" });
|
|
1252
1585
|
config3.clear();
|
|
1253
|
-
console.log(
|
|
1586
|
+
console.log(chalk17.green("\n Logged out successfully. Credentials cleared.\n"));
|
|
1254
1587
|
});
|
|
1255
1588
|
program.command("whoami").description("Show current authenticated user").action(whoamiCommand);
|
|
1256
1589
|
program.command("init").description("Initialize Riventa in current directory").action(initCommand);
|
|
@@ -1264,4 +1597,11 @@ program.command("security").description("Security scanning and score").option("-
|
|
|
1264
1597
|
program.command("config").description("Manage CLI configuration").option("--get <key>", "Get a config value").option("--set <key=value>", "Set a config value").option("--list", "List all config values").action(configCommand);
|
|
1265
1598
|
program.command("config:update <instruction>").description("Update .riventa.yml with AI").action(configUpdateCommand);
|
|
1266
1599
|
program.command("health").description("Check API connectivity and status").action(healthCommand);
|
|
1267
|
-
program.
|
|
1600
|
+
program.command("dashboard").description("Open dashboard in browser").option("-p, --page <page>", "Page to open (reviews, deployments, analytics, settings, api-keys, flags, monitoring)").action(dashboardCommand);
|
|
1601
|
+
program.command("open").description("Open current project in browser").action(() => dashboardCommand({}));
|
|
1602
|
+
var args = process.argv.slice(2);
|
|
1603
|
+
if (args.length === 0) {
|
|
1604
|
+
Promise.resolve().then(() => (init_repl(), repl_exports)).then(({ startRepl: startRepl2 }) => startRepl2());
|
|
1605
|
+
} else {
|
|
1606
|
+
program.parse();
|
|
1607
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configCommand,
|
|
3
|
+
deployCommand,
|
|
4
|
+
getConfig,
|
|
5
|
+
healthCommand,
|
|
6
|
+
initCommand,
|
|
7
|
+
loginCommand,
|
|
8
|
+
logsCommand,
|
|
9
|
+
printBanner,
|
|
10
|
+
projectsCommand,
|
|
11
|
+
reviewCommand,
|
|
12
|
+
rollbackCommand,
|
|
13
|
+
securityCommand,
|
|
14
|
+
statusCommand,
|
|
15
|
+
whoamiCommand
|
|
16
|
+
} from "./chunk-BMS2NG3R.js";
|
|
17
|
+
|
|
18
|
+
// src/repl.ts
|
|
19
|
+
import { createInterface } from "readline";
|
|
20
|
+
import chalk from "chalk";
|
|
21
|
+
var VERSION = "1.1.2";
|
|
22
|
+
var commands = {
|
|
23
|
+
login: { description: "Sign in via browser", action: loginCommand },
|
|
24
|
+
logout: { description: "Log out and clear credentials", action: async () => {
|
|
25
|
+
const Conf = (await import("conf")).default;
|
|
26
|
+
const config = new Conf({ projectName: "riventa-cli" });
|
|
27
|
+
config.clear();
|
|
28
|
+
console.log(chalk.green("\n Logged out successfully. Credentials cleared.\n"));
|
|
29
|
+
} },
|
|
30
|
+
whoami: { description: "Show current authenticated user", action: whoamiCommand },
|
|
31
|
+
init: { description: "Initialize Riventa in current directory", action: initCommand },
|
|
32
|
+
projects: { description: "List and switch between projects", action: projectsCommand },
|
|
33
|
+
deploy: { description: "Deploy current branch", action: deployCommand },
|
|
34
|
+
status: { description: "View project and deployment status", action: statusCommand },
|
|
35
|
+
logs: { description: "View deployment logs", action: logsCommand },
|
|
36
|
+
rollback: { description: "Rollback to a previous deployment", action: rollbackCommand },
|
|
37
|
+
review: { description: "Run AI code review on changes", action: reviewCommand },
|
|
38
|
+
security: { description: "Security scanning and score", action: securityCommand },
|
|
39
|
+
config: { description: "Manage CLI configuration", action: configCommand },
|
|
40
|
+
health: { description: "Check API connectivity and status", action: healthCommand }
|
|
41
|
+
};
|
|
42
|
+
function showHelp() {
|
|
43
|
+
console.log();
|
|
44
|
+
console.log(chalk.bold(" Available commands:"));
|
|
45
|
+
console.log();
|
|
46
|
+
const maxLen = Math.max(...Object.keys(commands).map((k) => k.length));
|
|
47
|
+
for (const [name, cmd] of Object.entries(commands)) {
|
|
48
|
+
console.log(chalk.cyan(` ${name.padEnd(maxLen + 2)}`) + chalk.gray(cmd.description));
|
|
49
|
+
}
|
|
50
|
+
console.log();
|
|
51
|
+
console.log(chalk.gray(" help") + chalk.gray("".padEnd(maxLen - 2)) + chalk.gray("Show this help"));
|
|
52
|
+
console.log(chalk.gray(" clear") + chalk.gray("".padEnd(maxLen - 3)) + chalk.gray("Clear the screen"));
|
|
53
|
+
console.log(chalk.gray(" exit") + chalk.gray("".padEnd(maxLen - 2)) + chalk.gray("Exit the CLI"));
|
|
54
|
+
console.log();
|
|
55
|
+
}
|
|
56
|
+
async function startRepl() {
|
|
57
|
+
const user = getConfig("user");
|
|
58
|
+
printBanner(VERSION, user?.email);
|
|
59
|
+
const cwd = process.cwd().split("/").pop() || "~";
|
|
60
|
+
const rl = createInterface({
|
|
61
|
+
input: process.stdin,
|
|
62
|
+
output: process.stdout,
|
|
63
|
+
prompt: chalk.hex("#2563EB")("riventa") + chalk.gray(`:${cwd}`) + chalk.white("> "),
|
|
64
|
+
completer: (line) => {
|
|
65
|
+
const completions = [...Object.keys(commands), "help", "clear", "exit"];
|
|
66
|
+
const hits = completions.filter((c) => c.startsWith(line.trim()));
|
|
67
|
+
return [hits.length ? hits : completions, line];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
rl.prompt();
|
|
71
|
+
rl.on("line", async (line) => {
|
|
72
|
+
const input = line.trim();
|
|
73
|
+
const [cmd, ...args] = input.split(/\s+/);
|
|
74
|
+
if (!cmd) {
|
|
75
|
+
rl.prompt();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (cmd === "exit" || cmd === "quit") {
|
|
79
|
+
console.log(chalk.gray("\n Goodbye!\n"));
|
|
80
|
+
process.exit(0);
|
|
81
|
+
}
|
|
82
|
+
if (cmd === "help") {
|
|
83
|
+
showHelp();
|
|
84
|
+
rl.prompt();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (cmd === "clear") {
|
|
88
|
+
console.clear();
|
|
89
|
+
const u = getConfig("user");
|
|
90
|
+
printBanner(VERSION, u?.email);
|
|
91
|
+
rl.prompt();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (cmd === "version") {
|
|
95
|
+
console.log(chalk.gray(`
|
|
96
|
+
v${VERSION}
|
|
97
|
+
`));
|
|
98
|
+
rl.prompt();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const command = commands[cmd];
|
|
102
|
+
if (!command) {
|
|
103
|
+
console.log(chalk.red(`
|
|
104
|
+
Unknown command: ${cmd}`));
|
|
105
|
+
console.log(chalk.gray(" Type ") + chalk.cyan("help") + chalk.gray(" to see available commands.\n"));
|
|
106
|
+
rl.prompt();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const originalExit = process.exit;
|
|
111
|
+
process.exit = (() => {
|
|
112
|
+
throw new Error("__REPL_EXIT__");
|
|
113
|
+
});
|
|
114
|
+
await command.action({ ...Object.fromEntries(args.map((a, i) => [i, a])) });
|
|
115
|
+
process.exit = originalExit;
|
|
116
|
+
} catch (err) {
|
|
117
|
+
if (err?.message !== "__REPL_EXIT__") {
|
|
118
|
+
console.log(chalk.red(`
|
|
119
|
+
Error: ${err.message}
|
|
120
|
+
`));
|
|
121
|
+
}
|
|
122
|
+
process.exit = (await import("process")).exit;
|
|
123
|
+
}
|
|
124
|
+
console.log();
|
|
125
|
+
rl.prompt();
|
|
126
|
+
});
|
|
127
|
+
rl.on("close", () => {
|
|
128
|
+
console.log(chalk.gray("\n Goodbye!\n"));
|
|
129
|
+
process.exit(0);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
startRepl
|
|
134
|
+
};
|
package/dist/repl.d.ts
ADDED