From c0113b301499471aa4de39d2b75a2ce1805e2820 Mon Sep 17 00:00:00 2001 From: ManuelHentschel <53863351+ManuelHentschel@users.noreply.github.com> Date: Thu, 25 May 2023 16:35:38 +0200 Subject: [PATCH] Fix vscdebugger install URL --- src/installRPackage.ts | 6 +++--- src/utils.ts | 44 +++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/installRPackage.ts b/src/installRPackage.ts index 85b6fa5..5d599b1 100644 --- a/src/installRPackage.ts +++ b/src/installRPackage.ts @@ -11,11 +11,11 @@ export interface PackageVersionInfo { version?: string; } -export type VersionCheckLevel = 'none'|'required'|'recommended'; +type VersionCheckLevel = 'none'|'required'|'recommended'; -export async function updateRPackage(extensionPath: string, packageName:string = 'vscDebugger'): Promise { - const url = getRDownloadLink(packageName); +export async function updateRPackage(extensionPath: string): Promise { + const url = getRDownloadLink(); const rPath = (await getRStartupArguments()).path.replace(/^"(.*)"$/, '$1'); const taskDefinition: vscode.TaskDefinition = { type: 'process' diff --git a/src/utils.ts b/src/utils.ts index 49c5dd8..2369c77 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,7 +8,20 @@ import path = require('path'); import fs = require('fs'); import winreg = require('winreg'); -const packageJson = <{[key: string]: any}>(require('../package.json')); +export interface RPackageInfo { + name: string, + required: string, + recommended: string, + warnIfNewer: string +} + +export interface PackageJson { + [key: string]: any + rPackageInfo: RPackageInfo + version: string +} + +const packageJson = (require('../package.json')); export function config(onlyDebugger: boolean = true): vscode.WorkspaceConfiguration { if(onlyDebugger){ @@ -148,19 +161,21 @@ export async function getRStartupArguments(launchConfig: { } -export function getRDownloadLink(packageName: string): string{ +export function getRDownloadLink(): string{ let url: string = config().get('packageURL', ''); if(url === ''){ - const platform: string = process.platform; - const version: string = String(packageJson.version); // e.g. "0.1.2" + const platform = process.platform; + const extensionVersion = packageJson.version; + const rPackageVersion = packageJson.rPackageInfo.recommended; // e.g. "0.1.2" + const rPackageName = packageJson.rPackageInfo.name; const urlBase = 'https://github.com/ManuelHentschel/VSCode-R-Debugger/releases/download/v' + - version + + extensionVersion + '/' + - packageName + + rPackageName + '_' + - version; + rPackageVersion; if(platform === 'win32'){ url = urlBase + '.zip'; @@ -181,19 +196,8 @@ export function escapeForRegex(text: string): string { return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } -export interface RequiredRPackageVersion { - name?: string, - required?: string, - recommended?: string, - warnIfNewer?: string -} - -export function getRequiredRPackageVersion(): RequiredRPackageVersion { - if(typeof packageJson.rPackageInfo === 'object'){ - return packageJson.rPackageInfo; - } else{ - return {}; - } +export function getRequiredRPackageVersion(): RPackageInfo { + return packageJson.rPackageInfo; }