Improved build script to allow for defining a custom domain for the webapp to use.

This commit is contained in:
Andrew Lalis 2022-05-31 00:47:11 +02:00
parent 2f7e3ec20c
commit f090e105dd
4 changed files with 36 additions and 16 deletions

View File

@ -11,33 +11,53 @@
module build_system;
import dsh;
import std.stdio;
import std.string;
const DIST = "./src/main/resources/app";
const DIST_ORIGIN = "./quasar-app/dist/spa";
const APP_BUILD = "quasar build -m spa";
const API_BUILD = "mvn clean package spring-boot:repackage -DskipTests=true";
void main(string[] args) {
print("Building RailSignalAPI");
string baseDomain = "localhost:8080";
bool useHttps = false;
if (args.length >= 2) {
baseDomain = args[1];
if (args.length >= 3 && args[2] == "secure") {
useHttps = true;
print("Will configure web app to use secure connections.");
}
}
string apiUrl = format!"%s://%s/api"(useHttps ? "https" : "http", baseDomain);
string wsUrl = format!"%s://%s/api/ws/app"(useHttps ? "wss" : "ws", baseDomain);
print("Building web app using API url %s and WS url %s", apiUrl, wsUrl);
sleepSeconds(3);
chdir("quasar-app");
print("Building app...");
setEnv("RAIL_SIGNAL_API_URL", apiUrl);
setEnv("RAIL_SIGNAL_WS_URL", wsUrl);
runOrQuit(APP_BUILD);
print("Copying dist from %s to %s", DIST_ORIGIN, DIST);
chdir("..");
removeIfExists(DIST);
mkdir(DIST);
copyDir(DIST_ORIGIN, DIST);
print("Building API...");
runOrQuit("mvn clean package spring-boot:repackage -DskipTests=true");
print("Build complete!");
if (args.length > 1 && args[1] == "run") {
string f = findFile("target", "^.+\\.jar$", false);
if (f == null) {
error("Could not find jar file!");
} else {
print("Running the program.");
run("java -jar " ~ f);
}
}
print("Building API...");
runOrQuit(API_BUILD);
print("Build complete!");
string jarFile = findFile(".", "\\.jar", false);
print("Generating run script...");
auto scriptFile = File("target/run.sh", "w");
scriptFile.write("#!/usr/bin/bash\n");
scriptFile.write("RAIL_SIGNAL_API_URL=http://localhost:8080/api\n");
scriptFile.write("RAIL_SIGNAL_WS_URL=ws://localhost:8080/api/ws/app\n");
scriptFile.write("java -jar " ~ jarFile ~ "\n");
scriptFile.close();
print("Script file generated.");
}

View File

@ -71,8 +71,8 @@ module.exports = configure(function (ctx) {
publicPath: "/app/",
// analyze: true,
env: {
API_URL: ctx.dev ? "http://localhost:8080/api" : "http://localhost:8080/api",
WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : "ws://localhost:8080/api/ws/app"
API_URL: ctx.dev ? "http://localhost:8080/api" : process.env.RAIL_SIGNAL_API_URL,
WS_URL: ctx.dev ? "ws://localhost:8080/api/ws/app" : process.env.RAIL_SIGNAL_WS_URL
},
// rawDefine: {}
// ignorePublicFolder: true,

View File

@ -1,2 +1,4 @@
export const API_URL = process.env.API_URL;
export const WS_URL = process.env.WS_URL;
console.log("Using API url: " + API_URL);
console.log("Using WS url: " + WS_URL);

View File

@ -99,8 +99,6 @@
dense
size="sm"
:label="node.name"
:color="component.activeConfiguration && component.activeConfiguration.id === config.id ? 'primary' : 'secondary'"
:text-color="'white'"
clickable
@click="select(node)"
/>