diff --git a/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/Angular.java b/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/Angular.java index b753dbdbdb3..584bd1010bb 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/Angular.java +++ b/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/Angular.java @@ -5,6 +5,11 @@ public class Angular { + public static final String APP_MODULE = "app.module.ts"; + public static final String APP_COMPONENT = "app.component.ts"; + public static final String APP_COMPONENT_SPEC = "app.component.spec.ts"; + public static final String APP_COMPONENT_HTML = "app.component.html"; + private Angular() {} public static List devDependencies() { @@ -59,8 +64,8 @@ public static List files() { return List.of("angular.json", "jest.conf.js", "tsconfig.app.json", "tsconfig.json", "tsconfig.spec.json"); } - public static List jwtFiles() { - return List.of("proxy.conf.json"); + public static Map jwtFiles() { + return Map.ofEntries(Map.entry("proxy.conf.json", "")); } public static Map angularFiles() { @@ -71,12 +76,12 @@ public static Map angularFiles() { Map.entry("main.ts", ""), Map.entry("polyfills.ts", ""), Map.entry("styles.css", ""), - Map.entry("app.module.ts", primaryApp), - Map.entry("app.component.ts", primaryApp), - Map.entry("app.component.html", primaryApp), + Map.entry(APP_MODULE, primaryApp), + Map.entry(APP_COMPONENT, primaryApp), + Map.entry(APP_COMPONENT_HTML, primaryApp), Map.entry("app-routing.module.ts", primaryApp), Map.entry("app-routing.module.spec.ts", primaryApp), - Map.entry("app.component.spec.ts", primaryApp), + Map.entry(APP_COMPONENT_SPEC, primaryApp), Map.entry("environment.prod.ts", environments), Map.entry("environment.prod.spec.ts", environments), Map.entry("environment.ts", environments), diff --git a/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainService.java b/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainService.java index de9b53efeb8..6c8e74d45fc 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainService.java +++ b/src/main/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainService.java @@ -1,6 +1,10 @@ package tech.jhipster.lite.generator.client.angular.core.domain; import static tech.jhipster.lite.common.domain.FileUtils.getPath; +import static tech.jhipster.lite.generator.client.angular.core.domain.Angular.APP_COMPONENT; +import static tech.jhipster.lite.generator.client.angular.core.domain.Angular.APP_COMPONENT_HTML; +import static tech.jhipster.lite.generator.client.angular.core.domain.Angular.APP_COMPONENT_SPEC; +import static tech.jhipster.lite.generator.client.angular.core.domain.Angular.APP_MODULE; import static tech.jhipster.lite.generator.project.domain.Constants.MAIN_WEBAPP; import static tech.jhipster.lite.generator.project.domain.Constants.PACKAGE_JSON; import static tech.jhipster.lite.generator.project.domain.DefaultConfig.BASE_NAME; @@ -18,11 +22,6 @@ public class AngularDomainService implements AngularService { public static final String SOURCE_PRIMARY = getPath(SOURCE, APP); public static final String DESTINATION_PRIMARY = APP; - private static final String APP_MODULE = "app.module.ts"; - private static final String APP_COMPONENT = "app.component.ts"; - private static final String APP_COMPONENT_SPEC = "app.component.spec.ts"; - private static final String APP_COMPONENT_HTML = "app.component.html"; - private final ProjectRepository projectRepository; private final NpmService npmService; @@ -432,7 +431,8 @@ public void addFiles(Project project) { } public void addJwtFiles(Project project) { - Angular.jwtFiles().forEach(file -> projectRepository.add(project, SOURCE, file)); + project.addConfig("serverPort", 8080); + Angular.jwtFiles().forEach((file, path) -> projectRepository.template(project, getPath(SOURCE, path), file, getPath("", path))); } public void addAngularFiles(Project project) { diff --git a/src/main/resources/generator/client/angular/proxy.conf.json b/src/main/resources/generator/client/angular/proxy.conf.json deleted file mode 100644 index 7d4976bc4b3..00000000000 --- a/src/main/resources/generator/client/angular/proxy.conf.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "/api": { - "target": "http://localhost:8080", - "secure": false - } -} diff --git a/src/main/resources/generator/client/angular/proxy.conf.json.mustache b/src/main/resources/generator/client/angular/proxy.conf.json.mustache new file mode 100644 index 00000000000..4ec09e6e12a --- /dev/null +++ b/src/main/resources/generator/client/angular/proxy.conf.json.mustache @@ -0,0 +1,6 @@ +{ + "/api": { + "target": "http://localhost:{{serverPort}}", + "secure": false + } +} diff --git a/src/test/java/tech/jhipster/lite/generator/client/angular/core/application/AngularAssert.java b/src/test/java/tech/jhipster/lite/generator/client/angular/core/application/AngularAssert.java index 00f230d4f5f..c14197602e3 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/angular/core/application/AngularAssert.java +++ b/src/test/java/tech/jhipster/lite/generator/client/angular/core/application/AngularAssert.java @@ -69,18 +69,8 @@ public static void assertAppWithCss(Project project) { } public static void assertAppJwt(Project project) { - String pathAuth = "src/main/webapp/app/auth"; - String pathLogin = "src/main/webapp/app/login"; - - assertFileExist(project, getPath(pathAuth, "account.model.ts")); - assertFileExist(project, getPath(pathAuth, "account.service.ts")); - assertFileExist(project, getPath(pathAuth, "account.service.spec.ts")); - assertFileExist(project, getPath(pathAuth, "auth-jwt.service.ts")); - assertFileExist(project, getPath(pathAuth, "auth-jwt.service.spec.ts")); - assertFileExist(project, getPath(pathAuth, "auth.interceptor.ts")); - assertFileExist(project, getPath(pathLogin, "login.service.ts")); - assertFileExist(project, getPath(pathLogin, "login.service.spec.ts")); - assertFileExist(project, getPath(pathLogin, "login.model.ts")); + String rootPath = "src/main/webapp/"; + Angular.angularJwtFiles().forEach((file, path) -> assertFileExist(project, getPath(rootPath + path, file))); } public static void assertLogos(Project project) { diff --git a/src/test/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainServiceTest.java b/src/test/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainServiceTest.java index 0c9ac0eacc2..8ae7fbedf50 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainServiceTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/angular/core/domain/AngularDomainServiceTest.java @@ -154,7 +154,7 @@ void shouldAddJwtFiles() { angularDomainService.addJwtFiles(project); - verify(projectRepository, times(1)).add(any(Project.class), anyString(), anyString()); + verify(projectRepository, times(1)).template(any(Project.class), anyString(), anyString(), anyString()); } @Test