From 2ec22f07d534c603bb15d560e23d3f21fb4d676d Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Thu, 16 May 2024 06:21:54 +0200 Subject: [PATCH] Fallback to the build command https://github.com/adbayb/termost/issues/28 --- src/bin/main.ts | 16 ++++++++++++++-- src/bin/shared/buildOptions/buildOptions.ts | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/bin/main.ts b/src/bin/main.ts index 273e903f..fe720082 100644 --- a/src/bin/main.ts +++ b/src/bin/main.ts @@ -1,13 +1,14 @@ #!/usr/bin/env node import { termost } from "termost"; +import * as child_process from "child_process"; export type CliCommandOptions = { isSilent: boolean; reactAppRootDirPath: string | undefined; }; -const program = termost("keycloakify"); +const program = termost("Keycloak theme builder"); program .option({ @@ -77,7 +78,7 @@ program "description": [ "Copy Keycloak default theme resources to the public directory.", "This command is meant to be explicitly used in Webpack projects only." - ].join("\n") + ].join(" ") }) .task({ "handler": async cliCommandOptions => { @@ -85,3 +86,14 @@ program 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" + }); + } +} diff --git a/src/bin/shared/buildOptions/buildOptions.ts b/src/bin/shared/buildOptions/buildOptions.ts index f64e0b12..c3e59595 100644 --- a/src/bin/shared/buildOptions/buildOptions.ts +++ b/src/bin/shared/buildOptions/buildOptions.ts @@ -19,6 +19,7 @@ export type BuildOptions = { artifactId: string; loginThemeResourcesFromKeycloakVersion: string; reactAppRootDirPath: string; + // TODO: Remove from vite type reactAppBuildDirPath: string; /** Directory that keycloakify outputs to. Defaults to {cwd}/build_keycloak */ keycloakifyBuildDirPath: string;