168 lines
5.6 KiB
JavaScript
168 lines
5.6 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.facebookReactNativeVersionToExpoVersionAsync = exports.facebookReactNativeVersionsAsync = exports.newestSdkVersionAsync = exports.setVersionsAsync = exports.versionsAsync = undefined;
|
|
|
|
let versionsAsync = exports.versionsAsync = (() => {
|
|
var _ref = _asyncToGenerator(function* () {
|
|
return yield (_Api || _load_Api()).default.versionsAsync();
|
|
});
|
|
|
|
return function versionsAsync() {
|
|
return _ref.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
let setVersionsAsync = exports.setVersionsAsync = (() => {
|
|
var _ref2 = _asyncToGenerator(function* (value) {
|
|
const user = yield (_User || _load_User()).default.getCurrentUserAsync();
|
|
const api = (_ApiV || _load_ApiV()).default.clientForUser(user);
|
|
return yield api.postAsync('versions/update', {
|
|
value,
|
|
secret: process.env.EXPO_VERSIONS_SECRET
|
|
});
|
|
});
|
|
|
|
return function setVersionsAsync(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
let newestSdkVersionAsync = exports.newestSdkVersionAsync = (() => {
|
|
var _ref3 = _asyncToGenerator(function* () {
|
|
let sdkVersions = yield (_Api || _load_Api()).default.sdkVersionsAsync();
|
|
let result = {};
|
|
let highestMajorVersion = '0.0.0';
|
|
(_lodash || _load_lodash()).default.forEach(sdkVersions, function (value, key) {
|
|
if ((_semver || _load_semver()).default.major(key) > (_semver || _load_semver()).default.major(highestMajorVersion)) {
|
|
highestMajorVersion = key;
|
|
result = value;
|
|
}
|
|
});
|
|
result.version = highestMajorVersion;
|
|
return result;
|
|
});
|
|
|
|
return function newestSdkVersionAsync() {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
let facebookReactNativeVersionsAsync = exports.facebookReactNativeVersionsAsync = (() => {
|
|
var _ref4 = _asyncToGenerator(function* () {
|
|
let sdkVersions = yield (_Api || _load_Api()).default.sdkVersionsAsync();
|
|
let facebookReactNativeVersions = new Set();
|
|
|
|
(_lodash || _load_lodash()).default.forEach(sdkVersions, function (value) {
|
|
if (value.facebookReactNativeVersion) {
|
|
facebookReactNativeVersions.add(value.facebookReactNativeVersion);
|
|
}
|
|
});
|
|
|
|
return Array.from(facebookReactNativeVersions);
|
|
});
|
|
|
|
return function facebookReactNativeVersionsAsync() {
|
|
return _ref4.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
let facebookReactNativeVersionToExpoVersionAsync = exports.facebookReactNativeVersionToExpoVersionAsync = (() => {
|
|
var _ref5 = _asyncToGenerator(function* (facebookReactNativeVersion) {
|
|
if (!(_semver || _load_semver()).default.valid(facebookReactNativeVersion)) {
|
|
throw new (_XDLError || _load_XDLError()).default((_ErrorCode || _load_ErrorCode()).default.INVALID_VERSION, `${facebookReactNativeVersion} is not a valid version. Must be in the form of x.y.z`);
|
|
}
|
|
|
|
let sdkVersions = yield (_Api || _load_Api()).default.sdkVersionsAsync();
|
|
let currentSdkVersion = null;
|
|
|
|
(_lodash || _load_lodash()).default.forEach(sdkVersions, function (value, key) {
|
|
if ((_semver || _load_semver()).default.major(value.facebookReactNativeVersion) === (_semver || _load_semver()).default.major(facebookReactNativeVersion) && (_semver || _load_semver()).default.minor(value.facebookReactNativeVersion) === (_semver || _load_semver()).default.minor(facebookReactNativeVersion) && (!currentSdkVersion || (_semver || _load_semver()).default.gt(key, currentSdkVersion))) {
|
|
currentSdkVersion = key;
|
|
}
|
|
});
|
|
|
|
return currentSdkVersion;
|
|
});
|
|
|
|
return function facebookReactNativeVersionToExpoVersionAsync(_x2) {
|
|
return _ref5.apply(this, arguments);
|
|
};
|
|
})();
|
|
|
|
exports.gteSdkVersion = gteSdkVersion;
|
|
exports.parseSdkVersionFromTag = parseSdkVersionFromTag;
|
|
|
|
var _lodash;
|
|
|
|
function _load_lodash() {
|
|
return _lodash = _interopRequireDefault(require('lodash'));
|
|
}
|
|
|
|
var _semver;
|
|
|
|
function _load_semver() {
|
|
return _semver = _interopRequireDefault(require('semver'));
|
|
}
|
|
|
|
var _Api;
|
|
|
|
function _load_Api() {
|
|
return _Api = _interopRequireDefault(require('./Api'));
|
|
}
|
|
|
|
var _ApiV;
|
|
|
|
function _load_ApiV() {
|
|
return _ApiV = _interopRequireDefault(require('./ApiV2'));
|
|
}
|
|
|
|
var _ErrorCode;
|
|
|
|
function _load_ErrorCode() {
|
|
return _ErrorCode = _interopRequireDefault(require('./ErrorCode'));
|
|
}
|
|
|
|
var _XDLError;
|
|
|
|
function _load_XDLError() {
|
|
return _XDLError = _interopRequireDefault(require('./XDLError'));
|
|
}
|
|
|
|
var _User;
|
|
|
|
function _load_User() {
|
|
return _User = _interopRequireDefault(require('./User'));
|
|
}
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
|
|
|
function gteSdkVersion(expJson, sdkVersion) {
|
|
if (!expJson.sdkVersion) {
|
|
return false;
|
|
}
|
|
|
|
if (expJson.sdkVersion === 'UNVERSIONED') {
|
|
return true;
|
|
}
|
|
|
|
try {
|
|
return (_semver || _load_semver()).default.gte(expJson.sdkVersion, sdkVersion);
|
|
} catch (e) {
|
|
throw new (_XDLError || _load_XDLError()).default((_ErrorCode || _load_ErrorCode()).default.INVALID_VERSION, `${expJson.sdkVersion} is not a valid version. Must be in the form of x.y.z`);
|
|
}
|
|
}
|
|
|
|
function parseSdkVersionFromTag(tag) {
|
|
if (tag.startsWith('sdk-')) {
|
|
return tag.substring(4);
|
|
}
|
|
|
|
return tag;
|
|
}
|
|
//# sourceMappingURL=__sourcemaps__/Versions.js.map
|