@itentialopensource/adapter-db_mssql 0.3.0 → 1.0.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/.eslintignore +1 -0
- package/CHANGELOG.md +16 -0
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +3 -148
- package/ENHANCE.md +28 -0
- package/PROPERTIES.md +111 -0
- package/SUMMARY.md +9 -0
- package/TROUBLESHOOT.md +28 -0
- package/adapter.js +44 -1
- package/error.json +12 -0
- package/metadata.json +49 -0
- package/package.json +19 -18
- package/pronghorn.json +134 -16
- package/propertiesDecorators.json +14 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/sampleProperties.json +4 -2
- package/test/integration/adapterTestIntegration.js +23 -1
- package/test/unit/adapterTestUnit.js +53 -17
- package/utils/adapterInfo.js +206 -0
- package/utils/artifactize.js +1 -1
- package/utils/packModificationScript.js +2 -2
- package/utils/removeHooks.js +20 -0
- package/utils/testRunner.js +17 -17
package/pronghorn.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"title": "MicrosoftSQL",
|
|
7
7
|
"src": "adapter.js",
|
|
8
8
|
"roles": [
|
|
9
|
-
|
|
9
|
+
"admin"
|
|
10
10
|
],
|
|
11
11
|
"methods": [
|
|
12
12
|
{
|
|
@@ -18,17 +18,29 @@
|
|
|
18
18
|
"name": "sql",
|
|
19
19
|
"type": "string",
|
|
20
20
|
"info": "",
|
|
21
|
-
"required": true
|
|
21
|
+
"required": true,
|
|
22
|
+
"schema": {
|
|
23
|
+
"title": "sql",
|
|
24
|
+
"type": "string"
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
],
|
|
24
28
|
"output": {
|
|
25
29
|
"name": "result",
|
|
26
30
|
"type": "object",
|
|
27
|
-
"description": "A JSON Object containing status, code and the result"
|
|
31
|
+
"description": "A JSON Object containing status, code and the result",
|
|
32
|
+
"schema": {
|
|
33
|
+
"title": "result",
|
|
34
|
+
"type": "object"
|
|
35
|
+
}
|
|
28
36
|
},
|
|
29
37
|
"roles": [
|
|
30
38
|
"admin"
|
|
31
39
|
],
|
|
40
|
+
"route": {
|
|
41
|
+
"verb": "POST",
|
|
42
|
+
"path": "/query"
|
|
43
|
+
},
|
|
32
44
|
"task": true
|
|
33
45
|
},
|
|
34
46
|
{
|
|
@@ -40,17 +52,29 @@
|
|
|
40
52
|
"name": "sql",
|
|
41
53
|
"type": "string",
|
|
42
54
|
"info": "",
|
|
43
|
-
"required": true
|
|
55
|
+
"required": true,
|
|
56
|
+
"schema": {
|
|
57
|
+
"title": "sql",
|
|
58
|
+
"type": "string"
|
|
59
|
+
}
|
|
44
60
|
}
|
|
45
61
|
],
|
|
46
62
|
"output": {
|
|
47
63
|
"name": "result",
|
|
48
64
|
"type": "object",
|
|
49
|
-
"description": "A JSON Object containing status, code and the result"
|
|
65
|
+
"description": "A JSON Object containing status, code and the result",
|
|
66
|
+
"schema": {
|
|
67
|
+
"title": "result",
|
|
68
|
+
"type": "object"
|
|
69
|
+
}
|
|
50
70
|
},
|
|
51
71
|
"roles": [
|
|
52
72
|
"admin"
|
|
53
73
|
],
|
|
74
|
+
"route": {
|
|
75
|
+
"verb": "POST",
|
|
76
|
+
"path": "/create"
|
|
77
|
+
},
|
|
54
78
|
"task": true
|
|
55
79
|
},
|
|
56
80
|
{
|
|
@@ -62,17 +86,63 @@
|
|
|
62
86
|
"name": "sql",
|
|
63
87
|
"type": "string",
|
|
64
88
|
"info": "",
|
|
65
|
-
"required": true
|
|
89
|
+
"required": true,
|
|
90
|
+
"schema": {
|
|
91
|
+
"title": "sql",
|
|
92
|
+
"type": "string"
|
|
93
|
+
}
|
|
66
94
|
}
|
|
67
95
|
],
|
|
68
96
|
"output": {
|
|
69
97
|
"name": "result",
|
|
70
98
|
"type": "object",
|
|
71
|
-
"description": "A JSON Object containing status, code and the result"
|
|
99
|
+
"description": "A JSON Object containing status, code and the result",
|
|
100
|
+
"schema": {
|
|
101
|
+
"title": "result",
|
|
102
|
+
"type": "object"
|
|
103
|
+
}
|
|
72
104
|
},
|
|
73
105
|
"roles": [
|
|
74
106
|
"admin"
|
|
75
107
|
],
|
|
108
|
+
"route": {
|
|
109
|
+
"verb": "POST",
|
|
110
|
+
"path": "/select"
|
|
111
|
+
},
|
|
112
|
+
"task": true
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "selectNoRecordSet",
|
|
116
|
+
"summary": "select item from MicrosoftSQL server",
|
|
117
|
+
"description": "select item from MicrosoftSQL server",
|
|
118
|
+
"input": [
|
|
119
|
+
{
|
|
120
|
+
"name": "sql",
|
|
121
|
+
"type": "string",
|
|
122
|
+
"info": "",
|
|
123
|
+
"required": true,
|
|
124
|
+
"schema": {
|
|
125
|
+
"title": "sql",
|
|
126
|
+
"type": "string"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"output": {
|
|
131
|
+
"name": "result",
|
|
132
|
+
"type": "object",
|
|
133
|
+
"description": "A JSON Object containing status, code and the result",
|
|
134
|
+
"schema": {
|
|
135
|
+
"title": "result",
|
|
136
|
+
"type": "object"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"roles": [
|
|
140
|
+
"admin"
|
|
141
|
+
],
|
|
142
|
+
"route": {
|
|
143
|
+
"verb": "POST",
|
|
144
|
+
"path": "/selectNoRecordSet"
|
|
145
|
+
},
|
|
76
146
|
"task": true
|
|
77
147
|
},
|
|
78
148
|
{
|
|
@@ -84,17 +154,29 @@
|
|
|
84
154
|
"name": "sql",
|
|
85
155
|
"type": "string",
|
|
86
156
|
"info": "",
|
|
87
|
-
"required": true
|
|
157
|
+
"required": true,
|
|
158
|
+
"schema": {
|
|
159
|
+
"title": "sql",
|
|
160
|
+
"type": "string"
|
|
161
|
+
}
|
|
88
162
|
}
|
|
89
163
|
],
|
|
90
164
|
"output": {
|
|
91
165
|
"name": "result",
|
|
92
166
|
"type": "object",
|
|
93
|
-
"description": "A JSON Object containing status, code and the result"
|
|
167
|
+
"description": "A JSON Object containing status, code and the result",
|
|
168
|
+
"schema": {
|
|
169
|
+
"title": "result",
|
|
170
|
+
"type": "object"
|
|
171
|
+
}
|
|
94
172
|
},
|
|
95
173
|
"roles": [
|
|
96
174
|
"admin"
|
|
97
175
|
],
|
|
176
|
+
"route": {
|
|
177
|
+
"verb": "POST",
|
|
178
|
+
"path": "/insert"
|
|
179
|
+
},
|
|
98
180
|
"task": true
|
|
99
181
|
},
|
|
100
182
|
{
|
|
@@ -106,17 +188,29 @@
|
|
|
106
188
|
"name": "sql",
|
|
107
189
|
"type": "string",
|
|
108
190
|
"info": "",
|
|
109
|
-
"required": true
|
|
191
|
+
"required": true,
|
|
192
|
+
"schema": {
|
|
193
|
+
"title": "sql",
|
|
194
|
+
"type": "string"
|
|
195
|
+
}
|
|
110
196
|
}
|
|
111
197
|
],
|
|
112
198
|
"output": {
|
|
113
199
|
"name": "result",
|
|
114
200
|
"type": "object",
|
|
115
|
-
"description": "A JSON Object containing status, code and the result"
|
|
201
|
+
"description": "A JSON Object containing status, code and the result",
|
|
202
|
+
"schema": {
|
|
203
|
+
"title": "result",
|
|
204
|
+
"type": "object"
|
|
205
|
+
}
|
|
116
206
|
},
|
|
117
207
|
"roles": [
|
|
118
208
|
"admin"
|
|
119
209
|
],
|
|
210
|
+
"route": {
|
|
211
|
+
"verb": "POST",
|
|
212
|
+
"path": "/update"
|
|
213
|
+
},
|
|
120
214
|
"task": true
|
|
121
215
|
},
|
|
122
216
|
{
|
|
@@ -128,17 +222,29 @@
|
|
|
128
222
|
"name": "sql",
|
|
129
223
|
"type": "string",
|
|
130
224
|
"info": "",
|
|
131
|
-
"required": true
|
|
225
|
+
"required": true,
|
|
226
|
+
"schema": {
|
|
227
|
+
"title": "sql",
|
|
228
|
+
"type": "string"
|
|
229
|
+
}
|
|
132
230
|
}
|
|
133
231
|
],
|
|
134
232
|
"output": {
|
|
135
233
|
"name": "result",
|
|
136
234
|
"type": "object",
|
|
137
|
-
"description": "A JSON Object containing status, code and the result"
|
|
235
|
+
"description": "A JSON Object containing status, code and the result",
|
|
236
|
+
"schema": {
|
|
237
|
+
"title": "result",
|
|
238
|
+
"type": "object"
|
|
239
|
+
}
|
|
138
240
|
},
|
|
139
241
|
"roles": [
|
|
140
242
|
"admin"
|
|
141
243
|
],
|
|
244
|
+
"route": {
|
|
245
|
+
"verb": "POST",
|
|
246
|
+
"path": "/delete"
|
|
247
|
+
},
|
|
142
248
|
"task": true
|
|
143
249
|
},
|
|
144
250
|
{
|
|
@@ -150,18 +256,30 @@
|
|
|
150
256
|
"name": "sql",
|
|
151
257
|
"type": "string",
|
|
152
258
|
"info": "",
|
|
153
|
-
"required": true
|
|
259
|
+
"required": true,
|
|
260
|
+
"schema": {
|
|
261
|
+
"title": "sql",
|
|
262
|
+
"type": "string"
|
|
263
|
+
}
|
|
154
264
|
}
|
|
155
265
|
],
|
|
156
266
|
"output": {
|
|
157
267
|
"name": "result",
|
|
158
268
|
"type": "object",
|
|
159
|
-
"description": "A JSON Object containing status, code and the result"
|
|
269
|
+
"description": "A JSON Object containing status, code and the result",
|
|
270
|
+
"schema": {
|
|
271
|
+
"title": "result",
|
|
272
|
+
"type": "object"
|
|
273
|
+
}
|
|
160
274
|
},
|
|
161
275
|
"roles": [
|
|
162
276
|
"admin"
|
|
163
277
|
],
|
|
278
|
+
"route": {
|
|
279
|
+
"verb": "POST",
|
|
280
|
+
"path": "/drop"
|
|
281
|
+
},
|
|
164
282
|
"task": true
|
|
165
283
|
}
|
|
166
284
|
]
|
|
167
|
-
}
|
|
285
|
+
}
|
|
Binary file
|
package/sampleProperties.json
CHANGED
|
@@ -129,7 +129,7 @@ function runErrorAsserts(data, error, code, origin, displayStr) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
// require the adapter that we are going to be using
|
|
132
|
-
const MicrosoftSQL = require('../../adapter
|
|
132
|
+
const MicrosoftSQL = require('../../adapter');
|
|
133
133
|
|
|
134
134
|
// begin the testing - these should be pretty well defined between the describe and the it!
|
|
135
135
|
describe('[integration] MicrosoftSQL Adapter Test', () => {
|
|
@@ -284,6 +284,28 @@ describe('[integration] MicrosoftSQL Adapter Test', () => {
|
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
286
|
|
|
287
|
+
describe('#selectNoRecordSet', function () {
|
|
288
|
+
if (!stub) {
|
|
289
|
+
it('should select a record', (done) => {
|
|
290
|
+
try {
|
|
291
|
+
a.selectNoRecordSet(selectSQL, (data, error) => {
|
|
292
|
+
try {
|
|
293
|
+
runCommonAsserts(data, error);
|
|
294
|
+
assert.equal(200, data.code);
|
|
295
|
+
done();
|
|
296
|
+
} catch (ex) {
|
|
297
|
+
log.error(`Test Failure: ${ex}`);
|
|
298
|
+
done(ex);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
} catch (exc) {
|
|
302
|
+
log.error(`Adapter Exception: ${exc}`);
|
|
303
|
+
done(exc);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
287
309
|
const querySQL = 'SELECT name FROM Dogs;';
|
|
288
310
|
describe('#query', function () {
|
|
289
311
|
if (!stub) {
|
|
@@ -16,7 +16,9 @@ const execute = require('child_process').execSync;
|
|
|
16
16
|
const { expect } = require('chai');
|
|
17
17
|
const { use } = require('chai');
|
|
18
18
|
const td = require('testdouble');
|
|
19
|
+
const Ajv = require('ajv');
|
|
19
20
|
|
|
21
|
+
const ajv = new Ajv({ strictSchema: false, allErrors: true, allowUnionTypes: true });
|
|
20
22
|
const anything = td.matchers.anything();
|
|
21
23
|
|
|
22
24
|
// stub and attemptTimeout are used throughout the code so set them here
|
|
@@ -122,7 +124,7 @@ function runErrorAsserts(data, error, code, origin, displayStr) {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
// require the adapter that we are going to be using
|
|
125
|
-
const MicrosoftSQL = require('../../adapter
|
|
127
|
+
const MicrosoftSQL = require('../../adapter');
|
|
126
128
|
|
|
127
129
|
// delete the .DS_Store directory in entities -- otherwise this will cause errors
|
|
128
130
|
const dirPath = path.join(__dirname, '../../entities/.DS_Store');
|
|
@@ -186,23 +188,33 @@ describe('[unit] MicrosoftSQL Adapter Test', () => {
|
|
|
186
188
|
});
|
|
187
189
|
});
|
|
188
190
|
it('package.json should be validated', (done) => {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
191
|
+
try {
|
|
192
|
+
const packageDotJson = require('../../package.json');
|
|
193
|
+
// Define the JSON schema for package.json
|
|
194
|
+
const packageJsonSchema = {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
name: { type: 'string' },
|
|
198
|
+
version: { type: 'string' }
|
|
199
|
+
// May need to add more properties as needed
|
|
200
|
+
},
|
|
201
|
+
required: ['name', 'version']
|
|
202
|
+
};
|
|
203
|
+
const validate = ajv.compile(packageJsonSchema);
|
|
204
|
+
const isValid = validate(packageDotJson);
|
|
205
|
+
|
|
206
|
+
if (isValid === false) {
|
|
207
|
+
log.error('The package.json contains errors');
|
|
208
|
+
assert.equal(true, isValid);
|
|
209
|
+
} else {
|
|
210
|
+
assert.equal(true, isValid);
|
|
211
|
+
}
|
|
204
212
|
|
|
205
|
-
|
|
213
|
+
done();
|
|
214
|
+
} catch (error) {
|
|
215
|
+
log.error(`Test Failure: ${error}`);
|
|
216
|
+
done(error);
|
|
217
|
+
}
|
|
206
218
|
});
|
|
207
219
|
it('package.json should be customized', (done) => {
|
|
208
220
|
const packageDotJson = require('../../package.json');
|
|
@@ -471,6 +483,30 @@ describe('[unit] MicrosoftSQL Adapter Test', () => {
|
|
|
471
483
|
}).timeout(attemptTimeout);
|
|
472
484
|
});
|
|
473
485
|
|
|
486
|
+
describe('#selectNoRecordSet - errors', () => {
|
|
487
|
+
it('should have a selectNoRecordSet function', (done) => {
|
|
488
|
+
assert.equal(true, typeof a.selectNoRecordSet === 'function');
|
|
489
|
+
done();
|
|
490
|
+
});
|
|
491
|
+
it('should error on selectNoRecordSet - no sql string', (done) => {
|
|
492
|
+
try {
|
|
493
|
+
a.selectNoRecordSet(null, (data, error) => {
|
|
494
|
+
try {
|
|
495
|
+
const displayE = 'sql is required';
|
|
496
|
+
runErrorAsserts(data, error, 'AD.300', 'Test-db_mssql-adapter-selectNoRecordSet', displayE);
|
|
497
|
+
done();
|
|
498
|
+
} catch (ex) {
|
|
499
|
+
log.error(`Test Failure: ${ex}`);
|
|
500
|
+
done(ex);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
} catch (exc) {
|
|
504
|
+
log.error(`Adapter Exception: ${exc}`);
|
|
505
|
+
done(exc);
|
|
506
|
+
}
|
|
507
|
+
}).timeout(attemptTimeout);
|
|
508
|
+
});
|
|
509
|
+
|
|
474
510
|
describe('#insert - errors', () => {
|
|
475
511
|
it('should have a insert function', (done) => {
|
|
476
512
|
assert.equal(true, typeof a.insert === 'function');
|
|
@@ -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 path = require('path');
|
|
8
|
+
const fs = require('fs-extra');
|
|
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/artifactize.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* @copyright Itential, LLC 2019 */
|
|
3
3
|
|
|
4
|
-
const fs = require('fs-extra');
|
|
5
4
|
const path = require('path');
|
|
6
5
|
const { spawnSync } = require('child_process');
|
|
7
|
-
const
|
|
6
|
+
const fs = require('fs-extra');
|
|
7
|
+
const { createBundle } = require('./artifactize');
|
|
8
8
|
|
|
9
9
|
const nodeEntryPath = path.resolve('.');
|
|
10
10
|
createBundle(nodeEntryPath).then((pathObj) => {
|