Skip to content

Commit da420cd

Browse files
committed
Merge branch 'master' of github.com:codercom/code-server
2 parents c6a46e4 + 742dd6f commit da420cd

File tree

18 files changed

+130
-53
lines changed

18 files changed

+130
-53
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dist
44
out
55
.DS_Store
66
release
7-
.cache
7+
.vscode
8+
.cache

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: node_js
22
node_js:
33
- 8.15.0
44
env:
5-
- VSCODE_VERSION="1.33.0" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION"
5+
- VSCODE_VERSION="1.33.1" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION"
66
matrix:
77
include:
88
- os: linux

Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ RUN apt-get update && apt-get install -y \
2424
git \
2525
locales \
2626
sudo \
27-
dumb-init
27+
dumb-init \
28+
vim \
29+
curl \
30+
wget
2831

2932
RUN locale-gen en_US.UTF-8
3033
# We unfortunately cannot use update-locale because docker will not use the env variables

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/c
2323

2424
## Getting Started
2525

26-
### Hosted
27-
28-
[Try `code-server` now](https://coder.com/signup) for free at coder.com.
29-
3026
### Docker
3127

3228
See docker oneliner mentioned above. Dockerfile is at [/Dockerfile](/Dockerfile).

build/tasks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const libPath = path.join(__dirname, "../lib");
1212
const vscodePath = path.join(libPath, "vscode");
1313
const defaultExtensionsPath = path.join(libPath, "extensions");
1414
const pkgsPath = path.join(__dirname, "../packages");
15-
const vscodeVersion = process.env.VSCODE_VERSION || "1.33.0";
15+
const vscodeVersion = process.env.VSCODE_VERSION || "1.33.1";
1616
const vsSourceUrl = `https://codesrv-ci.cdr.sh/vstar-${vscodeVersion}.tar.gz`;
1717

1818
const buildServerBinary = register("build:server:binary", async (runner) => {

doc/admin/install/digitalocean.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ If you're just starting out, we recommend [installing code-server locally](../..
3939
> To ensure the connection between you and your server is encrypted view our guide on [securing your setup](../../security/ssl.md)
4040
- Finally start the code-server
4141
```
42-
sudo ./code-server-linux -p 80
42+
sudo ./code-server -p 80
4343
```
4444
> For instructions on how to keep the server running after you end your SSH session please checkout [how to use systemd](https://www.linode.com/docs/quick-answers/linux/start-service-at-boot/) to start linux based services if they are killed
4545
- When you visit the public IP for your Digital Ocean instance, you will be greeted with this page. Code-server is using a self-signed SSL certificate for easy setup. To proceed to the IDE, click **"Advanced"**<img src ="../../assets/chrome_warning.png">

doc/self-hosted/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ OPTIONS
6262
> Example: `code-server -h 127.0.0.1`
6363
6464
### Open
65-
You can have the server automatically open the VS Code in your browser on startup by using the `code server -o` or `code-server --open` flags
65+
You can have the server automatically open the VS Code in your browser on startup by using the `code-server -o` or `code-server --open` flags
6666

6767
### Port
6868
By default, code-server will use `8443` as its port. This can be changed by using `code-server -p` or `code-server --port=` followed by the port you want to use.

packages/app/browser/src/app.html

+18-16
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@
77
</head>
88

99
<body>
10-
<div class="login">
11-
<div class="back"> <- Back </div>
12-
<h4 class="title">code-server</h4>
13-
<h2 class="subtitle">
14-
Enter server password
15-
</h2>
16-
<div class="mdc-text-field">
17-
<input type="password" id="password" class="mdc-text-field__input" required>
18-
<label class="mdc-floating-label" for="password">Password</label>
19-
<div class="mdc-line-ripple"></div>
20-
</div>
21-
<button id="submit" class="mdc-button mdc-button--unelevated">
22-
<span class="mdc-button__label">Enter IDE</span>
23-
</button>
24-
<div id="error-display"></div>
25-
</div>
10+
<form id="login-form">
11+
<div class="login">
12+
<div class="back">
13+
<- Back </div> <h4 class="title">code-server</h4>
14+
<h2 class="subtitle">
15+
Enter server password
16+
</h2>
17+
<div class="mdc-text-field">
18+
<input type="password" id="password" class="mdc-text-field__input" required>
19+
<label class="mdc-floating-label" for="password">Password</label>
20+
<div class="mdc-line-ripple"></div>
21+
</div>
22+
<button id="submit" class="mdc-button mdc-button--unelevated">
23+
<span class="mdc-button__label">Enter IDE</span>
24+
</button>
25+
<div id="error-display"></div>
26+
</div>
27+
</form>
2628
</body>
2729

2830
</html>

packages/app/browser/src/app.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ window.addEventListener("message", (event) => {
2020
});
2121

2222
const password = document.getElementById("password") as HTMLInputElement;
23-
const submit = document.getElementById("submit") as HTMLButtonElement;
24-
if (!submit) {
25-
throw new Error("No submit button found");
23+
const form = document.getElementById("login-form") as HTMLFormElement;
24+
25+
if (!form) {
26+
throw new Error("No password form found");
2627
}
27-
submit.addEventListener("click", () => {
28+
29+
form.addEventListener("submit", (e) => {
30+
e.preventDefault();
2831
document.cookie = `password=${password.value}`;
2932
location.reload();
3033
});
@@ -38,4 +41,4 @@ const errorDisplay = document.getElementById("error-display") as HTMLDivElement;
3841

3942
if (document.referrer === document.location.href && matches) {
4043
errorDisplay.innerText = "Password is incorrect!";
41-
}
44+
}

packages/ide/src/fill/electron.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ const newCreateElement = <K extends keyof HTMLElementTagNameMap>(tagName: K): HT
4545
},
4646
set: (value: string): void => {
4747
if (value) {
48-
value = value.replace(/file:\/\//g, "/resource");
48+
const resourceBaseUrl = location.pathname.replace(/\/$/, "") + "/resource";
49+
value = value.replace(/file:\/\//g, resourceBaseUrl);
4950
}
5051
oldSrc!.set!.call(img, value);
5152
},
@@ -66,7 +67,8 @@ const newCreateElement = <K extends keyof HTMLElementTagNameMap>(tagName: K): HT
6667
},
6768
set: (value: string): void => {
6869
if (value) {
69-
value = value.replace(/file:\/\//g, "/resource");
70+
const resourceBaseUrl = location.pathname.replace(/\/$/, "") + "/resource";
71+
value = value.replace(/file:\/\//g, resourceBaseUrl);
7072
}
7173
oldInnerHtml!.set!.call(style, value);
7274
},
@@ -80,7 +82,8 @@ const newCreateElement = <K extends keyof HTMLElementTagNameMap>(tagName: K): HT
8082
if (sheet && !overridden) {
8183
const oldInsertRule = sheet.insertRule;
8284
sheet.insertRule = (rule: string, index?: number): void => {
83-
rule = rule.replace(/file:\/\//g, "/resource");
85+
const resourceBaseUrl = location.pathname.replace(/\/$/, "") + "/resource";
86+
rule = rule.replace(/file:\/\//g, resourceBaseUrl);
8487
oldInsertRule.call(sheet, rule, index);
8588
};
8689
overridden = true;
@@ -145,8 +148,9 @@ const newCreateElement = <K extends keyof HTMLElementTagNameMap>(tagName: K): HT
145148
(view as any).send = (channel: string, ...args: any[]): void => { // tslint:disable-line no-any
146149
if (args[0] && typeof args[0] === "object" && args[0].contents) {
147150
// TODO
148-
args[0].contents = (args[0].contents as string).replace(/"(file:\/\/[^"]*)"/g, (m1) => `"/resource${m1}"`);
149-
args[0].contents = (args[0].contents as string).replace(/"vscode-resource:([^"]*)"/g, (m, m1) => `"/resource${m1}"`);
151+
const resourceBaseUrl = location.pathname.replace(/\/$/, "") + "/resource";
152+
args[0].contents = (args[0].contents as string).replace(/"(file:\/\/[^"]*)"/g, (m1) => `"${resourceBaseUrl}${m1}"`);
153+
args[0].contents = (args[0].contents as string).replace(/"vscode-resource:([^"]*)"/g, (m, m1) => `"${resourceBaseUrl}${m1}"`);
150154
args[0].contents = (args[0].contents as string).replace(/style-src vscode-core-resource:/g, "style-src 'self'");
151155
}
152156
if (view.contentWindow) {

packages/ide/src/retry.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class Retry {
7575

7676
// Times are in seconds.
7777
private readonly retryMinDelay = 1;
78-
private readonly retryMaxDelay = 10;
78+
private readonly retryMaxDelay = 3;
7979
private readonly maxImmediateRetries = 5;
8080
private readonly retryExponent = 1.5;
8181
private blocked: string | boolean | undefined;

packages/server/src/cli.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@ const bold = (text: string | number): string | number => {
200200
const webpackConfig = require(path.resolve(__dirname, "..", "..", "web", "webpack.config.js"));
201201
const compiler = require("webpack")(webpackConfig);
202202
app.use(require("webpack-dev-middleware")(compiler, {
203-
logger,
203+
logger: {
204+
trace: (m: string): void => logger.trace("webpack", field("message", m)),
205+
debug: (m: string): void => logger.debug("webpack", field("message", m)),
206+
info: (m: string): void => logger.info("webpack", field("message", m)),
207+
warn: (m: string): void => logger.warn("webpack", field("message", m)),
208+
error: (m: string): void => logger.error("webpack", field("message", m)),
209+
},
204210
publicPath: webpackConfig.output.publicPath,
205211
stats: webpackConfig.stats,
206212
}));

packages/vscode/src/dialog.scss

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
--primary: #2A2E37;
33
--border: black;
44
--faded: #a0a1a5;
5+
--disabled: #888;
56
--header-background: #161616;
67
--header-foreground: white;
78
--list-active-selection-background: rgb(0, 120, 160);
@@ -101,6 +102,12 @@
101102
background-color: var(--list-active-selection-background);
102103
color: var(--list-active-selection-foreground);
103104
}
105+
106+
&.disabled, &.disabled:hover {
107+
background-color: var(--primary);
108+
color: var(--disabled);
109+
cursor: initial;
110+
}
104111
}
105112
}
106113

@@ -134,6 +141,11 @@
134141
color: white;
135142
}
136143
}
144+
145+
button[disabled], button[disabled]:hover {
146+
color: var(--disabled);
147+
cursor: initial;
148+
}
137149
}
138150
}
139151

packages/vscode/src/dialog.ts

+47-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import { IThemeService } from "vs/platform/theme/common/themeService";
1616
import { workbench } from "./workbench";
1717
import "./dialog.scss";
1818

19+
/**
20+
* Describes the type of dialog to show.
21+
*/
1922
export enum DialogType {
2023
NewFolder,
2124
Save,
@@ -68,8 +71,12 @@ interface DialogEntry {
6871
readonly isDirectory: boolean;
6972
readonly size: number;
7073
readonly lastModified: string;
74+
readonly isDisabled?: boolean;
7175
}
7276

77+
/**
78+
* Open and save dialogs.
79+
*/
7380
class Dialog {
7481
private _path: string | undefined;
7582

@@ -265,8 +272,7 @@ class Dialog {
265272
}
266273
if (element.isDirectory) {
267274
this.path = element.fullPath;
268-
} else {
269-
// Open
275+
} else if (!(this.options as OpenDialogOptions).properties.openDirectory) {
270276
this.selectEmitter.emit(element.fullPath);
271277
}
272278
});
@@ -282,12 +288,18 @@ class Dialog {
282288
});
283289
buttonsNode.appendChild(cancelBtn);
284290
const confirmBtn = document.createElement("button");
285-
confirmBtn.innerText = "Confirm";
291+
const openFile = (this.options as OpenDialogOptions).properties.openFile;
292+
confirmBtn.innerText = openFile ? "Open" : "Confirm";
286293
confirmBtn.addEventListener("click", () => {
287-
if (this._path) {
294+
if (this._path && !openFile) {
288295
this.selectEmitter.emit(this._path);
289296
}
290297
});
298+
// Since a single click opens a file, the only time this button can be
299+
// used is on a directory, which is invalid for opening files.
300+
if (openFile) {
301+
confirmBtn.disabled = true;
302+
}
291303
buttonsNode.appendChild(confirmBtn);
292304
this.root.appendChild(buttonsNode);
293305
this.entryList.layout();
@@ -303,13 +315,19 @@ class Dialog {
303315
return this.errorEmitter.event;
304316
}
305317

318+
/**
319+
* Remove the dialog.
320+
*/
306321
public dispose(): void {
307322
this.selectEmitter.dispose();
308323
this.errorEmitter.dispose();
309324
this.entryList.dispose();
310325
this.background.remove();
311326
}
312327

328+
/**
329+
* Build and insert the path shown at the top of the dialog.
330+
*/
313331
private buildPath(): void {
314332
while (this.pathNode.lastChild) {
315333
this.pathNode.removeChild(this.pathNode.lastChild);
@@ -376,6 +394,9 @@ class Dialog {
376394
return (<any>this.entryList).typeFilterController.filter._pattern;
377395
}
378396

397+
/**
398+
* List the files and return dialog entries.
399+
*/
379400
private async list(directory: string): Promise<ReadonlyArray<DialogEntry>> {
380401
const paths = (await util.promisify(fs.readdir)(directory)).sort();
381402
const stats = await Promise.all(paths.map(p => util.promisify(fs.stat)(path.join(directory, p))));
@@ -386,6 +407,8 @@ class Dialog {
386407
isDirectory: stat.isDirectory(),
387408
lastModified: stat.mtime.toDateString(),
388409
size: stat.size,
410+
// If we are opening a directory, show files as disabled.
411+
isDisabled: !stat.isDirectory() && (this.options as OpenDialogOptions).properties.openDirectory,
389412
}));
390413
}
391414
}
@@ -397,11 +420,17 @@ interface DialogEntryData {
397420
label: HighlightedLabel;
398421
}
399422

423+
/**
424+
* Rendering for the different parts of a dialog entry.
425+
*/
400426
class DialogEntryRenderer implements ITreeRenderer<DialogEntry, string, DialogEntryData> {
401427
public get templateId(): string {
402428
return "dialog-entry";
403429
}
404430

431+
/**
432+
* Append and return containers for each part of the dialog entry.
433+
*/
405434
public renderTemplate(container: HTMLElement): DialogEntryData {
406435
addClass(container, "dialog-entry");
407436
addClass(container, "dialog-grid");
@@ -422,6 +451,9 @@ class DialogEntryRenderer implements ITreeRenderer<DialogEntry, string, DialogEn
422451
};
423452
}
424453

454+
/**
455+
* Render a dialog entry.
456+
*/
425457
public renderElement(node: ITreeNode<DialogEntry, string>, _index: number, templateData: DialogEntryData): void {
426458
templateData.icon.className = "dialog-entry-icon monaco-icon-label";
427459
const classes = getIconClasses(
@@ -444,8 +476,19 @@ class DialogEntryRenderer implements ITreeRenderer<DialogEntry, string, DialogEn
444476
}] : []);
445477
templateData.size.innerText = node.element.size.toString();
446478
templateData.lastModified.innerText = node.element.lastModified;
479+
480+
// We know this exists because we created the template.
481+
const entryContainer = templateData.label.element.parentElement!.parentElement!.parentElement!;
482+
if (node.element.isDisabled) {
483+
entryContainer.classList.add("disabled");
484+
} else {
485+
entryContainer.classList.remove("disabled");
486+
}
447487
}
448488

489+
/**
490+
* Does nothing (not implemented).
491+
*/
449492
public disposeTemplate(_templateData: DialogEntryData): void {
450493
// throw new Error("Method not implemented.");
451494
}

packages/vscode/src/fill/storageDatabase.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
2828
}
2929

3030
this.triggerFlush(WillSaveStateReason.SHUTDOWN);
31-
navigator.sendBeacon(`/resource${this.path}`, this.content);
31+
const resourceBaseUrl = location.pathname.replace(/\/$/, "") + "/resource";
32+
navigator.sendBeacon(`${resourceBaseUrl}/${this.path}`, this.content);
3233
});
3334
}
3435

0 commit comments

Comments
 (0)