This commit is contained in:
Joseph Garrone 2024-05-16 06:21:54 +02:00
parent d4f03b6b9e
commit 2ec22f07d5
2 changed files with 15 additions and 2 deletions

View File

@ -1,13 +1,14 @@
#!/usr/bin/env node #!/usr/bin/env node
import { termost } from "termost"; import { termost } from "termost";
import * as child_process from "child_process";
export type CliCommandOptions = { export type CliCommandOptions = {
isSilent: boolean; isSilent: boolean;
reactAppRootDirPath: string | undefined; reactAppRootDirPath: string | undefined;
}; };
const program = termost<CliCommandOptions>("keycloakify"); const program = termost<CliCommandOptions>("Keycloak theme builder");
program program
.option({ .option({
@ -77,7 +78,7 @@ program
"description": [ "description": [
"Copy Keycloak default theme resources to the public directory.", "Copy Keycloak default theme resources to the public directory.",
"This command is meant to be explicitly used in Webpack projects only." "This command is meant to be explicitly used in Webpack projects only."
].join("\n") ].join(" ")
}) })
.task({ .task({
"handler": async cliCommandOptions => { "handler": async cliCommandOptions => {
@ -85,3 +86,14 @@ program
return command({ cliCommandOptions }); return command({ cliCommandOptions });
} }
}); });
// Fallback to build command if no command is provided
{
const [, , ...rest] = process.argv;
if (rest.length === 0 || !rest[0].startsWith("-")) {
child_process.spawnSync("npx", ["keycloakify", "build", ...rest], {
"stdio": "inherit"
});
}
}

View File

@ -19,6 +19,7 @@ export type BuildOptions = {
artifactId: string; artifactId: string;
loginThemeResourcesFromKeycloakVersion: string; loginThemeResourcesFromKeycloakVersion: string;
reactAppRootDirPath: string; reactAppRootDirPath: string;
// TODO: Remove from vite type
reactAppBuildDirPath: string; reactAppBuildDirPath: string;
/** Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak */ /** Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak */
keycloakifyBuildDirPath: string; keycloakifyBuildDirPath: string;