download MSVC installer autoatically
This commit is contained in:
parent
4dfc20656c
commit
b482f90dbc
|
@ -58,6 +58,7 @@
|
|||
"i18next": "^22.4.9",
|
||||
"localforage": "^1.9.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"nodejs-file-downloader": "^4.13.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-i18next": "^12.1.4",
|
||||
"toml": "^3.0.0",
|
||||
|
@ -105,4 +106,4 @@
|
|||
"vite": "^5.4.14",
|
||||
"yazl": "^2.5.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ export const ipcMainChannels = {
|
|||
CHANGE_LANGUAGE: 'change-language',
|
||||
CHECK_FILE_PERMISSIONS: 'check-file-permissions',
|
||||
CHECK_STORAGE_TOKEN: 'check-storage-token',
|
||||
DOWNLOAD_MSVC: 'download-msvc',
|
||||
DOWNLOAD_URL: 'download-url',
|
||||
GET_ELECTRON_PATHS: 'get-electron-paths',
|
||||
GET_N_CPUS: 'get-n-cpus',
|
||||
|
|
|
@ -29,7 +29,7 @@ import {
|
|||
import {
|
||||
setupAddPlugin,
|
||||
setupRemovePlugin,
|
||||
setupCheckForWindowsDLL
|
||||
setupWindowsMSVCHandlers
|
||||
} from './setupAddRemovePlugin';
|
||||
import { ipcMainChannels } from './ipcMainChannels';
|
||||
import ELECTRON_DEV_MODE from './isDevMode';
|
||||
|
@ -164,7 +164,7 @@ export const createWindow = async () => {
|
|||
setupLaunchPluginServerHandler();
|
||||
setupAddPlugin(i18n);
|
||||
setupRemovePlugin();
|
||||
setupCheckForWindowsDLL();
|
||||
setupWindowsMSVCHandlers();
|
||||
setupOpenLocalHtml(mainWindow, ELECTRON_DEV_MODE);
|
||||
if (ELECTRON_DEV_MODE) {
|
||||
// The timing of this is fussy due a chromium bug. It seems to only
|
||||
|
|
|
@ -2,8 +2,9 @@ import upath from 'upath';
|
|||
import fs from 'fs';
|
||||
import { tmpdir } from 'os';
|
||||
import toml from 'toml';
|
||||
import { spawn } from 'child_process';
|
||||
import { execFile, spawn } from 'child_process';
|
||||
import { app, ipcMain } from 'electron';
|
||||
import { Downloader } from 'nodejs-file-downloader';
|
||||
|
||||
import { getLogger } from './logger';
|
||||
import { ipcMainChannels } from './ipcMainChannels';
|
||||
|
@ -182,11 +183,33 @@ export function setupRemovePlugin() {
|
|||
);
|
||||
}
|
||||
|
||||
export function setupCheckForWindowsDLL() {
|
||||
export function setupWindowsMSVCHandlers() {
|
||||
ipcMain.handle(
|
||||
ipcMainChannels.HAS_MSVC,
|
||||
() => {
|
||||
return fs.existsSync(upath.join('C:', 'Windows', 'System32', 'VCRUNTIME140_1.dll'));
|
||||
}
|
||||
);
|
||||
|
||||
ipcMain.handle(
|
||||
ipcMainChannels.DOWNLOAD_MSVC,
|
||||
async () => {
|
||||
const tmpDir = app.getPath('temp');
|
||||
const exeName = 'vc_redist.x64.exe';
|
||||
const downloader = new Downloader({
|
||||
url: 'https://aka.ms/vs/17/release/vc_redist.x64.exe',
|
||||
directory: tmpDir,
|
||||
fileName: exeName,
|
||||
});
|
||||
try {
|
||||
await downloader.download();
|
||||
logger.info("Download complete");
|
||||
} catch (error) {
|
||||
logger.error("Download failed", error);
|
||||
}
|
||||
logger.info('Launching MSVC installer');
|
||||
const exePath = upath.join(tmpDir, exeName);
|
||||
execFile(exePath);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -36,9 +36,11 @@ export default function PluginModal(props) {
|
|||
setShowPluginModal(false);
|
||||
};
|
||||
const handleModalOpen = () => {
|
||||
ipcRenderer.invoke(ipcMainChannels.HAS_MSVC).then((hasMSVC) => {
|
||||
setNeedsMSVC(!hasMSVC);
|
||||
});
|
||||
if (window.Workbench.OS === 'win32') {
|
||||
ipcRenderer.invoke(ipcMainChannels.HAS_MSVC).then((hasMSVC) => {
|
||||
setNeedsMSVC(!hasMSVC);
|
||||
});
|
||||
}
|
||||
setShowPluginModal(true);
|
||||
};
|
||||
|
||||
|
@ -81,11 +83,8 @@ export default function PluginModal(props) {
|
|||
});
|
||||
};
|
||||
|
||||
const openMSVCLink = () => {
|
||||
ipcRenderer.send(
|
||||
ipcMainChannels.OPEN_EXTERNAL_URL,
|
||||
'https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version'
|
||||
);
|
||||
const downloadMSVC = () => {
|
||||
ipcRenderer.invoke(ipcMainChannels.DOWNLOAD_MSVC);
|
||||
setShowPluginModal(false);
|
||||
}
|
||||
|
||||
|
@ -268,16 +267,17 @@ export default function PluginModal(props) {
|
|||
{t('Microsoft Visual C++ Redistributable must be installed!')}
|
||||
</h5>
|
||||
|
||||
{t(
|
||||
`Plugin features require the Microsoft Visual C++ Redistributable.
|
||||
You must download and install the redistributable before continuing.`
|
||||
)}
|
||||
{t('Plugin features require the ')}
|
||||
<a href="https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist">
|
||||
{t('Microsoft Visual C++ Redistributable.')}
|
||||
</a>
|
||||
{t('You must download and install the redistributable before continuing.')}
|
||||
|
||||
<Button
|
||||
className="mt-3"
|
||||
onClick={openMSVCLink}
|
||||
onClick={downloadMSVC}
|
||||
>
|
||||
{t('Go to download page')}
|
||||
{t('Continue to download and install')}
|
||||
</Button>
|
||||
</Modal.Body>
|
||||
);
|
||||
|
|
|
@ -4728,6 +4728,11 @@ flatted@^3.2.9:
|
|||
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.3.tgz#67c8fad95454a7c7abebf74bb78ee74a44023358"
|
||||
integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==
|
||||
|
||||
follow-redirects@^1.15.6:
|
||||
version "1.15.9"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1"
|
||||
integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==
|
||||
|
||||
for-each@^0.3.3:
|
||||
version "0.3.3"
|
||||
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
|
||||
|
@ -5235,7 +5240,7 @@ http2-wrapper@^1.0.0-beta.5.2:
|
|||
quick-lru "^5.1.1"
|
||||
resolve-alpn "^1.0.0"
|
||||
|
||||
https-proxy-agent@^5.0.1:
|
||||
https-proxy-agent@^5.0.0, https-proxy-agent@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6"
|
||||
integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==
|
||||
|
@ -6503,7 +6508,7 @@ mime-db@1.52.0:
|
|||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
|
||||
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
|
||||
|
||||
mime-types@^2.1.12:
|
||||
mime-types@^2.1.12, mime-types@^2.1.27:
|
||||
version "2.1.35"
|
||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
|
||||
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
|
||||
|
@ -6663,6 +6668,16 @@ node-releases@^2.0.14, node-releases@^2.0.19:
|
|||
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.19.tgz#9e445a52950951ec4d177d843af370b411caf314"
|
||||
integrity sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==
|
||||
|
||||
nodejs-file-downloader@^4.13.0:
|
||||
version "4.13.0"
|
||||
resolved "https://registry.yarnpkg.com/nodejs-file-downloader/-/nodejs-file-downloader-4.13.0.tgz#da87c30081de5ff4e8b864062c98cdec03e66ad0"
|
||||
integrity sha512-nI2fKnmJWWFZF6SgMPe1iBodKhfpztLKJTtCtNYGhm/9QXmWa/Pk9Sv00qHgzEvNLe1x7hjGDRor7gcm/ChaIQ==
|
||||
dependencies:
|
||||
follow-redirects "^1.15.6"
|
||||
https-proxy-agent "^5.0.0"
|
||||
mime-types "^2.1.27"
|
||||
sanitize-filename "^1.6.3"
|
||||
|
||||
normalize-path@3.0.0, normalize-path@^3.0.0, normalize-path@~3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
|
||||
|
@ -7933,16 +7948,7 @@ string-length@^4.0.1:
|
|||
char-regex "^1.0.2"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
"string-width-cjs@npm:string-width@^4.2.0":
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
dependencies:
|
||||
emoji-regex "^8.0.0"
|
||||
is-fullwidth-code-point "^3.0.0"
|
||||
strip-ansi "^6.0.1"
|
||||
|
||||
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
|
||||
version "4.2.3"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||
|
@ -8016,14 +8022,7 @@ string_decoder@~1.1.1:
|
|||
dependencies:
|
||||
safe-buffer "~5.1.0"
|
||||
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
dependencies:
|
||||
ansi-regex "^5.0.1"
|
||||
|
||||
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
||||
|
@ -8729,16 +8728,7 @@ word-wrap@^1.2.5:
|
|||
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
|
||||
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
|
||||
|
||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
dependencies:
|
||||
ansi-styles "^4.0.0"
|
||||
string-width "^4.1.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
wrap-ansi@^7.0.0:
|
||||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||
|
|
Loading…
Reference in New Issue