TramwayJS

CLI

Tramway comes with a CLI to facilitate rapid development

Get Started

If the tramway CLI isn't already installed as a development dependency, install it with the following command.

npm i -D tramway

Usage

Replace the COMMAND with the appropriate one from the table below with its corresponding arguments and options.

If installed globally:

tramway COMMAND

Otherwise:

./node_modules/.bin/tramway COMMAND

All commands that create new classes will update the corresponding index.js entries.

Configuration

The commands create their files in the default scalpel that TramwayJS follows

+ src
+- config
+- controllers
+- services
+- entities
+- repositories
+- providers
+- commands

In some projects, however, the structure can vary and the framework is able to adapt to adjustments using environment variables.

VariablePurposeDefault
TRAMWAY_PROJECT_PATHThe root path of the project./src
TRAMWAY_PROJECT_CONTROLLERS_PATHPath to controllers appended to TRAMWAY_PROJECT_PATHcontrollers
TRAMWAY_PROJECT_ENTITIES_PATHPath to entities appended to TRAMWAY_PROJECT_PATHentities
TRAMWAY_PROJECT_SERVICES_PATHPath to services appended to TRAMWAY_PROJECT_PATHservices
TRAMWAY_PROJECT_CONNECTIONS_PATHPath to connections appended to TRAMWAY_PROJECT_PATHconnections
TRAMWAY_PROJECT_REPOSITORIES_PATHPath to repositories appended to TRAMWAY_PROJECT_PATHrepositories
TRAMWAY_PROJECT_PROVIDERS_PATHPath to providers appended to TRAMWAY_PROJECT_PATHproviders
TRAMWAY_PROJECT_CONFIG_PATHPath to config appended to TRAMWAY_PROJECT_PATHconfig
TRAMWAY_PROJECT_ROUTES_FILEName of the routes file storied in the config directoryroutes
TRAMWAY_PROJECT_SERVICES_FILEName of the services file storied in the config directoryservices

Example:

TRAMWAY_PROJECT_PATH=./dev tramway create:service Service

This command will create a new Service.js file in ./dev/services. It has the same behavior as overriding the dir using the dir option but is meant for a global application.