From d48fe79b0f1d51c2feecf8a780436b9345caa076 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Thu, 29 Dec 2022 11:05:54 -0800 Subject: [PATCH 1/2] chore: normalize mocha configs - Sorted the JSON - Added a `$schema` ref - Use `require: ts-node/register` here - Remove `require: ts-node/register` from scripts in `package.json` --- .config/mocha.fast.json | 9 +++++---- .config/mocha.full.json | 4 +++- .config/mocha.test-explorer.json | 3 ++- package.json | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.config/mocha.fast.json b/.config/mocha.fast.json index 922306dfc..9e6866d3a 100644 --- a/.config/mocha.fast.json +++ b/.config/mocha.fast.json @@ -1,8 +1,9 @@ { "$schema": "https://json.schemastore.org/mocharc.json", - "timeout": 5000, - "spec": ["src/test/**/*.test.ts"], "exclude": ["src/test/packages/**", "src/test/slow/**"], - "watch-files": ["src/**/*.ts"], - "extension": ["ts", "tsx"] + "extension": ["ts", "tsx"], + "require": ["ts-node/register"], + "spec": ["src/test/**/*.test.ts"], + "timeout": 5000, + "watch-files": ["src/**/*.ts"] } diff --git a/.config/mocha.full.json b/.config/mocha.full.json index 067b822dd..6636bdce8 100644 --- a/.config/mocha.full.json +++ b/.config/mocha.full.json @@ -1,5 +1,7 @@ { + "$schema": "https://json.schemastore.org/mocharc.json", "timeout": 0, "spec": "src/test/**/*.test.ts", - "exclude": ["src/test/packages/**"] + "exclude": ["src/test/packages/**"], + "require": ["ts-node/register"] } diff --git a/.config/mocha.test-explorer.json b/.config/mocha.test-explorer.json index 709e1d2c7..f4b40c445 100644 --- a/.config/mocha.test-explorer.json +++ b/.config/mocha.test-explorer.json @@ -1,10 +1,11 @@ { + "$schema": "https://json.schemastore.org/mocharc.json", "extension": ["ts"], + "ignore": ["src/test/slow/**", "src/test/packages/**"], "package": "./package.json", "require": "ts-node/register", "slow": 500, "spec": ["src/**/*.test.ts"], - "ignore": ["src/test/slow/**", "src/test/packages/**"], "timeout": 0, "watch-files": ["src/**/*.ts"] } diff --git a/package.json b/package.json index 3e00e7d9b..b9b0875c4 100644 --- a/package.json +++ b/package.json @@ -62,11 +62,11 @@ "/tsdoc.json" ], "scripts": { - "test": "mocha -r ts-node/register --config .config/mocha.fast.json", - "test:cov": "c8 mocha -r ts-node/register --config .config/mocha.fast.json", + "test": "mocha --config .config/mocha.fast.json", + "test:cov": "c8 mocha --config .config/mocha.fast.json", "doc:c": "node bin/typedoc --tsconfig src/test/converter/tsconfig.json", "doc:c2": "node bin/typedoc --tsconfig src/test/converter2/tsconfig.json", - "test:full": "c8 mocha -r ts-node/register --config .config/mocha.full.json", + "test:full": "c8 mocha --config .config/mocha.full.json", "test:visual": "ts-node ./src/test/capture-screenshots.ts && ./scripts/compare_screenshots.sh", "test:visual:accept": "node scripts/accept_visual_regression.js", "rebuild_specs": "node scripts/rebuild_specs.js", From e2d5452836b94d775b5a08940e068e63506dcd4b Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Thu, 29 Dec 2022 11:25:22 -0800 Subject: [PATCH 2/2] chore(vscode): update tasks - Creates some build and watch tasks - Removed invalid task - Update `build_themes.js` to run async and support watch mode (watch mode cannot run using `esbuild.buildSync()`) --- .vscode/tasks.json | 77 +++++++++++++++++++++++++++++++++++++---- scripts/build_themes.js | 26 ++++++++------ 2 files changed, 87 insertions(+), 16 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index bc8b7c4fb..030f085c6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,16 +4,81 @@ "version": "2.0.0", "tasks": [ { - "label": "build", + "label": "build-tsc", + "type": "npm", + "script": "build:tsc", + "problemMatcher": ["$tsc"], + "detail": "Build TypeDoc w/ tsc", + "presentation": { + "group": "build", + "panel": "dedicated" + }, + "group": { + "kind": "build" + } + }, + { + "label": "build-themes", + "type": "npm", + "script": "build:themes", + "problemMatcher": ["$esbuild"], + "detail": "Build TypeDoc themes", + "presentation": { + "group": "build", + "panel": "dedicated" + }, + "group": { + "kind": "build" + } + }, + { + "label": "dev-build-tsc", "type": "shell", - "command": "npm run build", - "problemMatcher": ["$tsc"] + "command": "npm run build:tsc -- --watch", + "problemMatcher": ["$tsc-watch"], + "detail": "Build TypeDoc w/ tsc in watch mode", + "isBackground": true, + "presentation": { + "group": "dev", + "panel": "dedicated" + }, + "group": { + "kind": "build" + } }, { - "label": "build_and_test", + "label": "dev-build-themes", "type": "shell", - "command": "npm run build_and_test", - "problemMatcher": ["$tsc"] + "command": "npm run build:themes -- --watch", + "problemMatcher": ["$esbuild-watch"], + "detail": "Build TypeDoc themes in watch mode", + "isBackground": true, + "presentation": { + "group": "dev", + "panel": "dedicated" + }, + "group": { + "kind": "build" + } + }, + { + "label": "dev", + "dependsOn": ["dev-build-tsc", "dev-build-themes"], + "detail": "Build TypeDoc in watch mode", + "problemMatcher": [], + "group": { + "kind": "build" + } + }, + { + "label": "build", + "dependsOn": ["build-tsc", "build-themes"], + "detail": "Build TypeDoc", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + } } ] } diff --git a/scripts/build_themes.js b/scripts/build_themes.js index 39ad2d9ad..09879435c 100644 --- a/scripts/build_themes.js +++ b/scripts/build_themes.js @@ -1,12 +1,18 @@ const esbuild = require("esbuild"); -esbuild.buildSync({ - entryPoints: ["src/lib/output/themes/default/assets/bootstrap.ts"], - bundle: true, - minify: true, - outfile: "static/main.js", - banner: { - js: '"use strict";', - }, - logLevel: "info", -}); +esbuild + .build({ + entryPoints: ["src/lib/output/themes/default/assets/bootstrap.ts"], + bundle: true, + minify: true, + outfile: "static/main.js", + banner: { + js: '"use strict";', + }, + logLevel: "info", + watch: process.argv.slice(2).includes("--watch"), + }) + .catch((err) => { + console.error(err); + process.exitCode = 1; + });