Skip to content

Commit

Permalink
feat: added more verbosity for original config file
Browse files Browse the repository at this point in the history
Previously we only showed the configuration options merged with defaults
and after post-processing.
  • Loading branch information
EvanCarroll committed Sep 28, 2021
1 parent 685d2b5 commit c35ecd8
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,33 @@ const {validatePlugin, parseConfig} = require('./plugins/utils');

const CONFIG_NAME = 'release';

async function pkgRepoUrl(options) {
const {packageJson} = (await readPkgUp(options)) || {};
return packageJson && (isPlainObject(packageJson.repository) ? packageJson.repository.url : packageJson.repository);
}

const DEFAULTS = {
branches: [
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true},
],
tagFormat: `v\${version}`,
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
'@semantic-release/github',
],
};

module.exports = async (context, cliOptions) => {
const {cwd, env} = context;
const {config, filepath} = (await cosmiconfig(CONFIG_NAME).search(cwd)) || {};

debug('load config from: %s', filepath);

// Merge config file options and CLI/API options
let options = {...config, ...cliOptions};

Expand Down Expand Up @@ -54,22 +75,8 @@ module.exports = async (context, cliOptions) => {

// Set default options values if not defined yet
options = {
branches: [
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'next',
'next-major',
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true},
],
...DEFAULTS,
repositoryUrl: (await pkgRepoUrl({normalize: false, cwd})) || (await repoUrl({cwd, env})),
tagFormat: `v\${version}`,
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
'@semantic-release/npm',
'@semantic-release/github',
],
// Remove `null` and `undefined` options so they can be replaced with default ones
...pickBy(options, (option) => !isNil(option)),
...(options.branches ? {branches: castArray(options.branches)} : {}),
Expand All @@ -79,12 +86,8 @@ module.exports = async (context, cliOptions) => {
options.noCi = true;
}

debug('options values: %O', options);
debug(`Load config %O`,{filepath, 'unprocessed_config': config, 'processed_options': options});

return {options, plugins: await plugins({...context, options}, pluginsPath)};
};

async function pkgRepoUrl(options) {
const {packageJson} = (await readPkgUp(options)) || {};
return packageJson && (isPlainObject(packageJson.repository) ? packageJson.repository.url : packageJson.repository);
}

0 comments on commit c35ecd8

Please sign in to comment.