onedeploy-cli 0.1.3 → 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/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("Downloading Nebula...");
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("Extracting Nebula...");
39
+ console.log(`Extracting Nebula to ${tmpDir}/nebula...`);
39
40
  await promisify(execFile)("tar", [
40
41
  "-xf",
41
42
  `${tmpDir}/${packageName}`,
@@ -58,6 +59,15 @@ 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);
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);
61
71
  };
62
72
  export const connectNebula = async (instance) => {
63
73
  await getNebulaCert(instance);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onedeploy-cli",
3
- "version": "0.1.3",
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 () => {
@@ -102,6 +107,8 @@ const mainMenu = async (): Promise<boolean> => {
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) {