Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump electron version up to 25 #251

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-electron-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ env:
jobs:
linux-win-docker-builder:
timeout-minutes: 90
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
echo "IS_BFX_API_STAGING=1" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version: 16.20.0
node-version: 18.15.0
- name: Cache Electron binaries
id: electron-cache
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.linux-builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM electronuserland/builder:16
FROM electronuserland/builder:18

ARG NODE_VERSION="16.20.0"
ARG NODE_VERSION="18.15.0"

ENV IS_BFX_API_STAGING=${IS_BFX_API_STAGING:-0}
ENV IS_DEV_ENV=${IS_DEV_ENV:-0}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.mac-builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM electronuserland/builder:16
FROM electronuserland/builder:18

ARG NODE_VERSION="16.20.0"
ARG NODE_VERSION="18.15.0"

ENV IS_BFX_API_STAGING=${IS_BFX_API_STAGING:-0}
ENV IS_DEV_ENV=${IS_DEV_ENV:-0}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.ui-builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM electronuserland/builder:16
FROM electronuserland/builder:18

ARG NODE_VERSION="16.20.0"
ARG NODE_VERSION="18.17.1"

ENV IS_BFX_API_STAGING=${IS_BFX_API_STAGING:-0}
ENV IS_DEV_ENV=${IS_DEV_ENV:-0}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.win-builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM electronuserland/builder:16-wine
FROM electronuserland/builder:18-wine

ARG NODE_VERSION="16.20.0"
ARG NODE_VERSION="18.15.0"

ENV IS_BFX_API_STAGING=${IS_BFX_API_STAGING:-0}
ENV IS_DEV_ENV=${IS_DEV_ENV:-0}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ Download the correspondent binary according your operating system. Available the

## Setup

Functionality has been tested on `Ubuntu 20.04 LTS`
Functionality has been tested on `Ubuntu 22.04 LTS`

### Main Structure

To simplify setup/build/publish processes the following bash scripts are provided:

- `./scripts/setup.sh` - CLI as an easy way to get through the setup process. It will launch `./scripts/sync-repo.sh` script and then setup the development environment
- `./scripts/sync-repo.sh` - CLI to fetch the last changes of the repository/sub-modules from the main remote repo
- `./scripts/launch.sh` - CLI to launch docker-compose services to build releases and publish executable artifacts of the electron app with the last fetched changes
- `./scripts/launch.sh` - CLI to launch Docker Compose services to build releases and publish executable artifacts of the electron app with the last fetched changes

Additional bash scripts:

Expand All @@ -37,14 +37,14 @@ Additional bash scripts:

The setup was tested with the following dependencies:

- Docker version 20.10.12
- docker-compose version 1.29.2
- Docker version 24.0.6
- Docker Compose version 2.21.0
- git version 2.24.1

To install `Docker`/`docker-compose` check the corresponding sections of the official docs:
To install `Docker`/`Docker Compose` check the corresponding sections of the official docs:

- [install Docker](https://docs.docker.com/engine/install)
- [install docker-compose](https://docs.docker.com/compose/install)
- [install Docker Compose](https://docs.docker.com/compose/install) Compose V2 is included with all currently supported versions of Docker Desktop
- if you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it, [check the doc](https://docs.docker.com/engine/install/linux-postinstall)

### Setup electron app
Expand Down Expand Up @@ -121,7 +121,7 @@ export IS_AUTO_UPDATE_BEING_TESTED=true

For doing builds for other platforms please have [Multi Platform Build](https://www.electron.build/multi-platform-build) in consideration

To launch docker-compose services to build releases and publish executable artifacts of the electron app available the `./scripts/launch.sh` bash script.
To launch Docker Compose services to build releases and publish executable artifacts of the electron app available the `./scripts/launch.sh` bash script.
Available the following arguments:

```console
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.7'

services:
ui-builder:
container_name: ui-builder
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "bitfinex.com",
"main": "index.js",
"engine": {
"node": ">=14.16.0"
"node": ">=18.15.0"
},
"license": "Apache-2.0",
"dependencies": {
Expand All @@ -19,7 +19,7 @@
"cron-validate": "1.4.3",
"ed25519-supercop": "2.0.1",
"electron-alert": "0.1.20",
"electron-log": "4.4.1",
"electron-log": "4.4.8",
"electron-root-path": "1.0.16",
"electron-updater": "5.3.0",
"extract-zip": "2.0.1",
Expand All @@ -36,7 +36,7 @@
"devDependencies": {
"@mapbox/node-pre-gyp": "1.0.6",
"app-builder-bin": "4.1.0",
"electron": "21.3.3",
"electron": "25.8.1",
"electron-builder": "23.6.0",
"mocha": "10.2.0",
"standard": "16.0.4"
Expand Down
4 changes: 2 additions & 2 deletions scripts/helpers/install-backend-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function installBackendDeps {
cd "$ROOT"
echo -e "\n${COLOR_BLUE}Installing the main dev deps...${COLOR_NORMAL}"
rm -rf ./node_modules
npm i --development --no-audit --progress=false
npm i --development --no-audit --progress=false --force
npm ls --depth=0 --only=dev 1<&-

export npm_config_target_platform="$targetPlatform"
Expand All @@ -55,7 +55,7 @@ function installBackendDeps {
export npm_config_disturl="$DIST_URL"

echo -e "\n${COLOR_BLUE}Installing the main prod deps...${COLOR_NORMAL}"
npm i --production --include=dev --no-audit --progress=false
npm i --production --include=dev --no-audit --progress=false --force
rm -rf "$ROOT/node_modules/ed25519-supercop/build"
checkNodeModulesDir "$ROOT"
depsErr=$(npm ls --depth=0 --only=prod 2>&1 >/dev/null | grep -E -v "missing: eslint|--omit=dev" || [[ $? == 1 ]])
Expand Down
8 changes: 2 additions & 6 deletions scripts/helpers/install-nodejs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ script as required NodeJS version!${COLOR_NORMAL}" >&2
exit 1
fi

version="${1:-"16.20.0"}"
version="${1:-"18.15.0"}"

echo -e "\n${COLOR_BLUE}Installing the NodeJS v$version...${COLOR_NORMAL}"

Expand All @@ -25,11 +25,7 @@ unlink /usr/local/CHANGELOG.md
unlink /usr/local/LICENSE
unlink /usr/local/README.md

# https://github.com/npm/npm/issues/4531
npm config set unsafe-perm true

npm cache clear --force
npm install --global [email protected]
npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
npm install --global [email protected]

echo -e "\n${COLOR_GREEN}The NodeJS has been installed successful${COLOR_NORMAL}"
2 changes: 1 addition & 1 deletion scripts/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ if [ $syncSubModules == 1 ]; then
source "$ROOT/scripts/sync-repo.sh" "-wue"
fi

docker-compose up $composeCommonFlags $uiBuilderService \
docker compose up $composeCommonFlags $uiBuilderService \
$linuxBuilderService $winBuilderService $macBuilderService

if [ $buildLinux == 1 ]; then
Expand Down
3 changes: 2 additions & 1 deletion src/auto-updater/bfx.mac.updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const path = require('path')
const fs = require('fs')
const fsPromises = require('fs/promises')
const { spawn } = require('child_process')
const { MacUpdater } = require('electron-updater')
const extract = require('extract-zip')
Expand Down Expand Up @@ -54,7 +55,7 @@ class BfxMacUpdater extends MacUpdater {
const dist = path.join(root, '..')
const exec = path.join(root, 'Contents/MacOS/Bitfinex Report')

await fs.promises.rmdir(root, { recursive: true })
await fsPromises.rm(root, { recursive: true })

await extract(
downloadedFilePath,
Expand Down
6 changes: 2 additions & 4 deletions src/change-reports-folder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const electron = require('electron')
const { dialog, BrowserWindow } = require('electron')

const { CSV_PATH_VERSION } = require('./const')

Expand All @@ -14,10 +14,8 @@ const relaunch = require('./relaunch')
const { getConfigsKeeperByName } = require('./configs-keeper')

module.exports = ({ pathToUserDocuments }) => {
const dialog = electron.dialog || electron.remote.dialog

return async () => {
const win = electron.BrowserWindow.getFocusedWindow()
const win = BrowserWindow.getFocusedWindow()

try {
const {
Expand Down
6 changes: 2 additions & 4 deletions src/export-db.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const path = require('path')
const electron = require('electron')
const { dialog, BrowserWindow } = require('electron')

const { InvalidFilePathError } = require('./errors')
const { zip } = require('./archiver')
Expand All @@ -23,8 +23,6 @@ module.exports = ({
pathToUserData,
pathToUserDocuments
}) => {
const dialog = electron.dialog || electron.remote.dialog

const _timestamp = (new Date()).toISOString().split('.')[0]
const timestamp = _timestamp.replace(/[:]/g, '-')
const defaultPath = path.join(
Expand All @@ -37,7 +35,7 @@ module.exports = ({
const secretKeyPath = path.join(pathToUserData, SECRET_KEY_FILE_NAME)

return async () => {
const win = electron.BrowserWindow.getFocusedWindow()
const win = BrowserWindow.getFocusedWindow()

try {
const {
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/manage-window.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const electron = require('electron')
const { screen } = require('electron')

const hideWindow = (win, opts) => {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -74,7 +74,6 @@ const showWindow = (win, opts) => {
}

const centerWindow = (win, workArea) => {
const screen = electron.screen || electron.remote.screen
const {
getCursorScreenPoint,
getDisplayNearestPoint
Expand Down
6 changes: 2 additions & 4 deletions src/import-db.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const electron = require('electron')
const { dialog, BrowserWindow } = require('electron')

const {
InvalidFilePathError,
Expand Down Expand Up @@ -38,10 +38,8 @@ module.exports = ({
pathToUserData,
pathToUserDocuments
}) => {
const dialog = electron.dialog || electron.remote.dialog

return async () => {
const win = electron.BrowserWindow.getFocusedWindow()
const win = BrowserWindow.getFocusedWindow()

try {
const {
Expand Down
6 changes: 2 additions & 4 deletions src/relaunch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
const electron = require('electron')

module.exports = () => {
const app = electron.app || electron.remote.app

const options = {
args: process.argv.slice(1).concat(['--relaunch'])
}
Expand All @@ -14,6 +12,6 @@ module.exports = () => {
options.args.unshift('--appimage-extract-and-run')
}

app.relaunch(options)
app.exit(0)
electron.app.relaunch(options)
electron.app.exit(0)
}
5 changes: 2 additions & 3 deletions src/show-message-modal-dialog.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict'

const electron = require('electron')
const { dialog, BrowserWindow } = require('electron')

module.exports = async (win, opts = {}) => {
const dialog = electron.dialog || electron.remote.dialog
const _win = win && typeof win === 'object'
? win
: electron.BrowserWindow.getFocusedWindow()
: BrowserWindow.getFocusedWindow()

const {
response: btnId,
Expand Down
3 changes: 2 additions & 1 deletion src/window-creators.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ const _createWindow = async (
}

if (!pathname) {
await createLoadingWindow()
const props = await createLoadingWindow()
props.win.setAlwaysOnTop(true)

return res
}
Expand Down
10 changes: 4 additions & 6 deletions src/window-state-keeper.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict'

const electron = require('electron')
const { screen } = require('electron')

const { getConfigsKeeperByName } = require('./configs-keeper')

module.exports = (options) => {
const screen = electron.screen || electron.remote.screen

let state = null
let winRef = null
let stateChangeTimer = null
Expand All @@ -33,8 +31,8 @@ module.exports = (options) => {
}

const resetStateToDefault = () => {
const point = electron.screen.getCursorScreenPoint()
const displayBounds = electron.screen.getDisplayNearestPoint(point)
const point = screen.getCursorScreenPoint()
const displayBounds = screen.getDisplayNearestPoint(point)

state = {
width: config.defaultWidth || 800,
Expand All @@ -49,7 +47,7 @@ module.exports = (options) => {
const {
maxWidth,
maxHeight
} = electron.screen.getAllDisplays().reduce((
} = screen.getAllDisplays().reduce((
{ maxWidth, maxHeight },
{ workAreaSize: { width, height } }
) => {
Expand Down