utils

The common utility module. It provides various tools for managing a Rekit app.

Source:

Methods

(static) joinPath()

Source:

The unified version of 'path.join'. It forces forward slash ('/') on both unix like or windows system. It also normalizes the path to emmit double slash and '..'.

Example
const utils = require('rekit-core').utils;
const p1 = utils.joinPath('c:\\abc', '../def');
// p1 => 'c:/def'

(static) mapSrcFile(filePath)

Source:

Get the full path by a relative path to 'src'.

Example
const utils =require('rekit-core').utils;
utils.mapSrcFile('common/configStore.js');
// => /path/to/project/src/common/configStore.js
Parameters:
Name Type Description
filePath string

The file path relative to project's 'src' folder.

(static) setSilent(isSilent)

Source:

Don't output any logs.

Parameters:
Name Type Description
isSilent boolean

Whether to output logs.

(inner) error(msg)

Source:

Log an error message to console. It respects the setSilent switch.

Parameters:
Name Type Description
msg string

The message to log.

(inner) fatalError(msg)

Source:

Throw a fatal error and log an error message.

Parameters:
Name Type Description
msg string

The message to log.

(inner) getActionType(feature, action)

Source:

Get action type constant for a sync action. It uses UPPER_SNAKE_CASE and combines feature name and action name.

Example
const utils = require('rekit-core').utils;
utils.getActionType('home', 'doSomething');
// => HOME_DO_SOMETHING
Parameters:
Name Type Description
feature string

The feature name of the action.

action string

The action name.

(inner) getAsyncActionTypes(feature, action)

Source:

Get action type constants for an async action. It uses UPPER_SNAKE_CASE and combines feature name and action name.

Example
const utils = require('rekit-core').utils;
utils.getAsyncActionTypes('home', 'doAsync');
// =>
// {
//   doAsyncBegin: 'HOME_DO_ASYNC_BEGIN',
//   doAsyncSuccess: 'HOME_DO_ASYNC_SUCCESS',
//   doAsyncFailure: 'HOME_DO_ASYNC_FAILURE',
//   doAsyncDismissError: 'HOME_DO_ASYNC_DISMISS_ERROR',
// }
Parameters:
Name Type Description
feature string

The feature name of the action.

action string

The action name.

(inner) getFullPath(relPath)

Source:

Get the full path of a relative path to the project root.

Parameters:
Name Type Description
relPath string

The relative path.

(inner) getPkgJson()

Source:

Get the current project's package.json.

(inner) getProjectRoot()

Source:

Get the project root. By default it finds the Rekit project root of which the command is run.

(inner) getRelativePath(fullPath)

Source:

Get the relative path to the project root by given full path.

Parameters:
Name Type Description
fullPath string

A full path string.

(inner) log(msg)

Source:

Log a message to console. It respects the setSilent switch.

Parameters:
Name Type Description
msg string

The message to log.

(inner) setPkgJson()

Source:

Set the current project's package.json.

(inner) setProjectRoot(root)

Source:

By default Rekit will try to find the current Rekit project root. But you can also manually set it by calling this method.

Parameters:
Name Type Description
root string

The project root.

(inner) warn(msg)

Source:

Log a warning message to console. It respects the setSilent switch.

Parameters:
Name Type Description
msg string

The message to log.