Home Reference Source Repository

src/roc/config/roc.config.meta.js

import { isString, isBoolean, isPath, isArray, isObject, required } from 'roc/validators';

const configMeta = {
    settings: {
        groups: {
            runtime: {
                base: 'Base tag to be used in <head>, ' +
                    'see https://github.com/nfl/react-helmet.'
            }
        },
        descriptions: {
            runtime: {
                stats: 'Path to client stats file from build.',
                applicationName: 'Application name to use for <title>.',
                meta: 'Meta tags to be used in <head>, should be formatted as objects, ' +
                    'see https://github.com/nfl/react-helmet.',
                link: 'Link tags to be used in <head>, should be formatted as objects, ' +
                    'See https://github.com/nfl/react-helmet.',
                base: {
                    href: 'The document base address from which relative links are made.',
                    target: 'The browsing context in which the links should open.'
                },
                script: 'Script tags to be used in <head>, should be formatted as objects, ' +
                    'See https://github.com/nfl/react-helmet.',
                ssr: 'If server side rendering should be enabled.',
                clientBlocking: 'If "prefetch" should block a route transition on the client.',
                template: {
                    path: 'A directory where the template for the application can be found. Will default to internal ' +
                        'path.',
                    name: 'Name of the template file that will be used. Uses Nunjucks, please see documentaion for ' +
                        'more info.'
                },
                debug: {
                    client: 'Filter for debug messages that should be shown for the client, see ' +
                        'https://npmjs.com/package/debug.'
                },
                configWhitelistProperty: 'A single property to expose to the client from node-config. Make sure that ' +
                    'this property does NOT contain any secrets that should not be exposed to the world.'
            },

            dev: {
                a11y: 'If A11Y validation should be active. Currently it´s suggested to not enable reduxDevtools ' +
                    'with this.',
                reduxDevtools: {
                    enabled: 'If Redux Devtools should be enabled.',
                    position: 'Starting position of the Devtools, can be left, right, top or bottom.',
                    size: 'Default size of the Devtools, should be a number between 0 and 1.',
                    visibilityKey: 'The key that should toogle the Redux Devtools, will be combine with CTRL.',
                    positionKey: 'The key that should change position of the Redux Devtools, will be combine with ' +
                        'CTRL.',
                    defaultVisible: 'If the Redux Devtools should be shown by default.',
                    theme: 'The theme to use for the Redux Devtools, see ' +
                        'https://github.com/gaearon/redux-devtools-themes.'
                },
                reduxLogger: {
                    level: 'The logging level for Redux Logger, can be either warn, error or info.',
                    collapsed: 'If the logged actions by Redux Logger should be collapsed by default.',
                    duration: 'If Redux Logger should print the duration of each action.',
                    timestamp: 'If Redux Logger should print the timestamp with each action.'
                },
                yellowbox: {
                    enabled: 'If YellowBox should be enabled.',
                    ignore: 'Array of prefix strings that should be ignored by YelloBox.'
                }
            },

            build: {
                routes: 'The routes to use if no entry file is given, will use default entry files internally.',
                useDefaultRoutes: 'If Roc should use an internal wrapper around the routes, please look at the ' +
                    'documentation for more details.',

                reducers: 'The reducers to use if no entry file is given, will use default entry files internally.',
                useDefaultReducers: 'If Roc should use internally defined reducers, please look at the documentation ' +
                    ' for what reducers that are included.',

                reduxMiddlewares: 'The middlewares to use if no entry file is given, will use default entry files ' +
                    'internally.',
                useDefaultReduxMiddlewares: 'If Roc should use internally defined middlewares, please look at the ' +
                    ' documentation for what middlewares that are included.',

                clientLoading: 'The React component to use on the first client load while fetching data, will only ' +
                    'be used if clientBlocking is set to true.'
            }
        },

        validations: {
            runtime: {
                stats: isPath,
                applicationName: required(isString),
                meta: isArray(isObject(isString)),
                link: isArray(isObject(isString)),
                base: {
                    href: isString,
                    target: isString
                },
                script: isArray(isObject(isString)),
                ssr: isBoolean,
                clientBlocking: isBoolean,
                template: {
                    path: isPath,
                    name: isString
                },
                debug: {
                    client: isString
                },
                configWhitelistProperty: isString
            },

            dev: {
                a11y: isBoolean,
                reduxDevtools: {
                    enabled: isBoolean,
                    position: /^left|right|top|bottom$/,
                    size: (input) => input >= 0 && input <= 1,
                    visibilityKey: isString,
                    positionKey: isString,
                    defaultVisible: isBoolean,
                    theme: isString
                },
                reduxLogger: {
                    level: /^warn|error|info$/,
                    collapsed: isBoolean,
                    duration: isBoolean,
                    timestamp: isBoolean
                },
                yellowbox: {
                    enabled: isBoolean,
                    ignore: isArray(isString)
                }
            },

            build: {
                routes: isPath,
                useDefaultRoutes: isBoolean,

                reducers: isPath,
                useDefaultReducers: isBoolean,

                reduxMiddlewares: isPath,
                useDefaultReduxMiddlewares: isBoolean,

                clientLoading: isPath
            }
        }
    }
};

/**
 * Exports the `roc.config.meta.js`.
 *
 * @return {object} The `roc.config.meta.js`.
 */
export default configMeta;