MCPcopy
hub / github.com/angular/angularfire / deployToFunction

Function deployToFunction

src/schematics/deploy/actions.ts:157–273  ·  view source on GitHub ↗
(
  firebaseTools: FirebaseTools,
  context: BuilderContext,
  workspaceRoot: string,
  staticBuildTarget: BuildTarget,
  serverBuildTarget: BuildTarget,
  options: DeployBuilderOptions,
  firebaseToken?: string,
  fsHost: FSHost = defaultFsHost
)

Source from the content-addressed store, hash-verified

155};
156
157export const deployToFunction = async (
158 firebaseTools: FirebaseTools,
159 context: BuilderContext,
160 workspaceRoot: string,
161 staticBuildTarget: BuildTarget,
162 serverBuildTarget: BuildTarget,
163 options: DeployBuilderOptions,
164 firebaseToken?: string,
165 fsHost: FSHost = defaultFsHost
166) => {
167
168 const staticBuildOptions = await context.getTargetOptions(targetFromTargetString(staticBuildTarget.name));
169 if (!staticBuildOptions.outputPath || typeof staticBuildOptions.outputPath !== 'string') {
170 throw new Error(
171 `Cannot read the output path option of the Angular project '${staticBuildTarget.name}' in angular.json`
172 );
173 }
174
175 const serverBuildOptions = await context.getTargetOptions(targetFromTargetString(serverBuildTarget.name));
176 if (!serverBuildOptions.outputPath || typeof serverBuildOptions.outputPath !== 'string') {
177 throw new Error(
178 `Cannot read the output path option of the Angular project '${serverBuildTarget.name}' in angular.json`
179 );
180 }
181
182 const staticOut = join(workspaceRoot, staticBuildOptions.outputPath);
183 const serverOut = join(workspaceRoot, serverBuildOptions.outputPath);
184
185 const functionsOut = options.outputPath ? join(workspaceRoot, options.outputPath) : dirname(serverOut);
186 const functionName = options.functionName || DEFAULT_FUNCTION_NAME;
187
188 const newStaticOut = join(functionsOut, staticBuildOptions.outputPath);
189 const newServerOut = join(functionsOut, serverBuildOptions.outputPath);
190
191 // New behavior vs. old
192 if (options.outputPath) {
193 fsHost.removeSync(functionsOut);
194 fsHost.copySync(staticOut, newStaticOut);
195 fsHost.copySync(serverOut, newServerOut);
196 } else {
197 fsHost.moveSync(staticOut, newStaticOut);
198 fsHost.moveSync(serverOut, newServerOut);
199 }
200
201 const packageJson = getPackageJson(context, workspaceRoot, options);
202 const nodeVersion = packageJson.engines.node;
203
204 if (!satisfies(process.versions.node, nodeVersion.toString())) {
205 context.logger.warn(
206 `⚠️ Your Node.js version (${process.versions.node}) does not match the Firebase Functions runtime (${nodeVersion}).`
207 );
208 }
209
210 const functionsPackageJsonPath = join(functionsOut, 'package.json');
211 fsHost.writeFileSync(
212 functionsPackageJsonPath,
213 JSON.stringify(packageJson, null, 2)
214 );

Callers 2

actions.jasmine.tsFile · 0.90
deployFunction · 0.85

Calls 11

functionGen2Function · 0.90
defaultFunctionFunction · 0.90
getPackageJsonFunction · 0.85
removeSyncMethod · 0.80
copySyncMethod · 0.80
moveSyncMethod · 0.80
writeFileSyncMethod · 0.80
renameSyncMethod · 0.80
existsSyncMethod · 0.80
serveMethod · 0.80
deployMethod · 0.80

Tested by

no test coverage detected