forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathserverEnvironmentService.ts
191 lines (158 loc) · 6.29 KB
/
serverEnvironmentService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
import { OPTIONS, OptionDescriptions } from 'vs/platform/environment/node/argv';
import { refineServiceDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment';
import { memoize } from 'vs/base/common/decorators';
import { FileAccess } from 'vs/base/common/network';
import { AuthType } from 'vs/base/common/auth';
export const serverOptions: OptionDescriptions<ServerParsedArgs> = {
//#region @coder
'auth': { type: 'string' },
'port': { type: 'string' },
//#endregion
'pick-port': { type: 'string' },
'connectionToken': { type: 'string' }, // deprecated in favor of `--connection-token`
'connection-token': { type: 'string', description: nls.localize('connection-token', "A secret that must be included by the web client with all requests.") },
'connection-secret': { type: 'string', description: nls.localize('connection-secret', "Path to file that contains the connection token. This will require that all incoming connections know the secret.") },
'host': { type: 'string' },
'socket-path': { type: 'string' },
'driver': { type: 'string' },
'start-server': { type: 'boolean' },
'print-startup-performance': { type: 'boolean' },
'print-ip-address': { type: 'boolean' },
'disable-websocket-compression': { type: 'boolean' },
'fileWatcherPolling': { type: 'string' },
'enable-remote-auto-shutdown': { type: 'boolean' },
'remote-auto-shutdown-without-delay': { type: 'boolean' },
'without-browser-env-var': { type: 'boolean' },
'disable-telemetry': OPTIONS['disable-telemetry'],
'extensions-dir': OPTIONS['extensions-dir'],
'extensions-download-dir': OPTIONS['extensions-download-dir'],
'install-extension': OPTIONS['install-extension'],
'install-builtin-extension': OPTIONS['install-builtin-extension'],
'uninstall-extension': OPTIONS['uninstall-extension'],
'locate-extension': OPTIONS['locate-extension'],
'list-extensions': OPTIONS['list-extensions'],
'force': OPTIONS['force'],
'show-versions': OPTIONS['show-versions'],
'category': OPTIONS['category'],
'do-not-sync': OPTIONS['do-not-sync'],
'force-disable-user-env': OPTIONS['force-disable-user-env'],
'folder': { type: 'string' },
'workspace': { type: 'string' },
'web-user-data-dir': { type: 'string' },
'use-host-proxy': { type: 'string' },
'enable-sync': { type: 'boolean' },
'github-auth': { type: 'string' },
'log': { type: 'string' },
'logsPath': { type: 'string' },
'help': OPTIONS['help'],
'version': OPTIONS['version'],
'accept-server-license-terms': { type: 'boolean' },
_: OPTIONS['_']
};
export interface ServerParsedArgs {
//#region
auth?: AuthType;
//#endregion
port?: string;
'pick-port'?: string;
/**
* @deprecated use `connection-token` instead
*/
connectionToken?: string;
/**
* A secret token that must be provided by the web client with all requests.
* Use only `[0-9A-Za-z\-]`.
*
* By default, a UUID will be generated every time the server starts up.
*
* If the server is running on a multi-user system, then consider
* using `--connection-secret` which has the advantage that the token cannot
* be seen by other users using `ps` or similar commands.
*/
'connection-token'?: string;
/**
* A path to a filename which will be read on startup.
* Consider placing this file in a folder readable only by the same user (a `chmod 0700` directory).
*
* The contents of the file will be used as the connectionToken. Use only `[0-9A-Z\-]` as contents in the file.
* The file can optionally end in a `\n` which will be ignored.
*
* This secret must be communicated to any vscode instance via the resolver or embedder API.
*/
'connection-secret'?: string;
host?: string;
'socket-path'?: string;
driver?: string;
'print-startup-performance'?: boolean;
'print-ip-address'?: boolean;
'disable-websocket-compression'?: boolean;
'disable-telemetry'?: boolean;
fileWatcherPolling?: string;
'start-server'?: boolean;
'enable-remote-auto-shutdown'?: boolean;
'remote-auto-shutdown-without-delay'?: boolean;
'extensions-dir'?: string;
'extensions-download-dir'?: string;
'install-extension'?: string[];
'install-builtin-extension'?: string[];
'uninstall-extension'?: string[];
'list-extensions'?: boolean;
'locate-extension'?: string[];
'show-versions'?: boolean;
'category'?: string;
'force-disable-user-env'?: boolean;
'use-host-proxy'?: string;
'without-browser-env-var'?: boolean;
force?: boolean; // used by install-extension
'do-not-sync'?: boolean; // used by install-extension
'user-data-dir'?: string;
'builtin-extensions-dir'?: string;
// web
workspace: string;
folder: string;
'web-user-data-dir'?: string;
'enable-sync'?: boolean;
'github-auth'?: string;
'log'?: string;
'logsPath'?: string;
// server cli
help: boolean;
version: boolean;
'accept-server-license-terms': boolean;
_: string[];
}
export const IServerEnvironmentService = refineServiceDecorator<IEnvironmentService, IServerEnvironmentService>(IEnvironmentService);
export interface IServerEnvironmentService extends INativeEnvironmentService {
readonly args: ServerParsedArgs;
//#region @coder
readonly serviceWorkerFileName: string;
readonly serviceWorkerPath: string;
readonly proxyUri: string;
readonly auth: AuthType;
//#endregion
}
export class ServerEnvironmentService extends NativeEnvironmentService implements IServerEnvironmentService {
override get args(): ServerParsedArgs { return super.args as ServerParsedArgs; }
//#region @coder
public get auth(): AuthType {
return this.args['auth'] || AuthType.None;
}
public get serviceWorkerFileName(): string {
return 'service-worker.js';
}
@memoize
public get serviceWorkerPath(): string {
return FileAccess.asFileUri(`vs/code/browser/workbench/${this.serviceWorkerFileName}`, require).fsPath;
}
public get proxyUri(): string {
return '/proxy/{port}';
}
//#endregion
}