From 70a1672a052f8bef3ddf731b266e2b1efd4364bc Mon Sep 17 00:00:00 2001 From: dinglili Date: Thu, 4 Jul 2024 14:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E5=8D=B8=E8=BD=BD=E5=90=8E?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6;?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=83=A8=E5=88=86=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product.json | 5 +- resources/linux/debian/postrm.template | 4 ++ .../issue/electron-main/deployMainService.ts | 65 +++---------------- .../issue/electron-main/installUtils.ts | 41 ++---------- 4 files changed, 17 insertions(+), 98 deletions(-) diff --git a/product.json b/product.json index 8439e466..2ed0da67 100644 --- a/product.json +++ b/product.json @@ -532,12 +532,9 @@ ], "helpDocUrl":"https://gitee.com/openkylin/extensions-repo/blob/master/user-guide/%E7%9B%AE%E5%BD%95.md", "updateCheckUrl":"https://kylinhorn.cn/updateCheck/kylinide", -<<<<<<< HEAD "gIndexUrl":"https://gitee.com/openkylin/extensions-repo/raw/master/inst-configs-repo/kylin-code/config/g_index.json", -======= - "gIndexUrl":"https://gitee.com/blueskycs2c/installer_config/raw/master/test2/g_index.json", "deployFunc":true, ->>>>>>> 6ab623ca... 添加部署功能开关 + "extensionsControlManifest":{ "malicious": [], "deprecated": { diff --git a/resources/linux/debian/postrm.template b/resources/linux/debian/postrm.template index a04cc602..faf22f30 100755 --- a/resources/linux/debian/postrm.template +++ b/resources/linux/debian/postrm.template @@ -5,6 +5,10 @@ rm -f /usr/bin/@@NAME@@ +if [ -d /home/${SUDO_USER}/.config/Kylin-Code/installconfig ]; then + rm -rf /home/${SUDO_USER}/.config/Kylin-Code/installconfig +fi + # Update mimetype database for removed workspace mimetype if hash update-mime-database 2>/dev/null; then update-mime-database /usr/share/mime diff --git a/src/vs/platform/issue/electron-main/deployMainService.ts b/src/vs/platform/issue/electron-main/deployMainService.ts index e6e0895d..3c250d5a 100644 --- a/src/vs/platform/issue/electron-main/deployMainService.ts +++ b/src/vs/platform/issue/electron-main/deployMainService.ts @@ -132,11 +132,10 @@ export class DeployMainService implements IDeployMainService { this.registerListeners(); } reset() { - this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: {}, osinfo: "", localConfigMatch: 0 }; this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: {}, osinfo: "", localConfigMatch: 0, osrelease: "", supportList: [] }; this.updateConfigObject = { res: 0, g_index_Object: {}, osinfo: "", ConfigMatch: 0, base_url: "", depConfigInfo: "", osrelease: "", supportList: [] }; this.localConfigDir = installUtils.localConfigPath(); - this.installConfig = installUtils.installConfigDirPre();//.kylin-ide/installconfig + this.installConfig = installUtils.installConfigDirPre();//installconfig this.updateConfigDir = installUtils.installConfigDirPre() + "/" + installUtils.getDateDir(); this.logFile0 = this.installConfig + '/log/install.1.log'; @@ -195,8 +194,8 @@ export class DeployMainService implements IDeployMainService { //删除新下载但是没被使用的配置文件 if (this.updateConfigDir) { // const selectdir = this.localConfigDir; - this.logger.info("this.updateConfgDir :", this.updateConfigDir); - this.logger.info("this.localConfigDir :", this.localConfigDir); + this.logger.debug("this.updateConfgDir :", this.updateConfigDir); + this.logger.debug("this.localConfigDir :", this.localConfigDir); if (this.updateConfigDir !== this.localConfigDir) if (fs.existsSync(this.updateConfigDir)) fs.rmdirSync(this.updateConfigDir, { recursive: true }); @@ -562,7 +561,7 @@ export class DeployMainService implements IDeployMainService { } } if (this.DeployWindow) { - this.logger.info('配置文件信息', JSON.stringify(Data)); + // this.logger.info('配置文件信息', JSON.stringify(Data)); return Data; } else { return void 0; @@ -1271,44 +1270,6 @@ export class DeployMainService implements IDeployMainService { } } - reset() { - - this.sysinfo = { IDEVersion: this.productService.IDEVersion || "", localConfigFile: "", addNewPage: 0, localosinfo: "", urlosinfo: "", urlConfigFile: "" } - this.localConfigObject = { depConfigInfo: "", res: 0, g_index_Object: "", osinfo: "", localConfigMatch: 0 }; - this.updateConfigObject = { res: 0, g_index_Object: {}, osinfo: "", ConfigMatch: 0, base_url: "", depConfigInfo: "" }; - this.localConfigDir = installUtils.localConfigPath(); - this.installConfig = installUtils.installConfigDirPre();//.kylin-ide/installconfig - this.updateConfigDir = installUtils.installConfigDirPre() + "/" + installUtils.getDateDir(); - this.logFile0 = this.installConfig + '/log/install.1.log'; - this.resultFile = this.installConfig + '/resultFile'; - this.extLogFile0 = this.installConfig + '/log/extInstall.1.log'; - - this.baseUrl = ""; - this.extDownloadPath = ""; - // public extensionsGalleryConfiguration!: IExtensionsGalleryConfiguration; - // private preExtensionsGalleryConfig: IExtensionsGalleryConfiguration; - this.extMap = {}; - this.depList = []; - this.extList = []; - this.lastLogPosition = 0; - //文件监听; - this.installFsWatcher = null; - this.extlogFsWatcher = null; - this.pkglogFsWatcher = null; - //执行安装脚本的进程号; - this.installProcessId = null; - this.cancelFlag = false; - this.offset = 0; - this.resultIndex = 0; - - this.flagPkexec = 0; - this.lastExtLogPosition = 0; - - this.startInstallDepWatch = 0; - - this.controller = new AbortController(); - } - println(message?: any, ...optionalParams: any[]) { console.log(message, ...optionalParams); } @@ -1339,8 +1300,6 @@ export class DeployMainService implements IDeployMainService { FileAccess.asBrowserUri(`vs/code/electron-sandbox/deploy/deployWindow${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true) ); this.DeployWindow.webContents.openDevTools(); - // this.DeployWindow.setMenuBarVisibility(true); - // // Menu.setApplicationMenu(null); let initData = { isFirstLoad: flag, @@ -1376,7 +1335,8 @@ export class DeployMainService implements IDeployMainService { validatedIpcMain.on('kylinide.installWizard.skipWizard', listenerSkipWizard ); const listenerInit = async (event: IpcMainEvent, msg: any) => { - console.log("main on kylinide.installWizard.init"); + this.logger.info("接收消息:kylinide.installWizard.init"); + if (msg.type === "writeJson") { if (this.selectObject.updateFlag) { installUtils.modifyJsonProperty(this.installConfig + "/" + "selectFile.json", "selectDir", this.updateConfigDir); @@ -1398,7 +1358,7 @@ export class DeployMainService implements IDeployMainService { private createDeployBrowserWindow(position: IWindowState, ipcObjectUrl: IIPCObjectUrl, windowKind: string): BrowserWindow { const window = new BrowserWindow({ fullscreen: false, - // resizable: false, + resizable: true, width: position.width, height: position.height, minWidth: 300, @@ -1532,14 +1492,6 @@ export class DeployMainService implements IDeployMainService { }) } - - - // private safeSend(event: IpcMainEvent, channel: string, ...args: unknown[]): void { - // if (!event.sender.isDestroyed()) { - // event.sender.send(channel, ...args); - // } - // } - private replaceBaseUrl(url: string, baseurl: string) { if (url.startsWith("base-url:")) { url = url.replace("base-url:", baseurl); @@ -1554,7 +1506,6 @@ export class DeployMainService implements IDeployMainService { private versify(dataPath: string, signature: string) { const crypto = require('crypto'); - // const publicKeyPath = FileAccess.asFileUri('vs/platform/issue/electron-main/installWizard/key/public.pem').fsPath; const publicKeyPath = path.join(FileAccess.asFileUri('').fsPath, '..', "installwizard/key/public.pem"); this.logger.info("publicKeyPath", publicKeyPath); //获取数据 @@ -1766,7 +1717,7 @@ export class DeployMainService implements IDeployMainService { 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) { - this.logger.info("网上的配置文件版本与当前ide版本不兼容"); + this.logger.info("网上的配置文件版本与当前code版本不兼容"); flag++; } else { //下载和当前操作系统关联的插件配置文件 diff --git a/src/vs/platform/issue/electron-main/installUtils.ts b/src/vs/platform/issue/electron-main/installUtils.ts index 77bb844d..92ac7074 100644 --- a/src/vs/platform/issue/electron-main/installUtils.ts +++ b/src/vs/platform/issue/electron-main/installUtils.ts @@ -78,47 +78,14 @@ export function modifyJsonProperty(filePath: string, propertyName: string, newVa } export const compareVersions = (v1: string, v2: string) => { - // validate input and split into segments - const n1 = validateAndParse(v1); - const n2 = validateAndParse(v2); - - // pop off the patch - const p1 = n1.pop(); - const p2 = n2.pop(); - - // validate numbers - const r = compareSegments(n1, n2); - if (r !== 0) return r; - - - if (p1 && p2) { - return compareSegments(p1.split('.'), p2.split('.')); - } else if (p1 || p2) { - return p1 ? -1 : 1; + if (v1 && v2) { + return compareSegments(v1.split('.'), v2.split('.')); + } else if (v1 || v2) { + return v1 ? -1 : 1; } - return 0; }; - - -const semver = - /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i; - -const validateAndParse = (version: string) => { - if (typeof version !== 'string') { - throw new TypeError('Invalid argument expected string'); - } - const match = version.match(semver); - if (!match) { - throw new Error( - `Invalid argument not valid semver ('${version}' received)` - ); - } - match.shift(); - return match; -}; - const tryParse = (v: string) => { const n = parseInt(v, 10); return isNaN(n) ? v : n;