Skip to content

Commit

Permalink
fix(api): remove broken universal-speedtest to avoid confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
MauriceNino committed Nov 13, 2022
1 parent 0263a16 commit 0f5e785
Show file tree
Hide file tree
Showing 50 changed files with 49 additions and 524 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/ftp-npm-0.3.10-348fb9ac23-ddd313c1d4.zip
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/levn-npm-0.3.0-48d774b1c2-0d084a5242.zip
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/mime-npm-2.6.0-88b89d8de0-1497ba7b9f.zip
Binary file not shown.
Binary file removed .yarn/cache/mz-npm-2.7.0-ec3cef4ec2-8427de0ece.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/vm2-npm-3.9.9-03fd1f4dc5-ea48595656.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
30 changes: 9 additions & 21 deletions apps/api/src/static-info.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { HardwareInfo, ServerInfo } from '@dash/common';
import { HardwareInfo, removePad, ServerInfo } from '@dash/common';
import { exec as cexec } from 'child_process';
import * as fs from 'fs';
import { BehaviorSubject, map, Observable } from 'rxjs';
import * as si from 'systeminformation';
import { SpeedUnits, UniversalSpeedtest } from 'universal-speedtest';
import { inspect, promisify } from 'util';
import { CONFIG } from './config';
import { NET_INTERFACE_PATH } from './setup';
Expand Down Expand Up @@ -321,25 +320,14 @@ export const runSpeedTest = async (): Promise<string> => {
},
});
} else {
usedRunner = 'universal';
const universalSpeedtest = new UniversalSpeedtest({
measureUpload: true,
downloadUnit: SpeedUnits.bps,
uploadUnit: SpeedUnits.bps,
});

const speed = await universalSpeedtest.runSpeedtestNet();

STATIC_INFO.next({
...STATIC_INFO.getValue(),
network: {
...STATIC_INFO.getValue().network,
speedDown:
speed.downloadSpeed ?? STATIC_INFO.getValue().network.speedDown,
speedUp: speed.uploadSpeed ?? STATIC_INFO.getValue().network.speedUp,
publicIp: speed.client.ip ?? STATIC_INFO.getValue().network.publicIp,
},
});
throw new Error(removePad`
There is no speedtest module installed - please use one of the following:
- speedtest: https://www.speedtest.net/apps/cli
- speedtest-cli: https://github.com/sivel/speedtest-cli
For more help on how to setup dashdot, look here:
https://getdashdot.com/docs/install/from-source
`);
}

return usedRunner;
Expand Down
11 changes: 11 additions & 0 deletions libs/common/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export const clamp = (num: number, min: number, max: number) => {
return num > max ? max : num < min ? min : num;
};

export const removePad = (strings: TemplateStringsArray, ...content: any[]) => {
const complete = strings.reduce(
(acc, s, i) => `${acc}${s}${content[i] ?? ''}`,
''
);
const trimmed = complete.split('\n').filter(s => /^\s*$/.test(s) === false);
const shortestPad = Math.min(...trimmed.map(s => /(?!\s)/.exec(s)!.index));

return trimmed.map(s => s.substring(shortestPad)).join('\n');
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"systeminformation": "5.12.6",
"throttle-debounce": "5.0.0",
"tslib": "2.4.0",
"universal-speedtest": "2.0.5",
"use-color-scheme": "1.1.3",
"util": "0.12.4",
"web-vitals": "3.0.2",
Expand Down
Loading

0 comments on commit 0f5e785

Please sign in to comment.