@commitlint/load
Advanced tools
Comparing version 13.1.0 to 13.2.0
@@ -6,2 +6,18 @@ # Change Log | ||
# [13.2.0](https://github.com/conventional-changelog/commitlint/compare/v13.1.0...v13.2.0) (2021-09-28) | ||
### Bug Fixes | ||
* **types:** user config prompt ([6d7a1c4](https://github.com/conventional-changelog/commitlint/commit/6d7a1c40e2f8a8ff22595e0e17f71f3702b0699c)) | ||
### Features | ||
* **load:** add cosmiconfig typescript loader ([b65aced](https://github.com/conventional-changelog/commitlint/commit/b65acedc3334a859811762539ec8716de3e73f85)) | ||
# [13.1.0](https://github.com/conventional-changelog/commitlint/compare/v13.0.0...v13.1.0) (2021-07-24) | ||
@@ -8,0 +24,0 @@ |
@@ -22,3 +22,3 @@ "use strict"; | ||
const cwd = typeof options.cwd === 'undefined' ? process.cwd() : options.cwd; | ||
const loaded = await load_config_1.loadConfig(cwd, options.file); | ||
const loaded = await (0, load_config_1.loadConfig)(cwd, options.file); | ||
const base = loaded && loaded.filepath ? path_1.default.dirname(loaded.filepath) : cwd; | ||
@@ -28,7 +28,7 @@ // TODO: validate loaded.config against UserConfig type | ||
// Merge passed config with file based options | ||
const config = pick_config_1.pickConfig(merge_1.default({}, loaded ? loaded.config : null, seed)); | ||
const opts = merge_1.default({ extends: [], rules: {}, formatter: '@commitlint/format' }, pick_1.default(config, 'extends', 'plugins', 'ignores', 'defaultIgnores')); | ||
const config = (0, pick_config_1.pickConfig)((0, merge_1.default)({}, loaded ? loaded.config : null, seed)); | ||
const opts = (0, merge_1.default)({ extends: [], rules: {}, formatter: '@commitlint/format' }, (0, pick_1.default)(config, 'extends', 'plugins', 'ignores', 'defaultIgnores')); | ||
// Resolve parserPreset key | ||
if (typeof config.parserPreset === 'string') { | ||
const resolvedParserPreset = resolve_from_1.default(base, config.parserPreset); | ||
const resolvedParserPreset = (0, resolve_from_1.default)(base, config.parserPreset); | ||
config.parserPreset = { | ||
@@ -41,3 +41,3 @@ name: config.parserPreset, | ||
// Resolve extends key | ||
const extended = resolve_extends_1.default(opts, { | ||
const extended = (0, resolve_extends_1.default)(opts, { | ||
prefix: 'commitlint-config', | ||
@@ -47,3 +47,3 @@ cwd: base, | ||
}); | ||
const preset = pick_config_1.pickConfig(mergeWith_1.default(extended, config, w)); | ||
const preset = (0, pick_config_1.pickConfig)((0, mergeWith_1.default)(extended, config, w)); | ||
preset.plugins = {}; | ||
@@ -54,3 +54,3 @@ // TODO: check if this is still necessary with the new factory based conventional changelog parsers | ||
if (typeof preset.parserPreset === 'object') { | ||
preset.parserPreset.parserOpts = await load_parser_opts_1.loadParserOpts(preset.parserPreset.name, | ||
preset.parserPreset.parserOpts = await (0, load_parser_opts_1.loadParserOpts)(preset.parserPreset.name, | ||
// TODO: fix the types for factory based conventional changelog parsers | ||
@@ -66,3 +66,3 @@ preset.parserPreset); | ||
if (Array.isArray(extended.plugins)) { | ||
config.plugins = union_1.default(config.plugins, extended.plugins || []); | ||
config.plugins = (0, union_1.default)(config.plugins, extended.plugins || []); | ||
} | ||
@@ -73,3 +73,3 @@ // resolve plugins | ||
if (typeof plugin === 'string') { | ||
load_plugin_1.default(preset.plugins, plugin, process.env.DEBUG === 'true'); | ||
(0, load_plugin_1.default)(preset.plugins, plugin, process.env.DEBUG === 'true'); | ||
} | ||
@@ -82,3 +82,3 @@ else { | ||
const rules = preset.rules ? preset.rules : {}; | ||
const qualifiedRules = (await Promise.all(Object.entries(rules || {}).map((entry) => execute_rule_1.default(entry)))).reduce((registry, item) => { | ||
const qualifiedRules = (await Promise.all(Object.entries(rules || {}).map((entry) => (0, execute_rule_1.default)(entry)))).reduce((registry, item) => { | ||
const [key, value] = item; | ||
@@ -91,3 +91,3 @@ registry[key] = value; | ||
: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'; | ||
const prompt = preset.prompt && isPlainObject_1.default(preset.prompt) ? preset.prompt : {}; | ||
const prompt = preset.prompt && (0, isPlainObject_1.default)(preset.prompt) ? preset.prompt : {}; | ||
return { | ||
@@ -94,0 +94,0 @@ extends: preset.extends, |
@@ -9,4 +9,21 @@ "use strict"; | ||
const cosmiconfig_1 = require("cosmiconfig"); | ||
const cosmiconfig_typescript_loader_1 = __importDefault(require("@endemolshinegroup/cosmiconfig-typescript-loader")); | ||
async function loadConfig(cwd, configPath) { | ||
const explorer = cosmiconfig_1.cosmiconfig('commitlint'); | ||
const moduleName = 'commitlint'; | ||
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, { | ||
searchPlaces: [ | ||
'package.json', | ||
`.${moduleName}rc`, | ||
`.${moduleName}rc.json`, | ||
`.${moduleName}rc.yaml`, | ||
`.${moduleName}rc.yml`, | ||
`.${moduleName}rc.ts`, | ||
`.${moduleName}rc.js`, | ||
`${moduleName}.config.ts`, | ||
`${moduleName}.config.js`, | ||
], | ||
loaders: { | ||
'.ts': cosmiconfig_typescript_loader_1.default, | ||
}, | ||
}); | ||
const explicitPath = configPath ? path_1.default.resolve(cwd, configPath) : undefined; | ||
@@ -13,0 +30,0 @@ const explore = explicitPath ? explorer.load : explorer.search; |
@@ -11,4 +11,4 @@ "use strict"; | ||
function loadPlugin(plugins, pluginName, debug = false) { | ||
const longName = plugin_naming_1.normalizePackageName(pluginName); | ||
const shortName = plugin_naming_1.getShorthandName(longName); | ||
const longName = (0, plugin_naming_1.normalizePackageName)(pluginName); | ||
const shortName = (0, plugin_naming_1.getShorthandName)(longName); | ||
let plugin = null; | ||
@@ -33,3 +33,4 @@ if (pluginName.match(/\s+/u)) { | ||
console.error(chalk_1.default.red(`Failed to load plugin ${longName}.`)); | ||
throw new plugin_errors_1.MissingPluginError(pluginName, error.message, { | ||
const message = (error === null || error === void 0 ? void 0 : error.message) || 'Unknown error occurred'; | ||
throw new plugin_errors_1.MissingPluginError(pluginName, message, { | ||
pluginName: longName, | ||
@@ -36,0 +37,0 @@ commitlintPath: path_1.default.resolve(__dirname, '../..'), |
@@ -8,4 +8,4 @@ "use strict"; | ||
const pick_1 = __importDefault(require("lodash/pick")); | ||
const pickConfig = (input) => pick_1.default(input, 'extends', 'rules', 'plugins', 'parserPreset', 'formatter', 'ignores', 'defaultIgnores', 'helpUrl', 'prompt'); | ||
const pickConfig = (input) => (0, pick_1.default)(input, 'extends', 'rules', 'plugins', 'parserPreset', 'formatter', 'ignores', 'defaultIgnores', 'helpUrl', 'prompt'); | ||
exports.pickConfig = pickConfig; | ||
//# sourceMappingURL=pick-config.js.map |
{ | ||
"name": "@commitlint/load", | ||
"version": "13.1.0", | ||
"version": "13.2.0", | ||
"description": "Load shared commitlint configuration", | ||
@@ -37,5 +37,5 @@ "main": "lib/load.js", | ||
"devDependencies": { | ||
"@commitlint/test": "^13.0.0", | ||
"@commitlint/utils": "^13.0.0", | ||
"@types/lodash": "4.14.171", | ||
"@commitlint/test": "^13.2.0", | ||
"@commitlint/utils": "^13.2.0", | ||
"@types/lodash": "4.14.175", | ||
"conventional-changelog-atom": "^2.0.8", | ||
@@ -45,5 +45,6 @@ "execa": "^5.0.0" | ||
"dependencies": { | ||
"@commitlint/execute-rule": "^13.0.0", | ||
"@commitlint/resolve-extends": "^13.0.0", | ||
"@commitlint/types": "^13.1.0", | ||
"@commitlint/execute-rule": "^13.2.0", | ||
"@commitlint/resolve-extends": "^13.2.0", | ||
"@commitlint/types": "^13.2.0", | ||
"@endemolshinegroup/cosmiconfig-typescript-loader": "^3.0.2", | ||
"chalk": "^4.0.0", | ||
@@ -54,3 +55,3 @@ "cosmiconfig": "^7.0.0", | ||
}, | ||
"gitHead": "dfbb8c5e9481a5075458acad2e4666fd6b98f9a7" | ||
"gitHead": "65e45339c79e46d01e35ec067edf14d225a3528a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44616
396
8
+ Added@endemolshinegroup/cosmiconfig-typescript-loader@^3.0.2
+ Added@endemolshinegroup/cosmiconfig-typescript-loader@3.0.2(transitive)
+ Addedarg@4.1.3(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcreate-require@1.1.1(transitive)
+ Addeddiff@4.0.2(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedmake-error@1.3.6(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedts-node@9.1.1(transitive)
+ Addedtslib@2.7.0(transitive)
+ Addedtypescript@5.6.2(transitive)
+ Addedyn@3.1.1(transitive)
Updated@commitlint/types@^13.2.0