onedeploy-cli 0.1.2 → 0.1.4
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 +23 -2
- package/dist/index.js +6 -0
- package/dist/nebula.js +13 -14
- package/package.json +2 -1
- package/src/index.ts +8 -1
package/README.md
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
# OneDeploy CLI
|
|
2
2
|
|
|
3
|
-
This CLI allows you to connect to a OneDeploy cluster via
|
|
3
|
+
This CLI allows you to connect to a OneDeploy cluster via
|
|
4
|
+
[Nebula](https://github.com/slackhq/nebula).
|
|
5
|
+
|
|
6
|
+
## Getting Started
|
|
7
|
+
|
|
8
|
+
Run it using `sudo` on Unix-like systems:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
sudo npx onedeploy-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
or from an administrator prompt on Windows:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npx onedeploy-cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Then, you need to create an API key on your OneDeploy dashboard. You can
|
|
21
|
+
`Setup new connection` to enter your dashboard URL and API key. Afterwards, you
|
|
22
|
+
can `Connect` to the cluster you added. Please note that connections are stored
|
|
23
|
+
per computer (for the root user), not individually per user.
|
|
4
24
|
|
|
5
25
|
## License
|
|
6
26
|
|
|
7
|
-
The OneDeploy CLI licensed under MIT, see [here](./LICENSE). It uses the Nebula
|
|
27
|
+
The OneDeploy CLI licensed under MIT, see [here](./LICENSE). It uses the Nebula
|
|
28
|
+
overlay network, which is also MIT licensed.
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import prompts from "prompts";
|
|
3
3
|
import { loadConfig, saveConfig } from "./config.js";
|
|
4
4
|
import { cleanupNebula, connectNebula, installNebula } from "./nebula.js";
|
|
5
|
+
if (process.argv.includes("--version")) {
|
|
6
|
+
console.log("onedeploy-cli version 0.1.4");
|
|
7
|
+
process.exit();
|
|
8
|
+
}
|
|
5
9
|
const config = await loadConfig();
|
|
6
10
|
const setupConnection = async () => {
|
|
7
11
|
const result = await prompts([
|
|
@@ -100,6 +104,8 @@ const mainMenu = async () => {
|
|
|
100
104
|
}
|
|
101
105
|
return true;
|
|
102
106
|
};
|
|
107
|
+
// ignore SIGINTs to continue after Nebula is disconnected
|
|
108
|
+
process.on("SIGINT", () => { });
|
|
103
109
|
await installNebula();
|
|
104
110
|
try {
|
|
105
111
|
while (true) {
|
package/dist/nebula.js
CHANGED
|
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { Readable } from "node:stream";
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
|
+
import { parse } from "yaml";
|
|
8
9
|
const getNebulaPackageName = () => {
|
|
9
10
|
switch (process.platform) {
|
|
10
11
|
case "linux":
|
|
@@ -29,13 +30,13 @@ const nebulaUrl = `https://github.com/slackhq/nebula/releases/download/${nebulaV
|
|
|
29
30
|
const tmpDir = path.join(tmpdir(), `onedeploy-${randomUUID()}`);
|
|
30
31
|
await mkdir(tmpDir, { recursive: true });
|
|
31
32
|
export const installNebula = async () => {
|
|
32
|
-
console.log(
|
|
33
|
+
console.log(`Downloading Nebula to ${tmpDir}/${packageName}...`);
|
|
33
34
|
const file = await fetch(nebulaUrl);
|
|
34
35
|
if (file.body === null) {
|
|
35
36
|
throw new Error("Could not download Nebula executable.");
|
|
36
37
|
}
|
|
37
38
|
await writeFile(`${tmpDir}/${packageName}`, Readable.from(file.body));
|
|
38
|
-
console.log(
|
|
39
|
+
console.log(`Extracting Nebula to ${tmpDir}/nebula...`);
|
|
39
40
|
await promisify(execFile)("tar", [
|
|
40
41
|
"-xf",
|
|
41
42
|
`${tmpDir}/${packageName}`,
|
|
@@ -58,21 +59,19 @@ export const getNebulaCert = async (instance) => {
|
|
|
58
59
|
const { nebulaConfig } = (await response.json());
|
|
59
60
|
await writeFile(`${tmpDir}/nebula.yml`, nebulaConfig);
|
|
60
61
|
await chmod(`${tmpDir}/nebula.yml`, 0o600);
|
|
61
|
-
};
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
stdio: "inherit",
|
|
71
|
-
});
|
|
62
|
+
console.log(`Wrote Nebula configuration to ${tmpDir}/nebula.yml`);
|
|
63
|
+
const parsedConfig = parse(nebulaConfig);
|
|
64
|
+
await writeFile(`${tmpDir}/nebula-debug.crt`, parsedConfig.pki.cert);
|
|
65
|
+
const { stdout } = await promisify(execFile)(`${tmpDir}/nebula-cert`, [
|
|
66
|
+
"print",
|
|
67
|
+
"-path",
|
|
68
|
+
`${tmpDir}/nebula-debug.crt`,
|
|
69
|
+
]);
|
|
70
|
+
process.stdout.write(stdout);
|
|
72
71
|
};
|
|
73
72
|
export const connectNebula = async (instance) => {
|
|
74
73
|
await getNebulaCert(instance);
|
|
75
|
-
const nebula =
|
|
74
|
+
const nebula = spawn(`${tmpDir}/nebula`, ["-config", `${tmpDir}/nebula.yml`], { stdio: "inherit" });
|
|
76
75
|
const interval = setInterval(async () => {
|
|
77
76
|
// refresh Nebula cert every 10 minutes (lifetime is 15 minutes)
|
|
78
77
|
await getNebulaCert(instance);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onedeploy-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "CLI tool for connecting to OneDeploy via Nebula",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"onedeploy",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"prompts": "^2.4.2",
|
|
42
|
+
"yaml": "^2.8.1",
|
|
42
43
|
"yedra": "^0.17.9"
|
|
43
44
|
}
|
|
44
45
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,11 @@ import prompts from "prompts";
|
|
|
3
3
|
import { loadConfig, saveConfig } from "./config.js";
|
|
4
4
|
import { cleanupNebula, connectNebula, installNebula } from "./nebula.js";
|
|
5
5
|
|
|
6
|
+
if (process.argv.includes("--version")) {
|
|
7
|
+
console.log("onedeploy-cli version 0.1.4");
|
|
8
|
+
process.exit();
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
const config = await loadConfig();
|
|
7
12
|
|
|
8
13
|
const setupConnection = async () => {
|
|
@@ -100,8 +105,10 @@ const mainMenu = async (): Promise<boolean> => {
|
|
|
100
105
|
return false;
|
|
101
106
|
}
|
|
102
107
|
return true;
|
|
103
|
-
}
|
|
108
|
+
};
|
|
104
109
|
|
|
110
|
+
// ignore SIGINTs to continue after Nebula is disconnected
|
|
111
|
+
process.on("SIGINT", () => {});
|
|
105
112
|
await installNebula();
|
|
106
113
|
try {
|
|
107
114
|
while (true) {
|