Skip to content

Commit 3fb4470

Browse files
author
Akash Satheesan
authored
Merge branch 'main' into oxy/docker-buildx
2 parents 6066157 + 7a5c457 commit 3fb4470

File tree

11 files changed

+305
-89
lines changed

11 files changed

+305
-89
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ jobs:
409409
uses: actions/checkout@v2
410410
- name: Run Trivy vulnerability scanner in repo mode
411411
#Commit SHA for v0.0.17
412-
uses: aquasecurity/trivy-action@ac8de07fd168680dd0331bef43681c0e150e9ad1
412+
uses: aquasecurity/trivy-action@9438b49cc3156b2e8c77c1ba8ffbaa3bae24e3c2
413413
with:
414414
scan-type: "fs"
415415
scan-ref: "."

docs/install.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
- [Raspberry Pi](#raspberry-pi)
1616
- [Termux](#termux)
1717
- [Cloud providers](#cloud-providers)
18+
- [Uninstall](#uninstall)
19+
- [install.sh](#installsh-1)
20+
- [Homebrew](#homebrew)
21+
- [yarn, npm](#yarn-npm-1)
22+
- [Debian, Ubuntu](#debian-ubuntu-1)
1823

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

@@ -246,3 +251,54 @@ information.
246251
We maintain [one-click apps and install scripts for cloud
247252
providers](https://github.com/cdr/deploy-code-server) such as DigitalOcean,
248253
Railway, Heroku, and Azure.
254+
255+
## Uninstall
256+
257+
code-server can be completely uninstalled by removing the application directory, and your user configuration directory.
258+
259+
To delete settings and data:
260+
261+
```shell
262+
rm -rf ~/.local/share/code-server ~/.config/code-server
263+
```
264+
265+
### install.sh
266+
267+
If you installed with the install script, by default code-server will be in `~/.local/lib/code-server-<version>` and you can remove it with `rm -rf`. e.g.
268+
269+
```shell
270+
rm -rf ~/.local/lib/code-server-*
271+
```
272+
273+
### Homebrew
274+
275+
To remove the code-server homebrew package, run:
276+
277+
```shell
278+
brew remove code-server
279+
280+
# Alternatively
281+
brew uninstall code-server
282+
```
283+
284+
### yarn, npm
285+
286+
To remove the code-server global module, run:
287+
288+
```shell
289+
yarn global remove code-server
290+
```
291+
292+
or
293+
294+
```shell
295+
npm uninstall -g code-server
296+
```
297+
298+
### Debian, Ubuntu
299+
300+
To uninstall, run:
301+
302+
```shell
303+
sudo apt remove code-server
304+
```

docs/manifest.json

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"versions": ["v3.11.0", "v3.10.2"],
3+
"routes": [
4+
{
5+
"title": "Home",
6+
"description": "Learn how to install and run code-server.",
7+
"path": "./README.md",
8+
"icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16px\" xml:space=\"preserve\"><path d=\"M15.45,7L14,5.551V2c0-0.55-0.45-1-1-1h-1c-0.55,0-1,0.45-1,1v0.553L9,0.555C8.727,0.297,8.477,0,8,0S7.273,0.297,7,0.555 L0.55,7C0.238,7.325,0,7.562,0,8c0,0.563,0.432,1,1,1h1v6c0,0.55,0.45,1,1,1h3v-5c0-0.55,0.45-1,1-1h2c0.55,0,1,0.45,1,1v5h3 c0.55,0,1-0.45,1-1V9h1c0.568,0,1-0.437,1-1C16,7.562,15.762,7.325,15.45,7z\"></path></svg>"
9+
},
10+
{
11+
"title": "Requirements",
12+
"description": "Learn about what you need to run code-server.",
13+
"icon": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6 2V11H2V15C2 16.7 3.3 18 5 18H15C16.7 18 18 16.7 18 15V2H6ZM16 15C16 15.6 15.6 16 15 16H8V4H16V15Z\" /><path d=\"M14 7H10V9H14V7Z\" /><path d=\"M14 11H10V13H14V11Z\" /></svg>",
14+
"path": "./requirements.md"
15+
},
16+
{
17+
"title": "Install",
18+
"description": "How to install code-server.",
19+
"icon": "<svg class=\"MuiSvgIcon-root jss172\" focusable=\"false\" viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z\"></path></svg>",
20+
"path": "./install.md",
21+
"children": [
22+
{
23+
"title": "npm",
24+
"description": "How to install code-server using npm or yarn",
25+
"path": "./npm.md"
26+
}
27+
]
28+
},
29+
{
30+
"title": "Usage",
31+
"description": "How to set up and use code-server.",
32+
"icon": "<svg viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 10l-2.5-1.5L15 12V4h5v8z\"></path></svg>",
33+
"path": "./guide.md",
34+
"children": [
35+
{
36+
"title": "iPad",
37+
"description": "How to access your code-server installation using an iPad.",
38+
"path": "./ipad.md"
39+
},
40+
{
41+
"title": "Termux",
42+
"description": "How to install Termux to run code-server on an Android device.",
43+
"path": "./termux.md"
44+
}
45+
]
46+
},
47+
{
48+
"title": "Upgrade",
49+
"description": "How to upgrade code-server.",
50+
"icon": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17.8049 2.19795C17.7385 2.1311 17.6587 2.07899 17.5708 2.04504C17.4829 2.01108 17.3889 1.99604 17.2948 2.00089C7.89216 2.49153 4.4188 10.8673 4.38528 10.9517C4.33624 11.0736 4.32406 11.2071 4.35028 11.3358C4.3765 11.4645 4.43995 11.5827 4.53274 11.6756L8.32449 15.4674C8.41787 15.5606 8.53669 15.6242 8.66606 15.6502C8.79543 15.6762 8.92959 15.6634 9.05174 15.6135C9.13552 15.5793 17.4664 12.0671 17.9986 2.7087C18.0039 2.61474 17.9895 2.5207 17.9561 2.4327C17.9227 2.3447 17.8712 2.26471 17.8049 2.19795ZM12.3314 9.56427C12.1439 9.75179 11.9051 9.87951 11.645 9.93126C11.385 9.98302 11.1154 9.9565 10.8704 9.85505C10.6254 9.7536 10.4161 9.58178 10.2687 9.36131C10.1214 9.14085 10.0428 8.88166 10.0428 8.6165C10.0428 8.35135 10.1214 8.09215 10.2687 7.87169C10.4161 7.65123 10.6254 7.47941 10.8704 7.37796C11.1154 7.27651 11.385 7.24998 11.645 7.30174C11.9051 7.3535 12.1439 7.48121 12.3314 7.66873C12.5827 7.92012 12.7239 8.26104 12.7239 8.6165C12.7239 8.97197 12.5827 9.31288 12.3314 9.56427Z\"/><path d=\"M2.74602 14.5444C2.92281 14.3664 3.133 14.2251 3.36454 14.1285C3.59608 14.0319 3.8444 13.9819 4.09529 13.9815C4.34617 13.9811 4.59466 14.0302 4.82653 14.126C5.05839 14.2218 5.26907 14.3624 5.44647 14.5398C5.62386 14.7172 5.7645 14.9279 5.86031 15.1598C5.95612 15.3916 6.00522 15.6401 6.00479 15.891C6.00437 16.1419 5.95442 16.3902 5.85782 16.6218C5.76122 16.8533 5.61987 17.0635 5.44186 17.2403C4.69719 17.985 2 18.0004 2 18.0004C2 18.0004 2 15.2884 2.74602 14.5444Z\"/><path d=\"M8.9416 3.48269C7.99688 3.31826 7.02645 3.38371 6.11237 3.67352C5.19828 3.96332 4.36741 4.46894 3.68999 5.14765C3.33153 5.50944 3.01988 5.91477 2.76233 6.35415C2.68692 6.4822 2.6562 6.63169 2.67501 6.77911C2.69381 6.92652 2.76108 7.06351 2.86623 7.16853L4.1994 8.50238C5.43822 6.53634 7.04911 4.83119 8.9416 3.48269Z\"/><path d=\"M16.5181 11.0585C16.6825 12.0033 16.6171 12.9737 16.3273 13.8878C16.0375 14.8019 15.5318 15.6327 14.8531 16.3101C14.4914 16.6686 14.086 16.9803 13.6466 17.2378C13.5186 17.3132 13.3691 17.3439 13.2217 17.3251C13.0743 17.3063 12.9373 17.2391 12.8323 17.1339L11.4984 15.8007C13.4645 14.5619 15.1696 12.951 16.5181 11.0585Z\"/></svg>",
51+
"path": "./upgrade.md"
52+
},
53+
{
54+
"title": "FAQ",
55+
"description": "Frequently asked questions on installing and running code-server.",
56+
"icon": "<svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10.0001 18.3333C14.6025 18.3333 18.3334 14.6024 18.3334 10C18.3334 5.39762 14.6025 1.66666 10.0001 1.66666C5.39771 1.66666 1.66675 5.39762 1.66675 10C1.66675 14.6024 5.39771 18.3333 10.0001 18.3333Z\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M7.57495 7.5C7.77087 6.94306 8.15758 6.47342 8.66658 6.17428C9.17558 5.87513 9.77403 5.76578 10.3559 5.86559C10.9378 5.96541 11.4656 6.26794 11.8458 6.71961C12.2261 7.17128 12.4342 7.74294 12.4333 8.33333C12.4333 10 9.93328 10.8333 9.93328 10.8333\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M10 14.1667H10.0083\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
57+
"path": "./FAQ.md"
58+
},
59+
{
60+
"title": "Contributing",
61+
"description": "How to contribute to code-server.",
62+
"icon": "<svg width=\"20\" height=\"20\" fill=\"none\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M5 2.5V12.5\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M15 7.5C16.3807 7.5 17.5 6.38071 17.5 5C17.5 3.61929 16.3807 2.5 15 2.5C13.6193 2.5 12.5 3.61929 12.5 5C12.5 6.38071 13.6193 7.5 15 7.5Z\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M5 17.5C6.38071 17.5 7.5 16.3807 7.5 15C7.5 13.6193 6.38071 12.5 5 12.5C3.61929 12.5 2.5 13.6193 2.5 15C2.5 16.3807 3.61929 17.5 5 17.5Z\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M15 7.5C15 9.48912 14.2098 11.3968 12.8033 12.8033C11.3968 14.2098 9.48912 15 7.5 15\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>",
63+
"path": "./CONTRIBUTING.md",
64+
"children": [
65+
{
66+
"title": "Code of conduct",
67+
"description": "Coder expects contributors to code-server to behave in a manner that creates an open and welcoming environment.",
68+
"path": "./CODE_OF_CONDUCT.md"
69+
},
70+
{
71+
"title": "Maintenance",
72+
"description": "Learn about the workflow followed by code-server's maintainers.",
73+
"path": "./MAINTAINING.md"
74+
},
75+
{
76+
"title": "Triage",
77+
"description": "How the maintainers triage issues with code-server.",
78+
"path": "./triage.md"
79+
},
80+
{
81+
"title": "Security",
82+
"description": "Learn about the tools used to detect vulnerabilities in code-server, and how you can report vulnerabilities.",
83+
"path": "./SECURITY.md"
84+
}
85+
]
86+
}
87+
]
88+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"pem": "^1.14.2",
9797
"proxy-agent": "^5.0.0",
9898
"proxy-from-env": "^1.1.0",
99-
"qs": "6.7.0",
99+
"qs": "6.10.1",
100100
"rotating-file-stream": "^2.1.1",
101101
"safe-buffer": "^5.1.1",
102102
"safe-compare": "^1.1.4",

src/browser/register.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export async function registerServiceWorker(): Promise<void> {
55
const options = getOptions()
66
logger.level = options.logLevel
77

8-
const path = normalize(`${options.csStaticBase}/dist/serviceWorker.js`)
8+
const path = normalize(`${options.csStaticBase}/out/browser/serviceWorker.js`)
99
try {
1010
await navigator.serviceWorker.register(path, {
1111
scope: options.base + "/",

src/node/proxy_agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function newProxyAgent(inVSCode: boolean): http.Agent {
6262

6363
// If they have $NO_PROXY set to example.com then this check won't work!
6464
// But that's drastically unlikely.
65-
function shouldEnableProxy(): boolean {
65+
export function shouldEnableProxy(): boolean {
6666
let shouldEnable = false
6767

6868
const httpProxy = proxyFromEnv.getProxyForUrl(`http://example.com`)

test/unit/browser/register.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe("register", () => {
155155
await registerServiceWorker()
156156

157157
expect(mockFn).toBeCalled()
158-
expect(serviceWorkerPath).toMatch(`${csStaticBasePath}/dist/serviceWorker.js`)
158+
expect(serviceWorkerPath).toMatch(`${csStaticBasePath}/out/browser/serviceWorker.js`)
159159
expect(serviceWorkerScope).toMatch("/")
160160
})
161161
it("should register when options.base is defined", async () => {
@@ -176,7 +176,7 @@ describe("register", () => {
176176
await registerServiceWorker()
177177

178178
expect(mockFn).toBeCalled()
179-
expect(serviceWorkerPath).toMatch(`/dist/serviceWorker.js`)
179+
expect(serviceWorkerPath).toMatch(`/out/browser/serviceWorker.js`)
180180
expect(serviceWorkerScope).toMatch("/")
181181
})
182182
})

test/unit/helpers.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { promises as fs } from "fs"
2-
import { tmpdir } from "../../test/utils/helpers"
2+
import { tmpdir, useEnv } from "../../test/utils/helpers"
33

44
/**
55
* This file is for testing test helpers (not core code).
@@ -12,3 +12,30 @@ describe("test helpers", () => {
1212
expect(fs.access(pathToTempDir)).resolves.toStrictEqual(undefined)
1313
})
1414
})
15+
16+
describe("useEnv", () => {
17+
beforeAll(() => {
18+
jest.resetModules()
19+
process.env.TEST_USE_ENV = "test environment variable"
20+
})
21+
afterAll(() => {
22+
delete process.env.TEST_USE_ENV
23+
})
24+
it("should set and reset the env var", () => {
25+
const envKey = "TEST_ENV_VAR"
26+
const [setValue, resetValue] = useEnv(envKey)
27+
setValue("hello-world")
28+
expect(process.env[envKey]).toEqual("hello-world")
29+
resetValue()
30+
expect(process.env[envKey]).toEqual(undefined)
31+
})
32+
it("should set and reset the env var where a value was already set", () => {
33+
const envKey = "TEST_USE_ENV"
34+
expect(process.env[envKey]).toEqual("test environment variable")
35+
const [setValue, resetValue] = useEnv(envKey)
36+
setValue("hello there")
37+
expect(process.env[envKey]).toEqual("hello there")
38+
resetValue()
39+
expect(process.env[envKey]).toEqual("test environment variable")
40+
})
41+
})

test/unit/node/proxy_agent.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { shouldEnableProxy } from "../../../src/node/proxy_agent"
2+
import { useEnv } from "../../utils/helpers"
3+
4+
describe("shouldEnableProxy", () => {
5+
const [setHTTPProxy, resetHTTPProxy] = useEnv("HTTP_PROXY")
6+
const [setHTTPSProxy, resetHTTPSProxy] = useEnv("HTTPS_PROXY")
7+
const [setNoProxy, resetNoProxy] = useEnv("NO_PROXY")
8+
9+
beforeEach(() => {
10+
jest.resetModules() // Most important - it clears the cache
11+
resetHTTPProxy()
12+
resetNoProxy()
13+
resetHTTPSProxy()
14+
})
15+
16+
it("returns true when HTTP_PROXY is set", () => {
17+
setHTTPProxy("http://proxy.example.com")
18+
expect(shouldEnableProxy()).toBe(true)
19+
})
20+
it("returns true when HTTPS_PROXY is set", () => {
21+
setHTTPSProxy("https://proxy.example.com")
22+
expect(shouldEnableProxy()).toBe(true)
23+
})
24+
it("returns false when NO_PROXY is set", () => {
25+
setNoProxy("*")
26+
expect(shouldEnableProxy()).toBe(false)
27+
})
28+
it("should return false when neither HTTP_PROXY nor HTTPS_PROXY is set", () => {
29+
expect(shouldEnableProxy()).toBe(false)
30+
})
31+
it("should return false when NO_PROXY is set to https://example.com", () => {
32+
setNoProxy("https://example.com")
33+
expect(shouldEnableProxy()).toBe(false)
34+
})
35+
it("should return false when NO_PROXY is set to http://example.com", () => {
36+
setNoProxy("http://example.com")
37+
expect(shouldEnableProxy()).toBe(false)
38+
})
39+
})

test/utils/helpers.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,27 @@ export async function tmpdir(testName: string): Promise<string> {
3737

3838
return await fs.mkdtemp(path.join(dir, `${testName}-`), { encoding: "utf8" })
3939
}
40+
41+
/**
42+
* @description Helper function to use an environment variable.
43+
*
44+
* @returns an array (similar to useState in React) with a function
45+
* to set the value and reset the value
46+
*/
47+
export function useEnv(key: string): [(nextValue: string | undefined) => string | undefined, () => void] {
48+
const initialValue = process.env[key]
49+
const setValue = (nextValue: string | undefined) => (process.env[key] = nextValue)
50+
// Node automatically converts undefined to string 'undefined'
51+
// when assigning an environment variable.
52+
// which is why we need to delete it if it's supposed to be undefined
53+
// Source: https://stackoverflow.com/a/60147167
54+
const resetValue = () => {
55+
if (initialValue !== undefined) {
56+
process.env[key] = initialValue
57+
} else {
58+
delete process.env[key]
59+
}
60+
}
61+
62+
return [setValue, resetValue]
63+
}

0 commit comments

Comments
 (0)