Skip to content

Commit

Permalink
Remove deprecated --link (#6018)
Browse files Browse the repository at this point in the history
  • Loading branch information
code-asher authored Feb 13, 2023
1 parent 6d8ed77 commit ac1fba8
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 169 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 0 additions & 16 deletions ci/build/build-code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
2 changes: 0 additions & 2 deletions ci/build/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
23 changes: 2 additions & 21 deletions ci/build/npm-postinstall.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 0 additions & 11 deletions docs/link.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
23 changes: 1 addition & 22 deletions src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -184,7 +183,7 @@ export const options: Options<Required<UserProvidedArgs>> = {
// 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
`,
},
Expand Down Expand Up @@ -262,15 +261,6 @@ export const options: Options<Required<UserProvidedArgs>> = {
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<Required<UserProvidedArgs>>> = options): string[] => {
Expand Down Expand Up @@ -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 = {
Expand Down
43 changes: 0 additions & 43 deletions src/node/coder_cloud.ts

This file was deleted.

16 changes: 3 additions & 13 deletions src/node/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand All @@ -143,25 +138,20 @@ 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) {
logger.info(` - ${plural(args["proxy-domain"].length, "Proxying the following domain")}:`)
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) => {
Expand Down
34 changes: 3 additions & 31 deletions test/unit/node/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([])
Expand Down Expand Up @@ -881,21 +861,13 @@ describe("optionDescriptions", () => {

it("should show if an option is deprecated", () => {
const opts: Partial<Options<Required<UserProvidedArgs>>> = {
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", () => {
Expand Down

0 comments on commit ac1fba8

Please sign in to comment.