2021-06-03 03:36:25 +00:00
|
|
|
import {Template} from '../Template'
|
2021-06-02 01:59:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Template that generates a new application unit class in app/units.
|
|
|
|
*/
|
2021-06-03 03:36:25 +00:00
|
|
|
const templateUnit: Template = {
|
2021-06-02 01:59:40 +00:00
|
|
|
name: 'unit',
|
|
|
|
fileSuffix: '.ts',
|
|
|
|
description: 'Create a service unit that will start and stop with your application.',
|
|
|
|
baseAppPath: ['units'],
|
2021-06-03 03:36:25 +00:00
|
|
|
render(name: string) {
|
|
|
|
return `import {Singleton, Inject, Unit, Logging} from '@extollo/lib'
|
2021-06-02 01:59:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ${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!')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2021-06-03 03:36:25 +00:00
|
|
|
},
|
2021-06-02 01:59:40 +00:00
|
|
|
}
|
|
|
|
|
2021-06-03 03:36:25 +00:00
|
|
|
export { templateUnit }
|