Boar Tasks for server side
This repository contains Gulp-based tasks to make server-side applications easier. It can be used with any server side framework.
These tasks are helpers, you have to define your build tasks in your project's gulpfile.js
. You can find examples in our existing services or workshop material.
Usually we create a tasks.config.js
file which is for override the default task settings.
Sample config file
// tasks.config.js moduleexports = server: environmentVariables: DEBUG: 'suite-sdk,suiterequest' PORT: 9100 BASE_URL: 'http://localhost:9100' NODE_ENV: 'development' ;
Sample gulpfile
// gulpfile.js let gulp = ;let runSequence = ;let config = ;let tasks = ; gulp; gulp; gulp;gulp;gulp;
Available tasks
Server tasks
Start
Run a server with Nodemon for development purposes. It automatically restarts the server if any file changed and notifies the developer about it.
Default configuration
const path = ;const appRootPath = path; Configserver = path: 'server/' runnable: path filePattern: 'server/**/!(*.spec).{pug,js}' 'package.json' watchPattern: 'server/**/*.js' environmentVariables: NODE_ENV: processenvNODE_ENV || 'development' APP_ROOT_PATH: appRootPath IP: processenvIP || undefined PORT: processenvPORT || 9100 BASE_URL: processenvBASE_URL || 'http://localhost:9100' ;
Usage
gulp;
Docker
If you'd like to run your server in Docker and restart on file changes you have to set the NODEMON_LEGACY_WATCH
environment variable to true
. It forces Nodemon to use legacy change detection mode which is the only way to support Docker.
Test
Run all the tests found (all *.spec.js
files) in the codebase.
Default configuration
Configserver = path: 'server/' test: requires: 'co-mocha' flags: 'reporter dot' 'colors' environmentVariables: NODE_ENV: processenvNODE_ENV || 'test' APP_ROOT_PATH: process + '/server/' ;
Usage
gulp;
Run command with server environment variables
Run the specified command by spawning a child process. It sets the server environment variables from the configuration also for the child process.
Default configuration
Configserver = environmentVariables: PORT: processenvPORT || 9100 BASE_URL: processenvBASE_URL || 'http://localhost:9100' ;
Usage
// Creating task for a job-runnergulp;
Run command with test environment variables
Run the specified command by spawning a child process. It sets the test environment variables from the configuration also for the child process.
Default configuration
Configserver = test: environmentVariables: NODE_ENV: processenvNODE_ENV || 'test' APP_ROOT_PATH: process + '/server/processes/web/' ;
Usage
// Creating task for a job-runnergulp;
Run command with custom environment variables
Run the specified command by spawning a child process. It sets the given environment variables also for the child process.
Usage
// Creating task for a job-runnergulp;
Code style
Check code style using ESLint on the selected JavaScript files.
Default configuration
Configserver = codeStylePattern: 'server/**/*.js'
Usage
gulp;
Template code style
Check code style on the selected template files using pug-lint.
Default configuration
Configserver = app: templateCodeStylePattern: 'server/app/**/*.pug'
Code style rules
Install pug-lint-config-emarsys
to your project and create a file in your project's root called .pug-lintrc
with the following content:
{
"extends": "emarsys"
}
Usage
gulp;