Coder Social home page Coder Social logo

quarkiverse / quarkus-quinoa Goto Github PK

View Code? Open in Web Editor NEW
75.0 9.0 34.0 8.01 MB

Quinoa is a Quarkus extension which eases the development, the build and serving of single page apps (built with NodeJS: React, Angular, …) alongside Quarkus . It is possible to use it with a Quarkus backend in a single project

License: Apache License 2.0

Java 78.25% JavaScript 4.49% TypeScript 2.22% HTML 9.23% SCSS 0.03% CSS 1.38% Vue 4.40%
quarkus-extension angular frontend quarkus react vue web

quarkus-quinoa's Introduction

Quarkus Quinoa


Build Issues Maven Central License Project Map

All Contributors

Quinoa is a Quarkus extension which eases the development, the build and serving of single page apps or web components (built with npm : React, Angular, Vue, Lit, Svelte, Astro, SolidJS …) alongside Quarkus. It is possible to use it with a Quarkus backend in a single project.

You will be able to do live coding of the backend and frontend together nearly out of the box. In Quarkus dev mode, Quinoa will start the node live coding server provided by the target framework and forward relevant requests to it.

Versioning

There are multiple versions available please check which one for your Quarkus release version.

Version Explanation
1.x Quarkus 2 (legacy)
2.2.x Quarkus 3.2 LTS
2.3.x Quarkus 3.8 LTS
latest Quarkus 3.12

Getting started

Read the full Quinoa documentation.

Prerequisite

  • Create or use an existing Quarkus application
  • Add the Quinoa extension
  • Install NodeJS or make sure Quinoa is configured to install it.

Installation

Create a new Quinoa project (with a base Quinoa starter code):

quarkus create app quinoa-app -x=io.quarkiverse.quinoa:quarkus-quinoa

Then start the live-coding:

quarkus dev

And navigate to http://0.0.0.0:8080/quinoa.html

You could also just add the extension (but you won't get the starter code):

quarkus ext add io.quarkiverse.quinoa:quarkus-quinoa

🧑‍💻 Contributing

  • Contribution is the best way to support and get involved in community!
  • Please, consult our Code of Conduct policies for interacting in our community.
  • Contributions to quarkus-quinoa Please check our CONTRIBUTING.md

If you have any idea or question 🤷

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Andy Damevin
Andy Damevin

💻 🚧
Melloware
Melloware

💻 🚧
Phillip Krüger
Phillip Krüger

💻
Radim Vansa
Radim Vansa

💻
Blanc Frederic
Blanc Frederic

💻
andyhan
andyhan

💻
Marvin Bredal Lillehaug
Marvin Bredal Lillehaug

💻
John O'Hara
John O'Hara

💻
Holly Cummins
Holly Cummins

📖
Shivam Sharma
Shivam Sharma

🚇 📖 🔣
Ivan Milosavljević
Ivan Milosavljević

📖
Alex Karezin
Alex Karezin

📖
Thomas Sapelza
Thomas Sapelza

🐛
Steffen Van
Steffen Van

📖
Paul Dubs
Paul Dubs

📖
Andrei Hava
Andrei Hava

🐛
l2c0r3
l2c0r3

🐛
stevenfuhr
stevenfuhr

🐛
Leon Kirschner
Leon Kirschner

📖
mbouhda
mbouhda

🐛
mschorsch
mschorsch

🐛
Yann Le Moigne
Yann Le Moigne

💻
Alice
Alice

💻 🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

quarkus-quinoa's People

Contributors

actions-user avatar alexkarezin avatar allcontributors[bot] avatar andyhan avatar bentito avatar dependabot[bot] avatar ebullient avatar fasuke85 avatar fblan avatar gastaldi avatar holly-cummins avatar ia3andy avatar liquidnya avatar lukewoodcock avatar melloware avatar phillip-kruger avatar rvansa avatar shivam-sharma7 avatar steffenvan avatar stevenfuhr avatar stuartwdouglas avatar thejavaguy avatar treo avatar trpouh avatar ylemoigne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quarkus-quinoa's Issues

SPA-Routing not working with Quarkus 2.11.0.CR1

I updated my Quarkus-App to 2.11.0.CR1. The frontend is correctly served at the intended path but also at the paths of my Rest-API.
With Quarkus 2.10.2.Final everything works fine.

My quinoa config in application-properties:

quarkus.quinoa.ui-dir=voting-tool-frontend/
quarkus.quinoa.build-dir=dist/
quarkus.quinoa.enable-spa-routing=true
quarkus.quinoa.package-manager=npm.cmd

I use Vue 3 for my frontend.

My Rest-API should be reachable under /api as defined at my Application class.

@ApplicationPath("api")
@Blocking
class JaxRsApplication : Application() {
}

Add support for pnpm install

Now that we have support for NodeJS and NPM install, adding pnpm should be a piece of cake:

quarkus.quinoa.package-manager-install=true
quarkus.quinoa.package-manager-install.node-version=16.17.0
quarkus.quinoa.package-manager-install.pnpm-version=7.12.0

Default download root: https://registry.npmjs.org/pnpm/-/

Support dev mode with HTTPS

Quinoa should check on quarkus.http.insecure-requests and when it's disabled it should go straight to the SSL port, when it's redirect it should follow the redirects. Right now it does not appear to be working.

Quarkus Angular - Port 4200 Live Coding is not Listening

Here are my configurations and the stack trace below. If I run ng build, that works fine. I can even run ng serve in my webui directory and angular starts that way as well. Does anyone know a solution for the check timeout?

Thanks

Quarkus: 2.14.3
Angular 14.0.0
JDK 11

APPLICATION.PROPERTIES
quarkus.quinoa.build-dir=dist/webui
quarkus.quinoa.enable-spa-routing=true
quarkus.quinoa.dev-server.port=4200

PACKAGE.JSON
"start": "ng serve --host 0.0.0.0 --no-live-reload",

MacBook-Air:dfmea jeffrogers$ quarkus dev
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.mfmea:dfmea >---------------------------
[INFO] Building dfmea 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:2.14.3.Final:dev (default-cli) @ dfmea ---
[INFO] Invoking org.apache.maven.plugins:maven-resources-plugin:2.6:resources @ dfmea
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] Invoking io.quarkus.platform:quarkus-maven-plugin:2.14.3.Final:generate-code @ dfmea
[INFO] Invoking org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile @ dfmea
[INFO] Nothing to compile - all classes are up to date
[INFO] Invoking org.apache.maven.plugins:maven-resources-plugin:2.6:testResources @ dfmea
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jeffrogers/JavaWorkspace/Github/dfmea/src/test/resources
[INFO] Invoking io.quarkus.platform:quarkus-maven-plugin:2.14.3.Final:generate-code-tests @ dfmea
[INFO] Invoking org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile @ dfmea
[INFO] No sources to compile
Listening for transport dt_socket at address: 5005
2023-01-04 19:07:38,274 INFO [io.qua.qui.dep.pac.PackageManager] (build-10) Running Quinoa package manager live coding as a dev service: npm start

[email protected] start
ng serve --host 0.0.0.0

Warning: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disable-host-check" if that's the
case.

  • Generating browser application bundles (phase: setup)...
    2023-01-04 19:08:15,925 INFO [io.qua.qui.dep.pac.PackageManager] (build-10) Stopping Quinoa package manager live coding as a dev service.
    2023-01-04 19:08:16,066 INFO [io.qua.dep.dev.IsolatedDevModeMain] (main) Attempting to start live reload endpoint to recover from previous Quarkus startup failure
    2023-01-04 19:08:16,971 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkiverse.quinoa.deployment.ForwardedDevProcessor#prepareDevService threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Quinoa package manager live coding port 4200 is still not listening after the checkTimeout.
    at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:144)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at java.base/java.lang.Thread.run(Thread.java:829)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
    Caused by: java.lang.RuntimeException: Quinoa package manager live coding port 4200 is still not listening after the checkTimeout.
    at io.quarkiverse.quinoa.deployment.packagemanager.PackageManager.dev(PackageManager.java:113)
    at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:122)
    ... 11 more

    at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:335)
    at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:252)
    at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:60)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:86)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:447)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:59)
    at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:149)
    at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:104)
    at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:131)
    at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
    Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkiverse.quinoa.deployment.ForwardedDevProcessor#prepareDevService threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Quinoa package manager live coding port 4200 is still not listening after the checkTimeout.
    at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:144)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at java.base/java.lang.Thread.run(Thread.java:829)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
    Caused by: java.lang.RuntimeException: Quinoa package manager live coding port 4200 is still not listening after the checkTimeout.
    at io.quarkiverse.quinoa.deployment.packagemanager.PackageManager.dev(PackageManager.java:113)
    at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:122)
    ... 11 more

    at io.quarkus.builder.Execution.run(Execution.java:123)
    at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
    at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
    at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:331)
    ... 9 more
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Quinoa package manager live coding port 4200 is still not listening after the checkTimeout.
    at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:144)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
    at java.base/java.lang.Thread.run(Thread.java:829)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
    Caused by: java.lang.RuntimeException: Quinoa package manager live coding port 4200 is still not listening after the checkTimeout.
    at io.quarkiverse.quinoa.deployment.packagemanager.PackageManager.dev(PackageManager.java:113)
    at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:122)
    ... 11 more

Remove the need to manually install NodeJS to build the Quarkus project

It would be nice to have DevServices kick in, pull NodeJS and build the project, when a local Node JS is not installed. Some back-end developers don't have NodeJS/NPM installed locally, so when you clone a repo with Quinoa, you don't have to go through the installation process: a simple mvn quarkus:dev would build and run the entire thing.

Quinoa used to maven build my Angular / Java app, now it cannot recognize npm

Hi ,

I'm doing a mvn clean install. It seems (after starting quarkus) to execute the following from my package.json. I'm a new Angular developer, so perhaps I'm doing something wrong here.

{
  "name": "MyApp",
  "version": "1.0.0",
  "private": true,
  "description": "",
  "scripts": {
    "build": "npm run clean:dist && ng lint && ng build --base-href=. --configuration production",
    "clean:dist": "npm run rimraf -- dist",
    "server": "ng serve",
    "e2e": "tsc && concurrently \"http-server\" \"protractor protractor.config.js\"",
    "lint": "ng lint",
    "rimraf": "rimraf",
    "test": "ng test -- --no-watch --no-progress --browsers=ChromeHeadlessCI",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "start": "ng serve --host 0.0.0.0 --disable-host-check --no-live-reload "
  },

However, it fails now. Quinoa fails to find the npm it just installed.

[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] Running Quinoa package manager build command: node.exe C:\Users\derksenjpam\Development\source\uitgifteloket\uitgifteloket-v2\.quinoa\node\node_modules\npm\bin\npm-cli.js run build
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] 
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] > [email protected] build
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] > npm run clean:dist ; ng lint ; ng build --base-href=. --configuration production
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] 
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] 'npm' is not recognized as an internal or external command,
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] operable program or batch file.

Application.properties:

quarkus.quinoa.package-manager-install=true
quarkus.quinoa.package-manager-install.node-version=18.14.2
quarkus.quinoa.build-dir=dist
quarkus.quinoa.dev-server.port=4200
quarkus.quinoa.dev-server.check-timeout=120000

Quarkus version: 2.14.2.Final
Quinoa version: 1.2.3

CORS Issue with Create React App

Quinoa: 1.2.3
Quarkus: 2.15.2.Final

I following your instructions and I have my Create React App working when I run mvn quarkus:dev.

The app is served at http://localhost:8080 and the React app can hits its REST services at 8080.

However when I switch to the live coding port 3000 http://localhost:3000 the React app renders but I get CORS errors hitting localhost:8080.

My HTTP is configured correctly and my CORS setting is true.

# HTTP
quarkus.http.port=8080
quarkus.http.enable-compression=true
quarkus.http.cors=true
quarkus.http.filter.others.header.Cache-Control=no-cache
quarkus.http.filter.others.matches=/.*
quarkus.http.filter.others.methods=GET
quarkus.http.filter.others.order=0
quarkus.http.filter.static.header."Cache-Control"=public, immutable, max-age=31536000
quarkus.http.filter.static.matches=/static/.+
quarkus.http.filter.static.methods=GET,HEAD
quarkus.http.filter.static.order=1
# Quinoa
quarkus.quinoa.package-manager-install=true
quarkus.quinoa.package-manager-install.node-version=16.17.0
quarkus.quinoa.dev-server.port=3000
quarkus.quinoa.enable-spa-routing=true

However whenever using the Live Coding port 3000 it cannot access the services at localhost:8080 with CORS error. "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/entity/cars/manufacturers. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200."

image

image

I did not see anything in your guides about anything special that needs to be done for CORS to work properly?

relative path mismatch on Windows when running at fast-jar mode

quinoa extension version: 1.0.5
On Windows 11, first using pnpm create vite to create an empty front project, no matter vue or react, then modify the quarkus app's properties file according to quinoa docs, and then execute java -jar .\target\quarkus-app\quarkus-run.jar after mvn clean package -D skipTests to start the app, then visit http://localhost:8080, you will found that all the web resources startwith /assets/ are not found in the browser.

the content of target\quinoa-build is show as following:

|   favicon.ico
|   index.html
\---assets
        index.ac618489.js
        index.f0ced7b7.css
        logo.03d6d6da.png

when execute mvn package, the console will print

[INFO] [io.quarkiverse.quinoa.deployment.QuinoaProcessor] Quinoa generated resource: '/assets\index.ac618489.js'
[INFO] [io.quarkiverse.quinoa.deployment.QuinoaProcessor] Quinoa generated resource: '/assets\index.f0ced7b7.css'
[INFO] [io.quarkiverse.quinoa.deployment.QuinoaProcessor] Quinoa generated resource: '/assets\logo.03d6d6da.png'
[INFO] [io.quarkiverse.quinoa.deployment.QuinoaProcessor] Quinoa generated resource: '/favicon.ico'
[INFO] [io.quarkiverse.quinoa.deployment.QuinoaProcessor] Quinoa generated resource: '/index.html'
[INFO] [io.quarkus.deployment.QuarkusAugmentor] Quarkus augmentation completed in 11534ms

I do some investigation, and found that this issue is caused by the Path Separator difference between Windows ('\') and Unix ('/'), the browser always recognize the Unix style path separator not windows, but the Java NIO path's relativize() method will return the OS related relative path, which means on Windows it will always return a path contains '\' as the path separator not '/'. This will cause during runtime the route context path never matches the record in all the static generated build resource items.

I suggest to modify this line

final String name = "/" + targetDir.relativize(file);

final String name = "/" + targetDir.relativize(file).toString().replace('\\', '/');

It works on both Windows and Linux / MacOS.
@ia3andy

Unexpected deletion of served Folder

In Svelte "src/main/webui/public/" should be served. But only the build folder is regenerated "src/main/webui/public/build/"

In documentation it says it copies the content of "quarkus.quinoa.build-dir" but it is moving or deleting the folder

3 Possible solutions:

  • Mention deletion of served folder in documentation
  • different paths for deletion and serving
  • disable deletion of build folder

`src/main/ui` is ambigious

src/main/ui is quite ambigious folder name to use imo.

ui could also be a swing,jfx,etc ui. how about using src/main/webui or src/main/npm (as it must be a npm project anyway)

Vite compatibility - Forwarding to root

Have noticed a minor issue when using vitejs to bootstrap a project.

quinoa is not forwarding on to the vite server for calls to http://localhost:8080 (root) resulting in a Resource not Found message, however http://localhost:8080/index.html does resolve correctly, odd since vite server responds to http://localhost:3000 so unclear why the app is not forwarding to the dev server for root.

http://localhost:8080 -> Resource not found
http://localhost:8080/index.html -> ok
http://localhost:3000 -> ok

When the app is built it all works perfectly, just the dev mode has the issue.

When testing against the default quinoa quickstart, quinoa does indeed work as expected forwarding the request to the dev-server so http://localhost:8080 responds with the Theater app.

Have included a simple reproducer https://github.com/adamhenderson/quinoa-vite-reproducer

Guide to production usage of Quinoa

In the official documentation, a schema shows how the interactions between the browser, vert.x, quinoa works in a production environment.

However, I cant find a document anywhere explaining how to set this up.

When packaging my app, the quinoa folder gets created inside of target but nothing gets included within my jar file.

Is this something that will come still ? Or is it already available but not documented ?

PS: i know I could use the frontend plugin or other techniques for this but Id rather just use Quinoa

Angular "ng serve" is not answering on http://localhost:4200 from Java

This is referenced there: angular/angular-cli#2375

For some obscure reason, the workaround is to replace ng serve by ng serve --host 0.0.0.0 to make it work.

To reproduce, start ng serve then try this script with jbang:

///usr/bin/env jbang "$0" "$@" ; exit $?


import static java.lang.System.*;
import java.io.*;
import java.net.*;

public class MyTest {

    public static void main(String... args) {
         try {
            URL url = new URL("http://localhost:4200");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(2000);
            connection.setReadTimeout(2000);
            connection.connect();
            int code = connection.getResponseCode();
            System.out.println(code);

        } catch (ConnectException | SocketTimeoutException e) {
            e.printStackTrace();
        } catch (IOException e) {
            throw new RuntimeException("Error while checking if package manager dev server is up", e);
        }
    }
}

Using HttpFilter to redirect request (Undertow + Reasteasy) is not working as expected

When Quinoa webui generate an index.html, hitting /foo should serve the index.

import javax.enterprise.context.ApplicationScoped;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Pattern;
import java.util.stream.Stream;

/*
   Redirects unknown URLs to the default /index.html so that React can try and render them as part of browser Url History
 */
@WebFilter(urlPatterns = "/*", asyncSupported = true)
@ApplicationScoped
public class RouteFilter extends HttpFilter {
    private static final String[] PATH_PREFIXES = { "/api/", "/connect", "/dev" };
    private static final Pattern FILE_NAME_PATTERN = Pattern.compile(".*[.][a-zA-Z\\d]+");

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        chain.doFilter(request, response);

        if (response.getStatus() == 404 && !response.isCommitted()) {
            String path = request.getRequestURI().substring(
                    request.getContextPath().length()).replaceAll("[/]+$", "");
            if (Stream.of(PATH_PREFIXES).noneMatch(prefix -> path.startsWith(prefix)) && !FILE_NAME_PATTERN.matcher(path).matches()) {
                // We could not find the resource, i.e. it is not anything known to the server (i.e. it is not a REST
                // endpoint or a servlet), and does not look like a file so try handling it in the front-end routes.
                response.setStatus(200); //force response status when redirecting to /
                request.getRequestDispatcher("/").forward(request, response);
            }
        }
    }
}

More MPA/HDA friendliness needed

Hi. I've been continuing with the HDA-style approach using Quarkus (with Renarde), Quinoa and Htmx. My initial opinion is that Quinoa is quite SPA-centered and very hard to use for MPA or HDA apps.

This is going to be quite long, so here's a TL;DR: Quinoa could use an option for specifing requests that's it's allowed to redirect or the ignoring option could be regexp-based, otherwise it's unusable for developing MPA/HDA-style apps.

Long version:

After resolving the CSS purge issue with templates being outside Quinoas graps (#61) by a workaround (disable purge in dev mode), I've been hitting other road blocks, but let's get the context straight first.

When creating an MPA (classic multipage application) or an HDA (hypermedia-driven application, specifically with Htmx returning ready parts of the HTML), one often uses a configuration where back-end code handles templates (Qute in this case) and also has an additional side-pipeline for handling assets (JS, CSS, images, fonts, etc.) which is Node-based - mostly the aftermath of SPAs going mainstream and focusing all of the attention. This pipeline is almost always on this - a asset processing pipeline, not a fully-fledged UI app.

It's not really that exotic: Laravel has a whole module just for that (Mix), likewise Symfony (Encore). Quinoa on the other hand is mostly SPA-focused which bascially makes it imposible for using with a asset processing pipeline. My experiences with this so far were:

  • CSS purging problems due to templates being outside of the UI folder (#61 - worked around);
  • unable to utilize the Quinoas dev server, due to the fact of lacking a fine-grained configuration - this is a longer issue, which I'm going to go into detail below;
  • without the dev server, one is stuck with Quinoa running npm build all the time, which while being errorless, is very slow (imagine fine-tuning your UI code/CSS/whatever with small, rapid changes and being forced to wait a few seconds on every refresh - unusable in the long run).

Now, let's look at the dev server. It's a nice solution for an app that has all web resources (HTML, JS, CSS, other) on Quinoas side. Just redirect the requests to the UI dev server, ignore the REST API ones and done. This. This is very SPA-centric. It's basically unusable for a MPA-style development (hence HDA-style also, which is very similar, yet results in a hybrid SPA/MPA-like app).

A two problems here:

  1. Dev server requires, well, a UI dev server on the other side. For MPA/HDA it might not be the case. The whole process can be a simple pipeline for processing assets with a watcher triggering the build on change and outputing the resources in a target location. Quinoa goes either the "copy resources path" or "redirect requests path". Nothing in between, like: "watch the target dir and copy resources on change, because there's a second build pipeline building those assets".
  2. After working the first problem around by actually providing a simple web server for Quinoa to redirect to, there comes the second problem: no fine-grained request control. When the UI server is provided, Quinoa redirects the root request ("/") to the UI server. Not what one wants for the MPA/HDA, where the templates (and the root request) are being processed by the back-end. Of course there is an option for ignoring requests based on prefix, but try to use the root request ("/") here - you disable redirecting altogether. A simple regexp-based approach would solve the problem here. Either that or to provide options not only for ignoring requests, but for allowing also (e.g. allow prefixes like /images, /css, /fonts - for MPAs/HDAa you'll probably have only a few of those).

The above forces us to use the npm build style, which with constant full rebuilds (Webpack already takes around 4-5s at this point, and we're getting started), makes us thinking of dropping Quinoa in favor of hand-feeding src/main/resources/META-INF/resources by Webpack (which requires hand-crafted Gradle, Git and Webpack config and launching two dev mode tools separately). Resolving the second problem (by regexp or additional "allow requests" option) would make Quinoa fit for making MPA/HDA apps with only a bit of additional configuration.

Quinoa checks for "src/main" directory, even if not used

Greetings.

I am using quinoa + jib to produce docker images for a web project. The project itself is using Quarkus as thin wrapper to serve the files produced by the Quinoa processor, so the only "java-related" files in the project is a config/application.properties and a pom.xml.

The project is structured like a typical vite web project, which means that the project is not structured like a maven project, the web related files are in ${project.root}, not containing any main folder (like a typical maven project would).

My application.properties:

quarkus.quinoa.package-manager-install=true
quarkus.quinoa.package-manager-install.node-version=16.17.0
quarkus.quinoa.dev-server.port=5173
quarkus.quinoa.build-dir=dist
quarkus.quinoa.enable-spa-routing=true
quarkus.quinoa.ui-dir=.

When I run ./mvnw quarkus:dev, quarkus shows the following warning:

[WARNING] [io.quarkiverse.quinoa.deployment.QuinoaProcessor] Quinoa directory not found 'quarkus.quinoa.ui-dir=.'. It is recommended to remove the quarkus-quinoa extension if not used.

I found it strange at first, so I tried running the following command:
./mvnw quarkus:dev -Dquarkus.quinoa.ui-dir=$PWD

Which resulted to the same warning (but with the $PWD path resolved).

I debugged the building process by doing mvnDebug clean package -Dquarkus.quinoa.ui-dir=$PWD and found the following check being done:

Path toCheck = currentPath.resolve(Paths.get("src", "main"));

I them added a mock file in src/main/testfile and everything worked.

So wanted to point out if the src/main check is really necessary? Maintaining a mock file just as a workaround seems like a minor inconvenience and adds the possibility of accidentally breaking the build if someone removes it, so I think a mechanism to work around the findMainSourcesRoot check should be created.

Thanks in advance.

Backend api for POST,PUT,DELETE requests is not working


2022-06-01 13:53:21,675 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (vert.x-eventloop-thread-2) Request failed: java.lang.IllegalStateException: Response has already been written
	at io.vertx.core.http.impl.Http1xServerResponse.checkValid(Http1xServerResponse.java:675)
	at io.vertx.core.http.impl.Http1xServerResponse.exceptionHandler(Http1xServerResponse.java:294)
	at org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveOutputStream.<init>(ResteasyReactiveOutputStream.java:37)
	at org.jboss.resteasy.reactive.server.vertx.VertxResteasyReactiveRequestContext.createResponseOutputStream(VertxResteasyReactiveRequestContext.java:443)
	at org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext.getOrCreateOutputStream(ResteasyReactiveRequestContext.java:954)
	at io.quarkus.resteasy.reactive.jackson.runtime.serialisers.BasicServerJacksonMessageBodyWriter.writeResponse(BasicServerJacksonMessageBodyWriter.java:37)
	at org.jboss.resteasy.reactive.server.core.ServerSerialisers.invokeWriter(ServerSerialisers.java:214)
	at org.jboss.resteasy.reactive.server.core.ServerSerialisers.invokeWriter(ServerSerialisers.java:185)
	at org.jboss.resteasy.reactive.server.core.serialization.FixedEntityWriter.write(FixedEntityWriter.java:26)
	at org.jboss.resteasy.reactive.server.handlers.ResponseWriterHandler.handle(ResponseWriterHandler.java:33)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:114)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:141)
	at org.jboss.resteasy.reactive.server.vertx.VertxResteasyReactiveRequestContext$1$1.handle(VertxResteasyReactiveRequestContext.java:74)
	at org.jboss.resteasy.reactive.server.vertx.VertxResteasyReactiveRequestContext$1$1.handle(VertxResteasyReactiveRequestContext.java:71)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:63)
	at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:38)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:833)

Allow to define custom package manager commands

Discussed in #133

Originally posted by ia3andy July 4, 2022
This discussion has been initiated by @computerlove in #132.

I've been thinking into improving the customization of package manager commands in the long run (and not just "install").
I believe it would be nice to have something close to the script section in the package.json. e.g.:

quarkus:
  quinoa:
     package-manager-command:
       install-frozen: "npm ci --cache $CACHE_DIR/.npm --prefer-offline"
       // install: npm install (would still be the default)
       build-prod: "npm build-prod"
       build-dev: "npm build-dev"
       dev: "BROWSER=OFF npm dev" // default is "BROWSER=NONE npm start"

Instead of just the argument it would allow to edit the entire command (including envs) for one or more the available "actions". If not set if would keep the default (what we currently have).

To allow this, we might need to use something like commons.apache.org/proper/commons-exec and be careful about os compat.

Any thoughts?

In package-manager-install mode, npm install could fail as node is not added to the PATH when running

[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] Running Quinoa package manager install command: /workspace/source/node/node /workspace/source/node/node_modules/npm/bin/npm-cli.js install
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm notice 
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm notice New minor version of npm available! 8.15.0 -> 8.19.2
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.2>
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm notice Run `npm install -g [email protected]` to update!
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm notice 
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! code 127
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! path /workspace/source/src/main/webui/node_modules/esbuild
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! command failed
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! command sh /tmp/postinstall-fe388bfb.sh
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! /tmp/postinstall-fe388bfb.sh: line 1: node: command not found
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] 
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! A complete log of this run can be found in:
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR!     /root/.npm/_logs/2022-09-20T15_56_41_337Z-debug-0.log

This needs to be fixed by adding node to the PATH env.

Content Type Negotiation impossible

Hello,

I have the frontend and the backend running in the same Quarkus instance (of course) and the backend exposes an API for which content negotiation is necessary.

I noticed the following piece of code

final MultiMap headers = request.headers();
// Workaround for issue https://github.com/quarkiverse/quarkus-quinoa/issues/91
// See https://www.npmjs.com/package/connect-history-api-fallback#htmlacceptheaders
// When no Accept header is provided, the historyApiFallback is disabled
headers.remove("Accept");

This makes it impossible unfortunately for API clients to use content type negotiation using the Accept header in dev mode.
Can this be fixed somehow ?

I guess if we can find a way to compare the dev server port config with the actual request port, it should be feasible.

I tried to find my way in the code and write a PR but so far I didn't find a solution to retrieve the actual request port from the context.

Consider delegating to `npm run test` during maven test phases

I got caught out recently because I'd been relying on my CI to tell me if I broke tests. I was accustomed to everything happening via maven in my Quinoa project, so I didn't have any steps in my CI to run npm run test.

Should the maven test-running steps invoke npm testing steps? This would be be handy in some ways, but there are also arguments against it, similar to the arguments in #59. Among other things, it would slow builds down. If people didn't expect Quinoa to run their tests, they might end up running tests twice. (Locally, this would almost certainly happen to me, because I have one terminal open in Webstorm with my npm tests, and another window where I'm running quarkus dev in a Java IDE.)

Opening this issue to track the discussion and the decision. :)

Quinoa does not find node or yarn executable on Windows

Quinoa fail on windows complaining that it cannot find node or yarn executable (even if they are in path)
It can be reproduced with the starter code and maven or gradle.

I double check that the path is visible to java and contains yarn folder. The only thing I saw is that the env name on windows is lowercased ("Path"). I'm not sure how the ProcessBuilder resolve the binary path but it might be related to that.

<====2022-05-31 22:58:28,018 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkiverse.quinoa.deployment.ForwardedDevProcessor#prepareDevService threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Input/Output error while running process.
        at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:140)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:925)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.RuntimeException: Input/Output error while running process.
        at io.quarkiverse.quinoa.deployment.PackageManager.process(PackageManager.java:170)
        at io.quarkiverse.quinoa.deployment.PackageManager.dev(PackageManager.java:102)
        at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:120)
        ... 11 more
Caused by: java.io.IOException: Cannot run program "yarn" (in directory "C:\Users\loich\workspace\Projets\handyman\main-partition\..\webui"): CreateProcess error=2, Le fichier sp?cifi? est introuvable
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at io.quarkus.deployment.util.ProcessUtil.launchProcess(ProcessUtil.java:38)
        at io.quarkiverse.quinoa.deployment.PackageManager.process(PackageManager.java:168)
        ... 13 more
Caused by: java.io.IOException: CreateProcess error=2, Le fichier sp?cifi? est introuvable
        at java.base/java.lang.ProcessImpl.create(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:494)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
        ... 16 more

        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:330)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:252)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:60)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.firstStart(IsolatedDevModeMain.java:95)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:485)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.accept(IsolatedDevModeMain.java:68)
        at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:142)
        at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:97)
        at io.quarkus.deployment.dev.DevModeMain.start(DevModeMain.java:132)
        at io.quarkus.deployment.dev.DevModeMain.main(DevModeMain.java:62)
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkiverse.quinoa.deployment.ForwardedDevProcessor#prepareDevService threw an exception: java.lang.RuntimeException: java.lang.RuntimeException: Input/Output error while running process.
        at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:140)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:925)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.RuntimeException: Input/Output error while running process.
        at io.quarkiverse.quinoa.deployment.PackageManager.process(PackageManager.java:170)
        at io.quarkiverse.quinoa.deployment.PackageManager.dev(PackageManager.java:102)
        at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:120)
        ... 11 more
Caused by: java.io.IOException: Cannot run program "yarn" (in directory "C:\Users\loich\workspace\Projets\handyman\main-partition\..\webui"): CreateProcess error=2, Le fichier sp?cifi? est introuvable
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at io.quarkus.deployment.util.ProcessUtil.launchProcess(ProcessUtil.java:38)
        at io.quarkiverse.quinoa.deployment.PackageManager.process(PackageManager.java:168)
        ... 13 more
Caused by: java.io.IOException: CreateProcess error=2, Le fichier sp?cifi? est introuvable
        at java.base/java.lang.ProcessImpl.create(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:494)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
        ... 16 more

        at io.quarkus.builder.Execution.run(Execution.java:116)
        at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:157)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:328)
        ... 9 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Input/Output error while running process.
        at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:140)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:925)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at java.base/java.lang.Thread.run(Thread.java:833)
        at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Caused by: java.lang.RuntimeException: Input/Output error while running process.
        at io.quarkiverse.quinoa.deployment.PackageManager.process(PackageManager.java:170)
        at io.quarkiverse.quinoa.deployment.PackageManager.dev(PackageManager.java:102)
        at io.quarkiverse.quinoa.deployment.ForwardedDevProcessor.prepareDevService(ForwardedDevProcessor.java:120)
        ... 11 more
Caused by: java.io.IOException: Cannot run program "yarn" (in directory "C:\Users\loich\workspace\Projets\handyman\main-partition\..\webui"): CreateProcess error=2, Le fichier sp?cifi? est introuvable
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
        at io.quarkus.deployment.util.ProcessUtil.launchProcess(ProcessUtil.java:38)
        at io.quarkiverse.quinoa.deployment.PackageManager.process(PackageManager.java:168)
        ... 13 more
Caused by: java.io.IOException: CreateProcess error=2, Le fichier sp?cifi? est introuvable
        at java.base/java.lang.ProcessImpl.create(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:494)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)

guide requires quinoa already installed

"
Prerequisite

Install NodeJS (https://nodejs.org/)

Get a Quarkus application with Quinoa extension installed

"

should it not just be required to have a quarkus project with i.e. rest or similar installed and then guide explains how to add Quinoa ?

Support for remote-dev mode

Deploying in remote dev mode, with packaging set to mutable jar ,
doesn't serve the web ui application. It appears the quinoa-build is not included in the packaged application

Also the container logs seem log about not being able to find the Quinoa directory

Press [h] for more options>
2022-07-26 22:28:26,185 WARN  [io.qua.qui.dep.QuinoaProcessor] (build-23) Quinoa directory not found 'quarkus.quinoa.ui-dir=src/main/webui'. It is recommended to remove the quarkus-quinoa extension if not used.
2022-07-26 22:28:26,440 WARN  [io.qua.kub.dep.KubernetesProcessor] (build-41) No project was detected, skipping generation of kubernetes manifests!
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-07-26 22:28:28,178 INFO  [io.quarkus] (Quarkus Main Thread) webconsole 1.0 on JVM (powered by Quarkus 2.10.2.Final) started in 4.151s. Listening on: http://0.0.0.0:8080
2022-07-26 22:28:28,180 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2022-07-26 22:28:28,181 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, kubernetes, quinoa, resteasy-reactive, smallrye-context-propagation, vertx]

Quinoa PackageManager not working on own Gitlab Ci/Cd

I am trying to use Gitlab runner to build a Quarkus/Quinoa app.
The setup is Java 11 with Maven and the frontend uses Angular 14.1.1

Running the Quarkus server in dev mode works really nice, as well as running mvnw verify locally.
The issue only exits on the GitLab runner.

Project structure

myApp 
│
└───frontend
│   │
│   └───myApp
│   
└───src
     │
     └───main
     │  
     └───test

Pipeline Step

run-test:
  stage: test
  image: myOwnQuinoaImage:latest
  script:
    - ./mvnw verify

myOwnQuinoaImage:latest

FROM alpine:3.15.5

RUN apk add openjdk11
RUN apk add maven
RUN apk add nodejs
RUN apk add npm

pom.xml

...    
<dependency>
  <groupId>io.quarkiverse.quinoa</groupId>
  <artifactId>quarkus-quinoa</artifactId>
  <version>1.1.2</version>
</dependency>
...

application.properties

quarkus.quinoa.ui-dir=./frontend/myApp
quarkus.quinoa.build-dir=dist/myApp
quarkus.quinoa.enable-spa-routing=true
quarkus.quinoa.force-install=true
...

Exception log taken from the pipeline

[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! code E401
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! Incorrect or missing password.
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! If you were trying to login, change your password, create an
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! authentication token or enable two-factor authentication then
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! that means you likely typed your password in incorrectly.
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! Please try again, or recover your password at:
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR!     https://www.npmjs.com/forgot
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! 
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! If you were doing some other operation then your saved credentials are
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! probably out of date. To correct this please try logging in again with:
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR!     npm login
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] 
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR! A complete log of this run can be found in:
[INFO] [io.quarkiverse.quinoa.deployment.packagemanager.PackageManager] npm ERR!     /root/.npm/_logs/2022-08-09T09_39_19_934Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:19 min
[INFO] Finished at: 2022-08-09T09:39:20Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.10.2.Final:build (default) on project myProject: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] 	[error]: Build step io.quarkiverse.quinoa.deployment.QuinoaProcessor#prepareQuinoaDirectory threw an exception: java.lang.RuntimeException: Error in Quinoa while running package manager install command: npm install
[ERROR] 	at io.quarkiverse.quinoa.deployment.packagemanager.PackageManager.install(PackageManager.java:44)
[ERROR] 	at io.quarkiverse.quinoa.deployment.QuinoaProcessor.prepareQuinoaDirectory(QuinoaProcessor.java:100)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] 	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:944)
[ERROR] 	at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR] 	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR] 	at java.base/java.lang.Thread.run(Thread.java:829)
[ERROR] 	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Quinoa built resources not available in native build

The logs say the file is found, but a 404 is returned.

~/D/quinoa-bowl> docker run -i --rm -p 8080:8080 quinoa-bowl                                                                                                  main-!(origin/main)
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-04-21 07:08:09,910 INFO  [io.quarkus] (main) quinoa-bowl 1.0.0-SNAPSHOT native (powered by Quarkus 2.8.1.Final) started in 0.018s. Listening on: http://0.0.0.0:8080
2022-04-21 07:08:09,910 INFO  [io.quarkus] (main) Profile prod activated.
2022-04-21 07:08:09,910 INFO  [io.quarkus] (main) Installed features: [cdi, quinoa, resteasy-reactive, smallrye-context-propagation, vertx]
2022-04-21 07:08:12,793 INFO  [io.qua.qui.QuinoaUIResourceHandler] (vert.x-eventloop-thread-0) Quinoa is serving: '/'
2022-04-21 07:08:14,015 INFO  [io.qua.qui.QuinoaUIResourceHandler] (vert.x-eventloop-thread-0) Quinoa is serving: '/'
2022-04-21 07:08:14,262 INFO  [io.qua.qui.QuinoaUIResourceHandler] (vert.x-eventloop-thread-0) Quinoa is serving: '/'
2022-04-21 07:08:14,482 INFO  [io.qua.qui.QuinoaUIResourceHandler] (vert.x-eventloop-thread-0) Quinoa is serving: '/'
2022-04-21 07:08:14,685 INFO  [io.qua.qui.QuinoaUIResourceHandler] (vert.x-eventloop-thread-0) Quinoa is serving: '/'
2022-04-21 07:08:22,842 INFO  [io.qua.qui.QuinoaUIResourceHandler] (vert.x-eventloop-thread-0) Quinoa is serving: '/index.html'

Find a sustainable solution for dev server with non configurable historyApiFallback

Currently, it is not possible to configure historyApiFallback on:

  • react-scripts start (from RCA).
  • ng dev
  • vite dev

Since Quinoa is relying on having a 404 when a file is not found, this is a problem.

For some reason, the library used by those servers for SPA routing is disabled when the Accept header is not provided (See https://www.npmjs.com/package/connect-history-api-fallback#htmlacceptheaders).

As a workaround, when making the request from Quinoa using the Vert.x Http Client, the Accept header is not set. With this the dev server honors 404:
https://github.com/quarkiverse/quarkus-quinoa/blob/main/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaDevProxyHandler.java#L63

The best solution would be to have an environment to disable historyApiFallback but I've seen many issues asking for it without any resolution yet.

Quinoa dev server forwards to ipv6 loopback address, instead of ipv4

Hello!

I'm trying to embedd a vite vue frontend into my quarkus app. I've followed the steps here: https://quarkiverse.github.io/quarkiverse-docs/quarkus-quinoa/dev/#vite

While runing quarkus dev it starts up without issues. But when attempting to reach localhost:8080, I get this issue where Quinoa attempts to forward requests to the ipv6 loopback address, instead of ipv4:

$ quarkus dev
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< <redacted>:<redacted>>------------------------
[INFO] Building <redacted>1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- quarkus-maven-plugin:2.16.4.Final:dev (default-cli) @ <redacted>---
[INFO] Invoking org.apache.maven.plugins:maven-resources-plugin:2.6:resources @ <redacted>
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Invoking io.quarkus.platform:quarkus-maven-plugin:2.16.4.Final:generate-code @ <redacted>
[INFO] Invoking org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile @ <redacted>
[INFO] Nothing to compile - all classes are up to date
[INFO] Invoking org.apache.maven.plugins:maven-resources-plugin:2.6:testResources @ <redacted>
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/imago/Projects/<redacted>/src/test/resources
[INFO] Invoking io.quarkus.platform:quarkus-maven-plugin:2.16.4.Final:generate-code-tests @ <redacted>
[INFO] Invoking org.apache.maven.plugins:maven-compiler-plugin:3.10.1:testCompile @ <redacted>
[INFO] Nothing to compile - all classes are up to date
Listening for transport dt_socket at address: 5005
2023-03-08 06:52:16,892 INFO  [com.git.eir.mav.plu.fro.lib.NodeInstaller] (build-10) Node v16.17.0 is already installed.
2023-03-08 06:52:18,601 INFO  [io.qua.qui.dep.ForwardedDevProcessor] (build-8) Quinoa package manager live coding is up and running on port: 5173 (in 1575ms)
2023-03-08 06:52:18,604 INFO  [io.qua.qui.dep.ForwardedDevProcessor] (build-13) Quinoa is forwarding unhandled requests to port: 5173
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2023-03-08 06:52:19,128 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.quinoa.dev-server.host" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo <- Here I "guessed" how I maybe could target the host
2023-03-08 06:52:19,449 INFO  [io.quarkus] (Quarkus Main Thread) <redacted>1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.16.4.Final) started in 3.298s. Listening on: http://0.0.0.0:8080
2023-03-08 06:52:19,450 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2023-03-08 06:52:19,450 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, quinoa, resteasy-reactive, smallrye-context-propagation, vertx]
2023-03-08 06:52:29,068 ERROR [io.qua.qui.QuinoaDevProxyHandler] (vert.x-eventloop-thread-2) Quinoa failed to forward request, see logs.: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /[0:0:0:0:0:0:0:1]:5173
Caused by: java.net.ConnectException: Connection refused
        at java.base/sun.nio.ch.Net.pollConnect(Native Method)
        at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
        at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
        at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)

My vue app is reachable on 127.0.0.1:5173

$ curl "http://localhost:5173"   
<!DOCTYPE html>
<html lang="en">
  <head>
    <script type="module" src="/@vite/client"></script>

    <meta charset="UTF-8">
    <link rel="icon" href="/favicon.ico">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vite App</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>
  </body>
</html

But it's not reachable on [::1]:5173

$ curl -6 "http://[::1]:5173"
curl: (7) Failed to connect to ::1 port 5173: Connection refused

So an alternative is to figure out how to make npm host ipv6 servers, but that's somewhat useless as this npm server only will be used for local debugging. I'd prefer if I could make Quinoa target the ipv4 address, or force it to enter "ipv4-mode" somehow. Is this possible?

Current environment is:

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
...
$ java --version
openjdk 17.0.6 2023-01-17
OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)
OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)
$ quarkus version
2.16.4.Final

Many thanks,

Imago

Support for container image build

Container image for quinoaA app build using the quarkus-container-image-jib extension, fails to start
just running the application from the target directory runs fine ,

but when a container images is build from the Quinoa app project using the jib extension, the container logs throws exception/error:

The DelayedHandler was closed before any children handlers were configured. Messages will be written to stderr.
--
Tue, Jul 26 2022 6:37:40 pm | 2022-07-26 22:37:40,541 DEBUG [org.jboss.logging] (main) Logging Provider: org.jboss.logging.JBossLogManagerProvider
Tue, Jul 26 2022 6:37:40 pm |  
Tue, Jul 26 2022 6:37:40 pm | Exception in thread "main" java.nio.file.NoSuchFileException: /home/jboss/lib/deployment/deployment-class-path.dat
Tue, Jul 26 2022 6:37:40 pm | at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
Tue, Jul 26 2022 6:37:40 pm | at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
Tue, Jul 26 2022 6:37:40 pm | at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
Tue, Jul 26 2022 6:37:40 pm | at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
Tue, Jul 26 2022 6:37:40 pm | at java.base/java.nio.file.Files.newByteChannel(Files.java:371)
Tue, Jul 26 2022 6:37:40 pm | at java.base/java.nio.file.Files.newByteChannel(Files.java:422)
Tue, Jul 26 2022 6:37:40 pm | at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
Tue, Jul 26 2022 6:37:40 pm | at java.base/java.nio.file.Files.newInputStream(Files.java:156)
Tue, Jul 26 2022 6:37:40 pm | at io.quarkus.bootstrap.runner.DevModeMediator.doStart(DevModeMediator.java:39)
Tue, Jul 26 2022 6:37:40 pm | at io.quarkus.bootstrap.runner.DevModeMediator.doDevMode(DevModeMediator.java:29)
Tue, Jul 26 2022 6:37:40 pm | at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:45)
Tue, Jul 26 2022 6:37:40 pm | at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:31)

Routing does not work with RestEasy Classic

Hi,
I have generated a starter-project with Quinoa (v 1.0.3) and Resteasy Classic (2.9.2.Final), when i go to /quinoa.html I get an 404-error. If I only use Quinoa in the project it works as expected.

Option for specifying additional watch locations

Hi. I'm using Quarkus nad Quinoa to create a HDA (hypermedia-driven application) using Htmx-proposed approach (TL;DR - I return parts of HTML code instead of JSON, which Htmx uses to update the page). Quarkus has a nice templating solution (Qute) and now Quinoa is a cherry on top. :) The approach uses Quarkus+Qute for generating HTML and Quinoa+Webpack for generating other assets (images, fonts, CSS, etc.).

One point in the workflow is PurgeCSS, which removes any unnecessary CSS that is not present in the templates. The setup works quite well, until I update any of the templates. Quarkus will detect the change, but Quinoa won't, because the templates are in a seperate directory (src/main/resources/templates for Qute vs src/main/webui for Quinoa).

It would be nice to specify additional watch locations in Quinoa's configuration, to have a little more power over when the UI build is triggered. It could be a list of globs, regular expressions or a simple directory list.

The current workaround is to restart the Quarkus dev mode, triggering Quinoa in the process, which is not that bad at this point (a few seconds), but will probably grow in the future.

Quinoa re-routes to "/", but should route to `quarkus.http.root-path`

Actual behavior

The QuinoaSPARoutingHandler re-routes requests to "/". The application shows error "Resource not found".

See: https://github.com/quarkiverse/quarkus-quinoa/blob/main/runtime/src/main/java/io/quarkiverse/quinoa/QuinoaSPARoutingHandler.java#L36

Expected behavior

If the application uses quarkus.http.root-path=/some-base-path, Quinoa should re-route requests to "/some-base-path".

Using quarkus.http.root-path helps hosting multiple applications under the same domain.

Handle websocket in dev-mode or document that it is not forwarded (HMR)

Some NodeJS dev-server don't allow to set the websocket port for for hot reload. Currently those websocket connection are not forwarded by Quinoa.

Some other dev-server like Vite allow to change the HMR port, then http is sent and forwarded by Quinoa and HMR is sent to the frontend dev-server (which works great).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.