@kumologica/sdk 3.0.0 → 3.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/cli/commands/test.js +49 -26
- package/package.json +4 -4
package/cli/commands/test.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
exports.command = 'test';
|
|
2
|
-
exports.desc = `Run test suite`;
|
|
3
|
-
|
|
4
|
-
exports.builder = {
|
|
5
|
-
"flow-file-name": {
|
|
6
|
-
describe: "The name of kumologica flow file.\n Auto search if not provided.",
|
|
7
|
-
type: 'string',
|
|
8
|
-
alias: 'f',
|
|
9
|
-
nargs: 1
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
1
|
const chalk = require('chalk');
|
|
14
|
-
const
|
|
15
|
-
const
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const { logError } = require('./utils');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
16
6
|
const { AppServer } = require('@kumologica/runtime');
|
|
17
7
|
const { TestSuiteController } = require('./test-utils/TestSuiteController');
|
|
18
|
-
const path = require('path');
|
|
19
8
|
const { codegen } = require('@kumologica/builder');
|
|
9
|
+
|
|
10
|
+
const log = console.log;
|
|
11
|
+
const APP_SERVER_PORT = 1990;
|
|
20
12
|
|
|
21
13
|
async function runTest(flowFilePath) {
|
|
22
|
-
log(
|
|
14
|
+
log(`\n> Starting runtime on port ${APP_SERVER_PORT}...`);
|
|
23
15
|
|
|
24
16
|
let appServer = new AppServer({
|
|
25
|
-
projectDir:
|
|
17
|
+
projectDir: path.dirname(flowFilePath),
|
|
26
18
|
flowFilePath: flowFilePath,
|
|
27
19
|
port: APP_SERVER_PORT,
|
|
28
20
|
serverMode: AppServer.mode.HEADLESS_DEFAULT_EXPRESS,
|
|
@@ -33,7 +25,7 @@ async function runTest(flowFilePath) {
|
|
|
33
25
|
|
|
34
26
|
try {
|
|
35
27
|
await appServer.start();
|
|
36
|
-
log(
|
|
28
|
+
log(`> FlowFile to be tested: ${chalk.bold(path.resolve(flowFilePath))} \n`);
|
|
37
29
|
let testSuiteController = new TestSuiteController(appServer);
|
|
38
30
|
await testSuiteController.runTestSuite(); // no need to wait for response
|
|
39
31
|
process.exit(0);
|
|
@@ -47,18 +39,49 @@ async function runTest(flowFilePath) {
|
|
|
47
39
|
}
|
|
48
40
|
}
|
|
49
41
|
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
function isDirectory(dir) {
|
|
43
|
+
try{
|
|
44
|
+
let stats = fs.statSync(dir);
|
|
45
|
+
return stats.isDirectory();
|
|
46
|
+
} catch (err) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.command = 'test [project_dir]';
|
|
54
|
+
exports.desc = `Run test suite`;
|
|
55
|
+
|
|
56
|
+
exports.builder = (yargs) => {
|
|
57
|
+
yargs.positional(`project_dir`, {
|
|
58
|
+
type: 'string',
|
|
59
|
+
describe: 'Path to a valid kumologica project directory or flow file. (Optional)'
|
|
60
|
+
})
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
exports.handler =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
exports.handler = ({ project_dir }) => {
|
|
64
|
+
let projectDirOrFile = project_dir || process.cwd();
|
|
65
|
+
let projectFlowPath = projectDirOrFile;
|
|
66
|
+
|
|
67
|
+
let isDir = isDirectory(projectDirOrFile);
|
|
68
|
+
if (isDir){
|
|
69
|
+
let flowFileName = codegen.findFlowFile(projectDirOrFile); // returns only the flowname
|
|
70
|
+
if (!flowFileName){
|
|
71
|
+
logError(`No flow found in directory: ${projectDirOrFile}`);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}else {
|
|
74
|
+
projectFlowPath = path.join(projectDirOrFile, flowFileName);
|
|
75
|
+
}
|
|
76
|
+
} else if (isDir === false){
|
|
77
|
+
// do nothing as it was assumed to be a file
|
|
78
|
+
} else {
|
|
79
|
+
logError(`Directory does not exist: ${project_dir}`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
59
82
|
|
|
60
83
|
try {
|
|
61
|
-
runTest(
|
|
84
|
+
runTest(projectFlowPath);
|
|
62
85
|
} catch (e) {
|
|
63
86
|
console.log(`${e.message}`);
|
|
64
87
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"productName": "Kumologica Designer",
|
|
4
4
|
"copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
|
|
5
5
|
"author": "Kumologica Pty Ltd <contact@kumologica.com>",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.1",
|
|
7
7
|
"description": "Kumologica Designer, harnessing Serverless for your cloud integration needs",
|
|
8
8
|
"main": "src/app/main.js",
|
|
9
9
|
"files": [
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
},
|
|
65
65
|
"license": "Proprietary",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@kumologica/builder": "3.0.
|
|
68
|
-
"@kumologica/runtime": "3.0.
|
|
69
|
-
"@kumologica/devkit": "3.0.
|
|
67
|
+
"@kumologica/builder": "3.0.1",
|
|
68
|
+
"@kumologica/runtime": "3.0.1",
|
|
69
|
+
"@kumologica/devkit": "3.0.1",
|
|
70
70
|
"adm-zip": "^0.4.13",
|
|
71
71
|
"ajv": "^8.10.0",
|
|
72
72
|
"aws-sdk": "^2.513.0",
|