Code Cleanup & Remove Potential Tech Debt for Modes
remove places where we make assumptions on the existing model (sdk or runtime) to prevent future tech debt
This commit is contained in:
Родитель
e691be3deb
Коммит
f5c8fcf0c7
|
@ -36,14 +36,13 @@ import {
|
|||
IIssueContext,
|
||||
InstallationValidator,
|
||||
registerEventStream,
|
||||
RuntimeInstallationDirectoryProvider,
|
||||
VersionResolver,
|
||||
VSCodeExtensionContext,
|
||||
VSCodeEnvironment,
|
||||
WindowDisplayWorker,
|
||||
DotnetSDKAcquisitionStarted,
|
||||
GlobalInstallerResolver,
|
||||
SdkInstallationDirectoryProvider,
|
||||
getDirectoryPerMode,
|
||||
CommandExecutor,
|
||||
IDotnetListVersionsContext,
|
||||
WebRequestWorker,
|
||||
|
@ -406,7 +405,7 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
|
|||
installationValidator: new InstallationValidator(globalEventStream),
|
||||
timeoutSeconds: resolvedTimeoutSeconds,
|
||||
installMode: mode,
|
||||
installDirectoryProvider: mode === 'runtime' ? new RuntimeInstallationDirectoryProvider(context.globalStoragePath): new SdkInstallationDirectoryProvider(context.globalStoragePath),
|
||||
installDirectoryProvider: getDirectoryPerMode(mode, context.storagePath),
|
||||
proxyUrl: proxyLink,
|
||||
isExtensionTelemetryInitiallyEnabled: isExtensionTelemetryEnabled
|
||||
}
|
||||
|
|
|
@ -3,4 +3,6 @@
|
|||
* The .NET Foundation licenses this file to you under the MIT license.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export type DotnetInstallMode = 'sdk' | 'runtime' | 'aspnetcore';
|
||||
export type DotnetInstallMode = 'sdk' | 'runtime' | 'aspnetcore';
|
||||
|
||||
export const DotnetInstallModeList = ['sdk', 'runtime', 'aspnetcore'];
|
|
@ -3,6 +3,9 @@
|
|||
* The .NET Foundation licenses this file to you under the MIT license.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as path from 'path';
|
||||
import { SdkInstallationDirectoryProvider } from './SdkInstallationDirectoryProvider';
|
||||
import { RuntimeInstallationDirectoryProvider } from './RuntimeInstallationDirectoryProvider';
|
||||
import { DotnetInstallMode } from './DotnetInstallMode';
|
||||
|
||||
export abstract class IInstallationDirectoryProvider {
|
||||
constructor(protected storagePath: string) { }
|
||||
|
@ -14,3 +17,8 @@ export abstract class IInstallationDirectoryProvider {
|
|||
return path.join(this.storagePath, installFolderName);
|
||||
}
|
||||
}
|
||||
|
||||
export function getDirectoryPerMode(mode : DotnetInstallMode, storagePath : string)
|
||||
{
|
||||
return mode === 'runtime' ? new RuntimeInstallationDirectoryProvider(storagePath) : new SdkInstallationDirectoryProvider(storagePath);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ export interface InstallRecord
|
|||
}
|
||||
|
||||
|
||||
// we might be able to get rid of this
|
||||
/**
|
||||
* @remarks
|
||||
* The record can be the type or it can be a 'legacy' record from old installs which is just a string with the install key.
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
import { DotnetCoreAcquisitionWorker } from '../Acquisition/DotnetCoreAcquisitionWorker';
|
||||
import { looksLikeRuntimeVersion } from '../Acquisition/DotnetInstall';
|
||||
import { DotnetInstall } from '../Acquisition/DotnetInstall';
|
||||
import { DotnetInstallModeList } from '../Acquisition/DotnetInstallMode';
|
||||
import { IAcquisitionWorkerContext } from '../Acquisition/IAcquisitionWorkerContext';
|
||||
import { IDotnetAcquireContext } from '../IDotnetAcquireContext';
|
||||
import * as os from 'os';
|
||||
|
||||
export function getInstallKeyFromContext(ctx : IAcquisitionWorkerContext | undefined | null) : DotnetInstall | null
|
||||
|
@ -32,7 +32,8 @@ export function getInstallKeyFromContext(ctx : IAcquisitionWorkerContext | undef
|
|||
}
|
||||
export function isRuntimeInstallKey(installKey: string): boolean {
|
||||
const installKeyVersion = getVersionFromLegacyInstallKey(installKey);
|
||||
return !installKey.includes('sdk') && looksLikeRuntimeVersion(installKeyVersion);
|
||||
return !(DotnetInstallModeList.filter( (x : string) => x !== 'runtime')).some( (mode) => installKey.includes(mode))
|
||||
&& looksLikeRuntimeVersion(installKeyVersion);
|
||||
}
|
||||
|
||||
export function isGlobalLegacyInstallKey(installKey: string): boolean {
|
||||
|
|
|
@ -47,6 +47,7 @@ export * from './Acquisition/LinuxGlobalInstaller';
|
|||
export * from './Acquisition/VersionResolver';
|
||||
export * from './Acquisition/WinMacGlobalInstaller';
|
||||
export * from './Acquisition/ExistingPathResolver';
|
||||
export * from './Acquisition/IInstallationDirectoryProvider';
|
||||
export * from './Acquisition/SdkInstallationDirectoryProvider';
|
||||
export * from './Acquisition/RuntimeInstallationDirectoryProvider';
|
||||
export * from './test/mocks/MockObjects';
|
||||
|
|
|
@ -5,15 +5,13 @@
|
|||
* ------------------------------------------------------------------------------------------ */
|
||||
import * as os from 'os';
|
||||
|
||||
import { RuntimeInstallationDirectoryProvider } from '../../Acquisition/RuntimeInstallationDirectoryProvider';
|
||||
import { SdkInstallationDirectoryProvider } from '../../Acquisition/SdkInstallationDirectoryProvider';
|
||||
import { MockWindowDisplayWorker } from '../mocks/MockWindowDisplayWorker';
|
||||
import { MockDotnetCoreAcquisitionWorker, MockEventStream, MockExtensionContext, MockInstallationValidator, MockVSCodeEnvironment, MockVSCodeExtensionContext } from '../mocks/MockObjects';
|
||||
import { IDotnetAcquireContext } from '../../IDotnetAcquireContext';
|
||||
import { IAcquisitionWorkerContext } from '../../Acquisition/IAcquisitionWorkerContext';
|
||||
import { IEventStream } from '../../EventStream/EventStream';
|
||||
import { IUtilityContext } from '../../Utils/IUtilityContext';
|
||||
import { IInstallationDirectoryProvider } from '../../Acquisition/IInstallationDirectoryProvider';
|
||||
import { getDirectoryPerMode, IInstallationDirectoryProvider } from '../../Acquisition/IInstallationDirectoryProvider';
|
||||
import { DotnetInstallMode } from '../../Acquisition/DotnetInstallMode';
|
||||
|
||||
const standardTimeoutTime = 100000;
|
||||
|
@ -34,7 +32,7 @@ export function getMockAcquisitionContext(mode: DotnetInstallMode, version : str
|
|||
installMode: mode,
|
||||
installingArchitecture: arch,
|
||||
proxyUrl: undefined,
|
||||
installDirectoryProvider: directory ? directory : mode === 'runtime' ? new RuntimeInstallationDirectoryProvider('') : new SdkInstallationDirectoryProvider(''),
|
||||
installDirectoryProvider: directory ? directory : getDirectoryPerMode(mode, ''),
|
||||
isExtensionTelemetryInitiallyEnabled: true
|
||||
};
|
||||
return workerContext;
|
||||
|
|
Загрузка…
Ссылка в новой задаче