20
20
use Magento \Deploy \Model \Process ;
21
21
use Magento \Framework \Exception \LocalizedException ;
22
22
use Magento \Framework \App \State ;
23
+ use Magento \Deploy \Console \Command \DeployStaticOptionsInterface as Options ;
23
24
24
25
/**
25
26
* Deploy static content command
@@ -32,100 +33,15 @@ class DeployStaticContentCommand extends Command
32
33
*/
33
34
const DEFAULT_LANGUAGE_VALUE = 'en_US ' ;
34
35
35
- /**
36
- * Key for dry-run option
37
- */
38
- const DRY_RUN_OPTION = 'dry-run ' ;
39
-
40
36
/**
41
37
* Key for languages parameter
42
38
*/
43
39
const LANGUAGES_ARGUMENT = 'languages ' ;
44
40
45
- /**
46
- * Key for languages parameter
47
- */
48
- const LANGUAGE_OPTION = 'language ' ;
49
-
50
- /**
51
- * Key for exclude languages parameter
52
- */
53
- const EXCLUDE_LANGUAGE_OPTION = 'exclude-language ' ;
54
-
55
- /**
56
- * Key for javascript option
57
- */
58
- const JAVASCRIPT_OPTION = 'no-javascript ' ;
59
-
60
- /**
61
- * Key for css option
62
- */
63
- const CSS_OPTION = 'no-css ' ;
64
-
65
- /**
66
- * Key for less option
67
- */
68
- const LESS_OPTION = 'no-less ' ;
69
-
70
- /**
71
- * Key for images option
72
- */
73
- const IMAGES_OPTION = 'no-images ' ;
74
-
75
- /**
76
- * Key for fonts option
77
- */
78
- const FONTS_OPTION = 'no-fonts ' ;
79
-
80
- /**
81
- * Key for misc option
82
- */
83
- const MISC_OPTION = 'no-misc ' ;
84
-
85
- /**
86
- * Key for html option
87
- */
88
- const HTML_OPTION = 'no-html ' ;
89
-
90
- /**
91
- * Key for html option
92
- */
93
- const HTML_MINIFY_OPTION = 'no-html-minify ' ;
94
-
95
- /**
96
- * Key for theme option
97
- */
98
- const THEME_OPTION = 'theme ' ;
99
-
100
- /**
101
- * Key for exclude theme option
102
- */
103
- const EXCLUDE_THEME_OPTION = 'exclude-theme ' ;
104
-
105
- /**
106
- * Key for area option
107
- */
108
- const AREA_OPTION = 'area ' ;
109
-
110
- /**
111
- * Key for exclude area option
112
- */
113
- const EXCLUDE_AREA_OPTION = 'exclude-area ' ;
114
-
115
- /**
116
- * Jey for jobs option
117
- */
118
- const JOBS_AMOUNT = 'jobs ' ;
119
-
120
41
/**
121
42
* Default jobs amount
122
43
*/
123
- const DEFAULT_JOBS_AMOUNT = 3 ;
124
-
125
- /**
126
- * Force run of static deploy
127
- */
128
- const FORCE_RUN_OPTION = 'force ' ;
44
+ const DEFAULT_JOBS_AMOUNT = 4 ;
129
45
130
46
/** @var InputInterface */
131
47
private $ input ;
@@ -182,109 +98,109 @@ protected function configure()
182
98
->setDescription ('Deploys static view files ' )
183
99
->setDefinition ([
184
100
new InputOption (
185
- self ::DRY_RUN_OPTION ,
101
+ Options ::DRY_RUN_OPTION ,
186
102
'-d ' ,
187
103
InputOption::VALUE_NONE ,
188
104
'If specified, then no files will be actually deployed. '
189
105
),
190
106
new InputOption (
191
- self ::FORCE_RUN_OPTION ,
107
+ Options ::FORCE_RUN_OPTION ,
192
108
'-f ' ,
193
109
InputOption::VALUE_NONE ,
194
110
'If specified, then run files will be deployed in any mode. '
195
111
),
196
112
new InputOption (
197
- self ::JAVASCRIPT_OPTION ,
113
+ Options ::JAVASCRIPT_OPTION ,
198
114
null ,
199
115
InputOption::VALUE_NONE ,
200
116
'If specified, no JavaScript will be deployed. '
201
117
),
202
118
new InputOption (
203
- self ::CSS_OPTION ,
119
+ Options ::CSS_OPTION ,
204
120
null ,
205
121
InputOption::VALUE_NONE ,
206
122
'If specified, no CSS will be deployed. '
207
123
),
208
124
new InputOption (
209
- self ::LESS_OPTION ,
125
+ Options ::LESS_OPTION ,
210
126
null ,
211
127
InputOption::VALUE_NONE ,
212
128
'If specified, no LESS will be deployed. '
213
129
),
214
130
new InputOption (
215
- self ::IMAGES_OPTION ,
131
+ Options ::IMAGES_OPTION ,
216
132
null ,
217
133
InputOption::VALUE_NONE ,
218
134
'If specified, no images will be deployed. '
219
135
),
220
136
new InputOption (
221
- self ::FONTS_OPTION ,
137
+ Options ::FONTS_OPTION ,
222
138
null ,
223
139
InputOption::VALUE_NONE ,
224
140
'If specified, no font files will be deployed. '
225
141
),
226
142
new InputOption (
227
- self ::HTML_OPTION ,
143
+ Options ::HTML_OPTION ,
228
144
null ,
229
145
InputOption::VALUE_NONE ,
230
146
'If specified, no html files will be deployed. '
231
147
),
232
148
new InputOption (
233
- self ::MISC_OPTION ,
149
+ Options ::MISC_OPTION ,
234
150
null ,
235
151
InputOption::VALUE_NONE ,
236
152
'If specified, no miscellaneous files will be deployed. '
237
153
),
238
154
new InputOption (
239
- self ::HTML_MINIFY_OPTION ,
155
+ Options ::HTML_MINIFY_OPTION ,
240
156
null ,
241
157
InputOption::VALUE_NONE ,
242
158
'If specified, just html will not be minified and actually deployed. '
243
159
),
244
160
new InputOption (
245
- self ::THEME_OPTION ,
161
+ Options ::THEME_OPTION ,
246
162
'-t ' ,
247
163
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL ,
248
164
'If specified, just specific theme(s) will be actually deployed. ' ,
249
165
['all ' ]
250
166
),
251
167
new InputOption (
252
- self ::EXCLUDE_THEME_OPTION ,
168
+ Options ::EXCLUDE_THEME_OPTION ,
253
169
null ,
254
170
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL ,
255
171
'If specified, exclude specific theme(s) from deployment. ' ,
256
172
['none ' ]
257
173
),
258
174
new InputOption (
259
- self ::LANGUAGE_OPTION ,
175
+ Options ::LANGUAGE_OPTION ,
260
176
'-l ' ,
261
177
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL ,
262
178
'List of languages you want the tool populate files for. ' ,
263
179
['all ' ]
264
180
),
265
181
new InputOption (
266
- self ::EXCLUDE_LANGUAGE_OPTION ,
182
+ Options ::EXCLUDE_LANGUAGE_OPTION ,
267
183
null ,
268
184
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL ,
269
185
'List of langiages you do not want the tool populate files for. ' ,
270
186
['none ' ]
271
187
),
272
188
new InputOption (
273
- self ::AREA_OPTION ,
189
+ Options ::AREA_OPTION ,
274
190
'-a ' ,
275
191
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL ,
276
192
'List of areas you want the tool populate files for. ' ,
277
193
['all ' ]
278
194
),
279
195
new InputOption (
280
- self ::EXCLUDE_AREA_OPTION ,
196
+ Options ::EXCLUDE_AREA_OPTION ,
281
197
null ,
282
198
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL ,
283
199
'List of areas you do not want the tool populate files for. ' ,
284
200
['none ' ]
285
201
),
286
202
new InputOption (
287
- self :: JOBS_AMOUNT ,
203
+ Options:: JOBS_AMOUNT_OPTION ,
288
204
'-j ' ,
289
205
InputOption::VALUE_OPTIONAL ,
290
206
'Amount of jobs to which script can be paralleled. ' ,
@@ -441,7 +357,9 @@ private function getDeployableEntities($entities, $includedEntities, $excludedEn
441
357
*/
442
358
protected function execute (InputInterface $ input , OutputInterface $ output )
443
359
{
444
- if (!$ input ->getOption (self ::FORCE_RUN_OPTION ) && $ this ->getAppState ()->getMode () !== State::MODE_PRODUCTION ) {
360
+ if (!$ input ->getOption (Options::FORCE_RUN_OPTION )
361
+ && $ this ->getAppState ()->getMode () !== State::MODE_PRODUCTION
362
+ ) {
445
363
throw new LocalizedException (
446
364
__ (
447
365
"Deploy static content is applicable only for production mode. \n"
@@ -460,21 +378,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
460
378
$ output ->writeln ("Requested areas: " . implode (', ' , array_keys ($ deployableAreaThemeMap )));
461
379
$ output ->writeln ("Requested themes: " . implode (', ' , $ requestedThemes ));
462
380
463
- $ options = $ this ->input ->getOptions ();
464
381
$ deployer = $ this ->objectManager ->create (
465
382
\Magento \Deploy \Model \Deployer::class,
466
383
[
467
384
'filesUtil ' => $ filesUtil ,
468
385
'output ' => $ output ,
469
- 'isDryRun ' => $ options [self ::DRY_RUN_OPTION ],
470
- 'skipJavaScript ' => $ options [self ::JAVASCRIPT_OPTION ],
471
- 'skipCss ' => $ options [self ::CSS_OPTION ],
472
- 'skipLess ' => $ options [self ::LESS_OPTION ],
473
- 'skipImages ' => $ options [self ::IMAGES_OPTION ],
474
- 'skipFonts ' => $ options [self ::FONTS_OPTION ],
475
- 'skipHtml ' => $ options [self ::HTML_OPTION ],
476
- 'skipMisc ' => $ options [self ::MISC_OPTION ],
477
- 'skipHtmlMinify ' => $ options [self ::HTML_MINIFY_OPTION ]
386
+ 'options ' => $ this ->input ->getOptions (),
478
387
]
479
388
);
480
389
@@ -514,21 +423,21 @@ private function prepareDeployableEntities($filesUtil)
514
423
}
515
424
}
516
425
517
- $ areasInclude = $ this ->input ->getOption (self ::AREA_OPTION );
518
- $ areasExclude = $ this ->input ->getOption (self ::EXCLUDE_AREA_OPTION );
426
+ $ areasInclude = $ this ->input ->getOption (Options ::AREA_OPTION );
427
+ $ areasExclude = $ this ->input ->getOption (Options ::EXCLUDE_AREA_OPTION );
519
428
$ this ->checkAreasInput ($ magentoAreas , $ areasInclude , $ areasExclude );
520
429
$ deployableAreas = $ this ->getDeployableEntities ($ magentoAreas , $ areasInclude , $ areasExclude );
521
430
522
431
$ languagesInclude = $ this ->input ->getArgument (self ::LANGUAGES_ARGUMENT )
523
- ?: $ this ->input ->getOption (self ::LANGUAGE_OPTION );
524
- $ languagesExclude = $ this ->input ->getOption (self ::EXCLUDE_LANGUAGE_OPTION );
432
+ ?: $ this ->input ->getOption (Options ::LANGUAGE_OPTION );
433
+ $ languagesExclude = $ this ->input ->getOption (Options ::EXCLUDE_LANGUAGE_OPTION );
525
434
$ this ->checkLanguagesInput ($ languagesInclude , $ languagesExclude );
526
435
$ deployableLanguages = $ languagesInclude [0 ] == 'all '
527
436
? $ this ->getDeployableEntities ($ magentoLanguages , $ languagesInclude , $ languagesExclude )
528
437
: $ languagesInclude ;
529
438
530
- $ themesInclude = $ this ->input ->getOption (self ::THEME_OPTION );
531
- $ themesExclude = $ this ->input ->getOption (self ::EXCLUDE_THEME_OPTION );
439
+ $ themesInclude = $ this ->input ->getOption (Options ::THEME_OPTION );
440
+ $ themesExclude = $ this ->input ->getOption (Options ::EXCLUDE_THEME_OPTION );
532
441
$ this ->checkThemesInput ($ magentoThemes , $ themesInclude , $ themesExclude );
533
442
$ deployableThemes = $ this ->getDeployableEntities ($ magentoThemes , $ themesInclude , $ themesExclude );
534
443
@@ -620,10 +529,10 @@ private function isCanBeParalleled()
620
529
*/
621
530
private function getProcessesAmount ()
622
531
{
623
- $ jobs = (int )$ this ->input ->getOption (self :: JOBS_AMOUNT );
532
+ $ jobs = (int )$ this ->input ->getOption (Options:: JOBS_AMOUNT_OPTION );
624
533
if ($ jobs < 1 ) {
625
534
throw new \InvalidArgumentException (
626
- self :: JOBS_AMOUNT . ' argument has invalid value. It must be greater than 0 '
535
+ Options:: JOBS_AMOUNT_OPTION . ' argument has invalid value. It must be greater than 0 '
627
536
);
628
537
}
629
538
return $ jobs ;
0 commit comments