@atomicsolutions/proton5-cli 5.0.1
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/README.md +590 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +5 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/commands/config/add.d.ts +14 -0
- package/dist/commands/config/add.js +122 -0
- package/dist/commands/config/edit.d.ts +15 -0
- package/dist/commands/config/edit.js +63 -0
- package/dist/commands/config/list.d.ts +6 -0
- package/dist/commands/config/list.js +31 -0
- package/dist/commands/config/remove.d.ts +9 -0
- package/dist/commands/config/remove.js +35 -0
- package/dist/commands/connect.d.ts +9 -0
- package/dist/commands/connect.js +41 -0
- package/dist/commands/disconnect.d.ts +9 -0
- package/dist/commands/disconnect.js +30 -0
- package/dist/commands/runner/list-run.d.ts +6 -0
- package/dist/commands/runner/list-run.js +71 -0
- package/dist/commands/runner/status.d.ts +6 -0
- package/dist/commands/runner/status.js +24 -0
- package/dist/commands/runner/stop-run.d.ts +9 -0
- package/dist/commands/runner/stop-run.js +34 -0
- package/dist/commands/settings/index.d.ts +6 -0
- package/dist/commands/settings/index.js +25 -0
- package/dist/commands/settings/set.d.ts +10 -0
- package/dist/commands/settings/set.js +39 -0
- package/dist/commands/settings/unset.d.ts +10 -0
- package/dist/commands/settings/unset.js +35 -0
- package/dist/core/fileSystem/index.d.ts +10 -0
- package/dist/core/fileSystem/index.js +107 -0
- package/dist/core/manager/index.d.ts +31 -0
- package/dist/core/manager/index.js +287 -0
- package/dist/core/proton/api.d.ts +7 -0
- package/dist/core/proton/api.js +122 -0
- package/dist/core/proton/maven.d.ts +5 -0
- package/dist/core/proton/maven.js +74 -0
- package/dist/core/proton/npm.d.ts +1 -0
- package/dist/core/proton/npm.js +22 -0
- package/dist/core/proton/playwright.d.ts +5 -0
- package/dist/core/proton/playwright.js +47 -0
- package/dist/core/proton/pyTest.d.ts +5 -0
- package/dist/core/proton/pyTest.js +52 -0
- package/dist/core/proton/vbs.d.ts +5 -0
- package/dist/core/proton/vbs.js +46 -0
- package/dist/core/runner/index.d.ts +16 -0
- package/dist/core/runner/index.js +76 -0
- package/dist/core/services/api.d.ts +2 -0
- package/dist/core/services/api.js +20 -0
- package/dist/core/socket/index.d.ts +2 -0
- package/dist/core/socket/index.js +99 -0
- package/dist/core/store/index.d.ts +14 -0
- package/dist/core/store/index.js +212 -0
- package/dist/core/system/index.d.ts +12 -0
- package/dist/core/system/index.js +48 -0
- package/dist/daemon/index.d.ts +1 -0
- package/dist/daemon/index.js +5 -0
- package/dist/daemon/server.d.ts +1 -0
- package/dist/daemon/server.js +40 -0
- package/dist/daemon/state.d.ts +7 -0
- package/dist/daemon/state.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/ipc/client.d.ts +1 -0
- package/dist/ipc/client.js +16 -0
- package/dist/ipc/ensureDaemon.d.ts +1 -0
- package/dist/ipc/ensureDaemon.js +42 -0
- package/dist/ipc/protocol.d.ts +14 -0
- package/dist/ipc/protocol.js +1 -0
- package/dist/shared/constants.d.ts +4 -0
- package/dist/shared/constants.js +4 -0
- package/dist/shared/socketPath.d.ts +1 -0
- package/dist/shared/socketPath.js +5 -0
- package/dist/shared/types.d.ts +130 -0
- package/dist/shared/types.js +1 -0
- package/oclif.manifest.json +409 -0
- package/package.json +86 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runNpmInstall(dir: string): Promise<number>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
export async function runNpmInstall(dir) {
|
|
4
|
+
const homedir = os.homedir();
|
|
5
|
+
const repoLocalDir = String(homedir.replace(/[\\]/, '/') + '/.proton-runner-repo/' + dir).replace(/[\\]/, '/');
|
|
6
|
+
const exitCode = await executeProcess(repoLocalDir);
|
|
7
|
+
return exitCode;
|
|
8
|
+
}
|
|
9
|
+
function executeProcess(repoLocalDir) {
|
|
10
|
+
return new Promise(async (resolve) => {
|
|
11
|
+
try {
|
|
12
|
+
let pwCmd = ['install'];
|
|
13
|
+
const proc = spawn('npm', pwCmd, { cwd: repoLocalDir, shell: true });
|
|
14
|
+
proc.on('close', async (code) => {
|
|
15
|
+
resolve(Number(code));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
resolve(1);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { runner } from '../runner/index.js';
|
|
4
|
+
import { uploadLogFile } from './api.js';
|
|
5
|
+
import { manager } from '../manager/index.js';
|
|
6
|
+
export default class Playwright {
|
|
7
|
+
static async runScript(runConfig) {
|
|
8
|
+
const homedir = os.homedir();
|
|
9
|
+
const repoLocalDir = String(homedir + '/.proton-runner-repo/' + runConfig.dir).replace('\\', '/').replace('\\', '/');
|
|
10
|
+
const exitCode = await this.executeProcess(repoLocalDir, runConfig.idDatasetRun, runConfig.reference || '');
|
|
11
|
+
return exitCode;
|
|
12
|
+
}
|
|
13
|
+
static executeProcess(repoLocalDir, idDatasetRun, _reference) {
|
|
14
|
+
const activeConnection = runner.getActiveConnection();
|
|
15
|
+
if (!activeConnection) {
|
|
16
|
+
return Promise.resolve(1);
|
|
17
|
+
}
|
|
18
|
+
return new Promise(async (resolve) => {
|
|
19
|
+
try {
|
|
20
|
+
let pwCmd = ['./run-test.ts', `--id_dataset_run=${idDatasetRun}`];
|
|
21
|
+
const proc = spawn('node', pwCmd, { cwd: repoLocalDir, shell: true });
|
|
22
|
+
if (!proc.pid) {
|
|
23
|
+
resolve(1);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
manager.addProcess(idDatasetRun, proc.pid);
|
|
27
|
+
let log = '';
|
|
28
|
+
proc.stdout.setEncoding('latin1');
|
|
29
|
+
proc.stdout.on('data', (data) => {
|
|
30
|
+
log += data;
|
|
31
|
+
});
|
|
32
|
+
proc.on('close', async (code) => {
|
|
33
|
+
try {
|
|
34
|
+
await uploadLogFile(idDatasetRun, log);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.log('Erro ao gerar arquivo de log');
|
|
38
|
+
}
|
|
39
|
+
resolve(Number(code));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
resolve(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { runner } from '../runner/index.js';
|
|
4
|
+
import { uploadLogFile } from './api.js';
|
|
5
|
+
import { manager } from '../manager/index.js';
|
|
6
|
+
export default class PyTest {
|
|
7
|
+
static async runScript(runConfig) {
|
|
8
|
+
const homedir = os.homedir();
|
|
9
|
+
const repoLocalDir = String(homedir + '/.proton-runner-repo/' + runConfig.dir).replace('\\', '/').replace('\\', '/');
|
|
10
|
+
const exitCode = await this.executeProcess(repoLocalDir, runConfig.idDatasetRun, runConfig.reference || '');
|
|
11
|
+
return exitCode;
|
|
12
|
+
}
|
|
13
|
+
static executeProcess(repoLocalDir, idDatasetRun, _reference) {
|
|
14
|
+
const activeConnection = runner.getActiveConnection();
|
|
15
|
+
if (!activeConnection) {
|
|
16
|
+
return Promise.resolve(1);
|
|
17
|
+
}
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
try {
|
|
20
|
+
let pyCmd = ['run', 'pytest', 'tests/test_proton_script.py::test_run_proton_execution', `--id_dataset_run=${idDatasetRun}`];
|
|
21
|
+
const proc = spawn('uv', pyCmd, { cwd: repoLocalDir, shell: true });
|
|
22
|
+
if (!proc.pid) {
|
|
23
|
+
resolve(1);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
manager.addProcess(idDatasetRun, proc.pid);
|
|
27
|
+
let log = '';
|
|
28
|
+
proc.stdout.setEncoding('latin1');
|
|
29
|
+
proc.stdout.on('data', (data) => {
|
|
30
|
+
log += data;
|
|
31
|
+
});
|
|
32
|
+
proc.on('close', async (code) => {
|
|
33
|
+
try {
|
|
34
|
+
await uploadLogFile(idDatasetRun, log);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
console.log('Erro ao gerar arquivo de log');
|
|
38
|
+
}
|
|
39
|
+
if (code !== null) {
|
|
40
|
+
resolve(code);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
resolve(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
resolve(1);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { runner } from '../runner/index.js';
|
|
4
|
+
import { uploadLogFile } from './api.js';
|
|
5
|
+
import { manager } from '../manager/index.js';
|
|
6
|
+
export default class VBScript {
|
|
7
|
+
static async runScript(runConfig) {
|
|
8
|
+
const homedir = os.homedir();
|
|
9
|
+
const repoLocalDir = String(homedir + '/.proton-runner-repo/' + runConfig.dir).replace('\\', '/').replace('\\', '/');
|
|
10
|
+
const exitCode = await this.executeProcess(repoLocalDir, runConfig.idDatasetRun, runConfig.reference || '');
|
|
11
|
+
return exitCode;
|
|
12
|
+
}
|
|
13
|
+
static executeProcess(repoLocalDir, idDatasetRun, _reference) {
|
|
14
|
+
const activeConnection = runner.getActiveConnection();
|
|
15
|
+
if (!activeConnection) {
|
|
16
|
+
return Promise.resolve(1);
|
|
17
|
+
}
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
try {
|
|
20
|
+
const proc = spawn('wscript', ["SAP_Runner.vbs", String(idDatasetRun), `"${repoLocalDir}"`], { cwd: repoLocalDir, shell: true });
|
|
21
|
+
if (!proc.pid) {
|
|
22
|
+
resolve(1);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
manager.addProcess(idDatasetRun, proc.pid);
|
|
26
|
+
let log = '';
|
|
27
|
+
proc.stdout.setEncoding('latin1');
|
|
28
|
+
proc.stdout.on('data', (data) => {
|
|
29
|
+
log += data;
|
|
30
|
+
});
|
|
31
|
+
proc.on('close', async (code) => {
|
|
32
|
+
try {
|
|
33
|
+
await uploadLogFile(idDatasetRun, log);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.log('Erro ao gerar arquivo de log');
|
|
37
|
+
}
|
|
38
|
+
resolve(code);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
resolve(1);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IAlertMsg, IConnection, RunnerStatus } from "#types";
|
|
2
|
+
export declare class Runner {
|
|
3
|
+
connect(connection: IConnection): Promise<void>;
|
|
4
|
+
setConnectionError(msg: string): Promise<void>;
|
|
5
|
+
getActiveConnection(): IConnection | null;
|
|
6
|
+
getMavenPath(): string;
|
|
7
|
+
setConnected(token: string): Promise<void>;
|
|
8
|
+
isConnected(): boolean;
|
|
9
|
+
setDisconnected(): Promise<void>;
|
|
10
|
+
getStatus(): RunnerStatus;
|
|
11
|
+
setStatus(runnerStatus: RunnerStatus): Promise<void>;
|
|
12
|
+
setAlertMsg(alertMsg: IAlertMsg | null): void;
|
|
13
|
+
setMsgPanel(msg: string): void;
|
|
14
|
+
clearMsgPanel(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare const runner: Runner;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { connectToServer } from "../socket/index.js";
|
|
2
|
+
import { getStoreValue, setStoreValue } from '../store/index.js';
|
|
3
|
+
import { DateTime } from "luxon";
|
|
4
|
+
import i18n from 'i18next';
|
|
5
|
+
import { manager } from "../manager/index.js";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { updateRunnerStatus } from "../proton/api.js";
|
|
8
|
+
export class Runner {
|
|
9
|
+
async connect(connection) {
|
|
10
|
+
setStoreValue("activeConnection", connection);
|
|
11
|
+
connectToServer(connection);
|
|
12
|
+
}
|
|
13
|
+
async setConnectionError(msg) {
|
|
14
|
+
await this.setStatus("Offline");
|
|
15
|
+
setStoreValue("connected", false);
|
|
16
|
+
setStoreValue("activeConnection", null);
|
|
17
|
+
setStoreValue("alertMsg", { type: 'error', msg });
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
setStoreValue("alertMsg", null);
|
|
20
|
+
}, 3000);
|
|
21
|
+
}
|
|
22
|
+
getActiveConnection() {
|
|
23
|
+
return getStoreValue("activeConnection");
|
|
24
|
+
}
|
|
25
|
+
getMavenPath() {
|
|
26
|
+
const settings = getStoreValue("settings");
|
|
27
|
+
return path.join(settings.mavenPath, 'bin', 'mvn.cmd');
|
|
28
|
+
}
|
|
29
|
+
async setConnected(token) {
|
|
30
|
+
const activeConnection = getStoreValue("activeConnection");
|
|
31
|
+
setStoreValue("activeConnection", { ...activeConnection, token });
|
|
32
|
+
this.setMsgPanel(`✅ **${i18n.t("msgPanel.runnerConnected")}**`);
|
|
33
|
+
setStoreValue("connected", true);
|
|
34
|
+
await this.setStatus("Idle");
|
|
35
|
+
}
|
|
36
|
+
isConnected() {
|
|
37
|
+
return getStoreValue("connected");
|
|
38
|
+
}
|
|
39
|
+
async setDisconnected() {
|
|
40
|
+
const runList = getStoreValue("runList") || [];
|
|
41
|
+
runList.forEach(async (run) => {
|
|
42
|
+
await manager.stopRun(run.id);
|
|
43
|
+
});
|
|
44
|
+
setStoreValue("connected", false);
|
|
45
|
+
await this.setStatus("Offline");
|
|
46
|
+
setStoreValue("activeConnection", null);
|
|
47
|
+
this.clearMsgPanel();
|
|
48
|
+
manager.clearRunList();
|
|
49
|
+
manager.clearWaitList();
|
|
50
|
+
}
|
|
51
|
+
getStatus() {
|
|
52
|
+
return getStoreValue("runnerStatus");
|
|
53
|
+
}
|
|
54
|
+
async setStatus(runnerStatus) {
|
|
55
|
+
setStoreValue("runnerStatus", runnerStatus);
|
|
56
|
+
await updateRunnerStatus(runnerStatus);
|
|
57
|
+
if (runnerStatus === "Offline") {
|
|
58
|
+
setStoreValue("connected", false);
|
|
59
|
+
setStoreValue("activeConnection", null);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
setStoreValue("connected", true);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
setAlertMsg(alertMsg) {
|
|
66
|
+
setStoreValue("alertMsg", alertMsg);
|
|
67
|
+
}
|
|
68
|
+
setMsgPanel(msg) {
|
|
69
|
+
const currentMsg = getStoreValue("msgPanel") || "";
|
|
70
|
+
setStoreValue("msgPanel", currentMsg + DateTime.now().toFormat("dd-MM-yyyy HH:mm:ss") + ": " + msg + "\n");
|
|
71
|
+
}
|
|
72
|
+
clearMsgPanel() {
|
|
73
|
+
setStoreValue("msgPanel", "");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export const runner = new Runner();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
const defaultOptions = {
|
|
3
|
+
headers: {
|
|
4
|
+
'Content-Type': 'application/json',
|
|
5
|
+
platform: 'client'
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
// Criar instância
|
|
9
|
+
let api = axios.create(defaultOptions);
|
|
10
|
+
api.interceptors.response.use((response) => {
|
|
11
|
+
return response;
|
|
12
|
+
}, function (error) {
|
|
13
|
+
if (error.response) {
|
|
14
|
+
return Promise.resolve(error.response);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return Promise.resolve({ ...error, status: 500 });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
export default api;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { io } from 'socket.io-client';
|
|
2
|
+
import { getOS } from '../system/index.js';
|
|
3
|
+
import * as $ from '../../shared/constants.js';
|
|
4
|
+
import { runner } from '../runner/index.js';
|
|
5
|
+
import { manager } from '../manager/index.js';
|
|
6
|
+
import { setStoreValue } from '../store/index.js';
|
|
7
|
+
let socket = null;
|
|
8
|
+
export function connectToServer(config) {
|
|
9
|
+
if (socket)
|
|
10
|
+
return;
|
|
11
|
+
socket = io(`${config.server}/proton-runner`, {
|
|
12
|
+
reconnection: true,
|
|
13
|
+
reconnectionAttempts: Infinity,
|
|
14
|
+
reconnectionDelay: 1000,
|
|
15
|
+
reconnectionDelayMax: 5000,
|
|
16
|
+
});
|
|
17
|
+
socket.on('connect', async () => {
|
|
18
|
+
const machineParams = await getOS();
|
|
19
|
+
const connectionData = {
|
|
20
|
+
email: config.email,
|
|
21
|
+
password: config.password,
|
|
22
|
+
ip: machineParams.ip,
|
|
23
|
+
macAddress: machineParams.macAddress,
|
|
24
|
+
hostname: machineParams.hostname,
|
|
25
|
+
version: $.CST_CLIENT_VERSION,
|
|
26
|
+
operatingSystem: machineParams.operatingSystem,
|
|
27
|
+
architecture: machineParams.architecture,
|
|
28
|
+
availableProcessors: machineParams.availableProcessors,
|
|
29
|
+
freeMemory: machineParams.freeMemory,
|
|
30
|
+
totalMemory: machineParams.totalMemory,
|
|
31
|
+
privateMode: config.privateMode,
|
|
32
|
+
statusNotification: config.statusNotification
|
|
33
|
+
};
|
|
34
|
+
if (socket) {
|
|
35
|
+
socket.emit('authenticate', connectionData);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
socket.on('authorized', async (data) => {
|
|
39
|
+
try {
|
|
40
|
+
if (data.authorized && data.token) {
|
|
41
|
+
setStoreValue("activeConnection", { ...config, token: data.token });
|
|
42
|
+
await runner.setConnected(data.token);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
await runner.setConnectionError(data.msg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
console.error('[socket] Error handling authorized event:', err);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
socket.on('connect_error', (err) => {
|
|
53
|
+
// Não desconectar manualmente aqui — o socket.io gerencia a reconexão automaticamente.
|
|
54
|
+
// Chamar socket.disconnect() cancelaria o reconnection: true.
|
|
55
|
+
console.log('[socket] connect_error:', err.message);
|
|
56
|
+
});
|
|
57
|
+
socket.on('submitRun', async (data, callback) => {
|
|
58
|
+
const newRun = [];
|
|
59
|
+
if (data.datasetRun) {
|
|
60
|
+
data.datasetRun.forEach((datasetRun) => {
|
|
61
|
+
newRun.push({
|
|
62
|
+
...datasetRun,
|
|
63
|
+
status: 'Waiting',
|
|
64
|
+
system: data.system,
|
|
65
|
+
isRunning: false,
|
|
66
|
+
isComplete: false,
|
|
67
|
+
isUploadingResults: false
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
manager.addToWaitList(newRun);
|
|
72
|
+
callback('ack');
|
|
73
|
+
});
|
|
74
|
+
socket.on('updateRunStatus', async (data) => {
|
|
75
|
+
manager.updateRun(data.idDatasetRun, { status: data.status });
|
|
76
|
+
});
|
|
77
|
+
socket.on("error", (error) => {
|
|
78
|
+
console.log('[socket] error:', error);
|
|
79
|
+
});
|
|
80
|
+
socket.on('disconnect', reason => {
|
|
81
|
+
console.log('[socket] disconnected:', reason);
|
|
82
|
+
// Se o servidor fechou a conexão ativamente, reconectar manualmente,
|
|
83
|
+
// pois o socket.io não tenta reconectar automaticamente nesse caso.
|
|
84
|
+
if (reason === 'io server disconnect') {
|
|
85
|
+
socket?.connect();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
socket.on('reconnect', attempt => {
|
|
89
|
+
console.log('[socket] reconnected after', attempt, 'attempt(s)');
|
|
90
|
+
});
|
|
91
|
+
socket.on('reconnect_error', (err) => {
|
|
92
|
+
console.log('[socket] reconnect_error:', err.message);
|
|
93
|
+
});
|
|
94
|
+
socket.on('reconnect_failed', () => {
|
|
95
|
+
console.log('[socket] reconnect_failed — giving up');
|
|
96
|
+
runner.setConnectionError('serverConnectionError').catch(console.error);
|
|
97
|
+
socket = null;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
import type { IAppStoreData, IConnection } from '#types';
|
|
3
|
+
export declare const store: Conf<IAppStoreData>;
|
|
4
|
+
/**
|
|
5
|
+
* Read a value from the store using dot-path
|
|
6
|
+
* Ex: get("settings.mavenPath")
|
|
7
|
+
*/
|
|
8
|
+
export declare function getStoreValue<K extends keyof IAppStoreData>(key: K): IAppStoreData[K];
|
|
9
|
+
/**
|
|
10
|
+
* Write a value to the store
|
|
11
|
+
* Ex: setStoreValue("settings.mavenPath", "/usr/bin/mvn")
|
|
12
|
+
*/
|
|
13
|
+
export declare function setStoreValue(key: string, value: any): void;
|
|
14
|
+
export declare function addConfigItem(newConfig: IConnection): Promise<void>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
const schema = {
|
|
3
|
+
settings: {
|
|
4
|
+
type: "object",
|
|
5
|
+
properties: {
|
|
6
|
+
mavenPath: { type: "string" },
|
|
7
|
+
parallelRuns: { type: "number" }
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
config: {
|
|
11
|
+
type: "array",
|
|
12
|
+
items: {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
name: { type: "string" },
|
|
16
|
+
server: { type: "string" },
|
|
17
|
+
email: { type: "string" },
|
|
18
|
+
password: { type: "string" },
|
|
19
|
+
privateMode: { type: "boolean" },
|
|
20
|
+
statusNotification: { type: "boolean" },
|
|
21
|
+
token: { type: "string" },
|
|
22
|
+
order: { type: "number" }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
activeConnection: {
|
|
27
|
+
type: ["object", "null"],
|
|
28
|
+
properties: {
|
|
29
|
+
name: { type: "string" },
|
|
30
|
+
server: { type: "string" },
|
|
31
|
+
email: { type: "string" },
|
|
32
|
+
password: { type: "string" },
|
|
33
|
+
privateMode: { type: "boolean" },
|
|
34
|
+
statusNotification: { type: "boolean" },
|
|
35
|
+
token: { type: "string" },
|
|
36
|
+
order: { type: "number" }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
headerStyle: { type: "string" },
|
|
40
|
+
process: {
|
|
41
|
+
type: "array",
|
|
42
|
+
items: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
idDatasetRun: { type: "number" },
|
|
46
|
+
processId: { type: "number" }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
hasUpdate: { type: "string" },
|
|
51
|
+
connected: { type: "boolean" },
|
|
52
|
+
runnerStatus: { type: "string" },
|
|
53
|
+
runList: {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {
|
|
58
|
+
id: { type: "number" },
|
|
59
|
+
idDataset: { type: "number" },
|
|
60
|
+
idCycle: { type: "number" },
|
|
61
|
+
idScheduleRun: { type: "number" },
|
|
62
|
+
idRunner: { type: "number" },
|
|
63
|
+
idUser: { type: "number" },
|
|
64
|
+
idStatus: { type: "number" },
|
|
65
|
+
idPriority: { type: "number" },
|
|
66
|
+
device: { type: ["string", "null"] },
|
|
67
|
+
app: { type: ["string", "null"] },
|
|
68
|
+
executionDate: { type: "string" },
|
|
69
|
+
idErrorStrategy: { type: ["number", "null"] },
|
|
70
|
+
externalId: { type: ["string", "null"] },
|
|
71
|
+
status: { type: "string" },
|
|
72
|
+
system: { type: "array" },
|
|
73
|
+
isRunning: { type: "boolean" },
|
|
74
|
+
isComplete: { type: "boolean" },
|
|
75
|
+
isUploadingResults: { type: "boolean" },
|
|
76
|
+
dataset: {
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
id: { type: "number" },
|
|
80
|
+
idCategory: { type: "number" },
|
|
81
|
+
idAutomation: { type: "number" },
|
|
82
|
+
datasetVersion: { type: "number" },
|
|
83
|
+
description: { type: ["string", "null"] },
|
|
84
|
+
automation: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
id: { type: "number" },
|
|
88
|
+
name: { type: "string" },
|
|
89
|
+
idBusinessProcess: { type: "number" },
|
|
90
|
+
mobile: { type: "boolean" },
|
|
91
|
+
reference: { type: ["string", "null"] },
|
|
92
|
+
description: { type: ["string", "null"] },
|
|
93
|
+
private: { type: "boolean" },
|
|
94
|
+
createdBy: { type: "number" },
|
|
95
|
+
createdAt: { type: "string" }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
waitList: {
|
|
104
|
+
type: "array",
|
|
105
|
+
items: {
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: {
|
|
108
|
+
id: { type: "number" },
|
|
109
|
+
idDataset: { type: "number" },
|
|
110
|
+
idCycle: { type: "number" },
|
|
111
|
+
idScheduleRun: { type: "number" },
|
|
112
|
+
idRunner: { type: "number" },
|
|
113
|
+
idUser: { type: "number" },
|
|
114
|
+
idStatus: { type: "number" },
|
|
115
|
+
idPriority: { type: "number" },
|
|
116
|
+
device: { type: ["string", "null"] },
|
|
117
|
+
app: { type: ["string", "null"] },
|
|
118
|
+
executionDate: { type: "string" },
|
|
119
|
+
idErrorStrategy: { type: ["number", "null"] },
|
|
120
|
+
externalId: { type: ["string", "null"] },
|
|
121
|
+
status: { type: "string" },
|
|
122
|
+
system: { type: "array" },
|
|
123
|
+
isRunning: { type: "boolean" },
|
|
124
|
+
isComplete: { type: "boolean" },
|
|
125
|
+
isUploadingResults: { type: "boolean" },
|
|
126
|
+
dataset: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: {
|
|
129
|
+
id: { type: "number" },
|
|
130
|
+
idCategory: { type: "number" },
|
|
131
|
+
idAutomation: { type: "number" },
|
|
132
|
+
datasetVersion: { type: "number" },
|
|
133
|
+
description: { type: ["string", "null"] },
|
|
134
|
+
automation: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
id: { type: "number" },
|
|
138
|
+
name: { type: "string" },
|
|
139
|
+
idBusinessProcess: { type: "number" },
|
|
140
|
+
mobile: { type: "boolean" },
|
|
141
|
+
reference: { type: ["string", "null"] },
|
|
142
|
+
description: { type: ["string", "null"] },
|
|
143
|
+
private: { type: "boolean" },
|
|
144
|
+
createdBy: { type: "number" },
|
|
145
|
+
createdAt: { type: "string" }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
msgPanel: { type: "string" },
|
|
154
|
+
alertMsg: {
|
|
155
|
+
type: ["object", "null"],
|
|
156
|
+
properties: {
|
|
157
|
+
type: { type: "string" },
|
|
158
|
+
msg: { type: "string" }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
export const store = new Conf({
|
|
163
|
+
projectName: 'proton-runner',
|
|
164
|
+
projectSuffix: 'store',
|
|
165
|
+
schema,
|
|
166
|
+
defaults: {
|
|
167
|
+
connected: false,
|
|
168
|
+
runnerStatus: 'Offline',
|
|
169
|
+
msgPanel: '',
|
|
170
|
+
alertMsg: null,
|
|
171
|
+
headerStyle: 'light',
|
|
172
|
+
hasUpdate: '',
|
|
173
|
+
activeConnection: null,
|
|
174
|
+
config: [],
|
|
175
|
+
process: [],
|
|
176
|
+
runList: [],
|
|
177
|
+
waitList: [],
|
|
178
|
+
settings: {
|
|
179
|
+
mavenPath: '',
|
|
180
|
+
parallelRuns: 1
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
export function getStoreValue(key) {
|
|
185
|
+
return store.get(key);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Write a value to the store
|
|
189
|
+
* Ex: setStoreValue("settings.mavenPath", "/usr/bin/mvn")
|
|
190
|
+
*/
|
|
191
|
+
export function setStoreValue(key, value) {
|
|
192
|
+
store.set(key, value);
|
|
193
|
+
}
|
|
194
|
+
// export function subscribeStoreChanges(win: BrowserWindow) {
|
|
195
|
+
// const s = getStoreInstance();
|
|
196
|
+
// s.onDidAnyChange((newStore: any, oldStore: any) => {
|
|
197
|
+
// if (!newStore || !oldStore) return;
|
|
198
|
+
// Object.keys(newStore).forEach((key) => {
|
|
199
|
+
// if (newStore[key] !== oldStore[key]) {
|
|
200
|
+
// win.webContents.send("store:changed", {
|
|
201
|
+
// key,
|
|
202
|
+
// newValue: newStore[key],
|
|
203
|
+
// oldValue: oldStore[key]
|
|
204
|
+
// });
|
|
205
|
+
// }
|
|
206
|
+
// });
|
|
207
|
+
// });
|
|
208
|
+
// }
|
|
209
|
+
export async function addConfigItem(newConfig) {
|
|
210
|
+
const list = getStoreValue("config");
|
|
211
|
+
setStoreValue("config", [...list, newConfig]);
|
|
212
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function getOS(): Promise<{
|
|
2
|
+
hostname: string;
|
|
3
|
+
ip: string | null;
|
|
4
|
+
macAddress: string | null;
|
|
5
|
+
operatingSystem: string;
|
|
6
|
+
architecture: NodeJS.Architecture;
|
|
7
|
+
availableProcessors: number;
|
|
8
|
+
freeMemory: number;
|
|
9
|
+
totalMemory: number;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function getLocalIpAddress(): string | null;
|
|
12
|
+
export declare function getFirstMacAddress(): string | null;
|