Installing a Caplin Trader package

Note: this documentation is for a beta release of Caplin Trader 5. Features may change before the final release.

This page provides instructions on how to include a Caplin Trader 5 Node.js package in your application.

Contents:

Requirements

To install a Caplin Trader package in your application, you require the following:

Note: Caplin Trader 5 does not yet support npm 5 due to a known issue in npm 5.

Installing a Caplin Trader package

Caplin packages are stored locally in the caplin-packages directory of your workspace. To install a Caplin Package in your application, run the npm install command and pass the relative path to the Caplin package you want to install.

For example, to install the Caplin Trader package br-presenter, follow the steps below:

  1. Run the command below from the root directory of your Caplin Trader application:

    npm install --save ../../packages-caplin/br-presenter

    This command installs the br-presenter package and its dependencies to the node_modules directory. The --save option adds br-presenter as a project dependency in your application's package.json file.

  2. Some Caplin packages include Caplin Trader alias definitions. An extra step is required to ensure that Webpack can resolve these aliases to real modules.

    From the root directory of your application, run the command below to obtain an up-to-date list of alias definition modules in your application:

    find ./node_modules -name 'aliasProviders.js'

    For an application that has only the Caplin Trader br-presenter package installed, the output from the above command would typically be:

    ./node_modules/br-presenter/aliasProviders.js
    Tip: on Microsoft Windows, the find command is distributed with Cygwin and the Bash shell of Git for Windows.
  3. If the output from step 2 indicates that you have alias definitions in your application, edit your application's src/config/aliases.js module. Ensure that all aliasProvider modules listed by the find command above are imported and combined in a single module.exports object.

    Continuing this example, edit your application's aliases.js file so that it resembles the file below:

    // require aliasProvider here, add to the Object.assign list.
    const brPresenterAliasProviders = require('br-presenter/aliasProviders');
    
    module.exports = Object.assign({}, brPresenterAliasProviders);
    

This example application only has one Caplin Trader package that includes alias definitions. If another Caplin Trader package is installed that includes alias definitions, add the new package's aliasProviders module as an extra source object in the call to Object.assign(target, ...sources) in your application's aliases.js file. For example, if you install the ct-sljsadapter package, edit the aliases.js file so that it resembles the content below:

// require aliasProvider here, add to the Object.assign list.
const brPresenterAliasProviders = require('br-presenter/aliasProviders');
const ctSljsAdapterAliasProviders = require('ct-sljsadapter/aliasProviders');

module.exports = Object.assign({}, brPresenterAliasProviders, ctSljsAdapterAliasProviders);