@riventa/cli 1.1.1 → 1.1.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/dist/index.js +53 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
2
8
|
|
|
3
9
|
// src/index.ts
|
|
4
10
|
import { Command } from "commander";
|
|
5
|
-
import
|
|
11
|
+
import chalk15 from "chalk";
|
|
6
12
|
|
|
7
13
|
// src/commands/login.ts
|
|
8
14
|
import chalk2 from "chalk";
|
|
9
15
|
import inquirer from "inquirer";
|
|
10
16
|
import open from "open";
|
|
11
17
|
import ora from "ora";
|
|
18
|
+
import { exec } from "child_process";
|
|
19
|
+
import { existsSync } from "fs";
|
|
12
20
|
|
|
13
21
|
// src/utils/api.ts
|
|
14
22
|
import Conf from "conf";
|
|
@@ -71,6 +79,19 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
71
79
|
}
|
|
72
80
|
|
|
73
81
|
// src/commands/login.ts
|
|
82
|
+
function openUrl(url) {
|
|
83
|
+
const isWSL = existsSync("/proc/version") && __require("fs").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
|
+
}
|
|
74
95
|
async function loginCommand() {
|
|
75
96
|
const existingKey = getApiKey();
|
|
76
97
|
if (existingKey) {
|
|
@@ -137,7 +158,7 @@ async function deviceFlowLogin() {
|
|
|
137
158
|
console.log(chalk2.gray(` Opening ${verificationUrl}`));
|
|
138
159
|
console.log(chalk2.gray(" Enter the code above to authorize this device.\n"));
|
|
139
160
|
try {
|
|
140
|
-
await
|
|
161
|
+
await openUrl(verificationUrl);
|
|
141
162
|
} catch {
|
|
142
163
|
console.log(chalk2.yellow(` Could not open browser automatically.`));
|
|
143
164
|
console.log(chalk2.yellow(` Please visit: ${chalk2.white(verificationUrl)}
|
|
@@ -1233,24 +1254,45 @@ async function healthCommand() {
|
|
|
1233
1254
|
}
|
|
1234
1255
|
}
|
|
1235
1256
|
|
|
1257
|
+
// src/banner.ts
|
|
1258
|
+
import chalk14 from "chalk";
|
|
1259
|
+
function printBanner(version, email) {
|
|
1260
|
+
console.log();
|
|
1261
|
+
console.log(
|
|
1262
|
+
chalk14.bold.white("RIVENTA") + chalk14.bold.hex("#2563EB")(".DEV")
|
|
1263
|
+
);
|
|
1264
|
+
console.log(
|
|
1265
|
+
chalk14.gray(`Riventa CLI v${version} \xB7 AI-powered DevOps`)
|
|
1266
|
+
);
|
|
1267
|
+
if (email) {
|
|
1268
|
+
console.log(chalk14.gray(`Logged in as `) + chalk14.white(email));
|
|
1269
|
+
}
|
|
1270
|
+
console.log();
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1236
1273
|
// src/index.ts
|
|
1274
|
+
var VERSION = "1.1.2";
|
|
1237
1275
|
var program = new Command();
|
|
1238
|
-
program.name("riventa").description(
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1276
|
+
program.name("riventa").description(chalk15.cyan("Riventa.Dev CLI") + chalk15.gray(" \u2014 AI-powered DevOps automation")).version(VERSION).addHelpText("beforeAll", () => {
|
|
1277
|
+
const user = getConfig("user");
|
|
1278
|
+
printBanner(VERSION, user?.email);
|
|
1279
|
+
return "";
|
|
1280
|
+
}).addHelpText("after", `
|
|
1281
|
+
${chalk15.bold("Quick Start:")}
|
|
1282
|
+
${chalk15.gray("$")} riventa login Sign in via browser
|
|
1283
|
+
${chalk15.gray("$")} riventa init Initialize a project
|
|
1284
|
+
${chalk15.gray("$")} riventa review Run AI code review
|
|
1285
|
+
${chalk15.gray("$")} riventa deploy Deploy to production
|
|
1244
1286
|
|
|
1245
|
-
${
|
|
1246
|
-
${
|
|
1287
|
+
${chalk15.bold("Documentation:")}
|
|
1288
|
+
${chalk15.gray("https://riventa.dev/developers/cli")}
|
|
1247
1289
|
`);
|
|
1248
1290
|
program.command("login").description("Authenticate with Riventa.Dev").action(loginCommand);
|
|
1249
1291
|
program.command("logout").description("Log out and clear credentials").action(async () => {
|
|
1250
1292
|
const Conf3 = (await import("conf")).default;
|
|
1251
1293
|
const config3 = new Conf3({ projectName: "riventa-cli" });
|
|
1252
1294
|
config3.clear();
|
|
1253
|
-
console.log(
|
|
1295
|
+
console.log(chalk15.green("\n Logged out successfully. Credentials cleared.\n"));
|
|
1254
1296
|
});
|
|
1255
1297
|
program.command("whoami").description("Show current authenticated user").action(whoamiCommand);
|
|
1256
1298
|
program.command("init").description("Initialize Riventa in current directory").action(initCommand);
|