@epilot/cli 0.1.18 → 0.1.19
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/README.md
CHANGED
|
@@ -21,7 +21,7 @@ var auth_default = defineCommand({
|
|
|
21
21
|
description: "Manage authentication"
|
|
22
22
|
},
|
|
23
23
|
subCommands: {
|
|
24
|
-
login: () => import("./auth-login-
|
|
24
|
+
login: () => import("./auth-login-X2GRQW6N.js").then((m) => m.default),
|
|
25
25
|
token: () => import("./auth-token-J4FI2RMT.js").then((m) => m.default),
|
|
26
26
|
logout: defineCommand({
|
|
27
27
|
meta: { name: "logout", description: "Remove stored credentials" },
|
|
@@ -17,14 +17,34 @@ import {
|
|
|
17
17
|
import { defineCommand } from "citty";
|
|
18
18
|
import { randomBytes } from "crypto";
|
|
19
19
|
import { createServer } from "http";
|
|
20
|
+
|
|
21
|
+
// src/lib/environment.ts
|
|
22
|
+
var PORTAL_URLS = {
|
|
23
|
+
production: "https://portal.epilot.cloud",
|
|
24
|
+
staging: "https://portal.staging.epilot.cloud",
|
|
25
|
+
dev: "https://portal.dev.epilot.cloud"
|
|
26
|
+
};
|
|
27
|
+
var getPortalUrl = (env = "production") => {
|
|
28
|
+
return PORTAL_URLS[env];
|
|
29
|
+
};
|
|
30
|
+
var resolveEnvironment = (useDev, useStaging) => {
|
|
31
|
+
if (useDev) return "dev";
|
|
32
|
+
if (useStaging) return "staging";
|
|
33
|
+
return "production";
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/commands/auth-login.ts
|
|
20
37
|
var auth_login_default = defineCommand({
|
|
21
38
|
meta: { name: "login", description: "Authenticate with epilot" },
|
|
22
39
|
args: {
|
|
23
40
|
token: { type: "string", description: "Manually provide a token instead of browser login" },
|
|
24
|
-
profile: { type: "string", description: "Save credentials to this profile" }
|
|
41
|
+
profile: { type: "string", description: "Save credentials to this profile" },
|
|
42
|
+
"use-dev": { type: "boolean", description: "Use dev environment (portal.dev.epilot.cloud)" },
|
|
43
|
+
"use-staging": { type: "boolean", description: "Use staging environment (portal.staging.epilot.cloud)" }
|
|
25
44
|
},
|
|
26
45
|
run: async ({ args }) => {
|
|
27
46
|
const profileName = args.profile || process.env.EPILOT_PROFILE;
|
|
47
|
+
const env = resolveEnvironment(args["use-dev"], args["use-staging"]);
|
|
28
48
|
if (args.token) {
|
|
29
49
|
saveCredentials({ token: args.token }, profileName);
|
|
30
50
|
const suffix = profileName ? ` to profile "${profileName}"` : "";
|
|
@@ -41,7 +61,7 @@ var auth_login_default = defineCommand({
|
|
|
41
61
|
);
|
|
42
62
|
process.exit(1);
|
|
43
63
|
}
|
|
44
|
-
const token = await browserLogin(profileName);
|
|
64
|
+
const token = await browserLogin(profileName, env);
|
|
45
65
|
if (token) {
|
|
46
66
|
process.stdout.write(`${GREEN}${BOLD}Login successful!${RESET}
|
|
47
67
|
`);
|
|
@@ -52,7 +72,7 @@ var auth_login_default = defineCommand({
|
|
|
52
72
|
}
|
|
53
73
|
}
|
|
54
74
|
});
|
|
55
|
-
var browserLogin = async (profileName) => {
|
|
75
|
+
var browserLogin = async (profileName, env = "production") => {
|
|
56
76
|
const state = randomBytes(32).toString("hex");
|
|
57
77
|
const verificationCode = randomBytes(3).toString("hex").toUpperCase();
|
|
58
78
|
const suffix = profileName ? ` ${DIM}(profile: ${profileName})${RESET}` : "";
|
|
@@ -96,7 +116,8 @@ ${BOLD}epilot CLI Login${RESET}${suffix}
|
|
|
96
116
|
}
|
|
97
117
|
const port = address.port;
|
|
98
118
|
const callbackUrl = `http://localhost:${port}/callback`;
|
|
99
|
-
const
|
|
119
|
+
const portalUrl = getPortalUrl(env);
|
|
120
|
+
const loginUrl = `${portalUrl}/login?cli_callback=${encodeURIComponent(callbackUrl)}&state=${state}&code=${verificationCode}`;
|
|
100
121
|
process.stdout.write(`
|
|
101
122
|
${DIM}Login URL: ${loginUrl}${RESET}
|
|
102
123
|
|
package/dist/bin/epilot.js
CHANGED
|
@@ -11,7 +11,7 @@ import { defineCommand } from "citty";
|
|
|
11
11
|
var main = defineCommand({
|
|
12
12
|
meta: {
|
|
13
13
|
name: "epilot",
|
|
14
|
-
version: "0.1.
|
|
14
|
+
version: "0.1.19",
|
|
15
15
|
description: "CLI for epilot APIs"
|
|
16
16
|
},
|
|
17
17
|
args: {
|
|
@@ -25,10 +25,10 @@ var main = defineCommand({
|
|
|
25
25
|
jsonata: { type: "string", description: "JSONata expression" }
|
|
26
26
|
},
|
|
27
27
|
subCommands: {
|
|
28
|
-
auth: () => import("../auth-
|
|
28
|
+
auth: () => import("../auth-OPYS3QFL.js").then((m) => m.default),
|
|
29
29
|
profile: () => import("../profile-EK4HSQ57.js").then((m) => m.default),
|
|
30
30
|
completion: () => import("../completion-INJETNZK.js").then((m) => m.default),
|
|
31
|
-
upgrade: () => import("../upgrade-
|
|
31
|
+
upgrade: () => import("../upgrade-BFBIJHFI.js").then((m) => m.default),
|
|
32
32
|
"access-token": () => import("../access-token-CIM4RLBP.js").then((m) => m.default),
|
|
33
33
|
address: () => import("../address-EDRTUWTP.js").then((m) => m.default),
|
|
34
34
|
"address-suggestions": () => import("../address-suggestions-S5WEST2N.js").then((m) => m.default),
|
|
@@ -90,7 +90,7 @@ process.stderr.on("error", (err) => {
|
|
|
90
90
|
if (err.code === "EPIPE") process.exit(0);
|
|
91
91
|
throw err;
|
|
92
92
|
});
|
|
93
|
-
var VERSION = true ? "0.1.
|
|
93
|
+
var VERSION = true ? "0.1.19" : (await null).default.version;
|
|
94
94
|
var args = process.argv.slice(2);
|
|
95
95
|
var completionsIdx = args.indexOf("--_completions");
|
|
96
96
|
if (completionsIdx >= 0) {
|
|
@@ -72,7 +72,7 @@ ${GREEN}${BOLD}Upgraded to @epilot/cli@${latest}${RESET}
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
var getCurrentVersion = () => {
|
|
75
|
-
if (true) return "0.1.
|
|
75
|
+
if (true) return "0.1.19";
|
|
76
76
|
try {
|
|
77
77
|
const output = execSync("npm ls -g @epilot/cli --depth=0 --json 2>/dev/null", {
|
|
78
78
|
encoding: "utf-8",
|