( projectId: string, config: Config, serviceId?: string, location?: string, )
| 41 | |
| 42 | /** Picks SQL Connect services based on flags. */ |
| 43 | export async function pickServices( |
| 44 | projectId: string, |
| 45 | config: Config, |
| 46 | serviceId?: string, |
| 47 | location?: string, |
| 48 | ): Promise<ServiceInfo[]> { |
| 49 | const serviceInfos = await loadAll(projectId, config); |
| 50 | if (serviceInfos.length === 0) { |
| 51 | throw new FirebaseError( |
| 52 | "No SQL Connect services found in firebase.json. " + |
| 53 | `\nYou can run ${clc.bold("firebase init dataconnect")} to add a SQL Connect service.`, |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | const matchingServices = serviceInfos.filter( |
| 58 | (i) => |
| 59 | (!serviceId || i.dataConnectYaml.serviceId === serviceId) && |
| 60 | (!location || i.dataConnectYaml.location === location), |
| 61 | ); |
| 62 | if (matchingServices.length === 0) { |
| 63 | const serviceIds = serviceInfos.map( |
| 64 | (i) => `${i.dataConnectYaml.location}:${i.dataConnectYaml.serviceId}`, |
| 65 | ); |
| 66 | throw new FirebaseError( |
| 67 | `No service matched service in firebase.json. Available services: ${serviceIds.join(", ")}`, |
| 68 | ); |
| 69 | } |
| 70 | return matchingServices; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Loads all SQL Connect service configurations from the firebase.json file. |
no test coverage detected
searching dependent graphs…