Class: ADX

ADX


new ADX(adxDirPath)

Object used to generate, validate, show and build an ADX

Example of usage of existing ADX

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // Validate an ADX
 const validationConfig = {
     test : false,
     autoTest : false
 };

 myAdx.validate(validationConfig, (err, report) => {
     // Callback when the ADX structure has been validated
 });


 // Show the output of an ADX
 const showConfig = {
     output : 'fallback',
     fixture : 'single.xml'
 };

 myAdx.show(showConfig, (err, output) => {
     // Callback with the output of the ADX
 });

 // Build the ADX (package it)
 const buildConfig = {
     test : false,
     autoTest : false
 };

 myAdx.build(buildConfig, (err, path, report) => {
     // Callback when the ADX has been built
 });

Generate and use the new ADX instance

 const config = {
     output : '/path/of/parent/dir',
     template : 'blank'
 };

 ADX.generate('adc', 'myNewADC', config, (err, adc) => {
     console.log(adc.path);
     adc.load((err) =>{
         if (err) {
             console.log(err);
             return;
         }
         console.log(adc.configurator.info.get());
     });
 });
Parameters:
Name Type Description
adxDirPath String

Path of the ADX directory

Members


<static> preferences :Preferences

Instance of the object to manage the preferences

Type:

configurator :Configurator

Configurator of the ADX Expose the object to manipulate the config.xml

Type:

interviews :InterviewsFactory

Factory of interviews

Type:

path :string

Path to the ADX directory

Type:
  • string

Methods


<static> generate(type, name [, options] [, callback])

Generate a new ADX structure

 const ADX = require('adxutil').ADX;

 // Generate the ADC structure in '/path/of/parent/dir/myNewADC'
 const config = {
     output : '/path/of/parent/dir',
     template : 'blank'
 };
 ADX.generate('adc', 'myNewADC', config, (err, adc) => {
     console.log(adc.path);
 });

 // Generate the ADP structure in '/path/of/parent/dir/myMewADP'
 const config = {
     output : '/path/of/parent/dir',
     template : 'blank'
 };
 ADX.generate('adp', 'myNewADP', config, (err, adp) => {
     console.log(adp.path);
 });
Parameters:
Name Type Argument Description
type 'adc' | 'adp'

Type of the ADX ('adc' or 'adp')

name String

Name of the ADX to generate

options Object <optional>

Options

Properties
Name Type Argument Default Description
description String <optional>
''

Description of the ADX

author Object <optional>

Author of the ADX

Properties
Name Type Argument Default Description
name String <optional>
''

Author name

email String <optional>
''

Author email

company String <optional>
''

Author Company

website String <optional>
''

Author web site

output String <optional>
process.cwd()

Path of the output director

template String <optional>
"blank"

Name of the template to use

callback function <optional>
Properties
Name Type Argument Description
err Error <optional>

Error

adx ADX <optional>

Instance of the new generated ADX


<static> getTemplateList(type, callback)

Returns the list of templates directory

 const ADX = require('adxutil').ADX;

 // Get the list of the ADC templates
 ADX.getTemplateList('adc', (err, dirs) => {
     console.log(dirs[0].name); // -> "blank"
 });


 // Get the list of the ADP templates
 ADX.getTemplateList('adp', (err, dirs) => {
     console.log(dirs[0].name); // -> "blank"
 });
Parameters:
Name Type Description
type "adc" | "adp"

Type of the template list to obtain (adc or adp)

callback function

Callback

Properties
Name Type Description
err Error

Error

dirs Array.<Object>

List of template

dirs[].name String

Name of the template

dirs[].path String

Path of the template directory


build( [options] [, callback])

Build the ADX

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // Build the ADX (package it)
 const config = {
     test : false,
     autoTest : false
 };

 myAdx.build(config, (err, path, report) => {
     // Callback when the ADX has been built
 });
Parameters:
Name Type Argument Description
options Object <optional>

Options of validation

Properties
Name Type Argument Default Description
printMode String | 'default' | 'html' <optional>
'default'

Print mode (default console or html)

test Boolean <optional>
true

Run unit tests

autoTest Boolean <optional>
true

Run auto unit tests

logger Object <optional>

Logger

writeMessage function <optional>

Function where regular messages will be print

writeSuccess function <optional>

Function where success messages will be print

writeWarning function <optional>

Function where warning messages will be print

writeError function <optional>

Function where error messages will be print

callback function <optional>

Callback function

Properties
Name Type Argument Description
err Error <optional>

Error

outputPath String <optional>

Path of the output

report Object <optional>

Validation report


checkTestsDirectory(callback)

Verify if the fixtures, emulations, controls or pages exist and create it if it doesn't.

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // Check the `tests` directory
 myAdx.checkTestsDirectory((err) => {
     if (err) {
         console.warn(err);
     }
 });
Parameters:
Name Type Description
callback function

Callback when the operation is complete

Properties
Name Type Description
err Error

Error that occurred during the operation


destroy()

Release all resources


getEmulationList(callback)

Returns the list of emulations

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // List all emulations on the ADX
 myAdx.getEmulationList((err, list) => {
     console.log(list[0]); // -> "Javascript_Enable.xml"
 });
Parameters:
Name Type Description
callback function

Callback

Properties
Name Type Description
err Error

Error

list Array.<String>

List of emulations


getFixtureList(callback)

Returns the list of fixtures

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // List all fixtures on the ADX
 myAdx.getFixtureList((err, list) => {
     console.log(list[0]); // -> "Single.xml"
 });
Parameters:
Name Type Description
callback function

Callback

Properties
Name Type Description
err Error

Error

list Array.<String>

List of fixtures


load( [callback])

Load the config of the current ADX instance

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // Load an ADX
 myAdx.load((err) => {
     // Callback when the ADX has been loaded
 });
Parameters:
Name Type Argument Description
callback function <optional>

Callback function

Properties
Name Type Argument Description
err Error <optional>

Error


publish(platform, options, callback)

Publish to publisher

    const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // Publish the ADC
 const config = {
     username : "MyUserName",
     password : "secret",
     url : "https://...",
     demoUrl : "https://..."
 };

 myAdx.publish(platform, config, (err) => {
     // Callback when the ADC has been published
 });
Parameters:
Name Type Description
platform String

Name of the platform to push

options Object

Options of the platform

Properties
Name Type Argument Default Description
silent Boolean <optional>
false

By pass the output

callback function
Properties
Name Type Argument Default Description
err Error <optional>
null

show(options, callback)

Show the ADX output

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // Show the output of an ADX
 const config = {
     output : 'fallback',
     fixture : 'single.xml'
 };

 myAdx.show(config, (err, output) => {
     // Callback with the output of the ADX
 });
Parameters:
Name Type Description
options Object

Options

Properties
Name Type Argument Default Description
output String

Name of the ADX Output to use

fixture String

FileName of the ADX fixture to use

masterPage String <optional>

Path of the master page to use (ADC Only)

silent Boolean <optional>
false

Silent mode: Don't message in the console but only through the callback

callback function

Callback function

Properties
Name Type Description
err Error

Error

output String

Output string


validate( [options] [, callback])

Validate the current ADX instance

 const ADX = require('adxutil').ADX;
 const myAdx = new ADX('path/to/adx/dir');

 // Validate an ADX
 const config = {
     test : false,
     autoTest : false
 };

 myAdx.validate(config, (err, report) => {
     // Callback when the ADX structure has been validated
 });
Parameters:
Name Type Argument Description
options Object <optional>

Options of validation

Properties
Name Type Argument Default Description
printMode String | 'default' | 'html' <optional>
'default'

Print mode (default console or html)

test Boolean <optional>
true

Run unit tests

autoTest Boolean <optional>
true

Run auto unit tests

xml Boolean <optional>
true

Validate the config.xml file

logger Object <optional>

Logger

writeMessage function <optional>

Function where regular messages will be print

writeSuccess function <optional>

Function where success messages will be print

writeWarning function <optional>

Function where warning messages will be print

writeError function <optional>

Function where error messages will be print

callback function <optional>

Callback function

Properties
Name Type Argument Description
err Error <optional>

Error

report Object <optional>

Validation report