@@ -12,19 +12,16 @@ type SupportedPlatforms = 'win32' | 'darwin' | 'linux';
1212
1313export class CxInstaller {
1414 private readonly platform : string ;
15- private cliVersion : string ;
15+ private cliVersion = '2.2.6' ;
1616 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.
1817 private static installSemaphore = new Semaphore ( 1 ) ; // Semaphore with 1 slot
1918
2019 constructor ( platform : string ) {
2120 this . platform = platform ;
2221 this . resourceDirPath = path . join ( __dirname , `../wrapper/resources` ) ;
2322 }
2423
25- async getDownloadURL ( ) : Promise < string > {
26- const cliVersion = await this . readASTCLIVersion ( ) ;
27-
24+ getDownloadURL ( ) : string {
2825 const platforms : Record < SupportedPlatforms , { platform : string ; extension : string } > = {
2926 win32 : { platform : 'windows' , extension : 'zip' } ,
3027 darwin : { platform : 'darwin' , extension : 'tar.gz' } ,
@@ -38,7 +35,7 @@ export class CxInstaller {
3835 throw new Error ( 'Unsupported platform or architecture' ) ;
3936 }
4037
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 } ` ;
4239 }
4340
4441 getExecutablePath ( ) : string {
@@ -56,7 +53,7 @@ export class CxInstaller {
5653 logger . info ( 'Executable already installed.' ) ;
5754 return ;
5855 }
59- const url = await this . getDownloadURL ( ) ;
56+ const url = this . getDownloadURL ( ) ;
6057 const zipPath = path . join ( this . resourceDirPath , this . getCompressFolderName ( ) ) ;
6158
6259 await this . downloadFile ( url , zipPath ) ;
@@ -105,20 +102,6 @@ export class CxInstaller {
105102 checkExecutableExists ( ) : boolean {
106103 return fs . existsSync ( this . getExecutablePath ( ) ) ;
107104 }
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- }
122105
123106 getCompressFolderName ( ) : string {
124107 return `ast-cli.${ this . platform === 'win32' ? 'zip' : 'tar.gz' } ` ;
0 commit comments