-
-
Save Rawphs/4f0ef360ddab7794549fa7b9b7e8b821 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { GeneratorCommand } from '../Library/Command'; | |
export const cli = { | |
commands: [ | |
Cli.program('generator', { | |
commands: [ | |
Cli.command('generator:controller <name>', GeneratorCommand, 'generateController', { | |
description: 'Generates a new controller file', | |
examples: [ | |
`$ stix generator:controller user`, | |
`$ stix generator:module auth`, | |
], | |
}), | |
], | |
}), | |
], | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AbstractActionController, ContextInterface } from 'stix'; | |
export class {{ name }}Controller extends AbstractActionController { | |
public async root({ params }: ContextInterface) { | |
return this.okResponse({ Hello: 'world!' }); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ContextInterface } from 'stix'; | |
export class {{ name }} extends AbstractGate { | |
public passThrough (ctx: ContextInterface) { | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { AbstractCommand } from '../Command'; | |
import { inject } from '../ServiceManager/decorators'; | |
import { CliService } from '../Cli'; | |
import { Output } from '../Output'; | |
import { TapeRoller } from 'tape-roller'; | |
import * as path from 'path'; | |
export class GeneratorCommand extends AbstractCommand { | |
@inject(CliService) | |
private cliService: CliService; | |
async generateController (output: Output, params: { [key: string]: any }) { | |
const tapeRoller = new TapeRoller({ | |
sourceDirectory: path.resolve(__dirname, '..', '..', '..', 'templates', 'controller'), | |
targetDirectory: path.resolve(process.cwd(), 'app', 'src', 'Controller'), | |
}); | |
try { | |
await tapeRoller.read('Controller.ts').replace({ name: params.name }).write(`${params.name}Controller.ts`); | |
} catch (error) { | |
console.log(error); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { {{ name }} } from './src/{{ name }}'; | |
export default {{ name }}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as config from '../config'; | |
import { ModuleInterface } from 'stix'; | |
export class {{ name }} implements ModuleInterface { | |
getConfig() { | |
return config; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment