mirror of
https://github.com/cdr/code-server.git
synced 2025-12-10 02:12:21 +01:00
* Move integration types into code-server
This will be easier to maintain than to have it as a patch.
* Disable connection token
Using a flag means we will not need to patch it out. I think this is
new from 1.64?
* Add product.json to build process
This way we do not have to patch it.
* Ship with remote agent package.json
Instead of the root one. This contains fewer dependencies.
* Let Code handle errors
This way we will not have to patch Code to make this work and I think it
makes sense to let Code handle the request.
If we do want to handle errors we can do it cleanly by patching their
error handler to throw instead.
* Move manifest override into code-server
This way we will not have to patch it.
* Move to patches
- Switch submodule to track upstream
- Add quilt to the process
- Add patches
The node-* ignore was ignoring one of the diffs so I removed it. This
was added when we were curling Node as node-v{version}-darwin-x64 for
the macOS build but this no longer happens (we use the Node action to
install a specific version now so we just use the system-wide Node).
* Use pre-packaged Code
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import { logger } from "@coder/logger"
|
|
import { optionDescriptions, parse, readConfigFile, setDefaults, shouldOpenInExistingInstance } from "./cli"
|
|
import { getVersionString, getVersionJsonString } from "./constants"
|
|
import { openInExistingInstance, runCodeServer, runCodeCli, shouldSpawnCliProcess } from "./main"
|
|
import { isChild, wrapper } from "./wrapper"
|
|
|
|
async function entry(): Promise<void> {
|
|
// There's no need to check flags like --help or to spawn in an existing
|
|
// instance for the child process because these would have already happened in
|
|
// the parent and the child wouldn't have been spawned. We also get the
|
|
// arguments from the parent so we don't have to parse twice and to account
|
|
// for environment manipulation (like how PASSWORD gets removed to avoid
|
|
// leaking to child processes).
|
|
if (isChild(wrapper)) {
|
|
const args = await wrapper.handshake()
|
|
wrapper.preventExit()
|
|
const server = await runCodeServer(args)
|
|
wrapper.onDispose(() => server.dispose())
|
|
return
|
|
}
|
|
|
|
const cliArgs = parse(process.argv.slice(2))
|
|
const configArgs = await readConfigFile(cliArgs.config)
|
|
const args = await setDefaults(cliArgs, configArgs)
|
|
|
|
if (args.help) {
|
|
console.log("code-server", getVersionString())
|
|
console.log("")
|
|
console.log(`Usage: code-server [options] [path]`)
|
|
console.log(` - Opening a directory: code-server ./path/to/your/project`)
|
|
console.log(` - Opening a saved workspace: code-server ./path/to/your/project.code-workspace`)
|
|
console.log("")
|
|
console.log("Options")
|
|
optionDescriptions().forEach((description) => {
|
|
console.log("", description)
|
|
})
|
|
return
|
|
}
|
|
|
|
if (args.version) {
|
|
if (args.json) {
|
|
console.log(getVersionJsonString())
|
|
} else {
|
|
console.log(getVersionString())
|
|
}
|
|
return
|
|
}
|
|
|
|
if (shouldSpawnCliProcess(args)) {
|
|
logger.debug("Found VS Code arguments; spawning VS Code CLI")
|
|
return runCodeCli(args)
|
|
}
|
|
|
|
const socketPath = await shouldOpenInExistingInstance(cliArgs)
|
|
if (socketPath) {
|
|
logger.debug("Trying to open in existing instance")
|
|
return openInExistingInstance(args, socketPath)
|
|
}
|
|
|
|
return wrapper.start(args)
|
|
}
|
|
|
|
entry().catch((error) => {
|
|
logger.error(error.message)
|
|
wrapper.exit(error)
|
|
})
|