File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ public struct ApolloCLI {
1313 /// - timeout: The maximum time to wait before indicating that the download timed out, in seconds.
1414 public static func createCLI( cliFolderURL: URL , timeout: Double ) throws -> ApolloCLI {
1515 try CLIDownloader . downloadIfNeeded ( cliFolderURL: cliFolderURL, timeout: timeout)
16+
17+ if !( try CLIExtractor . validateSHASUMOfDownloadedFile ( in: cliFolderURL) ) {
18+ CodegenLogger . log ( " Downloaded zip file has incorrect SHASUM, forcing redownolad " )
19+ try CLIDownloader . forceRedownload ( cliFolderURL: cliFolderURL, timeout: timeout)
20+ }
21+
1622 let binaryFolderURL = try CLIExtractor . extractCLIIfNeeded ( from: cliFolderURL)
1723 return ApolloCLI ( binaryFolderURL: binaryFolderURL)
1824 }
Original file line number Diff line number Diff line change @@ -78,6 +78,22 @@ struct CLIExtractor {
7878 return true
7979 }
8080
81+ static func validateSHASUMOfDownloadedFile( in cliFolderURL: URL , expected: String = CLIExtractor . expectedSHASUM) throws -> Bool {
82+ let zipFileURL = ApolloFilePathHelper . zipFileURL ( fromCLIFolder: cliFolderURL)
83+
84+ do {
85+ try self . validateZipFileSHASUM ( at: zipFileURL)
86+ return true
87+ } catch {
88+ switch error {
89+ case CLIExtractorError . zipFileHasInvalidSHASUM:
90+ return false
91+ default :
92+ throw error
93+ }
94+ }
95+ }
96+
8197 /// Writes the SHASUM of the extracted version of the CLI to a file for faster checks to ensure we have the correct version.
8298 ///
8399 /// - Parameter apolloFolderURL: The URL to the extracted apollo folder.
@@ -119,7 +135,7 @@ struct CLIExtractor {
119135 /// - Parameter expected: The expected SHASUM. Defaults to the real expected SHASUM. This parameter exists mostly for testing.
120136 static func validateZipFileSHASUM( at zipFileURL: URL , expected: String = CLIExtractor . expectedSHASUM) throws {
121137 let shasum = try FileManager . default. apollo. shasum ( at: zipFileURL)
122- print ( " SHASUM: \( shasum) " )
138+ print ( " SHASUM of downloaded file : \( shasum) " )
123139 guard shasum == expected else {
124140 throw CLIExtractorError . zipFileHasInvalidSHASUM ( expectedSHASUM: expected, gotSHASUM: shasum)
125141 }
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ SCRIPT_DIR="$(dirname "$0")"
1111
1212# Get the SHASUM of the tarball
1313ZIP_FILE=" ${SCRIPT_DIR} /apollo.tar.gz"
14- ZIP_FILE_DOWNLOAD_URL=" https://install.apollographql.com/legacy-cli/darwin/2.28.0 "
14+ ZIP_FILE_DOWNLOAD_URL=" https://install.apollographql.com/legacy-cli/darwin/2.28.3 "
1515SHASUM_FILE=" ${SCRIPT_DIR} /apollo/.shasum"
1616APOLLO_DIR=" ${SCRIPT_DIR} " /apollo
1717IS_RETRY=" false"
@@ -58,7 +58,7 @@ extract_cli() {
5858
5959validate_codegen_and_extract_if_needed () {
6060 # Make sure the SHASUM matches the release for this version
61- EXPECTED_SHASUM=" 060d893aea4ebc2effa74b20433f5d0f586b31fec0d0f73c210ee152c032185e "
61+ EXPECTED_SHASUM=" cb2f4b9f53eb8443661e7658e407a3837da3d781649f8bc66a1c6cf7d32acef1 "
6262 update_shasum
6363
6464 if [[ ${SHASUM} = ${EXPECTED_SHASUM} * ]]; then
You can’t perform that action at this time.
0 commit comments