Skip to content

Commit

Permalink
Merge branch 'main' into 707-farm
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jul 2, 2024
2 parents 27c4db5 + 41ddbe2 commit 32f0b8c
Show file tree
Hide file tree
Showing 30 changed files with 716 additions and 189 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,16 @@
"contributions": [
"code"
]
},
{
"login": "liquidnya",
"name": "Alice",
"avatar_url": "https://avatars.githubusercontent.com/u/7364785?v=4",
"profile": "http://meow.liquidnya.art",
"contributions": [
"code",
"ideas"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .github/project.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
release:
current-version: 2.3.8
current-version: 2.4.0
next-version: 999-SNAPSHOT

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![Project Map](https://sourcespy.com/shield.svg)](https://sourcespy.com/github/quarkiversequarkusquinoa/)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-22-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-23-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Quinoa is a Quarkus extension which eases the development, the build and serving of single page apps or web components (built with [npm](https://docs.npmjs.com/) : [React](https://react.dev/learn), [Angular](https://angular.io/guide/what-is-angular), [Vue](https://vuejs.org/guide/introduction.html), [Lit](https://lit.dev/), [Svelte](https://svelte.dev/docs/introduction), [Astro](https://docs.astro.build/en/getting-started/), [SolidJS](https://www.solidjs.com/guides/getting-started) …) alongside [Quarkus](https://quarkus.io/). It is possible to use it with a Quarkus backend in a single project.
Expand All @@ -27,7 +27,8 @@ There are multiple versions available please check which one for your Quarkus re
| --- | --- |
| ![1.x](https://img.shields.io/maven-central/v/io.quarkiverse.quinoa/quarkus-quinoa?versionPrefix=1.&color=cyan) | Quarkus 2 (legacy) |
| ![2.2.x](https://img.shields.io/maven-central/v/io.quarkiverse.quinoa/quarkus-quinoa?versionPrefix=2.2&color=cyan) | Quarkus 3.2 LTS |
| ![latest](https://img.shields.io/maven-central/v/io.quarkiverse.quinoa/quarkus-quinoa?&color=cyan) | Quarkus 3.8 LTS |
| ![2.3.x](https://img.shields.io/maven-central/v/io.quarkiverse.quinoa/quarkus-quinoa?versionPrefix=2.3&color=cyan) | Quarkus 3.8 LTS |
| ![latest](https://img.shields.io/maven-central/v/io.quarkiverse.quinoa/quarkus-quinoa?&color=cyan) | Quarkus 3.12 |

## Getting started

Expand Down Expand Up @@ -117,6 +118,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ylemoigne"><img src="https://avatars.githubusercontent.com/u/2000657?v=4?s=100" width="100px;" alt="Yann Le Moigne"/><br /><sub><b>Yann Le Moigne</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-quinoa/commits?author=ylemoigne" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://meow.liquidnya.art"><img src="https://avatars.githubusercontent.com/u/7364785?v=4?s=100" width="100px;" alt="Alice"/><br /><sub><b>Alice</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-quinoa/commits?author=liquidnya" title="Code">💻</a> <a href="#ideas-liquidnya" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.jboss.logging.Logger;

import io.quarkiverse.quinoa.QuinoaDevProxyHandlerConfig;
import io.quarkiverse.quinoa.QuinoaNetworkConfiguration;
import io.quarkiverse.quinoa.QuinoaRecorder;
import io.quarkiverse.quinoa.deployment.config.DevServerConfig;
import io.quarkiverse.quinoa.deployment.config.QuinoaConfig;
Expand All @@ -42,14 +43,15 @@
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
import io.quarkus.deployment.builditem.DevServicesResultBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.LiveReloadBuildItem;
import io.quarkus.deployment.console.ConsoleInstalledBuildItem;
import io.quarkus.deployment.logging.LoggingSetupBuildItem;
import io.quarkus.dev.console.QuarkusConsole;
import io.quarkus.resteasy.reactive.server.spi.ResumeOn404BuildItem;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.quarkus.vertx.core.deployment.CoreVertxBuildItem;
import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.deployment.WebsocketSubProtocolsBuildItem;
import io.quarkus.vertx.http.runtime.HttpBuildTimeConfig;
Expand All @@ -62,7 +64,6 @@ public class ForwardedDevProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
public ForwardedDevServerBuildItem prepareDevService(
LaunchModeBuildItem launchMode,
ConfiguredQuinoaBuildItem configuredQuinoa,
InstalledPackageManagerBuildItem installedPackageManager,
QuinoaConfig userConfig,
Expand All @@ -78,9 +79,8 @@ public ForwardedDevServerBuildItem prepareDevService(
final QuinoaConfig resolvedConfig = configuredQuinoa.resolvedConfig();
final DevServerConfig devServerConfig = resolvedConfig.devServer();
liveReload.setContextObject(QuinoaConfig.class, resolvedConfig);
final String configuredDevServerHost = devServerConfig.host();
final boolean configuredTls = devServerConfig.tls();
final boolean configuredTlsAllowInsecure = devServerConfig.tlsAllowInsecure();
final QuinoaNetworkConfiguration networkConfiguration = new QuinoaNetworkConfiguration(devServerConfig.tls(),
devServerConfig.tlsAllowInsecure(), devServerConfig.host(), devServerConfig.port().orElse(0), false);
final PackageManagerRunner packageManagerRunner = installedPackageManager.getPackageManager();
final String checkPath = resolvedConfig.devServer().checkPath().orElse(null);
if (devService != null) {
Expand All @@ -94,13 +94,11 @@ public ForwardedDevServerBuildItem prepareDevService(
}
LOG.debug("Quinoa config did not change; no need to restart.");
devServices.produce(devService.toBuildItem());
final String resolvedDevServerHost = PackageManagerRunner.isDevServerUp(devServerConfig.tls(),
devServerConfig.tlsAllowInsecure(),
devServerConfig.host(),
devServerConfig.port().get(),
checkPath);
return new ForwardedDevServerBuildItem(devServerConfig.tls(), devServerConfig.tlsAllowInsecure(),
resolvedDevServerHost, devServerConfig.port().get());
networkConfiguration.setHost(devServerConfig.host());
networkConfiguration.setPort(devServerConfig.port().get());
final String resolvedDevServerHost = PackageManagerRunner.isDevServerUp(networkConfiguration, checkPath);
networkConfiguration.setHost(resolvedDevServerHost);
return new ForwardedDevServerBuildItem(networkConfiguration);
}
shutdownDevService();
}
Expand All @@ -119,14 +117,15 @@ public ForwardedDevServerBuildItem prepareDevService(
return null;
}
final Integer port = devServerConfig.port().get();
networkConfiguration.setPort(port);

if (!devServerConfig.managed()) {
// No need to start the dev-service it is not managed by Quinoa
// We just check that it is up
final String resolvedHostIPAddress = PackageManagerRunner.isDevServerUp(configuredTls, configuredTlsAllowInsecure,
configuredDevServerHost, port, checkPath);
final String resolvedHostIPAddress = PackageManagerRunner.isDevServerUp(networkConfiguration, checkPath);
if (resolvedHostIPAddress != null) {
return new ForwardedDevServerBuildItem(configuredTls, configuredTlsAllowInsecure, resolvedHostIPAddress, port);
networkConfiguration.setHost(resolvedHostIPAddress);
return new ForwardedDevServerBuildItem(networkConfiguration);
} else {
throw new IllegalStateException(
"The Web UI dev server (configured as not managed by Quinoa) is not started on port: " + port);
Expand All @@ -141,11 +140,8 @@ public ForwardedDevServerBuildItem prepareDevService(
final AtomicReference<Process> dev = new AtomicReference<>();
PackageManagerRunner.DevServer devServer = null;
try {
devServer = packageManagerRunner.dev(consoleInstalled, loggingSetup, configuredTls, configuredTlsAllowInsecure,
configuredDevServerHost,
port,
checkPath,
checkTimeout);
devServer = packageManagerRunner.dev(consoleInstalled, loggingSetup, networkConfiguration,
checkPath, checkTimeout);
dev.set(devServer.process());
devServer.logCompressor().close();
final LiveCodingLogOutputFilter logOutputFilter = new LiveCodingLogOutputFilter(
Expand All @@ -162,7 +158,8 @@ public ForwardedDevServerBuildItem prepareDevService(
devService = new DevServicesResultBuildItem.RunningDevService(
DEV_SERVICE_NAME, null, onClose, devServerConfigMap);
devServices.produce(devService.toBuildItem());
return new ForwardedDevServerBuildItem(configuredTls, configuredTlsAllowInsecure, devServer.hostIPAddress(), port);
networkConfiguration.setHost(devServer.hostIPAddress());
return new ForwardedDevServerBuildItem(networkConfiguration);
} catch (Throwable t) {
packageManagerRunner.stopDev(dev.get());
if (devServer != null) {
Expand All @@ -176,7 +173,7 @@ private static Map<String, String> createDevServiceMapForDevUI(QuinoaConfig quin
Map<String, String> devServerConfigMap = new LinkedHashMap<>();
devServerConfigMap.put("quarkus.quinoa.dev-server.host", quinoaConfig.devServer().host());
devServerConfigMap.put("quarkus.quinoa.dev-server.port",
quinoaConfig.devServer().port().map(p -> p.toString()).orElse(""));
quinoaConfig.devServer().port().map(Object::toString).orElse(""));
devServerConfigMap.put("quarkus.quinoa.dev-server.check-timeout",
Integer.toString(quinoaConfig.devServer().checkTimeout()));
devServerConfigMap.put("quarkus.quinoa.dev-server.check-path", quinoaConfig.devServer().checkPath().orElse(""));
Expand All @@ -194,6 +191,8 @@ public void runtimeInit(
Optional<ForwardedDevServerBuildItem> devProxy,
Optional<ConfiguredQuinoaBuildItem> configuredQuinoa,
CoreVertxBuildItem vertx,
HttpRootPathBuildItem httpRootPath,
NonApplicationRootPathBuildItem nonApplicationRootPath,
BuildProducer<RouteBuildItem> routes,
BuildProducer<WebsocketSubProtocolsBuildItem> websocketSubProtocols,
BuildProducer<ResumeOn404BuildItem> resumeOn404) throws IOException {
Expand All @@ -205,19 +204,24 @@ public void runtimeInit(
return;
}
LOG.infof("Quinoa is forwarding unhandled requests to port: %d", devProxy.get().getPort());
final QuinoaDevProxyHandlerConfig handlerConfig = toDevProxyHandlerConfig(quinoaConfig, httpBuildTimeConfig);
routes.produce(RouteBuildItem.builder().orderedRoute("/*", QUINOA_ROUTE_ORDER)
.handler(recorder.quinoaProxyDevHandler(handlerConfig, vertx.getVertx(), devProxy.get().isTls(),
devProxy.get().isTlsAllowInsecure(), devProxy.get().getHost(),
devProxy.get().getPort(),
quinoaConfig.devServer().websocket()))
final QuinoaDevProxyHandlerConfig handlerConfig = toDevProxyHandlerConfig(quinoaConfig, httpBuildTimeConfig,
nonApplicationRootPath);
String uiRootPath = QuinoaConfig.getNormalizedUiRootPath(quinoaConfig);
recorder.logUiRootPath(httpRootPath.relativePath(uiRootPath));
final QuinoaNetworkConfiguration networkConfig = new QuinoaNetworkConfiguration(devProxy.get().isTls(),
devProxy.get().isTlsAllowInsecure(), devProxy.get().getHost(),
devProxy.get().getPort(),
quinoaConfig.devServer().websocket());
// note that the uiRootPath is resolved relative to 'quarkus.http.root-path' by the RouteBuildItem
routes.produce(RouteBuildItem.builder().orderedRoute(uiRootPath + "*", QUINOA_ROUTE_ORDER)
.handler(recorder.quinoaProxyDevHandler(handlerConfig, vertx.getVertx(), networkConfig))
.build());
if (quinoaConfig.devServer().websocket()) {
websocketSubProtocols.produce(new WebsocketSubProtocolsBuildItem("*"));
}
if (quinoaConfig.enableSPARouting()) {
resumeOn404.produce(new ResumeOn404BuildItem());
routes.produce(RouteBuildItem.builder().orderedRoute("/*", QUINOA_SPA_ROUTE_ORDER)
routes.produce(RouteBuildItem.builder().orderedRoute(uiRootPath + "*", QUINOA_SPA_ROUTE_ORDER)
.handler(recorder.quinoaSPARoutingHandler(handlerConfig.ignoredPathPrefixes))
.build());
}
Expand Down Expand Up @@ -300,4 +304,4 @@ public Thread newThread(Runnable r) {

}

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.quarkiverse.quinoa.deployment;

import static io.quarkiverse.quinoa.QuinoaRecorder.QUINOA_SPA_ROUTE_ORDER;
import static io.quarkiverse.quinoa.deployment.config.QuinoaConfig.*;
import static io.quarkiverse.quinoa.deployment.config.QuinoaConfig.getNormalizedIgnoredPathPrefixes;
import static io.quarkiverse.quinoa.deployment.config.QuinoaConfig.isDevServerMode;
import static io.quarkiverse.quinoa.deployment.config.QuinoaConfig.isEnabled;
import static io.quarkiverse.quinoa.deployment.framework.FrameworkType.overrideConfig;
import static io.quarkiverse.quinoa.deployment.packagemanager.PackageManagerRunner.autoDetectPackageManager;
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT;
Expand Down Expand Up @@ -48,6 +50,8 @@
import io.quarkus.deployment.util.FileUtil;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.quarkus.vertx.http.deployment.HttpRootPathBuildItem;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.deployment.spi.GeneratedStaticResourceBuildItem;

Expand Down Expand Up @@ -219,15 +223,19 @@ void watchChanges(
public void produceGeneratedStaticResources(
ConfiguredQuinoaBuildItem configuredQuinoa,
BuildProducer<GeneratedStaticResourceBuildItem> generatedStaticResourceProducer,
Optional<BuiltResourcesBuildItem> uiResources) throws IOException {
Optional<BuiltResourcesBuildItem> uiResources) {
if (configuredQuinoa != null && configuredQuinoa.resolvedConfig().justBuild()) {
LOG.info("Quinoa is in build only mode");
return;
}
if (uiResources.isPresent() && !uiResources.get().resources().isEmpty()) {
String uiRootPath = QuinoaConfig.getNormalizedUiRootPath(configuredQuinoa.resolvedConfig());
for (BuiltResourcesBuildItem.BuiltResource resource : uiResources.get().resources()) {
// note how uiRootPath always starts and ends in a slash
// and resource.name() always starts in a slash, therfore resource.name().substring(1) never starts in a slash
generatedStaticResourceProducer
.produce(new GeneratedStaticResourceBuildItem(resource.name(), resource.content()));
.produce(new GeneratedStaticResourceBuildItem(uiRootPath + resource.name().substring(1),
resource.content()));
}
}
}
Expand All @@ -236,17 +244,24 @@ public void produceGeneratedStaticResources(
@Record(RUNTIME_INIT)
public void runtimeInit(
ConfiguredQuinoaBuildItem configuredQuinoa,
HttpRootPathBuildItem httpRootPath,
NonApplicationRootPathBuildItem nonApplicationRootPath,
QuinoaRecorder recorder,
BuildProducer<RouteBuildItem> routes,
Optional<BuiltResourcesBuildItem> uiResources) throws IOException {
if (configuredQuinoa != null && configuredQuinoa.resolvedConfig().justBuild()) {
return;
}
if (uiResources.isPresent() && !uiResources.get().resources().isEmpty()) {
if (configuredQuinoa.resolvedConfig().enableSPARouting()) {
routes.produce(RouteBuildItem.builder().orderedRoute("/*", QUINOA_SPA_ROUTE_ORDER)
String uiRootPath = QuinoaConfig.getNormalizedUiRootPath(configuredQuinoa.resolvedConfig());
// the resolvedUiRootPath is only used for logging
String resolvedUiRootPath = httpRootPath.relativePath(uiRootPath);
recorder.logUiRootPath(resolvedUiRootPath.endsWith("/") ? resolvedUiRootPath : resolvedUiRootPath + "/");
if (Objects.requireNonNull(configuredQuinoa).resolvedConfig().enableSPARouting()) {
routes.produce(RouteBuildItem.builder().orderedRoute(uiRootPath + "*", QUINOA_SPA_ROUTE_ORDER)
.handler(recorder
.quinoaSPARoutingHandler(getNormalizedIgnoredPathPrefixes(configuredQuinoa.resolvedConfig())))
.quinoaSPARoutingHandler(getNormalizedIgnoredPathPrefixes(configuredQuinoa.resolvedConfig(),
nonApplicationRootPath)))
.build());
}
}
Expand Down Expand Up @@ -425,4 +440,4 @@ public Path getUIDir() {
}
}

}
}
Loading

0 comments on commit 32f0b8c

Please sign in to comment.