From 44301d1830afa377bf9bf61ea05898bfe098c1e6 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 21 Dec 2020 13:32:16 +0100 Subject: [PATCH] chore: add 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 --- package-lock.json | 30 ++++++++++++++++++++++++++++++ package.json | 4 ++++ test/config/karma.unit.js | 9 ++++++++- test/spec/ModelerSpec.js | 5 ++++- test/spec/NavigatedViewerSpec.js | 4 +++- test/spec/ViewerSpec.js | 4 +++- 6 files changed, 52 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 22a5fe98..173bd766 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index a68a4c6a..1ec0afaf 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/config/karma.unit.js b/test/config/karma.unit.js index 458b8364..4154a1b7 100644 --- a/test/config/karma.unit.js +++ b/test/config/karma.unit.js @@ -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); }; diff --git a/test/spec/ModelerSpec.js b/test/spec/ModelerSpec.js index 0afd5eb0..2e266156 100644 --- a/test/spec/ModelerSpec.js +++ b/test/spec/ModelerSpec.js @@ -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) { diff --git a/test/spec/NavigatedViewerSpec.js b/test/spec/NavigatedViewerSpec.js index 853206b4..2717b166 100644 --- a/test/spec/NavigatedViewerSpec.js +++ b/test/spec/NavigatedViewerSpec.js @@ -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) { diff --git a/test/spec/ViewerSpec.js b/test/spec/ViewerSpec.js index 3840fc5c..93fff9db 100644 --- a/test/spec/ViewerSpec.js +++ b/test/spec/ViewerSpec.js @@ -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