Socket
Socket
Sign inDemoInstall

bpmnlint

Package Overview
Dependencies
Maintainers
8
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bpmnlint - npm Package Compare versions

Comparing version 6.5.0 to 7.0.0

188

bin/bpmnlint.js
#!/usr/bin/env node
const meow = require('meow');
const mri = require('mri');
const fs = require('fs');
const path = require('path');
const colors = require('ansi-colors');
colors.enabled = require('color-support').hasBasic;
const {

@@ -11,3 +15,3 @@ red,

magenta
} = require('chalk');
} = colors;

@@ -28,2 +32,23 @@ const { promisify } = require('util');

const CONFIG_NAME = '.bpmnlintrc';
const DEFAULT_CONFIG_CONTENTS = `{
"extends": "bpmnlint:recommended"
}`;
const HELP_STRING = `
Usage
$ bpmnlint diagram.bpmn
Options
--config, -c Path to configuration file. It overrides .bpmnlintrc if present.
--init Generate a .bpmnlintrc file in the current working directory
Examples
$ bpmnlint ./invoice.bpmn
$ bpmnlint --init
`;
const moddle = new BpmnModdle();

@@ -41,3 +66,3 @@

return Promise.all(
cli.input.map(
files.map(
file => tinyGlob(file, { dot: true })

@@ -50,22 +75,30 @@ )

* Reads XML form path and return moddle object
* @param {*} sourcePath
*
* @param {string} diagramXML
*
* @return { { rootElement: any; warnings: Error[], error?: Error } } parseResult
*/
function parseDiagram(diagramXML) {
return new Promise((resolve, reject) => {
moddle.fromXML(diagramXML, (error, moddleElement, context) => {
async function parseDiagram(diagramXML) {
if (error) {
return resolve({
error
});
}
try {
const {
rootElement: moddleElement,
warnings = []
} = await moddle.fromXML(diagramXML);
const warnings = context.warnings || [];
return {
moddleElement,
warnings
};
} catch (error) {
return resolve({
moddleElement,
warnings
});
});
});
const {
warnings = []
} = error;
return {
error,
warnings
};
}
}

@@ -114,3 +147,14 @@

function errorAndExit(...args) {
console.error(...args);
process.exit(1);
}
function infoAndExit(...args) {
console.log(...args);
process.exit(0);
}
/**

@@ -169,54 +213,2 @@ * Prints lint results to the console

const cli = meow(
`
Usage
$ bpmnlint diagram.bpmn
Options
--config, -c Path to configuration file. It overrides .bpmnlintrc if present.
--init Generate a .bpmnlintrc file in the current working directory
Examples
$ bpmnlint ./invoice.bpmn
$ bpmnlint --init
`,
{
flags: {
init: {
type: 'boolean'
},
config: {
type: 'string',
alias: 'c'
}
}
}
);
if (cli.flags.init) {
if (fs.existsSync('.bpmnlintrc')) {
console.warn('Not overriding existing .bpmnlintrc');
process.exit(1);
}
fs.writeFileSync('.bpmnlintrc', `{
"extends": "bpmnlint:recommended"
}`, 'utf8');
console.error(`Created ${magenta('.bpmnlintrc')} file`);
process.exit(0);
}
if (cli.input.length === 0) {
console.log('Error: bpmn file path missing');
process.exit(1);
}
function logAndExit(...args) {
console.error(...args);
process.exit(1);
}
async function lintDiagram(diagramPath, config) {

@@ -229,3 +221,3 @@

} catch (error) {
return logAndExit(`Error: Failed to read ${diagramPath}\n\n%s`, error.message);
return errorAndExit(`Error: Failed to read ${diagramPath}\n\n%s`, error.message);
}

@@ -284,7 +276,7 @@

} catch (e) {
return logAndExit(e);
return errorAndExit(e);
}
}
async function lint(config) {
async function lint(files, config) {

@@ -296,4 +288,2 @@ let errorCount = 0;

const files = await glob(cli.input);
for (let i = 0; i < files.length; i++) {

@@ -333,6 +323,34 @@ let results = await lintDiagram(files[i], config);

const configOverridePath = cli.flags.config;
const {
help,
init,
config: configOverridePath,
_: files
} = mri(process.argv.slice(2), {
string: [ 'config' ],
alias: {
c: 'config'
}
});
const configPath = configOverridePath || '.bpmnlintrc';
if (help) {
return infoAndExit(HELP_STRING);
}
if (init) {
if (fs.existsSync(CONFIG_NAME)) {
return errorAndExit('Not overriding existing .bpmnlintrc');
}
fs.writeFileSync(CONFIG_NAME, DEFAULT_CONFIG_CONTENTS, 'utf8');
return infoAndExit(`Created ${magenta(CONFIG_NAME)} file`);
}
if (files.length === 0) {
return errorAndExit('Error: bpmn file path missing');
}
const configPath = configOverridePath || CONFIG_NAME;
let configString, config;

@@ -346,4 +364,4 @@

configOverridePath
? `Error: Could not read ${ configOverridePath }`
: `Error: Could not locate local ${ magenta('.bpmnlintrc') } file. Create one via
? `Error: Could not read ${ magenta(configOverridePath) }`
: `Error: Could not locate local ${ magenta(CONFIG_NAME) } file. Create one via

@@ -355,3 +373,3 @@ ${magenta('bpmnlint --init')}

return logAndExit(message);
return errorAndExit(message);
}

@@ -362,8 +380,10 @@

} catch (err) {
return logAndExit('Error: Could not parse %s\n\n%s', configPath, err.message);
return errorAndExit('Error: Could not parse %s\n\n%s', configPath, err.message);
}
return lint(config);
const actualFiles = await glob(files);
return lint(actualFiles, config);
}
run().catch(logAndExit);
run().catch(errorAndExit);

@@ -9,2 +9,8 @@ # Changelog

## 7.0.0
* `CHORE`: update to `bpmn-moddle@7`
* `CHORE`: reduce library footprint
* `CHORE`: require `NodeJS>=10`
## 6.5.0

@@ -11,0 +17,0 @@

@@ -51,2 +51,3 @@ const Module = require('module');

} catch (err) {
/* ignore */

@@ -53,0 +54,0 @@ }

@@ -13,18 +13,18 @@ const BpmnModdle = require('bpmn-moddle');

*/
function createModdle(xml, elementType = 'bpmn:Definitions') {
async function createModdle(xml, elementType = 'bpmn:Definitions') {
const moddle = new BpmnModdle();
return new Promise((resolve, reject) => {
moddle.fromXML(xml, elementType, { lax: true }, function(err, root, context) {
if (err) {
return reject(err);
} else {
return resolve({
root,
context,
moddle
});
}
});
});
const {
rootElement: root,
warnings = []
} = await moddle.fromXML(xml, elementType, { lax: true });
return {
root,
moddle,
context: {
warnings
},
warnings
};
}

@@ -31,0 +31,0 @@

{
"name": "bpmnlint",
"description": "Validate your BPMN diagrams based on configurable lint rules",
"version": "6.5.0",
"version": "7.0.0",
"main": "lib/index.js",

@@ -26,3 +26,3 @@ "keywords": [

"engines": {
"node": ">= 8"
"node": ">= 10"
},

@@ -41,7 +41,8 @@ "license": "MIT",

"dependencies": {
"bpmn-moddle": "^6.0.0",
"bpmnlint-utils": "^1.0.1",
"chalk": "^2.4.2",
"ansi-colors": "^4.1.1",
"bpmn-moddle": "^7.0.3",
"bpmnlint-utils": "^1.0.2",
"cli-table": "^0.3.1",
"meow": "^5.0.0",
"color-support": "^1.1.3",
"mri": "^1.1.6",
"pluralize": "^7.0.0",

@@ -52,12 +53,12 @@ "tiny-glob": "^0.2.8"

"chai": "^4.2.0",
"eslint": "^5.16.0",
"eslint-plugin-bpmn-io": "^0.8.2",
"eslint": "^7.14.0",
"eslint-plugin-bpmn-io": "^0.11.0",
"esm": "^3.2.25",
"execa": "^2.0.3",
"install-local": "^1.0.0",
"mocha": "^6.2.0",
"mocha": "^8.2.1",
"npm-run-all": "^4.1.5",
"nyc": "^14.1.1",
"nyc": "^15.1.0",
"strip-indent": "^2.0.0"
}
}

@@ -32,2 +32,3 @@ const {

if (is(node, 'bpmn:SubProcess')) {
// TODO(nikku): better ignore expanded sub-processes only

@@ -34,0 +35,0 @@ return;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc