bdy 1.14.8-dev → 1.14.9-beta
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
CHANGED
|
@@ -273,6 +273,12 @@ class AgentManagerClass {
|
|
|
273
273
|
catch {
|
|
274
274
|
// do nothing
|
|
275
275
|
}
|
|
276
|
+
try {
|
|
277
|
+
this.system.clearNewAgentFiles();
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
// do nothing
|
|
281
|
+
}
|
|
276
282
|
output_1.default.exitError(txt);
|
|
277
283
|
}
|
|
278
284
|
async agentStop() {
|
|
@@ -491,7 +497,7 @@ class AgentManagerClass {
|
|
|
491
497
|
if (!forceParam) {
|
|
492
498
|
try {
|
|
493
499
|
// load from config
|
|
494
|
-
const json = this.system.
|
|
500
|
+
const json = this.system.loadNewAgentConfig();
|
|
495
501
|
this.shouldStart = !!json.shouldStart;
|
|
496
502
|
this.sshHostKey = json.sshHostKey;
|
|
497
503
|
}
|
|
@@ -508,7 +514,7 @@ class AgentManagerClass {
|
|
|
508
514
|
}
|
|
509
515
|
try {
|
|
510
516
|
// resave config
|
|
511
|
-
this.system.
|
|
517
|
+
this.system.saveNewAgentConfig(this.shouldStart, this.sshHostKey || '');
|
|
512
518
|
return true;
|
|
513
519
|
}
|
|
514
520
|
catch {
|
|
@@ -35,9 +35,15 @@ class AgentSystem {
|
|
|
35
35
|
getSystemConfigDir() {
|
|
36
36
|
return '';
|
|
37
37
|
}
|
|
38
|
+
getNewAgentConfigDir() {
|
|
39
|
+
return this.getSystemConfigDir();
|
|
40
|
+
}
|
|
38
41
|
getAgentConfigDir() {
|
|
39
42
|
return (0, utils_1.getHomeDirectory)();
|
|
40
43
|
}
|
|
44
|
+
getNewAgentConfigPath() {
|
|
45
|
+
return path_1.default.join(this.getNewAgentConfigDir(), 'srv.json');
|
|
46
|
+
}
|
|
41
47
|
getAgentConfigPath() {
|
|
42
48
|
return path_1.default.join(this.getAgentConfigDir(), 'agent.json');
|
|
43
49
|
}
|
|
@@ -78,8 +84,15 @@ class AgentSystem {
|
|
|
78
84
|
const str = (0, fs_1.readFileSync)(this.getSystemConfigPath(), 'utf-8');
|
|
79
85
|
return JSON.parse(str);
|
|
80
86
|
}
|
|
81
|
-
|
|
82
|
-
const
|
|
87
|
+
loadNewAgentConfig() {
|
|
88
|
+
const exists = (0, fs_1.existsSync)(this.getAgentConfigPath());
|
|
89
|
+
if (exists) {
|
|
90
|
+
(0, fs_1.cpSync)(this.getAgentConfigPath(), this.getNewAgentConfigPath(), {
|
|
91
|
+
force: true,
|
|
92
|
+
});
|
|
93
|
+
this.clearAgentFiles();
|
|
94
|
+
}
|
|
95
|
+
const str = (0, fs_1.readFileSync)(this.getNewAgentConfigPath(), 'utf-8');
|
|
83
96
|
return JSON.parse(str);
|
|
84
97
|
}
|
|
85
98
|
clearSystemFiles() {
|
|
@@ -89,6 +102,9 @@ class AgentSystem {
|
|
|
89
102
|
clearAgentFiles() {
|
|
90
103
|
(0, fs_1.rmSync)(this.getAgentConfigPath(), { force: true });
|
|
91
104
|
}
|
|
105
|
+
clearNewAgentFiles() {
|
|
106
|
+
(0, fs_1.rmSync)(this.getNewAgentConfigPath(), { force: true });
|
|
107
|
+
}
|
|
92
108
|
ensureSystemConfigDir() {
|
|
93
109
|
(0, fs_1.mkdirSync)(this.getSystemConfigDir(), { recursive: true });
|
|
94
110
|
}
|
|
@@ -160,10 +176,16 @@ class AgentSystem {
|
|
|
160
176
|
return false;
|
|
161
177
|
}
|
|
162
178
|
}
|
|
163
|
-
|
|
179
|
+
saveNewAgentConfig(shouldStart, sshHostKey) {
|
|
180
|
+
try {
|
|
181
|
+
this.clearAgentFiles();
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// do nothing
|
|
185
|
+
}
|
|
164
186
|
try {
|
|
165
187
|
logger_1.default.info(texts_1.LOG_SAVING_AGENT_LOCAL_CONFIG);
|
|
166
|
-
(0, fs_1.writeFileSync)(this.
|
|
188
|
+
(0, fs_1.writeFileSync)(this.getNewAgentConfigPath(), JSON.stringify({
|
|
167
189
|
shouldStart,
|
|
168
190
|
sshHostKey,
|
|
169
191
|
}), 'utf-8');
|
|
@@ -37,6 +37,12 @@ const removeAllAndExit = async (txt, id, host, token) => {
|
|
|
37
37
|
catch {
|
|
38
38
|
// do nothing
|
|
39
39
|
}
|
|
40
|
+
try {
|
|
41
|
+
manager_1.default.system.clearNewAgentFiles();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// do nothing
|
|
45
|
+
}
|
|
40
46
|
output_1.default.exitError(txt);
|
|
41
47
|
};
|
|
42
48
|
const commandAgentInstall = (0, utils_1.newCommand)('install', texts_1.DESC_COMMAND_AGENT_INSTALL);
|
|
@@ -95,7 +101,18 @@ commandAgentInstall.action(async (options) => {
|
|
|
95
101
|
if (!saved) {
|
|
96
102
|
await removeAllAndExit(texts_1.ERR_SWW_AGENT_ENABLING, id, host, token);
|
|
97
103
|
}
|
|
98
|
-
|
|
104
|
+
try {
|
|
105
|
+
manager_1.default.system.clearAgentFiles();
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// do nothing
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
manager_1.default.system.clearNewAgentFiles();
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// do nothing
|
|
115
|
+
}
|
|
99
116
|
await output_1.default.spinner(texts_1.TXT_ENABLING_AGENT);
|
|
100
117
|
if (process.env.DEBUG === '1') {
|
|
101
118
|
manager_1.default.start(id, host, token, port, !!options.start);
|
|
@@ -13,7 +13,7 @@ commandAgentRun.option('--token <token>');
|
|
|
13
13
|
commandAgentRun.option('--port <port>');
|
|
14
14
|
commandAgentRun.option('--start <start>');
|
|
15
15
|
commandAgentRun.action(async (options) => {
|
|
16
|
-
logger_1.default.changeRootPath(manager_1.default.system.
|
|
16
|
+
logger_1.default.changeRootPath(manager_1.default.system.getNewAgentConfigDir());
|
|
17
17
|
manager_1.default.start(options.id, options.host, options.token, parseInt(options.port, 10), String(options.start) === 'true');
|
|
18
18
|
});
|
|
19
19
|
exports.default = commandAgentRun;
|
|
@@ -39,6 +39,12 @@ commandAgentUninstall.action(async () => {
|
|
|
39
39
|
catch {
|
|
40
40
|
// do nothing
|
|
41
41
|
}
|
|
42
|
+
try {
|
|
43
|
+
manager_1.default.system.clearNewAgentFiles();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// do nothing
|
|
47
|
+
}
|
|
42
48
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_DISABLED);
|
|
43
49
|
});
|
|
44
50
|
exports.default = commandAgentUninstall;
|