diff --git a/packages/cli/changelog/@unreleased/pr-70.v2.yml b/packages/cli/changelog/@unreleased/pr-70.v2.yml new file mode 100644 index 000000000..d11b42897 --- /dev/null +++ b/packages/cli/changelog/@unreleased/pr-70.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Log OSDK CLI version on start of CLI + links: + - https://github.com/palantir/osdk-ts/pull/70 diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 5702cfbc6..0062464ca 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -25,10 +25,14 @@ import site from "./commands/site/index.js"; import typescript from "./commands/typescript/index.js"; import { ExitProcessError } from "./ExitProcessError.js"; import { logConfigFileMiddleware } from "./yargs/logConfigFileMiddleware.js"; -import { logVersionMiddleware } from "./yargs/logVersionMiddleware.js"; +import { logLevelMiddleware } from "./yargs/logLevelMiddleware.js"; import { YargsCheckError } from "./YargsCheckError.js"; export async function cli(args: string[] = process.argv) { + consola.info( + `Palantir OSDK CLI ${process.env.PACKAGE_VERSION}\n`, + ); + const base: Argv = yargs(hideBin(args)) .wrap(Math.min(150, yargs().terminalWidth())) .env("OSDK") @@ -43,7 +47,7 @@ export async function cli(args: string[] = process.argv) { }, ) .demandCommand() - .middleware(logVersionMiddleware, true) + .middleware(logLevelMiddleware, true) .middleware(logConfigFileMiddleware) .strict() .command({ diff --git a/packages/cli/src/yargs/logVersionMiddleware.ts b/packages/cli/src/yargs/logLevelMiddleware.ts similarity index 73% rename from packages/cli/src/yargs/logVersionMiddleware.ts rename to packages/cli/src/yargs/logLevelMiddleware.ts index f034a4887..9ecdc0058 100644 --- a/packages/cli/src/yargs/logVersionMiddleware.ts +++ b/packages/cli/src/yargs/logLevelMiddleware.ts @@ -18,21 +18,17 @@ import { consola } from "consola"; import type { CliCommonArgs } from "../CliCommonArgs.js"; let firstTime = true; -export async function logVersionMiddleware(args: CliCommonArgs) { +export async function logLevelMiddleware(args: CliCommonArgs) { if (firstTime) { firstTime = false; - // This will be called before any command is executed - consola.info( - `Palantir OSDK CLI ${process.env.PACKAGE_VERSION}`, - ); consola.level = 3 + args.verbose; // so 1 -v is debug logs and -vv is trace if (consola.level > 3) { consola.debug( - `Verbose logging enabled (${consola.level === 4 ? "debug" : "trace"})`, + `Verbose logging enabled (${ + consola.level === 4 ? "debug" : "trace" + })\n`, ); } - - consola.log(""); // intentional blank line } }