mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
db0efdf053
New config option replaces existing option exposeEnv. Set trustLevel=high in the bot config if you trust the contents of the repositories you are renovating. Doing so results in env being exposed, access to localhost, etc. Closes #2739
92 lines
2.3 KiB
JavaScript
92 lines
2.3 KiB
JavaScript
const commander = require('commander');
|
|
const configDefinitions = require('./definitions');
|
|
const { version } = require('../../package.json');
|
|
|
|
module.exports = {
|
|
getCliName,
|
|
getConfig,
|
|
};
|
|
|
|
function getCliName(option) {
|
|
if (option.cli === false) {
|
|
return '';
|
|
}
|
|
const nameWithHyphens = option.name.replace(/([A-Z])/g, '-$1');
|
|
return `--${nameWithHyphens.toLowerCase()}`;
|
|
}
|
|
|
|
function getConfig(input) {
|
|
// massage migrated configuration keys
|
|
const argv = input.map(a =>
|
|
a
|
|
.replace('--endpoints=', '--host-rules=')
|
|
.replace('--expose-env=true', '--trust-level=high')
|
|
.replace('--expose-env', '--trust-level=high')
|
|
);
|
|
const options = configDefinitions.getOptions();
|
|
|
|
const config = {};
|
|
|
|
const coersions = {
|
|
boolean: val => val === 'true',
|
|
list: val => {
|
|
if (val === '') {
|
|
return [];
|
|
}
|
|
try {
|
|
return JSON.parse(val);
|
|
} catch (err) {
|
|
return val.split(',').map(el => el.trim());
|
|
}
|
|
},
|
|
string: val => val,
|
|
integer: parseInt,
|
|
};
|
|
|
|
let program = new commander.Command().arguments('[repositories...]');
|
|
|
|
options.forEach(option => {
|
|
if (option.cli !== false) {
|
|
const param = `<${option.type}>`.replace('<boolean>', '[boolean]');
|
|
const optionString = `${getCliName(option)} ${param}`;
|
|
program = program.option(
|
|
optionString,
|
|
option.description,
|
|
coersions[option.type]
|
|
);
|
|
}
|
|
});
|
|
|
|
/* istanbul ignore next */
|
|
function helpConsole() {
|
|
/* eslint-disable no-console */
|
|
console.log(' Examples:');
|
|
console.log('');
|
|
console.log(' $ renovate --token abc123 singapore/lint-condo');
|
|
console.log(
|
|
' $ renovate --labels=renovate,dependency --ignore-unstable=false --log-level verbose singapore/lint-condo'
|
|
);
|
|
console.log(' $ renovate singapore/lint-condo singapore/package-test');
|
|
/* eslint-enable no-console */
|
|
}
|
|
|
|
program = program
|
|
.version(version, '-v, --version')
|
|
.on('--help', helpConsole)
|
|
.action(repositories => {
|
|
if (repositories && repositories.length) {
|
|
config.repositories = repositories;
|
|
}
|
|
})
|
|
.parse(argv);
|
|
|
|
options.forEach(option => {
|
|
if (option.cli !== false) {
|
|
if (program[option.name] !== undefined) {
|
|
config[option.name] = program[option.name];
|
|
}
|
|
}
|
|
});
|
|
|
|
return config;
|
|
}
|