Skip to content

02.1 Project Set up

Amit Gupta edited this page Jan 4, 2019 · 2 revisions

Installation

$npm install stubmatic -g

Note: You may need to run above command with 'sudo'.

Project setup

$stubmatic init [<repo name>]

This will setup a stub repo with 1 sample mapping and stub response file. Default repo name 'stub-repo'.

Run

$stubmatic --help

Usage: stubmatic [OPTION]

Command:

$ stubmatic [--version] [-v|--verbose [--debug]] [-l|--logs] [-d <repo location>] [-p|--port <port number>] [-P <port number>] [-c|--config <config file>] [--to <remote URL>]
$ stubmatic init [<repo name>]
$ stubmatic validate <json|yaml|xml file name>

Arguments
  -p, --port                 http port number
  -P                         https port number
  --host                     Host name
  -s, --stub                 path for stubs only if mapping file has relative path and they are not in current folder
  -c, --config               config file name. It must be json file.
  -h, --help                 display on screen help
  -d                         location of project directory, if it is not a current directory.
  -v, --verbose              verbose
  -l, --logs                 To enable file based logging
  --version                  Show currently installed version
  --debug                    To debug request calls (use with -v option)
  --to                       To redirect all the requests to a remote server. Work as proxy.

Considerations:
if -p, -s options are given then relevant properties from config file would be ignored;
Precedence of loading config is -p,-s > -c > -C > -d > default

No option:
if "stubmatic" runs without any option then it builds configuration from config.json in current directory otherwise from current directory structure. Default port is 7777.

Expected directory structure to build configuration by itself.
	Project
	 |__ dbsets
	 |__ dumps
	 |__ mappings
	 |__ stubs
	 |__ logs

Example:
------------------------
$stubmatic -p 9999
$stubmatic -d project-directory-path -c config.json
$stubmatic -d project-directory-path
$stubmatic -c config.json

Example

stubmatic

if config.json presents in the current directory, build configuration from that else from the current directory structure

stubmatic -d project-directory-path -c other-config.json

Use -c when the configuration file name is other than 'config.json'. project-directory-path can be relative or absolute

stubmatic -d project-directory-path

build configuration on the basis of directory structure if config.json is not present.

Use the following command to run stubmatic as a proxy to watch request response.

$ stubmatic --debug -v -p 8001 --to http://localhost:8000
Clone this wiki locally