chore: add <npm start> script

This script is the one stop utility that allows users to open a modeler
or viewer instance, directly within your browser.

Works via a custom launcher that openes the {KARMA_BASE}/debug.html
page in your default web browser.

Closes https://github.com/bpmn-io/bpmn-js/issues/1396
This commit is contained in:
Nico Rehwaldt 2020-12-21 13:32:16 +01:00 committed by Nico Rehwaldt
parent 3426e93b6a
commit 44301d1830
6 changed files with 52 additions and 4 deletions

30
package-lock.json generated
View File

@ -6523,6 +6523,15 @@
}
}
},
"karma-debug-launcher": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/karma-debug-launcher/-/karma-debug-launcher-0.0.3.tgz",
"integrity": "sha512-YYGby+j0hC4FIyfjgddlpxB7eQWYkVhsYlThqTQoZXmGM2XM87FII22VePuhBbD7xJaM92rvcXsgWAviS94pSA==",
"dev": true,
"requires": {
"open": "^7.3.0"
}
},
"karma-env-preprocessor": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/karma-env-preprocessor/-/karma-env-preprocessor-0.1.1.tgz",
@ -8164,6 +8173,27 @@
"wrappy": "1"
}
},
"open": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/open/-/open-7.3.0.tgz",
"integrity": "sha512-mgLwQIx2F/ye9SmbrUkurZCnkoXyXyu9EbHtJZrICjVAJfyMArdHp3KkixGdZx1ZHFPNIwl0DDM1dFFqXbTLZw==",
"dev": true,
"requires": {
"is-docker": "^2.0.0",
"is-wsl": "^2.1.1"
},
"dependencies": {
"is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"dev": true,
"requires": {
"is-docker": "^2.0.0"
}
}
}
},
"optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",

View File

@ -5,6 +5,9 @@
"scripts": {
"all": "run-s lint test distro test:distro",
"lint": "eslint .",
"start": "SINGLE_START=modeler npm run dev",
"start:viewer": "SINGLE_START=viewer npm run dev",
"start:navigated-viewer": "SINGLE_START=navigated-viewer npm run dev",
"dev": "npm test -- --auto-watch --no-single-run",
"test": "karma start test/config/karma.unit.js",
"distro": "node tasks/build-distro.js",
@ -56,6 +59,7 @@
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-debug-launcher": "0.0.3",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^2.1.0",
"karma-ie-launcher": "^1.0.0",

View File

@ -2,6 +2,8 @@ var path = require('path');
var collectTranslations = process.env.COLLECT_TRANSLATIONS;
var singleStart = process.env.SINGLE_START;
var coverage = process.env.COVERAGE;
// configures browsers to run test against
@ -90,10 +92,15 @@ module.exports = function(karma) {
};
if (collectTranslations) {
config.plugins = [].concat(config.plugins || [], 'karma-*', require('./translation-reporter'));
config.plugins = [].concat(config.plugins || ['karma-*'], require('./translation-reporter'));
config.reporters = [].concat(config.reporters || [], 'translation-reporter');
config.envPreprocessor = [].concat(config.envPreprocessor || [], 'COLLECT_TRANSLATIONS');
}
if (singleStart) {
config.browsers = [].concat(config.browsers, 'Debug');
config.envPreprocessor = [].concat(config.envPreprocessor || [], 'SINGLE_START');
}
karma.set(config);
};

View File

@ -15,6 +15,9 @@ import {
} from 'test/TestHelper';
var singleStart = window.__env__ && window.__env__.SINGLE_START === 'modeler';
describe('Modeler', function() {
var container;
@ -46,7 +49,7 @@ describe('Modeler', function() {
}
it('should import simple process', function() {
(singleStart ? it.only : it)('should import simple process', function() {
var xml = require('../fixtures/bpmn/simple.bpmn');
return createModeler(xml).then(function(result) {

View File

@ -8,6 +8,8 @@ import {
createViewer
} from 'test/TestHelper';
var singleStart = window.__env__ && window.__env__.SINGLE_START === 'navigated-viewer';
describe('NavigatedViewer', function() {
@ -18,7 +20,7 @@ describe('NavigatedViewer', function() {
});
it('should import simple process', function() {
(singleStart ? it.only : it)('should import simple process', function() {
var xml = require('../fixtures/bpmn/simple.bpmn');
return createViewer(container, NavigatedViewer, xml).then(function(result) {

View File

@ -12,6 +12,8 @@ import {
createViewer
} from 'test/TestHelper';
var singleStart = window.__env__ && window.__env__.SINGLE_START === 'viewer';
describe('Viewer', function() {
@ -22,7 +24,7 @@ describe('Viewer', function() {
});
it('should import simple process', function() {
(singleStart ? it.only : it)('should import simple process', function() {
var xml = require('../fixtures/bpmn/simple.bpmn');
// when