[JS, Wizard] Add redux and react router
^KT-41417 fixed
This commit is contained in:
+2
@@ -164,6 +164,8 @@ module.template.simple.use.kotlinx.html=Use kotlinx.html
|
|||||||
module.template.js.react.title=React Application
|
module.template.js.react.title=React Application
|
||||||
module.template.js.react.description=React Application
|
module.template.js.react.description=React Application
|
||||||
module.template.react.use.styled.components=Use styled-components
|
module.template.react.use.styled.components=Use styled-components
|
||||||
|
module.template.react.use.react.router.dom=Use react-router-dom
|
||||||
|
module.template.react.use.react.redux=Use react-redux
|
||||||
|
|
||||||
module.template.simple.nodejs.title=Node.JS Application
|
module.template.simple.nodejs.title=Node.JS Application
|
||||||
module.template.simple.nodejs.description=A blank application targeting Node.js
|
module.template.simple.nodejs.description=A blank application targeting Node.js
|
||||||
|
|||||||
+8
-2
@@ -26,9 +26,15 @@ object Versions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object JS_WRAPPERS {
|
object JS_WRAPPERS {
|
||||||
val KOTLIN_REACT: (kotlinVersion: Version) -> Version = { kotlinVersion -> version("16.13.1-pre.110-kotlin-$kotlinVersion") }
|
val KOTLIN_REACT: (kotlinVersion: Version) -> Version = wrapperVersion("16.13.1")
|
||||||
val KOTLIN_REACT_DOM = KOTLIN_REACT
|
val KOTLIN_REACT_DOM = KOTLIN_REACT
|
||||||
val KOTLIN_STYLED: (kotlinVersion: Version) -> Version = { kotlinVersion -> version("1.0.0-pre.110-kotlin-$kotlinVersion") }
|
val KOTLIN_STYLED: (kotlinVersion: Version) -> Version = wrapperVersion("1.0.0")
|
||||||
|
val KOTLIN_REACT_ROUTER_DOM: (kotlinVersion: Version) -> Version = wrapperVersion("5.1.2")
|
||||||
|
val KOTLIN_REDUX: (kotlinVersion: Version) -> Version = wrapperVersion("4.0.0")
|
||||||
|
val KOTLIN_REACT_REDUX: (kotlinVersion: Version) -> Version = wrapperVersion("5.0.7")
|
||||||
|
|
||||||
|
private fun wrapperVersion(version: String): (Version) -> Version =
|
||||||
|
{ kotlinVersion -> version("$version-pre.110-kotlin-$kotlinVersion") }
|
||||||
}
|
}
|
||||||
|
|
||||||
object GRADLE_PLUGINS {
|
object GRADLE_PLUGINS {
|
||||||
|
|||||||
+68
-20
@@ -9,9 +9,15 @@ package org.jetbrains.kotlin.tools.projectWizard.templates
|
|||||||
import org.jetbrains.annotations.NonNls
|
import org.jetbrains.annotations.NonNls
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.KotlinNewProjectWizardBundle
|
import org.jetbrains.kotlin.tools.projectWizard.KotlinNewProjectWizardBundle
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.Versions
|
import org.jetbrains.kotlin.tools.projectWizard.Versions
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.*
|
import org.jetbrains.kotlin.tools.projectWizard.core.Reader
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.Writer
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.asPath
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.core.buildList
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.TemplateSetting
|
import org.jetbrains.kotlin.tools.projectWizard.core.entity.settings.TemplateSetting
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.*
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.ArtifactBasedLibraryDependencyIR
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.DependencyIR
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.DependencyType
|
||||||
|
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.ModuleIR
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.library.MavenArtifact
|
import org.jetbrains.kotlin.tools.projectWizard.library.MavenArtifact
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin
|
||||||
@@ -34,7 +40,26 @@ class ReactJsClientTemplate : JsClientTemplate() {
|
|||||||
defaultValue = value(false)
|
defaultValue = value(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val settings: List<TemplateSetting<*, *>> = listOf(useStyledComponents)
|
val useReactRouterDom by booleanSetting(
|
||||||
|
KotlinNewProjectWizardBundle.message("module.template.react.use.react.router.dom"),
|
||||||
|
GenerationPhase.PROJECT_GENERATION
|
||||||
|
) {
|
||||||
|
defaultValue = value(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
val useReactRedux by booleanSetting(
|
||||||
|
KotlinNewProjectWizardBundle.message("module.template.react.use.react.redux"),
|
||||||
|
GenerationPhase.PROJECT_GENERATION
|
||||||
|
) {
|
||||||
|
defaultValue = value(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override val settings: List<TemplateSetting<*, *>> =
|
||||||
|
listOf(
|
||||||
|
useStyledComponents,
|
||||||
|
useReactRouterDom,
|
||||||
|
useReactRedux
|
||||||
|
)
|
||||||
|
|
||||||
override fun Writer.getRequiredLibraries(module: ModuleIR): List<DependencyIR> = withSettingsOf(module.originalModule) {
|
override fun Writer.getRequiredLibraries(module: ModuleIR): List<DependencyIR> = withSettingsOf(module.originalModule) {
|
||||||
buildList {
|
buildList {
|
||||||
@@ -44,6 +69,13 @@ class ReactJsClientTemplate : JsClientTemplate() {
|
|||||||
if (useStyledComponents.reference.settingValue) {
|
if (useStyledComponents.reference.settingValue) {
|
||||||
+Dependencies.KOTLIN_STYLED(kotlinVersion.version)
|
+Dependencies.KOTLIN_STYLED(kotlinVersion.version)
|
||||||
}
|
}
|
||||||
|
if (useReactRouterDom.reference.settingValue) {
|
||||||
|
+Dependencies.KOTLIN_REACT_ROUTER_DOM(kotlinVersion.version)
|
||||||
|
}
|
||||||
|
if (useReactRedux.reference.settingValue) {
|
||||||
|
+Dependencies.KOTLIN_REDUX(kotlinVersion.version)
|
||||||
|
+Dependencies.KOTLIN_REACT_REDUX(kotlinVersion.version)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,24 +100,40 @@ class ReactJsClientTemplate : JsClientTemplate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private object Dependencies {
|
private object Dependencies {
|
||||||
val KOTLIN_REACT = { kotlinVersion: Version ->
|
val KOTLIN_REACT = wrapperDependency(
|
||||||
|
"kotlin-react",
|
||||||
|
Versions.JS_WRAPPERS.KOTLIN_REACT
|
||||||
|
)
|
||||||
|
|
||||||
|
val KOTLIN_REACT_DOM = wrapperDependency(
|
||||||
|
"kotlin-react-dom",
|
||||||
|
Versions.JS_WRAPPERS.KOTLIN_REACT_DOM
|
||||||
|
)
|
||||||
|
|
||||||
|
val KOTLIN_STYLED = wrapperDependency(
|
||||||
|
"kotlin-styled",
|
||||||
|
Versions.JS_WRAPPERS.KOTLIN_STYLED
|
||||||
|
)
|
||||||
|
|
||||||
|
val KOTLIN_REACT_ROUTER_DOM = wrapperDependency(
|
||||||
|
"kotlin-react-router-dom",
|
||||||
|
Versions.JS_WRAPPERS.KOTLIN_REACT_ROUTER_DOM
|
||||||
|
)
|
||||||
|
|
||||||
|
val KOTLIN_REDUX = wrapperDependency(
|
||||||
|
"kotlin-redux",
|
||||||
|
Versions.JS_WRAPPERS.KOTLIN_REDUX
|
||||||
|
)
|
||||||
|
|
||||||
|
val KOTLIN_REACT_REDUX = wrapperDependency(
|
||||||
|
"kotlin-react-redux",
|
||||||
|
Versions.JS_WRAPPERS.KOTLIN_REACT_REDUX
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun wrapperDependency(artifact: String, version: (Version) -> Version) = { kotlinVersion: Version ->
|
||||||
ArtifactBasedLibraryDependencyIR(
|
ArtifactBasedLibraryDependencyIR(
|
||||||
MavenArtifact(Repositories.KOTLIN_JS_WRAPPERS_BINTRAY, "org.jetbrains", "kotlin-react"),
|
MavenArtifact(Repositories.KOTLIN_JS_WRAPPERS_BINTRAY, "org.jetbrains", artifact),
|
||||||
Versions.JS_WRAPPERS.KOTLIN_REACT(kotlinVersion),
|
version(kotlinVersion),
|
||||||
DependencyType.MAIN
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val KOTLIN_REACT_DOM = { kotlinVersion: Version ->
|
|
||||||
ArtifactBasedLibraryDependencyIR(
|
|
||||||
MavenArtifact(Repositories.KOTLIN_JS_WRAPPERS_BINTRAY, "org.jetbrains", "kotlin-react-dom"),
|
|
||||||
Versions.JS_WRAPPERS.KOTLIN_REACT_DOM(kotlinVersion),
|
|
||||||
DependencyType.MAIN
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val KOTLIN_STYLED = { kotlinVersion: Version ->
|
|
||||||
ArtifactBasedLibraryDependencyIR(
|
|
||||||
MavenArtifact(Repositories.KOTLIN_JS_WRAPPERS_BINTRAY, "org.jetbrains", "kotlin-styled"),
|
|
||||||
Versions.JS_WRAPPERS.KOTLIN_STYLED(kotlinVersion),
|
|
||||||
DependencyType.MAIN
|
DependencyType.MAIN
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user