Skip to content

Commit 1bd3486

Browse files
committed
remove references to pkg and product and use productService
1 parent 27aebd4 commit 1bd3486

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/vs/code/electron-main/window.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainServ
2626
import { endsWith } from 'vs/base/common/strings';
2727
import { RunOnceScheduler } from 'vs/base/common/async';
2828
import { IFileService } from 'vs/platform/files/common/files';
29+
import pkg from 'vs/platform/product/node/package';
2930

3031
const RUN_TEXTMATE_IN_WORKER = false;
3132

@@ -309,7 +310,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
309310
private handleMarketplaceRequests(): void {
310311

311312
// Resolve marketplace headers
312-
this.marketplaceHeadersPromise = resolveMarketplaceHeaders(this.environmentService, this.fileService);
313+
this.marketplaceHeadersPromise = resolveMarketplaceHeaders(pkg.version, this.environmentService, this.fileService);
313314

314315
// Inject headers when requests are incoming
315316
const urls = ['https://marketplace.visualstudio.com/*', 'https://*.vsassets.io/*'];

src/vs/platform/extensionManagement/node/extensionGalleryService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { assign, getOrDefault } from 'vs/base/common/objects';
1111
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1212
import { IPager } from 'vs/base/common/paging';
1313
import { IRequestService, IRequestOptions, IRequestContext, asJson, asText } from 'vs/platform/request/common/request';
14-
import pkg from 'vs/platform/product/node/package';
15-
import product from 'vs/platform/product/node/product';
1614
import { isEngineValid } from 'vs/platform/extensions/node/extensionValidator';
1715
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1816
import { generateUuid, isUUID } from 'vs/base/common/uuid';
@@ -24,6 +22,7 @@ import { IFileService } from 'vs/platform/files/common/files';
2422
import { URI } from 'vs/base/common/uri';
2523
import { joinPath } from 'vs/base/common/resources';
2624
import { VSBuffer } from 'vs/base/common/buffer';
25+
import { IProductService } from 'vs/platform/product/common/product';
2726

2827
interface IRawGalleryExtensionFile {
2928
assetType: string;
@@ -339,11 +338,12 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
339338
@IEnvironmentService private readonly environmentService: IEnvironmentService,
340339
@ITelemetryService private readonly telemetryService: ITelemetryService,
341340
@IFileService private readonly fileService: IFileService,
341+
@IProductService productService: IProductService,
342342
) {
343-
const config = product.extensionsGallery;
343+
const config = productService.extensionsGallery;
344344
this.extensionsGalleryUrl = config && config.serviceUrl;
345345
this.extensionsControlUrl = config && config.controlUrl;
346-
this.commonHeadersPromise = resolveMarketplaceHeaders(this.environmentService, this.fileService);
346+
this.commonHeadersPromise = resolveMarketplaceHeaders(productService.version, this.environmentService, this.fileService);
347347
}
348348

349349
private api(path = ''): string {
@@ -774,7 +774,7 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
774774
}
775775
}
776776

777-
export async function resolveMarketplaceHeaders(environmentService: IEnvironmentService, fileService: IFileService): Promise<{ [key: string]: string; }> {
777+
export async function resolveMarketplaceHeaders(version: string, environmentService: IEnvironmentService, fileService: IFileService): Promise<{ [key: string]: string; }> {
778778
const marketplaceMachineIdFile = URI.file(path.join(environmentService.userDataPath, 'machineid'));
779779

780780
let uuid: string | null = null;
@@ -796,8 +796,8 @@ export async function resolveMarketplaceHeaders(environmentService: IEnvironment
796796
}
797797
}
798798
return {
799-
'X-Market-Client-Id': `VSCode ${pkg.version}`,
800-
'User-Agent': `VSCode ${pkg.version}`,
799+
'X-Market-Client-Id': `VSCode ${version}`,
800+
'User-Agent': `VSCode ${version}`,
801801
'X-Market-User-Id': uuid
802802
};
803803
}

src/vs/platform/extensionManagement/test/node/extensionGalleryService.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { FileService } from 'vs/platform/files/common/fileService';
1818
import { NullLogService } from 'vs/platform/log/common/log';
1919
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
2020
import { Schemas } from 'vs/base/common/network';
21+
import pkg from 'vs/platform/product/node/package';
2122

2223
suite('Extension Gallery Service', () => {
2324
const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'extensiongalleryservice');
@@ -52,10 +53,10 @@ suite('Extension Gallery Service', () => {
5253
const args = ['--user-data-dir', marketplaceHome];
5354
const environmentService = new EnvironmentService(parseArgs(args), process.execPath);
5455

55-
return resolveMarketplaceHeaders(environmentService, fileService).then(headers => {
56+
return resolveMarketplaceHeaders(pkg.version, environmentService, fileService).then(headers => {
5657
assert.ok(isUUID(headers['X-Market-User-Id']));
5758

58-
return resolveMarketplaceHeaders(environmentService, fileService).then(headers2 => {
59+
return resolveMarketplaceHeaders(pkg.version, environmentService, fileService).then(headers2 => {
5960
assert.equal(headers['X-Market-User-Id'], headers2['X-Market-User-Id']);
6061
});
6162
});

0 commit comments

Comments
 (0)