bpmnlint 7.3.0 → 7.4.0
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
CHANGED
|
@@ -6,6 +6,10 @@ All notable changes to [bpmnlint](https://github.com/bpmn-io/bpmnlint) are docum
|
|
|
6
6
|
|
|
7
7
|
___Note:__ Yet to be released changes appear here._
|
|
8
8
|
|
|
9
|
+
## 7.4.0
|
|
10
|
+
|
|
11
|
+
* `FEAT`: resolve local package by name ([#64](https://github.com/bpmn-io/bpmnlint/pull/64))
|
|
12
|
+
|
|
9
13
|
## 7.3.0
|
|
10
14
|
|
|
11
15
|
* `FEAT`: support `--version` command line flag ([#65](https://github.com/bpmn-io/bpmnlint/pull/65))
|
|
@@ -9,6 +9,12 @@ function NodeResolver(options) {
|
|
|
9
9
|
this.require = options && options.require || createScopedRequire(process.cwd());
|
|
10
10
|
|
|
11
11
|
this.requireLocal = options && options.requireLocal || require;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
this.pkg = this.require('./package.json').name;
|
|
15
|
+
} catch (err) {
|
|
16
|
+
this.pkg = '__unknown';
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
module.exports = NodeResolver;
|
|
@@ -16,6 +22,10 @@ module.exports = NodeResolver;
|
|
|
16
22
|
|
|
17
23
|
NodeResolver.prototype.resolveRule = function(pkg, ruleName) {
|
|
18
24
|
|
|
25
|
+
const originalPkg = pkg;
|
|
26
|
+
|
|
27
|
+
pkg = this.normalizePkg(pkg);
|
|
28
|
+
|
|
19
29
|
try {
|
|
20
30
|
if (pkg === 'bpmnlint') {
|
|
21
31
|
return this.requireLocal(`../../rules/${ruleName}`);
|
|
@@ -23,12 +33,16 @@ NodeResolver.prototype.resolveRule = function(pkg, ruleName) {
|
|
|
23
33
|
return this.require(`${pkg}/rules/${ruleName}`);
|
|
24
34
|
}
|
|
25
35
|
} catch (err) {
|
|
26
|
-
throw new Error('Cannot resolve rule <' + ruleName + '> from <' +
|
|
36
|
+
throw new Error('Cannot resolve rule <' + ruleName + '> from <' + originalPkg + '>');
|
|
27
37
|
}
|
|
28
38
|
};
|
|
29
39
|
|
|
30
40
|
NodeResolver.prototype.resolveConfig = function(pkg, configName) {
|
|
31
41
|
|
|
42
|
+
const originalPkg = pkg;
|
|
43
|
+
|
|
44
|
+
pkg = this.normalizePkg(pkg);
|
|
45
|
+
|
|
32
46
|
// resolve config via $PKG/config/$NAME
|
|
33
47
|
try {
|
|
34
48
|
if (pkg === 'bpmnlint') {
|
|
@@ -53,10 +67,17 @@ NodeResolver.prototype.resolveConfig = function(pkg, configName) {
|
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
throw new Error(
|
|
56
|
-
'Cannot resolve config <' + configName + '> from <' +
|
|
70
|
+
'Cannot resolve config <' + configName + '> from <' + originalPkg + '>'
|
|
57
71
|
);
|
|
58
72
|
};
|
|
59
73
|
|
|
74
|
+
NodeResolver.prototype.normalizePkg = function(pkg) {
|
|
75
|
+
if (pkg !== 'bpmnlint' && pkg === this.pkg) {
|
|
76
|
+
pkg = '.';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return pkg;
|
|
80
|
+
};
|
|
60
81
|
|
|
61
82
|
// helpers ////////////////////
|
|
62
83
|
|
|
@@ -7,13 +7,15 @@ const NodeResolver = require('../resolver/node-resolver');
|
|
|
7
7
|
* a { config, resolver } bundle, resolving all enabled rules.
|
|
8
8
|
*
|
|
9
9
|
* @param {Object} config the parsed bpmnlint configuration
|
|
10
|
-
*
|
|
10
|
+
* @param {NodeResolver} [resolver]
|
|
11
11
|
* @return {Promise<String>} the configuration compiled to a JS file
|
|
12
12
|
*/
|
|
13
|
-
async function compileConfig(config) {
|
|
13
|
+
async function compileConfig(config, resolver) {
|
|
14
|
+
|
|
15
|
+
resolver = resolver || new NodeResolver();
|
|
14
16
|
|
|
15
17
|
const linter = new Linter({
|
|
16
|
-
resolver
|
|
18
|
+
resolver
|
|
17
19
|
});
|
|
18
20
|
|
|
19
21
|
const resolvedRules = await linter.resolveConfiguredRules(config);
|
|
@@ -86,7 +88,7 @@ export default bundle;
|
|
|
86
88
|
} = linter.parseRuleName(key);
|
|
87
89
|
|
|
88
90
|
return `
|
|
89
|
-
import rule_${idx} from '${pkg}/rules/${ruleName}';
|
|
91
|
+
import rule_${idx} from '${resolver.normalizePkg(pkg)}/rules/${ruleName}';
|
|
90
92
|
cache['${pkg}/${ruleName}'] = rule_${idx};`;
|
|
91
93
|
}).join('\n');
|
|
92
94
|
|