firebase-tools 10.4.0 → 10.5.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/accountExporter.js +95 -84
- package/lib/bin/firebase.js +1 -1
- package/lib/commands/emulators-start.js +6 -1
- package/lib/commands/ext-configure.js +4 -4
- package/lib/commands/ext-dev-emulators-start.js +5 -1
- package/lib/commands/ext-install.js +5 -4
- package/lib/commands/ext-update.js +2 -1
- package/lib/commands/functions-config-export.js +3 -1
- package/lib/config.js +11 -4
- package/lib/deploy/functions/checkIam.js +44 -1
- package/lib/deploy/functions/deploy.js +3 -7
- package/lib/deploy/functions/prepare.js +7 -5
- package/lib/deploy/functions/prepareFunctionsUpload.js +7 -13
- package/lib/deploy/functions/release/fabricator.js +13 -1
- package/lib/deploy/functions/release/index.js +1 -1
- package/lib/deploy/functions/services/firebaseAlerts.js +1 -17
- package/lib/deploy/functions/services/index.js +2 -1
- package/lib/deploy/hosting/deploy.js +10 -0
- package/lib/emulator/auth/operations.js +21 -20
- package/lib/emulator/auth/state.js +79 -43
- package/lib/emulator/commandUtils.js +72 -2
- package/lib/emulator/controller.js +23 -8
- package/lib/emulator/downloadableEmulators.js +18 -11
- package/lib/emulator/functionsEmulator.js +8 -18
- package/lib/emulator/functionsEmulatorShared.js +27 -1
- package/lib/emulator/shared/request.js +19 -0
- package/lib/emulator/storage/apis/firebase.js +20 -28
- package/lib/emulator/storage/apis/gcloud.js +69 -57
- package/lib/emulator/storage/files.js +42 -49
- package/lib/emulator/storage/index.js +14 -2
- package/lib/emulator/storage/rules/utils.js +11 -3
- package/lib/extensions/askUserForParam.js +43 -15
- package/lib/extensions/extensionsHelper.js +11 -2
- package/lib/extensions/paramHelper.js +7 -3
- package/lib/functions/projectConfig.js +34 -0
- package/lib/init/features/functions/index.js +4 -2
- package/lib/init/features/hosting/index.js +32 -41
- package/lib/init/features/index.js +22 -12
- package/lib/init/index.js +28 -11
- package/lib/requirePermissions.js +4 -1
- package/lib/serve/functions.js +5 -5
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schema/firebase-config.json +93 -36
- package/lib/emulator/storage/list.js +0 -18
package/lib/init/index.js
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.init = void 0;
|
|
4
|
-
const
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
+
const error_1 = require("../error");
|
|
6
7
|
const logger_1 = require("../logger");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const features = require("./features");
|
|
9
|
+
const featureFns = new Map([
|
|
10
|
+
["account", features.account],
|
|
11
|
+
["database", features.database],
|
|
12
|
+
["firestore", features.firestore],
|
|
13
|
+
["functions", features.functions],
|
|
14
|
+
["hosting", features.hosting],
|
|
15
|
+
["storage", features.storage],
|
|
16
|
+
["emulators", features.emulators],
|
|
17
|
+
["project", features.project],
|
|
18
|
+
["remoteconfig", features.remoteconfig],
|
|
19
|
+
["hosting:github", features.hostingGithub],
|
|
20
|
+
]);
|
|
10
21
|
async function init(setup, config, options) {
|
|
11
|
-
|
|
22
|
+
var _a;
|
|
23
|
+
const nextFeature = (_a = setup.features) === null || _a === void 0 ? void 0 : _a.shift();
|
|
12
24
|
if (nextFeature) {
|
|
13
|
-
if (!
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
if (!featureFns.has(nextFeature)) {
|
|
26
|
+
const availableFeatures = Object.keys(features)
|
|
27
|
+
.filter((f) => f !== "project")
|
|
28
|
+
.join(", ");
|
|
29
|
+
throw new error_1.FirebaseError(`${clc.bold(nextFeature)} is not a valid feature. Must be one of ${availableFeatures}`);
|
|
17
30
|
}
|
|
18
|
-
logger_1.logger.info(clc.bold(
|
|
19
|
-
|
|
31
|
+
logger_1.logger.info(clc.bold(`\n${clc.white("===")} ${(0, lodash_1.capitalize)(nextFeature)} Setup`));
|
|
32
|
+
const fn = featureFns.get(nextFeature);
|
|
33
|
+
if (!fn) {
|
|
34
|
+
throw new error_1.FirebaseError(`We've lost the function to init ${nextFeature}`, { exit: 2 });
|
|
35
|
+
}
|
|
36
|
+
await fn(setup, config, options);
|
|
20
37
|
return init(setup, config, options);
|
|
21
38
|
}
|
|
22
39
|
}
|
|
@@ -9,7 +9,10 @@ const error_1 = require("./error");
|
|
|
9
9
|
const iam_1 = require("./gcp/iam");
|
|
10
10
|
const BASE_PERMISSIONS = ["firebase.projects.get"];
|
|
11
11
|
async function requirePermissions(options, permissions = []) {
|
|
12
|
-
const projectId = (0, projectUtils_1.
|
|
12
|
+
const projectId = (0, projectUtils_1.getProjectId)(options);
|
|
13
|
+
if (!projectId) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
13
16
|
const requiredPermissions = BASE_PERMISSIONS.concat(permissions).sort();
|
|
14
17
|
await (0, requireAuth_1.requireAuth)(options);
|
|
15
18
|
logger_1.logger.debug(`[iam] checking project ${projectId} for permissions ${JSON.stringify(requiredPermissions)}`);
|
package/lib/serve/functions.js
CHANGED
|
@@ -7,6 +7,7 @@ const emulatorServer_1 = require("../emulator/emulatorServer");
|
|
|
7
7
|
const functionsEmulatorUtils_1 = require("../emulator/functionsEmulatorUtils");
|
|
8
8
|
const projectUtils_1 = require("../projectUtils");
|
|
9
9
|
const auth_1 = require("../auth");
|
|
10
|
+
const projectConfig = require("../functions/projectConfig");
|
|
10
11
|
const utils = require("../utils");
|
|
11
12
|
class FunctionsServer {
|
|
12
13
|
constructor() {
|
|
@@ -20,11 +21,10 @@ class FunctionsServer {
|
|
|
20
21
|
}
|
|
21
22
|
async start(options, partialArgs) {
|
|
22
23
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const functionsDir = path.join(options.config.projectDir, options.config.src.functions.source);
|
|
24
|
+
const config = projectConfig.normalizeAndValidate(options.config.src.functions)[0];
|
|
25
|
+
const functionsDir = path.join(options.config.projectDir, config.source);
|
|
26
26
|
const account = (0, auth_1.getProjectDefaultAccount)(options.config.projectDir);
|
|
27
|
-
const nodeMajorVersion = (0, functionsEmulatorUtils_1.parseRuntimeVersion)(
|
|
27
|
+
const nodeMajorVersion = (0, functionsEmulatorUtils_1.parseRuntimeVersion)(config.runtime);
|
|
28
28
|
this.backend = {
|
|
29
29
|
functionsDir,
|
|
30
30
|
nodeMajorVersion,
|
|
@@ -40,7 +40,7 @@ class FunctionsServer {
|
|
|
40
40
|
utils.assertIsNumber(options.port);
|
|
41
41
|
const targets = options.targets;
|
|
42
42
|
const port = options.port;
|
|
43
|
-
const hostingRunning = targets && targets.
|
|
43
|
+
const hostingRunning = targets && targets.includes("hosting");
|
|
44
44
|
if (hostingRunning) {
|
|
45
45
|
args.port = port + 1;
|
|
46
46
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.5.0",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "firebase-tools",
|
|
9
|
-
"version": "10.
|
|
9
|
+
"version": "10.5.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@google-cloud/pubsub": "^2.18.4",
|
package/package.json
CHANGED
|
@@ -326,54 +326,111 @@
|
|
|
326
326
|
"type": "object"
|
|
327
327
|
},
|
|
328
328
|
"functions": {
|
|
329
|
-
"
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
"
|
|
333
|
-
"
|
|
334
|
-
},
|
|
335
|
-
"type": "array"
|
|
336
|
-
},
|
|
337
|
-
"postdeploy": {
|
|
338
|
-
"anyOf": [
|
|
339
|
-
{
|
|
329
|
+
"anyOf": [
|
|
330
|
+
{
|
|
331
|
+
"additionalProperties": false,
|
|
332
|
+
"properties": {
|
|
333
|
+
"ignore": {
|
|
340
334
|
"items": {
|
|
341
335
|
"type": "string"
|
|
342
336
|
},
|
|
343
337
|
"type": "array"
|
|
344
338
|
},
|
|
345
|
-
{
|
|
339
|
+
"postdeploy": {
|
|
340
|
+
"anyOf": [
|
|
341
|
+
{
|
|
342
|
+
"items": {
|
|
343
|
+
"type": "string"
|
|
344
|
+
},
|
|
345
|
+
"type": "array"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"type": "string"
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
"predeploy": {
|
|
353
|
+
"anyOf": [
|
|
354
|
+
{
|
|
355
|
+
"items": {
|
|
356
|
+
"type": "string"
|
|
357
|
+
},
|
|
358
|
+
"type": "array"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"type": "string"
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
},
|
|
365
|
+
"runtime": {
|
|
366
|
+
"enum": [
|
|
367
|
+
"nodejs10",
|
|
368
|
+
"nodejs12",
|
|
369
|
+
"nodejs14",
|
|
370
|
+
"nodejs16"
|
|
371
|
+
],
|
|
372
|
+
"type": "string"
|
|
373
|
+
},
|
|
374
|
+
"source": {
|
|
346
375
|
"type": "string"
|
|
347
376
|
}
|
|
348
|
-
|
|
377
|
+
},
|
|
378
|
+
"type": "object"
|
|
349
379
|
},
|
|
350
|
-
|
|
351
|
-
"
|
|
352
|
-
|
|
353
|
-
|
|
380
|
+
{
|
|
381
|
+
"items": {
|
|
382
|
+
"additionalProperties": false,
|
|
383
|
+
"properties": {
|
|
384
|
+
"ignore": {
|
|
385
|
+
"items": {
|
|
386
|
+
"type": "string"
|
|
387
|
+
},
|
|
388
|
+
"type": "array"
|
|
389
|
+
},
|
|
390
|
+
"postdeploy": {
|
|
391
|
+
"anyOf": [
|
|
392
|
+
{
|
|
393
|
+
"items": {
|
|
394
|
+
"type": "string"
|
|
395
|
+
},
|
|
396
|
+
"type": "array"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"type": "string"
|
|
400
|
+
}
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
"predeploy": {
|
|
404
|
+
"anyOf": [
|
|
405
|
+
{
|
|
406
|
+
"items": {
|
|
407
|
+
"type": "string"
|
|
408
|
+
},
|
|
409
|
+
"type": "array"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"type": "string"
|
|
413
|
+
}
|
|
414
|
+
]
|
|
415
|
+
},
|
|
416
|
+
"runtime": {
|
|
417
|
+
"enum": [
|
|
418
|
+
"nodejs10",
|
|
419
|
+
"nodejs12",
|
|
420
|
+
"nodejs14",
|
|
421
|
+
"nodejs16"
|
|
422
|
+
],
|
|
354
423
|
"type": "string"
|
|
355
424
|
},
|
|
356
|
-
"
|
|
425
|
+
"source": {
|
|
426
|
+
"type": "string"
|
|
427
|
+
}
|
|
357
428
|
},
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
]
|
|
362
|
-
},
|
|
363
|
-
"runtime": {
|
|
364
|
-
"enum": [
|
|
365
|
-
"nodejs10",
|
|
366
|
-
"nodejs12",
|
|
367
|
-
"nodejs14",
|
|
368
|
-
"nodejs16"
|
|
369
|
-
],
|
|
370
|
-
"type": "string"
|
|
371
|
-
},
|
|
372
|
-
"source": {
|
|
373
|
-
"type": "string"
|
|
429
|
+
"type": "object"
|
|
430
|
+
},
|
|
431
|
+
"type": "array"
|
|
374
432
|
}
|
|
375
|
-
|
|
376
|
-
"type": "object"
|
|
433
|
+
]
|
|
377
434
|
},
|
|
378
435
|
"hosting": {
|
|
379
436
|
"anyOf": [
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListResponse = exports.ListItem = void 0;
|
|
4
|
-
class ListItem {
|
|
5
|
-
constructor(name, bucket) {
|
|
6
|
-
this.name = name;
|
|
7
|
-
this.bucket = bucket;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.ListItem = ListItem;
|
|
11
|
-
class ListResponse {
|
|
12
|
-
constructor(prefixes, items, nextPageToken) {
|
|
13
|
-
this.prefixes = prefixes;
|
|
14
|
-
this.items = items;
|
|
15
|
-
this.nextPageToken = nextPageToken;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ListResponse = ListResponse;
|