From 8dcc1e35670b69f1aae7da118f7cb873934363fb Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 12 Jul 2019 18:41:56 -0500 Subject: [PATCH] Accept argument to change initial working directory --- README.md | 64 ++++++++++++++++++++++++++++++++------------------- src/cli.ts | 3 +++ src/server.ts | 5 ++-- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 448ebaeb..1a9c69b2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ [![MIT license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cdr/code-server/blob/master/LICENSE) [![Discord](https://img.shields.io/discord/463752820026376202.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/zxSwN8Z) -`code-server` is [VS Code](https://github.com/Microsoft/vscode) running on a remote server, accessible through the browser. +`code-server` is [VS Code](https://github.com/Microsoft/vscode) running on a +remote server, accessible through the browser. Try it out: ```bash @@ -13,11 +14,11 @@ docker run -it -p 127.0.0.1:8443:8443 -v "${PWD}:/home/coder/project" codercom/c ``` - Code on your Chromebook, tablet, and laptop with a consistent dev environment. - - If you have a Windows or Mac workstation, more easily develop for Linux. + - If you have a Windows or Mac workstation, more easily develop for Linux. - Take advantage of large cloud servers to speed up tests, compilations, downloads, and more. - Preserve battery life when you're on the go. - - All intensive computation runs on your server. - - You're no longer running excess instances of Chrome. + - All intensive computation runs on your server. + - You're no longer running excess instances of Chrome. ![Screenshot](/doc/assets/ide.png) @@ -29,28 +30,35 @@ Use [sshcode](https://github.com/codercom/sshcode) for a simple setup. ### Docker -See docker oneliner mentioned above. Dockerfile is at [/Dockerfile](/Dockerfile). +See docker oneliner mentioned above. Dockerfile is at +[/Dockerfile](/Dockerfile). ### Binaries -1. [Download a binary](https://github.com/cdr/code-server/releases) (Linux and OS X supported. Windows coming soon) +1. [Download a binary](https://github.com/cdr/code-server/releases) (Linux and + OS X supported. Windows coming soon) 2. Start the binary with the project directory as the first argument - ``` - code-server - ``` - > You will be prompted to enter the password shown in the CLI - `code-server` should now be running at https://localhost:8443. +``` +code-server +``` +You will be prompted to enter the password shown in the CLI. `code-server` +should now be running at https://localhost:8443. - > code-server uses a self-signed SSL certificate that may prompt your browser to ask you some additional questions before you proceed. Please [read here](doc/self-hosted/index.md) for more information. +`code-server` uses a self-signed SSL certificate that may prompt your +browser to ask you some additional questions before you proceed. Please +[read here](doc/self-hosted/index.md) for more information. -For detailed instructions and troubleshooting, see the [self-hosted quick start guide](doc/self-hosted/index.md). +For detailed instructions and troubleshooting, see the +[self-hosted quick start guide](doc/self-hosted/index.md). -Quickstart guides for [Google Cloud](doc/admin/install/google_cloud.md), [AWS](doc/admin/install/aws.md), and [DigitalOcean](doc/admin/install/digitalocean.md). +Quickstart guides for [Google Cloud](doc/admin/install/google_cloud.md), +[AWS](doc/admin/install/aws.md), and +[DigitalOcean](doc/admin/install/digitalocean.md). How to [secure your setup](/doc/security/ssl.md). -## Build +### Build - If you also plan on developing, set the `OUT` environment variable: ` export OUT=/path/to/some/directory`. Otherwise it will build in this directory which will cause issues because then `yarn watch` will try to @@ -62,7 +70,7 @@ How to [secure your setup](/doc/security/ssl.md). `yarn binary` with the same arguments in the previous step to package the code into a single binary. -## Development +### Development ```fish git clone https://github.com/microsoft/vscode @@ -77,25 +85,31 @@ yarn start --allow-http --no-auth # Visit http://localhost:8443 ``` -### Known Issues +## Known Issues - Creating custom VS Code extensions and debugging them doesn't work. -- To debug Golang using [ms-vscode-go extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go), you need to add `--security-opt seccomp=unconfined` to your `docker run` arguments when launching code-server with Docker. See [#725](https://github.com/cdr/code-server/issues/725) for details. +- To debug Golang using + [ms-vscode-go extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go), + you need to add `--security-opt seccomp=unconfined` to your `docker run` + arguments when launching code-server with Docker. See + [#725](https://github.com/cdr/code-server/issues/725) for details. -### Future +## Future - **Stay up to date!** Get notified about new releases of code-server. ![Screenshot](/doc/assets/release.gif) - Windows support. - Electron and Chrome OS applications to bridge the gap between local<->remote. - Run VS Code unit tests against our builds to ensure features work as expected. -### Extensions +## Extensions -At the moment we can't use the official VSCode Marketplace. We've created a custom extension marketplace focused around open-sourced extensions. However, if you have access to the `.vsix` file, you can manually install the extension. +At the moment we can't use the official VSCode Marketplace. We've created a +custom extension marketplace focused around open-sourced extensions. However, +if you have access to the `.vsix` file, you can manually install the extension. ## Telemetry -Use the `--disable-telemetry` flag or set `DISABLE_TELEMETRY=true` to disable tracking ENTIRELY. +Set the `telemetry.enableTelemetry` user setting to false to disable telemetry. We use data collected to improve code-server. @@ -109,8 +123,10 @@ Development guides are coming soon. ## Enterprise -Visit [our enterprise page](https://coder.com/enterprise) for more information about our enterprise offering. +Visit [our enterprise page](https://coder.com/enterprise) for more information +about our enterprise offering. ## Commercialization -If you would like to commercialize code-server, please contact contact@coder.com. +If you would like to commercialize code-server, please contact +contact@coder.com. diff --git a/src/cli.ts b/src/cli.ts index a43b495c..cc866de2 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -127,6 +127,9 @@ const main = async (): Promise => { certKey: args["cert-key"], auth: typeof args.auth !== "undefined" ? args.auth : true, password: process.env.PASSWORD, + folderUri: args["_"] && args["_"].length > 1 + ? args["_"][args["_"].length - 1] + : undefined, }; if (!options.host) { diff --git a/src/server.ts b/src/server.ts index 50e9dd4d..8fac0f2d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -97,6 +97,7 @@ export interface ServerOptions { readonly certKey?: string; readonly auth?: boolean; readonly password?: string; + readonly folderUri?: string; } export abstract class Server { @@ -107,7 +108,7 @@ export abstract class Server { private listenPromise: Promise | undefined; - public constructor(private readonly options: ServerOptions) { + public constructor(protected readonly options: ServerOptions) { if (this.options.cert && this.options.certKey) { useHttpsTransformer(); const httpolyglot = require.__$__nodeRequire(path.resolve(__dirname, "../node_modules/httpolyglot/lib/index")) as typeof import("httpolyglot"); @@ -458,7 +459,7 @@ export class MainServer extends Server { const cwd = process.env.VSCODE_CWD || process.cwd(); const workspacePath = parsedUrl.query.workspace as string | undefined; - const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || cwd: undefined; + const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || this.options.folderUri || cwd: undefined; const options: Options = { WORKBENCH_WEB_CONGIGURATION: {