mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-12 17:48:19 +01:00
Install remote default extensions only if already installed locally (#243499)
remote default extensions only if local
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export const REMOTE_DEFAULT_EXTENSIONS = 'remote.defaultExtensions';
|
||||
export const REMOTE_DEFAULT_IF_LOCAL_EXTENSIONS = 'remote.defaultExtensionsIfInstalledLocally';
|
||||
|
||||
@@ -8,12 +8,13 @@ import { IConfigurationService } from '../../../../platform/configuration/common
|
||||
import { IEnvironmentService } from '../../../../platform/environment/common/environment.js';
|
||||
import { EXTENSION_INSTALL_SKIP_PUBLISHER_TRUST_CONTEXT, IExtensionGalleryService, IExtensionManagementService, InstallExtensionInfo } from '../../../../platform/extensionManagement/common/extensionManagement.js';
|
||||
import { areSameExtensions } from '../../../../platform/extensionManagement/common/extensionManagementUtil.js';
|
||||
import { ExtensionType } from '../../../../platform/extensions/common/extensions.js';
|
||||
import { IFileService } from '../../../../platform/files/common/files.js';
|
||||
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
|
||||
import { ILogService } from '../../../../platform/log/common/log.js';
|
||||
import { IProductService } from '../../../../platform/product/common/productService.js';
|
||||
import { REMOTE_DEFAULT_EXTENSIONS } from '../../../../platform/remote/common/remote.js';
|
||||
import { REMOTE_DEFAULT_IF_LOCAL_EXTENSIONS } from '../../../../platform/remote/common/remote.js';
|
||||
import { IRemoteAuthorityResolverService } from '../../../../platform/remote/common/remoteAuthorityResolver.js';
|
||||
import { IRemoteExtensionsScannerService } from '../../../../platform/remote/common/remoteExtensionsScanner.js';
|
||||
import { IStorageService, IS_NEW_KEY, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
|
||||
@@ -53,7 +54,12 @@ export class InstallRemoteExtensionsContribution implements IWorkbenchContributi
|
||||
return;
|
||||
}
|
||||
|
||||
const settingValue = this.configurationService.getValue<string[]>(REMOTE_DEFAULT_EXTENSIONS);
|
||||
if (!this.extensionManagementServerService.localExtensionManagementServer) {
|
||||
this.logService.error('No local extension management server available');
|
||||
return;
|
||||
}
|
||||
|
||||
const settingValue = this.configurationService.getValue<string[]>(REMOTE_DEFAULT_IF_LOCAL_EXTENSIONS);
|
||||
if (!settingValue?.length) {
|
||||
return;
|
||||
}
|
||||
@@ -62,17 +68,24 @@ export class InstallRemoteExtensionsContribution implements IWorkbenchContributi
|
||||
|
||||
const preferPrerelease = this.productService.quality !== 'stable';
|
||||
const galleryExtensions = await this.extensionGalleryService.getExtensions(settingValue.map((id) => ({ id })), CancellationToken.None);
|
||||
const alreadyInstalledExtensions = await this.extensionManagementServerService.remoteExtensionManagementServer.extensionManagementService.getInstalled();
|
||||
const alreadyInstalledInRemote = await this.extensionManagementServerService.remoteExtensionManagementServer.extensionManagementService.getInstalled(ExtensionType.User);
|
||||
const alreadyInstalledLocally = await this.extensionManagementServerService.localExtensionManagementServer.extensionManagementService.getInstalled(ExtensionType.User);
|
||||
|
||||
const prereleaseExtensionInfo: InstallExtensionInfo[] = [];
|
||||
const extensionInfo: InstallExtensionInfo[] = [];
|
||||
for (const id of settingValue) {
|
||||
const alreadyInstalled = alreadyInstalledExtensions.some(e => areSameExtensions(e.identifier, { id }));
|
||||
const alreadyInstalled = alreadyInstalledInRemote.some(e => areSameExtensions(e.identifier, { id }));
|
||||
if (alreadyInstalled) {
|
||||
this.logService.trace(`Default remote extension '${id}' is already installed`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const installedLocally = alreadyInstalledLocally.some(e => areSameExtensions(e.identifier, { id }));
|
||||
if (!installedLocally) {
|
||||
this.logService.trace(`Default remote extension '${id}' is not already installed locally`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const extension = galleryExtensions.find(e => areSameExtensions(e.identifier, { id }));
|
||||
if (!extension) {
|
||||
this.logService.warn(`Default remote extension '${id}' is not found`);
|
||||
|
||||
@@ -26,7 +26,7 @@ import { PersistentConnection } from '../../../../platform/remote/common/remoteA
|
||||
import { IDownloadService } from '../../../../platform/download/common/download.js';
|
||||
import { DownloadServiceChannel } from '../../../../platform/download/common/downloadIpc.js';
|
||||
import { RemoteLoggerChannelClient } from '../../../../platform/log/common/logIpc.js';
|
||||
import { REMOTE_DEFAULT_EXTENSIONS } from '../../../../platform/remote/common/remote.js';
|
||||
import { REMOTE_DEFAULT_IF_LOCAL_EXTENSIONS } from '../../../../platform/remote/common/remote.js';
|
||||
|
||||
|
||||
const EXTENSION_IDENTIFIER_PATTERN = '([a-z0-9A-Z][a-z0-9-A-Z]*)\\.([a-z0-9A-Z][a-z0-9-A-Z]*)$';
|
||||
@@ -360,9 +360,9 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
|
||||
default: 'localhost',
|
||||
description: localize('remote.localPortHost', "Specifies the local host name that will be used for port forwarding.")
|
||||
},
|
||||
[REMOTE_DEFAULT_EXTENSIONS]: {
|
||||
[REMOTE_DEFAULT_IF_LOCAL_EXTENSIONS]: {
|
||||
type: 'array',
|
||||
markdownDescription: localize('remote.defaultExtensions.markdownDescription', 'List of extensions to install automatically on all remotes.'),
|
||||
markdownDescription: localize('remote.defaultExtensionsIfInstalledLocally.markdownDescription', 'List of extensions to install automatically on all remotes if already installed locally.'),
|
||||
default: [
|
||||
'GitHub.copilot',
|
||||
'GitHub.copilot-chat'
|
||||
@@ -370,7 +370,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
|
||||
items: {
|
||||
type: 'string',
|
||||
pattern: EXTENSION_IDENTIFIER_PATTERN,
|
||||
patternErrorMessage: localize('remote.defaultExtensions.invalidFormat', 'Extension identifier must be in format "publisher.name".')
|
||||
patternErrorMessage: localize('remote.defaultExtensionsIfInstalledLocally.invalidFormat', 'Extension identifier must be in format "publisher.name".')
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user