TASKS-1823 WebManager module
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import app from '@adonisjs/core/services/app'
|
||||
|
||||
export function capitalize(str: string) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||
}
|
||||
|
||||
export function camelCase(str: string) {
|
||||
return str.replace(/_([a-z])/g, (_, c) => c.toUpperCase())
|
||||
}
|
||||
|
||||
export function pascalCase(str: string) {
|
||||
return capitalize(camelCase(str))
|
||||
}
|
||||
|
||||
// Naive singularization used for generated file names ("posts" -> "post"):
|
||||
// simply drops the trailing character.
|
||||
export function singularize(str: string) {
|
||||
return str.slice(0, str.length - 1)
|
||||
}
|
||||
|
||||
export function tableToModelName(tableName: string): string {
|
||||
return app.generators.modelName(tableName)
|
||||
}
|
||||
|
||||
export function tableToModelSchemaName(tableName: string): string {
|
||||
return app.generators.modelName(tableName) + 'Schema'
|
||||
}
|
||||
Reference in New Issue
Block a user