# All files / dist/cli app.js

19.33% Statements 23/119
0% Branches 0/60
0% Functions 0/50
18.75% Lines 21/112

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
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    2494x

    4x
    4x
    4x
    4x
    4x

    4x

    4x
    4x
    4x
    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x
     var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.PIPES=void 0;

    var _path=_interopRequireDefault(require("path"));
    var _fs=_interopRequireDefault(require("fs"));
    var _chalk=_interopRequireDefault(require("chalk"));
    var _inquirer=_interopRequireDefault(require("inquirer"));
    var _semver=_interopRequireDefault(require("semver"));
    var _common=require("../common");

    var _prompt=require("../systemTools/prompt");
    var _constants=require("../constants");

    var _apple=require("../platformTools/apple");
    var _android=require("../platformTools/android");
    var _tizen=require("../platformTools/tizen");
    var _webos=require("../platformTools/webos");
    var _electron=require("../platformTools/electron");
    var _firefox=require("../platformTools/firefox");
    var _web=require("../platformTools/web");
    var _templateTools=require("../templateTools");
    var _fileutils=require("../systemTools/fileutils");
    var _exec=require("../systemTools/exec");
    var _dist=_interopRequireDefault(require("../../dist"));
    var _buildHooks=require("../projectTools/buildHooks");
    var _logger=require("../systemTools/logger");
    var _projectParser=require("../projectTools/projectParser");
    var _workspace=require("../projectTools/workspace");
    var _configParser=require("../configTools/configParser");

    var CONFIGURE='configure';
    var SWITCH='switch';
    var CREATE='create';
    var NEW='new';

    var PIPES={
    APP_CONFIGURE_BEFORE:'configure:before',
    APP_CONFIGURE_AFTER:'configure:after',
    APP_SWITCH_BEFORE:'switch:before',
    APP_SWITCH_AFTER:'switch:after'};exports.PIPES=PIPES;

    var highlight=_chalk.default.green;

    var run=function run(c){
    (0,_common.logTask)('run');

    switch(c.command){
    case NEW:
    return _runCreate(c);
    case CONFIGURE:
    return _runConfigure(c);
    case SWITCH:
    return _runSwitch(c);}

    switch(c.subCommand){
    case CONFIGURE:
    (0,_common.logWarning)("$ "+_chalk.default.red('$ rnv app configure')+" is deprecated. Use "+_chalk.default.green('$ rnv configure')+" instead");
    return _runConfigure(c);

    default:
    return Promise.reject("cli:app: Sub-Command "+c.subCommand+" not supported");}

    };

    var _runConfigure=function _runConfigure(c){return new Promise(function(resolve,reject){
    var p=c.program.platform||'all';
    (0,_common.logTask)("_runConfigure:"+p);

    (0,_buildHooks.executePipe)(c,PIPES.APP_CONFIGURE_BEFORE).
    then(function(){return _checkAndCreatePlatforms(c,c.program.platform);}).
    then(function(){return(0,_projectParser.copyRuntimeAssets)(c);}).
    then(function(){return(0,_projectParser.copySharedPlatforms)(c);}).
    then(function(){return(0,_configParser.generateRuntimeConfig)(c);}).
    then(function(){return _runPlugins(c,c.paths.rnv.plugins.dir);}).
    then(function(){return _runPlugins(c,c.paths.project.projectConfig.pluginsDir);}).
    then(function(){return _isOK(c,p,[_constants.ANDROID])?(0,_android.configureGradleProject)(c,_constants.ANDROID):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.ANDROID_TV])?(0,_android.configureGradleProject)(c,_constants.ANDROID_TV):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.ANDROID_WEAR])?(0,_android.configureGradleProject)(c,_constants.ANDROID_WEAR):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.TIZEN])?(0,_tizen.configureTizenGlobal)(c,_constants.TIZEN):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.TIZEN])?(0,_tizen.configureTizenProject)(c,_constants.TIZEN):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.TIZEN_WATCH])?(0,_tizen.configureTizenProject)(c,_constants.TIZEN_WATCH):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.TIZEN_MOBILE])?(0,_tizen.configureTizenProject)(c,_constants.TIZEN_MOBILE):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.WEBOS])?(0,_webos.configureWebOSProject)(c,_constants.WEBOS):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.WEB])?(0,_web.configureWebProject)(c,_constants.WEB):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.MACOS])?(0,_electron.configureElectronProject)(c,_constants.MACOS):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.WINDOWS])?(0,_electron.configureElectronProject)(c,_constants.WINDOWS):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.KAIOS])?(0,_firefox.configureKaiOSProject)(c,_constants.KAIOS):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.FIREFOX_OS])?(0,_firefox.configureKaiOSProject)(c,_constants.FIREFOX_OS):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.FIREFOX_TV])?(0,_firefox.configureKaiOSProject)(c,_constants.FIREFOX_TV):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.IOS])?(0,_apple.configureXcodeProject)(c,_constants.IOS):Promise.resolve();}).
    then(function(){return _isOK(c,p,[_constants.TVOS])?(0,_apple.configureXcodeProject)(c,_constants.TVOS):Promise.resolve();}).
    then(function(){return(0,_buildHooks.executePipe)(c,PIPES.APP_CONFIGURE_AFTER);}).
    then(function(){return resolve();}).
    catch(function(e){return reject(e);});
    });};

    var _runSwitch=function _runSwitch(c){return new Promise(function(resolve,reject){
    var p=c.program.platform||'all';
    (0,_common.logTask)("_runSwitch:"+p);

    (0,_buildHooks.executePipe)(c,PIPES.APP_SWITCH_AFTER).

    then(function(){return(0,_projectParser.copyRuntimeAssets)(c);}).
    then(function(){return(0,_projectParser.copySharedPlatforms)(c);}).
    then(function(){return(0,_configParser.generateRuntimeConfig)(c);}).
    then(function(){return(0,_buildHooks.executePipe)(c,PIPES.APP_SWITCH_AFTER);}).
    then(function(){return resolve();}).
    catch(function(e){return reject(e);});
    });};

    var _isOK=function _isOK(c,p,list){
    var result=false;
    list.forEach(function(v){
    if((0,_common.isPlatformActive)(c,v)&&(p===v||p==='all'))result=true;
    });
    return result;
    };

    var _checkAndCreatePlatforms=function _checkAndCreatePlatforms(c,platform){return new Promise(function(resolve,reject){
    (0,_common.logTask)("_checkAndCreatePlatforms:"+platform);

    if(!_fs.default.existsSync(c.paths.project.builds.dir)){
    (0,_common.logWarning)('Platforms not created yet. creating them for you...');
    (0,_dist.default)((0,_common.spawnCommand)(c,{
    subCommand:'configure',
    program:{appConfig:c.runtime.appId,platform:platform}})).

    then(function(){return resolve();}).
    catch(function(e){return reject(e);});

    return;
    }
    if(platform){
    var appFolder=(0,_common.getAppFolder)(c,platform);
    if(!_fs.default.existsSync(appFolder)){
    (0,_common.logWarning)("Platform "+platform+" not created yet. creating them for you...");
    (0,_dist.default)((0,_common.spawnCommand)(c,{
    subCommand:'configure',
    program:{appConfig:c.runtime.appId,platform:platform}})).

    then(function(){return resolve();}).
    catch(function(e){return reject(e);});

    return;
    }
    }else{var
    platforms=c.buildConfig.platforms;
    var cmds=[];
    if(!platforms){
    reject("Your "+_chalk.default.white(c.paths.appConfig.config)+" is missconfigured. (Maybe you have older version?). Missing "+_chalk.default.white('{ platforms: {} }')+" object at root");
    return;
    }

    Object.keys(platforms).forEach(function(k){
    if(!_fs.default.existsSync(k)){
    (0,_common.logWarning)("Platform "+k+" not created yet. creating one for you...");
    cmds.push((0,_dist.default)((0,_common.spawnCommand)(c,{
    subCommand:'configure',
    program:{appConfig:c.runtime.appId,platform:platform}})));

    }
    });

    Promise.all(cmds).
    then(function(){return resolve();}).
    catch(function(e){return reject(e);});

    return;
    }
    resolve();
    });};

    var _runPlugins=function _runPlugins(c,pluginsPath){return new Promise(function(resolve){
    (0,_common.logTask)("_runPlugins:"+pluginsPath,_chalk.default.grey);

    if(!_fs.default.existsSync(pluginsPath)){
    (0,_common.logInfo)("Your project plugin folder "+_chalk.default.white(pluginsPath)+" does not exists. skipping plugin configuration");
    resolve();
    return;
    }

    _fs.default.readdirSync(pluginsPath).forEach(function(dir){
    var source=_path.default.resolve(pluginsPath,dir,'overrides');
    var dest=_path.default.resolve(c.paths.project.dir,'node_modules',dir);

    if(_fs.default.existsSync(source)){
    (0,_fileutils.copyFolderContentsRecursiveSync)(source,dest,false);

    }else{
    (0,_common.logInfo)("Your plugin configuration has no override path "+_chalk.default.white(source)+". skipping override action");
    }
    });

    resolve();
    });};var _default=

    run;exports.default=_default;
    //# sourceMappingURL=app.js.map