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
@@ -47,7 +47,7 @@ module.exports = new command_1.Command("projects:list")
47
47
  const spinner = ora("Preparing the list of your Firebase projects").start();
48
48
  let projects;
49
49
  try {
50
- projects = await projects_1.listFirebaseProjects();
50
+ projects = await (0, projects_1.listFirebaseProjects)();
51
51
  }
52
52
  catch (err) {
53
53
  spinner.fail();
@@ -28,7 +28,7 @@ module.exports = new command_1.Command("remoteconfig:get")
28
28
  .before(requirePermissions_1.requirePermissions, ["cloudconfig.configs.get"])
29
29
  .action(async (options) => {
30
30
  utils.assertIsStringOrUndefined(options.versionNumber);
31
- const template = await rcGet.getTemplate(projectUtils_1.needProjectId(options), checkValidOptionalNumber(options.versionNumber));
31
+ const template = await rcGet.getTemplate((0, projectUtils_1.needProjectId)(options), checkValidOptionalNumber(options.versionNumber));
32
32
  const table = new Table({ head: tableHead, style: { head: ["green"] } });
33
33
  if (template.conditions) {
34
34
  let updatedConditions = template.conditions
@@ -40,9 +40,9 @@ module.exports = new command_1.Command("remoteconfig:get")
40
40
  }
41
41
  table.push(["conditions", updatedConditions]);
42
42
  }
43
- const updatedParameters = get_1.parseTemplateForTable(template.parameters);
43
+ const updatedParameters = (0, get_1.parseTemplateForTable)(template.parameters);
44
44
  table.push(["parameters", updatedParameters]);
45
- const updatedParameterGroups = get_1.parseTemplateForTable(template.parameterGroups);
45
+ const updatedParameterGroups = (0, get_1.parseTemplateForTable)(template.parameterGroups);
46
46
  table.push(["parameterGroups", updatedParameterGroups]);
47
47
  table.push(["version", util.inspect(template.version, { showHidden: false, depth: null })]);
48
48
  const fileOut = !!options.output;
@@ -16,7 +16,7 @@ module.exports = new command_1.Command("remoteconfig:rollback")
16
16
  .withForce()
17
17
  .action(async (options) => {
18
18
  var _a;
19
- const templateVersion = await versionslist_1.getVersions(projectUtils_1.needProjectId(options), 1);
19
+ const templateVersion = await (0, versionslist_1.getVersions)((0, projectUtils_1.needProjectId)(options), 1);
20
20
  let targetVersion = 0;
21
21
  if (options.versionNumber) {
22
22
  targetVersion = options.versionNumber;
@@ -34,7 +34,7 @@ module.exports = new command_1.Command("remoteconfig:rollback")
34
34
  `. ` +
35
35
  `Invalid Version Number`);
36
36
  }
37
- const confirm = await prompt_1.promptOnce({
37
+ const confirm = await (0, prompt_1.promptOnce)({
38
38
  type: "confirm",
39
39
  name: "force",
40
40
  message: "Proceed to rollback template to version " + targetVersion + "?",
@@ -43,5 +43,5 @@ module.exports = new command_1.Command("remoteconfig:rollback")
43
43
  if (!confirm) {
44
44
  return;
45
45
  }
46
- return rollback_1.rollbackTemplate(projectUtils_1.needProjectId(options), targetVersion);
46
+ return (0, rollback_1.rollbackTemplate)((0, projectUtils_1.needProjectId)(options), targetVersion);
47
47
  });
@@ -6,11 +6,16 @@ const command_1 = require("../command");
6
6
  const projectUtils_1 = require("../projectUtils");
7
7
  const requireAuth_1 = require("../requireAuth");
8
8
  const requirePermissions_1 = require("../requirePermissions");
9
+ const utils_1 = require("../utils");
9
10
  const Table = require("cli-table");
10
11
  const tableHead = ["Update User", "Version Number", "Update Time"];
11
12
  function pushTableContents(table, version) {
12
13
  var _a;
13
- return table.push([(_a = version === null || version === void 0 ? void 0 : version.updateUser) === null || _a === void 0 ? void 0 : _a.email, version === null || version === void 0 ? void 0 : version.versionNumber, version === null || version === void 0 ? void 0 : version.updateTime]);
14
+ return table.push([
15
+ (_a = version.updateUser) === null || _a === void 0 ? void 0 : _a.email,
16
+ version.versionNumber,
17
+ version.updateTime ? (0, utils_1.datetimeString)(new Date(version.updateTime)) : "",
18
+ ]);
14
19
  }
15
20
  module.exports = new command_1.Command("remoteconfig:versions:list")
16
21
  .description("get a list of Remote Config template versions that have been published for a Firebase project")
@@ -18,7 +23,7 @@ module.exports = new command_1.Command("remoteconfig:versions:list")
18
23
  .before(requireAuth_1.requireAuth)
19
24
  .before(requirePermissions_1.requirePermissions, ["cloudconfig.configs.get"])
20
25
  .action(async (options) => {
21
- const versionsList = await rcVersion.getVersions(projectUtils_1.needProjectId(options), options.limit);
26
+ const versionsList = await rcVersion.getVersions((0, projectUtils_1.needProjectId)(options), options.limit);
22
27
  const table = new Table({ head: tableHead, style: { head: ["green"] } });
23
28
  for (let item = 0; item < versionsList.versions.length; item++) {
24
29
  pushTableContents(table, versionsList.versions[item]);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
- const { Command } = require("../command");
3
- const { Emulators } = require("../emulator/types");
4
- const { downloadEmulator } = require("../emulator/download");
5
- const NAME = Emulators.DATABASE;
6
- module.exports = new Command(`setup:emulators:${NAME}`)
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("../command");
4
+ const download_1 = require("../emulator/download");
5
+ const types_1 = require("../emulator/types");
6
+ const NAME = types_1.Emulators.DATABASE;
7
+ exports.default = new command_1.Command(`setup:emulators:${NAME}`)
7
8
  .description(`downloads the ${NAME} emulator`)
8
- .action((options) => {
9
- return downloadEmulator(NAME);
9
+ .action(() => {
10
+ return (0, download_1.downloadEmulator)(NAME);
10
11
  });
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
- const { Command } = require("../command");
3
- const { Emulators } = require("../emulator/types");
4
- const { downloadEmulator } = require("../emulator/download");
5
- const NAME = Emulators.FIRESTORE;
6
- module.exports = new Command(`setup:emulators:${NAME}`)
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("../command");
4
+ const download_1 = require("../emulator/download");
5
+ const types_1 = require("../emulator/types");
6
+ const NAME = types_1.Emulators.FIRESTORE;
7
+ exports.default = new command_1.Command(`setup:emulators:${NAME}`)
7
8
  .description(`downloads the ${NAME} emulator`)
8
- .action((options) => {
9
- return downloadEmulator(NAME);
9
+ .action(() => {
10
+ return (0, download_1.downloadEmulator)(NAME);
10
11
  });
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("../command");
4
- const { downloadEmulator } = require("../emulator/download");
5
- const EMULATOR_NAME = "pubsub";
6
- module.exports = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
4
+ const download_1 = require("../emulator/download");
5
+ const types_1 = require("../emulator/types");
6
+ const EMULATOR_NAME = types_1.Emulators.PUBSUB;
7
+ exports.default = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
7
8
  .description(`downloads the ${EMULATOR_NAME} emulator`)
8
9
  .action(() => {
9
- return downloadEmulator(EMULATOR_NAME);
10
+ return (0, download_1.downloadEmulator)(EMULATOR_NAME);
10
11
  });
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("../command");
4
4
  const download_1 = require("../emulator/download");
5
- const EMULATOR_NAME = "storage";
6
- module.exports = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
5
+ const types_1 = require("../emulator/types");
6
+ const EMULATOR_NAME = types_1.Emulators.STORAGE;
7
+ exports.default = new command_1.Command(`setup:emulators:${EMULATOR_NAME}`)
7
8
  .description(`downloads the ${EMULATOR_NAME} emulator`)
8
9
  .action(() => {
9
- return download_1.downloadEmulator(EMULATOR_NAME);
10
+ return (0, download_1.downloadEmulator)(EMULATOR_NAME);
10
11
  });
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
- const { Command } = require("../command");
3
- const { Emulators } = require("../emulator/types");
4
- const { downloadEmulator } = require("../emulator/download");
5
- const NAME = Emulators.UI;
6
- module.exports = new Command(`setup:emulators:${NAME}`)
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("../command");
4
+ const download_1 = require("../emulator/download");
5
+ const types_1 = require("../emulator/types");
6
+ const NAME = types_1.Emulators.UI;
7
+ exports.default = new command_1.Command(`setup:emulators:${NAME}`)
7
8
  .description(`downloads the ${NAME} emulator`)
8
- .action((options) => {
9
- return downloadEmulator(NAME);
9
+ .action(() => {
10
+ return (0, download_1.downloadEmulator)(NAME);
10
11
  });
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
- var _ = require("lodash");
3
- var clc = require("cli-color");
4
- var { Command } = require("../command");
5
- const { logger } = require("../logger");
6
- var requireConfig = require("../requireConfig");
7
- var utils = require("../utils");
8
- module.exports = new Command("target:apply <type> <name> <resources...>")
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const clc = require("cli-color");
4
+ const command_1 = require("../command");
5
+ const logger_1 = require("../logger");
6
+ const requireConfig = require("../requireConfig");
7
+ const utils = require("../utils");
8
+ const error_1 = require("../error");
9
+ exports.default = new command_1.Command("target:apply <type> <name> <resources...>")
9
10
  .description("apply a deploy target to a resource")
10
11
  .before(requireConfig)
11
- .action(function (type, name, resources, options) {
12
+ .action((type, name, resources, options) => {
12
13
  if (!options.project) {
13
- return utils.reject("Must have an active project to set deploy targets. Try " + clc.bold("firebase use --add"));
14
+ throw new error_1.FirebaseError(`Must have an active project to set deploy targets. Try ${clc.bold("firebase use --add")}`);
14
15
  }
15
- var changes = options.rc.applyTarget(options.project, type, name, resources);
16
- utils.logSuccess("Applied " + type + " target " + clc.bold(name) + " to " + clc.bold(resources.join(", ")));
17
- _.forEach(changes, function (change) {
18
- utils.logWarning("Previous target " + clc.bold(change.target) + " removed from " + clc.bold(change.resource));
19
- });
20
- logger.info();
21
- logger.info("Updated: " + name + " (" + options.rc.target(options.project, type, name).join(",") + ")");
16
+ const changes = options.rc.applyTarget(options.project, type, name, resources);
17
+ utils.logSuccess(`Applied ${type} target ${clc.bold(name)} to ${clc.bold(resources.join(", "))}`);
18
+ for (const change of changes) {
19
+ utils.logWarning(`Previous target ${clc.bold(change.target)} removed from ${clc.bold(change.resource)}`);
20
+ }
21
+ logger_1.logger.info();
22
+ logger_1.logger.info(`Updated: ${name} (${options.rc.target(options.project, type, name).join(",")})`);
22
23
  });
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
- var clc = require("cli-color");
3
- var { Command } = require("../command");
4
- var requireConfig = require("../requireConfig");
5
- var utils = require("../utils");
6
- module.exports = new Command("target:clear <type> <target>")
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const clc = require("cli-color");
4
+ const command_1 = require("../command");
5
+ const requireConfig = require("../requireConfig");
6
+ const utils = require("../utils");
7
+ exports.default = new command_1.Command("target:clear <type> <target>")
7
8
  .description("clear all resources from a named resource target")
8
9
  .before(requireConfig)
9
- .action(function (type, name, options) {
10
- var existed = options.rc.clearTarget(options.project, type, name);
10
+ .action((type, name, options) => {
11
+ const existed = options.rc.clearTarget(options.project, type, name);
11
12
  if (existed) {
12
- utils.logSuccess("Cleared " + type + " target " + clc.bold(name));
13
+ utils.logSuccess(`Cleared ${type} target ${clc.bold(name)}`);
13
14
  }
14
15
  else {
15
- utils.logWarning("No action taken. No " + type + " target found named " + clc.bold(name));
16
+ utils.logWarning(`No action taken. No ${type} target found named ${clc.bold(name)}`);
16
17
  }
17
- return Promise.resolve(existed);
18
+ return existed;
18
19
  });
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
- var clc = require("cli-color");
3
- var { Command } = require("../command");
4
- var requireConfig = require("../requireConfig");
5
- var utils = require("../utils");
6
- module.exports = new Command("target:remove <type> <resource>")
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const clc = require("cli-color");
4
+ const command_1 = require("../command");
5
+ const requireConfig = require("../requireConfig");
6
+ const utils = require("../utils");
7
+ exports.default = new command_1.Command("target:remove <type> <resource>")
7
8
  .description("remove a resource target")
8
9
  .before(requireConfig)
9
- .action(function (type, resource, options) {
10
- var name = options.rc.removeTarget(options.project, type, resource);
10
+ .action((type, resource, options) => {
11
+ const name = options.rc.removeTarget(options.project, type, resource);
11
12
  if (name) {
12
- utils.logSuccess("Removed " + type + " target " + clc.bold(name) + " from " + clc.bold(resource));
13
+ utils.logSuccess(`Removed ${type} target ${clc.bold(name)} from ${clc.bold(resource)}`);
13
14
  }
14
15
  else {
15
- utils.logWarning("No action taken. No target found for " + type + " resource " + clc.bold(resource));
16
+ utils.logWarning(`No action taken. No target found for ${type} resource ${clc.bold(resource)}`);
16
17
  }
17
18
  return Promise.resolve(name);
18
19
  });
@@ -1,33 +1,33 @@
1
1
  "use strict";
2
- var _ = require("lodash");
3
- var clc = require("cli-color");
4
- var { Command } = require("../command");
5
- const { logger } = require("../logger");
6
- var requireConfig = require("../requireConfig");
7
- var utils = require("../utils");
8
- function _logTargets(type, targets) {
9
- logger.info(clc.cyan("[ " + type + " ]"));
10
- _.forEach(targets, function (resources, name) {
11
- logger.info(name, "(" + (resources || []).join(",") + ")");
12
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const clc = require("cli-color");
4
+ const command_1 = require("../command");
5
+ const logger_1 = require("../logger");
6
+ const requireConfig = require("../requireConfig");
7
+ const utils = require("../utils");
8
+ function logTargets(type, targets) {
9
+ logger_1.logger.info(clc.cyan("[ " + type + " ]"));
10
+ for (const [name, resources] of Object.entries(targets)) {
11
+ logger_1.logger.info(name, "(" + (resources || []).join(",") + ")");
12
+ }
13
13
  }
14
- module.exports = new Command("target [type]")
14
+ exports.default = new command_1.Command("target [type]")
15
15
  .description("display configured deploy targets for the current project")
16
16
  .before(requireConfig)
17
- .action(function (type, options) {
17
+ .action((type, options) => {
18
18
  if (!options.project) {
19
19
  return utils.reject("No active project, cannot list deploy targets.");
20
20
  }
21
- logger.info("Resource targets for", clc.bold(options.project) + ":");
22
- logger.info();
21
+ logger_1.logger.info("Resource targets for", clc.bold(options.project) + ":");
22
+ logger_1.logger.info();
23
23
  if (type) {
24
- var targets = options.rc.targets(options.project, type);
25
- _logTargets(type, targets);
26
- return Promise.resolve(targets);
24
+ const targets = options.rc.targets(options.project, type);
25
+ logTargets(type, targets);
26
+ return targets;
27
27
  }
28
28
  const allTargets = options.rc.allTargets(options.project);
29
29
  for (const [targetType, targetName] of Object.entries(allTargets)) {
30
- _logTargets(targetType, targetName);
30
+ logTargets(targetType, targetName);
31
31
  }
32
- return Promise.resolve(allTargets);
32
+ return allTargets;
33
33
  });
package/lib/config.js CHANGED
@@ -22,7 +22,7 @@ class Config {
22
22
  this.defaults = {};
23
23
  this.notes = {};
24
24
  this.options = options || {};
25
- this.projectDir = options.projectDir || detectProjectRoot_1.detectProjectRoot(options);
25
+ this.projectDir = options.projectDir || (0, detectProjectRoot_1.detectProjectRoot)(options);
26
26
  this._src = src;
27
27
  if (this._src.firebase) {
28
28
  this.defaults.project = this._src.firebase;
@@ -64,7 +64,7 @@ class Config {
64
64
  });
65
65
  }
66
66
  parseFile(target, filePath) {
67
- const fullPath = projectPath_1.resolveProjectPath(this.options, filePath);
67
+ const fullPath = (0, projectPath_1.resolveProjectPath)(this.options, filePath);
68
68
  const ext = path.extname(filePath);
69
69
  if (!fsutils.fileExistsSync(fullPath)) {
70
70
  throw new error_1.FirebaseError("Parse Error: Imported file " + filePath + " does not exist", {
@@ -148,7 +148,7 @@ class Config {
148
148
  const writeTo = this.path(p);
149
149
  let next;
150
150
  if (fsutils.fileExistsSync(writeTo) && !force) {
151
- next = prompt_1.promptOnce({
151
+ next = (0, prompt_1.promptOnce)({
152
152
  type: "confirm",
153
153
  message: "File " + clc.underline(p) + " already exists. Overwrite?",
154
154
  default: false,
@@ -168,17 +168,17 @@ class Config {
168
168
  });
169
169
  }
170
170
  static load(options, allowMissing) {
171
- const pd = detectProjectRoot_1.detectProjectRoot(options);
171
+ const pd = (0, detectProjectRoot_1.detectProjectRoot)(options);
172
172
  const filename = options.configPath || Config.FILENAME;
173
173
  if (pd) {
174
174
  try {
175
175
  const filePath = path.resolve(pd, path.basename(filename));
176
176
  const data = cjson.load(filePath);
177
- const validator = firebaseConfigValidate_1.getValidator();
177
+ const validator = (0, firebaseConfigValidate_1.getValidator)();
178
178
  const valid = validator(data);
179
179
  if (!valid && validator.errors) {
180
180
  for (const e of validator.errors) {
181
- logger_1.logger.debug(firebaseConfigValidate_1.getErrorMessage(e));
181
+ logger_1.logger.debug((0, firebaseConfigValidate_1.getErrorMessage)(e));
182
182
  }
183
183
  }
184
184
  return new Config(data, options);
@@ -4,11 +4,11 @@ exports.realtimeOriginOrCustomUrl = exports.realtimeOriginOrEmulatorOrCustomUrl
4
4
  const utils_1 = require("../utils");
5
5
  const constants_1 = require("../emulator/constants");
6
6
  function realtimeOriginOrEmulatorOrCustomUrl(host) {
7
- return utils_1.envOverride(constants_1.Constants.FIREBASE_DATABASE_EMULATOR_HOST, utils_1.envOverride("FIREBASE_REALTIME_URL", host), addHttpIfRequired);
7
+ return (0, utils_1.envOverride)(constants_1.Constants.FIREBASE_DATABASE_EMULATOR_HOST, (0, utils_1.envOverride)("FIREBASE_REALTIME_URL", host), addHttpIfRequired);
8
8
  }
9
9
  exports.realtimeOriginOrEmulatorOrCustomUrl = realtimeOriginOrEmulatorOrCustomUrl;
10
10
  function realtimeOriginOrCustomUrl(host) {
11
- return utils_1.envOverride("FIREBASE_REALTIME_URL", host);
11
+ return (0, utils_1.envOverride)("FIREBASE_REALTIME_URL", host);
12
12
  }
13
13
  exports.realtimeOriginOrCustomUrl = realtimeOriginOrCustomUrl;
14
14
  function addHttpIfRequired(val) {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setRulesetLabels = exports.createRuleset = exports.getRulesetLabels = exports.getRuleset = exports.listAllRulesets = 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 utils = require("../utils");
7
8
  function handleErrorResponse(response) {
@@ -13,12 +14,9 @@ function handleErrorResponse(response) {
13
14
  code: 2,
14
15
  });
15
16
  }
17
+ const apiClient = new apiv2_1.Client({ urlPrefix: api_1.rtdbMetadataOrigin });
16
18
  async function listAllRulesets(databaseName) {
17
- const response = await api.request("GET", `/namespaces/${databaseName}/rulesets`, {
18
- auth: true,
19
- origin: api.rtdbMetadataOrigin,
20
- json: true,
21
- });
19
+ const response = await apiClient.get(`/namespaces/${databaseName}/rulesets`, { resolveOnHTTPError: true });
22
20
  if (response.status === 200) {
23
21
  return response.body.rulesets;
24
22
  }
@@ -26,11 +24,7 @@ async function listAllRulesets(databaseName) {
26
24
  }
27
25
  exports.listAllRulesets = listAllRulesets;
28
26
  async function getRuleset(databaseName, rulesetId) {
29
- const response = await api.request("GET", `/namespaces/${databaseName}/rulesets/${rulesetId}`, {
30
- auth: true,
31
- origin: api.rtdbMetadataOrigin,
32
- json: true,
33
- });
27
+ const response = await apiClient.get(`/namespaces/${databaseName}/rulesets/${rulesetId}`, { resolveOnHTTPError: true });
34
28
  if (response.status === 200) {
35
29
  return response.body;
36
30
  }
@@ -38,9 +32,8 @@ async function getRuleset(databaseName, rulesetId) {
38
32
  }
39
33
  exports.getRuleset = getRuleset;
40
34
  async function getRulesetLabels(databaseName) {
41
- const response = await api.request("GET", `/namespaces/${databaseName}/ruleset_labels`, {
42
- auth: true,
43
- origin: api.rtdbMetadataOrigin,
35
+ const response = await apiClient.get(`/namespaces/${databaseName}/ruleset_labels`, {
36
+ resolveOnHTTPError: true,
44
37
  });
45
38
  if (response.status === 200) {
46
39
  return response.body;
@@ -49,23 +42,22 @@ async function getRulesetLabels(databaseName) {
49
42
  }
50
43
  exports.getRulesetLabels = getRulesetLabels;
51
44
  async function createRuleset(databaseName, source) {
52
- const response = await api.request("POST", `/.settings/rulesets.json`, {
53
- auth: true,
54
- origin: utils.addSubdomain(api.realtimeOrigin, databaseName),
55
- json: false,
56
- data: source,
45
+ const localApiClient = new apiv2_1.Client({
46
+ urlPrefix: utils.addSubdomain(api_1.realtimeOrigin, databaseName),
57
47
  });
48
+ const response = await localApiClient.post(`/.settings/rulesets.json`, source, { resolveOnHTTPError: true });
58
49
  if (response.status === 200) {
59
- return JSON.parse(response.body).id;
50
+ return response.body.id;
60
51
  }
61
52
  return handleErrorResponse(response);
62
53
  }
63
54
  exports.createRuleset = createRuleset;
64
55
  async function setRulesetLabels(databaseName, labels) {
65
- const response = await api.request("PUT", `/.settings/ruleset_labels.json`, {
66
- auth: true,
67
- origin: utils.addSubdomain(api.realtimeOrigin, databaseName),
68
- data: labels,
56
+ const localApiClient = new apiv2_1.Client({
57
+ urlPrefix: utils.addSubdomain(api_1.realtimeOrigin, databaseName),
58
+ });
59
+ const response = await localApiClient.put(`/.settings/ruleset_labels.json`, labels, {
60
+ resolveOnHTTPError: true,
69
61
  });
70
62
  if (response.status === 200) {
71
63
  return response.body;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.clearCredentials = exports.getCredentialPathAsync = void 0;
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
- const api = require("./api");
6
+ const api_1 = require("./api");
7
7
  const logger_1 = require("./logger");
8
8
  async function getCredentialPathAsync(account) {
9
9
  const filePath = credFilePath(account.user);
@@ -43,8 +43,8 @@ exports.clearCredentials = clearCredentials;
43
43
  function getCredential(tokens) {
44
44
  if (tokens.refresh_token) {
45
45
  return {
46
- client_id: api.clientId,
47
- client_secret: api.clientSecret,
46
+ client_id: api_1.clientId,
47
+ client_secret: api_1.clientSecret,
48
48
  refresh_token: tokens.refresh_token,
49
49
  type: "authorized_user",
50
50
  };
@@ -11,14 +11,14 @@ const secrets_1 = require("./secrets");
11
11
  const validate_1 = require("./validate");
12
12
  async function deploy(context, options, payload) {
13
13
  var _a, _b, _c, _d, _e, _f;
14
- const projectId = projectUtils_1.needProjectId(options);
15
- await validate_1.checkBilling(projectId, options.nonInteractive);
16
- await provisioningHelper_1.bulkCheckProductsProvisioned(projectId, [
14
+ const projectId = (0, projectUtils_1.needProjectId)(options);
15
+ await (0, validate_1.checkBilling)(projectId, options.nonInteractive);
16
+ await (0, provisioningHelper_1.bulkCheckProductsProvisioned)(projectId, [
17
17
  ...((_a = payload.instancesToCreate) !== null && _a !== void 0 ? _a : []),
18
18
  ...((_b = payload.instancesToUpdate) !== null && _b !== void 0 ? _b : []),
19
19
  ...((_c = payload.instancesToConfigure) !== null && _c !== void 0 ? _c : []),
20
20
  ]);
21
- await secrets_1.handleSecretParams(payload, context.have, options.nonInteractive);
21
+ await (0, secrets_1.handleSecretParams)(payload, context.have, options.nonInteractive);
22
22
  const errorHandler = new errors_1.ErrorHandler();
23
23
  const validationQueue = new queue_1.default({
24
24
  retries: 5,
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deletesSummary = exports.configuresSummary = exports.updatesSummary = exports.createsSummary = exports.humanReadable = void 0;
4
4
  const clc = require("cli-color");
5
5
  const refs = require("../../extensions/refs");
6
- exports.humanReadable = (dep) => `${clc.bold(dep.instanceId)} (${dep.ref ? `${refs.toExtensionVersionRef(dep.ref)}` : `Installed from local source`})`;
6
+ const humanReadable = (dep) => `${clc.bold(dep.instanceId)} (${dep.ref ? `${refs.toExtensionVersionRef(dep.ref)}` : `Installed from local source`})`;
7
+ exports.humanReadable = humanReadable;
7
8
  const humanReadableUpdate = (from, to) => {
8
9
  var _a, _b, _c, _d, _e;
9
10
  if (((_a = from.ref) === null || _a === void 0 ? void 0 : _a.publisherId) == ((_b = to.ref) === null || _b === void 0 ? void 0 : _b.publisherId) &&
@@ -18,7 +19,7 @@ const humanReadableUpdate = (from, to) => {
18
19
  }
19
20
  };
20
21
  function createsSummary(toCreate) {
21
- const instancesToCreate = toCreate.map((s) => `\t${exports.humanReadable(s)}`).join("\n");
22
+ const instancesToCreate = toCreate.map((s) => `\t${(0, exports.humanReadable)(s)}`).join("\n");
22
23
  return toCreate.length
23
24
  ? `The following extension instances will be created:\n${instancesToCreate}\n`
24
25
  : "";
@@ -37,14 +38,14 @@ function updatesSummary(toUpdate, have) {
37
38
  }
38
39
  exports.updatesSummary = updatesSummary;
39
40
  function configuresSummary(toConfigure) {
40
- const instancesToConfigure = toConfigure.map((s) => `\t${exports.humanReadable(s)}`).join("\n");
41
+ const instancesToConfigure = toConfigure.map((s) => `\t${(0, exports.humanReadable)(s)}`).join("\n");
41
42
  return toConfigure.length
42
43
  ? `The following extension instances will be configured:\n${instancesToConfigure}\n`
43
44
  : "";
44
45
  }
45
46
  exports.configuresSummary = configuresSummary;
46
47
  function deletesSummary(toDelete) {
47
- const instancesToDelete = toDelete.map((s) => `\t${exports.humanReadable(s)}`).join("\n");
48
+ const instancesToDelete = toDelete.map((s) => `\t${(0, exports.humanReadable)(s)}`).join("\n");
48
49
  return toDelete.length
49
50
  ? `The following extension instances are not listed in 'firebase.json':\n${instancesToDelete}\n`
50
51
  : "";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.release = exports.deploy = exports.prepare = void 0;
3
4
  var prepare_1 = require("./prepare");
4
5
  Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return prepare_1.prepare; } });
5
6
  var deploy_1 = require("./deploy");
@@ -34,6 +34,6 @@ function readParams(args) {
34
34
  exports.readParams = readParams;
35
35
  function readParamsFile(projectDir, fileName) {
36
36
  const paramPath = path.join(projectDir, ENV_DIRECTORY, fileName);
37
- const params = paramHelper_1.readEnvFile(paramPath);
37
+ const params = (0, paramHelper_1.readEnvFile)(paramPath);
38
38
  return params;
39
39
  }
@@ -52,15 +52,15 @@ async function want(args) {
52
52
  const instanceId = e[0];
53
53
  const ref = refs.parse(e[1]);
54
54
  ref.version = await resolveVersion(ref);
55
- const params = params_1.readParams({
55
+ const params = (0, params_1.readParams)({
56
56
  projectDir: args.projectDir,
57
57
  instanceId,
58
58
  projectId: args.projectId,
59
59
  projectNumber: args.projectNumber,
60
60
  aliases: args.aliases,
61
61
  });
62
- const autoPopulatedParams = await extensionsHelper_1.getFirebaseProjectParams(args.projectId);
63
- const subbedParams = extensionsHelper_1.substituteParams(params, autoPopulatedParams);
62
+ const autoPopulatedParams = await (0, extensionsHelper_1.getFirebaseProjectParams)(args.projectId);
63
+ const subbedParams = (0, extensionsHelper_1.substituteParams)(params, autoPopulatedParams);
64
64
  instanceSpecs.push({
65
65
  instanceId,
66
66
  ref,