This commit is contained in:
Joseph Garrone 2024-09-05 01:19:50 +02:00
parent dbae909903
commit c5ef4c973b

View File

@ -12,6 +12,10 @@ import * as os from "os";
import { rmSync } from "../tools/fs.rmSync"; import { rmSync } from "../tools/fs.rmSync";
export async function command(params: { cliCommandOptions: CliCommandOptions }) { export async function command(params: { cliCommandOptions: CliCommandOptions }) {
const { cliCommandOptions } = params;
const buildContext = getBuildContext({ cliCommandOptions });
exit_if_maven_not_installed: { exit_if_maven_not_installed: {
let commandOutput: Buffer | undefined = undefined; let commandOutput: Buffer | undefined = undefined;
@ -25,31 +29,44 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
break exit_if_maven_not_installed; break exit_if_maven_not_installed;
} }
const installationCommand = (() => { if (
switch (os.platform()) { fs
case "darwin": .readFileSync(buildContext.packageJsonFilePath)
return "brew install mvn"; .toString("utf8")
case "win32": .includes(`"mvn"`)
return "choco install mvn"; ) {
case "linux": console.log(
default: chalk.red(
return "sudo apt-get install mvn"; [
} "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( console.log(
`${chalk.red("Apache Maven required.")} Install it with \`${chalk.bold( `${chalk.red("Apache Maven required.")} Install it with \`${chalk.bold(
installationCommand installationCommand
)}\` (for example)` )}\` (for example)`
); );
}
process.exit(1); process.exit(1);
} }
const { cliCommandOptions } = params;
const buildContext = getBuildContext({ cliCommandOptions });
console.log( console.log(
[ [
chalk.cyan(`keycloakify v${readThisNpmPackageVersion()}`), chalk.cyan(`keycloakify v${readThisNpmPackageVersion()}`),