Created
December 11, 2021 21:14
-
-
Save batosai/a0c58a353d86796285b8cd168bc9d063 to your computer and use it in GitHub Desktop.
Create scaffold command for Adonis 5
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 execa from 'execa' | |
import { BaseCommand, args } from '@adonisjs/core/build/standalone' | |
export default class MakeScaffold extends BaseCommand { | |
/** | |
* Command name is used to run the command | |
*/ | |
public static commandName = 'make:scaffold' | |
@args.string({ description: 'Name of the controller and model class' }) | |
public name: string | |
/** | |
* Command description is displayed in the "help" output | |
*/ | |
public static description = 'Make a new HTTP controller / Lucid model / view template' | |
public static settings = { | |
/** | |
* Set the following value to true, if you want to load the application | |
* before running the command | |
*/ | |
loadApp: false, | |
/** | |
* Set the following value to true, if you want this command to keep running until | |
* you manually decide to exit the process | |
*/ | |
stayAlive: false, | |
} | |
public async run() { | |
await execa.node('ace', ['make:controller', this.name], { | |
stdio: 'inherit', | |
}) | |
await execa.node('ace', ['make:model', this.name], { | |
stdio: 'inherit', | |
}) | |
await execa.node('ace', ['make:view', this.name], { | |
stdio: 'inherit', | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
node ace generate:manifest
node ace make:scaffold name