npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

boar-tasks-server

v12.0.2

Published

Boar Tasks for server side

Downloads

161

Readme

Boar Tasks for server side

npm version Dependency Status devDependency Status

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

module.exports = {
  server: {
    environmentVariables: {
      DEBUG: 'suite-sdk,suiterequest',
      PORT: 9100,
      BASE_URL: 'http://localhost:9100',
      NODE_ENV: 'development'
    }
  }
};

Sample gulpfile

// gulpfile.js

let gulp = require('gulp');
let runSequence = require('run-sequence');
let config = require('./tasks.config');
let tasks = require('boar-tasks-server').getTasks(gulp, config);

gulp.task('start', function(cb) {
  runSequence(['server', 'server-watch'], cb);
});

gulp.task('test', tasks.server.test);

gulp.task('server', tasks.server.start);
gulp.task('server-jshint', function() { return tasks.server.jshint(); });
gulp.task('server-watch', function() { gulp.watch(tasks.config.server.filePattern) });

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 = require('path');
const appRootPath = path.join(process.cwd(), 'server', 'processes', 'web');

Config.server = {
  path: 'server/',
  runnable: path.join(appRootPath, 'index.js'),
  filePattern: ['server/**/!(*.spec).{pug,js}', 'package.json'],
  watchPattern: 'server/**/*.js',
  environmentVariables: {
    NODE_ENV: process.env.NODE_ENV || 'development',
    APP_ROOT_PATH: appRootPath,
    IP: process.env.IP || undefined,
    PORT: process.env.PORT || 9100,
    BASE_URL: process.env.BASE_URL || 'http://localhost:9100'
  }
};

Usage

gulp.task('server', tasks.server.start);

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

Config.server = {
  path: 'server/',
  test: {
    requires: ['co-mocha'],
    flags: ['reporter dot', 'colors'],
    environmentVariables: {
      NODE_ENV: process.env.NODE_ENV || 'test',
      APP_ROOT_PATH: process.cwd() + '/server/'
    }
  }
};

Usage

gulp.task('test', tasks.server.test);

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

Config.server = {
  environmentVariables: {
    PORT: process.env.PORT || 9100,
    BASE_URL: process.env.BASE_URL || 'http://localhost:9100'
  }
};

Usage

// Creating task for a job-runner
gulp.task('job-runner', function (cb) { return tasks.server.runCommand('server/processes/job-runner', cb) });

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

Config.server = {
  test: {
    environmentVariables: {
      NODE_ENV: process.env.NODE_ENV || 'test',
      APP_ROOT_PATH: process.cwd() + '/server/processes/web/'
    }
  },
};

Usage

// Creating task for a job-runner
gulp.task('job-runner', function (cb) { return tasks.server.runTestCommand('server/processes/job-runner', cb) });

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-runner
gulp.task('job-runner', function (cb) { return tasks.server.runEnvironmentCommand('server/processes/job-runner', { NODE_ENV: 'integration' }, cb) });

Code style

Check code style using ESLint on the selected JavaScript files.

Default configuration

Config.server = {
  codeStylePattern: 'server/**/*.js'
}

Usage

gulp.task('server-codestyle', tasks.server.codeStyle);

Template code style

Check code style on the selected template files using pug-lint.

Default configuration

Config.server = {
  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.task('server-template-code-style', tasks.server.templateCodeStyle);