Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Merge branch 'electron' into desktop-v3.22.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Sánchez committed Apr 1, 2022
2 parents 2365323 + 17abc4d commit 10baaab
Show file tree
Hide file tree
Showing 28 changed files with 1,989 additions and 39 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/release-mainnet-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ jobs:
fail-fast: false
max-parallel: 15
matrix:
os: [macos-10.15, windows-latest, ubuntu-18.04]
os: [macos-10.15, windows-2019, ubuntu-18.04]

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: 14

# Linux build patches
- name: Install linux dependencies
if: startsWith(matrix.os, 'ubuntu')
Expand All @@ -34,11 +39,6 @@ jobs:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v2
with:
node-version: 14

- name: Run yarn install
run: yarn install --frozen-lockfile --network-timeout 1000000

Expand Down
4 changes: 4 additions & 0 deletions dev-app-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
owner: gnosis
repo: safe-react
provider: github
updaterCacheDirName: safe-react-updater
98 changes: 96 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
"email": "safe@gnosis.io"
},
"homepage": "/app",
"main": "public/electron.js",
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"build-desktop": "yarn compile-electron && cross-env REACT_APP_BUILD_FOR_DESKTOP=true REACT_APP_ENV=production yarn build",
"build": "cross-env REACT_APP_APP_VERSION=$npm_package_version rescripts --max-old-space-size=8192 build",
"compile-electron": "tsc --project tsconfig.electron.json",
"eject": "rescripts eject",
"electron-build": "yarn compile-electron && electron-builder --mac",
"electron-dev": "yarn compile-electron && concurrently \"cross-env BROWSER=none REACT_APP_BUILD_FOR_DESKTOP=true yarn start\" \"wait-on http://localhost:3000 && ELECTRON_ENV=development electron .\"",
"format:staged": "lint-staged",
"generate-types": "yarn generate-types:spendingLimit && yarn generate-types:safeDeployments && yarn generate-types:erc20 && yarn generate-types:erc721",
"generate-types:erc20": "cross-env typechain --target=web3-v1 --out-dir './src/types/contracts' './node_modules/@openzeppelin/contracts/build/contracts/ERC20.json'",
Expand All @@ -28,10 +33,12 @@
"generate-types:safeDeployments": "cross-env typechain --target=web3-v1 --out-dir './src/types/contracts' ./node_modules/@gnosis.pm/safe-deployments/dist/assets/**/*.json",
"lint:check": "eslint './src/**/*.{js,jsx,ts,tsx}'",
"lint:fix": "yarn lint:check --fix",
"postinstall": "patch-package && yarn generate-types",
"postinstall": "patch-package && electron-builder install-app-deps && yarn generate-types",
"preelectron-pack": "yarn build",
"prettier:check": "yarn prettier --check",
"prettier:fix": "yarn prettier --write",
"prettier": "prettier './src/**/*.{js,jsx,ts,tsx}'",
"release": "electron-builder --mac --linux --windows -p always",
"start": "rescripts start",
"start:docker": "docker-compose build && docker-compose up",
"test": "REACT_APP_ENV=test rescripts test --env=jsdom",
Expand Down Expand Up @@ -63,7 +70,82 @@
"!src/**/assets/**"
]
},
"productName": "Safe",
"productName": "Safe Multisig",
"build": {
"appId": "io.gnosis.safe",
"afterSign": "scripts/notarize.js",
"extends": null,
"productName": "Safe",
"asar": true,
"publish": [
{
"provider": "github",
"owner": "gnosis",
"repo": "safe-react"
}
],
"dmg": {
"sign": false,
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"files": [
"build",
"patches",
"public",
"scripts",
"dev-app-update.yml",
"package.json"
],
"directories": {
"buildResources": "public/resources"
},
"mac": {
"category": "public.app-category.productivity",
"hardenedRuntime": true,
"entitlements": "public/resources/entitlements.mac.plist",
"gatekeeperAssess": false,
"entitlementsInherit": "public/resources/entitlements.mac.plist",
"target": [
"dmg",
"zip"
],
"publish": [
{
"provider": "github",
"owner": "gnosis",
"repo": "safe-react"
}
]
},
"nsis": {
"deleteAppDataOnUninstall": true
},
"linux": {
"category": "Finance",
"target": [
"AppImage",
"deb",
"zip"
]
},
"win": {
"target": [
"nsis"
],
"icon": "public/resources/icon.ico"
}
},
"resolutions": {
"@babel/core": "^7.14.0",
"sass-loader": "^9.0.0"
Expand All @@ -89,6 +171,7 @@
"@gnosis.pm/safe-react-components": "^1.1.2",
"@gnosis.pm/safe-react-gateway-sdk": "^2.10.1",
"@gnosis.pm/safe-web3-lib": "^1.0.0",
"@ledgerhq/hw-transport-node-hid-singleton": "6.20.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.0",
"@material-ui/lab": "4.0.0-alpha.60",
Expand All @@ -103,10 +186,15 @@
"classnames": "^2.2.6",
"currency-flags": "3.2.1",
"date-fns": "^2.20.2",
"detect-port": "^1.3.0",
"electron-log": "^4.4.3",
"electron-settings": "^4.0.2",
"electron-updater": "4.6.1",
"eth-sig-util": "^2.5.3",
"ethereumjs-abi": "0.6.8",
"ethereumjs-util": "^7.0.10",
"exponential-backoff": "^3.1.0",
"express": "^4.17.3",
"final-form": "^4.20.2",
"final-form-calculate": "^1.3.2",
"framer-motion": "^4.1.17",
Expand Down Expand Up @@ -153,6 +241,8 @@
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@typechain/web3-v1": "^3.0.0",
"@types/detect-port": "^1.3.2",
"@types/express": "^4.17.13",
"@types/history": "4.6.2",
"@types/jest": "^27.0.1",
"@types/js-cookie": "^2.2.7",
Expand All @@ -171,6 +261,9 @@
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"dotenv-expand": "^5.1.0",
"electron": "13.6.9",
"electron-builder": "22.14.13",
"electron-notarize": "1.1.1",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
Expand All @@ -188,6 +281,7 @@
"sass": "^1.32.0",
"typechain": "^5.1.2",
"typescript": "^4.3.5",
"usb-detection": "^4.10.0",
"wait-on": "^6.0.0"
}
}
77 changes: 77 additions & 0 deletions public/auto-updater/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { dialog } from 'electron'
import settings from 'electron-settings'
import log from 'electron-log'
import { autoUpdater } from 'electron-updater'

// This logging setup is not required for auto-updates to work,
// but it sure makes debugging easier :)
//-------------------------------------------------------------------

autoUpdater.autoDownload = false
autoUpdater.logger = log
log.info('App starting...')

let initialized = false
let downloadProgress = 0

function init() {
if (initialized) return

initialized = true

autoUpdater.on('error', (error) => {
log.error(error == null ? 'unknown' : (error.stack || error).toString())
})

autoUpdater.on('update-available', (info) => {
if (info.version === settings.get('release.version')) {
log.info(`Skipped version ${info.version}`)
return
}
dialog
.showMessageBox({
type: 'info',
title: 'Found Updates',
message: 'There is a newer version of this app available. Do you want to update now?',
detail: info.releaseNotes.replace(/(<([^>]+)>)/g, ''),
buttons: ['Install Update', 'Remind me later', 'Skip this version'],
cancelId: 1,
})
.then((result) => {
if (result.response === 0) {
autoUpdater.downloadUpdate()
}
if (result.response === 2) {
settings.set('release', { version: info.version })
}
})

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
autoUpdater.logger?.info('Update Downloaded...')
dialog
.showMessageBox({
title: 'Install Updates',
message: releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.',
buttons: ['Restart', 'Cancel'],
cancelId: 1,
})
.then((result) => {
if (result.response === 0) {
autoUpdater.quitAndInstall()
}
})
})
})

autoUpdater.on('download-progress', (d) => {
downloadProgress = d.percent
autoUpdater.logger?.info(downloadProgress)
})

autoUpdater.checkForUpdates()
}

module.exports = {
init,
}
Loading

0 comments on commit 10baaab

Please sign in to comment.