From b41b619dfd4aa589efcc569d6ebead6cd1e81262 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Mon, 12 Jun 2023 10:51:35 +0700 Subject: [PATCH] feat(common/web): adds c8 for web/utils, web/keyboard-processor --- common/web/input-processor/build-bundler.js | 1 - common/web/keyboard-processor/.c8rc.json | 15 +++++++++++++++ common/web/keyboard-processor/build-bundler.js | 1 - common/web/keyboard-processor/build.sh | 2 +- common/web/keyboard-processor/package.json | 4 +++- .../src/keyboards/defaultLayouts.ts | 2 ++ .../src/keyboards/loaders/tsconfig.dom.json | 1 - .../src/keyboards/loaders/tsconfig.node.json | 1 - .../keyboard-processor/src/keyboards/test.ts | 5 ----- .../web/keyboard-processor/tsconfig.common.json | 1 - common/web/keyboard-processor/tsconfig.json | 1 - common/web/utils/.c8rc.json | 17 +++++++++++++++++ common/web/utils/build.sh | 2 +- common/web/utils/package.json | 2 ++ common/web/utils/src/test/managedPromise.js | 2 +- common/web/utils/src/test/versions.js | 2 +- package-lock.json | 4 ++++ 17 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 common/web/keyboard-processor/.c8rc.json delete mode 100644 common/web/keyboard-processor/src/keyboards/test.ts create mode 100644 common/web/utils/.c8rc.json diff --git a/common/web/input-processor/build-bundler.js b/common/web/input-processor/build-bundler.js index f16b207454..319a50f318 100644 --- a/common/web/input-processor/build-bundler.js +++ b/common/web/input-processor/build-bundler.js @@ -6,7 +6,6 @@ */ import esbuild from 'esbuild'; -import { spawn } from 'child_process'; // Bundled ES module version esbuild.buildSync({ diff --git a/common/web/keyboard-processor/.c8rc.json b/common/web/keyboard-processor/.c8rc.json new file mode 100644 index 0000000000..ceca963e15 --- /dev/null +++ b/common/web/keyboard-processor/.c8rc.json @@ -0,0 +1,15 @@ +{ + "check-coverage": false, + "clean": true, + "exclude": [ + "src/keyboards/loaders/dom*", + "node_modules/*", + "tests" + ], + "exclude-after-remap": true, + "reporter": ["text", "text-summary"], + "reports-dir": "build/coverage", + "src": [ + "src/" + ] +} \ No newline at end of file diff --git a/common/web/keyboard-processor/build-bundler.js b/common/web/keyboard-processor/build-bundler.js index 87625dd19c..7feb15d49f 100644 --- a/common/web/keyboard-processor/build-bundler.js +++ b/common/web/keyboard-processor/build-bundler.js @@ -6,7 +6,6 @@ */ import esbuild from 'esbuild'; -import { spawn } from 'child_process'; /** @type {esbuild.BuildOptions} */ const commonConfig = { diff --git a/common/web/keyboard-processor/build.sh b/common/web/keyboard-processor/build.sh index 01939b9e62..55c5a9294b 100755 --- a/common/web/keyboard-processor/build.sh +++ b/common/web/keyboard-processor/build.sh @@ -69,7 +69,7 @@ if builder_start_action test; then KARMA_CONFIG=CI.conf.cjs fi - mocha --recursive $MOCHA_FLAGS ./tests/node/ + c8 mocha --recursive $MOCHA_FLAGS ./tests/node/ karma start ./tests/dom/$KARMA_CONFIG builder_finish_action success test diff --git a/common/web/keyboard-processor/package.json b/common/web/keyboard-processor/package.json index 62a035ba05..747a2bbd9c 100644 --- a/common/web/keyboard-processor/package.json +++ b/common/web/keyboard-processor/package.json @@ -18,6 +18,7 @@ "homepage": "https://github.com/keymanapp/keyman#readme", "devDependencies": { "@keymanapp/resources-gosh": "*", + "c8": "^7.12.0", "chai": "^4.3.4", "karma": "^6.4.1", "karma-chai": "^0.1.0", @@ -35,7 +36,8 @@ "clean": "tsc -b --clean tsconfig.json", "karma": "karma", "test": "gosh ./test.sh", - "mocha": "mocha" + "mocha": "mocha", + "c8": "c8" }, "dependencies": { "@keymanapp/models-types": "*", diff --git a/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts b/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts index 4a692dab1d..8d187ac854 100644 --- a/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts +++ b/common/web/keyboard-processor/src/keyboards/defaultLayouts.ts @@ -548,6 +548,7 @@ export class Layouts { } // Defines the default visual layout for a keyboard. + /* c8 ignore start */ static dfltLayout: LayoutSpec = { "desktop": { @@ -847,4 +848,5 @@ export class Layouts { ] } }; + /* c8 ignore end */ } diff --git a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json b/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json index e5ab52729e..29824bc5d7 100644 --- a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json +++ b/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.dom.json @@ -9,7 +9,6 @@ "importHelpers": true, "inlineSources": true, "sourceMap": true, - "sourceRoot": "keyman/", "target": "es5", "types": ["node"], "lib": ["es6"], diff --git a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json b/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json index 7175be8333..08cdff18db 100644 --- a/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json +++ b/common/web/keyboard-processor/src/keyboards/loaders/tsconfig.node.json @@ -8,7 +8,6 @@ "declaration": true, "inlineSources": true, "sourceMap": true, - "sourceRoot": "keyman/", "target": "es5", "types": ["node"], "lib": ["es6"], diff --git a/common/web/keyboard-processor/src/keyboards/test.ts b/common/web/keyboard-processor/src/keyboards/test.ts deleted file mode 100644 index 65d3beae0c..0000000000 --- a/common/web/keyboard-processor/src/keyboards/test.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This specific module is allowed to reference the DOM in order to facilitate loading the keyboards -// into the DOM. - -/// - diff --git a/common/web/keyboard-processor/tsconfig.common.json b/common/web/keyboard-processor/tsconfig.common.json index 30fcd19eda..0bf6854b2c 100644 --- a/common/web/keyboard-processor/tsconfig.common.json +++ b/common/web/keyboard-processor/tsconfig.common.json @@ -9,7 +9,6 @@ "importHelpers": true, "inlineSources": true, "sourceMap": true, - "sourceRoot": "keyman/", "target": "es5", "types": ["node"], "lib": ["es6"], diff --git a/common/web/keyboard-processor/tsconfig.json b/common/web/keyboard-processor/tsconfig.json index 95071c36a7..9a7f1025b8 100644 --- a/common/web/keyboard-processor/tsconfig.json +++ b/common/web/keyboard-processor/tsconfig.json @@ -9,7 +9,6 @@ "importHelpers": true, "inlineSources": true, "sourceMap": true, - "sourceRoot": "keyman/", "target": "es5", "types": ["node"], "lib": ["es6"], diff --git a/common/web/utils/.c8rc.json b/common/web/utils/.c8rc.json new file mode 100644 index 0000000000..d9074b62f3 --- /dev/null +++ b/common/web/utils/.c8rc.json @@ -0,0 +1,17 @@ +{ + "all": true, + "check-coverage": false, + "clean": true, + "exclude": [ + "src/deviceSpec.ts", + "src/globalObject.ts", + "node_modules/*", + "src/test" + ], + "exclude-after-remap": true, + "reporter": ["text", "text-summary"], + "reports-dir": "build/coverage", + "src": [ + "src/" + ] +} \ No newline at end of file diff --git a/common/web/utils/build.sh b/common/web/utils/build.sh index d4ff9ef8f3..0445186df6 100755 --- a/common/web/utils/build.sh +++ b/common/web/utils/build.sh @@ -58,7 +58,7 @@ if builder_start_action test; then FLAGS="$FLAGS --reporter mocha-teamcity-reporter" fi - mocha --recursive $FLAGS ./src/test/ + c8 mocha --recursive $FLAGS ./src/test/ builder_finish_action success test fi \ No newline at end of file diff --git a/common/web/utils/package.json b/common/web/utils/package.json index 31e8388bb7..b487300011 100644 --- a/common/web/utils/package.json +++ b/common/web/utils/package.json @@ -19,6 +19,7 @@ }, "scripts": { "build": "gosh ./build.sh", + "c8": "c8", "clean": "tsc -b --clean", "mocha": "mocha", "tsc": "tsc" @@ -36,6 +37,7 @@ "devDependencies": { "@keymanapp/resources-gosh": "*", "@keymanapp/keyman-version": "*", + "c8": "^7.12.0", "chai": "^4.3.4", "mocha": "^10.0.0", "mocha-teamcity-reporter": "^4.0.0", diff --git a/common/web/utils/src/test/managedPromise.js b/common/web/utils/src/test/managedPromise.js index c189303276..7d2cfaf816 100644 --- a/common/web/utils/src/test/managedPromise.js +++ b/common/web/utils/src/test/managedPromise.js @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import ManagedPromise from '../../build/obj/managedPromise.js'; +import { ManagedPromise } from '@keymanapp/web-utils'; describe("ManagedPromise", () => { it(' resolution', async () => { diff --git a/common/web/utils/src/test/versions.js b/common/web/utils/src/test/versions.js index e6cf422dc4..36ed51cbac 100644 --- a/common/web/utils/src/test/versions.js +++ b/common/web/utils/src/test/versions.js @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import Version from '../../build/obj/version.js'; +import { Version } from '@keymanapp/web-utils'; describe('Version Logic', function() { it('Should provide a default, fallback value when nothing is specified', function() { diff --git a/package-lock.json b/package-lock.json index 960e9a3047..2b75063847 100644 --- a/package-lock.json +++ b/package-lock.json @@ -227,6 +227,7 @@ "@keymanapp/kmc": "*", "@keymanapp/resources-gosh": "*", "@types/node": "^11.9.4", + "c8": "^7.12.0", "chai": "^4.3.4", "mocha": "^10.0.0", "mocha-teamcity-reporter": "^4.0.0", @@ -245,6 +246,7 @@ }, "devDependencies": { "@keymanapp/resources-gosh": "*", + "c8": "^7.12.0", "chai": "^4.3.4", "karma": "^6.4.1", "karma-chai": "^0.1.0", @@ -296,6 +298,7 @@ "@keymanapp/models-types": "*", "@keymanapp/resources-gosh": "*", "@types/node": "^10.17.21", + "c8": "^7.12.0", "chai": "^4.3.4", "combine-source-map": "^0.8.0", "karma": "^6.4.1", @@ -608,6 +611,7 @@ "@keymanapp/keyman-version": "*", "@keymanapp/resources-gosh": "*", "@types/node": "^14.0.5", + "c8": "^7.12.0", "chai": "^4.3.4", "mocha": "^10.0.0", "mocha-teamcity-reporter": "^4.0.0",