onedeploy-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/index.js CHANGED
File without changes
package/dist/nebula.js CHANGED
@@ -9,10 +9,15 @@ import { parse } from "yaml";
9
9
  const getNebulaPackageName = () => {
10
10
  switch (process.platform) {
11
11
  case "linux":
12
- if (process.arch !== "x64") {
12
+ if (process.arch === "x64") {
13
+ return `nebula-linux-amd64.tar.gz`;
14
+ }
15
+ else if (process.arch === "arm64") {
16
+ return `nebula-linux-arm64.tar.gz`;
17
+ }
18
+ else {
13
19
  throw new Error(`Unsupported architecture: ${process.arch}`);
14
20
  }
15
- return `nebula-linux-amd64.tar.gz`;
16
21
  case "darwin":
17
22
  return `nebula-darwin.zip`;
18
23
  case "win32":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onedeploy-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "CLI tool for connecting to OneDeploy via Nebula",
5
5
  "keywords": [
6
6
  "onedeploy",
package/src/index.ts ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ import prompts from "prompts";
3
+ import { loadConfig, saveConfig } from "./config.js";
4
+ import {
5
+ cleanupNebula,
6
+ connectNebula,
7
+ installNebula,
8
+ isNebulaRunning,
9
+ } from "./nebula.js";
10
+
11
+ if (process.argv.includes("--version")) {
12
+ console.log("onedeploy-cli version 0.1.4");
13
+ process.exit();
14
+ }
15
+
16
+ const config = await loadConfig();
17
+
18
+ const setupConnection = async () => {
19
+ const result = await prompts([
20
+ {
21
+ type: "text",
22
+ name: "url",
23
+ message: "Enter OneDeploy URL",
24
+ },
25
+ {
26
+ type: "password",
27
+ name: "apiKey",
28
+ message: "Enter OneDeploy API key",
29
+ },
30
+ ]);
31
+ if (result.apiKey === undefined || result.url === undefined) {
32
+ return;
33
+ }
34
+ config.instances.push({ url: result.url, apiKey: result.apiKey });
35
+ await saveConfig(config);
36
+ };
37
+
38
+ const removeConnection = async () => {
39
+ const { connection } = await prompts([
40
+ {
41
+ type: "select",
42
+ name: "connection",
43
+ message: "Select connection to remove",
44
+ choices: config.instances.map((instance, index) => ({
45
+ title: instance.url,
46
+ value: index,
47
+ })),
48
+ },
49
+ ]);
50
+ if (connection === undefined) {
51
+ return;
52
+ }
53
+ const { confirm } = await prompts([
54
+ {
55
+ type: "confirm",
56
+ name: "confirm",
57
+ message: `Are you sure you want to remove connection to ${config.instances[connection].url}?`,
58
+ initial: false,
59
+ },
60
+ ]);
61
+ if (confirm === true) {
62
+ config.instances.splice(connection, 1);
63
+ await saveConfig(config);
64
+ }
65
+ };
66
+
67
+ const mainMenu = async (): Promise<boolean> => {
68
+ const { action } = await prompts([
69
+ {
70
+ type: "select",
71
+ name: "action",
72
+ message: "What do you want to do?",
73
+ choices: [
74
+ {
75
+ title: "Connect",
76
+ value: "connect",
77
+ disabled: config.instances.length === 0,
78
+ },
79
+ {
80
+ title: "Setup new connection",
81
+ value: "setup",
82
+ },
83
+ {
84
+ title: "Remove connection",
85
+ value: "remove",
86
+ },
87
+ ],
88
+ },
89
+ ]);
90
+ if (action === "connect") {
91
+ const result = await prompts([
92
+ {
93
+ type: "select",
94
+ name: "connection",
95
+ message: "Select OneDeploy instance",
96
+ choices: config.instances.map((instance) => ({
97
+ title: instance.url,
98
+ value: instance,
99
+ })),
100
+ },
101
+ ]);
102
+ if (result.connection !== undefined) {
103
+ await connectNebula(result.connection);
104
+ }
105
+ } else if (action === "setup") {
106
+ await setupConnection();
107
+ } else if (action === "remove") {
108
+ await removeConnection();
109
+ } else {
110
+ return false;
111
+ }
112
+ return true;
113
+ };
114
+
115
+ process.on("SIGINT", () => {
116
+ if (!isNebulaRunning) {
117
+ process.exit();
118
+ }
119
+ // ignore SIGINTs to continue after Nebula is disconnected
120
+ });
121
+ await installNebula();
122
+ try {
123
+ while (true) {
124
+ const shouldContinue = await mainMenu();
125
+ if (!shouldContinue) {
126
+ break;
127
+ }
128
+ }
129
+ } finally {
130
+ await cleanupNebula();
131
+ }