elestio 1.0.2 → 1.0.3
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/LICENSE +21 -21
- package/README.md +279 -264
- package/bin/elestio.js +5 -5
- package/package.json +42 -42
- package/src/api.js +105 -105
- package/src/cli.js +838 -829
- package/src/commands/access.js +132 -132
- package/src/commands/actions.js +427 -427
- package/src/commands/auth.js +146 -146
- package/src/commands/backups.js +215 -215
- package/src/commands/billing.js +106 -106
- package/src/commands/cicd.js +486 -484
- package/src/commands/projects.js +145 -145
- package/src/commands/services.js +294 -294
- package/src/commands/templates.js +188 -188
- package/src/commands/volumes.js +117 -117
- package/src/config.js +84 -84
- package/src/utils.js +162 -162
package/src/commands/access.js
CHANGED
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
import { apiRequest } from '../api.js';
|
|
2
|
-
import { loadConfig } from '../config.js';
|
|
3
|
-
import { log, colors, outputJson } from '../utils.js';
|
|
4
|
-
import { getServiceDetails } from './services.js';
|
|
5
|
-
|
|
6
|
-
export async function getCredentials(vmID, projectId = null, json = false) {
|
|
7
|
-
const config = loadConfig();
|
|
8
|
-
const pid = projectId || config.defaultProject;
|
|
9
|
-
if (!pid) throw new Error('Project ID required');
|
|
10
|
-
|
|
11
|
-
const serviceInfo = await getServiceDetails(vmID, pid);
|
|
12
|
-
if (!serviceInfo) throw new Error('Failed to get service details');
|
|
13
|
-
|
|
14
|
-
const targetPort = serviceInfo.adminInternalPort || 8080;
|
|
15
|
-
const srvPort = serviceInfo.adminExternalPort || 443;
|
|
16
|
-
|
|
17
|
-
const response = await apiRequest('/api/servers/getAppCredentials', 'POST', {
|
|
18
|
-
vmID: String(vmID), targetPort, srvPort,
|
|
19
|
-
projectID: String(pid), appID: 'CloudVM',
|
|
20
|
-
isServerDeleted: false, mode: 'dbAdmin'
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!response.url) throw new Error(response.message || 'Failed to get credentials');
|
|
24
|
-
|
|
25
|
-
if (json) {
|
|
26
|
-
outputJson({
|
|
27
|
-
service: { name: serviceInfo.displayName, type: serviceInfo.serverType, ip: serviceInfo.ipv4 },
|
|
28
|
-
credentials: { url: response.url, user: response.user, password: response.password },
|
|
29
|
-
database: serviceInfo.managedDBPort ? {
|
|
30
|
-
host: serviceInfo.cname, port: serviceInfo.managedDBPort
|
|
31
|
-
} : null
|
|
32
|
-
});
|
|
33
|
-
return response;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
console.log(`\n${colors.bold}Service Info${colors.reset}\n`);
|
|
37
|
-
console.log(` Name: ${serviceInfo.displayName}`);
|
|
38
|
-
console.log(` Type: ${serviceInfo.serverType} (${serviceInfo.cores} CPU / ${serviceInfo.ramGB} GB RAM)`);
|
|
39
|
-
console.log(` Status: ${serviceInfo.status}`);
|
|
40
|
-
console.log(` IP: ${serviceInfo.ipv4}`);
|
|
41
|
-
console.log(`\n${colors.bold}App Credentials${colors.reset}\n`);
|
|
42
|
-
console.log(` URL: ${colors.cyan}${response.url}${colors.reset}`);
|
|
43
|
-
console.log(` User: ${response.user || 'N/A'}`);
|
|
44
|
-
console.log(` Password: ${response.password || 'N/A'}`);
|
|
45
|
-
|
|
46
|
-
if (serviceInfo.managedDBPort) {
|
|
47
|
-
console.log(`\n${colors.bold}Database Connection${colors.reset}`);
|
|
48
|
-
console.log(` Host: ${serviceInfo.cname}`);
|
|
49
|
-
console.log(` Port: ${serviceInfo.managedDBPort}`);
|
|
50
|
-
}
|
|
51
|
-
console.log('');
|
|
52
|
-
return response;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export async function getSSH(vmID, projectId = null, json = false) {
|
|
56
|
-
const config = loadConfig();
|
|
57
|
-
const pid = projectId || config.defaultProject;
|
|
58
|
-
if (!pid) throw new Error('Project ID required');
|
|
59
|
-
|
|
60
|
-
const response = await apiRequest('/api/servers/startSSHDirect', 'POST', {
|
|
61
|
-
vmID: String(vmID), projectID: String(pid), path: '/root/'
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (!response.url) throw new Error(response.message || 'Failed to get SSH access');
|
|
65
|
-
|
|
66
|
-
if (json) { outputJson({ url: response.url }); return response; }
|
|
67
|
-
|
|
68
|
-
console.log(`\n${colors.bold}SSH Access${colors.reset}\n`);
|
|
69
|
-
console.log(` Web Terminal: ${colors.cyan}${response.url}${colors.reset}`);
|
|
70
|
-
console.log('');
|
|
71
|
-
return response;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function getSSHDirect(vmID, json = false) {
|
|
75
|
-
const response = await apiRequest('/api/servers/startSSHDirect', 'POST', { vmID: String(vmID) });
|
|
76
|
-
if (response.status !== 'OK' && !response.ip) throw new Error(response.message || 'Failed to get SSH info');
|
|
77
|
-
|
|
78
|
-
if (json) {
|
|
79
|
-
outputJson({ host: response.ip || response.host, port: response.port || 22, user: response.user || 'root' });
|
|
80
|
-
return response;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
console.log(`\n${colors.bold}Direct SSH${colors.reset}\n`);
|
|
84
|
-
console.log(` Host: ${response.ip || response.host || 'N/A'}`);
|
|
85
|
-
console.log(` Port: ${response.port || 22}`);
|
|
86
|
-
console.log(` User: ${response.user || 'root'}`);
|
|
87
|
-
console.log(`\n ${colors.dim}ssh ${response.user || 'root'}@${response.ip || response.host} -p ${response.port || 22}${colors.reset}`);
|
|
88
|
-
console.log('');
|
|
89
|
-
return response;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export async function getVSCode(vmID, projectId = null, json = false) {
|
|
93
|
-
const config = loadConfig();
|
|
94
|
-
const pid = projectId || config.defaultProject;
|
|
95
|
-
if (!pid) throw new Error('Project ID required');
|
|
96
|
-
|
|
97
|
-
const response = await apiRequest('/api/servers/startVSCode', 'POST', {
|
|
98
|
-
vmID: String(vmID), projectID: String(pid)
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
if (!response.url) throw new Error(response.message || 'Failed to get VSCode access');
|
|
102
|
-
|
|
103
|
-
if (json) { outputJson({ url: response.url, user: response.user, password: response.password }); return response; }
|
|
104
|
-
|
|
105
|
-
console.log(`\n${colors.bold}VSCode Web Access${colors.reset}\n`);
|
|
106
|
-
console.log(` URL: ${colors.cyan}${response.url}${colors.reset}`);
|
|
107
|
-
console.log(` User: ${response.user || 'N/A'}`);
|
|
108
|
-
console.log(` Password: ${response.password || 'N/A'}`);
|
|
109
|
-
console.log('');
|
|
110
|
-
return response;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export async function getFileExplorer(vmID, projectId = null, json = false) {
|
|
114
|
-
const config = loadConfig();
|
|
115
|
-
const pid = projectId || config.defaultProject;
|
|
116
|
-
if (!pid) throw new Error('Project ID required');
|
|
117
|
-
|
|
118
|
-
const response = await apiRequest('/api/servers/startFileExplorer', 'POST', {
|
|
119
|
-
vmID: String(vmID), projectID: String(pid)
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
if (!response.url) throw new Error(response.message || 'Failed to get File Explorer access');
|
|
123
|
-
|
|
124
|
-
if (json) { outputJson({ url: response.url, user: response.user, password: response.password }); return response; }
|
|
125
|
-
|
|
126
|
-
console.log(`\n${colors.bold}File Explorer Access${colors.reset}\n`);
|
|
127
|
-
console.log(` URL: ${colors.cyan}${response.url}${colors.reset}`);
|
|
128
|
-
console.log(` User: ${response.user || 'N/A'}`);
|
|
129
|
-
console.log(` Password: ${response.password || 'N/A'}`);
|
|
130
|
-
console.log('');
|
|
131
|
-
return response;
|
|
132
|
-
}
|
|
1
|
+
import { apiRequest } from '../api.js';
|
|
2
|
+
import { loadConfig } from '../config.js';
|
|
3
|
+
import { log, colors, outputJson } from '../utils.js';
|
|
4
|
+
import { getServiceDetails } from './services.js';
|
|
5
|
+
|
|
6
|
+
export async function getCredentials(vmID, projectId = null, json = false) {
|
|
7
|
+
const config = loadConfig();
|
|
8
|
+
const pid = projectId || config.defaultProject;
|
|
9
|
+
if (!pid) throw new Error('Project ID required');
|
|
10
|
+
|
|
11
|
+
const serviceInfo = await getServiceDetails(vmID, pid);
|
|
12
|
+
if (!serviceInfo) throw new Error('Failed to get service details');
|
|
13
|
+
|
|
14
|
+
const targetPort = serviceInfo.adminInternalPort || 8080;
|
|
15
|
+
const srvPort = serviceInfo.adminExternalPort || 443;
|
|
16
|
+
|
|
17
|
+
const response = await apiRequest('/api/servers/getAppCredentials', 'POST', {
|
|
18
|
+
vmID: String(vmID), targetPort, srvPort,
|
|
19
|
+
projectID: String(pid), appID: 'CloudVM',
|
|
20
|
+
isServerDeleted: false, mode: 'dbAdmin'
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (!response.url) throw new Error(response.message || 'Failed to get credentials');
|
|
24
|
+
|
|
25
|
+
if (json) {
|
|
26
|
+
outputJson({
|
|
27
|
+
service: { name: serviceInfo.displayName, type: serviceInfo.serverType, ip: serviceInfo.ipv4 },
|
|
28
|
+
credentials: { url: response.url, user: response.user, password: response.password },
|
|
29
|
+
database: serviceInfo.managedDBPort ? {
|
|
30
|
+
host: serviceInfo.cname, port: serviceInfo.managedDBPort
|
|
31
|
+
} : null
|
|
32
|
+
});
|
|
33
|
+
return response;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log(`\n${colors.bold}Service Info${colors.reset}\n`);
|
|
37
|
+
console.log(` Name: ${serviceInfo.displayName}`);
|
|
38
|
+
console.log(` Type: ${serviceInfo.serverType} (${serviceInfo.cores} CPU / ${serviceInfo.ramGB} GB RAM)`);
|
|
39
|
+
console.log(` Status: ${serviceInfo.status}`);
|
|
40
|
+
console.log(` IP: ${serviceInfo.ipv4}`);
|
|
41
|
+
console.log(`\n${colors.bold}App Credentials${colors.reset}\n`);
|
|
42
|
+
console.log(` URL: ${colors.cyan}${response.url}${colors.reset}`);
|
|
43
|
+
console.log(` User: ${response.user || 'N/A'}`);
|
|
44
|
+
console.log(` Password: ${response.password || 'N/A'}`);
|
|
45
|
+
|
|
46
|
+
if (serviceInfo.managedDBPort) {
|
|
47
|
+
console.log(`\n${colors.bold}Database Connection${colors.reset}`);
|
|
48
|
+
console.log(` Host: ${serviceInfo.cname}`);
|
|
49
|
+
console.log(` Port: ${serviceInfo.managedDBPort}`);
|
|
50
|
+
}
|
|
51
|
+
console.log('');
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function getSSH(vmID, projectId = null, json = false) {
|
|
56
|
+
const config = loadConfig();
|
|
57
|
+
const pid = projectId || config.defaultProject;
|
|
58
|
+
if (!pid) throw new Error('Project ID required');
|
|
59
|
+
|
|
60
|
+
const response = await apiRequest('/api/servers/startSSHDirect', 'POST', {
|
|
61
|
+
vmID: String(vmID), projectID: String(pid), path: '/root/'
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!response.url) throw new Error(response.message || 'Failed to get SSH access');
|
|
65
|
+
|
|
66
|
+
if (json) { outputJson({ url: response.url }); return response; }
|
|
67
|
+
|
|
68
|
+
console.log(`\n${colors.bold}SSH Access${colors.reset}\n`);
|
|
69
|
+
console.log(` Web Terminal: ${colors.cyan}${response.url}${colors.reset}`);
|
|
70
|
+
console.log('');
|
|
71
|
+
return response;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function getSSHDirect(vmID, json = false) {
|
|
75
|
+
const response = await apiRequest('/api/servers/startSSHDirect', 'POST', { vmID: String(vmID) });
|
|
76
|
+
if (response.status !== 'OK' && !response.ip) throw new Error(response.message || 'Failed to get SSH info');
|
|
77
|
+
|
|
78
|
+
if (json) {
|
|
79
|
+
outputJson({ host: response.ip || response.host, port: response.port || 22, user: response.user || 'root' });
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log(`\n${colors.bold}Direct SSH${colors.reset}\n`);
|
|
84
|
+
console.log(` Host: ${response.ip || response.host || 'N/A'}`);
|
|
85
|
+
console.log(` Port: ${response.port || 22}`);
|
|
86
|
+
console.log(` User: ${response.user || 'root'}`);
|
|
87
|
+
console.log(`\n ${colors.dim}ssh ${response.user || 'root'}@${response.ip || response.host} -p ${response.port || 22}${colors.reset}`);
|
|
88
|
+
console.log('');
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function getVSCode(vmID, projectId = null, json = false) {
|
|
93
|
+
const config = loadConfig();
|
|
94
|
+
const pid = projectId || config.defaultProject;
|
|
95
|
+
if (!pid) throw new Error('Project ID required');
|
|
96
|
+
|
|
97
|
+
const response = await apiRequest('/api/servers/startVSCode', 'POST', {
|
|
98
|
+
vmID: String(vmID), projectID: String(pid)
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (!response.url) throw new Error(response.message || 'Failed to get VSCode access');
|
|
102
|
+
|
|
103
|
+
if (json) { outputJson({ url: response.url, user: response.user, password: response.password }); return response; }
|
|
104
|
+
|
|
105
|
+
console.log(`\n${colors.bold}VSCode Web Access${colors.reset}\n`);
|
|
106
|
+
console.log(` URL: ${colors.cyan}${response.url}${colors.reset}`);
|
|
107
|
+
console.log(` User: ${response.user || 'N/A'}`);
|
|
108
|
+
console.log(` Password: ${response.password || 'N/A'}`);
|
|
109
|
+
console.log('');
|
|
110
|
+
return response;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export async function getFileExplorer(vmID, projectId = null, json = false) {
|
|
114
|
+
const config = loadConfig();
|
|
115
|
+
const pid = projectId || config.defaultProject;
|
|
116
|
+
if (!pid) throw new Error('Project ID required');
|
|
117
|
+
|
|
118
|
+
const response = await apiRequest('/api/servers/startFileExplorer', 'POST', {
|
|
119
|
+
vmID: String(vmID), projectID: String(pid)
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (!response.url) throw new Error(response.message || 'Failed to get File Explorer access');
|
|
123
|
+
|
|
124
|
+
if (json) { outputJson({ url: response.url, user: response.user, password: response.password }); return response; }
|
|
125
|
+
|
|
126
|
+
console.log(`\n${colors.bold}File Explorer Access${colors.reset}\n`);
|
|
127
|
+
console.log(` URL: ${colors.cyan}${response.url}${colors.reset}`);
|
|
128
|
+
console.log(` User: ${response.user || 'N/A'}`);
|
|
129
|
+
console.log(` Password: ${response.password || 'N/A'}`);
|
|
130
|
+
console.log('');
|
|
131
|
+
return response;
|
|
132
|
+
}
|