From 2a27cb82577c41386ab06e15dadd5b89b92726cd Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Mon, 26 May 2025 16:33:07 +0200 Subject: [PATCH 1/8] Change log level of profile log to debug --- src/core/command/cli-context.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/command/cli-context.ts b/src/core/command/cli-context.ts index 1ed54151..c49bea76 100644 --- a/src/core/command/cli-context.ts +++ b/src/core/command/cli-context.ts @@ -44,7 +44,7 @@ export class Context { try { this.profile = await this.profileService.findProfile(profileName); this.profileName = profileName; - this.log.info(`Using profile ${profileName}`); + this.log.debug(`Using profile ${profileName}`); } catch (err) { this.log.error(err); this.profile = undefined; From 9abdb840eb5cd05ac674b015295cb1fbe5c81136 Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Mon, 26 May 2025 16:33:28 +0200 Subject: [PATCH 2/8] Enable dev mode to run with uncompiled ts files in IDE --- src/content-cli.ts | 7 ++----- src/core/command/module-handler.ts | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/content-cli.ts b/src/content-cli.ts index 4b1f5d6e..5c77e03d 100644 --- a/src/content-cli.ts +++ b/src/content-cli.ts @@ -28,6 +28,7 @@ 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); if (!program.opts().quietmode) { @@ -60,11 +61,7 @@ async function run() { configureRootCommands(moduleHandler.configurator); - moduleHandler.discoverAndRegisterModules(__dirname); - - if (!process.argv.slice(2).length) { - program.outputHelp(); - } + moduleHandler.discoverAndRegisterModules(__dirname, program.opts().dev); try { program.parse(process.argv); diff --git a/src/core/command/module-handler.ts b/src/core/command/module-handler.ts index c8ec518f..50209e53 100644 --- a/src/core/command/module-handler.ts +++ b/src/core/command/module-handler.ts @@ -32,8 +32,9 @@ export class ModuleHandler { * instantiates the default exported class, and calls its register method. * * @param {any} rootPath - __dirname when invoked from the main entry file + * @param devMode - Use uncompiled modules for development debug mode */ - discoverAndRegisterModules(rootPath) { + discoverAndRegisterModules(rootPath, devMode = false) { let modulesDirPath = path.resolve(rootPath, "commands"); try { @@ -43,7 +44,7 @@ export class ModuleHandler { if (dirent.isDirectory()) { const moduleFolderName = dirent.name; - const moduleFileName = "module.js"; + const moduleFileName = devMode ? "module.ts" : "module.js"; // Calculate path relative to *this file's location in dist* let potentialModuleJsPath; From b09d37595a7d9d120953b407ba32b04e857133ef Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Mon, 26 May 2025 16:33:41 +0200 Subject: [PATCH 3/8] Handle form data in post method --- src/core/http/http-client.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/http/http-client.ts b/src/core/http/http-client.ts index 9afeaab2..8991275e 100644 --- a/src/core/http/http-client.ts +++ b/src/core/http/http-client.ts @@ -84,12 +84,18 @@ export class HttpClient { } public async post(url: string, body: any): Promise { + const contentType = body instanceof FormData + ? "multipart/form-data" + : "application/json;charset=utf-8"; + const requestBody = typeof body === "string" || body instanceof String || body instanceof FormData + ? body + : JSON.stringify(body) return new Promise((resolve, reject) => { this.axios.post( this.resolveUrl(url), - typeof body === "string" || body instanceof String ? body : JSON.stringify(body), + requestBody, { - headers: this.buildHeaders("application/json;charset=utf-8") + headers: this.buildHeaders(contentType) } ).then(response => { this.handleResponse(response, resolve, reject); From fe3ee0ad5b7ece6362a559b9ce6663f65604b83c Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Mon, 26 May 2025 17:44:39 +0200 Subject: [PATCH 4/8] Fix error logs in cli --- src/core/utils/logger.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/utils/logger.ts b/src/core/utils/logger.ts index cddd6464..c3dbf9f5 100644 --- a/src/core/utils/logger.ts +++ b/src/core/utils/logger.ts @@ -50,8 +50,7 @@ export const logger: Logger = winston.createLogger({ new winston.transports.Console({ level: 'info', format: winston.format.combine( - winston.format.colorize(), - winston.format.cli() + winston.format.colorize(), ), }), new winston.transports.File({ @@ -72,7 +71,6 @@ export const logger: Logger = winston.createLogger({ new winston.transports.Console({ format: winston.format.combine( winston.format.colorize(), - winston.format.cli() ), }), new winston.transports.File({ From c3f555ca4d4632c5ad4d29ea1847f8bd1394ce58 Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Tue, 27 May 2025 08:48:16 +0200 Subject: [PATCH 5/8] Fix list command printing wrong help message --- src/content-cli.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/content-cli.ts b/src/content-cli.ts index 5c77e03d..3d4b6d68 100644 --- a/src/content-cli.ts +++ b/src/content-cli.ts @@ -49,8 +49,7 @@ if (program.opts().debug) { function configureRootCommands(configurator: Configurator) { configurator.command("list") .description("Commands to list content.") - .alias("ls") - .action(() => program.outputHelp()); + .alias("ls"); } async function run() { From 6e35a8107d5f047c7e4903688f26e8f7fb742326 Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Tue, 27 May 2025 09:06:06 +0200 Subject: [PATCH 6/8] Remove double logs on get errors --- src/core/http/http-client.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/http/http-client.ts b/src/core/http/http-client.ts index 8991275e..460627ab 100644 --- a/src/core/http/http-client.ts +++ b/src/core/http/http-client.ts @@ -31,8 +31,7 @@ export class HttpClient { this.handleError(err, resolve, reject); }) }).catch(e => { - logger.error(e); - throw e; + throw new FatalError(e); }) } From dde3d5758cc24af4c9998835ea39160535eb9459 Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Tue, 27 May 2025 09:06:35 +0200 Subject: [PATCH 7/8] Remove extra log when printing data pools --- .../data-pipeline/data-pool/data-pool-command.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/data-pipeline/data-pool/data-pool-command.service.ts b/src/commands/data-pipeline/data-pool/data-pool-command.service.ts index 64b03085..080ac7d9 100644 --- a/src/commands/data-pipeline/data-pool/data-pool-command.service.ts +++ b/src/commands/data-pipeline/data-pool/data-pool-command.service.ts @@ -39,7 +39,6 @@ export class DataPoolCommandService { } public async listDataPools(jsonResponse: boolean): Promise { - logger.info(jsonResponse); if (jsonResponse) { await this.dataPoolService.findAndExportAllPools(); } else { From 307910d30028ce0e4eb40577d35b991946ed3285 Mon Sep 17 00:00:00 2001 From: Meris Nici Date: Tue, 27 May 2025 16:44:13 +0200 Subject: [PATCH 8/8] Use proper http service method on pullFile --- src/core/http/http-shared/base.manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/http/http-shared/base.manager.ts b/src/core/http/http-shared/base.manager.ts index f988151b..de37c5bf 100644 --- a/src/core/http/http-shared/base.manager.ts +++ b/src/core/http/http-shared/base.manager.ts @@ -37,7 +37,7 @@ export abstract class BaseManager { public async pullFile(): Promise { return new Promise((resolve, reject) => { this.httpClient - .getFile(this.getConfig().pullUrl) + .downloadFile(this.getConfig().pullUrl) .then(data => { const filename = this.writeStreamToFile(data); logger.info(this.fileDownloadedMessage + filename);