ts-node-client 1.8.7 → 2.1.1

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/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # TrustSource ts-node-client
2
2
 
3
- [![Travis build status](https://travis-ci.org/TrustSource/ts-node-client.svg?branch=master)](https://travis-ci.org/TrustSource/ts-node-client)
4
3
  [![Version](https://img.shields.io/npm/v/ts-node-client.svg)](http://npm.im/ts-node-client)
5
4
  [![Downloads](https://img.shields.io/npm/dm/ts-node-client.svg)](http://npm-stat.com/charts.html?package=ts-node-client)
6
5
  [![Downloads](https://img.shields.io/npm/dt/ts-node-client.svg)](http://npm-stat.com/charts.html?package=ts-node-client)
@@ -61,9 +60,9 @@ Options:
61
60
  --url url [default: null]
62
61
  --config, -c Config path [default: null]
63
62
  --proxy Proxy url like 'https://user:password@host:port' [default: null]
64
- --version, -v Prints a version [default: false]
63
+ --version Prints a version [default: null]
65
64
  --saveAs, -o Save as file (file name prefix) [default: null]
66
- --saveAsFormat, -of Save as format (scan / cydx / spdx) [default: null]
65
+ --saveAsFormat, -f Save as format (scan / cydx / spdx) [default: null]
67
66
  --debug [default: null]
68
67
  --simulate [default: null]
69
68
  --includeDevDependencies [default: null]
@@ -82,7 +81,6 @@ you should add value, for example:
82
81
 
83
82
  [View SBOM <img alt="TrustSource" src="https://app.trustsource.io/logo.png" width="70"/>](https://app.trustsource.io/api/v1/public-BoM/ae0832c6-5a55-4aa8-8c45-75528d0833fb)
84
83
 
85
-
86
84
  ## Known problems
87
85
 
88
86
  #### Error: The programmatic API was removed in npm v8.0.0
@@ -90,8 +88,13 @@ You should upgrade to 2.* versions of ts-node-client
90
88
 
91
89
  ## Changelog
92
90
 
93
- #### 2.0
91
+ #### 2.1.*
92
+ - Migrate 1.6.* - 1.8.* changes to version 2.1
93
+
94
+ #### 2.0.*
94
95
  - Support new scan tool and fix problem with programmatic API for >= npm@8.0.0
96
+ - Stop usage of [`global-npm`](https://github.com/dracupid/global-npm) until we find new resolution
97
+ - Get back `npm` as local dependency
95
98
 
96
99
  #### 1.8.*
97
100
  - SBOM
@@ -56,18 +56,13 @@ const getOptions = () => {
56
56
  default: null,
57
57
  describe: 'Proxy url like \'https://user:password@host:port\''
58
58
  },
59
- version: {
60
- alias: 'v',
61
- default: false,
62
- describe: 'Prints a version'
63
- },
64
59
  saveAs: {
65
60
  alias: 'o',
66
61
  default: null,
67
62
  describe: 'Save as file (file name prefix)'
68
63
  },
69
64
  saveAsFormat: {
70
- alias: 'of',
65
+ alias: 'f',
71
66
  default: null,
72
67
  describe: 'Save as format (scan / cydx / spdx)'
73
68
  },
@@ -96,6 +91,7 @@ const getOptions = () => {
96
91
  describe: 'includeDevDependencies'
97
92
  }
98
93
  })
94
+ .version()
99
95
  .usage(pckgJson.description)
100
96
  .help('help', 'Prints a usage statement')
101
97
  .fail((msg, err, yargsObject) => {
@@ -6,7 +6,7 @@
6
6
  *********************************************************/
7
7
  /* eslint-enable */
8
8
 
9
- const npm = require('global-npm');
9
+ const npm = require('npm');
10
10
  const debuglog = (require('debuglog'))('ts-npm-scanner');
11
11
  const ScanResult = require('./scanresult');
12
12
  const { RestClient } = require('./rest-client');
@@ -39,7 +39,8 @@ Scanner.prototype.scan = function scan(cb) {
39
39
  const dependency = self.walk(data);
40
40
  const result = new ScanResult(
41
41
  options.project,
42
- data.name, `npm:${data.name}`,
42
+ data.name,
43
+ `npm:${data.name}`,
43
44
  dependency
44
45
  );
45
46
  debuglog('result: ', JSON.stringify(result));
@@ -73,9 +74,16 @@ Scanner.prototype.walk = function walk(npmDependency, level) {
73
74
  printDependency(npmDependency, level);
74
75
 
75
76
  if (npmDependency.name) {
76
- const dependency = new Dependency(npmDependency.name, npmDependency.version, 'npm', npmDependency.description,
77
- npmDependency.private, npmDependency.licenses || npmDependency.license,
78
- npmDependency.homepage, npmDependency.repository ? npmDependency.repository.url : undefined);
77
+ const dependency = new Dependency(
78
+ npmDependency.name,
79
+ npmDependency.version,
80
+ 'npm',
81
+ npmDependency.description,
82
+ npmDependency.private,
83
+ npmDependency.licenses || npmDependency.license,
84
+ npmDependency.homepage,
85
+ npmDependency.repository ? npmDependency.repository.url : undefined
86
+ );
79
87
 
80
88
  if (npmDependency.dependencies) {
81
89
  Object.getOwnPropertyNames(npmDependency.dependencies).forEach((val) => {
package/lib/pkg.js CHANGED
@@ -13,20 +13,24 @@ PackageURL.get = function get(manager, org, key, version) {
13
13
  const parts = [];
14
14
  let partVersion;
15
15
  if (manager) {
16
- parts.push(encodeURI(manager));
16
+ parts.push(fixPart(manager));
17
17
  }
18
18
  if (org) {
19
- parts.push(encodeURI(org).replace('%3A', ':'));
19
+ parts.push(fixPart(org));
20
20
  }
21
21
  if (key) {
22
- parts.push(encodeURI(key).replace('%3A', ':'));
22
+ parts.push(fixPart(key));
23
23
  }
24
24
  if (version) {
25
- partVersion = `@${encodeURI(version).replace('%3A', ':')}`;
25
+ partVersion = `@${fixPart(version)}`;
26
26
  }
27
27
  return `pkg:${parts.join('/')}${partVersion}`;
28
28
  };
29
29
 
30
+ function fixPart(str) {
31
+ const newStr = encodeURI(str);
32
+ return newStr.replace('%3A', ':');
33
+ }
30
34
 
31
35
  module.exports = PackageURL;
32
36
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ts-node-client",
3
3
  "description": "npm / node module to transfer dependency information to TrustSource server.",
4
- "version": "1.8.7",
4
+ "version": "2.1.1",
5
5
  "private": false,
6
6
  "homepage": "https://app.trustsource.io/",
7
7
  "author": {
@@ -14,8 +14,7 @@
14
14
  },
15
15
  "license": "Apache-2.0",
16
16
  "engines": {
17
- "node": ">= 8.9.0",
18
- "npm": "< 8.0.0"
17
+ "node": ">= 8.9.0"
19
18
  },
20
19
  "main": "./lib/cli.js",
21
20
  "bin": {
@@ -23,26 +22,25 @@
23
22
  },
24
23
  "scripts": {
25
24
  "scan": "node ./bin/ts-node-client.js",
26
- "scan-with-brakes": "node ./bin/ts-node-client.js --breakOnViolations true --breakOnWarnings true",
27
- "scan-to-file": "node ./bin/ts-node-client.js --saveAsFormat cydx --saveAs test",
28
- "scan-prod": "node ./bin/ts-node-client.js --debug true",
25
+ "scan-with-brakes": "node ./bin/ts-node-client.js --breakOnViolations true --breakOnWarnings false",
26
+ "scan-to-file": "node ./bin/ts-node-client.js --saveAs test --saveAsFormat cydx",
29
27
  "lint": "eslint bin lib test",
30
28
  "lint-fix": "eslint bin lib test --fix",
31
29
  "test": "mocha test",
32
30
  "precommit": "npm run lint && npm run test"
33
31
  },
34
32
  "dependencies": {
33
+ "npm": "6.14.17",
35
34
  "axios": "0.26.1",
36
35
  "debuglog": "1.0.1",
37
- "global-npm": "0.5.0",
38
36
  "semver": "7.3.5",
39
- "yargs": "^15.4.1"
37
+ "yargs": "^17.5.0"
40
38
  },
41
39
  "devDependencies": {
42
- "eslint": "^7.32.0",
43
- "eslint-config-airbnb-base": "^14.2.1",
44
- "eslint-plugin-import": "^2.25.2",
45
- "eslint-plugin-sonarjs": "^0.10.0",
40
+ "eslint": "^8.15.0",
41
+ "eslint-config-airbnb-base": "^15.0.0",
42
+ "eslint-plugin-import": "^2.26.0",
43
+ "eslint-plugin-sonarjs": "^0.13.0",
46
44
  "mocha": "^9.2.2",
47
45
  "nock": "^12.0.3"
48
46
  },
@@ -52,6 +50,8 @@
52
50
  "meteor",
53
51
  "plugin",
54
52
  "opensource",
53
+ "cydx",
54
+ "spdx",
55
55
  "dependency-analysis"
56
56
  ]
57
57
  }
@@ -36,18 +36,24 @@ describe('Dependency', () => {
36
36
  it('should set license as object', () => {
37
37
  assert.deepEqual(new Dependency('---', '---', '---', '', true, 'MIT').licenses[0], { name: 'MIT' });
38
38
  assert.deepEqual(new Dependency('---', '---', '---', '', true, { type: 'MIT' }).licenses[0], { name: 'MIT' });
39
- assert.deepEqual(new Dependency('---', '---', '---', '', true, { type: 'MIT', url: 'https://test' }).licenses[0],
40
- { name: 'MIT', url: 'https://test' });
39
+ assert.deepEqual(
40
+ new Dependency('---', '---', '---', '', true, { type: 'MIT', url: 'https://test' }).licenses[0],
41
+ { name: 'MIT', url: 'https://test' }
42
+ );
41
43
  });
42
44
 
43
45
  it('should set license as array', () => {
44
- assert.deepEqual(new Dependency('---', '---', '---', '', true, ['MIT', 'Apache']).licenses,
45
- [{ name: 'MIT' }, { name: 'Apache' }]);
46
+ assert.deepEqual(
47
+ new Dependency('---', '---', '---', '', true, ['MIT', 'Apache']).licenses,
48
+ [{ name: 'MIT' }, { name: 'Apache' }]
49
+ );
46
50
  });
47
51
 
48
52
  it('should set license as array of objects', () => {
49
- assert.deepEqual(new Dependency('---', '---', '---', '', true, [{ type: 'MIT', url: 'url' }, { type: 'Apache' }]).licenses,
50
- [{ name: 'MIT', url: 'url' }, { name: 'Apache' }]);
53
+ assert.deepEqual(
54
+ new Dependency('---', '---', '---', '', true, [{ type: 'MIT', url: 'url' }, { type: 'Apache' }]).licenses,
55
+ [{ name: 'MIT', url: 'url' }, { name: 'Apache' }]
56
+ );
51
57
  });
52
58
 
53
59
  it('should not accept empty or invalid name', () => {
@@ -142,12 +148,32 @@ describe('Dependency', () => {
142
148
  });
143
149
 
144
150
  it('should extract additional repo-protocol from url', () => {
145
- assert.deepEqual(new Dependency('name', 'version', '---', 'description', '---', '---', 'home',
146
- 'git+https://github.com/eacg-gmbh/ecs-grunt-plugin.git').repoUrl,
147
- 'https://github.com/eacg-gmbh/ecs-grunt-plugin.git');
148
- assert.deepEqual(new Dependency('name', 'version', '---', 'description', '---', '---', 'home',
149
- 'svn+http://svnrepo.com/test.svn').repoUrl,
150
- 'http://svnrepo.com/test.svn');
151
+ assert.deepEqual(
152
+ new Dependency(
153
+ 'name',
154
+ 'version',
155
+ '---',
156
+ 'description',
157
+ '---',
158
+ '---',
159
+ 'home',
160
+ 'git+https://github.com/eacg-gmbh/ecs-grunt-plugin.git'
161
+ ).repoUrl,
162
+ 'https://github.com/eacg-gmbh/ecs-grunt-plugin.git'
163
+ );
164
+ assert.deepEqual(
165
+ new Dependency(
166
+ 'name',
167
+ 'version',
168
+ '---',
169
+ 'description',
170
+ '---',
171
+ '---',
172
+ 'home',
173
+ 'svn+http://svnrepo.com/test.svn'
174
+ ).repoUrl,
175
+ 'http://svnrepo.com/test.svn'
176
+ );
151
177
  });
152
178
 
153
179