DeployStaticOptions.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Deploy\Console;
  7. use Symfony\Component\Console\Input\InputOption;
  8. use Symfony\Component\Console\Input\InputArgument;
  9. /**
  10. * Static Content Deployment Options helper
  11. *
  12. * This class contains the list options and their related constants,
  13. * which can be used for static content deployment CLI command
  14. */
  15. class DeployStaticOptions
  16. {
  17. /**
  18. * Key for area option
  19. */
  20. const AREA = 'area';
  21. /**
  22. * Key for exclude area option
  23. */
  24. const EXCLUDE_AREA = 'exclude-area';
  25. /**
  26. * Key for theme option
  27. */
  28. const THEME = 'theme';
  29. /**
  30. * Key for exclude theme option
  31. */
  32. const EXCLUDE_THEME = 'exclude-theme';
  33. /**
  34. * Key for languages parameter
  35. */
  36. const LANGUAGE = 'language';
  37. /**
  38. * Key for exclude languages parameter
  39. */
  40. const EXCLUDE_LANGUAGE = 'exclude-language';
  41. /**
  42. * Use specific deployment strategy
  43. */
  44. const STRATEGY = 'strategy';
  45. /**
  46. * Key for jobs option
  47. */
  48. const JOBS_AMOUNT = 'jobs';
  49. /**
  50. * Force run of static deploy
  51. */
  52. const FORCE_RUN = 'force';
  53. /**
  54. * Symlink locale if it not customized
  55. */
  56. const SYMLINK_LOCALE = 'symlink-locale';
  57. /**
  58. * Key for javascript option
  59. */
  60. const NO_JAVASCRIPT = 'no-javascript';
  61. /**
  62. * Key for css option
  63. */
  64. const NO_CSS = 'no-css';
  65. /**
  66. * Key for fonts option
  67. */
  68. const NO_FONTS = 'no-fonts';
  69. /**
  70. * Key for images option
  71. */
  72. const NO_IMAGES = 'no-images';
  73. /**
  74. * Key for html option
  75. */
  76. const NO_HTML = 'no-html';
  77. /**
  78. * Key for html option
  79. */
  80. const NO_HTML_MINIFY = 'no-html-minify';
  81. /**
  82. * Key for misc option
  83. */
  84. const NO_MISC = 'no-misc';
  85. /**
  86. * Key for dry-run option
  87. *
  88. * @deprecated since 2.2.0
  89. */
  90. const DRY_RUN = 'dry-run';
  91. /**
  92. * Key for less option
  93. *
  94. * @deprecated since 2.2.0
  95. */
  96. const NO_LESS = 'no-less';
  97. /**
  98. * Default jobs amount
  99. */
  100. const DEFAULT_JOBS_AMOUNT = 0;
  101. /**
  102. * Key for languages parameter
  103. */
  104. const LANGUAGES_ARGUMENT = 'languages';
  105. /**
  106. * Static content version
  107. */
  108. const CONTENT_VERSION = 'content-version';
  109. /**
  110. * Key for refresh content version only mode
  111. */
  112. const REFRESH_CONTENT_VERSION_ONLY = 'refresh-content-version-only';
  113. /**
  114. * Deploy static command options list
  115. *
  116. * @return array
  117. */
  118. public function getOptionsList()
  119. {
  120. return array_merge($this->getBasicOptions(), $this->getSkipOptions());
  121. }
  122. /**
  123. * Basic options
  124. *
  125. * @return array
  126. */
  127. private function getBasicOptions()
  128. {
  129. return [
  130. new InputOption(
  131. self::FORCE_RUN,
  132. '-f',
  133. InputOption::VALUE_NONE,
  134. 'Deploy files in any mode.'
  135. ),
  136. new InputOption(
  137. self::STRATEGY,
  138. '-s',
  139. InputOption::VALUE_OPTIONAL,
  140. 'Deploy files using specified strategy.',
  141. 'quick'
  142. ),
  143. new InputOption(
  144. self::AREA,
  145. '-a',
  146. InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
  147. 'Generate files only for the specified areas.',
  148. ['all']
  149. ),
  150. new InputOption(
  151. self::EXCLUDE_AREA,
  152. null,
  153. InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
  154. 'Do not generate files for the specified areas.',
  155. ['none']
  156. ),
  157. new InputOption(
  158. self::THEME,
  159. '-t',
  160. InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
  161. 'Generate static view files for only the specified themes.',
  162. ['all']
  163. ),
  164. new InputOption(
  165. self::EXCLUDE_THEME,
  166. null,
  167. InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
  168. 'Do not generate files for the specified themes.',
  169. ['none']
  170. ),
  171. new InputOption(
  172. self::LANGUAGE,
  173. '-l',
  174. InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
  175. 'Generate files only for the specified languages.',
  176. ['all']
  177. ),
  178. new InputOption(
  179. self::EXCLUDE_LANGUAGE,
  180. null,
  181. InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
  182. 'Do not generate files for the specified languages.',
  183. ['none']
  184. ),
  185. new InputOption(
  186. self::JOBS_AMOUNT,
  187. '-j',
  188. InputOption::VALUE_OPTIONAL,
  189. 'Enable parallel processing using the specified number of jobs.',
  190. self::DEFAULT_JOBS_AMOUNT
  191. ),
  192. new InputOption(
  193. self::SYMLINK_LOCALE,
  194. null,
  195. InputOption::VALUE_NONE,
  196. 'Create symlinks for the files of those locales, which are passed for deployment, '
  197. . 'but have no customizations.'
  198. ),
  199. new InputOption(
  200. self::CONTENT_VERSION,
  201. null,
  202. InputArgument::OPTIONAL,
  203. 'Custom version of static content can be used if running deployment on multiple nodes '
  204. . 'to ensure that static content version is identical and caching works properly.'
  205. ),
  206. new InputOption(
  207. self::REFRESH_CONTENT_VERSION_ONLY,
  208. null,
  209. InputOption::VALUE_NONE,
  210. 'Refreshing the version of static content only can be used to refresh static content '
  211. . 'in browser cache and CDN cache.'
  212. ),
  213. new InputArgument(
  214. self::LANGUAGES_ARGUMENT,
  215. InputArgument::IS_ARRAY,
  216. 'Space-separated list of ISO-639 language codes for which to output static view files.'
  217. ),
  218. ];
  219. }
  220. /**
  221. * Additional options
  222. *
  223. * Used to re-deploy specific types of static files
  224. *
  225. * @return array
  226. */
  227. private function getSkipOptions()
  228. {
  229. return [
  230. new InputOption(
  231. self::NO_JAVASCRIPT,
  232. null,
  233. InputOption::VALUE_NONE,
  234. 'Do not deploy JavaScript files.'
  235. ),
  236. new InputOption(
  237. self::NO_CSS,
  238. null,
  239. InputOption::VALUE_NONE,
  240. 'Do not deploy CSS files.'
  241. ),
  242. new InputOption(
  243. self::NO_LESS,
  244. null,
  245. InputOption::VALUE_NONE,
  246. 'Do not deploy LESS files.'
  247. ),
  248. new InputOption(
  249. self::NO_IMAGES,
  250. null,
  251. InputOption::VALUE_NONE,
  252. 'Do not deploy images.'
  253. ),
  254. new InputOption(
  255. self::NO_FONTS,
  256. null,
  257. InputOption::VALUE_NONE,
  258. 'Do not deploy font files.'
  259. ),
  260. new InputOption(
  261. self::NO_HTML,
  262. null,
  263. InputOption::VALUE_NONE,
  264. 'Do not deploy HTML files.'
  265. ),
  266. new InputOption(
  267. self::NO_MISC,
  268. null,
  269. InputOption::VALUE_NONE,
  270. 'Do not deploy files of other types (.md, .jbf, .csv, etc.).'
  271. ),
  272. new InputOption(
  273. self::NO_HTML_MINIFY,
  274. null,
  275. InputOption::VALUE_NONE,
  276. 'Do not minify HTML files.'
  277. )
  278. ];
  279. }
  280. }