npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brewery-core-cli

v1.0.6

Published

Brewery cli helper

Downloads

12

Readme

brewery-cli

CLI tool for stratpoint brewery framework (https://gitlab.stratpoint.com/thebrewery/node-api-boilerplate)

Table of Contents

Prerequisites

Install pkg for creating executable files

npm install -g pkg

Build

To build executable file for all platforms (Windows, Linux, Macos) run:

npm run build

or

 pkg package.json

this will create the executable files on brewery-cli root directory

Usage

/path/to/executable <command> --options


Brewery CLI v1.0.0

Commands:
  init                              initialize project
  scaffold                          scaffold domain, models, repositories, routes, controllers, service/operation out of swagger specs

DB commands for backend:
  db:migrate                        Run pending migrations
  db:migrate:schema:timestamps:add  Update migration table to have timestamps
  db:migrate:status                 List the status of all migrations
  db:migrate:undo                   Reverts a migration
  db:migrate:undo:all               Revert all migrations ran
  db:seed                           Run specified seeder
  db:seed:undo                      Deletes data from the database
  db:seed:all                       Run every seeder
  db:seed:undo:all                  Deletes data from the database
  db:create                         Create database specified by configuration
  db:drop                           Drop database specified by configuration
  db:init                           Initializes project
  db:init:config                    Initializes configuration
  db:init:migrations                Initializes migrations
  db:init:models                    Initializes models
  db:init:seeders                   Initializes seeders
  db:migration:generate             Generates a new migration file
  db:model:generate                 Generates a model and its migration  
  db:seed:generate                  Generates a new seed file                            

Development

Creating commands:

Example command configuration:

Single command in one JSON file:

{
    "command": "command <!arg1> <arg2>",
    "description": "command description",
    "usage": "command arg1 --option=value ",
    "options": {
        "option1": {
            "description": "option1 description",
            "default" : true,
            "value": "required"
        },
        "option2": {
            "description": "option2 description"
        },
        "option3": {
            "description": "option3 description"
        }
    },
    "execPath": "./actions/command/"
}

Multiple commands in one JSON file:

[
  {
    "command": "namespace:command1 <!arg1> <arg2>",
    "description": "namespace:command1 description",
    "usage": "namespace:command1 --options=value ",
    "options": {
        "option1": {
            "description": "option1 description",
            "default" : true,
            "value": "required"
        },
        "option2": {
            "description": "option2 description"
        },
        "option3": {
            "description": "option3 description"
        }
    },
    "execPath": "./actions/namespace/"
  },
  {
    "command": "namespace:command2",
    "description": "namespace:command2 description",
    "usage": "namespace:command2 --options",
    "options": {
        "option1": {
            "description": "option1 description",
            "default" : true,
            "value": "required"
        },
        "option2": {
            "description": "option2 description"
        },
        "option3": {
            "description": "option3 description"
        }
    },
    "execPath": "./actions/namespace/"
  }
]

To create commands for CLI, create new json file on src/configs/your_command.json. The config json will automatically be loaded by the CLI.

  • command: Name of the command. Expected arguments for the command should be enclosed in "< >" eg. "<arg1>", if an argument is required it should be enclosed in "<! >" eg. "<!arg2>"
  • description: description of the command
  • usage: example usage of the command
  • options: available options for the command
    • default: set to true if option should be enabled by default.
    • value: set to required if a value for the option is required.
  • execPath: should contain the path to the script that will perform the action of your command, you may place your scripts on src/actions for uniformity
  • your execPath should return a function that requires 3 parameters for (config , command, args)

Example script for command action considering the following input from the CLI "brewery samplecommand argValue --option1=value":


const commandAction = (config, command, args) => {

  console.log(config); // contains config of your command loaded from the JSON file
  /*
    {
      "command": "samplecommand <!arg1> <arg2>",
      "description": "samplecommand description",
      "usage": "samplecommand --options=value ",
      "options": {
          "option1": {
              "description": "option1 description",
              "default" : true,
              "value": "required"
          },
          "option2": {
              "description": "option2 description"
          },
          "option3": {
              "description": "option3 description"
          }
      },
      "execPath": "./actions/samplecommand/"
    },
  */

 console.log(command); // contains organized data based on parsed input from cli
 /*
    {
      name: samplecommand
      args: {
        arg1: "argValue",
        arg2: null
      }
      options: {
          "option1": {
            value: "value"
          },
          "option2": null,
          "option3": null
      }
    }
 */

  console.log(args) // contains array of raw arguments inputted on the cli
  // ['brewery', 'samplecommand', 'argValue', '--option1=value']


  // Perform the action for your command ...

}

module.exports = commandAction;

Contributors

  • Joshua Elijah Mante
  • Ronald dela Cruz

License

MIT © Stratpoint Technologies Inc.