Archived
1
0

Update to 1.39.2

Also too the opportunity to rewrite the build script since there was a
change in the build steps (mainly how the product JSON is inserted) and
to get the build changes out of the patch. It also no longer relies on
external caching (we'll want to do this within CI instead).
This commit is contained in:
Asher
2019-10-18 18:20:02 -05:00
parent 56ce780522
commit bdd11f741b
25 changed files with 1122 additions and 1320 deletions

View File

@ -12,8 +12,7 @@ import { ExtensionIdentifier, IExtensionDescription } from "vs/platform/extensio
import { FileDeleteOptions, FileOpenOptions, FileOverwriteOptions, FileType, IStat, IWatchOptions } from "vs/platform/files/common/files";
import { DiskFileSystemProvider } from "vs/platform/files/node/diskFileSystemProvider";
import { ILogService } from "vs/platform/log/common/log";
import pkg from "vs/platform/product/node/package";
import product from "vs/platform/product/node/product";
import product from "vs/platform/product/common/product";
import { IRemoteAgentEnvironment } from "vs/platform/remote/common/remoteAgentEnvironment";
import { ITelemetryService } from "vs/platform/telemetry/common/telemetry";
import { INodeProxyService } from "vs/server/src/common/nodeProxy";
@ -228,7 +227,7 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
const scanMultiple = (isBuiltin: boolean, isUnderDevelopment: boolean, paths: string[]): Promise<IExtensionDescription[][]> => {
return Promise.all(paths.map((path) => {
return ExtensionScanner.scanExtensions(new ExtensionScannerInput(
pkg.version,
product.version,
product.commit,
locale,
!!process.env.VSCODE_DEV,
@ -295,7 +294,7 @@ export class NodeProxyService implements INodeProxyService {
public readonly onClose = this._onClose.event;
public constructor() {
// TODO: close/down/up
// TODO: down/up
const { Server } = localRequire<typeof import("@coder/node-browser/out/server/server")>("@coder/node-browser/out/server/server");
this.server = new Server({
onMessage: this.$onMessage,

View File

@ -5,10 +5,9 @@ import { setUnexpectedErrorHandler } from "vs/base/common/errors";
import { main as vsCli } from "vs/code/node/cliProcessMain";
import { validatePaths } from "vs/code/node/paths";
import { ParsedArgs } from "vs/platform/environment/common/environment";
import { buildHelpMessage, buildVersionMessage, Option as VsOption, options as vsOptions } from "vs/platform/environment/node/argv";
import { buildHelpMessage, buildVersionMessage, Option as VsOption, OPTIONS, OptionDescriptions } from "vs/platform/environment/node/argv";
import { parseMainProcessArgv } from "vs/platform/environment/node/argvHelper";
import pkg from "vs/platform/product/node/package";
import product from "vs/platform/product/node/product";
import product from "vs/platform/product/common/product";
import { ipcMain } from "vs/server/src/node/ipc";
import { enableCustomMarketplace } from "vs/server/src/node/marketplace";
import { MainServer } from "vs/server/src/node/server";
@ -24,7 +23,7 @@ interface Args extends ParsedArgs {
"cert-key"?: string;
format?: string;
host?: string;
open?: string;
open?: boolean;
port?: string;
socket?: string;
}
@ -35,14 +34,9 @@ interface Option extends VsOption {
}
const getArgs = (): Args => {
const options = vsOptions as Option[];
// The last item is _ which is like -- so our options need to come before it.
const last = options.pop()!;
// Remove options that won't work or don't make sense.
let i = options.length;
while (i--) {
switch (options[i].id) {
for (let key in OPTIONS) {
switch (key) {
case "add":
case "diff":
case "file-uri":
@ -57,24 +51,21 @@ const getArgs = (): Args => {
case "prof-startup":
case "inspect-extensions":
case "inspect-brk-extensions":
options.splice(i, 1);
delete OPTIONS[key];
break;
}
}
options.push({ id: "base-path", type: "string", cat: "o", description: "Base path of the URL at which code-server is hosted (used for login redirects)." });
options.push({ id: "cert", type: "string", cat: "o", description: "Path to certificate. If the path is omitted, both this and --cert-key will be generated." });
options.push({ id: "cert-key", type: "string", cat: "o", description: "Path to the certificate's key if one was provided." });
options.push({ id: "extra-builtin-extensions-dir", type: "string", cat: "o", description: "Path to an extra builtin extension directory." });
options.push({ id: "extra-extensions-dir", type: "string", cat: "o", description: "Path to an extra user extension directory." });
options.push({ id: "format", type: "string", cat: "o", description: `Format for the version. ${buildAllowedMessage(FormatType)}.` });
options.push({ id: "host", type: "string", cat: "o", description: "Host for the server." });
options.push({ id: "auth", type: "string", cat: "o", description: `The type of authentication to use. ${buildAllowedMessage(AuthType)}.` });
options.push({ id: "open", type: "boolean", cat: "o", description: "Open in the browser on startup." });
options.push({ id: "port", type: "string", cat: "o", description: "Port for the main server." });
options.push({ id: "socket", type: "string", cat: "o", description: "Listen on a socket instead of host:port." });
options.push(last);
const options = OPTIONS as OptionDescriptions<Required<Args>>;
options["base-path"] = { type: "string", cat: "o", description: "Base path of the URL at which code-server is hosted (used for login redirects)." };
options["cert"] = { type: "string", cat: "o", description: "Path to certificate. If the path is omitted, both this and --cert-key will be generated." };
options["cert-key"] = { type: "string", cat: "o", description: "Path to the certificate's key if one was provided." };
options["format"] = { type: "string", cat: "o", description: `Format for the version. ${buildAllowedMessage(FormatType)}.` };
options["host"] = { type: "string", cat: "o", description: "Host for the server." };
options["auth"] = { type: "string", cat: "o", description: `The type of authentication to use. ${buildAllowedMessage(AuthType)}.` };
options["open"] = { type: "boolean", cat: "o", description: "Open in the browser on startup." };
options["port"] = { type: "string", cat: "o", description: "Port for the main server." };
options["socket"] = { type: "string", cat: "o", description: "Listen on a socket instead of host:port." };
const args = parseMainProcessArgv(process.argv);
if (!args["user-data-dir"]) {
@ -84,6 +75,10 @@ const getArgs = (): Args => {
args["extensions-dir"] = path.join(args["user-data-dir"], "extensions");
}
if (!args.verbose && !args.log && process.env.LOG_LEVEL) {
args.log = process.env.LOG_LEVEL;
}
return validatePaths(args);
};
@ -161,19 +156,19 @@ const startCli = (): boolean | Promise<void> => {
const args = getArgs();
if (args.help) {
const executable = `${product.applicationName}${os.platform() === "win32" ? ".exe" : ""}`;
console.log(buildHelpMessage(product.nameLong, executable, pkg.codeServerVersion, undefined, false));
console.log(buildHelpMessage(product.nameLong, executable, product.codeServerVersion, OPTIONS, false));
return true;
}
if (args.version) {
if (args.format === "json") {
console.log(JSON.stringify({
codeServerVersion: pkg.codeServerVersion,
codeServerVersion: product.codeServerVersion,
commit: product.commit,
vscodeVersion: pkg.version,
vscodeVersion: product.version,
}));
} else {
buildVersionMessage(pkg.codeServerVersion, product.commit).split("\n").map((line) => logger.info(line));
buildVersionMessage(product.codeServerVersion, product.commit).split("\n").map((line) => logger.info(line));
}
return true;
}

View File

@ -5,7 +5,7 @@ import { CancellationToken } from "vs/base/common/cancellation";
import { mkdirp } from "vs/base/node/pfs";
import * as vszip from "vs/base/node/zip";
import * as nls from "vs/nls";
import product from "vs/platform/product/node/product";
import product from "vs/platform/product/common/product";
import { localRequire } from "vs/server/src/node/util";
const tarStream = localRequire<typeof import("tar-stream")>("tar-stream/index");

View File

@ -3,7 +3,7 @@ import * as path from "path";
import * as util from "util";
import { getPathFromAmdModule } from "vs/base/common/amd";
import * as lp from "vs/base/node/languagePacks";
import product from "vs/platform/product/node/product";
import product from "vs/platform/product/common/product";
import { Translations } from "vs/workbench/services/extensions/common/extensionPoints";
const configurations = new Map<string, Promise<lp.NLSConfiguration>>();
@ -28,6 +28,12 @@ export const getNlsConfiguration = async (locale: string, userDataPath: string):
if (isInternalConfiguration(config)) {
config._languagePackSupport = true;
}
// If the configuration has no results keep trying since code-server
// doesn't restart when a language is installed so this result would
// persist (the plugin might not be installed yet or something).
if (config.locale !== "en" && config.locale !== "en-us" && Object.keys(config.availableLanguages).length === 0) {
configurations.delete(id);
}
resolve(config);
}));
}

View File

@ -17,13 +17,12 @@ import { generateUuid } from "vs/base/common/uuid";
import { getMachineId } from 'vs/base/node/id';
import { NLSConfiguration } from "vs/base/node/languagePacks";
import { mkdirp, rimraf } from "vs/base/node/pfs";
import { ClientConnectionEvent, IPCServer, StaticRouter } from "vs/base/parts/ipc/common/ipc";
import { ClientConnectionEvent, IPCServer } from "vs/base/parts/ipc/common/ipc";
import { createChannelReceiver } from "vs/base/parts/ipc/node/ipc";
import { LogsDataCleaner } from "vs/code/electron-browser/sharedProcess/contrib/logsDataCleaner";
import { IConfigurationService } from "vs/platform/configuration/common/configuration";
import { ConfigurationService } from "vs/platform/configuration/node/configurationService";
import { ExtensionHostDebugBroadcastChannel } from "vs/platform/debug/common/extensionHostDebugIpc";
import { IDialogService } from "vs/platform/dialogs/common/dialogs";
import { DialogChannelClient } from "vs/platform/dialogs/node/dialogIpc";
import { IEnvironmentService, ParsedArgs } from "vs/platform/environment/common/environment";
import { EnvironmentService } from "vs/platform/environment/node/environmentService";
import { ExtensionGalleryService } from "vs/platform/extensionManagement/common/extensionGalleryService";
@ -38,13 +37,11 @@ import { InstantiationService } from "vs/platform/instantiation/common/instantia
import { ServiceCollection } from "vs/platform/instantiation/common/serviceCollection";
import { ILocalizationsService } from "vs/platform/localizations/common/localizations";
import { LocalizationsService } from "vs/platform/localizations/node/localizations";
import { LocalizationsChannel } from "vs/platform/localizations/node/localizationsIpc";
import { getLogLevel, ILogService } from "vs/platform/log/common/log";
import { LogLevelSetterChannel } from "vs/platform/log/common/logIpc";
import { LoggerChannel } from "vs/platform/log/common/logIpc";
import { SpdLogService } from "vs/platform/log/node/spdlogService";
import { IProductService } from "vs/platform/product/common/product";
import pkg from "vs/platform/product/node/package";
import product from "vs/platform/product/node/product";
import product from 'vs/platform/product/common/product';
import { IProductService } from "vs/platform/product/common/productService";
import { ConnectionType, ConnectionTypeRequest } from "vs/platform/remote/common/remoteAgentConnection";
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME } from "vs/platform/remote/common/remoteAgentFileSystemChannel";
import { IRequestService } from "vs/platform/request/common/request";
@ -56,14 +53,14 @@ import { ITelemetryServiceConfig, TelemetryService } from "vs/platform/telemetry
import { combinedAppender, LogAppender, NullTelemetryService } from "vs/platform/telemetry/common/telemetryUtils";
import { AppInsightsAppender } from "vs/platform/telemetry/node/appInsightsAppender";
import { resolveCommonProperties } from "vs/platform/telemetry/node/commonProperties";
import { UpdateChannel } from "vs/platform/update/node/updateIpc";
import { UpdateChannel } from "vs/platform/update/electron-main/updateIpc";
import { INodeProxyService, NodeProxyChannel } from "vs/server/src/common/nodeProxy";
import { TelemetryChannel } from "vs/server/src/common/telemetry";
import { ExtensionEnvironmentChannel, FileProviderChannel, NodeProxyService } from "vs/server/src/node/channel";
import { Connection, ExtensionHostConnection, ManagementConnection } from "vs/server/src/node/connection";
import { TelemetryClient } from "vs/server/src/node/insights";
import { getLocaleFromConfig, getNlsConfiguration } from "vs/server/src/node/nls";
import { NodeProxyChannel, INodeProxyService } from "vs/server/src/common/nodeProxy";
import { Protocol } from "vs/server/src/node/protocol";
import { TelemetryChannel } from "vs/server/src/common/telemetry";
import { UpdateService } from "vs/server/src/node/update";
import { AuthType, getMediaMime, getUriTransformer, localRequire, tmpdir } from "vs/server/src/node/util";
import { RemoteExtensionLogFileName } from "vs/workbench/services/remote/common/remoteAgentService";
@ -82,8 +79,9 @@ export enum HttpCode {
}
export interface Options {
WORKBENCH_WEB_CONGIGURATION: IWorkbenchConstructionOptions;
WORKBENCH_WEB_CONFIGURATION: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents };
REMOTE_USER_DATA_URI: UriComponents | URI;
PRODUCT_CONFIGURATION: Partial<IProductService>;
NLS_CONFIGURATION: NLSConfiguration;
}
@ -280,7 +278,7 @@ export abstract class Server {
// without adding query parameters which have their own issues.
// REVIEW: Discuss whether this is the best option; this is sort of a quick
// hack almost to get caching in the meantime but it does work pretty well.
if (/^\/static-.+/.test(base)) {
if (/^\/static-/.test(base)) {
base = "/static";
}
@ -361,7 +359,7 @@ export abstract class Server {
if (this.authenticate(request, data)) {
return {
redirect: "/",
headers: {"Set-Cookie": `password=${data.password}` }
headers: { "Set-Cookie": `password=${data.password}` }
};
}
console.error("Failed login attempt", JSON.stringify({
@ -538,7 +536,7 @@ export class MainServer extends Server {
}
private async getRoot(request: http.IncomingMessage, parsedUrl: url.UrlWithParsedQuery): Promise<Response> {
const filePath = path.join(this.rootPath, "out/vs/code/browser/workbench/workbench.html");
const filePath = path.join(this.rootPath, "out/vs/server/src/browser/workbench.html");
let [content, startPath] = await Promise.all([
util.promisify(fs.readFile)(filePath, "utf8"),
this.getFirstValidPath([
@ -567,17 +565,20 @@ export class MainServer extends Server {
const environment = this.services.get(IEnvironmentService) as IEnvironmentService;
const options: Options = {
WORKBENCH_WEB_CONGIGURATION: {
WORKBENCH_WEB_CONFIGURATION: {
workspaceUri: startPath && startPath.workspace ? transformer.transformOutgoing(startPath.uri) : undefined,
folderUri: startPath && !startPath.workspace ? transformer.transformOutgoing(startPath.uri) : undefined,
remoteAuthority,
productConfiguration: product,
logLevel: getLogLevel(environment),
},
REMOTE_USER_DATA_URI: transformer.transformOutgoing(URI.file(environment.userDataPath)),
PRODUCT_CONFIGURATION: {
extensionsGallery: product.extensionsGallery,
},
REMOTE_USER_DATA_URI: transformer.transformOutgoing((<EnvironmentService>environment).webUserDataHome),
NLS_CONFIGURATION: await getNlsConfiguration(environment.args.locale || await getLocaleFromConfig(environment.userDataPath), environment.userDataPath),
};
content = content.replace(/\/static\//g, `/static${product.commit ? `-${product.commit}` : ""}/`).replace("{{WEBVIEW_ENDPOINT}}", "");
content = content.replace(/{{COMMIT}}/g, product.commit || "");
for (const key in options) {
content = content.replace(`"{{${key}}}"`, `'${JSON.stringify(options[key as keyof Options])}'`);
}
@ -698,17 +699,15 @@ export class MainServer extends Server {
...environmentService.extraBuiltinExtensionPaths,
);
this.ipc.registerChannel("loglevel", new LogLevelSetterChannel(logService));
this.ipc.registerChannel("logger", new LoggerChannel(logService));
this.ipc.registerChannel(ExtensionHostDebugBroadcastChannel.ChannelName, new ExtensionHostDebugBroadcastChannel());
const router = new StaticRouter((ctx: any) => ctx.clientId === "renderer");
this.services.set(ILogService, logService);
this.services.set(IEnvironmentService, environmentService);
this.services.set(IConfigurationService, new SyncDescriptor(ConfigurationService, [environmentService.machineSettingsResource]));
this.services.set(IRequestService, new SyncDescriptor(RequestService));
this.services.set(IFileService, fileService);
this.services.set(IProductService, { _serviceBrand: undefined, ...product });
this.services.set(IDialogService, new DialogChannelClient(this.ipc.getChannel("dialog", router)));
this.services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
this.services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
@ -719,7 +718,7 @@ export class MainServer extends Server {
new LogAppender(logService),
),
commonProperties: resolveCommonProperties(
product.commit, pkg.codeServerVersion, await getMachineId(),
product.commit, product.codeServerVersion, await getMachineId(),
[], environmentService.installSourcePath, "code-server",
),
piiPaths: this.allowedRequestPaths,
@ -730,32 +729,25 @@ export class MainServer extends Server {
await new Promise((resolve) => {
const instantiationService = new InstantiationService(this.services);
const localizationService = instantiationService.createInstance(LocalizationsService);
this.services.set(ILocalizationsService, localizationService);
const proxyService = instantiationService.createInstance(NodeProxyService);
this.services.set(INodeProxyService, proxyService);
this.ipc.registerChannel("localizations", new LocalizationsChannel(localizationService));
this.services.set(ILocalizationsService, instantiationService.createInstance(LocalizationsService));
this.services.set(INodeProxyService, instantiationService.createInstance(NodeProxyService));
instantiationService.invokeFunction(() => {
instantiationService.createInstance(LogsDataCleaner);
const extensionsService = this.services.get(IExtensionManagementService) as IExtensionManagementService;
const telemetryService = this.services.get(ITelemetryService) as ITelemetryService;
const extensionsChannel = new ExtensionManagementChannel(extensionsService, (context) => getUriTransformer(context.remoteAuthority));
const extensionsEnvironmentChannel = new ExtensionEnvironmentChannel(environmentService, logService, telemetryService, this.options.connectionToken || "");
const fileChannel = new FileProviderChannel(environmentService, logService);
const requestChannel = new RequestChannel(this.services.get(IRequestService) as IRequestService);
const telemetryChannel = new TelemetryChannel(telemetryService);
const updateChannel = new UpdateChannel(instantiationService.createInstance(UpdateService));
const nodeProxyChannel = new NodeProxyChannel(proxyService);
this.ipc.registerChannel("extensions", extensionsChannel);
this.ipc.registerChannel("remoteextensionsenvironment", extensionsEnvironmentChannel);
this.ipc.registerChannel("request", requestChannel);
this.ipc.registerChannel("telemetry", telemetryChannel);
this.ipc.registerChannel("nodeProxy", nodeProxyChannel);
this.ipc.registerChannel("update", updateChannel);
this.ipc.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, fileChannel);
this.ipc.registerChannel("extensions", new ExtensionManagementChannel(
this.services.get(IExtensionManagementService) as IExtensionManagementService,
(context) => getUriTransformer(context.remoteAuthority),
));
this.ipc.registerChannel("remoteextensionsenvironment", new ExtensionEnvironmentChannel(
environmentService, logService, telemetryService, this.options.connectionToken || "",
));
this.ipc.registerChannel("request", new RequestChannel(this.services.get(IRequestService) as IRequestService));
this.ipc.registerChannel("telemetry", new TelemetryChannel(telemetryService));
this.ipc.registerChannel("nodeProxy", new NodeProxyChannel(this.services.get(INodeProxyService) as INodeProxyService));
this.ipc.registerChannel("localizations", createChannelReceiver(this.services.get(ILocalizationsService) as ILocalizationsService));
this.ipc.registerChannel("update", new UpdateChannel(instantiationService.createInstance(UpdateService)));
this.ipc.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, new FileProviderChannel(environmentService, logService));
resolve(new ErrorTelemetry(telemetryService));
});
});

View File

@ -11,9 +11,9 @@ import { IConfigurationService } from "vs/platform/configuration/common/configur
import { IEnvironmentService } from "vs/platform/environment/common/environment";
import { IFileService } from "vs/platform/files/common/files";
import { ILogService } from "vs/platform/log/common/log";
import pkg from "vs/platform/product/node/package";
import product from "vs/platform/product/common/product";
import { asJson, IRequestService } from "vs/platform/request/common/request";
import { AvailableForDownload, State, StateType, UpdateType } from "vs/platform/update/common/update";
import { AvailableForDownload, State, UpdateType } from "vs/platform/update/common/update";
import { AbstractUpdateService } from "vs/platform/update/electron-main/abstractUpdateService";
import { ipcMain } from "vs/server/src/node/ipc";
import { extract } from "vs/server/src/node/marketplace";
@ -43,25 +43,22 @@ export class UpdateService extends AbstractUpdateService {
}
if (latest) {
const latestMajor = parseInt(latest.name);
const currentMajor = parseInt(pkg.codeServerVersion);
const currentMajor = parseInt(product.codeServerVersion);
return !isNaN(latestMajor) && !isNaN(currentMajor) &&
currentMajor <= latestMajor && latest.name === pkg.codeServerVersion;
currentMajor <= latestMajor && latest.name === product.codeServerVersion;
}
return true;
}
protected buildUpdateFeedUrl(): string {
return "https://api.github.com/repos/cdr/code-server/releases/latest";
protected buildUpdateFeedUrl(quality: string): string {
return `${product.updateUrl}/${quality}`;
}
protected doQuitAndInstall(): void {
public async doQuitAndInstall(): Promise<void> {
ipcMain.relaunch();
}
protected async doCheckForUpdates(context: any): Promise<void> {
if (this.state.type !== StateType.Idle) {
return Promise.resolve();
}
this.setState(State.CheckingForUpdates(context));
try {
const update = await this.getLatestVersion();
@ -81,15 +78,13 @@ export class UpdateService extends AbstractUpdateService {
private async getLatestVersion(): Promise<IUpdate | null> {
const data = await this.requestService.request({
url: this.url,
headers: {
"User-Agent": "code-server",
},
headers: { "User-Agent": "code-server" },
}, CancellationToken.None);
return asJson(data);
}
protected async doDownloadUpdate(state: AvailableForDownload): Promise<void> {
this.setState(State.Updating(state.update));
this.setState(State.Downloading(state.update));
const target = os.platform();
const releaseName = await this.buildReleaseName(state.update.version);
const url = "https://github.com/cdr/code-server/releases/download/"
@ -125,8 +120,7 @@ export class UpdateService extends AbstractUpdateService {
private onRequestError(error: Error, showNotification?: boolean): void {
this.logService.error(error);
const message: string | undefined = showNotification ? (error.message || error.toString()) : undefined;
this.setState(State.Idle(UpdateType.Archive, message));
this.setState(State.Idle(UpdateType.Archive, showNotification ? (error.message || error.toString()) : undefined));
}
private async buildReleaseName(release: string): Promise<string> {
@ -136,7 +130,7 @@ export class UpdateService extends AbstractUpdateService {
stderr: error.message,
stdout: "",
}));
if (result.stderr.indexOf("musl") !== -1 || result.stdout.indexOf("musl") !== -1) {
if (/^musl/.test(result.stderr) || /^musl/.test(result.stdout)) {
target = "alpine";
}
}