@cyklang/cli 0.7.5 → 0.8.3
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/Cmd.js +11 -5
- package/build/CronCommand.d.ts +4 -0
- package/build/CronCommand.js +43 -0
- package/build/QueryCommand.js +42 -0
- package/build/TableCommand.js +12 -3
- 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 +11 -0
- package/src/Cmd.ts +8 -3
- package/src/CronCommand.ts +40 -0
- package/src/QueryCommand.ts +42 -0
- package/src/TableCommand.ts +16 -6
- 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.output +23 -0
- package/test/{t10.xml → db/t10.xml} +25 -24
- package/test/db/t13.output +2 -0
- package/test/db/t13.xml +36 -0
- package/test/{t14.output → db/t14.output} +2 -0
- package/test/{t14.xml → db/t14.xml} +2 -2
- package/test/db/t15.output +10 -0
- package/test/db/t15.xml +47 -0
- package/test/db/t16.output +16 -0
- package/test/{t16.xml → db/t16.xml} +6 -6
- package/test/{t20.xml → db/t20.xml} +1 -1
- package/test/{t22.xml → db/t22.xml} +7 -7
- package/test/{t23.xml → db/t23.xml} +4 -4
- package/test/db/test_schema.xml +15 -0
- package/test/t09.output +1 -1
- package/test/t09.xml +1 -1
- 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
- package/test/cyklang.xsd +0 -1090
- package/test/t13.xml +0 -23
- package/test/t15.xml +0 -47
- package/test/t16.output +0 -49
- package/test/t19.xml +0 -234
- /package/test/{t14.xsd → db/t14.xsd} +0 -0
- /package/test/{t20.output → db/t20.output} +0 -0
- /package/test/{t21.output → db/t21.output} +0 -0
- /package/test/{t21.xml → db/t21.xml} +0 -0
- /package/test/{t22.output → db/t22.output} +0 -0
- /package/test/{t23.output → db/t23.output} +0 -0
package/build/Cmd.js
CHANGED
|
@@ -44,12 +44,18 @@ class Cmd extends commander_1.Command {
|
|
|
44
44
|
this.option('--env <env>', 'path to the environment variables file');
|
|
45
45
|
}
|
|
46
46
|
async prologue(options) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
if (options.env || fs.existsSync('.env')) {
|
|
48
|
+
const dotenvOutput = dotenv_1.default.config({ path: options.env });
|
|
49
|
+
if (dotenvOutput.error !== undefined)
|
|
50
|
+
throw dotenvOutput.error;
|
|
51
|
+
}
|
|
50
52
|
const structure = new core_1.Structure();
|
|
51
|
-
if (process.env.DBREMOTE_URL
|
|
52
|
-
throw 'DBREMOTE_URL undefined';
|
|
53
|
+
if (!process.env.DBREMOTE_URL)
|
|
54
|
+
throw 'DBREMOTE_URL environment variable undefined';
|
|
55
|
+
if (!process.env.USER_NAME)
|
|
56
|
+
throw 'USER_NAME environment variable undefined';
|
|
57
|
+
if (!process.env.USER_PASSWORD)
|
|
58
|
+
throw 'USER_PASSWORD environment variable undefined';
|
|
53
59
|
logger.info('Cyk server: ' + process.env.DBREMOTE_URL);
|
|
54
60
|
const nodeCrypto = new NodeCrypto_1.NodeCrypto();
|
|
55
61
|
this.dbRemote = new core_1.DBRemote(structure.scope, process.env.DBREMOTE_URL, nodeCrypto);
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.CronCommand = CronCommand;
|
|
23
|
+
class CronList extends Cmd_1.Cmd {
|
|
24
|
+
constructor(name) {
|
|
25
|
+
super(name);
|
|
26
|
+
this.description('List scheduled batches')
|
|
27
|
+
.action(async (options) => {
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class CronAddCmd extends Cmd_1.Cmd {
|
|
32
|
+
constructor(name) {
|
|
33
|
+
super(name);
|
|
34
|
+
this.description('add a batch scheduling with cron')
|
|
35
|
+
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
36
|
+
.option('-m --module <module_name>', 'module name')
|
|
37
|
+
.option('-f --function <function>', 'function called in the module')
|
|
38
|
+
.option('-p --param <parameter_name_value>', 'name and value separated by = character')
|
|
39
|
+
.action(async (options) => {
|
|
40
|
+
console.log('options', options);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
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/TableCommand.js
CHANGED
|
@@ -320,6 +320,7 @@ class TableDropCommand extends Cmd_1.Cmd {
|
|
|
320
320
|
constructor(name, description) {
|
|
321
321
|
super(name);
|
|
322
322
|
this.description(description)
|
|
323
|
+
.option('-y --yes', 'confirmation is not required')
|
|
323
324
|
.argument('<table>', 'table name')
|
|
324
325
|
.action(async (table, options) => {
|
|
325
326
|
await this.commandDrop(table, options);
|
|
@@ -335,8 +336,14 @@ class TableDropCommand extends Cmd_1.Cmd {
|
|
|
335
336
|
console.log('table ' + table + ' does not exist');
|
|
336
337
|
return;
|
|
337
338
|
}
|
|
338
|
-
|
|
339
|
-
if (
|
|
339
|
+
let dropConfirmed = (options.yes !== undefined);
|
|
340
|
+
if (dropConfirmed === false) {
|
|
341
|
+
const reply = await inquirer_1.default.prompt({ type: 'confirm', name: 'confirm', message: 'Drop table ' + table + '?' });
|
|
342
|
+
if (reply.confirm) {
|
|
343
|
+
dropConfirmed = true;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (dropConfirmed) {
|
|
340
347
|
await dropTable(table, this.dbManager);
|
|
341
348
|
}
|
|
342
349
|
}
|
|
@@ -352,7 +359,9 @@ class TableDropCommand extends Cmd_1.Cmd {
|
|
|
352
359
|
*/
|
|
353
360
|
async function dropTable(table, dbManager) {
|
|
354
361
|
const dbTable = await dbManager.dbTableExist(table);
|
|
355
|
-
if (dbTable)
|
|
362
|
+
if (dbTable) {
|
|
356
363
|
await dbManager.dbTableDelete(dbTable);
|
|
364
|
+
console.log('table ' + dbTable.name + ' dropped');
|
|
365
|
+
}
|
|
357
366
|
}
|
|
358
367
|
exports.dropTable = dropTable;
|
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.8.3",
|
|
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
ADDED
package/src/Cmd.ts
CHANGED
|
@@ -22,11 +22,16 @@ export class Cmd extends Command {
|
|
|
22
22
|
|
|
23
23
|
async prologue(options: any): Promise<SigninResponse> {
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (options.env || fs.existsSync('.env')) {
|
|
26
|
+
const dotenvOutput = dotenv.config({ path: options.env })
|
|
27
|
+
if (dotenvOutput.error !== undefined) throw dotenvOutput.error
|
|
28
|
+
}
|
|
27
29
|
|
|
28
30
|
const structure = new Structure()
|
|
29
|
-
if (process.env.DBREMOTE_URL
|
|
31
|
+
if (! process.env.DBREMOTE_URL) throw 'DBREMOTE_URL environment variable undefined'
|
|
32
|
+
if (! process.env.USER_NAME) throw 'USER_NAME environment variable undefined'
|
|
33
|
+
if (! process.env.USER_PASSWORD) throw 'USER_PASSWORD environment variable undefined'
|
|
34
|
+
|
|
30
35
|
logger.info('Cyk server: ' + process.env.DBREMOTE_URL)
|
|
31
36
|
const nodeCrypto = new NodeCrypto()
|
|
32
37
|
this.dbRemote = new DBRemote(structure.scope, process.env.DBREMOTE_URL, nodeCrypto)
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class CronList extends Cmd {
|
|
19
|
+
constructor(name: string) {
|
|
20
|
+
super(name)
|
|
21
|
+
this.description('List scheduled batches')
|
|
22
|
+
.action(async (options: any) => {
|
|
23
|
+
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class CronAddCmd extends Cmd {
|
|
29
|
+
constructor(name: string) {
|
|
30
|
+
super(name)
|
|
31
|
+
this.description('add a batch scheduling with cron')
|
|
32
|
+
.option('-s --schedule <schedule>', 'schedule in crontab format')
|
|
33
|
+
.option('-m --module <module_name>', 'module name')
|
|
34
|
+
.option('-f --function <function>', 'function called in the module')
|
|
35
|
+
.option('-p --param <parameter_name_value>', 'name and value separated by = character')
|
|
36
|
+
.action(async (options: any) => {
|
|
37
|
+
console.log('options', options)
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
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/TableCommand.ts
CHANGED
|
@@ -324,6 +324,7 @@ class TableDropCommand extends Cmd {
|
|
|
324
324
|
constructor(name: string, description: string) {
|
|
325
325
|
super(name)
|
|
326
326
|
this.description(description)
|
|
327
|
+
.option('-y --yes', 'confirmation is not required')
|
|
327
328
|
.argument('<table>', 'table name')
|
|
328
329
|
.action(async (table, options) => {
|
|
329
330
|
await this.commandDrop(table, options)
|
|
@@ -334,18 +335,25 @@ class TableDropCommand extends Cmd {
|
|
|
334
335
|
try {
|
|
335
336
|
await this.prologue(options)
|
|
336
337
|
if (!this.dbManager) throw 'dbManager undefined'
|
|
337
|
-
|
|
338
|
+
|
|
338
339
|
const dbTable = await this.dbManager.dbTableExist(table)
|
|
339
340
|
if (!dbTable) {
|
|
340
341
|
console.log('table ' + table + ' does not exist')
|
|
341
342
|
return
|
|
342
343
|
}
|
|
343
|
-
|
|
344
|
-
if (
|
|
344
|
+
let dropConfirmed = (options.yes !== undefined)
|
|
345
|
+
if (dropConfirmed === false) {
|
|
346
|
+
const reply = await inquirer.prompt({ type: 'confirm', name: 'confirm', message: 'Drop table ' + table + '?' })
|
|
347
|
+
if (reply.confirm) {
|
|
348
|
+
dropConfirmed = true
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (dropConfirmed) {
|
|
345
353
|
await dropTable(table, this.dbManager)
|
|
346
354
|
}
|
|
347
355
|
}
|
|
348
|
-
catch(err) {
|
|
356
|
+
catch (err) {
|
|
349
357
|
logger.error(err)
|
|
350
358
|
}
|
|
351
359
|
}
|
|
@@ -358,8 +366,10 @@ class TableDropCommand extends Cmd {
|
|
|
358
366
|
*/
|
|
359
367
|
export async function dropTable(table: string, dbManager: DBManager) {
|
|
360
368
|
const dbTable = await dbManager.dbTableExist(table)
|
|
361
|
-
if (dbTable)
|
|
362
|
-
await dbManager.dbTableDelete(dbTable)
|
|
369
|
+
if (dbTable) {
|
|
370
|
+
await dbManager.dbTableDelete(dbTable)
|
|
371
|
+
console.log('table ' + dbTable.name + ' dropped')
|
|
372
|
+
}
|
|
363
373
|
}
|
|
364
374
|
|
|
365
375
|
|
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>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
New film ID 1
|
|
2
|
+
films_actors.resultset.at(0).t_actor.last_name CHANE YOU KAYE
|
|
3
|
+
actor 1 Maria CHANE YOU KAYE, film 1 La mélodie du bonheur
|
|
4
|
+
string(films_actors.resultset) : <object>
|
|
5
|
+
<object name="t_actor">
|
|
6
|
+
<number name="actor_id">1</number>
|
|
7
|
+
<string name="first_name" literal="">Maria</string>
|
|
8
|
+
<string name="last_name" literal="">CHANE YOU KAYE</string>
|
|
9
|
+
<datetime name="last_update">
|
|
10
|
+
</datetime>
|
|
11
|
+
<string name="cyk_remark" literal="">remarque</string>
|
|
12
|
+
<boolean name="cyk_disable">
|
|
13
|
+
</boolean>
|
|
14
|
+
</object>
|
|
15
|
+
<object name="t_film">
|
|
16
|
+
<number name="film_id">1</number>
|
|
17
|
+
<string name="title" literal="">La mélodie du bonheur</string>
|
|
18
|
+
<string name="description" literal="">Le film préféré de Mao</string>
|
|
19
|
+
<number name="release_year">1965</number>
|
|
20
|
+
<number name="length">60</number>
|
|
21
|
+
<number name="language_id">1</number>
|
|
22
|
+
</object>
|
|
23
|
+
</object>
|