firebase-tools 10.0.1 → 10.1.3

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 (254) hide show
  1. package/lib/accountExporter.js +9 -8
  2. package/lib/accountImporter.js +10 -8
  3. package/lib/api.js +1 -0
  4. package/lib/apiv2.js +91 -48
  5. package/lib/appdistribution/client.js +1 -1
  6. package/lib/appdistribution/options-parser-util.js +1 -1
  7. package/lib/archiveDirectory.js +63 -73
  8. package/lib/auth.js +2 -2
  9. package/lib/bin/firebase.js +1 -1
  10. package/lib/command.js +26 -26
  11. package/lib/commands/appdistribution-distribute.js +4 -4
  12. package/lib/commands/appdistribution-testers-add.js +2 -2
  13. package/lib/commands/appdistribution-testers-remove.js +2 -2
  14. package/lib/commands/apps-android-sha-create.js +2 -2
  15. package/lib/commands/apps-android-sha-delete.js +2 -2
  16. package/lib/commands/apps-android-sha-list.js +2 -2
  17. package/lib/commands/apps-create.js +9 -9
  18. package/lib/commands/apps-list.js +3 -3
  19. package/lib/commands/apps-sdkconfig.js +8 -8
  20. package/lib/commands/auth-export.js +26 -25
  21. package/lib/commands/auth-import.js +88 -78
  22. package/lib/commands/database-get.js +1 -1
  23. package/lib/commands/database-instances-create.js +4 -4
  24. package/lib/commands/database-instances-list.js +4 -4
  25. package/lib/commands/database-profile.js +1 -1
  26. package/lib/commands/database-push.js +1 -1
  27. package/lib/commands/database-remove.js +2 -2
  28. package/lib/commands/database-set.js +2 -2
  29. package/lib/commands/database-settings-get.js +1 -1
  30. package/lib/commands/database-settings-set.js +1 -1
  31. package/lib/commands/database-update.js +2 -2
  32. package/lib/commands/ext-configure.js +3 -3
  33. package/lib/commands/ext-dev-deprecate.js +4 -4
  34. package/lib/commands/ext-dev-extension-delete.js +3 -3
  35. package/lib/commands/ext-dev-init.js +4 -4
  36. package/lib/commands/ext-dev-list.js +1 -1
  37. package/lib/commands/ext-dev-publish.js +4 -4
  38. package/lib/commands/ext-dev-register.js +6 -6
  39. package/lib/commands/ext-dev-undeprecate.js +4 -4
  40. package/lib/commands/ext-dev-unpublish.js +3 -3
  41. package/lib/commands/ext-dev-usage.js +140 -0
  42. package/lib/commands/ext-export.js +8 -8
  43. package/lib/commands/ext-info.js +5 -5
  44. package/lib/commands/ext-install.js +27 -23
  45. package/lib/commands/ext-list.js +2 -2
  46. package/lib/commands/ext-sources-create.js +2 -2
  47. package/lib/commands/ext-uninstall.js +4 -4
  48. package/lib/commands/ext-update.js +18 -18
  49. package/lib/commands/ext.js +3 -3
  50. package/lib/commands/firestore-delete.js +1 -1
  51. package/lib/commands/functions-config-clone.js +22 -23
  52. package/lib/commands/functions-config-export.js +11 -11
  53. package/lib/commands/functions-config-get.js +22 -22
  54. package/lib/commands/functions-config-set.js +24 -22
  55. package/lib/commands/functions-config-unset.js +20 -22
  56. package/lib/commands/functions-delete.js +3 -3
  57. package/lib/commands/functions-deletegcfartifacts.js +4 -4
  58. package/lib/commands/functions-list.js +1 -1
  59. package/lib/commands/functions-log.js +1 -1
  60. package/lib/commands/help.js +12 -12
  61. package/lib/commands/hosting-channel-create.js +13 -13
  62. package/lib/commands/hosting-channel-delete.js +10 -10
  63. package/lib/commands/hosting-channel-deploy.js +18 -18
  64. package/lib/commands/hosting-channel-list.js +5 -5
  65. package/lib/commands/hosting-channel-open.js +9 -9
  66. package/lib/commands/hosting-clone.js +16 -16
  67. package/lib/commands/hosting-disable.js +1 -1
  68. package/lib/commands/hosting-sites-create.js +7 -7
  69. package/lib/commands/hosting-sites-delete.js +7 -7
  70. package/lib/commands/hosting-sites-get.js +2 -2
  71. package/lib/commands/hosting-sites-list.js +3 -3
  72. package/lib/commands/index.js +1 -0
  73. package/lib/commands/login-ci.js +10 -10
  74. package/lib/commands/login.js +2 -2
  75. package/lib/commands/logout.js +1 -1
  76. package/lib/commands/open.js +1 -1
  77. package/lib/commands/projects-addfirebase.js +2 -2
  78. package/lib/commands/projects-create.js +2 -2
  79. package/lib/commands/projects-list.js +1 -1
  80. package/lib/commands/remoteconfig-get.js +3 -3
  81. package/lib/commands/remoteconfig-rollback.js +3 -3
  82. package/lib/commands/remoteconfig-versions-list.js +7 -2
  83. package/lib/commands/setup-emulators-database.js +8 -7
  84. package/lib/commands/setup-emulators-firestore.js +8 -7
  85. package/lib/commands/setup-emulators-pubsub.js +5 -4
  86. package/lib/commands/setup-emulators-storage.js +4 -3
  87. package/lib/commands/setup-emulators-ui.js +8 -7
  88. package/lib/commands/target-apply.js +17 -16
  89. package/lib/commands/target-clear.js +11 -10
  90. package/lib/commands/target-remove.js +10 -9
  91. package/lib/commands/target.js +20 -20
  92. package/lib/config.js +6 -6
  93. package/lib/database/api.js +2 -2
  94. package/lib/database/metadata.js +16 -24
  95. package/lib/defaultCredentials.js +3 -3
  96. package/lib/deploy/extensions/deploy.js +4 -4
  97. package/lib/deploy/extensions/deploymentSummary.js +5 -4
  98. package/lib/deploy/extensions/index.js +1 -0
  99. package/lib/deploy/extensions/params.js +1 -1
  100. package/lib/deploy/extensions/planner.js +3 -3
  101. package/lib/deploy/extensions/prepare.js +9 -9
  102. package/lib/deploy/extensions/release.js +1 -1
  103. package/lib/deploy/extensions/secrets.js +7 -7
  104. package/lib/deploy/extensions/validate.js +2 -2
  105. package/lib/deploy/functions/backend.js +9 -5
  106. package/lib/deploy/functions/checkIam.js +7 -7
  107. package/lib/deploy/functions/containerCleaner.js +3 -3
  108. package/lib/deploy/functions/deploy.js +4 -4
  109. package/lib/deploy/functions/ensureCloudBuildEnabled.js +3 -3
  110. package/lib/deploy/functions/index.js +1 -0
  111. package/lib/deploy/functions/prepare.js +29 -23
  112. package/lib/deploy/functions/prompts.js +5 -5
  113. package/lib/deploy/functions/release/executor.js +4 -1
  114. package/lib/deploy/functions/release/fabricator.js +9 -6
  115. package/lib/deploy/functions/release/index.js +2 -2
  116. package/lib/deploy/functions/release/planner.js +6 -6
  117. package/lib/deploy/functions/release/reporter.js +8 -4
  118. package/lib/deploy/functions/runtimes/discovery/index.js +2 -2
  119. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +14 -14
  120. package/lib/deploy/functions/runtimes/golang/index.js +11 -14
  121. package/lib/deploy/functions/runtimes/index.js +6 -10
  122. package/lib/deploy/functions/runtimes/node/index.js +6 -10
  123. package/lib/deploy/functions/runtimes/node/parseTriggers.js +3 -3
  124. package/lib/deploy/functions/runtimes/node/validate.js +2 -1
  125. package/lib/deploy/functions/services/storage.js +1 -1
  126. package/lib/deploy/functions/triggerRegionHelper.js +1 -1
  127. package/lib/deploy/functions/validate.js +32 -4
  128. package/lib/deploy/hosting/convertConfig.js +45 -24
  129. package/lib/deploy/hosting/deploy.js +7 -7
  130. package/lib/deploy/hosting/prepare.js +1 -1
  131. package/lib/deploy/hosting/uploader.js +1 -1
  132. package/lib/deploy/hosting/validate.js +3 -3
  133. package/lib/deploy/remoteconfig/prepare.js +3 -3
  134. package/lib/deploy/remoteconfig/release.js +3 -3
  135. package/lib/deploy/storage/deploy.js +1 -1
  136. package/lib/deploy/storage/release.js +2 -2
  137. package/lib/detectProjectRoot.js +5 -5
  138. package/lib/emulator/auth/apiSpec.js +13 -7
  139. package/lib/emulator/auth/handlers.js +3 -3
  140. package/lib/emulator/auth/index.js +1 -1
  141. package/lib/emulator/auth/operations.js +256 -248
  142. package/lib/emulator/auth/server.js +11 -8
  143. package/lib/emulator/auth/state.js +12 -12
  144. package/lib/emulator/commandUtils.js +5 -5
  145. package/lib/emulator/controller.js +16 -11
  146. package/lib/emulator/downloadableEmulators.js +5 -4
  147. package/lib/emulator/emulatorLogger.js +1 -1
  148. package/lib/emulator/functionsEmulator.js +110 -75
  149. package/lib/emulator/functionsEmulatorRuntime.js +36 -21
  150. package/lib/emulator/functionsEmulatorShell.js +3 -2
  151. package/lib/emulator/functionsRuntimeWorker.js +1 -1
  152. package/lib/emulator/hubExport.js +2 -2
  153. package/lib/emulator/storage/apis/firebase.js +2 -2
  154. package/lib/emulator/storage/apis/gcloud.js +2 -2
  155. package/lib/emulator/storage/cloudFunctions.js +1 -1
  156. package/lib/emulator/storage/files.js +14 -14
  157. package/lib/emulator/storage/index.js +2 -2
  158. package/lib/emulator/storage/metadata.js +7 -6
  159. package/lib/emulator/storage/rules/runtime.js +10 -9
  160. package/lib/emulator/storage/server.js +2 -2
  161. package/lib/ensureApiEnabled.js +7 -7
  162. package/lib/error.js +3 -3
  163. package/lib/extensions/askUserForConsent.js +3 -4
  164. package/lib/extensions/askUserForParam.js +11 -11
  165. package/lib/extensions/billingMigrationHelper.js +2 -2
  166. package/lib/extensions/changelog.js +4 -4
  167. package/lib/extensions/displayExtensionInfo.js +6 -6
  168. package/lib/extensions/emulator/optionsHelper.js +1 -1
  169. package/lib/extensions/emulator/specHelper.js +1 -1
  170. package/lib/extensions/emulator/triggerHelper.js +1 -1
  171. package/lib/extensions/export.js +6 -6
  172. package/lib/extensions/extensionsApi.js +68 -110
  173. package/lib/extensions/extensionsHelper.js +56 -43
  174. package/lib/extensions/listExtensions.js +1 -1
  175. package/lib/extensions/localHelper.js +1 -1
  176. package/lib/extensions/metricsTypeDef.js +2 -0
  177. package/lib/extensions/metricsUtils.js +98 -0
  178. package/lib/extensions/paramHelper.js +6 -6
  179. package/lib/extensions/provisioningHelper.js +13 -14
  180. package/lib/extensions/resolveSource.js +6 -6
  181. package/lib/extensions/secretsUtils.js +3 -3
  182. package/lib/extensions/updateHelper.js +10 -10
  183. package/lib/extensions/utils.js +1 -1
  184. package/lib/extensions/warnings.js +11 -10
  185. package/lib/fetchWebSetup.js +2 -2
  186. package/lib/filterTargets.js +2 -2
  187. package/lib/firestore/indexes.js +2 -2
  188. package/lib/fsAsync.js +3 -3
  189. package/lib/fsutils.js +2 -2
  190. package/lib/functional.js +2 -1
  191. package/lib/functions/env.js +1 -1
  192. package/lib/functions/runtimeConfigExport.js +4 -4
  193. package/lib/functionsConfig.js +7 -8
  194. package/lib/functionsShellCommandAction.js +4 -3
  195. package/lib/gcp/cloudbilling.js +8 -19
  196. package/lib/gcp/cloudfunctions.js +22 -46
  197. package/lib/gcp/cloudlogging.js +8 -11
  198. package/lib/gcp/cloudmonitoring.js +77 -0
  199. package/lib/gcp/cloudscheduler.js +8 -19
  200. package/lib/gcp/firedata.js +5 -4
  201. package/lib/gcp/firestore.js +5 -5
  202. package/lib/gcp/iam.js +19 -34
  203. package/lib/gcp/resourceManager.js +10 -15
  204. package/lib/gcp/rules.js +18 -41
  205. package/lib/gcp/runtimeconfig.js +31 -53
  206. package/lib/gcp/secretManager.js +24 -45
  207. package/lib/gcp/storage.js +24 -29
  208. package/lib/getDefaultDatabaseInstance.js +1 -1
  209. package/lib/getDefaultHostingSite.js +1 -1
  210. package/lib/getProjectNumber.js +2 -2
  211. package/lib/handlePreviewToggles.js +5 -5
  212. package/lib/hosting/api.js +6 -6
  213. package/lib/hosting/cloudRunProxy.js +6 -6
  214. package/lib/hosting/functionsProxy.js +3 -3
  215. package/lib/hosting/implicitInit.js +2 -2
  216. package/lib/hosting/normalizedHostingConfigs.js +3 -3
  217. package/lib/hosting/proxy.js +2 -2
  218. package/lib/init/features/account.js +7 -7
  219. package/lib/init/features/database.js +9 -9
  220. package/lib/init/features/emulators.js +8 -8
  221. package/lib/init/features/firestore/index.js +3 -3
  222. package/lib/init/features/firestore/indexes.js +2 -2
  223. package/lib/init/features/firestore/rules.js +2 -2
  224. package/lib/init/features/functions/golang.js +4 -4
  225. package/lib/init/features/functions/index.js +4 -4
  226. package/lib/init/features/hosting/github.js +31 -31
  227. package/lib/init/features/project.js +8 -8
  228. package/lib/init/features/remoteconfig.js +2 -2
  229. package/lib/init/features/storage.js +2 -2
  230. package/lib/listFiles.js +1 -1
  231. package/lib/management/apps.js +3 -3
  232. package/lib/management/projects.js +6 -6
  233. package/lib/previews.js +2 -2
  234. package/lib/profiler.js +1 -1
  235. package/lib/projectPath.js +1 -1
  236. package/lib/projectUtils.js +2 -2
  237. package/lib/prompt.js +0 -1
  238. package/lib/rc.js +1 -1
  239. package/lib/remoteconfig/get.js +14 -8
  240. package/lib/remoteconfig/rollback.js +13 -6
  241. package/lib/remoteconfig/versionslist.js +13 -7
  242. package/lib/requireAuth.js +2 -2
  243. package/lib/requireDatabaseInstance.js +1 -1
  244. package/lib/requireHostingSite.js +1 -1
  245. package/lib/requirePermissions.js +4 -4
  246. package/lib/rulesDeploy.js +2 -2
  247. package/lib/serve/functions.js +14 -7
  248. package/lib/serve/hosting.js +7 -7
  249. package/lib/utils.js +3 -2
  250. package/npm-shrinkwrap.json +24090 -0
  251. package/package.json +36 -31
  252. package/schema/firebase-config.json +387 -12
  253. package/lib/commands/functions-config-legacy.js +0 -45
  254. package/lib/prepareFirebaseRules.js +0 -58
@@ -6,7 +6,7 @@ const fsutils = require("../../fsutils");
6
6
  const clc = require("cli-color");
7
7
  async function doSetup(setup, config) {
8
8
  setup.config.remoteconfig = {};
9
- const jsonFilePath = await prompt_1.promptOnce({
9
+ const jsonFilePath = await (0, prompt_1.promptOnce)({
10
10
  type: "input",
11
11
  name: "template",
12
12
  message: "What file should be used for your Remote Config template?",
@@ -17,7 +17,7 @@ async function doSetup(setup, config) {
17
17
  clc.bold(jsonFilePath) +
18
18
  " already exists." +
19
19
  " Do you want to overwrite the existing Remote Config template?";
20
- const overwrite = await prompt_1.promptOnce({
20
+ const overwrite = await (0, prompt_1.promptOnce)({
21
21
  type: "confirm",
22
22
  message: msg,
23
23
  default: false,
@@ -9,13 +9,13 @@ const ensureCloudResourceLocation_1 = require("../../ensureCloudResourceLocation
9
9
  const RULES_TEMPLATE = fs.readFileSync(__dirname + "/../../../templates/init/storage/storage.rules", "utf8");
10
10
  async function doSetup(setup, config) {
11
11
  setup.config.storage = {};
12
- ensureCloudResourceLocation_1.ensureLocationSet(setup.projectLocation, "Cloud Storage");
12
+ (0, ensureCloudResourceLocation_1.ensureLocationSet)(setup.projectLocation, "Cloud Storage");
13
13
  logger_1.logger.info();
14
14
  logger_1.logger.info("Firebase Storage Security Rules allow you to define how and when to allow");
15
15
  logger_1.logger.info("uploads and downloads. You can keep these rules in your project directory");
16
16
  logger_1.logger.info("and publish them with " + clc.bold("firebase deploy") + ".");
17
17
  logger_1.logger.info();
18
- const storageRulesFile = await prompt_1.promptOnce({
18
+ const storageRulesFile = await (0, prompt_1.promptOnce)({
19
19
  type: "input",
20
20
  name: "rules",
21
21
  message: "What file should be used for Storage Rules?",
package/lib/listFiles.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listFiles = void 0;
4
4
  const glob_1 = require("glob");
5
5
  function listFiles(cwd, ignore = []) {
6
- return glob_1.sync("**/*", {
6
+ return (0, glob_1.sync)("**/*", {
7
7
  cwd,
8
8
  dot: true,
9
9
  follow: true,
@@ -47,7 +47,7 @@ async function createIosApp(projectId, options) {
47
47
  timeout: CREATE_APP_API_REQUEST_TIMEOUT_MILLIS,
48
48
  data: options,
49
49
  });
50
- const appData = await operation_poller_1.pollOperation({
50
+ const appData = await (0, operation_poller_1.pollOperation)({
51
51
  pollerName: "Create iOS app Poller",
52
52
  apiOrigin: api.firebaseApiOrigin,
53
53
  apiVersion: "v1beta1",
@@ -69,7 +69,7 @@ async function createAndroidApp(projectId, options) {
69
69
  timeout: CREATE_APP_API_REQUEST_TIMEOUT_MILLIS,
70
70
  data: options,
71
71
  });
72
- const appData = await operation_poller_1.pollOperation({
72
+ const appData = await (0, operation_poller_1.pollOperation)({
73
73
  pollerName: "Create Android app Poller",
74
74
  apiOrigin: api.firebaseApiOrigin,
75
75
  apiVersion: "v1beta1",
@@ -94,7 +94,7 @@ async function createWebApp(projectId, options) {
94
94
  timeout: CREATE_APP_API_REQUEST_TIMEOUT_MILLIS,
95
95
  data: options,
96
96
  });
97
- const appData = await operation_poller_1.pollOperation({
97
+ const appData = await (0, operation_poller_1.pollOperation)({
98
98
  pollerName: "Create Web app Poller",
99
99
  apiOrigin: api.firebaseApiOrigin,
100
100
  apiVersion: "v1beta1",
@@ -103,7 +103,7 @@ async function selectProjectInteractively(pageSize = MAXIMUM_PROMPT_LIST) {
103
103
  return selectProjectFromList(projects);
104
104
  }
105
105
  async function selectProjectByPrompting() {
106
- const projectId = await prompt_1.promptOnce({
106
+ const projectId = await (0, prompt_1.promptOnce)({
107
107
  type: "input",
108
108
  message: "Please input the project ID you would like to use:",
109
109
  });
@@ -123,7 +123,7 @@ async function selectProjectFromList(projects = []) {
123
123
  utils.logBullet(`Don't want to scroll through all your projects? If you know your project ID, ` +
124
124
  `you can initialize it directly using ${clc.bold("firebase init --project <project_id>")}.\n`);
125
125
  }
126
- const projectId = await prompt_1.promptOnce({
126
+ const projectId = await (0, prompt_1.promptOnce)({
127
127
  type: "list",
128
128
  name: "id",
129
129
  message: "Select a default Firebase project for this directory:",
@@ -145,7 +145,7 @@ async function promptAvailableProjectId() {
145
145
  throw new error_1.FirebaseError("There are no available Google Cloud projects to add Firebase services.");
146
146
  }
147
147
  if (nextPageToken) {
148
- return await prompt_1.promptOnce({
148
+ return await (0, prompt_1.promptOnce)({
149
149
  type: "input",
150
150
  message: "Please input the ID of the Google Cloud Project you would like to add Firebase:",
151
151
  });
@@ -161,7 +161,7 @@ async function promptAvailableProjectId() {
161
161
  };
162
162
  });
163
163
  choices = _.orderBy(choices, ["name"], ["asc"]);
164
- return await prompt_1.promptOnce({
164
+ return await (0, prompt_1.promptOnce)({
165
165
  type: "list",
166
166
  name: "id",
167
167
  message: "Select the Google Cloud Platform project you would like to add Firebase:",
@@ -178,7 +178,7 @@ async function createCloudProject(projectId, options) {
178
178
  timeout: CREATE_PROJECT_API_REQUEST_TIMEOUT_MILLIS,
179
179
  data: { projectId, name: options.displayName || projectId, parent: options.parentResource },
180
180
  });
181
- const projectInfo = await operation_poller_1.pollOperation({
181
+ const projectInfo = await (0, operation_poller_1.pollOperation)({
182
182
  pollerName: "Project Creation Poller",
183
183
  apiOrigin: api.resourceManagerOrigin,
184
184
  apiVersion: "v1",
@@ -209,7 +209,7 @@ async function addFirebaseToCloudProject(projectId) {
209
209
  origin: api.firebaseApiOrigin,
210
210
  timeout: CREATE_PROJECT_API_REQUEST_TIMEOUT_MILLIS,
211
211
  });
212
- const projectInfo = await operation_poller_1.pollOperation({
212
+ const projectInfo = await (0, operation_poller_1.pollOperation)({
213
213
  pollerName: "Add Firebase Poller",
214
214
  apiOrigin: api.firebaseApiOrigin,
215
215
  apiVersion: "v1beta1",
package/lib/previews.js CHANGED
@@ -6,8 +6,8 @@ const configstore_1 = require("./configstore");
6
6
  exports.previews = Object.assign({ rtdbrules: false, ext: false, extdev: false, rtdbmanagement: false, functionsv2: false, golang: false, deletegcfartifacts: false, dotenv: false, artifactregistry: false }, configstore_1.configstore.get("previews"));
7
7
  if (process.env.FIREBASE_CLI_PREVIEWS) {
8
8
  process.env.FIREBASE_CLI_PREVIEWS.split(",").forEach((feature) => {
9
- if (lodash_1.has(exports.previews, feature)) {
10
- lodash_1.set(exports.previews, feature, true);
9
+ if ((0, lodash_1.has)(exports.previews, feature)) {
10
+ (0, lodash_1.set)(exports.previews, feature, true);
11
11
  }
12
12
  });
13
13
  }
package/lib/profiler.js CHANGED
@@ -14,7 +14,7 @@ const responseToError = require("./responseToError");
14
14
  const utils = require("./utils");
15
15
  tmp.setGracefulCleanup();
16
16
  async function profiler(options) {
17
- const origin = api_1.realtimeOriginOrEmulatorOrCustomUrl(options.instanceDetails.databaseUrl);
17
+ const origin = (0, api_1.realtimeOriginOrEmulatorOrCustomUrl)(options.instanceDetails.databaseUrl);
18
18
  const url = new URL(utils.getDatabaseUrl(origin, options.instance, "/.settings/profile.json?"));
19
19
  const rl = readline.createInterface({ input: process.stdin });
20
20
  const fileOut = !!options.output;
@@ -5,7 +5,7 @@ const path = require("path");
5
5
  const detectProjectRoot_1 = require("./detectProjectRoot");
6
6
  const error_1 = require("./error");
7
7
  function resolveProjectPath(options, filePath) {
8
- const projectRoot = detectProjectRoot_1.detectProjectRoot(options);
8
+ const projectRoot = (0, detectProjectRoot_1.detectProjectRoot)(options);
9
9
  if (!projectRoot) {
10
10
  throw new error_1.FirebaseError("Expected to be in a project directory, but none was found.", {
11
11
  exit: 2,
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAliases = exports.needProjectNumber = exports.needProjectId = exports.getProjectId = void 0;
4
4
  const projects_1 = require("./management/projects");
5
5
  const clc = require("cli-color");
6
- const marked = require("marked");
6
+ const { marked } = require("marked");
7
7
  const { FirebaseError } = require("./error");
8
8
  function getProjectId({ projectId, project, }) {
9
9
  return projectId || project;
@@ -43,7 +43,7 @@ async function needProjectNumber(options) {
43
43
  return options.projectNumber;
44
44
  }
45
45
  const projectId = needProjectId(options);
46
- const metadata = await projects_1.getFirebaseProject(projectId);
46
+ const metadata = await (0, projects_1.getFirebaseProject)(projectId);
47
47
  options.projectNumber = metadata.projectNumber;
48
48
  return options.projectNumber;
49
49
  }
package/lib/prompt.js CHANGED
@@ -15,7 +15,6 @@ async function prompt(options, questions) {
15
15
  const missingOptions = _.uniq(_.map(prompts, "name")).join(", ");
16
16
  throw new error_1.FirebaseError(`Missing required options (${missingOptions}) while running in non-interactive mode`, {
17
17
  children: prompts,
18
- exit: 1,
19
18
  });
20
19
  }
21
20
  const answers = await inquirer.prompt(prompts);
package/lib/rc.js CHANGED
@@ -17,7 +17,7 @@ const TARGET_TYPES = {
17
17
  };
18
18
  function loadRC(options) {
19
19
  const cwd = options.cwd || process.cwd();
20
- const dir = detectProjectRoot_1.detectProjectRoot(options);
20
+ const dir = (0, detectProjectRoot_1.detectProjectRoot)(options);
21
21
  const potential = path.resolve(dir || cwd, "./.firebaserc");
22
22
  return RC.loadFile(potential);
23
23
  }
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTemplate = exports.parseTemplateForTable = void 0;
4
- const api = require("../api");
4
+ const api_1 = require("../api");
5
+ const apiv2_1 = require("../apiv2");
5
6
  const logger_1 = require("../logger");
6
7
  const error_1 = require("../error");
7
8
  const TIMEOUT = 30000;
8
9
  const MAX_DISPLAY_ITEMS = 50;
10
+ const apiClient = new apiv2_1.Client({
11
+ urlPrefix: api_1.remoteConfigApiOrigin,
12
+ apiVersion: "v1",
13
+ });
9
14
  function parseTemplateForTable(templateItems) {
10
15
  let outputStr = "";
11
16
  let counter = 0;
@@ -24,20 +29,21 @@ function parseTemplateForTable(templateItems) {
24
29
  exports.parseTemplateForTable = parseTemplateForTable;
25
30
  async function getTemplate(projectId, versionNumber) {
26
31
  try {
27
- let request = `/v1/projects/${projectId}/remoteConfig`;
32
+ const params = new URLSearchParams();
28
33
  if (versionNumber) {
29
- request = request + "?versionNumber=" + versionNumber;
34
+ params.set("versionNumber", versionNumber);
30
35
  }
31
- const response = await api.request("GET", request, {
32
- auth: true,
33
- origin: api.remoteConfigApiOrigin,
36
+ const res = await apiClient.request({
37
+ method: "GET",
38
+ path: `/projects/${projectId}/remoteConfig`,
39
+ queryParams: params,
34
40
  timeout: TIMEOUT,
35
41
  });
36
- return response.body;
42
+ return res.body;
37
43
  }
38
44
  catch (err) {
39
45
  logger_1.logger.debug(err.message);
40
- throw new error_1.FirebaseError(`Failed to get Firebase Remote Config template for project ${projectId}. `, { exit: 2, original: err });
46
+ throw new error_1.FirebaseError(`Failed to get Firebase Remote Config template for project ${projectId}. `, { original: err });
41
47
  }
42
48
  }
43
49
  exports.getTemplate = getTemplate;
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rollbackTemplate = void 0;
4
- const api = require("../api");
4
+ const api_1 = require("../api");
5
+ const apiv2_1 = require("../apiv2");
6
+ const apiClient = new apiv2_1.Client({
7
+ urlPrefix: api_1.remoteConfigApiOrigin,
8
+ apiVersion: "v1",
9
+ });
5
10
  const TIMEOUT = 30000;
6
11
  async function rollbackTemplate(projectId, versionNumber) {
7
- const requestPath = `/v1/projects/${projectId}/remoteConfig:rollback?versionNumber=${versionNumber}`;
8
- const response = await api.request("POST", requestPath, {
9
- auth: true,
10
- origin: api.remoteConfigApiOrigin,
12
+ const params = new URLSearchParams();
13
+ params.set("versionNumber", `${versionNumber}`);
14
+ const res = await apiClient.request({
15
+ method: "POST",
16
+ path: `/projects/${projectId}/remoteConfig:rollback`,
17
+ queryParams: params,
11
18
  timeout: TIMEOUT,
12
19
  });
13
- return response.body;
20
+ return res.body;
14
21
  }
15
22
  exports.rollbackTemplate = rollbackTemplate;
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getVersions = void 0;
4
- const api = require("../api");
4
+ const api_1 = require("../api");
5
+ const apiv2_1 = require("../apiv2");
5
6
  const error_1 = require("../error");
6
7
  const logger_1 = require("../logger");
8
+ const apiClient = new apiv2_1.Client({
9
+ urlPrefix: api_1.remoteConfigApiOrigin,
10
+ apiVersion: "v1",
11
+ });
7
12
  const TIMEOUT = 30000;
8
13
  async function getVersions(projectId, maxResults = 10) {
9
14
  maxResults = maxResults || 300;
10
15
  try {
11
- let request = `/v1/projects/${projectId}/remoteConfig:listVersions`;
16
+ const params = new URLSearchParams();
12
17
  if (maxResults) {
13
- request = request + "?pageSize=" + maxResults;
18
+ params.set("pageSize", `${maxResults}`);
14
19
  }
15
- const response = await api.request("GET", request, {
16
- auth: true,
17
- origin: api.remoteConfigApiOrigin,
20
+ const response = await apiClient.request({
21
+ method: "GET",
22
+ path: `/projects/${projectId}/remoteConfig:listVersions`,
23
+ queryParams: params,
18
24
  timeout: TIMEOUT,
19
25
  });
20
26
  return response.body;
21
27
  }
22
28
  catch (err) {
23
29
  logger_1.logger.debug(err.message);
24
- throw new error_1.FirebaseError(`Failed to get Remote Config template versions for Firebase project ${projectId}. `, { exit: 2, original: err });
30
+ throw new error_1.FirebaseError(`Failed to get Remote Config template versions for Firebase project ${projectId}. `, { original: err });
25
31
  }
26
32
  }
27
33
  exports.getVersions = getVersions;
@@ -50,12 +50,12 @@ async function requireAuth(options) {
50
50
  }
51
51
  tokenOpt = tokenOpt || process.env.FIREBASE_TOKEN;
52
52
  if (tokenOpt) {
53
- auth_1.setRefreshToken(tokenOpt);
53
+ (0, auth_1.setRefreshToken)(tokenOpt);
54
54
  return;
55
55
  }
56
56
  if (!user || !tokens) {
57
57
  throw new error_1.FirebaseError(AUTH_ERROR_MESSAGE);
58
58
  }
59
- auth_1.setActiveAccount(options, { user, tokens });
59
+ (0, auth_1.setActiveAccount)(options, { user, tokens });
60
60
  }
61
61
  exports.requireAuth = requireAuth;
@@ -11,7 +11,7 @@ async function requireDatabaseInstance(options) {
11
11
  }
12
12
  let instance;
13
13
  try {
14
- instance = await getDefaultDatabaseInstance_1.getDefaultDatabaseInstance(options);
14
+ instance = await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)(options);
15
15
  }
16
16
  catch (err) {
17
17
  throw new error_1.FirebaseError(`Failed to get details for project: ${options.project}.`, {
@@ -6,7 +6,7 @@ async function requireHostingSite(options) {
6
6
  if (options.site) {
7
7
  return Promise.resolve();
8
8
  }
9
- const site = await getDefaultHostingSite_1.getDefaultHostingSite(options);
9
+ const site = await (0, getDefaultHostingSite_1.getDefaultHostingSite)(options);
10
10
  options.site = site;
11
11
  }
12
12
  exports.requireHostingSite = requireHostingSite;
@@ -9,14 +9,14 @@ 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 = projectUtils_1.needProjectId(options);
12
+ const projectId = (0, projectUtils_1.needProjectId)(options);
13
13
  const requiredPermissions = BASE_PERMISSIONS.concat(permissions).sort();
14
- await requireAuth_1.requireAuth(options);
14
+ await (0, requireAuth_1.requireAuth)(options);
15
15
  logger_1.logger.debug(`[iam] checking project ${projectId} for permissions ${JSON.stringify(requiredPermissions)}`);
16
16
  try {
17
- const iamResult = await iam_1.testIamPermissions(projectId, requiredPermissions);
17
+ const iamResult = await (0, iam_1.testIamPermissions)(projectId, requiredPermissions);
18
18
  if (!iamResult.passed) {
19
- throw new error_1.FirebaseError(`Authorization failed. This account is missing the following required permissions on project ${cli_color_1.bold(projectId)}:\n\n ${iamResult.missing.join("\n ")}`);
19
+ throw new error_1.FirebaseError(`Authorization failed. This account is missing the following required permissions on project ${(0, cli_color_1.bold)(projectId)}:\n\n ${iamResult.missing.join("\n ")}`);
20
20
  }
21
21
  }
22
22
  catch (err) {
@@ -56,7 +56,7 @@ class RulesDeploy {
56
56
  }
57
57
  async createRulesets(service) {
58
58
  const createdRulesetNames = [];
59
- const { latestName: latestRulesetName, latestContent: latestRulesetContent, } = await this.getCurrentRules(service);
59
+ const { latestName: latestRulesetName, latestContent: latestRulesetContent } = await this.getCurrentRules(service);
60
60
  const newRulesetsByFilename = new Map();
61
61
  for (const filename of Object.keys(this.rulesFiles)) {
62
62
  const files = this.rulesFiles[filename];
@@ -83,7 +83,7 @@ class RulesDeploy {
83
83
  " quota exceeded error while uploading rules");
84
84
  const history = await gcp.rules.listAllRulesets(this.options.project);
85
85
  if (history.length > RULESET_COUNT_LIMIT) {
86
- const confirm = await prompt_1.promptOnce({
86
+ const confirm = await (0, prompt_1.promptOnce)({
87
87
  type: "confirm",
88
88
  name: "force",
89
89
  message: `You have ${history.length} rules, do you want to delete the oldest ${RULESETS_TO_GC} to free up space?`,
@@ -11,23 +11,26 @@ const utils = require("../utils");
11
11
  class FunctionsServer {
12
12
  constructor() {
13
13
  this.emulatorServer = undefined;
14
+ this.backend = undefined;
14
15
  }
15
16
  assertServer() {
16
- if (!this.emulatorServer) {
17
+ if (!this.emulatorServer || !this.backend) {
17
18
  throw new Error("Must call start() before calling any other operation!");
18
19
  }
19
20
  }
20
21
  async start(options, partialArgs) {
21
- const projectId = projectUtils_1.needProjectId(options);
22
+ const projectId = (0, projectUtils_1.needProjectId)(options);
22
23
  utils.assertDefined(options.config.src.functions);
23
24
  utils.assertDefined(options.config.src.functions.source, "Error: 'functions.source' is not defined");
24
25
  const functionsDir = path.join(options.config.projectDir, options.config.src.functions.source);
25
- const account = auth_1.getProjectDefaultAccount(options.config.projectDir);
26
- const nodeMajorVersion = functionsEmulatorUtils_1.parseRuntimeVersion(options.config.get("functions.runtime"));
27
- const args = Object.assign({ projectId,
26
+ const account = (0, auth_1.getProjectDefaultAccount)(options.config.projectDir);
27
+ const nodeMajorVersion = (0, functionsEmulatorUtils_1.parseRuntimeVersion)(options.config.get("functions.runtime"));
28
+ this.backend = {
28
29
  functionsDir,
29
- account,
30
- nodeMajorVersion }, partialArgs);
30
+ env: {},
31
+ nodeMajorVersion,
32
+ };
33
+ const args = Object.assign({ projectId, emulatableBackends: [this.backend], account }, partialArgs);
31
34
  if (options.host) {
32
35
  utils.assertIsStringOrUndefined(options.host);
33
36
  args.host = options.host;
@@ -55,6 +58,10 @@ class FunctionsServer {
55
58
  this.assertServer();
56
59
  await this.emulatorServer.stop();
57
60
  }
61
+ getBackend() {
62
+ this.assertServer();
63
+ return this.backend;
64
+ }
58
65
  get() {
59
66
  this.assertServer();
60
67
  return this.emulatorServer.get();
@@ -20,7 +20,7 @@ let attempts = 0;
20
20
  let destroyServer = undefined;
21
21
  const logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HOSTING);
22
22
  function startServer(options, config, port, init) {
23
- const firebaseMiddleware = initMiddleware_1.initMiddleware(init);
23
+ const firebaseMiddleware = (0, initMiddleware_1.initMiddleware)(init);
24
24
  const morganStream = new stream_1.Writable();
25
25
  morganStream._write = (chunk, encoding, callback) => {
26
26
  if (chunk instanceof Buffer) {
@@ -36,7 +36,7 @@ function startServer(options, config, port, init) {
36
36
  port: port,
37
37
  host: options.host,
38
38
  config: config,
39
- cwd: detectProjectRoot_1.detectProjectRoot(options),
39
+ cwd: (0, detectProjectRoot_1.detectProjectRoot)(options),
40
40
  stack: "strict",
41
41
  before: {
42
42
  files: (req, res, next) => {
@@ -46,8 +46,8 @@ function startServer(options, config, port, init) {
46
46
  },
47
47
  },
48
48
  rewriters: {
49
- function: functionsProxy_1.default(options),
50
- run: cloudRunProxy_1.default(options),
49
+ function: (0, functionsProxy_1.default)(options),
50
+ run: (0, cloudRunProxy_1.default)(options),
51
51
  },
52
52
  }).listen(() => {
53
53
  const siteName = config.target || config.site;
@@ -57,7 +57,7 @@ function startServer(options, config, port, init) {
57
57
  }
58
58
  logger.logLabeled("SUCCESS", label, "Local server: " + clc.underline(clc.bold("http://" + options.host + ":" + port)));
59
59
  });
60
- destroyServer = utils_1.createDestroyer(server);
60
+ destroyServer = (0, utils_1.createDestroyer)(server);
61
61
  server.on("error", (err) => {
62
62
  if (err.code === "EADDRINUSE") {
63
63
  const message = "Port " + options.port + " is not available.";
@@ -83,8 +83,8 @@ function stop() {
83
83
  }
84
84
  exports.stop = stop;
85
85
  async function start(options) {
86
- const init = await implicitInit_1.implicitInit(options);
87
- const configs = normalizedHostingConfigs_1.normalizedHostingConfigs(options);
86
+ const init = await (0, implicitInit_1.implicitInit)(options);
87
+ const configs = (0, normalizedHostingConfigs_1.normalizedHostingConfigs)(options);
88
88
  for (let i = 0; i < configs.length; i++) {
89
89
  const port = i === 0 ? options.port : options.port + 4 + i;
90
90
  startServer(options, configs[i], port, init);
package/lib/utils.js CHANGED
@@ -333,9 +333,10 @@ function createDestroyer(server) {
333
333
  }
334
334
  exports.createDestroyer = createDestroyer;
335
335
  function datetimeString(d) {
336
- const day = `${d.getFullYear()}-${(d.getMonth() + 1)
336
+ const day = `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d
337
+ .getDate()
337
338
  .toString()
338
- .padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}`;
339
+ .padStart(2, "0")}`;
339
340
  const time = `${d.getHours().toString().padStart(2, "0")}:${d
340
341
  .getMinutes()
341
342
  .toString()