Commands
The SugoiJS cli pre-defined commands

Initialization

For initiating a new project use the init command.
1
$ sgi init
Copied!
After you'll run this command you will need to answer few questions which will help you to set the application you need

Generate

SugoiJS provides easy generation tool by the g or generate argument
1
$ sgi g <type> <name>
Copied!

Available types

  • module (m) - Generate a module with one service and one controller which contains the module name
    • After generating new module you will have to inject it to bootstrap module.
  • controller (c) - Generate a controller under 'controllers' directory.
    • After generating new controller you will have to inject it to the related module.
  • service (s) - Generate a service under 'services' directory.
    • After generating new service you will have to inject it to the related module.
  • model - Generate a model class.
  • mongo-model - Generate a mongo model class.

Commands example

1
$ sgi g m myModule
2
// Will create a module under the current path
3
// with controller and a service
Copied!
1
$ sgi g model myModel
2
// Will create a model under the current path
Copied!
1
$ sgi g mongo-model myMongoModel
2
// Will create a mongo-model under the current path
Copied!
1
$ sgi g c newController
2
// Will create a controller under the current path
3
// will create controllers directory
4
// if no such directory found under the path
Copied!
1
$ sgi g s newService
2
// Will create a service under the current path
3
// will create service directory
4
// if no such directory found under the path
Copied!

Build

SugoiJS provides easy build tool by the build argument.
1
$ sgi build
Copied!
By default the environment which will be used for configuration is the "default" environment
The SugoiJS build action requires the sugoi.json file, if it is missing on your project please execute update.
$ sgi update
For build while using the hot swap listener please apply the --watch flag
sgi build --watch

Build by project

sugoi.json supports multi-project configuration, the configuration is found under the project property:
1
"projects":{
2
"main": {
3
"entry": "src/app/main.ts",
4
"dist": "dist",
5
"commonDir": "../common",
6
"configurationDir": "configuration"
7
},
8
"microservice": {
9
"entry": "src/app/microserivce.ts",
10
"dist": "dist2",
11
"commonDir": "../common",
12
"configurationDir": "configuration",
13
"excludes": [],
14
"includes": []
15
}
16
}
Copied!
For define which project to use run:
sgi build --project=<project_name>

Example

1
sgi build --project=microservice
Copied!

Set build environment

For defining the environment to use in the build execute:
1
$ sgi build --environment=<environment>
Copied!
For example:
1
$ sgi build --environment=production
Copied!
You can build for production environment by usingsgi build --prod command

Update

For updating your project run and create missing files, execute:
1
$ sgi update
Copied!

Testing

SugoiJS using jest as testing infrastructure.
For run those tests execute:
1
$ sgi test
Copied!
The SugoiJS test action requires the jest.configuration.js file, if it is missing on your project please execute update.
$ sgi update
Last modified 2yr ago