firebase-tools 15.34.2 → 15.35.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/api.js +2 -4
- package/lib/apphosting/constants.js +1 -4
- package/lib/apphosting/utils.js +0 -26
- package/lib/commands/{crashlytics-onboard-web.js → crashlytics-setup.js} +5 -5
- package/lib/commands/crashlytics-sourcemap-upload.js +4 -0
- package/lib/commands/emulators-start.js +2 -2
- package/lib/commands/index.js +3 -2
- package/lib/commands/run-services-get.js +19 -0
- package/lib/commands/run-services-list.js +11 -0
- package/lib/crashlytics/alerts.js +1 -0
- package/lib/crashlytics/firebasetelemetry.js +5 -3
- package/lib/crashlytics/onboarding.js +8 -7
- package/lib/crashlytics/reports.js +46 -17
- package/lib/crashlytics/sourcemap.js +19 -5
- package/lib/dataconnect/dataplaneClient.js +0 -10
- package/lib/deploy/apphosting/deploy.js +20 -41
- package/lib/deploy/apphosting/localBuild.js +49 -0
- package/lib/deploy/apphosting/prepare.js +12 -25
- package/lib/deploy/apphosting/release.js +1 -1
- package/lib/deploy/apphosting/util.js +27 -4
- package/lib/deploy/functions/containerCleaner.js +1 -142
- package/lib/deploy/functions/functionsDeployHelper.js +0 -4
- package/lib/deploy/functions/validate.js +1 -1
- package/lib/deploy/run/deploy.js +26 -43
- package/lib/deploy/run/get.js +30 -0
- package/lib/deploy/run/list.js +38 -0
- package/lib/deploy/run/prereqs.js +0 -3
- package/lib/deploy/run/util.js +9 -0
- package/lib/emulator/commandUtils.js +105 -23
- package/lib/emulator/dataconnect/pgliteServer.js +1 -0
- package/lib/emulator/downloadableEmulators.js +43 -5
- package/lib/emulator/storage/rules/runtime.js +1 -0
- package/lib/extensions/extensionsApi.js +0 -8
- package/lib/extensions/extensionsHelper.js +1 -22
- package/lib/extensions/secretsUtils.js +0 -24
- package/lib/frameworks/next/utils.js +0 -11
- package/lib/fsAsync.js +34 -20
- package/lib/functions/kits/install.js +37 -337
- package/lib/functions/kits/sources/directory.js +59 -0
- package/lib/functions/kits/sources/index.js +19 -0
- package/lib/functions/kits/sources/npm.js +274 -0
- package/lib/functions/kits/sources/types.js +12 -0
- package/lib/gcp/artifactregistry.js +0 -5
- package/lib/gcp/iam.js +0 -4
- package/lib/gcp/pubsub.js +0 -14
- package/lib/gcp/storage.js +2 -1
- package/lib/init/features/run.js +3 -7
- package/lib/mcp/resources/guides/crashlytics_reports.js +33 -71
- package/lib/mcp/tools/crashlytics/reports.js +25 -30
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/lib/deploy/hosting/args.js +0 -2
|
@@ -9,7 +9,11 @@ exports.parseInspectionPort = parseInspectionPort;
|
|
|
9
9
|
exports.setExportOnExitOptions = setExportOnExitOptions;
|
|
10
10
|
exports.shutdownWhenKilled = shutdownWhenKilled;
|
|
11
11
|
exports.getListenOverview = getListenOverview;
|
|
12
|
+
exports.getListenSuffix = getListenSuffix;
|
|
12
13
|
exports.emulatorExec = emulatorExec;
|
|
14
|
+
exports.resetJavaBinaryForTesting = resetJavaBinaryForTesting;
|
|
15
|
+
exports.hasResolvedJavaBinary = hasResolvedJavaBinary;
|
|
16
|
+
exports.getJavaBinary = getJavaBinary;
|
|
13
17
|
exports.checkJavaMajorVersion = checkJavaMajorVersion;
|
|
14
18
|
const clc = require("colorette");
|
|
15
19
|
const childProcess = require("child_process");
|
|
@@ -289,6 +293,14 @@ function getListenOverview(emulator) {
|
|
|
289
293
|
return `${info.host}:${info.port}`;
|
|
290
294
|
}
|
|
291
295
|
}
|
|
296
|
+
function getListenSuffix(emulator) {
|
|
297
|
+
const info = registry_1.EmulatorRegistry.get(emulator)?.getInfo();
|
|
298
|
+
const listen = getListenOverview(emulator);
|
|
299
|
+
if (!info || !listen || utils.connectableHostname(info.host) === info.host) {
|
|
300
|
+
return "";
|
|
301
|
+
}
|
|
302
|
+
return ` (listening on ${listen})`;
|
|
303
|
+
}
|
|
292
304
|
async function emulatorExec(script, options) {
|
|
293
305
|
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
294
306
|
const extraEnv = {};
|
|
@@ -325,13 +337,50 @@ async function emulatorExec(script, options) {
|
|
|
325
337
|
}
|
|
326
338
|
}
|
|
327
339
|
const JAVA_VERSION_REGEX = /version "([1-9][0-9]*)/;
|
|
340
|
+
const JAVA_HOME_REGEX = /^\s*java\.home\s*=\s*(.+)$/m;
|
|
328
341
|
const JAVA_HINT = "Please make sure Java is installed and on your system PATH.";
|
|
329
|
-
|
|
342
|
+
let resolvedJavaBinary;
|
|
343
|
+
function resetJavaBinaryForTesting() {
|
|
344
|
+
resolvedJavaBinary = undefined;
|
|
345
|
+
}
|
|
346
|
+
function hasResolvedJavaBinary() {
|
|
347
|
+
return Boolean(resolvedJavaBinary);
|
|
348
|
+
}
|
|
349
|
+
function getJavaFromJavaHome() {
|
|
350
|
+
const rawJavaHome = process.env.JAVA_HOME?.replace(/"/g, "").trim();
|
|
351
|
+
if (!rawJavaHome) {
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
const javaBinName = utils.IS_WINDOWS ? "java.exe" : "java";
|
|
355
|
+
const candidate = path.join(rawJavaHome, "bin", javaBinName);
|
|
356
|
+
return fsutils.fileExistsSync(candidate) ? candidate : undefined;
|
|
357
|
+
}
|
|
358
|
+
function getJavaBinary() {
|
|
359
|
+
if (!utils.IS_WINDOWS) {
|
|
360
|
+
return "java";
|
|
361
|
+
}
|
|
362
|
+
if (resolvedJavaBinary) {
|
|
363
|
+
return resolvedJavaBinary;
|
|
364
|
+
}
|
|
365
|
+
return getJavaFromJavaHome() || "java";
|
|
366
|
+
}
|
|
367
|
+
function spawnJavaVersionProcess(binary) {
|
|
368
|
+
const args = utils.IS_WINDOWS
|
|
369
|
+
? [
|
|
370
|
+
"-Duser.language=en",
|
|
371
|
+
"-Dfile.encoding=UTF-8",
|
|
372
|
+
"-Dstdout.encoding=UTF-8",
|
|
373
|
+
"-Dstderr.encoding=UTF-8",
|
|
374
|
+
"-XshowSettings:properties",
|
|
375
|
+
"-version",
|
|
376
|
+
]
|
|
377
|
+
: ["-Duser.language=en", "-Dfile.encoding=UTF-8", "-version"];
|
|
330
378
|
return new Promise((resolve, reject) => {
|
|
331
379
|
let child;
|
|
332
380
|
try {
|
|
333
|
-
child = childProcess.spawn(
|
|
334
|
-
stdio: ["
|
|
381
|
+
child = childProcess.spawn(binary, args, {
|
|
382
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
383
|
+
windowsHide: true,
|
|
335
384
|
});
|
|
336
385
|
}
|
|
337
386
|
catch (err) {
|
|
@@ -343,12 +392,16 @@ async function checkJavaMajorVersion() {
|
|
|
343
392
|
let error = "";
|
|
344
393
|
child.stdout?.on("data", (data) => {
|
|
345
394
|
const str = data.toString("utf8");
|
|
346
|
-
|
|
395
|
+
if (!utils.IS_WINDOWS) {
|
|
396
|
+
logger_1.logger.debug(str);
|
|
397
|
+
}
|
|
347
398
|
output += str;
|
|
348
399
|
});
|
|
349
400
|
child.stderr?.on("data", (data) => {
|
|
350
401
|
const str = data.toString("utf8");
|
|
351
|
-
|
|
402
|
+
if (!utils.IS_WINDOWS) {
|
|
403
|
+
logger_1.logger.debug(str);
|
|
404
|
+
}
|
|
352
405
|
error += str;
|
|
353
406
|
});
|
|
354
407
|
child.once("error", (err) => {
|
|
@@ -367,29 +420,58 @@ async function checkJavaMajorVersion() {
|
|
|
367
420
|
resolve(`${output}\n${error}`);
|
|
368
421
|
}
|
|
369
422
|
});
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
async function checkJavaMajorVersion() {
|
|
426
|
+
let output;
|
|
427
|
+
try {
|
|
428
|
+
output = await spawnJavaVersionProcess("java");
|
|
429
|
+
}
|
|
430
|
+
catch (err) {
|
|
431
|
+
const javaHomeBin = utils.IS_WINDOWS ? getJavaFromJavaHome() : undefined;
|
|
432
|
+
if (!javaHomeBin) {
|
|
433
|
+
throw err;
|
|
434
|
+
}
|
|
435
|
+
output = await spawnJavaVersionProcess(javaHomeBin);
|
|
436
|
+
}
|
|
437
|
+
if (utils.IS_WINDOWS) {
|
|
438
|
+
const javaHomeMatch = JAVA_HOME_REGEX.exec(output);
|
|
439
|
+
if (javaHomeMatch) {
|
|
440
|
+
const javaHome = javaHomeMatch[1].trim();
|
|
441
|
+
const candidate = path.join(javaHome, "bin", "java.exe");
|
|
442
|
+
if (fsutils.fileExistsSync(candidate)) {
|
|
443
|
+
resolvedJavaBinary = candidate;
|
|
444
|
+
logger_1.logger.debug(`Resolved Java binary from java.home: ${resolvedJavaBinary}`);
|
|
381
445
|
}
|
|
382
446
|
}
|
|
383
447
|
else {
|
|
384
|
-
|
|
385
|
-
|
|
448
|
+
const fallback = getJavaFromJavaHome();
|
|
449
|
+
if (fallback) {
|
|
450
|
+
resolvedJavaBinary = fallback;
|
|
451
|
+
}
|
|
386
452
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
453
|
+
}
|
|
454
|
+
let versionInt = -1;
|
|
455
|
+
const match = JAVA_VERSION_REGEX.exec(output);
|
|
456
|
+
if (match) {
|
|
457
|
+
const version = match[1];
|
|
458
|
+
versionInt = parseInt(version, 10);
|
|
459
|
+
if (!versionInt) {
|
|
460
|
+
utils.logLabeledWarning("emulators", `Failed to parse Java version. Got "${match[0]}".`, "warn");
|
|
390
461
|
}
|
|
391
|
-
|
|
392
|
-
|
|
462
|
+
else {
|
|
463
|
+
logger_1.logger.debug(`Parsed Java major version: ${versionInt}`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
logger_1.logger.debug("java -version outputs:", output);
|
|
468
|
+
logger_1.logger.warn(`Failed to parse Java version.`);
|
|
469
|
+
}
|
|
470
|
+
const session = (0, track_1.emulatorSession)();
|
|
471
|
+
if (session) {
|
|
472
|
+
session.javaMajorVersion = versionInt;
|
|
473
|
+
}
|
|
474
|
+
return versionInt;
|
|
393
475
|
}
|
|
394
476
|
exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = 21;
|
|
395
477
|
exports.JAVA_DEPRECATION_WARNING = "firebase-tools no longer supports Java version before 21. " +
|
|
@@ -194,6 +194,7 @@ class PostgresServer {
|
|
|
194
194
|
}
|
|
195
195
|
exports.PostgresServer = PostgresServer;
|
|
196
196
|
async function fromNodeSocket(socket, options) {
|
|
197
|
+
socket.setNoDelay(true);
|
|
197
198
|
const rs = node_stream_1.Readable.toWeb(socket);
|
|
198
199
|
const ws = node_stream_1.Writable.toWeb(socket);
|
|
199
200
|
const opts = options
|
|
@@ -25,6 +25,7 @@ const path = require("path");
|
|
|
25
25
|
const os = require("os");
|
|
26
26
|
const registry_1 = require("./registry");
|
|
27
27
|
const download_1 = require("../emulator/download");
|
|
28
|
+
const commandUtils_1 = require("./commandUtils");
|
|
28
29
|
const experiments = require("../experiments");
|
|
29
30
|
const process = require("process");
|
|
30
31
|
const emulatorUpdateDetails = require("./downloadableEmulatorInfo.json");
|
|
@@ -252,6 +253,14 @@ function getExecPath(name) {
|
|
|
252
253
|
const details = getDownloadDetails(name);
|
|
253
254
|
return details.binaryPath || details.downloadPath;
|
|
254
255
|
}
|
|
256
|
+
function getPubsubJarPath() {
|
|
257
|
+
const details = getDownloadDetails(types_1.Emulators.PUBSUB);
|
|
258
|
+
return path.join(details.unzipDir || "", "pubsub-emulator", "lib", `cloud-pubsub-emulator-${details.version}-all.jar`);
|
|
259
|
+
}
|
|
260
|
+
function splitEnvOpts(value) {
|
|
261
|
+
const trimmed = value?.trim();
|
|
262
|
+
return trimmed ? trimmed.split(/\s+/) : [];
|
|
263
|
+
}
|
|
255
264
|
function getLogFileName(name) {
|
|
256
265
|
return `${name}-debug.log`;
|
|
257
266
|
}
|
|
@@ -261,7 +270,16 @@ function _getCommand(emulator, args) {
|
|
|
261
270
|
if (!args.port) {
|
|
262
271
|
args.port = defaultPort;
|
|
263
272
|
}
|
|
264
|
-
const
|
|
273
|
+
const useDirectPubsubJarOnWindows = emulator === types_1.Emulators.PUBSUB && utils.IS_WINDOWS && !process.env.PUBSUB_EMULATOR_BINARY_PATH;
|
|
274
|
+
const cmdLineArgs = useDirectPubsubJarOnWindows
|
|
275
|
+
? [
|
|
276
|
+
"-Duser.language=en",
|
|
277
|
+
...splitEnvOpts(process.env.JAVA_OPTS),
|
|
278
|
+
...splitEnvOpts(process.env.CLOUD_PUBSUB_EMULATOR_OPTS),
|
|
279
|
+
"-jar",
|
|
280
|
+
getPubsubJarPath(),
|
|
281
|
+
]
|
|
282
|
+
: baseCmd.args.slice();
|
|
265
283
|
if (baseCmd.binary === "java" &&
|
|
266
284
|
utils.isRunningInWSL() &&
|
|
267
285
|
(!args.host || !args.host.includes(":"))) {
|
|
@@ -286,12 +304,19 @@ function _getCommand(emulator, args) {
|
|
|
286
304
|
cmdLineArgs.push(argKey, argVal);
|
|
287
305
|
}
|
|
288
306
|
});
|
|
307
|
+
let binary = baseCmd.binary;
|
|
308
|
+
if (baseCmd.binary === "java" || useDirectPubsubJarOnWindows) {
|
|
309
|
+
binary = (0, commandUtils_1.getJavaBinary)();
|
|
310
|
+
}
|
|
311
|
+
else if (emulator === types_1.Emulators.PUBSUB && process.env.PUBSUB_EMULATOR_BINARY_PATH) {
|
|
312
|
+
binary = getExecPath(types_1.Emulators.PUBSUB);
|
|
313
|
+
}
|
|
289
314
|
return {
|
|
290
|
-
binary
|
|
315
|
+
binary,
|
|
291
316
|
args: cmdLineArgs,
|
|
292
317
|
optionalArgs: baseCmd.optionalArgs,
|
|
293
318
|
joinArgs: baseCmd.joinArgs,
|
|
294
|
-
shell: baseCmd.shell,
|
|
319
|
+
shell: useDirectPubsubJarOnWindows ? false : baseCmd.shell,
|
|
295
320
|
port: args.port,
|
|
296
321
|
};
|
|
297
322
|
}
|
|
@@ -307,7 +332,12 @@ async function _fatal(emulator, errorMsg) {
|
|
|
307
332
|
}
|
|
308
333
|
async function handleEmulatorProcessError(emulator, err, port) {
|
|
309
334
|
const description = constants_1.Constants.description(emulator);
|
|
310
|
-
|
|
335
|
+
const isJavaBinaryError = err.path === "java" ||
|
|
336
|
+
path
|
|
337
|
+
.basename(String(err.path || ""))
|
|
338
|
+
.replace(/\.exe$/i, "")
|
|
339
|
+
.toLowerCase() === "java";
|
|
340
|
+
if (isJavaBinaryError && err.code === "ENOENT") {
|
|
311
341
|
await _fatal(emulator, `${description} has exited because java is not installed, you can install it from https://openjdk.java.net/install/`);
|
|
312
342
|
}
|
|
313
343
|
else if (err.code === "EADDRINUSE") {
|
|
@@ -332,7 +362,7 @@ async function _runBinary(emulator, command, extraEnv) {
|
|
|
332
362
|
const opts = {
|
|
333
363
|
env: { ...process.env, ...extraEnv },
|
|
334
364
|
detached: true,
|
|
335
|
-
stdio: ["
|
|
365
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
336
366
|
};
|
|
337
367
|
if (command.shell && utils.IS_WINDOWS) {
|
|
338
368
|
opts.shell = true;
|
|
@@ -454,6 +484,14 @@ async function start(targetName, args, extraEnv = {}) {
|
|
|
454
484
|
throw new error_1.FirebaseError("emulator not found");
|
|
455
485
|
}
|
|
456
486
|
}
|
|
487
|
+
if (targetName === types_1.Emulators.PUBSUB &&
|
|
488
|
+
utils.IS_WINDOWS &&
|
|
489
|
+
!process.env.PUBSUB_EMULATOR_BINARY_PATH &&
|
|
490
|
+
!(0, commandUtils_1.hasResolvedJavaBinary)()) {
|
|
491
|
+
await (0, commandUtils_1.checkJavaMajorVersion)().catch((err) => {
|
|
492
|
+
logger.log("DEBUG", `Failed to resolve Java binary for Pub/Sub emulator: ${String(err)}`);
|
|
493
|
+
});
|
|
494
|
+
}
|
|
457
495
|
const command = _getCommand(targetName, args);
|
|
458
496
|
logger.log("DEBUG", `Starting ${constants_1.Constants.description(targetName)} with command ${JSON.stringify(command)}`);
|
|
459
497
|
return _runBinary(emulator, command, extraEnv);
|
|
@@ -93,6 +93,7 @@ class StorageRulesRuntime {
|
|
|
93
93
|
const command = (0, downloadableEmulators_1._getCommand)(types_2.Emulators.STORAGE, {});
|
|
94
94
|
this._childprocess = (0, cross_spawn_1.spawn)(command.binary, command.args, {
|
|
95
95
|
stdio: ["pipe", "pipe", "pipe"],
|
|
96
|
+
windowsHide: true,
|
|
96
97
|
});
|
|
97
98
|
this._childprocess.on("exit", () => {
|
|
98
99
|
this._alive = false;
|
|
@@ -9,7 +9,6 @@ exports.updateInstance = updateInstance;
|
|
|
9
9
|
exports.updateInstanceFromRegistry = updateInstanceFromRegistry;
|
|
10
10
|
exports.populateSpec = populateSpec;
|
|
11
11
|
exports.createSource = createSource;
|
|
12
|
-
exports.getSource = getSource;
|
|
13
12
|
exports.getExtensionVersion = getExtensionVersion;
|
|
14
13
|
exports.listExtensions = listExtensions;
|
|
15
14
|
exports.listExtensionVersions = listExtensionVersions;
|
|
@@ -263,13 +262,6 @@ async function createSource(projectId, packageUri, extensionRoot) {
|
|
|
263
262
|
}
|
|
264
263
|
return pollRes;
|
|
265
264
|
}
|
|
266
|
-
async function getSource(sourceName) {
|
|
267
|
-
const res = await extensionsApiClient.get(`/${sourceName}`);
|
|
268
|
-
if (res.body.spec) {
|
|
269
|
-
populateSpec(res.body.spec);
|
|
270
|
-
}
|
|
271
|
-
return res.body;
|
|
272
|
-
}
|
|
273
265
|
async function getExtensionVersion(extensionVersionRef) {
|
|
274
266
|
const ref = refs.parse(extensionVersionRef);
|
|
275
267
|
if (!ref.version) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resourceTypeToNiceName = exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.
|
|
3
|
+
exports.resourceTypeToNiceName = exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
|
|
4
4
|
exports.getDBInstanceFromURL = getDBInstanceFromURL;
|
|
5
5
|
exports.getFirebaseProjectParams = getFirebaseProjectParams;
|
|
6
6
|
exports.substituteParams = substituteParams;
|
|
@@ -10,7 +10,6 @@ exports.validateSpec = validateSpec;
|
|
|
10
10
|
exports.promptForValidInstanceId = promptForValidInstanceId;
|
|
11
11
|
exports.promptForValidRepoURI = promptForValidRepoURI;
|
|
12
12
|
exports.promptForExtensionRoot = promptForExtensionRoot;
|
|
13
|
-
exports.checkExtensionsApiEnabled = checkExtensionsApiEnabled;
|
|
14
13
|
exports.ensureExtensionsApiEnabled = ensureExtensionsApiEnabled;
|
|
15
14
|
exports.ensureExtensionsPublisherApiEnabled = ensureExtensionsPublisherApiEnabled;
|
|
16
15
|
exports.getNextVersionByStage = getNextVersionByStage;
|
|
@@ -21,7 +20,6 @@ exports.getMissingPublisherError = getMissingPublisherError;
|
|
|
21
20
|
exports.createSourceFromLocation = createSourceFromLocation;
|
|
22
21
|
exports.getPublisherProjectFromName = getPublisherProjectFromName;
|
|
23
22
|
exports.displayReleaseNotes = displayReleaseNotes;
|
|
24
|
-
exports.promptForRepeatInstance = promptForRepeatInstance;
|
|
25
23
|
exports.isUrlPath = isUrlPath;
|
|
26
24
|
exports.isLocalPath = isLocalPath;
|
|
27
25
|
exports.isLocalOrURLPath = isLocalOrURLPath;
|
|
@@ -77,7 +75,6 @@ var SourceOrigin;
|
|
|
77
75
|
})(SourceOrigin || (exports.SourceOrigin = SourceOrigin = {}));
|
|
78
76
|
exports.logPrefix = "extensions";
|
|
79
77
|
const VALID_LICENSES = ["apache-2.0"];
|
|
80
|
-
exports.URL_REGEX = /^https:/;
|
|
81
78
|
exports.EXTENSIONS_BUCKET_NAME = (0, utils_1.envOverride)("FIREBASE_EXTENSIONS_UPLOAD_BUCKET", "firebase-ext-eap-uploads");
|
|
82
79
|
exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = {
|
|
83
80
|
PROJECT_ID: "project-id",
|
|
@@ -348,13 +345,6 @@ async function promptForReleaseStage(args) {
|
|
|
348
345
|
}
|
|
349
346
|
return stage;
|
|
350
347
|
}
|
|
351
|
-
async function checkExtensionsApiEnabled(options) {
|
|
352
|
-
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
353
|
-
if (!projectId) {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
return await (0, ensureApiEnabled_1.check)(projectId, (0, api_1.extensionsOrigin)(), "extensions", options.markdown);
|
|
357
|
-
}
|
|
358
348
|
async function ensureExtensionsApiEnabled(options) {
|
|
359
349
|
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
360
350
|
if (!projectId) {
|
|
@@ -759,17 +749,6 @@ function displayReleaseNotes(args) {
|
|
|
759
749
|
`Once an extension version is uploaded, it becomes installable by other users and cannot be changed. If you wish to make changes after uploading, you will need to upload a new version.\n`;
|
|
760
750
|
logger_1.logger.info(message);
|
|
761
751
|
}
|
|
762
|
-
async function promptForRepeatInstance(projectName, extensionName) {
|
|
763
|
-
const message = `An extension with the ID '${clc.bold(extensionName)}' already exists in the project '${clc.bold(projectName)}'. What would you like to do?`;
|
|
764
|
-
return await (0, prompt_1.select)({
|
|
765
|
-
message,
|
|
766
|
-
choices: [
|
|
767
|
-
{ name: "Update or reconfigure the existing instance", value: "updateExisting" },
|
|
768
|
-
{ name: "Install a new instance with a different ID", value: "installNew" },
|
|
769
|
-
{ name: "Cancel extension installation", value: "cancel" },
|
|
770
|
-
],
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
752
|
function isUrlPath(extInstallPath) {
|
|
774
753
|
return extInstallPath.startsWith("https:");
|
|
775
754
|
}
|
|
@@ -4,17 +4,14 @@ exports.SECRET_ROLE = exports.SECRET_LABEL = void 0;
|
|
|
4
4
|
exports.ensureSecretManagerApiEnabled = ensureSecretManagerApiEnabled;
|
|
5
5
|
exports.usesSecrets = usesSecrets;
|
|
6
6
|
exports.grantFirexServiceAgentSecretAdminRole = grantFirexServiceAgentSecretAdminRole;
|
|
7
|
-
exports.getManagedSecrets = getManagedSecrets;
|
|
8
7
|
exports.getActiveSecrets = getActiveSecrets;
|
|
9
8
|
exports.getSecretLabels = getSecretLabels;
|
|
10
|
-
exports.prettySecretName = prettySecretName;
|
|
11
9
|
const getProjectNumber_1 = require("../getProjectNumber");
|
|
12
10
|
const utils = require("../utils");
|
|
13
11
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
14
12
|
const projectUtils_1 = require("../projectUtils");
|
|
15
13
|
const types_1 = require("./types");
|
|
16
14
|
const secretManagerApi = require("../gcp/secretManager");
|
|
17
|
-
const logger_1 = require("../logger");
|
|
18
15
|
const api_1 = require("../api");
|
|
19
16
|
exports.SECRET_LABEL = "firebase-extensions-managed";
|
|
20
17
|
exports.SECRET_ROLE = "secretmanager.secretAccessor";
|
|
@@ -31,19 +28,6 @@ async function grantFirexServiceAgentSecretAdminRole(secret) {
|
|
|
31
28
|
const saEmail = `service-${projectNumber}@${firexSaProjectId}.iam.gserviceaccount.com`;
|
|
32
29
|
return secretManagerApi.ensureServiceAgentRole(secret, [saEmail], "roles/secretmanager.admin");
|
|
33
30
|
}
|
|
34
|
-
async function getManagedSecrets(instance) {
|
|
35
|
-
if (!instance.config?.source?.spec) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
return (await Promise.all(getActiveSecrets(instance.config.source.spec, instance.config.params).map(async (secretResourceName) => {
|
|
39
|
-
const secret = secretManagerApi.parseSecretResourceName(secretResourceName);
|
|
40
|
-
const labels = (await secretManagerApi.getSecret(secret.projectId, secret.name)).labels;
|
|
41
|
-
if (labels && labels[exports.SECRET_LABEL]) {
|
|
42
|
-
return secretResourceName;
|
|
43
|
-
}
|
|
44
|
-
return Promise.resolve("");
|
|
45
|
-
}))).filter((secretId) => !!secretId);
|
|
46
|
-
}
|
|
47
31
|
function getActiveSecrets(spec, params) {
|
|
48
32
|
return spec.params
|
|
49
33
|
.map((p) => (p.type === types_1.ParamType.SECRET ? params[p.param] : ""))
|
|
@@ -54,11 +38,3 @@ function getSecretLabels(instanceId) {
|
|
|
54
38
|
labels[exports.SECRET_LABEL] = instanceId;
|
|
55
39
|
return labels;
|
|
56
40
|
}
|
|
57
|
-
function prettySecretName(secretResourceName) {
|
|
58
|
-
const nameTokens = secretResourceName.split("/");
|
|
59
|
-
if (nameTokens.length !== 4 && nameTokens.length !== 6) {
|
|
60
|
-
logger_1.logger.debug(`unable to parse secret secretResourceName: ${secretResourceName}`);
|
|
61
|
-
return secretResourceName;
|
|
62
|
-
}
|
|
63
|
-
return nameTokens.slice(0, 4).join("/");
|
|
64
|
-
}
|
|
@@ -8,9 +8,7 @@ exports.isRewriteSupportedByHosting = isRewriteSupportedByHosting;
|
|
|
8
8
|
exports.isRedirectSupportedByHosting = isRedirectSupportedByHosting;
|
|
9
9
|
exports.isHeaderSupportedByHosting = isHeaderSupportedByHosting;
|
|
10
10
|
exports.getNextjsRewritesToUse = getNextjsRewritesToUse;
|
|
11
|
-
exports.usesAppDirRouter = usesAppDirRouter;
|
|
12
11
|
exports.usesNextImage = usesNextImage;
|
|
13
|
-
exports.hasUnoptimizedImage = hasUnoptimizedImage;
|
|
14
12
|
exports.isUsingMiddleware = isUsingMiddleware;
|
|
15
13
|
exports.isUsingImageOptimization = isUsingImageOptimization;
|
|
16
14
|
exports.isUsingNextImageInAppDirectory = isUsingNextImageInAppDirectory;
|
|
@@ -34,7 +32,6 @@ exports.findEsbuildPath = findEsbuildPath;
|
|
|
34
32
|
exports.getGlobalEsbuildVersion = getGlobalEsbuildVersion;
|
|
35
33
|
exports.installEsbuild = installEsbuild;
|
|
36
34
|
exports.isNextJsVersionVulnerable = isNextJsVersionVulnerable;
|
|
37
|
-
const fs_1 = require("fs");
|
|
38
35
|
const fs_extra_1 = require("fs-extra");
|
|
39
36
|
const path_1 = require("path");
|
|
40
37
|
const promises_1 = require("fs/promises");
|
|
@@ -92,18 +89,10 @@ function getNextjsRewritesToUse(nextJsRewrites) {
|
|
|
92
89
|
}
|
|
93
90
|
return [];
|
|
94
91
|
}
|
|
95
|
-
function usesAppDirRouter(sourceDir) {
|
|
96
|
-
const appPathRoutesManifestPath = (0, path_1.join)(sourceDir, constants_1.APP_PATH_ROUTES_MANIFEST);
|
|
97
|
-
return (0, fs_1.existsSync)(appPathRoutesManifestPath);
|
|
98
|
-
}
|
|
99
92
|
async function usesNextImage(sourceDir, distDir) {
|
|
100
93
|
const exportMarker = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_1.EXPORT_MARKER));
|
|
101
94
|
return exportMarker.isNextImageImported;
|
|
102
95
|
}
|
|
103
|
-
async function hasUnoptimizedImage(sourceDir, distDir) {
|
|
104
|
-
const imagesManifest = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, distDir, constants_1.IMAGES_MANIFEST));
|
|
105
|
-
return imagesManifest.images.unoptimized;
|
|
106
|
-
}
|
|
107
96
|
async function isUsingMiddleware(dir, isDevMode) {
|
|
108
97
|
if (isDevMode) {
|
|
109
98
|
const middlewareFiles = await Promise.all([
|
package/lib/fsAsync.js
CHANGED
|
@@ -6,31 +6,42 @@ const ignore_1 = require("ignore");
|
|
|
6
6
|
const _ = require("lodash");
|
|
7
7
|
const minimatch = require("minimatch");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
const
|
|
9
|
+
const error_1 = require("./error");
|
|
10
|
+
function readGitIgnore(dirPath) {
|
|
11
|
+
const gitIgnorePath = (0, path_1.join)(dirPath, ".gitignore");
|
|
12
|
+
try {
|
|
13
|
+
const lines = (0, fs_extra_1.readFileSync)(gitIgnorePath)
|
|
14
|
+
.toString()
|
|
15
|
+
.split("\n")
|
|
16
|
+
.map((line) => line.trim())
|
|
17
|
+
.filter((line) => !line.startsWith("#") && line !== "");
|
|
18
|
+
return { dirPath, ignore: (0, ignore_1.default)().add(lines) };
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
throw new error_1.FirebaseError(`Could not read ${gitIgnorePath}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
22
|
+
original: (0, error_1.getError)(err),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function parentGitIgnores(root, dir) {
|
|
27
|
+
const folders = (0, path_1.relative)(root, dir).split(path_1.sep).filter(Boolean);
|
|
28
|
+
const states = [];
|
|
29
|
+
for (let depth = 0; depth < folders.length; depth++) {
|
|
30
|
+
const ancestor = (0, path_1.join)(root, ...folders.slice(0, depth));
|
|
31
|
+
const gitIgnorePath = (0, path_1.join)(ancestor, ".gitignore");
|
|
32
|
+
if (!(0, fs_extra_1.existsSync)(gitIgnorePath) || !(0, fs_extra_1.statSync)(gitIgnorePath).isFile()) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
states.push(readGitIgnore(ancestor));
|
|
36
|
+
}
|
|
37
|
+
return states;
|
|
38
|
+
}
|
|
10
39
|
async function readdirRecursiveHelper(options) {
|
|
11
40
|
const dirContents = (0, fs_extra_1.readdirSync)(options.path, { withFileTypes: true });
|
|
12
41
|
let currentGitIgnoreStack = options.gitIgnoreStack || [];
|
|
13
42
|
if (options.supportGitIgnore) {
|
|
14
43
|
if (dirContents.find((n) => n.name === ".gitignore")?.isFile()) {
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const lines = (0, fs_extra_1.readFileSync)(localGitIgnore)
|
|
18
|
-
.toString()
|
|
19
|
-
.split("\n")
|
|
20
|
-
.map((line) => line.trim())
|
|
21
|
-
.filter((line) => !line.startsWith("#") && line !== "");
|
|
22
|
-
const subIgnore = (0, ignore_1.default)().add(lines);
|
|
23
|
-
currentGitIgnoreStack = [
|
|
24
|
-
...currentGitIgnoreStack,
|
|
25
|
-
{
|
|
26
|
-
dirPath: options.path,
|
|
27
|
-
ignore: subIgnore,
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
logger_1.logger.debug(`Error reading .gitignore file at ${localGitIgnore}:`, e);
|
|
33
|
-
}
|
|
44
|
+
currentGitIgnoreStack = [...currentGitIgnoreStack, readGitIgnore(options.path)];
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
47
|
const fullPaths = dirContents
|
|
@@ -91,6 +102,9 @@ async function readdirRecursive(options) {
|
|
|
91
102
|
dirPath: options.path,
|
|
92
103
|
ignore: (0, ignore_1.default)().add(options.ignoreStrings || []),
|
|
93
104
|
});
|
|
105
|
+
if (options.gitIgnoreRoot) {
|
|
106
|
+
initialGitIgnoreStack.push(...parentGitIgnores(options.gitIgnoreRoot, options.path));
|
|
107
|
+
}
|
|
94
108
|
}
|
|
95
109
|
const maxDepth = options.maxDepth && options.maxDepth > 0 ? options.maxDepth : Infinity;
|
|
96
110
|
return await readdirRecursiveHelper({
|