ts-node-client 1.4.3 → 2.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/.eslintrc.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "extends": [
3
- "airbnb-base"
3
+ "airbnb-base",
4
+ "plugin:sonarjs/recommended"
4
5
  ],
5
6
  "plugins": [
7
+ "sonarjs"
6
8
  ],
7
9
  "env": {
8
10
  "node": true
@@ -20,7 +22,8 @@
20
22
  "newline-per-chained-call": [ "off" ],
21
23
  "comma-dangle": [ "error", "never" ],
22
24
  "linebreak-style": ["off"],
23
- "quotes": [ "error", "single" ]
25
+ "quotes": [ "error", "single" ],
26
+ "sonarjs/cognitive-complexity": ["error", 40]
24
27
  }
25
28
  }
26
29
 
@@ -0,0 +1,71 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '39 23 * * 1-5'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'javascript' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37
+ # Learn more:
38
+ # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39
+
40
+ steps:
41
+ - name: Checkout repository
42
+ uses: actions/checkout@v2
43
+
44
+ # Initializes the CodeQL tools for scanning.
45
+ - name: Initialize CodeQL
46
+ uses: github/codeql-action/init@v1
47
+ with:
48
+ languages: ${{ matrix.language }}
49
+ # If you wish to specify custom queries, you can do so here or in a config file.
50
+ # By default, queries listed here will override any specified in a config file.
51
+ # Prefix the list here with "+" to use these queries and those in the config file.
52
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
53
+
54
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55
+ # If this step fails, then you should remove it and run the build manually (see below)
56
+ - name: Autobuild
57
+ uses: github/codeql-action/autobuild@v1
58
+
59
+ # ℹ️ Command-line programs to run using the OS shell.
60
+ # 📚 https://git.io/JvXDl
61
+
62
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63
+ # and modify them (or add more) to build your code if your project
64
+ # uses a compiled language
65
+
66
+ #- run: |
67
+ # make bootstrap
68
+ # make release
69
+
70
+ - name: Perform CodeQL Analysis
71
+ uses: github/codeql-action/analyze@v1
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)
@@ -15,7 +14,7 @@ TrustSource node client
15
14
  ## Requirements
16
15
 
17
16
  * node >= 8.9.0
18
- * npm >= 6.0.0
17
+ * if you are using npm < 8.0.0 we recommend switch to ts-node-client version 1.5.2 until we provide more elegant solution
19
18
 
20
19
  ## Installation
21
20
  Run: `npm install --save-dev ts-node-client` or `yarn add --dev ts-node-client`
@@ -62,7 +61,7 @@ Options:
62
61
  --binaryLinks Binary links separated by comma [default: null]
63
62
  --url url [default: null]
64
63
  --config, -c Config path [default: null]
65
- --proxy Proxy url like 'http://user:password@host:port' [default: null]
64
+ --proxy Proxy url like 'https://user:password@host:port' [default: null]
66
65
  --version, -v Prints a version [default: false]
67
66
  --debug [default: null]
68
67
  --simulate [default: null]
@@ -75,6 +74,18 @@ Options:
75
74
 
76
75
  ## Changelog
77
76
 
77
+ #### 2.0.0
78
+ #### if you are using npm < 8.0.0 we recommend switch to ts-node-client version 1.5.2 until we provide more elegant solution
79
+ - Stop usage of [`global-npm`](https://github.com/dracupid/global-npm) until we find new resolution
80
+ - Get back `npm` as local dependency
81
+
82
+ #### 1.5.2
83
+ - Describe `Error: The programmatic API was removed in npm v8.0.0`
84
+
85
+ #### 1.5.1
86
+ - Bump devDependencies
87
+ - Introduce sonarjs
88
+
78
89
  #### 1.4.3
79
90
  - Bump glob-parent from 5.1.1 to 5.1.2
80
91
  - Bump path-parse from 1.0.6 to 1.0.7
@@ -141,11 +152,11 @@ Options:
141
152
  - options: **--credentials** and **--credentialsFile** instead you should use **--config**.
142
153
  - option **--baseUrl** instead you should use **--url**.
143
154
  - Added:
144
- - option **--config**. It is similar to credentials but it will contains any config information.
155
+ - option **--config**. It is similar to credentials, but it will contain any config information.
145
156
  - option **--url**. It is similar to baseUrl.
146
157
  - option **--apiKey** and **--userName** so it will be unnecessary to create `.tsrc.json` file.
147
158
  - options **--version** and **--help**.
148
- - options shortcuts.
159
+ - options shortcut.
149
160
 
150
161
  ## License
151
162
  [Apache-2.0](https://github.com/TrustSource/ts-node-client/blob/master/LICENSE)
package/SECURITY.md ADDED
@@ -0,0 +1,21 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Use this section to tell people about which versions of your project are
6
+ currently being supported with security updates.
7
+
8
+ | Version | Supported |
9
+ | ------- | ------------------ |
10
+ | 5.1.x | :white_check_mark: |
11
+ | 5.0.x | :x: |
12
+ | 4.0.x | :white_check_mark: |
13
+ | < 4.0 | :x: |
14
+
15
+ ## Reporting a Vulnerability
16
+
17
+ Use this section to tell people how to report a vulnerability.
18
+
19
+ Tell them where to go, how often they can expect to get an update on a
20
+ reported vulnerability, what to expect if the vulnerability is accepted or
21
+ declined, etc.
package/lib/cli.js CHANGED
@@ -35,8 +35,7 @@ function scan(options, scanDone) {
35
35
  return meteorScanner.scan(scanResult.module).then((meteorScanResult) => {
36
36
  // remove dependency introduced by local package.json (this will never be released)
37
37
  const npmDependencies = scanResult.dependencies.length === 1
38
- ? scanResult.dependencies[0].dependencies
39
- : scanResult.dependencies;
38
+ ? scanResult.dependencies[0].dependencies : scanResult.dependencies;
40
39
  Array.prototype.push.apply(meteorScanResult.dependencies, npmDependencies);
41
40
  return meteorScanResult;
42
41
  });
package/lib/dependency.js CHANGED
@@ -70,7 +70,8 @@ Dependency.getFirstByName = function getFirstByName(container, dependency) {
70
70
  }
71
71
  if (Array.isArray(container)) {
72
72
  return container.find((d) => d instanceof Dependency && d.name === dependency);
73
- } if (container instanceof Object && container[dependency] instanceof Dependency) {
73
+ }
74
+ if (container instanceof Object && container[dependency] instanceof Dependency) {
74
75
  return container[dependency];
75
76
  }
76
77
  return undefined;
@@ -9,7 +9,7 @@
9
9
  const fs = require('fs');
10
10
  const path = require('path');
11
11
  const debuglog = (require('debuglog'))('ts-meteor-scanner');
12
- const ScanResult = require('./scanresult.js');
12
+ const ScanResult = require('./scanresult');
13
13
  const { RestClient } = require('./rest-client');
14
14
  const Dependency = require('./dependency');
15
15
 
@@ -43,15 +43,15 @@ Scanner.prototype.transfer = function transfer(scan, cb) {
43
43
  };
44
44
 
45
45
  Scanner.prototype.gatherDependencies = function gatherDependencies(lines) {
46
- const dependencies = lines.map((l) => {
46
+ // remove falsy values
47
+ return lines.map((l) => {
47
48
  const parts = l.split('@');
48
49
  if (parts.length === 2) {
49
50
  printDependency(parts);
50
51
  return new Dependency(parts[0], parts[1], 'atm');
51
52
  }
52
53
  return null;
53
- }).filter(Boolean); // remove falsy values
54
- return dependencies;
54
+ }).filter(Boolean);
55
55
  };
56
56
 
57
57
 
@@ -6,9 +6,9 @@
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
- const ScanResult = require('./scanresult.js');
11
+ const ScanResult = require('./scanresult');
12
12
  const { RestClient } = require('./rest-client');
13
13
  const Dependency = require('./dependency');
14
14
 
@@ -121,7 +121,7 @@ RestClient.prototype.transfer = function transfer(scan, cb) {
121
121
  getReqOpts.method = 'GET';
122
122
  getReqOpts.uri += `/${body.scanId}`;
123
123
  delete getReqOpts.body;
124
- let i = 1;
124
+ let i = 1; // eslint-disable-line prefer-const
125
125
  checkAnalysisResults(options, getReqOpts, cb, error, response, body, i);
126
126
  } else {
127
127
  cb(null, body);
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.4.3",
4
+ "version": "2.0.0",
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": ">= 6.0.0"
17
+ "node": ">= 8.9.0"
19
18
  },
20
19
  "main": "./lib/cli.js",
21
20
  "bin": {
@@ -32,19 +31,19 @@
32
31
  },
33
32
  "dependencies": {
34
33
  "debuglog": "^1.0.1",
35
- "global-npm": "^0.4.1",
34
+ "npm": "6.14.15",
36
35
  "request": "^2.88.2",
37
36
  "semver": "^7.3.4",
38
37
  "yargs": "^15.4.1"
39
38
  },
40
39
  "devDependencies": {
41
- "eslint": "^6.8.0",
42
- "eslint-config-airbnb-base": "^14.1.0",
43
- "eslint-plugin-import": "^2.20.1",
44
- "husky": "^4.2.3",
45
- "mocha": "^6.2.3",
40
+ "eslint": "^7.32.0",
41
+ "eslint-config-airbnb-base": "^14.2.1",
42
+ "eslint-plugin-import": "^2.25.2",
43
+ "eslint-plugin-sonarjs": "^0.10.0",
44
+ "mocha": "^9.1.3",
46
45
  "nock": "^12.0.3",
47
- "ts-node-client": "^1.3.0"
46
+ "ts-node-client": "1.5.2"
48
47
  },
49
48
  "keywords": [
50
49
  "node",
@@ -9,11 +9,13 @@
9
9
 
10
10
 
11
11
  const assert = require('assert');
12
- const util = require('util');
12
+ const util = require('util');
13
+
14
+ const SHOULD_CONTAIN = 'should contain \'name\' and \'message\' fields';
13
15
 
14
16
  describe('Error object', () => {
15
17
  describe('Base object', () => {
16
- it('should contain \'name\' and \'message\' fields', () => {
18
+ it(SHOULD_CONTAIN, () => {
17
19
  try {
18
20
  throw new Error('test');
19
21
  } catch (err) {
@@ -24,7 +26,7 @@ describe('Error object', () => {
24
26
  });
25
27
 
26
28
  describe('TypeError object', () => {
27
- it('should contain \'name\' and \'message\' fields', () => {
29
+ it(SHOULD_CONTAIN, () => {
28
30
  try {
29
31
  throw new TypeError('test');
30
32
  } catch (err) {
@@ -44,7 +46,7 @@ describe('Error object', () => {
44
46
  MyError.prototype.constructor = MyError;
45
47
 
46
48
 
47
- it('should contain \'name\' and \'message\' fields', () => {
49
+ it(SHOULD_CONTAIN, () => {
48
50
  try {
49
51
  throw new MyError('test');
50
52
  } catch (err) {
@@ -64,7 +66,7 @@ describe('Error object', () => {
64
66
  }
65
67
  util.inherits(MyError, Error); // inherit at least better toString() method
66
68
 
67
- it('should contain \'name\' and \'message\' fields', () => {
69
+ it(SHOULD_CONTAIN, () => {
68
70
  try {
69
71
  throw new MyError('test');
70
72
  } catch (err) {
package/test/rest-test.js CHANGED
@@ -9,8 +9,9 @@
9
9
 
10
10
  const assert = require('assert');
11
11
  const nock = require('nock');
12
- const { RestClient } = require('../lib/rest-client');
12
+ const { RestClient } = require('../lib/rest-client');
13
13
 
14
+ const JSON_TYPE = 'application/json';
14
15
  const url = 'http://localhost:3000';
15
16
 
16
17
  /* eslint-disable no-new */
@@ -44,7 +45,7 @@ describe('RestClient', () => {
44
45
  it('should call callback with response data if no error orccurs', (done) => {
45
46
  nock(url, {
46
47
  reqheaders: {
47
- 'Content-Type': 'application/json'
48
+ 'Content-Type': JSON_TYPE
48
49
  }
49
50
  }).post('/api/v1/scans').reply(201, 'Test response');
50
51
 
@@ -58,10 +59,10 @@ describe('RestClient', () => {
58
59
  it('response should be parsed as json object, if \'content-type\': \'application/json\'', (done) => {
59
60
  nock(url, {
60
61
  reqheaders: {
61
- 'Content-Type': 'application/json'
62
+ 'Content-Type': JSON_TYPE
62
63
  }
63
64
  }).defaultReplyHeaders({
64
- 'Content-Type': 'application/json'
65
+ 'Content-Type': JSON_TYPE
65
66
  }).post('/api/v1/scans').reply(201, '{"bli": "blub"}');
66
67
 
67
68
  restClient.transfer({}, (err, data) => {