Skip to content

Commit a7aa6bd

Browse files
authored
Merge pull request #140 from magento-thunder/2002.0-11.01.18
Changes from develop branch
2 parents a104593 + 61e6424 commit a7aa6bd

File tree

152 files changed

+6841
-2336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+6841
-2336
lines changed

bin/ece-tools

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7-
require_once __DIR__ . '/../bootstrap.php';
7+
$container = require_once __DIR__ . '/../bootstrap.php';
88

9-
$application = \Magento\MagentoCloud\App\Bootstrap::create()->createApplication();
9+
$application = new \Magento\MagentoCloud\Application($container);
1010
$application->run();

bootstrap.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@
1010

1111
$handler = new \Magento\MagentoCloud\App\ErrorHandler();
1212
set_error_handler([$handler, 'handle']);
13+
14+
$config = $_SERVER['DIRS_CONFIG'] ?? [];
15+
16+
return new \Magento\MagentoCloud\App\Container(
17+
new \Magento\MagentoCloud\Filesystem\DirectoryList(ECE_BP, BP, $config)
18+
);

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"php": "^7.0",
1111
"monolog/monolog": "^1.17",
1212
"symfony/console": "^2.6",
13+
"illuminate/contracts": "^5.5",
1314
"illuminate/container": "^5.5",
1415
"illuminate/config": "^5.5",
1516
"psr/log": "^1.0",
@@ -36,13 +37,19 @@
3637
"Magento\\MagentoCloud\\": "src/"
3738
}
3839
},
40+
"autoload-dev": {
41+
"psr-4": {
42+
"Magento\\MagentoCloud\\Test\\": "tests/static/"
43+
}
44+
},
3945
"scripts": {
4046
"test": [
4147
"phpcs src --standard=tests/static/phpcs-ruleset.xml -p -n",
4248
"phpmd src xml tests/static/phpmd-ruleset.xml",
4349
"phpunit --configuration tests/unit/phpunit.xml.dist"
4450
],
45-
"test-coverage": "phpunit --configuration tests/unit/phpunit.xml.dist --coverage-html tests/unit/tmp/coverage"
51+
"test-coverage": "phpunit --configuration tests/unit/phpunit.xml.dist --coverage-clover tests/unit/tmp/clover.xml && php tests/unit/code-coverage.php tests/unit/tmp/clover.xml 85",
52+
"test-coverage-generate": "phpunit --configuration tests/unit/phpunit.xml.dist --coverage-html tests/unit/tmp/coverage"
4653
},
4754
"prefer-stable": true
4855
}

m2-ece-build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7-
require_once __DIR__ . '/bootstrap.php';
7+
$container = require_once __DIR__ . '/bootstrap.php';
88

9-
$application = \Magento\MagentoCloud\App\Bootstrap::create()->createApplication();
10-
$application->setDefaultCommand('build');
9+
$application = new \Magento\MagentoCloud\Application($container);
10+
$application->setDefaultCommand(\Magento\MagentoCloud\Command\Build::NAME);
1111
$application->run();

m2-ece-deploy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7-
require_once __DIR__ . '/bootstrap.php';
7+
$container = require_once __DIR__ . '/bootstrap.php';
88

9-
$application = \Magento\MagentoCloud\App\Bootstrap::create()->createApplication();
10-
$application->setDefaultCommand('deploy');
9+
$application = new \Magento\MagentoCloud\Application($container);
10+
$application->setDefaultCommand(\Magento\MagentoCloud\Command\Deploy::NAME);
1111
$application->run();
1212

m2-ece-scd-dump

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7-
require_once __DIR__ . '/bootstrap.php';
7+
$container = require_once __DIR__ . '/bootstrap.php';
88

9-
$application = \Magento\MagentoCloud\App\Bootstrap::create()->createApplication();
10-
$application->setDefaultCommand('dump');
9+
$application = new \Magento\MagentoCloud\Application($container);
10+
$application->setDefaultCommand(\Magento\MagentoCloud\Command\ConfigDump::NAME);
1111
$application->run();

src/App/Bootstrap.php

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/App/Container.php

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@
77

88
use Magento\MagentoCloud\Command\Build;
99
use Magento\MagentoCloud\Command\DbDump;
10-
use Magento\MagentoCloud\Command\CronUnlock;
1110
use Magento\MagentoCloud\Command\Deploy;
1211
use Magento\MagentoCloud\Command\ConfigDump;
12+
use Magento\MagentoCloud\Command\Prestart;
1313
use Magento\MagentoCloud\Command\PostDeploy;
1414
use Magento\MagentoCloud\Config\ValidatorInterface;
1515
use Magento\MagentoCloud\Config\Validator as ConfigValidator;
1616
use Magento\MagentoCloud\DB\Data\ConnectionInterface;
1717
use Magento\MagentoCloud\DB\Data\ReadConnection;
1818
use Magento\MagentoCloud\Filesystem\DirectoryCopier;
19+
use Magento\MagentoCloud\Filesystem\DirectoryList;
20+
use Magento\MagentoCloud\Filesystem\Flag;
1921
use Magento\MagentoCloud\Process\ProcessInterface;
2022
use Magento\MagentoCloud\Process\ProcessComposite;
2123
use Magento\MagentoCloud\Process\Build as BuildProcess;
2224
use Magento\MagentoCloud\Process\DbDump as DbDumpProcess;
2325
use Magento\MagentoCloud\Process\Deploy as DeployProcess;
2426
use Magento\MagentoCloud\Process\ConfigDump as ConfigDumpProcess;
27+
use Magento\MagentoCloud\Process\Prestart as PrestartProcess;
2528
use Magento\MagentoCloud\Process\PostDeploy as PostDeployProcess;
2629
use Psr\Container\ContainerInterface;
2730
use Magento\MagentoCloud\Process;
@@ -39,12 +42,11 @@ class Container implements ContainerInterface
3942
private $container;
4043

4144
/**
42-
* @param string $root
43-
* @param array $config
45+
* @param DirectoryList $directoryList
4446
*
4547
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
4648
*/
47-
public function __construct(string $root, array $config)
49+
public function __construct(DirectoryList $directoryList)
4850
{
4951
/**
5052
* Creating concrete container.
@@ -57,8 +59,8 @@ public function __construct(string $root, array $config)
5759
$this->container->instance(ContainerInterface::class, $this);
5860
$this->container->singleton(
5961
\Magento\MagentoCloud\Filesystem\DirectoryList::class,
60-
function () use ($root, $config) {
61-
return new \Magento\MagentoCloud\Filesystem\DirectoryList($root, $config);
62+
function () use ($directoryList) {
63+
return $directoryList;
6264
}
6365
);
6466
$this->container->singleton(\Magento\MagentoCloud\Filesystem\FileList::class);
@@ -70,6 +72,16 @@ function () use ($root, $config) {
7072
$fileList->getComposer()
7173
);
7274
});
75+
$this->container->singleton(
76+
Flag\Pool::class,
77+
function () {
78+
return new Flag\Pool([
79+
Flag\Manager::FLAG_REGENERATE => 'var/.regenerate',
80+
Flag\Manager::FLAG_STATIC_CONTENT_DEPLOY_IN_BUILD => '.static_content_deploy',
81+
Flag\Manager::FLAG_STATIC_CONTENT_DEPLOY_PENDING => 'var/.static_content_deploy_pending',
82+
]);
83+
}
84+
);
7385
/**
7486
* Interface to implementation binding.
7587
*/
@@ -82,14 +94,8 @@ function () use ($root, $config) {
8294
\Magento\MagentoCloud\DB\Dump::class
8395
);
8496
$this->container->singleton(\Magento\MagentoCloud\Config\Environment::class);
85-
$this->container->singleton(\Magento\MagentoCloud\Config\Build::class);
86-
$this->container->singleton(\Magento\MagentoCloud\Config\Deploy::class);
87-
$this->container->singleton(\Psr\Log\LoggerInterface::class, function () {
88-
return new \Monolog\Logger(
89-
'default',
90-
$this->container->make(\Magento\MagentoCloud\App\Logger\Pool::class)->getHandlers()
91-
);
92-
});
97+
$this->container->singleton(\Magento\MagentoCloud\Config\State::class);
98+
$this->container->singleton(\Psr\Log\LoggerInterface::class, \Magento\MagentoCloud\App\Logger::class);
9399
$this->container->singleton(\Magento\MagentoCloud\Package\Manager::class);
94100
$this->container->singleton(\Magento\MagentoCloud\Package\MagentoVersion::class);
95101
$this->container->singleton(\Magento\MagentoCloud\Util\UrlManager::class);
@@ -101,6 +107,17 @@ function () use ($root, $config) {
101107
$this->container->singleton(DirectoryCopier\CopyStrategy::class);
102108
$this->container->singleton(DirectoryCopier\SymlinkStrategy::class);
103109
$this->container->singleton(DirectoryCopier\StrategyFactory::class);
110+
$this->container->singleton(\Magento\MagentoCloud\Config\Stage\Build::class);
111+
$this->container->singleton(\Magento\MagentoCloud\Config\Stage\Deploy::class);
112+
$this->container->singleton(\Magento\MagentoCloud\Config\RepositoryFactory::class);
113+
$this->container->singleton(
114+
\Magento\MagentoCloud\Config\Stage\BuildInterface::class,
115+
\Magento\MagentoCloud\Config\Stage\Build::class
116+
);
117+
$this->container->singleton(
118+
\Magento\MagentoCloud\Config\Stage\DeployInterface::class,
119+
\Magento\MagentoCloud\Config\Stage\Deploy::class
120+
);
104121
/**
105122
* Contextual binding.
106123
*/
@@ -153,6 +170,10 @@ function () use ($root, $config) {
153170
$this->container->make(DeployProcess\CompressStaticContent::class),
154171
$this->container->make(DeployProcess\DisableGoogleAnalytics::class),
155172
$this->container->make(DeployProcess\UnlockCronJobs::class),
173+
/**
174+
* Remove this line after implementation post-deploy hook
175+
*/
176+
$this->container->make(PostDeployProcess\Backup::class),
156177
/**
157178
* Cache clean process must remain the last one in deploy chain.
158179
* Do not add any processes after it.
@@ -199,6 +220,16 @@ function () use ($root, $config) {
199220
],
200221
]);
201222
});
223+
$this->container->when(Prestart::class)
224+
->needs(ProcessInterface::class)
225+
->give(function () {
226+
return $this->container->makeWith(ProcessComposite::class, [
227+
'processes' => [
228+
$this->container->make(PrestartProcess\DeployStaticContent::class),
229+
$this->container->make(PrestartProcess\CompressStaticContent::class),
230+
],
231+
]);
232+
});
202233
$this->container->when(DeployProcess\InstallUpdate\ConfigUpdate\Urls::class)
203234
->needs(ProcessInterface::class)
204235
->give(function () {
@@ -246,16 +277,6 @@ function () use ($root, $config) {
246277
'system/websites',
247278
];
248279
});
249-
$this->container->when(DeployProcess\PreDeploy::class);
250-
$this->container->when(CronUnlock::class)
251-
->needs(ProcessInterface::class)
252-
->give(function () {
253-
return $this->container->makeWith(ProcessComposite::class, [
254-
'processes' => [
255-
$this->container->make(DeployProcess\UnlockCronJobs::class),
256-
],
257-
]);
258-
});
259280
$this->container->when(DeployProcess\PreDeploy::class)
260281
->needs(ProcessInterface::class)
261282
->give(function () {
@@ -277,9 +298,15 @@ function () use ($root, $config) {
277298
],
278299
]);
279300
});
280-
$this->container->when(\Magento\MagentoCloud\Config\Build::class)
281-
->needs(\Magento\MagentoCloud\Filesystem\Reader\ReaderInterface::class)
282-
->give(\Magento\MagentoCloud\Config\Build\Reader::class);
301+
$this->container->when(PrestartProcess\DeployStaticContent::class)
302+
->needs(ProcessInterface::class)
303+
->give(function () {
304+
return $this->container->makeWith(ProcessComposite::class, [
305+
'processes' => [
306+
$this->get(PrestartProcess\DeployStaticContent\Generate::class),
307+
],
308+
]);
309+
});
283310
$this->container->when(BuildProcess\DeployStaticContent::class)
284311
->needs(ProcessInterface::class)
285312
->give(function () {
@@ -306,6 +333,7 @@ function () use ($root, $config) {
306333
->give(function () {
307334
return $this->container->make(ProcessComposite::class, [
308335
'processes' => [
336+
$this->container->make(PostDeployProcess\Backup::class),
309337
$this->container->make(PostDeployProcess\CleanCache::class),
310338
],
311339
]);
@@ -341,4 +369,16 @@ public function set($abstract, $concrete, bool $shared = true)
341369
$this->container->forgetInstance($abstract);
342370
$this->container->bind($abstract, $concrete, $shared);
343371
}
372+
373+
/**
374+
* Creates instance with params.
375+
*
376+
* @param string $abstract The class name to create
377+
* @param array $params Associative array of constructor params
378+
* @return object The resolved object
379+
*/
380+
public function create(string $abstract, array $params = [])
381+
{
382+
return $this->container->make($abstract, $params);
383+
}
344384
}

0 commit comments

Comments
 (0)