(test) external asset mode by default

This commit is contained in:
Joseph Garrone
2021-03-22 20:54:28 +01:00
parent 1049e312f9
commit 24fccaf513
7 changed files with 141 additions and 54 deletions

View File

@ -6,11 +6,13 @@ import type { ParsedPackageJson } from "./generateJavaStackFiles";
import { join as pathJoin, relative as pathRelative, basename as pathBasename } from "path";
import * as child_process from "child_process";
import { generateDebugFiles, containerLaunchScriptBasename } from "./generateDebugFiles";
import { URL } from "url";
import { URL } from "url";
const reactProjectDirPath = process.cwd();
const isStandalone = process.argv[2]?.toLowerCase() === "--standalone";
const parsedPackageJson: ParsedPackageJson = require(pathJoin(reactProjectDirPath, "package.json"));
export const keycloakThemeBuildingDirPath = pathJoin(reactProjectDirPath, "build_keycloak");
@ -24,15 +26,50 @@ if (require.main === module) {
keycloakThemeBuildingDirPath,
"reactAppBuildDirPath": pathJoin(reactProjectDirPath, "build"),
"themeName": parsedPackageJson.name,
"urlPathname": (()=>{
"mode": (() => {
const { homepage } = parsedPackageJson;
return homepage === undefined ?
"/" :
new URL(homepage).pathname.replace(/([^/])$/, "$1/");
const url = (() => {
const { homepage } = parsedPackageJson;
return homepage === undefined ?
undefined :
new URL(homepage);
})();
const urlPathname =
url === undefined ?
"/" :
url.pathname.replace(/([^/])$/, "$1/");
return isStandalone ?
{
"type": "standalone",
urlPathname
} as const
:
{
"type": "static fetched from app",
urlPathname,
"urlOrigin": (() => {
if (url === undefined) {
console.error("ERROR: You must specify 'homepage' in your package.json");
process.exit(-1);
}
return url.origin;
})()
} as const;
})()
});
const { jarFilePath } = generateJavaStackFiles({