@rnv/engine-core
Version:
ReNative Engine Core
47 lines • 2.87 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var core_1 = require("@rnv/core");
var questionHelpers_1 = require("../questionHelpers");
var Question = function (data) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var c, platform, inputs, files, supportedPlatforms, optsPlatforms, selectedPlatforms, answer;
var _a, _b, _c, _d, _e;
return tslib_1.__generator(this, function (_f) {
switch (_f.label) {
case 0:
c = (0, core_1.getContext)();
platform = c.program.opts().platform;
inputs = data.inputs, files = data.files;
supportedPlatforms =
// files.template.renativeTemplateConfig?.templateConfig?.renative_json?..supportedPlatforms ||
((_b = (_a = files.template.renativeConfig) === null || _a === void 0 ? void 0 : _a.defaults) === null || _b === void 0 ? void 0 : _b.supportedPlatforms) || [];
supportedPlatforms.sort(function (a, b) { return core_1.RnvPlatforms.indexOf(a) - core_1.RnvPlatforms.indexOf(b); });
optsPlatforms = c.program.opts().platform && [c.program.opts().platform];
selectedPlatforms = optsPlatforms ||
((_d = (_c = files.template.renativeTemplateConfig) === null || _c === void 0 ? void 0 : _c.bootstrapConfig) === null || _d === void 0 ? void 0 : _d.defaultSelectedPlatforms) ||
supportedPlatforms;
if (supportedPlatforms.length === 0) {
(0, core_1.logError)("Template ".concat((_e = inputs.template) === null || _e === void 0 ? void 0 : _e.packageName, " does not seem to export any default platforms to support. contact the author."));
}
if (!(0, questionHelpers_1.checkInputValue)(platform)) return [3 /*break*/, 1];
inputs.supportedPlatforms = platform.split(',');
return [3 /*break*/, 3];
case 1: return [4 /*yield*/, (0, core_1.inquirerPrompt)({
name: 'inputSupportedPlatforms',
type: 'checkbox',
pageSize: 20,
message: 'What platforms would you like to use?',
validate: function (val) { return !!val.length || 'Please select at least a platform'; },
default: selectedPlatforms,
choices: supportedPlatforms,
})];
case 2:
answer = _f.sent();
inputs.supportedPlatforms = (answer === null || answer === void 0 ? void 0 : answer.inputSupportedPlatforms) || [];
_f.label = 3;
case 3: return [2 /*return*/];
}
});
}); };
exports.default = Question;
//# sourceMappingURL=supportedPlatforms.js.map
;