@@ -12,19 +12,16 @@ type SupportedPlatforms = 'win32' | 'darwin' | 'linux';
12
12
13
13
export class CxInstaller {
14
14
private readonly platform : string ;
15
- private cliVersion : string ;
15
+ private cliVersion = '2.2.6' ;
16
16
private readonly resourceDirPath : string ;
17
- private readonly cliDefaultVersion = '2.2.6' ; // This will be used if the version file is not found. Should be updated with the latest version.
18
17
private static installSemaphore = new Semaphore ( 1 ) ; // Semaphore with 1 slot
19
18
20
19
constructor ( platform : string ) {
21
20
this . platform = platform ;
22
21
this . resourceDirPath = path . join ( __dirname , `../wrapper/resources` ) ;
23
22
}
24
23
25
- async getDownloadURL ( ) : Promise < string > {
26
- const cliVersion = await this . readASTCLIVersion ( ) ;
27
-
24
+ getDownloadURL ( ) : string {
28
25
const platforms : Record < SupportedPlatforms , { platform : string ; extension : string } > = {
29
26
win32 : { platform : 'windows' , extension : 'zip' } ,
30
27
darwin : { platform : 'darwin' , extension : 'tar.gz' } ,
@@ -38,7 +35,7 @@ export class CxInstaller {
38
35
throw new Error ( 'Unsupported platform or architecture' ) ;
39
36
}
40
37
41
- return `https://download.checkmarx.com/CxOne/CLI/${ cliVersion } /ast-cli_${ cliVersion } _${ platformData . platform } _x64.${ platformData . extension } ` ;
38
+ return `https://download.checkmarx.com/CxOne/CLI/${ this . cliVersion } /ast-cli_${ this . cliVersion } _${ platformData . platform } _x64.${ platformData . extension } ` ;
42
39
}
43
40
44
41
getExecutablePath ( ) : string {
@@ -56,7 +53,7 @@ export class CxInstaller {
56
53
logger . info ( 'Executable already installed.' ) ;
57
54
return ;
58
55
}
59
- const url = await this . getDownloadURL ( ) ;
56
+ const url = this . getDownloadURL ( ) ;
60
57
const zipPath = path . join ( this . resourceDirPath , this . getCompressFolderName ( ) ) ;
61
58
62
59
await this . downloadFile ( url , zipPath ) ;
@@ -105,20 +102,6 @@ export class CxInstaller {
105
102
checkExecutableExists ( ) : boolean {
106
103
return fs . existsSync ( this . getExecutablePath ( ) ) ;
107
104
}
108
-
109
- async readASTCLIVersion ( ) : Promise < string > {
110
- if ( this . cliVersion ) {
111
- return this . cliVersion ;
112
- }
113
- try {
114
- const versionFilePath = path . join ( process . cwd ( ) , 'checkmarx-ast-cli.version' ) ;
115
- const versionContent = await fsPromises . readFile ( versionFilePath , 'utf-8' ) ;
116
- return versionContent . trim ( ) ;
117
- } catch ( error ) {
118
- logger . error ( 'Error reading AST CLI version: ' + error . message ) ;
119
- return this . cliDefaultVersion ;
120
- }
121
- }
122
105
123
106
getCompressFolderName ( ) : string {
124
107
return `ast-cli.${ this . platform === 'win32' ? 'zip' : 'tar.gz' } ` ;
0 commit comments