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 not available in the npm registry and are instead stored in the caplin-packages directory of your workspace. To install a Caplin Package, a relative file path to the package is passed to the npm install command.

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. 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 . -name 'aliasProviders.js'

    For an application containing just the Caplin Trader br-presenter package, 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 3 indicates that you have alias definitions in your application, edit your application's src/config/aliases.js file and export all aliasProvider modules merged together as a single object. This step is required for Webpack to correctly resolve Caplin Trader service aliases.

    Continuing this example, the edited aliases.js file below merges the br-presenter/aliasProviders module with a single export object:

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

    If there is more than one package in your application with an aliasProvider, then add each aliasProvider as an extra source object in the call to Object.assign(target, ...sources). For example, if the application in this example also has the Caplin ct-sljsadapter package installed, then the application's aliases.js file would look like the file 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);