firebase-tools 11.1.0 → 11.2.2

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.
Files changed (101) hide show
  1. package/lib/accountExporter.js +11 -4
  2. package/lib/accountImporter.js +5 -6
  3. package/lib/appdistribution/client.js +7 -9
  4. package/lib/auth.js +3 -5
  5. package/lib/checkValidTargetFilters.js +28 -18
  6. package/lib/commands/database-profile.js +2 -3
  7. package/lib/commands/database-push.js +2 -3
  8. package/lib/commands/database-remove.js +1 -2
  9. package/lib/commands/database-set.js +1 -2
  10. package/lib/commands/deploy.js +5 -6
  11. package/lib/commands/ext-dev-emulators-exec.js +1 -1
  12. package/lib/commands/ext-dev-emulators-start.js +1 -1
  13. package/lib/commands/ext-dev-list.js +6 -7
  14. package/lib/commands/ext-export.js +2 -0
  15. package/lib/commands/ext-info.js +12 -13
  16. package/lib/commands/ext.js +2 -3
  17. package/lib/commands/functions-delete.js +1 -7
  18. package/lib/commands/open.js +5 -6
  19. package/lib/commands/serve.js +3 -5
  20. package/lib/commands/use.js +2 -3
  21. package/lib/config.js +4 -3
  22. package/lib/deploy/database/prepare.js +2 -3
  23. package/lib/deploy/extensions/planner.js +1 -0
  24. package/lib/deploy/extensions/prepare.js +18 -1
  25. package/lib/deploy/extensions/release.js +4 -0
  26. package/lib/deploy/extensions/secrets.js +3 -3
  27. package/lib/deploy/functions/build.js +35 -53
  28. package/lib/deploy/functions/ensure.js +1 -11
  29. package/lib/deploy/functions/params.js +189 -0
  30. package/lib/deploy/functions/prepare.js +3 -13
  31. package/lib/deploy/functions/prepareFunctionsUpload.js +2 -3
  32. package/lib/deploy/functions/release/fabricator.js +0 -1
  33. package/lib/deploy/functions/release/index.js +1 -5
  34. package/lib/deploy/functions/runtimes/discovery/index.js +18 -3
  35. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +3 -2
  36. package/lib/deploy/functions/runtimes/golang/index.js +2 -22
  37. package/lib/deploy/functions/runtimes/node/index.js +3 -7
  38. package/lib/deploy/functions/runtimes/node/parseTriggers.js +2 -2
  39. package/lib/deploy/lifecycleHooks.js +8 -11
  40. package/lib/deploy/storage/prepare.js +2 -2
  41. package/lib/emulator/auth/index.js +1 -1
  42. package/lib/emulator/auth/operations.js +336 -64
  43. package/lib/emulator/auth/server.js +2 -2
  44. package/lib/emulator/auth/state.js +32 -7
  45. package/lib/emulator/commandUtils.js +1 -1
  46. package/lib/emulator/constants.js +1 -1
  47. package/lib/emulator/controller.js +6 -5
  48. package/lib/emulator/databaseEmulator.js +2 -2
  49. package/lib/emulator/download.js +1 -1
  50. package/lib/emulator/downloadableEmulators.js +6 -6
  51. package/lib/emulator/events/types.js +2 -3
  52. package/lib/emulator/firestoreEmulator.js +2 -2
  53. package/lib/emulator/functionsEmulator.js +36 -45
  54. package/lib/emulator/functionsEmulatorRuntime.js +12 -16
  55. package/lib/emulator/functionsEmulatorShared.js +7 -5
  56. package/lib/emulator/functionsRuntimeWorker.js +0 -6
  57. package/lib/emulator/hostingEmulator.js +1 -1
  58. package/lib/emulator/hub.js +1 -1
  59. package/lib/emulator/loggingEmulator.js +1 -1
  60. package/lib/emulator/pubsubEmulator.js +1 -1
  61. package/lib/emulator/storage/crc.js +4 -4
  62. package/lib/emulator/storage/index.js +1 -1
  63. package/lib/emulator/types.js +1 -1
  64. package/lib/extensions/askUserForConsent.js +1 -2
  65. package/lib/extensions/askUserForParam.js +15 -18
  66. package/lib/extensions/emulator/optionsHelper.js +4 -4
  67. package/lib/extensions/etags.js +28 -0
  68. package/lib/extensions/extensionsApi.js +1 -22
  69. package/lib/extensions/extensionsHelper.js +6 -6
  70. package/lib/extensions/listExtensions.js +9 -10
  71. package/lib/extensions/manifest.js +2 -2
  72. package/lib/extensions/resolveSource.js +11 -7
  73. package/lib/extensions/secretsUtils.js +3 -3
  74. package/lib/extensions/types.js +24 -0
  75. package/lib/extensions/updateHelper.js +1 -1
  76. package/lib/extensions/utils.js +1 -2
  77. package/lib/extensions/warnings.js +10 -4
  78. package/lib/firestore/encodeFirestoreValue.js +11 -8
  79. package/lib/fsAsync.js +3 -3
  80. package/lib/functions/env.js +5 -1
  81. package/lib/functionsConfig.js +18 -15
  82. package/lib/functionsConfigClone.js +10 -12
  83. package/lib/gcp/cloudfunctions.js +2 -15
  84. package/lib/gcp/rules.js +3 -4
  85. package/lib/gcp/runtimeconfig.js +2 -2
  86. package/lib/hosting/api.js +9 -11
  87. package/lib/hosting/expireUtils.js +2 -2
  88. package/lib/hosting/proxy.js +1 -1
  89. package/lib/init/features/hosting/github.js +1 -1
  90. package/lib/init/features/hosting/index.js +2 -2
  91. package/lib/localFunction.js +4 -4
  92. package/lib/management/projects.js +6 -7
  93. package/lib/previews.js +1 -1
  94. package/lib/profileReport.js +24 -22
  95. package/lib/prompt.js +1 -2
  96. package/lib/rc.js +12 -2
  97. package/lib/rulesDeploy.js +2 -2
  98. package/lib/serve/index.js +4 -5
  99. package/lib/utils.js +30 -6
  100. package/npm-shrinkwrap.json +2 -2
  101. package/package.json +10 -9
@@ -200,7 +200,8 @@ function assertManifestEndpoint(ep, id) {
200
200
  function parseEndpointForBuild(id, ep, project, defaultRegion, runtime) {
201
201
  let triggered;
202
202
  if (backend.isEventTriggered(ep)) {
203
- const _a = ep.eventTrigger, { serviceAccountEmail } = _a, newTrigger = __rest(_a, ["serviceAccountEmail"]);
203
+ const newTrigger = __rest(ep.eventTrigger, []);
204
+ delete newTrigger.serviceAccountEmail;
204
205
  triggered = { eventTrigger: newTrigger };
205
206
  triggered.eventTrigger.serviceAccount = ep.eventTrigger.serviceAccountEmail;
206
207
  (0, proto_1.renameIfPresent)(triggered.eventTrigger, ep.eventTrigger, "channel", "channel", (c) => resolveChannelName(project, c, defaultRegion));
@@ -264,7 +265,7 @@ function parseEndpointForBuild(id, ep, project, defaultRegion, runtime) {
264
265
  "firebase-tools with npm install -g firebase-tools@latest");
265
266
  }
266
267
  const parsed = Object.assign({ platform: ep.platform || "gcfv2", region: ep.region || [defaultRegion], project,
267
- runtime, entryPoint: ep.entryPoint, serviceAccount: ep.serviceAccountEmail || "default" }, triggered);
268
+ runtime, entryPoint: ep.entryPoint, serviceAccount: ep.serviceAccountEmail || null }, triggered);
268
269
  (0, proto_1.copyIfPresent)(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "timeoutSeconds", "vpc", "labels", "ingressSettings", "environmentVariables");
269
270
  (0, proto_1.renameIfPresent)(parsed, ep, "secretEnvironmentVariables", "secretEnvironmentVariables", (senvs) => {
270
271
  const secretEnvironmentVariables = [];
@@ -5,11 +5,9 @@ const util_1 = require("util");
5
5
  const node_fetch_1 = require("node-fetch");
6
6
  const fs = require("fs");
7
7
  const path = require("path");
8
- const portfinder = require("portfinder");
9
8
  const spawn = require("cross-spawn");
10
9
  const error_1 = require("../../../../error");
11
10
  const logger_1 = require("../../../../logger");
12
- const discovery = require("../discovery");
13
11
  const gomod = require("./gomod");
14
12
  const VERSION_TO_RUNTIME = {
15
13
  "1.13": "go113",
@@ -105,26 +103,8 @@ class Delegate {
105
103
  return p;
106
104
  });
107
105
  }
108
- async discoverBuild(configValues, envs) {
109
- return { requiredAPIs: [], endpoints: {}, params: [] };
110
- }
111
- async discoverSpec(configValues, envs) {
112
- let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
113
- if (!discovered) {
114
- const getPort = (0, util_1.promisify)(portfinder.getPort);
115
- const port = await getPort();
116
- portfinder.basePort = port + 1;
117
- const adminPort = await getPort();
118
- const kill = await this.serve(port, adminPort, envs);
119
- try {
120
- discovered = await discovery.detectFromPort(adminPort, this.projectId, this.runtime);
121
- }
122
- finally {
123
- await kill();
124
- }
125
- }
126
- discovered.environmentVariables = envs;
127
- return discovered;
106
+ async discoverBuild() {
107
+ return Promise.resolve({ requiredAPIs: [], endpoints: {}, params: [] });
128
108
  }
129
109
  }
130
110
  exports.Delegate = Delegate;
@@ -85,15 +85,15 @@ class Delegate {
85
85
  return p;
86
86
  });
87
87
  }
88
- async discoverSpec(config, env) {
88
+ async discoverBuild(config, env) {
89
89
  if (!semver.valid(this.sdkVersion)) {
90
90
  logger_1.logger.debug(`Could not parse firebase-functions version '${this.sdkVersion}' into semver. Falling back to parseTriggers.`);
91
- return parseTriggers.discoverBackend(this.projectId, this.sourceDir, this.runtime, config, env);
91
+ return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
92
92
  }
93
93
  if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION)) {
94
94
  (0, utils_1.logLabeledWarning)("functions", `You are using an old version of firebase-functions SDK (${this.sdkVersion}). ` +
95
95
  `Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION}`);
96
- return parseTriggers.discoverBackend(this.projectId, this.sourceDir, this.runtime, config, env);
96
+ return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
97
97
  }
98
98
  let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
99
99
  if (!discovered) {
@@ -107,11 +107,7 @@ class Delegate {
107
107
  await kill();
108
108
  }
109
109
  }
110
- discovered.environmentVariables = env;
111
110
  return discovered;
112
111
  }
113
- async discoverBuild(config, env) {
114
- return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
115
- }
116
112
  }
117
113
  exports.Delegate = Delegate;
@@ -45,7 +45,7 @@ function parseTriggers(projectId, sourceDir, configValues, envs) {
45
45
  });
46
46
  });
47
47
  }
48
- function useStrategy(context) {
48
+ function useStrategy() {
49
49
  return Promise.resolve(true);
50
50
  }
51
51
  exports.useStrategy = useStrategy;
@@ -179,7 +179,7 @@ function addResourcesToBuild(projectId, runtime, annotation, want) {
179
179
  };
180
180
  }
181
181
  const endpointId = annotation.name;
182
- const endpoint = Object.assign({ platform: annotation.platform || "gcfv1", region: regions, project: projectId, entryPoint: annotation.entryPoint, runtime: runtime, serviceAccount: annotation.serviceAccountEmail || "default" }, triggered);
182
+ const endpoint = Object.assign({ platform: annotation.platform || "gcfv1", region: regions, project: projectId, entryPoint: annotation.entryPoint, runtime: runtime, serviceAccount: annotation.serviceAccountEmail || null }, triggered);
183
183
  if (annotation.vpcConnector != null) {
184
184
  let maybeId = annotation.vpcConnector;
185
185
  if (maybeId && !maybeId.includes("/")) {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lifecycleHooks = void 0;
4
- const _ = require("lodash");
5
4
  const utils = require("../utils");
6
5
  const clc = require("cli-color");
7
6
  const childProcess = require("child_process");
@@ -32,7 +31,7 @@ function runCommand(command, childOptions) {
32
31
  reject(new Error("Command terminated with signal " + signal));
33
32
  }
34
33
  else if (code !== 0) {
35
- reject(new Error("Command terminated with non-zero exit code" + code));
34
+ reject(new Error("Command terminated with non-zero exit code " + code));
36
35
  }
37
36
  else {
38
37
  resolve();
@@ -54,7 +53,7 @@ function getChildEnvironment(target, overallOptions, config) {
54
53
  default:
55
54
  resourceDir = overallOptions.config.path(overallOptions.config.projectDir);
56
55
  }
57
- return _.assign({}, process.env, {
56
+ return Object.assign({}, process.env, {
58
57
  GCLOUD_PROJECT: projectId,
59
58
  PROJECT_DIR: projectDir,
60
59
  RESOURCE_DIR: resourceDir,
@@ -74,10 +73,8 @@ function runTargetCommands(target, hook, overallOptions, config) {
74
73
  shell: true,
75
74
  stdio: [0, 1, 2],
76
75
  };
77
- const runAllCommands = _.reduce(commands, (soFar, command) => {
78
- return soFar.then(() => {
79
- return runCommand(command, childOptions);
80
- });
76
+ const runAllCommands = commands.reduce((soFar, command) => {
77
+ return soFar.then(() => runCommand(command, childOptions));
81
78
  }, Promise.resolve());
82
79
  let logIdentifier = target;
83
80
  if (config.target) {
@@ -96,14 +93,14 @@ function getReleventConfigs(target, options) {
96
93
  if (!targetConfigs) {
97
94
  return [];
98
95
  }
99
- if (!_.isArray(targetConfigs)) {
96
+ if (!Array.isArray(targetConfigs)) {
100
97
  targetConfigs = [targetConfigs];
101
98
  }
102
99
  if (!options.only) {
103
100
  return targetConfigs;
104
101
  }
105
102
  let onlyTargets = options.only.split(",");
106
- if (_.includes(onlyTargets, target)) {
103
+ if (onlyTargets.includes(target)) {
107
104
  return targetConfigs;
108
105
  }
109
106
  onlyTargets = onlyTargets
@@ -114,12 +111,12 @@ function getReleventConfigs(target, options) {
114
111
  return individualOnly.replace(`${target}:`, "");
115
112
  });
116
113
  return targetConfigs.filter((config) => {
117
- return !config.target || _.includes(onlyTargets, config.target);
114
+ return !config.target || onlyTargets.includes(config.target);
118
115
  });
119
116
  }
120
117
  function lifecycleHooks(target, hook) {
121
118
  return function (context, options) {
122
- return _.reduce(getReleventConfigs(target, options), (previousCommands, individualConfig) => {
119
+ return getReleventConfigs(target, options).reduce((previousCommands, individualConfig) => {
123
120
  return previousCommands.then(() => {
124
121
  return runTargetCommands(target, hook, options, individualConfig);
125
122
  });
@@ -11,9 +11,9 @@ async function default_1(context, options) {
11
11
  _.set(context, "storage.rules", rulesConfig);
12
12
  const rulesDeploy = new rulesDeploy_1.RulesDeploy(options, rulesDeploy_1.RulesetServiceType.FIREBASE_STORAGE);
13
13
  _.set(context, "storage.rulesDeploy", rulesDeploy);
14
- if (_.isPlainObject(rulesConfig)) {
14
+ if (typeof rulesConfig === "object" && rulesConfig !== null) {
15
15
  const defaultBucket = await gcp.storage.getDefaultBucket(options.project);
16
- rulesConfig = [_.assign(rulesConfig, { bucket: defaultBucket })];
16
+ rulesConfig = [Object.assign(rulesConfig, { bucket: defaultBucket })];
17
17
  _.set(context, "storage.rules", rulesConfig);
18
18
  }
19
19
  rulesConfig.forEach((ruleConfig) => {
@@ -26,7 +26,7 @@ class AuthEmulator {
26
26
  return this.destroyServer ? this.destroyServer() : Promise.resolve();
27
27
  }
28
28
  getInfo() {
29
- const host = this.args.host || constants_1.Constants.getDefaultHost(types_1.Emulators.AUTH);
29
+ const host = this.args.host || constants_1.Constants.getDefaultHost();
30
30
  const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.AUTH);
31
31
  return {
32
32
  name: this.getName(),