From c5ef4c973b6147b854756d6665e8cfad5f274938 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Thu, 5 Sep 2024 01:19:50 +0200 Subject: [PATCH] #598 --- src/bin/keycloakify/keycloakify.ts | 57 +++++++++++++++++++----------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/src/bin/keycloakify/keycloakify.ts b/src/bin/keycloakify/keycloakify.ts index 548a9e67..b39dcad8 100644 --- a/src/bin/keycloakify/keycloakify.ts +++ b/src/bin/keycloakify/keycloakify.ts @@ -12,6 +12,10 @@ import * as os from "os"; import { rmSync } from "../tools/fs.rmSync"; export async function command(params: { cliCommandOptions: CliCommandOptions }) { + const { cliCommandOptions } = params; + + const buildContext = getBuildContext({ cliCommandOptions }); + exit_if_maven_not_installed: { let commandOutput: Buffer | undefined = undefined; @@ -25,31 +29,44 @@ export async function command(params: { cliCommandOptions: CliCommandOptions }) break exit_if_maven_not_installed; } - const installationCommand = (() => { - switch (os.platform()) { - case "darwin": - return "brew install mvn"; - case "win32": - return "choco install mvn"; - case "linux": - default: - return "sudo apt-get install mvn"; - } - })(); + if ( + fs + .readFileSync(buildContext.packageJsonFilePath) + .toString("utf8") + .includes(`"mvn"`) + ) { + console.log( + chalk.red( + [ + "Please remove the 'mvn' package from your package.json'dependencies list,", + "reinstall your dependencies and try again.", + "We need the Apache Maven CLI, not this: https://www.npmjs.com/package/mvn" + ].join(" ") + ) + ); + } else { + const installationCommand = (() => { + switch (os.platform()) { + case "darwin": + return "brew install mvn"; + case "win32": + return "choco install mvn"; + case "linux": + default: + return "sudo apt-get install mvn"; + } + })(); - console.log( - `${chalk.red("Apache Maven required.")} Install it with \`${chalk.bold( - installationCommand - )}\` (for example)` - ); + console.log( + `${chalk.red("Apache Maven required.")} Install it with \`${chalk.bold( + installationCommand + )}\` (for example)` + ); + } process.exit(1); } - const { cliCommandOptions } = params; - - const buildContext = getBuildContext({ cliCommandOptions }); - console.log( [ chalk.cyan(`keycloakify v${readThisNpmPackageVersion()}`),