firebase-tools 10.1.0 → 10.1.4
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/accountExporter.js +9 -8
- package/lib/accountImporter.js +10 -8
- package/lib/apiv2.js +91 -48
- package/lib/archiveDirectory.js +63 -73
- package/lib/bin/firebase.js +1 -1
- package/lib/commands/auth-export.js +26 -25
- package/lib/commands/auth-import.js +88 -78
- package/lib/commands/ext-configure.js +1 -1
- package/lib/commands/ext-dev-init.js +1 -1
- package/lib/commands/ext-dev-publish.js +1 -1
- package/lib/commands/ext-dev-register.js +1 -1
- package/lib/commands/ext-dev-usage.js +3 -8
- package/lib/commands/ext-info.js +1 -1
- package/lib/commands/ext-install.js +1 -1
- package/lib/commands/ext-uninstall.js +1 -1
- package/lib/commands/ext-update.js +1 -1
- package/lib/commands/functions-config-clone.js +22 -23
- package/lib/commands/functions-config-get.js +22 -22
- package/lib/commands/functions-config-set.js +24 -22
- package/lib/commands/functions-config-unset.js +20 -22
- package/lib/commands/help.js +12 -12
- package/lib/commands/hosting-channel-create.js +1 -1
- package/lib/commands/hosting-channel-delete.js +2 -2
- package/lib/commands/hosting-channel-deploy.js +1 -1
- package/lib/commands/hosting-clone.js +1 -1
- package/lib/commands/login-ci.js +10 -10
- package/lib/commands/remoteconfig-versions-list.js +6 -1
- package/lib/commands/setup-emulators-database.js +8 -7
- package/lib/commands/setup-emulators-firestore.js +8 -7
- package/lib/commands/setup-emulators-pubsub.js +5 -4
- package/lib/commands/setup-emulators-storage.js +3 -2
- package/lib/commands/setup-emulators-ui.js +8 -7
- package/lib/commands/target-apply.js +17 -16
- package/lib/commands/target-clear.js +11 -10
- package/lib/commands/target-remove.js +10 -9
- package/lib/commands/target.js +20 -20
- package/lib/database/metadata.js +16 -24
- package/lib/defaultCredentials.js +3 -3
- package/lib/deploy/functions/backend.js +3 -1
- package/lib/deploy/functions/prepare.js +17 -11
- package/lib/deploy/functions/release/fabricator.js +4 -1
- package/lib/deploy/functions/runtimes/golang/index.js +6 -9
- package/lib/deploy/functions/runtimes/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/index.js +5 -9
- package/lib/deploy/functions/runtimes/node/validate.js +2 -1
- package/lib/deploy/functions/validate.js +32 -4
- package/lib/deploy/hosting/convertConfig.js +45 -24
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/emulator/auth/widget_ui.js +1 -1
- package/lib/emulator/downloadableEmulators.js +3 -2
- package/lib/emulator/functionsEmulator.js +9 -1
- package/lib/emulator/functionsEmulatorRuntime.js +4 -4
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/files.js +8 -3
- package/lib/emulator/storage/rules/runtime.js +5 -4
- package/lib/extensions/askUserForConsent.js +1 -1
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/billingMigrationHelper.js +1 -1
- package/lib/extensions/changelog.js +1 -1
- package/lib/extensions/displayExtensionInfo.js +1 -1
- package/lib/extensions/extensionsApi.js +57 -112
- package/lib/extensions/extensionsHelper.js +19 -15
- package/lib/extensions/provisioningHelper.js +7 -10
- package/lib/extensions/resolveSource.js +5 -5
- package/lib/extensions/updateHelper.js +1 -1
- package/lib/extensions/warnings.js +1 -1
- package/lib/functionsConfig.js +4 -5
- package/lib/gcp/cloudbilling.js +8 -19
- package/lib/gcp/cloudfunctions.js +22 -46
- package/lib/gcp/cloudlogging.js +8 -11
- package/lib/gcp/cloudmonitoring.js +8 -5
- package/lib/gcp/cloudscheduler.js +7 -18
- package/lib/gcp/firedata.js +5 -4
- package/lib/gcp/firestore.js +5 -5
- package/lib/gcp/iam.js +18 -33
- package/lib/gcp/resourceManager.js +8 -13
- package/lib/gcp/rules.js +18 -41
- package/lib/gcp/runtimeconfig.js +31 -53
- package/lib/gcp/secretManager.js +21 -43
- package/lib/gcp/storage.js +25 -29
- package/lib/projectUtils.js +1 -1
- package/lib/remoteconfig/get.js +14 -8
- package/lib/remoteconfig/rollback.js +13 -6
- package/lib/remoteconfig/versionslist.js +13 -7
- package/npm-shrinkwrap.json +1439 -2295
- package/package.json +16 -11
- package/schema/firebase-config.json +387 -12
- package/standalone/firepit.js +4 -4
- package/templates/init/hosting/index.html +1 -1
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
|
@@ -30,22 +30,18 @@ function getHumanFriendlyRuntimeName(runtime) {
|
|
|
30
30
|
}
|
|
31
31
|
exports.getHumanFriendlyRuntimeName = getHumanFriendlyRuntimeName;
|
|
32
32
|
const factories = [node.tryCreateDelegate, golang.tryCreateDelegate];
|
|
33
|
-
async function getRuntimeDelegate(context
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
throw new error_1.FirebaseError(`No functions code detected at default location (./functions), and no functions.source defined in firebase.json`);
|
|
37
|
-
}
|
|
38
|
-
validate.functionsDirectoryExists(options, sourceDirName);
|
|
39
|
-
const runtime = options.config.get("functions.runtime");
|
|
33
|
+
async function getRuntimeDelegate(context) {
|
|
34
|
+
const { projectDir, sourceDir, runtime } = context;
|
|
35
|
+
validate.functionsDirectoryExists(sourceDir, projectDir);
|
|
40
36
|
if (runtime && !isValidRuntime(runtime)) {
|
|
41
|
-
throw new error_1.FirebaseError(
|
|
37
|
+
throw new error_1.FirebaseError(`Cannot deploy function with runtime ${runtime}`);
|
|
42
38
|
}
|
|
43
39
|
for (const factory of factories) {
|
|
44
|
-
const delegate = await factory(context
|
|
40
|
+
const delegate = await factory(context);
|
|
45
41
|
if (delegate) {
|
|
46
42
|
return delegate;
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
|
-
throw new error_1.FirebaseError(`Could not detect language for functions at ${
|
|
45
|
+
throw new error_1.FirebaseError(`Could not detect language for functions at ${sourceDir}`);
|
|
50
46
|
}
|
|
51
47
|
exports.getRuntimeDelegate = getRuntimeDelegate;
|
|
@@ -6,26 +6,22 @@ const fs = require("fs");
|
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const error_1 = require("../../../../error");
|
|
8
8
|
const parseRuntimeAndValidateSDK_1 = require("./parseRuntimeAndValidateSDK");
|
|
9
|
-
const projectUtils_1 = require("../../../../projectUtils");
|
|
10
|
-
const validate = require("./validate");
|
|
11
9
|
const logger_1 = require("../../../../logger");
|
|
10
|
+
const validate = require("./validate");
|
|
12
11
|
const versioning = require("./versioning");
|
|
13
12
|
const parseTriggers = require("./parseTriggers");
|
|
14
|
-
async function tryCreateDelegate(context
|
|
15
|
-
const
|
|
16
|
-
const sourceDir = options.config.path(projectRelativeSourceDir);
|
|
17
|
-
const packageJsonPath = path.join(sourceDir, "package.json");
|
|
13
|
+
async function tryCreateDelegate(context) {
|
|
14
|
+
const packageJsonPath = path.join(context.sourceDir, "package.json");
|
|
18
15
|
if (!(await (0, util_1.promisify)(fs.exists)(packageJsonPath))) {
|
|
19
16
|
logger_1.logger.debug("Customer code is not Node");
|
|
20
17
|
return undefined;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
runtime = (0, parseRuntimeAndValidateSDK_1.getRuntimeChoice)(sourceDir, runtime);
|
|
19
|
+
const runtime = (0, parseRuntimeAndValidateSDK_1.getRuntimeChoice)(context.sourceDir, context.runtime);
|
|
24
20
|
if (!runtime.startsWith("nodejs")) {
|
|
25
21
|
logger_1.logger.debug("Customer has a package.json but did not get a nodejs runtime. This should not happen");
|
|
26
22
|
throw new error_1.FirebaseError(`Unexpected runtime ${runtime}`);
|
|
27
23
|
}
|
|
28
|
-
return new Delegate(
|
|
24
|
+
return new Delegate(context.projectId, context.projectDir, context.sourceDir, runtime);
|
|
29
25
|
}
|
|
30
26
|
exports.tryCreateDelegate = tryCreateDelegate;
|
|
31
27
|
class Delegate {
|
|
@@ -9,7 +9,8 @@ const cjson = require("cjson");
|
|
|
9
9
|
function assertFunctionsSourcePresent(data, sourceDir, projectDir) {
|
|
10
10
|
const indexJsFile = path.join(sourceDir, data.main || "index.js");
|
|
11
11
|
if (!fsutils.fileExistsSync(indexJsFile)) {
|
|
12
|
-
const
|
|
12
|
+
const relativeMainPath = path.relative(projectDir, indexJsFile);
|
|
13
|
+
const msg = `${relativeMainPath} does not exist, can't deploy Cloud Functions`;
|
|
13
14
|
throw new error_1.FirebaseError(msg);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.functionIdsAreValid = exports.functionsDirectoryExists = void 0;
|
|
3
|
+
exports.functionIdsAreValid = exports.functionsDirectoryExists = exports.endpointsAreValid = void 0;
|
|
4
|
+
const path = require("path");
|
|
4
5
|
const clc = require("cli-color");
|
|
5
6
|
const error_1 = require("../../error");
|
|
6
7
|
const fsutils = require("../../fsutils");
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
const backend = require("./backend");
|
|
9
|
+
function endpointsAreValid(wantBackend) {
|
|
10
|
+
functionIdsAreValid(backend.allEndpoints(wantBackend));
|
|
11
|
+
const gcfV1WithConcurrency = backend
|
|
12
|
+
.allEndpoints(wantBackend)
|
|
13
|
+
.filter((endpoint) => (endpoint.concurrency || 1) != 1 && endpoint.platform == "gcfv1")
|
|
14
|
+
.map((endpoint) => endpoint.id);
|
|
15
|
+
if (gcfV1WithConcurrency.length) {
|
|
16
|
+
const msg = `Cannot set concurrency on the functions ${gcfV1WithConcurrency.join(",")} because they are GCF gen 1`;
|
|
17
|
+
throw new error_1.FirebaseError(msg);
|
|
18
|
+
}
|
|
19
|
+
const tooSmallForConcurrency = backend
|
|
20
|
+
.allEndpoints(wantBackend)
|
|
21
|
+
.filter((endpoint) => {
|
|
22
|
+
if ((endpoint.concurrency || 1) == 1) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const mem = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;
|
|
26
|
+
return mem < backend.MIN_MEMORY_FOR_CONCURRENCY;
|
|
27
|
+
})
|
|
28
|
+
.map((endpoint) => endpoint.id);
|
|
29
|
+
if (tooSmallForConcurrency.length) {
|
|
30
|
+
const msg = `Cannot set concurency on the functions ${tooSmallForConcurrency.join(",")} because they have fewer than 2GB memory`;
|
|
31
|
+
throw new error_1.FirebaseError(msg);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.endpointsAreValid = endpointsAreValid;
|
|
35
|
+
function functionsDirectoryExists(sourceDir, projectDir) {
|
|
36
|
+
if (!fsutils.dirExistsSync(sourceDir)) {
|
|
37
|
+
const sourceDirName = path.relative(projectDir, sourceDir);
|
|
10
38
|
const msg = `could not deploy functions because the ${clc.bold('"' + sourceDirName + '"')} ` +
|
|
11
39
|
`directory was not found. Please create it or specify a different source directory in firebase.json`;
|
|
12
40
|
throw new error_1.FirebaseError(msg);
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertConfig = void 0;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
function has(obj, k) {
|
|
6
|
+
return obj[k] !== undefined;
|
|
7
|
+
}
|
|
4
8
|
function extractPattern(type, spec) {
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
let glob = "";
|
|
10
|
+
let regex = "";
|
|
11
|
+
if ("source" in spec) {
|
|
12
|
+
glob = spec.source;
|
|
13
|
+
}
|
|
14
|
+
if ("glob" in spec) {
|
|
15
|
+
glob = spec.glob;
|
|
16
|
+
}
|
|
17
|
+
if ("regex" in spec) {
|
|
18
|
+
regex = spec.regex;
|
|
19
|
+
}
|
|
7
20
|
if (glob && regex) {
|
|
8
|
-
throw new FirebaseError(
|
|
21
|
+
throw new error_1.FirebaseError(`Cannot specify a ${type} pattern with both a glob and regex.`);
|
|
9
22
|
}
|
|
10
23
|
else if (glob) {
|
|
11
24
|
return { glob: glob };
|
|
@@ -13,33 +26,38 @@ function extractPattern(type, spec) {
|
|
|
13
26
|
else if (regex) {
|
|
14
27
|
return { regex: regex };
|
|
15
28
|
}
|
|
16
|
-
throw new FirebaseError(
|
|
29
|
+
throw new error_1.FirebaseError(`Cannot specify a ${type} with no pattern (either a glob or regex required).`);
|
|
17
30
|
}
|
|
18
|
-
|
|
31
|
+
function convertConfig(config) {
|
|
32
|
+
if (Array.isArray(config)) {
|
|
33
|
+
throw new error_1.FirebaseError(`convertConfig should be given a single configuration, not an array.`, {
|
|
34
|
+
exit: 2,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
19
37
|
const out = {};
|
|
20
38
|
if (!config) {
|
|
21
39
|
return out;
|
|
22
40
|
}
|
|
23
|
-
if (
|
|
24
|
-
out.rewrites = config.rewrites.map(
|
|
41
|
+
if (Array.isArray(config.rewrites)) {
|
|
42
|
+
out.rewrites = config.rewrites.map((rewrite) => {
|
|
25
43
|
const vRewrite = extractPattern("rewrite", rewrite);
|
|
26
|
-
if (rewrite
|
|
44
|
+
if ("destination" in rewrite) {
|
|
27
45
|
vRewrite.path = rewrite.destination;
|
|
28
46
|
}
|
|
29
|
-
else if (rewrite
|
|
47
|
+
else if ("function" in rewrite) {
|
|
30
48
|
vRewrite.function = rewrite.function;
|
|
31
49
|
}
|
|
32
|
-
else if (rewrite
|
|
50
|
+
else if ("dynamicLinks" in rewrite) {
|
|
33
51
|
vRewrite.dynamicLinks = rewrite.dynamicLinks;
|
|
34
52
|
}
|
|
35
|
-
else if (rewrite
|
|
53
|
+
else if ("run" in rewrite) {
|
|
36
54
|
vRewrite.run = Object.assign({ region: "us-central1" }, rewrite.run);
|
|
37
55
|
}
|
|
38
56
|
return vRewrite;
|
|
39
57
|
});
|
|
40
58
|
}
|
|
41
|
-
if (
|
|
42
|
-
out.redirects = config.redirects.map(
|
|
59
|
+
if (Array.isArray(config.redirects)) {
|
|
60
|
+
out.redirects = config.redirects.map((redirect) => {
|
|
43
61
|
const vRedirect = extractPattern("redirect", redirect);
|
|
44
62
|
vRedirect.location = redirect.destination;
|
|
45
63
|
if (redirect.type) {
|
|
@@ -48,17 +66,19 @@ module.exports = function (config) {
|
|
|
48
66
|
return vRedirect;
|
|
49
67
|
});
|
|
50
68
|
}
|
|
51
|
-
if (
|
|
52
|
-
out.headers = config.headers.map(
|
|
69
|
+
if (Array.isArray(config.headers)) {
|
|
70
|
+
out.headers = config.headers.map((header) => {
|
|
53
71
|
const vHeader = extractPattern("header", header);
|
|
54
72
|
vHeader.headers = {};
|
|
55
|
-
(header.headers
|
|
56
|
-
|
|
57
|
-
|
|
73
|
+
if (Array.isArray(header.headers) && header.headers.length) {
|
|
74
|
+
header.headers.forEach((h) => {
|
|
75
|
+
vHeader.headers[h.key] = h.value;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
58
78
|
return vHeader;
|
|
59
79
|
});
|
|
60
80
|
}
|
|
61
|
-
if (
|
|
81
|
+
if (has(config, "cleanUrls")) {
|
|
62
82
|
out.cleanUrls = config.cleanUrls;
|
|
63
83
|
}
|
|
64
84
|
if (config.trailingSlash === true) {
|
|
@@ -67,11 +87,12 @@ module.exports = function (config) {
|
|
|
67
87
|
else if (config.trailingSlash === false) {
|
|
68
88
|
out.trailingSlashBehavior = "REMOVE";
|
|
69
89
|
}
|
|
70
|
-
if (
|
|
90
|
+
if (has(config, "appAssociation")) {
|
|
71
91
|
out.appAssociation = config.appAssociation;
|
|
72
92
|
}
|
|
73
|
-
if (
|
|
93
|
+
if (has(config, "i18n")) {
|
|
74
94
|
out.i18n = config.i18n;
|
|
75
95
|
}
|
|
76
96
|
return out;
|
|
77
|
-
}
|
|
97
|
+
}
|
|
98
|
+
exports.convertConfig = convertConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const _ = require("lodash");
|
|
3
3
|
const api = require("../../api");
|
|
4
|
-
const convertConfig = require("./convertConfig");
|
|
4
|
+
const { convertConfig } = require("./convertConfig");
|
|
5
5
|
const deploymentTool = require("../../deploymentTool");
|
|
6
6
|
const { FirebaseError } = require("../../error");
|
|
7
7
|
const { normalizedHostingConfigs } = require("../../hosting/normalizedHostingConfigs");
|
|
@@ -221,6 +221,7 @@ async function handleEmulatorProcessError(emulator, err) {
|
|
|
221
221
|
exports.handleEmulatorProcessError = handleEmulatorProcessError;
|
|
222
222
|
async function _runBinary(emulator, command, extraEnv) {
|
|
223
223
|
return new Promise((resolve) => {
|
|
224
|
+
var _a, _b;
|
|
224
225
|
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(emulator.name);
|
|
225
226
|
emulator.stdout = fs.createWriteStream(getLogFileName(emulator.name));
|
|
226
227
|
try {
|
|
@@ -242,11 +243,11 @@ async function _runBinary(emulator, command, extraEnv) {
|
|
|
242
243
|
return;
|
|
243
244
|
}
|
|
244
245
|
logger.logLabeled("BULLET", emulator.name, `${description} logging to ${clc.bold(getLogFileName(emulator.name))}`);
|
|
245
|
-
emulator.instance.stdout.on("data", (data) => {
|
|
246
|
+
(_a = emulator.instance.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (data) => {
|
|
246
247
|
logger.log("DEBUG", data.toString());
|
|
247
248
|
emulator.stdout.write(data);
|
|
248
249
|
});
|
|
249
|
-
emulator.instance.stderr.on("data", (data) => {
|
|
250
|
+
(_b = emulator.instance.stderr) === null || _b === void 0 ? void 0 : _b.on("data", (data) => {
|
|
250
251
|
logger.log("DEBUG", data.toString());
|
|
251
252
|
emulator.stdout.write(data);
|
|
252
253
|
if (data.toString().includes("java.lang.UnsupportedClassVersionError")) {
|
|
@@ -525,7 +525,9 @@ class FunctionsEmulator {
|
|
|
525
525
|
if (requestedMajorVersion === hostMajorVersion) {
|
|
526
526
|
this.logger.logLabeled("SUCCESS", "functions", `Using node@${requestedMajorVersion} from host.`);
|
|
527
527
|
}
|
|
528
|
-
|
|
528
|
+
else {
|
|
529
|
+
this.logger.log("WARN", `Your requested "node" version "${requestedMajorVersion}" doesn't match your global version "${hostMajorVersion}". Using node@${hostMajorVersion} from host.`);
|
|
530
|
+
}
|
|
529
531
|
return process.execPath;
|
|
530
532
|
}
|
|
531
533
|
getUserEnvs(backend) {
|
|
@@ -638,6 +640,12 @@ class FunctionsEmulator {
|
|
|
638
640
|
cwd: frb.cwd,
|
|
639
641
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
640
642
|
});
|
|
643
|
+
if (!childProcess.stderr) {
|
|
644
|
+
throw new error_1.FirebaseError(`childProcess.stderr is undefined.`);
|
|
645
|
+
}
|
|
646
|
+
if (!childProcess.stdout) {
|
|
647
|
+
throw new error_1.FirebaseError(`childProcess.stdout is undefined.`);
|
|
648
|
+
}
|
|
641
649
|
const buffers = {
|
|
642
650
|
stderr: { pipe: childProcess.stderr, value: "" },
|
|
643
651
|
stdout: { pipe: childProcess.stdout, value: "" },
|
|
@@ -389,10 +389,10 @@ async function initializeFirebaseAdminStubs(frb) {
|
|
|
389
389
|
return Proxied.getOriginal(target, "auth");
|
|
390
390
|
})
|
|
391
391
|
.finalize();
|
|
392
|
-
require.cache[adminResolution.resolution] = {
|
|
392
|
+
require.cache[adminResolution.resolution] = Object.assign(require.cache[adminResolution.resolution], {
|
|
393
393
|
exports: proxiedAdminModule,
|
|
394
394
|
path: path.dirname(adminResolution.resolution),
|
|
395
|
-
};
|
|
395
|
+
});
|
|
396
396
|
logDebug("firebase-admin has been stubbed.", {
|
|
397
397
|
adminResolution,
|
|
398
398
|
});
|
|
@@ -456,10 +456,10 @@ async function initializeFunctionsConfigHelper(frb) {
|
|
|
456
456
|
return proxiedConfig;
|
|
457
457
|
})
|
|
458
458
|
.finalize();
|
|
459
|
-
require.cache[functionsResolution.resolution] = {
|
|
459
|
+
require.cache[functionsResolution.resolution] = Object.assign(require.cache[functionsResolution.resolution], {
|
|
460
460
|
exports: proxiedFunctionsModule,
|
|
461
461
|
path: path.dirname(functionsResolution.resolution),
|
|
462
|
-
};
|
|
462
|
+
});
|
|
463
463
|
logDebug("firebase-functions has been stubbed.", {
|
|
464
464
|
functionsResolution,
|
|
465
465
|
});
|
|
@@ -14,10 +14,10 @@ function createCloudEndpoints(emulator) {
|
|
|
14
14
|
storageLayer.createBucket(req.params[0]);
|
|
15
15
|
next();
|
|
16
16
|
});
|
|
17
|
-
gcloudStorageAPI.get("/b", (req, res) => {
|
|
17
|
+
gcloudStorageAPI.get("/b", async (req, res) => {
|
|
18
18
|
res.json({
|
|
19
19
|
kind: "storage#buckets",
|
|
20
|
-
items: storageLayer.listBuckets(),
|
|
20
|
+
items: await storageLayer.listBuckets(),
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
gcloudStorageAPI.get(["/b/:bucketId/o/:objectId", "/download/storage/v1/b/:bucketId/o/:objectId"], (req, res) => {
|
|
@@ -19,6 +19,7 @@ const fse = require("fs-extra");
|
|
|
19
19
|
const rimraf = require("rimraf");
|
|
20
20
|
const cloudFunctions_1 = require("./cloudFunctions");
|
|
21
21
|
const logger_1 = require("../../logger");
|
|
22
|
+
const adminSdkConfig_1 = require("../adminSdkConfig");
|
|
22
23
|
class StoredFile {
|
|
23
24
|
constructor(metadata, path) {
|
|
24
25
|
this.metadata = metadata;
|
|
@@ -108,9 +109,13 @@ class StorageLayer {
|
|
|
108
109
|
this._buckets.set(id, new metadata_1.CloudStorageBucketMetadata(id));
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
listBuckets() {
|
|
112
|
+
async listBuckets() {
|
|
112
113
|
if (this._buckets.size == 0) {
|
|
113
|
-
this.
|
|
114
|
+
let adminSdkConfig = await (0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(this._projectId);
|
|
115
|
+
if (!adminSdkConfig) {
|
|
116
|
+
adminSdkConfig = (0, adminSdkConfig_1.constructDefaultAdminSdkConfig)(this._projectId);
|
|
117
|
+
}
|
|
118
|
+
this.createBucket(adminSdkConfig.storageBucket);
|
|
114
119
|
}
|
|
115
120
|
return [...this._buckets.values()];
|
|
116
121
|
}
|
|
@@ -355,7 +360,7 @@ class StorageLayer {
|
|
|
355
360
|
const bucketsList = {
|
|
356
361
|
buckets: [],
|
|
357
362
|
};
|
|
358
|
-
for (const b of this.listBuckets()) {
|
|
363
|
+
for (const b of await this.listBuckets()) {
|
|
359
364
|
bucketsList.buckets.push({ id: b.id });
|
|
360
365
|
}
|
|
361
366
|
const bucketsFilePath = path.join(storageExportPath, "buckets.json");
|
|
@@ -62,6 +62,7 @@ class StorageRulesRuntime {
|
|
|
62
62
|
return this._alive;
|
|
63
63
|
}
|
|
64
64
|
async start(auto_download = true) {
|
|
65
|
+
var _a, _b;
|
|
65
66
|
const downloadDetails = downloadableEmulators_1.DownloadDetails[types_2.Emulators.STORAGE];
|
|
66
67
|
const hasEmulator = fs.existsSync(downloadDetails.downloadPath);
|
|
67
68
|
if (!hasEmulator) {
|
|
@@ -99,7 +100,7 @@ class StorageRulesRuntime {
|
|
|
99
100
|
this._childprocess.on("error", (err) => {
|
|
100
101
|
(0, downloadableEmulators_1.handleEmulatorProcessError)(types_2.Emulators.STORAGE, err);
|
|
101
102
|
});
|
|
102
|
-
this._childprocess.stderr.on("data", (buf) => {
|
|
103
|
+
(_a = this._childprocess.stderr) === null || _a === void 0 ? void 0 : _a.on("data", (buf) => {
|
|
103
104
|
const error = buf.toString();
|
|
104
105
|
if (error.includes("jarfile")) {
|
|
105
106
|
throw new error_1.FirebaseError("There was an issue starting the rules emulator, please run 'firebase setup:emulators:storage` again");
|
|
@@ -108,7 +109,7 @@ class StorageRulesRuntime {
|
|
|
108
109
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_2.Emulators.STORAGE).log("WARN", `Unexpected rules runtime error: ${buf.toString()}`);
|
|
109
110
|
}
|
|
110
111
|
});
|
|
111
|
-
this._childprocess.stdout.on("data", (buf) => {
|
|
112
|
+
(_b = this._childprocess.stdout) === null || _b === void 0 ? void 0 : _b.on("data", (buf) => {
|
|
112
113
|
const serializedRuntimeActionResponse = buf.toString("UTF8").trim();
|
|
113
114
|
if (serializedRuntimeActionResponse != "") {
|
|
114
115
|
let rap;
|
|
@@ -148,13 +149,13 @@ class StorageRulesRuntime {
|
|
|
148
149
|
throw new error_1.FirebaseError("Attempted to send Cloud Storage rules request with stale id");
|
|
149
150
|
}
|
|
150
151
|
return new Promise((resolve) => {
|
|
151
|
-
var _a;
|
|
152
|
+
var _a, _b;
|
|
152
153
|
this._requests[runtimeActionRequest.id] = {
|
|
153
154
|
request: runtimeActionRequest,
|
|
154
155
|
handler: resolve,
|
|
155
156
|
};
|
|
156
157
|
const serializedRequest = JSON.stringify(runtimeActionRequest);
|
|
157
|
-
(_a = this._childprocess) === null || _a === void 0 ? void 0 : _a.stdin.write(serializedRequest + "\n");
|
|
158
|
+
(_b = (_a = this._childprocess) === null || _a === void 0 ? void 0 : _a.stdin) === null || _b === void 0 ? void 0 : _b.write(serializedRequest + "\n");
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
161
|
async loadRuleset(source) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.promptForPublisherTOS = exports.displayApis = exports.displayRoles = exports.retrieveRoleInfo = exports.formatDescription = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const error_1 = require("../error");
|
|
9
9
|
const extensionsHelper_1 = require("../extensions/extensionsHelper");
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ask = exports.getInquirerDefault = exports.promptCreateSecret = exports.askForParam = exports.checkResponse = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const extensionsApi_1 = require("./extensionsApi");
|
|
8
8
|
const secretManagerApi = require("../gcp/secretManager");
|
|
9
9
|
const secretsUtils = require("./secretsUtils");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.displayNode10CreateBillingNotice = exports.displayNode10UpdateBillingNotice = void 0;
|
|
4
|
-
const marked = require("marked");
|
|
4
|
+
const { marked } = require("marked");
|
|
5
5
|
const TerminalRenderer = require("marked-terminal");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const extensionsHelper_1 = require("./extensionsHelper");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseChangelog = exports.getLocalChangelog = exports.breakingChangesInUpdate = exports.displayReleaseNotes = exports.getReleaseNotesForUpdate = void 0;
|
|
4
4
|
const clc = require("cli-color");
|
|
5
|
-
const marked = require("marked");
|
|
5
|
+
const { marked } = require("marked");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const semver = require("semver");
|
|
8
8
|
const TerminalRenderer = require("marked-terminal");
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printSourceDownloadLink = exports.displayUpdateChangesRequiringConfirmation = exports.displayUpdateChangesNoInput = exports.displayExtInfo = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const utils = require("../utils");
|
|
9
9
|
const extensionsHelper_1 = require("./extensionsHelper");
|