From ac1fba8bde0c3f29bf6bc27d3d7d75cb2390a7c2 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 13 Feb 2023 13:52:48 -0900 Subject: [PATCH] Remove deprecated --link (#6018) --- CHANGELOG.md | 8 +++++-- ci/build/build-code-server.sh | 16 ------------- ci/build/build-release.sh | 2 -- ci/build/npm-postinstall.sh | 23 ++----------------- docs/install.md | 6 ++--- docs/link.md | 11 --------- docs/manifest.json | 5 ---- src/node/cli.ts | 23 +------------------ src/node/coder_cloud.ts | 43 ----------------------------------- src/node/main.ts | 16 +++---------- test/unit/node/cli.test.ts | 34 +++------------------------ 11 files changed, 18 insertions(+), 169 deletions(-) delete mode 100644 docs/link.md delete mode 100644 src/node/coder_cloud.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 852c9de66..2a6468343 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,11 +22,15 @@ Code v99.99.999 ## [4.10.0](https://github.com/coder/code-server/releases/tag/v4.10.0) - TBD -Code v1.75.0 +Code v1.75.1 ### Changed -- Updated to Code 1.75.0 +- Updated to Code 1.75.1 + +### Removed + +- Removed `--link` (was deprecated in 4.0.1). ## [4.9.1](https://github.com/coder/code-server/releases/tag/v4.9.1) - 2022-12-15 diff --git a/ci/build/build-code-server.sh b/ci/build/build-code-server.sh index 01b348858..df86f2d97 100755 --- a/ci/build/build-code-server.sh +++ b/ci/build/build-code-server.sh @@ -14,22 +14,6 @@ main() { sed -i.bak "1s;^;#!/usr/bin/env node\n;" out/node/entry.js && rm out/node/entry.js.bak chmod +x out/node/entry.js fi - - # for arch; we do not use OS from lib.sh and get our own. - # lib.sh normalizes macos to darwin - but cloud-agent's binaries do not - source ./ci/lib.sh - OS="$(uname | tr '[:upper:]' '[:lower:]')" - - mkdir -p ./lib - - if ! [ -f ./lib/coder-cloud-agent ]; then - echo "Downloading the cloud agent..." - - set +e - curl -fsSL "https://github.com/coder/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent - chmod +x ./lib/coder-cloud-agent - set -e - fi } main "$@" diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index c81266858..576b084ae 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -63,8 +63,6 @@ EOF if [ "$KEEP_MODULES" = 1 ]; then rsync node_modules/ "$RELEASE_PATH/node_modules" - mkdir -p "$RELEASE_PATH/lib" - rsync ./lib/coder-cloud-agent "$RELEASE_PATH/lib" fi } diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index 0300440d0..8c10c8cee 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -1,18 +1,8 @@ #!/usr/bin/env sh set -eu -# Copied from ../lib.sh. -arch() { - cpu="$(uname -m)" - case "$cpu" in - aarch64) cpu=arm64 ;; - x86_64) cpu=amd64 ;; - esac - echo "$cpu" -} - -# Copied from ../lib.sh except we do not rename Darwin since the cloud agent -# uses "darwin" in the release names and we do not need to detect Alpine. +# Copied from ../lib.sh except we do not rename Darwin and we do not need to +# detect Alpine. os() { osname=$(uname | tr '[:upper:]' '[:lower:]') case $osname in @@ -61,7 +51,6 @@ symlink_bin_script() { cd "$oldpwd" } -ARCH="${NPM_CONFIG_ARCH:-$(arch)}" OS="$(os)" # This is due to an upstream issue with RHEL7/CentOS 7 comptability with node-argon2 @@ -102,14 +91,6 @@ main() { ;; esac - mkdir -p ./lib - - if curl -fsSL "https://github.com/coder/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent; then - chmod +x ./lib/coder-cloud-agent - else - echo "Failed to download cloud agent; --link will not work" - fi - if ! vscode_install; then echo "You may not have the required dependencies to build the native modules." echo "Please see https://github.com/coder/code-server/blob/main/docs/npm.md" diff --git a/docs/install.md b/docs/install.md index 5f5a9fcfa..b258a3107 100644 --- a/docs/install.md +++ b/docs/install.md @@ -297,9 +297,9 @@ You can install code-server using the [Helm package manager](https://coder.com/d ## Windows -We currently [do not publish Windows releases](https://github.com/coder/code-server/issues/1397). We recommend installing code-server onto Windows with [`npm`](#npm). - -> Note: You will also need to [build coder/cloud-agent manually](https://github.com/coder/cloud-agent/issues/17) if you would like to use `code-server --link` on Windows. +We currently [do not publish Windows +releases](https://github.com/coder/code-server/issues/1397). We recommend +installing code-server onto Windows with [`npm`](#npm). ## Raspberry Pi diff --git a/docs/link.md b/docs/link.md deleted file mode 100644 index 2ca9b4f6c..000000000 --- a/docs/link.md +++ /dev/null @@ -1,11 +0,0 @@ -# code-server --link - -> Note: This feature is no longer recommended due to instability. Stay tuned for a revised version. - -Run code-server with the flag `--link` and you'll get TLS, authentication, and a dedicated URL -for accessing your IDE out of the box. - -```console -$ code-server --link -Proxying code-server, you can access your IDE at https://example.coder.co -``` diff --git a/docs/manifest.json b/docs/manifest.json index fcd3150f3..4e82dcd7d 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -42,11 +42,6 @@ "description": "How to run code-server in Coder", "path": "./coder.md" }, - { - "title": "--link", - "description": "How to run code-server --link", - "path": "./link.md" - }, { "title": "iPad", "description": "How to access your code-server installation using an iPad.", diff --git a/src/node/cli.ts b/src/node/cli.ts index 520d0a554..b8498c1eb 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -84,7 +84,6 @@ export interface UserProvidedArgs extends UserProvidedCodeArgs { "reuse-window"?: boolean "new-window"?: boolean "ignore-last-opened"?: boolean - link?: OptionalString verbose?: boolean "app-name"?: string "welcome-text"?: string @@ -184,7 +183,7 @@ export const options: Options> = { // The preferred way to set the locale is via the UI. type: "string", description: ` - Set vscode display language and language to show on the login page, more info see + Set vscode display language and language to show on the login page, more info see https://en.wikipedia.org/wiki/IETF_language_tag `, }, @@ -262,15 +261,6 @@ export const options: Options> = { short: "w", description: "Text to show on login page", }, - link: { - type: OptionalString, - description: ` - Securely bind code-server via our cloud service with the passed name. You'll get a URL like - https://hostname-username.coder.co at which you can easily access your code-server instance. - Authorization is done via GitHub. - `, - deprecated: true, - }, } export const optionDescriptions = (opts: Partial>> = options): string[] => { @@ -547,17 +537,6 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config args.host = addr.host args.port = addr.port - // If we're being exposed to the cloud, we listen on a random address and - // disable auth. - if (args.link) { - args.host = "localhost" - args.port = 0 - args.socket = undefined - args["socket-mode"] = undefined - args.cert = undefined - args.auth = AuthType.None - } - if (args.cert && !args.cert.value) { const { cert, certKey } = await generateCertificate(args["cert-host"] || "localhost") args.cert = { diff --git a/src/node/coder_cloud.ts b/src/node/coder_cloud.ts deleted file mode 100644 index e34b6f317..000000000 --- a/src/node/coder_cloud.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { logger } from "@coder/logger" -import { spawn } from "child_process" -import path from "path" -import split2 from "split2" - -// https://github.com/coder/coder-cloud -const coderCloudAgent = path.resolve(__dirname, "../../lib/coder-cloud-agent") - -function runAgent(...args: string[]): Promise { - logger.debug(`running agent with ${args}`) - - const agent = spawn(coderCloudAgent, args, { - stdio: ["inherit", "inherit", "pipe"], - }) - - agent.stderr.pipe(split2()).on("data", (line) => { - line = line.replace(/^[0-9-]+ [0-9:]+ [^ ]+\t/, "") - logger.info(line) - }) - - return new Promise((res, rej) => { - agent.on("error", rej) - - agent.on("close", (code) => { - if (code !== 0) { - rej({ - message: `--link agent exited with ${code}`, - }) - return - } - res() - }) - }) -} - -export function coderCloudBind(address: URL | string, serverName = ""): Promise { - if (typeof address === "string") { - throw new Error("Cannot link socket paths") - } - - // Address needs to be in hostname:port format without the protocol. - return runAgent("bind", `--code-server-addr=${address.host}`, serverName) -} diff --git a/src/node/main.ts b/src/node/main.ts index cf5899526..64eeb619a 100644 --- a/src/node/main.ts +++ b/src/node/main.ts @@ -6,7 +6,6 @@ import { Disposable } from "../common/emitter" import { plural } from "../common/util" import { createApp, ensureAddress } from "./app" import { AuthType, DefaultedArgs, Feature, SpawnCodeCli, toCodeArgs, UserProvidedArgs } from "./cli" -import { coderCloudBind } from "./coder_cloud" import { commit, version } from "./constants" import { register } from "./routes" import { humanPath, isDirectory, loadAMDModule, open } from "./util" @@ -127,11 +126,7 @@ export const runCodeServer = async ( const disposeRoutes = await register(app, args) logger.info(`Using config file ${humanPath(os.homedir(), args.config)}`) - logger.info( - `${protocol.toUpperCase()} server listening on ${serverAddress.toString()} ${ - args.link ? "(randomized by --link)" : "" - }`, - ) + logger.info(`${protocol.toUpperCase()} server listening on ${serverAddress.toString()}`) if (args.auth === AuthType.Password) { logger.info(" - Authentication is enabled") @@ -143,13 +138,13 @@ export const runCodeServer = async ( logger.info(` - Using password from ${humanPath(os.homedir(), args.config)}`) } } else { - logger.info(` - Authentication is disabled ${args.link ? "(disabled by --link)" : ""}`) + logger.info(" - Authentication is disabled") } if (args.cert) { logger.info(` - Using certificate for HTTPS: ${humanPath(os.homedir(), args.cert.value)}`) } else { - logger.info(` - Not serving HTTPS ${args.link ? "(disabled by --link)" : ""}`) + logger.info(" - Not serving HTTPS") } if (args["proxy-domain"].length > 0) { @@ -157,11 +152,6 @@ export const runCodeServer = async ( args["proxy-domain"].forEach((domain) => logger.info(` - *.${domain}`)) } - if (args.link) { - await coderCloudBind(serverAddress, args.link.value) - logger.info(" - Connected to cloud agent") - } - if (args.enable && args.enable.length > 0) { logger.info("Enabling the following experimental features:") args.enable.forEach((feature) => { diff --git a/test/unit/node/cli.test.ts b/test/unit/node/cli.test.ts index 93124f933..3bb1024dc 100644 --- a/test/unit/node/cli.test.ts +++ b/test/unit/node/cli.test.ts @@ -297,26 +297,6 @@ describe("parser", () => { }) }) - it("should override with --link", async () => { - const args = parse( - "--cert test --cert-key test --socket test --socket-mode 777 --host 0.0.0.0 --port 8888 --link test".split(" "), - ) - const defaultArgs = await setDefaults(args) - expect(defaultArgs).toEqual({ - ...defaults, - auth: "none", - host: "localhost", - link: { - value: "test", - }, - port: 0, - cert: undefined, - "cert-key": path.resolve("test"), - socket: undefined, - "socket-mode": undefined, - }) - }) - it("should use env var password", async () => { process.env.PASSWORD = "test" const args = parse([]) @@ -881,21 +861,13 @@ describe("optionDescriptions", () => { it("should show if an option is deprecated", () => { const opts: Partial>> = { - link: { + cert: { type: OptionalString, - description: ` - Securely bind code-server via our cloud service with the passed name. You'll get a URL like - https://hostname-username.coder.co at which you can easily access your code-server instance. - Authorization is done via GitHub. - `, + description: "foo", deprecated: true, }, } - expect(optionDescriptions(opts)).toStrictEqual([ - ` --link (deprecated) Securely bind code-server via our cloud service with the passed name. You'll get a URL like - https://hostname-username.coder.co at which you can easily access your code-server instance. - Authorization is done via GitHub.`, - ]) + expect(optionDescriptions(opts)).toStrictEqual([" --cert (deprecated) foo"]) }) it("should show newlines in description", () => {