Skip to content

labibramadhan/mastery-cli

Repository files navigation

MasteryJS Command Line Utility

Command line utility to get started easily on MasteryJS, a scalable REST API framework build on top of Hapi and Sequelize.

npm version Dependency Status devDependency Status

API Documentation

Table of Contents

  1. Main Features
  2. Getting Started
    1. Prerequisites
    2. Installation
  3. Commands
    1. Server Management
    2. CLI Management

Main Features

  • Build system for MasteryJS
  • PM2 configuration using mastery.run.json file, see PM2 Process File
  • Server management including start, stop, reload, scaling a MasteryJS package server
  • Monitor MasteryJS processes using PM2 Monitoring
  • Ability to speak many languages

Getting Started

Prerequisites

  1. Git
  2. NodeJS version 6 or greater

Installation

Windows

Open Command Prompt that you will probably need to run as Administrator. And then, type

npm install -g mastery

MacOS/Linux

sudo npm install -g mastery

Commands

Server Management

New

Create a new MasteryJS project, cloning/download the latest source from MasteryJS repo.

This command can be executed anywhere.

Usage:

mastery new [destination]
  • [destination] is the path where the new project will be.

After that, a wizard will showing and there are some questions to follow.

Serve

Turn on MasteryJS directly from the source using babel-node.

This command must be executed inside the root of MasteryJS project.

Usage:

mastery serve -i|--inspect -p|--port <n>
  • -i, --inspect enable Chrome Developer Tools Inspector. This argument is optional.

  • -p, --port <n> enable --debug-brk feature, to debug using any supported IDE. Fill <n> with a port number.

Build

Build a MasteryJS project, this will transform MasteryJS source codes into ES2015 minified codes using babel + uglify. Also, a mastery.run.json file will be created for the PM2 needs. After that, a 'build' directory will exist. You can then deploy this directory.

This command must be executed inside the root of MasteryJS project.

Usage:

mastery build

Start

Start MasteryJS server that has been built before using PM2. By default, the processes spawned are using cluster mode.

This command must be executed inside the build of MasteryJS project.

Usage:

mastery start

Stop

Stop MasteryJS server.

This command must be executed inside the build of MasteryJS project.

Usage:

mastery stop

Restart

Restart MasteryJS server. This will execute the stop and start commands.

This command must be executed inside the build of MasteryJS project.

Usage:

mastery restart

Status

Launch PM2 Process Monitoring.

This command can be executed anywhere.

Usage:

mastery status

Scale

Scale MasteryJS cluster processes length that currently running.

This command must be executed inside the build of MasteryJS project.

Usage:

mastery scale [length]
  • [length] is optional. If length is not provided, a question will be prompted to define the length.

CLI Management

Conf

Change CLI configuration config.json value and change CLI language as well.

This command can be executed anywhere.

Usage:

mastery conf [key] [value]
  • [key] Configuration key to change its value.
  • [value] The new configuration value.

Example for changing the CLI language to Indonesian:

mastery conf lang id