firebase-tools-with-isolate 15.30.1 → 15.31.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/commands/auth-import.js +19 -10
- package/lib/commands/crashlytics-sourcemap-upload.js +2 -1
- package/lib/commands/ext-migrate.js +1 -1
- package/lib/crashlytics/sourcemap.js +35 -5
- package/lib/database/import.js +6 -6
- package/lib/deploy/functions/build.js +44 -13
- package/lib/deploy/functions/containerCleaner.js +1 -7
- package/lib/deploy/functions/params.js +40 -84
- package/lib/deploy/functions/prepare.js +7 -4
- package/lib/deploy/functions/runtimes/python/index.js +48 -17
- package/lib/emulator/auth/cloudFunctions.js +40 -5
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/functionsEmulator.js +13 -4
- package/lib/emulator/functionsEmulatorShared.js +14 -3
- package/lib/emulator/functionsEmulatorUtils.js +0 -4
- package/lib/experiments.js +6 -1
- package/lib/extensions/export.js +21 -11
- package/lib/extensions/replacements.json +15 -22
- package/lib/frameworks/next/index.js +4 -4
- package/lib/fsutils.js +20 -2
- package/lib/functions/kits/install.js +143 -78
- package/lib/functions/python.js +82 -0
- package/lib/management/projects.js +14 -0
- package/lib/prompt.js +4 -0
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +6 -11
- package/templates/init/functions/typescript/index-kit.ts +1 -1
- package/lib/deploy/functions/ensureCloudBuildEnabled.js +0 -1
- package/lib/deploy/functions/runtimes/discovery/mockDiscoveryServer.js +0 -14
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = void 0;
|
|
4
4
|
const csv_parse_1 = require("csv-parse");
|
|
5
|
-
const
|
|
5
|
+
const stream_chain_1 = require("stream-chain");
|
|
6
6
|
const clc = require("colorette");
|
|
7
7
|
const fs = require("fs-extra");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const pick_js_1 = require("stream-json/filters/pick.js");
|
|
9
|
+
const stream_array_js_1 = require("stream-json/streamers/stream-array.js");
|
|
10
10
|
const command_1 = require("../command");
|
|
11
11
|
const error_1 = require("../error");
|
|
12
12
|
const logger_1 = require("../logger");
|
|
@@ -80,9 +80,10 @@ exports.command = new command_1.Command("auth:import [dataFile]")
|
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
userListArr = await new Promise((resolve, reject) => {
|
|
83
|
-
const pipeline =
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const pipeline = (0, stream_chain_1.chain)([
|
|
84
|
+
inStream,
|
|
85
|
+
pick_js_1.pick.withParser({ filter: /^users$/ }),
|
|
86
|
+
(0, stream_array_js_1.streamArray)(),
|
|
86
87
|
({ value }) => {
|
|
87
88
|
counter++;
|
|
88
89
|
const user = (0, accountImporter_1.validateUserJson)(value);
|
|
@@ -97,14 +98,22 @@ exports.command = new command_1.Command("auth:import [dataFile]")
|
|
|
97
98
|
}
|
|
98
99
|
},
|
|
99
100
|
]);
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
let completed = false;
|
|
102
|
+
const onDone = () => {
|
|
103
|
+
if (completed) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
completed = true;
|
|
102
107
|
if (currentBatch.length) {
|
|
103
108
|
batches.push(currentBatch);
|
|
109
|
+
currentBatch = [];
|
|
104
110
|
}
|
|
105
111
|
resolve(batches);
|
|
106
|
-
}
|
|
107
|
-
|
|
112
|
+
};
|
|
113
|
+
pipeline.once("error", reject);
|
|
114
|
+
pipeline.once("finish", onDone);
|
|
115
|
+
pipeline.once("end", onDone);
|
|
116
|
+
pipeline.resume();
|
|
108
117
|
});
|
|
109
118
|
}
|
|
110
119
|
logger_1.logger.debug(`Preparing to import ${counter} user records in ${userListArr.length} batches.`);
|
|
@@ -41,7 +41,8 @@ exports.command = new command_1.Command("crashlytics:sourcemap:upload [mappingFi
|
|
|
41
41
|
ignoreStrings: ["node_modules", ".git"],
|
|
42
42
|
maxDepth: 20,
|
|
43
43
|
});
|
|
44
|
-
const
|
|
44
|
+
const baseDir = path.basename(filePath) === ".next" ? path.dirname(filePath) : filePath;
|
|
45
|
+
const mappings = await (0, sourcemap_1.findSourceMapMappings)(files, baseDir);
|
|
45
46
|
const result = await (0, sourcemap_1.uploadSourceMaps)(mappings, {
|
|
46
47
|
projectId,
|
|
47
48
|
bucketName,
|
|
@@ -94,7 +94,7 @@ exports.command = new command_1.Command("ext:migrate")
|
|
|
94
94
|
throw new error_1.FirebaseError(`Failed to deploy. Please fix and retry with firebase deploy --only functions:${kitInstanceId}. After success you may remove the old extension with firebase ext:uninstall ${plan.instanceId} --project ${projectId} --immediate`, { original: err instanceof Error ? err : undefined, exit: 1 });
|
|
95
95
|
}
|
|
96
96
|
const shouldUninstall = await (0, prompt_1.confirm)({
|
|
97
|
-
message: `Functions kit ${kitInstanceId} successfully deployed. After checking function logs to verify that your backend is performing correctly, you should uninstall extension instance ${plan.instanceId}. Uninstall it now?`,
|
|
97
|
+
message: `Functions kit ${kitInstanceId} successfully deployed. After checking function logs to verify that your backend is performing correctly, you should uninstall extension instance ${plan.instanceId}. It can take a few minutes for Eventarc to fully provision and new kits to react to events. Uninstall it now?`,
|
|
98
98
|
default: false,
|
|
99
99
|
nonInteractive: options.nonInteractive,
|
|
100
100
|
force: options.force,
|
|
@@ -24,6 +24,8 @@ const utils_1 = require("../utils");
|
|
|
24
24
|
const gcs = require("../gcp/storage");
|
|
25
25
|
const archiveFile_1 = require("../archiveFile");
|
|
26
26
|
exports.CONCURRENCY = 25;
|
|
27
|
+
const ANGULAR_DIST_DIR = "dist";
|
|
28
|
+
const ANGULAR_BROWSER_DIR = "browser";
|
|
27
29
|
function checkGoogleAppID(options) {
|
|
28
30
|
if (!options.app) {
|
|
29
31
|
throw new error_1.FirebaseError("set --app <appId> to a valid Firebase application id, e.g. 1:00000000:android:0000000");
|
|
@@ -287,9 +289,15 @@ async function uploadSourceMaps(mappings, request) {
|
|
|
287
289
|
}
|
|
288
290
|
async function uploadMap(request, attemptsRemaining = 0) {
|
|
289
291
|
const { projectId, mappingFile, obfuscatedFilePath, bucketName, appVersion, options } = request;
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
|
|
292
|
+
const rootDir = options.projectRoot ?? process.cwd();
|
|
293
|
+
const relativeToRoot = path.relative(rootDir, mappingFile);
|
|
294
|
+
const resolvedCheckPath = path.resolve(rootDir, relativeToRoot);
|
|
295
|
+
const filePath = !fs.existsSync(resolvedCheckPath) && fs.existsSync(mappingFile) ? mappingFile : relativeToRoot;
|
|
296
|
+
const pathSegments = obfuscatedFilePath.split(path.sep);
|
|
297
|
+
const browserIndex = pathSegments.lastIndexOf(ANGULAR_BROWSER_DIR);
|
|
298
|
+
const isAngularBuildDir = filePath.split(path.sep).includes(ANGULAR_DIST_DIR);
|
|
299
|
+
const normalizedSegments = isAngularBuildDir && browserIndex !== -1 ? pathSegments.slice(browserIndex + 1) : pathSegments;
|
|
300
|
+
const obfuscatedPath = normalizedSegments
|
|
293
301
|
.map((p) => (p === ".next" ? "_next" : p))
|
|
294
302
|
.filter((p) => p !== "dev")
|
|
295
303
|
.join("/");
|
|
@@ -338,22 +346,44 @@ async function uploadMap(request, attemptsRemaining = 0) {
|
|
|
338
346
|
function normalizeFileName(fileName) {
|
|
339
347
|
return fileName.replaceAll(/\//g, "-");
|
|
340
348
|
}
|
|
349
|
+
function isAlreadyExistsError(e) {
|
|
350
|
+
if (e.status !== 400) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
const message = e.message.toLowerCase();
|
|
354
|
+
const bodyMessage = (e.context?.body?.error?.message ?? "").toLowerCase();
|
|
355
|
+
return message.includes("already exists") || bodyMessage.includes("already exists");
|
|
356
|
+
}
|
|
341
357
|
async function registerSourceMap(sourceMap) {
|
|
342
358
|
const client = new apiv2_1.Client({
|
|
343
359
|
urlPrefix: "https://firebasetelemetryadmin.googleapis.com",
|
|
344
360
|
auth: true,
|
|
345
361
|
apiVersion: "v1alpha",
|
|
346
362
|
});
|
|
347
|
-
|
|
363
|
+
const patchSourceMap = async () => {
|
|
348
364
|
await client.patch(sourceMap.name, sourceMap, { queryParams: { allowMissing: "true" } });
|
|
349
365
|
logger_1.logger.debug(`Registered source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service`);
|
|
366
|
+
};
|
|
367
|
+
try {
|
|
368
|
+
await patchSourceMap();
|
|
350
369
|
}
|
|
351
370
|
catch (e) {
|
|
352
371
|
if (e instanceof error_1.FirebaseError) {
|
|
353
372
|
if (e.status === 409) {
|
|
354
373
|
return;
|
|
355
374
|
}
|
|
375
|
+
if (isAlreadyExistsError(e)) {
|
|
376
|
+
try {
|
|
377
|
+
logger_1.logger.debug(`Source map ${sourceMap.obfuscatedFilePath} already exists, deleting and re-registering`);
|
|
378
|
+
await client.delete(sourceMap.name);
|
|
379
|
+
await patchSourceMap();
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
catch (retryErr) {
|
|
383
|
+
throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service:\n${retryErr instanceof Error ? retryErr.message : String(retryErr)}`, { original: retryErr instanceof Error ? retryErr : undefined });
|
|
384
|
+
}
|
|
385
|
+
}
|
|
356
386
|
}
|
|
357
|
-
throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service:\n${e instanceof Error ? e.message : String(e)}
|
|
387
|
+
throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service:\n${e instanceof Error ? e.message : String(e)}`, { original: e instanceof Error ? e : undefined });
|
|
358
388
|
}
|
|
359
389
|
}
|
package/lib/database/import.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const stream_chain_1 = require("stream-chain");
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const
|
|
5
|
+
const filter_js_1 = require("stream-json/filters/filter.js");
|
|
6
6
|
const stream = require("stream");
|
|
7
|
-
const
|
|
7
|
+
const stream_object_js_1 = require("stream-json/streamers/stream-object.js");
|
|
8
8
|
const apiv2_1 = require("../apiv2");
|
|
9
9
|
const error_1 = require("../error");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
@@ -132,13 +132,13 @@ class DatabaseImporter {
|
|
|
132
132
|
};
|
|
133
133
|
return new Promise((resolve, reject) => {
|
|
134
134
|
const responses = [];
|
|
135
|
-
const pipeline =
|
|
135
|
+
const pipeline = (0, stream_chain_1.chain)([
|
|
136
136
|
this.inStream,
|
|
137
|
-
|
|
137
|
+
filter_js_1.filter.withParser({
|
|
138
138
|
filter: this.computeFilterString(this.dataPath) || (() => true),
|
|
139
139
|
pathSeparator: "/",
|
|
140
140
|
}),
|
|
141
|
-
|
|
141
|
+
(0, stream_object_js_1.streamObject)(),
|
|
142
142
|
]);
|
|
143
143
|
pipeline
|
|
144
144
|
.on("error", (err) => reject(new error_1.FirebaseError(`Invalid data; couldn't parse JSON object, array, or value. ${err.message}`, {
|
|
@@ -13,8 +13,10 @@ exports.isBlockingTriggered = isBlockingTriggered;
|
|
|
13
13
|
exports.resolveBackend = resolveBackend;
|
|
14
14
|
exports.envWithTypes = envWithTypes;
|
|
15
15
|
exports.toBackend = toBackend;
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
16
|
+
exports.applyKitSecretRefPrefix = applyKitSecretRefPrefix;
|
|
17
|
+
exports.applyEndpointPrefix = applyEndpointPrefix;
|
|
18
|
+
exports.applyEnvSecretBindingsToParams = applyEnvSecretBindingsToParams;
|
|
19
|
+
exports.applyEnvSecretBindingsToBuild = applyEnvSecretBindingsToBuild;
|
|
18
20
|
exports.parseSecretRef = parseSecretRef;
|
|
19
21
|
const backend = require("./backend");
|
|
20
22
|
const proto = require("../../gcp/proto");
|
|
@@ -23,9 +25,11 @@ const logger_1 = require("../../logger");
|
|
|
23
25
|
const error_1 = require("../../error");
|
|
24
26
|
const functional_1 = require("../../functional");
|
|
25
27
|
const cel_1 = require("./cel");
|
|
28
|
+
const projects = require("../../management/projects");
|
|
29
|
+
const projectConfig_1 = require("../../functions/projectConfig");
|
|
26
30
|
exports.REGION_TBD = "REGION_TBD";
|
|
27
31
|
exports.SECRET_REF_PREFIX = "FIREBASE_SECRET_REF_";
|
|
28
|
-
const
|
|
32
|
+
const GCP_PROJECT_ID_OR_NUM_PATTERN = "((?:\\d+)|(?:[a-z][-a-z0-9]{4,28}[a-z0-9]))";
|
|
29
33
|
exports.GCP_SECRET_ID_PATTERN = "([a-zA-Z0-9-_]+)";
|
|
30
34
|
exports.SECRET_REF_SHORT_RE = new RegExp("^" +
|
|
31
35
|
exports.GCP_SECRET_ID_PATTERN +
|
|
@@ -34,7 +38,7 @@ exports.SECRET_REF_SHORT_RE = new RegExp("^" +
|
|
|
34
38
|
")?$");
|
|
35
39
|
exports.SECRET_REF_LONG_RE = new RegExp("^" +
|
|
36
40
|
"projects/" +
|
|
37
|
-
|
|
41
|
+
GCP_PROJECT_ID_OR_NUM_PATTERN +
|
|
38
42
|
"/secrets/" +
|
|
39
43
|
exports.GCP_SECRET_ID_PATTERN +
|
|
40
44
|
"(?:(?:/versions/|:|#|@)" +
|
|
@@ -88,7 +92,6 @@ async function resolveBackend(opts) {
|
|
|
88
92
|
userEnvs: envWithTypes(opts.build.params, opts.userEnvs),
|
|
89
93
|
codebase: opts.codebase,
|
|
90
94
|
nonInteractive: opts.nonInteractive,
|
|
91
|
-
force: opts.force,
|
|
92
95
|
isEmulator: opts.isEmulator,
|
|
93
96
|
});
|
|
94
97
|
return { backend: toBackend(opts.build, paramValues), envs: paramValues, secretRefs: secretRefs };
|
|
@@ -385,7 +388,18 @@ function discoverTrigger(endpoint, region, r) {
|
|
|
385
388
|
}
|
|
386
389
|
(0, functional_1.assertExhaustive)(endpoint);
|
|
387
390
|
}
|
|
388
|
-
function
|
|
391
|
+
function applyKitSecretRefPrefix(build, instanceId) {
|
|
392
|
+
const kitPrefix = (0, projectConfig_1.addKitPrefix)(instanceId);
|
|
393
|
+
for (const secretParam of build.params.filter((p) => params.isSecretParam(p))) {
|
|
394
|
+
secretParam.resourceId = `${kitPrefix}-${secretParam.name}`;
|
|
395
|
+
}
|
|
396
|
+
for (const endpoint of Object.values(build.endpoints)) {
|
|
397
|
+
for (const envVar of endpoint.secretEnvironmentVariables ?? []) {
|
|
398
|
+
envVar.secret = `${kitPrefix}-${envVar.secret}`;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function applyEndpointPrefix(build, prefix) {
|
|
389
403
|
if (!prefix) {
|
|
390
404
|
return;
|
|
391
405
|
}
|
|
@@ -425,7 +439,19 @@ function applyPrefix(build, prefix) {
|
|
|
425
439
|
}
|
|
426
440
|
}
|
|
427
441
|
}
|
|
428
|
-
function
|
|
442
|
+
function applyEnvSecretBindingsToParams(params, envSecrets) {
|
|
443
|
+
for (const key of Object.keys(envSecrets)) {
|
|
444
|
+
const { secretId, version } = envSecrets[key];
|
|
445
|
+
for (const param of params) {
|
|
446
|
+
if (param.type === "secret" && param.name.toUpperCase() === key.toUpperCase()) {
|
|
447
|
+
param.resourceId = secretId;
|
|
448
|
+
param.version = version;
|
|
449
|
+
param.inLocalEnvironment = true;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
async function applyEnvSecretBindingsToBuild(build, envSecrets) {
|
|
429
455
|
if (envSecrets.empty) {
|
|
430
456
|
return;
|
|
431
457
|
}
|
|
@@ -433,15 +459,20 @@ function applyEnvSecretBindings(build, envSecrets) {
|
|
|
433
459
|
for (const endpointName of Object.keys(build.endpoints)) {
|
|
434
460
|
logger_1.logger.debug(`${endpointName} declared secrets: ${JSON.stringify(build.endpoints[endpointName].secretEnvironmentVariables)}`);
|
|
435
461
|
}
|
|
462
|
+
applyEnvSecretBindingsToParams(build.params, envSecrets);
|
|
463
|
+
const projectNumberToId = new Map();
|
|
436
464
|
for (const key of Object.keys(envSecrets)) {
|
|
437
465
|
const secretRef = envSecrets[key];
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
466
|
+
let { projectId } = secretRef;
|
|
467
|
+
const { secretId, version } = secretRef;
|
|
468
|
+
if (projectId && /^\d+$/.test(projectId)) {
|
|
469
|
+
let resolvedId = projectNumberToId.get(projectId);
|
|
470
|
+
if (!resolvedId) {
|
|
471
|
+
const project = await projects.getProject(projectId);
|
|
472
|
+
resolvedId = project.projectId;
|
|
473
|
+
projectNumberToId.set(projectId, resolvedId);
|
|
444
474
|
}
|
|
475
|
+
projectId = resolvedId;
|
|
445
476
|
}
|
|
446
477
|
for (const endpointName of Object.keys(build.endpoints)) {
|
|
447
478
|
const endpoint = build.endpoints[endpointName];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DockerHelper = exports.ContainerRegistryCleaner = exports.
|
|
3
|
+
exports.DockerHelper = exports.ContainerRegistryCleaner = exports.ArtifactRegistryCleaner = void 0;
|
|
4
4
|
exports.cleanupBuildImages = cleanupBuildImages;
|
|
5
5
|
exports.listGcfPaths = listGcfPaths;
|
|
6
6
|
exports.deleteGcfArtifacts = deleteGcfArtifacts;
|
|
@@ -134,12 +134,6 @@ ArtifactRegistryCleaner.POLLER_OPTIONS = {
|
|
|
134
134
|
apiVersion: artifactregistry.API_VERSION,
|
|
135
135
|
masterTimeout: 5 * 60 * 1000,
|
|
136
136
|
};
|
|
137
|
-
class NoopArtifactRegistryCleaner extends ArtifactRegistryCleaner {
|
|
138
|
-
cleanupFunction() {
|
|
139
|
-
return Promise.resolve();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.NoopArtifactRegistryCleaner = NoopArtifactRegistryCleaner;
|
|
143
137
|
class ContainerRegistryCleaner {
|
|
144
138
|
constructor() {
|
|
145
139
|
this.helpers = {};
|
|
@@ -9,19 +9,20 @@ exports.isTextInput = isTextInput;
|
|
|
9
9
|
exports.isSelectInput = isSelectInput;
|
|
10
10
|
exports.isResourceInput = isResourceInput;
|
|
11
11
|
exports.isMultiSelectInput = isMultiSelectInput;
|
|
12
|
+
exports.isSecretParam = isSecretParam;
|
|
12
13
|
exports.resolveParams = resolveParams;
|
|
13
14
|
const clc = require("colorette");
|
|
14
15
|
const logger_1 = require("../../logger");
|
|
15
16
|
const error_1 = require("../../error");
|
|
16
17
|
const prompt_1 = require("../../prompt");
|
|
17
18
|
const secrets_1 = require("../../functions/secrets");
|
|
18
|
-
const build = require("./build");
|
|
19
19
|
const functional_1 = require("../../functional");
|
|
20
20
|
const secretManager = require("../../gcp/secretManager");
|
|
21
21
|
const storage_1 = require("../../gcp/storage");
|
|
22
22
|
const cel_1 = require("./cel");
|
|
23
23
|
const secretManager_1 = require("../../gcp/secretManager");
|
|
24
24
|
const experiments = require("../../experiments");
|
|
25
|
+
const marked_1 = require("marked");
|
|
25
26
|
function dependenciesCEL(expr) {
|
|
26
27
|
const deps = [];
|
|
27
28
|
const paramCapture = /{{ params\.(\w+) }}/g;
|
|
@@ -82,6 +83,9 @@ function isResourceInput(input) {
|
|
|
82
83
|
function isMultiSelectInput(input) {
|
|
83
84
|
return {}.hasOwnProperty.call(input, "multiSelect");
|
|
84
85
|
}
|
|
86
|
+
function isSecretParam(param) {
|
|
87
|
+
return param.type === "secret";
|
|
88
|
+
}
|
|
85
89
|
class ParamValue {
|
|
86
90
|
constructor(rawValue, internal, types) {
|
|
87
91
|
this.rawValue = rawValue;
|
|
@@ -164,7 +168,7 @@ function canSatisfyParam(param, value) {
|
|
|
164
168
|
(0, functional_1.assertExhaustive)(param);
|
|
165
169
|
}
|
|
166
170
|
async function resolveParams(opts) {
|
|
167
|
-
const { params, firebaseConfig, userEnvs, codebase, nonInteractive = false,
|
|
171
|
+
const { params, firebaseConfig, userEnvs, codebase, nonInteractive = false, isEmulator = false, } = opts;
|
|
168
172
|
const paramValues = populateDefaultParams(firebaseConfig);
|
|
169
173
|
const secretRefs = {};
|
|
170
174
|
const [resolved, outstanding] = (0, functional_1.partition)(params, (param) => {
|
|
@@ -176,7 +180,7 @@ async function resolveParams(opts) {
|
|
|
176
180
|
const [needSecret, needPrompt] = (0, functional_1.partition)(outstanding, (param) => param.type === "secret");
|
|
177
181
|
if (!isEmulator) {
|
|
178
182
|
for (const param of needSecret) {
|
|
179
|
-
secretRefs[param.name] = await ensureSecret(param, firebaseConfig.projectId, nonInteractive
|
|
183
|
+
secretRefs[param.name] = await ensureSecret(param, firebaseConfig.projectId, nonInteractive);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
182
186
|
if (nonInteractive && needPrompt.length > 0) {
|
|
@@ -229,7 +233,7 @@ function populateDefaultParams(config) {
|
|
|
229
233
|
}
|
|
230
234
|
return defaultParams;
|
|
231
235
|
}
|
|
232
|
-
async function ensureSecret(secretParam, projectId, nonInteractive
|
|
236
|
+
async function ensureSecret(secretParam, projectId, nonInteractive) {
|
|
233
237
|
const resourceId = secretParam.resourceId || secretParam.name;
|
|
234
238
|
const version = secretParam.version || "latest";
|
|
235
239
|
let secretAlreadyExisted = false;
|
|
@@ -240,26 +244,11 @@ async function ensureSecret(secretParam, projectId, nonInteractive, force) {
|
|
|
240
244
|
"Set this secret before deploying:\n" +
|
|
241
245
|
`\tfirebase functions:secrets:set ${resourceId}${secretParam.format === "json" ? " --format=json --data-file <file.json>" : ""}`);
|
|
242
246
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
else {
|
|
249
|
-
secretParam.resourceId = await (0, prompt_1.input)({
|
|
250
|
-
default: secretParam.name,
|
|
251
|
-
message: `What resource ID do you want to use for the backing Secret resource for secret param ${secretParam.name}?`,
|
|
252
|
-
validate: (id) => {
|
|
253
|
-
if (new RegExp(`^${build.GCP_SECRET_ID_PATTERN}$`).test(id)) {
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
return "GCP Secret identifiers must contain only letters, numbers, underscores, and hyphens.";
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
return ensureSecret(secretParam, projectId, nonInteractive, force);
|
|
261
|
-
}
|
|
262
|
-
const promptMessage = `The value for this secret (${secretParam.name}) will be stored in Cloud Secret Manager (https://cloud.google.com/secret-manager/pricing) as ${resourceId}. Enter ${secretParam.format === "json" ? "a JSON value" : "a value"} for ${secretParam.label || secretParam.name}:`;
|
|
247
|
+
const label = secretParam.label || secretParam.name;
|
|
248
|
+
const notice = `The value for this secret will be stored in Cloud Secret Manager (https://cloud.google.com/secret-manager/pricing) as ${resourceId}.`;
|
|
249
|
+
const desc = secretParam.description ? `${secretParam.description} ${notice}` : notice;
|
|
250
|
+
logger_1.logger.info(`\n${clc.bold(label)}: ${(await (0, marked_1.marked)(desc)).trim()}`);
|
|
251
|
+
const promptMessage = `Enter ${secretParam.format === "json" ? "a JSON value" : "a value"} for ${label}:`;
|
|
263
252
|
const secretValue = await (0, prompt_1.password)({
|
|
264
253
|
message: promptMessage,
|
|
265
254
|
});
|
|
@@ -280,7 +269,8 @@ async function ensureSecret(secretParam, projectId, nonInteractive, force) {
|
|
|
280
269
|
secretAlreadyExisted = true;
|
|
281
270
|
}
|
|
282
271
|
const secretRefString = typeof version === "undefined" ? resourceId : `${resourceId}:${version}`;
|
|
283
|
-
if (experiments.isEnabled("secretEnvParams")
|
|
272
|
+
if (experiments.isEnabled("secretEnvParams") &&
|
|
273
|
+
experiments.isEnabled("writeDefaultSecretBindings")) {
|
|
284
274
|
if (!secretParam.inLocalEnvironment && secretAlreadyExisted) {
|
|
285
275
|
logger_1.logger.info(`Onetime (firebase-tools x.y.z+): storing a reference to existing secret ${secretParam.name}=${secretRefString} in .env files.`);
|
|
286
276
|
}
|
|
@@ -288,6 +278,13 @@ async function ensureSecret(secretParam, projectId, nonInteractive, force) {
|
|
|
288
278
|
return secretRefString;
|
|
289
279
|
}
|
|
290
280
|
async function promptParam(param, projectId, resolvedDefault) {
|
|
281
|
+
const label = param.label || param.name;
|
|
282
|
+
if (param.description) {
|
|
283
|
+
logger_1.logger.info(`\n${clc.bold(label)}: ${(await (0, marked_1.marked)(param.description)).trim()}`);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
logger_1.logger.info("");
|
|
287
|
+
}
|
|
291
288
|
if (param.type === "string") {
|
|
292
289
|
const provided = await promptStringParam(param, projectId, resolvedDefault);
|
|
293
290
|
return new ParamValue(provided.toString(), false, { string: true });
|
|
@@ -314,33 +311,21 @@ async function promptList(param, projectId, resolvedDefault) {
|
|
|
314
311
|
const defaultToText = { text: {} };
|
|
315
312
|
param.input = defaultToText;
|
|
316
313
|
}
|
|
317
|
-
|
|
314
|
+
const label = param.label || param.name;
|
|
318
315
|
if (isSelectInput(param.input)) {
|
|
319
316
|
throw new error_1.FirebaseError("List params cannot have non-list selector inputs");
|
|
320
317
|
}
|
|
321
318
|
else if (isMultiSelectInput(param.input)) {
|
|
322
|
-
|
|
323
|
-
if (param.description) {
|
|
324
|
-
prompt += ` \n(${param.description})`;
|
|
325
|
-
}
|
|
326
|
-
prompt += "\nSelect an option with the arrow keys, and use Enter to confirm your choice. ";
|
|
327
|
-
return promptSelectMultiple(prompt, param.input, resolvedDefault, param.input.multiSelect.nonEmpty, (res) => res);
|
|
319
|
+
return promptSelectMultiple(`Select values for ${label}:`, param.input, resolvedDefault, param.input.multiSelect.nonEmpty, (res) => res);
|
|
328
320
|
}
|
|
329
321
|
else if (isTextInput(param.input)) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
335
|
-
return res.split(param.delimiter || ",");
|
|
322
|
+
const delimiter = param.delimiter ? param.delimiter : ",";
|
|
323
|
+
return promptText(`Enter a list of strings (delimiter: ${delimiter}) for ${label}:`, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
324
|
+
return res.split(delimiter);
|
|
336
325
|
});
|
|
337
326
|
}
|
|
338
327
|
else if (isResourceInput(param.input)) {
|
|
339
|
-
|
|
340
|
-
if (param.description) {
|
|
341
|
-
prompt += ` \n(${param.description})`;
|
|
342
|
-
}
|
|
343
|
-
return promptResourceStrings(prompt, param.input, projectId, false);
|
|
328
|
+
return promptResourceStrings(`Select values for ${label}:`, param.input, projectId, false);
|
|
344
329
|
}
|
|
345
330
|
else {
|
|
346
331
|
(0, functional_1.assertExhaustive)(param.input);
|
|
@@ -352,24 +337,15 @@ async function promptBooleanParam(param, resolvedDefault) {
|
|
|
352
337
|
param.input = defaultToText;
|
|
353
338
|
}
|
|
354
339
|
const isTruthyInput = (res) => ["true", "y", "yes", "1"].includes(res.toLowerCase());
|
|
355
|
-
|
|
340
|
+
const label = param.label || param.name;
|
|
356
341
|
if (isSelectInput(param.input)) {
|
|
357
|
-
|
|
358
|
-
if (param.description) {
|
|
359
|
-
prompt += ` \n(${param.description})`;
|
|
360
|
-
}
|
|
361
|
-
prompt += "\nSelect an option with the arrow keys, and use Enter to confirm your choice. ";
|
|
362
|
-
return promptSelect(prompt, param.input, resolvedDefault, isTruthyInput);
|
|
342
|
+
return promptSelect(`Select a value for ${label}:`, param.input, resolvedDefault, isTruthyInput);
|
|
363
343
|
}
|
|
364
344
|
else if (isMultiSelectInput(param.input)) {
|
|
365
345
|
throw new error_1.FirebaseError("Non-list params cannot have multi selector inputs");
|
|
366
346
|
}
|
|
367
347
|
else if (isTextInput(param.input)) {
|
|
368
|
-
|
|
369
|
-
if (param.description) {
|
|
370
|
-
prompt += ` \n(${param.description})`;
|
|
371
|
-
}
|
|
372
|
-
return promptText(prompt, param.input, resolvedDefault, false, isTruthyInput);
|
|
348
|
+
return promptText(`Enter a boolean value for ${label}:`, param.input, resolvedDefault, false, isTruthyInput);
|
|
373
349
|
}
|
|
374
350
|
else if (isResourceInput(param.input)) {
|
|
375
351
|
throw new error_1.FirebaseError("Boolean params cannot have Cloud Resource selector inputs");
|
|
@@ -383,31 +359,18 @@ async function promptStringParam(param, projectId, resolvedDefault) {
|
|
|
383
359
|
const defaultToText = { text: {} };
|
|
384
360
|
param.input = defaultToText;
|
|
385
361
|
}
|
|
386
|
-
|
|
362
|
+
const label = param.label || param.name;
|
|
387
363
|
if (isResourceInput(param.input)) {
|
|
388
|
-
|
|
389
|
-
if (param.description) {
|
|
390
|
-
prompt += ` \n(${param.description})`;
|
|
391
|
-
}
|
|
392
|
-
return promptResourceString(prompt, param.input, projectId, resolvedDefault);
|
|
364
|
+
return promptResourceString(`Select a value for ${label}:`, param.input, projectId, resolvedDefault);
|
|
393
365
|
}
|
|
394
366
|
else if (isMultiSelectInput(param.input)) {
|
|
395
367
|
throw new error_1.FirebaseError("Non-list params cannot have multi selector inputs");
|
|
396
368
|
}
|
|
397
369
|
else if (isSelectInput(param.input)) {
|
|
398
|
-
|
|
399
|
-
if (param.description) {
|
|
400
|
-
prompt += ` \n(${param.description})`;
|
|
401
|
-
}
|
|
402
|
-
prompt += "\nSelect an option with the arrow keys, and use Enter to confirm your choice. ";
|
|
403
|
-
return promptSelect(prompt, param.input, resolvedDefault, (res) => res);
|
|
370
|
+
return promptSelect(`Select a value for ${label}:`, param.input, resolvedDefault, (res) => res);
|
|
404
371
|
}
|
|
405
372
|
else if (isTextInput(param.input)) {
|
|
406
|
-
|
|
407
|
-
if (param.description) {
|
|
408
|
-
prompt += ` \n(${param.description})`;
|
|
409
|
-
}
|
|
410
|
-
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => res);
|
|
373
|
+
return promptText(`Enter a string value for ${label}:`, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => res);
|
|
411
374
|
}
|
|
412
375
|
else {
|
|
413
376
|
(0, functional_1.assertExhaustive)(param.input);
|
|
@@ -418,14 +381,9 @@ async function promptIntParam(param, resolvedDefault) {
|
|
|
418
381
|
const defaultToText = { text: {} };
|
|
419
382
|
param.input = defaultToText;
|
|
420
383
|
}
|
|
421
|
-
|
|
384
|
+
const label = param.label || param.name;
|
|
422
385
|
if (isSelectInput(param.input)) {
|
|
423
|
-
|
|
424
|
-
if (param.description) {
|
|
425
|
-
prompt += ` \n(${param.description})`;
|
|
426
|
-
}
|
|
427
|
-
prompt += "\nSelect an option with the arrow keys, and use Enter to confirm your choice. ";
|
|
428
|
-
return promptSelect(prompt, param.input, resolvedDefault, (res) => {
|
|
386
|
+
return promptSelect(`Select a value for ${label}:`, param.input, resolvedDefault, (res) => {
|
|
429
387
|
if (isNaN(+res)) {
|
|
430
388
|
return { message: `"${res}" could not be converted to a number.` };
|
|
431
389
|
}
|
|
@@ -439,11 +397,7 @@ async function promptIntParam(param, resolvedDefault) {
|
|
|
439
397
|
throw new error_1.FirebaseError("Non-list params cannot have multi selector inputs");
|
|
440
398
|
}
|
|
441
399
|
else if (isTextInput(param.input)) {
|
|
442
|
-
|
|
443
|
-
if (param.description) {
|
|
444
|
-
prompt += ` \n(${param.description})`;
|
|
445
|
-
}
|
|
446
|
-
return promptText(prompt, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
400
|
+
return promptText(`Enter an integer value for ${label}:`, param.input, resolvedDefault, param.input.text.nonEmpty, (res) => {
|
|
447
401
|
if (isNaN(+res)) {
|
|
448
402
|
return { message: `"${res}" could not be converted to a number.` };
|
|
449
403
|
}
|
|
@@ -533,6 +487,7 @@ async function promptSelect(prompt, input, resolvedDefault, converter) {
|
|
|
533
487
|
const response = await (0, prompt_1.select)({
|
|
534
488
|
default: resolvedDefault,
|
|
535
489
|
message: prompt,
|
|
490
|
+
instructions: "(Use arrow keys to navigate, and Enter to confirm your choice)",
|
|
536
491
|
choices: input.select.options.map((option) => {
|
|
537
492
|
return {
|
|
538
493
|
checked: false,
|
|
@@ -552,6 +507,7 @@ async function promptSelectMultiple(prompt, input, resolvedDefault, enforceNonEm
|
|
|
552
507
|
const response = await (0, prompt_1.checkbox)({
|
|
553
508
|
default: resolvedDefault,
|
|
554
509
|
message: prompt,
|
|
510
|
+
instructions: "(Press Space to select, and Enter to confirm your choices)",
|
|
555
511
|
choices: input.multiSelect.options.map((option) => {
|
|
556
512
|
return {
|
|
557
513
|
checked: false,
|
|
@@ -211,18 +211,18 @@ async function prepare(context, options, payload) {
|
|
|
211
211
|
.filter((e) => e.codebase === codebase || e.codebase === undefined);
|
|
212
212
|
await resolveDefaultRegionsForBuild(wantBuild, backend.of(...relevantEndpoints));
|
|
213
213
|
const parsedSecretRefs = (0, functional_1.mapObject)(secretRefs, (unparsed) => build.parseSecretRef(unparsed));
|
|
214
|
-
build.
|
|
214
|
+
await build.applyEnvSecretBindingsToBuild(wantBuild, parsedSecretRefs);
|
|
215
215
|
const { backend: wantBackend, envs: resolvedEnvs, secretRefs: resolvedSecretRefs, } = await build.resolveBackend({
|
|
216
216
|
build: wantBuild,
|
|
217
217
|
firebaseConfig,
|
|
218
218
|
userEnvs,
|
|
219
219
|
codebase,
|
|
220
220
|
nonInteractive: options.nonInteractive,
|
|
221
|
-
force: options.force,
|
|
222
221
|
isEmulator: false,
|
|
223
222
|
});
|
|
224
223
|
functionsEnv.writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt);
|
|
225
|
-
if (experiments.isEnabled("secretEnvParams")
|
|
224
|
+
if (experiments.isEnabled("secretEnvParams") &&
|
|
225
|
+
experiments.isEnabled("writeDefaultSecretBindings")) {
|
|
226
226
|
functionsEnv.writeResolvedSecretRefs(resolvedSecretRefs, secretRefs, userEnvOpt);
|
|
227
227
|
}
|
|
228
228
|
let hasEnvsFromParams = false;
|
|
@@ -543,7 +543,10 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
|
|
|
543
543
|
const prefix = (0, projectConfig_1.isKitConfig)(codebaseConfig)
|
|
544
544
|
? (0, projectConfig_1.addKitPrefix)(codebase)
|
|
545
545
|
: codebaseConfig.prefix || "";
|
|
546
|
-
build.
|
|
546
|
+
build.applyEndpointPrefix(discoveredBuild, prefix);
|
|
547
|
+
if ((0, projectConfig_1.isKitConfig)(codebaseConfig)) {
|
|
548
|
+
build.applyKitSecretRefPrefix(discoveredBuild, codebase);
|
|
549
|
+
}
|
|
547
550
|
wantBuilds[codebase] = discoveredBuild;
|
|
548
551
|
}
|
|
549
552
|
return wantBuilds;
|