@commitlint/load 18.6.1 → 19.0.1
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/README.md +5 -10
- package/lib/load.d.ts +2 -0
- package/lib/load.d.ts.map +1 -1
- package/lib/load.js +39 -37
- package/lib/load.js.map +1 -1
- package/lib/utils/load-config.d.ts.map +1 -1
- package/lib/utils/load-config.js +16 -25
- package/lib/utils/load-config.js.map +1 -1
- package/lib/utils/load-parser-opts.js +1 -5
- package/lib/utils/load-parser-opts.js.map +1 -1
- package/lib/utils/load-plugin.d.ts +1 -1
- package/lib/utils/load-plugin.d.ts.map +1 -1
- package/lib/utils/load-plugin.js +21 -19
- package/lib/utils/load-plugin.js.map +1 -1
- package/lib/utils/plugin-errors.js +2 -7
- package/lib/utils/plugin-errors.js.map +1 -1
- package/lib/utils/plugin-naming.js +5 -14
- package/lib/utils/plugin-naming.js.map +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
> Load shared commitlint configuration
|
|
2
|
-
|
|
3
1
|
# @commitlint/load
|
|
4
2
|
|
|
3
|
+
Load shared commitlint configuration
|
|
4
|
+
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
7
|
```shell
|
|
8
8
|
npm install --save-dev @commitlint/load
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Documentation
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const load = require('@commitlint/load').default;
|
|
15
|
-
|
|
16
|
-
load({extends: ['./package']}).then((config) => console.log(config));
|
|
17
|
-
// => { extends: ['./package', './package-b'], rules: {} }
|
|
18
|
-
```
|
|
13
|
+
Consult [API docs](https://commitlint.js.org/api/load) for comprehensive documentation.
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
Documentation generated from [`docs` folder](../../docs/api/format.md).
|
package/lib/load.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveFrom, resolveFromSilent, resolveGlobalSilent } from '@commitlint/resolve-extends';
|
|
1
2
|
import { LoadOptions, QualifiedConfig, UserConfig } from '@commitlint/types';
|
|
2
3
|
export default function load(seed?: UserConfig, options?: LoadOptions): Promise<QualifiedConfig>;
|
|
4
|
+
export { resolveFrom, resolveFromSilent, resolveGlobalSilent };
|
|
3
5
|
//# sourceMappingURL=load.d.ts.map
|
package/lib/load.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAIA,OAAuB,EACtB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,WAAW,EAEX,eAAe,EAEf,UAAU,EACV,MAAM,mBAAmB,CAAC;AAoB3B,wBAA8B,IAAI,CACjC,IAAI,GAAE,UAAe,EACrB,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,eAAe,CAAC,CAmG1B;AAED,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAC,CAAC"}
|
package/lib/load.js
CHANGED
|
@@ -1,64 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { validateConfig } from '@commitlint/config-validator';
|
|
3
|
+
import executeRule from '@commitlint/execute-rule';
|
|
4
|
+
import resolveExtends, { resolveFrom, resolveFromSilent, resolveGlobalSilent, loadParserPreset, } from '@commitlint/resolve-extends';
|
|
5
|
+
import isPlainObject from 'lodash.isplainobject';
|
|
6
|
+
import merge from 'lodash.merge';
|
|
7
|
+
import uniq from 'lodash.uniq';
|
|
8
|
+
import { loadConfig } from './utils/load-config.js';
|
|
9
|
+
import { loadParserOpts } from './utils/load-parser-opts.js';
|
|
10
|
+
import loadPlugin from './utils/load-plugin.js';
|
|
11
|
+
/**
|
|
12
|
+
* formatter should be kept as is when unable to resolve it from config directory
|
|
13
|
+
*/
|
|
14
|
+
const resolveFormatter = (formatter, parent) => {
|
|
15
|
+
try {
|
|
16
|
+
return resolveFrom(formatter, parent);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return formatter;
|
|
20
|
+
}
|
|
4
21
|
};
|
|
5
|
-
|
|
6
|
-
const execute_rule_1 = __importDefault(require("@commitlint/execute-rule"));
|
|
7
|
-
const resolve_extends_1 = __importDefault(require("@commitlint/resolve-extends"));
|
|
8
|
-
const config_validator_1 = require("@commitlint/config-validator");
|
|
9
|
-
const lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
|
|
10
|
-
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
11
|
-
const lodash_uniq_1 = __importDefault(require("lodash.uniq"));
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
14
|
-
const load_config_1 = require("./utils/load-config");
|
|
15
|
-
const load_parser_opts_1 = require("./utils/load-parser-opts");
|
|
16
|
-
const load_plugin_1 = __importDefault(require("./utils/load-plugin"));
|
|
17
|
-
async function load(seed = {}, options = {}) {
|
|
22
|
+
export default async function load(seed = {}, options = {}) {
|
|
18
23
|
const cwd = typeof options.cwd === 'undefined' ? process.cwd() : options.cwd;
|
|
19
|
-
const loaded = await
|
|
20
|
-
const
|
|
24
|
+
const loaded = await loadConfig(cwd, options.file);
|
|
25
|
+
const baseDirectory = (loaded === null || loaded === void 0 ? void 0 : loaded.filepath) ? path.dirname(loaded.filepath) : cwd;
|
|
26
|
+
const configFilePath = loaded === null || loaded === void 0 ? void 0 : loaded.filepath;
|
|
21
27
|
let config = {};
|
|
22
28
|
if (loaded) {
|
|
23
|
-
|
|
29
|
+
validateConfig(loaded.filepath || '', loaded.config);
|
|
24
30
|
config = loaded.config;
|
|
25
31
|
}
|
|
26
32
|
// Merge passed config with file based options
|
|
27
|
-
config = (
|
|
33
|
+
config = merge({
|
|
28
34
|
extends: [],
|
|
29
35
|
plugins: [],
|
|
30
36
|
rules: {},
|
|
31
37
|
}, config, seed);
|
|
32
38
|
// Resolve parserPreset key
|
|
33
39
|
if (typeof config.parserPreset === 'string') {
|
|
34
|
-
const resolvedParserPreset = (
|
|
35
|
-
config.parserPreset = {
|
|
36
|
-
name: config.parserPreset,
|
|
37
|
-
path: resolvedParserPreset,
|
|
38
|
-
parserOpts: require(resolvedParserPreset),
|
|
39
|
-
};
|
|
40
|
+
const resolvedParserPreset = resolveFrom(config.parserPreset, configFilePath);
|
|
41
|
+
config.parserPreset = Object.assign({ name: config.parserPreset }, (await loadParserPreset(resolvedParserPreset)));
|
|
40
42
|
}
|
|
41
43
|
// Resolve extends key
|
|
42
|
-
const extended =
|
|
44
|
+
const extended = await resolveExtends(config, {
|
|
43
45
|
prefix: 'commitlint-config',
|
|
44
|
-
cwd:
|
|
45
|
-
parserPreset: config.parserPreset,
|
|
46
|
+
cwd: baseDirectory,
|
|
47
|
+
parserPreset: await config.parserPreset,
|
|
46
48
|
});
|
|
47
49
|
if (!extended.formatter || typeof extended.formatter !== 'string') {
|
|
48
50
|
extended.formatter = '@commitlint/format';
|
|
49
51
|
}
|
|
50
52
|
let plugins = {};
|
|
51
53
|
if (Array.isArray(extended.plugins)) {
|
|
52
|
-
(
|
|
54
|
+
for (const plugin of uniq(extended.plugins)) {
|
|
53
55
|
if (typeof plugin === 'string') {
|
|
54
|
-
plugins =
|
|
56
|
+
plugins = await loadPlugin(plugins, plugin, process.env.DEBUG === 'true');
|
|
55
57
|
}
|
|
56
58
|
else {
|
|
57
59
|
plugins.local = plugin;
|
|
58
60
|
}
|
|
59
|
-
}
|
|
61
|
+
}
|
|
60
62
|
}
|
|
61
|
-
const rules = (await Promise.all(Object.entries(extended.rules || {}).map((entry) => (
|
|
63
|
+
const rules = (await Promise.all(Object.entries(extended.rules || {}).map((entry) => executeRule(entry)))).reduce((registry, item) => {
|
|
62
64
|
// type of `item` can be null, but Object.entries always returns key pair
|
|
63
65
|
const [key, value] = item;
|
|
64
66
|
registry[key] = value;
|
|
@@ -69,7 +71,7 @@ async function load(seed = {}, options = {}) {
|
|
|
69
71
|
: typeof config.helpUrl === 'string'
|
|
70
72
|
? config.helpUrl
|
|
71
73
|
: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint';
|
|
72
|
-
const prompt = extended.prompt && (
|
|
74
|
+
const prompt = extended.prompt && isPlainObject(extended.prompt) ? extended.prompt : {};
|
|
73
75
|
return {
|
|
74
76
|
extends: Array.isArray(extended.extends)
|
|
75
77
|
? extended.extends
|
|
@@ -77,9 +79,9 @@ async function load(seed = {}, options = {}) {
|
|
|
77
79
|
? [extended.extends]
|
|
78
80
|
: [],
|
|
79
81
|
// Resolve config-relative formatter module
|
|
80
|
-
formatter:
|
|
82
|
+
formatter: resolveFormatter(extended.formatter, configFilePath),
|
|
81
83
|
// Resolve parser-opts from preset
|
|
82
|
-
parserPreset: await
|
|
84
|
+
parserPreset: await loadParserOpts(extended.parserPreset),
|
|
83
85
|
ignores: extended.ignores,
|
|
84
86
|
defaultIgnores: extended.defaultIgnores,
|
|
85
87
|
plugins: plugins,
|
|
@@ -88,5 +90,5 @@ async function load(seed = {}, options = {}) {
|
|
|
88
90
|
prompt,
|
|
89
91
|
};
|
|
90
92
|
}
|
|
91
|
-
|
|
93
|
+
export { resolveFrom, resolveFromSilent, resolveGlobalSilent };
|
|
92
94
|
//# sourceMappingURL=load.js.map
|
package/lib/load.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;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CAAC;gBACpB,CAAC,CAAC,EAAE;QACL,2CAA2C;QAC3C,SAAS,EAAE,gBAAgB,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;QAC/D,kCAAkC;QAClC,YAAY,EAAE,MAAM,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QACzD,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,OAAO;QAChB,MAAM;KACN,CAAC;AACH,CAAC;AAED,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAID,wBAAsB,UAAU,CAC/B,GAAG,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAwDlC;AAKD,eAAO,MAAM,uBAAuB,eAOnC,CAAC;AAGF,eAAO,MAAM,WAAW,QAAS,MAAM,YAStC,CAAC"}
|
package/lib/utils/load-config.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isEsmModule = exports.isDynamicAwaitSupported = exports.loadConfig = void 0;
|
|
7
|
-
const cosmiconfig_1 = require("cosmiconfig");
|
|
8
|
-
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
9
|
-
const fs_1 = require("fs");
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { cosmiconfig, defaultLoadersSync, defaultLoaders, } from 'cosmiconfig';
|
|
4
|
+
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';
|
|
11
5
|
const moduleName = 'commitlint';
|
|
12
|
-
async function loadConfig(cwd, configPath) {
|
|
6
|
+
export async function loadConfig(cwd, configPath) {
|
|
13
7
|
let tsLoaderInstance;
|
|
14
8
|
const tsLoader = (...args) => {
|
|
15
9
|
if (!tsLoaderInstance) {
|
|
16
|
-
tsLoaderInstance =
|
|
10
|
+
tsLoaderInstance = TypeScriptLoader();
|
|
17
11
|
}
|
|
18
12
|
return tsLoaderInstance(...args);
|
|
19
13
|
};
|
|
20
14
|
// If dynamic await is supported (Node >= v20.8.0) or directory uses ESM, support
|
|
21
15
|
// async js/cjs loaders (dynamic import). Otherwise, use synchronous js/cjs loaders.
|
|
22
|
-
const loaders =
|
|
23
|
-
?
|
|
24
|
-
:
|
|
25
|
-
const explorer =
|
|
16
|
+
const loaders = isDynamicAwaitSupported() || isEsmModule(cwd)
|
|
17
|
+
? defaultLoaders
|
|
18
|
+
: defaultLoadersSync;
|
|
19
|
+
const explorer = cosmiconfig(moduleName, {
|
|
26
20
|
searchPlaces: [
|
|
27
21
|
// cosmiconfig overrides default searchPlaces if any new search place is added (For e.g. `*.ts` files),
|
|
28
22
|
// we need to manually merge default searchPlaces from https://github.com/davidtheclark/cosmiconfig#searchplaces
|
|
@@ -50,7 +44,7 @@ async function loadConfig(cwd, configPath) {
|
|
|
50
44
|
'.js': loaders['.js'],
|
|
51
45
|
},
|
|
52
46
|
});
|
|
53
|
-
const explicitPath = configPath ?
|
|
47
|
+
const explicitPath = configPath ? path.resolve(cwd, configPath) : undefined;
|
|
54
48
|
const explore = explicitPath ? explorer.load : explorer.search;
|
|
55
49
|
const searchPath = explicitPath ? explicitPath : cwd;
|
|
56
50
|
const local = await explore(searchPath);
|
|
@@ -59,27 +53,24 @@ async function loadConfig(cwd, configPath) {
|
|
|
59
53
|
}
|
|
60
54
|
return null;
|
|
61
55
|
}
|
|
62
|
-
exports.loadConfig = loadConfig;
|
|
63
56
|
// See the following issues for more context, contributing to failing Jest tests:
|
|
64
57
|
// - Issue: https://github.com/nodejs/node/issues/40058
|
|
65
58
|
// - Resolution: https://github.com/nodejs/node/pull/48510 (Node v20.8.0)
|
|
66
|
-
const isDynamicAwaitSupported = () => {
|
|
59
|
+
export const isDynamicAwaitSupported = () => {
|
|
67
60
|
const [major, minor] = process.version
|
|
68
61
|
.replace('v', '')
|
|
69
62
|
.split('.')
|
|
70
63
|
.map((val) => parseInt(val));
|
|
71
64
|
return major >= 20 && minor >= 8;
|
|
72
65
|
};
|
|
73
|
-
exports.isDynamicAwaitSupported = isDynamicAwaitSupported;
|
|
74
66
|
// Is the given directory set up to use ESM (ECMAScript Modules)?
|
|
75
|
-
const isEsmModule = (cwd) => {
|
|
67
|
+
export const isEsmModule = (cwd) => {
|
|
76
68
|
var _a;
|
|
77
|
-
const packagePath =
|
|
78
|
-
if (!
|
|
69
|
+
const packagePath = path.join(cwd, 'package.json');
|
|
70
|
+
if (!existsSync(packagePath)) {
|
|
79
71
|
return false;
|
|
80
72
|
}
|
|
81
|
-
const packageJSON =
|
|
73
|
+
const packageJSON = readFileSync(packagePath, { encoding: 'utf-8' });
|
|
82
74
|
return ((_a = JSON.parse(packageJSON)) === null || _a === void 0 ? void 0 : _a.type) === 'module';
|
|
83
75
|
};
|
|
84
|
-
exports.isEsmModule = isEsmModule;
|
|
85
76
|
//# sourceMappingURL=load-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-config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AC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC;IACnE,OAAO,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,0CAAE,IAAI,MAAK,QAAQ,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadParserOpts = void 0;
|
|
4
1
|
function isObjectLike(obj) {
|
|
5
2
|
return Boolean(obj) && typeof obj === 'object'; // typeof null === 'object'
|
|
6
3
|
}
|
|
7
4
|
function isParserOptsFunction(obj) {
|
|
8
5
|
return typeof obj.parserOpts === 'function';
|
|
9
6
|
}
|
|
10
|
-
async function loadParserOpts(pendingParser) {
|
|
7
|
+
export async function loadParserOpts(pendingParser) {
|
|
11
8
|
if (typeof pendingParser === 'function') {
|
|
12
9
|
return loadParserOpts(pendingParser());
|
|
13
10
|
}
|
|
@@ -50,5 +47,4 @@ async function loadParserOpts(pendingParser) {
|
|
|
50
47
|
}
|
|
51
48
|
return parser;
|
|
52
49
|
}
|
|
53
|
-
exports.loadParserOpts = loadParserOpts;
|
|
54
50
|
//# sourceMappingURL=load-parser-opts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-parser-opts.js","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-parser-opts.js","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":"AAIA,SAAS,YAAY,CAAC,GAAY;IACjC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,2BAA2B;AAC5E,CAAC;AAED,SAAS,oBAA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,IAAI,uBAAJ,IAAI,CAAE,UAAU,IAC3B,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,2EAA2E;YAC3E,0GAA0G;YAC1G,IAAI,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;oBACrC,OAAO,iCACH,MAAM,KACT,UAAU,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,IAC3B,CAAC;gBACJ,CAAC,CAAC,CAAC;YACJ,CAAC;YACD,OAAO;QACR,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PluginRecords } from '@commitlint/types';
|
|
2
|
-
export default function loadPlugin(plugins: PluginRecords, pluginName: string, debug?: boolean): PluginRecords
|
|
2
|
+
export default function loadPlugin(plugins: PluginRecords, pluginName: string, debug?: boolean): Promise<PluginRecords>;
|
|
3
3
|
//# sourceMappingURL=load-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAS,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAiBxD,wBAA8B,UAAU,CACvC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,OAAe,GACpB,OAAO,CAAC,aAAa,CAAC,CA8DxB"}
|
package/lib/utils/load-plugin.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { normalizePackageName, getShorthandName } from './plugin-naming.js';
|
|
6
|
+
import { WhitespacePluginError, MissingPluginError } from './plugin-errors.js';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), '..');
|
|
9
|
+
const dynamicImport = async (id) => {
|
|
10
|
+
const imported = await import(path.isAbsolute(id) ? pathToFileURL(id).toString() : id);
|
|
11
|
+
return ('default' in imported && imported.default) || imported;
|
|
4
12
|
};
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
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;
|
|
13
|
+
export default async function loadPlugin(plugins, pluginName, debug = false) {
|
|
14
|
+
const longName = normalizePackageName(pluginName);
|
|
15
|
+
const shortName = getShorthandName(longName);
|
|
16
|
+
let plugin;
|
|
14
17
|
if (pluginName.match(/\s+/u)) {
|
|
15
|
-
throw new
|
|
18
|
+
throw new WhitespacePluginError(pluginName, {
|
|
16
19
|
pluginName: longName,
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
22
|
const pluginKey = longName === pluginName ? shortName : pluginName;
|
|
20
23
|
if (!plugins[pluginKey]) {
|
|
21
24
|
try {
|
|
22
|
-
plugin =
|
|
25
|
+
plugin = await dynamicImport(longName);
|
|
23
26
|
}
|
|
24
27
|
catch (pluginLoadErr) {
|
|
25
28
|
try {
|
|
@@ -28,11 +31,11 @@ function loadPlugin(plugins, pluginName, debug = false) {
|
|
|
28
31
|
}
|
|
29
32
|
catch (error) {
|
|
30
33
|
// If the plugin can't be resolved, display the missing plugin error (usually a config or install error)
|
|
31
|
-
console.error(
|
|
34
|
+
console.error(chalk.red(`Failed to load plugin ${longName}.`));
|
|
32
35
|
const message = (error === null || error === void 0 ? void 0 : error.message) || 'Unknown error occurred';
|
|
33
|
-
throw new
|
|
36
|
+
throw new MissingPluginError(pluginName, message, {
|
|
34
37
|
pluginName: longName,
|
|
35
|
-
commitlintPath:
|
|
38
|
+
commitlintPath: path.resolve(__dirname, '../..'),
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
// Otherwise, the plugin exists and is throwing on module load for some reason, so print the stack trace.
|
|
@@ -51,11 +54,10 @@ function loadPlugin(plugins, pluginName, debug = false) {
|
|
|
51
54
|
const loadedPluginAndVersion = version
|
|
52
55
|
? `${longName}@${version}`
|
|
53
56
|
: `${longName}, version unknown`;
|
|
54
|
-
console.log(
|
|
57
|
+
console.log(chalk.blue(`Loaded plugin ${pluginName} (${loadedPluginAndVersion}) (from ${resolvedPath})`));
|
|
55
58
|
}
|
|
56
59
|
plugins[pluginKey] = plugin;
|
|
57
60
|
}
|
|
58
61
|
return plugins;
|
|
59
62
|
}
|
|
60
|
-
exports.default = loadPlugin;
|
|
61
63
|
//# sourceMappingURL=load-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-plugin.js","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-plugin.js","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,KAAK,CAAC;AAGjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAC,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;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1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MissingPluginError = exports.WhitespacePluginError = void 0;
|
|
4
|
-
class WhitespacePluginError extends Error {
|
|
1
|
+
export class WhitespacePluginError extends Error {
|
|
5
2
|
constructor(pluginName, data = {}) {
|
|
6
3
|
super(`Whitespace found in plugin name '${pluginName}'`);
|
|
7
4
|
this.__proto__ = Error;
|
|
@@ -11,8 +8,7 @@ class WhitespacePluginError extends Error {
|
|
|
11
8
|
Object.setPrototypeOf(this, WhitespacePluginError.prototype);
|
|
12
9
|
}
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
class MissingPluginError extends Error {
|
|
11
|
+
export class MissingPluginError extends Error {
|
|
16
12
|
constructor(pluginName, errorMessage = '', data = {}) {
|
|
17
13
|
super(`Failed to load plugin ${pluginName}: ${errorMessage}`);
|
|
18
14
|
this.__proto__ = Error;
|
|
@@ -21,5 +17,4 @@ class MissingPluginError extends Error {
|
|
|
21
17
|
Object.setPrototypeOf(this, MissingPluginError.prototype);
|
|
22
18
|
}
|
|
23
19
|
}
|
|
24
|
-
exports.MissingPluginError = MissingPluginError;
|
|
25
20
|
//# sourceMappingURL=plugin-errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-errors.js","sourceRoot":"","sources":["../../src/utils/plugin-errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-errors.js","sourceRoot":"","sources":["../../src/utils/plugin-errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,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;AAED,MAAM,OAAO,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"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
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"));
|
|
1
|
+
import path from 'path';
|
|
8
2
|
// largely adapted from eslint's plugin system
|
|
9
3
|
const NAMESPACE_REGEX = /^@.*\//iu;
|
|
10
4
|
// In eslint this is a parameter - we don't need to support the extra options
|
|
11
5
|
const prefix = 'commitlint-plugin';
|
|
12
6
|
// Replace Windows with posix style paths
|
|
13
7
|
function convertPathToPosix(filepath) {
|
|
14
|
-
const normalizedFilepath =
|
|
8
|
+
const normalizedFilepath = path.normalize(filepath);
|
|
15
9
|
const posixFilepath = normalizedFilepath.replace(/\\/gu, '/');
|
|
16
10
|
return posixFilepath;
|
|
17
11
|
}
|
|
@@ -21,7 +15,7 @@ function convertPathToPosix(filepath) {
|
|
|
21
15
|
* @returns {string} Normalized name of the package
|
|
22
16
|
* @private
|
|
23
17
|
*/
|
|
24
|
-
function normalizePackageName(name) {
|
|
18
|
+
export function normalizePackageName(name) {
|
|
25
19
|
let normalizedName = name;
|
|
26
20
|
/**
|
|
27
21
|
* On Windows, name can come in with Windows slashes instead of Unix slashes.
|
|
@@ -53,13 +47,12 @@ function normalizePackageName(name) {
|
|
|
53
47
|
}
|
|
54
48
|
return normalizedName;
|
|
55
49
|
}
|
|
56
|
-
exports.normalizePackageName = normalizePackageName;
|
|
57
50
|
/**
|
|
58
51
|
* Removes the prefix from a fullname.
|
|
59
52
|
* @param {string} fullname The term which may have the prefix.
|
|
60
53
|
* @returns {string} The term without prefix.
|
|
61
54
|
*/
|
|
62
|
-
function getShorthandName(fullname) {
|
|
55
|
+
export function getShorthandName(fullname) {
|
|
63
56
|
if (fullname[0] === '@') {
|
|
64
57
|
let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, 'u').exec(fullname);
|
|
65
58
|
if (matchResult) {
|
|
@@ -75,15 +68,13 @@ function getShorthandName(fullname) {
|
|
|
75
68
|
}
|
|
76
69
|
return fullname;
|
|
77
70
|
}
|
|
78
|
-
exports.getShorthandName = getShorthandName;
|
|
79
71
|
/**
|
|
80
72
|
* Gets the scope (namespace) of a term.
|
|
81
73
|
* @param {string} term The term which may have the namespace.
|
|
82
74
|
* @returns {string} The namepace of the term if it has one.
|
|
83
75
|
*/
|
|
84
|
-
function getNamespaceFromTerm(term) {
|
|
76
|
+
export function getNamespaceFromTerm(term) {
|
|
85
77
|
const match = term.match(NAMESPACE_REGEX);
|
|
86
78
|
return match ? match[0] : '';
|
|
87
79
|
}
|
|
88
|
-
exports.getNamespaceFromTerm = getNamespaceFromTerm;
|
|
89
80
|
//# sourceMappingURL=plugin-naming.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-naming.js","sourceRoot":"","sources":["../../src/utils/plugin-naming.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-naming.js","sourceRoot":"","sources":["../../src/utils/plugin-naming.ts"],"names":[],"mappings":"AA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|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/load",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "19.0.1",
|
|
4
5
|
"description": "Load shared commitlint configuration",
|
|
5
6
|
"main": "lib/load.js",
|
|
6
7
|
"types": "lib/load.d.ts",
|
|
@@ -35,26 +36,25 @@
|
|
|
35
36
|
},
|
|
36
37
|
"license": "MIT",
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@commitlint/test": "^
|
|
39
|
+
"@commitlint/test": "^19.0.0",
|
|
39
40
|
"@types/lodash.isplainobject": "^4.0.8",
|
|
40
41
|
"@types/lodash.merge": "^4.6.8",
|
|
41
42
|
"@types/lodash.uniq": "^4.5.8",
|
|
42
|
-
"@types/node": "^18.
|
|
43
|
+
"@types/node": "^18.19.17",
|
|
43
44
|
"conventional-changelog-atom": "^4.0.0",
|
|
44
45
|
"typescript": "^5.2.2"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"@commitlint/config-validator": "^
|
|
48
|
-
"@commitlint/execute-rule": "^
|
|
49
|
-
"@commitlint/resolve-extends": "^
|
|
50
|
-
"@commitlint/types": "^
|
|
51
|
-
"chalk": "^
|
|
48
|
+
"@commitlint/config-validator": "^19.0.0",
|
|
49
|
+
"@commitlint/execute-rule": "^19.0.0",
|
|
50
|
+
"@commitlint/resolve-extends": "^19.0.1",
|
|
51
|
+
"@commitlint/types": "^19.0.0",
|
|
52
|
+
"chalk": "^5.3.0",
|
|
52
53
|
"cosmiconfig": "^8.3.6",
|
|
53
54
|
"cosmiconfig-typescript-loader": "^5.0.0",
|
|
54
55
|
"lodash.isplainobject": "^4.0.6",
|
|
55
56
|
"lodash.merge": "^4.6.2",
|
|
56
|
-
"lodash.uniq": "^4.5.0"
|
|
57
|
-
"resolve-from": "^5.0.0"
|
|
57
|
+
"lodash.uniq": "^4.5.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "9351b8e1f4e9fc1ff45e55dabcd2d887ac2a8070"
|
|
60
60
|
}
|