Skip to content

Commit d14f20b

Browse files
author
Oleksii Korshenko
committed
Updated loaded, metadata generator and changelog generator to use packages information
1 parent 04fd6c3 commit d14f20b

23 files changed

+506
-291
lines changed

changelog-generator.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,31 @@
1212
*/
1313
/** @var \Magento\DeprecationTool\DataStructure $structure */
1414

15-
$config = new \Magento\DeprecationTool\Config();
15+
$config = new \Magento\DeprecationTool\AppConfig();
1616
$dataStructureFactory = new \Magento\DeprecationTool\DataStructureFactory($config);
1717
$command = new \Magento\DeprecationTool\Compare\Command();
1818
$writer = new \Magento\DeprecationTool\Compare\ArtifactWriter($config);
1919

2020
foreach ($config->getEditions() as $edition) {
21-
$dataStructure = $dataStructureFactory->create($edition);
21+
$dataStructures = $dataStructureFactory->create($edition);
2222

23-
$classesChangelog = $command->compareDeprecatedClasses($dataStructure);
24-
$writer->write($edition, $classesChangelog, 'deprecated.classes');
23+
foreach ($dataStructures as $packageName => $dataStructure) {
24+
$classesChangelog = $command->compareDeprecatedClasses($dataStructure);
25+
$writer->write($packageName, $classesChangelog, 'deprecated-classes');
2526

26-
$methodsChangelog = $command->compareDeprecatedMethods($dataStructure);
27-
$writer->write($edition, $methodsChangelog, 'deprecated.methods');
27+
$methodsChangelog = $command->compareDeprecatedMethods($dataStructure);
28+
$writer->write($packageName, $methodsChangelog, 'deprecated-methods');
2829

29-
$propertiesChangelog = $command->compareDeprecatedProperties($dataStructure);
30-
$writer->write($edition, $propertiesChangelog, 'deprecated.properties');
30+
$propertiesChangelog = $command->compareDeprecatedProperties($dataStructure);
31+
$writer->write($packageName, $propertiesChangelog, 'deprecated-properties');
3132

32-
$newClassesChangelog = $command->compareNewClasses($dataStructure);
33-
$writer->write($edition, $newClassesChangelog, 'new.classes');
33+
$newClassesChangelog = $command->compareNewClasses($dataStructure);
34+
$writer->write($packageName, $newClassesChangelog, 'since-classes');
3435

35-
$newMethodsChangelog = $command->compareNewMethods($dataStructure);
36-
$writer->write($edition, $newMethodsChangelog, 'new.methods');
36+
$newMethodsChangelog = $command->compareNewMethods($dataStructure);
37+
$writer->write($packageName, $newMethodsChangelog, 'since-methods');
3738

38-
$newPropertiesChangelog = $command->compareNewProperties($dataStructure);
39-
$writer->write($edition, $newPropertiesChangelog, 'new.properties');
39+
$newPropertiesChangelog = $command->compareNewProperties($dataStructure);
40+
$writer->write($packageName, $newPropertiesChangelog, 'since-properties');
41+
}
4042
}

code-updater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
require_once 'bootstrap.php';
88
/** @var \Composer\Autoload\ClassLoader $loader */
99
$loader = require './vendor/autoload.php';
10-
$config = new \Magento\DeprecationTool\Config();
10+
$config = new \Magento\DeprecationTool\AppConfig();
1111
/** @var \Magento\DeprecationTool\CodeUpdater\AbstractUpdater[] $workers */
1212
$workers = [];
1313
foreach ($config->getEditions() as $edition) {

code/Config.php renamed to code/AppConfig.php

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Magento\DeprecationTool;
99

10-
class Config
10+
class AppConfig
1111
{
1212
const CE_EDITION = 'ce';
1313
const EE_EDITION = 'ee';
@@ -33,7 +33,9 @@ public function __construct()
3333
*/
3434
public function getTags($edition)
3535
{
36-
return isset($this->config[$edition. '_tags']['release']) ? $this->config[$edition. '_tags']['release'] : [];
36+
$tags = isset($this->config[$edition. '_tags']['release']) ? $this->config[$edition. '_tags']['release'] : [];
37+
usort($tags, 'version_compare');
38+
return $tags;
3739
}
3840

3941
/**
@@ -83,12 +85,12 @@ public function getSourceCodePath($edition, $release)
8385
}
8486

8587
/**
86-
* @param $edition
88+
* @param $packageName
8789
* @return string
8890
*/
89-
public function getChangelogPath($edition)
91+
public function getChangelogPath($packageName)
9092
{
91-
$path = BP . '/var/changelog/' . $edition;
93+
$path = BP . '/var/changelog/' . $packageName;
9294
return $path;
9395
}
9496

@@ -107,16 +109,14 @@ public function getLogPath($type)
107109
* @param $release
108110
* @return string
109111
*/
110-
public function getSourceCodeLocation($edition, $release)
112+
public function getGitSourceCodeLocation($edition, $release)
111113
{
112-
if ($edition == self::CE_EDITION) {
113-
$path = BP . '/var/releases/' . $release . '/magento2' . $edition;
114+
if ($edition == 'ce') {
115+
return BP . '/var/releases/' . $release . '/magento2' . $edition;
114116
} else {
115-
// Ex: /var/release/2.2.0/magento2ee/magento2ee; magento2ee is a sub-folder of root directory.
116-
$path = BP . '/var/releases/' . $release . '/magento2' . $edition . '/magento2' . $edition;
117+
return BP . '/var/releases/' . $release . '/magento2' . $edition . '/magento2' . $edition;
117118
}
118119

119-
return $path;
120120
}
121121

122122
/**
@@ -152,4 +152,21 @@ public function getArtifactPath($edition, $release, $withFileName = true)
152152
}
153153
return $path;
154154
}
155+
156+
/**
157+
* @param $package
158+
* @param $version
159+
* @param bool $withFileName
160+
* @return string
161+
*/
162+
public function getMetadataPath($package, $version, $withFileName = true)
163+
{
164+
$package = str_replace('/', '-', $package);
165+
if ($withFileName) {
166+
$path = BP . '/var/metadata/' . $package . '/' . $version . '.json';
167+
} else {
168+
$path = BP . '/var/metadata/' . $package;
169+
}
170+
return $path;
171+
}
155172
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\DeprecationTool\CheckoutStrategy\Composer;
8+
9+
use \Magento\DeprecationTool\CheckoutStrategyInterface;
10+
use \Magento\DeprecationTool\AppConfig;
11+
12+
class B2B implements CheckoutStrategyInterface
13+
{
14+
/**
15+
* @var AppConfig
16+
*/
17+
private $config;
18+
19+
/**
20+
* Initialize dependencies.
21+
*
22+
* @param AppConfig $config
23+
*/
24+
public function __construct(AppConfig $config)
25+
{
26+
$this->config = $config;
27+
}
28+
29+
/**
30+
* @param string $release
31+
* @param array|string $commit
32+
* @throws \Exception
33+
*/
34+
public function checkout($release, $commit)
35+
{
36+
throw new \Exception('This logic is not implemented yet');
37+
}
38+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
8+
namespace Magento\DeprecationTool\CheckoutStrategy\Composer;
9+
10+
use \Magento\DeprecationTool\CheckoutStrategyInterface;
11+
use \Magento\DeprecationTool\AppConfig;
12+
13+
class Community implements CheckoutStrategyInterface
14+
{
15+
/**
16+
* @var AppConfig
17+
*/
18+
private $config;
19+
20+
/**
21+
* Initialize dependencies.
22+
*
23+
* @param AppConfig $config
24+
*/
25+
public function __construct(AppConfig $config)
26+
{
27+
$this->config = $config;
28+
}
29+
30+
/**
31+
* @param string $release
32+
* @param string $commit
33+
*/
34+
public function checkout($release, $commit)
35+
{
36+
$path = $this->config->getSourceCodePath(AppConfig::CE_EDITION, $release);
37+
if (!file_exists($path . '/composer.json')) {
38+
$this->config->createFolder($path);
39+
exec('cd ' . $path . '; composer create-project magento/project-community-edition=' . $release . ' --repository-url=https://repo.magento.com ./');
40+
}
41+
}
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\DeprecationTool\CheckoutStrategy\Composer;
8+
9+
use \Magento\DeprecationTool\CheckoutStrategyInterface;
10+
use \Magento\DeprecationTool\AppConfig;
11+
12+
class Enterprise implements CheckoutStrategyInterface
13+
{
14+
/**
15+
* @var AppConfig
16+
*/
17+
private $config;
18+
19+
/**
20+
* Initialize dependencies.
21+
*
22+
* @param AppConfig $config
23+
*/
24+
public function __construct(AppConfig $config)
25+
{
26+
$this->config = $config;
27+
}
28+
29+
/**
30+
* @param string $release
31+
* @param string $commit
32+
*/
33+
public function checkout($release, $commit)
34+
{
35+
$path = $this->config->getSourceCodePath(AppConfig::EE_EDITION, $release);
36+
if (!file_exists($path . '/composer.json')) {
37+
$this->config->createFolder($path);
38+
exec('cd ' . $path . '; composer create-project magento/project-enterprise-edition=' . $release . ' --repository-url=https://repo.magento.com ./');
39+
}
40+
}
41+
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\DeprecationTool\CheckoutStrategy;
7+
namespace Magento\DeprecationTool\CheckoutStrategy\Git;
88

99
use \Magento\DeprecationTool\CheckoutStrategyInterface;
10-
use \Magento\DeprecationTool\Config;
10+
use \Magento\DeprecationTool\AppConfig;
1111

1212
class B2B implements CheckoutStrategyInterface
1313
{
1414
/**
15-
* @var Config
15+
* @var AppConfig
1616
*/
1717
private $config;
1818

1919
/**
2020
* Initialize dependencies.
2121
*
22-
* @param Config $config
22+
* @param AppConfig $config
2323
*/
24-
public function __construct(Config $config)
24+
public function __construct(AppConfig $config)
2525
{
2626
$this->config = $config;
2727
}
@@ -32,23 +32,23 @@ public function __construct(Config $config)
3232
*/
3333
public function checkout($release, $commit)
3434
{
35-
$cePath = $this->config->getSourceCodePath(Config::B2B_EDITION, $release);
35+
$cePath = $this->config->getSourceCodePath(AppConfig::B2B_EDITION, $release);
3636
if (!file_exists($cePath . '/composer.json')) {
3737
$this->config->createFolder($cePath);
38-
exec('cp -r ' . $this->config->getMasterSourceCodePath(Config::CE_EDITION) . '/ ' . $cePath . '/');
38+
exec('cp -r ' . $this->config->getMasterSourceCodePath(AppConfig::CE_EDITION) . '/ ' . $cePath . '/');
3939
exec('cd ' . $cePath . '; git checkout ' . $commit['ce']);
4040
}
4141

4242
$eePath = $cePath . '/magento2ee';
4343
if (!file_exists($eePath . '/composer.json')) {
4444
$this->config->createFolder($eePath);
45-
exec('cp -r ' . $this->config->getMasterSourceCodePath(Config::EE_EDITION) . '/ ' . $eePath . '/');
45+
exec('cp -r ' . $this->config->getMasterSourceCodePath(AppConfig::EE_EDITION) . '/ ' . $eePath . '/');
4646
exec('cd ' . $eePath . '; git checkout ' . $commit['ee']);
4747
$this->executeLinkCommand($eePath, $cePath, $eePath);
4848

4949
$b2bPath = $cePath . '/magento2b2b';
5050
$this->config->createFolder($b2bPath);
51-
exec('cp -r ' . $this->config->getMasterSourceCodePath(Config::B2B_EDITION) . '/ ' . $b2bPath . '/');
51+
exec('cp -r ' . $this->config->getMasterSourceCodePath(AppConfig::B2B_EDITION) . '/ ' . $b2bPath . '/');
5252
exec('cd ' . $b2bPath . '; git checkout ' . $commit['b2b']);
5353
$this->executeLinkCommand($b2bPath, $cePath, $eePath);
5454

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
* See COPYING.txt for license details.
66
*/
77

8-
namespace Magento\DeprecationTool\CheckoutStrategy;
8+
namespace Magento\DeprecationTool\CheckoutStrategy\Git;
99

1010
use \Magento\DeprecationTool\CheckoutStrategyInterface;
11-
use \Magento\DeprecationTool\Config;
11+
use \Magento\DeprecationTool\AppConfig;
1212

1313
class Community implements CheckoutStrategyInterface
1414
{
1515
/**
16-
* @var Config
16+
* @var AppConfig
1717
*/
1818
private $config;
1919

2020
/**
2121
* Initialize dependencies.
2222
*
23-
* @param Config $config
23+
* @param AppConfig $config
2424
*/
25-
public function __construct(Config $config)
25+
public function __construct(AppConfig $config)
2626
{
2727
$this->config = $config;
2828
}
@@ -33,10 +33,10 @@ public function __construct(Config $config)
3333
*/
3434
public function checkout($release, $commit)
3535
{
36-
$path = $this->config->getSourceCodePath(Config::CE_EDITION, $release);
36+
$path = $this->config->getSourceCodePath(AppConfig::CE_EDITION, $release);
3737
if (!file_exists($path . '/composer.json')) {
3838
$this->config->createFolder($path);
39-
exec('cp -r ' . $this->config->getMasterSourceCodePath(Config::CE_EDITION) . '/ ' . $path . '/');
39+
exec('cp -r ' . $this->config->getMasterSourceCodePath(AppConfig::CE_EDITION) . '/ ' . $path . '/');
4040
exec('cd ' . $path . '; git checkout ' . $commit);
4141
exec('cd ' . $path . '; composer install');
4242
}

0 commit comments

Comments
 (0)