Skip to content

Commit 1c9b57f

Browse files
ENGCOM-6041: Static Content Deploy - Add command line argument to disable JS Bundles #24899
2 parents 840af3e + 7b0773f commit 1c9b57f

File tree

4 files changed

+59
-33
lines changed

4 files changed

+59
-33
lines changed

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class DeployStaticOptions
7878
*/
7979
const NO_JAVASCRIPT = 'no-javascript';
8080

81+
/**
82+
* Key for js-bundle option
83+
*/
84+
const NO_JS_BUNDLE = 'no-js-bundle';
85+
8186
/**
8287
* Key for css option
8388
*/
@@ -122,9 +127,6 @@ class DeployStaticOptions
122127
*/
123128
const NO_LESS = 'no-less';
124129

125-
/**
126-
* Default jobs amount
127-
*/
128130
const DEFAULT_JOBS_AMOUNT = 0;
129131

130132
/**
@@ -275,6 +277,12 @@ private function getSkipOptions()
275277
InputOption::VALUE_NONE,
276278
'Do not deploy JavaScript files.'
277279
),
280+
new InputOption(
281+
self::NO_JS_BUNDLE,
282+
null,
283+
InputOption::VALUE_NONE,
284+
'Do not deploy JavaScript bundle files.'
285+
),
278286
new InputOption(
279287
self::NO_CSS,
280288
null,

app/code/Magento/Deploy/Service/DeployStaticContent.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66
namespace Magento\Deploy\Service;
77

8-
use Magento\Deploy\Strategy\DeployStrategyFactory;
9-
use Magento\Deploy\Process\QueueFactory;
108
use Magento\Deploy\Console\DeployStaticOptions as Options;
9+
use Magento\Deploy\Process\QueueFactory;
10+
use Magento\Deploy\Strategy\DeployStrategyFactory;
1111
use Magento\Framework\App\View\Deployment\Version\StorageInterface;
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\Framework\ObjectManagerInterface;
@@ -75,6 +75,9 @@ public function __construct(
7575
* @param array $options
7676
* @throws LocalizedException
7777
* @return void
78+
*
79+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
80+
* @SuppressWarnings(PHPMD.NPathComplexity)
7881
*/
7982
public function deploy(array $options)
8083
{
@@ -106,27 +109,35 @@ public function deploy(array $options)
106109

107110
$deployStrategy = $this->deployStrategyFactory->create(
108111
$options[Options::STRATEGY],
109-
[
110-
'queue' => $this->queueFactory->create($queueOptions)
111-
]
112+
['queue' => $this->queueFactory->create($queueOptions)]
112113
);
113114

114115
$packages = $deployStrategy->deploy($options);
115116

116117
if ($options[Options::NO_JAVASCRIPT] !== true) {
117-
$deployRjsConfig = $this->objectManager->create(DeployRequireJsConfig::class, [
118-
'logger' => $this->logger
119-
]);
120-
$deployI18n = $this->objectManager->create(DeployTranslationsDictionary::class, [
121-
'logger' => $this->logger
122-
]);
123-
$deployBundle = $this->objectManager->create(Bundle::class, [
124-
'logger' => $this->logger
125-
]);
118+
$deployRjsConfig = $this->objectManager->create(
119+
DeployRequireJsConfig::class,
120+
['logger' => $this->logger]
121+
);
122+
$deployI18n = $this->objectManager->create(
123+
DeployTranslationsDictionary::class,
124+
['logger' => $this->logger]
125+
);
126126
foreach ($packages as $package) {
127127
if (!$package->isVirtual()) {
128128
$deployRjsConfig->deploy($package->getArea(), $package->getTheme(), $package->getLocale());
129129
$deployI18n->deploy($package->getArea(), $package->getTheme(), $package->getLocale());
130+
}
131+
}
132+
}
133+
134+
if ($options[Options::NO_JAVASCRIPT] !== true && $options[Options::NO_JS_BUNDLE] !== true) {
135+
$deployBundle = $this->objectManager->create(
136+
Bundle::class,
137+
['logger' => $this->logger]
138+
);
139+
foreach ($packages as $package) {
140+
if (!$package->isVirtual()) {
130141
$deployBundle->deploy($package->getArea(), $package->getTheme(), $package->getLocale());
131142
}
132143
}

app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function testDeploy($options, $expectedContentVersion)
103103
$package->expects($this->never())->method('getTheme');
104104
$package->expects($this->never())->method('getLocale');
105105
} else {
106-
$package->expects($this->exactly(1))->method('isVirtual')->willReturn(false);
106+
$package->expects($this->exactly(2))->method('isVirtual')->willReturn(false);
107107
$package->expects($this->exactly(3))->method('getArea')->willReturn('area');
108108
$package->expects($this->exactly(3))->method('getTheme')->willReturn('theme');
109109
$package->expects($this->exactly(3))->method('getLocale')->willReturn('locale');
@@ -198,6 +198,7 @@ public function deployDataProvider()
198198
[
199199
'strategy' => 'compact',
200200
'no-javascript' => false,
201+
'no-js-bundle' => false,
201202
'no-html-minify' => false,
202203
'refresh-content-version-only' => false,
203204
],
@@ -207,6 +208,7 @@ public function deployDataProvider()
207208
[
208209
'strategy' => 'compact',
209210
'no-javascript' => false,
211+
'no-js-bundle' => false,
210212
'no-html-minify' => false,
211213
'refresh-content-version-only' => false,
212214
'content-version' => '123456',
@@ -226,25 +228,28 @@ public function deployDataProvider()
226228
public function testMaxExecutionTimeOptionPassed()
227229
{
228230
$options = [
229-
DeployStaticOptions::MAX_EXECUTION_TIME => 100,
231+
DeployStaticOptions::MAX_EXECUTION_TIME => 100,
230232
DeployStaticOptions::REFRESH_CONTENT_VERSION_ONLY => false,
231-
DeployStaticOptions::JOBS_AMOUNT => 3,
232-
DeployStaticOptions::STRATEGY => 'compact',
233-
DeployStaticOptions::NO_JAVASCRIPT => true,
234-
DeployStaticOptions::NO_HTML_MINIFY => true,
233+
DeployStaticOptions::JOBS_AMOUNT => 3,
234+
DeployStaticOptions::STRATEGY => 'compact',
235+
DeployStaticOptions::NO_JAVASCRIPT => true,
236+
DeployStaticOptions::NO_JS_BUNDLE => true,
237+
DeployStaticOptions::NO_HTML_MINIFY => true,
235238
];
236239

237240
$queueMock = $this->createMock(Queue::class);
238241
$strategyMock = $this->createMock(CompactDeploy::class);
239242
$this->queueFactory->expects($this->once())
240243
->method('create')
241-
->with([
242-
'logger' => $this->logger,
243-
'maxExecTime' => 100,
244-
'maxProcesses' => 3,
245-
'options' => $options,
246-
'deployPackageService' => null
247-
])
244+
->with(
245+
[
246+
'logger' => $this->logger,
247+
'maxExecTime' => 100,
248+
'maxProcesses' => 3,
249+
'options' => $options,
250+
'deployPackageService' => null
251+
]
252+
)
248253
->willReturn($queueMock);
249254
$this->deployStrategyFactory->expects($this->once())
250255
->method('create')

dev/tests/integration/testsuite/Magento/Deploy/DeployTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class DeployTest extends \PHPUnit\Framework\TestCase
7171
private $options = [
7272
Options::DRY_RUN => false,
7373
Options::NO_JAVASCRIPT => false,
74+
Options::NO_JS_BUNDLE => false,
7475
Options::NO_CSS => false,
7576
Options::NO_LESS => false,
7677
Options::NO_IMAGES => false,
@@ -100,9 +101,10 @@ protected function setUp()
100101
$this->rootDir = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);
101102

102103
$logger = $objectManager->get(\Psr\Log\LoggerInterface::class);
103-
$this->deployService = $objectManager->create(DeployStaticContent::class, [
104-
'logger' => $logger
105-
]);
104+
$this->deployService = $objectManager->create(
105+
DeployStaticContent::class,
106+
['logger' => $logger]
107+
);
106108

107109
$this->bundleConfig = $objectManager->create(BundleConfig::class);
108110
$this->config = $objectManager->create(View::class);

0 commit comments

Comments
 (0)