Skip to content

Commit

Permalink
chore(version): Bump version to v1.0.3 - Includes performance improve…
Browse files Browse the repository at this point in the history
…ments and bug fixes
  • Loading branch information
Alice39s committed Jan 2, 2025
1 parent 96e8336 commit 43e0763
Show file tree
Hide file tree
Showing 29 changed files with 948 additions and 333 deletions.
83 changes: 55 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
name: Build and Release

permissions:
contents: write
packages: write
Expand All @@ -16,22 +14,35 @@ on:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- version: "linux-x64"
os: ubuntu-latest
platform: linux-x64
- version: "linux-arm64"
os: ubuntu-latest
platform: linux-arm64
- version: "windows-x64"
os: windows-latest
platform: win32-x64
- version: "windows-arm64"
os: windows-latest
platform: win32-arm64
- version: "darwin-x64"
os: ubuntu-latest
platform: darwin-x64
- version: "darwin-arm64"
os: ubuntu-latest
platform: darwin-arm64

runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
platform: ${{ steps.detect_platform.outputs.PLATFORM }}
binary_name: ${{ steps.setup_env.outputs.BINARY_NAME }}
archive_name: ${{ steps.setup_env.outputs.ARCHIVE_NAME }}
strategy:
matrix:
version:
[
"linux-x64",
"linux-arm64",
"windows-x64",
"darwin-x64",
"darwin-arm64",
]

steps:
- uses: actions/checkout@v4
- uses: oven-sh/[email protected]
Expand All @@ -40,6 +51,7 @@ jobs:

- name: Detect Platform and Compress Format
id: detect_platform
shell: bash
run: |
PLATFORM="${{ matrix.version }}"
echo "PLATFORM=${PLATFORM}" >> $GITHUB_OUTPUT
Expand All @@ -52,12 +64,14 @@ jobs:
- name: Extract version number
id: get_version
shell: bash
run: |
VERSION=$(jq -r .version < package.json)
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Setup Build Environment
id: setup_env
shell: bash
run: |
mkdir -p ${{ runner.temp }}/build/out
mkdir -p ${{ runner.temp }}/build/logs
Expand All @@ -74,40 +88,54 @@ jobs:
bun install --no-install-postinstall || { echo "Failed to install dependencies"; exit 1; }
- name: Compile Code
shell: bash
run: |
bun build --compile --sourcemap --minify --bytecode \
--target=bun-${{ steps.detect_platform.outputs.PLATFORM }} \
--target=bun-${{ matrix.platform }} \
./src/cli.ts \
--outfile ${{ runner.temp }}/build/out/${{ steps.setup_env.outputs.BINARY_NAME }}
- name: Generate Checksums
- name: Generate Checksums (Linux/macOS)
if: runner.os != 'Windows'
working-directory: ${{ runner.temp }}/build/out
shell: bash
run: |
sha1sum ${{ steps.setup_env.outputs.BINARY_NAME }}* > checksum.txt
- name: Generate Checksums (Windows)
if: runner.os == 'Windows'
working-directory: ${{ runner.temp }}/build/out
shell: pwsh
run: |
Get-FileHash -Algorithm SHA1 ${{ steps.setup_env.outputs.BINARY_NAME }}* | ForEach-Object { "$($_.Hash.ToLower()) $($_.Path.Split('\')[-1])" } | Out-File -Encoding utf8 checksum.txt
- name: Compress artifacts (Linux)
if: startsWith(steps.detect_platform.outputs.PLATFORM, 'linux')
working-directory: ${{ runner.temp }}/build/out
shell: bash
run: |
tar -cJf ${{ steps.setup_env.outputs.ARCHIVE_NAME }} ${{ steps.setup_env.outputs.BINARY_NAME }}* checksum.txt
tar --threads=0 -c -I 'xz -5 -T0' -f ${{ steps.setup_env.outputs.ARCHIVE_NAME }} ${{ steps.setup_env.outputs.BINARY_NAME }}* checksum.txt
rm -f ${{ steps.setup_env.outputs.BINARY_NAME }}
# Keep a copy of checksum.txt for later use
cp checksum.txt ${{ steps.setup_env.outputs.BINARY_NAME }}.checksum.txt
- name: Compress artifacts (macOS/Windows)
if: ${{ !startsWith(steps.detect_platform.outputs.PLATFORM, 'linux') }}
- name: Compress artifacts (macOS)
if: contains(steps.detect_platform.outputs.PLATFORM, 'darwin')
working-directory: ${{ runner.temp }}/build/out
shell: bash
run: |
if [[ "${{ steps.detect_platform.outputs.PLATFORM }}" == *"windows"* ]]; then
zip -j ${{ steps.setup_env.outputs.ARCHIVE_NAME }} ${{ steps.setup_env.outputs.BINARY_NAME }}*.exe checksum.txt
rm -f ${{ steps.setup_env.outputs.BINARY_NAME }}*.exe
else
zip -j ${{ steps.setup_env.outputs.ARCHIVE_NAME }} ${{ steps.setup_env.outputs.BINARY_NAME }}* checksum.txt
rm -f ${{ steps.setup_env.outputs.BINARY_NAME }}
fi
# Keep a copy of checksum.txt for later use
zip -j ${{ steps.setup_env.outputs.ARCHIVE_NAME }} ${{ steps.setup_env.outputs.BINARY_NAME }}* checksum.txt
rm -f ${{ steps.setup_env.outputs.BINARY_NAME }}
cp checksum.txt ${{ steps.setup_env.outputs.BINARY_NAME }}.checksum.txt
- name: Compress artifacts (Windows)
if: runner.os == 'Windows'
working-directory: ${{ runner.temp }}/build/out
shell: pwsh
run: |
Compress-Archive -Path "${{ steps.setup_env.outputs.BINARY_NAME }}*.exe","checksum.txt" -DestinationPath "${{ steps.setup_env.outputs.ARCHIVE_NAME }}"
Remove-Item "${{ steps.setup_env.outputs.BINARY_NAME }}*.exe"
Copy-Item "checksum.txt" "${{ steps.setup_env.outputs.BINARY_NAME }}.checksum.txt"
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -133,7 +161,6 @@ jobs:
- name: Consolidate checksums
working-directory: ${{ runner.temp }}/release/
run: |
# Combine all checksum files into one
cat *.checksum.txt > checksums.txt
rm *.checksum.txt
Expand Down
48 changes: 43 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.3] - 2025-01-03

### Added

* **Initial release features (from 1.0.1):**
* Core speed test functionality
* Download and upload speed tests
* Latency measurement using TCP and HTTP protocols
* **New features:**
* New Aqua Speed banner images in English and Chinese
* Additional test types support (Cloudflare, LibreSpeed, Ookla)
* Improved latency measurement with ICMP, TCP, and HTTP protocols
* Dynamic chunk size adjustment for download test
* Enhanced speed test metrics with sliding window and adaptive chunk size
* **Additional features (from 1.0.2):**
* Support for DNS resolution and IP geolocation
* Cloudflare CDN location detection
* Configurable test parameters

### Changed

* Refactored codebase to improve maintainability and extensibility
* Optimized download test algorithm for better accuracy (from 1.0.2)
* Improved overall user experience and UI (from 1.0.2)
* Updated dependencies to latest versions

### Fixed

* Resolved workflow build error
* Improved error handling and logging
* Minor bug fixes and stability improvements (from 1.0.2)

# 1.0.2 (2024-12-27)

- Fix workflow build error

# 1.0.1 (2024-12-17)

Released the first version of Aqua Speed.
Expand All @@ -6,8 +48,4 @@ Released the first version of Aqua Speed.
- Support for LibreSpeed
- Support customized file speeding
- Support multi-threaded concurrent speed measurement
- Support real-time progress display

# 1.0.2 (2024-12-27)

- Fix workflow build error
- Support real-time progress display
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# :ocean: Aqua Speed

<div align="center" style="margin-bottom: 20px">

<img src="./assets/aqua-speed-banner-en.png" alt="Aqua Speed - Banner" style="width: 100%; max-width: 640px; height: auto;">

</div>

A modern network speed test CLI built with Bun and TypeScript.

<div align="center">
Expand All @@ -13,7 +19,6 @@ A modern network speed test CLI built with Bun and TypeScript.

<div align="center">


> English | [简体中文](README.zh.md)
</div>
Expand Down
6 changes: 6 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# :ocean: Aqua Speed

<div align="center" style="margin-bottom: 20px">

<img src="./assets/aqua-speed-banner-zh.png" alt="Aqua Speed - Banner" style="width: 100%; max-width: 640px; height: auto;">

</div>

一个使用 Bun 和 TypeScript 构建的现代网络测速 CLI 工具。

<div align="center">
Expand Down
Binary file added assets/aqua-speed-banner-en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/aqua-speed-banner-zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified bun.lockb
Binary file not shown.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aqua-speed",
"module": "./src/cli.ts",
"version": "1.0.2",
"version": "1.0.3",
"description": "A modern network speed test CLI built with Bun and TypeScript.",
"type": "module",
"scripts": {
Expand All @@ -24,6 +24,7 @@
],
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@types/bogon": "^1.0.2",
"@types/bun": "latest",
"@types/ping": "^0.4.4",
"@types/psl": "^1.1.3"
Expand All @@ -33,12 +34,14 @@
},
"dependencies": {
"@types/user-agents": "^1.0.4",
"bogon": "^1.1.0",
"bufferutil": "^4.0.8",
"chalk": "^5.4.0",
"commander": "^12.1.0",
"ora": "^8.1.1",
"ping": "^0.4.4",
"psl": "^1.15.0",
"table": "^6.9.0",
"undici": "^7.2.0",
"user-agents": "^1.1.396",
"ws": "^8.18.0"
Expand Down
25 changes: 20 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { program } from 'commander';
import { runSpeedTest } from './controllers/startTest';
import { runSpeedTest } from '@/controllers/runSpeedTest';
import { description, version } from '../package.json';
import { formatTestResults } from './utils/format';
import type { TestConfig, TestDisplay } from './types';
import { mergeTestConfig, prepareDisplayInfo } from './controllers/processOptions';
import { getIpGeolocation } from './models/tools/getGeoIp';
import { formatTestResults } from '@/utils/format';
import type { TestConfig, TestDisplay } from '@/types';
import { mergeTestConfig, prepareDisplayInfo } from '@/controllers/processOptions';
import { getIpGeolocation, getIpGeoOnly } from '@/models/tools/getGeoIp';
import { resolveDns } from '@/models/tools/dnsResolver';
import chalk from 'chalk';
import { manageDebugMode, isDebugMode } from './utils/common';

Expand Down Expand Up @@ -32,6 +33,20 @@ async function displayStart(display: TestDisplay, config: TestConfig): Promise<v

console.log(chalk.yellow('Test Configuration:'));

try {
const resResult = await resolveDns(config.server);
if (resResult.ip) {
const ipInfo = await getIpGeoOnly(resResult.ip);
const { ip, region, country, org } = ipInfo;
const location = `${region}, ${country}`;

console.log(chalk.gray(" IP: ") + chalk.white(`${ip}`) + chalk.gray(` (${org})`));
console.log(chalk.gray(" Location: ") + chalk.white(location));
}
} catch (error) {
console.error(chalk.red('Error details:'), error);
process.exit(1);
}

for (const [key, value] of Object.entries(display.testInfo)) {
console.log(chalk.gray(` ${key}: `) + chalk.white(value));
Expand Down
42 changes: 42 additions & 0 deletions src/constant/default.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { TestType } from '@/types';
import { isDebugMode } from '@/utils/common';

export const DEFAULT_TEST_OPTIONS = {
minTestTime: 5000,
maxTestTime: 30000,
targetError: 0.05,
minSamples: 3,
progressInterval: 200,
thread: 4,
type: 'SingleFile' as TestType,
debug: isDebugMode()
};

export const TEST_ENDPOINTS = {
LibreSpeed: (baseUrl: string, testType: string) => {
const paths = ['/backend', '/speed', ''];
const endpoint = testType === 'download' ? 'garbage.php' : 'empty.php';
const params = testType === 'download' ? '?ckSize=100' : '';
const path = paths[0];
const url = `${baseUrl}${path}/${endpoint}${params}?r=${Math.random()}`;
const referrer = `${baseUrl}/speedtest_worker.js?r=${Math.random()}`;

return {
url,
referrer,
fallbackUrls: paths.slice(1).map(p =>
`${baseUrl}${p}/${endpoint}${params}?r=${Math.random()}`
)
};
},
Cloudflare: (baseUrl: string, testType: string) => ({
url: `${baseUrl}/${testType === 'download' ? '__down?bytes=10000000' : '__up?r=0'}&measId=${Math.random() * Number(10000000000000000n)}`,
referrer: "https://speed.cloudflare.com/",
fallbackUrls: []
}),
SingleFile: (baseUrl: string, testType: string) => ({
url: baseUrl,
referrer: '',
fallbackUrls: []
})
};
2 changes: 1 addition & 1 deletion src/constant/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UserAgent from 'user-agents';
import Logger from '../utils/logger';
import Logger from '@/utils/logger';
import type { RequestInit, Dispatcher } from 'undici';
import type { ClientOptions } from 'ws';

Expand Down
8 changes: 4 additions & 4 deletions src/controllers/processOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCloudflareColoInfo } from '../models/tools/cloudflareColo';
import type { TestConfig, TestDisplay } from '../types';
import { isValidUrl, getDomainName } from '../utils/common';
import { getCloudflareColoInfo } from '@/models/tools/cloudflareColo';
import type { TestConfig, TestDisplay } from '@/types';
import { isValidUrl, getDomainName } from '@/utils/common';

/**
* Default Test Config
Expand Down Expand Up @@ -131,7 +131,7 @@ async function prepareDisplayInfo(config: TestConfig): Promise<TestDisplay> {
*/
function createDefaultDisplayInfo(config: TestConfig): TestDisplay {
return {
serverName: config.server,
serverName: config.server || DEFAULT_CONFIG.server,
flags: [],
testInfo: {
Server: config.server || DEFAULT_CONFIG.server,
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/startTest.ts → src/controllers/runSpeedTest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { SpeedTestOptions, TestResult, SpeedStats, LatencyResult } from '../types';
import { measureLatency } from '../models/latencyTest';
import { sleep, usToMs, isDebugMode } from '../utils/common';
import { measureDownload, measureUpload } from '../models/speedTest';
import Logger from '../utils/logger';
import { getDomainName } from '../utils/common';
import type { SpeedTestOptions, TestResult, SpeedStats, LatencyResult } from '@/types';
import { measureLatency } from '@/models/latencyTest';
import { sleep, usToMs, isDebugMode } from '@/utils/common';
import { measureDownload, measureUpload } from '@/models';
import Logger from '@/utils/logger';
import { getDomainName } from '@/utils/common';

const logger = new Logger();

Expand Down
Loading

0 comments on commit 43e0763

Please sign in to comment.