firebase-tools 12.0.1 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEndpointFiltered = exports.isCodebaseFiltered = exports.groupEndpointsByCodebase = exports.targetCodebases = exports.getFunctionLabel = exports.getEndpointFilters = exports.parseFunctionSelector = exports.endpointMatchesFilter = exports.endpointMatchesAnyFilter = void 0;
3
+ exports.isEndpointFiltered = exports.isCodebaseFiltered = exports.groupEndpointsByCodebase = exports.targetCodebases = exports.getFunctionLabel = exports.getHumanFriendlyPlatformName = exports.getEndpointFilters = exports.parseFunctionSelector = exports.endpointMatchesFilter = exports.endpointMatchesAnyFilter = void 0;
4
4
  const backend = require("./backend");
5
5
  const projectConfig_1 = require("../../functions/projectConfig");
6
6
  function endpointMatchesAnyFilter(endpoint, filters) {
@@ -67,6 +67,13 @@ function getEndpointFilters(options) {
67
67
  return filters;
68
68
  }
69
69
  exports.getEndpointFilters = getEndpointFilters;
70
+ function getHumanFriendlyPlatformName(platform) {
71
+ if (platform === "gcfv1") {
72
+ return "1st Gen";
73
+ }
74
+ return "2nd Gen";
75
+ }
76
+ exports.getHumanFriendlyPlatformName = getHumanFriendlyPlatformName;
70
77
  function getFunctionLabel(fn) {
71
78
  let id = `${fn.id}(${fn.region})`;
72
79
  if (fn.codebase && fn.codebase !== projectConfig_1.DEFAULT_CODEBASE) {
@@ -25,6 +25,7 @@ const utils = require("../../../utils");
25
25
  const services = require("../services");
26
26
  const v1_1 = require("../../../functions/events/v1");
27
27
  const checkIam_1 = require("../checkIam");
28
+ const functionsDeployHelper_1 = require("../functionsDeployHelper");
28
29
  const gcfV1PollerOptions = {
29
30
  apiOrigin: api_1.functionsOrigin,
30
31
  apiVersion: gcf.API_VERSION,
@@ -536,8 +537,9 @@ class Fabricator {
536
537
  }
537
538
  logOpStart(op, endpoint) {
538
539
  const runtime = (0, runtimes_1.getHumanFriendlyRuntimeName)(endpoint.runtime);
540
+ const platform = (0, functionsDeployHelper_1.getHumanFriendlyPlatformName)(endpoint.platform);
539
541
  const label = helper.getFunctionLabel(endpoint);
540
- utils.logLabeledBullet("functions", `${op} ${runtime} function ${clc.bold(label)}...`);
542
+ utils.logLabeledBullet("functions", `${op} ${runtime} (${platform}) function ${clc.bold(label)}...`);
541
543
  }
542
544
  logOpSuccess(op, endpoint) {
543
545
  utils.logSuccess(this.getLogSuccessMessage(op, endpoint));
@@ -11,6 +11,7 @@ const RUNTIMES = [
11
11
  "nodejs14",
12
12
  "nodejs16",
13
13
  "nodejs18",
14
+ "nodejs20",
14
15
  "python310",
15
16
  "python311",
16
17
  ];
@@ -32,6 +33,7 @@ const MESSAGE_FRIENDLY_RUNTIMES = {
32
33
  nodejs14: "Node.js 14",
33
34
  nodejs16: "Node.js 16",
34
35
  nodejs18: "Node.js 18",
36
+ nodejs20: "Node.js 20",
35
37
  python310: "Python 3.10",
36
38
  python311: "Python 3.11",
37
39
  };
@@ -15,6 +15,7 @@ const ENGINE_RUNTIMES = {
15
15
  14: "nodejs14",
16
16
  16: "nodejs16",
17
17
  18: "nodejs18",
18
+ 20: "nodejs20",
18
19
  };
19
20
  const ENGINE_RUNTIMES_NAMES = Object.values(ENGINE_RUNTIMES);
20
21
  exports.RUNTIME_NOT_SET = "`runtime` field is required but was not found in firebase.json.\n" +
@@ -107,7 +107,7 @@ class Delegate {
107
107
  var _a, _b;
108
108
  const modulesDir = await this.modulesDir();
109
109
  const envWithAdminPort = Object.assign(Object.assign({}, envs), { ADMIN_PORT: port.toString() });
110
- const args = [this.bin, path.join(modulesDir, "private", "serving.py")];
110
+ const args = [this.bin, `"${path.join(modulesDir, "private", "serving.py")}"`];
111
111
  const stdout = [];
112
112
  const stderr = [];
113
113
  logger_1.logger.debug(`Running admin server with args: ${JSON.stringify(args)} and env: ${JSON.stringify(envWithAdminPort)} in ${this.sourceDir}`);
@@ -18,9 +18,9 @@ const EMULATOR_INSTANCE_KILL_TIMEOUT = 4000;
18
18
  const CACHE_DIR = process.env.FIREBASE_EMULATORS_PATH || path.join(os.homedir(), ".cache", "firebase", "emulators");
19
19
  const EMULATOR_UPDATE_DETAILS = {
20
20
  database: {
21
- version: "4.11.0",
22
- expectedSize: 34318940,
23
- expectedChecksum: "311609538bd65666eb724ef47c2e6466",
21
+ version: "4.11.2",
22
+ expectedSize: 34495935,
23
+ expectedChecksum: "2fd771101c0e1f7898c04c9204f2ce63",
24
24
  },
25
25
  firestore: {
26
26
  version: "1.17.4",
@@ -332,7 +332,12 @@ class FunctionsEmulator {
332
332
  this.logger.logLabeled("ERROR", "functions", `Failed to load function definition from source: ${e}`);
333
333
  return;
334
334
  }
335
- this.workerPools[emulatableBackend.codebase].refresh();
335
+ if (this.debugMode) {
336
+ this.workerPools[emulatableBackend.codebase].exit();
337
+ }
338
+ else {
339
+ this.workerPools[emulatableBackend.codebase].refresh();
340
+ }
336
341
  this.blockingFunctionsConfig = {};
337
342
  const toSetup = triggerDefinitions.filter((definition) => {
338
343
  if (force) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ɵcodegenFunctionsDirectory = exports.ɵcodegenPublicDirectory = exports.getDevModeHandle = exports.build = exports.init = exports.discover = exports.docsUrl = exports.type = exports.support = exports.name = void 0;
3
+ exports.ɵcodegenFunctionsDirectory = exports.shouldUseDevModeHandle = exports.getValidBuildTargets = exports.ɵcodegenPublicDirectory = exports.getDevModeHandle = exports.build = exports.init = exports.discover = exports.docsUrl = exports.type = exports.support = exports.name = void 0;
4
4
  const path_1 = require("path");
5
5
  const child_process_1 = require("child_process");
6
6
  const cross_spawn_1 = require("cross-spawn");
@@ -10,6 +10,7 @@ const prompt_1 = require("../../prompt");
10
10
  const utils_1 = require("../utils");
11
11
  const utils_2 = require("./utils");
12
12
  const constants_1 = require("../constants");
13
+ const error_1 = require("../../error");
13
14
  exports.name = "Angular";
14
15
  exports.support = "preview";
15
16
  exports.type = 3;
@@ -42,26 +43,36 @@ async function init(setup, config) {
42
43
  }
43
44
  }
44
45
  exports.init = init;
45
- async function build(dir) {
46
- const { targets, serverTarget, serveOptimizedImages, locales } = await (0, utils_2.getBuildConfig)(dir);
46
+ async function build(dir, configuration) {
47
+ const { targets, serverTarget, serveOptimizedImages, locales, baseHref } = await (0, utils_2.getBuildConfig)(dir, configuration);
47
48
  await (0, utils_1.warnIfCustomBuildScript)(dir, exports.name, DEFAULT_BUILD_SCRIPT);
48
49
  for (const target of targets) {
49
50
  const cli = (0, utils_1.getNodeModuleBin)("ng", dir);
50
- (0, cross_spawn_1.sync)(cli, ["run", target], {
51
+ const result = (0, cross_spawn_1.sync)(cli, ["run", target], {
51
52
  cwd: dir,
52
53
  stdio: "inherit",
53
54
  });
55
+ if (result.status !== 0)
56
+ throw new error_1.FirebaseError(`Unable to build ${target}`);
54
57
  }
55
58
  const wantsBackend = !!serverTarget || serveOptimizedImages;
59
+ const rewrites = serverTarget
60
+ ? []
61
+ : [
62
+ {
63
+ source: path_1.posix.join(baseHref, "**"),
64
+ destination: path_1.posix.join(baseHref, "index.html"),
65
+ },
66
+ ];
56
67
  const i18n = !!locales;
57
- return { wantsBackend, i18n };
68
+ return { wantsBackend, i18n, rewrites };
58
69
  }
59
70
  exports.build = build;
60
- async function getDevModeHandle(dir) {
71
+ async function getDevModeHandle(dir, configuration) {
61
72
  const { targetStringFromTarget } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/architect");
62
- const { serveTarget } = await (0, utils_2.getContext)(dir);
73
+ const { serveTarget } = await (0, utils_2.getContext)(dir, configuration);
63
74
  if (!serveTarget)
64
- return;
75
+ throw new Error("Could not find the serveTarget");
65
76
  const host = new Promise((resolve) => {
66
77
  const cli = (0, utils_1.getNodeModuleBin)("ng", dir);
67
78
  const serve = (0, cross_spawn_1.spawn)(cli, ["run", targetStringFromTarget(serveTarget), "--host", "localhost"], {
@@ -80,8 +91,8 @@ async function getDevModeHandle(dir) {
80
91
  return (0, utils_1.simpleProxy)(await host);
81
92
  }
82
93
  exports.getDevModeHandle = getDevModeHandle;
83
- async function ɵcodegenPublicDirectory(sourceDir, destDir) {
84
- const { outputPath, baseHref, defaultLocale, locales } = await (0, utils_2.getBrowserConfig)(sourceDir);
94
+ async function ɵcodegenPublicDirectory(sourceDir, destDir, configuration) {
95
+ const { outputPath, baseHref, defaultLocale, locales } = await (0, utils_2.getBrowserConfig)(sourceDir, configuration);
85
96
  await (0, promises_1.mkdir)((0, path_1.join)(destDir, baseHref), { recursive: true });
86
97
  if (locales) {
87
98
  await Promise.all([
@@ -99,11 +110,33 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir) {
99
110
  }
100
111
  }
101
112
  exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
102
- async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
113
+ async function getValidBuildTargets(purpose, dir) {
114
+ const validTargetNames = new Set(["development", "production"]);
115
+ try {
116
+ const { workspaceProject, browserTarget, serverTarget, serveTarget } = await (0, utils_2.getContext)(dir);
117
+ const { target } = ((purpose === "serve" && serveTarget) || serverTarget || browserTarget);
118
+ const workspaceTarget = workspaceProject.targets.get(target);
119
+ Object.keys(workspaceTarget.configurations || {}).forEach((it) => validTargetNames.add(it));
120
+ }
121
+ catch (e) {
122
+ }
123
+ const allTargets = await (0, utils_2.getAllTargets)(purpose, dir);
124
+ return [...validTargetNames, ...allTargets];
125
+ }
126
+ exports.getValidBuildTargets = getValidBuildTargets;
127
+ async function shouldUseDevModeHandle(targetOrConfiguration, dir) {
128
+ const { serveTarget } = await (0, utils_2.getContext)(dir, targetOrConfiguration);
129
+ if (!serveTarget)
130
+ return false;
131
+ return serveTarget.configuration !== "production";
132
+ }
133
+ exports.shouldUseDevModeHandle = shouldUseDevModeHandle;
134
+ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, configuration) {
103
135
  var _a;
104
136
  var _b;
105
- const { packageJson, serverOutputPath, browserOutputPath, defaultLocale, serverLocales, browserLocales, bundleDependencies, externalDependencies, baseHref: baseUrl, serveOptimizedImages, } = await (0, utils_2.getServerConfig)(sourceDir);
137
+ const { packageJson, serverOutputPath, browserOutputPath, defaultLocale, serverLocales, browserLocales, bundleDependencies, externalDependencies, baseHref: baseUrl, serveOptimizedImages, } = await (0, utils_2.getServerConfig)(sourceDir, configuration);
106
138
  const dotEnv = { __NG_BROWSER_OUTPUT_PATH__: browserOutputPath };
139
+ let rewriteSource = undefined;
107
140
  await Promise.all([
108
141
  serverOutputPath
109
142
  ? (0, promises_1.mkdir)((0, path_1.join)(destDir, serverOutputPath), { recursive: true }).then(() => (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, serverOutputPath), (0, path_1.join)(destDir, serverOutputPath)))
@@ -154,7 +187,8 @@ exports.handle = function(req,res) {
154
187
  }
155
188
  else {
156
189
  bootstrapScript = `exports.handle = (res, req) => req.sendStatus(404);\n`;
190
+ rewriteSource = path_1.posix.join(baseUrl, "__image__");
157
191
  }
158
- return { bootstrapScript, packageJson, baseUrl, dotEnv };
192
+ return { bootstrapScript, packageJson, baseUrl, dotEnv, rewriteSource };
159
193
  }
160
194
  exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = void 0;
3
+ exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = exports.getContext = exports.getAllTargets = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const error_1 = require("../../error");
6
6
  const path_1 = require("path");
@@ -49,7 +49,46 @@ async function localesForTarget(dir, architectHost, target, workspaceProject) {
49
49
  (0, utils_1.validateLocales)(locales);
50
50
  return { locales, defaultLocale };
51
51
  }
52
- async function getContext(dir) {
52
+ const DEV_SERVER_TARGETS = [
53
+ "@angular-devkit/build-angular:dev-server",
54
+ "@nguniversal/builders:ssr-dev-server",
55
+ ];
56
+ function getValidBuilders(purpose) {
57
+ return [
58
+ "@angular/fire:deploy",
59
+ "@angular-devkit/build-angular:browser",
60
+ "@nguniversal/builders:prerender",
61
+ ...(purpose === "deploy" ? [] : DEV_SERVER_TARGETS),
62
+ ];
63
+ }
64
+ async function getAllTargets(purpose, dir) {
65
+ const validBuilders = getValidBuilders(purpose);
66
+ const { NodeJsAsyncHost } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/core/node");
67
+ const { workspaces } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/core");
68
+ const { targetStringFromTarget } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/architect");
69
+ const host = workspaces.createWorkspaceHost(new NodeJsAsyncHost());
70
+ const { workspace } = await workspaces.readWorkspace(dir, host);
71
+ const targets = [];
72
+ workspace.projects.forEach((projectDefinition, project) => {
73
+ if (projectDefinition.extensions.projectType !== "application")
74
+ return;
75
+ projectDefinition.targets.forEach((targetDefinition, target) => {
76
+ if (!validBuilders.includes(targetDefinition.builder))
77
+ return;
78
+ const configurations = Object.keys(targetDefinition.configurations || {});
79
+ if (!configurations.includes("production"))
80
+ configurations.push("production");
81
+ if (!configurations.includes("development"))
82
+ configurations.push("development");
83
+ configurations.forEach((configuration) => {
84
+ targets.push(targetStringFromTarget({ project, target, configuration }));
85
+ });
86
+ });
87
+ });
88
+ return targets;
89
+ }
90
+ exports.getAllTargets = getAllTargets;
91
+ async function getContext(dir, targetOrConfiguration) {
53
92
  const { NodeJsAsyncHost } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/core/node");
54
93
  const { workspaces } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/core");
55
94
  const { WorkspaceNodeModulesArchitectHost } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/architect/node");
@@ -59,12 +98,26 @@ async function getContext(dir) {
59
98
  const { workspace } = await workspaces.readWorkspace(dir, host);
60
99
  const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, dir);
61
100
  const architect = new Architect(architectHost);
62
- let project = globalThis.NG_DEPLOY_PROJECT;
101
+ let overrideTarget;
102
+ let project;
63
103
  let browserTarget;
64
104
  let serverTarget;
65
105
  let prerenderTarget;
66
106
  let serveTarget;
67
107
  let serveOptimizedImages = false;
108
+ let deployTargetName;
109
+ let configuration = undefined;
110
+ if (targetOrConfiguration) {
111
+ try {
112
+ overrideTarget = targetFromTargetString(targetOrConfiguration);
113
+ configuration = overrideTarget.configuration;
114
+ project = overrideTarget.project;
115
+ }
116
+ catch (e) {
117
+ deployTargetName = "deploy";
118
+ configuration = targetOrConfiguration;
119
+ }
120
+ }
68
121
  if (!project) {
69
122
  const angularJson = parse(await host.readFile((0, path_1.join)(dir, "angular.json")));
70
123
  project = angularJson.defaultProject;
@@ -79,11 +132,25 @@ async function getContext(dir) {
79
132
  project = apps[0];
80
133
  }
81
134
  if (!project)
82
- throw new error_1.FirebaseError("Unable to determine the application to deploy, you should use `ng deploy` via @angular/fire.");
135
+ throw new error_1.FirebaseError("Unable to determine the application to deploy, specify a target via the FIREBASE_FRAMEWORKS_BUILD_TARGET environment variable");
83
136
  const workspaceProject = workspace.projects.get(project);
84
137
  if (!workspaceProject)
85
138
  throw new error_1.FirebaseError(`No project ${project} found.`);
86
- const deployTargetDefinition = workspaceProject.targets.get("deploy");
139
+ if (overrideTarget) {
140
+ const target = workspaceProject.targets.get(overrideTarget.target);
141
+ const builder = target.builder;
142
+ if (builder === "@angular/fire:deploy")
143
+ deployTargetName = overrideTarget.target;
144
+ if (builder === "@angular-devkit/build-angular:browser")
145
+ browserTarget = overrideTarget;
146
+ if (builder === "@nguniversal/builders:prerender")
147
+ prerenderTarget = overrideTarget;
148
+ if (typeof builder === "string" && DEV_SERVER_TARGETS.includes(builder))
149
+ serveTarget = overrideTarget;
150
+ }
151
+ const deployTargetDefinition = deployTargetName
152
+ ? workspaceProject.targets.get(deployTargetName)
153
+ : undefined;
87
154
  if ((deployTargetDefinition === null || deployTargetDefinition === void 0 ? void 0 : deployTargetDefinition.builder) === "@angular/fire:deploy") {
88
155
  const options = deployTargetDefinition.options;
89
156
  if (typeof (options === null || options === void 0 ? void 0 : options.prerenderTarget) === "string")
@@ -107,76 +174,57 @@ async function getContext(dir) {
107
174
  console.warn("Treating the application as fully rendered. Add a serverTarget to your deploy target in angular.json to utilize server-side rendering.");
108
175
  }
109
176
  }
110
- else if (workspaceProject.targets.has("prerender")) {
111
- const target = workspaceProject.targets.get("prerender");
112
- const configurations = Object.keys(target.configurations);
113
- const configuration = configurations.includes("production")
114
- ? "production"
115
- : target.defaultConfiguration;
116
- if (!configuration)
117
- throw new Error("No production or default configutation found for prerender.");
118
- if (configuration !== "production")
119
- console.warn(`Using ${configuration} configuration for the prerender, we suggest adding a production target.`);
120
- prerenderTarget = { project, target: "prerender", configuration };
121
- const production = await architectHost.getOptionsForTarget(prerenderTarget);
122
- if (typeof (production === null || production === void 0 ? void 0 : production.browserTarget) !== "string")
177
+ if (!overrideTarget && !prerenderTarget && workspaceProject.targets.has("prerender")) {
178
+ const { defaultConfiguration = "production" } = workspaceProject.targets.get("prerender");
179
+ prerenderTarget = { project, target: "prerender", configuration: defaultConfiguration };
180
+ }
181
+ if (serveTarget) {
182
+ const options = await architectHost.getOptionsForTarget(serveTarget);
183
+ if (typeof (options === null || options === void 0 ? void 0 : options.browserTarget) !== "string")
184
+ throw new Error(`${serveTarget.target} browserTarget expected to be string, check your angular.json.`);
185
+ browserTarget = targetFromTargetString(options.browserTarget);
186
+ if (options === null || options === void 0 ? void 0 : options.serverTarget) {
187
+ if (typeof options.serverTarget !== "string")
188
+ throw new Error(`${serveTarget.target} serverTarget expected to be string, check your angular.json.`);
189
+ serverTarget = targetFromTargetString(options.serverTarget);
190
+ }
191
+ }
192
+ else if (prerenderTarget) {
193
+ const options = await architectHost.getOptionsForTarget(prerenderTarget);
194
+ if (typeof (options === null || options === void 0 ? void 0 : options.browserTarget) !== "string")
123
195
  throw new Error("Prerender browserTarget expected to be string, check your angular.json.");
124
- browserTarget = targetFromTargetString(production.browserTarget);
125
- if (typeof (production === null || production === void 0 ? void 0 : production.serverTarget) !== "string")
196
+ browserTarget = targetFromTargetString(options.browserTarget);
197
+ if (typeof (options === null || options === void 0 ? void 0 : options.serverTarget) !== "string")
126
198
  throw new Error("Prerender serverTarget expected to be string, check your angular.json.");
127
- serverTarget = targetFromTargetString(production.serverTarget);
199
+ serverTarget = targetFromTargetString(options.serverTarget);
200
+ }
201
+ if (!browserTarget && workspaceProject.targets.has("build")) {
202
+ const { defaultConfiguration = "production" } = workspaceProject.targets.get("build");
203
+ browserTarget = { project, target: "build", configuration: defaultConfiguration };
204
+ }
205
+ if (!serverTarget && workspaceProject.targets.has("server")) {
206
+ const { defaultConfiguration = "production" } = workspaceProject.targets.get("server");
207
+ serverTarget = { project, target: "server", configuration: defaultConfiguration };
128
208
  }
129
- else {
130
- if (workspaceProject.targets.has("build")) {
131
- const target = workspaceProject.targets.get("build");
132
- const configurations = Object.keys(target.configurations);
133
- const configuration = configurations.includes("production")
134
- ? "production"
135
- : target.defaultConfiguration;
136
- if (!configuration)
137
- throw new Error("No production or default configutation found for build.");
138
- if (configuration !== "production")
139
- console.warn(`Using ${configuration} configuration for the browser deploy, we suggest adding a production target.`);
140
- browserTarget = { project, target: "build", configuration };
209
+ if (!serveTarget) {
210
+ if (serverTarget && workspaceProject.targets.has("serve-ssr")) {
211
+ const { defaultConfiguration = "development" } = workspaceProject.targets.get("serve-ssr");
212
+ serveTarget = { project, target: "serve-ssr", configuration: defaultConfiguration };
141
213
  }
142
- if (workspaceProject.targets.has("server")) {
143
- const target = workspaceProject.targets.get("server");
144
- const configurations = Object.keys(target.configurations);
145
- const configuration = configurations.includes("production")
146
- ? "production"
147
- : target.defaultConfiguration;
148
- if (!configuration)
149
- throw new Error("No production or default configutation found for server.");
150
- if (configuration !== "production")
151
- console.warn(`Using ${configuration} configuration for the server deploy, we suggest adding a production target.`);
152
- serverTarget = { project, target: "server", configuration };
214
+ else if (workspaceProject.targets.has("serve")) {
215
+ const { defaultConfiguration = "development" } = workspaceProject.targets.get("serve");
216
+ serveTarget = { project, target: "serve", configuration: defaultConfiguration };
153
217
  }
154
218
  }
155
- if (serverTarget && workspaceProject.targets.has("serve-ssr")) {
156
- const target = workspaceProject.targets.get("serve-ssr");
157
- const configurations = Object.keys(target.configurations);
158
- const configuration = configurations.includes("development")
159
- ? "development"
160
- : target.defaultConfiguration;
161
- if (!configuration)
162
- throw new Error("No development or default configutation found for serve-ssr.");
163
- if (configuration !== "development")
164
- console.warn(`Using ${configuration} configuration for the local server, we suggest adding a development target.`);
165
- serveTarget = { project, target: "serve-ssr", configuration };
166
- }
167
- else if (workspaceProject.targets.has("serve")) {
219
+ if (configuration) {
220
+ if (prerenderTarget)
221
+ prerenderTarget.configuration = configuration;
168
222
  if (serverTarget)
169
- console.warn(`No server-ssr target found.`);
170
- const target = workspaceProject.targets.get("serve");
171
- const configurations = Object.keys(target.configurations);
172
- const configuration = configurations.includes("development")
173
- ? "development"
174
- : target.defaultConfiguration;
175
- if (!configuration)
176
- throw new Error("No development or default configutation found for serve.");
177
- if (configuration !== "development")
178
- console.warn(`Using ${configuration} configuration for the local server, we suggest adding a development target.`);
179
- serveTarget = { project, target: "serve", configuration };
223
+ serverTarget.configuration = configuration;
224
+ if (browserTarget)
225
+ browserTarget.configuration = configuration;
226
+ if (serveTarget)
227
+ serveTarget.configuration = configuration;
180
228
  }
181
229
  if (!browserTarget)
182
230
  throw new error_1.FirebaseError(`No browser target on ${project}`);
@@ -184,7 +232,7 @@ async function getContext(dir) {
184
232
  if (!browserTargetOptions) {
185
233
  throw new error_1.FirebaseError(`Couldn't find options for ${targetStringFromTarget(browserTarget)}.`);
186
234
  }
187
- const baseHref = browserTargetOptions.baseHref || "";
235
+ const baseHref = browserTargetOptions.baseHref || "/";
188
236
  if (typeof baseHref !== "string") {
189
237
  throw new error_1.FirebaseError(`baseHref on ${targetStringFromTarget(browserTarget)} was not a string`);
190
238
  }
@@ -202,8 +250,8 @@ async function getContext(dir) {
202
250
  };
203
251
  }
204
252
  exports.getContext = getContext;
205
- async function getBrowserConfig(sourceDir) {
206
- const { architectHost, browserTarget, baseHref, workspaceProject } = await getContext(sourceDir);
253
+ async function getBrowserConfig(sourceDir, configuration) {
254
+ const { architectHost, browserTarget, baseHref, workspaceProject } = await getContext(sourceDir, configuration);
207
255
  const { locales, defaultLocale } = await localesForTarget(sourceDir, architectHost, browserTarget, workspaceProject);
208
256
  const browserTargetOptions = await architectHost.getOptionsForTarget(browserTarget);
209
257
  if (typeof (browserTargetOptions === null || browserTargetOptions === void 0 ? void 0 : browserTargetOptions.outputPath) !== "string")
@@ -212,9 +260,9 @@ async function getBrowserConfig(sourceDir) {
212
260
  return { locales, baseHref, outputPath, defaultLocale };
213
261
  }
214
262
  exports.getBrowserConfig = getBrowserConfig;
215
- async function getServerConfig(sourceDir) {
263
+ async function getServerConfig(sourceDir, configuration) {
216
264
  var _a;
217
- const { architectHost, host, serverTarget, browserTarget, baseHref, workspaceProject, serveOptimizedImages, } = await getContext(sourceDir);
265
+ const { architectHost, host, serverTarget, browserTarget, baseHref, workspaceProject, serveOptimizedImages, } = await getContext(sourceDir, configuration);
218
266
  const browserTargetOptions = await architectHost.getOptionsForTarget(browserTarget);
219
267
  if (typeof (browserTargetOptions === null || browserTargetOptions === void 0 ? void 0 : browserTargetOptions.outputPath) !== "string")
220
268
  throw new Error("browserTarget output path is not a string");
@@ -259,13 +307,14 @@ async function getServerConfig(sourceDir) {
259
307
  };
260
308
  }
261
309
  exports.getServerConfig = getServerConfig;
262
- async function getBuildConfig(sourceDir) {
310
+ async function getBuildConfig(sourceDir, configuration) {
263
311
  const { targetStringFromTarget } = (0, utils_1.relativeRequire)(sourceDir, "@angular-devkit/architect");
264
- const { browserTarget, prerenderTarget, serverTarget, architectHost, workspaceProject, serveOptimizedImages, } = await getContext(sourceDir);
312
+ const { browserTarget, baseHref, prerenderTarget, serverTarget, architectHost, workspaceProject, serveOptimizedImages, } = await getContext(sourceDir, configuration);
265
313
  const targets = (prerenderTarget ? [prerenderTarget] : [browserTarget, serverTarget].filter((it) => !!it)).map((it) => targetStringFromTarget(it));
266
314
  const locales = await localesForTarget(sourceDir, architectHost, browserTarget, workspaceProject);
267
315
  return {
268
316
  targets,
317
+ baseHref,
269
318
  serverTarget,
270
319
  locales,
271
320
  serveOptimizedImages,
@@ -35,7 +35,7 @@ async function build(cwd) {
35
35
  throw new error_1.FirebaseError("Deploying an Astro application with SSR on Firebase Hosting requires the @astrojs/node adapter.");
36
36
  }
37
37
  const build = (0, cross_spawn_1.sync)(cli, ["build"], { cwd, stdio: "inherit" });
38
- if (build.status)
38
+ if (build.status !== 0)
39
39
  throw new error_1.FirebaseError("Unable to build your Astro app");
40
40
  return { wantsBackend: output === "server" };
41
41
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebFrameworks = exports.I18N_ROOT = exports.ALLOWED_SSR_REGIONS = exports.DEFAULT_REGION = exports.VALID_LOCALE_FORMATS = exports.VALID_ENGINES = exports.NODE_VERSION = exports.SHARP_VERSION = exports.FIREBASE_ADMIN_VERSION = exports.FIREBASE_FUNCTIONS_VERSION = exports.FIREBASE_FRAMEWORKS_VERSION = exports.MAILING_LIST_URL = exports.FEATURE_REQUEST_URL = exports.FILE_BUG_URL = exports.DEFAULT_DOCS_URL = exports.SupportLevelWarnings = exports.NPM_COMMAND_TIMEOUT_MILLIES = void 0;
3
+ exports.DEFAULT_SHOULD_USE_DEV_MODE_HANDLE = exports.GET_DEFAULT_BUILD_TARGETS = exports.WebFrameworks = exports.I18N_ROOT = exports.ALLOWED_SSR_REGIONS = exports.DEFAULT_REGION = exports.VALID_LOCALE_FORMATS = exports.VALID_ENGINES = exports.NODE_VERSION = exports.SHARP_VERSION = exports.FIREBASE_ADMIN_VERSION = exports.FIREBASE_FUNCTIONS_VERSION = exports.FIREBASE_FRAMEWORKS_VERSION = exports.MAILING_LIST_URL = exports.FEATURE_REQUEST_URL = exports.FILE_BUG_URL = exports.DEFAULT_DOCS_URL = exports.SupportLevelWarnings = exports.NPM_COMMAND_TIMEOUT_MILLIES = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const clc = require("colorette");
@@ -21,7 +21,7 @@ exports.FIREBASE_FUNCTIONS_VERSION = "^4.3.0";
21
21
  exports.FIREBASE_ADMIN_VERSION = "^11.0.1";
22
22
  exports.SHARP_VERSION = "^0.32.1";
23
23
  exports.NODE_VERSION = parseInt(process.versions.node, 10);
24
- exports.VALID_ENGINES = { node: [16, 18] };
24
+ exports.VALID_ENGINES = { node: [16, 18, 20] };
25
25
  exports.VALID_LOCALE_FORMATS = [/^ALL_[a-z]+$/, /^[a-z]+_ALL$/, /^[a-z]+(_[a-z]+)?$/];
26
26
  exports.DEFAULT_REGION = "us-central1";
27
27
  exports.ALLOWED_SSR_REGIONS = [
@@ -43,3 +43,11 @@ exports.WebFrameworks = Object.fromEntries((0, fs_1.readdirSync)(__dirname)
43
43
  }
44
44
  })
45
45
  .filter(([, obj]) => obj && obj.name && obj.discover && obj.build && obj.type !== undefined && obj.support));
46
+ function GET_DEFAULT_BUILD_TARGETS() {
47
+ return Promise.resolve(["production", "development"]);
48
+ }
49
+ exports.GET_DEFAULT_BUILD_TARGETS = GET_DEFAULT_BUILD_TARGETS;
50
+ function DEFAULT_SHOULD_USE_DEV_MODE_HANDLE(target) {
51
+ return Promise.resolve(target === "development");
52
+ }
53
+ exports.DEFAULT_SHOULD_USE_DEV_MODE_HANDLE = DEFAULT_SHOULD_USE_DEV_MODE_HANDLE;
@@ -21,10 +21,10 @@ async function getConfig(root) {
21
21
  async function discover(dir) {
22
22
  if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
23
23
  return;
24
- const { serveDir } = await getConfig(dir);
25
- if (!serveDir)
24
+ const { serveDir: publicDirectory } = await getConfig(dir);
25
+ if (!publicDirectory)
26
26
  return;
27
- return { mayWantBackend: true };
27
+ return { mayWantBackend: true, publicDirectory };
28
28
  }
29
29
  exports.discover = discover;
30
30
  async function build(cwd) {
@@ -88,7 +88,7 @@ async function getBootstrapScript(root, _bootstrapScript = "", _entry) {
88
88
  async function ɵcodegenFunctionsDirectory(root, dest) {
89
89
  const bootstrapScript = await getBootstrapScript(root);
90
90
  if (!bootstrapScript)
91
- return;
91
+ throw new Error("Cloud not find bootstrapScript");
92
92
  await (0, promises_1.mkdir)(dest, { recursive: true });
93
93
  const { packageJson } = await getConfig(root);
94
94
  const packResults = (0, child_process_1.execSync)(`npm pack ${root} --json`, { cwd: dest });
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FALLBACK_PROJECT_NAME = exports.DART_RESERVED_WORDS = void 0;
4
+ exports.DART_RESERVED_WORDS = [
5
+ "abstract",
6
+ "else",
7
+ "import",
8
+ "show",
9
+ "as",
10
+ "enum",
11
+ "in",
12
+ "static",
13
+ "assert",
14
+ "export",
15
+ "interface",
16
+ "super",
17
+ "async",
18
+ "extends",
19
+ "is",
20
+ "switch",
21
+ "await",
22
+ "extension",
23
+ "late",
24
+ "sync",
25
+ "base",
26
+ "external",
27
+ "library",
28
+ "this",
29
+ "break",
30
+ "factory",
31
+ "mixin",
32
+ "throw",
33
+ "case",
34
+ "false",
35
+ "new",
36
+ "true",
37
+ "catch",
38
+ "final",
39
+ "null",
40
+ "try",
41
+ "class",
42
+ "on",
43
+ "typedef",
44
+ "const",
45
+ "finally",
46
+ "operator",
47
+ "var",
48
+ "continue",
49
+ "for",
50
+ "part",
51
+ "void",
52
+ "covariant",
53
+ "function",
54
+ "required",
55
+ "when",
56
+ "default",
57
+ "get",
58
+ "rethrow",
59
+ "while",
60
+ "deferred",
61
+ "hide",
62
+ "return",
63
+ "with",
64
+ "do",
65
+ "if",
66
+ "sealed",
67
+ "yield",
68
+ "dynamic",
69
+ "implements",
70
+ "set",
71
+ ];
72
+ exports.FALLBACK_PROJECT_NAME = "hello_firebase";