No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

warnings.js 6.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.outOfBandChangesWarning = exports.paramsFlagDeprecationWarning = exports.displayWarningsForDeploy = exports.displayWarningPrompts = void 0;
  4. const { marked } = require("marked");
  5. const clc = require("colorette");
  6. const types_1 = require("./types");
  7. const displayExtensionInfo_1 = require("./displayExtensionInfo");
  8. const extensionsHelper_1 = require("./extensionsHelper");
  9. const resolveSource_1 = require("./resolveSource");
  10. const deploymentSummary_1 = require("../deploy/extensions/deploymentSummary");
  11. const planner_1 = require("../deploy/extensions/planner");
  12. const functional_1 = require("../functional");
  13. const utils = require("../utils");
  14. const logger_1 = require("../logger");
  15. function displayEAPWarning({ publisherId, sourceDownloadUri, githubLink, }) {
  16. const publisherNameLink = githubLink ? `[${publisherId}](${githubLink})` : publisherId;
  17. const warningMsg = `This extension is in preview and is built by a developer in the [Extensions Publisher Early Access Program](http://bit.ly/firex-provider). Its functionality might change in backward-incompatible ways. Since this extension isn't built by Firebase, reach out to ${publisherNameLink} with questions about this extension.`;
  18. const legalMsg = "\n\nIt is provided “AS IS”, without any warranty, express or implied, from Google. Google disclaims all liability for any damages, direct or indirect, resulting from the use of the extension, and its functionality might change in backward - incompatible ways.";
  19. utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(warningMsg + legalMsg));
  20. (0, displayExtensionInfo_1.printSourceDownloadLink)(sourceDownloadUri);
  21. }
  22. function displayExperimentalWarning() {
  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. }
  25. async function displayWarningPrompts(publisherId, launchStage, extensionVersion) {
  26. const trustedPublishers = await (0, resolveSource_1.getTrustedPublishers)();
  27. if (!trustedPublishers.includes(publisherId)) {
  28. displayEAPWarning({
  29. publisherId,
  30. sourceDownloadUri: extensionVersion.sourceDownloadUri,
  31. githubLink: extensionVersion.spec.sourceUrl,
  32. });
  33. }
  34. else if (launchStage === types_1.RegistryLaunchStage.EXPERIMENTAL) {
  35. displayExperimentalWarning();
  36. }
  37. else {
  38. return;
  39. }
  40. }
  41. exports.displayWarningPrompts = displayWarningPrompts;
  42. const toListEntry = (i) => {
  43. var _a, _b, _c, _d;
  44. const idAndRef = (0, deploymentSummary_1.humanReadable)(i);
  45. const sourceCodeLink = `\n\t[Source Code](${(_a = i.extensionVersion) === null || _a === void 0 ? void 0 : _a.sourceDownloadUri})`;
  46. const githubLink = ((_c = (_b = i.extensionVersion) === null || _b === void 0 ? void 0 : _b.spec) === null || _c === void 0 ? void 0 : _c.sourceUrl)
  47. ? `\n\t[Publisher Contact](${(_d = i.extensionVersion) === null || _d === void 0 ? void 0 : _d.spec.sourceUrl})`
  48. : "";
  49. return `${idAndRef}${sourceCodeLink}${githubLink}`;
  50. };
  51. async function displayWarningsForDeploy(instancesToCreate) {
  52. const trustedPublishers = await (0, resolveSource_1.getTrustedPublishers)();
  53. const publishedExtensionInstances = instancesToCreate.filter((i) => i.ref);
  54. for (const i of publishedExtensionInstances) {
  55. await (0, planner_1.getExtension)(i);
  56. }
  57. const [eapExtensions, nonEapExtensions] = (0, functional_1.partition)(publishedExtensionInstances, (i) => { var _a, _b; return !trustedPublishers.includes((_b = (_a = i.ref) === null || _a === void 0 ? void 0 : _a.publisherId) !== null && _b !== void 0 ? _b : ""); });
  58. const experimental = nonEapExtensions.filter((i) => i.extension.registryLaunchStage === types_1.RegistryLaunchStage.EXPERIMENTAL);
  59. if (experimental.length) {
  60. const humanReadableList = experimental.map((i) => `\t${(0, deploymentSummary_1.humanReadable)(i)}`).join("\n");
  61. utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`The following are instances of ${clc.bold("experimental")} extensions.They may not be production-ready. Their functionality may change in backward-incompatible ways before their official release, or they may be discontinued.\n${humanReadableList}\n`, { gfm: false }));
  62. }
  63. if (eapExtensions.length) {
  64. const humanReadableList = eapExtensions.map(toListEntry).join("\n");
  65. utils.logLabeledBullet(extensionsHelper_1.logPrefix, marked(`These extensions are in preview and are built by a developer in the Extensions Publisher Early Access Program (http://bit.ly/firex-provider). Their functionality might change in backwards-incompatible ways. Since these extensions aren't built by Firebase, reach out to their publisher with questions about them.` +
  66. ` They are provided “AS IS”, without any warranty, express or implied, from Google.` +
  67. ` Google disclaims all liability for any damages, direct or indirect, resulting from the use of these extensions\n${humanReadableList}`, { gfm: false }));
  68. }
  69. return experimental.length > 0 || eapExtensions.length > 0;
  70. }
  71. exports.displayWarningsForDeploy = displayWarningsForDeploy;
  72. function paramsFlagDeprecationWarning() {
  73. logger_1.logger.warn("The --params flag is deprecated and will be removed in firebase-tools@11. " +
  74. "Instead, use an extensions manifest and `firebase deploy --only extensions` to deploy extensions noninteractively. " +
  75. "See https://firebase.google.com/docs/extensions/manifest for more details");
  76. }
  77. exports.paramsFlagDeprecationWarning = paramsFlagDeprecationWarning;
  78. function outOfBandChangesWarning(instanceIds) {
  79. logger_1.logger.warn("The following instances may have been changed in the Firebase console or by another machine since the last deploy from this machine.\n\t" +
  80. clc.bold(instanceIds.join("\n\t")) +
  81. "\nIf you proceed with this deployment, those changes will be overwritten. To avoid this, run `firebase ext:export` to sync these changes to your local extensions manifest.");
  82. }
  83. exports.outOfBandChangesWarning = outOfBandChangesWarning;