@cyklang/cli 0.8.0 → 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.d.ts +4 -0
- package/build/CronCommand.js +113 -0
- package/build/QueryCommand.js +42 -0
- package/build/TestCommand.js +2 -1
- package/build/console.js +1 -0
- package/build/index.js +4 -1
- package/clean_test.sh +20 -0
- package/package.json +3 -3
- package/run_test.sh +3 -3
- package/src/CronCommand.ts +113 -0
- package/src/QueryCommand.ts +42 -0
- package/src/TestCommand.ts +11 -10
- package/src/console.ts +1 -0
- package/src/index.ts +4 -1
- package/test/db/schema.xsd +74 -0
- package/test/db/t10.xml +4 -25
- package/test/db/t13.xml +15 -2
- package/test/db/t14.xml +1 -1
- package/test/db/t15.output +8 -2
- package/test/db/t15.xml +12 -10
- package/test/db/test_schema.xml +15 -0
- package/test/t27.output +2 -0
- package/test/t27.xml +22 -1
- package/build/TableData.d.ts +0 -5
- package/build/TableData.js +0 -61
- package/build/TestCommand copy.d.ts +0 -5
- package/build/TestCommand copy.js +0 -111
- package/build/cykquery.d.ts +0 -2
- package/build/cykquery.js +0 -145
- package/build/cyktable.d.ts +0 -2
- package/build/cyktable.js +0 -133
- package/build/module.d.ts +0 -2
- package/build/module.js +0 -290
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CronCommand = void 0;
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const loglevel_1 = __importDefault(require("loglevel"));
|
|
9
|
+
const Cmd_1 = require("./Cmd");
|
|
10
|
+
const logger = loglevel_1.default.getLogger('CronCommand.ts');
|
|
11
|
+
logger.setLevel('debug');
|
|
12
|
+
class CronCommand extends commander_1.Command {
|
|
13
|
+
constructor(name) {
|
|
14
|
+
super(name);
|
|
15
|
+
this.description('batch scheduling with cron')
|
|
16
|
+
.addCommand(new CronList('list'))
|
|
17
|
+
.addCommand(new CronList('l'))
|
|
18
|
+
.addCommand(new CronAddCmd('add'))
|
|
19
|
+
.addCommand(new CronAddCmd('a'))
|
|
20
|
+
.addCommand(new CronDeleteCmd('delete'))
|
|
21
|
+
.addCommand(new CronDeleteCmd('d'));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.CronCommand = CronCommand;
|
|
25
|
+
class CronList extends Cmd_1.Cmd {
|
|
26
|
+
constructor(name) {
|
|
27
|
+
super(name);
|
|
28
|
+
this.description('List scheduled batches')
|
|
29
|
+
.action(async (options) => {
|
|
30
|
+
await this.commandList(options);
|
|
31
|
+
});
|
|
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
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class CronAddCmd extends Cmd_1.Cmd {
|
|
45
|
+
constructor(name) {
|
|
46
|
+
super(name);
|
|
47
|
+
this.description('add a batch scheduling with cron')
|
|
48
|
+
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
49
|
+
.option('-m --module <module_name>', 'module name')
|
|
50
|
+
.option('-f --function <function>', 'function called in the module')
|
|
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"')
|
|
87
|
+
.action(async (options) => {
|
|
88
|
+
await this.commandDelete(options);
|
|
89
|
+
});
|
|
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
|
+
}
|
|
113
|
+
}
|
package/build/QueryCommand.js
CHANGED
|
@@ -9,6 +9,7 @@ const loglevel_1 = __importDefault(require("loglevel"));
|
|
|
9
9
|
const Cmd_1 = require("./Cmd");
|
|
10
10
|
const commander_1 = require("commander");
|
|
11
11
|
const DBClient_1 = require("./DBClient");
|
|
12
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
12
13
|
const logger = loglevel_1.default.getLogger("QueryCommand.ts");
|
|
13
14
|
logger.setLevel("debug");
|
|
14
15
|
class QueryCommand extends commander_1.Command {
|
|
@@ -17,6 +18,7 @@ class QueryCommand extends commander_1.Command {
|
|
|
17
18
|
this.description('query management');
|
|
18
19
|
this.addCommand(new QueryList('list', 'list queries'));
|
|
19
20
|
this.addCommand(new QueryList('l', 'list queries'));
|
|
21
|
+
this.addCommand(new QueryDelete('delete'));
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
exports.QueryCommand = QueryCommand;
|
|
@@ -40,6 +42,46 @@ class QueryList extends Cmd_1.Cmd {
|
|
|
40
42
|
dbClient.selectFromTable('List of Queries', 'cyk_query', { fields: 'query_id,query_name,query_auth,query_access,query_description', sort: options.sort || '1' });
|
|
41
43
|
}
|
|
42
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* class QueryDelete
|
|
47
|
+
*/
|
|
48
|
+
class QueryDelete extends Cmd_1.Cmd {
|
|
49
|
+
constructor(name) {
|
|
50
|
+
super(name);
|
|
51
|
+
this.description('delete query from cyk_query table')
|
|
52
|
+
.option('-y --yes', 'confirmation is not required')
|
|
53
|
+
.argument('<query>', 'query name')
|
|
54
|
+
.action(async (query, options) => {
|
|
55
|
+
await this.commandDelete(query, options);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async commandDelete(query, options) {
|
|
59
|
+
try {
|
|
60
|
+
await this.prologue(options);
|
|
61
|
+
if (!this.dbManager)
|
|
62
|
+
throw 'dbManager undefined';
|
|
63
|
+
const dbQuery = await this.dbManager.dbQueryExist(query);
|
|
64
|
+
if (!dbQuery) {
|
|
65
|
+
console.log('query ' + query + ' does not exist ');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
let deleteConfirmed = (options.yes !== undefined);
|
|
69
|
+
if (deleteConfirmed === false) {
|
|
70
|
+
const reply = await inquirer_1.default.prompt({ type: 'confirm', name: 'confirm', message: 'Delete query ' + query + '?' });
|
|
71
|
+
if (reply.confirm) {
|
|
72
|
+
deleteConfirmed = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (deleteConfirmed) {
|
|
76
|
+
await this.dbManager.dbQueryDelete(dbQuery);
|
|
77
|
+
console.log('Query ' + query + ' has been deleted');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
logger.error(err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
43
85
|
//--------------------------------------------------------------------------------------------------------------------
|
|
44
86
|
// class queryData
|
|
45
87
|
//--------------------------------------------------------------------------------------------------------------------
|
package/build/TestCommand.js
CHANGED
|
@@ -112,7 +112,8 @@ async function testfile(filename) {
|
|
|
112
112
|
let xmlError = err;
|
|
113
113
|
(0, console_1.errorconsole)(xmlError);
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
else
|
|
116
|
+
console.log(err);
|
|
116
117
|
}
|
|
117
118
|
let log = fs.readFileSync(logfilename);
|
|
118
119
|
if (fs.existsSync(outfilename) === true) {
|
package/build/console.js
CHANGED
package/build/index.js
CHANGED
|
@@ -43,6 +43,7 @@ const TableDataCommand_1 = require("./TableDataCommand");
|
|
|
43
43
|
const TestCommand_1 = require("./TestCommand");
|
|
44
44
|
const UninstallCommand_1 = require("./UninstallCommand");
|
|
45
45
|
const UserCommand_1 = require("./UserCommand");
|
|
46
|
+
const CronCommand_1 = require("./CronCommand");
|
|
46
47
|
const logger = loglevel_1.default.getLogger("index.ts");
|
|
47
48
|
logger.setLevel("debug");
|
|
48
49
|
/**
|
|
@@ -181,7 +182,7 @@ class StopCommand extends commander_1.Command {
|
|
|
181
182
|
*/
|
|
182
183
|
const program = new commander_1.Command();
|
|
183
184
|
program.name('cyk').description('cyklang CLI')
|
|
184
|
-
.version('0.
|
|
185
|
+
.version('0.8.3');
|
|
185
186
|
program.addCommand(new StartCommand('start'));
|
|
186
187
|
program.addCommand(new StopCommand('stop'));
|
|
187
188
|
program.addCommand(new InstallCommand_1.InstallCommand('install'));
|
|
@@ -204,4 +205,6 @@ program.addCommand(new RunCommand_1.RunCommand('run'));
|
|
|
204
205
|
program.addCommand(new RunCommand_1.RunCommand('r'));
|
|
205
206
|
program.addCommand(new OpenCommand_1.OpenCommand('open'));
|
|
206
207
|
program.addCommand(new OpenCommand_1.OpenCommand('o'));
|
|
208
|
+
program.addCommand(new CronCommand_1.CronCommand('cron'));
|
|
209
|
+
program.addCommand(new CronCommand_1.CronCommand('c'));
|
|
207
210
|
program.parse();
|
package/clean_test.sh
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
cyk table drop -y t_film_actor
|
|
4
|
+
cyk table drop -y t_film
|
|
5
|
+
cyk table drop -y t_actor
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
psql -c "
|
|
9
|
+
do \$\$
|
|
10
|
+
declare next_id int;
|
|
11
|
+
begin
|
|
12
|
+
select max(table_id)+1 from cyk_table into next_id;
|
|
13
|
+
execute 'alter sequence cyk_table_table_id_seq restart with ' || next_id ;
|
|
14
|
+
end \$\$
|
|
15
|
+
"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyklang/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "cyklang CLI",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"npm:upgrade": "npx npm-check-updates -iu",
|
|
12
12
|
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install",
|
|
13
13
|
"dev": "nodemon -e ts --ignore build --exec \"npm run global\" ",
|
|
14
|
-
"test": "
|
|
14
|
+
"test": "./run_test.sh"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"author": "",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cyklang/core": "^0.
|
|
20
|
+
"@cyklang/core": "^0.6.2",
|
|
21
21
|
"commander": "^9.4.0",
|
|
22
22
|
"dotenv": "^16.0.1",
|
|
23
23
|
"form-data": "^4.0.0",
|
package/run_test.sh
CHANGED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import loglevel from 'loglevel'
|
|
3
|
+
import { Cmd } from "./Cmd";
|
|
4
|
+
const logger = loglevel.getLogger('CronCommand.ts')
|
|
5
|
+
logger.setLevel('debug')
|
|
6
|
+
|
|
7
|
+
export class CronCommand extends Command {
|
|
8
|
+
constructor(name: string) {
|
|
9
|
+
super(name)
|
|
10
|
+
this.description('batch scheduling with cron')
|
|
11
|
+
.addCommand(new CronList('list'))
|
|
12
|
+
.addCommand(new CronList('l'))
|
|
13
|
+
.addCommand(new CronAddCmd('add'))
|
|
14
|
+
.addCommand(new CronAddCmd('a'))
|
|
15
|
+
.addCommand(new CronDeleteCmd('delete'))
|
|
16
|
+
.addCommand(new CronDeleteCmd('d'))
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class CronList extends Cmd {
|
|
21
|
+
constructor(name: string) {
|
|
22
|
+
super(name)
|
|
23
|
+
this.description('List scheduled batches')
|
|
24
|
+
.action(async (options: any) => {
|
|
25
|
+
await this.commandList(options)
|
|
26
|
+
})
|
|
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
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class CronAddCmd extends Cmd {
|
|
43
|
+
constructor(name: string) {
|
|
44
|
+
super(name)
|
|
45
|
+
this.description('add a batch scheduling with cron')
|
|
46
|
+
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
47
|
+
.option('-m --module <module_name>', 'module name')
|
|
48
|
+
.option('-f --function <function>', 'function called in the module')
|
|
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"')
|
|
87
|
+
.action(async (options: any) => {
|
|
88
|
+
await this.commandDelete(options)
|
|
89
|
+
})
|
|
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
|
+
}
|
|
113
|
+
}
|
package/src/QueryCommand.ts
CHANGED
|
@@ -5,6 +5,7 @@ import loglevel from 'loglevel'
|
|
|
5
5
|
import { Cmd } from './Cmd'
|
|
6
6
|
import { Command } from 'commander'
|
|
7
7
|
import { DBClient } from "./DBClient"
|
|
8
|
+
import inquirer from 'inquirer'
|
|
8
9
|
const logger = loglevel.getLogger("QueryCommand.ts")
|
|
9
10
|
logger.setLevel("debug")
|
|
10
11
|
|
|
@@ -14,6 +15,7 @@ export class QueryCommand extends Command {
|
|
|
14
15
|
this.description('query management')
|
|
15
16
|
this.addCommand(new QueryList('list', 'list queries'))
|
|
16
17
|
this.addCommand(new QueryList('l', 'list queries'))
|
|
18
|
+
this.addCommand(new QueryDelete('delete'))
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -42,7 +44,47 @@ class QueryList extends Cmd {
|
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
/**
|
|
48
|
+
* class QueryDelete
|
|
49
|
+
*/
|
|
50
|
+
class QueryDelete extends Cmd {
|
|
51
|
+
constructor(name: string) {
|
|
52
|
+
super(name)
|
|
53
|
+
this.description('delete query from cyk_query table')
|
|
54
|
+
.option('-y --yes', 'confirmation is not required')
|
|
55
|
+
.argument('<query>', 'query name')
|
|
56
|
+
.action(async (query, options) => {
|
|
57
|
+
await this.commandDelete(query, options)
|
|
58
|
+
})
|
|
59
|
+
}
|
|
45
60
|
|
|
61
|
+
async commandDelete(query: string, options: any) {
|
|
62
|
+
try {
|
|
63
|
+
await this.prologue(options)
|
|
64
|
+
if (! this.dbManager) throw 'dbManager undefined'
|
|
65
|
+
|
|
66
|
+
const dbQuery = await this.dbManager.dbQueryExist(query)
|
|
67
|
+
if (! dbQuery ) {
|
|
68
|
+
console.log('query ' + query + ' does not exist ')
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
let deleteConfirmed = (options.yes !== undefined)
|
|
72
|
+
if (deleteConfirmed === false) {
|
|
73
|
+
const reply = await inquirer.prompt({ type: 'confirm', name: 'confirm', message: 'Delete query ' + query + '?' })
|
|
74
|
+
if (reply.confirm) {
|
|
75
|
+
deleteConfirmed = true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (deleteConfirmed) {
|
|
79
|
+
await this.dbManager.dbQueryDelete(dbQuery)
|
|
80
|
+
console.log('Query ' + query + ' has been deleted')
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
logger.error(err)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
46
88
|
|
|
47
89
|
//--------------------------------------------------------------------------------------------------------------------
|
|
48
90
|
// class queryData
|
package/src/TestCommand.ts
CHANGED
|
@@ -11,15 +11,15 @@ export class TestCommand extends Cmd {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
super('test')
|
|
13
13
|
this.description('test script').version('0.1')
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
.argument('<files...>', 'local module file(s) to test run')
|
|
15
|
+
.action(async (files: any, options: any) => {
|
|
16
|
+
await this.testRun(files, options)
|
|
17
|
+
})
|
|
18
18
|
}
|
|
19
19
|
async testRun(files: string[], options: any) {
|
|
20
20
|
try {
|
|
21
21
|
const signinResponse = await this.prologue(options)
|
|
22
|
-
for (let ind=0; ind < files.length; ind++) {
|
|
22
|
+
for (let ind = 0; ind < files.length; ind++) {
|
|
23
23
|
const result = await testfile(files[ind])
|
|
24
24
|
if (result === false) {
|
|
25
25
|
logger.debug('*********** FAILURE ' + files[ind] + ' ***************')
|
|
@@ -50,12 +50,12 @@ async function testfile(filename: string): Promise<boolean> {
|
|
|
50
50
|
|
|
51
51
|
let xml = fs.readFileSync(xmlfilename)
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
fs.writeFileSync(logfilename, "")
|
|
55
55
|
//console.log(xml.toString())
|
|
56
56
|
try {
|
|
57
57
|
if (process.env.DBREMOTE_URL === undefined) throw 'DBREMOTE_URL undefined'
|
|
58
|
-
logger.trace('DBREMOTE_URL '+process.env.DBREMOTE_URL)
|
|
58
|
+
logger.trace('DBREMOTE_URL ' + process.env.DBREMOTE_URL)
|
|
59
59
|
const structure = new Structure()
|
|
60
60
|
const nodeCrypto = new NodeCrypto()
|
|
61
61
|
const dbRemote = new DBRemote(structure.scope, process.env.DBREMOTE_URL, nodeCrypto)
|
|
@@ -67,7 +67,7 @@ async function testfile(filename: string): Promise<boolean> {
|
|
|
67
67
|
let script = new Script(structure.scope, xmlfilename, xml.toString())
|
|
68
68
|
const user_lang = login.content.user_lang
|
|
69
69
|
if (user_lang && user_lang.trim() !== '') {
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
const langfilename = filename + "__" + user_lang + ".xml"
|
|
72
72
|
|
|
73
73
|
if (fs.existsSync(langfilename)) {
|
|
@@ -97,11 +97,12 @@ async function testfile(filename: string): Promise<boolean> {
|
|
|
97
97
|
let xmlError = <XmlError>err
|
|
98
98
|
errorconsole(xmlError)
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
else
|
|
101
|
+
console.log(err)
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
let log = fs.readFileSync(logfilename)
|
|
104
|
-
if (fs.existsSync(outfilename) === true
|
|
105
|
+
if (fs.existsSync(outfilename) === true) {
|
|
105
106
|
let out = fs.readFileSync(outfilename)
|
|
106
107
|
|
|
107
108
|
if (log.toString() === out.toString()) {
|
package/src/console.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { TableDataCommand } from './TableDataCommand'
|
|
|
15
15
|
import { TestCommand } from './TestCommand'
|
|
16
16
|
import { UninstallCommand } from './UninstallCommand'
|
|
17
17
|
import { UserCommand } from './UserCommand'
|
|
18
|
+
import { CronCommand } from './CronCommand'
|
|
18
19
|
|
|
19
20
|
const logger = loglevel.getLogger("index.ts")
|
|
20
21
|
logger.setLevel("debug")
|
|
@@ -175,7 +176,7 @@ class StopCommand extends Command {
|
|
|
175
176
|
*/
|
|
176
177
|
const program = new Command()
|
|
177
178
|
program.name('cyk').description('cyklang CLI')
|
|
178
|
-
.version('0.
|
|
179
|
+
.version('0.8.3')
|
|
179
180
|
program.addCommand(new StartCommand('start'))
|
|
180
181
|
program.addCommand(new StopCommand('stop'))
|
|
181
182
|
program.addCommand(new InstallCommand('install'))
|
|
@@ -198,5 +199,7 @@ program.addCommand(new RunCommand('run'))
|
|
|
198
199
|
program.addCommand(new RunCommand('r'))
|
|
199
200
|
program.addCommand(new OpenCommand('open'))
|
|
200
201
|
program.addCommand(new OpenCommand('o'))
|
|
202
|
+
program.addCommand(new CronCommand('cron'))
|
|
203
|
+
program.addCommand(new CronCommand('c'))
|
|
201
204
|
|
|
202
205
|
program.parse()
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
3
|
+
|
|
4
|
+
<xs:element name="query" type="queryType"/>
|
|
5
|
+
<xs:element name="object" type="declareObject"/>
|
|
6
|
+
|
|
7
|
+
<xs:complexType name="declareObject" mixed="true">
|
|
8
|
+
<xs:group ref="declareVariable" minOccurs="0" maxOccurs="unbounded"/>
|
|
9
|
+
<xs:attribute name="name" type="xs:string"/>
|
|
10
|
+
<xs:attribute name="type" type="xs:string"/>
|
|
11
|
+
</xs:complexType>
|
|
12
|
+
|
|
13
|
+
<xs:complexType name="queryType" mixed="true">
|
|
14
|
+
<xs:group ref="queryTypeChild" minOccurs="1" maxOccurs="unbounded"/>
|
|
15
|
+
<xs:attribute name="name" type="xs:string"/>
|
|
16
|
+
</xs:complexType>
|
|
17
|
+
|
|
18
|
+
<xs:group name="queryTypeChild">
|
|
19
|
+
<xs:choice>
|
|
20
|
+
<xs:element name="string" type="queryStringChild"/>
|
|
21
|
+
<xs:element name="object" type="queryObjectChild"/>
|
|
22
|
+
</xs:choice>
|
|
23
|
+
</xs:group>
|
|
24
|
+
|
|
25
|
+
<xs:complexType name="queryStringChild">
|
|
26
|
+
<xs:simpleContent>
|
|
27
|
+
<xs:restriction base="stringType">
|
|
28
|
+
<xs:attribute name="name" use="required">
|
|
29
|
+
<xs:simpleType>
|
|
30
|
+
<xs:restriction base="xs:string">
|
|
31
|
+
<xs:enumeration value="sql"></xs:enumeration>
|
|
32
|
+
<xs:enumeration value="fields"></xs:enumeration>
|
|
33
|
+
<xs:enumeration value="entities"></xs:enumeration>
|
|
34
|
+
</xs:restriction>
|
|
35
|
+
</xs:simpleType>
|
|
36
|
+
</xs:attribute>
|
|
37
|
+
</xs:restriction>
|
|
38
|
+
</xs:simpleContent>
|
|
39
|
+
</xs:complexType>
|
|
40
|
+
|
|
41
|
+
<xs:complexType name="queryObjectChild" mixed="true">
|
|
42
|
+
<xs:group ref="declareVariable" minOccurs="0" maxOccurs="unbounded"/>
|
|
43
|
+
<xs:attribute name="name" type="xs:string" fixed="params"/>
|
|
44
|
+
</xs:complexType>
|
|
45
|
+
|
|
46
|
+
<xs:group name="declareVariable">
|
|
47
|
+
<xs:choice>
|
|
48
|
+
<xs:element name="number" type="numberType"/>
|
|
49
|
+
<xs:element name="string" type="stringType"/>
|
|
50
|
+
<xs:element name="query" type="queryType"/>
|
|
51
|
+
<xs:element name="object" type="declareObject"/>
|
|
52
|
+
</xs:choice>
|
|
53
|
+
</xs:group>
|
|
54
|
+
|
|
55
|
+
<xs:complexType name="numberType">
|
|
56
|
+
<xs:simpleContent>
|
|
57
|
+
<xs:extension base="xs:string">
|
|
58
|
+
<xs:attribute name="name" type="xs:string"/>
|
|
59
|
+
</xs:extension>
|
|
60
|
+
</xs:simpleContent>
|
|
61
|
+
|
|
62
|
+
</xs:complexType>
|
|
63
|
+
|
|
64
|
+
<xs:complexType name="stringType">
|
|
65
|
+
<xs:simpleContent>
|
|
66
|
+
<xs:extension base="xs:string">
|
|
67
|
+
<xs:attribute name="name" type="xs:string"/>
|
|
68
|
+
<xs:attribute name="literal" type="xs:string" fixed=""/>
|
|
69
|
+
</xs:extension>
|
|
70
|
+
</xs:simpleContent>
|
|
71
|
+
|
|
72
|
+
</xs:complexType>
|
|
73
|
+
|
|
74
|
+
</xs:schema>
|