# All files / dist/setupTools base.js

8.72% Statements 13/149
0% Branches 0/77
4.76% Functions 1/21
11.76% Lines 8/68

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
    1434x
    4x
    4x

    4x

    4x

    4x

    4x

    4x
     var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));
    var _shelljs=_interopRequireDefault(require("shelljs"));
    var _inquirer=_interopRequireDefault(require("inquirer"));

    var _exec=require("../systemTools/exec");
    var _common=require("../common");
    var _configParser=require("../configTools/configParser");
    var _fileutils=require("../systemTools/fileutils");
    var _config=_interopRequireDefault(require("./config"));var

    BasePlatformSetup=function(){
    function BasePlatformSetup(os,c){(0,_classCallCheck2.default)(this,BasePlatformSetup);var
    paths=c.paths;
    this.os=os;
    this.c=c;
    this.globalConfigPath=paths.private.config;
    this.availableDownloader=null;
    this.androidSdkLocation=(0,_fileutils.replaceHomeFolder)('~/Android');
    this.sdksToInstall='"build-tools;28.0.3" "emulator" "extras;android;m2repository" "extras;google;m2repository" "patcher;v4" "platform-tools" "platforms;android-28" "sources;android-28" "system-images;android-28;google_apis_playstore;x86" "tools"';
    }(0,_createClass2.default)(BasePlatformSetup,[{key:"checkPrereqs",value:function checkPrereqs()

    {
    (0,_common.logInfo)("Platform "+this.os);
    (0,_common.logInfo)('Checking if wget or curl is installed');
    if((0,_exec.commandExistsSync)('wget')){
    this.availableDownloader='wget';
    }else if((0,_exec.commandExistsSync)('curl')){
    this.availableDownloader='curl';
    }
    }},{key:"installPrereqs",value:function installPrereqs(){return _regenerator.default.async(function installPrereqs$(_context){while(1){switch(_context.prev=_context.next){case 0:return _context.abrupt("return",

    true);case 1:case"end":return _context.stop();}}});}},{key:"postInstall",value:function postInstall(

    sdk){var location;return _regenerator.default.async(function postInstall$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(!(
    sdk==='android')){_context2.next=4;break;}
    location=_config.default.android.location;_context2.next=4;return _regenerator.default.awrap(
    (0,_fileutils.updateConfigFile)({androidSdk:location},this.globalConfigPath));case 4:if(!(

    sdk==='tizen')){_context2.next=7;break;}_context2.next=7;return _regenerator.default.awrap(
    (0,_fileutils.updateConfigFile)({tizenSdk:this.tizenSdkPath},this.globalConfigPath));case 7:if(!(

    sdk==='webos')){_context2.next=10;break;}_context2.next=10;return _regenerator.default.awrap(
    (0,_fileutils.updateConfigFile)({webosSdk:this.webosSdkPath},this.globalConfigPath));case 10:_context2.next=12;return _regenerator.default.awrap(

    (0,_configParser.configureRnvGlobal)(this.c));case 12:case"end":return _context2.stop();}}},null,this);}},{key:"downloadSdk",value:function downloadSdk(

    sdk){var downloader,aditionalArguments,locationArgument,command;return _regenerator.default.async(function downloadSdk$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:
    downloader=this.availableDownloader;if(
    downloader){_context3.next=3;break;}throw new Error('Wget or cURL not installed!');case 3:
    (0,_common.logDebug)("Downloading "+sdk+" SDK to "+_config.default[sdk].downloadLocation+" using "+downloader);_context3.next=6;return _regenerator.default.awrap(

    _shelljs.default.rm(_config.default[sdk].downloadLocation));case 6:

    if(downloader==='wget'){
    aditionalArguments='-q';
    locationArgument=(0,_fileutils.replaceHomeFolder)('-P ~/');
    }
    if(downloader==='curl'){
    aditionalArguments='-#';
    locationArgument="--output "+_config.default[sdk].downloadLocation;
    }

    command=downloader+" "+aditionalArguments+" "+_config.default[sdk].sdkUrl+" "+locationArgument;

    (0,_common.logDebug)('Running',command);
    (0,_common.logInfo)("Downloading "+sdk+" SDK...");_context3.next=13;return _regenerator.default.awrap(
    _shelljs.default.exec(command));case 13:case"end":return _context3.stop();}}},null,this);}},{key:"unzipSdk",value:function unzipSdk(

    sdk){return _regenerator.default.async(function unzipSdk$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:
    (0,_common.logDebug)("Unzipping from "+_config.default[sdk].downloadLocation+" to "+_config.default[sdk].location);if(
    (0,_exec.commandExistsSync)('unzip')){_context4.next=3;break;}throw new Error('unzip is not installed');case 3:_context4.next=5;return _regenerator.default.awrap(
    _shelljs.default.exec("unzip -qq -o "+_config.default[sdk].downloadLocation+" -d "+_config.default[sdk].location));case 5:case"end":return _context4.stop();}}});}},{key:"installSdksAndEmulator",value:function installSdksAndEmulator(){return _regenerator.default.async(function installSdksAndEmulator$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:

    (0,_common.logDebug)('Accepting licenses');_context5.next=3;return _regenerator.default.awrap(
    _shelljs.default.exec("yes | "+_config.default.android.location+"/tools/bin/sdkmanager --licenses > /dev/null"));case 3:
    (0,_common.logDebug)('Installing SDKs',this.sdksToInstall);_context5.next=6;return _regenerator.default.awrap(
    _shelljs.default.exec(_config.default.android.location+"/tools/bin/sdkmanager "+this.sdksToInstall+" > /dev/null"));case 6:case"end":return _context5.stop();}}},null,this);}},{key:"installSdk",value:function installSdk(

    sdk){return _regenerator.default.async(function installSdk$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:
    this.checkPrereqs();_context6.next=3;return _regenerator.default.awrap(
    this.installPrereqs());case 3:_context6.t0=

    sdk;_context6.next=_context6.t0===
    'android'?6:_context6.t0===

    'tizen'?13:_context6.t0===

    'webos'?16:19;break;case 6:_context6.next=8;return _regenerator.default.awrap(this.downloadSdk(sdk));case 8:_context6.next=10;return _regenerator.default.awrap(this.unzipSdk(sdk));case 10:_context6.next=12;return _regenerator.default.awrap(this.installSdksAndEmulator());case 12:return _context6.abrupt("break",20);case 13:_context6.next=15;return _regenerator.default.awrap(this.installTizenSdk());case 15:return _context6.abrupt("break",20);case 16:_context6.next=18;return _regenerator.default.awrap(
    this.installWebosSdk());case 18:return _context6.abrupt("break",20);case 19:return _context6.abrupt("break",20);case 20:

    this.postInstall(sdk);case 21:case"end":return _context6.stop();}}},null,this);}},{key:"installTizenSdk",value:function installTizenSdk(){return _regenerator.default.async(function installTizenSdk$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:return _context7.abrupt("return",

    true);case 1:case"end":return _context7.stop();}}});}},{key:"installWebosSdk",value:function installWebosSdk(){return _regenerator.default.async(function installWebosSdk$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:return _context8.abrupt("return",

    true);case 1:case"end":return _context8.stop();}}});}},{key:"askToInstallSDK",value:function askToInstallSDK(

    sdk){var sdkInstall,response;return _regenerator.default.async(function askToInstallSDK$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:if(

    this.c.program.ci){_context9.next=5;break;}_context9.next=3;return _regenerator.default.awrap(
    _inquirer.default.prompt([{
    name:'sdkInstall',
    type:'confirm',
    message:"Do you want to install "+sdk+" SDK?"}]));case 3:response=_context9.sent;

    sdkInstall=response.sdkInstall;case 5:if(!(

    this.c.program.ci||sdkInstall)){_context9.next=8;break;}_context9.next=8;return _regenerator.default.awrap(
    this.installSdk(sdk));case 8:case"end":return _context9.stop();}}},null,this);}}]);return BasePlatformSetup;}();var _default=

    BasePlatformSetup;exports.default=_default;
    //# sourceMappingURL=base.js.map