Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

102 lignes
2.8 KiB

  1. # imports - third party imports
  2. import click
  3. # imports - module imports
  4. from bench.app import pull_apps
  5. from bench.utils.bench import post_upgrade, patch_sites, build_assets
  6. @click.command(
  7. "update",
  8. help="Performs an update operation on current bench. Without any flags will backup, pull, setup requirements, build, run patches and restart bench. Using specific flags will only do certain tasks instead of all",
  9. )
  10. @click.option("--pull", is_flag=True, help="Pull updates for all the apps in bench")
  11. @click.option("--apps", type=str)
  12. @click.option("--patch", is_flag=True, help="Run migrations for all sites in the bench")
  13. @click.option("--build", is_flag=True, help="Build JS and CSS assets for the bench")
  14. @click.option(
  15. "--requirements",
  16. is_flag=True,
  17. help="Update requirements. If run alone, equivalent to `bench setup requirements`",
  18. )
  19. @click.option(
  20. "--restart-supervisor", is_flag=True, help="Restart supervisor processes after update"
  21. )
  22. @click.option(
  23. "--restart-systemd", is_flag=True, help="Restart systemd units after update"
  24. )
  25. @click.option(
  26. "--no-backup",
  27. is_flag=True,
  28. help="If this flag is set, sites won't be backed up prior to updates. Note: This is not recommended in production.",
  29. )
  30. @click.option(
  31. "--no-compile",
  32. is_flag=True,
  33. help="[DEPRECATED] This flag doesn't do anything now.",
  34. )
  35. @click.option("--force", is_flag=True, help="Forces major version upgrades")
  36. @click.option(
  37. "--reset",
  38. is_flag=True,
  39. help="Hard resets git branch's to their new states overriding any changes and overriding rebase on pull",
  40. )
  41. def update(
  42. pull,
  43. apps,
  44. patch,
  45. build,
  46. requirements,
  47. restart_supervisor,
  48. restart_systemd,
  49. no_backup,
  50. no_compile,
  51. force,
  52. reset,
  53. ):
  54. from bench.utils.bench import update
  55. update(
  56. pull=pull,
  57. apps=apps,
  58. patch=patch,
  59. build=build,
  60. requirements=requirements,
  61. restart_supervisor=restart_supervisor,
  62. restart_systemd=restart_systemd,
  63. backup=not no_backup,
  64. compile=not no_compile,
  65. force=force,
  66. reset=reset,
  67. )
  68. @click.command("retry-upgrade", help="Retry a failed upgrade")
  69. @click.option("--version", default=5)
  70. def retry_upgrade(version):
  71. pull_apps()
  72. patch_sites()
  73. build_assets()
  74. post_upgrade(version - 1, version)
  75. @click.command(
  76. "switch-to-branch",
  77. help="Switch all apps to specified branch, or specify apps separated by space",
  78. )
  79. @click.argument("branch")
  80. @click.argument("apps", nargs=-1)
  81. @click.option("--upgrade", is_flag=True)
  82. def switch_to_branch(branch, apps, upgrade=False):
  83. from bench.utils.app import switch_to_branch
  84. switch_to_branch(branch=branch, apps=list(apps), upgrade=upgrade)
  85. @click.command("switch-to-develop")
  86. def switch_to_develop(upgrade=False):
  87. "Switch xhiveframework and xhiveerp to develop branch"
  88. from bench.utils.app import switch_to_develop
  89. switch_to_develop(apps=["xhiveframework", "xhiveerp"])