kern0-cli 0.1.2 ā 0.1.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/lib/cli/commands/setup.ts +69 -0
- package/lib/cli/index.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { loadConfig, saveConfig } from "../config";
|
|
2
|
+
|
|
3
|
+
export async function setupCommand(): Promise<void> {
|
|
4
|
+
console.log("\nš§ KernZero CLI Setup\n");
|
|
5
|
+
|
|
6
|
+
const config = loadConfig();
|
|
7
|
+
|
|
8
|
+
console.log("Current configuration:");
|
|
9
|
+
console.log(` API URL: ${config.api_url}\n`);
|
|
10
|
+
|
|
11
|
+
console.log("Available endpoints:");
|
|
12
|
+
console.log(" 1. Staging: https://staging.kernzero.com");
|
|
13
|
+
console.log(" 2. Production: https://kernzero.com");
|
|
14
|
+
console.log(" 3. Local: http://localhost:3000");
|
|
15
|
+
console.log(" 4. Custom (enter URL)\n");
|
|
16
|
+
|
|
17
|
+
const readline = await import("readline");
|
|
18
|
+
const rl = readline.createInterface({
|
|
19
|
+
input: process.stdin,
|
|
20
|
+
output: process.stdout,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const question = (prompt: string): Promise<string> => {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
rl.question(prompt, resolve);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const choice = await question("Select option (1-4): ");
|
|
31
|
+
|
|
32
|
+
let apiUrl = config.api_url;
|
|
33
|
+
|
|
34
|
+
switch (choice.trim()) {
|
|
35
|
+
case "1":
|
|
36
|
+
apiUrl = "https://staging.kernzero.com";
|
|
37
|
+
console.log("\nā
Set to Staging");
|
|
38
|
+
break;
|
|
39
|
+
case "2":
|
|
40
|
+
apiUrl = "https://kernzero.com";
|
|
41
|
+
console.log("\nā
Set to Production");
|
|
42
|
+
break;
|
|
43
|
+
case "3":
|
|
44
|
+
apiUrl = "http://localhost:3000";
|
|
45
|
+
console.log("\nā
Set to Local");
|
|
46
|
+
break;
|
|
47
|
+
case "4":
|
|
48
|
+
const custom = await question("Enter API URL: ");
|
|
49
|
+
apiUrl = custom.trim();
|
|
50
|
+
console.log(`\nā
Set to ${apiUrl}`);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
console.log("\nā Invalid option");
|
|
54
|
+
rl.close();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
config.api_url = apiUrl;
|
|
59
|
+
saveConfig(config);
|
|
60
|
+
|
|
61
|
+
console.log("\nā
Configuration saved to ~/.kern0/config.json");
|
|
62
|
+
console.log("\nNext steps:");
|
|
63
|
+
console.log(" 1. Run: kern0 login");
|
|
64
|
+
console.log(" 2. Authenticate with your passkey");
|
|
65
|
+
console.log(" 3. Check: kern0 whoami\n");
|
|
66
|
+
} finally {
|
|
67
|
+
rl.close();
|
|
68
|
+
}
|
|
69
|
+
}
|
package/lib/cli/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { login, logout } from "./commands/auth";
|
|
4
|
+
import { setupCommand } from "./commands/setup";
|
|
4
5
|
import {
|
|
5
6
|
listOrgs,
|
|
6
7
|
selectOrg,
|
|
@@ -40,6 +41,10 @@ async function main() {
|
|
|
40
41
|
await logout();
|
|
41
42
|
break;
|
|
42
43
|
|
|
44
|
+
case "setup":
|
|
45
|
+
await setupCommand();
|
|
46
|
+
break;
|
|
47
|
+
|
|
43
48
|
// Organization commands
|
|
44
49
|
case "org":
|
|
45
50
|
switch (subcommand) {
|
|
@@ -174,6 +179,9 @@ Kern0 CLI - Recovery Readiness Assessment Tool
|
|
|
174
179
|
USAGE:
|
|
175
180
|
kern0 <command> [options]
|
|
176
181
|
|
|
182
|
+
FIRST TIME SETUP:
|
|
183
|
+
setup Configure API endpoint (required before login)
|
|
184
|
+
|
|
177
185
|
AUTHENTICATION:
|
|
178
186
|
login Authenticate with OAuth device flow
|
|
179
187
|
logout Clear credentials and log out
|