Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data class TemplateJson(
val version: String?,
val tooltipTag: String = "",
val defaultSaveLocation: String? = null,
val defaultAppName: String? = null,
val parameters: ParametersJson? = null,
val system: SystemParametersJson? = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ZipRecipeExecutor(

companion object {
private val log = LoggerFactory.getLogger(ZipRecipeExecutor::class.java)
private val CLASS_NAME_PATTERN = Regex("[^a-zA-Z0-9]")
}

override fun execute(
Expand Down Expand Up @@ -73,7 +74,9 @@ class ZipRecipeExecutor(
.syntax(customSyntax)
.build()

val (identifiers, warnings) = metaJson.pebbleParams(data, defModule, params)
val className = data.name.replace(CLASS_NAME_PATTERN, "")
val (baseIdentifiers, warnings) = metaJson.pebbleParams(data, defModule, params)
val identifiers = baseIdentifiers + (KEY_CLASS_NAME to className)
if (warnings.isNotEmpty()) {
warn("Identifier warnings: ${warnings.joinToString(System.lineSeparator())}")
}
Expand All @@ -98,6 +101,7 @@ class ZipRecipeExecutor(

val relativePath = normalized.removePrefix("$basePath/")
.replace(packageName.value, defModule.packageName.replace(".", "/"))
.replace(KEY_CLASS_NAME, className)

val outFile = File(projectDir, relativePath.removeSuffix(TEMPLATE_EXTENSION)).canonicalFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const val DELIM_COMMENT_CLOSE = "#}"

const val KEY_PACKAGE_NAME = "PACKAGE_NAME"
const val KEY_APP_NAME = "APP_NAME"
const val KEY_CLASS_NAME = "CLASS_NAME"
const val KEY_SAVE_LOCATION = "SAVE_LOCATION"
const val KEY_AGP_VERSION = "AGP_VERSION"
const val KEY_KOTLIN_VERSION = "KOTLIN_VERSION"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.itsaky.androidide.templates.TextFieldWidget
import com.itsaky.androidide.templates.Widget
import com.itsaky.androidide.templates.base.baseZipProject
import com.itsaky.androidide.templates.booleanParameter
import com.itsaky.androidide.templates.projectNameParameter
import com.itsaky.androidide.templates.stringParameter
import com.itsaky.androidide.utils.FeatureFlags
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -86,6 +87,9 @@ object ZipTemplateReader {
}

val project = baseZipProject(
projectName = projectNameParameter {
metaJson.defaultAppName?.let { default = it }
},
showLanguage = (metaJson.parameters?.optional?.language != null),
showMinSdk = (metaJson.parameters?.optional?.minsdk != null),
showPackageName = (metaJson.parameters?.required?.packageName != null),
Expand Down
Loading