Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/294 task run checkproperties on config load #324

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
68 changes: 36 additions & 32 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ yargs
describe: 'metadata keys that shall be exclusively downloaded',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.retrieve(argv.BU, csvToArray(argv.TYPE), csvToArray(argv.KEY));
await Mcdev.retrieve(argv.BU, csvToArray(argv.TYPE), csvToArray(argv.KEY));
},
})
.command({
Expand All @@ -59,10 +59,10 @@ yargs
describe: 'metadata key that shall be exclusively uploaded',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.deploy(argv.BU, csvToArray(argv.TYPE), csvToArray(argv.KEY));
await Mcdev.deploy(argv.BU, csvToArray(argv.TYPE), csvToArray(argv.KEY));
},
})
.command({
Expand All @@ -74,10 +74,10 @@ yargs
describe: 'name of your installed package',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.initProject(argv.credentialsName, argv.skipInteraction);
await Mcdev.initProject(argv.credentialsName, argv.skipInteraction);
},
})
.command({
Expand All @@ -90,10 +90,10 @@ yargs
describe: 'name of your installed package',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.findBUs(argv.credentialsName);
await Mcdev.findBUs(argv.credentialsName);
},
})
.command({
Expand All @@ -105,10 +105,10 @@ yargs
describe: 'the business unit to deploy to',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.badKeys(argv.BU);
await Mcdev.badKeys(argv.BU);
},
})
.command({
Expand All @@ -128,10 +128,10 @@ yargs
'metadata type to generate docs for; currently supported: dataExtension, role',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.document(argv.BU, argv.TYPE);
await Mcdev.document(argv.BU, argv.TYPE);
},
})
.command({
Expand All @@ -154,10 +154,10 @@ yargs
describe: 'the key to delete',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.deleteByKey(argv.BU, argv.TYPE, argv.EXTERNALKEY);
await Mcdev.deleteByKey(argv.BU, argv.TYPE, argv.EXTERNALKEY);
},
})
.command({
Expand All @@ -184,10 +184,10 @@ yargs
describe: 'market used for reverse building template',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.retrieveAsTemplate(argv.BU, argv.TYPE, csvToArray(argv.NAME), argv.MARKET);
await Mcdev.retrieveAsTemplate(argv.BU, argv.TYPE, csvToArray(argv.NAME), argv.MARKET);
},
})
.command({
Expand All @@ -214,12 +214,12 @@ yargs
describe: 'market used for reverse building template',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
const keyArr = csvToArray(argv.KEY);

Mcdev.buildTemplate(argv.BU, argv.TYPE, keyArr, argv.MARKET);
await Mcdev.buildTemplate(argv.BU, argv.TYPE, keyArr, argv.MARKET);
},
})
.command({
Expand All @@ -245,10 +245,10 @@ yargs
describe: 'the business unit to deploy to',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.buildDefinition(argv.BU, argv.TYPE, argv.NAME, argv.MARKET);
await Mcdev.buildDefinition(argv.BU, argv.TYPE, argv.NAME, argv.MARKET);
},
})
.command({
Expand All @@ -270,30 +270,30 @@ yargs
describe: 'name of the metadata component',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.buildDefinitionBulk(argv.LISTNAME, argv.TYPE, argv.NAME);
await Mcdev.buildDefinitionBulk(argv.LISTNAME, argv.TYPE, argv.NAME);
},
})
.command({
command: 'selectTypes',
aliases: ['st'],
desc: 'lets you choose what metadata types to retrieve',
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.selectTypes();
await Mcdev.selectTypes();
},
})
.command({
command: 'explainTypes',
aliases: ['et'],
desc: 'explains metadata types that can be retrieved',
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.explainTypes();
await Mcdev.explainTypes();
},
})
.command({
Expand All @@ -312,10 +312,10 @@ yargs
'Disable templating & instead filter by the specified file path (comma separated)',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.createDeltaPkg(argv);
await Mcdev.createDeltaPkg(argv);
},
})
.command({
Expand All @@ -338,22 +338,22 @@ yargs
describe: 'key(s) of the metadata component(s)',
});
},
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
const keyArr = csvToArray(argv.KEY);

Mcdev.getFilesToCommit(argv.BU, argv.TYPE, keyArr);
await Mcdev.getFilesToCommit(argv.BU, argv.TYPE, keyArr);
},
})
.command({
command: 'upgrade',
aliases: ['up'],
desc: 'Add NPM dependencies and IDE configuration files to your project',
handler: (argv) => {
handler: async (argv) => {
Mcdev.setSkipInteraction(argv.skipInteraction);
Mcdev.setLoggingLevel(argv);
Mcdev.upgrade(argv.skipInteraction);
await Mcdev.upgrade(argv.skipInteraction);
},
})
.option('verbose', {
Expand All @@ -374,6 +374,10 @@ yargs
})
.demandCommand(1, 'Please enter a valid command')
.strict()
.fail((_, err) => {
Util.logger.error(err.message);
process.exit(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

our adaption of Util.logger.error already sets the exit code to 1

Copy link
Contributor

Choose a reason for hiding this comment

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

error: function (msg) {

Copy link
Contributor

@JoernBerkefeld JoernBerkefeld Jun 30, 2022

Choose a reason for hiding this comment

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

also there is a method to wrap around exit code 1:

signalFatalError() {

apparently the right way to do it for async-functions was process.exitCode = 1;
here more on the why: https://nodejs.dev/learn/how-to-exit-from-a-nodejs-program

})
.recommendCommands()
.wrap(yargs.terminalWidth())
.epilog(
Expand Down
Loading