@mimik/local 1.6.0 → 4.4.2
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/.eslintrc +15 -3
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +4 -0
- package/Gulpfile.js +6 -7
- package/README.md +164 -17
- package/configuration/config.js +4 -4
- package/index.js +365 -94
- package/lib/common.js +55 -3
- package/lib/commonExt.js +29 -21
- package/lib/helpers.js +81 -40
- package/lib/rp-axios-wrapper.js +36 -0
- package/lib/tasks.js +225 -94
- package/manual-test/getAPI.js +1 -1
- package/manual-test/retrieve.js +5 -3
- package/manual-test/start-example.json +46 -0
- package/manual-test/startTest-example.json +8 -0
- package/manual-test/test.json +46 -0
- package/manual-test/testMerge.js +66 -0
- package/manual-test/testString.js +7 -0
- package/package.json +28 -20
- package/package.json.bak +0 -57
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const colors = require('colors');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const json = require('comment-json');
|
|
4
|
+
|
|
5
|
+
colors.setTheme({
|
|
6
|
+
success: 'green',
|
|
7
|
+
warn: 'yellow',
|
|
8
|
+
error: 'red',
|
|
9
|
+
info: ['grey', 'bold'],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const exitError = (regType, error, filename) => {
|
|
13
|
+
let details = `{ statusCode: ${error.statusCode || 500}, message: ${error.message || error}`;
|
|
14
|
+
|
|
15
|
+
if (filename) details = `, ${details}, filename: ${filename}`;
|
|
16
|
+
details = `${details} }`;
|
|
17
|
+
console.error(`${regType}status: ` + 'error'.error + ', ' + details.info);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const regType = 'test';
|
|
22
|
+
|
|
23
|
+
const readMerge = (fname, fnameSupp) => {
|
|
24
|
+
const parse = (rawFile, rawFilename) => {
|
|
25
|
+
try { return json.parse(rawFile); }
|
|
26
|
+
catch (errParse) { exitError(regType, errParse, rawFilename); }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const merge = (origRawFile, parsedFile, origRawFileSupp, parsedFileSupp) => {
|
|
30
|
+
const keysParsedFile = Object.keys(parsedFile);
|
|
31
|
+
let rawFile = origRawFile;
|
|
32
|
+
let rawFileSupp = origRawFileSupp;
|
|
33
|
+
|
|
34
|
+
Object.keys(parsedFileSupp).forEach((key) => {
|
|
35
|
+
if (keysParsedFile.includes(key)) {
|
|
36
|
+
const regex = new RegExp(`\n[ \t]+"${key}"`);
|
|
37
|
+
|
|
38
|
+
rawFile = rawFile.replace(regex, `\n// "${key}"`)
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
rawFile = rawFile.substring(0, rawFile.length - 2);
|
|
42
|
+
rawFileSupp = rawFileSupp.substring(1);
|
|
43
|
+
return `${rawFile},\n//-- test\n${rawFileSupp}`;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
let readFileRaw;
|
|
47
|
+
let readFileSuppRaw;
|
|
48
|
+
|
|
49
|
+
try { readFileRaw = fs.readFileSync(fname).toString(); }
|
|
50
|
+
catch (errFname) {
|
|
51
|
+
if (errFname.code !== 'ENOENT') exitError(regType, errFname, fname);
|
|
52
|
+
throw errFname;
|
|
53
|
+
}
|
|
54
|
+
const readFile = parse(readFileRaw, fname);
|
|
55
|
+
|
|
56
|
+
try { readFileSuppRaw = fs.readFileSync(fnameSupp).toString(); }
|
|
57
|
+
catch (errFnameSupp) {
|
|
58
|
+
if (errFnameSupp.code !== 'ENOENT') exitError(regType, errFnameSupp, fnameSupp);
|
|
59
|
+
return readFile;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return parse(merge(readFileRaw, readFile, readFileSuppRaw, parse(readFileSuppRaw, fnameSupp)), `${fname} + ${fnameSupp}`);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
console.log(json.stringify(readMerge('../../../mst-2297/local/start-example.json', '../../../mst-2297/local/startTest-example.json'), null, 2))
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mimik/local",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"description": "Local setup configuration for normal and test opreration",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"lint": "gulp lint",
|
|
8
8
|
"docs": "gulp docs",
|
|
9
9
|
"test": "exit 0",
|
|
10
|
-
"
|
|
10
|
+
"prepublishOnly": "gulp docs; gulp lint; npm run test",
|
|
11
|
+
"commit-ready": "gulp docs; gulp lint; npm run test",
|
|
12
|
+
"prepare": "husky install"
|
|
11
13
|
},
|
|
12
14
|
"husky": {
|
|
13
15
|
"hooks": {
|
|
@@ -19,38 +21,44 @@
|
|
|
19
21
|
"mimik",
|
|
20
22
|
"microservice"
|
|
21
23
|
],
|
|
22
|
-
"author": "mimik",
|
|
24
|
+
"author": "mimik technology inc <support@mimik.com> (https://developer.mimik.com/)",
|
|
23
25
|
"license": "Apache-2.0",
|
|
24
26
|
"repository": {
|
|
25
27
|
"type": "git",
|
|
26
28
|
"url": "https://bitbucket.org/mimiktech/local"
|
|
27
29
|
},
|
|
28
30
|
"dependencies": {
|
|
29
|
-
"
|
|
31
|
+
"@mimik/eslint-plugin-dependencies": "2.4.1",
|
|
32
|
+
"@mimik/eslint-plugin-document-env": "1.0.0",
|
|
33
|
+
"@mimik/git-hooks": "1.5.2",
|
|
34
|
+
"axios": "0.24.0",
|
|
35
|
+
"bluebird": "3.7.2",
|
|
36
|
+
"chai": "4.3.4",
|
|
30
37
|
"colors": "1.4.0",
|
|
31
|
-
"comment-json": "
|
|
32
|
-
"
|
|
33
|
-
"eslint
|
|
34
|
-
"eslint-
|
|
35
|
-
"eslint-plugin-
|
|
36
|
-
"eslint-plugin-
|
|
37
|
-
"eslint-plugin-react
|
|
38
|
+
"comment-json": "4.1.1",
|
|
39
|
+
"debug": "4.3.3",
|
|
40
|
+
"eslint": "8.4.1",
|
|
41
|
+
"eslint-config-airbnb": "18.2.1",
|
|
42
|
+
"eslint-plugin-import": "2.25.3",
|
|
43
|
+
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
44
|
+
"eslint-plugin-react": "7.27.1",
|
|
45
|
+
"eslint-plugin-react-hooks": "4.3.0",
|
|
38
46
|
"fancy-log": "1.3.3",
|
|
39
47
|
"gulp": "4.0.2",
|
|
40
48
|
"gulp-env": "0.4.0",
|
|
41
49
|
"gulp-eslint": "6.0.0",
|
|
42
|
-
"gulp-git": "2.
|
|
50
|
+
"gulp-git": "2.10.1",
|
|
43
51
|
"gulp-spawn-mocha": "6.0.0",
|
|
44
52
|
"ip": "1.1.5",
|
|
45
|
-
"jsdoc-to-markdown": "
|
|
46
|
-
"lodash": "4.17.
|
|
47
|
-
"mocha": "
|
|
48
|
-
"mochawesome": "
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"uuid": "
|
|
53
|
+
"jsdoc-to-markdown": "7.1.0",
|
|
54
|
+
"lodash": "4.17.21",
|
|
55
|
+
"mocha": "9.1.3",
|
|
56
|
+
"mochawesome": "7.0.1",
|
|
57
|
+
"nyc": "15.1.0",
|
|
58
|
+
"supertest": "6.1.6",
|
|
59
|
+
"uuid": "8.3.2"
|
|
52
60
|
},
|
|
53
61
|
"devDependencies": {
|
|
54
|
-
"husky": "
|
|
62
|
+
"husky": "7.0.4"
|
|
55
63
|
}
|
|
56
64
|
}
|
package/package.json.bak
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mimik/local",
|
|
3
|
-
"version": "1.6.0",
|
|
4
|
-
"description": "Local setup configuration for normal and test opreration",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"lint": "gulp lint",
|
|
8
|
-
"docs": "gulp docs",
|
|
9
|
-
"test": "exit 0",
|
|
10
|
-
"prepublishOnly": "gulp docs; gulp lint; npm run test",
|
|
11
|
-
"commit-ready": "gulp docs; gulp lint; npm run test"
|
|
12
|
-
},
|
|
13
|
-
"husky": {
|
|
14
|
-
"hooks": {
|
|
15
|
-
"pre-commit": "npm run commit-ready",
|
|
16
|
-
"pre-push": "npm run test"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"mimik",
|
|
21
|
-
"microservice"
|
|
22
|
-
],
|
|
23
|
-
"author": "mimik",
|
|
24
|
-
"license": "Apache-2.0",
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "https://bitbucket.org/mimiktech/local"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"bluebird": "3.7.1",
|
|
31
|
-
"colors": "1.4.0",
|
|
32
|
-
"comment-json": "2.2.0",
|
|
33
|
-
"eslint": "6.5.1",
|
|
34
|
-
"eslint-config-airbnb": "18.0.1",
|
|
35
|
-
"eslint-plugin-import": "2.18.02",
|
|
36
|
-
"eslint-plugin-jsx-a11y": "6.2.3",
|
|
37
|
-
"eslint-plugin-react": "7.16.0",
|
|
38
|
-
"eslint-plugin-react-hooks": "2.2.0",
|
|
39
|
-
"fancy-log": "1.3.3",
|
|
40
|
-
"gulp": "4.0.2",
|
|
41
|
-
"gulp-env": "0.4.0",
|
|
42
|
-
"gulp-eslint": "6.0.0",
|
|
43
|
-
"gulp-git": "2.9.0",
|
|
44
|
-
"gulp-spawn-mocha": "6.0.0",
|
|
45
|
-
"ip": "1.1.5",
|
|
46
|
-
"jsdoc-to-markdown": "5.0.2",
|
|
47
|
-
"lodash": "4.17.15",
|
|
48
|
-
"mocha": "6.2.2",
|
|
49
|
-
"mochawesome": "4.1.0",
|
|
50
|
-
"request": "2.88.0",
|
|
51
|
-
"request-promise": "4.2.4",
|
|
52
|
-
"uuid": "3.3.3"
|
|
53
|
-
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"husky": "3.0.9"
|
|
56
|
-
}
|
|
57
|
-
}
|