@@ -32,16 +32,6 @@ export class CxInstaller {
3232 linux : { platform : linuxOS , extension : 'tar.gz' }
3333 } ;
3434
35- // Default version and its paired SHA-256 checksums, keyed by "platform_architecture".
36- // Update both together when bumping the default CLI version.
37- private readonly cliDefaultVersion = '2.3.48' ;
38- private static readonly cliDefaultChecksums : Record < string , string > = {
39- 'windows_x64' : '441ee8df46cc630ae000f8ba73925113aeed8c4d16cf274944aff3e7197e3470' ,
40- 'darwin_x64' : 'b72f7e4ca14e5e56600b07d22c848a4b85e7c37d2e595424340cc699ea10006b' ,
41- 'linux_x64' : 'eb3eb55add37f150188f5a8b36b2a659f902ad9569dcb7ee652531fe525022e2' ,
42- 'linux_arm64' : '7df61689b3c2bbd4c27face5bdc0da97f63e4533229d6b53dd777f90d3904931' ,
43- 'linux_armv6' : '99659f2e0804b197550efc6a9ddb6029babc980d32bdfeeb508199247ac95878'
44- } ;
4535
4636 constructor ( platform : string , client : AstClient ) {
4737 this . platform = platform as SupportedPlatforms ;
@@ -50,8 +40,7 @@ export class CxInstaller {
5040 }
5141
5242 // Returns the CLI version and its platform-specific SHA-256 checksum.
53- // Tries the version file and checksums file first; falls back to the
54- // hardcoded defaults if the version file is absent or empty.
43+ // Reads from version and checksums files. Throws CxError if version is absent or version file is empty.
5544 // Result is cached after the first read.
5645 async readASTCLIVersion ( ) : Promise < { version : string ; checksum : string | null } > {
5746 if ( this . cliVersion ) {
@@ -68,24 +57,23 @@ export class CxInstaller {
6857 const trimmed = content . trim ( ) ;
6958 if ( trimmed ) version = trimmed ;
7059 } catch {
71- // version file absent — fall through to defaults
60+ // version file absent — will throw error below
7261 }
7362
74- let checksum : string | null ;
7563 if ( version === null ) {
76- version = this . cliDefaultVersion ;
77- checksum = CxInstaller . cliDefaultChecksums [ key ] ?? null ;
78- } else {
79- try {
80- const content = await fsPromises . readFile ( this . getChecksumsFilePath ( ) , 'utf-8' ) ;
81- checksum = ( JSON . parse ( content ) as Record < string , string > ) [ key ] ?? null ;
82- if ( checksum === null ) {
83- logger . warn ( `No checksum found for ${ key } in checksums file. Download will not be verified.` ) ;
84- }
85- } catch {
86- logger . warn ( `Checksums file not found. Download of version ${ version } will not be verified.` ) ;
87- checksum = null ;
64+ throw new CxError ( `CLI version not found` ) ;
65+ }
66+
67+ let checksum : string | null ;
68+ try {
69+ const content = await fsPromises . readFile ( this . getChecksumsFilePath ( ) , 'utf-8' ) ;
70+ checksum = ( JSON . parse ( content ) as Record < string , string > ) [ key ] ?? null ;
71+ if ( checksum === null ) {
72+ logger . warn ( `No checksum found for ${ key } in checksums file. Download will not be verified.` ) ;
8873 }
74+ } catch {
75+ logger . warn ( `Checksums file not found. Download of version ${ version } will not be verified.` ) ;
76+ checksum = null ;
8977 }
9078
9179 this . cliVersion = version ;
0 commit comments