UNPKG

@rnv/engine-core

Version:
74 lines 4.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var path_1 = tslib_1.__importDefault(require("path")); var core_1 = require("@rnv/core"); var fs_1 = require("fs"); exports.default = (0, core_1.createTask)({ description: 'Preconfigures your current workspace defined via "workspaceID" prop in renative config file', fn: function (_a) { var ctx = _a.ctx; return tslib_1.__awaiter(void 0, void 0, void 0, function () { var paths, files, oldGlobalConfigPath, defaultWorkspaceCnf, newConfig; var _b, _c; return tslib_1.__generator(this, function (_d) { paths = ctx.paths, files = ctx.files; // Check globalConfig Dir if ((0, core_1.fsExistsSync)(paths.workspace.dir)) { (0, core_1.logDebug)("".concat(paths.workspace.dir, " folder exists!")); } else { (0, core_1.logInfo)("".concat(paths.workspace.dir, " folder missing! Creating one for you...")); (0, core_1.mkdirSync)(paths.workspace.dir); } // Check globalConfig if ((0, core_1.fsExistsSync)(paths.workspace.config)) { (0, core_1.logDebug)("".concat(paths.workspace.dir, "/").concat(core_1.RnvFileName.renative, " file exists!")); } else { oldGlobalConfigPath = path_1.default.join(paths.workspace.dir, 'config.json'); if ((0, core_1.fsExistsSync)(oldGlobalConfigPath)) { (0, core_1.logWarning)('Found old version of your config. will copy it to new renative.json config'); (0, core_1.copyFileSync)(oldGlobalConfigPath, paths.workspace.config); } else { (0, core_1.logInfo)("".concat(paths.workspace.dir, "/").concat(core_1.RnvFileName.renative, " file missing! Creating one for you...")); defaultWorkspaceCnf = { sdks: { ANDROID_SDK: '/Users/<USER>/Library/Android/sdk', ANDROID_NDK: '/Users/<USER>/Library/Android/sdk/ndk-bundle', IOS_SDK: 'No need. Just install Xcode', TIZEN_SDK: '/Users/<USER>/tizen-studio', WEBOS_SDK: '/Users/<USER>/Library/webOS_TV_SDK', KAIOS_SDK: '/Applications/Kaiosrt.app', }, }; (0, fs_1.writeFileSync)(paths.workspace.config, JSON.stringify(defaultWorkspaceCnf, null, 2)); } } if ((0, core_1.fsExistsSync)(paths.workspace.config)) { files.workspace.config = JSON.parse((0, core_1.fsReadFileSync)(paths.workspace.config).toString()); if ((_b = files.workspace.config) === null || _b === void 0 ? void 0 : _b.appConfigsPath) { if (!(0, core_1.fsExistsSync)(files.workspace.config.appConfigsPath)) { (0, core_1.logWarning)("Your custom global appConfig is pointing to ".concat((0, core_1.chalk)().bold.white(files.workspace.config.appConfigsPath), " which doesn't exist! Make sure you create one in that location")); } else { (0, core_1.logInfo)("Found custom appConfing location pointing to ".concat((0, core_1.chalk)().bold.white(files.workspace.config.appConfigsPath), ". ReNativewill now swith to that location!")); paths.project.appConfigsDir = files.workspace.config.appConfigsPath; } } // Check config sanity if (((_c = files.workspace.config) === null || _c === void 0 ? void 0 : _c.defaultTargets) === undefined) { (0, core_1.logWarning)("You're missing defaultTargets in your config ".concat((0, core_1.chalk)().bold.white(paths.workspace.config), ". Let's add them!")); newConfig = tslib_1.__assign(tslib_1.__assign({}, files.workspace.config), { defaultTargets: {} }); (0, core_1.fsWriteFileSync)(paths.workspace.config, JSON.stringify(newConfig, null, 2)); } } return [2 /*return*/, true]; }); }); }, task: core_1.RnvTaskName.workspaceConfigure, isGlobalScope: true, }); //# sourceMappingURL=taskWorkspaceConfigure.js.map