Make new node based bundler the default

This commit is contained in:
garronej
2023-02-04 18:02:39 +01:00
parent ac05d529ca
commit 4e6a290693
2 changed files with 31 additions and 23 deletions

View File

@ -4,9 +4,10 @@ import type { Equals } from "tsafe";
import { id } from "tsafe/id"; import { id } from "tsafe/id";
import { parse as urlParse } from "url"; import { parse as urlParse } from "url";
import { typeGuard } from "tsafe/typeGuard"; import { typeGuard } from "tsafe/typeGuard";
import { symToStr } from "tsafe/symToStr";
const BUNDLERS = ["mvn", "keycloakify", "none"] as const; const bundlers = ["mvn", "keycloakify", "none"] as const;
type Bundler = typeof BUNDLERS[number]; type Bundler = typeof bundlers[number];
type ParsedPackageJson = { type ParsedPackageJson = {
name: string; name: string;
version: string; version: string;
@ -32,7 +33,7 @@ const zParsedPackageJson = z.object({
"areAppAndKeycloakServerSharingSameDomain": z.boolean().optional(), "areAppAndKeycloakServerSharingSameDomain": z.boolean().optional(),
"artifactId": z.string().optional(), "artifactId": z.string().optional(),
"groupId": z.string().optional(), "groupId": z.string().optional(),
"bundler": z.enum(BUNDLERS).optional() "bundler": z.enum(bundlers).optional()
}) })
.optional() .optional()
}); });
@ -51,7 +52,7 @@ export namespace BuildOptions {
extraThemeProperties?: string[]; extraThemeProperties?: string[];
groupId: string; groupId: string;
artifactId?: string; artifactId?: string;
bundler?: Bundler; bundler: Bundler;
}; };
export type Standalone = Common & { export type Standalone = Common & {
@ -133,11 +134,12 @@ export function readBuildOptions(params: {
assert( assert(
typeGuard<Bundler | undefined>( typeGuard<Bundler | undefined>(
KEYCLOAKIFY_BUNDLER, KEYCLOAKIFY_BUNDLER,
KEYCLOAKIFY_BUNDLER === undefined || id<readonly string[]>(BUNDLERS).includes(KEYCLOAKIFY_BUNDLER) [undefined, ...id<readonly string[]>(bundlers)].includes(KEYCLOAKIFY_BUNDLER)
) ),
`${symToStr({ KEYCLOAKIFY_BUNDLER })} should be one of ${bundlers.join(", ")}`
); );
return KEYCLOAKIFY_BUNDLER ?? bundler; return KEYCLOAKIFY_BUNDLER ?? bundler ?? "keycloakify";
})(), })(),
"artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId, "artifactId": process.env.KEYCLOAKIFY_ARTIFACT_ID ?? artifactId,
"groupId": (() => { "groupId": (() => {

View File

@ -8,6 +8,8 @@ import { readBuildOptions } from "./BuildOptions";
import { getLogger } from "../tools/logger"; import { getLogger } from "../tools/logger";
import { getCliOptions } from "../tools/cliOptions"; import { getCliOptions } from "../tools/cliOptions";
import jar from "../tools/jar"; import jar from "../tools/jar";
import { assert } from "tsafe/assert";
import type { Equals } from "tsafe";
const reactProjectDirPath = process.cwd(); const reactProjectDirPath = process.cwd();
@ -51,9 +53,11 @@ export async function main() {
buildOptions buildOptions
}); });
if (buildOptions.bundler === "none") { switch (buildOptions.bundler) {
case "none":
logger.log("😱 Skipping bundling step, there will be no jar"); logger.log("😱 Skipping bundling step, there will be no jar");
} else if (buildOptions.bundler === "keycloakify") { break;
case "keycloakify":
logger.log("🫶 Let keycloakify do its thang"); logger.log("🫶 Let keycloakify do its thang");
await jar({ await jar({
"rootPath": keycloakThemeBuildingDirPath, "rootPath": keycloakThemeBuildingDirPath,
@ -62,11 +66,13 @@ export async function main() {
"artifactId": buildOptions.artifactId || `${buildOptions.themeName}-keycloak-theme`, "artifactId": buildOptions.artifactId || `${buildOptions.themeName}-keycloak-theme`,
"targetPath": jarFilePath "targetPath": jarFilePath
}); });
} else { break;
case "mvn":
logger.log("🫙 Run maven to deliver a jar"); logger.log("🫙 Run maven to deliver a jar");
child_process.execSync("mvn package", { child_process.execSync("mvn package", { "cwd": keycloakThemeBuildingDirPath });
"cwd": keycloakThemeBuildingDirPath break;
}); default:
assert<Equals<typeof buildOptions.bundler, never>>(false);
} }
// We want, however, to test in a container running the latest Keycloak version // We want, however, to test in a container running the latest Keycloak version