@itentialopensource/adapter-generic 0.1.8 → 0.2.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/.eslintrc.js +1 -0
- package/AUTH.md +6 -6
- package/BROKER.md +4 -4
- package/CALLS.md +9 -9
- package/ENHANCE.md +3 -3
- package/PROPERTIES.md +24 -9
- package/README.md +24 -23
- package/SUMMARY.md +2 -2
- package/TAB1.md +1 -1
- package/TAB2.md +6 -6
- package/TROUBLESHOOT.md +10 -1
- package/UTILITIES.md +473 -0
- package/adapter.js +5 -5
- package/adapterBase.js +52 -16
- package/package.json +24 -28
- package/pronghorn.json +15 -13
- package/propertiesSchema.json +68 -7
- package/report/adapterInfo.json +7 -7
- package/report/updateReport1748551642673.json +120 -0
- package/sampleProperties.json +4 -0
- package/test/integration/adapterTestBasicGet.js +88 -54
- package/test/integration/adapterTestConnectivity.js +15 -16
- package/test/integration/adapterTestIntegration.js +12 -45
- package/test/unit/adapterBaseTestUnit.js +641 -39
- package/test/unit/adapterTestUnit.js +116 -149
- package/utils/adapterInfo.js +114 -164
- package/utils/argParser.js +44 -0
- package/utils/checkMigrate.js +77 -38
- package/utils/entitiesToDB.js +53 -42
- package/utils/logger.js +26 -0
- package/utils/modify.js +56 -55
- package/utils/mongoDbConnection.js +79 -0
- package/utils/mongoUtils.js +162 -0
- package/utils/taskMover.js +31 -32
- package/utils/tbScript.js +36 -172
- package/utils/tbUtils.js +84 -226
- package/utils/troubleshootingAdapter.js +68 -84
- package/utils/updateAdapterConfig.js +158 -0
- package/utils/addAuth.js +0 -94
- package/utils/artifactize.js +0 -146
- package/utils/basicGet.js +0 -50
- package/utils/packModificationScript.js +0 -35
- package/utils/patches2bundledDeps.js +0 -90
|
@@ -18,10 +18,10 @@ const { expect } = require('chai');
|
|
|
18
18
|
const { use } = require('chai');
|
|
19
19
|
const td = require('testdouble');
|
|
20
20
|
const Ajv = require('ajv');
|
|
21
|
+
const log = require('../../utils/logger');
|
|
21
22
|
|
|
22
23
|
const ajv = new Ajv({ strictSchema: false, allErrors: true, allowUnionTypes: true });
|
|
23
24
|
const anything = td.matchers.anything();
|
|
24
|
-
let logLevel = 'none';
|
|
25
25
|
const isRapidFail = false;
|
|
26
26
|
|
|
27
27
|
// read in the properties from the sampleProperties files
|
|
@@ -36,13 +36,17 @@ const samProps = require(`${adaptdir}/sampleProperties.json`).properties;
|
|
|
36
36
|
// these variables can be changed to run in integrated mode so easier to set them here
|
|
37
37
|
// always check these in with bogus data!!!
|
|
38
38
|
samProps.stub = true;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
samProps.
|
|
42
|
-
samProps.
|
|
43
|
-
samProps.
|
|
44
|
-
samProps.
|
|
45
|
-
samProps.
|
|
39
|
+
|
|
40
|
+
// uncomment if connecting
|
|
41
|
+
// samProps.host = 'replace.hostorip.here';
|
|
42
|
+
// samProps.authentication.username = 'username';
|
|
43
|
+
// samProps.authentication.password = 'password';
|
|
44
|
+
// samProps.authentication.token = 'password';
|
|
45
|
+
// samProps.protocol = 'http';
|
|
46
|
+
// samProps.port = 80;
|
|
47
|
+
// samProps.ssl.enabled = false;
|
|
48
|
+
// samProps.ssl.accept_invalid_cert = false;
|
|
49
|
+
|
|
46
50
|
samProps.request.attempt_timeout = 1200000;
|
|
47
51
|
const attemptTimeout = samProps.request.attempt_timeout;
|
|
48
52
|
const { stub } = samProps;
|
|
@@ -64,43 +68,6 @@ global.pronghornProps = {
|
|
|
64
68
|
|
|
65
69
|
global.$HOME = `${__dirname}/../..`;
|
|
66
70
|
|
|
67
|
-
// set the log levels that Pronghorn uses, spam and trace are not defaulted in so without
|
|
68
|
-
// this you may error on log.trace calls.
|
|
69
|
-
const myCustomLevels = {
|
|
70
|
-
levels: {
|
|
71
|
-
spam: 6,
|
|
72
|
-
trace: 5,
|
|
73
|
-
debug: 4,
|
|
74
|
-
info: 3,
|
|
75
|
-
warn: 2,
|
|
76
|
-
error: 1,
|
|
77
|
-
none: 0
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// need to see if there is a log level passed in
|
|
82
|
-
process.argv.forEach((val) => {
|
|
83
|
-
// is there a log level defined to be passed in?
|
|
84
|
-
if (val.indexOf('--LOG') === 0) {
|
|
85
|
-
// get the desired log level
|
|
86
|
-
const inputVal = val.split('=')[1];
|
|
87
|
-
|
|
88
|
-
// validate the log level is supported, if so set it
|
|
89
|
-
if (Object.hasOwnProperty.call(myCustomLevels.levels, inputVal)) {
|
|
90
|
-
logLevel = inputVal;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// need to set global logging
|
|
96
|
-
global.log = winston.createLogger({
|
|
97
|
-
level: logLevel,
|
|
98
|
-
levels: myCustomLevels.levels,
|
|
99
|
-
transports: [
|
|
100
|
-
new winston.transports.Console()
|
|
101
|
-
]
|
|
102
|
-
});
|
|
103
|
-
|
|
104
71
|
/**
|
|
105
72
|
* Runs the error asserts for the test
|
|
106
73
|
*/
|
|
@@ -314,16 +281,16 @@ describe('[unit] Generic Adapter Test', () => {
|
|
|
314
281
|
assert.notEqual(undefined, packageDotJson.dependencies);
|
|
315
282
|
assert.notEqual(null, packageDotJson.dependencies);
|
|
316
283
|
assert.notEqual('', packageDotJson.dependencies);
|
|
317
|
-
assert.equal('
|
|
318
|
-
assert.equal('
|
|
319
|
-
assert.equal('
|
|
320
|
-
assert.equal('
|
|
321
|
-
assert.equal('
|
|
322
|
-
assert.equal('
|
|
323
|
-
assert.equal('
|
|
324
|
-
assert.equal('
|
|
325
|
-
assert.equal('
|
|
326
|
-
assert.equal('
|
|
284
|
+
assert.equal('8.17.1', packageDotJson.dependencies.ajv);
|
|
285
|
+
assert.equal('1.9.0', packageDotJson.dependencies.axios);
|
|
286
|
+
assert.equal('11.1.0', packageDotJson.dependencies.commander);
|
|
287
|
+
assert.equal('11.3.0', packageDotJson.dependencies['fs-extra']);
|
|
288
|
+
assert.equal('10.8.2', packageDotJson.dependencies.mocha);
|
|
289
|
+
assert.equal('2.0.1', packageDotJson.dependencies['mocha-param']);
|
|
290
|
+
assert.equal('0.4.4', packageDotJson.dependencies.ping);
|
|
291
|
+
assert.equal('1.4.10', packageDotJson.dependencies['readline-sync']);
|
|
292
|
+
assert.equal('7.7.2', packageDotJson.dependencies.semver);
|
|
293
|
+
assert.equal('3.17.0', packageDotJson.dependencies.winston);
|
|
327
294
|
done();
|
|
328
295
|
} catch (error) {
|
|
329
296
|
log.error(`Test Failure: ${error}`);
|
|
@@ -336,12 +303,12 @@ describe('[unit] Generic Adapter Test', () => {
|
|
|
336
303
|
assert.notEqual(undefined, packageDotJson.devDependencies);
|
|
337
304
|
assert.notEqual(null, packageDotJson.devDependencies);
|
|
338
305
|
assert.notEqual('', packageDotJson.devDependencies);
|
|
339
|
-
assert.equal('
|
|
340
|
-
assert.equal('
|
|
341
|
-
assert.equal('
|
|
342
|
-
assert.equal('
|
|
343
|
-
assert.equal('
|
|
344
|
-
assert.equal('
|
|
306
|
+
assert.equal('4.5.0', packageDotJson.devDependencies.chai);
|
|
307
|
+
assert.equal('8.57.0', packageDotJson.devDependencies.eslint);
|
|
308
|
+
assert.equal('15.0.0', packageDotJson.devDependencies['eslint-config-airbnb-base']);
|
|
309
|
+
assert.equal('2.31.0', packageDotJson.devDependencies['eslint-plugin-import']);
|
|
310
|
+
assert.equal('3.1.0', packageDotJson.devDependencies['eslint-plugin-json']);
|
|
311
|
+
assert.equal('3.18.0', packageDotJson.devDependencies.testdouble);
|
|
345
312
|
done();
|
|
346
313
|
} catch (error) {
|
|
347
314
|
log.error(`Test Failure: ${error}`);
|
|
@@ -415,94 +382,94 @@ describe('[unit] Generic Adapter Test', () => {
|
|
|
415
382
|
done(error);
|
|
416
383
|
}
|
|
417
384
|
});
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
385
|
+
it('pronghorn.json should only expose workflow functions', (done) => {
|
|
386
|
+
try {
|
|
387
|
+
const pronghornDotJson = require('../../pronghorn.json');
|
|
388
|
+
|
|
389
|
+
for (let m = 0; m < pronghornDotJson.methods.length; m += 1) {
|
|
390
|
+
let found = false;
|
|
391
|
+
let paramissue = false;
|
|
392
|
+
|
|
393
|
+
for (let w = 0; w < wffunctions.length; w += 1) {
|
|
394
|
+
if (pronghornDotJson.methods[m].name === wffunctions[w]) {
|
|
395
|
+
found = true;
|
|
396
|
+
const methLine = execute(`grep "${wffunctions[w]}(" adapter.js | grep "callback) {"`).toString();
|
|
397
|
+
let wfparams = [];
|
|
398
|
+
|
|
399
|
+
if (methLine && methLine.indexOf('(') >= 0 && methLine.indexOf(')') >= 0) {
|
|
400
|
+
const temp = methLine.substring(methLine.indexOf('(') + 1, methLine.lastIndexOf(')'));
|
|
401
|
+
wfparams = temp.split(',');
|
|
402
|
+
|
|
403
|
+
for (let t = 0; t < wfparams.length; t += 1) {
|
|
404
|
+
// remove default value from the parameter name
|
|
405
|
+
wfparams[t] = wfparams[t].substring(0, wfparams[t].search(/=/) > 0 ? wfparams[t].search(/#|\?|=/) : wfparams[t].length);
|
|
406
|
+
// remove spaces
|
|
407
|
+
wfparams[t] = wfparams[t].trim();
|
|
408
|
+
|
|
409
|
+
if (wfparams[t] === 'callback') {
|
|
410
|
+
wfparams.splice(t, 1);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// if there are inputs defined but not on the method line
|
|
416
|
+
if (wfparams.length === 0 && (pronghornDotJson.methods[m].input
|
|
417
|
+
&& pronghornDotJson.methods[m].input.length > 0)) {
|
|
418
|
+
paramissue = true;
|
|
419
|
+
} else if (wfparams.length > 0 && (!pronghornDotJson.methods[m].input
|
|
420
|
+
|| pronghornDotJson.methods[m].input.length === 0)) {
|
|
421
|
+
// if there are no inputs defined but there are on the method line
|
|
422
|
+
paramissue = true;
|
|
423
|
+
} else {
|
|
424
|
+
for (let p = 0; p < pronghornDotJson.methods[m].input.length; p += 1) {
|
|
425
|
+
let pfound = false;
|
|
426
|
+
for (let wfp = 0; wfp < wfparams.length; wfp += 1) {
|
|
427
|
+
if (pronghornDotJson.methods[m].input[p].name.toUpperCase() === wfparams[wfp].toUpperCase()) {
|
|
428
|
+
pfound = true;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (!pfound) {
|
|
433
|
+
paramissue = true;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
for (let wfp = 0; wfp < wfparams.length; wfp += 1) {
|
|
437
|
+
let pfound = false;
|
|
438
|
+
for (let p = 0; p < pronghornDotJson.methods[m].input.length; p += 1) {
|
|
439
|
+
if (pronghornDotJson.methods[m].input[p].name.toUpperCase() === wfparams[wfp].toUpperCase()) {
|
|
440
|
+
pfound = true;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (!pfound) {
|
|
445
|
+
paramissue = true;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (!found) {
|
|
455
|
+
// this is the reason to go through both loops - log which ones are not found so
|
|
456
|
+
// they can be worked
|
|
457
|
+
log.error(`${pronghornDotJson.methods[m].name} not found in workflow functions`);
|
|
458
|
+
}
|
|
459
|
+
if (paramissue) {
|
|
460
|
+
// this is the reason to go through both loops - log which ones are not found so
|
|
461
|
+
// they can be worked
|
|
462
|
+
log.error(`${pronghornDotJson.methods[m].name} has a parameter mismatch`);
|
|
463
|
+
}
|
|
464
|
+
assert.equal(true, found);
|
|
465
|
+
assert.equal(false, paramissue);
|
|
466
|
+
}
|
|
467
|
+
done();
|
|
468
|
+
} catch (error) {
|
|
469
|
+
log.error(`Adapter Exception: ${error}`);
|
|
470
|
+
done(error);
|
|
471
|
+
}
|
|
472
|
+
}).timeout(attemptTimeout);
|
|
506
473
|
it('pronghorn.json should expose all workflow functions', (done) => {
|
|
507
474
|
try {
|
|
508
475
|
const pronghornDotJson = require('../../pronghorn.json');
|
package/utils/adapterInfo.js
CHANGED
|
@@ -1,20 +1,94 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/* @copyright Itential, LLC
|
|
2
|
+
/* @copyright Itential, LLC 2025 */
|
|
3
|
+
|
|
3
4
|
/* eslint global-require:warn */
|
|
4
5
|
/* eslint import/no-dynamic-require:warn */
|
|
5
6
|
/* eslint prefer-destructuring:warn */
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* This script will determine the information about the adapter and store
|
|
10
|
+
* it into a file in the adapter. This is self contained and only depends on
|
|
11
|
+
* finding files within the adapter to gather information.
|
|
12
|
+
*
|
|
13
|
+
* This utility is used when adapters are committed and pushed. It is not used by
|
|
14
|
+
* any customers nor is it references in any scripts.
|
|
15
|
+
*/
|
|
16
|
+
|
|
7
17
|
const path = require('path');
|
|
8
18
|
const fs = require('fs-extra');
|
|
9
19
|
|
|
10
20
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
21
|
+
* @summary Count the number of lines in a file
|
|
22
|
+
* @param {string} filePath - The path to the file
|
|
23
|
+
* @returns {number} The total number of lines in the file
|
|
24
|
+
*/
|
|
25
|
+
function countLinesInFile(filePath) {
|
|
26
|
+
if (fs.existsSync(filePath)) {
|
|
27
|
+
const cFile = fs.readFileSync(filePath, 'utf8');
|
|
28
|
+
return cFile.split('\n').length;
|
|
29
|
+
}
|
|
30
|
+
console.log(`Missing - ${path.basename(filePath)}`);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @summary Count the number of lines across multiple files
|
|
36
|
+
* @param {array} filePaths - An array of file paths
|
|
37
|
+
* @returns {number} The total number of lines across all files
|
|
38
|
+
*/
|
|
39
|
+
function countLinesInFiles(filePaths) {
|
|
40
|
+
return filePaths.reduce((total, filePath) => total + countLinesInFile(filePath), 0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @summary Count the number of lines in all json files within an entity directory
|
|
45
|
+
* @param {string} entityDir - The entity directory
|
|
46
|
+
* @returns {number} The total number of lines across all JSON files in the entity directory
|
|
47
|
+
*/
|
|
48
|
+
function countEntityLines(entityDir) {
|
|
49
|
+
let totalLines = 0;
|
|
50
|
+
|
|
51
|
+
if (!fs.existsSync(entityDir)) {
|
|
52
|
+
console.log('Could not find the entities directory');
|
|
53
|
+
return totalLines;
|
|
54
|
+
}
|
|
55
|
+
const entities = fs.readdirSync(entityDir);
|
|
56
|
+
for (let e = 0; e < entities.length; e += 1) {
|
|
57
|
+
const entityPath = path.join(entityDir, entities[e]);
|
|
58
|
+
if (fs.statSync(entityPath).isDirectory()) {
|
|
59
|
+
const jsonFiles = fs.readdirSync(entityPath).filter((f) => f.endsWith('.json'));
|
|
60
|
+
for (let j = 0; j < jsonFiles.length; j += 1) {
|
|
61
|
+
totalLines += countLinesInFile(path.join(entityPath, jsonFiles[j]));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return totalLines;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @summary Count the number of test cases in a file
|
|
70
|
+
* @param {string} filePath - The path to the test file
|
|
71
|
+
* @returns {number} The total number of test cases in the file
|
|
13
72
|
*/
|
|
73
|
+
function countTestsInFile(filePath) {
|
|
74
|
+
if (fs.existsSync(filePath)) {
|
|
75
|
+
const tFile = fs.readFileSync(filePath, 'utf8');
|
|
76
|
+
const ttestCount = tFile.split('it(\'').length;
|
|
77
|
+
return ttestCount;
|
|
78
|
+
}
|
|
79
|
+
console.log(`Missing - ${path.basename(filePath)}`);
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
14
82
|
|
|
15
83
|
/**
|
|
16
|
-
*
|
|
84
|
+
* @summary Count the number of test cases across multiple files
|
|
85
|
+
* @param {array} filePaths - An array of test file paths
|
|
86
|
+
* @returns {number} The total number of test cases across all files
|
|
17
87
|
*/
|
|
88
|
+
function countTestsInFiles(filePaths) {
|
|
89
|
+
return filePaths.reduce((total, filePath) => total + countTestsInFile(filePath), 0);
|
|
90
|
+
}
|
|
91
|
+
|
|
18
92
|
function adapterInfo() {
|
|
19
93
|
// set the base pase of the adapter - tool shoud be one level up in utils
|
|
20
94
|
let adaptdir = __dirname;
|
|
@@ -23,172 +97,43 @@ function adapterInfo() {
|
|
|
23
97
|
if (adaptdir.endsWith('/utils')) {
|
|
24
98
|
adaptdir = adaptdir.substring(0, adaptdir.length - 6);
|
|
25
99
|
}
|
|
100
|
+
|
|
101
|
+
// if no package.json then not in right place - end with error
|
|
102
|
+
if (!fs.existsSync(`${adaptdir}/package.json`)) {
|
|
103
|
+
throw new Error('Missing - package.json');
|
|
104
|
+
}
|
|
26
105
|
const pack = require(`${adaptdir}/package.json`);
|
|
27
106
|
infoRes.version = pack.version;
|
|
28
107
|
|
|
29
108
|
let configCount = 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (fs.existsSync(`${adaptdir}/propertiesSchema.json`)) {
|
|
37
|
-
const cFile = fs.readFileSync(`${adaptdir}/propertiesSchema.json`, 'utf8');
|
|
38
|
-
configCount += cFile.split('\n').length;
|
|
39
|
-
} else {
|
|
40
|
-
console.log('Missing - propertiesSchema.json');
|
|
41
|
-
}
|
|
42
|
-
if (fs.existsSync(`${adaptdir}/error.json`)) {
|
|
43
|
-
const cFile = fs.readFileSync(`${adaptdir}/error.json`, 'utf8');
|
|
44
|
-
configCount += cFile.split('\n').length;
|
|
45
|
-
} else {
|
|
46
|
-
console.log('Missing - error.json');
|
|
47
|
-
}
|
|
48
|
-
const entitydir = path.join(adaptdir, '/entities');
|
|
49
|
-
if (fs.existsSync(entitydir) && fs.statSync(entitydir).isDirectory()) {
|
|
50
|
-
const entities = fs.readdirSync(entitydir);
|
|
51
|
-
// need to go through each entity in the entities directory
|
|
52
|
-
for (let e = 0; e < entities.length; e += 1) {
|
|
53
|
-
if (fs.statSync(`${entitydir}/${entities[e]}`).isDirectory()) {
|
|
54
|
-
const cfiles = fs.readdirSync(entitydir);
|
|
55
|
-
for (let c = 0; c < cfiles.length; c += 1) {
|
|
56
|
-
if (cfiles[c].endsWith('.json')) {
|
|
57
|
-
const ccFile = fs.readFileSync(`${entitydir}/${entities[e]}/${cfiles[c]}`, 'utf8');
|
|
58
|
-
configCount += ccFile.split('\n').length;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
console.log('Could not find the entities directory');
|
|
65
|
-
}
|
|
109
|
+
const configFiles = ['pronghorn.json', 'propertiesSchema.json', 'error.json'].map((f) => path.join(adaptdir, f));
|
|
110
|
+
configCount = countLinesInFiles(configFiles);
|
|
111
|
+
|
|
112
|
+
const entityDir = path.join(adaptdir, '/entities');
|
|
113
|
+
configCount += countEntityLines(entityDir);
|
|
114
|
+
|
|
66
115
|
infoRes.configLines = configCount;
|
|
67
116
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
scodeCount += sFile.split('\n').length;
|
|
72
|
-
} else {
|
|
73
|
-
console.log('Missing - utils/artifactize.js');
|
|
74
|
-
}
|
|
75
|
-
if (fs.existsSync(`${adaptdir}/utils/basicGet.js`)) {
|
|
76
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/basicGet.js`, 'utf8');
|
|
77
|
-
scodeCount += sFile.split('\n').length;
|
|
78
|
-
} else {
|
|
79
|
-
console.log('Missing - utils/basicGet.js');
|
|
80
|
-
}
|
|
81
|
-
if (fs.existsSync(`${adaptdir}/utils/checkMigrate.js`)) {
|
|
82
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/checkMigrate.js`, 'utf8');
|
|
83
|
-
scodeCount += sFile.split('\n').length;
|
|
84
|
-
} else {
|
|
85
|
-
console.log('Missing - utils/checkMigrate.js');
|
|
86
|
-
}
|
|
87
|
-
if (fs.existsSync(`${adaptdir}/utils/findPath.js`)) {
|
|
88
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/findPath.js`, 'utf8');
|
|
89
|
-
scodeCount += sFile.split('\n').length;
|
|
90
|
-
} else {
|
|
91
|
-
console.log('Missing - utils/findPath.js');
|
|
92
|
-
}
|
|
93
|
-
if (fs.existsSync(`${adaptdir}/utils/modify.js`)) {
|
|
94
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/modify.js`, 'utf8');
|
|
95
|
-
scodeCount += sFile.split('\n').length;
|
|
96
|
-
} else {
|
|
97
|
-
console.log('Missing - utils/modify.js');
|
|
98
|
-
}
|
|
99
|
-
if (fs.existsSync(`${adaptdir}/utils/packModificationScript.js`)) {
|
|
100
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/packModificationScript.js`, 'utf8');
|
|
101
|
-
scodeCount += sFile.split('\n').length;
|
|
102
|
-
} else {
|
|
103
|
-
console.log('Missing - utils/packModificationScript.js');
|
|
104
|
-
}
|
|
105
|
-
if (fs.existsSync(`${adaptdir}/utils/setup.js`)) {
|
|
106
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/setup.js`, 'utf8');
|
|
107
|
-
scodeCount += sFile.split('\n').length;
|
|
108
|
-
} else {
|
|
109
|
-
console.log('Missing - utils/setup.js');
|
|
110
|
-
}
|
|
111
|
-
if (fs.existsSync(`${adaptdir}/utils/tbScript.js`)) {
|
|
112
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/tbScript.js`, 'utf8');
|
|
113
|
-
scodeCount += sFile.split('\n').length;
|
|
114
|
-
} else {
|
|
115
|
-
console.log('Missing - utils/tbScript.js');
|
|
116
|
-
}
|
|
117
|
-
if (fs.existsSync(`${adaptdir}/utils/tbUtils.js`)) {
|
|
118
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/tbUtils.js`, 'utf8');
|
|
119
|
-
scodeCount += sFile.split('\n').length;
|
|
120
|
-
} else {
|
|
121
|
-
console.log('Missing - utils/tbUtils.js');
|
|
122
|
-
}
|
|
123
|
-
if (fs.existsSync(`${adaptdir}/utils/testRunner.js`)) {
|
|
124
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/testRunner.js`, 'utf8');
|
|
125
|
-
scodeCount += sFile.split('\n').length;
|
|
126
|
-
} else {
|
|
127
|
-
console.log('Missing - utils/testRunner.js');
|
|
128
|
-
}
|
|
129
|
-
if (fs.existsSync(`${adaptdir}/utils/troubleshootingAdapter.js`)) {
|
|
130
|
-
const sFile = fs.readFileSync(`${adaptdir}/utils/troubleshootingAdapter.js`, 'utf8');
|
|
131
|
-
scodeCount += sFile.split('\n').length;
|
|
132
|
-
} else {
|
|
133
|
-
console.log('Missing - utils/troubleshootingAdapter.js');
|
|
134
|
-
}
|
|
135
|
-
infoRes.scriptLines = scodeCount;
|
|
117
|
+
const utilFiles = ['argParser', 'checkMigrate.js', 'entitiesToDB.js', 'findPath.js', 'logger.js', 'methodDocumentor.js', 'modify.js', 'mongoDbConnection.js',
|
|
118
|
+
'mongoUtils.js', 'setup.js', 'taskMover.js', 'tbScript.js', 'tbUtils.js', 'testRunner.js', 'troubleshootingAdapter.js', 'updateAdapterConfig.js'
|
|
119
|
+
].map((f) => path.join(adaptdir, 'utils', f));
|
|
136
120
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
infoRes.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
let ttestCount = 0;
|
|
154
|
-
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`)) {
|
|
155
|
-
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`, 'utf8');
|
|
156
|
-
tcodeCount += tFile.split('\n').length;
|
|
157
|
-
ttestCount += tFile.split('it(\'').length;
|
|
158
|
-
} else {
|
|
159
|
-
console.log('Missing - test/integration/adapterTestBasicGet.js');
|
|
160
|
-
}
|
|
161
|
-
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`)) {
|
|
162
|
-
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`, 'utf8');
|
|
163
|
-
tcodeCount += tFile.split('\n').length;
|
|
164
|
-
ttestCount += tFile.split('it(\'').length;
|
|
165
|
-
} else {
|
|
166
|
-
console.log('Missing - test/integration/adapterTestConnectivity.js');
|
|
167
|
-
}
|
|
168
|
-
if (fs.existsSync(`${adaptdir}/test/integration/adapterTestIntegration.js`)) {
|
|
169
|
-
const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestIntegration.js`, 'utf8');
|
|
170
|
-
tcodeCount += tFile.split('\n').length;
|
|
171
|
-
ttestCount += tFile.split('it(\'').length;
|
|
172
|
-
} else {
|
|
173
|
-
console.log('Missing - test/integration/adapterTestIntegration.js');
|
|
174
|
-
}
|
|
175
|
-
if (fs.existsSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`)) {
|
|
176
|
-
const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`, 'utf8');
|
|
177
|
-
tcodeCount += tFile.split('\n').length;
|
|
178
|
-
ttestCount += tFile.split('it(\'').length;
|
|
179
|
-
} else {
|
|
180
|
-
console.log('Missing - test/unit/adapterBaseTestUnit.js');
|
|
181
|
-
}
|
|
182
|
-
if (fs.existsSync(`${adaptdir}/test/unit/adapterTestUnit.js`)) {
|
|
183
|
-
const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterTestUnit.js`, 'utf8');
|
|
184
|
-
tcodeCount += tFile.split('\n').length;
|
|
185
|
-
ttestCount += tFile.split('it(\'').length;
|
|
186
|
-
} else {
|
|
187
|
-
console.log('Missing - test/unit/adapterTestUnit.js');
|
|
188
|
-
}
|
|
189
|
-
infoRes.testLines = tcodeCount;
|
|
190
|
-
infoRes.testCases = ttestCount;
|
|
191
|
-
infoRes.totalCodeLines = scodeCount + codeCount + tcodeCount;
|
|
121
|
+
infoRes.scriptLines = countLinesInFiles(utilFiles);
|
|
122
|
+
|
|
123
|
+
const adapterFiles = ['adapter.js', 'adapterBase.js'].map((f) => path.join(adaptdir, f));
|
|
124
|
+
infoRes.codeLines = countLinesInFiles(adapterFiles);
|
|
125
|
+
|
|
126
|
+
const testFiles = [
|
|
127
|
+
'test/integration/adapterTestBasicGet.js',
|
|
128
|
+
'test/integration/adapterTestConnectivity.js',
|
|
129
|
+
'test/integration/adapterTestIntegration.js',
|
|
130
|
+
'test/unit/adapterBaseTestUnit.js',
|
|
131
|
+
'test/unit/adapterTestUnit.js'
|
|
132
|
+
].map((f) => path.join(adaptdir, f));
|
|
133
|
+
infoRes.testLines = countLinesInFiles(testFiles);
|
|
134
|
+
infoRes.testCases = countTestsInFiles(testFiles);
|
|
135
|
+
|
|
136
|
+
infoRes.totalCodeLines = infoRes.scriptLines + infoRes.codeLines + infoRes.testLines;
|
|
192
137
|
|
|
193
138
|
if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
|
|
194
139
|
// Read the entity schema from the file system
|
|
@@ -203,4 +148,9 @@ function adapterInfo() {
|
|
|
203
148
|
fs.writeFileSync(`${adaptdir}/report/adapterInfo.json`, JSON.stringify(infoRes, null, 2));
|
|
204
149
|
}
|
|
205
150
|
|
|
206
|
-
|
|
151
|
+
try {
|
|
152
|
+
adapterInfo();
|
|
153
|
+
} catch (err) {
|
|
154
|
+
console.error(err.message);
|
|
155
|
+
process.exit();
|
|
156
|
+
}
|