Skip to main content
Skip table of contents

Dependency installation and usage

Introduction

This page covers the installation and usage of client-specific dependencies for the OCB without affecting the existing functionality.

There are 2 types of dependency:

  • Generic (common for all the application clients)

  • Client-specific

For each client-specific dependency, we are creating mock files. When the client-specific dependency is imported in any of the components, we have to keep one condition check for each functionality use, so that it will not break if we don't install actually dependency.

Installation commands

To install dependencies for Windows, use this command:

CODE
yarn installPackages

To install dependencies with a valid client for Windows, use this command:

CODE
yarn installPackages client=<client name>

To install dependencies for iOS, use this command:

CODE
sudo yarn installPackages

To install dependencies with a valid client for iOS, use this command:

CODE
sudo yarn installPackages client=<client name>

Parameters

Client is an optional parameter. If no client name is added for this parameter, it will default to install dependencies from package.json and also the mock modules from dependencies.json (scripts/appBuild/dependencies.json).

If a valid client name is added, it will install generic dependencies together with client-specific dependencies.

Adding dependencies

To add a dependency, use this command.

CODE
yarn addPackage client=<client name> <dependencies name separated by space>

Examples

Here client parameter is missing so the module will be considered generic and it will install the ramda module and update the package.json file. If any module is already installed in any client with the same name, it will automatically be removed from the client.

CODE
/**
 * Adding new generic dependencies for windows
 */
yarn addPackage ramda

Here the client is provided so the module is considered as client-specific and it will install the module and update scripts/appBuild/dependencies.json. Also for each client-specific module, mock files will be created under the optional-dependencies directory.

CODE
/**
 * Adding new client-specific dependencies with version for IOS
 */
sudo yarn addPackage client=customer1 [email protected]

Removing dependencies command

To delete a dependency, use this command.

CODE
yarn delPackage client=<client name> <dependencies name separated by space>

Examples

Here client parameter is missing so the module will be considered generic and it will remove the ramda module and update the package.json file.

CODE
/**
 * Removing the generic dependencies
 */

yarn delPackage ramda

Here the client is provided so the module is considered as client-specific and it will remove the module and update scripts/appBuild/dependencies.json. Also for each client-specific module, mock files will be removed under the optional-dependencies directory.

CODE
/**
 * Removing the client-specific dependencies IOS
 */

sudo yarn delPackage client=customer1 ramda

Configuration file

ACTIONSCRIPT3
{
	"customer1": {
	},
	"optionalDependencies": {
	}
}

Check before using client-specific dependencies

Client-specific dependencies from any components must be validated to check whether they are mock dependencies or actual dependencies.

Here is an example of validating the dependency:

JS
import isNumber from "is-number"; // importing Client specific dependency 
import { isMockDependency } from "src/store/utils/utils"; //method for validating the client specific dependency.

Before using any functionalities isNumber we have to validate it as follows.

JS
!isMockDependency(isNumber)&&isNumber(1234);

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.