mirror of
https://github.com/coder/code-server.git
synced 2026-05-05 20:15:19 +02:00
feat: apply patch after setting up subtree
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
* A list of command line arguments we support natively.
|
||||
*/
|
||||
export interface NativeParsedArgs {
|
||||
'extra-extensions-dir'?: string[];
|
||||
'extra-builtin-extensions-dir'?: string[];
|
||||
_: string[];
|
||||
'folder-uri'?: string[]; // undefined or array of 1 or more
|
||||
'file-uri'?: string[]; // undefined or array of 1 or more
|
||||
|
||||
@@ -122,6 +122,8 @@ export interface INativeEnvironmentService extends IEnvironmentService {
|
||||
extensionsPath?: string;
|
||||
extensionsDownloadPath: string;
|
||||
builtinExtensionsPath: string;
|
||||
extraExtensionPaths: string[]
|
||||
extraBuiltinExtensionPaths: string[]
|
||||
|
||||
// --- Smoke test support
|
||||
driverHandle?: string;
|
||||
|
||||
@@ -54,6 +54,8 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
|
||||
'extensions-dir': { type: 'string', deprecates: 'extensionHomePath', cat: 'e', args: 'dir', description: localize('extensionHomePath', "Set the root path for extensions.") },
|
||||
'extensions-download-dir': { type: 'string' },
|
||||
'builtin-extensions-dir': { type: 'string' },
|
||||
'extra-builtin-extensions-dir': { type: 'string[]', cat: 'o', description: 'Path to an extra builtin extension directory.' },
|
||||
'extra-extensions-dir': { type: 'string[]', cat: 'o', description: 'Path to an extra user extension directory.' },
|
||||
'list-extensions': { type: 'boolean', cat: 'e', description: localize('listExtensions', "List the installed extensions.") },
|
||||
'show-versions': { type: 'boolean', cat: 'e', description: localize('showVersions', "Show versions of installed extensions, when using --list-extension.") },
|
||||
'category': { type: 'string', cat: 'e', description: localize('category', "Filters installed extensions by provided category, when using --list-extension.") },
|
||||
@@ -318,4 +320,3 @@ export function buildHelpMessage(productName: string, executableName: string, ve
|
||||
export function buildVersionMessage(version: string | undefined, commit: string | undefined): string {
|
||||
return `${version || localize('unknownVersion', "Unknown version")}\n${commit || localize('unknownCommit', "Unknown commit")}\n${process.arch}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +138,13 @@ export class NativeEnvironmentService implements INativeEnvironmentService {
|
||||
return resources.joinPath(this.userHome, product.dataFolderName, 'extensions').fsPath;
|
||||
}
|
||||
|
||||
@memoize get extraExtensionPaths(): string[] {
|
||||
return (this._args['extra-extensions-dir'] || []).map((p) => <string>parsePathArg(p, process));
|
||||
}
|
||||
@memoize get extraBuiltinExtensionPaths(): string[] {
|
||||
return (this._args['extra-builtin-extensions-dir'] || []).map((p) => <string>parsePathArg(p, process));
|
||||
}
|
||||
|
||||
@memoize
|
||||
get extensionDevelopmentLocationURI(): URI[] | undefined {
|
||||
const s = this._args.extensionDevelopmentPath;
|
||||
|
||||
@@ -91,7 +91,7 @@ export class ExtensionsScanner extends Disposable {
|
||||
}
|
||||
|
||||
async scanAllUserExtensions(): Promise<ILocalExtension[]> {
|
||||
return this.scanExtensionsInDir(this.extensionsPath, ExtensionType.User);
|
||||
return this.scanExtensionsInDirs(this.extensionsPath, this.environmentService.extraExtensionPaths, ExtensionType.User);
|
||||
}
|
||||
|
||||
async extractUserExtension(identifierWithVersion: ExtensionIdentifierWithVersion, zipPath: string, token: CancellationToken): Promise<ILocalExtension> {
|
||||
@@ -236,7 +236,13 @@ export class ExtensionsScanner extends Disposable {
|
||||
|
||||
private async scanExtensionsInDir(dir: string, type: ExtensionType): Promise<ILocalExtension[]> {
|
||||
const limiter = new Limiter<any>(10);
|
||||
const extensionsFolders = await pfs.readdir(dir);
|
||||
const extensionsFolders = await pfs.readdir(dir)
|
||||
.catch((error) => {
|
||||
if (error.code !== 'ENOENT') {
|
||||
throw error;
|
||||
}
|
||||
return <string[]>[];
|
||||
});
|
||||
const extensions = await Promise.all<ILocalExtension>(extensionsFolders.map(extensionFolder => limiter.queue(() => this.scanExtension(extensionFolder, dir, type))));
|
||||
return extensions.filter(e => e && e.identifier);
|
||||
}
|
||||
@@ -266,7 +272,7 @@ export class ExtensionsScanner extends Disposable {
|
||||
}
|
||||
|
||||
private async scanDefaultSystemExtensions(): Promise<ILocalExtension[]> {
|
||||
const result = await this.scanExtensionsInDir(this.systemExtensionsPath, ExtensionType.System);
|
||||
const result = await this.scanExtensionsInDirs(this.systemExtensionsPath, this.environmentService.extraBuiltinExtensionPaths, ExtensionType.System);
|
||||
this.logService.trace('Scanned system extensions:', result.length);
|
||||
return result;
|
||||
}
|
||||
@@ -370,4 +376,9 @@ export class ExtensionsScanner extends Disposable {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async scanExtensionsInDirs(dir: string, dirs: string[], type: ExtensionType): Promise<ILocalExtension[]>{
|
||||
const results = await Promise.all([dir, ...dirs].map((path) => this.scanExtensionsInDir(path, type)));
|
||||
return results.reduce((flat, current) => flat.concat(current), []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,12 @@ if (isWeb || typeof require === 'undefined' || typeof require.__$__nodeRequire !
|
||||
],
|
||||
});
|
||||
}
|
||||
// NOTE@coder: Add the ability to inject settings from the server.
|
||||
const el = document.getElementById('vscode-remote-product-configuration');
|
||||
const rawProductConfiguration = el && el.getAttribute('data-settings');
|
||||
if (rawProductConfiguration) {
|
||||
Object.assign(product, JSON.parse(rawProductConfiguration));
|
||||
}
|
||||
}
|
||||
|
||||
// Native (non-sandboxed)
|
||||
|
||||
@@ -32,6 +32,8 @@ export type ConfigurationSyncStore = {
|
||||
};
|
||||
|
||||
export interface IProductConfiguration {
|
||||
readonly codeServerVersion?: string;
|
||||
|
||||
readonly version: string;
|
||||
readonly date?: string;
|
||||
readonly quality?: string;
|
||||
|
||||
@@ -208,7 +208,8 @@ export class BrowserSocketFactory implements ISocketFactory {
|
||||
}
|
||||
|
||||
connect(host: string, port: number, query: string, callback: IConnectCallback): void {
|
||||
const socket = this._webSocketFactory.create(`ws://${host}:${port}/?${query}&skipWebSocketFrames=false`);
|
||||
// NOTE@coder: Modified to work against the current path.
|
||||
const socket = this._webSocketFactory.create(`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.host}${window.location.pathname}?${query}&skipWebSocketFrames=false`);
|
||||
const errorListener = socket.onError((err) => callback(err, undefined));
|
||||
socket.onOpen(() => {
|
||||
errorListener.dispose();
|
||||
@@ -216,6 +217,3 @@ export class BrowserSocketFactory implements ISocketFactory {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
|
||||
options.socketFactory.connect(
|
||||
options.host,
|
||||
options.port,
|
||||
`reconnectionToken=${options.reconnectionToken}&reconnection=${options.reconnectionProtocol ? 'true' : 'false'}`,
|
||||
`type=${connectionTypeToString(connectionType)}&reconnectionToken=${options.reconnectionToken}&reconnection=${options.reconnectionProtocol ? 'true' : 'false'}`,
|
||||
(err: any, socket: ISocket | undefined) => {
|
||||
if (err || !socket) {
|
||||
options.logService.error(`${logPrefix} socketFactory.connect() failed. Error:`);
|
||||
@@ -338,7 +338,8 @@ export class ReconnectionWaitEvent {
|
||||
public readonly type = PersistentConnectionEventType.ReconnectionWait;
|
||||
constructor(
|
||||
public readonly durationSeconds: number,
|
||||
private readonly cancellableTimer: CancelablePromise<void>
|
||||
private readonly cancellableTimer: CancelablePromise<void>,
|
||||
public readonly connectionAttempt: number
|
||||
) { }
|
||||
|
||||
public skipWait(): void {
|
||||
@@ -422,7 +423,7 @@ abstract class PersistentConnection extends Disposable {
|
||||
const waitTime = (attempt < TIMES.length ? TIMES[attempt] : TIMES[TIMES.length - 1]);
|
||||
try {
|
||||
const sleepPromise = sleep(waitTime);
|
||||
this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise));
|
||||
this._onDidStateChange.fire(new ReconnectionWaitEvent(waitTime, sleepPromise, attempt+1));
|
||||
|
||||
this._options.logService.info(`${logPrefix} waiting for ${waitTime} seconds before reconnecting...`);
|
||||
try {
|
||||
|
||||
@@ -122,8 +122,8 @@ export class BrowserStorageService extends Disposable implements IStorageService
|
||||
return this.getStorage(scope).getNumber(key, fallbackValue);
|
||||
}
|
||||
|
||||
store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): void {
|
||||
this.getStorage(scope).set(key, value);
|
||||
store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise<void> {
|
||||
return this.getStorage(scope).set(key, value);
|
||||
}
|
||||
|
||||
remove(key: string, scope: StorageScope): void {
|
||||
|
||||
@@ -85,7 +85,7 @@ export interface IStorageService {
|
||||
* The scope argument allows to define the scope of the storage
|
||||
* operation to either the current workspace only or all workspaces.
|
||||
*/
|
||||
store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): void;
|
||||
store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise<void> | void;
|
||||
|
||||
/**
|
||||
* Delete an element stored under the provided key from storage.
|
||||
|
||||
@@ -201,8 +201,8 @@ export class NativeStorageService extends Disposable implements IStorageService
|
||||
return this.getStorage(scope).getNumber(key, fallbackValue);
|
||||
}
|
||||
|
||||
store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): void {
|
||||
this.getStorage(scope).set(key, value);
|
||||
store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise<void> {
|
||||
return this.getStorage(scope).set(key, value);
|
||||
}
|
||||
|
||||
remove(key: string, scope: StorageScope): void {
|
||||
|
||||
Reference in New Issue
Block a user