From 9f7b7f88026ff4ebdf5e42a2830749c0c258e690 Mon Sep 17 00:00:00 2001 From: lizschwab Date: Fri, 4 Sep 2026 11:33:32 -0700 Subject: [PATCH 1/4] chore: rename the package scripts to be more compatible with nx --- .github/copilot-instructions.md | 2 +- .github/workflows/browser_test.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/update-gh-pages.yml | 2 +- AGENTS.md | 6 +++--- nx.json | 17 ++++++++++------- package.json | 8 ++++---- packages/blockly/AGENTS.md | 14 +++++++------- packages/blockly/package.json | 16 ++++++++-------- .../blockly/scripts/gulpfiles/test_tasks.mjs | 4 ++-- packages/blockly/tests/compile/index.html | 2 +- packages/blockly/tests/mocha/node-setup.mjs | 2 +- packages/docs/AGENTS.md | 4 ++-- packages/docs/README.md | 2 +- .../core/building_and_compilation/advanced.mdx | 2 +- .../docs/docs/guides/contribute/core/index.mdx | 2 +- .../docs/docs/guides/contribute/samples.mdx | 2 +- packages/docs/package.json | 2 +- .../block-dynamic-connection/package.json | 2 +- packages/plugins/block-plus-minus/package.json | 2 +- .../block-shareable-procedures/package.json | 2 +- packages/plugins/block-test/package.json | 2 +- packages/plugins/content-highlight/package.json | 2 +- .../plugins/continuous-toolbox/package.json | 2 +- .../plugins/cross-tab-copy-paste/package.json | 2 +- packages/plugins/dev-create/bin/plugin.js | 2 +- packages/plugins/dev-tools/package.json | 2 +- .../plugins/disable-top-blocks/package.json | 2 +- packages/plugins/field-angle/package.json | 2 +- packages/plugins/field-bitmap/package.json | 2 +- .../field-colour-hsv-sliders/package.json | 2 +- packages/plugins/field-colour/package.json | 2 +- packages/plugins/field-date/package.json | 2 +- .../field-dependent-dropdown/package.json | 2 +- .../plugins/field-multilineinput/package.json | 2 +- packages/plugins/field-slider/package.json | 2 +- packages/plugins/fixed-edges/package.json | 2 +- packages/plugins/modal/package.json | 2 +- packages/plugins/scroll-options/package.json | 2 +- .../plugins/shadow-block-converter/package.json | 2 +- .../strict-connection-checker/package.json | 2 +- packages/plugins/suggested-blocks/package.json | 2 +- packages/plugins/theme-dark/package.json | 2 +- .../plugins/theme-deuteranopia/package.json | 2 +- packages/plugins/theme-hackermode/package.json | 2 +- .../plugins/theme-highcontrast/package.json | 2 +- packages/plugins/theme-modern/package.json | 2 +- packages/plugins/theme-tritanopia/package.json | 2 +- packages/plugins/toolbox-search/package.json | 2 +- .../plugins/typed-variable-modal/package.json | 2 +- .../plugins/workspace-backpack/package.json | 2 +- packages/plugins/workspace-minimap/package.json | 2 +- packages/plugins/workspace-search/package.json | 2 +- packages/plugins/zoom-to-fit/package.json | 2 +- 54 files changed, 83 insertions(+), 80 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 06bf0d0db7a..dbf94a26bb0 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -10,7 +10,7 @@ can exist in more than one package. ## General principles -- **Style:** Suggest `npm run format` (from the repo root) or `npm run lint:fix` for +- **Style:** Suggest `npm run format` (from the repo root) or `npm run lint-fix` for formatting issues; do not comment on individual style nits. - **Patterns:** Prefer established Blockly patterns and the official docs over newly invented conventions. This covers conventions — naming, API shape, file layout — not diff --git a/.github/workflows/browser_test.yml b/.github/workflows/browser_test.yml index 5e4df2435ed..448eb0da2ef 100644 --- a/.github/workflows/browser_test.yml +++ b/.github/workflows/browser_test.yml @@ -55,7 +55,7 @@ jobs: run: npm run build - name: Run Test - run: npm run test:browser + run: npm run test-browser env: CI: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aaf78b04984..945afe82f12 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: working-directory: ./packages/blockly - name: Run Build - run: npm run build:all + run: npm run build-all - name: Run Test run: npm run test diff --git a/.github/workflows/update-gh-pages.yml b/.github/workflows/update-gh-pages.yml index f9fdfb8e7bf..6bae90308e3 100644 --- a/.github/workflows/update-gh-pages.yml +++ b/.github/workflows/update-gh-pages.yml @@ -43,4 +43,4 @@ jobs: - name: Update GitHub Pages working-directory: ./packages/blockly - run: npm run updateGithubPages:staging + run: npm run updateGithubPages-staging diff --git a/AGENTS.md b/AGENTS.md index 88dba46f705..2cab61b3398 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -50,13 +50,13 @@ Run these from the repo root. Root scripts fan out across workspaces via Nx. npm ci # Install. Re-run after any pull that changes package-lock.json. npm run build # Build every package except the docs site -npm run build:all # Build everything, including the docs site -npm run build:docs # Docs site only +npm run build-all # Build everything, including the docs site +npm run build-docs # Docs site only npm run test # Full test suite across all packages. Slow. npm run lint # ESLint across all workspaces -npm run lint:fix +npm run lint-fix npm run format # Prettier write, whole repo npm run format:check diff --git a/nx.json b/nx.json index a85906fed71..ff1462653a7 100644 --- a/nx.json +++ b/nx.json @@ -68,26 +68,29 @@ "lint": { "cache": true }, - "lint:fix": { + "lint-fix": { "cache": true }, "test": { "dependsOn": ["^build"], "cache": true }, - "test:browser": { + "test-browser": { "cache": true }, - "test:mocha:node": { + "test-mocha-node": { "cache": true }, - "test:generators": { + "test-generators": { "cache": true }, - "test:mocha:interactive": { + "test-mocha-interactive": { "cache": true }, - "test:compile:advanced": { + "test-compile-advanced": { + "cache": true + }, + "test-mocha-typecheck": { "cache": true }, "swizzle": { @@ -102,7 +105,7 @@ "write-heading-ids": { "cache": true }, - "audit:fix": { + "audit-fix": { "cache": true }, "prepack": { diff --git a/package.json b/package.json index 65a29904d83..ef72095367d 100644 --- a/package.json +++ b/package.json @@ -44,12 +44,12 @@ "scripts": { "test": "npx nx run-many -t test --exclude=blockly && npx nx run blockly:test", "lint": "npm run lint --ws --if-present", - "lint:fix": "npm run lint:fix --ws --if-present", + "lint-fix": "npm run lint-fix --ws --if-present", "build": "npx nx run-many -t build --exclude=blockly-docs", - "build:docs": "npx nx run blockly-docs:build", - "build:all": "npx nx run-many -t build", + "build-docs": "npx nx run blockly-docs:build", + "build-all": "npx nx run-many -t build", "format": "prettier --write .", - "format:check": "prettier --check .", + "format-check": "prettier --check .", "postinstall": "patch-package", "clean": "npx nx reset && npm run clean --ws --if-present" }, diff --git a/packages/blockly/AGENTS.md b/packages/blockly/AGENTS.md index 624e1e61a92..05e2f8ae100 100644 --- a/packages/blockly/AGENTS.md +++ b/packages/blockly/AGENTS.md @@ -19,20 +19,20 @@ npm run start # Dev server, watches for changes and serves the playgrou # at /tests/playground.html npm run test # The full CI suite. Slow — see below. -npm run test:mocha:node # Unit tests headless under Node + jsdom. The fast inner loop. -npm run test:mocha:interactive # Unit tests in a real browser, hot reloads on change -npm run test:browser # Webdriver tests in a real browser -npm run test:generators # Code generator golden-file tests +npm run test-mocha-node # Unit tests headless under Node + jsdom. The fast inner loop. +npm run test-mocha-interactive # Unit tests in a real browser, hot reloads on change +npm run test-browser # Webdriver tests in a real browser +npm run test-generators # Code generator golden-file tests npm run lint # ESLint check -npm run lint:fix # ESLint auto-fix +npm run lint-fix # ESLint auto-fix ``` Prettier is configured at the repo root only — run `npm run format` from there. `npm run test` runs the entire CI suite in series: eslint, build, renamings, mocha, generators, type definitions, and two advanced-compilation passes. Prefer -`test:mocha:node` while iterating and save the full suite for a final check. +`test-mocha-node` while iterating and save the full suite for a final check. ### Running a single test @@ -52,7 +52,7 @@ Mocha tests use the `tdd` UI (`suite` / `test`), not BDD. not need converting as a drive-by. TypeScript tests run under Node's native type stripping, with type checking as a -separate `npm run test:mocha:typecheck` pass. So +separate `npm run test-mocha-typecheck` pass. So [`tests/mocha/tsconfig.json`](tests/mocha/tsconfig.json) sets `erasableSyntaxOnly`, and anything requiring codegen is unavailable: no `enum`, no parameter properties, no `namespace`. `verbatimModuleSyntax` is also on, so type-only imports must be written as diff --git a/packages/blockly/package.json b/packages/blockly/package.json index 785334abd12..c94afdda6c2 100644 --- a/packages/blockly/package.json +++ b/packages/blockly/package.json @@ -93,7 +93,7 @@ "docs": "gulp docs", "messages": "gulp messages", "lint": "eslint .", - "lint:fix": "eslint . --fix", + "lint-fix": "eslint . --fix", "langfiles": "gulp langfiles", "minify": "gulp minify", "package": "gulp pack", @@ -103,14 +103,14 @@ "rebuildBlockly": "npm run build && node \"scripts/prepare_advanced_playground.mjs\"", "tsc": "gulp tsc", "test": "gulp test", - "test:browser": "npx mocha --config tests/browser/.mocharc.js", - "test:mocha:node": "npm run test:mocha:typecheck && npx mocha --config tests/mocha/.mocharc.node.cjs \"tests/mocha/**/*_test.{js,ts}\"", - "test:mocha:typecheck": "tsc -p tests/mocha/tsconfig.json", - "test:generators": "gulp testGenerators", - "test:mocha:interactive": "npm run build && node scripts/prepare_mocha_bundle.mjs && concurrently -n tsc,tsc:tests,esbuild,python3 \"tsc --watch --preserveWatchOutput --outDir \"build/src\" --declarationDir \"build/declarations\"\" \"npm run test:mocha:typecheck -- --watch --preserveWatchOutput\" \"esbuild build/tests/bundle-entry.js --bundle --sourcemap --alias:blockly/core=./build/src/core/blockly.js --alias:blockly/blocks=./build/src/blocks/blocks.js --alias:blockly=./build/src/core/blockly.js --outfile=build/tests/mocha-bundle.js --servedir=. --serve=127.0.0.1:8080 --watch=forever --log-level=warning\" \"python3 -m webbrowser 'http://localhost:8080/tests/mocha/index.html'\"", - "test:compile:advanced": "gulp buildAdvancedCompilationTest --debug", + "test-browser": "npx mocha --config tests/browser/.mocharc.js", + "test-mocha-node": "npm run test-mocha-typecheck && npx mocha --config tests/mocha/.mocharc.node.cjs \"tests/mocha/**/*_test.{js,ts}\"", + "test-mocha-typecheck": "tsc -p tests/mocha/tsconfig.json", + "test-generators": "gulp testGenerators", + "test-mocha-interactive": "npm run build && node scripts/prepare_mocha_bundle.mjs && concurrently -n tsc,tsc:tests,esbuild,python3 \"tsc --watch --preserveWatchOutput --outDir \"build/src\" --declarationDir \"build/declarations\"\" \"npm run test-mocha-typecheck -- --watch --preserveWatchOutput\" \"esbuild build/tests/bundle-entry.js --bundle --sourcemap --alias:blockly/core=./build/src/core/blockly.js --alias:blockly/blocks=./build/src/blocks/blocks.js --alias:blockly=./build/src/core/blockly.js --outfile=build/tests/mocha-bundle.js --servedir=. --serve=127.0.0.1:8080 --watch=forever --log-level=warning\" \"python3 -m webbrowser 'http://localhost:8080/tests/mocha/index.html'\"", + "test-compile-advanced": "gulp buildAdvancedCompilationTest --debug", "updateGithubPages": "node scripts/update_github_pages.mjs --upstream", - "updateGithubPages:staging": "node scripts/update_github_pages.mjs --use-local" + "updateGithubPages-staging": "node scripts/update_github_pages.mjs --use-local" }, "exports": { ".": { diff --git a/packages/blockly/scripts/gulpfiles/test_tasks.mjs b/packages/blockly/scripts/gulpfiles/test_tasks.mjs index cef09f693b5..031f43482c0 100644 --- a/packages/blockly/scripts/gulpfiles/test_tasks.mjs +++ b/packages/blockly/scripts/gulpfiles/test_tasks.mjs @@ -168,7 +168,7 @@ function renamings() { * @return {Promise} Asynchronous result. */ function mocha() { - return runTestCommand('mocha', 'npm run test:mocha:node'); + return runTestCommand('mocha', 'npm run test-mocha-node'); } /** @@ -261,7 +261,7 @@ export async function generators() { * @returns {Promise} Async result. */ function advancedCompile() { - return runTestCommand('advanced_compile', 'npm run test:compile:advanced'); + return runTestCommand('advanced_compile', 'npm run test-compile-advanced'); } /** diff --git a/packages/blockly/tests/compile/index.html b/packages/blockly/tests/compile/index.html index 0c6ea998871..6215cb0703b 100644 --- a/packages/blockly/tests/compile/index.html +++ b/packages/blockly/tests/compile/index.html @@ -22,7 +22,7 @@

Blockly: Advanced Compilation Test

-

To run this test manually, run `npm run test:compile:advanced` +

To run this test manually, run `npm run test-compile-advanced` from the command line, then open this file in your web browser.

Measure the size of main_compressed.js (295kb as of October 2017), then reload diff --git a/packages/blockly/tests/mocha/node-setup.mjs b/packages/blockly/tests/mocha/node-setup.mjs index ad29fb348da..f7e48810faa 100644 --- a/packages/blockly/tests/mocha/node-setup.mjs +++ b/packages/blockly/tests/mocha/node-setup.mjs @@ -12,7 +12,7 @@ * expect, installs the geometry stubs JSDom lacks, exposes sinon as a global, * loads Blockly + the standard blocks + the JavaScript generator, and installs * the shared DOM fixtures. The same fixtures and tests run in the browser via - * `npm run test:mocha:interactive`. + * `npm run test-mocha-interactive`. */ import {config as chaiConfig} from 'chai'; diff --git a/packages/docs/AGENTS.md b/packages/docs/AGENTS.md index 5e16333a17b..ed5e6987c1c 100644 --- a/packages/docs/AGENTS.md +++ b/packages/docs/AGENTS.md @@ -6,7 +6,7 @@ Repo-wide conventions are in the [root `AGENTS.md`](../../AGENTS.md). ## Commands -Run from `packages/docs/`, or from the repo root as `npm run build:docs`. +Run from `packages/docs/`, or from the repo root as `npm run build-docs`. ```bash npm start # build the API reference, then serve the site locally @@ -14,7 +14,7 @@ npm run build # production build npm run serve # serve an already-built site npm run clear # clear the Docusaurus cache npm run lint # ESLint over docs/**/*.mdx -npm run lint:fix +npm run lint-fix ``` ## Things to know diff --git a/packages/docs/README.md b/packages/docs/README.md index 2ea142ec257..adfb091f7f4 100644 --- a/packages/docs/README.md +++ b/packages/docs/README.md @@ -45,7 +45,7 @@ npm run format # check linting: npm run lint # fix linting: -npm run lint:fix +npm run lint-fix ``` Prettier is used for formatting JavaScript files (the `format` script). diff --git a/packages/docs/docs/guides/contribute/core/building_and_compilation/advanced.mdx b/packages/docs/docs/guides/contribute/core/building_and_compilation/advanced.mdx index 4678f8d578d..7a6c6a19559 100644 --- a/packages/docs/docs/guides/contribute/core/building_and_compilation/advanced.mdx +++ b/packages/docs/docs/guides/contribute/core/building_and_compilation/advanced.mdx @@ -32,7 +32,7 @@ The associated test app is located in `packages/blockly/tests/compile/`. If you want to run this `ADVANCED_OPTIMIZATIONS` test locally, you can use: ``` -npm run test:compile:advanced +npm run test-compile-advanced ``` ## Use advanced compilation diff --git a/packages/docs/docs/guides/contribute/core/index.mdx b/packages/docs/docs/guides/contribute/core/index.mdx index 480870640c4..4548f6a5af7 100644 --- a/packages/docs/docs/guides/contribute/core/index.mdx +++ b/packages/docs/docs/guides/contribute/core/index.mdx @@ -53,7 +53,7 @@ to create a PR. 1. Run `npm run format` to format the code and automatically fix some lint problems. 1. Run `npm test` to run the automated tests. This also runs `eslint`. -1. If there are lint errors, run `npm run lint:fix` to fix the problems that +1. If there are lint errors, run `npm run lint-fix` to fix the problems that are autofixable. Address any remaining lint warnings or errors. 1. If all tests pass, you are ready to open a PR against **main** with your changes. diff --git a/packages/docs/docs/guides/contribute/samples.mdx b/packages/docs/docs/guides/contribute/samples.mdx index f289f7910b6..429ff2e05d6 100644 --- a/packages/docs/docs/guides/contribute/samples.mdx +++ b/packages/docs/docs/guides/contribute/samples.mdx @@ -85,7 +85,7 @@ order to create a PR. and there are no errors or warnings in the console. 1. Run `npm run build` and ensure there are no build errors. 1. If applicable, run `npm run test` to run the automated tests. -1. Run `npm run lint:fix` to fix lint errors. Address any remaining warnings or +1. Run `npm run lint-fix` to fix lint errors. Address any remaining warnings or errors. 1. Run `npm run format` to run the autoformatter. 1. If all tests pass, you are ready to open a PR against **main** with your diff --git a/packages/docs/package.json b/packages/docs/package.json index 54ecb77af9a..ed48a814aff 100644 --- a/packages/docs/package.json +++ b/packages/docs/package.json @@ -48,7 +48,7 @@ "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "lint": "eslint 'docs/**/*.mdx'", - "lint:fix": "eslint 'docs/**/*.mdx' --fix" + "lint-fix": "eslint 'docs/**/*.mdx' --fix" }, "dependencies": { "@docusaurus/core": "3.10.2", diff --git a/packages/plugins/block-dynamic-connection/package.json b/packages/plugins/block-dynamic-connection/package.json index ec4f37f387a..900564d23d8 100644 --- a/packages/plugins/block-dynamic-connection/package.json +++ b/packages/plugins/block-dynamic-connection/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A group of blocks that add connections dynamically.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/block-plus-minus/package.json b/packages/plugins/block-plus-minus/package.json index f4b5f12417c..4998faedda5 100644 --- a/packages/plugins/block-plus-minus/package.json +++ b/packages/plugins/block-plus-minus/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A group of blocks that replace the built-in mutator UI with a +/- based UI.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/block-shareable-procedures/package.json b/packages/plugins/block-shareable-procedures/package.json index bbd9c3b2107..388966711ae 100644 --- a/packages/plugins/block-shareable-procedures/package.json +++ b/packages/plugins/block-shareable-procedures/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A plugin that adds procedure blocks which are backed by explicit data models.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/block-test/package.json b/packages/plugins/block-test/package.json index 76da4052dec..0556ed219c2 100644 --- a/packages/plugins/block-test/package.json +++ b/packages/plugins/block-test/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A group of Blockly test blocks.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/content-highlight/package.json b/packages/plugins/content-highlight/package.json index 7d9d5884c9b..d483f4f591c 100644 --- a/packages/plugins/content-highlight/package.json +++ b/packages/plugins/content-highlight/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly workspace plugin that adds a highlight around the content area.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/continuous-toolbox/package.json b/packages/plugins/continuous-toolbox/package.json index f0c2fe3d991..6f39d5a3191 100644 --- a/packages/plugins/continuous-toolbox/package.json +++ b/packages/plugins/continuous-toolbox/package.json @@ -8,7 +8,7 @@ "lint": "eslint .", "prepublishOnly": "npm run clean && npm run build", "start": "blockly-scripts start", - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "predeploy": "npm run build && blockly-scripts predeploy" }, "main": "./dist/index.js", diff --git a/packages/plugins/cross-tab-copy-paste/package.json b/packages/plugins/cross-tab-copy-paste/package.json index dd9629517c5..ba57b923e16 100644 --- a/packages/plugins/cross-tab-copy-paste/package.json +++ b/packages/plugins/cross-tab-copy-paste/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "Allows copying blocks between multiple tabs with Blockly editors.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/dev-create/bin/plugin.js b/packages/plugins/dev-create/bin/plugin.js index c37edc47d8c..e0692c660d2 100644 --- a/packages/plugins/dev-create/bin/plugin.js +++ b/packages/plugins/dev-create/bin/plugin.js @@ -101,7 +101,7 @@ exports.createPlugin = function (pluginName, options) { version: `0.0.0`, description: `A Blockly ${pluginType}.`, scripts: { - 'audit:fix': 'blockly-scripts auditFix', + 'audit-fix': 'blockly-scripts auditFix', 'build': 'blockly-scripts build', 'clean': 'blockly-scripts clean', 'predeploy': 'blockly-scripts predeploy', diff --git a/packages/plugins/dev-tools/package.json b/packages/plugins/dev-tools/package.json index f1d151d5c0c..b9e21f0da03 100644 --- a/packages/plugins/dev-tools/package.json +++ b/packages/plugins/dev-tools/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A library of common utilities for Blockly extension development.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/disable-top-blocks/package.json b/packages/plugins/disable-top-blocks/package.json index 6e350aa9fbd..a5bf272fc83 100644 --- a/packages/plugins/disable-top-blocks/package.json +++ b/packages/plugins/disable-top-blocks/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin that shows the 'disable' context menu option only on non-orphan blocks.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-angle/package.json b/packages/plugins/field-angle/package.json index 0f867746001..d81c928c352 100644 --- a/packages/plugins/field-angle/package.json +++ b/packages/plugins/field-angle/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly angle field.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-bitmap/package.json b/packages/plugins/field-bitmap/package.json index eaf85a9c271..25db59deedc 100644 --- a/packages/plugins/field-bitmap/package.json +++ b/packages/plugins/field-bitmap/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A field that lets users input a pixel grid with their mouse.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-colour-hsv-sliders/package.json b/packages/plugins/field-colour-hsv-sliders/package.json index 3f9d8b9107d..0c6047a2b3a 100644 --- a/packages/plugins/field-colour-hsv-sliders/package.json +++ b/packages/plugins/field-colour-hsv-sliders/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly colour field using HSV sliders.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-colour/package.json b/packages/plugins/field-colour/package.json index 5c7ecd817a4..ea21138f724 100644 --- a/packages/plugins/field-colour/package.json +++ b/packages/plugins/field-colour/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly colour field.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-date/package.json b/packages/plugins/field-date/package.json index 8d63f31d517..b68a8044d7a 100644 --- a/packages/plugins/field-date/package.json +++ b/packages/plugins/field-date/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly date picker field that uses the browser's date picker.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-dependent-dropdown/package.json b/packages/plugins/field-dependent-dropdown/package.json index 077cf90b962..0ad10aef903 100644 --- a/packages/plugins/field-dependent-dropdown/package.json +++ b/packages/plugins/field-dependent-dropdown/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly dropdown field that automatically updates its available options depending on the value of another field.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-multilineinput/package.json b/packages/plugins/field-multilineinput/package.json index 8a51e50f6d6..bd7f7ab999a 100644 --- a/packages/plugins/field-multilineinput/package.json +++ b/packages/plugins/field-multilineinput/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly multilineinput field.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/field-slider/package.json b/packages/plugins/field-slider/package.json index 30d18bfd3bb..3757655c880 100644 --- a/packages/plugins/field-slider/package.json +++ b/packages/plugins/field-slider/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly slider field.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/fixed-edges/package.json b/packages/plugins/fixed-edges/package.json index 9193fe14a80..c15f7cf02ce 100644 --- a/packages/plugins/fixed-edges/package.json +++ b/packages/plugins/fixed-edges/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A plugin that provides a MetricsManager that can be used to prevent the workspace from expanding to the top/left/right/bottom when blocks are dragged to that edge.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/modal/package.json b/packages/plugins/modal/package.json index 7a33d90d5a3..d5b22d8dced 100644 --- a/packages/plugins/modal/package.json +++ b/packages/plugins/modal/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin that creates a modal.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/scroll-options/package.json b/packages/plugins/scroll-options/package.json index 9fbc6d9f680..219b4f32202 100644 --- a/packages/plugins/scroll-options/package.json +++ b/packages/plugins/scroll-options/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin that adds advanced scroll options such as scroll-on-drag and scroll while holding a block.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/shadow-block-converter/package.json b/packages/plugins/shadow-block-converter/package.json index d05fa2fbc8a..b8c52ed3c6e 100644 --- a/packages/plugins/shadow-block-converter/package.json +++ b/packages/plugins/shadow-block-converter/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A workspace change listener that converts shadow blocks to real blocks when the user edits them.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/strict-connection-checker/package.json b/packages/plugins/strict-connection-checker/package.json index 2dcbac8ea91..261f2f2429f 100644 --- a/packages/plugins/strict-connection-checker/package.json +++ b/packages/plugins/strict-connection-checker/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A connection checker that prevents blocks that don't provide type information from being connected to blocks that do.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/suggested-blocks/package.json b/packages/plugins/suggested-blocks/package.json index 9bd5addcaac..1933d84508b 100644 --- a/packages/plugins/suggested-blocks/package.json +++ b/packages/plugins/suggested-blocks/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A plugin that adds toolbox panes with suggested blocks based on the user's past usage of blocks.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/theme-dark/package.json b/packages/plugins/theme-dark/package.json index 52dd500ab24..c44546a4426 100644 --- a/packages/plugins/theme-dark/package.json +++ b/packages/plugins/theme-dark/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly dark theme.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/theme-deuteranopia/package.json b/packages/plugins/theme-deuteranopia/package.json index 0cbc439522b..e83436b425a 100644 --- a/packages/plugins/theme-deuteranopia/package.json +++ b/packages/plugins/theme-deuteranopia/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly theme for people that have deuteranopia.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/theme-hackermode/package.json b/packages/plugins/theme-hackermode/package.json index 57d8aa868c9..2c85adc6c97 100644 --- a/packages/plugins/theme-hackermode/package.json +++ b/packages/plugins/theme-hackermode/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "description": "A Blockly theme with an all black theme and green text to mimic a hacking page", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "predeploy": "blockly-scripts predeploy", diff --git a/packages/plugins/theme-highcontrast/package.json b/packages/plugins/theme-highcontrast/package.json index 23dec455ad3..e3ea8ab62f6 100644 --- a/packages/plugins/theme-highcontrast/package.json +++ b/packages/plugins/theme-highcontrast/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly high contrast theme.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/theme-modern/package.json b/packages/plugins/theme-modern/package.json index d768172f039..704c64bf8b3 100644 --- a/packages/plugins/theme-modern/package.json +++ b/packages/plugins/theme-modern/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly modern theme with darker block borders.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/theme-tritanopia/package.json b/packages/plugins/theme-tritanopia/package.json index e4490ca2e8a..7beab4f4648 100644 --- a/packages/plugins/theme-tritanopia/package.json +++ b/packages/plugins/theme-tritanopia/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly theme for people that have tritanopia.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/toolbox-search/package.json b/packages/plugins/toolbox-search/package.json index 98dc87e35dd..88e551896d3 100644 --- a/packages/plugins/toolbox-search/package.json +++ b/packages/plugins/toolbox-search/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin that adds a toolbox category that allows searching for blocks.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/typed-variable-modal/package.json b/packages/plugins/typed-variable-modal/package.json index 2870166a3ec..b99b65012c1 100644 --- a/packages/plugins/typed-variable-modal/package.json +++ b/packages/plugins/typed-variable-modal/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin to create a modal for creating typed variables.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/workspace-backpack/package.json b/packages/plugins/workspace-backpack/package.json index cf937e20f19..80a85bac1c3 100644 --- a/packages/plugins/workspace-backpack/package.json +++ b/packages/plugins/workspace-backpack/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin that adds Backpack support.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/workspace-minimap/package.json b/packages/plugins/workspace-minimap/package.json index ec7344583f0..fd5335cdd16 100644 --- a/packages/plugins/workspace-minimap/package.json +++ b/packages/plugins/workspace-minimap/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/workspace-search/package.json b/packages/plugins/workspace-search/package.json index 57449344688..46987d12afb 100644 --- a/packages/plugins/workspace-search/package.json +++ b/packages/plugins/workspace-search/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin that adds workspace search support.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", diff --git a/packages/plugins/zoom-to-fit/package.json b/packages/plugins/zoom-to-fit/package.json index 1a4fad13acc..f7840353fc1 100644 --- a/packages/plugins/zoom-to-fit/package.json +++ b/packages/plugins/zoom-to-fit/package.json @@ -3,7 +3,7 @@ "version": "13.1.0", "description": "A Blockly plugin that adds a zoom-to-fit control to the workspace.", "scripts": { - "audit:fix": "blockly-scripts auditFix", + "audit-fix": "blockly-scripts auditFix", "build": "blockly-scripts build", "clean": "blockly-scripts clean", "lint": "eslint .", From a0b52fbc8d6607ca4ee9ddfe281e902ee9d0db0d Mon Sep 17 00:00:00 2001 From: lizschwab Date: Fri, 4 Sep 2026 12:07:26 -0700 Subject: [PATCH 2/4] chore: fixed missed format:check references --- .github/workflows/build.yml | 2 +- AGENTS.md | 4 ++-- packages/docs/README.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 945afe82f12..b0b23644a6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,4 +97,4 @@ jobs: run: npm install - name: Check Format - run: npm run format:check + run: npm run format-check diff --git a/AGENTS.md b/AGENTS.md index 2cab61b3398..578633ee528 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,7 +58,7 @@ npm run test # Full test suite across all packages. Slow. npm run lint # ESLint across all workspaces npm run lint-fix npm run format # Prettier write, whole repo -npm run format:check +npm run format-check npm run clean # Reset the Nx cache and clean every package ``` @@ -77,7 +77,7 @@ npx nx run-many -t build --projects=@blockly/field-slider Two things to watch out for: -- `format` and `format:check` exist **only** at the root. Prettier is configured once +- `format` and `format-check` exist **only** at the root. Prettier is configured once for the whole repo, so there is no per-package equivalent. - `build`, `test`, `clean`, `lint`, and `start` exist at both levels and mean different things. At the root they fan out through Nx; inside a package they run that package's diff --git a/packages/docs/README.md b/packages/docs/README.md index 97add4ec841..ba6f9055a4f 100644 --- a/packages/docs/README.md +++ b/packages/docs/README.md @@ -39,7 +39,7 @@ The build folder is now served at http://localhost:3000/ ```bash # check formatting: -npm run format:check +npm run format-check # fix formatting: npm run format # check linting: From fb4c4b45f4eeb33bcc93587c4488bd6f44c0a27c Mon Sep 17 00:00:00 2001 From: lizschwab Date: Wed, 9 Sep 2026 09:55:36 -0700 Subject: [PATCH 3/4] chore: stop using gulp as a test runner --- package.json | 2 +- packages/blockly/gulpfile.mjs | 3 - packages/blockly/package.json | 19 +- .../blockly/scripts/gulpfiles/test_tasks.mjs | 305 ------------------ .../tests/generators/test_generators.mjs | 119 +++++++ .../blockly/tests/scripts/test_helpers.mjs | 75 +++++ 6 files changed, 212 insertions(+), 311 deletions(-) delete mode 100644 packages/blockly/scripts/gulpfiles/test_tasks.mjs create mode 100644 packages/blockly/tests/generators/test_generators.mjs create mode 100644 packages/blockly/tests/scripts/test_helpers.mjs diff --git a/package.json b/package.json index 699184cf2cd..6d71537ae53 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "typescript-eslint": "^8.66.0" }, "scripts": { - "test": "npx nx run-many -t test --exclude=blockly && npx nx run blockly:test", + "test": "npx nx run-many -t test", "lint": "npm run lint --ws --if-present", "lint-fix": "npm run lint-fix --ws --if-present", "build": "npx nx run-many -t build --exclude=blockly-docs", diff --git a/packages/blockly/gulpfile.mjs b/packages/blockly/gulpfile.mjs index 82b393382ef..d68143d2d7c 100644 --- a/packages/blockly/gulpfile.mjs +++ b/packages/blockly/gulpfile.mjs @@ -36,7 +36,6 @@ import { pack, typings, } from './scripts/gulpfiles/package_tasks.mjs'; -import {generators, test} from './scripts/gulpfiles/test_tasks.mjs'; const clean = parallel(cleanBuildDir, cleanReleaseDir); @@ -66,8 +65,6 @@ export { export { messages, // Generate msg/json/en.json et al. clean, - test, - generators as testGenerators, buildAdvancedCompilationTest, typings, } diff --git a/packages/blockly/package.json b/packages/blockly/package.json index ef69695c10b..df156c62aa8 100644 --- a/packages/blockly/package.json +++ b/packages/blockly/package.json @@ -51,6 +51,10 @@ }, "test": { "dependsOn": [ + { + "projects": "blockly", + "target": "package" + }, { "projects": "@blockly/block-test", "target": "build" @@ -61,6 +65,14 @@ } ] }, + "test-compile-advanced-browser": { + "dependsOn": [ + { + "projects": "blockly", + "target": "test-compile-advanced" + } + ] + }, "docs": { "dependsOn": [ "package", @@ -101,13 +113,16 @@ "rebuildAdvancedPlayground": "npm run build --workspace=@blockly/dev-tools && node \"scripts/prepare_advanced_playground.mjs\"", "rebuildBlockly": "npm run build && node \"scripts/prepare_advanced_playground.mjs\"", "tsc": "gulp tsc", - "test": "gulp test", + "test": "nx run-many -p blockly --targets=lint,test-renamings,test-mocha-node,test-generators,test-type-definitions,test-compile-advanced,test-compile-advanced-browser", "test-browser": "npx mocha --config tests/browser/.mocharc.js", "test-mocha-node": "npm run test-mocha-typecheck && npx mocha --config tests/mocha/.mocharc.node.cjs \"tests/mocha/**/*_test.{js,ts}\"", "test-mocha-typecheck": "tsc -p tests/mocha/tsconfig.json", - "test-generators": "gulp testGenerators", + "test-generators": "node \"tests/generators/test_generators.mjs\"", "test-mocha-interactive": "npm run build && node scripts/prepare_mocha_bundle.mjs && concurrently -n tsc,tsc:tests,esbuild,python3 \"tsc --watch --preserveWatchOutput --outDir \"build/src\" --declarationDir \"build/declarations\"\" \"npm run test-mocha-typecheck -- --watch --preserveWatchOutput\" \"esbuild build/tests/bundle-entry.js --bundle --sourcemap --alias:blockly/core=./build/src/core/blockly.js --alias:blockly/blocks=./build/src/blocks/blocks.js --alias:blockly=./build/src/core/blockly.js --outfile=build/tests/mocha-bundle.js --servedir=. --serve=127.0.0.1:8080 --watch=forever --log-level=warning\" \"python3 -m webbrowser 'http://localhost:8080/tests/mocha/index.html'\"", "test-compile-advanced": "gulp buildAdvancedCompilationTest --debug", + "test-compile-advanced-browser": "node \"tests/compile/webdriver.js\"", + "test-renamings": "node \"tests/migration/validate-renamings.mjs\"", + "test-type-definitions": "tsc -p ./tests/typescript/tsconfig.json -outDir \"build/src\"", "updateGithubPages": "node scripts/update_github_pages.mjs --upstream", "updateGithubPages-staging": "node scripts/update_github_pages.mjs --use-local" }, diff --git a/packages/blockly/scripts/gulpfiles/test_tasks.mjs b/packages/blockly/scripts/gulpfiles/test_tasks.mjs deleted file mode 100644 index 031f43482c0..00000000000 --- a/packages/blockly/scripts/gulpfiles/test_tasks.mjs +++ /dev/null @@ -1,305 +0,0 @@ -/** - * @license - * Copyright 2022 Google LLC - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @fileoverview Gulp tasks to test. - */ -/* eslint-env node */ - -import asyncDone from 'async-done'; -import {spawnSync} from 'child_process'; -import * as fs from 'fs'; -import * as gulp from 'gulp'; -import * as path from 'path'; -import {rimraf} from 'rimraf'; - -import {TEST_TSC_OUTPUT_DIR} from './config.mjs'; - -const OUTPUT_DIR = 'build/generators'; -const GOLDEN_DIR = 'tests/generators/golden'; - -const BOLD_GREEN = '\x1b[1;32m'; -const BOLD_RED = '\x1b[1;31m'; -const ANSI_RESET = '\x1b[0m'; - -let successCount = 0; -let failCount = 0; -let firstErr; -const results = {}; - -/** - * Run an arbitrary Gulp task as a test. - * @param {function} task Any Gulp task. - * @return {Promise} Asynchronous result. - */ -function runTestTask(id, task) { - return new Promise((resolve) => { - console.log('======================================='); - console.log(`== ${id}`); - - // Turn any task into a Promise! - const asyncTask = new Promise((resolve, reject) => { - asyncDone(task, (error, result) => { - if (error) reject(error); - resolve(result); - }); - }); - - if (process.env.CI) console.log('::group::'); - asyncTask - .then((result) => { - successCount++; - if (process.env.CI) console.log('::endgroup::'); - console.log(`${BOLD_GREEN}SUCCESS:${ANSI_RESET} ${id}`); - results[id] = {success: true}; - resolve(result); - }) - .catch((err) => { - failCount++; - if (!firstErr) { - // Save the first error so we can use it in the stack trace later. - firstErr = err; - } - console.error(err.message); - if (process.env.CI) console.log('::endgroup::'); - console.log(`${BOLD_RED}FAILED:${ANSI_RESET} ${id}`); - results[id] = {success: false, message: err.message}; - // Always continue. - resolve(err); - }); - }); -} - -function createSummary() { - let summary = '# Test Summary\n\n'; - summary += '|Test Name|Passed?|Error message|\n'; - summary += '|---------|-------|-------------|\n'; - for (const test in results) { - summary += `|${test}|${results[test].success - ? ':white_check_mark:' : ':x:'}|${results[test].message ?? ''}|\n`; - } - summary += `\n\n## Total: ${successCount} passed. ${failCount} failed.`; - return summary; -} - -/** - * Print test results and fail the task if needed. - */ -function reportTestResult() { - console.log('======================================='); - if (process.env.CI && process.env.GITHUB_STEP_SUMMARY) { - try { - fs.writeFileSync(process.env.GITHUB_STEP_SUMMARY, createSummary()); - } catch(e) { - // Don't fail CI just because we couldn't write the summary. - console.log('Failed to write job summary', e); - } - } - // Check result. - if (failCount === 0) { - console.log( - `${BOLD_GREEN}All ${successCount} tests passed.${ANSI_RESET}`); - return Promise.resolve(); - } - console.log( - `${BOLD_RED}Failures in ${failCount} test groups.${ANSI_RESET}`); - return Promise.reject(firstErr || - 'Unspecified test failures, see above. The following stack trace is unlikely to be useful.'); -} - -/** - * Helper method for running test command. - * @param {string} command Command line to run. - * @return {Promise} Asynchronous result. - */ -async function runTestCommand(id, command) { - return runTestTask(id, async () => { - const result = spawnSync(command, { - shell: true, - stdio: 'inherit', - env: process.env, - }); - if (result.error) { - throw result.error; - } - if (result.status !== 0) { - throw new Error( - `Command failed with exit code ${result.status}: ${command}`, - ); - } - }); -} - -/** - * Lint the codebase. - * Skip for CI environments, because linting is run separately. - * @return {Promise} Asynchronous result. - */ -function eslint() { - if (process.env.CI) { - console.log('Skip linting.'); - return Promise.resolve(); - } - return runTestCommand('eslint', 'eslint .'); -} - -/** - * Run the full usual build and package process, checking to ensure - * there are no Closure Compiler warnings / errors. - * @return {Promise} Asynchronous result. - */ -function build() { - return runTestCommand('build', 'npm run package -- --verbose --debug'); -} - -/** - * Run renaming validation test. - * @return {Promise} Asynchronous result. - */ -function renamings() { - return runTestCommand('renamings', 'tests/migration/validate-renamings.mjs'); -} - -/** - * Run Mocha tests under Node. - * @return {Promise} Asynchronous result. - */ -function mocha() { - return runTestCommand('mocha', 'npm run test-mocha-node'); -} - -/** - * Helper method for comparison file. - * @param {string} file1 First target file. - * @param {string} file2 Second target file. - * @return {boolean} Comparison result (true: same / false: different). - */ -function compareFile(file1, file2) { - const buf1 = fs.readFileSync(file1); - const buf2 = fs.readFileSync(file2); - // Normalize the line feed. - const code1 = buf1.toString().replace(/(?:\r\n|\r|\n)/g, '\n'); - const code2 = buf2.toString().replace(/(?:\r\n|\r|\n)/g, '\n'); - return code1 === code2; -} - -/** - * Helper method for checking the result of generator. - * @param {string} suffix Target suffix. - * @return {number} Check result (0: success / 1: failed). - */ -function checkResult(suffix) { - const fileName = `generated.${suffix}`; - const resultFileName = path.posix.join(OUTPUT_DIR, fileName); - - const SUCCESS_PREFIX = `${BOLD_GREEN}SUCCESS:${ANSI_RESET}`; - const FAILURE_PREFIX = `${BOLD_RED}FAILED:${ANSI_RESET}`; - - if (fs.existsSync(resultFileName)) { - const goldenFileName = path.posix.join(GOLDEN_DIR, fileName); - if (fs.existsSync(goldenFileName)) { - if (compareFile(resultFileName, goldenFileName)) { - console.log(`${SUCCESS_PREFIX} ${suffix}: ` + - `${resultFileName} matches ${goldenFileName}`); - return 0; - } else { - console.log( - `${FAILURE_PREFIX} ${suffix}: ` + - `${resultFileName} does not match ${goldenFileName}`); - } - } else { - console.log(`File ${goldenFileName} not found!`); - } - } else { - console.log(`File ${resultFileName} not found!`); - } - return 1; -} - -/** - * Run generator tests inside a browser and check the results. - * @return {Promise} Asynchronous result. - */ -export async function generators() { - return runTestTask('generators', async () => { - // Clean up. - rimraf.sync(OUTPUT_DIR); - fs.mkdirSync(OUTPUT_DIR); - - const result = spawnSync('node', ['tests/generators/webdriver.js', OUTPUT_DIR], { - stdio: 'inherit', - env: process.env, - }); - if (result.error) { - throw result.error; - } - if (result.status !== 0) { - throw new Error('Generator browser tests failed.'); - } - - const generatorSuffixes = ['js', 'py', 'dart', 'lua', 'php']; - let failed = 0; - generatorSuffixes.forEach((suffix) => { - failed += checkResult(suffix); - }); - - if (failed === 0) { - console.log(`${BOLD_GREEN}All generator tests passed.${ANSI_RESET}`); - } else { - console.log( - `${BOLD_RED}Failures in ${failed} generator tests.${ANSI_RESET}`); - throw new Error('Generator tests failed.'); - } - }); -} - -/** - * Attempt advanced compilation of a Blockly app. - * @returns {Promise} Async result. - */ -function advancedCompile() { - return runTestCommand('advanced_compile', 'npm run test-compile-advanced'); -} - -/** - * Attempt advanced compilation of a Blockly app and make sure it runs in the browser. - * Should be run after the `advancedCompile` test. - * @return {Promise} Asynchronous result. - */ -function advancedCompileInBrowser() { - return runTestCommand( - 'advanced_compile_in_browser', - 'node tests/compile/webdriver.js', - ); -} - -/** - * Verify the built Blockly type definitions compile with the supported - * TypeScript examples included in `./tests/typescript`. - * @returns {Promise} Asynchronous result. - */ -function typeDefinitions() { - return runTestCommand('type_definitions', - `tsc -p ./tests/typescript/tsconfig.json -outDir ${TEST_TSC_OUTPUT_DIR}`); -} - -// Run all tests in sequence. -const tasks = [ - eslint, - // Build must run before the remaining tasks - build, - renamings, - mocha, - generators, - typeDefinitions, - // Make sure these two are in series with each other - advancedCompile, - advancedCompileInBrowser -]; - -export const test = gulp.series(...tasks, reportTestResult); - - diff --git a/packages/blockly/tests/generators/test_generators.mjs b/packages/blockly/tests/generators/test_generators.mjs new file mode 100644 index 00000000000..8395d3d5c17 --- /dev/null +++ b/packages/blockly/tests/generators/test_generators.mjs @@ -0,0 +1,119 @@ +/** + * @license + * Copyright 2026 Raspberry Pi Foundation + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Tests the Blockly generators inside a browser and reports the + * results. + */ + +import {spawnSync} from 'child_process'; +import * as fs from 'fs'; +import * as path from 'path'; +import {rimraf} from 'rimraf'; +import { + ANSI_RESET, + BOLD_GREEN, + BOLD_RED, + runTestFunction, +} from '../scripts/test_helpers.mjs'; + +export const OUTPUT_DIR = 'build/generators'; +export const GOLDEN_DIR = 'tests/generators/golden'; + +/** + * Helper method for checking the result of generator. + * @param {string} suffix Target suffix. + * @return {number} Check result (0: success / 1: failed). + */ +export function checkResult(suffix) { + const fileName = `generated.${suffix}`; + const resultFileName = path.posix.join(OUTPUT_DIR, fileName); + + const SUCCESS_PREFIX = `${BOLD_GREEN}SUCCESS:${ANSI_RESET}`; + const FAILURE_PREFIX = `${BOLD_RED}FAILED:${ANSI_RESET}`; + + if (fs.existsSync(resultFileName)) { + const goldenFileName = path.posix.join(GOLDEN_DIR, fileName); + if (fs.existsSync(goldenFileName)) { + if (compareFile(resultFileName, goldenFileName)) { + console.log( + `${SUCCESS_PREFIX} ${suffix}: ` + + `${resultFileName} matches ${goldenFileName}`, + ); + return 0; + } else { + console.log( + `${FAILURE_PREFIX} ${suffix}: ` + + `${resultFileName} does not match ${goldenFileName}`, + ); + } + } else { + console.log(`File ${goldenFileName} not found!`); + } + } else { + console.log(`File ${resultFileName} not found!`); + } + return 1; +} + +/** + * Helper method for comparison file. + * @param {string} file1 First target file. + * @param {string} file2 Second target file. + * @return {boolean} Comparison result (true: same / false: different). + */ +function compareFile(file1, file2) { + const buf1 = fs.readFileSync(file1); + const buf2 = fs.readFileSync(file2); + // Normalize the line feed. + const code1 = buf1.toString().replace(/(?:\r\n|\r|\n)/g, '\n'); + const code2 = buf2.toString().replace(/(?:\r\n|\r|\n)/g, '\n'); + return code1 === code2; +} + +/** + * Run generator tests inside a browser and check the results. + * @return {Promise} Asynchronous result. + */ +export async function generators() { + return runTestFunction('generators', async () => { + // Clean up. + rimraf.sync(OUTPUT_DIR); + fs.mkdirSync(OUTPUT_DIR); + + const result = spawnSync( + 'node', + ['tests/generators/webdriver.js', OUTPUT_DIR], + { + stdio: 'inherit', + env: process.env, + }, + ); + if (result.error) { + throw result.error; + } + if (result.status !== 0) { + throw new Error('Generator browser tests failed.'); + } + + const generatorSuffixes = ['js', 'py', 'dart', 'lua', 'php']; + let failed = 0; + generatorSuffixes.forEach((suffix) => { + failed += checkResult(suffix); + }); + + if (failed === 0) { + console.log(`${BOLD_GREEN}All generator tests passed.${ANSI_RESET}`); + } else { + console.log( + `${BOLD_RED}Failures in ${failed} generator tests.${ANSI_RESET}`, + ); + throw new Error('Generator tests failed.'); + } + }); +} + +await generators(); diff --git a/packages/blockly/tests/scripts/test_helpers.mjs b/packages/blockly/tests/scripts/test_helpers.mjs new file mode 100644 index 00000000000..dc9de875c11 --- /dev/null +++ b/packages/blockly/tests/scripts/test_helpers.mjs @@ -0,0 +1,75 @@ +/** + * @license + * Copyright 2022 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Node test scripts. + */ +import asyncDone from 'async-done'; +import {spawnSync} from 'child_process'; + +export const BOLD_GREEN = '\x1b[1;32m'; +export const BOLD_RED = '\x1b[1;31m'; +export const ANSI_RESET = '\x1b[0m'; + +/** + * Run an arbitrary function as a test. + * @param {id} id The test id/name. + * @param {function(): Promise} testFunction Any function to be run as a test. + * @return {Promise} Asynchronous result. + */ +export function runTestFunction(id, testFunction) { + return new Promise((resolve) => { + console.log('======================================='); + console.log(`== ${id}`); + + // Turn the testFunction into a Promise + const asyncFunction = new Promise((resolve, reject) => { + asyncDone(testFunction, (error, result) => { + if (error) reject(error); + resolve(result); + }); + }); + + if (process.env.CI) console.log('::group::'); + asyncFunction + .then((result) => { + if (process.env.CI) console.log('::endgroup::'); + console.log(`${BOLD_GREEN}SUCCESS:${ANSI_RESET} ${id}`); + resolve(result); + }) + .catch((err) => { + console.error(err.message); + if (process.env.CI) console.log('::endgroup::'); + console.log(`${BOLD_RED}FAILED:${ANSI_RESET} ${id}`); + // Always continue. + resolve(err); + }); + }); +} + +/** + * Helper method for running test command. + * @param {id} id The test command id/name. + * @param {string} command Command line to run. + * @return {Promise} Asynchronous result. + */ +export async function runTestCommand(id, command) { + return runTestFunction(id, async () => { + const result = spawnSync(command, { + shell: true, + stdio: 'inherit', + env: process.env, + }); + if (result.error) { + throw result.error; + } + if (result.status !== 0) { + throw new Error( + `Command failed with exit code ${result.status}: ${command}`, + ); + } + }); +} From d4292b7b715baace4a4174eff4b5a5084a88ac7b Mon Sep 17 00:00:00 2001 From: lizschwab Date: Wed, 9 Sep 2026 10:28:52 -0700 Subject: [PATCH 4/4] chore: formatting --- packages/blockly/tests/scripts/test_helpers.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/blockly/tests/scripts/test_helpers.mjs b/packages/blockly/tests/scripts/test_helpers.mjs index dc9de875c11..e49d63698aa 100644 --- a/packages/blockly/tests/scripts/test_helpers.mjs +++ b/packages/blockly/tests/scripts/test_helpers.mjs @@ -68,7 +68,7 @@ export async function runTestCommand(id, command) { } if (result.status !== 0) { throw new Error( - `Command failed with exit code ${result.status}: ${command}`, + `Command failed with exit code ${result.status}: ${command}`, ); } });