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 { diff --git a/src/content-cli.ts b/src/content-cli.ts index 4b1f5d6e..3d4b6d68 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) { @@ -48,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() { @@ -60,11 +60,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/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; 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; diff --git a/src/core/http/http-client.ts b/src/core/http/http-client.ts index 9afeaab2..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); }) } @@ -84,12 +83,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); 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); 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({