How to use the @adonisjs/ace.args.string 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 / Make / Model.ts View on Github external
* file that was distributed with this source code.
*/

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

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

/**
 * Make a new model
 */
export default class MakeModel extends BaseCommand {
  public static commandName = 'make:model'
  public static description = 'Make a new Lucid model'

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

  /**
   * 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 / MakeMigration.ts View on Github external
import { snakeCase } from 'snake-case'
import { inject } from '@adonisjs/fold'
import { BaseCommand, args, flags } from '@adonisjs/ace'
import { DatabaseContract } from '@ioc:Adonis/Lucid/Database'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'

@inject([null, 'Adonis/Lucid/Database'])
export default class MakeMigration extends BaseCommand {
  public static commandName = 'make:migration'
  public static description = 'Make a new migration file'

  /**
   * The name of the migration file. We use this to create the migration
   * file and generate the table name
   */
  @args.string({ description: 'Name of the migration file' })
  public name: string

  /**
   * Choose a custom pre-defined connection. Otherwise, we use the
   * default connection
   */
  @flags.string({ description: 'Define a custom database connection for the migration' })
  public connection: string

  /**
   * Pre select migration directory. If this is defined, we will ignore the paths
   * defined inside the config.
   */
  @flags.string({ description: 'Pre-select a migration directory' })
  public folder: string
github adonisjs / assembler / commands / Make / Provider.ts View on Github external
export default class MakeProvider extends BaseGenerator {
  /**
   * Required by BaseGenerator
   */
  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 / adonis-cli / src / Commands / New.ts View on Github external
import { BaseCommand, flags, args } from '@adonisjs/ace'

import { Installer } from '../Services/Installer'
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()) {
github adonisjs / assembler / commands / Make / Middleware.ts View on Github external
export default class MakeMiddleware extends BaseGenerator {
  /**
   * Required by BaseGenerator
   */
  protected $suffix = ''
  protected $form = 'singular' as const
  protected $pattern = 'pascalcase' as const
  protected $resourceName: string

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

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

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

  /**
github adonisjs / adonis-cli / src / Commands / RunInstructions.ts View on Github external
*/

import { BaseCommand, args } from '@adonisjs/ace'
import { Application } from '@adonisjs/application/build/standalone'
import { executeInstructions, sinkVersion } from '@adonisjs/sink'

import { getRcContents } from '../helpers'

/**
 * Run instructions for a given dependency
 */
export default class RunInstructions extends BaseCommand {
  public static commandName = 'run:instructions'
  public static description = 'Run instructions for a given adonisjs package'

  @args.string({
    description: 'Name of the package. It must be installed as your project dependency',
    name: 'projectName',
  })
  public projectName: string

  /**
   * Reference to the project root. It always have 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)
github adonisjs / assembler / commands / Invoke.ts View on Github external
import { BaseCommand, args } from '@adonisjs/ace'

import { Manifest } from '../src/Manifest'
import { ADONIS_ACE_CWD } from '../config/env'

/**
 * Invoke post install instructions
 */
export default class Invoke extends BaseCommand {
  public static commandName = 'invoke'
  public static description = 'Invoke post install instructions on a given AdonisJs package'

  /**
   * Use yarn when building for production to install dependencies
   */
  @args.string({ description: 'Name of the package for which to invoke post install instructions' })
  public name: string

  /**
   * Invoked automatically by ace
   */
  public async handle () {
    const cwd = ADONIS_ACE_CWD()

    /**
     * Dis-allow when CWD is missing. It will always be set by `node ace`
     * commands
     */
    if (!cwd) {
      this.logger.error(
        'Cannot invoke post install instructions. Make sure you running this command as "node ace invoke"',
      )
github adonisjs / assembler / commands / Make / View.ts View on Github external
/**
   * Required by BaseGenerator
   */
  protected $suffix = ''
  protected $extname = '.edge'
  protected $form = 'singular' as const
  protected $pattern = 'snakecase' as const
  protected $resourceName: string

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

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

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

  /**
github adonisjs / adonis-cli / src / Commands / Make / Provider.ts View on Github external
* file that was distributed with this source code.
*/

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

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

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

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

  /**
   * 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 / assembler / commands / Make / Command.ts View on Github external
* Command to make a new command
 */
export default class MakeCommand extends BaseGenerator {
  /**
   * Required by BaseGenerator
   */
  protected $pattern = 'pascalcase' as const
  protected $resourceName: string

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

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

  /**
   * Returns the template stub based upon the `--resource`
   * flag value
   */
  protected $getStub (): string {
    return join(
      __dirname,
      '..',
      '..',
      'templates',
      'command.txt',
    )
  }