[JS, Wizard] Add react application template

^KT-41417 fixed
This commit is contained in:
Ilya Goncharov
2020-08-24 18:06:21 +03:00
parent 01064a4e46
commit d5340803bd
8 changed files with 43 additions and 2 deletions
@@ -129,6 +129,9 @@ project.template.native.console.description=Application with Kotlin/Native that
project.template.browser.title=Browser Application
project.template.browser.description=A blank application targeting the browser
project.template.react.title=React Application
project.template.react.description=React application targeting Browser
project.template.nodejs.title=Node.JS Application
project.template.nodejs.description=A blank application targeting Node.js
@@ -77,6 +77,7 @@ sealed class ProjectTemplate : DisplayableSettingItem {
MultiplatformLibraryProjectTemplate,
NativeApplicationProjectTemplate,
FrontendApplicationProjectTemplate,
ReactApplicationProjectTemplate,
FullStackWebApplicationProjectTemplate,
NodeJsApplicationProjectTemplate
)
@@ -298,6 +299,31 @@ object FrontendApplicationProjectTemplate : ProjectTemplate() {
)
}
object ReactApplicationProjectTemplate : ProjectTemplate() {
override val title = KotlinNewProjectWizardBundle.message("project.template.react.title")
override val description = KotlinNewProjectWizardBundle.message("project.template.react.description")
override val id = "reactApplication"
@NonNls
override val suggestedProjectName = "myKotlinJsApplication"
override val projectKind = ProjectKind.Js
override val setsPluginSettings: List<SettingWithValue<*, *>>
get() = listOf(
KotlinPlugin.modules.reference withValue listOf(
Module(
"js",
BrowserJsSinglePlatformModuleConfigurator,
template = ReactJsClientTemplate(),
sourcesets = SourcesetType.ALL.map { type ->
Sourceset(type, dependencies = emptyList())
},
subModules = emptyList()
)
)
)
}
object MultiplatformMobileApplicationProjectTemplate : ProjectTemplate() {
override val title = KotlinNewProjectWizardBundle.message("project.template.mpp.mobile.title")
override val description = KotlinNewProjectWizardBundle.message("project.template.mpp.mobile.description")
@@ -52,7 +52,7 @@ class ReactJsClientTemplate : JsClientTemplate() {
buildList {
val hasKtorServNeighbourTarget = hasKtorServNeighbourTarget(module)
if (!hasKtorServNeighbourTarget) {
+(FileTemplateDescriptor("$id/index.html.vm") asResourceOf SourcesetType.main)
+(FileTemplateDescriptor("jsClient/index.html.vm") asResourceOf SourcesetType.main)
}
+(FileTemplateDescriptor("$id/reactClient.kt.vm", "client.kt".asPath()) asSrcOf SourcesetType.main)
+(FileTemplateDescriptor("$id/reactComponent.kt.vm", "welcome.kt".asPath()) asSrcOf SourcesetType.main)
@@ -57,7 +57,7 @@ class SimpleJsClientTemplate : JsClientTemplate() {
buildList {
val hasKtorServNeighbourTarget = hasKtorServNeighbourTarget(module)
if (!hasKtorServNeighbourTarget) {
+(FileTemplateDescriptor("$id/index.html.vm") asResourceOf SourcesetType.main)
+(FileTemplateDescriptor("jsClient/index.html.vm") asResourceOf SourcesetType.main)
}
if (useKotlinxHtml.reference.settingValue()) {
+(FileTemplateDescriptor("$id/client.kt.vm") asSrcOf SourcesetType.main)