How to use the @adonisjs/ace.flags.boolean function in @adonisjs/ace

To help you get started, we’ve selected a few @adonisjs/ace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adonisjs / adonis-cli / src / Commands / Build.ts View on Github external
import { getRcContents } from '../helpers'
import { Compiler } from '../Services/Compiler'

/**
 * Build the AdonisJs typescript project for production.
 */
export default class Build extends BaseCommand {
  public static commandName = 'build'
  public static description = `Compile Typescript project to Javascript`

  @flags.boolean({
    description: 'Use yarn instead of npm for installing dependencies',
  })
  public yarn: boolean

  @flags.boolean({ description: 'Build the project for development and watch for file changes' })
  public watch: boolean

  /**
   * Reference to the project root. It always has to be
   * the current working directory
   */
  public projectRoot = process.cwd()

  /**
   * Called by ace automatically, when this command is invoked
   */
  public async handle () {
    const rcContents = await getRcContents(this.projectRoot)

    /**
     * Ensure `.adonisrc.json` file exists
github adonisjs / adonis-cli / src / Commands / Make / Controller.ts View on Github external
import { BaseCommand, args, flags } from '@adonisjs/ace'

import { getRcContents } from '../../helpers'
import { ResourceBuilder } from '../../Services/ResourceBuilder'

/**
 * Make a new controller
 */
export default class MakeController extends BaseCommand {
  public static commandName = 'make:controller'
  public static description = 'Make a new HTTP controller'

  @args.string({ description: 'Name of the controller' })
  public name: string

  @flags.boolean({ description: 'Create a resourceful controller' })
  public resource: boolean

  /**
   * Reference to the project root. It always has to be
   * the current working directory
   */
  public projectRoot = process.cwd()

  /**
   * Called by ace automatically, when this command is invoked
   */
  public async handle () {
    const rcContents = await getRcContents(this.projectRoot)

    /**
     * Ensure `.adonisrc.json` file exists
github adonisjs / adonis-lucid / commands / Migrate.ts View on Github external
import MigrationsBase from './MigrationsBase'

/**
 * The command is meant to migrate the database by execute migrations
 * in `up` direction.
 */
@inject([null, 'Adonis/Lucid/Database'])
export default class Migrate extends MigrationsBase {
  public static commandName = 'migration:run'
  public static description = 'Run pending migrations'

  @flags.string({ description: 'Define a custom database connection' })
  public connection: string

  @flags.boolean({ description: 'Print SQL queries, instead of running the migrations' })
  public dryRun: boolean

  /**
   * This command loads the application, since we need the runtime
   * to find the migration directories for a given connection
   */
  public static settings = {
    loadApp: true,
  }

  constructor (app: ApplicationContract, private _db: DatabaseContract) {
    super(app)
  }

  /**
   * Handle command
github adonisjs / assembler / commands / Make / Controller.ts View on Github external
/**
   * Do not pluralize `HomeController` name
   */
  protected $formIgnoreList = ['Home']

  /**
   * Command meta data
   */
  public static commandName = 'make:controller'
  public static description = 'Make a new HTTP controller'

  @args.string({ description: 'Make of the controller class' })
  public name: string

  @flags.boolean({ description: 'Add resourceful methods to the controller class', alias: 'r' })
  public resource: boolean

  /**
   * Returns the template stub based upon the `--resource`
   * flag value
   */
  protected $getStub (): string {
    return join(
      __dirname,
      '..',
      '..',
      'templates',
      this.resource ? 'resource-controller.txt' : 'controller.txt',
    )
  }
github adonisjs / adonis-cli / src / Commands / Serve.ts View on Github external
/**
 * Command to compile and start HTTP server for AdonisJs
 * applications.
 */
export default class Serve extends BaseCommand {
  public static commandName = 'serve'
  public static description = 'Compile Typescript project to Javascript and start the development HTTP server'

  @flags.boolean({ description: 'Build the project and watch for file changes' })
  public watch: boolean

  @flags.array({ description: 'Pass arguments to the node command' })
  public nodeArgs: string[]

  @flags.boolean({
    description: 'Enable/disable the Typescript compiler, but still start the HTTP server',
    default: true,
  })
  public compile: boolean

  /**
   * Reference to the project root. It always have to be
   * the current working directory
   */
  public projectRoot = process.cwd()

  /**
   * Compile and serve the project
   */
  private async _compileAndServe (rcContents: RcFile) {
    const compiler = new Compiler(this.projectRoot, rcContents, this.nodeArgs)
github adonisjs / assembler / commands / Make / Provider.ts View on Github external
*/
  protected $suffix = 'Provider'
  protected $form = 'singular' as const
  protected $pattern = 'pascalcase' as const
  protected $resourceName: string

  /**
   * Command meta data
   */
  public static commandName = 'make:provider'
  public static description = 'Make a new IoC container provider'

  @args.string({ description: 'Make of the provider class' })
  public name: string

  @flags.boolean({ description: 'Register provider under the ace providers array' })
  public ace: boolean

  /**
   * Returns the template stub path
   */
  protected $getStub (): string {
    return join(
      __dirname,
      '..',
      '..',
      'templates',
      'provider.txt',
    )
  }

  /**
github adonisjs / assembler / commands / Build.ts View on Github external
/**
   * Allows watching for file changes
   */
  @flags.boolean({ description: 'Watch for file changes and re-build the project', alias: 'w' })
  public watch: boolean

  /**
   * Build for production
   */
  @flags.boolean({ description: 'Build for production', alias: 'prod' })
  public production: boolean

  /**
   * Use yarn when building for production to install dependencies
   */
  @flags.boolean({ description: 'Use yarn for installing dependencies. Defaults to npm' })
  public yarn: boolean

  /**
   * Invoked automatically by ace
   */
  public async handle () {
    const { Watcher } = await import('../src/Watcher')
    const { Compiler } = await import('../src/Compiler')
    const { ADONIS_ACE_CWD, ADONIS_IS_TYPESCRIPT } = await import('../config/env')

    const cwd = ADONIS_ACE_CWD()

    /**
     * Dis-allow when CWD is missing. It will always be set by `node ace`
     * commands and also when project is not a typescript project.
     */
github adonisjs / adonis-cli / src / Commands / New.ts View on Github external
import { satisfiesNodeVersion, dumpAsciiLogo } from '../helpers'

/**
 * Build the AdonisJs typescript project for production.
 */
export default class NewApp extends BaseCommand {
  public static commandName = 'new'
  public static description = 'Scaffold a new application'

  @flags.boolean({ description: 'Use yarn instead of npm for installing dependencies' })
  public yarn: boolean

  @args.string({ description: 'The name/path of the project directory' })
  public name: string

  @flags.boolean({ description: 'Create project for REST API server' })
  public apiOnly: boolean

  /**
   * Reference to the project root. It always has to be
   * the current working directory
   */
  public projectRoot = process.cwd()

  /**
   * Called by ace automatically, when this command is invoked
   */
  public async handle () {
    if (!satisfiesNodeVersion()) {
      const message = [
        `Unsatisfied Node.js version ${process.version}`,
        'Please update Node.js to {10.15.3} before you continue',
github adonisjs / adonis-lucid / commands / Rollback.ts View on Github external
import MigrationsBase from './MigrationsBase'

/**
 * The command is meant to migrate the database by execute migrations
 * in `up` direction.
 */
@inject([null, 'Adonis/Lucid/Database'])
export default class Migrate extends MigrationsBase {
  public static commandName = 'migration:rollback'
  public static description = 'Rollback migrations to a given batch number'

  @flags.string({ description: 'Define a custom database connection' })
  public connection: string

  @flags.boolean({ description: 'Print SQL queries, instead of running the migrations' })
  public dryRun: boolean

  @flags.number({
    description: 'Define custom batch number for rollback. Use 0 to rollback to initial state',
  })
  public batch: number

  /**
   * This command loads the application, since we need the runtime
   * to find the migration directories for a given connection
   */
  public static settings = {
    loadApp: true,
  }

  constructor (app: ApplicationContract, private _db: DatabaseContract) {
github adonisjs / assembler / commands / Serve.ts View on Github external
*/

import { BaseCommand, flags } from '@adonisjs/ace'

/**
 * Compile typescript project to Javascript and start
 * the HTTP server
 */
export default class Serve extends BaseCommand {
  public static commandName = 'serve'
  public static description = 'Compile typescript code to Javascript and start the HTTP server'

  /**
   * Allows watching for file changes
   */
  @flags.boolean({ description: 'Watch for file changes and re-build the project', alias: 'w' })
  public watch: boolean

  /**
   * Allows watching for file changes
   */
  @flags.boolean({
    description: 'Turn off Typescript compiler by passing --no-compile',
    default: true,
  })
  public compile: boolean

  /**
   * Arguments to pass to the `node` binary
   */
  @flags.array({ description: 'CLI options to pass to the node command line' })
  public nodeArgs: string[] = []