mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix: Onboarding config should use repo config, not defaults (#386)
This commit is contained in:
parent
3486b6db77
commit
87967b4945
5 changed files with 21 additions and 17 deletions
|
@ -3,7 +3,6 @@ const configDefinitions = require('./definitions');
|
|||
module.exports = {
|
||||
getDefault,
|
||||
getConfig,
|
||||
getOnboardingConfig,
|
||||
};
|
||||
|
||||
const defaultValues = {
|
||||
|
@ -26,14 +25,3 @@ function getConfig() {
|
|||
});
|
||||
return config;
|
||||
}
|
||||
|
||||
function getOnboardingConfig() {
|
||||
const options = configDefinitions.getOptions();
|
||||
const config = {};
|
||||
options.forEach(option => {
|
||||
if (option.level !== 'global' && option.onboarding !== false) {
|
||||
config[option.name] = getDefault(option);
|
||||
}
|
||||
});
|
||||
return config;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ const githubApp = require('./github-app');
|
|||
module.exports = {
|
||||
parseConfigs,
|
||||
filterConfig,
|
||||
getOnboardingConfig,
|
||||
};
|
||||
|
||||
async function parseConfigs(env, argv) {
|
||||
|
@ -134,3 +135,16 @@ function filterConfig(inputConfig, filterLevel) {
|
|||
}
|
||||
return outputConfig;
|
||||
}
|
||||
|
||||
function getOnboardingConfig(repoConfig) {
|
||||
const config = {};
|
||||
for (const option of definitions.getOptions()) {
|
||||
if (option.level !== 'global' && option.onboarding !== false) {
|
||||
config[option.name] = repoConfig[option.name];
|
||||
}
|
||||
}
|
||||
if (repoConfig.detectedPackageFiles) {
|
||||
config.packageFiles = [];
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
|
|
@ -67,5 +67,6 @@ async function detectPackageFiles(config) {
|
|||
config.logger.trace({ config }, 'detectPackageFiles');
|
||||
const packageFiles = await config.api.findFilePaths('package.json');
|
||||
config.logger.debug(`Found ${packageFiles.length} package file(s)`);
|
||||
return Object.assign({}, config, { packageFiles });
|
||||
const detectedPackageFiles = true;
|
||||
return Object.assign({}, config, { packageFiles, detectedPackageFiles });
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const handlebars = require('handlebars');
|
||||
const stringify = require('json-stringify-pretty-compact');
|
||||
|
||||
const defaultsParser = require('../../config/defaults');
|
||||
const configParser = require('../../config');
|
||||
|
||||
const onboardBranchName = 'renovate/configure';
|
||||
const onboardPrTitle = 'Configure Renovate';
|
||||
|
@ -13,14 +13,14 @@ module.exports = {
|
|||
};
|
||||
|
||||
async function createBranch(config) {
|
||||
const defaultConfig = defaultsParser.getOnboardingConfig();
|
||||
const defaultConfigString = `${stringify(defaultConfig)}\n`;
|
||||
const onboardingConfig = configParser.getOnboardingConfig(config);
|
||||
const onboardingConfigString = `${stringify(onboardingConfig)}\n`;
|
||||
await config.api.commitFilesToBranch(
|
||||
onboardBranchName,
|
||||
[
|
||||
{
|
||||
name: 'renovate.json',
|
||||
contents: defaultConfigString,
|
||||
contents: onboardingConfigString,
|
||||
},
|
||||
],
|
||||
'Add renovate.json'
|
||||
|
|
|
@ -96,6 +96,7 @@ If the default settings are all suitable for you, simply close this Pull Request
|
|||
findPr: jest.fn(),
|
||||
},
|
||||
logger,
|
||||
detectedPackageFiles: true,
|
||||
};
|
||||
});
|
||||
it('returns true if onboarding is false', async () => {
|
||||
|
|
Loading…
Reference in a new issue