firebase-tools 12.9.1 → 13.0.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.
- package/lib/apiv2.js +7 -0
- package/lib/auth.js +8 -4
- package/lib/commands/frameworks-backends-delete.js +66 -6
- package/lib/commands/frameworks-backends-get.js +57 -18
- package/lib/commands/frameworks-backends-list.js +42 -15
- package/lib/commands/index.js +0 -1
- package/lib/commands/login-use.js +25 -6
- package/lib/config.js +10 -8
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +2 -2
- package/lib/deploy/lifecycleHooks.js +5 -0
- package/lib/fetchMOTD.js +1 -1
- package/lib/firestore/api.js +6 -6
- package/lib/frameworks/angular/index.js +22 -24
- package/lib/frameworks/angular/utils.js +217 -97
- package/lib/frameworks/constants.js +6 -3
- package/lib/frameworks/next/index.js +4 -0
- package/lib/frameworks/next/utils.js +6 -2
- package/lib/functionsShellCommandAction.js +3 -3
- package/lib/gcp/cloudbuild.js +24 -3
- package/lib/gcp/storage.js +11 -5
- package/lib/hosting/runTags.js +2 -1
- package/lib/init/features/frameworks/index.js +24 -22
- package/lib/init/features/frameworks/repo.js +108 -36
- package/lib/localFunction.js +77 -14
- package/lib/utils.js +28 -1
- package/package.json +2 -3
- package/templates/popup.html +64 -0
- package/lib/commands/ext-dev-publish.js +0 -32
|
@@ -4,12 +4,16 @@ exports.getBuildConfig = exports.getServerConfig = exports.getBrowserConfig = ex
|
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
const error_1 = require("../../error");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
+
const assert_1 = require("assert");
|
|
8
|
+
const utils_2 = require("../../utils");
|
|
7
9
|
async function localesForTarget(dir, architectHost, target, workspaceProject) {
|
|
8
10
|
var _a;
|
|
9
11
|
const { targetStringFromTarget } = (0, utils_1.relativeRequire)(dir, "@angular-devkit/architect");
|
|
10
12
|
const targetOptions = await architectHost.getOptionsForTarget(target);
|
|
11
|
-
if (!targetOptions)
|
|
12
|
-
|
|
13
|
+
if (!targetOptions) {
|
|
14
|
+
const targetString = targetStringFromTarget(target);
|
|
15
|
+
throw new error_1.FirebaseError(`Couldn't find options for ${targetString}.`);
|
|
16
|
+
}
|
|
13
17
|
let locales = undefined;
|
|
14
18
|
let defaultLocale = undefined;
|
|
15
19
|
if (targetOptions.localize) {
|
|
@@ -52,11 +56,15 @@ async function localesForTarget(dir, architectHost, target, workspaceProject) {
|
|
|
52
56
|
const DEV_SERVER_TARGETS = [
|
|
53
57
|
"@angular-devkit/build-angular:dev-server",
|
|
54
58
|
"@nguniversal/builders:ssr-dev-server",
|
|
59
|
+
"@angular-devkit/build-angular:ssr-dev-server",
|
|
55
60
|
];
|
|
56
61
|
function getValidBuilders(purpose) {
|
|
57
62
|
return [
|
|
63
|
+
"@angular-devkit/build-angular:application",
|
|
64
|
+
"@angular-devkit/build-angular:browser-esbuild",
|
|
58
65
|
"@angular/fire:deploy",
|
|
59
66
|
"@angular-devkit/build-angular:browser",
|
|
67
|
+
"@angular-devkit/build-angular:prerender",
|
|
60
68
|
"@nguniversal/builders:prerender",
|
|
61
69
|
...(purpose === "deploy" ? [] : DEV_SERVER_TARGETS),
|
|
62
70
|
];
|
|
@@ -99,13 +107,14 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
99
107
|
const architectHost = new WorkspaceNodeModulesArchitectHost(workspace, dir);
|
|
100
108
|
const architect = new Architect(architectHost);
|
|
101
109
|
let overrideTarget;
|
|
110
|
+
let deployTarget;
|
|
102
111
|
let project;
|
|
112
|
+
let buildTarget;
|
|
103
113
|
let browserTarget;
|
|
104
114
|
let serverTarget;
|
|
105
115
|
let prerenderTarget;
|
|
106
116
|
let serveTarget;
|
|
107
117
|
let serveOptimizedImages = false;
|
|
108
|
-
let deployTargetName;
|
|
109
118
|
let configuration = undefined;
|
|
110
119
|
if (targetOrConfiguration) {
|
|
111
120
|
try {
|
|
@@ -114,7 +123,6 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
114
123
|
project = overrideTarget.project;
|
|
115
124
|
}
|
|
116
125
|
catch (e) {
|
|
117
|
-
deployTargetName = "deploy";
|
|
118
126
|
configuration = targetOrConfiguration;
|
|
119
127
|
}
|
|
120
128
|
}
|
|
@@ -139,136 +147,233 @@ async function getContext(dir, targetOrConfiguration) {
|
|
|
139
147
|
if (overrideTarget) {
|
|
140
148
|
const target = workspaceProject.targets.get(overrideTarget.target);
|
|
141
149
|
const builder = target.builder;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
switch (builder) {
|
|
151
|
+
case "@angular/fire:deploy":
|
|
152
|
+
deployTarget = overrideTarget;
|
|
153
|
+
break;
|
|
154
|
+
case "@angular-devkit/build-angular:application":
|
|
155
|
+
buildTarget = overrideTarget;
|
|
156
|
+
break;
|
|
157
|
+
case "@angular-devkit/build-angular:browser-esbuild":
|
|
158
|
+
case "@angular-devkit/build-angular:browser":
|
|
159
|
+
browserTarget = overrideTarget;
|
|
160
|
+
break;
|
|
161
|
+
case "@angular-devkit/build-angular:prerender":
|
|
162
|
+
case "@nguniversal/builders:prerender":
|
|
163
|
+
prerenderTarget = overrideTarget;
|
|
164
|
+
break;
|
|
165
|
+
case "@angular-devkit/build-angular:dev-server":
|
|
166
|
+
case "@nguniversal/builders:ssr-dev-server":
|
|
167
|
+
case "@angular-devkit/build-angular:ssr-dev-server":
|
|
168
|
+
serveTarget = overrideTarget;
|
|
169
|
+
break;
|
|
170
|
+
default:
|
|
171
|
+
throw new error_1.FirebaseError(`builder ${builder} not known.`);
|
|
172
|
+
}
|
|
150
173
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
174
|
+
else if (workspaceProject.targets.has("deploy")) {
|
|
175
|
+
const { builder, defaultConfiguration = "production" } = workspaceProject.targets.get("deploy");
|
|
176
|
+
if (builder === "@angular/fire:deploy") {
|
|
177
|
+
deployTarget = {
|
|
178
|
+
project,
|
|
179
|
+
target: "deploy",
|
|
180
|
+
configuration: configuration || defaultConfiguration,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (deployTarget) {
|
|
185
|
+
const options = await architectHost.getOptionsForTarget(deployTarget);
|
|
186
|
+
if (!options)
|
|
187
|
+
throw new error_1.FirebaseError("Unable to get options for ng-deploy.");
|
|
188
|
+
if (options.buildTarget) {
|
|
189
|
+
(0, utils_2.assertIsString)(options.buildTarget);
|
|
190
|
+
buildTarget = targetFromTargetString(options.buildTarget);
|
|
191
|
+
}
|
|
192
|
+
if (options.prerenderTarget) {
|
|
193
|
+
(0, utils_2.assertIsString)(options.prerenderTarget);
|
|
157
194
|
prerenderTarget = targetFromTargetString(options.prerenderTarget);
|
|
158
|
-
|
|
195
|
+
}
|
|
196
|
+
if (options.browserTarget) {
|
|
197
|
+
(0, utils_2.assertIsString)(options.browserTarget);
|
|
159
198
|
browserTarget = targetFromTargetString(options.browserTarget);
|
|
160
|
-
|
|
199
|
+
}
|
|
200
|
+
if (options.serverTarget) {
|
|
201
|
+
(0, utils_2.assertIsString)(options.serverTarget);
|
|
161
202
|
serverTarget = targetFromTargetString(options.serverTarget);
|
|
162
|
-
|
|
203
|
+
}
|
|
204
|
+
if (options.serveOptimizedImages) {
|
|
163
205
|
serveOptimizedImages = true;
|
|
164
206
|
}
|
|
165
|
-
if (!browserTarget)
|
|
166
|
-
throw new Error("ng-deploy is missing a browser target. Plase check your angular.json.");
|
|
167
207
|
if (prerenderTarget) {
|
|
168
208
|
const prerenderOptions = await architectHost.getOptionsForTarget(prerenderTarget);
|
|
169
|
-
if (
|
|
170
|
-
throw new
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
209
|
+
if (!browserTarget) {
|
|
210
|
+
throw new error_1.FirebaseError("ng-deploy with prerenderTarget requires a browserTarget");
|
|
211
|
+
}
|
|
212
|
+
if (targetStringFromTarget(browserTarget) !== (prerenderOptions === null || prerenderOptions === void 0 ? void 0 : prerenderOptions.browserTarget)) {
|
|
213
|
+
throw new error_1.FirebaseError("ng-deploy's browserTarget and prerender's browserTarget do not match. Please check your angular.json");
|
|
214
|
+
}
|
|
215
|
+
if (serverTarget && targetStringFromTarget(serverTarget) !== (prerenderOptions === null || prerenderOptions === void 0 ? void 0 : prerenderOptions.serverTarget)) {
|
|
216
|
+
throw new error_1.FirebaseError("ng-deploy's serverTarget and prerender's serverTarget do not match. Please check your angular.json");
|
|
217
|
+
}
|
|
218
|
+
if (!serverTarget) {
|
|
174
219
|
console.warn("Treating the application as fully rendered. Add a serverTarget to your deploy target in angular.json to utilize server-side rendering.");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (!buildTarget && !browserTarget) {
|
|
223
|
+
throw new error_1.FirebaseError("ng-deploy is missing a build target. Plase check your angular.json.");
|
|
175
224
|
}
|
|
176
225
|
}
|
|
177
|
-
if (!overrideTarget
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
226
|
+
else if (!overrideTarget) {
|
|
227
|
+
if (workspaceProject.targets.has("prerender")) {
|
|
228
|
+
const { defaultConfiguration = "production" } = workspaceProject.targets.get("prerender");
|
|
229
|
+
prerenderTarget = {
|
|
230
|
+
project,
|
|
231
|
+
target: "prerender",
|
|
232
|
+
configuration: configuration || defaultConfiguration,
|
|
233
|
+
};
|
|
234
|
+
const options = await architectHost.getOptionsForTarget(prerenderTarget);
|
|
235
|
+
(0, utils_2.assertIsString)(options === null || options === void 0 ? void 0 : options.browserTarget);
|
|
236
|
+
browserTarget = targetFromTargetString(options.browserTarget);
|
|
237
|
+
(0, utils_2.assertIsString)(options === null || options === void 0 ? void 0 : options.serverTarget);
|
|
189
238
|
serverTarget = targetFromTargetString(options.serverTarget);
|
|
190
239
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
240
|
+
if (!buildTarget && !browserTarget && workspaceProject.targets.has("build")) {
|
|
241
|
+
const { builder, defaultConfiguration = "production" } = workspaceProject.targets.get("build");
|
|
242
|
+
const target = {
|
|
243
|
+
project,
|
|
244
|
+
target: "build",
|
|
245
|
+
configuration: configuration || defaultConfiguration,
|
|
246
|
+
};
|
|
247
|
+
if (builder === "@angular-devkit/build-angular:browser" ||
|
|
248
|
+
builder === "@angular-devkit/build-angular:browser-esbuild") {
|
|
249
|
+
browserTarget = target;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
buildTarget = target;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (!serverTarget && workspaceProject.targets.has("server")) {
|
|
256
|
+
const { defaultConfiguration = "production" } = workspaceProject.targets.get("server");
|
|
257
|
+
serverTarget = {
|
|
258
|
+
project,
|
|
259
|
+
target: "server",
|
|
260
|
+
configuration: configuration || defaultConfiguration,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
208
263
|
}
|
|
209
264
|
if (!serveTarget) {
|
|
210
265
|
if (serverTarget && workspaceProject.targets.has("serve-ssr")) {
|
|
211
266
|
const { defaultConfiguration = "development" } = workspaceProject.targets.get("serve-ssr");
|
|
212
|
-
serveTarget = {
|
|
267
|
+
serveTarget = {
|
|
268
|
+
project,
|
|
269
|
+
target: "serve-ssr",
|
|
270
|
+
configuration: configuration || defaultConfiguration,
|
|
271
|
+
};
|
|
213
272
|
}
|
|
214
273
|
else if (workspaceProject.targets.has("serve")) {
|
|
215
274
|
const { defaultConfiguration = "development" } = workspaceProject.targets.get("serve");
|
|
216
|
-
serveTarget = {
|
|
275
|
+
serveTarget = {
|
|
276
|
+
project,
|
|
277
|
+
target: "serve",
|
|
278
|
+
configuration: configuration || defaultConfiguration,
|
|
279
|
+
};
|
|
217
280
|
}
|
|
218
281
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
282
|
+
for (const target of [
|
|
283
|
+
deployTarget,
|
|
284
|
+
buildTarget,
|
|
285
|
+
prerenderTarget,
|
|
286
|
+
serverTarget,
|
|
287
|
+
browserTarget,
|
|
288
|
+
serveTarget,
|
|
289
|
+
]) {
|
|
290
|
+
if (target) {
|
|
291
|
+
const targetString = targetStringFromTarget(target);
|
|
292
|
+
if (target.project !== project)
|
|
293
|
+
throw new error_1.FirebaseError(`${targetString} is not in project ${project}. Please check your angular.json`);
|
|
294
|
+
const definition = workspaceProject.targets.get(target.target);
|
|
295
|
+
if (!definition)
|
|
296
|
+
throw new error_1.FirebaseError(`${target} could not be found in your angular.json`);
|
|
297
|
+
const { builder } = definition;
|
|
298
|
+
if (target === deployTarget && builder === "@angular/fire:deploy")
|
|
299
|
+
continue;
|
|
300
|
+
if (target === buildTarget && builder === "@angular-devkit/build-angular:application")
|
|
301
|
+
continue;
|
|
302
|
+
if (target === browserTarget && builder === "@angular-devkit/build-angular:browser-esbuild")
|
|
303
|
+
continue;
|
|
304
|
+
if (target === browserTarget && builder === "@angular-devkit/build-angular:browser")
|
|
305
|
+
continue;
|
|
306
|
+
if (target === prerenderTarget && builder === "@angular-devkit/build-angular:prerender")
|
|
307
|
+
continue;
|
|
308
|
+
if (target === prerenderTarget && builder === "@nguniversal/builders:prerender")
|
|
309
|
+
continue;
|
|
310
|
+
if (target === serverTarget && builder === "@angular-devkit/build-angular:server")
|
|
311
|
+
continue;
|
|
312
|
+
if (target === serveTarget && builder === "@nguniversal/builders:ssr-dev-server")
|
|
313
|
+
continue;
|
|
314
|
+
if (target === serveTarget && builder === "@angular-devkit/build-angular:ssr-dev-server")
|
|
315
|
+
continue;
|
|
316
|
+
if (target === serveTarget && builder === "@angular-devkit/build-angular:dev-server")
|
|
317
|
+
continue;
|
|
318
|
+
throw new error_1.FirebaseError(`${definition.builder} (${targetString}) is not a recognized builder. Please check your angular.json`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const buildOrBrowserTarget = buildTarget || browserTarget;
|
|
322
|
+
if (!buildOrBrowserTarget) {
|
|
323
|
+
throw new error_1.FirebaseError(`No build target on ${project}`);
|
|
228
324
|
}
|
|
229
|
-
|
|
230
|
-
throw new error_1.FirebaseError(`No browser target on ${project}`);
|
|
231
|
-
const browserTargetOptions = await architectHost.getOptionsForTarget(browserTarget);
|
|
325
|
+
const browserTargetOptions = await architectHost.getOptionsForTarget(buildOrBrowserTarget);
|
|
232
326
|
if (!browserTargetOptions) {
|
|
233
|
-
|
|
327
|
+
const targetString = targetStringFromTarget(buildOrBrowserTarget);
|
|
328
|
+
throw new error_1.FirebaseError(`Couldn't find options for ${targetString}.`);
|
|
234
329
|
}
|
|
235
330
|
const baseHref = browserTargetOptions.baseHref || "/";
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
331
|
+
(0, utils_2.assertIsString)(baseHref);
|
|
332
|
+
const buildTargetOptions = buildTarget && (await architectHost.getOptionsForTarget(buildTarget));
|
|
333
|
+
const ssr = buildTarget ? !!(buildTargetOptions === null || buildTargetOptions === void 0 ? void 0 : buildTargetOptions.ssr) : !!serverTarget;
|
|
239
334
|
return {
|
|
240
335
|
architect,
|
|
241
336
|
architectHost,
|
|
242
337
|
baseHref,
|
|
243
338
|
host,
|
|
339
|
+
buildTarget,
|
|
244
340
|
browserTarget,
|
|
245
341
|
prerenderTarget,
|
|
246
342
|
serverTarget,
|
|
247
343
|
serveTarget,
|
|
248
344
|
workspaceProject,
|
|
249
345
|
serveOptimizedImages,
|
|
346
|
+
ssr,
|
|
250
347
|
};
|
|
251
348
|
}
|
|
252
349
|
exports.getContext = getContext;
|
|
253
350
|
async function getBrowserConfig(sourceDir, configuration) {
|
|
254
|
-
const { architectHost, browserTarget, baseHref, workspaceProject } = await getContext(sourceDir, configuration);
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const
|
|
351
|
+
const { architectHost, browserTarget, buildTarget, baseHref, workspaceProject } = await getContext(sourceDir, configuration);
|
|
352
|
+
const buildOrBrowserTarget = buildTarget || browserTarget;
|
|
353
|
+
if (!buildOrBrowserTarget) {
|
|
354
|
+
throw new assert_1.AssertionError({ message: "expected build or browser target defined" });
|
|
355
|
+
}
|
|
356
|
+
const { locales, defaultLocale } = await localesForTarget(sourceDir, architectHost, buildOrBrowserTarget, workspaceProject);
|
|
357
|
+
const targetOptions = await architectHost.getOptionsForTarget(buildOrBrowserTarget);
|
|
358
|
+
(0, utils_2.assertIsString)(targetOptions === null || targetOptions === void 0 ? void 0 : targetOptions.outputPath);
|
|
359
|
+
const outputPath = (0, path_1.join)(targetOptions.outputPath, buildTarget ? "browser" : "");
|
|
260
360
|
return { locales, baseHref, outputPath, defaultLocale };
|
|
261
361
|
}
|
|
262
362
|
exports.getBrowserConfig = getBrowserConfig;
|
|
263
363
|
async function getServerConfig(sourceDir, configuration) {
|
|
264
364
|
var _a;
|
|
265
|
-
const { architectHost, host, serverTarget, browserTarget, baseHref, workspaceProject, serveOptimizedImages, } = await getContext(sourceDir, configuration);
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
throw new
|
|
269
|
-
|
|
365
|
+
const { architectHost, host, buildTarget, serverTarget, browserTarget, baseHref, workspaceProject, serveOptimizedImages, ssr, } = await getContext(sourceDir, configuration);
|
|
366
|
+
const buildOrBrowserTarget = buildTarget || browserTarget;
|
|
367
|
+
if (!buildOrBrowserTarget) {
|
|
368
|
+
throw new assert_1.AssertionError({ message: "expected build or browser target to be defined" });
|
|
369
|
+
}
|
|
370
|
+
const browserTargetOptions = await architectHost.getOptionsForTarget(buildOrBrowserTarget);
|
|
371
|
+
(0, utils_2.assertIsString)(browserTargetOptions === null || browserTargetOptions === void 0 ? void 0 : browserTargetOptions.outputPath);
|
|
372
|
+
const browserOutputPath = (0, path_1.join)(browserTargetOptions.outputPath, buildTarget ? "browser" : "")
|
|
373
|
+
.split(path_1.sep)
|
|
374
|
+
.join(path_1.posix.sep);
|
|
270
375
|
const packageJson = JSON.parse(await host.readFile((0, path_1.join)(sourceDir, "package.json")));
|
|
271
|
-
if (!
|
|
376
|
+
if (!ssr) {
|
|
272
377
|
return {
|
|
273
378
|
packageJson,
|
|
274
379
|
browserOutputPath,
|
|
@@ -282,17 +387,23 @@ async function getServerConfig(sourceDir, configuration) {
|
|
|
282
387
|
serveOptimizedImages,
|
|
283
388
|
};
|
|
284
389
|
}
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const
|
|
390
|
+
const buildOrServerTarget = buildTarget || serverTarget;
|
|
391
|
+
if (!buildOrServerTarget) {
|
|
392
|
+
throw new assert_1.AssertionError({ message: "expected build or server target to be defined" });
|
|
393
|
+
}
|
|
394
|
+
const { locales: serverLocales, defaultLocale } = await localesForTarget(sourceDir, architectHost, buildOrServerTarget, workspaceProject);
|
|
395
|
+
const serverTargetOptions = await architectHost.getOptionsForTarget(buildOrServerTarget);
|
|
396
|
+
(0, utils_2.assertIsString)(serverTargetOptions === null || serverTargetOptions === void 0 ? void 0 : serverTargetOptions.outputPath);
|
|
397
|
+
const serverOutputPath = (0, path_1.join)(serverTargetOptions.outputPath, buildTarget ? "server" : "")
|
|
398
|
+
.split(path_1.sep)
|
|
399
|
+
.join(path_1.posix.sep);
|
|
290
400
|
if (serverLocales && !defaultLocale) {
|
|
291
401
|
throw new error_1.FirebaseError("It's required that your source locale to be one of the localize options");
|
|
292
402
|
}
|
|
403
|
+
const serverEntry = buildTarget ? "server.mjs" : serverTarget && "main.js";
|
|
293
404
|
const externalDependencies = serverTargetOptions.externalDependencies || [];
|
|
294
405
|
const bundleDependencies = (_a = serverTargetOptions.bundleDependencies) !== null && _a !== void 0 ? _a : true;
|
|
295
|
-
const { locales: browserLocales } = await localesForTarget(sourceDir, architectHost,
|
|
406
|
+
const { locales: browserLocales } = await localesForTarget(sourceDir, architectHost, buildOrBrowserTarget, workspaceProject);
|
|
296
407
|
return {
|
|
297
408
|
packageJson,
|
|
298
409
|
browserOutputPath,
|
|
@@ -304,20 +415,29 @@ async function getServerConfig(sourceDir, configuration) {
|
|
|
304
415
|
browserLocales,
|
|
305
416
|
defaultLocale,
|
|
306
417
|
serveOptimizedImages,
|
|
418
|
+
serverEntry,
|
|
307
419
|
};
|
|
308
420
|
}
|
|
309
421
|
exports.getServerConfig = getServerConfig;
|
|
310
422
|
async function getBuildConfig(sourceDir, configuration) {
|
|
311
423
|
const { targetStringFromTarget } = (0, utils_1.relativeRequire)(sourceDir, "@angular-devkit/architect");
|
|
312
|
-
const { browserTarget, baseHref, prerenderTarget, serverTarget, architectHost, workspaceProject, serveOptimizedImages, } = await getContext(sourceDir, configuration);
|
|
313
|
-
const targets = (
|
|
314
|
-
|
|
424
|
+
const { buildTarget, browserTarget, baseHref, prerenderTarget, serverTarget, architectHost, workspaceProject, serveOptimizedImages, ssr, } = await getContext(sourceDir, configuration);
|
|
425
|
+
const targets = (buildTarget
|
|
426
|
+
? [buildTarget]
|
|
427
|
+
: prerenderTarget
|
|
428
|
+
? [prerenderTarget]
|
|
429
|
+
: [browserTarget, serverTarget].filter((it) => !!it)).map((it) => targetStringFromTarget(it));
|
|
430
|
+
const buildOrBrowserTarget = buildTarget || browserTarget;
|
|
431
|
+
if (!buildOrBrowserTarget) {
|
|
432
|
+
throw new assert_1.AssertionError({ message: "expected build or browser target defined" });
|
|
433
|
+
}
|
|
434
|
+
const locales = await localesForTarget(sourceDir, architectHost, buildOrBrowserTarget, workspaceProject);
|
|
315
435
|
return {
|
|
316
436
|
targets,
|
|
317
437
|
baseHref,
|
|
318
|
-
serverTarget,
|
|
319
438
|
locales,
|
|
320
439
|
serveOptimizedImages,
|
|
440
|
+
ssr,
|
|
321
441
|
};
|
|
322
442
|
}
|
|
323
443
|
exports.getBuildConfig = getBuildConfig;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_SHOULD_USE_DEV_MODE_HANDLE = exports.GET_DEFAULT_BUILD_TARGETS = 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 clc = require("colorette");
|
|
5
|
+
const experiments = require("../experiments");
|
|
5
6
|
exports.NPM_COMMAND_TIMEOUT_MILLIES = 10000;
|
|
6
7
|
exports.SupportLevelWarnings = {
|
|
7
8
|
["experimental"]: (framework) => `Thank you for trying our ${clc.italic("experimental")} support for ${framework} on Firebase Hosting.
|
|
@@ -14,9 +15,11 @@ exports.DEFAULT_DOCS_URL = "https://firebase.google.com/docs/hosting/frameworks/
|
|
|
14
15
|
exports.FILE_BUG_URL = "https://github.com/firebase/firebase-tools/issues/new?template=bug_report.md";
|
|
15
16
|
exports.FEATURE_REQUEST_URL = "https://github.com/firebase/firebase-tools/issues/new?template=feature_request.md";
|
|
16
17
|
exports.MAILING_LIST_URL = "https://goo.gle/41enW5X";
|
|
17
|
-
|
|
18
|
-
exports.
|
|
19
|
-
|
|
18
|
+
const DEFAULT_FIREBASE_FRAMEWORKS_VERSION = "^0.11.0";
|
|
19
|
+
exports.FIREBASE_FRAMEWORKS_VERSION = (experiments.isEnabled("internaltesting") && process.env.FIREBASE_FRAMEWORKS_VERSION) ||
|
|
20
|
+
DEFAULT_FIREBASE_FRAMEWORKS_VERSION;
|
|
21
|
+
exports.FIREBASE_FUNCTIONS_VERSION = "^4.5.0";
|
|
22
|
+
exports.FIREBASE_ADMIN_VERSION = "^11.11.1";
|
|
20
23
|
exports.SHARP_VERSION = "^0.32.1";
|
|
21
24
|
exports.NODE_VERSION = parseInt(process.versions.node, 10);
|
|
22
25
|
exports.VALID_ENGINES = { node: [16, 18, 20] };
|
|
@@ -114,6 +114,10 @@ async function build(dir) {
|
|
|
114
114
|
headers.push(...headersFromMetaFiles);
|
|
115
115
|
if (appPathsManifest) {
|
|
116
116
|
const unrenderedServerComponents = (0, utils_2.getNonStaticServerComponents)(appPathsManifest, appPathRoutesManifest, prerenderedRoutes, dynamicRoutes);
|
|
117
|
+
if (unrenderedServerComponents.has("/_not-found") &&
|
|
118
|
+
(await (0, utils_2.hasStaticAppNotFoundComponent)(dir, distDir))) {
|
|
119
|
+
unrenderedServerComponents.delete("/_not-found");
|
|
120
|
+
}
|
|
117
121
|
for (const key of unrenderedServerComponents) {
|
|
118
122
|
reasonsForBackend.add(`non-static component ${key}`);
|
|
119
123
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNextVersion = exports.getBuildId = exports.getHeadersFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
|
|
3
|
+
exports.hasStaticAppNotFoundComponent = exports.getNextVersion = exports.getBuildId = exports.getHeadersFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -156,7 +156,7 @@ function getNonStaticServerComponents(appPathsManifest, appPathRoutesManifest, p
|
|
|
156
156
|
return !(prerenderedRoutes.includes(path) || dynamicRoutes.includes(path));
|
|
157
157
|
})
|
|
158
158
|
.map(([it]) => it);
|
|
159
|
-
return nonStaticServerComponents;
|
|
159
|
+
return new Set(nonStaticServerComponents);
|
|
160
160
|
}
|
|
161
161
|
exports.getNonStaticServerComponents = getNonStaticServerComponents;
|
|
162
162
|
async function getHeadersFromMetaFiles(sourceDir, distDir, basePath, appPathRoutesManifest) {
|
|
@@ -195,3 +195,7 @@ function getNextVersion(cwd) {
|
|
|
195
195
|
return nextVersionSemver.toString();
|
|
196
196
|
}
|
|
197
197
|
exports.getNextVersion = getNextVersion;
|
|
198
|
+
async function hasStaticAppNotFoundComponent(sourceDir, distDir) {
|
|
199
|
+
return (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDir, distDir, "server", "app", "_not-found.html"));
|
|
200
|
+
}
|
|
201
|
+
exports.hasStaticAppNotFoundComponent = hasStaticAppNotFoundComponent;
|
|
@@ -4,7 +4,6 @@ exports.actionFunction = void 0;
|
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const repl = require("repl");
|
|
6
6
|
const _ = require("lodash");
|
|
7
|
-
const request = require("request");
|
|
8
7
|
const util = require("util");
|
|
9
8
|
const shell = require("./emulator/functionsEmulatorShell");
|
|
10
9
|
const commandUtils = require("./emulator/commandUtils");
|
|
@@ -16,6 +15,7 @@ const types_1 = require("./emulator/types");
|
|
|
16
15
|
const hubClient_1 = require("./emulator/hubClient");
|
|
17
16
|
const portUtils_1 = require("./emulator/portUtils");
|
|
18
17
|
const constants_1 = require("./emulator/constants");
|
|
18
|
+
const localFunction_2 = require("./localFunction");
|
|
19
19
|
const projectUtils_1 = require("./projectUtils");
|
|
20
20
|
const serveFunctions = new functions_1.FunctionsServer();
|
|
21
21
|
const actionFunction = async (options) => {
|
|
@@ -89,8 +89,8 @@ const actionFunction = async (options) => {
|
|
|
89
89
|
}
|
|
90
90
|
utils.logLabeledWarning("functions", `The following emulators are not running, calls to these services will affect production: ${clc.bold(otherEmulators.join(", "))}`);
|
|
91
91
|
const writer = (output) => {
|
|
92
|
-
if (output
|
|
93
|
-
return
|
|
92
|
+
if (output === localFunction_2.HTTPS_SENTINEL) {
|
|
93
|
+
return localFunction_2.HTTPS_SENTINEL;
|
|
94
94
|
}
|
|
95
95
|
return util.inspect(output);
|
|
96
96
|
};
|
package/lib/gcp/cloudbuild.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteRepository = exports.getRepository = exports.createRepository = exports.fetchLinkableRepositories = exports.deleteConnection = exports.getConnection = exports.createConnection = void 0;
|
|
3
|
+
exports.deleteRepository = exports.getRepository = exports.createRepository = exports.fetchLinkableRepositories = exports.deleteConnection = exports.listConnections = exports.getConnection = exports.createConnection = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const api_1 = require("../api");
|
|
6
|
+
const PAGE_SIZE_MAX = 100;
|
|
6
7
|
const client = new apiv2_1.Client({
|
|
7
8
|
urlPrefix: api_1.cloudbuildOrigin,
|
|
8
9
|
auth: true,
|
|
9
10
|
apiVersion: "v2",
|
|
10
11
|
});
|
|
11
|
-
async function createConnection(projectId, location, connectionId) {
|
|
12
|
-
const res = await client.post(`projects/${projectId}/locations/${location}/connections`, { githubConfig
|
|
12
|
+
async function createConnection(projectId, location, connectionId, githubConfig = {}) {
|
|
13
|
+
const res = await client.post(`projects/${projectId}/locations/${location}/connections`, { githubConfig }, { queryParams: { connectionId } });
|
|
13
14
|
return res.body;
|
|
14
15
|
}
|
|
15
16
|
exports.createConnection = createConnection;
|
|
@@ -19,6 +20,26 @@ async function getConnection(projectId, location, connectionId) {
|
|
|
19
20
|
return res.body;
|
|
20
21
|
}
|
|
21
22
|
exports.getConnection = getConnection;
|
|
23
|
+
async function listConnections(projectId, location) {
|
|
24
|
+
const conns = [];
|
|
25
|
+
const getNextPage = async (pageToken = "") => {
|
|
26
|
+
const res = await client.get(`/projects/${projectId}/locations/${location}/connections`, {
|
|
27
|
+
queryParams: {
|
|
28
|
+
pageSize: PAGE_SIZE_MAX,
|
|
29
|
+
pageToken,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
if (Array.isArray(res.body.connections)) {
|
|
33
|
+
conns.push(...res.body.connections);
|
|
34
|
+
}
|
|
35
|
+
if (res.body.nextPageToken) {
|
|
36
|
+
await getNextPage(res.body.nextPageToken);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
await getNextPage();
|
|
40
|
+
return conns;
|
|
41
|
+
}
|
|
42
|
+
exports.listConnections = listConnections;
|
|
22
43
|
async function deleteConnection(projectId, location, connectionId) {
|
|
23
44
|
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}`;
|
|
24
45
|
const res = await client.delete(name);
|
package/lib/gcp/storage.js
CHANGED
|
@@ -2,23 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getServiceAccount = exports.listBuckets = exports.getBucket = exports.deleteObject = exports.uploadObject = exports.upload = exports.getDefaultBucket = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
+
const clc = require("colorette");
|
|
5
6
|
const api_1 = require("../api");
|
|
6
7
|
const apiv2_1 = require("../apiv2");
|
|
7
8
|
const error_1 = require("../error");
|
|
8
9
|
const logger_1 = require("../logger");
|
|
9
|
-
const
|
|
10
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
10
11
|
async function getDefaultBucket(projectId) {
|
|
11
12
|
var _a;
|
|
13
|
+
await (0, ensureApiEnabled_1.ensure)(projectId, "firebasestorage.googleapis.com", "storage", false);
|
|
12
14
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseStorageOrigin, apiVersion: "v1alpha" });
|
|
16
|
+
const response = await localAPIClient.get(`/projects/${projectId}/defaultBucket`);
|
|
17
|
+
if (!((_a = response.body) === null || _a === void 0 ? void 0 : _a.bucket.name)) {
|
|
15
18
|
logger_1.logger.debug("Default storage bucket is undefined.");
|
|
16
19
|
throw new error_1.FirebaseError("Your project is being set up. Please wait a minute before deploying again.");
|
|
17
20
|
}
|
|
18
|
-
return
|
|
21
|
+
return response.body.bucket.name.split("/").pop();
|
|
19
22
|
}
|
|
20
23
|
catch (err) {
|
|
21
|
-
|
|
24
|
+
if ((err === null || err === void 0 ? void 0 : err.status) === 404) {
|
|
25
|
+
throw new error_1.FirebaseError(`Firebase Storage has not been set up on project '${clc.bold(projectId)}'. Go to https://console.firebase.google.com/project/${projectId}/storage and click 'Get Started' to set up Firebase Storage.`);
|
|
26
|
+
}
|
|
27
|
+
logger_1.logger.info("\n\nUnexpected error when fetching default storage bucket.");
|
|
22
28
|
throw err;
|
|
23
29
|
}
|
|
24
30
|
}
|
package/lib/hosting/runTags.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureLatestRevisionTagged = exports.setRewriteTags = exports.setGarbageCollectionThreshold = exports.gcTagsForServices = exports.TODO_TAG_NAME = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
4
5
|
const run = require("../gcp/run");
|
|
5
6
|
const api = require("./api");
|
|
6
7
|
const error_1 = require("../error");
|
|
@@ -10,7 +11,7 @@ async function gcTagsForServices(project, services) {
|
|
|
10
11
|
var _a;
|
|
11
12
|
const validTagsByServiceByRegion = {};
|
|
12
13
|
const sites = await api.listSites(project);
|
|
13
|
-
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(site.name)));
|
|
14
|
+
const allVersionsNested = await Promise.all(sites.map((site) => api.listVersions(node_path_1.posix.basename(site.name))));
|
|
14
15
|
const activeVersions = [...(0, functional_1.flattenArray)(allVersionsNested)].filter((version) => {
|
|
15
16
|
return version.status === "CREATED" || version.status === "FINALIZED";
|
|
16
17
|
});
|