firebase-tools-with-isolate 15.32.0 → 15.34.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/accountImporter.js +6 -3
- package/lib/api.js +3 -3
- package/lib/apphosting/backend.js +1 -1
- package/lib/apphosting/secrets/index.js +7 -2
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +31 -24
- package/lib/commands/apps-create.js +34 -3
- package/lib/commands/crashlytics-heapdumps-disable.js +26 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +54 -0
- package/lib/commands/crashlytics-heapdumps-status.js +32 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/functions-kits-uninstall.js +43 -21
- package/lib/commands/functions-lifecycle-list.js +5 -6
- package/lib/commands/hosting-channel-deploy.js +3 -3
- package/lib/commands/hosting-clone.js +102 -31
- package/lib/commands/hosting-disable.js +5 -1
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +7 -0
- package/lib/commands/run-services-update.js +16 -0
- package/lib/config.js +1 -0
- package/lib/crashlytics/alerts.js +122 -0
- package/lib/crashlytics/onboarding.js +71 -3
- package/lib/crashlytics/profilingManager.js +195 -0
- package/lib/crashlytics/sourcemap.js +46 -11
- package/lib/crashlytics/types.js +6 -1
- package/lib/deploy/apphosting/prepare.js +1 -0
- package/lib/deploy/auth/deploy.js +1 -1
- package/lib/deploy/auth/prepare.js +6 -7
- package/lib/deploy/firestore/prepare.js +5 -5
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/cel.js +89 -58
- package/lib/deploy/functions/functionsDeployHelper.js +10 -0
- package/lib/deploy/functions/params.js +4 -2
- package/lib/deploy/functions/prepare.js +25 -8
- package/lib/deploy/functions/release/executor.js +7 -3
- package/lib/deploy/functions/release/fabricator.js +42 -14
- package/lib/deploy/functions/release/planner.js +3 -2
- package/lib/deploy/functions/release/sourceTokenScraper.js +1 -1
- package/lib/deploy/functions/validate.js +16 -0
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/release.js +2 -2
- package/lib/deploy/index.js +5 -0
- package/lib/deploy/run/args.js +2 -0
- package/lib/deploy/run/buildEnv.js +72 -0
- package/lib/deploy/run/deploy.js +214 -0
- package/lib/deploy/run/index.js +23 -0
- package/lib/deploy/run/prepare.js +47 -0
- package/lib/deploy/run/prereqs.js +32 -0
- package/lib/deploy/run/release.js +9 -0
- package/lib/deploy/run/update.js +50 -0
- package/lib/deploy/run/util.js +73 -0
- package/lib/emulator/apphosting/serve.js +1 -1
- package/lib/emulator/auth/operations.js +8 -4
- package/lib/emulator/auth/utils.js +1 -1
- package/lib/emulator/commandUtils.js +7 -3
- package/lib/emulator/databaseEmulator.js +7 -3
- package/lib/emulator/dataconnect/pgliteServer.js +1 -1
- package/lib/emulator/dataconnectEmulator.js +1 -1
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +1 -3
- package/lib/emulator/emulatorLogger.js +2 -1
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/functionsEmulatorRuntime.js +2 -1
- package/lib/emulator/functionsEmulatorShared.js +1 -41
- package/lib/experiments.js +17 -11
- package/lib/extensions/warnings.js +48 -7
- package/lib/firestore/validator.js +1 -1
- package/lib/frameworks/next/constants.js +20 -12
- package/lib/frameworks/next/index.js +4 -23
- package/lib/frameworks/next/utils.js +28 -0
- package/lib/functions/env.js +4 -2
- package/lib/functions/projectConfig.js +10 -5
- package/lib/gcp/artifactregistry.js +20 -0
- package/lib/gcp/cloudmonitoring.js +80 -3
- package/lib/gcp/cloudsql/permissions.js +21 -32
- package/lib/gcp/cloudsql/permissionsSetup.js +6 -6
- package/lib/gcp/cloudtasks.js +15 -1
- package/lib/gcp/cloudtrace.js +38 -0
- package/lib/gcp/run.js +5 -0
- package/lib/gcp/runv2.js +32 -11
- package/lib/gcp/storage.js +9 -5
- package/lib/hosting/api.js +15 -15
- package/lib/hosting/runTags.js +1 -1
- package/lib/init/features/auth.js +46 -8
- package/lib/init/features/hosting/index.js +4 -2
- package/lib/init/features/index.js +4 -1
- package/lib/init/features/run.js +159 -0
- package/lib/init/index.js +6 -0
- package/lib/management/apps.js +4 -2
- package/lib/mcp/tools/firestore/converter.js +2 -2
- package/lib/mcp/util.js +11 -10
- package/lib/profileReport.js +12 -9
- package/lib/scopes.js +1 -3
- package/lib/streamJson.js +1 -0
- package/lib/throttler/throttler.js +1 -0
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +0 -15
- package/package.json +11 -17
- package/schema/firebase-config.json +41 -0
- package/schema/firebaserc.json +133 -0
- package/lib/mcp/resources/guides/init_data_connect.js +0 -30
- package/lib/mcp/resources/guides/init_rtdb.js +0 -30
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_LIFECYCLE_RULES = exports.DEFAULT_CORS_RULES = exports.DEFAULT_FILE_TTL_DAYS = exports.DEFAULT_BUCKET_LOCATION = exports.DEFAULT_CORS_ORIGINS = exports.HEAP_DUMP_BUCKET_PREFIX = exports.STORAGE_OBJECT_CREATOR_ROLE = exports.CRASHLYTICS_SERVICE_NAME = void 0;
|
|
4
|
+
exports.getCrashlyticsV1Client = getCrashlyticsV1Client;
|
|
5
|
+
exports.parseAndroidHashedId = parseAndroidHashedId;
|
|
6
|
+
exports.createBucketName = createBucketName;
|
|
7
|
+
exports.getCrashlyticsP4sa = getCrashlyticsP4sa;
|
|
8
|
+
exports.resolveAndroidAppId = resolveAndroidAppId;
|
|
9
|
+
exports.getProfilingManagerConfig = getProfilingManagerConfig;
|
|
10
|
+
exports.updateProfilingManagerConfig = updateProfilingManagerConfig;
|
|
11
|
+
exports.ensureHeapDumpStorageBucket = ensureHeapDumpStorageBucket;
|
|
12
|
+
exports.ensureHeapDumpP4saRole = ensureHeapDumpP4saRole;
|
|
13
|
+
exports.enableHeapDumpCollection = enableHeapDumpCollection;
|
|
14
|
+
exports.disableHeapDumpCollection = disableHeapDumpCollection;
|
|
15
|
+
const apiv2_1 = require("../apiv2");
|
|
16
|
+
const api_1 = require("../api");
|
|
17
|
+
const error_1 = require("../error");
|
|
18
|
+
const logger_1 = require("../logger");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
const utils_2 = require("./utils");
|
|
21
|
+
const storage = require("../gcp/storage");
|
|
22
|
+
const resourceManager = require("../gcp/resourceManager");
|
|
23
|
+
const serviceusage = require("../gcp/serviceusage");
|
|
24
|
+
const apps_1 = require("../management/apps");
|
|
25
|
+
function getCrashlyticsV1Client() {
|
|
26
|
+
return new apiv2_1.Client({
|
|
27
|
+
urlPrefix: (0, api_1.crashlyticsApiOrigin)(),
|
|
28
|
+
apiVersion: "v1",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.CRASHLYTICS_SERVICE_NAME = "firebasecrashlytics.googleapis.com";
|
|
32
|
+
exports.STORAGE_OBJECT_CREATOR_ROLE = "roles/storage.objectCreator";
|
|
33
|
+
exports.HEAP_DUMP_BUCKET_PREFIX = "firebasecrashlytics-heap-dumps-";
|
|
34
|
+
exports.DEFAULT_CORS_ORIGINS = ["https://console.firebase.google.com"];
|
|
35
|
+
exports.DEFAULT_BUCKET_LOCATION = "us-east1";
|
|
36
|
+
exports.DEFAULT_FILE_TTL_DAYS = 90;
|
|
37
|
+
exports.DEFAULT_CORS_RULES = [
|
|
38
|
+
{
|
|
39
|
+
origin: exports.DEFAULT_CORS_ORIGINS,
|
|
40
|
+
method: ["GET", "HEAD", "OPTIONS"],
|
|
41
|
+
responseHeader: ["Content-Type", "Access-Control-Allow-Origin", "Content-Length"],
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
exports.DEFAULT_LIFECYCLE_RULES = [
|
|
45
|
+
{
|
|
46
|
+
action: { type: "Delete" },
|
|
47
|
+
condition: { age: exports.DEFAULT_FILE_TTL_DAYS },
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
const ANDROID_APP_ID_REGEX = /^\d+:(\d+):android:([a-fA-F0-9]+)$/;
|
|
51
|
+
function parseAndroidHashedId(appId) {
|
|
52
|
+
const match = ANDROID_APP_ID_REGEX.exec(appId);
|
|
53
|
+
if (!match) {
|
|
54
|
+
throw new error_1.FirebaseError(`App ID '${appId}' is not a valid Android app ID (expected format '1:<project-number>:android:<hash>'). ` +
|
|
55
|
+
"Heap dump collection is only supported for Android apps. " +
|
|
56
|
+
"Run 'firebase apps:list ANDROID' to view valid Android app IDs for your project.");
|
|
57
|
+
}
|
|
58
|
+
return match[2].toLowerCase();
|
|
59
|
+
}
|
|
60
|
+
function createBucketName(appId) {
|
|
61
|
+
return `${exports.HEAP_DUMP_BUCKET_PREFIX}${parseAndroidHashedId(appId)}`;
|
|
62
|
+
}
|
|
63
|
+
function getCrashlyticsP4sa(projectNumber) {
|
|
64
|
+
return `service-${projectNumber}@gcp-sa-crashlytics.iam.gserviceaccount.com`;
|
|
65
|
+
}
|
|
66
|
+
async function resolveAndroidAppId(projectId, options) {
|
|
67
|
+
if (options.app) {
|
|
68
|
+
parseAndroidHashedId(options.app);
|
|
69
|
+
return options.app;
|
|
70
|
+
}
|
|
71
|
+
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANDROID);
|
|
72
|
+
if (apps.length === 0) {
|
|
73
|
+
throw new error_1.FirebaseError(`No Android apps found in project '${projectId}'. Heap dump collection is only supported for Android apps.\n` +
|
|
74
|
+
"You can register an Android app using 'firebase apps:create ANDROID <package-name>'");
|
|
75
|
+
}
|
|
76
|
+
if (apps.length === 1) {
|
|
77
|
+
return apps[0].appId;
|
|
78
|
+
}
|
|
79
|
+
if (options.nonInteractive) {
|
|
80
|
+
throw new error_1.FirebaseError(`Project '${projectId}' has multiple Android apps. Please specify an app ID with '--app <appID>'.`);
|
|
81
|
+
}
|
|
82
|
+
const selectedApp = await (0, apps_1.selectAppInteractively)(apps, apps_1.AppPlatform.ANDROID, {
|
|
83
|
+
message: "Select an Android app:",
|
|
84
|
+
});
|
|
85
|
+
return selectedApp.appId;
|
|
86
|
+
}
|
|
87
|
+
async function getProfilingManagerConfig(appId) {
|
|
88
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
89
|
+
logger_1.logger.debug(`[crashlytics] getProfilingManagerConfig called with appId: ${appId}`);
|
|
90
|
+
const response = await getCrashlyticsV1Client().request({
|
|
91
|
+
method: "GET",
|
|
92
|
+
headers: {
|
|
93
|
+
"Content-Type": "application/json",
|
|
94
|
+
},
|
|
95
|
+
path: `/projects/${projectNumber}/apps/${appId}/appconfig:profilingManager`,
|
|
96
|
+
timeout: utils_2.TIMEOUT,
|
|
97
|
+
});
|
|
98
|
+
const config = response.body?.configuration || {};
|
|
99
|
+
return {
|
|
100
|
+
gcsBucket: config.gcsBucket || "",
|
|
101
|
+
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async function updateProfilingManagerConfig(appId, config) {
|
|
105
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
106
|
+
logger_1.logger.debug(`[crashlytics] updateProfilingManagerConfig called with appId: ${appId}, config: ${JSON.stringify(config)}`);
|
|
107
|
+
await getCrashlyticsV1Client().request({
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers: {
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
},
|
|
112
|
+
path: `/projects/${projectNumber}/apps/${appId}/appconfig:profilingManager`,
|
|
113
|
+
body: {
|
|
114
|
+
projectNumber,
|
|
115
|
+
gmpAppId: appId,
|
|
116
|
+
configuration: {
|
|
117
|
+
gcsBucket: config.gcsBucket ?? "",
|
|
118
|
+
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
timeout: utils_2.TIMEOUT,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.DEFAULT_BUCKET_LOCATION) {
|
|
125
|
+
const bucketName = createBucketName(appId);
|
|
126
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
127
|
+
try {
|
|
128
|
+
const bucket = await storage.getBucket(bucketName);
|
|
129
|
+
if (bucket.projectNumber && String(bucket.projectNumber) !== projectNumber) {
|
|
130
|
+
throw new error_1.FirebaseError(`Cloud Storage bucket '${bucketName}' already exists and is owned by another project.`);
|
|
131
|
+
}
|
|
132
|
+
const patchPayload = {};
|
|
133
|
+
const hasConsoleCors = bucket.cors?.some((rule) => exports.DEFAULT_CORS_ORIGINS.every((origin) => rule.origin?.includes(origin)));
|
|
134
|
+
if (!hasConsoleCors) {
|
|
135
|
+
patchPayload.cors = [...(bucket.cors ?? []), ...exports.DEFAULT_CORS_RULES];
|
|
136
|
+
}
|
|
137
|
+
const hasDeleteLifecycle = bucket.lifecycle?.rule?.some((rule) => rule.action.type === "Delete" && rule.condition.age !== undefined);
|
|
138
|
+
if (!hasDeleteLifecycle) {
|
|
139
|
+
patchPayload.lifecycle = {
|
|
140
|
+
rule: [...(bucket.lifecycle?.rule ?? []), ...exports.DEFAULT_LIFECYCLE_RULES],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (Object.keys(patchPayload).length > 0) {
|
|
144
|
+
logger_1.logger.debug(`[crashlytics] Bucket ${bucketName} found without full configuration. Patching ${Object.keys(patchPayload).join(", ")}.`);
|
|
145
|
+
await storage.patchBucket(bucketName, patchPayload);
|
|
146
|
+
}
|
|
147
|
+
return bucketName;
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
const status = (0, error_1.getErrStatus)(err);
|
|
151
|
+
if (status !== 404) {
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
logger_1.logger.debug(`[crashlytics] Creating GCS bucket ${bucketName} in ${location}...`);
|
|
156
|
+
await storage.createBucket(projectId, {
|
|
157
|
+
name: bucketName,
|
|
158
|
+
location,
|
|
159
|
+
cors: exports.DEFAULT_CORS_RULES,
|
|
160
|
+
lifecycle: { rule: exports.DEFAULT_LIFECYCLE_RULES },
|
|
161
|
+
}, true);
|
|
162
|
+
return bucketName;
|
|
163
|
+
}
|
|
164
|
+
async function ensureHeapDumpP4saRole(projectId, projectNumber) {
|
|
165
|
+
await serviceusage.generateServiceIdentityAndPoll(projectNumber, exports.CRASHLYTICS_SERVICE_NAME, "crashlytics");
|
|
166
|
+
const p4saEmail = getCrashlyticsP4sa(projectNumber);
|
|
167
|
+
const hasRole = await resourceManager.serviceAccountHasRoles(projectId, p4saEmail, [exports.STORAGE_OBJECT_CREATOR_ROLE], true);
|
|
168
|
+
if (!hasRole) {
|
|
169
|
+
logger_1.logger.debug(`[crashlytics] Adding ${exports.STORAGE_OBJECT_CREATOR_ROLE} to ${p4saEmail}...`);
|
|
170
|
+
await resourceManager.addServiceAccountToRoles(projectId, p4saEmail, [exports.STORAGE_OBJECT_CREATOR_ROLE], true);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function enableHeapDumpCollection(projectId, appId, location = exports.DEFAULT_BUCKET_LOCATION) {
|
|
174
|
+
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
175
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Google Cloud Storage bucket...");
|
|
176
|
+
const bucketName = await ensureHeapDumpStorageBucket(projectId, appId, location);
|
|
177
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring service agent permissions...");
|
|
178
|
+
await ensureHeapDumpP4saRole(projectId, projectNumber);
|
|
179
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling Crashlytics heap dump collection...");
|
|
180
|
+
await updateProfilingManagerConfig(appId, {
|
|
181
|
+
gcsBucket: bucketName,
|
|
182
|
+
heapDumpCollectionEnabled: true,
|
|
183
|
+
});
|
|
184
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully enabled Crashlytics heap dump collection!");
|
|
185
|
+
return bucketName;
|
|
186
|
+
}
|
|
187
|
+
async function disableHeapDumpCollection(appId) {
|
|
188
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Disabling Crashlytics heap dump collection...");
|
|
189
|
+
const currentConfig = await getProfilingManagerConfig(appId);
|
|
190
|
+
await updateProfilingManagerConfig(appId, {
|
|
191
|
+
gcsBucket: currentConfig.gcsBucket,
|
|
192
|
+
heapDumpCollectionEnabled: false,
|
|
193
|
+
});
|
|
194
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully disabled Crashlytics heap dump collection!");
|
|
195
|
+
}
|
|
@@ -304,7 +304,7 @@ async function uploadMap(request, attemptsRemaining = 0) {
|
|
|
304
304
|
const tmpArchive = await (0, archiveFile_1.archiveFile)(filePath, { archivedFileName: "mapping.js.map" });
|
|
305
305
|
const appId = options.app || "";
|
|
306
306
|
const gcsFile = `${appId}-${appVersion}-${normalizeFileName(obfuscatedPath)}.zip`;
|
|
307
|
-
const uid = (0, utils_1.murmurHashV3)(
|
|
307
|
+
const uid = (0, utils_1.murmurHashV3)(obfuscatedPath);
|
|
308
308
|
const name = `projects/${projectId}/locations/global/mappingFiles/${uid}`;
|
|
309
309
|
const stream = fs.createReadStream(tmpArchive);
|
|
310
310
|
stream.on("error", (err) => {
|
|
@@ -316,15 +316,15 @@ async function uploadMap(request, attemptsRemaining = 0) {
|
|
|
316
316
|
stream,
|
|
317
317
|
}, bucketName);
|
|
318
318
|
const fileUri = `gs://${bucket}/${object}`;
|
|
319
|
-
logger_1.logger.debug(`Uploaded mapping file ${filePath} to ${fileUri}`);
|
|
319
|
+
logger_1.logger.debug(`Uploaded mapping file ${filePath} to GCS: ${fileUri}`);
|
|
320
320
|
await registerSourceMap({
|
|
321
321
|
name,
|
|
322
322
|
appId,
|
|
323
323
|
version: appVersion,
|
|
324
324
|
obfuscatedFilePath: `/${obfuscatedPath}`,
|
|
325
325
|
fileUri,
|
|
326
|
-
});
|
|
327
|
-
logger_1.logger.debug(`
|
|
326
|
+
}, options);
|
|
327
|
+
logger_1.logger.debug(`Successfully registered source map in Firebase Telemetry for /${obfuscatedPath}`);
|
|
328
328
|
return true;
|
|
329
329
|
}
|
|
330
330
|
catch (e) {
|
|
@@ -351,10 +351,45 @@ function isAlreadyExistsError(e) {
|
|
|
351
351
|
return false;
|
|
352
352
|
}
|
|
353
353
|
const message = e.message.toLowerCase();
|
|
354
|
-
const
|
|
354
|
+
const context = e.context;
|
|
355
|
+
const bodyMessage = (context?.body?.error?.message ?? "").toLowerCase();
|
|
355
356
|
return message.includes("already exists") || bodyMessage.includes("already exists");
|
|
356
357
|
}
|
|
357
|
-
async function
|
|
358
|
+
async function listAllMappingFiles(client, collectionPath) {
|
|
359
|
+
const cache = new Map();
|
|
360
|
+
let pageToken;
|
|
361
|
+
do {
|
|
362
|
+
const queryParams = {};
|
|
363
|
+
if (pageToken) {
|
|
364
|
+
queryParams.pageToken = pageToken;
|
|
365
|
+
}
|
|
366
|
+
const listResponse = await client.get(collectionPath, { queryParams });
|
|
367
|
+
for (const mappingFile of listResponse.body?.mappingFiles ?? []) {
|
|
368
|
+
if (mappingFile.obfuscatedFilePath && mappingFile.name) {
|
|
369
|
+
cache.set(mappingFile.obfuscatedFilePath, mappingFile.name);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
pageToken = listResponse.body?.nextPageToken;
|
|
373
|
+
} while (pageToken);
|
|
374
|
+
return cache;
|
|
375
|
+
}
|
|
376
|
+
function getOrListAllMappingFiles(client, collectionPath, options) {
|
|
377
|
+
if (options) {
|
|
378
|
+
options.__mappingFilesCache ?? (options.__mappingFilesCache = listAllMappingFiles(client, collectionPath).catch((err) => {
|
|
379
|
+
delete options.__mappingFilesCache;
|
|
380
|
+
throw err;
|
|
381
|
+
}));
|
|
382
|
+
return options.__mappingFilesCache;
|
|
383
|
+
}
|
|
384
|
+
return listAllMappingFiles(client, collectionPath);
|
|
385
|
+
}
|
|
386
|
+
async function findExistingSourceMapName(client, sourceMap, options) {
|
|
387
|
+
const lastSlashIndex = sourceMap.name.lastIndexOf("/");
|
|
388
|
+
const collectionPath = lastSlashIndex === -1 ? sourceMap.name : sourceMap.name.slice(0, lastSlashIndex);
|
|
389
|
+
const cache = await getOrListAllMappingFiles(client, collectionPath, options);
|
|
390
|
+
return cache.get(sourceMap.obfuscatedFilePath);
|
|
391
|
+
}
|
|
392
|
+
async function registerSourceMap(sourceMap, options) {
|
|
358
393
|
const client = new apiv2_1.Client({
|
|
359
394
|
urlPrefix: "https://firebasetelemetryadmin.googleapis.com",
|
|
360
395
|
auth: true,
|
|
@@ -362,7 +397,6 @@ async function registerSourceMap(sourceMap) {
|
|
|
362
397
|
});
|
|
363
398
|
const patchSourceMap = async () => {
|
|
364
399
|
await client.patch(sourceMap.name, sourceMap, { queryParams: { allowMissing: "true" } });
|
|
365
|
-
logger_1.logger.debug(`Registered source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry service`);
|
|
366
400
|
};
|
|
367
401
|
try {
|
|
368
402
|
await patchSourceMap();
|
|
@@ -374,16 +408,17 @@ async function registerSourceMap(sourceMap) {
|
|
|
374
408
|
}
|
|
375
409
|
if (isAlreadyExistsError(e)) {
|
|
376
410
|
try {
|
|
377
|
-
logger_1.logger.debug(`Source map ${sourceMap.obfuscatedFilePath} already exists, deleting and re-registering
|
|
378
|
-
await client
|
|
411
|
+
logger_1.logger.debug(`Source map ${sourceMap.obfuscatedFilePath} already exists, deleting and re-registering...`);
|
|
412
|
+
const existingName = (await findExistingSourceMapName(client, sourceMap, options)) ?? sourceMap.name;
|
|
413
|
+
await client.delete(existingName);
|
|
379
414
|
await patchSourceMap();
|
|
380
415
|
return;
|
|
381
416
|
}
|
|
382
417
|
catch (retryErr) {
|
|
383
|
-
throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry
|
|
418
|
+
throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry:\n${retryErr instanceof Error ? retryErr.message : String(retryErr)}`, { original: retryErr instanceof Error ? retryErr : undefined });
|
|
384
419
|
}
|
|
385
420
|
}
|
|
386
421
|
}
|
|
387
|
-
throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry
|
|
422
|
+
throw new error_1.FirebaseError(`Failed to register source map ${sourceMap.obfuscatedFilePath} with Firebase Telemetry:\n${e instanceof Error ? e.message : String(e)}`, { original: e instanceof Error ? e : undefined });
|
|
388
423
|
}
|
|
389
424
|
}
|
package/lib/crashlytics/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TimeGranularity = exports.ThreadState = exports.Signal = exports.State = exports.SessionEventType = exports.FormFactor = exports.TrackType = exports.ErrorType = void 0;
|
|
3
|
+
exports.AlertType = exports.TimeGranularity = exports.ThreadState = exports.Signal = exports.State = exports.SessionEventType = exports.FormFactor = exports.TrackType = exports.ErrorType = void 0;
|
|
4
4
|
var ErrorType;
|
|
5
5
|
(function (ErrorType) {
|
|
6
6
|
ErrorType["ERROR_TYPE_UNSPECIFIED"] = "ERROR_TYPE_UNSPECIFIED";
|
|
@@ -65,3 +65,8 @@ var TimeGranularity;
|
|
|
65
65
|
TimeGranularity["TIME_GRANULARITY_HOUR"] = "TIME_GRANULARITY_HOUR";
|
|
66
66
|
TimeGranularity["TIME_GRANULARITY_DAY"] = "TIME_GRANULARITY_DAY";
|
|
67
67
|
})(TimeGranularity || (exports.TimeGranularity = TimeGranularity = {}));
|
|
68
|
+
exports.AlertType = {
|
|
69
|
+
ALERT_TYPE_UNSPECIFIED: "ALERT_TYPE_UNSPECIFIED",
|
|
70
|
+
ALERT_TYPE_NEW_ISSUE: "ALERT_TYPE_NEW_ISSUE",
|
|
71
|
+
ALERT_TYPE_REGRESSED_ISSUE: "ALERT_TYPE_REGRESSED_ISSUE",
|
|
72
|
+
};
|
|
@@ -4,6 +4,7 @@ exports.default = default_1;
|
|
|
4
4
|
exports.injectEnvVarsFromApphostingConfig = injectEnvVarsFromApphostingConfig;
|
|
5
5
|
exports.injectAutoInitEnvVars = injectAutoInitEnvVars;
|
|
6
6
|
exports.getBackendConfigs = getBackendConfigs;
|
|
7
|
+
exports.prepareLocalBuildScratchDirectory = prepareLocalBuildScratchDirectory;
|
|
7
8
|
exports.injectAngularEnvVars = injectAngularEnvVars;
|
|
8
9
|
const crypto = require("crypto");
|
|
9
10
|
const fs = require("fs");
|
|
@@ -4,23 +4,22 @@ exports.prepare = prepare;
|
|
|
4
4
|
const apps_1 = require("../../management/apps");
|
|
5
5
|
const logger_1 = require("../../logger");
|
|
6
6
|
const projectUtils_1 = require("../../projectUtils");
|
|
7
|
+
const DEFAULT_APP_DISPLAY_NAME = "Default Web App";
|
|
7
8
|
async function prepare(context, options) {
|
|
8
9
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
9
10
|
const config = options.config.src.auth;
|
|
10
11
|
if (!config) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
|
-
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.
|
|
14
|
-
let app = apps.find((a) => a.displayName ===
|
|
15
|
-
if (!app && apps.length > 0) {
|
|
16
|
-
app = apps[0];
|
|
17
|
-
}
|
|
14
|
+
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANY);
|
|
15
|
+
let app = apps.find((a) => a.displayName === DEFAULT_APP_DISPLAY_NAME) || apps[0];
|
|
18
16
|
if (!app) {
|
|
19
|
-
logger_1.logger.info(
|
|
17
|
+
logger_1.logger.info(`No Firebase App found. Creating '${DEFAULT_APP_DISPLAY_NAME}' for Auth provisioning...`);
|
|
20
18
|
app = await (0, apps_1.createWebApp)(projectId, {
|
|
21
|
-
displayName:
|
|
19
|
+
displayName: DEFAULT_APP_DISPLAY_NAME,
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
context.auth = context.auth || {};
|
|
25
23
|
context.auth.appId = app.appId;
|
|
24
|
+
context.auth.platform = app.platform;
|
|
26
25
|
}
|
|
@@ -94,11 +94,11 @@ async function default_1(context, options) {
|
|
|
94
94
|
await (0, ensureApiEnabled_1.ensure)(context.projectId, (0, api_1.firestoreOrigin)(), "firestore");
|
|
95
95
|
if (options.only) {
|
|
96
96
|
const targets = options.only.split(",");
|
|
97
|
-
const excludeRules = targets.
|
|
98
|
-
const excludeIndexes = targets.
|
|
99
|
-
const includeRules = targets.
|
|
100
|
-
const includeIndexes = targets.
|
|
101
|
-
const onlyFirestore = targets.
|
|
97
|
+
const excludeRules = targets.includes("firestore:indexes");
|
|
98
|
+
const excludeIndexes = targets.includes("firestore:rules");
|
|
99
|
+
const includeRules = targets.includes("firestore:rules");
|
|
100
|
+
const includeIndexes = targets.includes("firestore:indexes");
|
|
101
|
+
const onlyFirestore = targets.includes("firestore");
|
|
102
102
|
context.firestoreIndexes = !excludeIndexes || includeIndexes || onlyFirestore;
|
|
103
103
|
context.firestoreRules = !excludeRules || includeRules || onlyFirestore;
|
|
104
104
|
}
|
|
@@ -94,6 +94,9 @@ async function resolveBackend(opts) {
|
|
|
94
94
|
nonInteractive: opts.nonInteractive,
|
|
95
95
|
isEmulator: opts.isEmulator,
|
|
96
96
|
});
|
|
97
|
+
if (opts.resolveRegions) {
|
|
98
|
+
await opts.resolveRegions(opts.build, paramValues);
|
|
99
|
+
}
|
|
97
100
|
return { backend: toBackend(opts.build, paramValues), envs: paramValues, secretRefs: secretRefs };
|
|
98
101
|
}
|
|
99
102
|
function envWithTypes(definedParams, rawEnvs) {
|
|
@@ -10,9 +10,10 @@ const CMP = /((?:!=)|(?:==)|(?:>=)|(?:<=)|>|<)/.source;
|
|
|
10
10
|
const identityRegexp = /{{ params\.(\S+) }}/;
|
|
11
11
|
const dualComparisonRegexp = new RegExp(/{{ params\.(\S+) CMP params\.(\S+) }}/.source.replace("CMP", CMP));
|
|
12
12
|
const comparisonRegexp = new RegExp(/{{ params\.(\S+) CMP (.+) }}/.source.replace("CMP", CMP));
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const EXPR_PREFIX = "{{ ";
|
|
14
|
+
const EXPR_SUFFIX = " }}";
|
|
15
|
+
const QUESTION_TOKEN = " ? ";
|
|
16
|
+
const COLON_TOKEN = " : ";
|
|
16
17
|
function listEquals(a, b) {
|
|
17
18
|
return a.every((item) => b.includes(item)) && b.every((item) => a.includes(item));
|
|
18
19
|
}
|
|
@@ -28,36 +29,74 @@ function isComparisonExpression(value) {
|
|
|
28
29
|
function isDualComparisonExpression(value) {
|
|
29
30
|
return dualComparisonRegexp.test(value);
|
|
30
31
|
}
|
|
31
|
-
function isTernaryExpression(value) {
|
|
32
|
-
return ternaryRegexp.test(value);
|
|
33
|
-
}
|
|
34
|
-
function isLiteralTernaryExpression(value) {
|
|
35
|
-
return literalTernaryRegexp.test(value);
|
|
36
|
-
}
|
|
37
|
-
function isDualTernaryExpression(value) {
|
|
38
|
-
return dualTernaryRegexp.test(value);
|
|
39
|
-
}
|
|
40
32
|
class ExprParseError extends error_1.FirebaseError {
|
|
41
33
|
}
|
|
42
34
|
exports.ExprParseError = ExprParseError;
|
|
35
|
+
function parseTernary(expr) {
|
|
36
|
+
if (!expr.startsWith(EXPR_PREFIX) || !expr.endsWith(EXPR_SUFFIX)) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const body = expr.slice(EXPR_PREFIX.length, -EXPR_SUFFIX.length);
|
|
40
|
+
let inQuotes = false;
|
|
41
|
+
let depth = 0;
|
|
42
|
+
let question = -1;
|
|
43
|
+
let colon = -1;
|
|
44
|
+
for (let i = 0; i < body.length; i++) {
|
|
45
|
+
if (inQuotes && body[i] === "\\") {
|
|
46
|
+
i++;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (body[i] === '"') {
|
|
50
|
+
inQuotes = !inQuotes;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (inQuotes)
|
|
54
|
+
continue;
|
|
55
|
+
if (body.startsWith(QUESTION_TOKEN, i)) {
|
|
56
|
+
if (depth === 0) {
|
|
57
|
+
question = i;
|
|
58
|
+
}
|
|
59
|
+
depth++;
|
|
60
|
+
i += QUESTION_TOKEN.length - 1;
|
|
61
|
+
}
|
|
62
|
+
else if (body.startsWith(COLON_TOKEN, i)) {
|
|
63
|
+
if (depth > 0) {
|
|
64
|
+
depth--;
|
|
65
|
+
if (depth === 0) {
|
|
66
|
+
colon = i;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
i += COLON_TOKEN.length - 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (question === -1) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (colon === -1) {
|
|
77
|
+
throw new ExprParseError(`Malformed CEL ternary expression '${expr}'`);
|
|
78
|
+
}
|
|
79
|
+
const condition = body.slice(0, question).trim();
|
|
80
|
+
const ifTrue = body.slice(question + QUESTION_TOKEN.length, colon).trim();
|
|
81
|
+
const ifFalse = body.slice(colon + COLON_TOKEN.length).trim();
|
|
82
|
+
if (!condition || !ifTrue || !ifFalse) {
|
|
83
|
+
throw new ExprParseError(`Malformed CEL ternary expression '${expr}'`);
|
|
84
|
+
}
|
|
85
|
+
return { condition, ifTrue, ifFalse };
|
|
86
|
+
}
|
|
43
87
|
function resolveExpression(wantType, expr, params) {
|
|
44
88
|
expr = preprocessLists(wantType, expr, params);
|
|
45
89
|
if (isIdentityExpression(expr)) {
|
|
46
90
|
return resolveIdentity(wantType, expr, params);
|
|
47
91
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
else if (isLiteralTernaryExpression(expr)) {
|
|
52
|
-
return resolveLiteralTernary(wantType, expr, params);
|
|
92
|
+
const ternary = parseTernary(expr);
|
|
93
|
+
if (ternary) {
|
|
94
|
+
return resolveTernary({ wantType, expr, parts: ternary, params });
|
|
53
95
|
}
|
|
54
|
-
else if (
|
|
55
|
-
return resolveTernary(wantType, expr, params);
|
|
56
|
-
}
|
|
57
|
-
else if (isDualComparisonExpression(expr)) {
|
|
96
|
+
else if (wantType === "boolean" && isDualComparisonExpression(expr)) {
|
|
58
97
|
return resolveDualComparison(expr, params);
|
|
59
98
|
}
|
|
60
|
-
else if (isComparisonExpression(expr)) {
|
|
99
|
+
else if (wantType === "boolean" && isComparisonExpression(expr)) {
|
|
61
100
|
return resolveComparison(expr, params);
|
|
62
101
|
}
|
|
63
102
|
else {
|
|
@@ -261,53 +300,45 @@ function resolveDualComparison(expr, params) {
|
|
|
261
300
|
throw new ExprParseError(`could not infer type of param ${lhsName} used in comparison operation`);
|
|
262
301
|
}
|
|
263
302
|
}
|
|
264
|
-
function resolveTernary(
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
return resolveParamListOrLiteral(wantType, match[5], params);
|
|
276
|
-
}
|
|
303
|
+
function resolveTernary(options) {
|
|
304
|
+
const { wantType, expr, parts, params } = options;
|
|
305
|
+
const isTrue = resolveTernaryCondition(expr, parts.condition, params);
|
|
306
|
+
return resolveTernaryBranch({
|
|
307
|
+
wantType,
|
|
308
|
+
expr,
|
|
309
|
+
branch: isTrue ? parts.ifTrue : parts.ifFalse,
|
|
310
|
+
params,
|
|
311
|
+
});
|
|
277
312
|
}
|
|
278
|
-
function
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
|
|
313
|
+
function resolveTernaryCondition(expr, condition, params) {
|
|
314
|
+
const conditionExpr = `${EXPR_PREFIX}${condition}${EXPR_SUFFIX}`;
|
|
315
|
+
if (isDualComparisonExpression(conditionExpr)) {
|
|
316
|
+
return resolveDualComparison(conditionExpr, params);
|
|
282
317
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
if (isTrue) {
|
|
286
|
-
return resolveParamListOrLiteral(wantType, match[4], params);
|
|
318
|
+
else if (isComparisonExpression(conditionExpr)) {
|
|
319
|
+
return resolveComparison(conditionExpr, params);
|
|
287
320
|
}
|
|
288
|
-
|
|
289
|
-
return resolveParamListOrLiteral(wantType, match[5], params);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function resolveLiteralTernary(wantType, expr, params) {
|
|
293
|
-
const match = literalTernaryRegexp.exec(expr);
|
|
321
|
+
const match = identityRegexp.exec(conditionExpr);
|
|
294
322
|
if (!match) {
|
|
295
|
-
throw new ExprParseError(
|
|
323
|
+
throw new ExprParseError(`CEL ternary expression '${expr}' is conditioned on an unsupported form`);
|
|
296
324
|
}
|
|
297
325
|
const paramName = match[1];
|
|
298
|
-
const paramValue = params[
|
|
326
|
+
const paramValue = params[paramName];
|
|
299
327
|
if (!paramValue) {
|
|
300
|
-
throw new ExprParseError(
|
|
328
|
+
throw new ExprParseError(`CEL ternary expression '${expr}' references missing param ${paramName}`);
|
|
301
329
|
}
|
|
302
330
|
if (!paramValue.legalBoolean) {
|
|
303
|
-
throw new ExprParseError(
|
|
331
|
+
throw new ExprParseError(`CEL ternary expression '${expr}' is conditional on non-boolean param ${paramName}`);
|
|
304
332
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
333
|
+
return paramValue.asBoolean();
|
|
334
|
+
}
|
|
335
|
+
function resolveTernaryBranch(options) {
|
|
336
|
+
const { wantType, expr, branch, params } = options;
|
|
337
|
+
const nested = parseTernary(`${EXPR_PREFIX}${branch}${EXPR_SUFFIX}`);
|
|
338
|
+
if (nested) {
|
|
339
|
+
return resolveTernary({ wantType, expr, parts: nested, params });
|
|
310
340
|
}
|
|
341
|
+
return resolveParamListOrLiteral(wantType, branch, params);
|
|
311
342
|
}
|
|
312
343
|
function resolveParamListOrLiteral(wantType, field, params) {
|
|
313
344
|
const match = paramRegexp.exec(field);
|
|
@@ -7,6 +7,7 @@ exports.parseFunctionSelector = parseFunctionSelector;
|
|
|
7
7
|
exports.getEndpointFilters = getEndpointFilters;
|
|
8
8
|
exports.getHumanFriendlyPlatformName = getHumanFriendlyPlatformName;
|
|
9
9
|
exports.getFunctionLabel = getFunctionLabel;
|
|
10
|
+
exports.generationDowngradeMessage = generationDowngradeMessage;
|
|
10
11
|
exports.targetCodebases = targetCodebases;
|
|
11
12
|
exports.groupEndpointsByCodebase = groupEndpointsByCodebase;
|
|
12
13
|
exports.isCodebaseFiltered = isCodebaseFiltered;
|
|
@@ -101,6 +102,15 @@ function getFunctionLabel(fn) {
|
|
|
101
102
|
}
|
|
102
103
|
return id;
|
|
103
104
|
}
|
|
105
|
+
function generationDowngradeMessage(want, have) {
|
|
106
|
+
if (want.platform !== "gcfv1" || have.platform === "gcfv1") {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const from = have.platform === "gcfv2" ? "GCFv2" : "Cloud Run";
|
|
110
|
+
return (`[${getFunctionLabel(want)}] Functions cannot be downgraded from ${from} to GCFv1. ` +
|
|
111
|
+
`To recreate it as GCFv1, delete the existing function first: ` +
|
|
112
|
+
`firebase functions:delete ${want.id} --region ${want.region}`);
|
|
113
|
+
}
|
|
104
114
|
function targetCodebases(config, filters) {
|
|
105
115
|
const codebasesFromConfig = getCodebasesFromConfig(config);
|
|
106
116
|
if (!filters) {
|
|
@@ -417,7 +417,7 @@ async function promptIntParam(param, resolvedDefault) {
|
|
|
417
417
|
async function promptResourceString(prompt, input, projectId, resolvedDefault) {
|
|
418
418
|
const notFound = new error_1.FirebaseError(`No instances of ${input.resource.type} found.`);
|
|
419
419
|
switch (input.resource.type) {
|
|
420
|
-
case "storage.googleapis.com/Bucket":
|
|
420
|
+
case "storage.googleapis.com/Bucket": {
|
|
421
421
|
const buckets = (await (0, storage_1.listBuckets)(projectId)).map((b) => b.name);
|
|
422
422
|
if (buckets.length === 0) {
|
|
423
423
|
throw notFound;
|
|
@@ -430,6 +430,7 @@ async function promptResourceString(prompt, input, projectId, resolvedDefault) {
|
|
|
430
430
|
},
|
|
431
431
|
};
|
|
432
432
|
return promptSelect(prompt, forgedInput, resolvedDefault, (res) => res);
|
|
433
|
+
}
|
|
433
434
|
default:
|
|
434
435
|
logger_1.logger.warn(`Warning: unknown resource type ${input.resource.type}; defaulting to raw text input...`);
|
|
435
436
|
return promptText(prompt, { text: {} }, resolvedDefault, true, (res) => res);
|
|
@@ -438,7 +439,7 @@ async function promptResourceString(prompt, input, projectId, resolvedDefault) {
|
|
|
438
439
|
async function promptResourceStrings(prompt, input, projectId, enforceNonEmpty) {
|
|
439
440
|
const notFound = new error_1.FirebaseError(`No instances of ${input.resource.type} found.`);
|
|
440
441
|
switch (input.resource.type) {
|
|
441
|
-
case "storage.googleapis.com/Bucket":
|
|
442
|
+
case "storage.googleapis.com/Bucket": {
|
|
442
443
|
const buckets = (await (0, storage_1.listBuckets)(projectId)).map((b) => b.name);
|
|
443
444
|
if (buckets.length === 0) {
|
|
444
445
|
throw notFound;
|
|
@@ -451,6 +452,7 @@ async function promptResourceStrings(prompt, input, projectId, enforceNonEmpty)
|
|
|
451
452
|
},
|
|
452
453
|
};
|
|
453
454
|
return promptSelectMultiple(prompt, forgedInput, undefined, enforceNonEmpty, (res) => res);
|
|
455
|
+
}
|
|
454
456
|
default:
|
|
455
457
|
logger_1.logger.warn(`Warning: unknown resource type ${input.resource.type}; defaulting to raw text input...`);
|
|
456
458
|
return promptText(prompt, { text: {} }, undefined, enforceNonEmpty, (res) => res.split(","));
|