Skip to content

Lloople/vapor-maker-commands

Repository files navigation

Vapor Maker Commands

Vapor Logo Swift 5.2 Logo Build Status MIT License

This package installs a few helpful commands to help you bootstrap your Vapor application.

Installation

Add the adapter in your dependencies array in Package.swift:

dependencies: [
    // ...,
    .package(url: "https://github.com/lloople/vapor-maker-commands.git", from: "1.0.0")
],

Also ensure you add it as a dependency to your target:

targets: [
    .target(name: "App", dependencies: [
        .product(name: "VaporMakerCommands", package:"vapor-maker-commands")
        .product(name: "Vapor", package: "vapor"), 
        // ..., 
    ]),
    // ...
]

Register the commands in your configure.swift file:

app.registerMakerCommands()

Usage

Controllers

Creates a new controller type inside Sources/App/Controllers path. --rest flag adds the default CRUD methods for your controller actions.

vapor run make:controller UsersController
vapor run make:controller PostsController --rest
vapor run make:controller PlayersController --boot

Commands

Creates a new command type inside Sources/App/Commands path.

vapor run make:command CreateUserCommand

Contents

Creates a new content type inside Sources/App/Contents path. --with-validation flag adds the Validatable extension to your content.

vapor run make:content UserContent
vapor run make:content UserContent --with-validation

Custom Leaf Tags

Creates a new custom leaf tag type inside Sources/App/LeafTags path.

vapor run make:leaf-tag CopyrightTag

Middlewares

Creates a new middleware type inside Sources/App/Middlewares path. --after flag will guide you on how to modify the response to be returned from your middleware.

vapor run make:middleware UserIsAdminMiddleware
vapor run make:middleware AddUserToResponseMiddleware --after

Migrations

Creates a new migration type inside Sources/App/Migrations path.

vapor run make:migration UsersMigration

Models

Creates a new model type inside Sources/App/Models path.

vapor run make:model User

Additional info

All commands come with a --force flag to override existing files.