Skip to content

Commit

Permalink
LTS 3.15
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 5, 2024
1 parent fa365b0 commit 9d68a1e
Show file tree
Hide file tree
Showing 15 changed files with 14,042 additions and 9,908 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
public class PackageManagerInstallFactory {

private static final Platform defaultPlatform = Platform.guess();
private static final String DEFAULT_CACHE_PATH = "cache";
private final Vertx vertx;

private final Path uiDir;
private final Path installDir;
Expand All @@ -18,7 +16,6 @@ public class PackageManagerInstallFactory {
private final String password;

public PackageManagerInstallFactory(Vertx vertx, Path uiDir, Path installDir, String userName, String password) {
this.vertx = vertx;
this.uiDir = uiDir;
this.installDir = installDir;
this.cacheResolver = getDefaultCacheResolver(installDir);
Expand Down Expand Up @@ -63,8 +60,8 @@ private InstallConfig getInstallConfig() {
return new DefaultInstallConfig(installDir.toFile(), uiDir.toFile(), this.cacheResolver, defaultPlatform);
}

private static final CacheResolver getDefaultCacheResolver(Path root) {
private static CacheResolver getDefaultCacheResolver(Path root) {
return new DirectoryCacheResolver(root.resolve("cache").toFile());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public VertxFileDownloader(Vertx vertx) {
if (proxyUser != null && proxyPassword != null) {
options.getProxyOptions().setUsername(proxyUser).setPassword(proxyPassword);
}
LOG.tracef("Using Proxy %", options.getProxyOptions().toString());
}

this.webClient = WebClient.create(vertx, options);
Expand Down Expand Up @@ -90,7 +91,8 @@ public void download(String downloadUrl, String destination, String userName, St
.as(BodyCodec.pipe(destinationFile))
.send();
future.onComplete((r) -> latch.countDown());
latch.await(5, TimeUnit.MINUTES);
boolean result = latch.await(5, TimeUnit.MINUTES);
LOG.tracef("Latch Result %", result);
if (!future.succeeded()) {
throw new DownloadException("Could not download " + downloadUrl, future.cause());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public InstalledPackageManagerBuildItem install(
configuredQuinoa.uiDir(),
consoleInstalledBuildItem,
loggingSetupBuildItem);
packageManagerBinary = Optional.of(result.getPackageManagerBinary());
paths.add(result.getNodeDirPath());
packageManagerBinary = Optional.of(result.packageManagerBinary());
paths.add(result.nodeDirPath());
}

final PackageManagerRunner packageManagerRunner = autoDetectPackageManager(packageManagerBinary,
Expand Down Expand Up @@ -175,7 +175,7 @@ && isDevServerMode(configuredQuinoa.resolvedConfig())) {
&& liveReload.getChangedResources().stream()
.noneMatch(r -> r.startsWith(packageManagerRunner.getDirectory().toString()))
&& contextObject != null) {
return new TargetDirBuildItem(contextObject.getLocation());
return new TargetDirBuildItem(contextObject.location());
}
if (configuredQuinoa.resolvedConfig().runTests()) {
packageManagerRunner.test();
Expand Down Expand Up @@ -452,16 +452,7 @@ public static Path initializeTargetDirectory(OutputTargetBuildItem outputTarget)
return targetBuildDir;
}

private static class QuinoaLiveContext {
private final Path location;

private QuinoaLiveContext(Path location) {
this.location = location;
}

public Path getLocation() {
return location;
}
private record QuinoaLiveContext(Path location) {
}

public static class ProjectDirs {
Expand All @@ -482,4 +473,4 @@ public Path getUIDir() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,37 @@
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.*;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509ExtendedTrustManager;

public class SslUtil {
private final static X509ExtendedTrustManager NON_VALIDATING_TRUST_MANAGER = new X509ExtendedTrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) {
}

@Override
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException {
public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) {
}

@Override
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) {
}

@Override
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException {
public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) {
}

@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}

@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
public void checkServerTrusted(X509Certificate[] chain, String authType) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface DevServerConfig {

/**
* Port of the server to forward requests to.
* The dev server process (i.e npm start) is managed like a dev service by Quarkus.
* The dev server process (i.e. npm start) is managed like a dev service by Quarkus.
* If the external server responds with a 404, it is ignored by Quinoa and processed like any other backend request.
*/
@ConfigDocDefault("framework detection or fallback to empty")
Expand Down Expand Up @@ -138,4 +138,4 @@ static boolean isEqual(DevServerConfig d1, DevServerConfig d2) {
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public interface QuinoaConfig {
*/
@WithParentName
@ConfigDocDefault("enabled (disabled in test mode)")
public Optional<Boolean> enabled();
Optional<Boolean> enabled();

/**
* Indicate if Quinoa should just do the build part.
* If true, Quinoa will NOT serve the Web UI built resources.
* This is handy when the output of the build is used
* to be served via something else (nginx, cdn, ...)
* Quinoa put the built files in 'target/quinoa/build' (or 'build/quinoa/build with Gradle).
* Quinoa put the built files in 'target/quinoa/build' (or 'build/quinoa/build' with Gradle).
*/
@WithDefault("false")
boolean justBuild();
Expand All @@ -56,7 +56,7 @@ public interface QuinoaConfig {
String uiRootPath();

/**
* Path to the Web UI (NodeJS) root directory (relative to the project root).
* Path to the Web UI (Node.js) root directory (relative to the project root).
*/
@WithDefault(DEFAULT_WEB_UI_DIR)
String uiDir();
Expand Down Expand Up @@ -284,4 +284,4 @@ static boolean isEqual(QuinoaConfig q1, QuinoaConfig q2) {
return true;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,7 @@ private static FrameworkType resolveFramework(String script) {
return null;
}

static class DetectedFramework {
public final FrameworkType type;

public final String devScript;
public final boolean isCustomized;

public DetectedFramework(FrameworkType type, String devScript, boolean isCustomized) {
this.type = type;
this.devScript = devScript;
this.isCustomized = isCustomized;
}
record DetectedFramework(FrameworkType type, String devScript, boolean isCustomized) {

@Override
public boolean equals(Object o) {
Expand All @@ -197,11 +187,6 @@ public boolean equals(Object o) {
return isCustomized == that.isCustomized && type == that.type && Objects.equals(devScript, that.devScript);
}

@Override
public int hashCode() {
return Objects.hash(type, devScript, isCustomized);
}

@Override
public String toString() {
return new StringJoiner(", ", DetectedFramework.class.getSimpleName() + "[", "]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public NextFramework() {
public QuinoaConfig override(QuinoaConfig delegate, Optional<JsonObject> packageJson,
Optional<String> detectedDevScript,
boolean isCustomized) {
if (delegate.packageManagerCommand().build().equals("run build") && packageJson.isPresent()) {
if (delegate.packageManagerCommand().build().orElse("???").equals("run build") && packageJson.isPresent()) {
JsonObject scripts = packageJson.get().getJsonObject("scripts");
if (scripts != null) {
String buildScript = scripts.getString("build");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.UncheckedIOException;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

Expand Down Expand Up @@ -74,7 +75,7 @@ public static Installation install(PackageManagerInstallConfig config,
}
}
} finally {
vertx.close();
Objects.requireNonNull(vertx).close();
}

throw new RuntimeException("Error while installing NodeJS", thrown);
Expand Down Expand Up @@ -107,7 +108,7 @@ private static Installation attemptInstall(PackageManagerInstallConfig config, P
nodeInstallerLogCompressor = new StartupLogCompressor("node installer", consoleInstalledBuildItem,
loggingSetupBuildItem);
factory.getNodeInstaller()
.setNodeVersion("v" + config.nodeVersion().get())
.setNodeVersion("v" + config.nodeVersion().orElse("???"))
.setNodeDownloadRoot(config.nodeDownloadRoot())
.setNpmVersion(config.npmVersion())
.install();
Expand All @@ -122,7 +123,7 @@ private static Installation attemptInstall(PackageManagerInstallConfig config, P
}
}

// Use npm if npmVersion is different from provided or if no other version is set (then it will use the version provided by nodejs)
// Use npm if npmVersion is different from provided or if no other version is set (then it will use the version provided by Node.js)
String executionPath = NPM_PATH;
final String npmVersion = config.npmVersion();
boolean isNpmProvided = PackageManagerInstallConfig.NPM_PROVIDED.equalsIgnoreCase(npmVersion);
Expand All @@ -132,7 +133,7 @@ private static Installation attemptInstall(PackageManagerInstallConfig config, P
npmInstallerLogCompressor = new StartupLogCompressor("npm installer", consoleInstalledBuildItem,
loggingSetupBuildItem);
factory.getNPMInstaller()
.setNodeVersion("v" + config.nodeVersion().get())
.setNodeVersion("v" + config.nodeVersion().orElse("???"))
.setNpmVersion(npmVersion)
.setNpmDownloadRoot(config.npmDownloadRoot())
.install();
Expand All @@ -149,7 +150,7 @@ private static Installation attemptInstall(PackageManagerInstallConfig config, P
executionPath = YARN_PATH;
factory.getYarnInstaller()
.setIsYarnBerry(isYarnBerry(uiDir))
.setYarnVersion("v" + config.yarnVersion().get())
.setYarnVersion("v" + config.yarnVersion().orElse("???"))
.setYarnDownloadRoot(config.yarnDownloadRoot())
.setIsYarnBerry(true)
.install();
Expand All @@ -160,7 +161,7 @@ private static Installation attemptInstall(PackageManagerInstallConfig config, P
if (pnpmVersion.isPresent() && isNpmProvided && yarnVersion.isEmpty()) {
executionPath = PNPM_PATH;
factory.getPnpmInstaller()
.setNodeVersion("v" + config.nodeVersion().get())
.setNodeVersion("v" + config.nodeVersion().orElse("???"))
.setPnpmVersion(pnpmVersion.get())
.setPnpmDownloadRoot(config.pnpmDownloadRoot())
.install();
Expand Down Expand Up @@ -201,22 +202,7 @@ public static String quotePathWithSpaces(String path) {
return path.contains(" ") ? "\"".concat(path).concat("\"") : path;
}

public static class Installation {
private final String nodeDirPath;
private final String packageManagerBinary;

public Installation(String nodeDirPath, String packageManagerBinary) {
this.nodeDirPath = nodeDirPath;
this.packageManagerBinary = packageManagerBinary;
}

public String getNodeDirPath() {
return nodeDirPath;
}

public String getPackageManagerBinary() {
return packageManagerBinary;
}
public record Installation(String nodeDirPath, String packageManagerBinary) {
}

}
}
Loading

0 comments on commit 9d68a1e

Please sign in to comment.