Import other modules into monorepo
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
38
src/cli/templates/unit.ts
Normal file
38
src/cli/templates/unit.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import {Template} from "../Template"
|
||||
import {UniversalPath} from "../../util"
|
||||
|
||||
/**
|
||||
* Template that generates a new application unit class in app/units.
|
||||
*/
|
||||
const unit_template: Template = {
|
||||
name: 'unit',
|
||||
fileSuffix: '.ts',
|
||||
description: 'Create a service unit that will start and stop with your application.',
|
||||
baseAppPath: ['units'],
|
||||
render(name: string, fullCanonicalName: string, targetFilePath: UniversalPath) {
|
||||
return `import {Singleton, Inject} from "@extollo/di"
|
||||
import {Unit, Logging} from "@extollo/lib"
|
||||
|
||||
/**
|
||||
* ${name} Unit
|
||||
* ---------------------------------------
|
||||
* Put some description here.
|
||||
*/
|
||||
@Singleton()
|
||||
export class ${name} extends Unit {
|
||||
@Inject()
|
||||
protected readonly logging!: Logging
|
||||
|
||||
public async up() {
|
||||
this.logging.info('${name} has started!')
|
||||
}
|
||||
|
||||
public async down() {
|
||||
this.logging.info('${name} has stopped!')
|
||||
}
|
||||
}
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
export { unit_template }
|
||||
Reference in New Issue
Block a user