diff --git a/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java index 17fed0c8..56fff3ce 100644 --- a/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/QuinoaProcessor.java @@ -226,7 +226,8 @@ public void runtimeInit( @BuildStep(onlyIf = IsDevelopment.class) List hotDeploymentWatchedFiles(QuinoaConfig quinoaConfig, OutputTargetBuildItem outputTarget) { - final List watchedFiles = new ArrayList<>(PackageManagerType.values().length); + final List watchedFiles = new ArrayList<>( + PackageManagerType.values().length); final ProjectDirs projectDirs = resolveProjectDirs(quinoaConfig, outputTarget); if (projectDirs == null) { // UI dir is misconfigured so just skip watching files @@ -263,7 +264,8 @@ private QuinoaDirectoryBuildItem initDefaultConfig(PackageManager packageManager buildDirectory = detectedFramework.getBuildDirectory(); LOG.infof("%s framework setting build directory: '%s'", framework, buildDirectory); } - return new QuinoaDirectoryBuildItem(packageManager, detectedFramework.getDevServerCommand(), port, buildDirectory); + return new QuinoaDirectoryBuildItem(packageManager, detectedFramework.getDevServerCommand(), port, + buildDirectory); } private HashSet prepareBuiltResources( @@ -277,7 +279,8 @@ private HashSet prepareBuiltResources( for (Path file : files) { final String name = "/" + targetDir.relativize(file).toString().replace('\\', '/'); LOG.infof("Quinoa generated resource: '%s'", name); - generatedResources.produce(new GeneratedResourceBuildItem(META_INF_WEB_UI + name, Files.readAllBytes(file), true)); + generatedResources + .produce(new GeneratedResourceBuildItem(META_INF_WEB_UI + name, Files.readAllBytes(file), true)); if (nativeImageResources != null) { nativeImageResources .produce(new NativeImageResourceBuildItem(META_INF_WEB_UI + name)); @@ -337,9 +340,9 @@ static Path findProjectRoot(Path outputDirectory) { } if (currentPath.getParent() != null && Files.exists(currentPath.getParent())) { currentPath = currentPath.getParent(); - } else { - return null; } + return null; + } while (true); } diff --git a/deployment/src/main/java/io/quarkiverse/quinoa/deployment/packagemanager/PackageManager.java b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/packagemanager/PackageManager.java index 71c27f22..64ce6653 100644 --- a/deployment/src/main/java/io/quarkiverse/quinoa/deployment/packagemanager/PackageManager.java +++ b/deployment/src/main/java/io/quarkiverse/quinoa/deployment/packagemanager/PackageManager.java @@ -50,7 +50,8 @@ public void install(boolean frozenLockfile) { LOG.infof("Running Quinoa package manager install command: %s", install.commandWithArguments); if (!exec(install)) { throw new RuntimeException( - format("Error in Quinoa while running package manager install command: %s", install.commandWithArguments)); + format("Error in Quinoa while running package manager install command: %s", + install.commandWithArguments)); } } @@ -59,7 +60,8 @@ public void build(LaunchMode mode) { LOG.infof("Running Quinoa package manager build command: %s", build.commandWithArguments); if (!exec(build)) { throw new RuntimeException( - format("Error in Quinoa while running package manager build command: %s", build.commandWithArguments)); + format("Error in Quinoa while running package manager build command: %s", + build.commandWithArguments)); } } @@ -68,7 +70,8 @@ public void test() { LOG.infof("Running Quinoa package manager test command: %s", test.commandWithArguments); if (!exec(test)) { throw new RuntimeException( - format("Error in Quinoa while running package manager test command: %s", test.commandWithArguments)); + format("Error in Quinoa while running package manager test command: %s", + test.commandWithArguments)); } } @@ -114,7 +117,8 @@ private static void killDescendants(ProcessHandle process, boolean force) { }); } - public DevServer dev(String devServerCommand, String devServerHost, int devServerPort, String checkPath, int checkTimeout) { + public DevServer dev(String devServerCommand, String devServerHost, int devServerPort, String checkPath, + int checkTimeout) { final Command dev = packageManagerCommands.dev(devServerCommand); LOG.infof("Running Quinoa package manager live coding as a dev service: %s", dev.commandWithArguments); Process p = process(dev); @@ -228,9 +232,8 @@ private boolean exec(Command command) { private String[] runner(Command command) { if (isWindows()) { return new String[] { "cmd.exe", "/c", command.commandWithArguments }; - } else { - return new String[] { "sh", "-c", command.commandWithArguments }; } + return new String[] { "sh", "-c", command.commandWithArguments }; } private static class HandleOutput implements Runnable { diff --git a/deployment/src/main/resources/dev-ui/qwc-quinoa-card.js b/deployment/src/main/resources/dev-ui/qwc-quinoa-card.js index 1fffcbab..d930a1d9 100644 --- a/deployment/src/main/resources/dev-ui/qwc-quinoa-card.js +++ b/deployment/src/main/resources/dev-ui/qwc-quinoa-card.js @@ -1,181 +1,191 @@ -import {LitElement, html, css} from 'lit'; -import {JsonRpc} from 'jsonrpc'; -import {notifier} from 'notifier'; -import {pages} from 'build-time-data'; -import '@vaadin/progress-bar'; -import '@vaadin/button'; -import 'qwc/qwc-extension-link.js'; +import { LitElement, html, css } from "lit"; +import { JsonRpc } from "jsonrpc"; +import { notifier } from "notifier"; +import { pages } from "build-time-data"; +import "@vaadin/progress-bar"; +import "@vaadin/button"; +import "qwc/qwc-extension-link.js"; const NAME = "Quinoa"; -const DESCRIPTION = "Quinoa serves single page applications or web components (built with NodeJS: React, Angular, Vue, Lit, …)"; +const DESCRIPTION = + "Quinoa serves single page applications or web components (built with NodeJS: React, Angular, Vue, Lit, …)"; export class QwcQuinoaCard extends LitElement { + jsonRpc = new JsonRpc(this); - jsonRpc = new JsonRpc(this); - - static styles = css` - .identity { - display: flex; - justify-content: flex-start; - } - - .description { - padding-bottom: 10px; - } - - .logo { - padding-bottom: 10px; - margin-right: 5px; - } - - .card-content { - color: var(--lumo-contrast-90pct); - display: flex; - flex-direction: column; - justify-content: flex-start; - padding: 2px 2px; - height: 100%; - } - - .card-content slot { - display: flex; - flex-flow: column wrap; - padding-top: 5px; - } - - .button { - cursor: pointer; - } - - .installIcon { - color: var(--lumo-primary-text-colo); - } - - .restartIcon { - color: var(--lumo-primary-text-colo); - } - `; - - static properties = { - description: {type: String}, - build_in_progress: {state: true, type: Boolean}, - build_complete: {state: true, type: Boolean}, - build_error: {state: true, type: Boolean}, - result: {type: String} - }; - - constructor() { - super(); + static styles = css` + .identity { + display: flex; + justify-content: flex-start; } - connectedCallback() { - super.connectedCallback(); - this.build_in_progress = false; - this.build_complete = false; - this.build_error = false; - this.result = ""; + .description { + padding-bottom: 10px; } - render() { - let progress; - if (this.build_in_progress) { - progress = html` -
-
Executing Node command...
- -
`; - } else if (this.build_complete) { - progress = html` -
-
${this.result}
- -
`; - } else { - progress = html` -
`; - } - - return html` -
-
- -
${DESCRIPTION}
-
- ${this._renderCardLinks()} - ${this._renderActions()} - ${progress} -
- `; + .logo { + padding-bottom: 10px; + margin-right: 5px; } - _renderActions() { - return html` - this._install()} class="button" - title="Run package manager 'install' command to update packages and restart the Node server"> - - Install/Update Packages - - `; + .card-content { + color: var(--lumo-contrast-90pct); + display: flex; + flex-direction: column; + justify-content: flex-start; + padding: 2px 2px; + height: 100%; } - _install() { - this.build_complete = false; - this.build_in_progress = true; - this.build_error = false; - this.result = ""; - this.jsonRpc.install() - .onNext(jsonRpcResponse => { - const msg = jsonRpcResponse.result; - if (msg === "started") { - this.build_complete = false; - this.build_in_progress = true; - this.build_error = false; - } else if (msg.includes("installed")) { - this.build_complete = true; - this.build_in_progress = false; - this.result = msg; - this._success('Packages updated or installed successfully.'); - } else { - this.build_complete = true; - this.build_in_progress = false; - this.build_error = true; - this._error(msg) - } - }); + .card-content slot { + display: flex; + flex-flow: column wrap; + padding-top: 5px; } - _success(message) { - notifier.showSuccessMessage(message, "top-center"); + .button { + cursor: pointer; } - _error(message) { - notifier.showErrorMessage(message, "top-stretch"); + .installIcon { + color: var(--lumo-primary-text-colo); } - _renderCardLinks() { - return html`${pages.map(page => html` - - - `)}`; + .restartIcon { + color: var(--lumo-primary-text-colo); + } + `; + + static properties = { + description: { type: String }, + build_in_progress: { state: true, type: Boolean }, + build_complete: { state: true, type: Boolean }, + build_error: { state: true, type: Boolean }, + result: { type: String }, + }; + + constructor() { + super(); + } + + connectedCallback() { + super.connectedCallback(); + this.build_in_progress = false; + this.build_complete = false; + this.build_error = false; + this.result = ""; + } + + render() { + let progress; + if (this.build_in_progress) { + progress = html`
+
Executing Node command...
+ +
`; + } else if (this.build_complete) { + progress = html`
+
${this.result}
+ +
`; + } else { + progress = html`
`; } + return html` +
+
+ +
${DESCRIPTION}
+
+ ${this._renderCardLinks()} ${this._renderActions()} ${progress} +
+ `; + } + + _renderActions() { + return html` + this._install()} + class="button" + title="Run package manager 'install' command to update packages and restart the Node server" + > + + Install/Update Packages + + `; + } + + _install() { + this.build_complete = false; + this.build_in_progress = true; + this.build_error = false; + this.result = ""; + this.jsonRpc.install().onNext((jsonRpcResponse) => { + const msg = jsonRpcResponse.result; + if (msg === "started") { + this.build_complete = false; + this.build_in_progress = true; + this.build_error = false; + } else if (msg.includes("installed")) { + this.build_complete = true; + this.build_in_progress = false; + this.result = msg; + this._success("Packages updated or installed successfully."); + } + this.build_complete = true; + this.build_in_progress = false; + this.build_error = true; + this._error(msg); + }); + } + + _success(message) { + notifier.showSuccessMessage(message, "top-center"); + } + + _error(message) { + notifier.showErrorMessage(message, "top-stretch"); + } + + _renderCardLinks() { + return html`${pages.map( + (page) => html` + + + ` + )}`; + } } -customElements.define('qwc-quinoa-card', QwcQuinoaCard); \ No newline at end of file +customElements.define("qwc-quinoa-card", QwcQuinoaCard); diff --git a/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaDevProxyHandler.java b/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaDevProxyHandler.java index c24b1827..99800d3b 100644 --- a/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaDevProxyHandler.java +++ b/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaDevProxyHandler.java @@ -36,7 +36,8 @@ class QuinoaDevProxyHandler implements Handler { private final ClassLoader currentClassLoader; private final QuinoaHandlerConfig config; - QuinoaDevProxyHandler(final QuinoaHandlerConfig config, final Vertx vertx, String host, int port, boolean websocket) { + QuinoaDevProxyHandler(final QuinoaHandlerConfig config, final Vertx vertx, String host, int port, + boolean websocket) { this.host = host; this.port = port; this.client = WebClient.create(vertx); @@ -85,7 +86,8 @@ private void handleHttpRequest(final RoutingContext ctx, final String resourcePa final String uri = computeResourceURI(resourcePath, request); // Workaround for issue https://github.com/quarkiverse/quarkus-quinoa/issues/91 - // See https://www.npmjs.com/package/connect-history-api-fallback#htmlacceptheaders + // See + // https://www.npmjs.com/package/connect-history-api-fallback#htmlacceptheaders // When no Accept header is provided, the historyApiFallback is disabled headers.remove("Accept"); // Disable compression in the forwarded request @@ -125,9 +127,9 @@ private void forwardError(AsyncResult> event, int statusCod final HttpServerResponse response = ctx.response().setStatusCode(statusCode); if (body != null) { response.send(body); - } else { - response.send(); } + response.send(); + } private void forwardResponse(AsyncResult> event, HttpServerRequest request, RoutingContext ctx, @@ -143,9 +145,8 @@ private void forwardResponse(AsyncResult> event, HttpServer final Buffer body = event.result().body(); if (body != null) { response.send(body); - } else { - response.send(); } + response.send(); } diff --git a/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaSPARoutingHandler.java b/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaSPARoutingHandler.java index 752c4afe..addb08c7 100644 --- a/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaSPARoutingHandler.java +++ b/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaSPARoutingHandler.java @@ -34,8 +34,7 @@ public void handle(RoutingContext ctx) { LOG.debugf("Quinoa is re-routing SPA request '%s' to '/'", ctx.normalizedPath()); } ctx.reroute(ctx.mountPoint() != null ? ctx.mountPoint() : "/"); - } else { - next(currentClassLoader, ctx); } + next(currentClassLoader, ctx); } }