-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/171-variable-syntax
- Loading branch information
Showing
10 changed files
with
181 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
cli/src/main/java/com/devonfw/tools/ide/tool/pgadmin/PgAdmin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.devonfw.tools.ide.tool.pgadmin; | ||
|
||
import com.devonfw.tools.ide.common.Tag; | ||
import com.devonfw.tools.ide.context.IdeContext; | ||
import com.devonfw.tools.ide.repo.ToolRepository; | ||
import com.devonfw.tools.ide.tool.GlobalToolCommandlet; | ||
import com.devonfw.tools.ide.tool.PackageManager; | ||
import com.devonfw.tools.ide.tool.PackageManagerCommand; | ||
import com.devonfw.tools.ide.version.VersionIdentifier; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* {@link GlobalToolCommandlet} for <a href="https://www.pgadmin.org/">pgadmin</a> | ||
*/ | ||
public class PgAdmin extends GlobalToolCommandlet { | ||
/** | ||
* The constructor. | ||
* | ||
* @param context the {@link IdeContext}. | ||
*/ | ||
public PgAdmin(IdeContext context) { | ||
|
||
//TODO: add relevant Tag. | ||
super(context, "pgadmin", Set.of(Tag.DB)); | ||
} | ||
|
||
@Override | ||
protected boolean doInstall(boolean silent) { | ||
|
||
if (this.context.getSystemInfo().isLinux()) { | ||
return runWithPackageManager(silent, getPackageManagerCommandsInstall()); | ||
} else { | ||
return super.doInstall(silent); | ||
} | ||
} | ||
|
||
private List<PackageManagerCommand> getPackageManagerCommandsInstall() { | ||
|
||
String edition = getEdition(); | ||
ToolRepository toolRepository = this.context.getDefaultToolRepository(); | ||
VersionIdentifier configuredVersion = getConfiguredVersion(); | ||
String resolvedVersion = toolRepository.resolveVersion(this.tool, edition, configuredVersion).toString(); | ||
|
||
List<PackageManagerCommand> pmCommands = new ArrayList<>(); | ||
|
||
pmCommands.add(new PackageManagerCommand(PackageManager.APT, Arrays.asList( | ||
"curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | " | ||
+ "sudo gpg --yes --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg", | ||
"sudo sh -c 'echo \"deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] " | ||
+ "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main\" " | ||
+ "> /etc/apt/sources.list.d/pgadmin4.list && apt update'", String.format( | ||
"sudo apt install -y --allow-downgrades pgadmin4=%1$s pgadmin4-server=%1$s pgadmin4-desktop=%1$s pgadmin4-web=%1$s", | ||
resolvedVersion)))); | ||
|
||
return pmCommands; | ||
} | ||
|
||
@Override | ||
public void uninstall() { | ||
|
||
if (this.context.getSystemInfo().isLinux()) { | ||
runWithPackageManager(false, getPackageManagerCommandsUninstall()); | ||
} else { | ||
super.uninstall(); | ||
} | ||
} | ||
|
||
private List<PackageManagerCommand> getPackageManagerCommandsUninstall() { | ||
|
||
List<PackageManagerCommand> pmCommands = new ArrayList<>(); | ||
|
||
pmCommands.add(new PackageManagerCommand(PackageManager.APT, | ||
Arrays.asList("sudo apt -y autoremove pgadmin4 pgadmin4-server pgadmin4-desktop pgadmin4-web"))); | ||
|
||
return pmCommands; | ||
} | ||
|
||
@Override | ||
protected String getBinaryName() { | ||
|
||
return "pgadmin4"; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
cli/src/main/java/com/devonfw/tools/ide/tool/pgadmin/PgAdminUrlUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.devonfw.tools.ide.tool.pgadmin; | ||
|
||
import com.devonfw.tools.ide.os.OperatingSystem; | ||
import com.devonfw.tools.ide.url.model.folder.UrlVersion; | ||
import com.devonfw.tools.ide.url.updater.WebsiteUrlUpdater; | ||
import com.devonfw.tools.ide.version.VersionIdentifier; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* {@link WebsiteUrlUpdater} for pgadmin. | ||
*/ | ||
public class PgAdminUrlUpdater extends WebsiteUrlUpdater { | ||
|
||
@Override | ||
protected String getTool() { | ||
|
||
return "pgadmin"; | ||
} | ||
|
||
@Override | ||
protected String getVersionUrl() { | ||
|
||
return "https://www.postgresql.org/ftp/pgadmin/pgadmin4/"; | ||
} | ||
|
||
@Override | ||
protected Pattern getVersionPattern() { | ||
|
||
return Pattern.compile("v(\\d{1,2}+\\.\\d+)"); | ||
} | ||
|
||
@Override | ||
protected String getVersionPrefixToRemove() { | ||
|
||
return "v"; | ||
} | ||
|
||
@Override | ||
protected void addVersion(UrlVersion urlVersion) { | ||
|
||
VersionIdentifier vid = urlVersion.getVersionIdentifier(); | ||
|
||
String baseUrl = "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/"; | ||
doAddVersion(urlVersion, baseUrl + "v${version}/windows/pgadmin4-${version}-x64.exe", OperatingSystem.WINDOWS); | ||
|
||
if (vid.compareVersion(VersionIdentifier.of("7.6")).isGreater()) { | ||
doAddVersion(urlVersion, baseUrl + "v${version}/macos/pgadmin4-${version}-arm64.dmg", MAC, ARM64); | ||
doAddVersion(urlVersion, baseUrl + "v${version}/macos/pgadmin4-${version}-x86_64.dmg", MAC, X64); | ||
} else { | ||
doAddVersion(urlVersion, baseUrl + "v${version}/macos/pgadmin4-${version}.dmg", MAC); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters