Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.displayNode10CreateBillingNotice = exports.displayNode10UpdateBillingNotice = void 0;
  4. const { marked } = require("marked");
  5. const TerminalRenderer = require("marked-terminal");
  6. const error_1 = require("../error");
  7. const extensionsHelper_1 = require("./extensionsHelper");
  8. const prompt_1 = require("../prompt");
  9. const utils = require("../utils");
  10. const utils_1 = require("./utils");
  11. marked.setOptions({
  12. renderer: new TerminalRenderer(),
  13. });
  14. const urlPricingExamples = "https://cloud.google.com/functions/pricing#pricing_examples";
  15. const urlFAQ = "https://firebase.google.com/support/faq/#extensions-pricing";
  16. const billingMsgUpdate = "This update includes an upgrade to Node.js 10 from Node.js 8, which is no" +
  17. " longer maintained. Starting with this update, you will be charged a" +
  18. " small amount (typically around $0.01/month) for the Firebase resources" +
  19. " required by this extension (even if it is not used), in addition to any" +
  20. " charges associated with its usage.\n\n" +
  21. `See pricing examples: **[${urlPricingExamples}](${urlPricingExamples})**\n` +
  22. `See the FAQ: **[${urlFAQ}](${urlFAQ})**\n`;
  23. const billingMsgCreate = "You will be charged around $0.01/month for the Firebase resources" +
  24. " required by this extension (even if it is not used). Additionally," +
  25. " using this extension will contribute to your project's overall usage" +
  26. " level of Firebase services. However, you'll only be charged for usage" +
  27. " that exceeds Firebase's free tier for those services.\n\n" +
  28. `See pricing examples: **[${urlPricingExamples}](${urlPricingExamples})**\n` +
  29. `See the FAQ: **[${urlFAQ}](${urlFAQ})**\n`;
  30. const defaultSpecVersion = "v1beta";
  31. const defaultRuntimes = {
  32. v1beta: "nodejs8",
  33. };
  34. function hasRuntime(spec, runtime) {
  35. const specVersion = spec.specVersion || defaultSpecVersion;
  36. const defaultRuntime = defaultRuntimes[specVersion];
  37. const resources = spec.resources || [];
  38. return resources.some((r) => runtime === ((0, utils_1.getResourceRuntime)(r) || defaultRuntime));
  39. }
  40. function displayNode10UpdateBillingNotice(curSpec, newSpec) {
  41. if (hasRuntime(curSpec, "nodejs8") && hasRuntime(newSpec, "nodejs10")) {
  42. utils.logLabeledWarning(extensionsHelper_1.logPrefix, marked(billingMsgUpdate));
  43. }
  44. }
  45. exports.displayNode10UpdateBillingNotice = displayNode10UpdateBillingNotice;
  46. async function displayNode10CreateBillingNotice(spec, prompt) {
  47. if (hasRuntime(spec, "nodejs10")) {
  48. utils.logLabeledWarning(extensionsHelper_1.logPrefix, marked(billingMsgCreate));
  49. if (prompt) {
  50. const continueUpdate = await (0, prompt_1.promptOnce)({
  51. type: "confirm",
  52. message: "Do you wish to continue?",
  53. default: true,
  54. });
  55. if (!continueUpdate) {
  56. throw new error_1.FirebaseError(`Cancelled.`, { exit: 2 });
  57. }
  58. }
  59. }
  60. }
  61. exports.displayNode10CreateBillingNotice = displayNode10CreateBillingNotice;