Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"form-data": "4.0.1",
"openid-client": "5.6.1",
"hpagent": "1.2.0",
"package-up": "5.0.0",
"semver": "7.6.3",
"valid-url": "1.0.9",
"winston": "3.17.0",
Expand Down
36 changes: 20 additions & 16 deletions src/content-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@ if (!semverSatisfies(process.version, requiredVersion)) {
process.exit(1);
}

// Global configuration options
const program: Command = new Command();
program.version(VersionUtils.getCurrentCliVersion());
program.option("-q, --quietmode", "Reduce output to a minimum", false);
program.option("-p, --profile [profile]");
program.option("--debug", "Print debug messages", false);
program.option("--dev", "Development Mode", false);
program.parseOptions(process.argv);
async function configureGlobalConfigurationOptions(): Promise<Command> {
const program: Command = new Command();
const currentCliVersion = await VersionUtils.getCurrentCliVersion();
program.version(currentCliVersion);
program.option("-q, --quietmode", "Reduce output to a minimum", false);
program.option("-p, --profile [profile]");
program.option("--debug", "Print debug messages", false);
program.option("--dev", "Development Mode", false);
program.parseOptions(process.argv);

if (!program.opts().quietmode) {
console.log(`Content CLI - (C) Copyright 2025 - Celonis SE - Version ${VersionUtils.getCurrentCliVersion()}`);
console.log();
}
if (!program.opts().quietmode) {
console.log(`Content CLI - (C) Copyright 2025 - Celonis SE - Version ${currentCliVersion}`);
console.log();
}

if (program.opts().debug) {
logger.transports.forEach(t => {
t.level = "debug";
});
if (program.opts().debug) {
logger.transports.forEach(t => {
t.level = "debug";
});
}
return program;
}

/**
Expand All @@ -53,6 +56,7 @@ function configureRootCommands(configurator: Configurator): void {
}

async function run(): Promise<void> {
const program = await configureGlobalConfigurationOptions();
const context = new Context(program.opts());
await context.init();

Expand Down
14 changes: 10 additions & 4 deletions src/core/utils/version.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// tslint:disable-next-line:no-var-requires
const { version } = require("../../../package.json");
import * as fs from "fs";

export class VersionUtils {
public static getCurrentCliVersion(): string {
return version;
public static async getCurrentCliVersion(): Promise<string> {
const { packageUp } = await import("package-up");
const packageJsonPath = await packageUp();
if (!packageJsonPath) {
throw new Error("Could not find package.json");
}

const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
return pkg.version;
}
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3075,6 +3075,11 @@ fill-range@^7.1.1:
dependencies:
to-regex-range "^5.0.1"

find-up-simple@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/find-up-simple/-/find-up-simple-1.0.1.tgz#18fb90ad49e45252c4d7fca56baade04fa3fca1e"
integrity sha512-afd4O7zpqHeRyg4PfDQsXmlDe2PfdHtJt6Akt8jOWaApLOZk5JXs6VMR29lz03pRe9mpykrRCYIYxaJYcfpncQ==

find-up@^4.0.0, find-up@^4.1.0:
version "4.1.0"
resolved "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz"
Expand Down Expand Up @@ -4459,6 +4464,13 @@ pac-resolver@^7.0.1:
degenerator "^5.0.0"
netmask "^2.0.2"

package-up@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/package-up/-/package-up-5.0.0.tgz#3facda2aa9248c0b68b3dddfa4c58d22aa3faea2"
integrity sha512-MQEgDUvXCa3sGvqHg3pzHO8e9gqTCMPVrWUko3vPQGntwegmFo52mZb2abIVTjFnUcW0BcPz0D93jV5Cas1DWA==
dependencies:
find-up-simple "^1.0.0"

packageurl-js@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/packageurl-js/-/packageurl-js-2.0.1.tgz"
Expand Down
Loading