-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.php
More file actions
210 lines (181 loc) · 7.53 KB
/
Configuration.php
File metadata and controls
210 lines (181 loc) · 7.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
use Business\Estimator\UpgradeEstimator;
class Configuration
{
public const DEMOSHOP_GITHUB_URL_TO_COMPARE_WITH = 'https://github.com/spryker-shop';
public const SPRYKER_VENDORS = [
'spryker',
'spryker-shop',
'spryker-feature',
'spryker-eco',
'spryker-sdk',
];
public const VENDOR_SPRYKER_FEATURE = 'spryker-feature';
public const GITHUB_CONTENT_URL = 'https://raw.githubusercontent.com';
public const COMPOSER_JSON_FILE_NAME = 'composer.json';
public const LAYERS = ['Client', 'Glue', 'Shared', 'Service', 'Zed', 'Yves'];
public const OUTPUTS_FOLDER_PATH = './outputs';
public const UPGRADE_GUIDES_FOLDER_PATH = './UpgradeGuides';
protected const DEMOSHOP_TYPE_B2C = 'b2c-demo-shop';
protected const DEMOSHOP_TYPE_B2B = 'b2b-demo-shop';
protected const DEMOSHOP_TYPE_B2B_MARKETPLACE = 'b2b-demo-marketplace';
protected const DEMOSHOP_TYPE_B2C_MARKETPLACE = 'b2c-demo-marketplace';
protected const CONFIG_FILE_NAME = 'config.ini';
protected const CONFIGURATION_KEY_PATH_TO_PROJECT = 'path_to_project';
protected const CONFIGURATION_KEY_DESIRED_VERSON = 'desired_version';
protected const CONFIGURATION_KEY_CURRENT_DEMOSHOP_TYPE = 'current_demoshop_type';
protected const CONFIGURATION_KEY_PROJECT_MAIN_NAMESPACE_PATH = 'project_main_namespace_path';
protected const CONFIGURATION_KEY_PROJECT_NAMESPACE_PATHES = 'project_namespace_pathes';
protected const CONFIGURATION_KEY_PROJECT_GLOSSARY_PATH = 'project_glossary_path';
protected const CONFIGURATION_KEY_UPDATED_PACKAGES = 'updated_packages';
protected const CONFIGURATION_KEY_PARTIAL_UPDATE_PACKAGES = 'partial_update_packages';
protected const CONFIGURATION_KEY_PARTIAL_UPDATE_PACKAGES_NOT_IN = 'partial_update_packages_not_in';
protected const GITHUB_TOKEN = 'github_token';
protected const CONFIGURATION_KEY_DESIRED_PHP_VERSON = 'desired_php_version';
protected array $configuration;
public function __construct()
{
$this->configuration = parse_ini_file(static::CONFIG_FILE_NAME);
}
public function getPathToProject(): string
{
return $this->configuration[static::CONFIGURATION_KEY_PATH_TO_PROJECT];
}
public function getDesiredVersion(): string
{
return $this->configuration[static::CONFIGURATION_KEY_DESIRED_VERSON];
}
public function getCurrentDemoshopType(): string
{
return $this->configuration[static::CONFIGURATION_KEY_CURRENT_DEMOSHOP_TYPE];
}
public function getProjectGlossaryPath(): string
{
return $this->configuration[static::CONFIGURATION_KEY_PROJECT_GLOSSARY_PATH];
}
public function getProjectMainNamespacePath(): string
{
return $this->configuration[static::CONFIGURATION_KEY_PROJECT_MAIN_NAMESPACE_PATH];
}
public function getProjectNamespacePathes(): array
{
return $this->configuration[static::CONFIGURATION_KEY_PROJECT_NAMESPACE_PATHES];
}
public function getUpdatedPackages(): array
{
return $this->configuration[static::CONFIGURATION_KEY_UPDATED_PACKAGES];
}
public function getPartialUpdatePackages(): array
{
return $this->configuration[static::CONFIGURATION_KEY_PARTIAL_UPDATE_PACKAGES] ?? [];
}
public function getPartialUpdatePackagesNotIn(): array
{
return $this->configuration[static::CONFIGURATION_KEY_PARTIAL_UPDATE_PACKAGES_NOT_IN] ?? [];
}
public function getAllDemoshopTypes(): array
{
return [
static::DEMOSHOP_TYPE_B2C => static::DEMOSHOP_TYPE_B2C,
static::DEMOSHOP_TYPE_B2B => static::DEMOSHOP_TYPE_B2B,
static::DEMOSHOP_TYPE_B2C_MARKETPLACE => static::DEMOSHOP_TYPE_B2C_MARKETPLACE,
static::DEMOSHOP_TYPE_B2B_MARKETPLACE => static::DEMOSHOP_TYPE_B2B_MARKETPLACE,
];
}
public function getGithubToken(): string
{
return $this->configuration[static::GITHUB_TOKEN];
}
public function getDesiredPHPVersion(): string
{
return $this->configuration[static::CONFIGURATION_KEY_DESIRED_PHP_VERSON];
}
public function getUpgradeEstimationReportFilePath(string $processType): string
{
if ($processType === UpgradeEstimator::PROCESS_TYPE_REGULAR_UPDATE) {
return sprintf(
'%s/upgrade_to_%s_estimation_report%s.csv',
Configuration::OUTPUTS_FOLDER_PATH,
$this->getDesiredVersion(),
$this->isSdkInsideProject() ? '' : '_for_' . basename($this->getPathToProject()),
);
}
if ($processType === UpgradeEstimator::PROCESS_TYPE_PHP_UPDATE) {
return sprintf(
'%s/upgrade_to_%s_estimation_report%s.csv',
Configuration::OUTPUTS_FOLDER_PATH,
'PHP_' . $this->getDesiredPHPVersion(),
$this->isSdkInsideProject() ? '' : '_for_' . basename($this->getPathToProject()),
);
}
return sprintf(
'%s/partial_upgrade_estimation_report%s.csv',
Configuration::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : '_for_' . basename($this->getPathToProject()),
);
}
public function getCompatibilityReportFilePath(): string
{
return sprintf(
'%s/PHP_compatybility_upgrade_instruction%s_to_%s.csv',
static::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : '_for_' . basename($this->getPathToProject()),
$this->getDesiredPHPVersion(),
);
}
public function getPartialUpdateReportFilePath(): string
{
return sprintf(
'%s/partial_upgrade_instruction%s.csv',
static::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : '_for_' . basename($this->getPathToProject()),
);
}
public function getUpdateOrderAnalyzerReportFilePath(): string
{
return sprintf(
'%s/update_instruction%s_to_%s_version.csv',
static::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : '_for_' . basename($this->getPathToProject()),
$this->getDesiredVersion(),
);
}
public function getGlossaryAnalyzerReportFilePath(): string
{
return sprintf(
'%s/missing_glossary_keys%s.txt',
static::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : '_for_' . basename($this->getPathToProject()),
);
}
public function getOutdatedPackagesAnalyzerReportFilePath(): string
{
return sprintf(
'%s/outdated_packages%s_comparing_to_%s_version.txt',
static::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : '_in_' . basename($this->getPathToProject()),
$this->getDesiredVersion(),
);
}
public function getExtendedFilesAnalyzerReportFilePath(): string
{
return sprintf(
'%s/%sextended_project_level_files_list.txt',
static::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : basename($this->getPathToProject()) . '_',
);
}
public function getMissingPluginsFinderReportFilePath(): string
{
return sprintf(
'%s/missing_plugins%s_comparing_to_%s_version.txt',
static::OUTPUTS_FOLDER_PATH,
$this->isSdkInsideProject() ? '' : '_in_' . basename($this->getPathToProject()),
$this->getDesiredVersion(),
);
}
protected function isSdkInsideProject(): bool
{
return $this->getPathToProject() === '..';
}
}