diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7387615..425d974 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,6 +3,8 @@ name: CI on: pull_request: push: + branches: + - main jobs: eslint: @@ -91,14 +93,14 @@ jobs: - name: Build CLI for x64 run: bun build:cli --target=bun-windows-x64 --outfile=dist/cli/windows/cli_windows_x64.exe - - - name: Build CLI for x64 (baseline) - run: bun build:cli --target=bun-windows-x64-baseline --outfile=dist/cli/windows/cli_windows_x64_baseline.exe - - - name: Use Resource Hacker - run: | - ResourceHacker.exe -open dist/cli/windows/cli_windows_x64.exe -save dist/cli/windows/cli_windows_x64.exe -action addoverwrite -res resource.res - ResourceHacker.exe -open dist/cli/windows/cli_windows_x64_baseline.exe -save dist/cli/windows/cli_windows_x64_baseline.exe -action addoverwrite -res resource.res + # + # - name: Build CLI for x64 (baseline) + # run: bun build:cli --target=bun-windows-x64-baseline --outfile=dist/cli/windows/cli_windows_x64_baseline.exe + # + # - name: Use Resource Hacker + # run: | + # ResourceHacker.exe -open dist/cli/windows/cli_windows_x64.exe -save dist/cli/windows/cli_windows_x64.exe -action addoverwrite -res resource.res + # ResourceHacker.exe -open dist/cli/windows/cli_windows_x64_baseline.exe -save dist/cli/windows/cli_windows_x64_baseline.exe -action addoverwrite -res resource.res build-linux: name: Build CLI (Linux) diff --git a/README.md b/README.md index a1e1ee3..f3b0ecc 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,8 @@ Download the correct binary for your system from here, and run it. | -------- | ------------ | --- | ----------------------------------------------------------------------------------------------- | | Windows | x64 | GUI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/windows-x64-gui.exe) | | Windows | x64 | CLI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/windows-x64-cli.exe) | -| macOS | x64 | GUI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/macos-x64-gui) | -| macOS | x64 | CLI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/macos-x64-cli) | -| macOS | arm64 | GUI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/macos-arm64-gui) | -| macOS | arm64 | CLI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/macos-arm64-cli) | +| macOS | Universal | GUI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/macos-x64-gui) | +| macOS | Universal | CLI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/macos-x64-cli) | | Linux | x64 | GUI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/linux-x64-gui) | | Linux | x64 | CLI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/linux-x64-cli) | | Linux | arm64 | GUI | [Download](https://github.com/lbryfoundation/bookbuddies/releases/download/linux-arm64-gui) | diff --git a/bun.lockb b/bun.lockb index 2db90d3..ecf8f6e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 93dc7e4..82153cc 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,12 @@ "@types/cli-progress": "^3.11.6", "@types/eslint__js": "^8.42.3", "@types/readline-sync": "^1.4.8", - "@typescript-eslint/eslint-plugin": "^8.2.0", + "@typescript-eslint/eslint-plugin": "^8.3.0", "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", "prettier": "^3.3.3", "typescript": "^5.5.4", - "typescript-eslint": "^8.2.0" + "typescript-eslint": "^8.3.0" }, "scripts": { "lint": "bun update && bun eslint --fix && bun prettier . -w && bun tsc --noEmit", @@ -28,12 +28,13 @@ "@inquirer/prompts": "^5.3.8", "@sentry/bun": "^8.26.0", "adm-zip": "^0.5.15", + "ajv": "^8.17.1", "app-root-path": "^3.1.0", "cli-progress": "^3.12.0", "colors": "^1.4.0", - "hono": "^4.5.8", + "hono": "^4.5.9", "jszip": "^3.10.1", - "ora": "^8.0.1", + "ora": "^8.1.0", "readline-sync": "^1.4.10" } } diff --git a/src/cli/cli.ts b/src/cli/cli.ts index bebe457..dec8fc9 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -35,7 +35,7 @@ coreEvents.on('lbrynet downloaded', () => { }) coreEvents.on('lbrynet starting', () => { currentSpinner = ora({ - text: `Starting the LBRY SDK${process.platform === 'win32' ? ', this may trigger a Windows Firewall prompt or take a long time!' : ''}`, + text: `Starting the LBRY SDK, this may ${process.platform === 'win32' ? 'trigger a Windows Firewall prompt or ' : ''}take a long time!`, spinner: 'bouncingBar' }).start() }) diff --git a/src/cli/settings/schema.json b/src/cli/settings/schema.json new file mode 100644 index 0000000..09a7638 --- /dev/null +++ b/src/cli/settings/schema.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "version": { "type": "number", "minimum": 1, "maximum": 1 }, + "storageSpace": { "type": "number", "minimum": 1 }, + "username": { "type": "string" }, + "sentry": { "type": "boolean" }, + "advanced": { + "type": "object", + "properties": { + "rpcPort": { "type": "number", "minimum": 1024, "maximum": 65535 }, + "udpPort": { "type": "number", "minimum": 1024, "maximum": 65535 }, + "tcpPort": { "type": "number", "minimum": 1024, "maximum": 65535 } + }, + "required": ["rpcPort", "udpPort", "tcpPort"] + } + }, + "required": ["version", "storageSpace", "sentry", "advanced"] +} diff --git a/src/cli/settings/settings.ts b/src/cli/settings/settings.ts index 88cd393..84b0393 100644 --- a/src/cli/settings/settings.ts +++ b/src/cli/settings/settings.ts @@ -2,6 +2,10 @@ import { number, input, confirm } from '@inquirer/prompts' import colors from 'colors' import type { Settings } from '../../types/settings' import type { BunFile } from 'bun' +import Ajv from 'ajv' +import schema from './schema.json' with { type: 'file' } + +const ajv = new Ajv() const theme = { prefix: '?', @@ -90,6 +94,19 @@ const requestSettings = async ( } export default async (): Promise => { - const settingsFile = Bun.file('settings.json') - return await requestSettings(settingsFile, true) + const settingsFile = await Bun.file('settings.json') + let requiresRequest = false + const settingsJson = await settingsFile + .json() + .catch(() => (requiresRequest = true)) + if ( + !ajv.validate( + await Bun.file(schema as unknown as string).json(), + settingsJson + ) + ) + requiresRequest = true + if (requiresRequest) + return await requestSettings(settingsFile, await settingsFile.exists()) + return settingsJson }