CONTRIBUTING.md 5.0 KB
Newer Older
1 2
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
A
Anmol Sethi 已提交
3 4
# Contributing

A
Anmol Sethi 已提交
5
- [Pull Requests](#pull-requests)
6 7 8 9 10 11 12 13
- [Requirements](#requirements)
- [Development Workflow](#development-workflow)
- [Build](#build)
- [Structure](#structure)
  - [VS Code Patch](#vs-code-patch)

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

14 15
- [Detailed CI and build process docs](../ci)

A
Anmol Sethi 已提交
16 17 18 19 20 21 22 23 24 25
## Pull Requests

Please link to the issue each PR solves.
If there is no existing issue, please first create one unless the fix is minor.

Please make sure the base of your PR is the master branch. We keep the GitHub
default branch the latest release branch to avoid confusion as the
documentation is on GitHub and we don't want users to see docs on unreleased
features.

26 27 28 29 30
## Requirements

Please refer to [VS Code's prerequisites](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#prerequisites).

Differences:
A
Anmol Sethi 已提交
31

A
Anmol Sethi 已提交
32
- We require a minimum of node v12 but later versions should work.
G
G r e y 已提交
33
- We use [nfpm](https://github.com/goreleaser/nfpm) to build `.deb` and `.rpm` packages.
A
Anmol Sethi 已提交
34
- We use [jq](https://stedolan.github.io/jq/) to build code-server releases.
35
- The [CI container](../ci/images/debian10/Dockerfile) is a useful reference for all our dependencies.
36 37

## Development Workflow
A
Anmol Sethi 已提交
38 39 40 41

```shell
yarn
yarn vscode
A
Anmol Sethi 已提交
42 43
yarn watch
# Visit http://localhost:8080 once the build completed.
A
Anmol Sethi 已提交
44 45
```

46 47 48
To develop inside of an isolated docker container:

```shell
49 50 51
./ci/dev/image/run.sh yarn
./ci/dev/image/run.sh yarn vscode
./ci/dev/image/run.sh yarn watch
52 53
```

54
`yarn watch` will live reload changes to the source.
A
Anmol Sethi 已提交
55 56 57 58 59 60

If changes are made to the patch and you've built previously you must manually
reset VS Code then run `yarn vscode:patch`.

## Build

61 62 63
You can build with:

```shell
64
./ci/dev/image/run.sh ./ci/steps/release.sh
65 66 67 68 69 70 71 72 73 74 75 76 77 78
```

Run your build with:

```
cd release
yarn --production
# Runs the built JavaScript with Node.
node .
```

Build release packages (make sure you run `./ci/steps/release.sh` first):

```
79
IMAGE=centos7 ./ci/dev/image/run.sh ./ci/steps/release-packages.sh
80 81 82 83 84 85
# The standalone release is in ./release-standalone
# .deb, .rpm and the standalone archive are in ./release-packages
```

The `release.sh` script is the equivalent of:

A
Anmol Sethi 已提交
86 87
```shell
yarn
88
yarn vscode
A
Anmol Sethi 已提交
89
yarn build
90 91
yarn build:vscode
yarn release
A
Anmol Sethi 已提交
92
```
93

94
And `release-packages.sh` is:
95 96

```
97 98
yarn release:standalone
yarn test:standalone-release
99 100 101
yarn package
```

A
Anmol Sethi 已提交
102 103 104 105 106 107 108
For a faster release build you can also run:

```
KEEP_MODULES=1 ./ci/steps/release.sh
node ./release
```

A
Anmol Sethi 已提交
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
## Structure

The `code-server` script serves an HTTP API to login and start a remote VS Code process.

The CLI code is in [./src/node](./src/node) and the HTTP routes are implemented in
[./src/node/app](./src/node/app).

Most of the meaty parts are in our VS Code patch which is described next.

### VS Code Patch

Back in v1 of code-server, we had an extensive patch of VS Code that split the codebase
into a frontend and server. The frontend consisted of all UI code and the server ran
the extensions and exposed an API to the frontend for file access and everything else
that the UI needed.

This worked but eventually Microsoft added support to VS Code to run it in the web.
They have open sourced the frontend but have kept the server closed source.

So in interest of piggy backing off their work, v2 and beyond use the VS Code
web frontend and fill in the server. This is contained in our
[./ci/dev/vscode.patch](../ci/dev/vscode.patch) under the path `src/vs/server`.

Other notable changes in our patch include:

- Add our own build file which includes our code and VS Code's web code.
- Allow multiple extension directories (both user and built-in).
- Modify the loader, websocket, webview, service worker, and asset requests to
  use the URL of the page as a base (and TLS if necessary for the websocket).
- Send client-side telemetry through the server.
- Allow modification of the display language.
- Make it possible for us to load code on the client.
- Make extensions work in the browser.
- Make it possible to install extensions of any kind.
- Fix getting permanently disconnected when you sleep or hibernate for a while.
- Add connection type to web socket query parameters.

Some known issues presently:

- Creating custom VS Code extensions and debugging them doesn't work.
- Extension profiling and tips are currently disabled.

As the web portion of VS Code matures, we'll be able to shrink and maybe even entirely
eliminate our patch. In the meantime, however, upgrading the VS Code version requires
ensuring that the patch still applies and has the intended effects.

To generate a new patch run `yarn vscode:diff`.

**note**: We have extension docs on the CI and build system at [./ci/README.md](../ci/README.md)

If functionality doesn't depend on code from VS Code then it should be moved
into code-server otherwise it should be in the patch.

In the future we'd like to run VS Code unit tests against our builds to ensure features
work as expected.