@@ -4,19 +4,32 @@ import { Command } from "../command";
4
4
import { Options } from "../options" ;
5
5
import { needProjectId } from "../projectUtils" ;
6
6
import { logWarning } from "../utils" ;
7
+ import { FirebaseError } from "../error" ;
7
8
8
9
export const command = new Command ( "apphosting:builds:get <backendId> <buildId>" )
9
10
. description ( "get a build for an App Hosting backend" )
10
- . option ( "-l, --location <location>" , "specify the region of the backend" )
11
11
. before ( apphosting . ensureApiEnabled )
12
12
. 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" ;
17
13
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
+ let 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
+ logger . info ( JSON . stringify ( matchingBuilds [ 0 ] , null , 2 ) ) ;
28
+ return matchingBuilds [ 0 ] ;
29
+ }
30
+ if ( builds . unreachable && builds . unreachable . length !== 0 ) {
31
+ logWarning ( `Backends with the following primary regions are unreachable: ${ builds . unreachable } .\n` +
32
+ "If your backend is in one of these regions, please try again later." ) ;
33
+ }
34
+ throw new FirebaseError ( `No build ${ buildId } found for any backend ${ backendId } .` ) ;
22
35
} ) ;
0 commit comments