verteilen-core 1.2.4 → 1.2.7
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/client/analysis.d.ts +35 -0
- package/dist/client/analysis.js +382 -0
- package/dist/client/client.d.ts +25 -0
- package/dist/client/client.js +227 -0
- package/dist/client/cluster.d.ts +1 -0
- package/dist/{src/client → client}/cluster.js +1 -2
- package/dist/client/database.d.ts +13 -0
- package/dist/client/database.js +37 -0
- package/dist/client/execute.d.ts +24 -0
- package/dist/{src/client → client}/execute.js +61 -51
- package/dist/client/http.d.ts +7 -0
- package/dist/client/http.js +40 -0
- package/dist/client/javascript.d.ts +47 -0
- package/dist/{src/client → client}/javascript.js +110 -136
- package/dist/client/job_database.d.ts +10 -0
- package/dist/client/job_database.js +34 -0
- package/dist/client/job_execute.d.ts +20 -0
- package/dist/client/job_execute.js +173 -0
- package/dist/client/os.d.ts +29 -0
- package/dist/client/os.js +197 -0
- package/dist/client/resource.d.ts +7 -0
- package/dist/client/resource.js +107 -0
- package/dist/client/shell.d.ts +16 -0
- package/dist/client/shell.js +122 -0
- package/dist/computed.d.ts +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -3
- package/dist/interface/base.d.ts +70 -0
- package/dist/interface/bus.d.ts +90 -0
- package/dist/interface/enum.d.ts +143 -0
- package/dist/interface/execute.d.ts +20 -0
- package/dist/interface/record.d.ts +93 -0
- package/dist/interface/server.d.ts +76 -0
- package/dist/interface/struct.d.ts +182 -0
- package/dist/interface/table.d.ts +20 -0
- package/dist/interface/ui.d.ts +29 -0
- package/dist/interface.d.ts +29 -0
- package/dist/plugins/i18n.d.ts +1666 -0
- package/dist/script/console_manager.d.ts +18 -0
- package/dist/script/console_manager.js +131 -0
- package/dist/script/console_server_manager.d.ts +13 -0
- package/dist/script/console_server_manager.js +40 -0
- package/dist/script/execute/base.d.ts +45 -0
- package/dist/script/execute/base.js +200 -0
- package/dist/script/execute/feedback.d.ts +12 -0
- package/dist/script/execute/feedback.js +179 -0
- package/dist/script/execute/interface.d.ts +8 -0
- package/dist/script/execute/region_job.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_job.js +1 -0
- package/dist/script/execute/region_project.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_project.js +4 -0
- package/dist/script/execute/region_subtask.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_subtask.js +1 -0
- package/dist/script/execute/region_task.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_task.js +4 -0
- package/dist/script/execute/runner.d.ts +14 -0
- package/dist/script/execute/runner.js +264 -0
- package/dist/script/execute/util_parser.d.ts +14 -0
- package/dist/script/execute/util_parser.js +135 -0
- package/dist/script/execute_manager.d.ts +25 -0
- package/dist/script/execute_manager.js +297 -0
- package/dist/script/socket_manager.d.ts +31 -0
- package/dist/script/socket_manager.js +263 -0
- package/dist/script/webhook_manager.d.ts +3 -0
- package/dist/script/webhook_server_manager.d.ts +13 -0
- package/dist/script/webhook_server_manager.js +133 -0
- package/dist/server/detail.d.ts +72 -0
- package/dist/server/detail.js +451 -0
- package/dist/server/io.d.ts +46 -0
- package/dist/{src/server → server}/io.js +42 -51
- package/dist/server/plugin.d.ts +18 -0
- package/dist/{src/server → server}/plugin.js +45 -54
- package/dist/server/server.d.ts +27 -0
- package/dist/server/server.js +53 -0
- package/dist/server.d.ts +4 -0
- package/dist/util/console_handle.d.ts +20 -0
- package/dist/util/console_handle.js +244 -0
- package/dist/util/log_handle.d.ts +23 -0
- package/dist/util/log_handle.js +224 -0
- package/index.ts +1 -6
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/test/TEST.d.ts +1 -0
- package/test/TEST.js +88 -0
- package/test/client/execute.test.d.ts +1 -0
- package/{dist/test → test}/client/execute.test.js +6 -15
- package/test/client/javascript.test.d.ts +1 -0
- package/{dist/test → test}/client/javascript.test.js +21 -30
- package/test/client/server.test.d.ts +1 -0
- package/test/client/task.test.d.ts +1 -0
- package/{dist/test → test}/client/task.test.js +1 -1
- package/test/script/parser.test.d.ts +1 -0
- package/test/script/socket.test.d.ts +1 -0
- package/tsconfig.json +8 -4
- package/dist/jest.config.js +0 -8
- package/dist/src/client/analysis.js +0 -383
- package/dist/src/client/client.js +0 -233
- package/dist/src/client/database.js +0 -36
- package/dist/src/client/http.js +0 -37
- package/dist/src/client/job_database.js +0 -36
- package/dist/src/client/job_execute.js +0 -171
- package/dist/src/client/job_parameter.js +0 -36
- package/dist/src/client/os.js +0 -202
- package/dist/src/client/parameter.js +0 -36
- package/dist/src/client/resource.js +0 -118
- package/dist/src/client/shell.js +0 -118
- package/dist/src/script/console_manager.js +0 -125
- package/dist/src/script/console_server_manager.js +0 -37
- package/dist/src/script/execute/base.js +0 -197
- package/dist/src/script/execute/feedback.js +0 -188
- package/dist/src/script/execute/runner.js +0 -274
- package/dist/src/script/execute/util_parser.js +0 -137
- package/dist/src/script/execute_manager.js +0 -309
- package/dist/src/script/socket_manager.js +0 -260
- package/dist/src/script/webhook_server_manager.js +0 -140
- package/dist/src/server/detail.js +0 -428
- package/dist/src/server/server.js +0 -51
- package/dist/src/util/console_handle.js +0 -248
- package/dist/src/util/log_handle.js +0 -230
- package/dist/src/util/server/console_handle.js +0 -248
- package/dist/src/util/server/log_handle.js +0 -230
- package/dist/test/TEST.js +0 -105
- /package/dist/{src/computed.js → computed.js} +0 -0
- /package/dist/{src/interface → interface}/base.js +0 -0
- /package/dist/{src/interface → interface}/bus.js +0 -0
- /package/dist/{src/interface → interface}/enum.js +0 -0
- /package/dist/{src/interface → interface}/execute.js +0 -0
- /package/dist/{src/interface → interface}/record.js +0 -0
- /package/dist/{src/interface → interface}/server.js +0 -0
- /package/dist/{src/interface → interface}/struct.js +0 -0
- /package/dist/{src/interface → interface}/table.js +0 -0
- /package/dist/{src/interface → interface}/ui.js +0 -0
- /package/dist/{src/interface.js → interface.js} +0 -0
- /package/dist/{src/lan → lan}/en.json +0 -0
- /package/dist/{src/lan → lan}/zh_TW.json +0 -0
- /package/dist/{src/plugins → plugins}/i18n.js +0 -0
- /package/dist/{src/script → script}/execute/interface.js +0 -0
- /package/dist/{src/script → script}/webhook_manager.js +0 -0
- /package/dist/{src/server.js → server.js} +0 -0
- /package/{dist/test → test}/client/server.test.js +0 -0
- /package/{dist/test → test}/script/parser.test.js +0 -0
- /package/{dist/test → test}/script/socket.test.js +0 -0
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.Client = void 0;
|
|
46
|
-
const path = __importStar(require("path"));
|
|
47
|
-
const tcp_port_used_1 = require("tcp-port-used");
|
|
48
|
-
const ws = __importStar(require("ws"));
|
|
49
|
-
const interface_1 = require("../interface");
|
|
50
|
-
const analysis_1 = require("./analysis");
|
|
51
|
-
const fs_1 = require("fs");
|
|
52
|
-
const os = __importStar(require("os"));
|
|
53
|
-
const pem = __importStar(require("pem"));
|
|
54
|
-
const https = __importStar(require("https"));
|
|
55
|
-
class Client {
|
|
56
|
-
get count() {
|
|
57
|
-
return this.sources.length;
|
|
58
|
-
}
|
|
59
|
-
get clients() {
|
|
60
|
-
return this.sources;
|
|
61
|
-
}
|
|
62
|
-
constructor(_messager, _messager_log) {
|
|
63
|
-
this.plugins = { plugins: [] };
|
|
64
|
-
this.httpss = undefined;
|
|
65
|
-
this.client = undefined;
|
|
66
|
-
this.sources = [];
|
|
67
|
-
this.Init = () => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
let port_result = interface_1.PORT;
|
|
69
|
-
let canbeuse = false;
|
|
70
|
-
while (!canbeuse) {
|
|
71
|
-
yield (0, tcp_port_used_1.check)(port_result).then(x => {
|
|
72
|
-
canbeuse = !x;
|
|
73
|
-
}).catch(err => {
|
|
74
|
-
canbeuse = true;
|
|
75
|
-
});
|
|
76
|
-
if (!canbeuse)
|
|
77
|
-
port_result += 1;
|
|
78
|
-
}
|
|
79
|
-
const pems = yield this.get_pem();
|
|
80
|
-
this.httpss = https.createServer({ key: pems[0], cert: pems[1], minVersion: 'TLSv1.2', maxVersion: 'TLSv1.3' }, (req, res) => {
|
|
81
|
-
res.writeHead(200);
|
|
82
|
-
res.end('HTTPS server is running');
|
|
83
|
-
});
|
|
84
|
-
this.httpss.addListener('upgrade', (req, res, head) => console.log('UPGRADE:', req.url));
|
|
85
|
-
this.client = new ws.Server({ server: this.httpss });
|
|
86
|
-
this.client.on('listening', () => {
|
|
87
|
-
this.messager_log('[Server] Listen PORT: ' + port_result.toString());
|
|
88
|
-
});
|
|
89
|
-
this.client.on('error', (err) => {
|
|
90
|
-
this.messager_log(`[Server] Error ${err.name}\n\t${err.message}\n\t${err.stack}`);
|
|
91
|
-
});
|
|
92
|
-
this.client.on('close', () => {
|
|
93
|
-
this.messager_log('[Server] Close !');
|
|
94
|
-
this.Release();
|
|
95
|
-
});
|
|
96
|
-
this.client.on('connection', (ws, request) => {
|
|
97
|
-
const a = new analysis_1.ClientAnalysis(this.messager, this.messager_log, this);
|
|
98
|
-
this.analysis.push(a);
|
|
99
|
-
this.sources.push(ws);
|
|
100
|
-
this.messager_log(`[Server] New Connection detected, ${ws.url}`);
|
|
101
|
-
ws.on('close', (code, reason) => {
|
|
102
|
-
const index = this.sources.findIndex(x => x == ws);
|
|
103
|
-
if (index != -1)
|
|
104
|
-
this.sources.splice(index, 1);
|
|
105
|
-
this.messager_log(`[Source] Close ${code} ${reason}`);
|
|
106
|
-
a.disconnect(ws);
|
|
107
|
-
});
|
|
108
|
-
ws.on('error', (err) => {
|
|
109
|
-
this.messager_log(`[Source] Error ${err.name}\n\t${err.message}\n\t${err.stack}`);
|
|
110
|
-
});
|
|
111
|
-
ws.on('open', () => {
|
|
112
|
-
this.messager_log(`[Source] New source is connected, URL: ${ws === null || ws === void 0 ? void 0 : ws.url}`);
|
|
113
|
-
});
|
|
114
|
-
ws.on('message', (data, isBinery) => {
|
|
115
|
-
const h = JSON.parse(data.toString());
|
|
116
|
-
a.analysis(h, ws);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
this.httpss.listen(port_result, () => {
|
|
120
|
-
this.messager_log('[Server] Select Port: ' + port_result.toString());
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
this.Destroy = () => {
|
|
124
|
-
if (this.client == undefined)
|
|
125
|
-
return;
|
|
126
|
-
this.client.close((err) => {
|
|
127
|
-
this.messager_log(`[Client] Close error ${err}`);
|
|
128
|
-
});
|
|
129
|
-
this.Release();
|
|
130
|
-
};
|
|
131
|
-
this.Release = () => {
|
|
132
|
-
this.analysis.forEach(x => x.stop_all());
|
|
133
|
-
this.analysis.forEach(x => x.destroy());
|
|
134
|
-
this.analysis = [];
|
|
135
|
-
};
|
|
136
|
-
this.savePlugin = () => {
|
|
137
|
-
const f = path.join(os.homedir(), interface_1.DATA_FOLDER);
|
|
138
|
-
const pluginPath = path.join(f, 'plugin.json');
|
|
139
|
-
if (!(0, fs_1.existsSync)(f))
|
|
140
|
-
(0, fs_1.mkdirSync)(f, { recursive: true });
|
|
141
|
-
(0, fs_1.writeFileSync)(pluginPath, JSON.stringify(this.plugins, null, 4));
|
|
142
|
-
};
|
|
143
|
-
this.update = () => {
|
|
144
|
-
this.analysis.forEach(x => x.update(this));
|
|
145
|
-
};
|
|
146
|
-
this.loadPlugins = () => {
|
|
147
|
-
const f = path.join(os.homedir(), interface_1.DATA_FOLDER);
|
|
148
|
-
const pluginPath = path.join(f, 'plugin.json');
|
|
149
|
-
if (!(0, fs_1.existsSync)(f))
|
|
150
|
-
(0, fs_1.mkdirSync)(f, { recursive: true });
|
|
151
|
-
if (!(0, fs_1.existsSync)(pluginPath)) {
|
|
152
|
-
(0, fs_1.writeFileSync)(pluginPath, JSON.stringify(this.plugins, null, 4));
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this.plugins = JSON.parse((0, fs_1.readFileSync)(pluginPath).toString());
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
this.get_pem = () => {
|
|
159
|
-
return new Promise((resolve) => {
|
|
160
|
-
const pemFolder = path.join(os.homedir(), interface_1.DATA_FOLDER, 'pem');
|
|
161
|
-
if (!(0, fs_1.existsSync)(pemFolder))
|
|
162
|
-
(0, fs_1.mkdirSync)(pemFolder);
|
|
163
|
-
const clientKey = path.join(pemFolder, "client_clientkey.pem");
|
|
164
|
-
const certificate = path.join(pemFolder, "client_certificate.pem");
|
|
165
|
-
if (!(0, fs_1.existsSync)(clientKey) || !(0, fs_1.existsSync)(certificate)) {
|
|
166
|
-
pem.createCertificate({ selfSigned: true }, (err, keys) => {
|
|
167
|
-
(0, fs_1.writeFileSync)(clientKey, keys.clientKey, { encoding: 'utf8' });
|
|
168
|
-
(0, fs_1.writeFileSync)(certificate, keys.certificate, { encoding: 'utf8' });
|
|
169
|
-
resolve([keys.clientKey, keys.certificate]);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
resolve([(0, fs_1.readFileSync)(clientKey, 'utf8').toString(), (0, fs_1.readFileSync)(certificate, 'utf8').toString()]);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
this.messager = _messager;
|
|
178
|
-
this.messager_log = _messager_log;
|
|
179
|
-
this.analysis = [];
|
|
180
|
-
this.updatehandle = setInterval(this.update, interface_1.CLIENT_UPDATETICK);
|
|
181
|
-
this.loadPlugins();
|
|
182
|
-
}
|
|
183
|
-
Dispose() {
|
|
184
|
-
clearInterval(this.updatehandle);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
exports.Client = Client;
|
|
188
|
-
Client.workerPath = (filename = "worker", extension = ".exe") => {
|
|
189
|
-
var _a;
|
|
190
|
-
const isExe = ((_a = process.pkg) === null || _a === void 0 ? void 0 : _a.entrypoint) != undefined;
|
|
191
|
-
const exe = process.platform == 'win32' ? filename + extension : filename;
|
|
192
|
-
let workerExe = "";
|
|
193
|
-
let p = 0;
|
|
194
|
-
if (isExe && path.basename(process.execPath) == (process.platform ? "app.exe" : 'app')) {
|
|
195
|
-
workerExe = path.join(process.execPath, "..", "bin", exe);
|
|
196
|
-
p = 1;
|
|
197
|
-
}
|
|
198
|
-
else if ((process.mainModule && process.mainModule.filename.indexOf('app.asar') !== -1) ||
|
|
199
|
-
process.argv.filter(a => a.indexOf('app.asar') !== -1).length > 0) {
|
|
200
|
-
workerExe = path.join("bin", exe);
|
|
201
|
-
p = 2;
|
|
202
|
-
}
|
|
203
|
-
else if (process.env.NODE_ENV === 'development') {
|
|
204
|
-
workerExe = path.join(process.cwd(), "bin", exe);
|
|
205
|
-
p = 3;
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
workerExe = Client.isTypescript() ? path.join(__dirname, "bin", exe) : path.join(__dirname, "..", "bin", exe);
|
|
209
|
-
p = 4;
|
|
210
|
-
}
|
|
211
|
-
return workerExe;
|
|
212
|
-
};
|
|
213
|
-
Client.isTypescript = () => {
|
|
214
|
-
const extension = path.extname(__filename);
|
|
215
|
-
if (extension === ".ts") {
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
const lastArg = process.execArgv[process.execArgv.length - 1];
|
|
219
|
-
if (lastArg && path.parse(lastArg).name.indexOf("ts-node") > 0) {
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
try {
|
|
223
|
-
return process[Symbol.for("ts-node.register.instance")] ||
|
|
224
|
-
(process.env.NODE_ENV === "test" &&
|
|
225
|
-
process.env.ACTIONHERO_TEST_FILE_EXTENSION !== "js")
|
|
226
|
-
? true
|
|
227
|
-
: false;
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
console.error(error);
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientDatabase = void 0;
|
|
4
|
-
class ClientDatabase {
|
|
5
|
-
constructor(_source) {
|
|
6
|
-
this.feedbacknumber = (data) => {
|
|
7
|
-
this.feedback("feedback_number", data);
|
|
8
|
-
};
|
|
9
|
-
this.feedbackboolean = (data) => {
|
|
10
|
-
this.feedback("feedback_boolean", data);
|
|
11
|
-
};
|
|
12
|
-
this.feedbackstring = (data) => {
|
|
13
|
-
this.feedback("feedback_string", data);
|
|
14
|
-
};
|
|
15
|
-
this.feedbackobject = (data) => {
|
|
16
|
-
this.feedback("feedback_object", data);
|
|
17
|
-
};
|
|
18
|
-
this.feedbacklist = (data) => {
|
|
19
|
-
this.feedback("feedback_list", data);
|
|
20
|
-
};
|
|
21
|
-
this.feedbackselect = (data) => {
|
|
22
|
-
this.feedback("feedback_select", data);
|
|
23
|
-
};
|
|
24
|
-
this.feedback = (title, data) => {
|
|
25
|
-
if (this.source == undefined)
|
|
26
|
-
return;
|
|
27
|
-
const p = {
|
|
28
|
-
name: title,
|
|
29
|
-
data: data
|
|
30
|
-
};
|
|
31
|
-
this.source.send(JSON.stringify(p, null, 2));
|
|
32
|
-
};
|
|
33
|
-
this.source = _source;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.ClientDatabase = ClientDatabase;
|
package/dist/src/client/http.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientHTTP = void 0;
|
|
4
|
-
class ClientHTTP {
|
|
5
|
-
constructor(_url, _method, _params) {
|
|
6
|
-
this.RUN = () => {
|
|
7
|
-
fetch(this.url, {
|
|
8
|
-
method: this.method,
|
|
9
|
-
body: this.params
|
|
10
|
-
}).then(x => {
|
|
11
|
-
x.text().then(y => {
|
|
12
|
-
const h = {
|
|
13
|
-
name: "result",
|
|
14
|
-
data: {
|
|
15
|
-
status: x.status,
|
|
16
|
-
statusText: x.statusText,
|
|
17
|
-
headers: x.headers,
|
|
18
|
-
ok: x.ok,
|
|
19
|
-
data: y
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
console.log(JSON.stringify(h));
|
|
23
|
-
});
|
|
24
|
-
}).catch((reason) => {
|
|
25
|
-
const h = {
|
|
26
|
-
name: "error",
|
|
27
|
-
data: reason
|
|
28
|
-
};
|
|
29
|
-
console.log(JSON.stringify(h));
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
this.url = _url;
|
|
33
|
-
this.method = _method;
|
|
34
|
-
this.params = _params;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.ClientHTTP = ClientHTTP;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientJobDatabase = void 0;
|
|
4
|
-
class ClientJobDatabase {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.feedbacknumber = (data) => {
|
|
7
|
-
this.feedback("feedbacknumber", data);
|
|
8
|
-
};
|
|
9
|
-
this.feedbackboolean = (data) => {
|
|
10
|
-
this.feedback("feedbackboolean", data);
|
|
11
|
-
};
|
|
12
|
-
this.feedbackstring = (data) => {
|
|
13
|
-
this.feedback("feedbackstring", data);
|
|
14
|
-
};
|
|
15
|
-
this.feedbackobject = (data) => {
|
|
16
|
-
this.feedback("feedbackobject", data);
|
|
17
|
-
};
|
|
18
|
-
this.feedbacklist = (data) => {
|
|
19
|
-
this.feedback("feedbacklist", data);
|
|
20
|
-
};
|
|
21
|
-
this.feedbackselect = (data) => {
|
|
22
|
-
this.feedback("feedbackselect", data);
|
|
23
|
-
};
|
|
24
|
-
this.feedback = (title, data) => {
|
|
25
|
-
const p = {
|
|
26
|
-
name: title,
|
|
27
|
-
data: {
|
|
28
|
-
key: data.key,
|
|
29
|
-
value: data.value
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
console.log(JSON.stringify(p));
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.ClientJobDatabase = ClientJobDatabase;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ClientJobExecute = void 0;
|
|
13
|
-
const interface_1 = require("../interface");
|
|
14
|
-
const i18n_1 = require("../plugins/i18n");
|
|
15
|
-
const javascript_1 = require("./javascript");
|
|
16
|
-
const job_database_1 = require("./job_database");
|
|
17
|
-
const os_1 = require("./os");
|
|
18
|
-
class ClientJobExecute {
|
|
19
|
-
constructor(_messager, _messager_log, _job, _source, _plugin) {
|
|
20
|
-
this.execute = () => {
|
|
21
|
-
this.messager_log(`[Execute] ${this.job.uuid} ${this.job.category == interface_1.JobCategory.Execution ? i18n_1.i18n.global.t(interface_1.JobTypeText[this.job.type]) : i18n_1.i18n.global.t(interface_1.JobType2Text[this.job.type])}`, this.tag, this.runtime);
|
|
22
|
-
const child = this.job.category == interface_1.JobCategory.Execution ? this.execute_job_exe() : this.execute_job_con();
|
|
23
|
-
return child;
|
|
24
|
-
};
|
|
25
|
-
this.stop_all = () => {
|
|
26
|
-
this.os.stopall();
|
|
27
|
-
};
|
|
28
|
-
this.execute_job_exe = () => {
|
|
29
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
switch (this.job.type) {
|
|
31
|
-
case interface_1.JobType.COPY_FILE:
|
|
32
|
-
{
|
|
33
|
-
const data = { from: this.job.string_args[0], to: this.job.string_args[1] };
|
|
34
|
-
this.os.file_copy(data);
|
|
35
|
-
resolve(`Copy file successfully, ${data.from}, ${data.to}`);
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case interface_1.JobType.COPY_DIR:
|
|
39
|
-
{
|
|
40
|
-
const data = { from: this.job.string_args[0], to: this.job.string_args[1] };
|
|
41
|
-
this.os.dir_copy(data);
|
|
42
|
-
resolve(`Copy dir successfully, ${data.from}, ${data.to}`);
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
case interface_1.JobType.DELETE_FILE:
|
|
46
|
-
{
|
|
47
|
-
const data = { path: this.job.string_args[0] };
|
|
48
|
-
this.os.file_delete(data);
|
|
49
|
-
resolve(`Delete file successfully, ${data.path}`);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
case interface_1.JobType.DELETE_DIR:
|
|
53
|
-
{
|
|
54
|
-
const data = { path: this.job.string_args[0] };
|
|
55
|
-
this.os.dir_delete(data);
|
|
56
|
-
resolve(`Delete folder successfully, ${data.path}`);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
case interface_1.JobType.CREATE_DIR:
|
|
60
|
-
{
|
|
61
|
-
const data = { path: this.job.string_args[0] };
|
|
62
|
-
this.os.dir_create(data);
|
|
63
|
-
resolve(`Create dir successfully, ${data.path}`);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
case interface_1.JobType.CREATE_FILE:
|
|
67
|
-
{
|
|
68
|
-
const data = { from: this.job.string_args[0], to: this.job.string_args[1] };
|
|
69
|
-
this.os.file_write(data);
|
|
70
|
-
resolve(`Create file successfully, ${data.from} ${data.to}`);
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
case interface_1.JobType.RENAME:
|
|
74
|
-
{
|
|
75
|
-
const data = { from: this.job.string_args[0], to: this.job.string_args[1] };
|
|
76
|
-
this.os.rename(data);
|
|
77
|
-
resolve(`Rename successfully, ${data.from} ${data.to}`);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case interface_1.JobType.JAVASCRIPT:
|
|
81
|
-
{
|
|
82
|
-
yield this.javascript.JavascriptExecuteWithLib(this.job.script, this.job.string_args).then(() => {
|
|
83
|
-
resolve(`Execute Javascript successfully`);
|
|
84
|
-
}).catch(k => {
|
|
85
|
-
reject(k);
|
|
86
|
-
});
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
case interface_1.JobType.COMMAND:
|
|
90
|
-
{
|
|
91
|
-
this.os.command(this.job.string_args[1], this.job.string_args[2], this.job.string_args[0]).then(m => {
|
|
92
|
-
resolve(m);
|
|
93
|
-
}).catch(err => {
|
|
94
|
-
reject(err);
|
|
95
|
-
});
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case interface_1.JobType.LIB_COMMAND:
|
|
99
|
-
{
|
|
100
|
-
const target = this.plugin.plugins.find(x => x.name == this.job.string_args[0]);
|
|
101
|
-
if (target == undefined) {
|
|
102
|
-
reject("Cannot find plugin " + this.job.string_args[0]);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const archTarget = target.contents.find(x => x.arch == process.arch && x.platform == process.platform);
|
|
106
|
-
if (archTarget == undefined) {
|
|
107
|
-
reject({
|
|
108
|
-
code: 1,
|
|
109
|
-
message: "Cannot find plugin match arch " + this.job.string_args[0] + " " + process.arch
|
|
110
|
-
});
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
this.os.lib_command(archTarget.filename, this.job.string_args[1]).then(m => {
|
|
114
|
-
resolve(m);
|
|
115
|
-
}).catch(err => {
|
|
116
|
-
reject(err);
|
|
117
|
-
});
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}));
|
|
122
|
-
};
|
|
123
|
-
this.execute_job_con = () => {
|
|
124
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
switch (this.job.type) {
|
|
126
|
-
case interface_1.JobType2.CHECK_PATH:
|
|
127
|
-
{
|
|
128
|
-
const data = { path: this.job.string_args[0] };
|
|
129
|
-
if (this.os.fs_exist(data)) {
|
|
130
|
-
resolve(`Path exist ${data.path}`);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
reject({
|
|
134
|
-
code: 2,
|
|
135
|
-
message: `Path not exist ${data.path}`
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
case interface_1.JobType2.JAVASCRIPT:
|
|
141
|
-
{
|
|
142
|
-
const r = yield this.javascript.JavascriptExecuteWithLib(this.job.script, this.job.string_args);
|
|
143
|
-
if (r != undefined && r == 0) {
|
|
144
|
-
resolve(`Execute Javascript successfully`);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
reject({
|
|
148
|
-
code: 3,
|
|
149
|
-
message: `Execute Javascript failed`
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}));
|
|
156
|
-
};
|
|
157
|
-
this.messager = _messager;
|
|
158
|
-
this.messager_log = _messager_log;
|
|
159
|
-
this.tag = _job.uuid;
|
|
160
|
-
this.runtime = _job.runtime_uuid || '';
|
|
161
|
-
this.job = _job;
|
|
162
|
-
this.plugin = _plugin;
|
|
163
|
-
this.para = new job_database_1.ClientJobDatabase();
|
|
164
|
-
this.os = new os_1.ClientOS(() => this.tag, () => this.job.runtime_uuid || '', _messager, _messager_log);
|
|
165
|
-
this.javascript = new javascript_1.ClientJavascript(_messager, _messager_log, () => this.job);
|
|
166
|
-
this.database = process.env.database != undefined ? JSON.parse(process.env.database) : undefined;
|
|
167
|
-
this.libraries = process.env.libraries != undefined ? JSON.parse(process.env.libraries) : undefined;
|
|
168
|
-
javascript_1.ClientJavascript.Init(_messager, _messager_log, this.os, this.para, () => this.libraries, () => this.database, () => this.job);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
exports.ClientJobExecute = ClientJobExecute;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientJobParameter = void 0;
|
|
4
|
-
class ClientJobParameter {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.feedbacknumber = (data) => {
|
|
7
|
-
this.feedback("feedbacknumber", data);
|
|
8
|
-
};
|
|
9
|
-
this.feedbackboolean = (data) => {
|
|
10
|
-
this.feedback("feedbackboolean", data);
|
|
11
|
-
};
|
|
12
|
-
this.feedbackstring = (data) => {
|
|
13
|
-
this.feedback("feedbackstring", data);
|
|
14
|
-
};
|
|
15
|
-
this.feedbackobject = (data) => {
|
|
16
|
-
this.feedback("feedbackobject", data);
|
|
17
|
-
};
|
|
18
|
-
this.feedbacklist = (data) => {
|
|
19
|
-
this.feedback("feedbacklist", data);
|
|
20
|
-
};
|
|
21
|
-
this.feedbackselect = (data) => {
|
|
22
|
-
this.feedback("feedbackselect", data);
|
|
23
|
-
};
|
|
24
|
-
this.feedback = (title, data) => {
|
|
25
|
-
const p = {
|
|
26
|
-
name: title,
|
|
27
|
-
data: {
|
|
28
|
-
key: data.key,
|
|
29
|
-
value: data.value
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
console.log(JSON.stringify(p));
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.ClientJobParameter = ClientJobParameter;
|