ts-node-client 3.2.1 → 3.2.3
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/.editorconfig +10 -10
- package/.eslintrc.json +29 -29
- package/.gitattributes +4 -4
- package/.github/workflows/codeql-analysis.yml +71 -71
- package/.github/workflows/publish.yml +32 -0
- package/.travis.yml +12 -12
- package/CHANGELOG.md +67 -52
- package/LICENSE +202 -202
- package/README.md +191 -191
- package/SECURITY.md +21 -21
- package/lib/cli.js +122 -122
- package/lib/convertor.js +244 -244
- package/lib/dependency.js +169 -169
- package/lib/meteor-scanner.js +61 -61
- package/lib/npm-scanner.js +334 -334
- package/lib/pkg.js +36 -36
- package/lib/rest-client.js +129 -129
- package/lib/scanresult.js +32 -32
- package/package-lock.json +5147 -0
- package/package-lock_dev_test.json +47 -47
- package/package-lock_v1.json +863 -863
- package/package-lock_v2.json +5147 -5147
- package/package-lock_v3.json +3014 -3014
- package/package.json +55 -55
- package/test/dependency-test.js +309 -309
- package/test/error-test.js +80 -80
- package/test/rest-test.js +75 -75
- package/test/scanresult-test.js +44 -44
- package/.yarnrc.yml +0 -1
package/test/error-test.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**********************************************************
|
|
3
|
-
* Copyright (c) 2017. Enterprise Architecture Group, EACG
|
|
4
|
-
*
|
|
5
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
*********************************************************/
|
|
7
|
-
/* eslint-enable */
|
|
8
|
-
/* eslint-env mocha */
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const assert = require('assert');
|
|
12
|
-
const util = require('util');
|
|
13
|
-
|
|
14
|
-
const SHOULD_CONTAIN = 'should contain \'name\' and \'message\' fields';
|
|
15
|
-
|
|
16
|
-
describe('Error object', () => {
|
|
17
|
-
describe('Base object', () => {
|
|
18
|
-
it(SHOULD_CONTAIN, () => {
|
|
19
|
-
try {
|
|
20
|
-
throw new Error('test');
|
|
21
|
-
} catch (err) {
|
|
22
|
-
assert.equal(err.name, 'Error');
|
|
23
|
-
assert.equal(err.message, 'test');
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('TypeError object', () => {
|
|
29
|
-
it(SHOULD_CONTAIN, () => {
|
|
30
|
-
try {
|
|
31
|
-
throw new TypeError('test');
|
|
32
|
-
} catch (err) {
|
|
33
|
-
assert.equal(err.name, 'TypeError');
|
|
34
|
-
assert.equal(err.message, 'test');
|
|
35
|
-
assert.equal(typeof err.stack, 'string');
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('Custom error object MDN version', () => {
|
|
41
|
-
function MyError(message) {
|
|
42
|
-
this.name = 'MyError';
|
|
43
|
-
this.message = message || 'Default Message';
|
|
44
|
-
}
|
|
45
|
-
MyError.prototype = Object.create(Error.prototype);
|
|
46
|
-
MyError.prototype.constructor = MyError;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
it(SHOULD_CONTAIN, () => {
|
|
50
|
-
try {
|
|
51
|
-
throw new MyError('test');
|
|
52
|
-
} catch (err) {
|
|
53
|
-
assert.equal(err.name, 'MyError');
|
|
54
|
-
assert.equal(err.message, 'test');
|
|
55
|
-
assert.equal(typeof err.stack, 'undefined');
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe('Custom error object Node version', () => {
|
|
61
|
-
function MyError(message) {
|
|
62
|
-
Error.call(this);
|
|
63
|
-
this.name = 'MyError';
|
|
64
|
-
this.message = message || 'Default Message';
|
|
65
|
-
Error.captureStackTrace(this);
|
|
66
|
-
}
|
|
67
|
-
util.inherits(MyError, Error); // inherit at least better toString() method
|
|
68
|
-
|
|
69
|
-
it(SHOULD_CONTAIN, () => {
|
|
70
|
-
try {
|
|
71
|
-
throw new MyError('test');
|
|
72
|
-
} catch (err) {
|
|
73
|
-
assert.equal(err.name, 'MyError');
|
|
74
|
-
assert.equal(err.message, 'test');
|
|
75
|
-
assert.equal(typeof err.stack, 'string');
|
|
76
|
-
assert.equal(err.toString(), 'MyError: test');
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**********************************************************
|
|
3
|
+
* Copyright (c) 2017. Enterprise Architecture Group, EACG
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*********************************************************/
|
|
7
|
+
/* eslint-enable */
|
|
8
|
+
/* eslint-env mocha */
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const assert = require('assert');
|
|
12
|
+
const util = require('util');
|
|
13
|
+
|
|
14
|
+
const SHOULD_CONTAIN = 'should contain \'name\' and \'message\' fields';
|
|
15
|
+
|
|
16
|
+
describe('Error object', () => {
|
|
17
|
+
describe('Base object', () => {
|
|
18
|
+
it(SHOULD_CONTAIN, () => {
|
|
19
|
+
try {
|
|
20
|
+
throw new Error('test');
|
|
21
|
+
} catch (err) {
|
|
22
|
+
assert.equal(err.name, 'Error');
|
|
23
|
+
assert.equal(err.message, 'test');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('TypeError object', () => {
|
|
29
|
+
it(SHOULD_CONTAIN, () => {
|
|
30
|
+
try {
|
|
31
|
+
throw new TypeError('test');
|
|
32
|
+
} catch (err) {
|
|
33
|
+
assert.equal(err.name, 'TypeError');
|
|
34
|
+
assert.equal(err.message, 'test');
|
|
35
|
+
assert.equal(typeof err.stack, 'string');
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('Custom error object MDN version', () => {
|
|
41
|
+
function MyError(message) {
|
|
42
|
+
this.name = 'MyError';
|
|
43
|
+
this.message = message || 'Default Message';
|
|
44
|
+
}
|
|
45
|
+
MyError.prototype = Object.create(Error.prototype);
|
|
46
|
+
MyError.prototype.constructor = MyError;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
it(SHOULD_CONTAIN, () => {
|
|
50
|
+
try {
|
|
51
|
+
throw new MyError('test');
|
|
52
|
+
} catch (err) {
|
|
53
|
+
assert.equal(err.name, 'MyError');
|
|
54
|
+
assert.equal(err.message, 'test');
|
|
55
|
+
assert.equal(typeof err.stack, 'undefined');
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('Custom error object Node version', () => {
|
|
61
|
+
function MyError(message) {
|
|
62
|
+
Error.call(this);
|
|
63
|
+
this.name = 'MyError';
|
|
64
|
+
this.message = message || 'Default Message';
|
|
65
|
+
Error.captureStackTrace(this);
|
|
66
|
+
}
|
|
67
|
+
util.inherits(MyError, Error); // inherit at least better toString() method
|
|
68
|
+
|
|
69
|
+
it(SHOULD_CONTAIN, () => {
|
|
70
|
+
try {
|
|
71
|
+
throw new MyError('test');
|
|
72
|
+
} catch (err) {
|
|
73
|
+
assert.equal(err.name, 'MyError');
|
|
74
|
+
assert.equal(err.message, 'test');
|
|
75
|
+
assert.equal(typeof err.stack, 'string');
|
|
76
|
+
assert.equal(err.toString(), 'MyError: test');
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
package/test/rest-test.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**********************************************************
|
|
3
|
-
* Copyright (c) 2017. Enterprise Architecture Group, EACG
|
|
4
|
-
*
|
|
5
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
*********************************************************/
|
|
7
|
-
/* eslint-enable */
|
|
8
|
-
/* eslint-env mocha */
|
|
9
|
-
|
|
10
|
-
const assert = require('assert');
|
|
11
|
-
const nock = require('nock');
|
|
12
|
-
const { RestClient } = require('../lib/rest-client');
|
|
13
|
-
|
|
14
|
-
const JSON_TYPE = 'application/json';
|
|
15
|
-
const url = 'http://localhost:3000';
|
|
16
|
-
|
|
17
|
-
/* eslint-disable no-new */
|
|
18
|
-
describe('RestClient', () => {
|
|
19
|
-
describe('Constructor', () => {
|
|
20
|
-
it('should throw Error if no options defined', () => {
|
|
21
|
-
assert.throws(() => {
|
|
22
|
-
new RestClient();
|
|
23
|
-
}, TypeError);
|
|
24
|
-
});
|
|
25
|
-
it('should throw Error if no url attribute defined', () => {
|
|
26
|
-
assert.throws(() => {
|
|
27
|
-
new RestClient({});
|
|
28
|
-
}, TypeError);
|
|
29
|
-
});
|
|
30
|
-
it('should accept url attribute', () => {
|
|
31
|
-
assert.doesNotThrow(() => {
|
|
32
|
-
const restClient = new RestClient({ url });
|
|
33
|
-
assert.notEqual(restClient, undefined);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('transfer method', () => {
|
|
39
|
-
let restClient;
|
|
40
|
-
|
|
41
|
-
beforeEach(() => {
|
|
42
|
-
restClient = new RestClient({ url: 'http://localhost:3000', apiKey: 'test' });
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should call callback with response data if no error occurs', (done) => {
|
|
46
|
-
nock(url, {
|
|
47
|
-
reqheaders: {
|
|
48
|
-
'Content-Type': JSON_TYPE
|
|
49
|
-
}
|
|
50
|
-
}).post('/api/v1/scans').reply(201, 'Test response');
|
|
51
|
-
|
|
52
|
-
restClient.transfer({}, (err, data) => {
|
|
53
|
-
assert.equal(err, null);
|
|
54
|
-
assert.equal(data, 'Test response');
|
|
55
|
-
done();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('response should be parsed as json object, if \'content-type\': \'application/json\'', (done) => {
|
|
60
|
-
nock(url, {
|
|
61
|
-
reqheaders: {
|
|
62
|
-
'Content-Type': JSON_TYPE
|
|
63
|
-
}
|
|
64
|
-
}).defaultReplyHeaders({
|
|
65
|
-
'Content-Type': JSON_TYPE
|
|
66
|
-
}).post('/api/v1/scans').reply(201, '{"bli": "blub"}');
|
|
67
|
-
|
|
68
|
-
restClient.transfer({}, (err, data) => {
|
|
69
|
-
assert.equal(err, null);
|
|
70
|
-
assert.deepEqual(data, { bli: 'blub' });
|
|
71
|
-
done();
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**********************************************************
|
|
3
|
+
* Copyright (c) 2017. Enterprise Architecture Group, EACG
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*********************************************************/
|
|
7
|
+
/* eslint-enable */
|
|
8
|
+
/* eslint-env mocha */
|
|
9
|
+
|
|
10
|
+
const assert = require('assert');
|
|
11
|
+
const nock = require('nock');
|
|
12
|
+
const { RestClient } = require('../lib/rest-client');
|
|
13
|
+
|
|
14
|
+
const JSON_TYPE = 'application/json';
|
|
15
|
+
const url = 'http://localhost:3000';
|
|
16
|
+
|
|
17
|
+
/* eslint-disable no-new */
|
|
18
|
+
describe('RestClient', () => {
|
|
19
|
+
describe('Constructor', () => {
|
|
20
|
+
it('should throw Error if no options defined', () => {
|
|
21
|
+
assert.throws(() => {
|
|
22
|
+
new RestClient();
|
|
23
|
+
}, TypeError);
|
|
24
|
+
});
|
|
25
|
+
it('should throw Error if no url attribute defined', () => {
|
|
26
|
+
assert.throws(() => {
|
|
27
|
+
new RestClient({});
|
|
28
|
+
}, TypeError);
|
|
29
|
+
});
|
|
30
|
+
it('should accept url attribute', () => {
|
|
31
|
+
assert.doesNotThrow(() => {
|
|
32
|
+
const restClient = new RestClient({ url });
|
|
33
|
+
assert.notEqual(restClient, undefined);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('transfer method', () => {
|
|
39
|
+
let restClient;
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
restClient = new RestClient({ url: 'http://localhost:3000', apiKey: 'test' });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should call callback with response data if no error occurs', (done) => {
|
|
46
|
+
nock(url, {
|
|
47
|
+
reqheaders: {
|
|
48
|
+
'Content-Type': JSON_TYPE
|
|
49
|
+
}
|
|
50
|
+
}).post('/api/v1/scans').reply(201, 'Test response');
|
|
51
|
+
|
|
52
|
+
restClient.transfer({}, (err, data) => {
|
|
53
|
+
assert.equal(err, null);
|
|
54
|
+
assert.equal(data, 'Test response');
|
|
55
|
+
done();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('response should be parsed as json object, if \'content-type\': \'application/json\'', (done) => {
|
|
60
|
+
nock(url, {
|
|
61
|
+
reqheaders: {
|
|
62
|
+
'Content-Type': JSON_TYPE
|
|
63
|
+
}
|
|
64
|
+
}).defaultReplyHeaders({
|
|
65
|
+
'Content-Type': JSON_TYPE
|
|
66
|
+
}).post('/api/v1/scans').reply(201, '{"bli": "blub"}');
|
|
67
|
+
|
|
68
|
+
restClient.transfer({}, (err, data) => {
|
|
69
|
+
assert.equal(err, null);
|
|
70
|
+
assert.deepEqual(data, { bli: 'blub' });
|
|
71
|
+
done();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
package/test/scanresult-test.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**********************************************************
|
|
3
|
-
* Copyright (c) 2017. Enterprise Architecture Group, EACG
|
|
4
|
-
*
|
|
5
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
*********************************************************/
|
|
7
|
-
/* eslint-enable */
|
|
8
|
-
/* eslint-env mocha */
|
|
9
|
-
|
|
10
|
-
const assert = require('assert');
|
|
11
|
-
const Dependency = require('../lib/dependency');
|
|
12
|
-
const ScanResult = require('../lib/scanresult');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
describe('ScanResult', () => {
|
|
16
|
-
describe('Constructor', () => {
|
|
17
|
-
it('should handle dependencies as array', () => {
|
|
18
|
-
const root1 = new Dependency('root1', '1.1', '---');
|
|
19
|
-
const root2 = new Dependency('root2', '2.0', '---');
|
|
20
|
-
const child1 = new Dependency('child1', '1.0', '---');
|
|
21
|
-
const deps = [root1, root2];
|
|
22
|
-
const scanResult = new ScanResult('project', 'module', 'moduleId', deps);
|
|
23
|
-
|
|
24
|
-
root1.addDependency(child1);
|
|
25
|
-
|
|
26
|
-
assert.equal(scanResult.dependencies.length, 2);
|
|
27
|
-
assert.equal(scanResult.dependencies[0], root1);
|
|
28
|
-
assert.equal(scanResult.dependencies[1], root2);
|
|
29
|
-
assert.equal(scanResult.dependencies[0].dependencies[0], child1);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should handle dependencies as hash', () => {
|
|
33
|
-
const deps = { root1: new Dependency('root1', '1.1', '---'), root2: new Dependency('root2', '2.0', '---') };
|
|
34
|
-
deps.root1.addDependency(new Dependency('child1', '1.0.0', '---'));
|
|
35
|
-
const scanResult = new ScanResult('project', 'module', 'moduleId', deps);
|
|
36
|
-
|
|
37
|
-
assert.equal(scanResult.dependencies.length, 2);
|
|
38
|
-
assert.equal(scanResult.dependencies[0].name, 'root1');
|
|
39
|
-
assert.equal(scanResult.dependencies[1].name, 'root2');
|
|
40
|
-
assert.equal(scanResult.dependencies[0].dependencies[0].name, 'child1');
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**********************************************************
|
|
3
|
+
* Copyright (c) 2017. Enterprise Architecture Group, EACG
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*********************************************************/
|
|
7
|
+
/* eslint-enable */
|
|
8
|
+
/* eslint-env mocha */
|
|
9
|
+
|
|
10
|
+
const assert = require('assert');
|
|
11
|
+
const Dependency = require('../lib/dependency');
|
|
12
|
+
const ScanResult = require('../lib/scanresult');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
describe('ScanResult', () => {
|
|
16
|
+
describe('Constructor', () => {
|
|
17
|
+
it('should handle dependencies as array', () => {
|
|
18
|
+
const root1 = new Dependency('root1', '1.1', '---');
|
|
19
|
+
const root2 = new Dependency('root2', '2.0', '---');
|
|
20
|
+
const child1 = new Dependency('child1', '1.0', '---');
|
|
21
|
+
const deps = [root1, root2];
|
|
22
|
+
const scanResult = new ScanResult('project', 'module', 'moduleId', deps);
|
|
23
|
+
|
|
24
|
+
root1.addDependency(child1);
|
|
25
|
+
|
|
26
|
+
assert.equal(scanResult.dependencies.length, 2);
|
|
27
|
+
assert.equal(scanResult.dependencies[0], root1);
|
|
28
|
+
assert.equal(scanResult.dependencies[1], root2);
|
|
29
|
+
assert.equal(scanResult.dependencies[0].dependencies[0], child1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should handle dependencies as hash', () => {
|
|
33
|
+
const deps = { root1: new Dependency('root1', '1.1', '---'), root2: new Dependency('root2', '2.0', '---') };
|
|
34
|
+
deps.root1.addDependency(new Dependency('child1', '1.0.0', '---'));
|
|
35
|
+
const scanResult = new ScanResult('project', 'module', 'moduleId', deps);
|
|
36
|
+
|
|
37
|
+
assert.equal(scanResult.dependencies.length, 2);
|
|
38
|
+
assert.equal(scanResult.dependencies[0].name, 'root1');
|
|
39
|
+
assert.equal(scanResult.dependencies[1].name, 'root2');
|
|
40
|
+
assert.equal(scanResult.dependencies[0].dependencies[0].name, 'child1');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
package/.yarnrc.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
nodeLinker: node-modules
|