onedeploy-cli 0.1.7 → 0.1.8
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 +0 -0
- package/dist/nebula.js +1 -1
- package/package.json +5 -5
- package/src/index.ts +126 -0
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/nebula.js
CHANGED
|
@@ -30,7 +30,7 @@ const getNebulaPackageName = () => {
|
|
|
30
30
|
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
const nebulaVersion = "v1.
|
|
33
|
+
const nebulaVersion = "v1.10.0";
|
|
34
34
|
const packageName = getNebulaPackageName();
|
|
35
35
|
const nebulaUrl = `https://github.com/slackhq/nebula/releases/download/${nebulaVersion}/${packageName}`;
|
|
36
36
|
const tmpDir = path.join(tmpdir(), `onedeploy-${randomUUID()}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onedeploy-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "CLI tool for connecting to OneDeploy via Nebula",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"onedeploy",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"fix": "biome check src/* --fix"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@biomejs/biome": "^2.3.
|
|
36
|
-
"@types/node": "^
|
|
35
|
+
"@biomejs/biome": "^2.3.8",
|
|
36
|
+
"@types/node": "^25.0.1",
|
|
37
37
|
"@types/prompts": "^2.4.9",
|
|
38
38
|
"typescript": "^5.9.3"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"prompts": "^2.4.2",
|
|
42
|
-
"yaml": "^2.8.
|
|
43
|
-
"yedra": "^0.
|
|
42
|
+
"yaml": "^2.8.2",
|
|
43
|
+
"yedra": "^0.19.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
if (result.url === undefined) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
config.instances.push({ url: result.url });
|
|
30
|
+
await saveConfig(config);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const removeConnection = async () => {
|
|
34
|
+
const { connection } = await prompts([
|
|
35
|
+
{
|
|
36
|
+
type: "select",
|
|
37
|
+
name: "connection",
|
|
38
|
+
message: "Select connection to remove",
|
|
39
|
+
choices: config.instances.map((instance, index) => ({
|
|
40
|
+
title: instance.url,
|
|
41
|
+
value: index,
|
|
42
|
+
})),
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
if (connection === undefined) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const { confirm } = await prompts([
|
|
49
|
+
{
|
|
50
|
+
type: "confirm",
|
|
51
|
+
name: "confirm",
|
|
52
|
+
message: `Are you sure you want to remove connection to ${config.instances[connection].url}?`,
|
|
53
|
+
initial: false,
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
if (confirm === true) {
|
|
57
|
+
config.instances.splice(connection, 1);
|
|
58
|
+
await saveConfig(config);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const mainMenu = async (): Promise<boolean> => {
|
|
63
|
+
const { action } = await prompts([
|
|
64
|
+
{
|
|
65
|
+
type: "select",
|
|
66
|
+
name: "action",
|
|
67
|
+
message: "What do you want to do?",
|
|
68
|
+
choices: [
|
|
69
|
+
{
|
|
70
|
+
title: "Connect",
|
|
71
|
+
value: "connect",
|
|
72
|
+
disabled: config.instances.length === 0,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
title: "Setup new connection",
|
|
76
|
+
value: "setup",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: "Remove connection",
|
|
80
|
+
value: "remove",
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
if (action === "connect") {
|
|
86
|
+
const result = await prompts([
|
|
87
|
+
{
|
|
88
|
+
type: "select",
|
|
89
|
+
name: "connection",
|
|
90
|
+
message: "Select OneDeploy instance",
|
|
91
|
+
choices: config.instances.map((instance) => ({
|
|
92
|
+
title: instance.url,
|
|
93
|
+
value: instance,
|
|
94
|
+
})),
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
if (result.connection !== undefined) {
|
|
98
|
+
await connectNebula(result.connection);
|
|
99
|
+
}
|
|
100
|
+
} else if (action === "setup") {
|
|
101
|
+
await setupConnection();
|
|
102
|
+
} else if (action === "remove") {
|
|
103
|
+
await removeConnection();
|
|
104
|
+
} else {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
process.on("SIGINT", () => {
|
|
111
|
+
if (!isNebulaRunning) {
|
|
112
|
+
process.exit();
|
|
113
|
+
}
|
|
114
|
+
// ignore SIGINTs to continue after Nebula is disconnected
|
|
115
|
+
});
|
|
116
|
+
await installNebula();
|
|
117
|
+
try {
|
|
118
|
+
while (true) {
|
|
119
|
+
const shouldContinue = await mainMenu();
|
|
120
|
+
if (!shouldContinue) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} finally {
|
|
125
|
+
await cleanupNebula();
|
|
126
|
+
}
|