Make new node based bundler the default
This commit is contained in:
@ -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": (() => {
|
||||||
|
@ -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,22 +53,26 @@ export async function main() {
|
|||||||
buildOptions
|
buildOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
if (buildOptions.bundler === "none") {
|
switch (buildOptions.bundler) {
|
||||||
logger.log("😱 Skipping bundling step, there will be no jar");
|
case "none":
|
||||||
} else if (buildOptions.bundler === "keycloakify") {
|
logger.log("😱 Skipping bundling step, there will be no jar");
|
||||||
logger.log("🫶 Let keycloakify do its thang");
|
break;
|
||||||
await jar({
|
case "keycloakify":
|
||||||
"rootPath": keycloakThemeBuildingDirPath,
|
logger.log("🫶 Let keycloakify do its thang");
|
||||||
"version": buildOptions.version,
|
await jar({
|
||||||
"groupId": buildOptions.groupId,
|
"rootPath": keycloakThemeBuildingDirPath,
|
||||||
"artifactId": buildOptions.artifactId || `${buildOptions.themeName}-keycloak-theme`,
|
"version": buildOptions.version,
|
||||||
"targetPath": jarFilePath
|
"groupId": buildOptions.groupId,
|
||||||
});
|
"artifactId": buildOptions.artifactId || `${buildOptions.themeName}-keycloak-theme`,
|
||||||
} else {
|
"targetPath": jarFilePath
|
||||||
logger.log("🫙 Run maven to deliver a jar");
|
});
|
||||||
child_process.execSync("mvn package", {
|
break;
|
||||||
"cwd": keycloakThemeBuildingDirPath
|
case "mvn":
|
||||||
});
|
logger.log("🫙 Run maven to deliver a jar");
|
||||||
|
child_process.execSync("mvn package", { "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
|
||||||
|
Reference in New Issue
Block a user