Skip to content

Commit d545af0

Browse files
authored
Merge branch 'main' into other/benalvo/sync-wrapper
2 parents 2a6b6b7 + 01c8e9f commit d545af0

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@CheckmarxDev/ast-cli-javascript-wrapper-runtime-cli",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "AST CLI Javascript wrapper runtime CLI",
55
"main": "dist/main/wrapper/CxWrapper.js",
66
"typings": "dist/main/wrapper/CxWrapper.d.ts",

src/main/client/AstClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {logger} from '../wrapper/loggerConfig';
22
import * as fs from 'fs';
33
import {finished} from 'stream/promises';
44
import {Client} from "./Client";
5+
import {CxError} from "../errors/CxError";
56

67
export class AstClient {
78
private client: Client;
@@ -20,10 +21,9 @@ export class AstClient {
2021
logger.info(`Download completed successfully. File saved to: ${outputPath}`);
2122
} catch (error) {
2223
logger.error(`Error downloading file from ${url}: ${error.message || error}`);
23-
throw error;
24+
throw new CxError(error.message || error);
2425
} finally {
2526
writer.close();
26-
logger.info('Write stream closed.');
2727
}
2828
}
2929
}

src/main/client/HttpClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Client} from "./Client";
44

55
export class HttpClient implements Client {
66
private readonly axiosConfig: AxiosRequestConfig;
7+
private readonly domainErrMsg = 'Unable to download the CLI from the URL. Try adding the domain: \'download.checkmarx.com\' to your allow list.';
78

89
constructor() {
910
this.axiosConfig = {
@@ -45,6 +46,9 @@ export class HttpClient implements Client {
4546
return response;
4647
} catch (error) {
4748
logger.error(`Error sending ${method} request to ${url}: ${error.message || error}`);
49+
if (this.axiosConfig.proxy!==undefined) {
50+
throw new Error(`${this.domainErrMsg} \nError: ${error.message || error}`);
51+
}
4852
throw error;
4953
}
5054
}

src/main/errors/CxError.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class CxError extends Error {
2+
constructor(message: string) {
3+
super(message);
4+
this.name = "CxError";
5+
}
6+
}

src/main/osinstaller/CxInstaller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as tar from 'tar';
55
import * as unzipper from 'unzipper';
66
import {logger} from "../wrapper/loggerConfig";
77
import {AstClient} from "../client/AstClient";
8+
import {CxError} from "../errors/CxError";
89

910
const linuxOS = 'linux';
1011
const macOS = 'darwin';
@@ -41,7 +42,7 @@ export class CxInstaller {
4142
const platformData = CxInstaller.PLATFORMS[this.platform];
4243

4344
if (!platformData) {
44-
throw new Error('Unsupported platform or architecture');
45+
throw new CxError('Unsupported platform or architecture');
4546
}
4647

4748
const architecture = this.getArchitecture();
@@ -103,6 +104,9 @@ export class CxInstaller {
103104
logger.info('Extracted CLI to:', this.resourceDirPath);
104105
} catch (error) {
105106
logger.error('Error during installation:', error);
107+
if (error instanceof CxError) {
108+
process.exit(1);
109+
}
106110
}
107111
}
108112

0 commit comments

Comments
 (0)