Skip to content

Commit 5f00e79

Browse files
committed
Replace default extension marketplace with Open VSX.
1 parent 65b2462 commit 5f00e79

File tree

8 files changed

+58
-35
lines changed

8 files changed

+58
-35
lines changed

product.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,15 @@
100100
"keyboardShortcutsUrlWin": "https://go.microsoft.com/fwlink/?linkid=832145",
101101
"introductoryVideosUrl": "https://go.microsoft.com/fwlink/?linkid=832146",
102102
"tipsAndTricksUrl": "https://go.microsoft.com/fwlink/?linkid=852118",
103-
"newsletterSignupUrl": "https://www.research.net/r/vsc-newsletter"
103+
"newsletterSignupUrl": "https://www.research.net/r/vsc-newsletter",
104+
"extensionsGallery": {
105+
"serviceUrl": "https://open-vsx.org/vscode/gallery",
106+
"itemUrl": "https://open-vsx.org/vscode/item",
107+
"resourceUrlTemplate": "https://open-vsx.org/vscode/asset/{publisher}/{name}/{version}/Microsoft.VisualStudio.Code.WebResources/{path}",
108+
"controlUrl": "",
109+
"recommendationsUrl": ""
110+
},
111+
"linkProtectionTrustedDomains": [
112+
"https://open-vsx.org"
113+
]
104114
}

src/vs/base/node/marketplace.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,13 @@ const extractTar = async (tarPath: string, targetPath: string, options: vszip.IE
158158
/**
159159
* Override original functionality so we can use a custom marketplace with
160160
* either tars or zips.
161+
* @deprecated This should be phased out as we move toward Open VSX.
161162
*/
162-
export const enableCustomMarketplace = (product: IProductConfiguration): void => {
163-
const extensionsGallery: IProductConfiguration['extensionsGallery'] = {
164-
serviceUrl: process.env.SERVICE_URL || 'https://extensions.coder.com/api',
165-
resourceUrlTemplate: '',
166-
itemUrl: process.env.ITEM_URL || '',
167-
controlUrl: '',
168-
recommendationsUrl: '',
169-
...(product.extensionsGallery || {}),
170-
};
171-
172-
// Workaround for readonly property.
173-
Object.assign(product, { extensionsGallery });
163+
export const monkeyPatchVSZip = (product: IProductConfiguration): void => {
164+
if (product.extensionsGallery?.serviceUrl !== 'https://extensions.coder.com/api') {
165+
return;
166+
}
167+
console.log('Patching VS Zip...');
174168

175169
const target = vszip as typeof vszip;
176170

src/vs/code/node/cli.ts

-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { isAbsolute, join } from 'vs/base/common/path';
1111
import { IProcessEnvironment, isWindows } from 'vs/base/common/platform';
1212
import { randomPort } from 'vs/base/common/ports';
1313
import { isString } from 'vs/base/common/types';
14-
import { enableCustomMarketplace } from 'vs/base/node/marketplace';
1514
import { whenDeleted, writeFileSync } from 'vs/base/node/pfs';
1615
import { findFreePort } from 'vs/base/node/ports';
1716
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
@@ -35,9 +34,6 @@ interface IMainCli {
3534
}
3635

3736
export async function main(argv: string[]): Promise<any> {
38-
/** @coder */
39-
enableCustomMarketplace(product);
40-
4137
let args: NativeParsedArgs;
4238

4339
try {

src/vs/code/node/cliProcessMain.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Schemas } from 'vs/base/common/network';
1515
import { isAbsolute, join } from 'vs/base/common/path';
1616
import { cwd } from 'vs/base/common/process';
1717
import { URI } from 'vs/base/common/uri';
18-
import { enableCustomMarketplace } from 'vs/base/node/marketplace';
18+
import { monkeyPatchVSZip } from 'vs/base/node/marketplace';
1919
import { Promises } from 'vs/base/node/pfs';
2020
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2121
import { ConfigurationService } from 'vs/platform/configuration/common/configurationService';
@@ -59,7 +59,7 @@ class CliMain extends Disposable {
5959
gracefulify(fs);
6060

6161
/** @coder */
62-
enableCustomMarketplace(product);
62+
monkeyPatchVSZip(product);
6363

6464
this.registerListeners();
6565
}

src/vs/platform/product/common/product.ts

+35
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,39 @@ else {
7676
}
7777
}
7878

79+
/**
80+
* Override original functionality so we can use a custom marketplace with
81+
* either tars or zips.
82+
* @deprecated This should be phased out as we move toward Open VSX.
83+
*/
84+
function parseExtensionsGallery(product: IProductConfiguration) {
85+
if (typeof env['EXTENSIONS_GALLERY'] === 'undefined') {
86+
return;
87+
}
88+
89+
let extensionsGallery: NonNullable<IProductConfiguration['extensionsGallery']>;
90+
91+
try {
92+
extensionsGallery = {
93+
serviceUrl: '',
94+
itemUrl: '',
95+
resourceUrlTemplate: '',
96+
controlUrl: '',
97+
recommendationsUrl: '',
98+
...JSON.parse(env['EXTENSIONS_GALLERY'])
99+
};
100+
} catch (error) {
101+
console.error(error);
102+
return;
103+
}
104+
105+
console.log(`Custom marketplace enabled.`);
106+
console.log(JSON.stringify(extensionsGallery, null, 2));
107+
108+
// Workaround for readonly property.
109+
Object.assign(product, { extensionsGallery });
110+
}
111+
112+
parseExtensionsGallery(product);
113+
79114
export default product;

src/vs/server/@types/code-server-lib/index.d.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ declare global {
1919
authed: boolean;
2020
disableUpdateCheck: boolean;
2121
startPath?: StartPath;
22-
codeServerVersion: string;
22+
codeServerVersion?: string;
2323
serverUrl: URL;
2424
}
2525

@@ -29,13 +29,6 @@ declare global {
2929

3030
export type CreateVSServer = (serverConfiguration: ServerConfiguration) => Promise<Server>;
3131

32-
/**
33-
* Base options included on every page.
34-
*/
35-
export interface ClientConfiguration extends Pick<ServerConfiguration, 'codeServerVersion'> {
36-
base: string;
37-
csStaticBase: string;
38-
}
3932

4033
/**
4134
* @deprecated This should be removed when code-server merges with lib/vscode
@@ -72,4 +65,4 @@ declare global {
7265
}
7366
}
7467

75-
export {};
68+
export { };

src/vs/server/entry.ts

-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { enableCustomMarketplace } from 'vs/base/node/marketplace';
7-
import product from 'vs/platform/product/common/product';
86
import { ArgumentParser } from '../platform/environment/node/argumentParser';
97
import { ServerProcessMain } from './main';
108

@@ -35,7 +33,6 @@ export const main = async () => {
3533
args,
3634
authed: false,
3735
disableUpdateCheck: true,
38-
codeServerVersion: 'Unknown',
3936
serverUrl,
4037
});
4138

@@ -51,8 +48,6 @@ export const main = async () => {
5148
* It should eventually be phased out and folded into VS Code's existing CLI flow.
5249
*/
5350
export const createVSServer: CodeServerLib.CreateVSServer = async serverConfig => {
54-
enableCustomMarketplace(product);
55-
5651
const codeServer = new ServerProcessMain(serverConfig);
5752

5853
return codeServer.startup({ listenWhenReady: false });

src/vs/server/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import { ILifecycleService, NullLifecycleService } from 'vs/workbench/services/l
8282
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME } from 'vs/workbench/services/remote/common/remoteAgentFileSystemChannel';
8383
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
8484
import { UriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentityService';
85-
import { enableCustomMarketplace } from 'vs/base/node/marketplace';
85+
import { monkeyPatchVSZip } from 'vs/base/node/marketplace';
8686

8787
interface IServerProcessMainStartupOptions {
8888
listenWhenReady?: boolean;
@@ -110,7 +110,7 @@ export class ServerProcessMain extends Disposable implements IServerProcessMain
110110
// Enable gracefulFs
111111
gracefulify(fs);
112112

113-
enableCustomMarketplace(product);
113+
monkeyPatchVSZip(product);
114114
this.registerListeners();
115115
}
116116

0 commit comments

Comments
 (0)