MCPcopy Create free account
hub / github.com/firebase/firebase-tools / uploadCodebase

Function uploadCodebase

src/deploy/functions/deploy.ts:138–171  ·  view source on GitHub ↗
(
  context: args.Context,
  projectNumber: string,
  codebase: string,
  wantBackend: backend.Backend,
)

Source from the content-addressed store, hash-verified

136}
137
138async 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.

Callers 1

deployFunction · 0.85

Calls 6

configForCodebaseFunction · 0.90
logLabeledSuccessFunction · 0.90
logWarningFunction · 0.90
uploadSourceV1Function · 0.85
uploadSourceV2Function · 0.85
allMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…