bpmnlint-plugin-camunda-compat 0.1.1 → 0.2.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
@@ -1,15 +1,20 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to [bpmnlint-plugin-example](https://github.com/camunda/bpmnlint-plugin-camunda-compat) are documented here. We use [semantic versioning](http://semver.org/) for releases.
3
+ All notable changes to [bpmnlint-plugin-camunda-compat](https://github.com/camunda/bpmnlint-plugin-camunda-compat) are documented here. We use [semantic versioning](http://semver.org/) for releases.
4
4
 
5
5
  ## Unreleased
6
6
 
7
7
  ___Note:__ Yet to be released changes appear here._
8
8
 
9
- ## 0.0.1
9
+ ## 0.2.0
10
+
11
+ * `FEAT`: early return if execution platform does not match
12
+ * `FIX`: correct check for `bpmn:BaseElement`
13
+
14
+ ## 0.1.1
10
15
 
11
16
  * `FEAT`: initial support for Camunda Cloud 1.0, 1.1, 1.2, and 1.3
12
17
 
13
18
  ## ...
14
19
 
15
- Check `git log` for earlier history.
20
+ Check `git log` for earlier history.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A bpmnlint plug-in for Camunda Cloud and Platform compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,4 +2,4 @@ const { createRule } = require('./utils/rule');
2
2
 
3
3
  const checks = require('./camunda-cloud-1-0-checks');
4
4
 
5
- module.exports = createRule('1.0', checks);
5
+ module.exports = createRule('Camunda Cloud', '1.0', checks);
@@ -2,4 +2,4 @@ const { createRule } = require('./utils/rule');
2
2
 
3
3
  const checks = require('./camunda-cloud-1-1-checks');
4
4
 
5
- module.exports = createRule('1.1', checks);
5
+ module.exports = createRule('Camunda Cloud', '1.1', checks);
@@ -2,4 +2,4 @@ const { createRule } = require('./utils/rule');
2
2
 
3
3
  const checks = require('./camunda-cloud-1-2-checks');
4
4
 
5
- module.exports = createRule('1.2', checks);
5
+ module.exports = createRule('Camunda Cloud', '1.2', checks);
@@ -2,4 +2,4 @@ const { createRule } = require('./utils/rule');
2
2
 
3
3
  const checks = require('./camunda-cloud-1-3-checks');
4
4
 
5
- module.exports = createRule('1.3', checks);
5
+ module.exports = createRule('Camunda Cloud', '1.3', checks);
@@ -11,79 +11,38 @@ const {
11
11
 
12
12
  const { toSemverMinor } = require('./engine-profile');
13
13
 
14
- module.exports.createRule = function(version, checks) {
14
+ module.exports.createRule = function(ruleExecutionPlatform, ruleExecutionPlatformVersion, checks) {
15
15
  return () => {
16
16
  return {
17
17
  check: (node, reporter) => {
18
-
19
- // do not lint properties (yet)
20
- if (!isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
21
- return;
22
- }
23
-
24
- const engineProfile = getEngineProfile(node);
25
-
26
- if (!engineProfile) {
27
- return;
28
- }
29
-
30
- const {
31
- executionPlatform,
32
- executionPlatformVersion
33
- } = engineProfile;
34
-
35
- if (!executionPlatformVersion || toSemverMinor(executionPlatformVersion) !== version) {
18
+ if (is(node, 'bpmn:Definitions')) {
19
+ executionPlatform = node.get('modeler:executionPlatform');
20
+ executionPlatformVersion = node.get('modeler:executionPlatformVersion');
21
+
22
+ if (!executionPlatform
23
+ || executionPlatform !== ruleExecutionPlatform
24
+ || !executionPlatformVersion
25
+ || toSemverMinor(executionPlatformVersion) !== ruleExecutionPlatformVersion) {
26
+ return false;
27
+ }
28
+ } else if (!isAny(node, [ 'bpmn:FlowElement', 'bpmn:FlowElementsContainer' ])) {
36
29
  return;
37
30
  }
38
31
 
39
32
  const result = checkNode(node, checks);
40
33
 
41
34
  if (result === false) {
42
- reporter.report(node.get('id') || '', `Element of type <${ node.$type }> not supported by ${ executionPlatform } ${ toSemverMinor(executionPlatformVersion) }`);
35
+ reporter.report(node.get('id') || '', `Element of type <${ node.$type }> not supported by ${ ruleExecutionPlatform } ${ toSemverMinor(ruleExecutionPlatformVersion) }`);
43
36
  }
44
37
 
45
38
  if (isString(result)) {
46
- reporter.report(node.get('id') || '', `Element of type <${ result }> not supported by ${ executionPlatform } ${ toSemverMinor(executionPlatformVersion) }`);
39
+ reporter.report(node.get('id') || '', `Element of type <${ result }> not supported by ${ ruleExecutionPlatform } ${ toSemverMinor(ruleExecutionPlatformVersion) }`);
47
40
  }
48
41
  }
49
42
  };
50
43
  };
51
44
  }
52
45
 
53
- function getDefinitions(node) {
54
- if (is(node, 'bpmn:Definitions')) {
55
- return node;
56
- }
57
-
58
- const parent = node.$parent;
59
-
60
- if (!parent) {
61
- return null;
62
- }
63
-
64
- return getDefinitions(parent);
65
- }
66
-
67
- function getEngineProfile(node) {
68
- const definitions = getDefinitions(node);
69
-
70
- if (!definitions) {
71
- return null;
72
- }
73
-
74
- const executionPlatform = definitions.get('modeler:executionPlatform'),
75
- executionPlatformVersion = definitions.get('modeler:executionPlatformVersion');
76
-
77
- if (!executionPlatform) {
78
- return null;
79
- }
80
-
81
- return {
82
- executionPlatform,
83
- executionPlatformVersion
84
- };
85
- }
86
-
87
46
  /**
88
47
  * @param {ModdleElement} node
89
48
  * @param {Array<Function>} checks
@@ -226,11 +185,5 @@ module.exports.hasLoopCharacteristicsOfType = function(type) {
226
185
  }
227
186
 
228
187
  module.exports.isNotBpmn = function(node) {
229
- const { $descriptor: descriptor } = node;
230
-
231
- const { $pkg: package } = descriptor;
232
-
233
- const { uri } = package;
234
-
235
- return uri !== 'http://www.omg.org/spec/BPMN/20100524/MODEL';
188
+ return !is(node, 'bpmn:BaseElement');
236
189
  }