引用平台log
This commit is contained in:
parent
9bd714534e
commit
28c6de1af4
|
@ -107,7 +107,6 @@
|
|||
"yauzl": "^2.9.2",
|
||||
"yazl": "^2.4.3",
|
||||
"axios": "^1.6.1",
|
||||
"log4js": "^6.9.1",
|
||||
"async-mutex": "^0.4.0",
|
||||
"@azure/abort-controller": "^1.0.0"
|
||||
},
|
||||
|
@ -223,7 +222,6 @@
|
|||
"xml2js": "^0.5.0",
|
||||
"yaserver": "^0.4.0",
|
||||
"axios": "^1.6.1",
|
||||
"log4js": "^6.9.1",
|
||||
"async-mutex": "^0.4.0",
|
||||
"@azure/abort-controller": "^1.0.0"
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as fs from 'fs'
|
||||
import { logger } from 'vs/platform/issue/electron-main/logger';
|
||||
// import { logger } from 'vs/platform/issue/electron-main/logger';
|
||||
//读取JSON数据,并将其转换为对象格式
|
||||
/**
|
||||
*
|
||||
|
@ -7,13 +7,13 @@ import { logger } from 'vs/platform/issue/electron-main/logger';
|
|||
* @returns 对象
|
||||
*/
|
||||
export function readJSON(filePath: string): any {
|
||||
logger.debug("readJSON");
|
||||
// logger.debug("readJSON");
|
||||
try {
|
||||
logger.debug("readJSON" + filePath);
|
||||
// logger.debug("readJSON" + filePath);
|
||||
let Object = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
||||
return Object;
|
||||
} catch {
|
||||
logger.debug("readJSON,null");
|
||||
// logger.debug("readJSON,null");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ export function getKeyObject(key: string, JSONObject: any): any {
|
|||
*/
|
||||
export function getListGoFromKey(key: string, filePath: string): any[] {
|
||||
|
||||
logger.debug("getListGoFromKey");
|
||||
// logger.debug("getListGoFromKey");
|
||||
|
||||
let goInfoArry: any[] = [];
|
||||
const JSONObject = readJSON(filePath);
|
||||
|
@ -54,10 +54,10 @@ export function getListGoFromKey(key: string, filePath: string): any[] {
|
|||
goInfoArry.push(tmp);
|
||||
})
|
||||
}
|
||||
goInfoArry.forEach(function (item) {
|
||||
logger.debug("getListGoFromKey" + item.url);
|
||||
});
|
||||
logger.debug("getListGoFromKey,end");
|
||||
// goInfoArry.forEach(function (item) {
|
||||
// logger.debug("getListGoFromKey" + item.url);
|
||||
// });
|
||||
// logger.debug("getListGoFromKey,end");
|
||||
return goInfoArry;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ import { IDiagnosticsMainService } from 'vs/platform/diagnostics/electron-main/d
|
|||
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService';
|
||||
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
|
||||
import { IDeployMainService, DeployWindowConfiguration, DeployData } from 'vs/platform/issue/common/deploy';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { ILogService, ILogger } from 'vs/platform/log/common/log';
|
||||
import { ILoggerMainService } from 'vs/platform/log/electron-main/loggerService';
|
||||
import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
|
@ -40,7 +41,7 @@ import { platform } from 'vs/base/common/process';
|
|||
import { join } from 'vs/base/common/path';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { logger } from 'vs/platform/issue/electron-main/logger';
|
||||
// import { logger } from 'vs/platform/issue/electron-main/logger';
|
||||
import * as installUtils from 'vs/platform/issue/electron-main/installUtils';
|
||||
import * as pathUtils from 'vs/platform/issue/electron-main/pathUtils';
|
||||
import * as configUtils from 'vs/platform/issue/electron-main/configUtils';
|
||||
|
@ -52,7 +53,6 @@ import axios from "axios";
|
|||
import { spawn, ChildProcess } from 'child_process';
|
||||
import { AbortController } from "@azure/abort-controller";
|
||||
|
||||
|
||||
const deployWindowState = 'deploy.deployWindowState';
|
||||
interface IBrowserWindowOptions {
|
||||
backgroundColor: string | undefined;
|
||||
|
@ -135,10 +135,12 @@ export class DeployMainService implements IDeployMainService {
|
|||
};
|
||||
|
||||
startInstallDepWatch = 0;
|
||||
logger: ILogger;
|
||||
|
||||
constructor(
|
||||
private userEnv: IProcessEnvironment,
|
||||
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
|
||||
@ILoggerMainService private readonly loggerMainService: ILoggerMainService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService,
|
||||
@IDiagnosticsMainService private readonly diagnosticsMainService: IDiagnosticsMainService,
|
||||
|
@ -162,21 +164,37 @@ export class DeployMainService implements IDeployMainService {
|
|||
this.logFile0 = this.installConfig + '/log/install.1.log';
|
||||
this.resultFile = this.installConfig + '/resultFile';
|
||||
this.extLogFile0 = this.installConfig + '/log/extInstall.1.log';
|
||||
this.logger = loggerMainService.createLogger(URI.file(this.installConfig + "/log/installguide.log"));
|
||||
this.removeListeners();
|
||||
this.registerListeners();
|
||||
}
|
||||
//#region Register Listeners
|
||||
|
||||
listenerShow = (event: IpcMainEvent, msg: any) => {
|
||||
if (msg.type === 'info') {
|
||||
if (this.DeployWindow)
|
||||
dialog.showMessageBox(this.DeployWindow, {
|
||||
type: 'info',
|
||||
title: msg.title,
|
||||
message: msg.message,
|
||||
});
|
||||
}
|
||||
|
||||
this.logger.info("显示窗口");
|
||||
// this.showWindow();
|
||||
};
|
||||
|
||||
listenerHelpLink = (event: IpcMainEvent) => {
|
||||
logger.info("打开帮助页面");
|
||||
// logger.info("打开帮助页面");
|
||||
this.logger.info("打开帮助页面");
|
||||
this.openHelpLink();
|
||||
};
|
||||
listenerMiniWindow = (event: IpcMainEvent) => {
|
||||
logger.info("最小化窗口");
|
||||
this.logger.info("最小化窗口");
|
||||
this.minWindow();
|
||||
};
|
||||
listenerCloseWindow = (event: IpcMainEvent) => {
|
||||
logger.info("关闭窗口");
|
||||
this.logger.info("关闭窗口");
|
||||
this.closeWindow();
|
||||
};
|
||||
|
||||
|
@ -290,12 +308,15 @@ export class DeployMainService implements IDeployMainService {
|
|||
else if (msg.type === 'installScript') {
|
||||
if (msg.script['file_name'].endsWith(".js")) {
|
||||
try {
|
||||
await this.loadAndInvokeFunction(this.selectObject.dirPath + '/' + msg.script['file_name'], "main");
|
||||
const resarry = await this.loadAndInvokeFunction(this.selectObject.dirPath + '/' + msg.script['file_name'], "main");
|
||||
const scriptMsg = {
|
||||
type: "scriptExecSucc",
|
||||
type: resarry[1] === 0 ? "scriptExecSucc" : "scriptExecFail",
|
||||
depName: msg.script['file_name']
|
||||
};
|
||||
logger.info("脚本执行成功" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
if (resarry[1] === 0)
|
||||
this.logger.info("脚本执行成功" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
else
|
||||
this.logger.info("脚本执行失败" + this.selectObject.dirPath + '/' + msg.script['file_name'] + resarry[0]);
|
||||
if (this.DeployWindow)
|
||||
this.DeployWindow.webContents.send("kylinide.installWizard.msg", scriptMsg)
|
||||
} catch {
|
||||
|
@ -303,7 +324,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
type: "scriptExecFail",
|
||||
depName: msg.script['file_name']
|
||||
};
|
||||
logger.info("脚本执行失败" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
this.logger.info("脚本执行失败" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
if (this.DeployWindow)
|
||||
this.DeployWindow.webContents.send("kylinide.installWizard.msg", scriptMsg)
|
||||
}
|
||||
|
@ -315,7 +336,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
type: "scriptExecSucc",
|
||||
depName: msg.script['file_name']
|
||||
};
|
||||
logger.info("脚本执行成功" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
this.logger.info("脚本执行成功" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
if (this.DeployWindow)
|
||||
this.DeployWindow.webContents.send("kylinide.installWizard.msg", scriptMsg)
|
||||
}).catch(error => {
|
||||
|
@ -323,7 +344,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
type: "scriptExecFail",
|
||||
depName: msg.script['file_name']
|
||||
};
|
||||
logger.info("脚本执行失败" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
this.logger.info("脚本执行失败" + this.selectObject.dirPath + '/' + msg.script['file_name']);
|
||||
if (this.DeployWindow)
|
||||
this.DeployWindow.webContents.send("kylinide.installWizard.msg", scriptMsg)
|
||||
});
|
||||
|
@ -343,7 +364,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
sudokill.on('exit', (code, signal) => {
|
||||
if (code == 127) {
|
||||
console.log('授权失败', code);
|
||||
logger.error("取消安装授权失败");
|
||||
this.logger.error("取消安装授权失败");
|
||||
} else {
|
||||
if (this.DeployWindow) {
|
||||
this.DeployWindow.webContents.send("kylinide.installWizard.removeFileLister", { type: 'installFile' });
|
||||
|
@ -377,7 +398,219 @@ export class DeployMainService implements IDeployMainService {
|
|||
}
|
||||
|
||||
};
|
||||
listenerDepInfo = (event: IpcMainEvent, msg: any) => {
|
||||
|
||||
handleInitConfigVersify = async (event: IpcMainInvokeEvent, msg: any) => {
|
||||
//start configverify
|
||||
// updateConfigDir = msg.dst;
|
||||
let selectPageShow = 0;
|
||||
let message: string = "";
|
||||
this.logger.info("开始校验本地数据");
|
||||
this.localConfigObject = await this.localConfigVerify(this.localConfigDir, this.productService.IDEVersion);
|
||||
this.logger.info("本地数据校验结束");
|
||||
this.logger.info("开始下载校验网络数据");
|
||||
this.updateConfigObject = await this.downloadAndVerify(this.updateConfigDir, msg);
|
||||
this.logger.info("网络数据校验结束");
|
||||
//1.本地error ,net error -1;
|
||||
//2.本地error,net right 1;
|
||||
//3.本地 right ,net error 2;
|
||||
//4.本地right ,net right ,== 3
|
||||
//5.本地right ,net right , != 4
|
||||
//for test
|
||||
if (this.localConfigObject.res != 0 && this.updateConfigObject.res != 0) {
|
||||
if (this.DeployWindow) {
|
||||
if (this.localConfigObject.osinfo == "undefined" && this.updateConfigObject.osinfo == "undefined") {
|
||||
this.logger.error("安装引导器仅支持openKylin操作系统,脚本根据/etc/os-release信息判断操作系统类型");
|
||||
await dialog.showMessageBox(this.DeployWindow,
|
||||
{
|
||||
type: "error",
|
||||
title: "配置文件检查",
|
||||
buttons: ["OK"],
|
||||
detail: `点击【OK】按钮后,将跳过此引导步骤,请根据开发需要自行下载插件、安装软件依赖。具体信息请查看日志${this.installConfig}/log/instguide.log`,
|
||||
message: "安装引导器不支持当前系统。"
|
||||
});
|
||||
if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
this.DeployWindow.close();
|
||||
// .then(result => {
|
||||
// if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
// this.DeployWindow.close();
|
||||
// resolve(void 0);
|
||||
// })
|
||||
return void 0;
|
||||
} else {
|
||||
this.logger.error("本地数据及网络数据校验失败");
|
||||
await dialog.showMessageBox(this.DeployWindow,
|
||||
{
|
||||
type: "error",
|
||||
title: "配置文件检查",
|
||||
buttons: ["OK"],
|
||||
detail: `点击【OK】按钮后,将跳过此引导步骤,请根据开发需要自行下载插件、安装软件依赖。具体信息请查看日志${this.installConfig}/log/instguide.log`,
|
||||
message: "本地数据及网络数据校验失败"
|
||||
});
|
||||
if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
this.DeployWindow.close();
|
||||
return void 0;
|
||||
// .then(result => {
|
||||
// if (this.DeployWindow && this.DeployWindow != undefined)
|
||||
// this.DeployWindow.close();
|
||||
// resolve(void 0);
|
||||
// })
|
||||
}
|
||||
}
|
||||
selectPageShow = -1;
|
||||
} else {
|
||||
|
||||
if (this.localConfigObject.res != 0 && this.updateConfigObject.res == 0) {
|
||||
|
||||
selectPageShow = 1;
|
||||
if (this.localConfigObject.osinfo == "undefined") {
|
||||
message = "本地配置文件不支持当前环境,选择更新选项";
|
||||
this.logger.error(message);
|
||||
} else {
|
||||
message = "本地配置文件已损坏,选择更新选项";
|
||||
this.logger.error("本地数据校验失败");
|
||||
}
|
||||
|
||||
} else if (this.localConfigObject.res == 0 && this.updateConfigObject.res != 0) {
|
||||
if (this.updateConfigObject.osinfo == "undefined") {
|
||||
message = "联网数据文件不支持当前环境";
|
||||
this.logger.error(message);
|
||||
} else {
|
||||
message = "网络数据文件校验失败";
|
||||
this.logger.error(message);
|
||||
}
|
||||
selectPageShow = 2;
|
||||
} else if (this.localConfigObject.res == 0 && this.updateConfigObject.res == 0) {
|
||||
if (installUtils.compareVersions(this.updateConfigObject.g_index_Object.ver, this.localConfigObject.g_index_Object.ver) > 0) {
|
||||
//显示询问用户是否更新配置文件
|
||||
//比较具体的配置文件是否一致,若是一致则还是选择本地配置,若是不同则
|
||||
let updateosinfo = this.updateConfigObject.osinfo;
|
||||
let localosinfo = this.localConfigObject.osinfo;
|
||||
if (this.updateConfigObject.g_index_Object["config-file"][updateosinfo][0]['sign-md5'] !== this.localConfigObject.g_index_Object["config-file"][localosinfo][0]['sign-md5'])
|
||||
selectPageShow = 4;
|
||||
else {
|
||||
this.logger.info("联网数据与本地配置文件数据版本一致");
|
||||
selectPageShow = 3;
|
||||
message = "联网数据与本地配置文件数据版本一致";
|
||||
}
|
||||
} else {
|
||||
selectPageShow = 3;
|
||||
this.logger.info("联网数据与本地配置文件数据版本一致");
|
||||
message = "联网数据与本地配置文件数据版本一致";
|
||||
}
|
||||
}
|
||||
console.log("selectPageShow:" + selectPageShow);
|
||||
let Data;
|
||||
if (selectPageShow == 0) {
|
||||
this.selectObject.depInfoJsonPath = this.localConfigDir + "/" + this.localConfigObject.depConfigInfo['file_name'];
|
||||
this.selectObject.extAddressPath = this.localConfigDir + "/" + this.localConfigObject.g_index_Object['ext-file']['file_name'];
|
||||
Data = {
|
||||
osinfo: this.localConfigObject.osinfo,
|
||||
selectPageShow: selectPageShow,
|
||||
type: "configVersify"
|
||||
}
|
||||
|
||||
} else {
|
||||
Data = {
|
||||
localConfigObject: this.localConfigObject,
|
||||
updateConfigObject: this.updateConfigObject,
|
||||
selectPageShow: selectPageShow,
|
||||
message: message,
|
||||
type: "configVersify"
|
||||
}
|
||||
}
|
||||
if (this.DeployWindow) {
|
||||
return Data;
|
||||
} else {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
handleInitConfigSelect = async (event: IpcMainInvokeEvent, msg: any) => {
|
||||
let osinfo = "";
|
||||
if (msg.select === "local") {
|
||||
osinfo = this.localConfigObject.osinfo;
|
||||
this.selectObject.dirPath = this.localConfigDir;
|
||||
this.selectObject.updateFlag = false;
|
||||
this.selectObject.depInfoJsonPath = this.localConfigDir + "/" + this.localConfigObject.depConfigInfo['file_name'];
|
||||
this.selectObject.extAddressPath = this.localConfigDir + "/" + this.localConfigObject.g_index_Object['ext-file']['file_name'];
|
||||
} else if (msg.select === "update") {
|
||||
this.selectObject.dirPath = this.updateConfigDir;
|
||||
this.selectObject.updateFlag = true;
|
||||
osinfo = this.updateConfigObject.osinfo;
|
||||
this.selectObject.depInfoJsonPath = this.updateConfigDir + "/" + this.updateConfigObject.depConfigInfo['file_name'];
|
||||
this.selectObject.extAddressPath = this.updateConfigDir + "/" + this.updateConfigObject.g_index_Object['ext-file']['file_name']; //error
|
||||
|
||||
}
|
||||
const { osFile, data } = this.readOSInfo();
|
||||
const osObject = {
|
||||
type: "osinfo",
|
||||
osinfo: osinfo,
|
||||
osFile: osFile,
|
||||
osData: data
|
||||
}
|
||||
this.logger.info(`选择的配置文件名称:${this.selectObject.depInfoJsonPath}`);
|
||||
this.logger.info(`识别操作系统信息:${osinfo}`);
|
||||
|
||||
if (this.DeployWindow) {
|
||||
// this.DeployWindow.webContents.send('kylinide.installWizard.init', osObject);
|
||||
return osObject;
|
||||
}
|
||||
else {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
|
||||
handleInitConfigGetValue = async (event: IpcMainInvokeEvent, msg: any) => {
|
||||
|
||||
const selectJson = installUtils.selectFileJson();
|
||||
let selectKey: string[];
|
||||
if (selectJson && selectJson.hasOwnProperty('selectKey'))
|
||||
selectKey = selectJson['selectKey'];
|
||||
else { selectKey = []; }
|
||||
const Data = {
|
||||
type: "configGetValue",
|
||||
depInfoData: JSON.parse(fs.readFileSync(this.selectObject.depInfoJsonPath, 'utf-8')),
|
||||
depInfoJsonPath: this.selectObject.depInfoJsonPath,
|
||||
extAddressPath: this.selectObject.extAddressPath,
|
||||
selectKey: selectKey ? selectKey : []
|
||||
}
|
||||
if (this.DeployWindow) {
|
||||
// if (msg.class === "install")
|
||||
// this.DeployWindow.webContents.send('kylinide.installWizard.init', Data);
|
||||
// else if (msg.class === "download") {
|
||||
// this.DeployWindow.webContents.send('kylinide.installWizard.justDownLoad', Data); // todo
|
||||
// }
|
||||
return Data;
|
||||
}
|
||||
else {
|
||||
return void 0;
|
||||
}
|
||||
};
|
||||
|
||||
handleHttpVerify = async (event: IpcMainInvokeEvent, msg: any) => {
|
||||
|
||||
try {
|
||||
await this.checkHttp();
|
||||
console.log("ipc main kylinide.installWizard.init httpVerify");
|
||||
// this.DeployWindow?.webContents.send('kylinide.installWizard.init', { type: "httpVerify" });
|
||||
return { type: "httpVerify" };
|
||||
// this.safeSend(event, 'kylinide.installWizard.init', { type: "httpVerify" });
|
||||
} catch (error) {
|
||||
if (this.DeployWindow) {
|
||||
dialog.showMessageBox(this.DeployWindow,
|
||||
{
|
||||
type: "error",
|
||||
title: "网络检查",
|
||||
message: "网络异常,无法使用在线安装"
|
||||
});
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
//联网下载、检查、校验配置
|
||||
};
|
||||
|
||||
handleDepList = async (event: IpcMainInvokeEvent, msg: any) => {
|
||||
this.depList = [];
|
||||
this.extList = [];
|
||||
// scriptList = [];
|
||||
|
@ -1020,7 +1253,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
|
||||
|
||||
const listenerSkipWizard = async (event: IpcMainEvent) => {
|
||||
logger.info("跳过配置");
|
||||
this.logger.info("跳过配置");
|
||||
if (this.DeployWindow && this.DeployWindow != undefined) {
|
||||
this.DeployWindow.close();
|
||||
resolve(void 0);
|
||||
|
@ -1030,51 +1263,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
);
|
||||
const listenerInit = async (event: IpcMainEvent, msg: any) => {
|
||||
console.log("main on kylinide.installWizard.init");
|
||||
if (msg.type === "httpVerify") {
|
||||
this.checkHttp().then(async res => {
|
||||
console.log("ipc main kylinide.installWizard.init httpVerify");
|
||||
this.DeployWindow?.webContents.send('kylinide.installWizard.init', { type: "httpVerify" });
|
||||
// this.safeSend(event, 'kylinide.installWizard.init', { type: "httpVerify" });
|
||||
}
|
||||
).catch(error => {
|
||||
const msg = {
|
||||
type: "internetError",
|
||||
title: "网络检查",
|
||||
message: "网络异常,无法使用在线安装"
|
||||
}
|
||||
if (this.DeployWindow) {
|
||||
dialog.showMessageBox(this.DeployWindow,
|
||||
{
|
||||
type: "error",
|
||||
title: "网络检查",
|
||||
message: "网络异常,无法使用在线安装"
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
//联网下载、检查、校验配置
|
||||
}
|
||||
else if (msg.type === "configGetValue") {
|
||||
const selectJson = installUtils.selectFileJson();
|
||||
let selectKey: string[];
|
||||
if (selectJson && selectJson.hasOwnProperty('selectKey'))
|
||||
selectKey = selectJson['selectKey'];
|
||||
else { selectKey = []; }
|
||||
const Data = {
|
||||
type: "configGetValue",
|
||||
depInfoData: JSON.parse(fs.readFileSync(this.selectObject.depInfoJsonPath, 'utf-8')),
|
||||
depInfoJsonPath: this.selectObject.depInfoJsonPath,
|
||||
extAddressPath: this.selectObject.extAddressPath,
|
||||
selectKey: selectKey ? selectKey : []
|
||||
}
|
||||
if (this.DeployWindow) {
|
||||
if (msg.class === "install")
|
||||
this.DeployWindow.webContents.send('kylinide.installWizard.init', Data);
|
||||
else if (msg.class === "download") {
|
||||
this.DeployWindow.webContents.send('kylinide.installWizard.justDownLoad', Data);
|
||||
}
|
||||
}
|
||||
} else if (msg.type === "writeJson") {
|
||||
if (msg.type === "writeJson") {
|
||||
if (this.selectObject.updateFlag) {
|
||||
installUtils.modifyJsonProperty(this.installConfig + "/" + "selectFile.json", "selectDir", this.updateConfigDir);
|
||||
} else {
|
||||
|
@ -1201,7 +1390,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
|
||||
checkHttp() {
|
||||
return new Promise((resolve, reject) => {
|
||||
logger.info("检查网络联通情况");
|
||||
this.logger.info("检查网络联通情况");
|
||||
const options = {
|
||||
host: 'www.baidu.com',
|
||||
port: 80,
|
||||
|
@ -1210,20 +1399,20 @@ export class DeployMainService implements IDeployMainService {
|
|||
const req = http.get(options, (res: any) => {
|
||||
if (res.statusCode === 200) {
|
||||
resolve(200);
|
||||
logger.info("网络联通正常");
|
||||
this.logger.info("网络联通正常");
|
||||
} else {
|
||||
reject(res.statusCode)
|
||||
logger.info('无法访问网络');
|
||||
this.logger.info('无法访问网络');
|
||||
}
|
||||
});
|
||||
|
||||
req.setTimeout(5000, () => {
|
||||
reject(-1);
|
||||
logger.error('网络请求验证超时');
|
||||
this.logger.error('网络请求验证超时');
|
||||
});
|
||||
req.on('error', (error) => {
|
||||
reject(error);
|
||||
logger.error('网络链接发生错误:', error);
|
||||
this.logger.error('网络链接发生错误:', error);
|
||||
});
|
||||
req.end();
|
||||
})
|
||||
|
@ -1263,9 +1452,9 @@ export class DeployMainService implements IDeployMainService {
|
|||
verify.update(md5data);
|
||||
const isVerified = verify.verify(publicKey, signature, 'hex');
|
||||
if (isVerified) {
|
||||
logger.info("签名验证成功:" + dataPath);
|
||||
this.logger.info("签名验证成功:" + dataPath);
|
||||
} else {
|
||||
logger.info("签名验证失败:" + dataPath);
|
||||
this.logger.info("签名验证失败:" + dataPath);
|
||||
}
|
||||
return isVerified
|
||||
}
|
||||
|
@ -1286,7 +1475,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
return new Promise((resolve, reject) => {
|
||||
writer.on('finish', () => {
|
||||
// console.log('文件已下载到本地:', dst);
|
||||
logger.info("文件下载成功:" + dst);
|
||||
this.logger.info("文件下载成功:" + dst);
|
||||
resolve(0);
|
||||
});
|
||||
|
||||
|
@ -1299,14 +1488,14 @@ export class DeployMainService implements IDeployMainService {
|
|||
});
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error("文件下载失败:" + dst);
|
||||
this.logger.error("文件下载失败:" + dst);
|
||||
if (axios.isCancel(error)) {
|
||||
logger.error('请求已取消');
|
||||
this.logger.error('请求已取消');
|
||||
}
|
||||
else if (error.code === 'ECONNABORTED') {
|
||||
logger.error("请求超时");
|
||||
this.logger.error("请求超时");
|
||||
} else {
|
||||
logger.error('请求发生错误', error.message);
|
||||
this.logger.error('请求发生错误', error.message);
|
||||
}
|
||||
return Promise.reject(-1);
|
||||
}
|
||||
|
@ -1336,12 +1525,12 @@ export class DeployMainService implements IDeployMainService {
|
|||
//执行脚本,获取操作系统信息
|
||||
const functionName = 'getosinfo';
|
||||
const osinfo = await this.loadAndInvokeFunction(match_script_filePath, functionName);
|
||||
logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osinfo);
|
||||
this.logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osinfo);
|
||||
let localConfigMatch = 0;
|
||||
// 检测文件是否有osinfo想匹配的
|
||||
if (g_index_localDataObject["config-file"].hasOwnProperty(`${osinfo}`)) {
|
||||
if (installUtils.compareVersions(g_index_localDataObject['config-file'][osinfo][0]["kylin-ide-lowest-ver"], IDEVersion) == 1) {
|
||||
logger.info("本地配置文件版本与当前ide版本不兼容");
|
||||
this.logger.info("本地配置文件版本与当前ide版本不兼容");
|
||||
flag++;
|
||||
} else {
|
||||
if (!this.versify(path.join(installUtils.localConfigPath(), `${g_index_localDataObject['config-file'][osinfo][0]['file_name']}`), `${g_index_localDataObject['config-file'][osinfo][0]['sign-md5']}`)) {
|
||||
|
@ -1362,7 +1551,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
file_name = object[i]["file_name"];
|
||||
sign_md5 = object[i]["sign-md5"];
|
||||
if (!this.versify(path.join(configDir, file_name), sign_md5)) {
|
||||
logger.error(path.join(configDir, file_name) + "文件校验失败");
|
||||
this.logger.error(path.join(configDir, file_name) + "文件校验失败");
|
||||
flag++;
|
||||
} else {
|
||||
console.log(path.join(configDir, file_name) + "文件校验正确");
|
||||
|
@ -1385,7 +1574,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
}
|
||||
return configData;
|
||||
} catch (error: any) {
|
||||
logger.error("本地数据校验失败" + error);
|
||||
this.logger.error("本地数据校验失败" + error);
|
||||
let configData = {
|
||||
res: -1,
|
||||
g_index_Object: "",
|
||||
|
@ -1444,14 +1633,14 @@ export class DeployMainService implements IDeployMainService {
|
|||
//执行脚本,获取操作系统信息
|
||||
const functionName = 'getosinfo';
|
||||
let osinfo = await this.loadAndInvokeFunction(match_script_filePath, functionName);
|
||||
logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osinfo);
|
||||
this.logger.info("通过脚本" + match_script_filePath + "获取操作系统信息" + osinfo);
|
||||
|
||||
let ConfigMatch = 0;
|
||||
// 检测文件是否有osinfo想匹配的
|
||||
if (osinfo !== 'undefined') {
|
||||
if (g_index_Object["config-file"].hasOwnProperty(`${osinfo}`)) {
|
||||
if (installUtils.compareVersions(g_index_Object['config-file'][osinfo][0]["kylin-ide-lowest-ver"], this.productService.IDEVersion) == 1) {
|
||||
logger.info("网上的配置文件版本与当前ide版本不兼容");
|
||||
this.logger.info("网上的配置文件版本与当前ide版本不兼容");
|
||||
flag++;
|
||||
} else {
|
||||
//下载和当前操作系统关联的插件配置文件
|
||||
|
@ -1482,7 +1671,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
const res = await this.download_File(this.replaceBaseUrl(file_url, this.baseUrl), path.join(updateConfigDir, file_name));
|
||||
if (res == 0) {
|
||||
if (!this.versify(path.join(updateConfigDir, file_name), sign_md5)) {
|
||||
logger.error(path.join(updateConfigDir, file_name) + "文件校验失败");
|
||||
this.logger.error(path.join(updateConfigDir, file_name) + "文件校验失败");
|
||||
flag++;
|
||||
}
|
||||
} else {
|
||||
|
@ -1508,7 +1697,7 @@ export class DeployMainService implements IDeployMainService {
|
|||
}
|
||||
return configData;
|
||||
} catch (error) {
|
||||
logger.error("网络数据校验失败" + error);
|
||||
this.logger.error("网络数据校验失败" + error);
|
||||
let configData = {
|
||||
res: -1,
|
||||
g_index_Object: {},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { execSync } from "child_process";
|
||||
import { logger } from 'vs/platform/issue/electron-main/logger';
|
||||
// import { logger } from 'vs/platform/issue/electron-main/logger';
|
||||
|
||||
export function pyDependsFromUrl(execPath: string, pkgname: string, sourceUrl: string, destPath: string) {
|
||||
const cmd = `${execPath} download ${pkgname} -i ${sourceUrl} -d ${destPath}`;
|
||||
|
@ -17,11 +17,11 @@ export function pyDependsFromUrl(execPath: string, pkgname: string, sourceUrl: s
|
|||
|
||||
export function goDependsFromUrl(execPath: string, pkgUrl: string, destPath: string) {
|
||||
// go get -d github.com/go-sql-driver/mysql
|
||||
logger.debug("goDependsFromUrl");
|
||||
logger.debug(execPath);
|
||||
// logger.debug("goDependsFromUrl");
|
||||
// logger.debug(execPath);
|
||||
const cmd = `${execPath} get -d ${pkgUrl}`;
|
||||
//go的三个环境变量做到配置文件里面
|
||||
logger.debug(cmd);
|
||||
// logger.debug(cmd);
|
||||
const envVar = { GOPATH: destPath, GO111MODULE: "on", GOPROXY: "https://goproxy.cn,direct", GOSUMDB: "off" }
|
||||
try {
|
||||
const res = execSync(cmd, { encoding: 'utf-8', env: { ...process.env, ...envVar } }).toString().trim();
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import * as log4js from 'log4js';
|
||||
import * as installUtils from 'vs/platform/issue/electron-main/installUtils';
|
||||
|
||||
const level = 'debug';
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
file: {
|
||||
type: 'file',
|
||||
filename: `${installUtils.logDirectory()}/instguide.log`,
|
||||
}
|
||||
},
|
||||
categories: {
|
||||
default: { appenders: ['file'], level: level }
|
||||
}
|
||||
});
|
||||
|
||||
export const logger = log4js.getLogger();
|
Loading…
Reference in New Issue