# All files / dist/systemTools logger.js

31.25% Statements 80/256
4.41% Branches 6/136
9.52% Functions 4/42
28.71% Lines 60/209

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
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    3254x
    32x

    4x

    4x

    4x

    4x
    4x
    4x
    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x
    4x
    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    4x

    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.printBoxEnd=exports.logStatus=exports.printBoxStart=exports.printArrIntoBox=exports.printIntoBox=exports.logAppInfo=exports.logInitialize=exports.logEnd=exports.logError=exports.logSuccess=exports.logComplete=exports.isInfoEnabled=exports.logDebug=exports.logInfo=exports.logWarning=exports.logTask=exports.setCurrentJob=exports.logSummary=exports.getCurrentCommand=exports.logAndSave=exports.configureLogger=exports.logWelcome=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _chalk2=_interopRequireDefault(require("chalk"));
    var _prompt=require("./prompt");function ownKeys(object,enumerableOnly){vEar keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnEPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(source,true).forEach(function(key){(0,_defineProperty2.default)(target,key,source[key]);});}else if(Object.geEtOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(source).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}

    var _chalkCols={
    white:function white(v){return v;},
    green:function green(v){return v;},
    red:function red(v){return v;},
    yellow:function yellow(v){return v;},
    default:function _default(v){return v;},
    gray:function gray(v){return v;},
    blue:function blue(v){return v;},
    magenta:function magenta(v){return v;}};

    var _chalkMono=_objectSpread({},
    _chalkCols,{
    bold:_chalkCols});

    var chalk=_chalk2.default;

    var RNV_START='🚀 ReNative';
    var RNV='ReNative';
    var LINE=chalk.bold.white('----------------------------------------------------------');
    var LINE2=chalk.gray('----------------------------------------------------------');

    var logWelcome=function logWelcome(){var _c2,_c2$files,_c2$files$rnv,_c2$files$rnv$package,_c3;
    var str=_defaultColor("\n\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502                                                                              \u2502\n\u2502        "+

    chalk.red('██████╗')+" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"+chalk.red('███╗   ██╗')+" \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557"+chalk.red('██╗   ██╗')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557       \u2502\n\u2502        "+
    chalk.red('██╔══██╗')+"\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"+chalk.red('████╗  ██║')+"\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2551"+chalk.red('██║   ██║')+"\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D       \u2502\n\u2502        "+
    chalk.red('██████╔╝')+"\u2588\u2588\u2588\u2588\u2588\u2557  "+chalk.red('██╔██╗ ██║')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551   \u2588\u2588\u2551   \u2588\u2588\u2551"+chalk.red('██║   ██║')+"\u2588\u2588\u2588\u2588\u2588\u2557         \u2502\n\u2502        "+
    chalk.red('██╔══██╗')+"\u2588\u2588\u2554\u2550\u2550\u255D  "+chalk.red('██║╚██╗██║')+"\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551   \u2588\u2588\u2551   \u2588\u2588\u2551"+chalk.red('╚██╗ ██╔╝')+"\u2588\u2588\u2554\u2550\u2550\u255D         \u2502\n\u2502        "+
    chalk.red('██║  ██║')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"+chalk.red('██║ ╚████║')+"\u2588\u2588\u2551  \u2588\u2588\u2551   \u2588\u2588\u2551   \u2588\u2588\u2551"+chalk.red(' ╚████╔╝ ')+"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557       \u2502\n\u2502        "+
    chalk.red('╚═╝  ╚═╝')+"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"+chalk.red('╚═╝  ╚═══╝')+"\u255A\u2550\u255D  \u255A\u2550\u255D   \u255A\u2550\u255D   \u255A\u2550\u255D"+chalk.red('  ╚═══╝  ')+"\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D       \u2502\n\u2502                                                                              \u2502\n");

    if((_c2=_c)==null?void 0:(_c2$files=_c2.files)==null?void 0:(_c2$files$rnv=_c2$files.rnv)==null?void 0:(_c2$files$rnv$package=_c2$files$rnv.package)==null?void 0:_c2$files$rnv$package.version){
    _c.rnvVersion=_c.files.rnv.package.version;
    str+=printIntoBox("      Version: "+chalk.green(_c.rnvVersion),1);
    if(_c.rnvVersion.includes('alpha')){
    str+=printIntoBox("      "+chalk.yellow('WARNING: this is a prerelease version.'),1);
    str+=printIntoBox("      "+chalk.yellow('Use "npm install rnv" for stable one.'),1);
    }
    }
    str+=printIntoBox("      "+chalk.blue('https://renative.org'),1);
    str+=printIntoBox("      \uD83D\uDE80 "+chalk.yellow('Firing up!...'),1);
    str+=printIntoBox("      "+getCurrentCommand());
    if((_c3=_c)==null?void 0:_c3.timeStart)str+=printIntoBox("      Start Time: "+_c.timeStart.toLocaleString());
    str+=printIntoBox('');
    str+=printBoxEnd();
    str+='\n';

    console.log(str);
    };exports.logWelcome=logWelcome;

    var _messages=[];
    var _currentCommand;
    var _currentProcess;
    var _isInfoEnabled=false;
    var _c;
    var _isMono=false;
    var _defaultColor;
    var _highlightColor;

    var configureLogger=function configureLogger(c,process,command,subCommand,isInfoEnabled){
    _messages=[];
    _c=c;
    _c.timeStart=new Date();
    _currentProcess=process;
    _currentCommand=command;
    _currentSubCommand=subCommand;
    _isInfoEnabled=isInfoEnabled;
    _isMono=c.program.mono;
    if(_isMono){
    chalk=_chalkMono;
    }
    _updateDefaultColors();
    RNV=getCurrentCommand();
    };exports.configureLogger=configureLogger;

    var _updateDefaultColors=function _updateDefaultColors(){
    _defaultColor=chalk.gray;
    _highlightColor=chalk.green;
    };
    _updateDefaultColors();

    var logAndSave=function logAndSave(msg,skipLog){
    if(_messages&&!_messages.includes(msg))_messages.push(msg);
    if(!skipLog)console.log(""+msg);
    };exports.logAndSave=logAndSave;

    var PRIVATE_PARAMS=['-k','--key'];

    var getCurrentCommand=function getCurrentCommand(){var excludeDollar=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;
    if(!_c)return'_c is undefined';
    var argArr=_c.process.argv.slice(2);
    var hideNext=false;
    var output=argArr.map(function(v){
    if(hideNext){
    hideNext=false;
    return'********';
    }
    if(PRIVATE_PARAMS.includes(v)){
    hideNext=true;
    }

    return v;
    }).join(' ');
    var dollar=excludeDollar?'':'$ ';
    return dollar+"rnv "+output;
    };exports.getCurrentCommand=getCurrentCommand;

    var logSummary=function logSummary(){
    var logContent=printIntoBox('All good as 🦄 ');
    if(_messages&&_messages.length){
    logContent='';
    _messages.forEach(function(m){
    logContent+="\u2502 "+m+"\n";
    });
    }

    var timeString='';
    if(_c){
    _c.timeEnd=new Date();
    timeString="| "+_c.timeEnd.toLocaleString();
    }

    var str=printBoxStart("\uD83D\uDE80  SUMMARY "+timeString,getCurrentCommand());
    if(_c){
    if(_c.files.project.package){
    str+=printIntoBox("Project Name: "+_highlightColor(_c.files.project.package.name),1);
    str+=printIntoBox("Project Version: "+_highlightColor(_c.files.project.package.version),1);
    }
    if(_c.buildConfig){
    str+=printIntoBox("App Config: "+_highlightColor(_c.buildConfig.id),1);
    }
    if(_c.files.project.config){
    var defaultProjectConfigs=_c.files.project.config.defaults;
    if(defaultProjectConfigs==null?void 0:defaultProjectConfigs.supportedPlatforms){var _c$buildConfig,_c$buildConfig$defaul;
    var plats=[];
    (0,_prompt.generateOptions)((_c$buildConfig=_c.buildConfig)==null?void 0:(_c$buildConfig$defaul=_c$buildConfig.defaults)==null?void 0:_c$buildConfig$defaul.supportedPlatforms,true,null,function(i,obj,mapping,defaultVal){
    var isEjected='';
    if(_c.paths.project.platformTemplatesDirs){
    isEjected=_c.paths.project.platformTemplatesDirs[obj].includes(_c.paths.rnv.platformTemplates.dir)?'':'(ejected)';
    }

    plats.push(""+defaultVal+isEjected);
    });
    str+=printArrIntoBox(plats,'Supported Platfroms: ');
    }
    if(defaultProjectConfigs==null?void 0:defaultProjectConfigs.template){
    str+=printIntoBox("Master Template: "+_highlightColor(defaultProjectConfigs.template),1);
    }
    }
    if(_c.process){var _c$process$versions;
    var envString=_c.process.platform+" | "+_c.process.arch+" | node v"+((_c$process$versions=_c.process.versions)==null?void 0:_c$process$versions.node)+" | rnv v"+_c.rnvVersion;
    str+=printIntoBox("Env Info: "+chalk.gray(envString),1);
    }

    if(_c.program.scheme)str+=printIntoBox("Build Scheme: "+_highlightColor(_c.program.scheme),1);
    if(_c.platform)str+=printIntoBox("Platform: "+_highlightColor(_c.platform),1);
    if(_c.timeEnd){
    str+=printIntoBox("Executed Time: "+chalk.yellow(_msToTime(_c.timeEnd-_c.timeStart)),1);
    }
    }

    str+=printIntoBox('');
    str+=logContent;
    str+=printIntoBox('');
    str+=printBoxEnd();

    console.log(str);
    };exports.logSummary=logSummary;

    var _msToTime=function _msToTime(s){
    var ms=s%1000;
    s=(s-ms)/1000;
    var secs=s%60;
    s=(s-secs)/60;
    var mins=s%60;
    var hrs=(s-mins)/60;

    return hrs+"h:"+mins+"m:"+secs+"s:"+ms+"ms";
    };

    var setCurrentJob=function setCurrentJob(job){
    _currentCommand=job;
    };exports.setCurrentJob=setCurrentJob;

    var logTask=function logTask(task,customChalk){
    var ch=customChalk||chalk.green;
    var postMsg=customChalk?'':' - Starting!';
    console.log(ch(RNV+" - "+task+postMsg));
    };exports.logTask=logTask;

    var logWarning=function logWarning(msg){
    logAndSave(chalk.yellow("\u26A0\uFE0F  "+RNV+" - WARNING: "+msg));
    };exports.logWarning=logWarning;

    var logInfo=function logInfo(msg){
    console.log(chalk.magenta("\u2139\uFE0F  "+RNV+" - NOTE: "+msg));
    };exports.logInfo=logInfo;

    var logDebug=function logDebug(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}
    if(_isInfoEnabled)console.log.apply(null,args);
    };exports.logDebug=logDebug;

    var isInfoEnabled=function isInfoEnabled(){return _isInfoEnabled;};exports.isInfoEnabled=isInfoEnabled;

    var logComplete=function logComplete(){var isEnd=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;
    console.log(chalk.bold.white("\n "+RNV+" - Done! \uD83D\uDE80"));
    if(isEnd)logEnd(0);
    };exports.logComplete=logComplete;

    var logSuccess=function logSuccess(msg){
    logAndSave("\u2705 "+chalk.magenta(msg));
    };exports.logSuccess=logSuccess;

    var logError=function logError(e){var isEnd=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;
    if(e&&e.message){
    logAndSave(chalk.bold.red("\uD83D\uDED1  "+RNV+" - ERRROR! "+e.message+"\n"+e.stack),isEnd);
    }else{
    logAndSave(chalk.bold.red("\uD83D\uDED1  "+RNV+" - ERRROR! "+e),isEnd);
    }
    if(isEnd)logEnd(1);
    };exports.logError=logError;

    var logEnd=function logEnd(code){
    logSummary();
    if(_currentProcess)_currentProcess.exit(code);
    };exports.logEnd=logEnd;

    var logInitialize=function logInitialize(){
    logWelcome();

    };exports.logInitialize=logInitialize;

    var logAppInfo=function logAppInfo(c){return new Promise(function(resolve,reject){
    console.log(chalk.gray("\n"+LINE2+"\n\u2139\uFE0F  Current App Config: "+chalk.bold.white(c.buildConfig.id)+"\n"+LINE2));

    resolve();
    });};exports.logAppInfo=logAppInfo;

    var printIntoBox=function printIntoBox(str2){var chalkIntend=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;
    var output=_defaultColor('│  ');
    var endLine='';
    var intend;
    if(_isMono){
    intend=0;
    chalkIntend=0;
    }else{
    intend=str2===''?1:2;
    }
    for(var i=0;i<chalkIntend+intend;i++){
    endLine+='          ';
    }
    endLine+='                                                                               │\n';
    output+=_defaultColor(str2);
    var l=output.length-endLine.length;
    output+=_defaultColor(endLine.slice(l));
    return output;
    };exports.printIntoBox=printIntoBox;

    var printArrIntoBox=function printArrIntoBox(arr){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';
    var output='';
    var stringArr='';
    var i=0;
    arr.forEach(function(v){
    var l=i===0?60-_defaultColor(prefix).length:60;
    if(stringArr.length>l){
    if(i===0&&prefix.length){
    output+=printIntoBox(""+_defaultColor(prefix)+_highlightColor(stringArr),2);
    }else{
    output+=printIntoBox(_highlightColor(stringArr),1);
    }

    stringArr='';
    i++;
    }
    stringArr+=v+", ";

    });
    if(i===0&&prefix.length){
    output+=printIntoBox(""+_defaultColor(prefix)+_highlightColor(stringArr.slice(0,-2)),2);
    }else{
    output+=printIntoBox(_highlightColor(stringArr.slice(0,-2)),1);
    }

    return output;
    };exports.printArrIntoBox=printArrIntoBox;

    var printBoxStart=function printBoxStart(str,str2){
    var output=_defaultColor('┌──────────────────────────────────────────────────────────────────────────────┐\n');
    output+=printIntoBox(str);
    output+=printIntoBox(str2||'');
    output+=_defaultColor('├──────────────────────────────────────────────────────────────────────────────┤\n');
    return output;
    };exports.printBoxStart=printBoxStart;

    var logStatus=function logStatus(){

    };exports.logStatus=logStatus;

    var printBoxEnd=function printBoxEnd(){return _defaultColor('└──────────────────────────────────────────────────────────────────────────────┘');};exports.printBoxEnd=printBoxEnd;
    //# sourceMappingURL=logger.js.map