Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2464 Fixed upgrade compatibility tool #2482

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .github/workflows/gradlepublishalpha.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).

## 5.4.0

### Fixed

- Fixed Upgrade Compatibility Tool [#2482](https://github.com/magento/magento2-phpstorm-plugin/pull/2482)
Replaced hardcoded Magento versions with dynamic fetching via Packagist API.
Fixed UI icon references.
Updated Run command.

### Changed

- Updated Gradle Intellij plugin to version 2 [#2473](https://github.com/magento/magento2-phpstorm-plugin/pull/2473)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.jetbrains.php.config.commandLine.PhpCommandSettings;
import com.jetbrains.php.config.commandLine.PhpCommandSettingsBuilder;
import com.jetbrains.php.config.interpreters.PhpInterpreter;
import com.magento.idea.magento2plugin.project.Settings;
import com.magento.idea.magento2uct.execution.filters.UctPhpFileFilter;
import com.magento.idea.magento2uct.execution.filters.UctResultFileFilter;
import com.magento.idea.magento2uct.packages.IssueSeverityLevel;
Expand All @@ -42,7 +43,8 @@
"PMD.NPathComplexity",
"PMD.CyclomaticComplexity",
"PMD.ExcessiveImports",
"PMD.CognitiveComplexity"
"PMD.CognitiveComplexity",
"PMD.ExcessiveMethodLength"
})
public class UctRunConfiguration extends LocatableConfigurationBase<UctRunConfigurationOptions> {

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

if (!getComingVersion().isEmpty()) {
commandSettingsBuilder.addArgument(
"--current-version=" + Settings.getInstance(getProject()).magentoVersion
);
}

final GeneralCommandLine commandLine =
commandSettingsBuilder.createGeneralCommandLine();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="983" height="546"/>
<xy x="20" y="20" width="1264" height="1030"/>
</constraints>
<properties/>
<border type="none"/>
Expand Down Expand Up @@ -137,7 +137,7 @@
</constraints>
<properties>
<font size="12"/>
<icon value="general/information.png"/>
<icon value="icons/information.png"/>
<text value="If your CLI output is cut, you should increase your buffer size:"/>
</properties>
</component>
Expand Down Expand Up @@ -176,7 +176,7 @@
<alignmentY value="0.5"/>
<enabled value="true"/>
<font size="12" style="1"/>
<icon value="general/warning.png"/>
<icon value="icons/warning.png"/>
<text value="Could not find UCT in the project:"/>
</properties>
</component>
Expand All @@ -195,7 +195,7 @@
<contentAreaFilled value="true"/>
<hideActionText value="false"/>
<horizontalTextPosition value="11"/>
<icon value="actions/install.png"/>
<icon value="icons/install.png"/>
<iconTextGap value="5"/>
<inheritsPopupMenu value="false"/>
<label value="Download"/>
Expand Down Expand Up @@ -249,7 +249,7 @@
<foreground color="-2730672"/>
<horizontalAlignment value="2"/>
<horizontalTextPosition value="11"/>
<icon value="general/warning.png"/>
<icon value="icons/warning.png"/>
<text value="Adobe Commerce only."/>
<toolTipText value="You should have Magento authentication keys"/>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
import org.jdesktop.swingx.JXHyperlink;
import org.jetbrains.annotations.NotNull;

@SuppressWarnings({"PMD.TooManyFields", "PMD.ExcessiveImports"})
@SuppressWarnings({
"PMD.TooManyFields",
"PMD.ExcessiveImports",
"PMD.TooManyMethods"
})
public class UctSettingsEditor extends SettingsEditor<UctRunConfiguration> {

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

validateExecutablePathField();
validateComingVersionField((ComboBoxItemData) comingVersion.getSelectedItem());

myScriptName
.getComponent()
Expand Down Expand Up @@ -399,7 +402,7 @@ private void validateComingVersionField(final ComboBoxItemData selectedItem) {
* @return ComboBoxItemData
*/
private ComboBoxItemData getCorrectedSelectedItem(final Object selectedItem) {
ComboBoxItemData selectedComingVersion;
final ComboBoxItemData selectedComingVersion;

if (selectedItem instanceof ComboBoxItemData) {
selectedComingVersion = (ComboBoxItemData) selectedItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,22 @@

package com.magento.idea.magento2uct.packages;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;

public enum SupportedVersion {

V230("2.3.0"),
V231("2.3.1"),
V232("2.3.2"),
V2322("2.3.2-p2"),
V233("2.3.3"),
V2331("2.3.3-p1"),
V234("2.3.4"),
V2341("2.3.4-p1"),
V2342("2.3.4-p2"),
V235("2.3.5"),
V2351("2.3.5-p1"),
V2352("2.3.5-p2"),
V236("2.3.6"),
V2361("2.3.6-p1"),
V237("2.3.7"),
V2371("2.3.7-p1"),
V240("2.4.0"),
V2401("2.4.0-p1"),
V241("2.4.1"),
V2411("2.4.1-p1"),
V242("2.4.2"),
V2421("2.4.2-p1"),
V2422("2.4.2-p2"),
V243("2.4.3"),
V2431("2.4.3-p1"),
V2444("2.4.4-beta4");

;
private final String version;
private static final Integer SUCCESS_CODE = 200;

SupportedVersion(final String version) {
this.version = version;
Expand Down Expand Up @@ -77,10 +57,75 @@ public String getVersion() {
* @return List[String]
*/
public static List<String> getSupportedVersions() {
final List<String> versions = new LinkedList<>();
try {
return fetchSupportedVersions();
} catch (Exception e) { //NOPMD - suppressed AvoidCatchingGenericException
// Return an empty list or log the exception
return List.of();
}
}

for (final SupportedVersion version : SupportedVersion.values()) {
versions.add(version.getVersion());
/**
* Fetch supported versions dynamically from Packagist
* This method performs an HTTP GET request to fetch version data in JSON format
* from a predefined URL and parses it into a list of version strings.
*
* @return List[String] containing supported version strings
* @throws IOException if an error occurs during HTTP connection or JSON parsing
*/
public static List<String> fetchSupportedVersions() throws IOException {
final String url = "https://repo.packagist.org/p2/magento/community-edition.json";
final List<String> versions = new ArrayList<>();

HttpURLConnection connection = null;
try {
// Establish HTTP connection
connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept", "application/json");

if (connection.getResponseCode() != SUCCESS_CODE) {
throw new IOException(//NOPMD - suppressed AvoidThrowingRawExceptionTypes
"Failed to fetch data, HTTP response code: " + connection.getResponseCode()
);
}

// Read JSON response
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(connection.getInputStream()))
) {
final StringBuilder response = new StringBuilder();
String line;
while (true) {
line = reader.readLine();
if (line == null) {
break;
}
response.append(line);
}

// Parse JSON for version data
final JSONObject jsonResponse = new JSONObject(response.toString());
final JSONArray packageObject = jsonResponse
.getJSONObject("packages")
.getJSONArray("magento/community-edition");

for (final Object o : packageObject) {
final JSONObject version = (JSONObject) o;
if (version == null) {
continue;
}
final String versionstring = version.getString("version");
if (versionstring == null) {
continue;
}
versions.add(versionstring);
}
}
} finally {
if (connection != null) {
connection.disconnect();
}
}

return versions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void setCurrentVersion(final @Nullable SupportedVersion version) {
public @NotNull SupportedVersion getCurrentVersionOrDefault() {
final SupportedVersion currentVersion = getCurrentVersion();

return currentVersion == null ? SupportedVersion.V230 : currentVersion;
return currentVersion == null ? SupportedVersion.valueOf("2.3.0") : currentVersion;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private void groupLoadedData() {
VersioningDataOperationsUtil.unionVersionDataWithChangelog(
versioningData,
new ArrayList<>(Collections.singletonList(
SupportedVersion.V230.getVersion()
SupportedVersion.valueOf("2.3.0").getVersion()
)),
true
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private void groupLoadedData() {
VersioningDataOperationsUtil.unionVersionDataWithChangelog(
versioningData,
new ArrayList<>(Collections.singletonList(
SupportedVersion.V230.getVersion()
SupportedVersion.valueOf("2.3.0").getVersion()
)),
true
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private void groupLoadedData() {
VersioningDataOperationsUtil.unionVersionDataWithChangelog(
versioningData,
new ArrayList<>(Collections.singletonList(
SupportedVersion.V230.getVersion()
SupportedVersion.valueOf("2.3.0").getVersion()
)),
false
);
Expand Down
Binary file added src/main/resources/icons/information.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/icons/install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/icons/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading