-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2502 from DamnClin/react-modules
Migrate react modules
- Loading branch information
Showing
25 changed files
with
335 additions
and
684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/tech/jhipster/lite/generator/client/common/domain/ClientsModulesFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package tech.jhipster.lite.generator.client.common.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.module.domain.Indentation; | ||
import tech.jhipster.lite.module.domain.JHipsterModule.JHipsterModuleBuilder; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
public class ClientsModulesFactory { | ||
|
||
private static final String CACHE_NEEDLE = " \"cacheDirectories\":"; | ||
|
||
private ClientsModulesFactory() {} | ||
|
||
public static JHipsterModuleBuilder clientModuleBuilder(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
|
||
return moduleBuilder(properties) | ||
.optionalReplacements() | ||
.in("package.json") | ||
.add(justLineBefore(text(CACHE_NEEDLE)), jestSonar(properties.indentation())) | ||
.and() | ||
.and(); | ||
} | ||
|
||
private static String jestSonar(Indentation indentation) { | ||
return new StringBuilder() | ||
.append(indentation.spaces()) | ||
.append("\"jestSonar\": {") | ||
.append(LINE_BREAK) | ||
.append(indentation.times(2)) | ||
.append("\"reportPath\": \"target/test-results/jest\",") | ||
.append(LINE_BREAK) | ||
.append(indentation.times(2)) | ||
.append("\"reportFile\": \"TESTS-results-sonar.xml\"") | ||
.append(LINE_BREAK) | ||
.append(indentation.spaces()) | ||
.append("},") | ||
.toString(); | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
...a/tech/jhipster/lite/generator/client/react/core/application/ReactApplicationService.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...ch/jhipster/lite/generator/client/react/core/application/ReactCoreApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tech.jhipster.lite.generator.client.react.core.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.client.react.core.domain.ReactCoreModulesFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class ReactCoreApplicationService { | ||
|
||
private final ReactCoreModulesFactory factory; | ||
|
||
public ReactCoreApplicationService() { | ||
factory = new ReactCoreModulesFactory(); | ||
} | ||
|
||
public JHipsterModule buildModuleWithoutStyle(JHipsterModuleProperties properties) { | ||
return factory.buildModuleWithoutStyle(properties); | ||
} | ||
|
||
public JHipsterModule buildModuleWithStyle(JHipsterModuleProperties properties) { | ||
return factory.buildModuleWithStyle(properties); | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
src/main/java/tech/jhipster/lite/generator/client/react/core/domain/React.java
This file was deleted.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
...n/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package tech.jhipster.lite.generator.client.react.core.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
import static tech.jhipster.lite.module.domain.packagejson.VersionSource.*; | ||
|
||
import tech.jhipster.lite.generator.client.common.domain.ClientsModulesFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterDestination; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.JHipsterSource; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
public class ReactCoreModulesFactory { | ||
|
||
private static final JHipsterSource SOURCE = from("client/react"); | ||
|
||
private static final JHipsterSource WEBAPP_SOURCE = SOURCE.append("src/main/webapp"); | ||
private static final JHipsterDestination WEBAPP_DESTINATION = to("src/main/webapp"); | ||
|
||
private static final JHipsterSource APP_SOURCE = WEBAPP_SOURCE.append("app"); | ||
private static final JHipsterDestination APP_DESTINATION = WEBAPP_DESTINATION.append("app"); | ||
|
||
private static final String PRIMARY_APP = "common/primary/app"; | ||
private static final String CONTENT_IMAGES = "content/images"; | ||
|
||
private static final JHipsterSource PRIMARY_APP_SOURCE = APP_SOURCE.append(PRIMARY_APP); | ||
private static final JHipsterDestination PRIMARY_APP_DESTINATION = APP_DESTINATION.append(PRIMARY_APP); | ||
|
||
private static final String TEST_PRIMARY = "src/test/javascript/spec/common/primary/app"; | ||
|
||
public JHipsterModule buildModuleWithoutStyle(JHipsterModuleProperties properties) { | ||
//@formatter:off | ||
return commonModuleBuilder(properties) | ||
.files() | ||
.add(PRIMARY_APP_SOURCE.template("App.tsx"), APP_DESTINATION.append("common/primary/app/App.tsx")) | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
|
||
public JHipsterModule buildModuleWithStyle(JHipsterModuleProperties properties) { | ||
//@formatter:off | ||
return commonModuleBuilder(properties) | ||
.files() | ||
.add(PRIMARY_APP_SOURCE.template("StyledApp.tsx"), PRIMARY_APP_DESTINATION.append("App.tsx")) | ||
.add(PRIMARY_APP_SOURCE.template("App.css"), PRIMARY_APP_DESTINATION.append("App.css")) | ||
.batch(WEBAPP_SOURCE.append(CONTENT_IMAGES), WEBAPP_DESTINATION.append(CONTENT_IMAGES)) | ||
.file("JHipster-Lite-neon-blue.png") | ||
.file("ReactLogo.png") | ||
.and() | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
|
||
private static JHipsterModuleBuilder commonModuleBuilder(JHipsterModuleProperties properties) { | ||
//@formatter:off | ||
return ClientsModulesFactory.clientModuleBuilder(properties) | ||
.packageJson() | ||
.addDevDependency(packageName("@testing-library/jest-dom"), REACT) | ||
.addDevDependency(packageName("@testing-library/react"), REACT) | ||
.addDevDependency(packageName("@testing-library/user-event"), REACT) | ||
.addDevDependency(packageName("@types/jest"), REACT) | ||
.addDevDependency(packageName("@types/node"), REACT) | ||
.addDevDependency(packageName("@types/react"), REACT) | ||
.addDevDependency(packageName("@types/react-dom"), REACT) | ||
.addDevDependency(packageName("@types/ws"), REACT) | ||
.addDevDependency(packageName("@vitejs/plugin-react"), REACT) | ||
.addDevDependency(packageName("jest"), REACT) | ||
.addDevDependency(packageName("jest-sonar-reporter"), REACT) | ||
.addDevDependency(packageName("jest-css-modules"), REACT) | ||
.addDevDependency(packageName("jest-environment-jsdom"), REACT) | ||
.addDevDependency(packageName("typescript"), REACT) | ||
.addDevDependency(packageName("ts-jest"), REACT) | ||
.addDevDependency(packageName("ts-node"), REACT) | ||
.addDevDependency(packageName("vite"), REACT) | ||
.addDependency(packageName("react"), REACT) | ||
.addDependency(packageName("react-dom"), REACT) | ||
.addScript(scriptKey("dev"), scriptCommand("vite")) | ||
.addScript(scriptKey("build"), scriptCommand("tsc && vite build --emptyOutDir")) | ||
.addScript(scriptKey("preview"), scriptCommand("vite preview")) | ||
.addScript(scriptKey("start"), scriptCommand("vite")) | ||
.addScript(scriptKey("test"), scriptCommand("jest")) | ||
.addScript(scriptKey("dev"), scriptCommand("vite")) | ||
.addScript(scriptKey("test:watch"), scriptCommand("jest --watch")) | ||
.and() | ||
.files() | ||
.batch(SOURCE, to(".")) | ||
.file("tsconfig.json") | ||
.file("vite.config.ts") | ||
.file("jest.config.ts") | ||
.and() | ||
.batch(APP_SOURCE, APP_DESTINATION) | ||
.template("index.css") | ||
.template("index.tsx") | ||
.template("vite-env.d.ts") | ||
.and() | ||
.add(WEBAPP_SOURCE.template("index.html"), WEBAPP_DESTINATION.append("index.html")) | ||
.add(SOURCE.append(TEST_PRIMARY).template("App.spec.tsx"), to(TEST_PRIMARY).append("App.spec.tsx")) | ||
.add(WEBAPP_SOURCE.template("config/setupTests.ts"), WEBAPP_DESTINATION.append("config/setupTests.ts")) | ||
.and(); | ||
//@formatter:on | ||
} | ||
} |
Oops, something went wrong.