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

Upgrade to Electron 6 #8791

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ yarn-error.log
.idea/
.eslintcache
app/coverage
script/coverage
app/static/common
app/test/fixtures
gemoji
Expand Down
2 changes: 1 addition & 1 deletion app/.npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
runtime = electron
disturl = https://atom.io/download/electron
target = 5.0.6
target = 6.1.6
arch = x64
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "GitHub Desktop",
"bundleID": "com.github.GitHubClient",
"companyName": "GitHub, Inc.",
"version": "2.2.4",
"version": "2.3.0-test1",
"main": "./main.js",
"repository": {
"type": "git",
Expand Down Expand Up @@ -34,7 +34,7 @@
"fs-admin": "^0.3.1",
"fs-extra": "^6.0.0",
"fuzzaldrin-plus": "^0.6.0",
"keytar": "^4.4.1",
"keytar": "^4.13.0",
"mem": "^4.3.0",
"memoize-one": "^4.0.3",
"moment": "^2.24.0",
Expand Down
2 changes: 1 addition & 1 deletion app/src/crash/crash-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class CrashApp extends React.Component<ICrashAppProps, ICrashAppState> {

ipcRenderer.on(
'error',
(event: Electron.IpcMessageEvent, crashDetails: ICrashDetails) => {
(event: Electron.IpcRendererEvent, crashDetails: ICrashDetails) => {
this.setState(crashDetails)
}
)
Expand Down
2 changes: 1 addition & 1 deletion app/src/lib/app-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const shell: IAppShell = {
return new Promise<boolean>((resolve, reject) => {
ipcRenderer.once(
'open-external-result',
(event: Electron.IpcMessageEvent, { result }: { result: boolean }) => {
(event: Electron.IpcRendererEvent, { result }: { result: boolean }) => {
resolve(result)
}
)
Expand Down
4 changes: 2 additions & 2 deletions app/src/lib/stores/app-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
private wireupIpcEventHandlers(window: Electron.BrowserWindow) {
ipcRenderer.on(
windowStateChannelName,
(event: Electron.IpcMessageEvent, windowState: WindowState) => {
(event: Electron.IpcRendererEvent, windowState: WindowState) => {
this.windowState = windowState
this.emitUpdate()
}
Expand All @@ -520,7 +520,7 @@ export class AppStore extends TypedBaseStore<IAppState> {

ipcRenderer.on(
'app-menu',
(event: Electron.IpcMessageEvent, { menu }: { menu: IMenu }) => {
(event: Electron.IpcRendererEvent, { menu }: { menu: IMenu }) => {
this.setAppMenu(menu)
}
)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main-process/app-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class AppWindow {
quitting = true
})

ipcMain.on('will-quit', (event: Electron.IpcMessageEvent) => {
ipcMain.on('will-quit', (event: Electron.IpcMainEvent) => {
quitting = true
event.returnValue = true
})
Expand Down Expand Up @@ -142,7 +142,7 @@ export class AppWindow {
// TODO: This should be scoped by the window.
ipcMain.once(
'renderer-ready',
(event: Electron.IpcMessageEvent, readyTime: number) => {
(event: Electron.IpcMainEvent, readyTime: number) => {
this._rendererReadyTime = readyTime

this.maybeEmitDidLoad()
Expand Down
4 changes: 2 additions & 2 deletions app/src/main-process/crash-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class CrashWindow {
}
})

ipcMain.on('crash-ready', (event: Electron.IpcMessageEvent) => {
ipcMain.on('crash-ready', (event: Electron.IpcMainEvent) => {
log.debug(`Crash process is ready`)

this.hasSentReadyEvent = true
Expand All @@ -104,7 +104,7 @@ export class CrashWindow {
this.maybeEmitDidLoad()
})

ipcMain.on('crash-quit', (event: Electron.IpcMessageEvent) => {
ipcMain.on('crash-quit', (event: Electron.IpcMainEvent) => {
log.debug('Got quit signal from crash process')
this.window.close()
})
Expand Down
23 changes: 12 additions & 11 deletions app/src/main-process/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { showUncaughtException } from './show-uncaught-exception'
import { IMenuItem } from '../lib/menu-item'
import { buildContextMenu } from './menu/build-context-menu'

app.setAppLogsPath()
enableSourceMaps()

let mainWindow: AppWindow | null = null
Expand Down Expand Up @@ -288,7 +289,7 @@ app.on('ready', () => {

ipcMain.on(
'update-preferred-app-menu-item-labels',
(event: Electron.IpcMessageEvent, labels: MenuLabelsEvent) => {
(event: Electron.IpcMainEvent, labels: MenuLabelsEvent) => {
// The current application menu is mutable and we frequently
// change whether particular items are enabled or not through
// the update-menu-state IPC event. This menu that we're creating
Expand Down Expand Up @@ -361,7 +362,7 @@ app.on('ready', () => {
}
)

ipcMain.on('menu-event', (event: Electron.IpcMessageEvent, args: any[]) => {
ipcMain.on('menu-event', (event: Electron.IpcMainEvent, args: any[]) => {
const { name }: { name: MenuEvent } = event as any
if (mainWindow) {
mainWindow.sendMenuEvent(name)
Expand All @@ -374,7 +375,7 @@ app.on('ready', () => {
*/
ipcMain.on(
'execute-menu-item',
(event: Electron.IpcMessageEvent, { id }: { id: string }) => {
(event: Electron.IpcMainEvent, { id }: { id: string }) => {
const currentMenu = Menu.getApplicationMenu()

if (currentMenu === null) {
Expand All @@ -393,7 +394,7 @@ app.on('ready', () => {
ipcMain.on(
'update-menu-state',
(
event: Electron.IpcMessageEvent,
event: Electron.IpcMainEvent,
items: Array<{ id: string; state: IMenuItemState }>
) => {
let sendMenuChangedEvent = false
Expand Down Expand Up @@ -435,7 +436,7 @@ app.on('ready', () => {

ipcMain.on(
'show-contextual-menu',
(event: Electron.IpcMessageEvent, items: ReadonlyArray<IMenuItem>) => {
(event: Electron.IpcMainEvent, items: ReadonlyArray<IMenuItem>) => {
const menu = buildContextMenu(items, ix =>
event.sender.send('contextual-menu-action', ix)
)
Expand All @@ -458,7 +459,7 @@ app.on('ready', () => {
ipcMain.on(
'show-certificate-trust-dialog',
(
event: Electron.IpcMessageEvent,
event: Electron.IpcMainEvent,
{
certificate,
message,
Expand All @@ -475,22 +476,22 @@ app.on('ready', () => {

ipcMain.on(
'log',
(event: Electron.IpcMessageEvent, level: LogLevel, message: string) => {
(event: Electron.IpcMainEvent, level: LogLevel, message: string) => {
writeLog(level, message)
}
)

ipcMain.on(
'uncaught-exception',
(event: Electron.IpcMessageEvent, error: Error) => {
(event: Electron.IpcMainEvent, error: Error) => {
handleUncaughtException(error)
}
)

ipcMain.on(
'send-error-report',
(
event: Electron.IpcMessageEvent,
event: Electron.IpcMainEvent,
{
error,
extra,
Expand All @@ -510,7 +511,7 @@ app.on('ready', () => {

ipcMain.on(
'open-external',
async (event: Electron.IpcMessageEvent, { path }: { path: string }) => {
async (event: Electron.IpcMainEvent, { path }: { path: string }) => {
const pathLowerCase = path.toLowerCase()
if (
pathLowerCase.startsWith('http://') ||
Expand All @@ -533,7 +534,7 @@ app.on('ready', () => {

ipcMain.on(
'show-item-in-folder',
(event: Electron.IpcMessageEvent, { path }: { path: string }) => {
(event: Electron.IpcMainEvent, { path }: { path: string }) => {
Fs.stat(path, (err, stats) => {
if (err) {
log.error(`Unable to find file at '${path}'`, err)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main-process/menu/build-default-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function buildDefaultMenu({
},
separator,
{ role: 'hide' },
{ role: 'hideothers' },
{ role: 'hideOthers' },
{ role: 'unhide' },
separator,
{ role: 'quit' },
Expand Down
33 changes: 15 additions & 18 deletions app/src/main-process/show-uncaught-exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,21 @@ export function showUncaughtException(isLaunchError: boolean, error: Error) {
crashWindow.show()
})

crashWindow.onFailedToLoad(() => {
dialog.showMessageBox(
{
type: 'error',
title: __DARWIN__ ? `Unrecoverable Error` : 'Unrecoverable error',
message:
`GitHub Desktop has encountered an unrecoverable error and will need to restart.\n\n` +
`This has been reported to the team, but if you encounter this repeatedly please report ` +
`this issue to the GitHub Desktop issue tracker.\n\n${error.stack ||
error.message}`,
},
response => {
if (!__DEV__) {
app.relaunch()
}
app.quit()
}
)
crashWindow.onFailedToLoad(async () => {
await dialog.showMessageBox({
type: 'error',
title: __DARWIN__ ? `Unrecoverable Error` : 'Unrecoverable error',
message:
`GitHub Desktop has encountered an unrecoverable error and will need to restart.\n\n` +
`This has been reported to the team, but if you encounter this repeatedly please report ` +
`this issue to the GitHub Desktop issue tracker.\n\n${error.stack ||
error.message}`,
})

if (!__DEV__) {
app.relaunch()
}
app.quit()
})

crashWindow.onClose(() => {
Expand Down
3 changes: 2 additions & 1 deletion app/src/ui/add-repository/add-existing-repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ export class AddExistingRepository extends React.Component<

private showFilePicker = async () => {
const window = remote.getCurrentWindow()
const directory = remote.dialog.showOpenDialog(window, {
// eslint-disable-next-line no-sync
const directory = remote.dialog.showOpenDialogSync(window, {
properties: ['createDirectory', 'openDirectory'],
})
if (directory === undefined) {
Expand Down
3 changes: 2 additions & 1 deletion app/src/ui/add-repository/create-repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export class CreateRepository extends React.Component<

private showFilePicker = async () => {
const window = remote.getCurrentWindow()
const directory = remote.dialog.showOpenDialog(window, {
// eslint-disable-next-line no-sync
const directory = remote.dialog.showOpenDialogSync(window, {
properties: ['createDirectory', 'openDirectory'],
})

Expand Down
9 changes: 6 additions & 3 deletions app/src/ui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class App extends React.Component<IAppProps, IAppState> {

ipcRenderer.on(
'menu-event',
(event: Electron.IpcMessageEvent, { name }: { name: MenuEvent }) => {
(event: Electron.IpcRendererEvent, { name }: { name: MenuEvent }) => {
this.onMenuEvent(name)
}
)
Expand All @@ -241,7 +241,10 @@ export class App extends React.Component<IAppProps, IAppState> {

ipcRenderer.on(
'launch-timing-stats',
(event: Electron.IpcMessageEvent, { stats }: { stats: ILaunchStats }) => {
(
event: Electron.IpcRendererEvent,
{ stats }: { stats: ILaunchStats }
) => {
console.info(`App ready time: ${stats.mainReadyTime}ms`)
console.info(`Load time: ${stats.loadTime}ms`)
console.info(`Renderer ready time: ${stats.rendererReadyTime}ms`)
Expand All @@ -253,7 +256,7 @@ export class App extends React.Component<IAppProps, IAppState> {
ipcRenderer.on(
'certificate-error',
(
event: Electron.IpcMessageEvent,
event: Electron.IpcRendererEvent,
{
certificate,
error,
Expand Down
3 changes: 2 additions & 1 deletion app/src/ui/clone-repository/clone-repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ export class CloneRepository extends React.Component<

private onChooseDirectory = async () => {
const window = remote.getCurrentWindow()
const directories = remote.dialog.showOpenDialog(window, {
// eslint-disable-next-line no-sync
const directories = remote.dialog.showOpenDialogSync(window, {
properties: ['createDirectory', 'openDirectory'],
})

Expand Down
3 changes: 2 additions & 1 deletion app/src/ui/dispatcher/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@ export class Dispatcher {
*/
public async relocateRepository(repository: Repository): Promise<void> {
const window = remote.getCurrentWindow()
const directories = remote.dialog.showOpenDialog(window, {
// eslint-disable-next-line no-sync
const directories = remote.dialog.showOpenDialogSync(window, {
properties: ['openDirectory'],
})

Expand Down
2 changes: 1 addition & 1 deletion app/src/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ ipcRenderer.on('blur', () => {

ipcRenderer.on(
'url-action',
(event: Electron.IpcMessageEvent, { action }: { action: URLActionType }) => {
(event: Electron.IpcRendererEvent, { action }: { action: URLActionType }) => {
dispatcher.dispatchURLAction(action)
}
)
Expand Down
2 changes: 1 addition & 1 deletion app/src/ui/lib/ui-activity-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class UiActivityMonitor implements IUiActivityMonitor {
this.emit('keyboard')
}

private onMenuEvent = (event: Electron.IpcMessageEvent) => {
private onMenuEvent = (event: Electron.IpcRendererEvent) => {
this.emit('menu')
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/ui/main-process-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let currentContextualMenuItems: ReadonlyArray<IMenuItem> | null = null
export function registerContextualMenuActionDispatcher() {
ipcRenderer.on(
'contextual-menu-action',
(event: Electron.IpcMessageEvent, index: number) => {
(event: Electron.IpcRendererEvent, index: number) => {
if (!currentContextualMenuItems) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/ui/window/window-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class WindowControls extends React.Component<{}, IWindowControlState> {
}

private onWindowStateChanged = (
event: Electron.IpcMessageEvent,
event: Electron.IpcRendererEvent,
windowState: WindowState
) => {
this.setState({ windowState })
Expand Down
3 changes: 2 additions & 1 deletion app/styles/ui/_app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
&-contents {
display: flex;
flex-direction: column;
flex-grow: 1;
flex: 1 1 auto;
height: 100%;
}
}