From 12fc824432731d7708cc3ce99adc1834c903b942 Mon Sep 17 00:00:00 2001 From: Krzysztof Platis Date: Wed, 24 Apr 2024 14:55:46 +0200 Subject: [PATCH] chore: fix build/test of schematics in individual libraries, when running it in isolation from the core schematics build/test (#18769) Previously we're run the script "copy-feature-toggles" only as a pre-build (and a pre-test) step only of the core schematics. Now we run script "copy-feature-toggles" inside the script "clean" of the core schematics. Why: All individual libraries' "test:schematics" commands run the core's schematics "clean" script before executing their tests. So now we're sure that the script "copy-feature-toggles" will be run before "test:schematics" of any individual library. Such an individual run of tests might happen due to `Nx` choosing to build only the selective changed libraries. **QA steps:** Verify you can run tests of schematics of an individual lib, e.g. QuotesL 1. checkout to this branch locally 2. make sure you DO NOT HAVE a file `projects/schematics/src/feature-toggles.copied-from-core-lib.ts` - otherwise please delete it. 3. `cd feature-libs/quote` 4. `npm run test:schematics` 5. Verify the tests passed. Especially no such error occured like there: https://github.com/SAP/spartacus/actions/runs/8815031194/job/24196138821?pr=18768 --- projects/schematics/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/schematics/package.json b/projects/schematics/package.json index 23486ee49dc..79f32bf0a12 100644 --- a/projects/schematics/package.json +++ b/projects/schematics/package.json @@ -11,9 +11,9 @@ "license": "MIT", "main": "index.js", "scripts": { - "build": "npm run clean && npm run copy-feature-toggles && npm --prefix ../../ run generate:deps && ../../node_modules/.bin/tsc -p ./tsconfig.schematics.json", - "clean": "../../node_modules/.bin/rimraf --glob \"index.js*\" \"index.d.ts\" \"src/**/*.js\" \"src/**/*.js.map\" \"src/**/*.d.ts\"", - "test": "npm run clean && npm run copy-feature-toggles && ../../node_modules/.bin/jest --config ./jest.schematics.config.js", + "build": "npm run clean && npm --prefix ../../ run generate:deps && ../../node_modules/.bin/tsc -p ./tsconfig.schematics.json", + "clean": "../../node_modules/.bin/rimraf --glob \"index.js*\" \"index.d.ts\" \"src/**/*.js\" \"src/**/*.js.map\" \"src/**/*.d.ts\" && npm run copy-feature-toggles", + "test": "npm run clean && ../../node_modules/.bin/jest --config ./jest.schematics.config.js", "copy-feature-toggles": "node copy-feature-toggles" }, "dependencies": {