From cda11145b1421fbe94a23d86f3bb0a10fb4ec129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Fri, 13 Sep 2024 23:29:17 +0200 Subject: [PATCH 1/6] feat(vue): split build:vue script into two scripts: build:tsc and build:vite --- .../generator/client/vue/core/domain/VueModulesFactory.java | 3 ++- .../client/vue/core/domain/VueModulesFactoryTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java index fe81ff5b033..bcd3b1055f0 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java @@ -70,7 +70,8 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) { .addDevDependency(packageName("sinon"), VUE) .addDevDependency(packageName("npm-run-all2"), COMMON) .addScript(scriptKey("build"), scriptCommand("npm-run-all build:*")) - .addScript(scriptKey("build:vue"), scriptCommand("vue-tsc -p tsconfig.build.json --noEmit && vite build --emptyOutDir")) + .addScript(scriptKey("build:tsc"), scriptCommand("vue-tsc -p tsconfig.build.json --noEmit")) + .addScript(scriptKey("build:vite"), scriptCommand("vite build --emptyOutDir")) .addScript(scriptKey("dev"), scriptCommand("npm-run-all --parallel dev:*")) .addScript(scriptKey("dev:vite"), scriptCommand("vite")) .addScript(scriptKey("watch"), scriptCommand("npm-run-all --parallel watch:*")) diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java index 42122ebf80e..cfc11e904a5 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java @@ -51,7 +51,8 @@ void shouldCreateVueModule() { .containing(nodeDependency("vue-router")) .containing(nodeDependency("npm-run-all2")) .containing(nodeScript("build", "npm-run-all build:*")) - .containing(nodeScript("build:vue", "vue-tsc -p tsconfig.build.json --noEmit && vite build --emptyOutDir")) + .containing(nodeScript("build:tsc", "vue-tsc -p tsconfig.build.json --noEmit")) + .containing(nodeScript("build:vite", "vite build --emptyOutDir")) .containing(nodeScript("dev", "npm-run-all --parallel dev:*")) .containing(nodeScript("dev:vite", "vite")) .containing(nodeScript("watch", "npm-run-all --parallel watch:*")) From b350c469068d900362dd4b441eae7099241a592f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Fri, 13 Sep 2024 23:30:18 +0200 Subject: [PATCH 2/6] fix(vue): remove duplicated script "test:watch" in package.json There's already "watch:test" --- .../lite/generator/client/vue/core/domain/VueModulesFactory.java | 1 - .../generator/client/vue/core/domain/VueModulesFactoryTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java index bcd3b1055f0..4195ad8aa45 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java @@ -83,7 +83,6 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) { .addScript(scriptKey("test"), scriptCommand("npm run watch:test")) .addScript(scriptKey("watch:test"), scriptCommand("vitest --")) .addScript(scriptKey("test:coverage"), scriptCommand("vitest run --coverage")) - .addScript(scriptKey("test:watch"), scriptCommand("vitest --")) .and() .files() .add(SOURCE.template("eslint.config.js.mustache"), to("eslint.config.js")) diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java index cfc11e904a5..32af45b8184 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java @@ -64,7 +64,6 @@ void shouldCreateVueModule() { .containing(nodeScript("start", "vite")) .containing(nodeScript("test", "npm run watch:test")) .containing(nodeScript("test:coverage", "vitest run --coverage")) - .containing(nodeScript("test:watch", "vitest --")) .and() .hasFile(".lintstagedrc.cjs") .containing( From 1911fc39f0ca8cad70a6e0b3bfd5a07a4893bf24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Sat, 14 Sep 2024 17:20:09 +0200 Subject: [PATCH 3/6] feat(vue): call build:tsc when launching watch:tsc script This factorises the way to launch the typescript compiler --- .../generator/client/vue/core/domain/VueModulesFactory.java | 2 +- .../generator/client/vue/core/domain/VueModulesFactoryTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java index 4195ad8aa45..4a898ef0ad9 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java @@ -79,7 +79,7 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) { .addScript(scriptKey("lint"), scriptCommand("eslint .")) .addScript(scriptKey("preview"), scriptCommand("vite preview")) .addScript(scriptKey("start"), scriptCommand("vite")) - .addScript(scriptKey("watch:tsc"), scriptCommand("vue-tsc -p tsconfig.build.json --noEmit --watch")) + .addScript(scriptKey("watch:tsc"), scriptCommand("npm run build:tsc -- --watch")) .addScript(scriptKey("test"), scriptCommand("npm run watch:test")) .addScript(scriptKey("watch:test"), scriptCommand("vitest --")) .addScript(scriptKey("test:coverage"), scriptCommand("vitest run --coverage")) diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java index 32af45b8184..ddb1ddbd958 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java @@ -56,7 +56,7 @@ void shouldCreateVueModule() { .containing(nodeScript("dev", "npm-run-all --parallel dev:*")) .containing(nodeScript("dev:vite", "vite")) .containing(nodeScript("watch", "npm-run-all --parallel watch:*")) - .containing(nodeScript("watch:tsc", "vue-tsc -p tsconfig.build.json --noEmit --watch")) + .containing(nodeScript("watch:tsc", "npm run build:tsc -- --watch")) .containing(nodeScript("watch:test", "vitest --")) .containing(nodeDependency("piqure")) .containing(nodeScript("lint", "eslint .")) From f1961e4d56eed9e393016f9a390dfdd997c6049c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Sat, 14 Sep 2024 17:22:06 +0200 Subject: [PATCH 4/6] feat(react): split build:vite script into two scripts: build:tsc and build:vite --- .../client/react/core/domain/ReactCoreModulesFactory.java | 3 ++- .../client/react/core/domain/ReactCoreModulesFactoryTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java index 3842b08a4f4..c2260436811 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java @@ -65,7 +65,8 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { .addScript(scriptKey("dev"), scriptCommand("npm-run-all dev:*")) .addScript(scriptKey("dev:vite"), scriptCommand("vite")) .addScript(scriptKey("build"), scriptCommand("npm-run-all build:*")) - .addScript(scriptKey("build:vite"), scriptCommand("tsc && vite build --emptyOutDir")) + .addScript(scriptKey("build:tsc"), scriptCommand("tsc")) + .addScript(scriptKey("build:vite"), scriptCommand("vite build --emptyOutDir")) .addScript(scriptKey("preview"), scriptCommand("vite preview")) .addScript(scriptKey("start"), scriptCommand("vite")) .addScript(scriptKey("lint"), scriptCommand("eslint .")) diff --git a/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java index 8db18cfb6d1..58d2dbbb203 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.java @@ -48,7 +48,8 @@ void shouldBuildModuleWithStyle() { .containing(nodeScript("dev", "npm-run-all dev:*")) .containing(nodeScript("dev:vite", "vite")) .containing(nodeScript("build", "npm-run-all build:*")) - .containing(nodeScript("build:vite", "tsc && vite build --emptyOutDir")) + .containing(nodeScript("build:tsc", "tsc")) + .containing(nodeScript("build:vite", "vite build --emptyOutDir")) .containing(nodeScript("watch", "npm-run-all --parallel watch:*")) .containing(nodeScript("watch:tsc", "tsc --noEmit --watch")) .containing(nodeScript("preview", "vite preview")) From b6edfe86c6ed83347d26de6df57b32c9531b9808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Sat, 14 Sep 2024 17:45:37 +0200 Subject: [PATCH 5/6] feat(typescript): add npm watch script for typescript compilation and tests --- .../typescript/core/domain/TypescriptModuleFactory.java | 7 +++++-- .../domain/core/TypescriptModuleFactoryTest.java | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/typescript/core/domain/TypescriptModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/typescript/core/domain/TypescriptModuleFactory.java index 1c80856dae4..100acd2d94a 100644 --- a/src/main/java/tech/jhipster/lite/generator/typescript/core/domain/TypescriptModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/typescript/core/domain/TypescriptModuleFactory.java @@ -29,14 +29,17 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { .addDevDependency(packageName("eslint-config-prettier"), COMMON) .addDevDependency(packageName("eslint-plugin-import-x"), COMMON) .addDevDependency(packageName("globals"), COMMON) + .addDevDependency(packageName("npm-run-all2"), COMMON) .addDevDependency(packageName("typescript-eslint"), COMMON) .addDevDependency(packageName("vite-tsconfig-paths"), COMMON) .addDevDependency(packageName("vitest"), COMMON) .addDevDependency(packageName("vitest-sonar-reporter"), COMMON) .addScript(scriptKey("lint"), scriptCommand("eslint .")) - .addScript(scriptKey("test"), scriptCommand("npm run test:watch")) + .addScript(scriptKey("test"), scriptCommand("npm run watch:test")) .addScript(scriptKey("test:coverage"), scriptCommand("vitest run --coverage")) - .addScript(scriptKey("test:watch"), scriptCommand("vitest --")) + .addScript(scriptKey("watch"), scriptCommand("npm-run-all --parallel watch:*")) + .addScript(scriptKey("watch:tsc"), scriptCommand("tsc --noEmit --watch")) + .addScript(scriptKey("watch:test"), scriptCommand("vitest --")) .and() .files() .batch(SOURCE, to(".")) diff --git a/src/test/java/tech/jhipster/lite/generator/typescript/domain/core/TypescriptModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/typescript/domain/core/TypescriptModuleFactoryTest.java index 6ddf4d8eaca..0bf06af3607 100644 --- a/src/test/java/tech/jhipster/lite/generator/typescript/domain/core/TypescriptModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/typescript/domain/core/TypescriptModuleFactoryTest.java @@ -37,9 +37,11 @@ void shouldCreateTypescriptModule() { .containing(nodeDependency("vite-tsconfig-paths")) .containing(nodeDependency("vitest")) .containing(nodeDependency("vitest-sonar-reporter")) - .containing(nodeScript("test", "npm run test:watch")) + .containing(nodeScript("test", "npm run watch:test")) .containing(nodeScript("test:coverage", "vitest run --coverage")) - .containing(nodeScript("test:watch", "vitest --")) + .containing(nodeScript("watch", "npm-run-all --parallel watch:*")) + .containing(nodeScript("watch:test", "vitest --")) + .containing(nodeScript("watch:tsc", "tsc --noEmit --watch")) .containing(nodeScript("lint", "eslint .")) .and() .hasPrefixedFiles("", "eslint.config.js", "tsconfig.json"); From 0862b8b1d6e7ddf779b5acd066736c69d86e3ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Sat, 14 Sep 2024 17:49:27 +0200 Subject: [PATCH 6/6] fix(react): npm-run-all2 should only be a devDependency --- .../client/react/core/domain/ReactCoreModulesFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java index c2260436811..4a286515679 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java @@ -61,7 +61,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { .addDevDependency(packageName("vitest-sonar-reporter"), COMMON) .addDependency(packageName("react"), REACT) .addDependency(packageName("react-dom"), REACT) - .addDependency(packageName("npm-run-all2"), COMMON) + .addDevDependency(packageName("npm-run-all2"), COMMON) .addScript(scriptKey("dev"), scriptCommand("npm-run-all dev:*")) .addScript(scriptKey("dev:vite"), scriptCommand("vite")) .addScript(scriptKey("build"), scriptCommand("npm-run-all build:*"))