aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-23 06:18:56 -0500
committerGitHub <noreply@github.com>2024-02-23 11:18:56 +0000
commit8078e0ec7279916e56bdc8bab88ee7f1e1594425 (patch)
treea817e8aa6d8a8f3647e341c45a3cca5eebe44811
parent62ac615450ef8b96fa9dd90b8b4e7fe486cc77a6 (diff)
Package scripts update (#714)
* Update license-report commands * Rename build-libs * Update test-lint-js * Rename test-lint-json * Update test-lint-css * Rename test-lint-html * Update test-ts * Update test-code * Update test-build * Rename * Test JSON types * Distinguish JS tests from JSON tests * Add bench test * Test markdown * Add fast test option * Rename test:code * Describe scripts * Add test-build action * Add test:static-analysis * Update CI * Fix path * Fix missing type definition
-rw-r--r--.github/workflows/bench.yml2
-rw-r--r--.github/workflows/broken-links.yml2
-rw-r--r--.github/workflows/ci.yml99
-rw-r--r--.github/workflows/create-prerelease-on-tag.yml2
-rw-r--r--README.md2
-rw-r--r--benches/jsconfig.json3
-rw-r--r--docs/development/npm-scripts.md86
-rw-r--r--package.json40
8 files changed, 181 insertions, 55 deletions
diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml
index 775e94a7..004e806b 100644
--- a/.github/workflows/bench.yml
+++ b/.github/workflows/bench.yml
@@ -22,7 +22,7 @@ jobs:
run: npm ci
- name: Build Libs
- run: npm run build-libs
+ run: npm run build:libs
- name: Run Benchmarks
uses: CodSpeedHQ/action@v2
diff --git a/.github/workflows/broken-links.yml b/.github/workflows/broken-links.yml
index 4cea3b06..b5d296ea 100644
--- a/.github/workflows/broken-links.yml
+++ b/.github/workflows/broken-links.yml
@@ -20,7 +20,7 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Build Legal
- run: npm run license-report
+ run: npm run license-report:html
- uses: lycheeverse/lychee-action@c053181aa0c3d17606addfe97a9075a32723548a
with:
fail: true
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ea42aab4..a9c56cdc 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -10,9 +10,72 @@ on:
merge_group:
jobs:
- test:
+ static-analysis:
+ name: Static Analysis
runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup node
+ uses: actions/setup-node@v4
+ with:
+ node-version-file: "package.json"
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Build third-party libraries
+ run: npm run build:libs
+
+ - name: Run static analysis tests
+ run: npm run test:static-analysis
+
+ static-analysis-json:
+ name: Static Analysis (JSON)
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup node
+ uses: actions/setup-node@v4
+ with:
+ node-version-file: "package.json"
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Build third-party libraries
+ run: npm run build:libs
+
+ - name: Run static analysis tests
+ run: npm run test:json
+
+ unit-tests:
+ name: Unit Tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ - name: Setup node
+ uses: actions/setup-node@v4
+ with:
+ node-version-file: "package.json"
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Build third-party libraries
+ run: npm run build:libs
+
+ - name: Run unit tests
+ run: npm run test:unit
+
+ test-build:
+ name: Test Build
+ runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -26,40 +89,10 @@ jobs:
run: npm ci
- name: Build Libs
- run: npm run build-libs
-
- - name: Lint JS
- run: npm run test-lint-js
- env:
- CI: true
-
- - name: Validate JS Types
- run: npm run test-ts
- env:
- CI: true
-
- - name: Lint CSS
- run: npm run test-lint-css
- env:
- CI: true
-
- - name: Lint HTML
- run: npm run test-lint-html
- env:
- CI: true
-
- - name: Tests
- run: npm run test-code
- env:
- CI: true
-
- - name: Test JSON
- run: npm run test-json
- env:
- CI: true
+ run: npm run build:libs
- name: Build Legal
- run: npm run license-report
+ run: npm run license-report:html
- name: Build
run: npm run build
diff --git a/.github/workflows/create-prerelease-on-tag.yml b/.github/workflows/create-prerelease-on-tag.yml
index 6f82a85e..884d7902 100644
--- a/.github/workflows/create-prerelease-on-tag.yml
+++ b/.github/workflows/create-prerelease-on-tag.yml
@@ -26,7 +26,7 @@ jobs:
run: npm ci
- name: Build Legal
- run: npm run license-report
+ run: npm run license-report:html
- name: Build
run: npm run-script build -- --all --version ${{ github.ref_name }}
diff --git a/README.md b/README.md
index 810235a1..2ae53a79 100644
--- a/README.md
+++ b/README.md
@@ -115,7 +115,7 @@ Required licensing notices for this project follow below:
Yomitan uses several third-party libraries to function.
-<!-- The following table is generated using the command `npm run license-report-markdown`. -->
+<!-- The following table is generated using the command `npm run license-report:markdown`. -->
| Name | Installed version | License type | Link |
| :------------------ | :---------------- | :----------- | :----------------------------------------------- |
diff --git a/benches/jsconfig.json b/benches/jsconfig.json
index 8743868a..eb7512c4 100644
--- a/benches/jsconfig.json
+++ b/benches/jsconfig.json
@@ -18,7 +18,8 @@
"test/*": ["../types/test/*"],
"rollup/parseAst": ["../types/other/rollup-parse-ast"],
"ext/json-schema": ["../types/ext/json-schema"],
- "json-schema": ["json-schema"]
+ "json-schema": ["json-schema"],
+ "chai": ["../node_modules/@vitest/expect/dist/chai.d.cts"]
},
"types": [
"chrome",
diff --git a/docs/development/npm-scripts.md b/docs/development/npm-scripts.md
new file mode 100644
index 00000000..522be174
--- /dev/null
+++ b/docs/development/npm-scripts.md
@@ -0,0 +1,86 @@
+# npm Scripts
+
+This file documents the scripts available in the [package.json](../../package.json) file.
+Scripts can be executed by running `npm run <name>`.
+
+- `bench`
+ Runs performance benchmarks.
+
+- `build`
+ Builds packages for all of the primary build targets and outputs them to the builds folder in the root project directory.
+
+- `build:libs`
+ Rebuilds all of the third-party dependencies that the extension uses.
+
+- `test`
+ Runs all of the tests.
+
+- `test:fast`
+ Runs most of the tests that are used more frequently in the typical development process.
+
+- `test:static-analysis`
+ Runs all of the static analysis tests.
+
+- `test:js`
+ Runs [eslint](https://eslint.org/) on all of the JavaScript and TypeScript files in the project.
+
+- `test:json`
+ Runs all JSON tests.
+
+- `test:json:format`
+ Runs eslint on all of the JSON files in the project.
+
+- `test:json:types`
+ Performs type checking on all of the JSON files in the project.
+ Running this script often takes a long time since it has to validate a lot of files with complex types.
+
+- `test:css`
+ Runs [stylelint](https://stylelint.io/) on all of the CSS files in the project.
+
+- `test:html`
+ Runs [html-validate](https://html-validate.org/) on all of the HTML files in the project.
+
+- `test:md`
+ Runs [prettier](https://prettier.io/) on all of the Markdown files in the project.
+
+- `test:md:write`
+ Uses prettier to fix all issues it encounters with files.
+
+- `test:ts`
+ Runs [TypeScript](https://www.typescriptlang.org/) validation on all of the JavaScript and TypeScript files in the project.
+
+- `test:ts:main`
+ Runs [TypeScript](https://www.typescriptlang.org/) validation on the files in the [ext](../../ext/) folder.
+
+- `test:ts:dev`
+ Runs [TypeScript](https://www.typescriptlang.org/) validation on the files in the [dev](../../dev/) folder.
+
+- `test:ts:test`
+ Runs [TypeScript](https://www.typescriptlang.org/) validation on the files in the [test](../../test/) folder.
+
+- `test:ts:bench`
+ Runs [TypeScript](https://www.typescriptlang.org/) validation on the files in the [benches](../../benches/) folder.
+
+- `test:unit`
+ Runs all of the unit tests in the project using [vitest](https://vitest.dev/).
+
+- `test:unit:write`
+ Overwrites the expected test output data for some of the larger tests.
+ This usually only needs to be run when something modifies the format of dictionary entries or Anki data.
+
+- `test:unit:options`
+ Runs unit tests related to the extension's options and their upgrade process.
+
+- `test:build`
+ Performs a dry run of the build process without generating any files.
+
+- `license-report:html`
+ Generates a file containing license information about the third-party dependencies the extension uses.
+ The resulting file is located at ext/legal-npm.html.
+
+- `license-report:markdown`
+ Generates a Markdown table containing license information about the third-party dependencies the extension uses.
+ This table is located in the [README.md](../../README.md#third-party-libraries) file
+
+- `prepare`
+ Sets up [husky](https://typicode.github.io/husky/) for some git pre-commit tasks.
diff --git a/package.json b/package.json
index 715977f8..2012bc89 100644
--- a/package.json
+++ b/package.json
@@ -12,23 +12,29 @@
"scripts": {
"bench": "vitest bench",
"build": "node ./dev/bin/build.js",
- "build-libs": "node ./dev/bin/build-libs.js",
- "test": "npm run test-lint-js && npm run test-ts && npm run test-lint-css && npm run test-lint-html && npm run test-code && npm run test-json && npm run test-build",
- "test-lint-js": "npx eslint .",
- "test-lint-json": "npx eslint **/*.json",
- "test-lint-css": "npx stylelint \"ext/**/*.css\" \"test/**/*.css\" \"dev/**/*.css\"",
- "test-lint-html": "npx html-validate \"ext/**/*.html\" \"test/**/*.html\" \"dev/**/*.html\"",
- "test-ts": "npm run test-ts-main && npm run test-ts-dev && npm run test-ts-test",
- "test-ts-main": "npx tsc --noEmit --project jsconfig.json",
- "test-ts-dev": "npx tsc --noEmit --project dev/jsconfig.json",
- "test-ts-test": "npx tsc --noEmit --project test/jsconfig.json",
- "test-code": "vitest run",
- "test-code-write": "vitest run --config test/data/vitest.write.config.json",
- "test-options-update": "vitest run --config test/data/vitest.options.config.json",
- "test-json": "vitest run --config test/data/vitest.json.config.json",
- "test-build": "node ./dev/bin/build.js --dryRun --all",
- "license-report": "license-report --output=html --only=prod --fields=name --fields=installedVersion --fields=licenseType --fields=link --html.cssFile=dev/data/legal-npm.css > ext/legal-npm.html",
- "license-report-markdown": "license-report --output=markdown --only=prod --fields=name --fields=installedVersion --fields=licenseType --fields=link",
+ "build:libs": "node ./dev/bin/build-libs.js",
+ "test": "npm run test:js && npm run test:ts && npm run test:css && npm run test:html && npm run test:unit && npm run test:json && npm run test:md && npm run test:build",
+ "test:fast": "npm run test:js && npm run test:ts && npm run test:unit && npm run test:json:format",
+ "test:static-analysis": "npm run test:js && npm run test:ts && npm run test:css && npm run test:html && npm run test:json && npm run test:md",
+ "test:js": "npx eslint . --ignore-pattern **/*.json",
+ "test:json": "npm run test:json:format && npm run test:json:types",
+ "test:json:format": "npx eslint **/*.json",
+ "test:json:types": "vitest run --config test/data/vitest.json.config.json",
+ "test:css": "npx stylelint \"ext/**/*.css\" \"test/**/*.css\" \"dev/**/*.css\"",
+ "test:html": "npx html-validate \"ext/**/*.html\" \"test/**/*.html\" \"dev/**/*.html\"",
+ "test:md": "prettier . --check",
+ "test:md:write": "prettier . --write",
+ "test:ts": "npm run test:ts:main && npm run test:ts:dev && npm run test:ts:test && npm run test:ts:bench",
+ "test:ts:main": "npx tsc --noEmit --project jsconfig.json",
+ "test:ts:dev": "npx tsc --noEmit --project dev/jsconfig.json",
+ "test:ts:test": "npx tsc --noEmit --project test/jsconfig.json",
+ "test:ts:bench": "npx tsc --noEmit --project benches/jsconfig.json",
+ "test:unit": "vitest run",
+ "test:unit:write": "vitest run --config test/data/vitest.write.config.json",
+ "test:unit:options": "vitest run --config test/data/vitest.options.config.json",
+ "test:build": "node ./dev/bin/build.js --dryRun --all",
+ "license-report:html": "license-report --output=html --only=prod --fields=name --fields=installedVersion --fields=licenseType --fields=link --html.cssFile=dev/data/legal-npm.css > ext/legal-npm.html",
+ "license-report:markdown": "license-report --output=markdown --only=prod --fields=name --fields=installedVersion --fields=licenseType --fields=link",
"prepare": "husky install"
},
"repository": {