node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »

urbanjs-tools

urbanjs-tools

Development stack for node packages

API documentation

.setupInMemoryTranspile()

Installs in memory transpile and sourcemap support

const tools = require('urbanjs-tools');
 
// optional
tools.setGlobalConfiguration({
  babel: //...
  typescript: //...
});
 
tools.setupInMemoryTranspile();

.setGlobalConfiguration(config)

Sets global configuration object

const tools = require('urbanjs-tools');
tools.setGlobalConfiguration(currentValues => Object.assign({}, currentValues, {
  typescript: <typescript compiler options>,
  babel: <babel configuration>,
  sourceFiles: <array of source file glob patterns>
});

.getGlobalConfiguration()

Returns the global configuration object

const tools = require('urbanjs-tools');
const globals = tools.getGlobalConfiguration();

.getTool(toolName)

Returns a registrable gulp tool: (gulp, taskName, parameters) => void

Please check Tool configuration section for more information about parameters.

const gulp = require('gulp');
const tools = require('urbanjs-tools');
tools.getTool('mocha').register(gulp, 'test-unit', {
  files: ['src/**']
});

.initializeTask(gulp, taskName, parameters)

Uses taskName to find the tool and registers it

Use .getTool() to register a task with different name than the name of the tool

Please check Tool configuration section for more information about parameters.

const gulp = require('gulp');
const tools = require('urbanjs-tools');
tools.initializeTask(gulp, 'mocha', {
  files: ['src/**']
});

.initializeTasks(gulp, parametersByToolName)

Registers all tasks with their parameters

Please check Tool configuration section for more information about parameters.

const gulp = require('gulp');
const tools = require('urbanjs-tools');
tools.initializeTasks(gulp, {
  mocha: {
    files: ['src/**']
  },
  // ...
});

.initializePreset(gulp, presetName, parameters)

Registers a preset with its subtasks

Please check Preset configuration section for more information about parameters.

const gulp = require('gulp');
const tools = require('urbanjs-tools');
tools.initializePreset(gulp, 'security', ['nsp', 'retire']);
tools.initializePreset(gulp, 'analyse', true);

.initializePresets(gulp, parametersByPresetName)

Registers all presets with their subtasks

Please check Preset configuration section for more information about parameters.

const gulp = require('gulp');
const tools = require('urbanjs-tools');
tools.initializePresets(gulp, {
  security: ['nsp', 'retire'],
  analyze: true
});

.initialize(gulp, parametersByTaskNameOrPresetName)

Registers all tasks and presets with their parameters

const gulp = require('gulp');
const tools = require('urbanjs-tools');
tools.initialize(gulp, {
  mocha: {
    files: ['src/**']
  },
  security: ['nsp', 'retire'],
  analyze: true
});

Tool configuration

parameters argument can be

  • true to use defaults
  • object to merge it with defaults on root level
  • function to get the defaults and return the final configuration (output won't be merged with defaults)

Defaults of tools can be found in packages/<tool>/src/defaults.ts files e.g. mocha.

Preset Configuration

parameters argument can be

  • true to use default tasks
  • array of task names to use it as is
  • function to get the defaults and return the final list of task names

Default preset configuration can be found here.