firebase-tools 11.4.0 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +8 -15
  2. package/lib/accountImporter.js +1 -1
  3. package/lib/auth.js +3 -4
  4. package/lib/bin/firebase.js +4 -4
  5. package/lib/command.js +3 -3
  6. package/lib/commands/apps-android-sha-create.js +1 -1
  7. package/lib/commands/apps-android-sha-delete.js +1 -1
  8. package/lib/commands/apps-create.js +1 -1
  9. package/lib/commands/apps-list.js +1 -1
  10. package/lib/commands/auth-export.js +1 -1
  11. package/lib/commands/auth-import.js +1 -1
  12. package/lib/commands/database-instances-list.js +1 -1
  13. package/lib/commands/database-push.js +1 -1
  14. package/lib/commands/database-remove.js +1 -1
  15. package/lib/commands/database-set.js +1 -1
  16. package/lib/commands/database-update.js +1 -1
  17. package/lib/commands/emulators-start.js +1 -1
  18. package/lib/commands/ext-dev-deprecate.js +1 -1
  19. package/lib/commands/ext-dev-emulators-exec.js +1 -1
  20. package/lib/commands/ext-dev-emulators-start.js +1 -1
  21. package/lib/commands/ext-dev-extension-delete.js +1 -1
  22. package/lib/commands/ext-dev-list.js +1 -1
  23. package/lib/commands/ext-dev-publish.js +1 -1
  24. package/lib/commands/ext-dev-register.js +1 -1
  25. package/lib/commands/ext-dev-undeprecate.js +1 -1
  26. package/lib/commands/ext-dev-unpublish.js +1 -1
  27. package/lib/commands/ext-dev-usage.js +1 -1
  28. package/lib/commands/ext-info.js +1 -1
  29. package/lib/commands/ext-install.js +2 -2
  30. package/lib/commands/ext-update.js +1 -1
  31. package/lib/commands/ext.js +1 -1
  32. package/lib/commands/firestore-delete.js +2 -2
  33. package/lib/commands/firestore-indexes-list.js +3 -3
  34. package/lib/commands/functions-config-clone.js +1 -1
  35. package/lib/commands/functions-config-export.js +1 -1
  36. package/lib/commands/functions-config-set.js +1 -1
  37. package/lib/commands/functions-config-unset.js +1 -1
  38. package/lib/commands/functions-delete.js +1 -1
  39. package/lib/commands/functions-secrets-set.js +1 -1
  40. package/lib/commands/help.js +1 -1
  41. package/lib/commands/hosting-channel-create.js +5 -5
  42. package/lib/commands/hosting-channel-delete.js +3 -3
  43. package/lib/commands/hosting-channel-deploy.js +6 -6
  44. package/lib/commands/hosting-channel-list.js +2 -2
  45. package/lib/commands/hosting-channel-open.js +2 -2
  46. package/lib/commands/hosting-clone.js +13 -8
  47. package/lib/commands/hosting-disable.js +1 -1
  48. package/lib/commands/hosting-sites-create.js +4 -4
  49. package/lib/commands/hosting-sites-delete.js +4 -4
  50. package/lib/commands/hosting-sites-list.js +2 -2
  51. package/lib/commands/init.js +5 -5
  52. package/lib/commands/login-add.js +1 -1
  53. package/lib/commands/login-ci.js +4 -2
  54. package/lib/commands/login-list.js +1 -1
  55. package/lib/commands/login-use.js +1 -1
  56. package/lib/commands/login.js +1 -1
  57. package/lib/commands/logout.js +1 -1
  58. package/lib/commands/open.js +3 -3
  59. package/lib/commands/projects-list.js +2 -2
  60. package/lib/commands/serve.js +1 -1
  61. package/lib/commands/target-apply.js +1 -1
  62. package/lib/commands/target-clear.js +1 -1
  63. package/lib/commands/target-remove.js +1 -1
  64. package/lib/commands/target.js +1 -1
  65. package/lib/commands/use.js +7 -7
  66. package/lib/config.js +1 -1
  67. package/lib/deploy/database/prepare.js +3 -3
  68. package/lib/deploy/database/release.js +3 -3
  69. package/lib/deploy/extensions/deploymentSummary.js +1 -1
  70. package/lib/deploy/extensions/errors.js +1 -1
  71. package/lib/deploy/extensions/secrets.js +1 -1
  72. package/lib/deploy/extensions/tasks.js +2 -2
  73. package/lib/deploy/firestore/deploy.js +2 -2
  74. package/lib/deploy/firestore/prepare.js +2 -2
  75. package/lib/deploy/functions/backend.js +7 -5
  76. package/lib/deploy/functions/build.js +110 -95
  77. package/lib/deploy/functions/checkIam.js +3 -3
  78. package/lib/deploy/functions/containerCleaner.js +2 -2
  79. package/lib/deploy/functions/deploy.js +2 -2
  80. package/lib/deploy/functions/ensure.js +2 -2
  81. package/lib/deploy/functions/params.js +5 -2
  82. package/lib/deploy/functions/prepare.js +4 -4
  83. package/lib/deploy/functions/prepareFunctionsUpload.js +2 -2
  84. package/lib/deploy/functions/pricing.js +3 -2
  85. package/lib/deploy/functions/prompts.js +2 -2
  86. package/lib/deploy/functions/release/fabricator.js +10 -9
  87. package/lib/deploy/functions/release/index.js +1 -1
  88. package/lib/deploy/functions/release/reporter.js +1 -1
  89. package/lib/deploy/functions/runtimes/discovery/parsing.js +19 -8
  90. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +112 -107
  91. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +1 -1
  92. package/lib/deploy/functions/runtimes/node/parseTriggers.js +54 -26
  93. package/lib/deploy/functions/runtimes/node/versioning.js +4 -4
  94. package/lib/deploy/functions/services/storage.js +6 -0
  95. package/lib/deploy/functions/validate.js +1 -1
  96. package/lib/deploy/hosting/convertConfig.js +13 -2
  97. package/lib/deploy/hosting/deploy.js +11 -10
  98. package/lib/deploy/hosting/uploader.js +2 -2
  99. package/lib/deploy/hosting/validate.js +2 -2
  100. package/lib/deploy/index.js +7 -7
  101. package/lib/deploy/lifecycleHooks.js +5 -2
  102. package/lib/deploy/storage/prepare.js +5 -3
  103. package/lib/deploy/storage/release.js +7 -6
  104. package/lib/emulator/commandUtils.js +1 -1
  105. package/lib/emulator/controller.js +1 -1
  106. package/lib/emulator/databaseEmulator.js +1 -1
  107. package/lib/emulator/downloadableEmulators.js +1 -1
  108. package/lib/emulator/emulatorLogger.js +1 -1
  109. package/lib/emulator/extensionsEmulator.js +2 -2
  110. package/lib/emulator/firestoreEmulator.js +1 -1
  111. package/lib/emulator/functionsEmulator.js +22 -10
  112. package/lib/emulator/functionsEmulatorShared.js +6 -11
  113. package/lib/emulator/loggingEmulator.js +2 -2
  114. package/lib/emulator/storage/apis/firebase.js +13 -1
  115. package/lib/emulator/storage/apis/gcloud.js +15 -8
  116. package/lib/emulator/storage/files.js +26 -24
  117. package/lib/emulator/storage/metadata.js +6 -6
  118. package/lib/emulator/storage/multipart.js +4 -3
  119. package/lib/emulator/storage/persistence.js +26 -12
  120. package/lib/emulator/storage/rules/runtime.js +1 -1
  121. package/lib/emulator/storage/rules/utils.js +4 -2
  122. package/lib/emulator/types.js +1 -0
  123. package/lib/ensureApiEnabled.js +7 -7
  124. package/lib/extensions/askUserForConsent.js +1 -1
  125. package/lib/extensions/askUserForEventsConfig.js +1 -1
  126. package/lib/extensions/askUserForParam.js +1 -1
  127. package/lib/extensions/changelog.js +2 -2
  128. package/lib/extensions/checkProjectBilling.js +2 -2
  129. package/lib/extensions/displayExtensionInfo.js +2 -102
  130. package/lib/extensions/emulator/triggerHelper.js +2 -2
  131. package/lib/extensions/extensionsApi.js +1 -1
  132. package/lib/extensions/extensionsHelper.js +1 -1
  133. package/lib/extensions/listExtensions.js +1 -1
  134. package/lib/extensions/manifest.js +1 -1
  135. package/lib/extensions/metricsUtils.js +1 -1
  136. package/lib/extensions/paramHelper.js +1 -1
  137. package/lib/extensions/updateHelper.js +3 -9
  138. package/lib/extensions/warnings.js +2 -2
  139. package/lib/fetchMOTD.js +1 -1
  140. package/lib/firestore/delete.js +1 -1
  141. package/lib/firestore/indexes.js +2 -2
  142. package/lib/firestore/validator.js +1 -1
  143. package/lib/functional.js +16 -1
  144. package/lib/functions/env.js +3 -3
  145. package/lib/functions/runtimeConfigExport.js +1 -1
  146. package/lib/functionsConfig.js +1 -1
  147. package/lib/functionsConfigClone.js +1 -1
  148. package/lib/functionsShellCommandAction.js +1 -1
  149. package/lib/gcp/cloudfunctions.js +24 -11
  150. package/lib/gcp/cloudfunctionsv2.js +48 -24
  151. package/lib/gcp/cloudscheduler.js +58 -22
  152. package/lib/gcp/cloudtasks.js +21 -4
  153. package/lib/gcp/proto.js +18 -6
  154. package/lib/gcp/resourceManager.js +25 -3
  155. package/lib/gcp/serviceusage.js +2 -2
  156. package/lib/handlePreviewToggles.js +4 -4
  157. package/lib/hosting/implicitInit.js +1 -1
  158. package/lib/hosting/normalizedHostingConfigs.js +3 -3
  159. package/lib/index.js +3 -3
  160. package/lib/init/features/database.js +1 -1
  161. package/lib/init/features/emulators.js +1 -1
  162. package/lib/init/features/firestore/index.js +2 -2
  163. package/lib/init/features/firestore/indexes.js +1 -1
  164. package/lib/init/features/firestore/rules.js +1 -1
  165. package/lib/init/features/functions/golang.js +1 -1
  166. package/lib/init/features/functions/index.js +8 -1
  167. package/lib/init/features/hosting/github.js +9 -9
  168. package/lib/init/features/hosting/index.js +1 -1
  169. package/lib/init/features/project.js +1 -1
  170. package/lib/init/features/remoteconfig.js +1 -1
  171. package/lib/init/features/storage.js +1 -1
  172. package/lib/init/index.js +1 -1
  173. package/lib/logError.js +3 -3
  174. package/lib/management/projects.js +1 -1
  175. package/lib/parseBoltRules.js +1 -1
  176. package/lib/previews.js +1 -1
  177. package/lib/profileReport.js +2 -2
  178. package/lib/projectUtils.js +1 -1
  179. package/lib/rc.js +1 -1
  180. package/lib/requireAuth.js +5 -1
  181. package/lib/requireDatabaseInstance.js +2 -2
  182. package/lib/requirePermissions.js +2 -2
  183. package/lib/rulesDeploy.js +49 -13
  184. package/lib/serve/hosting.js +2 -1
  185. package/lib/utils.js +10 -10
  186. package/npm-shrinkwrap.json +26 -295
  187. package/package.json +8 -5
  188. package/templates/hosting/init.js +6 -2
@@ -287,15 +287,15 @@ class CloudStorageObjectMetadata {
287
287
  }
288
288
  exports.CloudStorageObjectMetadata = CloudStorageObjectMetadata;
289
289
  function toSerializedDate(d) {
290
- const day = `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d
291
- .getDate()
290
+ const day = `${d.getUTCFullYear()}-${(d.getUTCMonth() + 1).toString().padStart(2, "0")}-${d
291
+ .getUTCDate()
292
292
  .toString()
293
293
  .padStart(2, "0")}`;
294
- const time = `${d.getHours().toString().padStart(2, "0")}:${d
295
- .getMinutes()
294
+ const time = `${d.getUTCHours().toString().padStart(2, "0")}:${d
295
+ .getUTCMinutes()
296
296
  .toString()
297
- .padStart(2, "0")}:${d.getSeconds().toString().padStart(2, "0")}.${d
298
- .getMilliseconds()
297
+ .padStart(2, "0")}:${d.getUTCSeconds().toString().padStart(2, "0")}.${d
298
+ .getUTCMilliseconds()
299
299
  .toString()
300
300
  .padStart(3, "0")}`;
301
301
  return `${day}T${time}Z`;
@@ -23,7 +23,8 @@ function splitBufferByDelimiter(buffer, delimiter, maxResults = -1) {
23
23
  return bufferParts;
24
24
  }
25
25
  function parseMultipartRequestBody(boundaryId, body) {
26
- const boundaryString = `--${boundaryId}`;
26
+ const cleanBoundaryId = boundaryId.replace(/^["'](.+(?=["']$))["']$/, "$1");
27
+ const boundaryString = `--${cleanBoundaryId}`;
27
28
  const bodyParts = splitBufferByDelimiter(body, boundaryString).map((buf) => {
28
29
  return Buffer.from(buf.slice(2));
29
30
  });
@@ -35,8 +36,8 @@ function parseMultipartRequestBody(boundaryId, body) {
35
36
  }
36
37
  function parseMultipartRequestBodyPart(bodyPart) {
37
38
  const sections = splitBufferByDelimiter(bodyPart, LINE_SEPARATOR, 3);
38
- const contentTypeRaw = sections[0].toString();
39
- if (!contentTypeRaw.startsWith("Content-Type: ")) {
39
+ const contentTypeRaw = sections[0].toString().toLowerCase();
40
+ if (!contentTypeRaw.startsWith("content-type: ")) {
40
41
  throw new Error(`Failed to parse multipart request body part. Missing content type.`);
41
42
  }
42
43
  const dataRaw = Buffer.from(sections[2]).slice(0, sections[2].byteLength - LINE_SEPARATOR.length);
@@ -4,9 +4,12 @@ exports.Persistence = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const rimraf = require("rimraf");
6
6
  const fs = require("fs");
7
+ const fse = require("fs-extra");
7
8
  const path = require("path");
9
+ const uuid = require("uuid");
8
10
  class Persistence {
9
11
  constructor(dirPath) {
12
+ this._diskPathMap = new Map();
10
13
  this.reset(dirPath);
11
14
  }
12
15
  reset(dirPath) {
@@ -14,22 +17,18 @@ class Persistence {
14
17
  (0, fs_1.mkdirSync)(dirPath, {
15
18
  recursive: true,
16
19
  });
20
+ this._diskPathMap = new Map();
17
21
  }
18
22
  get dirPath() {
19
23
  return this._dirPath;
20
24
  }
21
25
  appendBytes(fileName, bytes) {
22
- const filepath = this.getDiskPath(fileName);
23
- let fd;
24
- try {
25
- fs.appendFileSync(filepath, bytes);
26
- return filepath;
27
- }
28
- finally {
29
- if (fd) {
30
- (0, fs_1.closeSync)(fd);
31
- }
26
+ if (!this._diskPathMap.has(fileName)) {
27
+ this._diskPathMap.set(fileName, this.generateNewDiskName());
32
28
  }
29
+ const filepath = this.getDiskPath(fileName);
30
+ fs.appendFileSync(filepath, bytes);
31
+ return filepath;
33
32
  }
34
33
  readBytes(fileName, size, fileOffset) {
35
34
  let fd;
@@ -55,6 +54,7 @@ class Persistence {
55
54
  throw err;
56
55
  }
57
56
  }
57
+ this._diskPathMap.delete(fileName);
58
58
  }
59
59
  deleteAll() {
60
60
  return new Promise((resolve, reject) => {
@@ -63,16 +63,30 @@ class Persistence {
63
63
  reject(err);
64
64
  }
65
65
  else {
66
+ this._diskPathMap = new Map();
66
67
  resolve();
67
68
  }
68
69
  });
69
70
  });
70
71
  }
71
72
  renameFile(oldName, newName) {
72
- (0, fs_1.renameSync)(this.getDiskPath(oldName), this.getDiskPath(newName));
73
+ const oldNameId = this.getDiskFileName(oldName);
74
+ this._diskPathMap.set(newName, oldNameId);
75
+ this._diskPathMap.delete(oldName);
73
76
  }
74
77
  getDiskPath(fileName) {
75
- return path.join(this._dirPath, encodeURIComponent(fileName));
78
+ const shortenedDiskPath = this.getDiskFileName(fileName);
79
+ return path.join(this._dirPath, encodeURIComponent(shortenedDiskPath));
80
+ }
81
+ getDiskFileName(fileName) {
82
+ return this._diskPathMap.get(fileName);
83
+ }
84
+ copyFromExternalPath(sourcePath, newName) {
85
+ this._diskPathMap.set(newName, this.generateNewDiskName());
86
+ fse.copyFileSync(sourcePath, this.getDiskPath(newName));
87
+ }
88
+ generateNewDiskName() {
89
+ return uuid.v4();
76
90
  }
77
91
  }
78
92
  exports.Persistence = Persistence;
@@ -199,6 +199,7 @@ class StorageRulesRuntime {
199
199
  service: "firebase.storage",
200
200
  path: opts.path,
201
201
  method: opts.method,
202
+ delimiter: opts.delimiter,
202
203
  variables: runtimeVariables,
203
204
  },
204
205
  };
@@ -293,7 +294,6 @@ function createRequestExpressionValue(opts) {
293
294
  segments: opts.path
294
295
  .split("/")
295
296
  .filter((s) => s)
296
- .slice(3)
297
297
  .map((simple) => ({
298
298
  simple,
299
299
  })),
@@ -5,13 +5,14 @@ const emulatorLogger_1 = require("../../emulatorLogger");
5
5
  const types_1 = require("../../types");
6
6
  function getFirebaseRulesValidator(rulesetProvider) {
7
7
  return {
8
- validate: async (path, bucketId, method, variableOverrides, authorization) => {
8
+ validate: async (path, bucketId, method, variableOverrides, authorization, delimiter) => {
9
9
  return await isPermitted({
10
10
  ruleset: rulesetProvider(bucketId),
11
11
  file: variableOverrides,
12
12
  path,
13
13
  method,
14
14
  authorization,
15
+ delimiter,
15
16
  });
16
17
  },
17
18
  };
@@ -19,7 +20,7 @@ function getFirebaseRulesValidator(rulesetProvider) {
19
20
  exports.getFirebaseRulesValidator = getFirebaseRulesValidator;
20
21
  function getAdminOnlyFirebaseRulesValidator() {
21
22
  return {
22
- validate: (_path, _bucketId, _method, _variableOverrides, _authorization) => {
23
+ validate: (_path, _bucketId, _method, _variableOverrides, _authorization, delimiter) => {
23
24
  return Promise.resolve(true);
24
25
  },
25
26
  };
@@ -42,6 +43,7 @@ async function isPermitted(opts) {
42
43
  path: opts.path,
43
44
  file: opts.file,
44
45
  token: opts.authorization ? opts.authorization.split(" ")[1] : undefined,
46
+ delimiter: opts.delimiter,
45
47
  });
46
48
  if (issues.exist()) {
47
49
  issues.all.forEach((warningOrError) => {
@@ -56,6 +56,7 @@ exports.EMULATORS_SUPPORTED_BY_USE_EMULATOR = [
56
56
  Emulators.DATABASE,
57
57
  Emulators.FIRESTORE,
58
58
  Emulators.FUNCTIONS,
59
+ Emulators.STORAGE,
59
60
  ];
60
61
  exports.ALL_EMULATORS = [
61
62
  Emulators.HUB,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enableApiURI = exports.ensure = exports.check = exports.POLL_SETTINGS = void 0;
4
- const cli_color_1 = require("cli-color");
4
+ const colorette_1 = require("colorette");
5
5
  const track_1 = require("./track");
6
6
  const api_1 = require("./api");
7
7
  const apiv2_1 = require("./apiv2");
@@ -21,7 +21,7 @@ async function check(projectId, apiName, prefix, silent = false) {
21
21
  });
22
22
  const isEnabled = res.body.state === "ENABLED";
23
23
  if (isEnabled && !silent) {
24
- utils.logLabeledSuccess(prefix, `required API ${(0, cli_color_1.bold)(apiName)} is enabled`);
24
+ utils.logLabeledSuccess(prefix, `required API ${(0, colorette_1.bold)(apiName)} is enabled`);
25
25
  }
26
26
  return isEnabled;
27
27
  }
@@ -34,7 +34,7 @@ async function enable(projectId, apiName) {
34
34
  }
35
35
  catch (err) {
36
36
  if ((0, error_1.isBillingError)(err)) {
37
- throw new error_1.FirebaseError(`Your project ${(0, cli_color_1.bold)(projectId)} must be on the Blaze (pay-as-you-go) plan to complete this command. Required API ${(0, cli_color_1.bold)(apiName)} can't be enabled until the upgrade is complete. To upgrade, visit the following URL:
37
+ throw new error_1.FirebaseError(`Your project ${(0, colorette_1.bold)(projectId)} must be on the Blaze (pay-as-you-go) plan to complete this command. Required API ${(0, colorette_1.bold)(apiName)} can't be enabled until the upgrade is complete. To upgrade, visit the following URL:
38
38
 
39
39
  https://console.firebase.google.com/project/${projectId}/usage/details`);
40
40
  }
@@ -54,27 +54,27 @@ async function pollCheckEnabled(projectId, apiName, prefix, silent, enablementRe
54
54
  return;
55
55
  }
56
56
  if (!silent) {
57
- utils.logLabeledBullet(prefix, `waiting for API ${(0, cli_color_1.bold)(apiName)} to activate...`);
57
+ utils.logLabeledBullet(prefix, `waiting for API ${(0, colorette_1.bold)(apiName)} to activate...`);
58
58
  }
59
59
  return pollCheckEnabled(projectId, apiName, prefix, silent, enablementRetries, pollRetries + 1);
60
60
  }
61
61
  async function enableApiWithRetries(projectId, apiName, prefix, silent, enablementRetries = 0) {
62
62
  if (enablementRetries > 1) {
63
- throw new error_1.FirebaseError(`Timed out waiting for API ${(0, cli_color_1.bold)(apiName)} to enable. Please try again in a few minutes.`);
63
+ throw new error_1.FirebaseError(`Timed out waiting for API ${(0, colorette_1.bold)(apiName)} to enable. Please try again in a few minutes.`);
64
64
  }
65
65
  await enable(projectId, apiName);
66
66
  return pollCheckEnabled(projectId, apiName, prefix, silent, enablementRetries);
67
67
  }
68
68
  async function ensure(projectId, apiName, prefix, silent = false) {
69
69
  if (!silent) {
70
- utils.logLabeledBullet(prefix, `ensuring required API ${(0, cli_color_1.bold)(apiName)} is enabled...`);
70
+ utils.logLabeledBullet(prefix, `ensuring required API ${(0, colorette_1.bold)(apiName)} is enabled...`);
71
71
  }
72
72
  const isEnabled = await check(projectId, apiName, prefix, silent);
73
73
  if (isEnabled) {
74
74
  return;
75
75
  }
76
76
  if (!silent) {
77
- utils.logLabeledWarning(prefix, `missing required API ${(0, cli_color_1.bold)(apiName)}. Enabling now...`);
77
+ utils.logLabeledWarning(prefix, `missing required API ${(0, colorette_1.bold)(apiName)}. Enabling now...`);
78
78
  }
79
79
  return enableApiWithRetries(projectId, apiName, prefix, silent);
80
80
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.promptForPublisherTOS = exports.displayApis = exports.displayRoles = exports.retrieveRoleInfo = exports.formatDescription = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const { marked } = require("marked");
6
6
  const TerminalRenderer = require("marked-terminal");
7
7
  const error_1 = require("../error");
@@ -4,7 +4,7 @@ exports.askForEventArcLocation = exports.askShouldCollectEventsConfig = exports.
4
4
  const prompt_1 = require("../prompt");
5
5
  const extensionsApi = require("../extensions/extensionsApi");
6
6
  const utils = require("../utils");
7
- const clc = require("cli-color");
7
+ const clc = require("colorette");
8
8
  const logger_1 = require("../logger");
9
9
  const { marked } = require("marked");
10
10
  function checkAllowedEventTypesResponse(response, validEvents) {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInquirerDefault = exports.promptCreateSecret = exports.askForParam = exports.ask = exports.checkResponse = exports.SecretLocation = void 0;
4
4
  const _ = require("lodash");
5
- const clc = require("cli-color");
5
+ const clc = require("colorette");
6
6
  const { marked } = require("marked");
7
7
  const types_1 = require("./types");
8
8
  const secretManagerApi = require("../gcp/secretManager");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseChangelog = exports.getLocalChangelog = exports.breakingChangesInUpdate = exports.displayReleaseNotes = exports.getReleaseNotesForUpdate = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const { marked } = require("marked");
6
6
  const path = require("path");
7
7
  const semver = require("semver");
@@ -39,7 +39,7 @@ function displayReleaseNotes(releaseNotes, fromVersion) {
39
39
  const table = new Table({ head: ["Version", "What's New"], style: { head: ["yellow", "bold"] } });
40
40
  for (const [version, note] of Object.entries(releaseNotes)) {
41
41
  if (breakingVersions.includes(version)) {
42
- table.push([clc.yellow.bold(version), marked(note)]);
42
+ table.push([clc.yellow(clc.bold(version)), marked(note)]);
43
43
  }
44
44
  else {
45
45
  table.push([version, marked(note)]);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enableBilling = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const opn = require("open");
6
6
  const cloudbilling = require("../gcp/cloudbilling");
7
7
  const error_1 = require("../error");
@@ -59,7 +59,7 @@ async function setUpBillingAccount(projectId) {
59
59
  logger_1.logger.info();
60
60
  logger_1.logger.info(`Extension require your project to be upgraded to the Blaze plan. Please visit the following link to add a billing account:`);
61
61
  logger_1.logger.info();
62
- logger_1.logger.info(clc.bold.underline(billingURL));
62
+ logger_1.logger.info(clc.bold(clc.underline(billingURL)));
63
63
  logger_1.logger.info();
64
64
  const open = await prompt.promptOnce({
65
65
  name: "open-url",
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printSourceDownloadLink = exports.displayUpdateChangesRequiringConfirmation = exports.displayUpdateChangesNoInput = exports.displayExtInfo = void 0;
4
- const _ = require("lodash");
5
- const clc = require("cli-color");
3
+ exports.printSourceDownloadLink = exports.displayExtInfo = void 0;
4
+ const clc = require("colorette");
6
5
  const { marked } = require("marked");
7
6
  const TerminalRenderer = require("marked-terminal");
8
7
  const utils = require("../utils");
@@ -12,8 +11,6 @@ const error_1 = require("../error");
12
11
  marked.setOptions({
13
12
  renderer: new TerminalRenderer(),
14
13
  });
15
- const additionColor = clc.green;
16
- const deletionColor = clc.red;
17
14
  function displayExtInfo(extensionName, publisher, spec, published = false) {
18
15
  const lines = [];
19
16
  lines.push(`**Name**: ${spec.displayName}`);
@@ -46,103 +43,6 @@ function displayExtInfo(extensionName, publisher, spec, published = false) {
46
43
  }
47
44
  }
48
45
  exports.displayExtInfo = displayExtInfo;
49
- function displayUpdateChangesNoInput(spec, newSpec) {
50
- var _a, _b, _c, _d;
51
- const lines = [];
52
- if (spec.displayName !== newSpec.displayName) {
53
- lines.push("", "**Name:**", deletionColor(`- ${spec.displayName}`), additionColor(`+ ${newSpec.displayName}`));
54
- }
55
- if (((_a = spec.author) === null || _a === void 0 ? void 0 : _a.authorName) !== ((_b = newSpec.author) === null || _b === void 0 ? void 0 : _b.authorName)) {
56
- lines.push("", "**Author:**", deletionColor(`- ${(_c = spec.author) === null || _c === void 0 ? void 0 : _c.authorName}`), additionColor(`+ ${(_d = spec.author) === null || _d === void 0 ? void 0 : _d.authorName}`));
57
- }
58
- if (spec.description !== newSpec.description) {
59
- lines.push("", "**Description:**", deletionColor(`- ${spec.description}`), additionColor(`+ ${newSpec.description}`));
60
- }
61
- if (spec.sourceUrl !== newSpec.sourceUrl) {
62
- lines.push("", "**Source code:**", deletionColor(`- ${spec.sourceUrl}`), additionColor(`+ ${newSpec.sourceUrl}`));
63
- }
64
- if (spec.billingRequired && !newSpec.billingRequired) {
65
- lines.push("", "**Billing is no longer required for this extension.**");
66
- }
67
- logger_1.logger.info(marked(lines.join("\n")));
68
- return lines;
69
- }
70
- exports.displayUpdateChangesNoInput = displayUpdateChangesNoInput;
71
- async function displayUpdateChangesRequiringConfirmation(args) {
72
- const equals = (a, b) => {
73
- return _.isEqual(a, b);
74
- };
75
- if (args.spec.license !== args.newSpec.license) {
76
- const message = "\n" +
77
- "**License**\n" +
78
- deletionColor(args.spec.license ? `- ${args.spec.license}\n` : "- None\n") +
79
- additionColor(args.newSpec.license ? `+ ${args.newSpec.license}\n` : "+ None\n");
80
- logger_1.logger.info(message);
81
- if (!(await (0, extensionsHelper_1.confirm)({ nonInteractive: args.nonInteractive, force: args.force, default: true }))) {
82
- throw new error_1.FirebaseError("Unable to update this extension instance without explicit consent for the change to 'License'.");
83
- }
84
- }
85
- const apisDiffDeletions = _.differenceWith(args.spec.apis, _.get(args.newSpec, "apis", []), equals);
86
- const apisDiffAdditions = _.differenceWith(args.newSpec.apis, _.get(args.spec, "apis", []), equals);
87
- if (apisDiffDeletions.length || apisDiffAdditions.length) {
88
- let message = "\n**APIs:**\n";
89
- apisDiffDeletions.forEach((api) => {
90
- message += deletionColor(`- ${api.apiName} (${api.reason})\n`);
91
- });
92
- apisDiffAdditions.forEach((api) => {
93
- message += additionColor(`+ ${api.apiName} (${api.reason})\n`);
94
- });
95
- logger_1.logger.info(message);
96
- if (!(await (0, extensionsHelper_1.confirm)({ nonInteractive: args.nonInteractive, force: args.force, default: true }))) {
97
- throw new error_1.FirebaseError("Unable to update this extension instance without explicit consent for the change to 'APIs'.");
98
- }
99
- }
100
- const resourcesDiffDeletions = _.differenceWith(args.spec.resources, _.get(args.newSpec, "resources", []), compareResources);
101
- const resourcesDiffAdditions = _.differenceWith(args.newSpec.resources, _.get(args.spec, "resources", []), compareResources);
102
- if (resourcesDiffDeletions.length || resourcesDiffAdditions.length) {
103
- let message = "\n**Resources:**\n";
104
- resourcesDiffDeletions.forEach((resource) => {
105
- message += deletionColor(` - ${getResourceReadableName(resource)}`);
106
- });
107
- resourcesDiffAdditions.forEach((resource) => {
108
- message += additionColor(`+ ${getResourceReadableName(resource)}`);
109
- });
110
- logger_1.logger.info(message);
111
- if (!(await (0, extensionsHelper_1.confirm)({ nonInteractive: args.nonInteractive, force: args.force, default: true }))) {
112
- throw new error_1.FirebaseError("Unable to update this extension instance without explicit consent for the change to 'Resources'.");
113
- }
114
- }
115
- const rolesDiffDeletions = _.differenceWith(args.spec.roles, _.get(args.newSpec, "roles", []), equals);
116
- const rolesDiffAdditions = _.differenceWith(args.newSpec.roles, _.get(args.spec, "roles", []), equals);
117
- if (rolesDiffDeletions.length || rolesDiffAdditions.length) {
118
- let message = "\n**Permissions:**\n";
119
- rolesDiffDeletions.forEach((role) => {
120
- message += deletionColor(`- ${role.role} (${role.reason})\n`);
121
- });
122
- rolesDiffAdditions.forEach((role) => {
123
- message += additionColor(`+ ${role.role} (${role.reason})\n`);
124
- });
125
- logger_1.logger.info(message);
126
- if (!(await (0, extensionsHelper_1.confirm)({ nonInteractive: args.nonInteractive, force: args.force, default: true }))) {
127
- throw new error_1.FirebaseError("Unable to update this extension instance without explicit consent for the change to 'Permissions'.");
128
- }
129
- }
130
- if (!args.spec.billingRequired && args.newSpec.billingRequired) {
131
- logger_1.logger.info("Billing is now required for the new version of this extension.");
132
- if (!(await (0, extensionsHelper_1.confirm)({ nonInteractive: args.nonInteractive, force: args.force, default: true }))) {
133
- throw new error_1.FirebaseError("Unable to update this extension instance without explicit consent for the change to 'BillingRequired'.");
134
- }
135
- }
136
- }
137
- exports.displayUpdateChangesRequiringConfirmation = displayUpdateChangesRequiringConfirmation;
138
- function compareResources(resource1, resource2) {
139
- return resource1.name === resource2.name && resource1.type === resource2.type;
140
- }
141
- function getResourceReadableName(resource) {
142
- return resource.type === "firebaseextensions.v1beta.function"
143
- ? `${resource.name} (Cloud Function): ${resource.description}\n`
144
- : `${resource.name} (${resource.type})\n`;
145
- }
146
46
  function printSourceDownloadLink(sourceDownloadUri) {
147
47
  const sourceDownloadMsg = `Want to review the source code that will be installed? Download it here: ${sourceDownloadUri}`;
148
48
  utils.logBullet(marked(sourceDownloadMsg));
@@ -12,8 +12,8 @@ function functionResourceToEmulatedTriggerDefintion(resource) {
12
12
  platform: "gcfv1",
13
13
  };
14
14
  const properties = resource.properties || {};
15
- proto.renameIfPresent(etd, properties, "timeoutSeconds", "timeout", proto.secondsFromDuration);
16
- proto.renameIfPresent(etd, properties, "regions", "location", (str) => [str]);
15
+ proto.convertIfPresent(etd, properties, "timeoutSeconds", "timeout", proto.secondsFromDuration);
16
+ proto.convertIfPresent(etd, properties, "regions", "location", (str) => [str]);
17
17
  proto.copyIfPresent(etd, properties, "availableMemoryMb");
18
18
  if (properties.httpsTrigger) {
19
19
  etd.httpsTrigger = properties.httpsTrigger;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getExtension = exports.deleteExtension = exports.unpublishExtension = exports.publishExtensionVersion = exports.undeprecateExtensionVersion = exports.deprecateExtensionVersion = exports.registerPublisherProfile = exports.getPublisherProfile = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = void 0;
4
4
  const yaml = require("js-yaml");
5
- const clc = require("cli-color");
5
+ const clc = require("colorette");
6
6
  const { marked } = require("marked");
7
7
  const apiv2_1 = require("../apiv2");
8
8
  const api_1 = require("../api");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.canonicalizeRefInput = exports.diagnoseAndFixProject = exports.confirm = exports.getSourceOrigin = exports.isLocalOrURLPath = exports.isLocalPath = exports.isUrlPath = exports.instanceIdExists = exports.promptForRepeatInstance = exports.promptForOfficialExtension = exports.displayReleaseNotes = exports.getPublisherProjectFromName = exports.createSourceFromLocation = exports.publishExtensionVersionFromLocalSource = exports.ensureExtensionsApiEnabled = exports.promptForValidInstanceId = exports.validateSpec = exports.validateCommandLineParams = exports.populateDefaultParams = exports.substituteParams = exports.getFirebaseProjectParams = exports.getDBInstanceFromURL = exports.resourceTypeToNiceName = exports.AUTOPOULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.URL_REGEX = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const ora = require("ora");
6
6
  const semver = require("semver");
7
7
  const { marked } = require("marked");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.listExtensions = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const Table = require("cli-table");
6
6
  const extensionsApi_1 = require("./extensionsApi");
7
7
  const logger_1 = require("../logger");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.showPostDeprecationNotice = exports.readInstanceParam = exports.getInstanceRef = exports.getInstanceTarget = exports.instanceExists = exports.loadConfig = exports.removeFromManifest = exports.writeLocalSecrets = exports.writeToManifest = exports.ENV_DIRECTORY = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const path = require("path");
6
6
  const refs = require("./refs");
7
7
  const config_1 = require("../config");
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildMetricsTableRow = exports.parseBucket = exports.parseTimeseriesResponse = void 0;
4
4
  const semver = require("semver");
5
- const clc = require("cli-color");
5
+ const clc = require("colorette");
6
6
  function parseTimeseriesResponse(series) {
7
7
  const ret = [];
8
8
  for (const s of series) {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readEnvFile = exports.promptForNewParams = exports.getParamsForUpdate = exports.getParams = exports.getParamsWithCurrentValuesAsDefaults = exports.setNewDefaults = exports.buildBindingOptionsWithBaseValue = exports.getBaseParamBindings = void 0;
4
4
  const path = require("path");
5
- const clc = require("cli-color");
5
+ const clc = require("colorette");
6
6
  const fs = require("fs-extra");
7
7
  const error_1 = require("../error");
8
8
  const logger_1 = require("../logger");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inferUpdateSource = exports.updateFromPublisherSource = exports.updateToVersionFromPublisherSource = exports.updateFromUrlSource = exports.updateFromLocalSource = exports.update = exports.displayChanges = exports.warningUpdateToOtherSource = exports.getExistingSourceOrigin = void 0;
4
- const clc = require("cli-color");
3
+ exports.inferUpdateSource = exports.updateFromPublisherSource = exports.updateToVersionFromPublisherSource = exports.updateFromUrlSource = exports.updateFromLocalSource = exports.update = exports.warningUpdateToOtherSource = exports.getExistingSourceOrigin = void 0;
4
+ const clc = require("colorette");
5
5
  const semver = require("semver");
6
6
  const { marked } = require("marked");
7
7
  const error_1 = require("../error");
@@ -52,12 +52,6 @@ function warningUpdateToOtherSource(sourceOrigin) {
52
52
  logger_1.logger.info(marked(warning));
53
53
  }
54
54
  exports.warningUpdateToOtherSource = warningUpdateToOtherSource;
55
- async function displayChanges(args) {
56
- utils.logLabeledBullet("extensions", "This update contains the following changes:");
57
- (0, displayExtensionInfo_1.displayUpdateChangesNoInput)(args.spec, args.newSpec);
58
- await (0, displayExtensionInfo_1.displayUpdateChangesRequiringConfirmation)(args);
59
- }
60
- exports.displayChanges = displayChanges;
61
55
  async function update(updateOptions) {
62
56
  const { projectId, instanceId, source, extRef, params, canEmitEvents, allowedEventTypes, eventarcChannel, } = updateOptions;
63
57
  if (extRef) {
@@ -126,7 +120,7 @@ async function updateToVersionFromPublisherSource(projectId, instanceId, extVers
126
120
  source = await extensionsApi.getExtensionVersion(extVersionRef);
127
121
  }
128
122
  catch (err) {
129
- throw new error_1.FirebaseError(`Could not find source '${clc.bold(extVersionRef)}' because (${clc.bold(version)}) is not a published version. To update, use the latest version of this extension (${clc.bold(extension.latestVersion)}).`);
123
+ throw new error_1.FirebaseError(`Could not find source '${clc.bold(extVersionRef)}' because (${clc.bold(version || "")}) is not a published version. To update, use the latest version of this extension (${clc.bold(extension.latestVersion || "")}).`);
130
124
  }
131
125
  showUpdateVersionInfo(instanceId, existingSpec.version, source.spec.version, extVersionRef);
132
126
  warningUpdateToOtherSource(extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.outOfBandChangesWarning = exports.paramsFlagDeprecationWarning = exports.displayWarningsForDeploy = exports.displayWarningPrompts = void 0;
4
4
  const { marked } = require("marked");
5
- const clc = require("cli-color");
5
+ const clc = require("colorette");
6
6
  const types_1 = require("./types");
7
7
  const displayExtensionInfo_1 = require("./displayExtensionInfo");
8
8
  const extensionsHelper_1 = require("./extensionsHelper");
@@ -20,7 +20,7 @@ function displayEAPWarning({ publisherId, sourceDownloadUri, githubLink, }) {
20
20
  (0, displayExtensionInfo_1.printSourceDownloadLink)(sourceDownloadUri);
21
21
  }
22
22
  function displayExperimentalWarning() {
23
- utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`${clc.yellow.bold("Important")}: This extension is ${clc.bold("experimental")} and may not be production-ready. Its functionality might change in backward-incompatible ways before its official release, or it may be discontinued.`));
23
+ utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`${clc.yellow(clc.bold("Important"))}: This extension is ${clc.bold("experimental")} and may not be production-ready. Its functionality might change in backward-incompatible ways before its official release, or it may be discontinued.`));
24
24
  }
25
25
  async function displayWarningPrompts(publisherId, launchStage, extensionVersion) {
26
26
  const trustedPublishers = await (0, resolveSource_1.getTrustedPublishers)();
package/lib/fetchMOTD.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchMOTD = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const semver = require("semver");
6
6
  const apiv2_1 = require("./apiv2");
7
7
  const configstore_1 = require("./configstore");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FirestoreDelete = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const ProgressBar = require("progress");
6
6
  const apiv2 = require("../apiv2");
7
7
  const firestore = require("../gcp/firestore");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FirestoreIndexes = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const logger_1 = require("../logger");
6
6
  const utils = require("../utils");
7
7
  const validator = require("./validator");
@@ -345,7 +345,7 @@ class FirestoreIndexes {
345
345
  return result;
346
346
  }
347
347
  if (spec.indexes[0].collectionId) {
348
- utils.logBullet(clc.bold.cyan("firestore:") +
348
+ utils.logBullet(clc.bold(clc.cyan("firestore:")) +
349
349
  " your indexes indexes are specified in the v1beta1 API format. " +
350
350
  "Please upgrade to the new index API format by running " +
351
351
  clc.bold("firebase firestore:indexes") +
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertEnum = exports.assertHasOneOf = exports.assertHas = void 0;
4
- const clc = require("cli-color");
4
+ const clc = require("colorette");
5
5
  const error_1 = require("../error");
6
6
  function assertHas(obj, prop) {
7
7
  const objString = clc.cyan(JSON.stringify(obj));
package/lib/functional.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.partition = exports.assertExhaustive = exports.zipIn = exports.zip = exports.reduceFlat = exports.flatten = exports.flattenArray = exports.flattenObject = void 0;
3
+ exports.nullsafeVisitor = exports.mapObject = exports.partition = exports.assertExhaustive = exports.zipIn = exports.zip = exports.reduceFlat = exports.flatten = exports.flattenArray = exports.flattenObject = void 0;
4
4
  function* flattenObject(obj) {
5
5
  function* helper(path, obj) {
6
6
  for (const [k, v] of Object.entries(obj)) {
@@ -63,3 +63,18 @@ function partition(arr, callbackFn) {
63
63
  }, [[], []]);
64
64
  }
65
65
  exports.partition = partition;
66
+ function mapObject(input, transform) {
67
+ const result = {};
68
+ for (const [k, v] of Object.entries(input)) {
69
+ result[k] = transform(v);
70
+ }
71
+ return result;
72
+ }
73
+ exports.mapObject = mapObject;
74
+ const nullsafeVisitor = (func, ...rest) => (first) => {
75
+ if (first === null) {
76
+ return null;
77
+ }
78
+ return func(first, ...rest);
79
+ };
80
+ exports.nullsafeVisitor = nullsafeVisitor;