@commitlint/load 8.3.5 → 8.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/lib/load.d.ts +3 -0
- package/lib/load.d.ts.map +1 -0
- package/lib/load.js +99 -0
- package/lib/load.js.map +1 -0
- package/lib/utils/load-config.d.ts +7 -0
- package/lib/utils/load-config.d.ts.map +1 -0
- package/lib/utils/load-config.js +43 -0
- package/lib/utils/load-config.js.map +1 -0
- package/lib/utils/load-parser-opts.d.ts +2 -0
- package/lib/utils/load-parser-opts.d.ts.map +1 -0
- package/lib/utils/load-parser-opts.js +39 -0
- package/lib/utils/load-parser-opts.js.map +1 -0
- package/lib/utils/load-plugin.d.ts +3 -0
- package/lib/utils/load-plugin.d.ts.map +1 -0
- package/lib/utils/load-plugin.js +61 -0
- package/lib/utils/load-plugin.js.map +1 -0
- package/lib/utils/pick-config.d.ts +3 -0
- package/lib/utils/pick-config.d.ts.map +1 -0
- package/lib/utils/pick-config.js +10 -0
- package/lib/utils/pick-config.js.map +1 -0
- package/lib/utils/plugin-errors.d.ts +13 -0
- package/lib/utils/plugin-errors.d.ts.map +1 -0
- package/lib/utils/plugin-errors.js +25 -0
- package/lib/utils/plugin-errors.js.map +1 -0
- package/lib/utils/plugin-naming.d.ts +20 -0
- package/lib/utils/plugin-naming.d.ts.map +1 -0
- package/lib/utils/plugin-naming.js +89 -0
- package/lib/utils/plugin-naming.js.map +1 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.3.6](https://github.com/conventional-changelog/commitlint/compare/v8.3.5...v8.3.6) (2021-11-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @commitlint/load
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [8.3.5](https://github.com/conventional-changelog/commitlint/compare/v8.3.4...v8.3.5) (2020-01-15)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @commitlint/load
|
package/lib/load.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,WAAW,EAEX,eAAe,EAEf,UAAU,EAEV,MAAM,mBAAmB,CAAC;AAgB3B,wBAA8B,IAAI,CACjC,IAAI,GAAE,UAAe,EACrB,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,eAAe,CAAC,CAyG1B"}
|
package/lib/load.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const execute_rule_1 = __importDefault(require("@commitlint/execute-rule"));
|
|
7
|
+
const resolve_extends_1 = __importDefault(require("@commitlint/resolve-extends"));
|
|
8
|
+
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
9
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
10
|
+
const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
|
|
11
|
+
const pick_1 = __importDefault(require("lodash/pick"));
|
|
12
|
+
const union_1 = __importDefault(require("lodash/union"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
15
|
+
const load_config_1 = require("./utils/load-config");
|
|
16
|
+
const load_parser_opts_1 = require("./utils/load-parser-opts");
|
|
17
|
+
const load_plugin_1 = __importDefault(require("./utils/load-plugin"));
|
|
18
|
+
const pick_config_1 = require("./utils/pick-config");
|
|
19
|
+
const w = (_, b) => Array.isArray(b) ? b : undefined;
|
|
20
|
+
async function load(seed = {}, options = {}) {
|
|
21
|
+
const cwd = typeof options.cwd === 'undefined' ? process.cwd() : options.cwd;
|
|
22
|
+
const loaded = await (0, load_config_1.loadConfig)(cwd, options.file);
|
|
23
|
+
const base = loaded && loaded.filepath ? path_1.default.dirname(loaded.filepath) : cwd;
|
|
24
|
+
// TODO: validate loaded.config against UserConfig type
|
|
25
|
+
// Might amount to breaking changes, defer until 9.0.0
|
|
26
|
+
// Merge passed config with file based options
|
|
27
|
+
const config = (0, pick_config_1.pickConfig)((0, merge_1.default)({}, loaded ? loaded.config : null, seed));
|
|
28
|
+
const opts = (0, merge_1.default)({ extends: [], rules: {}, formatter: '@commitlint/format' }, (0, pick_1.default)(config, 'extends', 'plugins', 'ignores', 'defaultIgnores'));
|
|
29
|
+
// Resolve parserPreset key
|
|
30
|
+
if (typeof config.parserPreset === 'string') {
|
|
31
|
+
const resolvedParserPreset = (0, resolve_from_1.default)(base, config.parserPreset);
|
|
32
|
+
config.parserPreset = {
|
|
33
|
+
name: config.parserPreset,
|
|
34
|
+
path: resolvedParserPreset,
|
|
35
|
+
parserOpts: require(resolvedParserPreset),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Resolve extends key
|
|
39
|
+
const extended = (0, resolve_extends_1.default)(opts, {
|
|
40
|
+
prefix: 'commitlint-config',
|
|
41
|
+
cwd: base,
|
|
42
|
+
parserPreset: config.parserPreset,
|
|
43
|
+
});
|
|
44
|
+
const preset = (0, pick_config_1.pickConfig)((0, mergeWith_1.default)(extended, config, w));
|
|
45
|
+
preset.plugins = {};
|
|
46
|
+
// TODO: check if this is still necessary with the new factory based conventional changelog parsers
|
|
47
|
+
// config.extends = Array.isArray(config.extends) ? config.extends : [];
|
|
48
|
+
// Resolve parser-opts from preset
|
|
49
|
+
if (typeof preset.parserPreset === 'object') {
|
|
50
|
+
preset.parserPreset.parserOpts = await (0, load_parser_opts_1.loadParserOpts)(preset.parserPreset.name,
|
|
51
|
+
// TODO: fix the types for factory based conventional changelog parsers
|
|
52
|
+
preset.parserPreset);
|
|
53
|
+
}
|
|
54
|
+
// Resolve config-relative formatter module
|
|
55
|
+
if (typeof config.formatter === 'string') {
|
|
56
|
+
preset.formatter =
|
|
57
|
+
resolve_from_1.default.silent(base, config.formatter) || config.formatter;
|
|
58
|
+
}
|
|
59
|
+
// Read plugins from extends
|
|
60
|
+
if (Array.isArray(extended.plugins)) {
|
|
61
|
+
config.plugins = (0, union_1.default)(config.plugins, extended.plugins || []);
|
|
62
|
+
}
|
|
63
|
+
// resolve plugins
|
|
64
|
+
if (Array.isArray(config.plugins)) {
|
|
65
|
+
config.plugins.forEach((plugin) => {
|
|
66
|
+
if (typeof plugin === 'string') {
|
|
67
|
+
(0, load_plugin_1.default)(preset.plugins, plugin, process.env.DEBUG === 'true');
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
preset.plugins.local = plugin;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const rules = preset.rules ? preset.rules : {};
|
|
75
|
+
const qualifiedRules = (await Promise.all(Object.entries(rules || {}).map((entry) => (0, execute_rule_1.default)(entry)))).reduce((registry, item) => {
|
|
76
|
+
const [key, value] = item;
|
|
77
|
+
registry[key] = value;
|
|
78
|
+
return registry;
|
|
79
|
+
}, {});
|
|
80
|
+
const helpUrl = typeof extended.helpUrl === 'string'
|
|
81
|
+
? extended.helpUrl
|
|
82
|
+
: typeof config.helpUrl === 'string'
|
|
83
|
+
? config.helpUrl
|
|
84
|
+
: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint';
|
|
85
|
+
const prompt = preset.prompt && (0, isPlainObject_1.default)(preset.prompt) ? preset.prompt : {};
|
|
86
|
+
return {
|
|
87
|
+
extends: preset.extends,
|
|
88
|
+
formatter: preset.formatter,
|
|
89
|
+
parserPreset: preset.parserPreset,
|
|
90
|
+
ignores: preset.ignores,
|
|
91
|
+
defaultIgnores: preset.defaultIgnores,
|
|
92
|
+
plugins: preset.plugins,
|
|
93
|
+
rules: qualifiedRules,
|
|
94
|
+
helpUrl,
|
|
95
|
+
prompt,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
exports.default = load;
|
|
99
|
+
//# sourceMappingURL=load.js.map
|
package/lib/load.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":";;;;;AAAA,4EAAmD;AACnD,kFAAyD;AASzD,yEAAiD;AACjD,yDAAiC;AACjC,iEAAyC;AACzC,uDAA+B;AAC/B,yDAAiC;AACjC,gDAAwB;AACxB,gEAAuC;AACvC,qDAA+C;AAC/C,+DAAwD;AACxD,sEAA6C;AAC7C,qDAA+C;AAE/C,MAAM,CAAC,GAAG,CAAI,CAAU,EAAE,CAA0C,EAAE,EAAE,CACvE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAEnB,KAAK,UAAU,IAAI,CACjC,OAAmB,EAAE,EACrB,UAAuB,EAAE;IAEzB,MAAM,GAAG,GAAG,OAAO,OAAO,CAAC,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAC7E,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAU,EAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAE7E,uDAAuD;IACvD,sDAAsD;IAEtD,8CAA8C;IAC9C,MAAM,MAAM,GAAG,IAAA,wBAAU,EAAC,IAAA,eAAK,EAAC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";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
9
|
+
const cosmiconfig_typescript_loader_1 = __importDefault(require("@endemolshinegroup/cosmiconfig-typescript-loader"));
|
|
10
|
+
async function loadConfig(cwd, configPath) {
|
|
11
|
+
const moduleName = 'commitlint';
|
|
12
|
+
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
13
|
+
searchPlaces: [
|
|
14
|
+
// cosmiconfig overrides default searchPlaces if any new search place is added (For e.g. `*.ts` files),
|
|
15
|
+
// we need to manually merge default searchPlaces from https://github.com/davidtheclark/cosmiconfig#searchplaces
|
|
16
|
+
'package.json',
|
|
17
|
+
`.${moduleName}rc`,
|
|
18
|
+
`.${moduleName}rc.json`,
|
|
19
|
+
`.${moduleName}rc.yaml`,
|
|
20
|
+
`.${moduleName}rc.yml`,
|
|
21
|
+
`.${moduleName}rc.js`,
|
|
22
|
+
`.${moduleName}rc.cjs`,
|
|
23
|
+
`${moduleName}.config.js`,
|
|
24
|
+
`${moduleName}.config.cjs`,
|
|
25
|
+
// files supported by TypescriptLoader
|
|
26
|
+
`.${moduleName}rc.ts`,
|
|
27
|
+
`${moduleName}.config.ts`,
|
|
28
|
+
],
|
|
29
|
+
loaders: {
|
|
30
|
+
'.ts': cosmiconfig_typescript_loader_1.default,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const explicitPath = configPath ? path_1.default.resolve(cwd, configPath) : undefined;
|
|
34
|
+
const explore = explicitPath ? explorer.load : explorer.search;
|
|
35
|
+
const searchPath = explicitPath ? explicitPath : cwd;
|
|
36
|
+
const local = await explore(searchPath);
|
|
37
|
+
if (local) {
|
|
38
|
+
return local;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
exports.loadConfig = loadConfig;
|
|
43
|
+
//# sourceMappingURL=load-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,6CAAwC;AACxC,qHAAgF;AAQzE,KAAK,UAAU,UAAU,CAC/B,GAAW,EACX,UAAmB;IAEnB,MAAM,UAAU,GAAG,YAAY,CAAC;IAChC,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC,UAAU,EAAE;QACxC,YAAY,EAAE;YACb,uGAAuG;YACvG,gHAAgH;YAChH,cAAc;YACd,IAAI,UAAU,IAAI;YAClB,IAAI,UAAU,SAAS;YACvB,IAAI,UAAU,SAAS;YACvB,IAAI,UAAU,QAAQ;YACtB,IAAI,UAAU,OAAO;YACrB,IAAI,UAAU,QAAQ;YACtB,GAAG,UAAU,YAAY;YACzB,GAAG,UAAU,aAAa;YAE1B,sCAAsC;YACtC,IAAI,UAAU,OAAO;YACrB,GAAG,UAAU,YAAY;SACzB;QACD,OAAO,EAAE;YACR,KAAK,EAAE,uCAAgB;SACvB;KACD,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC/D,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IACrD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAExC,IAAI,KAAK,EAAE;QACV,OAAO,KAAK,CAAC;KACb;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAtCD,gCAsCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-parser-opts.d.ts","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":"AAAA,wBAAsB,cAAc,CACnC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,gBA6C3B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadParserOpts = void 0;
|
|
4
|
+
async function loadParserOpts(parserName, pendingParser) {
|
|
5
|
+
// Await for the module, loaded with require
|
|
6
|
+
const parser = await pendingParser;
|
|
7
|
+
// Await parser opts if applicable
|
|
8
|
+
if (typeof parser === 'object' &&
|
|
9
|
+
typeof parser.parserOpts === 'object' &&
|
|
10
|
+
typeof parser.parserOpts.then === 'function') {
|
|
11
|
+
return (await parser.parserOpts).parserOpts;
|
|
12
|
+
}
|
|
13
|
+
// Create parser opts from factory
|
|
14
|
+
if (typeof parser === 'object' &&
|
|
15
|
+
typeof parser.parserOpts === 'function' &&
|
|
16
|
+
parserName.startsWith('conventional-changelog-')) {
|
|
17
|
+
return await new Promise((resolve) => {
|
|
18
|
+
const result = parser.parserOpts((_, opts) => {
|
|
19
|
+
resolve(opts.parserOpts);
|
|
20
|
+
});
|
|
21
|
+
// If result has data or a promise, the parser doesn't support factory-init
|
|
22
|
+
// due to https://github.com/nodejs/promises-debugging/issues/16 it just quits, so let's use this fallback
|
|
23
|
+
if (result) {
|
|
24
|
+
Promise.resolve(result).then((opts) => {
|
|
25
|
+
resolve(opts.parserOpts);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// Pull nested paserOpts, might happen if overwritten with a module in main config
|
|
31
|
+
if (typeof parser === 'object' &&
|
|
32
|
+
typeof parser.parserOpts === 'object' &&
|
|
33
|
+
typeof parser.parserOpts.parserOpts === 'object') {
|
|
34
|
+
return parser.parserOpts.parserOpts;
|
|
35
|
+
}
|
|
36
|
+
return parser.parserOpts;
|
|
37
|
+
}
|
|
38
|
+
exports.loadParserOpts = loadParserOpts;
|
|
39
|
+
//# sourceMappingURL=load-parser-opts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-parser-opts.js","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":";;;AAAO,KAAK,UAAU,cAAc,CACnC,UAAkB,EAClB,aAA2B;IAE3B,4CAA4C;IAC5C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;IAEnC,kCAAkC;IAClC,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;QACrC,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,KAAK,UAAU,EAC3C;QACD,OAAO,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC;KAC5C;IAED,kCAAkC;IAClC,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU;QACvC,UAAU,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAC/C;QACD,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAQ,EAAE,IAAuB,EAAE,EAAE;gBACtE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,2EAA2E;YAC3E,0GAA0G;YAC1G,IAAI,MAAM,EAAE;gBACX,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;oBACrC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBAC1B,CAAC,CAAC,CAAC;aACH;QACF,CAAC,CAAC,CAAC;KACH;IAED,kFAAkF;IAClF,IACC,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;QACrC,OAAO,MAAM,CAAC,UAAU,CAAC,UAAU,KAAK,QAAQ,EAC/C;QACD,OAAO,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;KACpC;IAED,OAAO,MAAM,CAAC,UAAU,CAAC;AAC1B,CAAC;AA/CD,wCA+CC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,UAAU,CACjC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,OAAe,GACpB,aAAa,CA8Df"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const plugin_naming_1 = require("./plugin-naming");
|
|
9
|
+
const plugin_errors_1 = require("./plugin-errors");
|
|
10
|
+
function loadPlugin(plugins, pluginName, debug = false) {
|
|
11
|
+
const longName = (0, plugin_naming_1.normalizePackageName)(pluginName);
|
|
12
|
+
const shortName = (0, plugin_naming_1.getShorthandName)(longName);
|
|
13
|
+
let plugin = null;
|
|
14
|
+
if (pluginName.match(/\s+/u)) {
|
|
15
|
+
throw new plugin_errors_1.WhitespacePluginError(pluginName, {
|
|
16
|
+
pluginName: longName,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const pluginKey = longName === pluginName ? shortName : pluginName;
|
|
20
|
+
if (!plugins[pluginKey]) {
|
|
21
|
+
try {
|
|
22
|
+
plugin = require(longName);
|
|
23
|
+
}
|
|
24
|
+
catch (pluginLoadErr) {
|
|
25
|
+
try {
|
|
26
|
+
// Check whether the plugin exists
|
|
27
|
+
require.resolve(longName);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// If the plugin can't be resolved, display the missing plugin error (usually a config or install error)
|
|
31
|
+
console.error(chalk_1.default.red(`Failed to load plugin ${longName}.`));
|
|
32
|
+
const message = (error === null || error === void 0 ? void 0 : error.message) || 'Unknown error occurred';
|
|
33
|
+
throw new plugin_errors_1.MissingPluginError(pluginName, message, {
|
|
34
|
+
pluginName: longName,
|
|
35
|
+
commitlintPath: path_1.default.resolve(__dirname, '../..'),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// Otherwise, the plugin exists and is throwing on module load for some reason, so print the stack trace.
|
|
39
|
+
throw pluginLoadErr;
|
|
40
|
+
}
|
|
41
|
+
// This step is costly, so skip if debug is disabled
|
|
42
|
+
if (debug) {
|
|
43
|
+
const resolvedPath = require.resolve(longName);
|
|
44
|
+
let version = null;
|
|
45
|
+
try {
|
|
46
|
+
version = require(`${longName}/package.json`).version;
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
// Do nothing
|
|
50
|
+
}
|
|
51
|
+
const loadedPluginAndVersion = version
|
|
52
|
+
? `${longName}@${version}`
|
|
53
|
+
: `${longName}, version unknown`;
|
|
54
|
+
console.log(chalk_1.default.blue(`Loaded plugin ${pluginName} (${loadedPluginAndVersion}) (from ${resolvedPath})`));
|
|
55
|
+
}
|
|
56
|
+
plugins[pluginKey] = plugin;
|
|
57
|
+
}
|
|
58
|
+
return plugins;
|
|
59
|
+
}
|
|
60
|
+
exports.default = loadPlugin;
|
|
61
|
+
//# sourceMappingURL=load-plugin.js.map
|
|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AS,EAAE,OAAO,CAAC;iBAChD,CAAC,CAAC;aACH;YAED,yGAAyG;YACzG,MAAM,aAAa,CAAC;SACpB;QAED,oDAAoD;QACpD,IAAI,KAAK,EAAE;YACV,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAE/C,IAAI,OAAO,GAAG,IAAI,CAAC;YAEnB,IAAI;gBACH,OAAO,GAAG,OAAO,CAAC,GAAG,QAAQ,eAAe,CAAC,CAAC,OAAO,CAAC;aACtD;YAAC,OAAO,CAAC,EAAE;gBACX,aAAa;aACb;YAED,MAAM,sBAAsB,GAAG,OAAO;gBACrC,CAAC,CAAC,GAAG,QAAQ,IAAI,OAAO,EAAE;gBAC1B,CAAC,CAAC,GAAG,QAAQ,mBAAmB,CAAC;YAElC,OAAO,CAAC,GAAG,CACV,eAAK,CAAC,IAAI,CACT,iBAAiB,UAAU,KAAK,sBAAsB,WAAW,YAAY,GAAG,CAChF,CACD,CAAC;SACF;QAED,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;KAC5B;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAlED,6BAkEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick-config.d.ts","sourceRoot":"","sources":["../../src/utils/pick-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAG7C,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,UAY1C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.pickConfig = void 0;
|
|
7
|
+
const pick_1 = __importDefault(require("lodash/pick"));
|
|
8
|
+
const pickConfig = (input) => (0, pick_1.default)(input, 'extends', 'rules', 'plugins', 'parserPreset', 'formatter', 'ignores', 'defaultIgnores', 'helpUrl', 'prompt');
|
|
9
|
+
exports.pickConfig = pickConfig;
|
|
10
|
+
//# sourceMappingURL=pick-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick-config.js","sourceRoot":"","sources":["../../src/utils/pick-config.ts"],"names":[],"mappings":";;;;;;AACA,uDAA+B;AAExB,MAAM,UAAU,GAAG,CAAC,KAAc,EAAc,EAAE,CACxD,IAAA,cAAI,EACH,KAAK,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,QAAQ,CACR,CAAC;AAZU,QAAA,UAAU,cAYpB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class WhitespacePluginError extends Error {
|
|
2
|
+
__proto__: ErrorConstructor;
|
|
3
|
+
messageTemplate: string;
|
|
4
|
+
messageData: any;
|
|
5
|
+
constructor(pluginName?: string, data?: any);
|
|
6
|
+
}
|
|
7
|
+
export declare class MissingPluginError extends Error {
|
|
8
|
+
__proto__: ErrorConstructor;
|
|
9
|
+
messageTemplate: string;
|
|
10
|
+
messageData: any;
|
|
11
|
+
constructor(pluginName?: string, errorMessage?: string, data?: any);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=plugin-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-errors.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,qBAAsB,SAAQ,KAAK;IAC/C,SAAS,mBAAS;IAEX,eAAe,EAAE,MAAM,CAAsB;IAC7C,WAAW,EAAE,GAAG,CAAM;gBAEjB,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ;CAO/C;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC5C,SAAS,mBAAS;IAEX,eAAe,EAAE,MAAM,CAAoB;IAC3C,WAAW,EAAE,GAAG,CAAC;gBAEZ,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,GAAE,MAAW,EAAE,IAAI,GAAE,GAAQ;CAO1E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingPluginError = exports.WhitespacePluginError = void 0;
|
|
4
|
+
class WhitespacePluginError extends Error {
|
|
5
|
+
constructor(pluginName, data = {}) {
|
|
6
|
+
super(`Whitespace found in plugin name '${pluginName}'`);
|
|
7
|
+
this.__proto__ = Error;
|
|
8
|
+
this.messageTemplate = 'whitespace-found';
|
|
9
|
+
this.messageData = {};
|
|
10
|
+
this.messageData = data;
|
|
11
|
+
Object.setPrototypeOf(this, WhitespacePluginError.prototype);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.WhitespacePluginError = WhitespacePluginError;
|
|
15
|
+
class MissingPluginError extends Error {
|
|
16
|
+
constructor(pluginName, errorMessage = '', data = {}) {
|
|
17
|
+
super(`Failed to load plugin ${pluginName}: ${errorMessage}`);
|
|
18
|
+
this.__proto__ = Error;
|
|
19
|
+
this.messageTemplate = 'plugin-missing';
|
|
20
|
+
this.messageData = data;
|
|
21
|
+
Object.setPrototypeOf(this, MissingPluginError.prototype);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.MissingPluginError = MissingPluginError;
|
|
25
|
+
//# sourceMappingURL=plugin-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-errors.js","sourceRoot":"","sources":["../../src/utils/plugin-errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAM/C,YAAY,UAAmB,EAAE,OAAY,EAAE;QAC9C,KAAK,CAAC,oCAAoC,UAAU,GAAG,CAAC,CAAC;QAN1D,cAAS,GAAG,KAAK,CAAC;QAEX,oBAAe,GAAW,kBAAkB,CAAC;QAC7C,gBAAW,GAAQ,EAAE,CAAC;QAK5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACD;AAbD,sDAaC;AAED,MAAa,kBAAmB,SAAQ,KAAK;IAM5C,YAAY,UAAmB,EAAE,eAAuB,EAAE,EAAE,OAAY,EAAE;QACzE,KAAK,CAAC,yBAAyB,UAAU,KAAK,YAAY,EAAE,CAAC,CAAC;QAN/D,cAAS,GAAG,KAAK,CAAC;QAEX,oBAAe,GAAW,gBAAgB,CAAC;QAMjD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACD;AAbD,gDAaC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brings package name to correct format based on prefix
|
|
3
|
+
* @param {string} name The name of the package.
|
|
4
|
+
* @returns {string} Normalized name of the package
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizePackageName(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Removes the prefix from a fullname.
|
|
10
|
+
* @param {string} fullname The term which may have the prefix.
|
|
11
|
+
* @returns {string} The term without prefix.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getShorthandName(fullname: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the scope (namespace) of a term.
|
|
16
|
+
* @param {string} term The term which may have the namespace.
|
|
17
|
+
* @returns {string} The namepace of the term if it has one.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNamespaceFromTerm(term: string): string;
|
|
20
|
+
//# sourceMappingURL=plugin-naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-naming.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-naming.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UA2ChD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,UAiBhD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAIhD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getNamespaceFromTerm = exports.getShorthandName = exports.normalizePackageName = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
// largely adapted from eslint's plugin system
|
|
9
|
+
const NAMESPACE_REGEX = /^@.*\//iu;
|
|
10
|
+
// In eslint this is a parameter - we don't need to support the extra options
|
|
11
|
+
const prefix = 'commitlint-plugin';
|
|
12
|
+
// Replace Windows with posix style paths
|
|
13
|
+
function convertPathToPosix(filepath) {
|
|
14
|
+
const normalizedFilepath = path_1.default.normalize(filepath);
|
|
15
|
+
const posixFilepath = normalizedFilepath.replace(/\\/gu, '/');
|
|
16
|
+
return posixFilepath;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Brings package name to correct format based on prefix
|
|
20
|
+
* @param {string} name The name of the package.
|
|
21
|
+
* @returns {string} Normalized name of the package
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
function normalizePackageName(name) {
|
|
25
|
+
let normalizedName = name;
|
|
26
|
+
/**
|
|
27
|
+
* On Windows, name can come in with Windows slashes instead of Unix slashes.
|
|
28
|
+
* Normalize to Unix first to avoid errors later on.
|
|
29
|
+
* https://github.com/eslint/eslint/issues/5644
|
|
30
|
+
*/
|
|
31
|
+
if (normalizedName.indexOf('\\') > -1) {
|
|
32
|
+
normalizedName = convertPathToPosix(normalizedName);
|
|
33
|
+
}
|
|
34
|
+
if (normalizedName.charAt(0) === '@') {
|
|
35
|
+
/**
|
|
36
|
+
* it's a scoped package
|
|
37
|
+
* package name is the prefix, or just a username
|
|
38
|
+
*/
|
|
39
|
+
const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, 'u'), scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, 'u');
|
|
40
|
+
if (scopedPackageShortcutRegex.test(normalizedName)) {
|
|
41
|
+
normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
|
|
42
|
+
}
|
|
43
|
+
else if (!scopedPackageNameRegex.test(normalizedName.split('/')[1])) {
|
|
44
|
+
/**
|
|
45
|
+
* for scoped packages, insert the prefix after the first / unless
|
|
46
|
+
* the path is already @scope/eslint or @scope/eslint-xxx-yyy
|
|
47
|
+
*/
|
|
48
|
+
normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (normalizedName.indexOf(`${prefix}-`) !== 0) {
|
|
52
|
+
normalizedName = `${prefix}-${normalizedName}`;
|
|
53
|
+
}
|
|
54
|
+
return normalizedName;
|
|
55
|
+
}
|
|
56
|
+
exports.normalizePackageName = normalizePackageName;
|
|
57
|
+
/**
|
|
58
|
+
* Removes the prefix from a fullname.
|
|
59
|
+
* @param {string} fullname The term which may have the prefix.
|
|
60
|
+
* @returns {string} The term without prefix.
|
|
61
|
+
*/
|
|
62
|
+
function getShorthandName(fullname) {
|
|
63
|
+
if (fullname[0] === '@') {
|
|
64
|
+
let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, 'u').exec(fullname);
|
|
65
|
+
if (matchResult) {
|
|
66
|
+
return matchResult[1];
|
|
67
|
+
}
|
|
68
|
+
matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, 'u').exec(fullname);
|
|
69
|
+
if (matchResult) {
|
|
70
|
+
return `${matchResult[1]}/${matchResult[2]}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (fullname.startsWith(`${prefix}-`)) {
|
|
74
|
+
return fullname.slice(prefix.length + 1);
|
|
75
|
+
}
|
|
76
|
+
return fullname;
|
|
77
|
+
}
|
|
78
|
+
exports.getShorthandName = getShorthandName;
|
|
79
|
+
/**
|
|
80
|
+
* Gets the scope (namespace) of a term.
|
|
81
|
+
* @param {string} term The term which may have the namespace.
|
|
82
|
+
* @returns {string} The namepace of the term if it has one.
|
|
83
|
+
*/
|
|
84
|
+
function getNamespaceFromTerm(term) {
|
|
85
|
+
const match = term.match(NAMESPACE_REGEX);
|
|
86
|
+
return match ? match[0] : '';
|
|
87
|
+
}
|
|
88
|
+
exports.getNamespaceFromTerm = getNamespaceFromTerm;
|
|
89
|
+
//# sourceMappingURL=plugin-naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-naming.js","sourceRoot":"","sources":["../../src/utils/plugin-naming.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,8CAA8C;AAC9C,MAAM,eAAe,GAAG,UAAU,CAAC;AACnC,6EAA6E;AAC7E,MAAM,MAAM,GAAG,mBAAmB,CAAC;AAEnC,yCAAyC;AACzC,SAAS,kBAAkB,CAAC,QAAgB;IAC3C,MAAM,kBAAkB,GAAG,cAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE9D,OAAO,aAAa,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAChD,IAAI,cAAc,GAAG,IAAI,CAAC;IAE1B;;;;OAIG;IACH,IAAI,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CA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AAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1E,IAAI,WAAW,EAAE;YAChB,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7C;KACD;SAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE;QAC7C,OAAO,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;KACzC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC;AAjBD,4CAiBC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAE1C,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9B,CAAC;AAJD,oDAIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/load",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.6",
|
|
4
4
|
"description": "Load shared commitlint configuration",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@commitlint/test": "8.2.0",
|
|
60
|
-
"@commitlint/utils": "^8.3.
|
|
60
|
+
"@commitlint/utils": "^8.3.6",
|
|
61
61
|
"ava": "0.22.0",
|
|
62
62
|
"babel-cli": "6.26.0",
|
|
63
63
|
"babel-preset-commitlint": "^8.2.0",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"globby": "10.0.1"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@commitlint/execute-rule": "^8.3.
|
|
72
|
-
"@commitlint/resolve-extends": "^8.3.
|
|
71
|
+
"@commitlint/execute-rule": "^8.3.6",
|
|
72
|
+
"@commitlint/resolve-extends": "^8.3.6",
|
|
73
73
|
"babel-runtime": "^6.23.0",
|
|
74
74
|
"chalk": "2.4.2",
|
|
75
75
|
"cosmiconfig": "^5.2.0",
|
|
76
|
-
"lodash": "4.17.
|
|
76
|
+
"lodash": "4.17.21",
|
|
77
77
|
"resolve-from": "^5.0.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "9ef77c205ce9338850b15374fd003f2052211803"
|
|
80
80
|
}
|