@@ -4,19 +4,35 @@ import { Command } from "../command";
44import { Options } from "../options" ;
55import { needProjectId } from "../projectUtils" ;
66import { logWarning } from "../utils" ;
7+ import { FirebaseError } from "../error" ;
78
89export const command = new Command ( "apphosting:builds:get <backendId> <buildId>" )
910 . description ( "get a build for an App Hosting backend" )
10- . option ( "-l, --location <location>" , "specify the region of the backend" )
1111 . before ( apphosting . ensureApiEnabled )
1212 . action ( async ( backendId : string , buildId : string , options : Options ) => {
13- if ( options . location !== undefined ) {
14- logWarning ( "--location is being removed in the next major release." ) ;
15- }
16- options . location = options . location ?? "us-central" ;
1713 const projectId = needProjectId ( options ) ;
18- const location = options . location as string ;
19- const build = await apphosting . getBuild ( projectId , location , backendId , buildId ) ;
20- logger . info ( JSON . stringify ( build , null , 2 ) ) ;
21- return build ;
14+ const builds = await apphosting . listBuilds ( projectId , /* location: */ "-" , /* backendId */ "-" ) ;
15+ const matchingBuilds = builds . builds . filter ( ( b ) => {
16+ const parsedBuild = apphosting . parseBuildName ( b . name ) ;
17+ if ( parsedBuild . backendId === backendId && parsedBuild . buildId === buildId ) {
18+ return true ;
19+ }
20+ } ) ;
21+ if ( matchingBuilds . length > 0 ) {
22+ if ( matchingBuilds . length > 1 ) {
23+ logWarning (
24+ `Detected multiple backends with same backendId (${ backendId } ) and buildId (${ buildId } ) within the same global location. ` +
25+ "Please delete and recreate any backends that share an ID with another. Use `apphosting:backends:list` to see all backends." ,
26+ ) ;
27+ }
28+ logger . info ( JSON . stringify ( matchingBuilds [ 0 ] , null , 2 ) ) ;
29+ return matchingBuilds [ 0 ] ;
30+ }
31+ if ( builds . unreachable && builds . unreachable . length !== 0 ) {
32+ logWarning (
33+ `Backends with the following primary regions are unreachable: ${ builds . unreachable } .\n` +
34+ "If your backend is in one of these regions, please try again later." ,
35+ ) ;
36+ }
37+ throw new FirebaseError ( `No build ${ buildId } found for any backend ${ backendId } .` ) ;
2238 } ) ;
0 commit comments