Antonio 545eb92454
Adapt and enhance the releasing tools (#6092)
* feat(tools): adapt and enhance the releasing tools

- Create tag and bump script to manage the repository
- Adapt and enhance the RELEASING.md file
- Remove unused releasing tools in plugins/main plugin
- Support for bumping multi plugins
- Support for running a specific bump task for each plugin

* feat(tools): remove early return and add warning message when there are changes to the tag script

* feat(tools): removed release package scripts from main plugin and fix bump script

* feat(tools): fix description of tag tool

* fix: fix problems in RELEASING.md and minor fixes related to releasing scripts

* fix: RELEASING.md and remove warning in releasing bump script

* fix: add missing flag to tag command in the RELEASING.md

* fix: flag in RELEASING.md file

* feat: sign commit and tag in the release tag script

* feat: enhance release tools

- Added dependant options to scripts
- Fix description in manifest-changelog option
- Enhance some messages

* fix: typo in release tools

* feat: add warning message related to the tag script in the RELEASING.md doc file
2023-11-13 10:11:42 +01:00

70 lines
1.4 KiB
JavaScript

function createCLI(name, description, usage, options) {
const logger = require('../../release/lib/logger').create();
function help() {
console.log(`${name} - Help
${description}
Usage: ${usage}
Options:
${options
.map(
option => `${[
option.long ? '--' + option.long : '',
option.short ? '-' + option.short : '',
]
.filter(v => v)
.join(', ')}${option.help ? ' ' + option.help : ''}
${option.description}`,
)
.join('\n')}
`);
process.exit(0);
}
/**
*
* @param {String[]} input Input parameters
* @returns {Object} the configuration values
*/
function parse(inputText) {
if (!inputText) {
help();
}
let configuration = {
_unparsed: '',
};
const input = inputText.split(' ');
// Parse the input parameters
while (input.length) {
// Extract the first parameter
const [parameter] = input.splice(0, 1);
const option = options.find(
option =>
parameter === '--' + option.long || parameter === '-' + option.short,
);
if (option) {
configuration = {
...configuration,
...option.parse(parameter, input, { logger, option }),
};
} else {
configuration._unparsed = [configuration._unparsed, parameter]
.filter(v => v)
.join(' ');
}
}
return configuration;
}
return {
parse,
help,
};
}
module.exports = createCLI;