Skip to content

Commit

Permalink
add piqure in react core
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienpuissant committed Sep 29, 2024
1 parent 87e1974 commit 689587e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package tech.jhipster.lite.generator.client.react.core.domain;

import static tech.jhipster.lite.module.domain.JHipsterModule.*;
import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.COMMON;
import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.REACT;
import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.*;
import static tech.jhipster.lite.module.domain.replacement.ReplacementCondition.always;

import java.util.function.Consumer;
Expand All @@ -23,6 +22,8 @@ public class ReactCoreModulesFactory {
private static final JHipsterSource APP_SOURCE = WEBAPP_SOURCE.append("app");
private static final JHipsterDestination APP_DESTINATION = WEBAPP_DESTINATION.append("app");

private static final JHipsterSource PIQURE_SOURCE = from("client/common/piqure");

private static final String PRIMARY_APP = "home/infrastructure/primary";
private static final String ASSETS = "assets";

Expand Down Expand Up @@ -51,6 +52,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addDevDependency(packageName("vite"), COMMON)
.addDependency(packageName("react"), REACT)
.addDependency(packageName("react-dom"), REACT)
.addDependency(packageName("piqure"), COMMON)
.addScript(scriptKey("dev"), scriptCommand("npm-run-all dev:*"))
.addScript(scriptKey("dev:vite"), scriptCommand("vite"))
.addScript(scriptKey("build"), scriptCommand("npm-run-all build:*"))
Expand All @@ -68,6 +70,9 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addTemplate("index.tsx")
.addTemplate("vite-env.d.ts")
.and()
.batch(PIQURE_SOURCE, APP_DESTINATION)
.addTemplate("injections.ts")
.and()
.add(WEBAPP_SOURCE.template("index.html"), WEBAPP_DESTINATION.append("index.html"))
.add(SOURCE.append(TEST_PRIMARY).template("HomePage.spec.tsx"), to(TEST_PRIMARY).append("HomePage.spec.tsx"))
.add(PRIMARY_APP_SOURCE.template("HomePage.tsx"), PRIMARY_APP_DESTINATION.append("HomePage.tsx"))
Expand Down Expand Up @@ -158,6 +163,7 @@ private Consumer<JHipsterModuleBuilder> patchVitestConfig(JHipsterModuleProperti
.add(text("plugins: ["), "plugins: [react(), ")
.add(text("environment: 'node',"), "environment: 'jsdom',")
.add(vitestCoverageExclusion(properties,"src/main/webapp/app/index.tsx"))
.add(vitestCoverageExclusion(properties,"src/main/webapp/app/injections.ts"))
.and();
//@formatter:on
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class VueModulesFactory {

private static final JHipsterSource SOURCE = from("client/vue");
private static final JHipsterSource APP_SOURCE = from("client/vue/webapp/app");
private static final JHipsterSource PIQURE_SOURCE = from("client/common/piqure");
private static final JHipsterSource DOCUMENTATION_SOURCE = SOURCE.append("documentation");
private static final JHipsterSource IMAGE_SOURCE = SOURCE.append("webapp/content/images");

Expand Down Expand Up @@ -47,7 +48,7 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) {
.addDependency(packageName("vue"), VUE)
.addDependency(packageName("axios"), VUE)
.addDependency(packageName("vue-router"), VUE)
.addDependency(packageName("piqure"), VUE)
.addDependency(packageName("piqure"), COMMON)
.addDevDependency(packageName("@vitejs/plugin-vue"), VUE)
.addDevDependency(packageName("@vue/test-utils"), VUE)
.addDevDependency(packageName("@vue/tsconfig"), VUE)
Expand Down Expand Up @@ -76,9 +77,11 @@ public JHipsterModule buildVueModule(JHipsterModuleProperties properties) {
.addTemplate("env.d.ts")
.addTemplate("main.ts")
.addTemplate("AppVue.vue")
.addTemplate("injections.ts")
.addTemplate("router.ts")
.and()
.batch(PIQURE_SOURCE, MAIN_DESTINATION)
.addTemplate("injections.ts")
.and()
.batch(APP_SOURCE.append("home"), MAIN_DESTINATION.append("home"))
.addTemplate("application/HomeRouter.ts")
.addTemplate("infrastructure/primary/HomepageVue.vue")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"i18next": "23.15.1",
"i18next-browser-languagedetector": "8.0.0",
"i18next-http-backend": "2.6.1",
"keycloak-js": "25.0.6"
"keycloak-js": "25.0.6",
"piqure": "2.0.0"
},
"devDependencies": {
"@babel/cli": "7.25.6",
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/generator/dependencies/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"i18next-vue": "5.0.0",
"pinia": "2.2.2",
"pinia-plugin-persistedstate": "4.0.2",
"piqure": "2.0.0",
"vue": "3.5.8",
"vue-router": "4.4.5"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void shouldBuildModuleWithStyle() {
.containing(nodeDependency("vite"))
.containing(nodeDependency("react"))
.containing(nodeDependency("react-dom"))
.containing(nodeDependency("piqure"))
.containing(nodeScript("dev", "npm-run-all dev:*"))
.containing(nodeScript("dev:vite", "vite"))
.containing(nodeScript("build", "npm-run-all build:*"))
Expand Down Expand Up @@ -64,7 +65,7 @@ void shouldBuildModuleWithStyle() {
.and()
.hasFiles("vite.config.ts")
.hasFiles("src/main/webapp/index.html")
.hasPrefixedFiles("src/main/webapp/app", "index.css", "index.tsx", "vite-env.d.ts")
.hasPrefixedFiles("src/main/webapp/app", "index.css", "index.tsx", "vite-env.d.ts", "injections.ts")
.hasFiles("src/test/webapp/unit/home/infrastructure/primary/HomePage.spec.tsx")
.hasFile("src/main/webapp/app/home/infrastructure/primary/HomePage.tsx")
.containing("import './HomePage.css';")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default defineConfig({
include: ['src/main/webapp/**/*.ts?(x)'],
exclude: [
...configDefaults.coverage.exclude as string[],
'src/main/webapp/app/injections.ts',
'src/main/webapp/app/index.tsx',
],
provider: 'istanbul',
Expand Down

0 comments on commit 689587e

Please sign in to comment.