cassian-cli 0.1.5 → 0.1.6
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/commands/exec.d.ts +3 -1
- package/dist/commands/exec.js +3 -2
- package/dist/commands/login.js +13 -7
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/commands/exec.d.ts
CHANGED
package/dist/commands/exec.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ApiClient } from "../lib/api.js";
|
|
2
2
|
import { loadConfig } from "../lib/config.js";
|
|
3
3
|
import { fatal, handleError } from "../lib/errors.js";
|
|
4
|
-
export async function exec(args) {
|
|
4
|
+
export async function exec(args, opts = {}) {
|
|
5
5
|
if (args.length === 0) {
|
|
6
6
|
fatal("No command specified.", "Usage: cassian exec <command>");
|
|
7
7
|
}
|
|
8
8
|
const command = args.join(" ");
|
|
9
|
+
const timeout = parseInt(opts.timeout || "600");
|
|
9
10
|
let config;
|
|
10
11
|
try {
|
|
11
12
|
config = loadConfig();
|
|
@@ -22,7 +23,7 @@ export async function exec(args) {
|
|
|
22
23
|
}
|
|
23
24
|
const result = await client.post(`/v1/instances/${instance.id}/exec`, {
|
|
24
25
|
command,
|
|
25
|
-
timeout
|
|
26
|
+
timeout,
|
|
26
27
|
});
|
|
27
28
|
if (result.stdout)
|
|
28
29
|
process.stdout.write(result.stdout);
|
package/dist/commands/login.js
CHANGED
|
@@ -9,8 +9,6 @@ export async function login() {
|
|
|
9
9
|
const callbackUrl = `http://localhost:${CALLBACK_PORT}/callback`;
|
|
10
10
|
const platformUrl = PLATFORM_URL;
|
|
11
11
|
console.log();
|
|
12
|
-
console.log(" Opening Cassian in your browser...");
|
|
13
|
-
console.log();
|
|
14
12
|
const authUrl = `${platformUrl}?cli_redirect=${encodeURIComponent(callbackUrl)}`;
|
|
15
13
|
// Derive the allowed CORS origin from platformUrl (e.g. https://trycassian.com)
|
|
16
14
|
const allowedOrigin = new URL(platformUrl).origin;
|
|
@@ -66,11 +64,19 @@ export async function login() {
|
|
|
66
64
|
res.end();
|
|
67
65
|
});
|
|
68
66
|
server.listen(CALLBACK_PORT, "127.0.0.1", () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
console.log(dim(" Login URL (open in any browser):"));
|
|
68
|
+
console.log(` ${authUrl}`);
|
|
69
|
+
console.log();
|
|
70
|
+
console.log(dim(" Press Enter to open in browser..."));
|
|
71
|
+
if (process.stdin.isTTY) {
|
|
72
|
+
process.stdin.setRawMode(true);
|
|
73
|
+
process.stdin.resume();
|
|
74
|
+
process.stdin.once("data", () => {
|
|
75
|
+
process.stdin.setRawMode(false);
|
|
76
|
+
process.stdin.pause();
|
|
77
|
+
open(authUrl).catch(() => { });
|
|
78
|
+
});
|
|
79
|
+
}
|
|
74
80
|
});
|
|
75
81
|
server.on("error", () => {
|
|
76
82
|
fatal("Could not start login. Try again.");
|
package/dist/index.js
CHANGED
|
@@ -43,8 +43,8 @@ program
|
|
|
43
43
|
program
|
|
44
44
|
.command("exec <command...>")
|
|
45
45
|
.description("Run a command on the instance and return output")
|
|
46
|
-
.option("--timeout <seconds>", "Command timeout in seconds", "
|
|
47
|
-
.action((command, opts) => exec(command));
|
|
46
|
+
.option("--timeout <seconds>", "Command timeout in seconds", "600")
|
|
47
|
+
.action((command, opts) => exec(command, opts));
|
|
48
48
|
program
|
|
49
49
|
.command("sync")
|
|
50
50
|
.description("Sync workspace from instance to local")
|