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

Dependency upgrades #330

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04] # macOS-latest is disabled because of timeout issues
node-version: [16.x]
os: [ubuntu-20.04] # macOS-latest is disabled because of timeout issues
node-version: [18.x]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
# import simone's signing key
- run: curl -sSL https://github.com/bassosimone.gpg | gpg --import -
# import tor's signing key
- run: curl -sSL https://openpgpkey.torproject.org/.well-known/openpgpkey/torproject.org/hu/kounek7zrdx745qydx6p59t9mqjpuhdf | gpg --import -

- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v1
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -55,7 +55,7 @@ jobs:

- name: Upload screenshots as workflow artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: E2E-Screenshots
path: test/screenshots/**/*.png
2 changes: 0 additions & 2 deletions build/entitlements.mac.inherit.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion main/__tests__/actions_child_process_spawn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
showMeasurement,
} from '../actions'
import childProcess from 'child_process'
import log from 'electron-log'
import log from 'electron-log/main'
import Sentry from '@sentry/electron'

jest.mock('electron-util', () => ({
Expand Down
2 changes: 1 addition & 1 deletion main/__tests__/actions_resolved_data.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { listMeasurements, listResults, showMeasurement } from '../actions'
import log from 'electron-log'
import log from 'electron-log/main'
import Sentry from '@sentry/electron'
import { Ooniprobe } from '../utils/ooni/ooniprobe'

Expand Down
6 changes: 3 additions & 3 deletions main/actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { Ooniprobe } = require('./utils/ooni/ooniprobe')
const { getAutorunHomeDir } = require('./utils/paths')
const log = require('electron-log')
const Sentry = require('@sentry/electron')
const log = require('electron-log/main')
const Sentry = require('@sentry/electron/main')

const hardReset = () => {
const ooniHome = new Ooniprobe()
Expand Down Expand Up @@ -113,7 +113,7 @@ const showMeasurement = (msmtID) => {
Sentry.addBreadcrumb({
category: 'actions',
message: data.message,
level: Sentry.Severity.Error
level: 'error',
})
reject(data.message)
return
Expand Down
11 changes: 6 additions & 5 deletions main/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
// Packages
const initializeSentry = require('./utils/sentry')
// Get sentry up and running (if already)
initializeSentry()
const { app, Menu, ipcMain } = require('electron')
const prepareNext = require('electron-next')
const { is } = require('electron-util')
const isDev = require('electron-is-dev')
const fixPath = require('fix-path')
const Sentry = require('@sentry/electron')
const log = require('electron-log')
const Sentry = require('@sentry/electron/main')
const log = require('electron-log/main')
log.initialize()
log.transports.console.level = isDev ? 'debug' : 'info'
log.transports.file.level = 'debug'

const { getConfig, maybeMigrate, initConfigFile } = require('./utils/config')
const { mainWindow, openAboutWindow } = require('./windows')
const toggleWindow = require('./windows/toggle')
const { ipcBindingsForMain } = require('./ipcBindings')
const initializeSentry = require('./utils/sentry')
const store = require('./utils/store')
const updater = require('./updater')
const autorun = require('./utils/autorun/schedule')
Expand All @@ -26,8 +29,6 @@ if (!app.requestSingleInstanceLock()) {
log.info('Second instance not allowed. Quitting.')
app.quit()
}
// Get sentry up and running (if already)
initializeSentry()

// initialize store in app.getPath('userData')/settings.json
store.init()
Expand Down
2 changes: 1 addition & 1 deletion main/ipcBindings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { app } = require('electron')
const log = require('electron-log')
const log = require('electron-log/main')
const fs = require('fs-extra')
const { is } = require('electron-util')

Expand Down
2 changes: 1 addition & 1 deletion main/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

const { openAboutWindow } = require('./windows')
const log = require('electron-log')
const log = require('electron-log/main')
const { autoUpdater } = require('electron-updater')
const semver = require('semver')

Expand Down
2 changes: 1 addition & 1 deletion main/utils/__tests__/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
maybeMigrate,
} from '../config'

import log from 'electron-log'
import log from 'electron-log/main'
import fs from 'fs-extra'
import Sentry from '../sentry'

Expand Down
2 changes: 1 addition & 1 deletion main/utils/__tests__/store.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import log from 'electron-log'
import log from 'electron-log/main'
import Store from 'electron-store'
import { init, get, set, reset } from '../store'

Expand Down
3 changes: 1 addition & 2 deletions main/utils/autorun/mac-scheduler.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { app } = require('electron')
const { writeFile, unlink } = require('fs').promises
const { existsSync, writeFileSync } = require('fs-extra')
const { spawnSync } = require('child_process')
const { join } = require('path')
const os = require('os')
const log = require('electron-log')
const log = require('electron-log/main')

const { getAutorunHomeDir, getProbeBinaryPath, getTorBinaryPath } = require('../paths')

Expand Down
2 changes: 1 addition & 1 deletion main/utils/autorun/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const LATEST_AUTORUN_VERSION = 1
// Note: initConfigFile in turn initializes Sentry (again) with no extra effect
initConfigFile({ configFilePath: join(getAutorunHomeDir(), 'config.json') })

const log = require('electron-log')
const log = require('electron-log/main')
const winScheduler = require('./windows-scheduler')
const macScheduler = require('./mac-scheduler')
const taskId = process.env.npm_package_build_appId || 'org.ooni.probe-desktop'
Expand Down
4 changes: 2 additions & 2 deletions main/utils/autorun/windows-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ SOFTWARE.
// Based on: https://github.com/AndreaFranchini/windows-scheduler/blob/master/task.js

const { execSync } = require('child_process')
const log = require('electron-log')
const log = require('electron-log/main')
const { app } = require('electron')
const { join } = require('path')
const { getBinaryDirectory, getAutorunHomeDir, getProbeBinaryPath, getTorBinaryPath } = require('../paths')
const { getBinaryDirectory } = require('../paths')
const { writeFile, unlink } = require('fs').promises
const { taskXMLTemplate } = require('./taskTemplateWin')

Expand Down
2 changes: 1 addition & 1 deletion main/utils/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path')
const fs = require('fs-extra')
const log = require('electron-log')
const log = require('electron-log/main')

const { getHomeDir, getAutorunHomeDir } = require('./paths')

Expand Down
2 changes: 1 addition & 1 deletion main/utils/ooni/__tests__/ooniprobe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Ooniprobe } from '../ooniprobe'
import childProcess from 'child_process'
import log from 'electron-log'
import log from 'electron-log/main'
import pkgJson from '../../../../package.json'
import Sentry from '@sentry/electron'
import { Readable } from 'stream'
Expand Down
2 changes: 1 addition & 1 deletion main/utils/ooni/__tests__/run_child_process_spawn.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Runner } from '../run'
import childProcess from 'child_process'
import log from 'electron-log'
import log from 'electron-log/main'
import Sentry from '@sentry/electron'

jest.mock('electron-util', () => ({
Expand Down
4 changes: 2 additions & 2 deletions main/utils/ooni/ooniprobe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const { EventEmitter } = require('events')
const childProcess = require('child_process')
const os = require('os')
const path = require('path')
const log = require('electron-log')
const log = require('electron-log/main')
const { is } = require('electron-util')

const split2 = require('split2')

const Sentry = require('@sentry/electron')
const Sentry = require('@sentry/electron/main')

const { getProbeBinaryPath, getTorBinaryPath, getHomeDir } = require('../paths')
const pkgJson = require('../../../package.json')
Expand Down
2 changes: 1 addition & 1 deletion main/utils/ooni/run.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global windows */
const { Ooniprobe } = require('./ooniprobe')
const log = require('electron-log')
const log = require('electron-log/main')

class Runner {
constructor({testGroupName, inputFile = null}) {
Expand Down
2 changes: 1 addition & 1 deletion main/utils/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path')
const { is } = require('electron-util')
const electron = require('electron')
const log = require('electron-log')
const log = require('electron-log/main')

const getBinarySuffix = () => (process.platform === 'win32' ? '.exe' : '')

Expand Down
4 changes: 2 additions & 2 deletions main/utils/sentry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { init } = require('@sentry/electron')
const { init } = require('@sentry/electron/main')
const isDev = require('electron-is-dev')
const log = require('electron-log')
const log = require('electron-log/main')

const { name } = require('../../package.json')
const { getConfig } = require('../utils/config')
Expand Down
2 changes: 1 addition & 1 deletion main/utils/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Store = require('electron-store')
const log = require('electron-log')
const log = require('electron-log/main')

const schema = {
autorun: {
Expand Down
5 changes: 3 additions & 2 deletions main/windows/aboutWindow.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const electron = require('electron')
const windowURL = require('./windowURL')
const { join } = require('path')

let window = null

Expand All @@ -12,9 +13,9 @@ const aboutWindow = () => {
show: false,
backgroundColor: '#fff',
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
enableRemoteModule: true,
preload: join(__dirname, 'preload.js'),
sandbox: false,
}
})

Expand Down
108 changes: 108 additions & 0 deletions main/windows/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const { ipcRenderer } = require('electron')

module.exports = {
ooni: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('ooni', subscription)
return () => {
ipcRenderer.removeListener('ooni', subscription)
}
},
config: {
get: (data) => ipcRenderer.invoke('config.get', data),
getFreshConfig: () => ipcRenderer.invoke('get-fresh-config'),
set: (key, currentValue, value) => ipcRenderer.invoke('config.set', key, currentValue, value),
onboard: (crashReportsOptIn) => ipcRenderer.invoke('config.onboard', { crashReportsOptIn }),
categories: () => ipcRenderer.sendSync('config.categories')
},
ooniprobe: {
run: (testGroupToRun, inputFile) => ipcRenderer.send('ooniprobe.run', { testGroupToRun, inputFile }),
stop: () => ipcRenderer.send('ooniprobe.stop'),
runningTest: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('ooniprobe.running-test', subscription)
return () => {
ipcRenderer.removeAllListeners('ooniprobe.running-test', subscription)
}
},
done: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('ooniprobe.done', subscription)
return () => {
ipcRenderer.removeAllListeners('ooniprobe.done', subscription)
}
},
completed: (fn) => ipcRenderer.on('ooniprobe.completed', () => fn()),
error: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('ooniprobe.error', subscription)
return () => {
ipcRenderer.removeAllListeners('ooniprobe.error', subscription)
}
},
},
autorun: {
schedule: () => ipcRenderer.invoke('autorun.schedule'),
remindLater: () => ipcRenderer.send('autorun.remind-later'),
maybeRemind: () => ipcRenderer.send('autorun.maybe-remind'),
cancel: () => ipcRenderer.send('autorun.cancel'),
showPrompt: (fn) => {
const subscription = () => fn()
ipcRenderer.on('autorun.showPrompt', subscription)
return () => {
ipcRenderer.removeAllListeners('autorun.showPrompt', subscription)
}
},
removeShowPromptListeners: () => ipcRenderer.removeAllListeners('autorun.showPrompt'),
status: () => ipcRenderer.invoke('autorun.status'),
disable: () => ipcRenderer.invoke('autorun.disable')
},
about: {
reset: () => ipcRenderer.invoke('reset'),
debugGetAllPaths: () => ipcRenderer.sendSync('debugGetAllPaths'),
updateMessage: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('update-message', subscription)
return () => {
ipcRenderer.removeAllListeners('update-message', subscription)
}
},
updateProgress: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('update-progress', subscription)
return () => {
ipcRenderer.removeAllListeners('update-progress', subscription)
}
}
},
results: {
list: (resultID) => ipcRenderer.invoke('list-results', resultID),
showMeasurement: (msmtID) => ipcRenderer.invoke('show-measurement', msmtID),
last: {
request: (testGroupName) => ipcRenderer.send('results.last.request', { testGroupName }),
response: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('results.last.response', subscription)
return () => {
ipcRenderer.removeAllListeners('results.last.response', subscription)
}
},
},
},
prefs: {
get: (key) => ipcRenderer.sendSync('prefs.get', key),
save: (key, value) => ipcRenderer.sendSync('prefs.save', { key, value })
},
fs: {
write: {
request: (testListString) => ipcRenderer.send('fs.write.request', testListString),
response: (fn) => {
const subscription = (_, args) => fn(args)
ipcRenderer.on('fs.write.response', subscription)
return () => {
ipcRenderer.removeAllListeners('fs.write.response', subscription)
}
},
}
}
}
Loading
Loading