Skip to content

Commit 87eac34

Browse files
Additional enhancements, bug fixes
1 parent 498fb19 commit 87eac34

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ private void lookupUctExecutablePath(
239239
uctExecutablePath = storedUctExecutable;
240240
return;
241241
}
242-
final VirtualFile uctExecutableVf = UctModuleLocatorUtil.locateUctExecutable(project);
242+
final VirtualFile uctExecutableVf = UctModuleLocatorUtil.locateUctExecutable(
243+
project,
244+
uctRunConfiguration.getProjectRoot()
245+
);
243246

244247
if (uctExecutableVf == null) {
245248
warningPanel.setVisible(true);
@@ -264,7 +267,11 @@ private String getStoredUctExecutablePath(
264267
if (!uctRunConfiguration.getScriptName().isEmpty()) {
265268
uctExecutablePath = uctRunConfiguration.getScriptName();
266269

267-
return uctExecutablePath;
270+
if (UctExecutableValidatorUtil.validate(uctExecutablePath)) {
271+
return uctExecutablePath;
272+
} else {
273+
uctRunConfiguration.setScriptName("");
274+
}
268275
}
269276
if (!uctRunConfiguration.isNewlyCreated()) {
270277
return null;

src/com/magento/idea/magento2uct/execution/output/ReportBuilder.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.util.ArrayList;
2929
import java.util.LinkedList;
3030
import java.util.List;
31+
import java.util.Locale;
32+
3133
import org.jetbrains.annotations.NotNull;
3234
import org.json.simple.JSONObject;
3335

@@ -39,7 +41,10 @@ public class ReportBuilder {
3941

4042
private final Project project;
4143
private final Report report;
42-
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHms");
44+
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(
45+
"dd_MMM_yyyy_HH:mm:ss",
46+
Locale.US
47+
);
4348

4449
/**
4550
* Report builder.

src/com/magento/idea/magento2uct/util/module/UctModuleLocatorUtil.java

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ private UctModuleLocatorUtil() {
2727
}
2828

2929
/**
30-
* Find UCT executable for the specified project.
30+
* Find UCT executable for the specified magento 2 project path.
3131
*
3232
* @param project Project
33+
* @param projectRoot String
3334
*
3435
* @return VirtualFile
3536
*/
36-
public static @Nullable VirtualFile locateUctExecutable(final @NotNull Project project) {
37-
final PsiDirectory uctModuleDir = locateModule(project);
37+
public static @Nullable VirtualFile locateUctExecutable(
38+
final @NotNull Project project,
39+
final @NotNull String projectRoot
40+
) {
41+
final PsiDirectory uctModuleDir = locateModule(project, projectRoot);
3842

3943
if (uctModuleDir == null) {
4044
return null;
@@ -54,6 +58,7 @@ private UctModuleLocatorUtil() {
5458
* Find UCT module base directory.
5559
*
5660
* @param project Project
61+
* @param projectRoot String
5762
*
5863
* @return PsiDirectory
5964
*/
@@ -63,24 +68,27 @@ private UctModuleLocatorUtil() {
6368
"PMD.CyclomaticComplexity",
6469
"PMD.AvoidDeeplyNestedIfStmts"
6570
})
66-
public static @Nullable PsiDirectory locateModule(final @NotNull Project project) {
67-
final String projectBasePath = project.getBasePath();
68-
69-
if (projectBasePath == null) {
71+
public static @Nullable PsiDirectory locateModule(
72+
final @NotNull Project project,
73+
final @NotNull String projectRoot
74+
) {
75+
if (projectRoot.isEmpty()) {
7076
return null;
7177
}
72-
final VirtualFile projectBaseVf = VfsUtil.findFile(Path.of(projectBasePath), false);
78+
final VirtualFile magentoProjectBaseVf = VfsUtil.findFile(Path.of(projectRoot), false);
7379

74-
if (projectBaseVf == null) {
80+
if (magentoProjectBaseVf == null) {
7581
return null;
7682
}
7783
final PsiManager psiManager = PsiManager.getInstance(project);
78-
final PsiDirectory projectBaseDir = psiManager.findDirectory(projectBaseVf);
84+
final PsiDirectory magentoProjectBaseDir = psiManager.findDirectory(magentoProjectBaseVf);
7985

80-
if (projectBaseDir == null) {
86+
if (magentoProjectBaseDir == null) {
8187
return null;
8288
}
83-
final PsiFile composerConfigurationFile = projectBaseDir.findFile(ComposerJson.FILE_NAME);
89+
final PsiFile composerConfigurationFile = magentoProjectBaseDir.findFile(
90+
ComposerJson.FILE_NAME
91+
);
8492

8593
if (composerConfigurationFile instanceof JsonFile) {
8694
final boolean hasUctAsProjectDependency = composerConfigurationFile
@@ -89,15 +97,15 @@ private UctModuleLocatorUtil() {
8997

9098
if (hasUctAsProjectDependency) {
9199
PsiDirectory uctBaseDir = findSubdirectoryByPath(
92-
projectBaseDir,
100+
magentoProjectBaseDir,
93101
"vendor".concat(File.separator)
94102
.concat("magento")
95103
.concat(File.separator)
96104
.concat("module-upgrade-compatibility-tool")
97105
);
98106
if (uctBaseDir == null) {
99107
uctBaseDir = findSubdirectoryByPath(
100-
projectBaseDir,
108+
magentoProjectBaseDir,
101109
"app".concat(File.separator)
102110
.concat("code")
103111
.concat(File.separator)
@@ -110,6 +118,21 @@ private UctModuleLocatorUtil() {
110118
return uctBaseDir;
111119
}
112120
}
121+
final String projectBasePath = project.getBasePath();
122+
123+
if (projectBasePath == null) {
124+
return null;
125+
}
126+
final VirtualFile projectBaseVf = VfsUtil.findFile(Path.of(projectBasePath), false);
127+
128+
if (projectBaseVf == null) {
129+
return null;
130+
}
131+
final PsiDirectory projectBaseDir = psiManager.findDirectory(projectBaseVf);
132+
133+
if (projectBaseDir == null) {
134+
return null;
135+
}
113136

114137
for (final PsiDirectory subDir : projectBaseDir.getSubdirectories()) {
115138
final PsiFile composerFile = subDir.findFile(ComposerJson.FILE_NAME);

0 commit comments

Comments
 (0)