Up
This commit is contained in:
parent
8c50d1c727
commit
bdc3deb8d1
77
index.d.ts
vendored
77
index.d.ts
vendored
@ -3,44 +3,41 @@
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
declare function echo(message: string): void
|
||||
declare function echo(message: string): void
|
||||
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
declare function prompt(text: string, def?: string): string
|
||||
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
declare function promptBoolean(text: string, def?: boolean): boolean
|
||||
|
||||
/**
|
||||
* Renders a template
|
||||
*
|
||||
* @param name - The template name
|
||||
* @param context - The template context
|
||||
*/
|
||||
declare function render(name: string, context: any): string
|
||||
|
||||
/**
|
||||
* Write a string to a file
|
||||
*
|
||||
* @param input - The content of the file
|
||||
* @param output - The output path
|
||||
*/
|
||||
declare function write(input: string, output: string): void
|
||||
|
||||
/**
|
||||
* Copy a file
|
||||
*
|
||||
* @param input - The input path
|
||||
* @param output - The output path
|
||||
*/
|
||||
declare function copy(input: string, output: string): void
|
||||
declare interface prompt {
|
||||
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
string(text: string, def?: string): string
|
||||
|
||||
/**
|
||||
* Prompt a user for text input
|
||||
*
|
||||
* @param text - The text to display for the prompt
|
||||
* @param def - A default value
|
||||
*/
|
||||
boolean(text: string, def?: boolean): boolean
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a template
|
||||
*
|
||||
* @param name - The template name
|
||||
* @param context - The template context
|
||||
* @param output - The output path, if absent, default to the template name
|
||||
*/
|
||||
declare function render(name: string, context: any, output?: string): string
|
||||
|
||||
/**
|
||||
* Copy a file
|
||||
*
|
||||
* @param input - The input path
|
||||
* @param output - The output path, if absent, default to the input path
|
||||
*/
|
||||
declare function copy(input: string, output?: string): void
|
||||
18
index.js
18
index.js
@ -13,14 +13,12 @@ const files = [
|
||||
"gradlew.bat",
|
||||
]
|
||||
|
||||
for (let file of files) {
|
||||
copy(file, file)
|
||||
}
|
||||
files.forEach(f => copy(f))
|
||||
|
||||
const projectName = prompt("Project name")
|
||||
const javaVersion = prompt("Java version", "15")
|
||||
const basePackage = prompt("Base package")
|
||||
const mainClassName = prompt("Main class", projectName)
|
||||
const projectName = prompt.string("Project name")
|
||||
const javaVersion = prompt.string("Java version", "15")
|
||||
const basePackage = prompt.string("Base package")
|
||||
const mainClassName = prompt.string("Main class", projectName)
|
||||
|
||||
const mainClassNameWithPackage = `${basePackage}.${mainClassName}`
|
||||
|
||||
@ -44,9 +42,7 @@ const templates = [
|
||||
"buildSrc/src/main/kotlin/kotlin-convention.gradle.kts",
|
||||
]
|
||||
|
||||
for (let template of templates) {
|
||||
write(render(template, ctx), template)
|
||||
}
|
||||
templates.forEach(t => render(t, ctx))
|
||||
|
||||
const mainClassFile = "app/src/" + mainClassName + ".kt"
|
||||
write(render("app/src/App.kt", ctx), mainClassFile)
|
||||
render("app/src/App.kt", ctx, mainClassFile)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user