-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
46 lines (45 loc) · 1.53 KB
/
start.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const { post } = require('../../helpers/request-helper');
const startHandler = async ({ endpoint, rejectUnauthorized, algorithmName, devFolder, $0: appName }) => {
// get all parameters, decorate,
const body = {
name: algorithmName,
options: {
devMode: true,
devFolder
}
};
// send update, if doesn't exist, exit.
const res = await post({ endpoint, rejectUnauthorized, path: 'store/algorithms?overwrite=true', body });
if (res.result.error || res.error) {
let msg;
msg = res.result.error.message.includes('missing') ? "algorithm doesn't exist" : msg = res.result.error.message;
console.log(`code: ${res.result.error.code}, message: ${msg}`);
return;
}
console.log(`algorithm ${algorithmName} modified to be in development mode.`);
console.log('to sync the folder to the algorithm run');
console.log(`${appName} sync watch -a ${algorithmName} -f localAlgoFolder`);
};
module.exports = {
command: 'start',
description: 'start an existing algorithm in development mode',
options: {
},
builder: {
algorithmName: {
demandOption: true,
describe: 'The name of the algorithm to sync data into',
type: 'string',
alias: ['a']
},
devFolder: {
demandOption: true,
describe: 'folder in pod to sync to',
type: 'string',
alias: ['f']
}
},
handler: async (argv) => {
await startHandler(argv);
}
};