Skip to content

Commit 28f5787

Browse files
committed
MAGETWO-50673: Static asset deployment is crazy slow with multiple locales
- MAGETWO-54819: Make deploy configurable
1 parent 66aee7d commit 28f5787

File tree

3 files changed

+111
-110
lines changed

3 files changed

+111
-110
lines changed

app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
*/
2929
class DeployStaticContentCommand extends Command
3030
{
31+
/**
32+
* Key for dry-run option
33+
* @deprecated
34+
* @see Magento\Deploy\Console\Command\DeployStaticOptionsInterface::DRY_RUN
35+
*/
36+
const DRY_RUN_OPTION = 'dry-run';
37+
38+
/**
39+
* Key for languages parameter
40+
* @deprecated
41+
* @see DeployStaticContentCommand::LANGUAGES_ARGUMENT
42+
*/
43+
const LANGUAGE_OPTION = 'languages';
44+
3145
/**
3246
* Default language value
3347
*/
@@ -98,109 +112,109 @@ protected function configure()
98112
->setDescription('Deploys static view files')
99113
->setDefinition([
100114
new InputOption(
101-
Options::DRY_RUN_OPTION,
115+
Options::DRY_RUN,
102116
'-d',
103117
InputOption::VALUE_NONE,
104118
'If specified, then no files will be actually deployed.'
105119
),
106120
new InputOption(
107-
Options::FORCE_RUN_OPTION,
121+
Options::FORCE_RUN,
108122
'-f',
109123
InputOption::VALUE_NONE,
110124
'If specified, then run files will be deployed in any mode.'
111125
),
112126
new InputOption(
113-
Options::JAVASCRIPT_OPTION,
127+
Options::NO_JAVASCRIPT,
114128
null,
115129
InputOption::VALUE_NONE,
116130
'If specified, no JavaScript will be deployed.'
117131
),
118132
new InputOption(
119-
Options::CSS_OPTION,
133+
Options::NO_CSS,
120134
null,
121135
InputOption::VALUE_NONE,
122136
'If specified, no CSS will be deployed.'
123137
),
124138
new InputOption(
125-
Options::LESS_OPTION,
139+
Options::NO_LESS,
126140
null,
127141
InputOption::VALUE_NONE,
128142
'If specified, no LESS will be deployed.'
129143
),
130144
new InputOption(
131-
Options::IMAGES_OPTION,
145+
Options::NO_IMAGES,
132146
null,
133147
InputOption::VALUE_NONE,
134148
'If specified, no images will be deployed.'
135149
),
136150
new InputOption(
137-
Options::FONTS_OPTION,
151+
Options::NO_FONTS,
138152
null,
139153
InputOption::VALUE_NONE,
140154
'If specified, no font files will be deployed.'
141155
),
142156
new InputOption(
143-
Options::HTML_OPTION,
157+
Options::NO_HTML,
144158
null,
145159
InputOption::VALUE_NONE,
146160
'If specified, no html files will be deployed.'
147161
),
148162
new InputOption(
149-
Options::MISC_OPTION,
163+
Options::NO_MISC,
150164
null,
151165
InputOption::VALUE_NONE,
152166
'If specified, no miscellaneous files will be deployed.'
153167
),
154168
new InputOption(
155-
Options::HTML_MINIFY_OPTION,
169+
Options::NO_HTML_MINIFY,
156170
null,
157171
InputOption::VALUE_NONE,
158-
'If specified, just html will not be minified and actually deployed.'
172+
'If specified, html will not be minified.'
159173
),
160174
new InputOption(
161-
Options::THEME_OPTION,
175+
Options::THEME,
162176
'-t',
163177
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
164178
'If specified, just specific theme(s) will be actually deployed.',
165179
['all']
166180
),
167181
new InputOption(
168-
Options::EXCLUDE_THEME_OPTION,
182+
Options::EXCLUDE_THEME,
169183
null,
170184
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
171185
'If specified, exclude specific theme(s) from deployment.',
172186
['none']
173187
),
174188
new InputOption(
175-
Options::LANGUAGE_OPTION,
189+
Options::LANGUAGE,
176190
'-l',
177191
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
178192
'List of languages you want the tool populate files for.',
179193
['all']
180194
),
181195
new InputOption(
182-
Options::EXCLUDE_LANGUAGE_OPTION,
196+
Options::EXCLUDE_LANGUAGE,
183197
null,
184198
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
185199
'List of langiages you do not want the tool populate files for.',
186200
['none']
187201
),
188202
new InputOption(
189-
Options::AREA_OPTION,
203+
Options::AREA,
190204
'-a',
191205
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
192206
'List of areas you want the tool populate files for.',
193207
['all']
194208
),
195209
new InputOption(
196-
Options::EXCLUDE_AREA_OPTION,
210+
Options::EXCLUDE_AREA,
197211
null,
198212
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
199213
'List of areas you do not want the tool populate files for.',
200214
['none']
201215
),
202216
new InputOption(
203-
Options::JOBS_AMOUNT_OPTION,
217+
Options::JOBS_AMOUNT,
204218
'-j',
205219
InputOption::VALUE_OPTIONAL,
206220
'Amount of jobs to which script can be paralleled.',
@@ -357,9 +371,7 @@ private function getDeployableEntities($entities, $includedEntities, $excludedEn
357371
*/
358372
protected function execute(InputInterface $input, OutputInterface $output)
359373
{
360-
if (!$input->getOption(Options::FORCE_RUN_OPTION)
361-
&& $this->getAppState()->getMode() !== State::MODE_PRODUCTION
362-
) {
374+
if (!$input->getOption(Options::FORCE_RUN) && $this->getAppState()->getMode() !== State::MODE_PRODUCTION) {
363375
throw new LocalizedException(
364376
__(
365377
"Deploy static content is applicable only for production mode.\n"
@@ -423,21 +435,21 @@ private function prepareDeployableEntities($filesUtil)
423435
}
424436
}
425437

426-
$areasInclude = $this->input->getOption(Options::AREA_OPTION);
427-
$areasExclude = $this->input->getOption(Options::EXCLUDE_AREA_OPTION);
438+
$areasInclude = $this->input->getOption(Options::AREA);
439+
$areasExclude = $this->input->getOption(Options::EXCLUDE_AREA);
428440
$this->checkAreasInput($magentoAreas, $areasInclude, $areasExclude);
429441
$deployableAreas = $this->getDeployableEntities($magentoAreas, $areasInclude, $areasExclude);
430442

431443
$languagesInclude = $this->input->getArgument(self::LANGUAGES_ARGUMENT)
432-
?: $this->input->getOption(Options::LANGUAGE_OPTION);
433-
$languagesExclude = $this->input->getOption(Options::EXCLUDE_LANGUAGE_OPTION);
444+
?: $this->input->getOption(Options::LANGUAGE);
445+
$languagesExclude = $this->input->getOption(Options::EXCLUDE_LANGUAGE);
434446
$this->checkLanguagesInput($languagesInclude, $languagesExclude);
435447
$deployableLanguages = $languagesInclude[0] == 'all'
436448
? $this->getDeployableEntities($magentoLanguages, $languagesInclude, $languagesExclude)
437449
: $languagesInclude;
438450

439-
$themesInclude = $this->input->getOption(Options::THEME_OPTION);
440-
$themesExclude = $this->input->getOption(Options::EXCLUDE_THEME_OPTION);
451+
$themesInclude = $this->input->getOption(Options::THEME);
452+
$themesExclude = $this->input->getOption(Options::EXCLUDE_THEME);
441453
$this->checkThemesInput($magentoThemes, $themesInclude, $themesExclude);
442454
$deployableThemes = $this->getDeployableEntities($magentoThemes, $themesInclude, $themesExclude);
443455

@@ -529,10 +541,10 @@ private function isCanBeParalleled()
529541
*/
530542
private function getProcessesAmount()
531543
{
532-
$jobs = (int)$this->input->getOption(Options::JOBS_AMOUNT_OPTION);
544+
$jobs = (int)$this->input->getOption(Options::JOBS_AMOUNT);
533545
if ($jobs < 1) {
534546
throw new \InvalidArgumentException(
535-
Options::JOBS_AMOUNT_OPTION . ' argument has invalid value. It must be greater than 0'
547+
Options::JOBS_AMOUNT . ' argument has invalid value. It must be greater than 0'
536548
);
537549
}
538550
return $jobs;

app/code/Magento/Deploy/Console/Command/DeployStaticOptionsInterface.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,85 +11,85 @@ interface DeployStaticOptionsInterface
1111
/**
1212
* Key for dry-run option
1313
*/
14-
const DRY_RUN_OPTION = 'dry-run';
14+
const DRY_RUN = 'dry-run';
1515

1616
/**
1717
* Key for languages parameter
1818
*/
19-
const LANGUAGE_OPTION = 'language';
19+
const LANGUAGE = 'language';
2020

2121
/**
2222
* Key for exclude languages parameter
2323
*/
24-
const EXCLUDE_LANGUAGE_OPTION = 'exclude-language';
24+
const EXCLUDE_LANGUAGE = 'exclude-language';
2525

2626
/**
2727
* Key for javascript option
2828
*/
29-
const JAVASCRIPT_OPTION = 'no-javascript';
29+
const NO_JAVASCRIPT = 'no-javascript';
3030

3131
/**
3232
* Key for css option
3333
*/
34-
const CSS_OPTION = 'no-css';
34+
const NO_CSS = 'no-css';
3535

3636
/**
3737
* Key for less option
3838
*/
39-
const LESS_OPTION = 'no-less';
39+
const NO_LESS = 'no-less';
4040

4141
/**
4242
* Key for images option
4343
*/
44-
const IMAGES_OPTION = 'no-images';
44+
const NO_IMAGES = 'no-images';
4545

4646
/**
4747
* Key for fonts option
4848
*/
49-
const FONTS_OPTION = 'no-fonts';
49+
const NO_FONTS = 'no-fonts';
5050

5151
/**
5252
* Key for misc option
5353
*/
54-
const MISC_OPTION = 'no-misc';
54+
const NO_MISC = 'no-misc';
5555

5656
/**
5757
* Key for html option
5858
*/
59-
const HTML_OPTION = 'no-html';
59+
const NO_HTML = 'no-html';
6060

6161
/**
6262
* Key for html option
6363
*/
64-
const HTML_MINIFY_OPTION = 'no-html-minify';
64+
const NO_HTML_MINIFY = 'no-html-minify';
6565

6666
/**
6767
* Key for theme option
6868
*/
69-
const THEME_OPTION = 'theme';
69+
const THEME = 'theme';
7070

7171
/**
7272
* Key for exclude theme option
7373
*/
74-
const EXCLUDE_THEME_OPTION = 'exclude-theme';
74+
const EXCLUDE_THEME = 'exclude-theme';
7575

7676
/**
7777
* Key for area option
7878
*/
79-
const AREA_OPTION = 'area';
79+
const AREA = 'area';
8080

8181
/**
8282
* Key for exclude area option
8383
*/
84-
const EXCLUDE_AREA_OPTION = 'exclude-area';
84+
const EXCLUDE_AREA = 'exclude-area';
8585

8686
/**
8787
* Jey for jobs option
8888
*/
89-
const JOBS_AMOUNT_OPTION = 'jobs';
89+
const JOBS_AMOUNT = 'jobs';
9090

9191
/**
9292
* Force run of static deploy
9393
*/
94-
const FORCE_RUN_OPTION = 'force';
94+
const FORCE_RUN = 'force';
9595
}

0 commit comments

Comments
 (0)