@itentialopensource/adapter-meraki 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- package/AUTH.md +14 -15
- package/BROKER.md +195 -0
- package/CALLS.md +158 -89
- package/CHANGELOG.md +8 -0
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +14 -14
- package/PROPERTIES.md +483 -89
- package/README.md +131 -51
- package/SUMMARY.md +2 -2
- package/TROUBLESHOOT.md +4 -3
- package/adapter.js +175 -394
- package/adapterBase.js +607 -157
- package/entities/.generic/action.json +105 -0
- package/entities/.generic/schema.json +6 -1
- package/package.json +3 -2
- package/pronghorn.json +79 -0
- package/propertiesSchema.json +13 -0
- package/refs?service=git-upload-pack +0 -0
- package/sampleProperties.json +82 -0
- package/test/unit/adapterBaseTestUnit.js +10 -3
- package/test/unit/adapterTestUnit.js +4 -14
- package/utils/adapterInfo.js +206 -0
- package/utils/pre-commit.sh +3 -0
@@ -104,6 +104,111 @@
|
|
104
104
|
"mockFile": ""
|
105
105
|
}
|
106
106
|
]
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"name": "getGenericsNoBase",
|
110
|
+
"protocol": "REST",
|
111
|
+
"method": "GET",
|
112
|
+
"entitypath": "/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
113
|
+
"requestSchema": "schema.json",
|
114
|
+
"responseSchema": "schema.json",
|
115
|
+
"timeout": 0,
|
116
|
+
"sendEmpty": false,
|
117
|
+
"sendGetBody": false,
|
118
|
+
"requestDatatype": "JSON",
|
119
|
+
"responseDatatype": "JSON",
|
120
|
+
"headers": {},
|
121
|
+
"responseObjects": [
|
122
|
+
{
|
123
|
+
"type": "default",
|
124
|
+
"key": "",
|
125
|
+
"mockFile": ""
|
126
|
+
}
|
127
|
+
]
|
128
|
+
},
|
129
|
+
{
|
130
|
+
"name": "createGenericNoBase",
|
131
|
+
"protocol": "REST",
|
132
|
+
"method": "POST",
|
133
|
+
"entitypath": "/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
134
|
+
"requestSchema": "schema.json",
|
135
|
+
"responseSchema": "schema.json",
|
136
|
+
"timeout": 0,
|
137
|
+
"sendEmpty": false,
|
138
|
+
"sendGetBody": false,
|
139
|
+
"requestDatatype": "JSON",
|
140
|
+
"responseDatatype": "JSON",
|
141
|
+
"headers": {},
|
142
|
+
"responseObjects": [
|
143
|
+
{
|
144
|
+
"type": "default",
|
145
|
+
"key": "",
|
146
|
+
"mockFile": ""
|
147
|
+
}
|
148
|
+
]
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"name": "updateGenericNoBase",
|
152
|
+
"protocol": "REST",
|
153
|
+
"method": "PUT",
|
154
|
+
"entitypath": "/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
155
|
+
"requestSchema": "schema.json",
|
156
|
+
"responseSchema": "schema.json",
|
157
|
+
"timeout": 0,
|
158
|
+
"sendEmpty": false,
|
159
|
+
"sendGetBody": false,
|
160
|
+
"requestDatatype": "JSON",
|
161
|
+
"responseDatatype": "JSON",
|
162
|
+
"headers": {},
|
163
|
+
"responseObjects": [
|
164
|
+
{
|
165
|
+
"type": "default",
|
166
|
+
"key": "",
|
167
|
+
"mockFile": ""
|
168
|
+
}
|
169
|
+
]
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"name": "patchGenericNoBase",
|
173
|
+
"protocol": "REST",
|
174
|
+
"method": "PATCH",
|
175
|
+
"entitypath": "/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
176
|
+
"requestSchema": "schema.json",
|
177
|
+
"responseSchema": "schema.json",
|
178
|
+
"timeout": 0,
|
179
|
+
"sendEmpty": false,
|
180
|
+
"sendGetBody": false,
|
181
|
+
"requestDatatype": "JSON",
|
182
|
+
"responseDatatype": "JSON",
|
183
|
+
"headers": {},
|
184
|
+
"responseObjects": [
|
185
|
+
{
|
186
|
+
"type": "default",
|
187
|
+
"key": "",
|
188
|
+
"mockFile": ""
|
189
|
+
}
|
190
|
+
]
|
191
|
+
},
|
192
|
+
{
|
193
|
+
"name": "deleteGenericNoBase",
|
194
|
+
"protocol": "REST",
|
195
|
+
"method": "DELETE",
|
196
|
+
"entitypath": "/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
197
|
+
"requestSchema": "schema.json",
|
198
|
+
"responseSchema": "schema.json",
|
199
|
+
"timeout": 0,
|
200
|
+
"sendEmpty": false,
|
201
|
+
"sendGetBody": false,
|
202
|
+
"requestDatatype": "JSON",
|
203
|
+
"responseDatatype": "JSON",
|
204
|
+
"headers": {},
|
205
|
+
"responseObjects": [
|
206
|
+
{
|
207
|
+
"type": "default",
|
208
|
+
"key": "",
|
209
|
+
"mockFile": ""
|
210
|
+
}
|
211
|
+
]
|
107
212
|
}
|
108
213
|
]
|
109
214
|
}
|
@@ -14,7 +14,12 @@
|
|
14
14
|
"createGeneric",
|
15
15
|
"updateGeneric",
|
16
16
|
"patchGeneric",
|
17
|
-
"deleteGeneric"
|
17
|
+
"deleteGeneric",
|
18
|
+
"getGenericsNoBase",
|
19
|
+
"createGenericNoBase",
|
20
|
+
"updateGenericNoBase",
|
21
|
+
"patchGenericNoBase",
|
22
|
+
"deleteGenericNoBase"
|
18
23
|
],
|
19
24
|
"external_name": "ph_request_type"
|
20
25
|
}
|
package/package.json
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@itentialopensource/adapter-meraki",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.3",
|
4
4
|
"description": "This adapter integrates with system described as: merakiDashboardApi.",
|
5
5
|
"main": "adapter.js",
|
6
|
+
"systemName": "Meraki",
|
6
7
|
"wizardVersion": "2.44.7",
|
7
|
-
"engineVersion": "1.61.
|
8
|
+
"engineVersion": "1.61.3",
|
8
9
|
"adapterType": "http",
|
9
10
|
"scripts": {
|
10
11
|
"artifactize": "npm i && node utils/packModificationScript.js",
|
package/pronghorn.json
CHANGED
@@ -402,6 +402,85 @@
|
|
402
402
|
},
|
403
403
|
"task": true
|
404
404
|
},
|
405
|
+
{
|
406
|
+
"name": "genericAdapterRequestNoBasePath",
|
407
|
+
"summary": "Makes the requested generic call with no base path or version",
|
408
|
+
"description": "Makes the requested generic call with no base path or version",
|
409
|
+
"input": [
|
410
|
+
{
|
411
|
+
"name": "uriPath",
|
412
|
+
"type": "string",
|
413
|
+
"info": "the path of the api call - do not include the host, port, base path or version",
|
414
|
+
"description": "the path of the api call",
|
415
|
+
"schema": {
|
416
|
+
"title": "uriPath",
|
417
|
+
"type": "string"
|
418
|
+
},
|
419
|
+
"required": true
|
420
|
+
},
|
421
|
+
{
|
422
|
+
"name": "restMethod",
|
423
|
+
"type": "string",
|
424
|
+
"info": "the rest method (GET, POST, PUT, PATCH, DELETE)",
|
425
|
+
"description": "the rest method (GET, POST, PUT, PATCH, DELETE)",
|
426
|
+
"schema": {
|
427
|
+
"title": "restMethod",
|
428
|
+
"type": "string"
|
429
|
+
},
|
430
|
+
"required": true
|
431
|
+
},
|
432
|
+
{
|
433
|
+
"name": "queryData",
|
434
|
+
"type": "object",
|
435
|
+
"info": "the query parameters to be put on the url (optional)",
|
436
|
+
"description": "the query parameters to be put on the url (optional)",
|
437
|
+
"schema": {
|
438
|
+
"title": "queryData",
|
439
|
+
"type": "object"
|
440
|
+
},
|
441
|
+
"required": false
|
442
|
+
},
|
443
|
+
{
|
444
|
+
"name": "requestBody",
|
445
|
+
"type": "object",
|
446
|
+
"info": "the payload to be sent with the request (optional)",
|
447
|
+
"description": "the payload to be sent with the request (optional)",
|
448
|
+
"schema": {
|
449
|
+
"title": "requestBody",
|
450
|
+
"type": "object"
|
451
|
+
},
|
452
|
+
"required": false
|
453
|
+
},
|
454
|
+
{
|
455
|
+
"name": "addlHeaders",
|
456
|
+
"type": "object",
|
457
|
+
"info": "additional headers to be put on the call (optional)",
|
458
|
+
"description": "additional headers to be put on the call (optional)",
|
459
|
+
"schema": {
|
460
|
+
"title": "addlHeaders",
|
461
|
+
"type": "object"
|
462
|
+
},
|
463
|
+
"required": false
|
464
|
+
}
|
465
|
+
],
|
466
|
+
"output": {
|
467
|
+
"name": "result",
|
468
|
+
"type": "object",
|
469
|
+
"description": "A JSON Object containing status, code and the result",
|
470
|
+
"schema": {
|
471
|
+
"title": "result",
|
472
|
+
"type": "object"
|
473
|
+
}
|
474
|
+
},
|
475
|
+
"roles": [
|
476
|
+
"admin"
|
477
|
+
],
|
478
|
+
"route": {
|
479
|
+
"verb": "POST",
|
480
|
+
"path": "/genericAdapterRequestNoBasePath"
|
481
|
+
},
|
482
|
+
"task": true
|
483
|
+
},
|
405
484
|
{
|
406
485
|
"name": "getDevice",
|
407
486
|
"summary": "Get the Appliance",
|
package/propertiesSchema.json
CHANGED
@@ -51,6 +51,11 @@
|
|
51
51
|
"description": "When true the path variables are encoded in the url",
|
52
52
|
"default": true
|
53
53
|
},
|
54
|
+
"encode_queryvars": {
|
55
|
+
"type": "boolean",
|
56
|
+
"description": "When true the path variables are encoded in the url",
|
57
|
+
"default": true
|
58
|
+
},
|
54
59
|
"save_metric": {
|
55
60
|
"type": [
|
56
61
|
"boolean",
|
@@ -977,6 +982,14 @@
|
|
977
982
|
"description": "return failure or ignore failure",
|
978
983
|
"default": "ignore"
|
979
984
|
},
|
985
|
+
"requestFields": {
|
986
|
+
"type": "object",
|
987
|
+
"description": "The json object with response fields of the call to getDevice",
|
988
|
+
"additionalProperties": {
|
989
|
+
"type": "string"
|
990
|
+
},
|
991
|
+
"properties": {}
|
992
|
+
},
|
980
993
|
"responseFields": {
|
981
994
|
"type": "object",
|
982
995
|
"description": "The json object with response fields of the call to getDevicesFiltered",
|
Binary file
|
package/sampleProperties.json
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
"version": "v0",
|
9
9
|
"cache_location": "none",
|
10
10
|
"encode_pathvars": true,
|
11
|
+
"encode_queryvars": true,
|
11
12
|
"save_metric": true,
|
12
13
|
"stub": true,
|
13
14
|
"protocol": "https",
|
@@ -95,6 +96,87 @@
|
|
95
96
|
"key_file": "",
|
96
97
|
"cert_file": ""
|
97
98
|
}
|
99
|
+
},
|
100
|
+
"deviceBroker": {
|
101
|
+
"getDevice": [
|
102
|
+
{
|
103
|
+
"path": "/get/devices/{id}",
|
104
|
+
"method": "GET",
|
105
|
+
"query": {},
|
106
|
+
"body": {},
|
107
|
+
"headers": {},
|
108
|
+
"handleFailure": "ignore",
|
109
|
+
"requestFields": {
|
110
|
+
"id": "name"
|
111
|
+
},
|
112
|
+
"responseFields": {
|
113
|
+
"name": "host",
|
114
|
+
"ostype": "os",
|
115
|
+
"ostypePrefix": "system-",
|
116
|
+
"ipaddress": "attributes.ipaddr",
|
117
|
+
"port": 443
|
118
|
+
}
|
119
|
+
}
|
120
|
+
],
|
121
|
+
"getDevicesFiltered": [
|
122
|
+
{
|
123
|
+
"path": "/get/devices",
|
124
|
+
"method": "GET",
|
125
|
+
"query": {},
|
126
|
+
"body": {},
|
127
|
+
"headers": {},
|
128
|
+
"handleFailure": "ignore",
|
129
|
+
"requestFields": {},
|
130
|
+
"responseFields": {
|
131
|
+
"name": "host",
|
132
|
+
"ostype": "os",
|
133
|
+
"ostypePrefix": "system-",
|
134
|
+
"ipaddress": "attributes.ipaddr",
|
135
|
+
"port": 443
|
136
|
+
}
|
137
|
+
}
|
138
|
+
],
|
139
|
+
"isAlive": [
|
140
|
+
{
|
141
|
+
"path": "/get/devices/{id}/status",
|
142
|
+
"method": "GET",
|
143
|
+
"query": {},
|
144
|
+
"body": {},
|
145
|
+
"headers": {},
|
146
|
+
"handleFailure": "ignore",
|
147
|
+
"statusValue": "online",
|
148
|
+
"requestFields": {
|
149
|
+
"id": "name"
|
150
|
+
},
|
151
|
+
"responseFields": {
|
152
|
+
"status": "status"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
],
|
156
|
+
"getConfig": [
|
157
|
+
{
|
158
|
+
"path": "/get/devices/{id}/configPart1",
|
159
|
+
"method": "GET",
|
160
|
+
"query": {},
|
161
|
+
"body": {},
|
162
|
+
"headers": {},
|
163
|
+
"handleFailure": "ignore",
|
164
|
+
"requestFields": {
|
165
|
+
"id": "name"
|
166
|
+
},
|
167
|
+
"responseFields": {}
|
168
|
+
}
|
169
|
+
],
|
170
|
+
"getCount": [
|
171
|
+
{
|
172
|
+
"path": "/get/devices",
|
173
|
+
"method": "GET",
|
174
|
+
"query": {},
|
175
|
+
"body": {},
|
176
|
+
"headers": {},
|
177
|
+
"handleFailure": "ignore"
|
178
|
+
}
|
179
|
+
]
|
98
180
|
}
|
99
181
|
},
|
100
182
|
"groups": [],
|
@@ -317,8 +317,10 @@ describe('[unit] Adapter Base Test', () => {
|
|
317
317
|
});
|
318
318
|
it('should return a list of functions', (done) => {
|
319
319
|
const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
|
320
|
-
'entityInList', 'getAllCapabilities', 'getAllFunctions', '
|
321
|
-
'
|
320
|
+
'entityInList', 'getAllCapabilities', 'getAllFunctions', 'getConfig', 'getDevice', 'getDevicesFiltered', 'hasDevices', 'hasEntities',
|
321
|
+
'healthCheck', 'iapFindAdapterPath', 'iapGetAdapterQueue', 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount', 'iapMakeBrokerCall',
|
322
|
+
'iapMoveAdapterEntitiesToDB', 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapSuspendAdapter',
|
323
|
+
'iapTroubleshootAdapter', 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'isAlive', 'refreshProperties', 'addListener',
|
322
324
|
'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
|
323
325
|
'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
|
324
326
|
try {
|
@@ -817,12 +819,17 @@ describe('[unit] Adapter Base Test', () => {
|
|
817
819
|
try {
|
818
820
|
assert.notEqual(0, expectedCapabilities.length);
|
819
821
|
assert.equal('.generic', expectedCapabilities[0].entity);
|
820
|
-
assert.equal(
|
822
|
+
assert.equal(10, expectedCapabilities[0].actions.length);
|
821
823
|
assert.equal('getGenerics', expectedCapabilities[0].actions[0]);
|
822
824
|
assert.equal('createGeneric', expectedCapabilities[0].actions[1]);
|
823
825
|
assert.equal('updateGeneric', expectedCapabilities[0].actions[2]);
|
824
826
|
assert.equal('patchGeneric', expectedCapabilities[0].actions[3]);
|
825
827
|
assert.equal('deleteGeneric', expectedCapabilities[0].actions[4]);
|
828
|
+
assert.equal('getGenericsNoBase', expectedCapabilities[0].actions[5]);
|
829
|
+
assert.equal('createGenericNoBase', expectedCapabilities[0].actions[6]);
|
830
|
+
assert.equal('updateGenericNoBase', expectedCapabilities[0].actions[7]);
|
831
|
+
assert.equal('patchGenericNoBase', expectedCapabilities[0].actions[8]);
|
832
|
+
assert.equal('deleteGenericNoBase', expectedCapabilities[0].actions[9]);
|
826
833
|
assert.equal('.system', expectedCapabilities[1].entity);
|
827
834
|
assert.equal(2, expectedCapabilities[1].actions.length);
|
828
835
|
assert.equal('getToken', expectedCapabilities[1].actions[0]);
|
@@ -475,6 +475,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
475
475
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapUnsuspendAdapter'));
|
476
476
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'iapGetAdapterQueue'));
|
477
477
|
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequest'));
|
478
|
+
assert.notEqual(undefined, pronghornDotJson.methods.find((e) => e.name === 'genericAdapterRequestNoBasePath'));
|
478
479
|
done();
|
479
480
|
} catch (error) {
|
480
481
|
log.error(`Test Failure: ${error}`);
|
@@ -646,6 +647,8 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
646
647
|
assert.equal('string', propertiesDotJson.definitions.authentication.properties.client_id.type);
|
647
648
|
assert.equal('string', propertiesDotJson.definitions.authentication.properties.client_secret.type);
|
648
649
|
assert.equal('string', propertiesDotJson.definitions.authentication.properties.grant_type.type);
|
650
|
+
assert.notEqual(undefined, propertiesDotJson.definitions.ssl);
|
651
|
+
assert.notEqual(null, propertiesDotJson.definitions.ssl);
|
649
652
|
assert.notEqual('', propertiesDotJson.definitions.ssl);
|
650
653
|
assert.equal('string', propertiesDotJson.definitions.ssl.properties.ecdhCurve.type);
|
651
654
|
assert.equal('boolean', propertiesDotJson.definitions.ssl.properties.enabled.type);
|
@@ -659,6 +662,7 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
659
662
|
assert.equal('string', propertiesDotJson.properties.version.type);
|
660
663
|
assert.equal('string', propertiesDotJson.properties.cache_location.type);
|
661
664
|
assert.equal('boolean', propertiesDotJson.properties.encode_pathvars.type);
|
665
|
+
assert.equal('boolean', propertiesDotJson.properties.encode_queryvars.type);
|
662
666
|
assert.equal(true, Array.isArray(propertiesDotJson.properties.save_metric.type));
|
663
667
|
assert.equal('string', propertiesDotJson.properties.protocol.type);
|
664
668
|
assert.notEqual(undefined, propertiesDotJson.definitions);
|
@@ -707,8 +711,6 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
707
711
|
assert.equal('string', propertiesDotJson.definitions.proxy.properties.protocol.type);
|
708
712
|
assert.equal('string', propertiesDotJson.definitions.proxy.properties.username.type);
|
709
713
|
assert.equal('string', propertiesDotJson.definitions.proxy.properties.password.type);
|
710
|
-
assert.notEqual(undefined, propertiesDotJson.definitions.ssl);
|
711
|
-
assert.notEqual(null, propertiesDotJson.definitions.ssl);
|
712
714
|
assert.notEqual(undefined, propertiesDotJson.definitions.mongo);
|
713
715
|
assert.notEqual(null, propertiesDotJson.definitions.mongo);
|
714
716
|
assert.notEqual('', propertiesDotJson.definitions.mongo);
|
@@ -1291,18 +1293,6 @@ describe('[unit] Meraki Adapter Test', () => {
|
|
1291
1293
|
});
|
1292
1294
|
});
|
1293
1295
|
|
1294
|
-
describe('#hasDevices', () => {
|
1295
|
-
it('should have a hasDevices function', (done) => {
|
1296
|
-
try {
|
1297
|
-
assert.equal(true, typeof a.hasDevices === 'function');
|
1298
|
-
done();
|
1299
|
-
} catch (error) {
|
1300
|
-
log.error(`Test Failure: ${error}`);
|
1301
|
-
done(error);
|
1302
|
-
}
|
1303
|
-
});
|
1304
|
-
});
|
1305
|
-
|
1306
1296
|
describe('#getDevice', () => {
|
1307
1297
|
it('should have a getDevice function', (done) => {
|
1308
1298
|
try {
|
@@ -0,0 +1,206 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
/* @copyright Itential, LLC 2019 */
|
3
|
+
/* eslint global-require:warn */
|
4
|
+
/* eslint import/no-dynamic-require:warn */
|
5
|
+
/* eslint prefer-destructuring:warn */
|
6
|
+
|
7
|
+
const fs = require('fs-extra');
|
8
|
+
const path = require('path');
|
9
|
+
|
10
|
+
/**
|
11
|
+
* This script will determine the information about the adapter and store
|
12
|
+
* it into a file in the adapter.
|
13
|
+
*/
|
14
|
+
|
15
|
+
/**
|
16
|
+
* get adapter information
|
17
|
+
*/
|
18
|
+
function adapterInfo() {
|
19
|
+
// set the base pase of the adapter - tool shoud be one level up in utils
|
20
|
+
let adaptdir = __dirname;
|
21
|
+
const infoRes = {};
|
22
|
+
|
23
|
+
if (adaptdir.endsWith('/utils')) {
|
24
|
+
adaptdir = adaptdir.substring(0, adaptdir.length - 6);
|
25
|
+
}
|
26
|
+
const pack = require(`${adaptdir}/package.json`);
|
27
|
+
infoRes.version = pack.version;
|
28
|
+
|
29
|
+
let configCount = 0;
|
30
|
+
if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
|
31
|
+
const cFile = fs.readFileSync(`${adaptdir}/pronghorn.json`, 'utf8');
|
32
|
+
configCount += cFile.split('\n').length;
|
33
|
+
} else {
|
34
|
+
console.log('Missing - pronghorn.json');
|
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
|
+
}
|
66
|
+
infoRes.configLines = configCount;
|
67
|
+
|
68
|
+
let scodeCount = 0;
|
69
|
+
if (fs.existsSync(`${adaptdir}/utils/artifactize.js`)) {
|
70
|
+
const sFile = fs.readFileSync(`${adaptdir}/utils/artifactize.js`, 'utf8');
|
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;
|
136
|
+
|
137
|
+
let codeCount = 0;
|
138
|
+
if (fs.existsSync(`${adaptdir}/adapter.js`)) {
|
139
|
+
const aFile = fs.readFileSync(`${adaptdir}/adapter.js`, 'utf8');
|
140
|
+
codeCount += aFile.split('\n').length;
|
141
|
+
} else {
|
142
|
+
console.log('Missing - utils/adapter.js');
|
143
|
+
}
|
144
|
+
if (fs.existsSync(`${adaptdir}/adapterBase.js`)) {
|
145
|
+
const aFile = fs.readFileSync(`${adaptdir}/adapterBase.js`, 'utf8');
|
146
|
+
codeCount += aFile.split('\n').length;
|
147
|
+
} else {
|
148
|
+
console.log('Missing - utils/adapterBase.js');
|
149
|
+
}
|
150
|
+
infoRes.codeLines = codeCount;
|
151
|
+
|
152
|
+
let tcodeCount = 0;
|
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;
|
192
|
+
|
193
|
+
if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
|
194
|
+
// Read the entity schema from the file system
|
195
|
+
const phFile = path.join(adaptdir, '/pronghorn.json');
|
196
|
+
const prong = require(phFile);
|
197
|
+
infoRes.wfTasks = prong.methods.length;
|
198
|
+
} else {
|
199
|
+
console.log('Missing - pronghorn.json');
|
200
|
+
}
|
201
|
+
|
202
|
+
console.log(JSON.stringify(infoRes));
|
203
|
+
fs.writeFileSync(`${adaptdir}/report/adapterInfo.json`, JSON.stringify(infoRes, null, 2));
|
204
|
+
}
|
205
|
+
|
206
|
+
adapterInfo();
|
package/utils/pre-commit.sh
CHANGED
@@ -17,6 +17,9 @@ printf "%b" "Running pre-commit hooks...\\n"
|
|
17
17
|
# verify testing script is stubbed and no credentials
|
18
18
|
node utils/testRunner.js -r
|
19
19
|
|
20
|
+
# update the adapter information file
|
21
|
+
node utils/adapterInfo.js
|
22
|
+
|
20
23
|
# security audit on the code
|
21
24
|
npm audit --registry=https://registry.npmjs.org --audit-level=moderate
|
22
25
|
|