Skip to content

Commit d20519f

Browse files
author
Katie Horne
committed
Merge conflicts
2 parents 4d6bbab + 2a5f5e4 commit d20519f

File tree

20 files changed

+514
-156
lines changed

20 files changed

+514
-156
lines changed

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ updates:
1919
time: "11:00"
2020
ignore:
2121
- dependency-name: "@types/node"
22-
versions: ["15.x", "14.x", "13.x"]
22+
update-types: ["version-update:semver-major"]
2323
- dependency-name: "xdg-basedir"
2424
# 5.0.0 has breaking changes as they switch to named exports
2525
# and convert the module to ESM

.github/workflows/ci.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ on:
1616

1717
jobs:
1818
prebuild:
19-
name: Pre-build checks
19+
name: Pre-Build checks
2020
runs-on: ubuntu-latest
21+
timeout-minutes: 5
2122
env:
2223
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2324
steps:
@@ -65,6 +66,7 @@ jobs:
6566
name: Run audit-ci
6667
needs: prebuild
6768
runs-on: ubuntu-latest
69+
timeout-minutes: 5
6870
steps:
6971
- name: Checkout repo
7072
uses: actions/checkout@v2
@@ -95,6 +97,7 @@ jobs:
9597
name: Build
9698
needs: prebuild
9799
runs-on: ubuntu-latest
100+
timeout-minutes: 30
98101
steps:
99102
- uses: actions/checkout@v2
100103
with:
@@ -170,6 +173,7 @@ jobs:
170173
name: x86-64 Linux build
171174
needs: build
172175
runs-on: ubuntu-latest
176+
timeout-minutes: 15
173177
container: "centos:7"
174178

175179
steps:
@@ -240,6 +244,7 @@ jobs:
240244
name: Linux ARM64 cross-compile build
241245
needs: build
242246
runs-on: ubuntu-16.04
247+
timeout-minutes: 15
243248
env:
244249
AR: aarch64-linux-gnu-ar
245250
CC: aarch64-linux-gnu-gcc
@@ -293,6 +298,7 @@ jobs:
293298
name: x86-64 macOS build
294299
needs: build
295300
runs-on: macos-latest
301+
timeout-minutes: 15
296302
steps:
297303
- uses: actions/checkout@v2
298304

@@ -333,6 +339,7 @@ jobs:
333339
name: End-to-end tests
334340
needs: package-linux-amd64
335341
runs-on: ubuntu-latest
342+
timeout-minutes: 15
336343
env:
337344
# Since we build code-server we might as well run tests from the release
338345
# since VS Code will load faster due to the bundling.

docs/guide.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- [Using a self-signed certificate](#using-a-self-signed-certificate)
1111
- [External authentication](#external-authentication)
1212
- [HTTPS](#https)
13-
- [Securely accessing development web services](#securely-accessing-development-web-services)
13+
- [Self Signed Certificate](#self-signed-certificate)
1414
- [Using a subdomain](#using-a-subdomain)
1515
- [Using a subpath](#using-a-subpath)
1616
- [Stripping `/proxy/<port>` from the request path](#stripping-proxyport-from-the-request-path)
@@ -202,6 +202,10 @@ At this point, you should be able to access code-server via
202202
At this point, you should be able to access code-server via
203203
`https://mydomain.com`.
204204

205+
> If you set `proxy_set_header Host $host;` in your reverse proxy config, it
206+
> will change the address displayed in the green section of code-server in the
207+
> bottom left to show the correct address.
208+
205209
### Using a self-signed certificate
206210

207211
> Self signed certificates do not work with iPad; see [./ipad.md](./ipad.md) for
@@ -276,7 +280,7 @@ redirect all HTTP requests to HTTPS.
276280
> You can use [Let's Encrypt](https://letsencrypt.org/) to get a TLS certificate
277281
for free.
278282

279-
## Securely accessing development web services
283+
### Self Signed Certificate
280284

281285
If you're working on a web service and want to access it locally, code-server
282286
can proxy to any port using either a subdomain or a subpath, allowing you to

docs/install.md

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
33
# Install
44

5+
<<<<<<< HEAD
56
- [Install](#install)
67
- [install.sh](#installsh)
78
- [Detection reference](#detection-reference)
@@ -16,6 +17,22 @@
1617
- [Raspberry Pi](#raspberry-pi)
1718
- [Termux](#termux)
1819
- [Cloud providers](#cloud-providers)
20+
=======
21+
- [Install](#install)
22+
- [install.sh](#installsh)
23+
- [Detection reference](#detection-reference)
24+
- [yarn, npm](#yarn-npm)
25+
- [Standalone releases](#standalone-releases)
26+
- [Debian, Ubuntu](#debian-ubuntu)
27+
- [Fedora, CentOS, RHEL, SUSE](#fedora-centos-rhel-suse)
28+
- [Arch Linux](#arch-linux)
29+
- [macOS](#macos)
30+
- [Docker](#docker)
31+
- [Helm](#helm)
32+
- [Raspberry Pi](#raspberry-pi)
33+
- [Termux](#termux)
34+
- [Cloud providers](#cloud-providers)
35+
>>>>>>> main
1936
2037
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2138

@@ -247,3 +264,4 @@ information.
247264
We maintain [one-click apps and install scripts for cloud
248265
providers](https://github.com/cdr/deploy-code-server) such as DigitalOcean,
249266
Railway, Heroku, and Azure.
267+
[https://github.com/cdr/deploy-code-server](https://github.com/cdr/deploy-code-server)

docs/npm.md

+21
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Alpine](#alpine)
1010
- [macOS](#macos)
1111
- [FreeBSD](#freebsd)
12+
- [Issues with Node.js after version upgrades](#issues-with-nodejs-after-version-upgrades)
1213

1314
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1415

@@ -63,3 +64,23 @@ xcode-select --install
6364
pkg install -y git python npm-node14 yarn-node14 pkgconf
6465
pkg install -y libinotify
6566
```
67+
68+
## Issues with Node.js after version upgrades
69+
70+
Occasionally, you may run into issues with Node.js.
71+
72+
If you install code-server using `yarn` or `npm`, and you upgrade your Node.js
73+
version, you may need to reinstall code-server to recompile native modules.
74+
Sometimes, you can get around this by navigating into code-server's `lib/vscode`
75+
directory and running `npm rebuild` to recompile the modules.
76+
77+
A step-by-step example of how you might do this is:
78+
79+
1. Install code-server: `brew install code-server`
80+
2. Navigate into the directory: `cd
81+
/usr/local/Cellar/code-server/<version>/libexec/lib/vscode/`
82+
3. Recompile the native modules: `npm rebuild`
83+
4. Restart code-server
84+
85+
If you need further assistance, post on our [GitHub Discussions
86+
page](https://github.com/cdr/code-server/discussions).

install.sh

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eu
33

44
# code-server's automatic install script.
5-
# See https://github.com/cdr/code-server/blob/main/docs/install.md
5+
# See https://coder.com/docs/code-server/v3.10.2/install
66

77
usage() {
88
arg0="$0"
@@ -58,7 +58,7 @@ Usage:
5858
- If Homebrew is not installed it will install the latest standalone release
5959
into ~/.local
6060
61-
- For FreeBSD, it will install the npm package with yarn or npm.
61+
- For FreeBSD or Alpine, it will install the npm package with yarn or npm.
6262
6363
- If ran on an architecture with no releases, it will install the
6464
npm package with yarn or npm.
@@ -67,7 +67,7 @@ Usage:
6767
6868
It will cache all downloaded assets into ~/.cache/code-server
6969
70-
More installation docs are at https://github.com/cdr/code-server/blob/main/docs/install.md
70+
More installation docs are at https://coder.com/docs/code-server/v3.10.2/install
7171
EOF
7272
}
7373

@@ -238,6 +238,17 @@ main() {
238238
return
239239
fi
240240

241+
if [ "$OS" = "linux" ] && [ "$(distro)" = "alpine" ]; then
242+
if [ "$METHOD" = standalone ]; then
243+
echoerr "No precompiled releases available for alpine."
244+
echoerr 'Please rerun without the "--method standalone" flag to install from npm.'
245+
exit 1
246+
fi
247+
echoh "No precompiled releases available for alpine."
248+
install_npm
249+
return
250+
fi
251+
241252
CACHE_DIR="$(echo_cache_dir)"
242253

243254
if [ "$METHOD" = standalone ]; then
@@ -419,7 +430,7 @@ install_npm() {
419430
echoh
420431
echoerr "Please install npm or yarn to install code-server!"
421432
echoerr "You will need at least node v12 and a few C dependencies."
422-
echoerr "See the docs https://github.com/cdr/code-server/blob/v3.10.2/docs/install.md#yarn-npm"
433+
echoerr "See the docs https://coder.com/docs/code-server/v3.10.2/install#yarn-npm"
423434
exit 1
424435
}
425436

lib/vscode/src/vs/workbench/contrib/files/browser/explorerViewlet.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,15 @@ viewsRegistry.registerViewWelcomeContent(EmptyView.ID, {
303303
order: 1
304304
});
305305

306+
// NOTE@coder:
307+
// We use OpenFolderAction.ID instead of commandId
308+
// because for some reason, the command openFileFolder
309+
// does not work as expected and causes the "Open Folder"
310+
// command to not work
311+
// See: https://github.com/cdr/code-server/issues/3457
306312
viewsRegistry.registerViewWelcomeContent(EmptyView.ID, {
307313
content: localize({ key: 'noFolderHelp', comment: ['Please do not translate the word "commmand", it is part of our internal syntax which must not change'] },
308-
"You have not yet opened a folder.\n[Open Folder](command:{0})", commandId),
314+
"You have not yet opened a folder.\n[Open Folder](command:{0})", OpenFolderAction.ID),
309315
when: ContextKeyExpr.or(ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), RemoteNameContext.isEqualTo('')), ContextKeyExpr.and(WorkbenchStateContext.notEqualsTo('workspace'), IsWebContext)),
310316
group: ViewContentGroups.Open,
311317
order: 1

package.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
"@types/tar-fs": "^2.0.0",
5353
"@types/tar-stream": "^2.1.0",
5454
"@types/ws": "^7.2.6",
55-
"@types/wtfnode": "^0.7.0",
5655
"@typescript-eslint/eslint-plugin": "^4.7.0",
5756
"@typescript-eslint/parser": "^4.7.0",
5857
"audit-ci": "^4.0.0",
@@ -64,15 +63,13 @@
6463
"eslint-import-resolver-alias": "^1.1.2",
6564
"eslint-plugin-import": "^2.18.2",
6665
"eslint-plugin-prettier": "^3.1.0",
67-
"leaked-handles": "^5.2.0",
6866
"prettier": "^2.2.1",
6967
"prettier-plugin-sh": "^0.7.1",
7068
"shellcheck": "^1.0.0",
7169
"stylelint": "^13.0.0",
7270
"stylelint-config-recommended": "^5.0.0",
7371
"ts-node": "^10.0.0",
74-
"typescript": "^4.1.3",
75-
"wtfnode": "^0.9.0"
72+
"typescript": "^4.1.3"
7673
},
7774
"resolutions": {
7875
"normalize-package-data": "^3.0.0",
@@ -95,7 +92,6 @@
9592
"httpolyglot": "^0.1.2",
9693
"js-yaml": "^4.0.0",
9794
"limiter": "^1.1.5",
98-
"node-fetch": "^2.6.1",
9995
"pem": "^1.14.2",
10096
"proxy-agent": "^4.0.0",
10197
"proxy-from-env": "^1.1.0",
@@ -106,7 +102,6 @@
106102
"semver": "^7.1.3",
107103
"split2": "^3.2.2",
108104
"tar-fs": "^2.0.0",
109-
"tar-stream": "^2.2.0",
110105
"ws": "^7.2.0",
111106
"xdg-basedir": "^4.0.0",
112107
"yarn": "^1.22.4"

src/browser/pages/vscode.ts

+58-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,64 @@ try {
9595
console.error(error)
9696
}
9797

98+
export function setBodyBackgroundToThemeBackgroundColor(document: Document, localStorage: Storage) {
99+
const errorMsgPrefix = "[vscode]"
100+
101+
if (!document) {
102+
throw new Error(`${errorMsgPrefix} Could not set body background to theme background color. Document is undefined.`)
103+
}
104+
105+
if (!localStorage) {
106+
throw new Error(
107+
`${errorMsgPrefix} Could not set body background to theme background color. localStorage is undefined.`,
108+
)
109+
}
110+
111+
const colorThemeData = localStorage.getItem("colorThemeData")
112+
113+
if (!colorThemeData) {
114+
throw new Error(
115+
`${errorMsgPrefix} Could not set body background to theme background color. Could not find colorThemeData in localStorage.`,
116+
)
117+
}
118+
119+
let _colorThemeData
120+
try {
121+
// We wrap this JSON.parse logic in a try/catch
122+
// because it can throw if the JSON is invalid.
123+
// and instead of throwing a random error
124+
// we can throw our own error, which will be more helpful
125+
// to the end user.
126+
_colorThemeData = JSON.parse(colorThemeData)
127+
} catch {
128+
throw new Error(
129+
`${errorMsgPrefix} Could not set body background to theme background color. Could not parse colorThemeData from localStorage.`,
130+
)
131+
}
132+
133+
const hasColorMapProperty = Object.prototype.hasOwnProperty.call(_colorThemeData, "colorMap")
134+
if (!hasColorMapProperty) {
135+
throw new Error(
136+
`${errorMsgPrefix} Could not set body background to theme background color. colorThemeData is missing colorMap.`,
137+
)
138+
}
139+
140+
const editorBgColor = _colorThemeData.colorMap["editor.background"]
141+
142+
if (!editorBgColor) {
143+
throw new Error(
144+
`${errorMsgPrefix} Could not set body background to theme background color. colorThemeData.colorMap["editor.background"] is undefined.`,
145+
)
146+
}
147+
148+
document.body.style.background = editorBgColor
149+
150+
return null
151+
}
152+
98153
try {
99-
document.body.style.background = JSON.parse(localStorage.getItem("colorThemeData")!).colorMap["editor.background"]
154+
setBodyBackgroundToThemeBackgroundColor(document, localStorage)
100155
} catch (error) {
101-
// Oh well.
156+
console.error("Something went wrong setting the body background to the theme background color.")
157+
console.error(error)
102158
}

src/node/http.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { normalize, Options } from "../common/util"
77
import { AuthType, DefaultedArgs } from "./cli"
88
import { commit, rootPath } from "./constants"
99
import { Heart } from "./heart"
10-
import { getPasswordMethod, IsCookieValidArgs, isCookieValid, sanitizeString } from "./util"
10+
import { getPasswordMethod, IsCookieValidArgs, isCookieValid, sanitizeString, escapeHtml } from "./util"
1111

1212
declare global {
1313
// eslint-disable-next-line @typescript-eslint/no-namespace
@@ -35,7 +35,7 @@ export const replaceTemplates = <T extends object>(
3535
...extraOpts,
3636
}
3737
return content
38-
.replace(/{{TO}}/g, (typeof req.query.to === "string" && req.query.to) || "/")
38+
.replace(/{{TO}}/g, (typeof req.query.to === "string" && escapeHtml(req.query.to)) || "/")
3939
.replace(/{{BASE}}/g, options.base)
4040
.replace(/{{CS_STATIC_BASE}}/g, options.csStaticBase)
4141
.replace(/"{{OPTIONS}}"/, `'${JSON.stringify(options)}'`)
@@ -100,7 +100,8 @@ export const relativeRoot = (req: express.Request): string => {
100100
}
101101

102102
/**
103-
* Redirect relatively to `/${to}`. Query variables will be preserved.
103+
* Redirect relatively to `/${to}`. Query variables on the current URI will be preserved.
104+
* `to` should be a simple path without any query parameters
104105
* `override` will merge with the existing query (use `undefined` to unset).
105106
*/
106107
export const redirect = (

0 commit comments

Comments
 (0)