@cyklang/cli 0.8.3 → 0.9.0
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/build/CronCommand.js +73 -3
- package/package.json +1 -1
- package/src/CronCommand.ts +76 -3
package/build/CronCommand.js
CHANGED
|
@@ -16,7 +16,9 @@ class CronCommand extends commander_1.Command {
|
|
|
16
16
|
.addCommand(new CronList('list'))
|
|
17
17
|
.addCommand(new CronList('l'))
|
|
18
18
|
.addCommand(new CronAddCmd('add'))
|
|
19
|
-
.addCommand(new CronAddCmd('a'))
|
|
19
|
+
.addCommand(new CronAddCmd('a'))
|
|
20
|
+
.addCommand(new CronDeleteCmd('delete'))
|
|
21
|
+
.addCommand(new CronDeleteCmd('d'));
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
exports.CronCommand = CronCommand;
|
|
@@ -25,8 +27,19 @@ class CronList extends Cmd_1.Cmd {
|
|
|
25
27
|
super(name);
|
|
26
28
|
this.description('List scheduled batches')
|
|
27
29
|
.action(async (options) => {
|
|
30
|
+
await this.commandList(options);
|
|
28
31
|
});
|
|
29
32
|
}
|
|
33
|
+
async commandList(options) {
|
|
34
|
+
try {
|
|
35
|
+
await this.prologue(options);
|
|
36
|
+
const json = await this.dbRemote?.apiServer.get('/api/admin/cron');
|
|
37
|
+
console.log(json);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
logger.error(err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
30
43
|
}
|
|
31
44
|
class CronAddCmd extends Cmd_1.Cmd {
|
|
32
45
|
constructor(name) {
|
|
@@ -35,9 +48,66 @@ class CronAddCmd extends Cmd_1.Cmd {
|
|
|
35
48
|
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
36
49
|
.option('-m --module <module_name>', 'module name')
|
|
37
50
|
.option('-f --function <function>', 'function called in the module')
|
|
38
|
-
.option('-p --
|
|
51
|
+
.option('-p --params <name_value_pairs>', 'URL encoded form without ? (question mark) ie "p1=val1&p2=val2"')
|
|
52
|
+
.action(async (options) => {
|
|
53
|
+
await this.commandAdd(options);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* @param options
|
|
59
|
+
*/
|
|
60
|
+
async commandAdd(options) {
|
|
61
|
+
try {
|
|
62
|
+
await this.prologue(options);
|
|
63
|
+
if (!this.dbRemote)
|
|
64
|
+
throw 'dbRemote undefined';
|
|
65
|
+
const payload = {
|
|
66
|
+
schedule: options.schedule,
|
|
67
|
+
module: options.module,
|
|
68
|
+
function: options.function,
|
|
69
|
+
params: options.params
|
|
70
|
+
};
|
|
71
|
+
const response = await this.dbRemote.apiServer.post('/api/admin/cron', payload);
|
|
72
|
+
logger.debug(response);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
logger.error(err);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class CronDeleteCmd extends Cmd_1.Cmd {
|
|
80
|
+
constructor(name) {
|
|
81
|
+
super(name);
|
|
82
|
+
this.description('delete a batch scheduling with cron')
|
|
83
|
+
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
84
|
+
.option('-m --module <module_name>', 'module name')
|
|
85
|
+
.option('-f --function <function>', 'function called in the module')
|
|
86
|
+
.option('-p --params <name_value_pairs>', 'URL encoded form without ? (question mark) ie "p1=val1&p2=val2"')
|
|
39
87
|
.action(async (options) => {
|
|
40
|
-
|
|
88
|
+
await this.commandDelete(options);
|
|
41
89
|
});
|
|
42
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param options
|
|
94
|
+
*/
|
|
95
|
+
async commandDelete(options) {
|
|
96
|
+
try {
|
|
97
|
+
await this.prologue(options);
|
|
98
|
+
if (!this.dbRemote)
|
|
99
|
+
throw 'dbRemote undefined';
|
|
100
|
+
const payload = {
|
|
101
|
+
schedule: options.schedule,
|
|
102
|
+
module: options.module,
|
|
103
|
+
function: options.function,
|
|
104
|
+
params: options.params
|
|
105
|
+
};
|
|
106
|
+
const response = await this.dbRemote.apiServer.delete('/api/admin/cron', payload);
|
|
107
|
+
logger.debug(response);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
logger.error(err);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
43
113
|
}
|
package/package.json
CHANGED
package/src/CronCommand.ts
CHANGED
|
@@ -12,6 +12,8 @@ export class CronCommand extends Command {
|
|
|
12
12
|
.addCommand(new CronList('l'))
|
|
13
13
|
.addCommand(new CronAddCmd('add'))
|
|
14
14
|
.addCommand(new CronAddCmd('a'))
|
|
15
|
+
.addCommand(new CronDeleteCmd('delete'))
|
|
16
|
+
.addCommand(new CronDeleteCmd('d'))
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
|
|
@@ -20,9 +22,21 @@ class CronList extends Cmd {
|
|
|
20
22
|
super(name)
|
|
21
23
|
this.description('List scheduled batches')
|
|
22
24
|
.action(async (options: any) => {
|
|
23
|
-
|
|
25
|
+
await this.commandList(options)
|
|
24
26
|
})
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
async commandList(options: any) {
|
|
30
|
+
try {
|
|
31
|
+
await this.prologue(options)
|
|
32
|
+
|
|
33
|
+
const json = await this.dbRemote?.apiServer.get('/api/admin/cron')
|
|
34
|
+
console.log(json)
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
logger.error(err)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
26
40
|
}
|
|
27
41
|
|
|
28
42
|
class CronAddCmd extends Cmd {
|
|
@@ -32,9 +46,68 @@ class CronAddCmd extends Cmd {
|
|
|
32
46
|
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
33
47
|
.option('-m --module <module_name>', 'module name')
|
|
34
48
|
.option('-f --function <function>', 'function called in the module')
|
|
35
|
-
.option('-p --
|
|
49
|
+
.option('-p --params <name_value_pairs>', 'URL encoded form without ? (question mark) ie "p1=val1&p2=val2"')
|
|
50
|
+
.action(async (options: any) => {
|
|
51
|
+
await this.commandAdd(options)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param options
|
|
57
|
+
*/
|
|
58
|
+
async commandAdd(options: any) {
|
|
59
|
+
try {
|
|
60
|
+
|
|
61
|
+
await this.prologue(options)
|
|
62
|
+
if (! this.dbRemote) throw 'dbRemote undefined'
|
|
63
|
+
const payload: any = {
|
|
64
|
+
schedule: options.schedule,
|
|
65
|
+
module: options.module,
|
|
66
|
+
function: options.function,
|
|
67
|
+
params: options.params
|
|
68
|
+
}
|
|
69
|
+
const response = await this.dbRemote.apiServer.post('/api/admin/cron', payload)
|
|
70
|
+
logger.debug(response)
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
logger.error(err)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
class CronDeleteCmd extends Cmd {
|
|
80
|
+
constructor(name: string) {
|
|
81
|
+
super(name)
|
|
82
|
+
this.description('delete a batch scheduling with cron')
|
|
83
|
+
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
84
|
+
.option('-m --module <module_name>', 'module name')
|
|
85
|
+
.option('-f --function <function>', 'function called in the module')
|
|
86
|
+
.option('-p --params <name_value_pairs>', 'URL encoded form without ? (question mark) ie "p1=val1&p2=val2"')
|
|
36
87
|
.action(async (options: any) => {
|
|
37
|
-
|
|
88
|
+
await this.commandDelete(options)
|
|
38
89
|
})
|
|
39
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param options
|
|
94
|
+
*/
|
|
95
|
+
async commandDelete(options: any) {
|
|
96
|
+
try {
|
|
97
|
+
|
|
98
|
+
await this.prologue(options)
|
|
99
|
+
if (! this.dbRemote) throw 'dbRemote undefined'
|
|
100
|
+
const payload: any = {
|
|
101
|
+
schedule: options.schedule,
|
|
102
|
+
module: options.module,
|
|
103
|
+
function: options.function,
|
|
104
|
+
params: options.params
|
|
105
|
+
}
|
|
106
|
+
const response = await this.dbRemote.apiServer.delete('/api/admin/cron', payload)
|
|
107
|
+
logger.debug(response)
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
logger.error(err)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
40
113
|
}
|