-
Notifications
You must be signed in to change notification settings - Fork 814
/
Copy pathdeploy.ts
53 lines (44 loc) · 1.61 KB
/
deploy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { ipcMain, IpcMainEvent } from 'electron'
import Deploy from '../deploy'
import Renderer from '../renderer'
import SftpDeploy from '../plugins/deploys/sftp'
import GitHubDeploy from '../plugins/deploys/github'
export default class DeployEvents {
constructor(appInstance: any) {
const { platform } = appInstance.db.setting
const deploy = new Deploy(appInstance)
const sftp = new SftpDeploy(appInstance)
const github = new GitHubDeploy(appInstance)
const renderer = new Renderer(appInstance)
ipcMain.removeAllListeners('site-publish')
ipcMain.removeAllListeners('site-published')
ipcMain.removeAllListeners('remote-detect')
ipcMain.removeAllListeners('remote-detected')
ipcMain.on('site-publish', async (event: IpcMainEvent, params: any) => {
const client = ({
'github': github,
'coding': deploy,
'sftp': sftp,
} as any)[platform]
// render
console.time('site-publish-render')
renderer.db.themeConfig.domain = renderer.db.setting.domain
await renderer.renderAll()
console.timeEnd('site-publish-render')
// publish
console.time('site-publish')
const result = await client.publish()
console.timeEnd('site-publish')
event.sender.send('site-published', result)
})
ipcMain.on('remote-detect', async (event: IpcMainEvent, params: any) => {
const client = ({
'github': github,
'coding': deploy,
'sftp': sftp,
} as any)[platform]
const result = await client.remoteDetect()
event.sender.send('remote-detected', result)
})
}
}