rafaygen-cli 1.0.2 → 1.0.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/rgcli.js +0 -10
- package/package.json +1 -1
- package/src/auth.js +18 -25
package/bin/rgcli.js
CHANGED
|
@@ -48,16 +48,6 @@ program
|
|
|
48
48
|
|
|
49
49
|
// Handle default command if no args provided -> Start Chat Loop
|
|
50
50
|
if (process.argv.length === 2) {
|
|
51
|
-
console.log(chalk.cyan.bold(`
|
|
52
|
-
____ __ _____
|
|
53
|
-
| _ \\ / _| / ____|
|
|
54
|
-
| |_) | __ _| |_ __ _ _ _| | __ ___ _ __
|
|
55
|
-
| _ < / _\` | _/ _\` | | | | |_ / _ \\ '_ \\
|
|
56
|
-
| |_) | (_| | || (_| | |_| |__| | __/ | | |
|
|
57
|
-
|____/ \\__,_|_| \\__,_|\\__, \\_____\\___|_| |_|
|
|
58
|
-
__/ |
|
|
59
|
-
|___/
|
|
60
|
-
`));
|
|
61
51
|
startInteractiveLoop();
|
|
62
52
|
} else {
|
|
63
53
|
program.parse(process.argv);
|
package/package.json
CHANGED
package/src/auth.js
CHANGED
|
@@ -46,7 +46,7 @@ export async function startAuthLoop() {
|
|
|
46
46
|
const { printAsciiLogo, printSuccess } = await import("./ui.js");
|
|
47
47
|
|
|
48
48
|
printAsciiLogo();
|
|
49
|
-
console.log(chalk.yellow("You are not logged in. Let's get you authenticated
|
|
49
|
+
console.log(chalk.yellow("You are not logged in. Let's get you authenticated!\n"));
|
|
50
50
|
|
|
51
51
|
while (true) {
|
|
52
52
|
const { method } = await inquirer.prompt([
|
|
@@ -72,21 +72,18 @@ export async function startAuthLoop() {
|
|
|
72
72
|
{
|
|
73
73
|
type: "password",
|
|
74
74
|
name: "token",
|
|
75
|
-
message: "Paste your RafayGen Personal Access Token:"
|
|
75
|
+
message: "Paste your RafayGen Personal Access Token:",
|
|
76
|
+
validate: (input) => input.trim() !== "" ? true : "Token cannot be empty"
|
|
76
77
|
}
|
|
77
78
|
]);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return;
|
|
82
|
-
} else {
|
|
83
|
-
console.log(chalk.red("Token cannot be empty. Try again."));
|
|
84
|
-
}
|
|
79
|
+
setToken(token.trim());
|
|
80
|
+
printSuccess("Successfully logged in to RafayGen!");
|
|
81
|
+
return;
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
if (method === "browser") {
|
|
88
85
|
const loginUrl = "https://rafaygen.com/settings/tokens";
|
|
89
|
-
console.log(chalk.cyan(
|
|
86
|
+
console.log(chalk.cyan(`\nOpening browser to: ${loginUrl}`));
|
|
90
87
|
console.log(chalk.gray("If the browser doesn't open, copy and paste the URL manually."));
|
|
91
88
|
try {
|
|
92
89
|
await open(loginUrl);
|
|
@@ -98,37 +95,33 @@ export async function startAuthLoop() {
|
|
|
98
95
|
{
|
|
99
96
|
type: "password",
|
|
100
97
|
name: "token",
|
|
101
|
-
message: "Once you create a token, paste it here:"
|
|
98
|
+
message: "Once you create a token, paste it here:",
|
|
99
|
+
validate: (input) => input.trim() !== "" ? true : "Token cannot be empty"
|
|
102
100
|
}
|
|
103
101
|
]);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
102
|
+
setToken(token.trim());
|
|
103
|
+
printSuccess("Successfully logged in to RafayGen!");
|
|
104
|
+
return;
|
|
109
105
|
}
|
|
110
106
|
|
|
111
107
|
if (method === "device") {
|
|
112
108
|
const code = Math.floor(100000 + Math.random() * 900000);
|
|
113
|
-
console.log(chalk.magenta.bold(
|
|
109
|
+
console.log(chalk.magenta.bold(`\nYour Device Code is: ${code}`));
|
|
114
110
|
console.log(chalk.white(`1. Go to https://rafaygen.com/device on your phone or computer.`));
|
|
115
111
|
console.log(chalk.white(`2. Enter the code above.`));
|
|
116
112
|
|
|
117
|
-
// In a real implementation, you'd poll the API here.
|
|
118
|
-
// We will simulate the polling for now until the backend endpoint is fully built.
|
|
119
113
|
console.log(chalk.gray("(Device flow polling is simulated in this CLI version)"));
|
|
120
114
|
const { token } = await inquirer.prompt([
|
|
121
115
|
{
|
|
122
116
|
type: "password",
|
|
123
117
|
name: "token",
|
|
124
|
-
message: "Or just paste the token manually for now:"
|
|
118
|
+
message: "Or just paste the token manually for now:",
|
|
119
|
+
validate: (input) => input.trim() !== "" ? true : "Token cannot be empty"
|
|
125
120
|
}
|
|
126
121
|
]);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
122
|
+
setToken(token.trim());
|
|
123
|
+
printSuccess("Successfully logged in to RafayGen!");
|
|
124
|
+
return;
|
|
132
125
|
}
|
|
133
126
|
}
|
|
134
127
|
}
|