[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.semverMin = semverMin;
|
---|
| 7 | exports.semverify = semverify;
|
---|
| 8 | exports.isUnreleasedVersion = isUnreleasedVersion;
|
---|
| 9 | exports.getLowestUnreleased = getLowestUnreleased;
|
---|
| 10 | exports.getHighestUnreleased = getHighestUnreleased;
|
---|
| 11 | exports.getLowestImplementedVersion = getLowestImplementedVersion;
|
---|
| 12 |
|
---|
| 13 | var _semver = require("semver");
|
---|
| 14 |
|
---|
| 15 | var _helperValidatorOption = require("@babel/helper-validator-option");
|
---|
| 16 |
|
---|
| 17 | var _targets = require("./targets");
|
---|
| 18 |
|
---|
| 19 | const versionRegExp = /^(\d+|\d+.\d+)$/;
|
---|
| 20 | const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets");
|
---|
| 21 |
|
---|
| 22 | function semverMin(first, second) {
|
---|
| 23 | return first && _semver.lt(first, second) ? first : second;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | function semverify(version) {
|
---|
| 27 | if (typeof version === "string" && _semver.valid(version)) {
|
---|
| 28 | return version;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | v.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`);
|
---|
| 32 | const split = version.toString().split(".");
|
---|
| 33 |
|
---|
| 34 | while (split.length < 3) {
|
---|
| 35 | split.push("0");
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | return split.join(".");
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | function isUnreleasedVersion(version, env) {
|
---|
| 42 | const unreleasedLabel = _targets.unreleasedLabels[env];
|
---|
| 43 | return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | function getLowestUnreleased(a, b, env) {
|
---|
| 47 | const unreleasedLabel = _targets.unreleasedLabels[env];
|
---|
| 48 | const hasUnreleased = [a, b].some(item => item === unreleasedLabel);
|
---|
| 49 |
|
---|
| 50 | if (hasUnreleased) {
|
---|
| 51 | return a === hasUnreleased ? b : a || b;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | return semverMin(a, b);
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | function getHighestUnreleased(a, b, env) {
|
---|
| 58 | return getLowestUnreleased(a, b, env) === a ? b : a;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | function getLowestImplementedVersion(plugin, environment) {
|
---|
| 62 | const result = plugin[environment];
|
---|
| 63 |
|
---|
| 64 | if (!result && environment === "android") {
|
---|
| 65 | return plugin.chrome;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | return result;
|
---|
| 69 | } |
---|