@zohodesk/testinglibrary 0.1.8-eslint-12 → 0.1.8-eslint-13

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.
@@ -14,8 +14,10 @@ var _path = _interopRequireDefault(require("path"));
14
14
  var _logger = require("../utils/logger");
15
15
  var _cliArgsToObject = require("../utils/cliArgsToObject");
16
16
  var _fileUtils = require("../utils/fileUtils");
17
+ var _requestJarAPI = require("./requestJarAPI");
17
18
  async function runEslintForDiff(cliParams, options = {}) {
18
19
  // $(git diff --name-only HEAD HEAD~1 | grep -E '\.(js|jsx)$' | xargs)
20
+ await (0, _requestJarAPI.requestJAR)(cliParams);
19
21
  const {
20
22
  diffPath = null
21
23
  } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.requestJAR = requestJAR;
8
+ var _https = _interopRequireDefault(require("https"));
9
+ var _cliArgsToObject = require("../utils/cliArgsToObject");
10
+ var _logger = require("../utils/logger");
11
+ var _fs = _interopRequireDefault(require("fs"));
12
+ var _path = _interopRequireDefault(require("path"));
13
+ var _child_process = require("child_process");
14
+ var _rootPath = require("../utils/rootPath");
15
+ async function requestJAR(cliParams, options = {}) {
16
+ const {
17
+ pat,
18
+ requestUrl
19
+ } = (0, _cliArgsToObject.cliArgsToObject)(cliParams);
20
+ const endpoint = requestUrl || 'https://zgit.csez.zohocorpin.com/zohodesk/zohodesk/-/raw/master/sonardependencies/lib/sonar-scanner-cli-4.8.0.2856.jar?inline=false';
21
+ const body = {
22
+ method: 'GET',
23
+ headers: {
24
+ 'Content-Type': 'application/java-archive',
25
+ 'PRIVATE-TOKEN': `${pat}`
26
+ }
27
+ };
28
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Cloning jar ${(0, _rootPath.getSonarJarPath)()}`);
29
+ if (!pat) {
30
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `PAT token is Needed ..`);
31
+ process.exit(0);
32
+ }
33
+ return await new Promise(resolve => {
34
+ const jarAPI = _https.default.request(endpoint, body, response => {
35
+ var responseChunk = '';
36
+ const fileStream = _fs.default.createWriteStream((0, _rootPath.getSonarJarPath)());
37
+ response.on('data', data => {
38
+ responseChunk += data;
39
+ });
40
+ response.pipe(fileStream);
41
+ fileStream.on('finish', finish => {
42
+ fileStream.close();
43
+ });
44
+ response.on('error', error => {
45
+ _logger.Logger.log(_logger.Logger.FAILURE_TYPE, `Error - ${error}`);
46
+ });
47
+ response.on('end', end => {
48
+ // at end
49
+ resolve({
50
+ path: (0, _rootPath.getSonarJarPath)()
51
+ });
52
+ });
53
+ });
54
+ jarAPI.end();
55
+ });
56
+ }
@@ -48,9 +48,5 @@ function getExecutableBinaryPath(command) {
48
48
  }
49
49
  function getSonarJarPath() {
50
50
  const jarPath = _path.default.resolve('node_modules', '@zohodesk', 'testinglibrary', 'build', 'lint-ci', 'java-jar', 'sonar-scanner-cli-4.8.0.2856.jar');
51
- if ((0, _fileUtils.checkIfFileExists)(jarPath)) {
52
- return jarPath;
53
- }
54
- _logger.Logger.log(_logger.Logger.FAILURE_TYPE, 'cannot find - Java-Jar');
55
- process.exit(0);
51
+ return jarPath;
56
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-eslint-12",
3
+ "version": "0.1.8-eslint-13",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {