暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = exports.TARGET_PERMISSIONS = exports.VALID_DEPLOY_TARGETS = void 0;
  4. const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
  5. const requirePermissions_1 = require("../requirePermissions");
  6. const checkIam_1 = require("../deploy/functions/checkIam");
  7. const checkValidTargetFilters_1 = require("../checkValidTargetFilters");
  8. const command_1 = require("../command");
  9. const deploy_1 = require("../deploy");
  10. const requireConfig_1 = require("../requireConfig");
  11. const filterTargets_1 = require("../filterTargets");
  12. const requireHostingSite_1 = require("../requireHostingSite");
  13. exports.VALID_DEPLOY_TARGETS = [
  14. "database",
  15. "storage",
  16. "firestore",
  17. "functions",
  18. "hosting",
  19. "remoteconfig",
  20. "extensions",
  21. ];
  22. exports.TARGET_PERMISSIONS = {
  23. database: ["firebasedatabase.instances.update"],
  24. hosting: ["firebasehosting.sites.update"],
  25. functions: [
  26. "cloudfunctions.functions.list",
  27. "cloudfunctions.functions.create",
  28. "cloudfunctions.functions.get",
  29. "cloudfunctions.functions.update",
  30. "cloudfunctions.functions.delete",
  31. "cloudfunctions.operations.get",
  32. ],
  33. firestore: [
  34. "datastore.indexes.list",
  35. "datastore.indexes.create",
  36. "datastore.indexes.update",
  37. "datastore.indexes.delete",
  38. ],
  39. storage: [
  40. "firebaserules.releases.create",
  41. "firebaserules.rulesets.create",
  42. "firebaserules.releases.update",
  43. ],
  44. remoteconfig: ["cloudconfig.configs.get", "cloudconfig.configs.update"],
  45. };
  46. exports.command = new command_1.Command("deploy")
  47. .description("deploy code and assets to your Firebase project")
  48. .withForce("delete Cloud Functions missing from the current working directory without confirmation")
  49. .option("-p, --public <path>", "override the Hosting public directory specified in firebase.json")
  50. .option("-m, --message <message>", "an optional message describing this deploy")
  51. .option("--only <targets>", 'only deploy to specified, comma-separated targets (e.g. "hosting,storage"). For functions, ' +
  52. 'can specify filters with colons to scope function deploys to only those functions (e.g. "--only functions:func1,functions:func2"). ' +
  53. "When filtering based on export groups (the exported module object keys), use dots to specify group names " +
  54. '(e.g. "--only functions:group1.subgroup1,functions:group2)"')
  55. .option("--except <targets>", 'deploy to all targets except specified (e.g. "database")')
  56. .before(requireConfig_1.requireConfig)
  57. .before((options) => {
  58. options.filteredTargets = (0, filterTargets_1.filterTargets)(options, exports.VALID_DEPLOY_TARGETS);
  59. const permissions = options.filteredTargets.reduce((perms, target) => {
  60. return perms.concat(exports.TARGET_PERMISSIONS[target]);
  61. }, []);
  62. return (0, requirePermissions_1.requirePermissions)(options, permissions);
  63. })
  64. .before((options) => {
  65. if (options.filteredTargets.includes("functions")) {
  66. return (0, checkIam_1.checkServiceAccountIam)(options.project);
  67. }
  68. })
  69. .before(async (options) => {
  70. if (options.filteredTargets.includes("database")) {
  71. await (0, requireDatabaseInstance_1.requireDatabaseInstance)(options);
  72. }
  73. if (options.filteredTargets.includes("hosting")) {
  74. await (0, requireHostingSite_1.requireHostingSite)(options);
  75. }
  76. })
  77. .before(checkValidTargetFilters_1.checkValidTargetFilters)
  78. .action((options) => {
  79. return (0, deploy_1.deploy)(options.filteredTargets, options);
  80. });