File tree Expand file tree Collapse file tree 2 files changed +30
-8
lines changed
genkit-tools/cli/src/commands Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change 239239DOWNLOAD_URL=" https://storage.googleapis.com/genkit-assets-cli/$channel /$MACHINE /latest"
240240echo " -- Downloading binary from $DOWNLOAD_URL "
241241
242- # We use "curl" to download the binary with a flag set to follow redirects
243- # (GitHub download URLs redirect to CDNs) and a flag to show a progress bar.
244- curl -o " /tmp/genkit_standalone.tmp" --fail -L --progress-bar $DOWNLOAD_URL
245- if [ $? -ne 0 ]; then
246- echo " Something went wrong. Failed to download binary from $DOWNLOAD_URL "
247- echo " Please file a bug with your system information on GitHub."
248- echo " https://github.com/firebase/genkit/"
242+ # Download the binary, but capture HTTP status code to detect 404s (package not found)
243+ HTTP_STATUS=$( curl -w " %{http_code}" -o " /tmp/genkit_standalone.tmp" --fail -L --progress-bar " $DOWNLOAD_URL " 2> /dev/null)
244+ CURL_EXIT_CODE=$?
245+
246+ if [ $CURL_EXIT_CODE -ne 0 ] || [ " $HTTP_STATUS " = " 404" ]; then
247+ # Check if the user requested a specific version (by checking if DOWNLOAD_URL contains /v[0-9])
248+ if [[ " $DOWNLOAD_URL " =~ /v[0-9]+\. [0-9]+\. [0-9]+/ ]] || [[ " $HTTP_STATUS " = " 404" ]]; then
249+ echo " Package not found. The requested version does not exist for your platform."
250+ else
251+ echo " Something went wrong. Failed to download binary from $DOWNLOAD_URL "
252+ echo " Please file a bug with your system information on GitHub."
253+ echo " https://github.com/firebase/genkit/"
254+ fi
249255
250256 send_analytics_event download_failure
251257
Original file line number Diff line number Diff line change @@ -250,6 +250,15 @@ async function downloadAndInstall(version: string): Promise<void> {
250250
251251 // If not running from a binary, we should install using package manager
252252 if ( ! runtime . isCompiledBinary ) {
253+ // Check if the requested version is available on npm
254+ const availableVersions = await getAvailableVersionsFromNpm ( ) ;
255+ if ( ! availableVersions . includes ( version . replace ( / ^ v / , '' ) ) ) {
256+ logger . error (
257+ `Version ${ clc . bold ( version ) } is not available on npm.`
258+ ) ;
259+ process . exit ( 1 ) ;
260+ }
261+
253262 const pm = await inquirePackageManager ( ) ;
254263 let command = '' ;
255264
@@ -260,7 +269,7 @@ async function downloadAndInstall(version: string): Promise<void> {
260269 }
261270
262271 logger . info ( `Running using ${ pm ?. type } , downloading using ${ pm ?. type } ...` ) ;
263- execSync ( command ) ;
272+ execSync ( command , { stdio : 'inherit' } ) ;
264273 logger . info (
265274 `${ clc . green ( '✓' ) } Successfully updated to ${ clc . bold ( version ) } `
266275 ) ;
@@ -441,6 +450,13 @@ export const update = new Command('update')
441450
442451 logger . info ( `${ clc . yellow ( '!' ) } Reinstalling v${ clc . bold ( version ) } ...` ) ;
443452 } else if ( version ) {
453+ if ( version === currentVersion ) {
454+ logger . info (
455+ `${ clc . green ( '✓' ) } Already using version v${ clc . bold ( version ) } .`
456+ ) ;
457+ return ;
458+ }
459+
444460 logger . info ( `Installing v${ clc . bold ( version ) } ...` ) ;
445461 } else {
446462 logger . info ( 'Checking for updates...' ) ;
You can’t perform that action at this time.
0 commit comments