# All files / src index.js

63.75% Statements 51/80
30% Branches 3/10
26.09% Functions 6/23
68.09% Lines 32/47

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    1221x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x

    1x
    1x
    1x
    1x

    1x
    1x

    1x

    1x
    1x

    1x

    1x

    1x
     import chalk from 'chalk';
    import Common, { initializeBuilder, startBuilder } from './common';
    import Logger, { logComplete, logError, logWelcome, logInfo, configureLogger, logInitialize } from './systemTools/logger';
    import Runner from './cli/runner';
    import Tools from './cli/tools';
    import App from './cli/app';
    import Platform from './cli/platform';
    import Hooks from './cli/hooks';
    import Target from './cli/target';
    import Linker from './cli/linker';
    import Plugin from './cli/plugin';
    import Template from './cli/template';
    import Constants from './constants';
    import Exec from './systemTools/exec';
    import FileUtils from './systemTools/fileutils';
    import Doctor from './systemTools/doctor';
    import PlatformTools from './platformTools';
    import PluginTools from './pluginTools';
    import SetupTools from './setupTools';

    const commands = {
        start: Runner,
        build: Runner,
        export: Runner,
        app: App,
        new: App,
        configure: App,
        switch: App,
        link: Linker,
        platform: Platform,
        run: Runner,
        package: Runner,
        deploy: Runner,
        target: Target,
        plugin: Plugin,
        log: Runner,
        hooks: Hooks,
        status: Tools,
        fix: Tools,
        clean: Tools,
        tool: Tools,
        template: Template,
        debug: Runner,
        crypto: Tools
    };

    const run = (cmd, subCmd, program, process) => {
        initializeBuilder(cmd, subCmd, process, program)
            .then(c => checkWelcome(c))
            .then(c => startBuilder(c))
            .then((v) => {
        E        if (commands[cmd]) {
                    commands[cmd](v)
                        .then(() => {
                            if (program.debug) logInfo('You started a debug build. Make sure you have the debugger started or start it with `rnv debug`');
                            logComplete(true);
                        })
                        .catch(e => logError(e, true));
                } else if (program.help) {
                    // program.help();
                    logError(`Command ${chalk.white(cmd)} is not supported by ReNative CLI. Here is some help:`);
                    logHelp();
                    logComplete(true);
                } else {
                    logError(`Command ${chalk.white(cmd)} is not supported by ReNative CLI. run ${chalk.white('rnv')} for help`, true);
                }
            })
            .catch(e => logError(e, true));
    };

    const checkWelcome = c => new Promise((resolve, reject) => {
        Iif (!c.command && !c.subCommand) {
            logWelcome();

            logHelp();
        } else {
            resolve(c);
        }
    });

    const logHelp = () => {
        let cmdsString = '';
        for (const key in commands) {
            cmdsString += `${key}, `;
        }

        console.log(`
    ${chalk.bold.white('COMMANDS:')}

    ${cmdsString}

    ${chalk.bold.white('OPTIONS:')}

    '-i, --info', 'Show full debug info'
    '-u, --update', 'Force update dependencies (iOS only)'
    '-p, --platform <value>', 'Select specific platform' // <ios|android|web|...>
    '-c, --appConfigID <value>', 'Select specific appConfigID' // <ios|android|web|...>
    '-t, --target <value>', 'Select specific simulator' // <.....>
    '-d, --device [value]', 'Select connected device'
    '-s, --scheme <value>', 'Select build scheme' // <Debug | Release>
    '-f, --filter <value>', 'Filter Value'
    '-l, --list', 'Return list of items related to command' // <alpha|beta|prod>
    '-r, --reset', 'Also perform reset'
    '-b, --blueprint', 'Blueprint for targets'
    '-h, --host <value>', 'Custom Host IP'
    '-x, --exeMethod <value>', 'Executable method in buildHooks'
    '-P, --port <value>', 'Custom Port'
    '-H, --help', 'Help'
    '-D, --debug', 'enable remote debugger'
    '--hosted', 'Run in a hosted environment (skip bundleAssets)'
    '--debugIp <value>', '(optional) overwrite the ip to which the remote debugger will connect'
    `);
    };

    export {
        Constants, Runner, App, Platform, Target, Common, Exec, FileUtils,
        PlatformTools, Doctor, PluginTools, SetupTools, Logger,
        run
    };

    export default { run };