Skip to content

Instantly share code, notes, and snippets.

@batosai
Created December 11, 2021 21:14
Show Gist options
  • Save batosai/a0c58a353d86796285b8cd168bc9d063 to your computer and use it in GitHub Desktop.
Save batosai/a0c58a353d86796285b8cd168bc9d063 to your computer and use it in GitHub Desktop.
Create scaffold command for Adonis 5
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',
})
}
}
@batosai
Copy link
Author

batosai commented Dec 11, 2021

node ace generate:manifest

node ace make:scaffold name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment