( context: args.Context, projectNumber: string, codebase: string, wantBackend: backend.Backend, )
| 136 | } |
| 137 | |
| 138 | async function uploadCodebase( |
| 139 | context: args.Context, |
| 140 | projectNumber: string, |
| 141 | codebase: string, |
| 142 | wantBackend: backend.Backend, |
| 143 | ): Promise<void> { |
| 144 | const source = context.sources?.[codebase]; |
| 145 | if (!source || (!source.functionsSourceV1 && !source.functionsSourceV2)) { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | const uploads: Promise<unknown>[] = []; |
| 150 | try { |
| 151 | uploads.push(uploadSourceV1(context.projectId, source, wantBackend)); |
| 152 | uploads.push(uploadSourceV2(context.projectId, projectNumber, source, wantBackend)); |
| 153 | |
| 154 | const [sourceUrl, storage] = await Promise.all(uploads); |
| 155 | if (sourceUrl) { |
| 156 | source.sourceUrl = sourceUrl as string; |
| 157 | } |
| 158 | if (storage) { |
| 159 | source.storage = storage as gcfv2.StorageSource; |
| 160 | } |
| 161 | |
| 162 | const cfg = configForCodebase(context.config!, codebase); |
| 163 | const label = cfg.source ?? cfg.remoteSource?.dir ?? "remote"; |
| 164 | if (uploads.length) { |
| 165 | logLabeledSuccess("functions", `${clc.bold(label)} source uploaded successfully`); |
| 166 | } |
| 167 | } catch (err: any) { |
| 168 | logWarning(clc.yellow("functions:") + " Upload Error: " + err.message); |
| 169 | throw err; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * The "deploy" stage for Cloud Functions -- uploads source code to a generated URL. |
no test coverage detected
searching dependent graphs…