Skip to content

Commit e707d28

Browse files
committed
Replace semver with compareVersions
1 parent 78e4264 commit e707d28

27 files changed

+313
-216
lines changed

src/js/CliAutoComplete.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import GUI from "./gui";
22
import CONFIGURATOR from "./data_storage";
33
import FC from "./fc";
4-
import semver from "semver";
4+
import compareVersions from "./utils/compareVersions";
55
import $ from "jquery";
66

77
/**
@@ -460,7 +460,7 @@ CliAutoComplete._initTextcomplete = function () {
460460
search: function (term, callback) {
461461
sendOnEnter = false;
462462
let arr = cache.resources;
463-
if (semver.gte(FC.CONFIG.flightControllerVersion, "4.0.0")) {
463+
if (compareVersions.gte(FC.CONFIG.flightControllerVersion, "4.0.0")) {
464464
arr = ["show"].concat(arr);
465465
} else {
466466
arr = ["list"].concat(arr);

src/js/Features.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { bit_check, bit_set, bit_clear } from "./bit";
2-
import { API_VERSION_1_45, API_VERSION_1_46, API_VERSION_1_47 } from "./data_storage";
3-
import semver from "semver";
2+
import compareVersions from "./utils/compareVersions";
3+
import { API_VERSION_1_45, API_VERSION_1_46, API_VERSION_25_12 } from "./data_storage";
44
import { tracking } from "./Analytics";
55
import $ from "jquery";
66

@@ -42,13 +42,13 @@ const Features = function (config) {
4242
});
4343
}
4444

45-
if (semver.gte(config.apiVersion, API_VERSION_1_47)) {
45+
if (compareVersions.gte(config.apiVersion, API_VERSION_25_12)) {
4646
addFeatureDependsOn(self._features, "SOFTSERIAL", "SOFTSERIAL");
4747
}
4848

4949
if (config.buildOptions?.length) {
5050
// Filter features based on build options
51-
if (semver.gte(config.apiVersion, API_VERSION_1_45)) {
51+
if (compareVersions.gte(config.apiVersion, API_VERSION_1_45)) {
5252
self._features = [];
5353

5454
for (const feature of features) {
@@ -62,7 +62,7 @@ const Features = function (config) {
6262
}
6363

6464
// Add TELEMETRY feature if any of the following protocols are used: CRSF, GHST, FPORT, JETI
65-
if (semver.gte(config.apiVersion, API_VERSION_1_46)) {
65+
if (compareVersions.gte(config.apiVersion, API_VERSION_1_46)) {
6666
let enableTelemetry = false;
6767
if (
6868
config.buildOptions.some(

src/js/TuningSliders.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import MSP from "./msp";
22
import FC from "./fc";
33
import MSPCodes from "./msp/MSPCodes";
4-
import semver from "semver";
5-
import { API_VERSION_1_47 } from "./data_storage";
4+
import compareVersions from "./utils/compareVersions";
5+
import { API_VERSION_25_12 } from "./data_storage";
66
import { isExpertModeEnabled } from "./utils/isExportModeEnabled";
77
import { mspHelper } from "./msp/MSPHelper";
88
import $ from "jquery";
@@ -271,7 +271,7 @@ TuningSliders.updateSlidersWarning = function (slidersUnavailable = false) {
271271
const WARNING_D_MAX_GAIN = 60;
272272
const WARNING_I_GAIN = 2.5 * FC.PIDS[0][0];
273273
const WARNING_D_GAIN = 42;
274-
const enableWarning = semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_47)
274+
const enableWarning = compareVersions.lt(FC.CONFIG.apiVersion, API_VERSION_25_12)
275275
? FC.PIDS[0][0] > WARNING_P_GAIN ||
276276
FC.PIDS[0][1] > WARNING_I_GAIN ||
277277
FC.PIDS[0][2] > WARNING_D_MAX_GAIN ||

src/js/VirtualFC.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Features from "./Features";
22
import { i18n } from "./localization";
33
import Beepers from "./Beepers";
44
import FC from "./fc";
5-
import CONFIGURATOR, { API_VERSION_1_47 } from "./data_storage";
5+
import CONFIGURATOR, { API_VERSION_25_12 } from "./data_storage";
66
import { OSD } from "./tabs/osd";
7-
import semver from "semver";
7+
import compareVersions from "./utils/compareVersions";
88
import { addArrayElement, addArrayElementAfter } from "./utils/array";
99

1010
const VirtualFC = {
@@ -240,7 +240,7 @@ const VirtualFC = {
240240
"LAP TIMER RESET",
241241
];
242242

243-
if (semver.gte(virtualFC.CONFIG.apiVersion, API_VERSION_1_47)) {
243+
if (compareVersions.gte(virtualFC.CONFIG.apiVersion, API_VERSION_25_12)) {
244244
addArrayElementAfter(virtualFC.AUX_CONFIG, "HORIZON", "ALT_HOLD");
245245
addArrayElementAfter(virtualFC.AUX_CONFIG, "CAMSTAB", "POS_HOLD");
246246
addArrayElement(virtualFC.AUX_CONFIG, "CHIRP");
@@ -259,7 +259,7 @@ const VirtualFC = {
259259
}
260260

261261
// 11 1111 (pass bitchecks)
262-
virtualFC.CONFIG.activeSensors = semver.gte(virtualFC.CONFIG.apiVersion, API_VERSION_1_47) ? 127 : 63;
262+
virtualFC.CONFIG.activeSensors = compareVersions.gte(virtualFC.CONFIG.apiVersion, API_VERSION_25_12) ? 127 : 63;
263263

264264
virtualFC.SENSOR_CONFIG_ACTIVE = {
265265
gyro_hardware: 2, // MPU6050

src/js/data_storage.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ export const API_VERSION_1_39 = "1.39.0";
22
export const API_VERSION_1_44 = "1.44.0";
33
export const API_VERSION_1_45 = "1.45.0";
44
export const API_VERSION_1_46 = "1.46.0";
5-
export const API_VERSION_1_47 = "1.47.0";
5+
export const API_VERSION_25_12 = "25.12.0";
66

77
const CONFIGURATOR = {
8-
// all versions are specified and compared using semantic versioning http://semver.org/
98
API_VERSION_ACCEPTED: API_VERSION_1_44,
10-
API_VERSION_MAX_SUPPORTED: API_VERSION_1_47,
9+
API_VERSION_MAX_SUPPORTED: API_VERSION_25_12,
1110

1211
connectionValid: false,
1312
connectionValidCliOnly: false,

src/js/debug.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import FC from "./fc.js";
2-
import { API_VERSION_1_46, API_VERSION_1_47 } from "./data_storage";
3-
import semver from "semver";
2+
import compareVersions from "./utils/compareVersions.js";
3+
import { API_VERSION_1_46, API_VERSION_25_12 } from "./data_storage";
44
import { removeArrayElement, addArrayElement, replaceArrayElement, addArrayElementAfter } from "./utils/array";
55

66
const DEBUG = {
@@ -809,7 +809,7 @@ const DEBUG = {
809809
};
810810

811811
function update() {
812-
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
812+
if (compareVersions.gte(FC.CONFIG.apiVersion, API_VERSION_1_46)) {
813813
DEBUG.fieldNames.ATTITUDE = {
814814
"debug[all]": "Attitude",
815815
"debug[0]": "Roll Angle",
@@ -823,7 +823,7 @@ function update() {
823823
};
824824
}
825825

826-
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
826+
if (compareVersions.gte(FC.CONFIG.apiVersion, API_VERSION_25_12)) {
827827
replaceArrayElement(DEBUG.modes, "GPS_RESCUE_THROTTLE_PID", "AUTOPILOT_ALTITUDE");
828828
removeArrayElement(DEBUG.modes, "GYRO_SCALED");
829829
addArrayElementAfter(DEBUG.modes, "RANGEFINDER_QUALITY", "OPTICALFLOW");
@@ -835,7 +835,7 @@ function update() {
835835

836836
delete DEBUG.fieldNames.GPS_RESCUE_THROTTLE_PID;
837837
delete DEBUG.fieldNames.GYRO_SCALED;
838-
838+
839839
DEBUG.fieldNames["MULTI_GYRO_RAW"] = DEBUG.fieldNames.DUAL_GYRO_RAW;
840840
DEBUG.fieldNames["MULTI_GYRO_DIFF"] = DEBUG.fieldNames.DUAL_GYRO_DIFF;
841841
DEBUG.fieldNames["MULTI_GYRO_SCALED"] = DEBUG.fieldNames.DUAL_GYRO_SCALED;

src/js/fc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { bit_check } from "./bit";
22
import { reactive } from "vue";
33
import { API_VERSION_1_45, API_VERSION_1_46 } from "./data_storage";
4-
import semver from "semver";
4+
import compareVersions from "./utils/compareVersions";
55

66
const INITIAL_CONFIG = {
77
apiVersion: "0.0.0",
@@ -803,7 +803,7 @@ const FC = {
803803
"IRC GHOST",
804804
];
805805

806-
if (semver.gte(apiVersion, API_VERSION_1_46)) {
806+
if (compareVersions.gte(apiVersion, API_VERSION_1_46)) {
807807
// Default to NONE and move SPEKTRUM1024 to the end (firmware PR #12500)
808808
serialRxTypes[0] = "NONE";
809809
serialRxTypes.push("SPEKTRUM1024");
@@ -965,7 +965,7 @@ const FC = {
965965
versionFilterDefaults.dterm_lowpass_dyn_max_hz = 150;
966966

967967
// Introduced in 1.45
968-
if (semver.gte(this.CONFIG.apiVersion, API_VERSION_1_45)) {
968+
if (compareVersions.gte(this.CONFIG.apiVersion, API_VERSION_1_45)) {
969969
versionFilterDefaults.dyn_notch_min_hz = 100;
970970
}
971971

0 commit comments

Comments
 (0)