bdy 1.15.7-dev-package → 1.16.0-dev
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/distTs/package.json +1 -1
- package/distTs/src/agent/agent.js +28 -56
- package/distTs/src/agent/linux.js +22 -23
- package/distTs/src/agent/manager.js +12 -105
- package/distTs/src/agent/osx.js +22 -27
- package/distTs/src/agent/socket/client.js +4 -4
- package/distTs/src/agent/system.js +89 -21
- package/distTs/src/agent/windows.js +21 -32
- package/distTs/src/api/client.js +25 -101
- package/distTs/src/command/agent/debug.js +10 -3
- package/distTs/src/command/agent/disable.js +6 -6
- package/distTs/src/command/agent/enable.js +6 -6
- package/distTs/src/command/agent/install.js +106 -27
- package/distTs/src/command/agent/restart.js +21 -11
- package/distTs/src/command/agent/run.js +1 -1
- package/distTs/src/command/agent/standalone/kill.js +22 -0
- package/distTs/src/command/agent/standalone.js +136 -0
- package/distTs/src/command/agent/start.js +19 -12
- package/distTs/src/command/agent/status.js +44 -17
- package/distTs/src/command/agent/stop.js +20 -13
- package/distTs/src/command/agent/target/disable.js +6 -6
- package/distTs/src/command/agent/target/enable.js +6 -6
- package/distTs/src/command/agent/target/status.js +6 -6
- package/distTs/src/command/agent/tunnel/http.js +6 -6
- package/distTs/src/command/agent/tunnel/list.js +6 -6
- package/distTs/src/command/agent/tunnel/remove.js +6 -6
- package/distTs/src/command/agent/tunnel/start.js +7 -7
- package/distTs/src/command/agent/tunnel/status.js +6 -6
- package/distTs/src/command/agent/tunnel/tcp.js +6 -6
- package/distTs/src/command/agent/tunnel/tls.js +6 -6
- package/distTs/src/command/agent/uninstall.js +2 -2
- package/distTs/src/command/agent/update.js +19 -17
- package/distTs/src/command/agent/version.js +3 -5
- package/distTs/src/command/agent.js +0 -4
- package/distTs/src/command/pipeline/run.js +3 -3
- package/distTs/src/command/pre.js +10 -2
- package/distTs/src/command/vt/scrap.js +193 -0
- package/distTs/src/index.js +0 -2
- package/distTs/src/input.js +1 -24
- package/distTs/src/output.js +16 -4
- package/distTs/src/texts.js +22 -85
- package/distTs/src/tunnel/api/agent.js +0 -9
- package/distTs/src/types/tunnel.js +0 -3
- package/package.json +1 -1
- package/distTs/src/command/package/download.js +0 -259
- package/distTs/src/command/package/publish.js +0 -231
- package/distTs/src/command/package.js +0 -14
|
@@ -9,22 +9,26 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const texts_1 = require("../texts");
|
|
11
11
|
const logger_1 = __importDefault(require("../logger"));
|
|
12
|
+
const manager_1 = __importDefault(require("./manager"));
|
|
13
|
+
const output_1 = __importDefault(require("../output"));
|
|
12
14
|
class AgentSystem {
|
|
13
|
-
// extend
|
|
14
|
-
isEnabled() {
|
|
15
|
-
return Promise.resolve(false);
|
|
16
|
-
}
|
|
17
15
|
// extend
|
|
18
16
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
|
-
|
|
17
|
+
async install(id, host, token, port, start, user, pass, debug) {
|
|
20
18
|
return Promise.reject();
|
|
21
19
|
}
|
|
22
20
|
// extend
|
|
23
|
-
update() {
|
|
21
|
+
async update() {
|
|
24
22
|
return Promise.reject();
|
|
25
23
|
}
|
|
26
24
|
// extend
|
|
27
|
-
|
|
25
|
+
async uninstall() {
|
|
26
|
+
return Promise.reject();
|
|
27
|
+
}
|
|
28
|
+
async stop() {
|
|
29
|
+
return Promise.reject();
|
|
30
|
+
}
|
|
31
|
+
async start() {
|
|
28
32
|
return Promise.reject();
|
|
29
33
|
}
|
|
30
34
|
// extend
|
|
@@ -182,29 +186,83 @@ class AgentSystem {
|
|
|
182
186
|
return this.downloadFile(`https://es.buddy.works/bdy/${env}/${version}/${archive}`, archivePath);
|
|
183
187
|
}
|
|
184
188
|
killStandaloneProc() {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
189
|
+
return new Promise((resolve) => {
|
|
190
|
+
let pid = 0;
|
|
191
|
+
try {
|
|
192
|
+
const str = this.loadStandaloneProcConfig();
|
|
193
|
+
pid = Number.parseInt(str, 10);
|
|
194
|
+
if (pid) {
|
|
195
|
+
process.kill(pid);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// do nothing
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
this.clearStandaloneProcConfig();
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// do nothing
|
|
190
206
|
}
|
|
207
|
+
let tsInterval = null;
|
|
208
|
+
let tsTimeout = null;
|
|
209
|
+
const finish = () => {
|
|
210
|
+
if (tsInterval)
|
|
211
|
+
clearInterval(tsInterval);
|
|
212
|
+
if (tsTimeout)
|
|
213
|
+
clearTimeout(tsTimeout);
|
|
214
|
+
resolve();
|
|
215
|
+
};
|
|
216
|
+
if (!pid) {
|
|
217
|
+
finish();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
tsTimeout = setTimeout(finish, 30000);
|
|
221
|
+
tsInterval = setInterval(() => {
|
|
222
|
+
try {
|
|
223
|
+
process.kill(pid, 0);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
finish();
|
|
227
|
+
}
|
|
228
|
+
}, 100);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
startStandaloneProc() {
|
|
232
|
+
let json;
|
|
233
|
+
try {
|
|
234
|
+
json = this.loadSystemConfig();
|
|
191
235
|
}
|
|
192
236
|
catch {
|
|
193
|
-
|
|
237
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
194
238
|
}
|
|
195
|
-
|
|
196
|
-
|
|
239
|
+
if (json.debug) {
|
|
240
|
+
logger_1.default.setDebug(true);
|
|
197
241
|
}
|
|
198
|
-
|
|
199
|
-
|
|
242
|
+
const saved = this.saveStandaloneProcConfig();
|
|
243
|
+
if (!saved) {
|
|
244
|
+
output_1.default.exitError(texts_1.ERR_SWW_AGENT_ENABLING);
|
|
200
245
|
}
|
|
246
|
+
logger_1.default.changeRootPath(this.getNewAgentConfigDir());
|
|
247
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_STARTED);
|
|
248
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_STARTED);
|
|
249
|
+
const onProcessExit = () => {
|
|
250
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_EXITING);
|
|
251
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_EXITING);
|
|
252
|
+
this.clearStandaloneProcConfig();
|
|
253
|
+
process.exit(0);
|
|
254
|
+
};
|
|
255
|
+
process.on('SIGINT', onProcessExit);
|
|
256
|
+
process.on('SIGTERM', onProcessExit);
|
|
257
|
+
process.on('SIGQUIT', onProcessExit);
|
|
258
|
+
manager_1.default.start(json.id, json.host, json.token, json.port);
|
|
201
259
|
}
|
|
202
260
|
clearStandaloneProcConfig() {
|
|
203
261
|
try {
|
|
204
262
|
logger_1.default.info(texts_1.LOG_REMOVING_AGENT_PROC_ID);
|
|
205
263
|
this.ensureSystemConfigDir();
|
|
206
264
|
(0, fs_1.rmSync)(this.getSystemStandalonePath(), {
|
|
207
|
-
force: true
|
|
265
|
+
force: true,
|
|
208
266
|
});
|
|
209
267
|
return true;
|
|
210
268
|
}
|
|
@@ -227,7 +285,16 @@ class AgentSystem {
|
|
|
227
285
|
return false;
|
|
228
286
|
}
|
|
229
287
|
}
|
|
230
|
-
|
|
288
|
+
hasSystemConfig() {
|
|
289
|
+
try {
|
|
290
|
+
this.loadSystemConfig();
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
saveSystemConfig(id, host, token, port, standalone, debug) {
|
|
231
298
|
try {
|
|
232
299
|
logger_1.default.info(texts_1.LOG_SAVING_AGENT_SYSTEM_CONFIG);
|
|
233
300
|
this.ensureSystemConfigDir();
|
|
@@ -236,6 +303,8 @@ class AgentSystem {
|
|
|
236
303
|
host,
|
|
237
304
|
token,
|
|
238
305
|
port,
|
|
306
|
+
standalone,
|
|
307
|
+
debug
|
|
239
308
|
}), 'utf-8');
|
|
240
309
|
return true;
|
|
241
310
|
}
|
|
@@ -245,7 +314,7 @@ class AgentSystem {
|
|
|
245
314
|
return false;
|
|
246
315
|
}
|
|
247
316
|
}
|
|
248
|
-
saveNewAgentConfig(
|
|
317
|
+
saveNewAgentConfig(sshHostKey) {
|
|
249
318
|
try {
|
|
250
319
|
this.clearAgentFiles();
|
|
251
320
|
}
|
|
@@ -255,7 +324,6 @@ class AgentSystem {
|
|
|
255
324
|
try {
|
|
256
325
|
logger_1.default.info(texts_1.LOG_SAVING_AGENT_LOCAL_CONFIG);
|
|
257
326
|
(0, fs_1.writeFileSync)(this.getNewAgentConfigPath(), JSON.stringify({
|
|
258
|
-
shouldStart,
|
|
259
327
|
sshHostKey,
|
|
260
328
|
}), 'utf-8');
|
|
261
329
|
return true;
|
|
@@ -20,21 +20,6 @@ class AgentWindows extends system_1.default {
|
|
|
20
20
|
isSupported() {
|
|
21
21
|
return Promise.resolve(process.arch === 'x64');
|
|
22
22
|
}
|
|
23
|
-
isEnabled() {
|
|
24
|
-
return new Promise((resolve) => {
|
|
25
|
-
if (this.isStandaloneProcRunning()) {
|
|
26
|
-
resolve(true);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.sc('query bdy')
|
|
30
|
-
.then(() => {
|
|
31
|
-
resolve(true);
|
|
32
|
-
})
|
|
33
|
-
.catch(() => {
|
|
34
|
-
resolve(false);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
23
|
getBinaryArchive() {
|
|
39
24
|
return 'win-x64.zip';
|
|
40
25
|
}
|
|
@@ -79,7 +64,7 @@ class AgentWindows extends system_1.default {
|
|
|
79
64
|
async update() {
|
|
80
65
|
try {
|
|
81
66
|
logger_1.default.info(texts_1.LOG_AGENT_STOPPING_SYSTEM);
|
|
82
|
-
await this.
|
|
67
|
+
await this.stop();
|
|
83
68
|
logger_1.default.info(texts_1.LOG_AGENT_SYSTEM_DIR);
|
|
84
69
|
await this.ensureSystemConfigDir();
|
|
85
70
|
logger_1.default.info(texts_1.LOG_AGENT_DOWNLOADING_ARCHIVE);
|
|
@@ -88,7 +73,7 @@ class AgentWindows extends system_1.default {
|
|
|
88
73
|
await this.extractBinaryArchive();
|
|
89
74
|
try {
|
|
90
75
|
logger_1.default.info(texts_1.LOG_AGENT_STARTING_SYSTEM);
|
|
91
|
-
await this.
|
|
76
|
+
await this.start();
|
|
92
77
|
}
|
|
93
78
|
catch {
|
|
94
79
|
// do nothing, it will throw operation pending
|
|
@@ -99,7 +84,14 @@ class AgentWindows extends system_1.default {
|
|
|
99
84
|
throw err;
|
|
100
85
|
}
|
|
101
86
|
}
|
|
102
|
-
async
|
|
87
|
+
async install(id, host, token, port, start, user, pass, debug) {
|
|
88
|
+
try {
|
|
89
|
+
// ensure srv was clear
|
|
90
|
+
await this.uninstall();
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
// do nothing
|
|
94
|
+
}
|
|
103
95
|
try {
|
|
104
96
|
logger_1.default.info(texts_1.LOG_AGENT_SYSTEM_DIR);
|
|
105
97
|
await this.ensureSystemConfigDir();
|
|
@@ -115,7 +107,7 @@ class AgentWindows extends system_1.default {
|
|
|
115
107
|
await this.extractBinaryArchive();
|
|
116
108
|
logger_1.default.info(texts_1.LOG_AGENT_ENABLING_SYSTEM);
|
|
117
109
|
await this.nssm(`install bdy ${this.getSystemBinaryPath()}`);
|
|
118
|
-
await this.nssm(`set bdy AppParameters agent run --id="${id}" --host="${host}" --token="${token}" --port=${port}
|
|
110
|
+
await this.nssm(`set bdy AppParameters agent run --id="${id}" --host="${host}" --token="${token}" --port=${port}`);
|
|
119
111
|
await this.nssm('set bdy DisplayName Buddy Tunnel Agent');
|
|
120
112
|
await this.nssm('set bdy AppThrottle 5000');
|
|
121
113
|
await this.nssm('set bdy AppRestartDelay 0');
|
|
@@ -125,7 +117,8 @@ class AgentWindows extends system_1.default {
|
|
|
125
117
|
if (user && pass) {
|
|
126
118
|
await this.nssm(`set bdy ObjectName ${user} ${pass}`);
|
|
127
119
|
}
|
|
128
|
-
|
|
120
|
+
if (start)
|
|
121
|
+
await this.start();
|
|
129
122
|
logger_1.default.info(texts_1.LOG_AGENT_ENABLED);
|
|
130
123
|
}
|
|
131
124
|
catch (err) {
|
|
@@ -133,9 +126,15 @@ class AgentWindows extends system_1.default {
|
|
|
133
126
|
throw err;
|
|
134
127
|
}
|
|
135
128
|
}
|
|
136
|
-
async
|
|
129
|
+
async stop() {
|
|
130
|
+
await this.nssm('stop bdy');
|
|
131
|
+
}
|
|
132
|
+
async start() {
|
|
133
|
+
await this.nssm('start bdy');
|
|
134
|
+
}
|
|
135
|
+
async uninstall() {
|
|
137
136
|
try {
|
|
138
|
-
await this.
|
|
137
|
+
await this.stop();
|
|
139
138
|
}
|
|
140
139
|
catch {
|
|
141
140
|
// do nothing
|
|
@@ -152,15 +151,5 @@ class AgentWindows extends system_1.default {
|
|
|
152
151
|
});
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
|
-
sc(cmd) {
|
|
156
|
-
return new Promise((resolve, reject) => {
|
|
157
|
-
(0, child_process_1.exec)(`sc ${cmd}`, (err) => {
|
|
158
|
-
if (!err)
|
|
159
|
-
resolve();
|
|
160
|
-
else
|
|
161
|
-
reject(err);
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
154
|
}
|
|
166
155
|
exports.default = AgentWindows;
|
package/distTs/src/api/client.js
CHANGED
|
@@ -19,12 +19,26 @@ class ApiClient {
|
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
async
|
|
22
|
+
async request(method, path, body, parseResponseBody = false) {
|
|
23
|
+
const headers = {
|
|
24
|
+
authorization: `Bearer ${this.token}`,
|
|
25
|
+
};
|
|
26
|
+
let bodyParsed = undefined;
|
|
27
|
+
if (body) {
|
|
28
|
+
headers['content-type'] = 'application/json; charset=utf-8';
|
|
29
|
+
bodyParsed = JSON.stringify(body);
|
|
30
|
+
}
|
|
31
|
+
const opts = {
|
|
32
|
+
method,
|
|
33
|
+
path,
|
|
34
|
+
headers,
|
|
35
|
+
body: bodyParsed,
|
|
36
|
+
};
|
|
23
37
|
let status;
|
|
24
38
|
let responseBody;
|
|
25
|
-
logger_1.default.debug(`API CLIENT: ${
|
|
26
|
-
logger_1.default.debug(
|
|
27
|
-
logger_1.default.debug(
|
|
39
|
+
logger_1.default.debug(`API CLIENT: ${method} ${this.baseUrl.protocol}//${this.baseUrl.host}${path}`);
|
|
40
|
+
logger_1.default.debug(headers);
|
|
41
|
+
logger_1.default.debug(body);
|
|
28
42
|
try {
|
|
29
43
|
const r = await this.client.request(opts);
|
|
30
44
|
status = r.statusCode;
|
|
@@ -40,7 +54,11 @@ class ApiClient {
|
|
|
40
54
|
await responseBody.dump();
|
|
41
55
|
throw new Error(texts_1.ERR_REST_API_WRONG_TOKEN);
|
|
42
56
|
}
|
|
43
|
-
if (
|
|
57
|
+
if (status === 403) {
|
|
58
|
+
await responseBody.dump();
|
|
59
|
+
throw new Error(texts_1.ERR_REST_API_RATE_LIMIT);
|
|
60
|
+
}
|
|
61
|
+
if ([400, 404].includes(status)) {
|
|
44
62
|
let json;
|
|
45
63
|
try {
|
|
46
64
|
json = await responseBody.json();
|
|
@@ -61,7 +79,7 @@ class ApiClient {
|
|
|
61
79
|
else
|
|
62
80
|
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
63
81
|
}
|
|
64
|
-
if (
|
|
82
|
+
if (status === 200) {
|
|
65
83
|
if (parseResponseBody) {
|
|
66
84
|
try {
|
|
67
85
|
const b = await responseBody.json();
|
|
@@ -75,9 +93,6 @@ class ApiClient {
|
|
|
75
93
|
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
76
94
|
}
|
|
77
95
|
}
|
|
78
|
-
else if (returnRawBody) {
|
|
79
|
-
return responseBody;
|
|
80
|
-
}
|
|
81
96
|
else {
|
|
82
97
|
await responseBody.dump();
|
|
83
98
|
return null;
|
|
@@ -88,58 +103,8 @@ class ApiClient {
|
|
|
88
103
|
throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
|
-
async requestMultipart(path, body, parseResponseBody = false) {
|
|
92
|
-
const headers = {
|
|
93
|
-
authorization: `Bearer ${this.token}`,
|
|
94
|
-
};
|
|
95
|
-
const opts = {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
path,
|
|
98
|
-
headers,
|
|
99
|
-
body,
|
|
100
|
-
};
|
|
101
|
-
return await this._request(opts, parseResponseBody);
|
|
102
|
-
}
|
|
103
|
-
async request(method, path, body, parseResponseBody = false, returnRawBody = false) {
|
|
104
|
-
const headers = {
|
|
105
|
-
authorization: `Bearer ${this.token}`,
|
|
106
|
-
};
|
|
107
|
-
let bodyParsed = undefined;
|
|
108
|
-
if (body) {
|
|
109
|
-
headers['content-type'] = 'application/json; charset=utf-8';
|
|
110
|
-
bodyParsed = JSON.stringify(body);
|
|
111
|
-
}
|
|
112
|
-
const opts = {
|
|
113
|
-
method,
|
|
114
|
-
path,
|
|
115
|
-
headers,
|
|
116
|
-
body: bodyParsed,
|
|
117
|
-
};
|
|
118
|
-
return await this._request(opts, parseResponseBody, returnRawBody);
|
|
119
|
-
}
|
|
120
|
-
async getResourceByIdentifier(workspace, params) {
|
|
121
|
-
let query = '';
|
|
122
|
-
Object.keys(params).forEach((key) => {
|
|
123
|
-
if (!query)
|
|
124
|
-
query += '?';
|
|
125
|
-
else
|
|
126
|
-
query += '&';
|
|
127
|
-
query += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
|
|
128
|
-
});
|
|
129
|
-
return await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/identifiers${query}`, null, true);
|
|
130
|
-
}
|
|
131
106
|
async getPipelineByIdentifier(workspace, project, identifier) {
|
|
132
|
-
return await this.
|
|
133
|
-
}
|
|
134
|
-
async getPackageVersionByIdentifier(workspace, project, pkg, version) {
|
|
135
|
-
const opts = {
|
|
136
|
-
package: pkg,
|
|
137
|
-
};
|
|
138
|
-
if (project)
|
|
139
|
-
opts.project = project;
|
|
140
|
-
if (version)
|
|
141
|
-
opts.package_version = version;
|
|
142
|
-
return await this.getResourceByIdentifier(workspace, opts);
|
|
107
|
+
return await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/identifiers?project=${encodeURIComponent(project)}&pipeline=${encodeURIComponent(identifier)}`, null, true);
|
|
143
108
|
}
|
|
144
109
|
async getPipelineRun(workspace, project, pipelineId, executionId) {
|
|
145
110
|
return await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(executionId)}`, null, true);
|
|
@@ -147,46 +112,5 @@ class ApiClient {
|
|
|
147
112
|
async postPipelineRun(workspace, project, pipelineId, body) {
|
|
148
113
|
return await this.request('POST', `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions`, body, true);
|
|
149
114
|
}
|
|
150
|
-
async getPackageVersion(workspace, pkgId, versionId) {
|
|
151
|
-
return await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${encodeURIComponent(versionId)}`, null, true);
|
|
152
|
-
}
|
|
153
|
-
async getPackageLatest(workspace, pkgId) {
|
|
154
|
-
const res = await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions?page=1&per_page=1`, null, true);
|
|
155
|
-
if (res && res.versions && res.versions.length > 0) {
|
|
156
|
-
return res.versions[0];
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
async downloadPackageVersion(workspace, pkgId, versionId) {
|
|
161
|
-
return await this.request('GET', `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${encodeURIComponent(versionId)}/download`, null, false, true);
|
|
162
|
-
}
|
|
163
|
-
async postPackageVersion(workspace, pkgId, version) {
|
|
164
|
-
return await this.request('POST', `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions`, {
|
|
165
|
-
version
|
|
166
|
-
}, true);
|
|
167
|
-
}
|
|
168
|
-
async postPackageVersionZip(workspace, pkgId, versionId, file) {
|
|
169
|
-
const form = new undici_1.FormData();
|
|
170
|
-
form.append('file', file);
|
|
171
|
-
return await this.requestMultipart(`/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${versionId}/upload`, form, true);
|
|
172
|
-
}
|
|
173
|
-
async postPackage(workspace, project, identifier) {
|
|
174
|
-
const body = {
|
|
175
|
-
name: identifier,
|
|
176
|
-
identifier,
|
|
177
|
-
type: 'FILE',
|
|
178
|
-
scope: 'WORKSPACE',
|
|
179
|
-
authorization: {
|
|
180
|
-
type: 'BUDDY'
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
if (project) {
|
|
184
|
-
body.project = {
|
|
185
|
-
name: project
|
|
186
|
-
};
|
|
187
|
-
body.scope = 'PROJECT';
|
|
188
|
-
}
|
|
189
|
-
return await this.request('POST', `/workspaces/${encodeURIComponent(workspace)}/packages`, body, true);
|
|
190
|
-
}
|
|
191
115
|
}
|
|
192
116
|
exports.default = ApiClient;
|
|
@@ -11,15 +11,22 @@ const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
|
11
11
|
const commandAgentDebug = (0, utils_1.newCommand)('debug', texts_1.DESC_COMMAND_AGENT_DEBUG);
|
|
12
12
|
commandAgentDebug.argument('<on/off>');
|
|
13
13
|
commandAgentDebug.action(async (debug) => {
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
output_1.default.exitError(texts_1.
|
|
14
|
+
const hasAdminRights = await manager_1.default.system.hasAdminRights();
|
|
15
|
+
if (!hasAdminRights) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
17
|
+
}
|
|
18
|
+
if (!commandAgentDebug.agentInstalled) {
|
|
19
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
20
|
+
}
|
|
21
|
+
if (!commandAgentDebug.agentStatus) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
23
|
}
|
|
18
24
|
try {
|
|
19
25
|
const debugOn = debug === 'on';
|
|
20
26
|
const json = manager_1.default.system.loadSystemConfig();
|
|
21
27
|
const api = new agent_1.default(json.port);
|
|
22
28
|
await api.debugChange(debugOn);
|
|
29
|
+
manager_1.default.system.saveSystemConfig(json.id, json.host, json.token, json.port, !!json.standalone, debugOn);
|
|
23
30
|
output_1.default.exitSuccess(debugOn ? texts_1.TXT_AGENT_DEBUG_ON : texts_1.TXT_AGENT_DEBUG_OFF);
|
|
24
31
|
}
|
|
25
32
|
catch (err) {
|
|
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
8
|
const output_1 = __importDefault(require("../../output"));
|
|
10
9
|
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
11
10
|
const commandAgentDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_DISABLE);
|
|
12
11
|
commandAgentDisable.action(async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (!commandAgentDisable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentDisable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
|
-
const
|
|
19
|
-
const api = new agent_1.default(json.port);
|
|
19
|
+
const api = new agent_1.default(commandAgentDisable.agentPort || 0);
|
|
20
20
|
await api.disableAgent();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_STOPPED);
|
|
22
22
|
}
|
|
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
8
|
const output_1 = __importDefault(require("../../output"));
|
|
10
9
|
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
11
10
|
const commandAgentEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_ENABLE);
|
|
12
11
|
commandAgentEnable.action(async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (!commandAgentEnable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentEnable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
|
-
const
|
|
19
|
-
const api = new agent_1.default(json.port);
|
|
19
|
+
const api = new agent_1.default(commandAgentEnable.agentPort || 0);
|
|
20
20
|
await api.enableAgent();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_STARTED);
|
|
22
22
|
}
|