Skip to content

Commit b3cd67a

Browse files
authored
Merge branch '5.4.0-develop' into updated-readme
2 parents 538b1cf + 730194c commit b3cd67a

File tree

13 files changed

+108
-76
lines changed

13 files changed

+108
-76
lines changed

.github/workflows/gradlepublishalpha.yml

-31
This file was deleted.

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
66

77
## 5.4.0
88

9+
### Fixed
10+
11+
- Fixed Upgrade Compatibility Tool [#2482](https://github.com/magento/magento2-phpstorm-plugin/pull/2482)
12+
Replaced hardcoded Magento versions with dynamic fetching via Packagist API.
13+
Fixed UI icon references.
14+
Updated Run command.
15+
916
### Changed
1017

1118
- Updated Gradle Intellij plugin to version 2 [#2473](https://github.com/magento/magento2-phpstorm-plugin/pull/2473)

src/main/java/com/magento/idea/magento2uct/execution/configurations/UctRunConfiguration.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.jetbrains.php.config.commandLine.PhpCommandSettings;
2929
import com.jetbrains.php.config.commandLine.PhpCommandSettingsBuilder;
3030
import com.jetbrains.php.config.interpreters.PhpInterpreter;
31+
import com.magento.idea.magento2plugin.project.Settings;
3132
import com.magento.idea.magento2uct.execution.filters.UctPhpFileFilter;
3233
import com.magento.idea.magento2uct.execution.filters.UctResultFileFilter;
3334
import com.magento.idea.magento2uct.packages.IssueSeverityLevel;
@@ -42,7 +43,8 @@
4243
"PMD.NPathComplexity",
4344
"PMD.CyclomaticComplexity",
4445
"PMD.ExcessiveImports",
45-
"PMD.CognitiveComplexity"
46+
"PMD.CognitiveComplexity",
47+
"PMD.ExcessiveMethodLength"
4648
})
4749
public class UctRunConfiguration extends LocatableConfigurationBase<UctRunConfigurationOptions> {
4850

@@ -263,6 +265,12 @@ public boolean isNewlyCreated() {
263265
commandSettingsBuilder.addArgument("--coming-version=" + getComingVersion());
264266
}
265267

268+
if (!getComingVersion().isEmpty()) {
269+
commandSettingsBuilder.addArgument(
270+
"--current-version=" + Settings.getInstance(getProject()).magentoVersion
271+
);
272+
}
273+
266274
final GeneralCommandLine commandLine =
267275
commandSettingsBuilder.createGeneralCommandLine();
268276

src/main/java/com/magento/idea/magento2uct/execution/configurations/UctSettingsEditor.form

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="18" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="0" left="0" bottom="0" right="0"/>
55
<constraints>
6-
<xy x="20" y="20" width="983" height="546"/>
6+
<xy x="20" y="20" width="1264" height="1030"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
@@ -137,7 +137,7 @@
137137
</constraints>
138138
<properties>
139139
<font size="12"/>
140-
<icon value="general/information.png"/>
140+
<icon value="icons/information.png"/>
141141
<text value="If your CLI output is cut, you should increase your buffer size:"/>
142142
</properties>
143143
</component>
@@ -176,7 +176,7 @@
176176
<alignmentY value="0.5"/>
177177
<enabled value="true"/>
178178
<font size="12" style="1"/>
179-
<icon value="general/warning.png"/>
179+
<icon value="icons/warning.png"/>
180180
<text value="Could not find UCT in the project:"/>
181181
</properties>
182182
</component>
@@ -195,7 +195,7 @@
195195
<contentAreaFilled value="true"/>
196196
<hideActionText value="false"/>
197197
<horizontalTextPosition value="11"/>
198-
<icon value="actions/install.png"/>
198+
<icon value="icons/install.png"/>
199199
<iconTextGap value="5"/>
200200
<inheritsPopupMenu value="false"/>
201201
<label value="Download"/>
@@ -249,7 +249,7 @@
249249
<foreground color="-2730672"/>
250250
<horizontalAlignment value="2"/>
251251
<horizontalTextPosition value="11"/>
252-
<icon value="general/warning.png"/>
252+
<icon value="icons/warning.png"/>
253253
<text value="Adobe Commerce only."/>
254254
<toolTipText value="You should have Magento authentication keys"/>
255255
</properties>

src/main/java/com/magento/idea/magento2uct/execution/configurations/UctSettingsEditor.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
import org.jdesktop.swingx.JXHyperlink;
4343
import org.jetbrains.annotations.NotNull;
4444

45-
@SuppressWarnings({"PMD.TooManyFields", "PMD.ExcessiveImports"})
45+
@SuppressWarnings({
46+
"PMD.TooManyFields",
47+
"PMD.ExcessiveImports",
48+
"PMD.TooManyMethods"
49+
})
4650
public class UctSettingsEditor extends SettingsEditor<UctRunConfiguration> {
4751

4852
private static final String LEARN_MORE_URI =
@@ -339,7 +343,6 @@ private void validateSettingsForm() {
339343
comingVersionError.setForeground(new Color(252, 119, 83));
340344

341345
validateExecutablePathField();
342-
validateComingVersionField((ComboBoxItemData) comingVersion.getSelectedItem());
343346

344347
myScriptName
345348
.getComponent()
@@ -399,7 +402,7 @@ private void validateComingVersionField(final ComboBoxItemData selectedItem) {
399402
* @return ComboBoxItemData
400403
*/
401404
private ComboBoxItemData getCorrectedSelectedItem(final Object selectedItem) {
402-
ComboBoxItemData selectedComingVersion;
405+
final ComboBoxItemData selectedComingVersion;
403406

404407
if (selectedItem instanceof ComboBoxItemData) {
405408
selectedComingVersion = (ComboBoxItemData) selectedItem;

src/main/java/com/magento/idea/magento2uct/packages/SupportedVersion.java

+77-32
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,22 @@
55

66
package com.magento.idea.magento2uct.packages;
77

8+
import java.io.BufferedReader;
9+
import java.io.IOException;
10+
import java.io.InputStreamReader;
11+
import java.net.HttpURLConnection;
12+
import java.net.URL;
813
import java.util.ArrayList;
9-
import java.util.LinkedList;
1014
import java.util.List;
1115
import org.jetbrains.annotations.NotNull;
1216
import org.jetbrains.annotations.Nullable;
17+
import org.json.JSONArray;
18+
import org.json.JSONObject;
1319

1420
public enum SupportedVersion {
15-
16-
V230("2.3.0"),
17-
V231("2.3.1"),
18-
V232("2.3.2"),
19-
V2322("2.3.2-p2"),
20-
V233("2.3.3"),
21-
V2331("2.3.3-p1"),
22-
V234("2.3.4"),
23-
V2341("2.3.4-p1"),
24-
V2342("2.3.4-p2"),
25-
V235("2.3.5"),
26-
V2351("2.3.5-p1"),
27-
V2352("2.3.5-p2"),
28-
V236("2.3.6"),
29-
V2361("2.3.6-p1"),
30-
V237("2.3.7"),
31-
V2371("2.3.7-p1"),
32-
V240("2.4.0"),
33-
V2401("2.4.0-p1"),
34-
V241("2.4.1"),
35-
V2411("2.4.1-p1"),
36-
V242("2.4.2"),
37-
V2421("2.4.2-p1"),
38-
V2422("2.4.2-p2"),
39-
V243("2.4.3"),
40-
V2431("2.4.3-p1"),
41-
V2444("2.4.4-beta4");
42-
21+
;
4322
private final String version;
23+
private static final Integer SUCCESS_CODE = 200;
4424

4525
SupportedVersion(final String version) {
4626
this.version = version;
@@ -77,10 +57,75 @@ public String getVersion() {
7757
* @return List[String]
7858
*/
7959
public static List<String> getSupportedVersions() {
80-
final List<String> versions = new LinkedList<>();
60+
try {
61+
return fetchSupportedVersions();
62+
} catch (Exception e) { //NOPMD - suppressed AvoidCatchingGenericException
63+
// Return an empty list or log the exception
64+
return List.of();
65+
}
66+
}
8167

82-
for (final SupportedVersion version : SupportedVersion.values()) {
83-
versions.add(version.getVersion());
68+
/**
69+
* Fetch supported versions dynamically from Packagist
70+
* This method performs an HTTP GET request to fetch version data in JSON format
71+
* from a predefined URL and parses it into a list of version strings.
72+
*
73+
* @return List[String] containing supported version strings
74+
* @throws IOException if an error occurs during HTTP connection or JSON parsing
75+
*/
76+
public static List<String> fetchSupportedVersions() throws IOException {
77+
final String url = "https://repo.packagist.org/p2/magento/community-edition.json";
78+
final List<String> versions = new ArrayList<>();
79+
80+
HttpURLConnection connection = null;
81+
try {
82+
// Establish HTTP connection
83+
connection = (HttpURLConnection) new URL(url).openConnection();
84+
connection.setRequestMethod("GET");
85+
connection.setRequestProperty("Accept", "application/json");
86+
87+
if (connection.getResponseCode() != SUCCESS_CODE) {
88+
throw new IOException(//NOPMD - suppressed AvoidThrowingRawExceptionTypes
89+
"Failed to fetch data, HTTP response code: " + connection.getResponseCode()
90+
);
91+
}
92+
93+
// Read JSON response
94+
try (BufferedReader reader = new BufferedReader(
95+
new InputStreamReader(connection.getInputStream()))
96+
) {
97+
final StringBuilder response = new StringBuilder();
98+
String line;
99+
while (true) {
100+
line = reader.readLine();
101+
if (line == null) {
102+
break;
103+
}
104+
response.append(line);
105+
}
106+
107+
// Parse JSON for version data
108+
final JSONObject jsonResponse = new JSONObject(response.toString());
109+
final JSONArray packageObject = jsonResponse
110+
.getJSONObject("packages")
111+
.getJSONArray("magento/community-edition");
112+
113+
for (final Object o : packageObject) {
114+
final JSONObject version = (JSONObject) o;
115+
if (version == null) {
116+
continue;
117+
}
118+
final String versionstring = version.getString("version");
119+
if (versionstring == null) {
120+
continue;
121+
}
122+
versions.add(versionstring);
123+
}
124+
}
125+
} finally {
126+
if (connection != null) {
127+
connection.disconnect();
128+
}
84129
}
85130

86131
return versions;

src/main/java/com/magento/idea/magento2uct/settings/UctSettingsService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void setCurrentVersion(final @Nullable SupportedVersion version) {
175175
public @NotNull SupportedVersion getCurrentVersionOrDefault() {
176176
final SupportedVersion currentVersion = getCurrentVersion();
177177

178-
return currentVersion == null ? SupportedVersion.V230 : currentVersion;
178+
return currentVersion == null ? SupportedVersion.valueOf("2.3.0") : currentVersion;
179179
}
180180

181181
/**

src/main/java/com/magento/idea/magento2uct/versioning/indexes/data/ApiCoverageStateIndex.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private void groupLoadedData() {
168168
VersioningDataOperationsUtil.unionVersionDataWithChangelog(
169169
versioningData,
170170
new ArrayList<>(Collections.singletonList(
171-
SupportedVersion.V230.getVersion()
171+
SupportedVersion.valueOf("2.3.0").getVersion()
172172
)),
173173
true
174174
);

src/main/java/com/magento/idea/magento2uct/versioning/indexes/data/DeprecationStateIndex.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private void groupLoadedData() {
151151
VersioningDataOperationsUtil.unionVersionDataWithChangelog(
152152
versioningData,
153153
new ArrayList<>(Collections.singletonList(
154-
SupportedVersion.V230.getVersion()
154+
SupportedVersion.valueOf("2.3.0").getVersion()
155155
)),
156156
true
157157
);

src/main/java/com/magento/idea/magento2uct/versioning/indexes/data/ExistenceStateIndex.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private void groupLoadedData() {
196196
VersioningDataOperationsUtil.unionVersionDataWithChangelog(
197197
versioningData,
198198
new ArrayList<>(Collections.singletonList(
199-
SupportedVersion.V230.getVersion()
199+
SupportedVersion.valueOf("2.3.0").getVersion()
200200
)),
201201
false
202202
);
833 Bytes
Loading

src/main/resources/icons/install.png

600 Bytes
Loading

src/main/resources/icons/warning.png

687 Bytes
Loading

0 commit comments

Comments
 (0)