修改读取配置文件路径的问题

This commit is contained in:
dinglili 2024-07-04 13:49:57 +08:00 committed by wangpenglong
parent 177b25c018
commit 73ade152af
16 changed files with 244 additions and 1381 deletions

View File

@ -64,6 +64,7 @@ const vscodeResources = [
'out-build/vs/base/node/{stdForkStart.js,terminateProcess.sh,cpuUsage.sh,ps.sh}',
'out-build/vs/base/browser/ui/codicons/codicon/**',
'out-build/vs/base/parts/sandbox/electron-sandbox/preload.js',
'out-build/vs/base/parts/sandbox/electron-sandbox/deploypreload.js',
'out-build/vs/base/parts/sandbox/electron-sandbox/preload-aux.js',
'out-build/vs/workbench/browser/media/*-theme.css',
'out-build/vs/workbench/contrib/debug/**/*.json',
@ -123,6 +124,7 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series(
manual: [
{ src: [...windowBootstrapFiles, 'out-build/vs/code/electron-sandbox/workbench/workbench.js'], out: 'vs/code/electron-sandbox/workbench/workbench.js' },
{ src: [...windowBootstrapFiles, 'out-build/vs/code/electron-sandbox/issue/issueReporter.js'], out: 'vs/code/electron-sandbox/issue/issueReporter.js' },
{ src: [...windowBootstrapFiles, 'out-build/vs/code/electron-sandbox/deploy/deployWindow.js'], out: 'vs/code/electron-sandbox/deploy/deployWindow.js' },
{ src: [...windowBootstrapFiles, 'out-build/vs/code/electron-sandbox/processExplorer/processExplorer.js'], out: 'vs/code/electron-sandbox/processExplorer/processExplorer.js' }
]
}
@ -228,6 +230,10 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
const extensions = gulp.src(['.build/extensions/**', ...platformSpecificBuiltInExtensionsExclusions], { base: '.build', dot: true });
//打包配置文件
gulp.src('installwizard/config/*').pipe(gulp.dest(destination + '/resources/app/installwizard/config/'));
//打包
gulp.src('installwizard/key/*').pipe(gulp.dest(destination + '/resources/app/installwizard/key/'));
const sources = es.merge(src, extensions)
.pipe(filter(['**', '!**/*.js.map'], { dot: true }));

View File

@ -78,7 +78,8 @@ exports.code = [
createModuleDescription('vs/code/node/cliProcessMain', ['vs/code/node/cli']),
createModuleDescription('vs/code/electron-sandbox/issue/issueReporterMain'),
createModuleDescription('vs/code/node/sharedProcess/sharedProcessMain'),
createModuleDescription('vs/code/electron-sandbox/processExplorer/processExplorerMain')
createModuleDescription('vs/code/electron-sandbox/processExplorer/processExplorerMain'),
createModuleDescription('vs/code/electron-sandbox/deploy/deployWindowMain')
];
exports.entrypoint = createModuleDescription;

View File

@ -127,8 +127,6 @@
<div class="sceneChoosePanel">
<h2>开发场景</h2>
<form id="checkboxForm">
<script src="common.js"></script>
<!-- 复选框列表 -->
</form>
</div>
<div class="sceneChooseSeparator"></div>

View File

@ -1,5 +1,6 @@
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
<html>
<head>
<meta charset="utf-8" />
@ -34,15 +35,153 @@
</style>
<body aria-label="">
<div id="loader"></div>
<p>hello</p>
<div id="deploycontainer" class="deploycontainer">
<div class="header-drag-region" id="header-drag-region">
<div class="header-left" style="float: left;">
<div class="header-icon" id="header-icon"></div>
<div class="title" id="title">安装向导</div>
</div>
<div class="header-right" id="header-right" style="float: right;">
<div class="minw" id="minwBtn"></div>
<div class="headclose" id="closeBtn"></div>
</div>
</div>
<div id="process-list"></div>
<div class="bodycontent" id="bodycontent">
<div class="tab" id="homepage">
<div class="installInfo1" id="installInfo1">
<h3>安装引导说明:</h3>
<p>1.本安装引导用于引导用户根据开发场景安装基础功能插件、安装依赖软件、配置基本开发环境。</p>
<p>2.本安装引导仅安装基础插件,可以在插件市场中获取更多插件。</p>
<p>3.在线安装功能需要连接互联网下载插件和依赖软件。</p>
<p>4.您也可以选择跳过此步骤,自己手动安装插件和依赖软件。</p>
<p>5.点击帮助按钮,会访问线上帮助文档</p>
</div>
<div class="devContent">
<form class="installSelectionType">
<label class="installSelection radiogroup">
<input type="radio" id="onlineInstall" name="choice" value="onlineInstall" checked>
<label for="onlineInstall" id="onlineInstalllabel">在线安装</label><br>
</label>
<!-- <label class="installSelection">
<input type="radio" id="localInstall" name="choice" value="localInstall">
<label for="localInstall">本地安装</label><br>
</label>
<label class="installSelection">
<input type="radio" id="justDownload" name="choice" value="justDownload">
<label for="justDownload">仅下载不安装</label><br>
</label> -->
<label class="installSelection radiogroup">
<input type="radio" id="notNow" name="choice" value="notNow">
<label for="notNow" id="lablenotNow">跳过所有</label><br>
</label>
</form>
</div>
</div>
<div class="tab" id="waitTab">
<div class="wait-container">
<div class="line-spin-fade-loader">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<h3>请稍等片刻...</h3>
<p>正在联网进行配置文件下载、检查、校验及本地配置文件的校验等工作</p>
</div>
</div>
<div class="tab" id="onlineInstallTab1">
<div class="installInfo1">
<h3>说明:</h3>
<p>1.检查到有配置文件更新。本安装引导会根据配置文件更新内容。新配置文件可能修改了旧版本配置文件的问题,建议选择“是”更新配置文件。</p>
<p>2.如果您想按照旧版配置文件操作,可以选择“否”不更新配置文件。</p>
</div>
<div class="devContentCol">
<form class="SelectionUpdate">
<div class="radiogroup">
<input type="radio" id="onlineUpdateConfig" name="updateConfig" value="onlineUpdateConfig" checked>
<label for="onlineUpdateConfig" id="labelonlineUpdateConfig"></label><br>
</div>
<div class="radiogroup">
<input type="radio" id="onlineLocalConfig" name="updateConfig" value="onlineLocalConfig">
<label for="onlineLocalConfig"></label><br>
</div>
</form>
</div>
<div class="onlinewarningrow">
<div class="onlinewarningicon"></div>
<div class="onlinewarning" id="onlinewarning"></div>
</div>
</div>
<div class="tab" id="onlineInstallTab2">
<div class="installInfo1 osInfo" id="osInfo">
</div>
<div class="osInfoShow" id="osInfoShow">
</div>
</div>
<div class="tab" id="onlineInstallTab3">
<div class="sceneChooseInfo">
<div class="sceneChoosePanel">
<h2>开发场景</h2>
<form id="checkboxForm">
</form>
</div>
<div class="sceneChooseSeparator"></div>
<div class="depOutputTextbox sceneChooseOutput">
<div id="depOutDesc" style="white-space: pre-wrap;"></div>
<pre id="outputPre"></pre>
</div>
</div>
</div>
<div class="tab progressTab" id="onlineInstallTab4">
<div class="progress-container">
<div class="progressinfoContainer">
<div>
<span class="progressinfoTitle">安装进度:</span>
<span class="progressinfoValue">00.00%</span>
</div>
<div>
<span id="progressInfoFinish" class="progressInfoFinish"></span>
<label id="progressInfoCancel" class="progressInfoCancel">取消</label>
</div>
</div>
<progress class="progress-view" value="50" max="100"></progress>
</div>
<div class="detailInstallOutputTextbox">
<label for="detailInstallOutputTextbox">安装详情</label>
<div>
<pre id="detailInstallPre" style="display: block"></pre>
<pre id="installLogPre" style="display: none"></pre>
<pre id="extInstallLogPre" style="display: none"></pre>
<pre id="finishPage" style="display: none"></pre>
<button class="switchInstallOutput" id="switchInstallOutput">
<img src="./media/switch.png" style="display: inline-block;" alt="切换" width="10px" height="8px"/>
<div style="display: inline-block; margin-left: 4px;">切换输出</div>
</button>
</div>
</div>
</div>
</div>
<div class="indicator" id="indicator">
</div>
<div class="footer">
<div class="helpLink" id="helpLink" style="float: left;" ></div>
<div class="btn-group" style="float: right;">
<button class="prevStep" id="prevStep">上一步</button>
<button class="cancel" id="cancel" style="display:none"></button>
<button class="nextStep" id="nextStep" type="submit">下一步</button>
</div>
</div>
</div>
</body>
<!-- Startup (do not modify order of script tags!) -->
<script src="../../../../bootstrap.js"></script>
<script src="../../../../vs/loader.js"></script>
<script src="../../../../bootstrap-window.js"></script>
<script src="deployWindow.js"></script>
</html>

View File

@ -1,37 +1,13 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Copyright (c) kylinIDETeam. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/deploy';
import 'vs/base/browser/ui/codicons/codiconStyles'; // make sure codicon css is loaded
import { localize } from 'vs/nls';
import { $, append, createStyleSheet } from 'vs/base/browser/dom';
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { DataTree } from 'vs/base/browser/ui/tree/dataTree';
import { IDataSource, ITreeNode, ITreeRenderer } from 'vs/base/browser/ui/tree/tree';
import { RunOnceScheduler } from 'vs/base/common/async';
import { ProcessItem } from 'vs/base/common/processes';
import { IContextMenuItem } from 'vs/base/parts/contextmenu/common/contextmenu';
import { popup } from 'vs/base/parts/contextmenu/electron-sandbox/contextmenu';
// import { localize } from 'vs/nls';
import { ipcRenderer } from 'vs/base/parts/sandbox/electron-sandbox/globals';
import { IRemoteDiagnosticError, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics';
import { ByteSize } from 'vs/platform/files/common/files';
import { ElectronIPCMainProcessService } from 'vs/platform/ipc/electron-sandbox/mainProcessService';
import { DeployData, DeployWindowConfiguration } from 'vs/platform/issue/common/deploy';
import { INativeHostService } from 'vs/platform/native/common/native';
import { NativeHostService } from 'vs/platform/native/common/nativeHostService';
import { getIconsStyleSheet } from 'vs/platform/theme/browser/iconsStyleSheet';
import { applyZoom, zoomIn, zoomOut } from 'vs/platform/window/electron-sandbox/window';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { mainWindow } from 'vs/base/browser/window';
import { ThemeIcon } from 'vs/base/common/themables';
import { Codicon } from 'vs/base/common/codicons';
import { addDisposableListener, EventType, getWindow, getWindowId, hide, show } from 'vs/base/browser/dom';
import { isDisposable } from 'vs/base/common/lifecycle';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { OpenerService } from 'vs/editor/browser/services/openerService';
import { DeployWindowConfiguration } from 'vs/platform/issue/common/deploy';
import { IpcRendererEvent } from 'vs/base/parts/sandbox/electron-sandbox/electronTypes';
class deployWindow {
@ -69,9 +45,9 @@ class deployWindow {
progressNum = 0;
downState = new Map();
configList: { [key: string]: any } = {};
extList = [];
depList = [];
scriptList = [];
extList: any[] = [];
depList: any[] = [];
scriptList: any[] = [];
configData = [];
// 创建监听器
@ -327,11 +303,11 @@ class deployWindow {
this.reset();
};
private nativeHostService: INativeHostService;
// private nativeHostService: INativeHostService;
// private productService: IProductService;
constructor(windowId: number, private data: DeployData) {
const mainProcessService = new ElectronIPCMainProcessService(windowId);
this.nativeHostService = new NativeHostService(windowId, mainProcessService) as INativeHostService;
constructor(windowId: number) {
// const mainProcessService = new ElectronIPCMainProcessService(windowId);
// this.nativeHostService = new NativeHostService(windowId, mainProcessService) as INativeHostService;
this.onlineInstallRadio = document.getElementById("onlineInstall");
this.localInstallRadio = document.getElementById("localInstall");
@ -346,15 +322,15 @@ class deployWindow {
this.registerEventListener();
}
setHeader() {
// Minimize
var titleRight: HTMLElement | null;
titleRight = document.getElementById("header-right");
if (titleRight) {
const minimizeIcon = append(titleRight, $('window-minimize' + ThemeIcon.asCSSSelector(Codicon.chromeMinimize)));
const closeIcon = append(titleRight, $('div.window-icon.window-close' + ThemeIcon.asCSSSelector(Codicon.chromeClose)));
}
}
// setHeader() {
// // Minimize
// var titleRight: HTMLElement | null;
// titleRight = document.getElementById("header-right");
// if (titleRight) {
// const minimizeIcon = append(titleRight, $('window-minimize' + ThemeIcon.asCSSSelector(Codicon.chromeMinimize)));
// const closeIcon = append(titleRight, $('div.window-icon.window-close' + ThemeIcon.asCSSSelector(Codicon.chromeClose)));
// }
// }
showTab(n: number) {
let x = document.getElementsByClassName('tab') as HTMLCollectionOf<HTMLElement>;
x[n].style.display = 'flex';
@ -534,7 +510,7 @@ class deployWindow {
console.log("nextPrev onlineInstallTab3");
// 获取所有选中的复选框
let selectedCheckboxes = checkboxForm!.querySelectorAll('input[type="checkbox"]:checked');
let checkSelectedValues = [];
// let checkSelectedValues = [];
this.extInstallState.clear();
this.extDownloadDoneCounter = 0;
this.extInstallDoneCounter = 0;
@ -1213,7 +1189,7 @@ export function startup(configuration: DeployWindowConfiguration): void {
// applyZoom(configuration.data.zoomLevel);
console.log("-----------------dll-------------startupdeploy");
new deployWindow(configuration.windowId, configuration.data);
new deployWindow(configuration.windowId);
}

View File

@ -1,11 +1,9 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Copyright (c) kylinIDETeam. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
import { PerformanceInfo, SystemInfo } from 'vs/platform/diagnostics/common/diagnostics';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
// Since data sent through the service is serialized to JSON, functions will be lost, so Color objects

View File

@ -3,49 +3,30 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { BrowserWindow, BrowserWindowConstructorOptions, contentTracing, Display, ipcMain, IpcMainEvent, IpcMainInvokeEvent, screen, Menu, dialog, shell } from 'electron';
import { arch, release, type } from 'os';
import { resolve } from 'path';
import { Promises, raceTimeout, timeout } from 'vs/base/common/async';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { randomPath } from 'vs/base/common/extpath';
import { BrowserWindow, BrowserWindowConstructorOptions, Display, IpcMainEvent, IpcMainInvokeEvent, screen, dialog, shell } from 'electron';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { FileAccess } from 'vs/base/common/network';
import { IProcessEnvironment, isMacintosh } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri';
import { listProcesses } from 'vs/base/node/ps';
import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain';
import { localize } from 'vs/nls';
import { IDiagnosticsService, isRemoteDiagnosticError, PerformanceInfo, SystemInfo } from 'vs/platform/diagnostics/common/diagnostics';
import { IDiagnosticsMainService } from 'vs/platform/diagnostics/electron-main/diagnosticsMainService';
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService';
// import { localize } from 'vs/nls';
// import { IDiagnosticsService } from 'vs/platform/diagnostics/common/diagnostics';
// import { IDiagnosticsMainService } from 'vs/platform/diagnostics/electron-main/diagnosticsMainService';
// 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, ILogger } from 'vs/platform/log/common/log';
import { 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 { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
import product from 'vs/platform/product/common/product';
import { IProductService } from 'vs/platform/product/common/productService';
import { IIPCObjectUrl, IProtocolMainService } from 'vs/platform/protocol/electron-main/protocol';
import { IStateService } from 'vs/platform/state/node/state';
import { UtilityProcess } from 'vs/platform/utilityProcess/electron-main/utilityProcess';
import { zoomLevelToZoomFactor } from 'vs/platform/window/common/window';
import { ICodeWindow, IWindowState } from 'vs/platform/window/electron-main/window';
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
// import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
import { activeContrastBorder, buttonBackground, buttonForeground, buttonHoverBackground, editorBackground, editorForeground, foreground, inputActiveOptionBorder, inputBackground, inputBorder, inputForeground, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground, listActiveSelectionBackground, listActiveSelectionForeground, listFocusBackground, listFocusForeground, listFocusOutline, listHoverBackground, listHoverForeground, scrollbarShadow, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, textLinkActiveForeground, textLinkForeground } from 'vs/platform/theme/common/colorRegistry';
// import { getZoomLevel } from 'vs/base/browser/browser';
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService'
import { platform } from 'vs/base/common/process';
// import { IStateService } from 'vs/platform/state/node/state';
import { IWindowState } from 'vs/platform/window/electron-main/window';
// import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
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 * 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';
import * as downUtils from 'vs/platform/issue/electron-main/downUtils';
import * as fs from 'fs';
import * as path from 'path';
import * as http from 'http';
@ -53,27 +34,27 @@ 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;
title: string;
zoomLevel: number;
alwaysOnTop: boolean;
}
// const deployWindowState = 'deploy.deployWindowState';
// interface IBrowserWindowOptions {
// backgroundColor: string | undefined;
// title: string;
// zoomLevel: number;
// alwaysOnTop: boolean;
// }
interface installInfo {
// interface installInfo {
// osInfo: string;
IDEVersion: string;
// localConfigData: {};
// urlConfigFile;
localConfigFile: string;
// selectConfigPath;
addNewPage: number;
localosinfo: string;
urlosinfo: string;
urlConfigFile: string;
}
// // osInfo: string;
// IDEVersion: string;
// // localConfigData: {};
// // urlConfigFile;
// localConfigFile: string;
// // selectConfigPath;
// addNewPage: number;
// localosinfo: string;
// urlosinfo: string;
// urlConfigFile: string;
// }
type IStrictWindowState = Required<Pick<IWindowState, 'x' | 'y' | 'width' | 'height'>>;
@ -81,11 +62,11 @@ export class DeployMainService implements IDeployMainService {
declare readonly _serviceBrand: undefined;
private static readonly DEFAULT_BACKGROUND_COLOR = '#1E1E1E';
// private static readonly DEFAULT_BACKGROUND_COLOR = '#1E1E1E';
private DeployWindow: BrowserWindow | null = null;
private sysinfo: installInfo;
// private sysinfo: installInfo;
// private installconfigpath: string;
private localConfigObject: { res: number; depConfigInfo: any; g_index_Object: any; osinfo: string; localConfigMatch: number; };
// private baseUrl: string = "";
@ -141,22 +122,30 @@ export class DeployMainService implements IDeployMainService {
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,
@IDialogMainService private readonly dialogMainService: IDialogMainService,
@INativeHostMainService private readonly nativeHostMainService: INativeHostMainService,
// @ILogService private readonly logService: ILogService,
// @IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService,
// @IDiagnosticsMainService private readonly diagnosticsMainService: IDiagnosticsMainService,
// @IDialogMainService private readonly dialogMainService: IDialogMainService,
// @INativeHostMainService private readonly nativeHostMainService: INativeHostMainService,
@IProtocolMainService private readonly protocolMainService: IProtocolMainService,
@IProductService private readonly productService: IProductService,
@IStateService private readonly stateService: IStateService,
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
// @IStateService private readonly stateService: IStateService,
// @IWindowsMainService private readonly windowsMainService: IWindowsMainService,
// @IOpenerService private readonly _openerService: IOpenerService,
// @IThemeMainService private readonly themeMainService: IThemeMainService,
// @IThemeService private readonly themeService: IThemeService,
// @INativeWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
) {
this.reset();
this.logger = loggerMainService.createLogger(URI.file(this.installConfig + "/log/installguide.log"));
// 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.logger = this.loggerMainService.createLogger(URI.file(this.installConfig + "/log/installguide.log"));
this.removeListeners();
this.registerListeners();
}
@ -553,6 +542,7 @@ export class DeployMainService implements IDeployMainService {
return void 0;
}
}
return void 0;
};
handleInitConfigSelect = async (event: IpcMainInvokeEvent, msg: any) => {
@ -1512,11 +1502,13 @@ export class DeployMainService implements IDeployMainService {
})
}
private safeSend(event: IpcMainEvent, channel: string, ...args: unknown[]): void {
if (!event.sender.isDestroyed()) {
event.sender.send(channel, ...args);
}
}
// 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:")) {
@ -1532,7 +1524,9 @@ export class DeployMainService implements IDeployMainService {
private versify(dataPath: string, signature: string) {
const crypto = require('crypto');
const publicKeyPath = path.join(__dirname, "./installWizard/key/public.pem");
// 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);
//获取数据
const dataToSign = fs.readFileSync(dataPath, 'utf-8');
@ -1921,9 +1915,9 @@ export class DependInfo extends Disposable {
}
interface PkgDownInfo {
name: string,
version: string,
epoch: string,
state: string //downloaded,downloadFailed
}
// interface PkgDownInfo {
// name: string,
// version: string,
// epoch: string,
// state: string //downloaded,downloadFailed
// }

View File

@ -1,10 +1,9 @@
import { execSync } from "child_process";
// 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}`;
try {
const res = execSync(cmd, { encoding: 'utf-8' }).toString().trim();
execSync(cmd, { encoding: 'utf-8' }).toString().trim();
console.log("download success" + pkgname);
return true;
}
@ -24,7 +23,7 @@ export function goDependsFromUrl(execPath: string, pkgUrl: string, destPath: str
// 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();
execSync(cmd, { encoding: 'utf-8', env: { ...process.env, ...envVar } }).toString().trim();
console.log("download success" + pkgUrl);
return true;
}

View File

@ -1,6 +1,7 @@
import * as os from 'os';
import * as fs from 'fs';
import * as path from 'path';
import { FileAccess } from 'vs/base/common/network';
let showFunc: boolean = true;
export const instflag = showFunc;
@ -20,7 +21,7 @@ export function installConfigDirPre() {
// 1.如果没有selectfile.json则使用的为/usr/share、...目录下的配置文件
// 2.如果存在selectfile.json则使用的配置文件地址为selecDir的值
export function localConfigPath() {
let localConfigDir = path.join(path.dirname(__dirname), "../../../config/");
let localConfigDir = path.join(FileAccess.asFileUri('').fsPath, '..', "installwizard/config/");
if (fs.existsSync(installConfigDirPre() + '/' + 'selectFile.json')) {
let jsonContent = fs.readFileSync(installConfigDirPre() + '/' + 'selectFile.json', 'utf-8');
let jsonData = JSON.parse(jsonContent);

View File

@ -1,246 +0,0 @@
{
"version":"0.0.1",
"kylin-ide-lowest-ver":"0.3.0",
"first_class_list":{
"description":{
"en":"",
"zh_cn":"勾选分类后会安装该选项的基本插件、系统软件依赖。可以从插件市场或openKylin extensions-repo仓库获取更多插件。"
},
"Remote_key":{
"en":"Remote development",
"zh_cn":"远程开发"
},
"C_key":{
"en":"C/C++ development",
"zh_cn":"C/C++开发"
},
"Python3_key":{
"en":"Python3 development",
"zh_cn":"Python3开发"
},
"Go_key":{
"en":"Go development",
"zh_cn":"Go开发"
},
"JavaScript_key":{
"en":"Built-in JavaScript development",
"zh_cn":"内置JavaScript开发",
"show_type":"picked_gray"
}
},
"second_class":{
"Remote_key": {
"discription":{
"en":"Remote development",
"zh_cn":"远程开发"
},
"ext-list": [
"KylinIdeTeam.extension-dependency",
"xhafei.remote-dev"
],
"pkg-list":{
},
"script-list":[
]
},
"C_key": {
"discription":{
"en":"Basic function of C/C++ development: linting, intellisense, compile, debug. You may install other extensions to get more functions.",
"zh_cn":"C/C++开发需要的基本功能:语法检查、跳转、补全、编译、调试等。可以安装其他插件获得更多功能。"
},
"ext-list": [
"KylinIdeTeam.extension-dependency",
"KylinIdeTeam.gitlens",
"KylinIdeTeam.project-manager",
"KylinIdeTeam.vscode-clangd",
"KylinIdeTeam.debug",
"KylinIdeTeam.cmake-intellisence"
],
"pkg-list":{
"deb":{
"git":{},
"ssh-askpass":{},
"clangd":{},
"libclang-common-10-dev":{},
"build-essential":{},
"cmake":{},
"gdb":{},
"debhelper":{}
}
},
"script-list":[
]
},
"Python3_key":{
"discription":{
"en":"Python3 development",
"zh_cn":"Python3开发"
},
"ext-list": [
"KylinIdeTeam.extension-dependency",
"KylinIdeTeam.gitlens",
"KylinIdeTeam.python"
],
"pkg-list":{
"deb":{
"git":{},
"ssh-askpass":{},
"python3":{},
"python3-autopep8":{},
"python3-pip":{}
}
},
"script-list":[
{
"order":1,
"postin":"python3-pip" ,
"file_url":"base-url:/python3_config-0.0.1.sh",
"file_name": "python3_config-0.0.1.sh",
"ver": "0.0.1",
"sign-md5": "5abef8fab04ca04d2b74531c1e563ceac297e3bdced8df4a519dad90386f25682ec985b008ab73b25254add9ae92f840a1d86a5c4829389d328aa555ef30e792fee4a8beaf3da2ddba2afe19ddfa03898fef102299ef5a8fe2001af394a7e2ecfd0adc63fe4231bc95337909856b438ed73acba41f217c8f0f2ae7640bb2cc78"
}
]
},
"Go_key":{
"discription":{
"en":"Go development",
"zh_cn":"Go开发"
},
"ext-list": [
"KylinIdeTeam.extension-dependency",
"KylinIdeTeam.gitlens",
"KylinIdeTeam.go"
],
"pkg-list":{
"deb":{
"git":{},
"ssh-askpass":{},
"golang-1.14":{}
}
},
"script-list":[
{
"order":1,
"postin":"golang-1.14",
"file_url":"base-url:/go_config-0.0.1.js",
"file_name": "go_config-0.0.1.js",
"ver": "0.0.1",
"sign-md5": "cd79e95d69868f87caca7197e68597e29a4ac9c6fce6134ba174e2f8331e372e6e7598d5e769b9dd06f8f99a82dfa5cb8602e7b17cd63e330273a7f1bb0befe25d3101ddddc7b11546cb9dfd7bf9266d5ffc0e2fc460e3bb074aba311f0ec6c930d85f61a7f4db0b473400863204b13a6f0d08749193fbaf190fafa72d340054"
}
]
},
"JavaScript_key":{
"discription":{
"en":"Built-in support JavaScript development(Please install NodeJS by yourself if needed)",
"zh_cn":"内置支持JavaScript开发如需NodeJS请自行安装"
},
"ext-list": [
],
"pkg-list":{
},
"script-list":[
]
}
},
"ext_detail":{
"KylinIdeTeam.extension-dependency":{
"ext_id": "KylinIdeTeam.extension-dependency",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.project-manager":{
"ext_id": "KylinIdeTeam.project-manager",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.vscode-gradle":{
"ext_id": "KylinIdeTeam.vscode-gradle",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.vscode-java-dependency":{
"ext_id": "KylinIdeTeam.vscode-java-dependency",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.vscode-java-pack": {
"ext_id": "KylinIdeTeam.vscode-java-pack",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.vscode-java-test": {
"ext_id": "KylinIdeTeam.vscode-java-test",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.vscode-maven": {
"ext_id": "KylinIdeTeam.vscode-maven",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.gitlens": {
"ext_id": "KylinIdeTeam.gitlens",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.cmake-intellisence": {
"ext_id": "KylinIdeTeam.cmake-intellisence",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.go": {
"ext_id": "KylinIdeTeam.go",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.java": {
"ext_id": "KylinIdeTeam.java",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.python": {
"ext_id": "KylinIdeTeam.python",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.vscode-clangd": {
"ext_id": "KylinIdeTeam.vscode-clangd",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.debug": {
"ext_id": "KylinIdeTeam.debug",
"ext_version": {
"latest":true
}
},
"KylinIdeTeam.vscode-java-debug": {
"ext_id": "KylinIdeTeam.vscode-java-debug",
"ext_version": {
"latest":true
}
},
"xhafei.remote-dev": {
"ext_id": "xhafei.remote-dev",
"ext_version": {
"latest":true
}
}
}
}

View File

@ -1,319 +0,0 @@
{
"version": "0.0.1",
"KylinIdeTeam.extension-dependency": {
"ext_id": "KylinIdeTeam.extension-dependency",
"ext_name": "extension dependency",
"ext_descrip": {
"en": "extension dependency",
"zh_cn": "插件依赖管理器"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-extension-dependency"
}
}
},
"KylinIdeTeam.offline-extensions-manager": {
"ext_id": "KylinIdeTeam.offline-extensions-manager",
"ext_name":"offline extensions manager",
"ext_descrip": {
"en": "offline extensions manager",
"zh_cn": "离线插件管理器"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-offline-extensions-manager"
}
}
},
"KylinIdeTeam.project-manager": {
"ext_id": "KylinIdeTeam.project-manager",
"ext_name":"Kylin Project Manager",
"ext_descrip": {
"en": "Kylin Project Manager",
"zh_cn": "麒麟项目管理器"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-project-manager"
}
}
},
"KylinIdeTeam.vscode-gradle": {
"ext_id": "KylinIdeTeam.vscode-gradle",
"ext_name":"Java Gradle (Support openjdk11 runtime)",
"ext_descrip": {
"en": "Java Gradle (Support openjdk11 runtime)",
"zh_cn": "Java Gradle(支持openjdk11运行时)"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-vscode-gradle"
}
}
},
"KylinIdeTeam.vscode-java-dependency": {
"ext_id": "KylinIdeTeam.vscode-java-dependency",
"ext_name":"Java Dependency (Support openjdk11 runtime)",
"ext_descrip": {
"en": "Java Dependency (Support openjdk11 runtime)",
"zh_cn": "Java依赖(支持openjdk11运行时) "
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-vscode-java-dependency"
}
}
},
"KylinIdeTeam.vscode-java-pack": {
"ext_id": "KylinIdeTeam.vscode-java-pack",
"ext_name":"Java Pack (Support openjdk11 runtime)",
"ext_descrip": {
"en": "Java Pack (Support openjdk11 runtime)",
"zh_cn": "Java Pack(支持openjdk11运行时) "
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-vscode-java-pack"
}
}
},
"KylinIdeTeam.vscode-java-test": {
"ext_id": "KylinIdeTeam.vscode-java-test",
"ext_name":"Java Test (Support openjdk11 runtime)",
"ext_descrip": {
"en": "Java Test (Support openjdk11 runtime)",
"zh_cn": "Java Test(支持openjdk11运行时) "
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-vscode-java-test"
}
}
},
"KylinIdeTeam.vscode-maven": {
"ext_id": "KylinIdeTeam.vscode-maven",
"ext_name":"Java Maven (Support openjdk11 runtime)",
"ext_descrip": {
"en": "Java Maven (Support openjdk11 runtime)",
"zh_cn": "Java Maven(支持openjdk11运行时) "
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-vscode-maven"
}
}
},
"KylinIdeTeam.gitlens": {
"ext_id": "KylinIdeTeam.gitlens",
"ext_name": "gitlens",
"ext_descrip": {
"en": "Gitlens lower version for friendly licence",
"zh_cn": "Gitlens免费版本"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-gitlens"
}
}
},
"KylinIdeTeam.cmake-intellisence": {
"ext_id": "KylinIdeTeam.cmake-intellisence",
"ext_name": "CMake IntelliSence",
"ext_descrip": {
"en": "CMake IntelliSence",
"zh_cn": "CMake编辑支持"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "cmake-intellisence"
}
}
},
"KylinIdeTeam.go": {
"ext_id": "KylinIdeTeam.go",
"ext_name": "Go(for KylinOS)",
"ext_descrip": {
"en": "Go(for KylinOS)",
"zh_cn": "Go编辑调试支持(适配麒麟操作系统)"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-go"
}
}
},
"KylinIdeTeam.java": {
"ext_id": "KylinIdeTeam.java",
"ext_name": "Java (Support openjdk11 runtime) ",
"ext_descrip": {
"en": "Java (Support openjdk11 runtime) ",
"zh_cn": "Java编辑支持 (支持openjdk11运行时)"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-java"
}
}
},
"KylinIdeTeam.python": {
"ext_id": "KylinIdeTeam.python",
"ext_name": "Python(with jedi language server)",
"ext_descrip": {
"en": "Python(with jedi language server) ",
"zh_cn": "Python编辑调试支持(使用jedi语言服务端)"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-python"
}
}
},
"KylinIdeTeam.vscode-clangd": {
"ext_id": "KylinIdeTeam.vscode-clangd",
"ext_name": "vscode-clangd",
"ext_descrip": {
"en": "C/C++ edit support, use clangd as language server",
"zh_cn": "C/C++编辑支持使用clangd作为语言服务端"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-vscode-clangd"
}
}
},
"KylinIdeTeam.debug": {
"ext_id": "KylinIdeTeam.debug",
"ext_name": "Native Debug(fix some bugs)",
"ext_descrip": {
"en": "C/C++ gdb debug support",
"zh_cn": "C/C++ gdb调试支持"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "native-debug"
}
}
},
"KylinIdeTeam.historydebug": {
"ext_id": "KylinIdeTeam.historydebug",
"ext_name": "historyDebug",
"ext_descrip": {
"en": "history debug",
"zh_cn": "历史调试支持"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "historydebug"
}
}
},
"KylinIdeTeam.js-debug": {
"ext_id": "KylinIdeTeam.js-debug",
"ext_name": "JavaScript Debugger(for KylinOS)",
"ext_descrip": {
"en": "JavaScript Debugger(for KylinOS)",
"zh_cn": "JavaScript调试支持(适配麒麟系统)"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-js-debug"
}
}
},
"KylinIdeTeam.vscode-java-debug": {
"ext_id": "KylinIdeTeam.vscode-java-debug",
"ext_name": "Java Debug (Support openjdk11 runtime)",
"ext_descrip": {
"en": "Java Debug (Support openjdk11 runtime)",
"zh_cn": "Java调试支持(支持openjdk11运行时)"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "vscode-java-debug"
}
}
},
"KylinIdeTeam.deadlock-detect": {
"ext_id": "KylinIdeTeam.deadlock-detect",
"ext_name": "deadlock-detect",
"ext_descrip": {
"en": "C/C++/java deadlock detect",
"zh_cn": "C/C++/java 程序死锁分析"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "deadlock-detect"
}
}
},
"KylinIdeTeam.memleak-detect": {
"ext_id": "KylinIdeTeam.memleak-detect",
"ext_name": "memleak-detect",
"ext_descrip": {
"en": "C/C++ memory leak detect",
"zh_cn": "C/C++ 程序泄漏检测"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "openkylin",
"repo": "ide-memleak-detect"
}
}
},
"xhafei.remote-dev": {
"ext_id": "xhafei.remote-dev",
"ext_name": "Kylin remote development",
"ext_descrip": {
"en": "remote development support",
"zh_cn": "远程开发支持"
},
"ext_links": {
"gitee": {
"prefix": "https://gitee.com",
"org": "mcy-kylin",
"repo": "remote-dev"
}
}
}
}

View File

@ -1,32 +0,0 @@
{
"ver": "0.0.1",
"base-url":"https://gitee.com/openkylin/extensions-repo/raw/master/inst-configs-repo/kylin-code/config",
"ext-file": {
"file_url": "base-url:/ext_link_address-0.0.1.json",
"file_name": "ext_link_address-0.0.1.json",
"ver": "0.0.1",
"sign-md5": "a57db37948052f7d03f102c16be8867a17a3b2b171bf75add8dd3d4f2b0774198e858c58792c7517fd875109eb8fee5206011c7635c87437e3d645d9b18102cfae988e2d2fc4a387cb6bbf49241b9e8fd2189ebae46633fa4bddc68912b849c07ab278eaba2adaadd260b122c7998b56b6e3308fdfdad57289522c66e8534f4d"
},
"match-script":
{
"file_url": "base-url:/os_classify_script-0.0.1.js",
"file_name": "os_classify_script-0.0.1.js",
"ver": "0.0.1",
"sign-md5": "96c5730cd2fd1ca3e271011d8af71ca51f3c1c8a783811c2e95bb1b0131aab9c57463cc468dafd344ee617baf67ca96c529590159e7f66459ebbd219bcee7e7b7271c6e8eeed27831a696ec0d0d6a49dadb91bd5116a203cd363583384f0fccd53b0cb8e29b2f6b6b275be6fbc72e8d05fdb98f4a230377eefb2843e9a0a4e11"
},
"config-file": {
"x86_openkylin_desktop": [
{
"discription": {
"en": "X86 openKylin Desktop yangtze",
"zh_cn": "X86 openKylin开源操作系统"
},
"file_url": "base-url:/desktop_os_common-0.0.1.json",
"file_name": "desktop_os_common-0.0.1.json",
"ver": "0.0.1",
"kylin-ide-lowest-ver": "0.3.0",
"sign-md5":"015746b2030147d9502c465fca90a7a5ff387b66690793869e2b155ec844fc34f01e6131043ab496265a18a7068649ab9892bd9adb5f52d0ec26e5e545df3d2f265da072a120d5d1b236f600bc701d88e1bd594cc6c846d806a9f5b32993a6eddeff860f590bf31784b6878424e29d69aba32f302ff6df63628f88e5ea1abab5"
}
]
}
}

View File

@ -1,508 +0,0 @@
const { exec, spawnSync, spawn, execSync } = require('child_process');
const os = require('os');
const fs = require('fs');
//go工具安装
function GoToolsInstall(archName, goVersion, goPath, systemtype) {
return new Promise(async (resolve, reject) => {
let installToolsMessage = '';
let codeProcess = 0
if (archName.indexOf('longarch64') === -1) {
installToolsMessage = "正在" + archName + "架构," + systemtype + "系统类型上安装go版本为" + goVersion + "的工具:" + '\n';
switch (goVersion) {
case '1.13':
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go版本为", goVersion, "的工具:")
try {
await gopls095Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await dlv160Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败")
}
return
case '1.14':
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go版本为", goVersion, "的工具:")
try {
await gopls095Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await dlv161Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败:", error)
}
return
case '1.15':
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go版本为", goVersion, "的工具:")
try {
await gopls095Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await dlv161Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败:", error)
}
return
default:
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go工具:")
installToolsMessage = "正在" + archName + "架构," + systemtype + "系统类型上安装go工具:" + '\n';
try {
await goplsInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await dlvInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败:", error)
}
}
} else {
installToolsMessage = "正在" + archName + "架构," + systemtype + "系统类型上安装go版本为" + goVersion + "的工具:" + '\n';
switch (goVersion) {
case '1.15':
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go版本为", goVersion, "的工具:")
try {
await gopls095Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败:", error)
}
return
case '1.14':
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go版本为", goVersion, "的工具:")
try {
await gopls095Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败:", error)
}
return
case '1.13':
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go版本为", goVersion, "的工具:")
try {
await gopls095Install(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败:", error)
}
return
default:
console.log("正在", archName, "架构,", systemtype, "系统类型上安装go工具:")
installToolsMessage = "正在" + archName + "架构," + systemtype + "系统类型上安装go工具" + '\n';
try {
await goplsInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
await goOutLineInstall(goPath)
.then(([results, code]) => {
installToolsMessage += results + '\n'
codeProcess += code
})
.catch((error) => {
console.error(error);
});
resolve([installToolsMessage, codeProcess])
} catch (error) {
console.log("Go工具安裝失败:", error)
}
}
}
})
}
//判断go路径是否存在
function executableFileExists(filePath) {
let exists = true;
try {
exists = fs.statSync(filePath).isFile();
if (exists) {
fs.accessSync(filePath, fs.constants.F_OK | fs.constants.X_OK);
}
} catch (e) {
exists = false;
}
return exists;
}
//下载gopls@0.9.5
function gopls095Install(goPath) {
return new Promise((resolve, reject) => {
const ls = spawn(goPath, ["get", "-v", "golang.org/x/tools/gopls@v0.9.5"]);
ls.stderr.on('data', (data) => { console.error(`${data}`); });
ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
ls.on('close', (code) => {
console.log(`子进程退出码:${code}`);
if (code === 0) {
console.log("gopls@v0.9.5安装成功");
resolve(["gopls@v0.9.5安装成功", code]);
} else {
console.log("gopls@v0.9.5安装失败");
resolve(["gopls@v0.9.5安装失败", code]);
}
});
})
}
//下载gopls
function goplsInstall(goPath) {
return new Promise((resolve, reject) => {
const ls = spawn(goPath, ["get", "-v", "golang.org/x/tools/gopls"]);
ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
ls.stderr.on('data', (data) => { console.error(`${data}`); });
ls.on('close', (code) => {
console.log(`子进程退出码:${code}`);
if (code === 0) {
console.log("gopls安装成功");
resolve(["gopls安装成功", code]);
} else {
console.log("gopls安装失败");
resolve(["gopls安装失败", code]);
}
});
})
}
//下载dlv@1.6.0
function dlv160Install(goPath) {
return new Promise((resolve, reject) => {
const ls = spawn(goPath, ["get", "-v", "github.com/go-delve/delve/cmd/dlv@v1.6.0"]);
ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
ls.stderr.on('data', (data) => { console.error(`${data}`); });
ls.on('close', (code) => {
console.log(`子进程退出码:${code}`);
if (code === 0) {
console.log("dlv@v1.6.0安装成功");
resolve(["dlv@v1.6.0安装成功", code]);
} else {
console.log("dlv@v1.6.0安装失败");
resolve(["dlv@v1.6.0安装失败", code]);
}
});
})
}
//下载dlv@1.6.1
function dlv161Install(goPath) {
return new Promise((resolve, reject) => {
const ls = spawn(goPath, ["get", "-v", "github.com/go-delve/delve/cmd/dlv@v1.6.1"]);
ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
ls.stderr.on('data', (data) => { console.error(`${data}`); });
ls.on('close', (code) => {
console.log(`子进程退出码:${code}`);
if (code === 0) {
console.log("dlv@v1.6.1安装成功");
resolve(["dlv@v1.6.1安装成功", code])
} else {
console.log("dlv@v1.6.1安装失败");
resolve(["dlv@v1.6.1安装失败", code])
}
});
})
}
//下载dlv
function dlvInstall(goPath) {
return new Promise((resolve, reject) => {
const ls = spawn(goPath, ["get", "-v", "github.com/go-delve/delve/cmd/dlv"]);
ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
ls.stderr.on('data', (data) => { console.error(`${data}`); });
ls.on('close', (code) => {
console.log(`子进程退出码:${code}`);
if (code === 0) {
console.log("dlv安装成功");
resolve(["dlv安装成功", code])
} else {
console.log("dlv安装失败");
resolve(["dlv安装失败", code])
}
});
})
}
//下载go-outline
function goOutLineInstall(goPath) {
return new Promise((resolve, reject) => {
const ls = spawn(goPath, ["get", "-v", "github.com/ramya-rao-a/go-outline"]);
ls.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
ls.stderr.on('data', (data) => { console.error(`${data}`); });
ls.on('close', (code) => {
console.log(`子进程退出码:${code}`);
if (code === 0) {
console.log("go-outline安装成功");
resolve(["go-outline安装成功", code])
} else {
console.log("go-outline安装失败");
resolve(["go-outline安装失败", code])
}
});
})
}
//获取go路径以及版本号
function getGoPath() {
const p = "";
const defaultPathsForGo =
process.platform === 'win32'
? ['C:\\Program Files\\Go\\bin\\go.exe', 'C:\\Program Files (x86)\\Go\\bin\\go.exe']
: ['/usr/bin/go', '/bin/go', '/usr/local/go/bin/go', '/usr/local/bin/go', '/usr/lib/go-1.15/bin/go', '/usr/lib/go-1.14/bin/go', '/usr/lib/go-1.13/bin/go'];
for (const p of defaultPathsForGo) {
if (executableFileExists(p)) {
return p;
}
}
return p;
}
//设置go代理
function setting(goPath) {
process.env.GO111MODULE = "on";
process.env.GOPROXY = "https://goproxy.cn,direct";
exec(`${goPath} env -w GO111MODULE=on && ${goPath} env -w GOPROXY=https://goproxy.cn,direct`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
// console.log(`stdout: ${stdout}`);
console.log("Go代理设置成功!")
// console.log(`stderr: ${stderr}`);
})
}
//检查系统类型
function checkSystemType() {
let cmdResult = spawnSync('ls', ['/usr/bin/dpkg']);
if (cmdResult.stdout !== null) {
let libcResult = spawnSync('dpkg-query', ['-W', 'libc6']);
if (libcResult.stdout !== null) {
if (libcResult.stdout.toString() !== '') {
return 'deb';
}
}
}
cmdResult = spawnSync('ls', ['/usr/bin/rpm']);
if (cmdResult.stdout !== null) {
let libcResult = spawnSync('rpm', ['-qa', 'glibc']);
if (libcResult.stdout !== null) {
if (libcResult.stdout.toString() !== '') {
return 'rpm';
}
}
}
return 'unknown';
}
async function main() {
return new Promise((resolve, reject) => {
let goVersion = "";
let goPath = "";
const archName = os.arch();
goPath = getGoPath();
if (goPath === '') {
resolve("go路径找不到");
return;
}
if (goPath.indexOf('go-1.15') !== -1) {
goVersion = "1.15";
} else if (goPath.indexOf('go-1.14') !== -1) {
goVersion = "1.14";
} else if (goPath.indexOf('go-1.13') !== -1) {
goVersion = "1.13";
} else {
let cmdResult = spawnSync('go', ['version']);
if (cmdResult && cmdResult.stdout !== null && cmdResult.stdout.toString().indexOf("1.13") !== -1) {
goVersion = '1.13';
}
}
const systemtype = checkSystemType();
let p = new Promise((resolve, reject) => {
setting(goPath)
setTimeout(() => {
resolve();
}, 1000);
// reject("dddd");
})
p.then(async (value) => {
if (goPath !== "") {
GoToolsInstall(archName, goVersion, goPath, systemtype)
.then(([results, code]) => {
resolve([results, code])
})
} else {
console.log("找不到go路径")
}
})
})
}
// main();
module.exports = {
main
}

View File

@ -1,141 +0,0 @@
const os = require('os');
const fs = require('fs');
var os_arch; //arch x86_64
var os_org; //Kylin
var os_type; // Desktop Server
var os_release;// eg:2203
var os_version_id; // V10
var os_sp;//sp
var os_custom; //hwe
var pretty_name;
//检查系统架构
function getArch() {
const arch = os.arch();
let res = '';
switch (arch) {
case 'x64':
case 'x86':
case "x86_64": res = 'x86'; break;
case 'arm':
case 'arm64':
case 'aarch64': res = 'arm'; break;
case 'loongarch': res = 'loongarch'; break;
default: res = "other";
}
return res;
}
function returnosinfo() {
if (os_arch == 'x86' && os_org == 'openkylin' && os_type == 'desktop') {
return "x86_openkylin_desktop";
}
return "undefined"
}
function getosinfo() {
const kyinfoPath = '/etc/.kyinfo';
const osReleasePath = '/etc/os-release';
//1、架构
//2、是否是麒麟系统
//3、是桌面系统还是服务器系统
//4、是否是V10
//5、是否带sp是sp几
//6、小版本号
//7、定制版字符
var dist_id;
var os_info
os_arch = getArch();
/*
1.存在.kyinfo的系统 取值dist_id 架构之前的信息
2.不在.kyinfo的系统但是存在os-release 的kylin系统
3.不是kylin的系统但是存在os-release
目前可以先做第一和第二种分类
*/
let data;
let releasedata;
if (fs.existsSync(kyinfoPath) && fs.existsSync(osReleasePath)) {
os_org = "kylin";
try {
let milestone;
let dist_id;
let tmpstr;
let version_id;
data = fs.readFileSync(kyinfoPath, 'utf8');
releasedata = fs.readFileSync(osReleasePath, 'utf8');
// 使用 split 方法将文件内容分割成行数组
const lines = data.split('\n');
// 遍历行数组 获取系统架构
lines.forEach((line) => {
if (line.startsWith("milestone=")) {
milestone = line.slice(10).toLocaleLowerCase();
} else if (line.startsWith("dist_id=")) {
dist_id = line.slice(8).toLocaleLowerCase();
}
});//end lines
const releasedatalines = releasedata.split('\n');
releasedatalines.forEach((line) => {
if (line.startsWith("PRETTY_NAME=")) {
pretty_name = line.slice(12).toLocaleLowerCase().replace(/"/g, '');
} else if (line.startsWith("VERSION_ID=")) {
version_id = line.slice(11).toLocaleLowerCase().replace(/"/g, '');
}
});
if (version_id) {
os_version_id = version_id;
}
os_type = dist_id.includes('desktop') ? "desktop" : "server";
if (milestone.indexOf('release')) {
os_release = milestone.slice(milestone.indexOf('release') + 8);
}
if (dist_id.includes('edu')) {
os_custom = 'edu';
} else {
os_custom = 'gen';
}
if (dist_id.includes('hwe')) {
os_custom += 'hwe';
}
if (dist_id.includes('gfb')) {
l
os_custom += 'gfb'
}
} catch (err) {
os_info = "";
}
}else if(fs.existsSync(osReleasePath)){
try {
let milestone;
let dist_id;
let tmpstr;
let version_id;
releasedata = fs.readFileSync(osReleasePath, 'utf8');
const releasedatalines = releasedata.split('\n');
releasedatalines.forEach((line) => {
if (line.startsWith("PRETTY_NAME=")) {
pretty_name = line.slice(12).toLocaleLowerCase().replace(/"/g, '');
} else if (line.startsWith("VERSION_ID=")) {
version_id = line.slice(11).toLocaleLowerCase().replace(/"/g, '');
}else if (line.startsWith("ID=")) {
os_org = line.slice(3).toLocaleLowerCase().replace(/"/g, '');
}else if (line.startsWith("VERSION_CODENAME=")) {
os_custom = line.slice(17).toLocaleLowerCase().replace(/"/g, '');
}
});
if (version_id) {
os_version_id = version_id;
}
if(pretty_name.includes('openkylin'))
os_type ="desktop";
} catch (err) {
os_info = "";
}
}
os_info = returnosinfo();
return os_info;
}
module.exports = { getosinfo }

View File

@ -1,3 +0,0 @@
#!/bin/bash
echo "exec \"pip3 install pylint -i https://pypi.tuna.tsinghua.edu.cn/simple\""
pip3 install pylint -i https://pypi.tuna.tsinghua.edu.cn/simple