Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class DataPoolCommandService {
}

public async listDataPools(jsonResponse: boolean): Promise<any> {
logger.info(jsonResponse);
if (jsonResponse) {
await this.dataPoolService.findAndExportAllPools();
} else {
Expand Down
10 changes: 3 additions & 7 deletions src/content-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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() {
Expand All @@ -60,11 +60,7 @@ async function run() {

configureRootCommands(moduleHandler.configurator);

moduleHandler.discoverAndRegisterModules(__dirname);

if (!process.argv.slice(2).length) {
Comment thread
ZgjimHaziri marked this conversation as resolved.
program.outputHelp();
}
moduleHandler.discoverAndRegisterModules(__dirname, program.opts().dev);

try {
program.parse(process.argv);
Expand Down
2 changes: 1 addition & 1 deletion src/core/command/cli-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/core/command/module-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions src/core/http/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export class HttpClient {
this.handleError(err, resolve, reject);
})
}).catch(e => {
logger.error(e);
throw e;
throw new FatalError(e);
})
}

Expand Down Expand Up @@ -84,12 +83,18 @@ export class HttpClient {
}

public async post(url: string, body: any): Promise<any> {
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)
Comment on lines +86 to +91
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This methods was design to work only with application/json and the postFile method here to be used for form-data. Did we try only changing the usage to postFile instead of post before modifying this? Asking to know if there was any issue with the postFile implementation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't test it. I compared the implementations between old and refactor code base, and this method looked pretty much what was required, and left it as is because it fixed the issue. We can also go back to it and use proper method

return new Promise<any>((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);
Expand Down
2 changes: 1 addition & 1 deletion src/core/http/http-shared/base.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export abstract class BaseManager {
public async pullFile(): Promise<any> {
return new Promise<void>((resolve, reject) => {
this.httpClient
.getFile(this.getConfig().pullUrl)
.downloadFile(this.getConfig().pullUrl)
.then(data => {
const filename = this.writeStreamToFile(data);
logger.info(this.fileDownloadedMessage + filename);
Expand Down
4 changes: 1 addition & 3 deletions src/core/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand Down