refactor: 增量更新,杀掉端口占用的进程

pull/67/head
xiaojunnuo 2021-04-03 23:43:03 +08:00
parent baf789c2da
commit 10ec91f3b0
10 changed files with 40 additions and 45 deletions

View File

@ -58,11 +58,6 @@
Windows: 请选择DevSidecar-x.x.x.exe
Mac: 请选择DevSidecar-x.x.x.dmg
* 阿里云直接下载http链接某些浏览器可能打不开请前往release下载
[windows版](http://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.exe)
[Mac版](http://dev-sidecar.docmirror.cn/update/DevSidecar-1.5.0.dmg)
#### 2 安装后打开

View File

@ -16,8 +16,9 @@ module.exports = {
// 'cdn.cypress.io': [{ regexp: '/desktop/.*', proxy: 'http://npm.taobao.org/mirrors/cypress/' }]
// },
variables: {
SASS_BINARY_SITE: 'https://npm.taobao.org/mirrors/node-sass/',
PHANTOMJS_CDNURL: 'https://npm.taobao.org/mirrors/phantomjs/',
phantomjs_cdnurl: 'https://npm.taobao.org/dist/phantomjs',
chromedriver_cdnurl: 'https://npm.taobao.org/mirrors/chromedriver',
sass_binary_site: 'https://npm.taobao.org/mirrors/node-sass',
ELECTRON_MIRROR: 'https://npm.taobao.org/mirrors/electron/',
// CYPRESS_DOWNLOAD_MIRROR: 'https://cdn.cypress.io',
NVM_NODEJS_ORG_MIRROR: 'https://npm.taobao.org/mirrors/node',

View File

@ -12,7 +12,8 @@ const executor = {
throw Error('暂未实现此功能')
},
async mac (exec, { port }) {
throw Error('暂未实现此功能')
await exec('kill `lsof -i:' + port + " |grep 'DevSide\\|Elect' |awk '{print $2}'`")
return true
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@docmirror/dev-sidecar-gui",
"version": "1.5.1",
"version": "1.5.0",
"private": false,
"license": "MPL-2.0",
"scripts": {

View File

@ -15,7 +15,7 @@ function appendIntro (context, systemType, latest) {
})
}
exports.default = async function (context) {
console.log('context222', context)
// console.log('context222', context)
appendIntro(context, 'mac', 'latest-mac.yml')
appendIntro(context, 'win', 'latest.yml')
}

View File

@ -2,7 +2,7 @@ const path = require('path')
const AdmZip = require('adm-zip')
const pkg = require('../package.json')
exports.default = async function (context) {
console.log('context', context)
// console.log('context', context)
let targetPath
let systemType = ''
if (context.packager.platform.nodeName === 'darwin') {

View File

@ -8,7 +8,6 @@ import fs from 'fs'
import AdmZip from 'adm-zip'
import logger from '../../utils/util.log'
import appPathUtil from '../../utils/util.apppath'
import DevSidecar from '@docmirror/dev-sidecar'
// eslint-disable-next-line no-unused-vars
const isMac = process.platform === 'darwin'
@ -49,18 +48,22 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
}
// 本地开发环境改变app-update.yml地址
if (process.env.NODE_ENV === 'development' && !isMac) {
autoUpdater.updateConfigPath = path.join(__dirname, 'win-unpacked/resources/app-update.yml')
autoUpdater.setFeedURL({
provider: 'generic',
url: 'http://localhost/dev-sidecar/'
})
if (isMac) {
autoUpdater.updateConfigPath = path.join(__dirname, 'mac/DevSidecar.app/Contents/Resources/app-update.yml')
} else {
autoUpdater.updateConfigPath = path.join(__dirname, 'win-unpacked/resources/app-update.yml')
}
}
autoUpdater.autoDownload = false
let partPackagePath = null
function downloadPart (app, value) {
const appPath = appPathUtil.getAppRootPath()
const appPath = appPathUtil.getAppRootPath(app)
const fileDir = path.join(appPath, 'update')
logger.info('download dir', fileDir)
try {
@ -87,11 +90,11 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
}
function updatePart (app, api, value, partPackagePath, quit) {
const appPath = appPathUtil.getAppRootPath()
const appPath = appPathUtil.getAppRootPath(app)
const platform = api.shell.getSystemPlatform()
let target = path.join(appPath, 'resources')
if (platform === 'mac') {
target = path.join(appPath, 'Contents/Resources')
target = path.join(appPath, 'Resources')
}
log.info('开始解压缩,安装升级包', partPackagePath, target)
@ -176,15 +179,13 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
export default {
install (context) {
const { app, win, beforeQuit, quit, log } = context
const { app, api, win, beforeQuit, quit, log } = context
if (process.env.NODE_ENV === 'development') {
Object.defineProperty(app, 'isPackaged', {
get () {
return true
}
})
// updateUrl = 'http://dev-sidecar.docmirror.cn/update/'
// updateUrl = 'http://localhost/dev-sidecar/'
}
updateHandle(app, api, win, beforeQuit, quit, log)
}

View File

@ -60,7 +60,21 @@ function install (app, api) {
// 有增量更新
api.update.downloadPart(value)
} else {
api.update.downloadUpdate()
api.shell.getSystemPlatform().then((platform) => {
if (platform === 'mac') {
app.$notification.open({
duration: 15,
message: 'Mac暂不支持全量自动升级',
description:
'请前往github或gitee项目release页面下载新版本手动安装',
onClick: () => {
}
})
return
}
api.update.downloadUpdate()
})
}
}
function foundNewVersion (value) {
@ -69,21 +83,6 @@ function install (app, api) {
if (updateParams.autoDownload !== false) {
app.$message.info('发现新版本,正在下载中...')
updateParams.downloading = true
api.shell.getSystemPlatform().then((platform) => {
if (platform === 'mac') {
app.$notification.open({
duration: 10,
message: 'Mac暂不支持自动升级',
description:
'请前往github或gitee项目主页下载新版本手动安装听说苹果对于Electron开发的应用审核不好过。。。。好吧我承认是因为没有钱买苹果开发者账号┓( ´∀` )┏',
onClick: () => {
}
})
}
})
downloadNewVersion(value)
return
}

View File

@ -1,13 +1,11 @@
import path from 'path'
// const isDevelopment = process.env.NODE_ENV !== 'production'
const isDevelopment = process.env.NODE_ENV !== 'production'
export default {
getAppRootPath () {
// if (isDevelopment) {
// return app.getAppPath()
// } else {
// return path.join(app.getAppPath(), '../../')
// }
return path.resolve('.')
getAppRootPath (app) {
if (isDevelopment) {
return app.getAppPath()
} else {
return path.join(app.getAppPath(), '../../')
}
}
}

View File

@ -63,7 +63,7 @@ module.exports = {
publish: {
provider: 'generic',
// url: 'http://dev-sidecar.docmirror.cn/update/'
url: 'http://localhost/dev-sidecar/'
url: 'http://dev-sidecar.docmirror.cn/update/preview/'
}
},
chainWebpackMainProcess (config) {