Skip to content

Commit 6505265

Browse files
Enhance AppConfiguration and ApplicationPathResolver to support dev profile, update version to 1.0.2, and modify installation path logic
1 parent 7fc0015 commit 6505265

File tree

6 files changed

+74
-16
lines changed

6 files changed

+74
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- Call to apis refactored
2-
- Update version fixed
1+
- If the CLI is reinstalled and if it was added to PATH previously, it will not be added again.
2+
- When using a dev profile a different location will be used

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>net.andrecarbajal</groupId>
1212
<artifactId>mine-control-cli</artifactId>
13-
<version>1.0.1</version>
13+
<version>1.0.2</version>
1414
<name>mine-control-cli</name>
1515
<description>A powerful CLI tool to create, manage, and run Minecraft servers effortlessly.</description>
1616
<url/>

setup.iss

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define MyAppName "MineControl CLI"
2-
#define MyAppVersion "1.0.1"
2+
#define MyAppVersion "1.0.2"
33
#define MyAppPublisher "Andre Carbajal"
44
#define MyAppExeName "mine-control-cli.exe"
55

@@ -20,14 +20,37 @@ WizardStyle=modern
2020
Source: "target\mine-control-cli.exe"; DestDir: "{app}"; Flags: ignoreversion
2121
Source: "target\*.dll"; DestDir: "{app}"; Flags: ignoreversion
2222

23-
[Registry]
24-
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
25-
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"
23+
[Code]
24+
procedure ModifyPath();
25+
var
26+
Path: string;
27+
AppDir: string;
28+
begin
29+
if not RegQueryStringValue(HKLM, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', Path) then
30+
begin
31+
Exit;
32+
end;
2633
27-
[Run]
28-
Filename: "{sys}\cmd.exe"; \
29-
Parameters: "/C setx PATH ""%PATH%;{app}"""; \
30-
Flags: runhidden
34+
AppDir := ExpandConstant('{app}');
35+
36+
if Pos(LowerCase(AppDir), LowerCase(Path)) = 0 then
37+
begin
38+
if Pos(';', Path[Length(Path)]) <> 0 then
39+
Path := Path + AppDir
40+
else
41+
Path := Path + ';' + AppDir;
42+
43+
RegWriteExpandStringValue(HKLM, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', Path);
44+
end;
45+
end;
46+
47+
procedure CurStepChanged(CurStep: TSetupStep);
48+
begin
49+
if CurStep = ssPostInstall then
50+
begin
51+
ModifyPath();
52+
end;
53+
end;
3154
3255
[UninstallDelete]
3356
Type: files; Name: "{app}\*.*"

src/main/java/net/andrecarbajal/mine_control_cli/config/AppConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.springframework.context.annotation.Bean;
1212
import org.springframework.context.annotation.Configuration;
1313
import org.springframework.context.annotation.PropertySource;
14+
import org.springframework.core.env.Environment;
1415

1516
import java.nio.file.Files;
1617
import java.nio.file.Path;
@@ -26,9 +27,9 @@ public class AppConfiguration {
2627
private Path instancesPath;
2728
private Path backupsPath;
2829

29-
public AppConfiguration(ApplicationProperties applicationProperties) {
30+
public AppConfiguration(ApplicationProperties applicationProperties, Environment environment) {
3031
this.applicationProperties = applicationProperties;
31-
this.applicationPathResolver = new ApplicationPathResolver(applicationProperties);
32+
this.applicationPathResolver = new ApplicationPathResolver(applicationProperties, environment);
3233
this.updateChecker = new UpdateChecker(applicationProperties);
3334
}
3435

src/main/java/net/andrecarbajal/mine_control_cli/config/path/ApplicationPathResolver.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
import net.andrecarbajal.mine_control_cli.config.ApplicationProperties;
44
import net.andrecarbajal.mine_control_cli.util.system.OsChecker;
5+
import org.springframework.core.env.Environment;
56

67
import java.nio.file.Files;
78
import java.nio.file.Path;
89
import java.nio.file.Paths;
910

1011
public class ApplicationPathResolver {
1112
private final ApplicationProperties applicationProperties;
13+
private final Environment environment;
1214

13-
public ApplicationPathResolver(ApplicationProperties applicationProperties) {
15+
public ApplicationPathResolver(ApplicationProperties applicationProperties, Environment environment) {
1416
this.applicationProperties = applicationProperties;
17+
this.environment = environment;
1518
}
1619

1720
public Path getApplicationPath() {
@@ -21,7 +24,13 @@ public Path getApplicationPath() {
2124
default -> System.getProperty("user.home");
2225
};
2326

24-
return Paths.get(baseFolder, applicationProperties.getName());
27+
String appName = applicationProperties.getName();
28+
29+
if (environment.matchesProfiles("dev")) {
30+
appName += "-dev";
31+
}
32+
33+
return Paths.get(baseFolder, appName);
2534
}
2635

2736
public void createApplicationPath() {
@@ -42,4 +51,4 @@ public Path createSubdirectory(String subdirectory) {
4251
throw new RuntimeException("Error creating " + subdirectory + " directory", e);
4352
}
4453
}
45-
}
54+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
spring:
2+
profiles:
3+
active: dev
4+
application:
5+
name: @project.artifactId@
6+
version: @project.version@
7+
main:
8+
banner-mode: off
9+
shell:
10+
history:
11+
enabled: false
12+
interactive:
13+
enabled: true
14+
command:
15+
quit:
16+
enabled: false
17+
history:
18+
enabled: false
19+
version:
20+
show-build-name: true
21+
show-build-group: true
22+
23+
logging:
24+
level:
25+
root: off

0 commit comments

Comments
 (0)