mirror of https://github.com/coder/code-server.git
feat: add version of Code OSS to output (#4925)
Show the bundled version of Code OSS in the text-based output for --version and --help, in addition to the JSON output (--version --json) Closes: #4874
This commit is contained in:
parent
506d3f43ed
commit
2c785779b5
|
@ -35,7 +35,7 @@ export const httpProxyUri =
|
||||||
* for outputting to the console.
|
* for outputting to the console.
|
||||||
*/
|
*/
|
||||||
export function getVersionString(): string {
|
export function getVersionString(): string {
|
||||||
return [version, commit].join(" ")
|
return [version, commit, "with Code", codeVersion].join(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { logger } from "@coder/logger"
|
import { logger } from "@coder/logger"
|
||||||
import { optionDescriptions, parse, readConfigFile, setDefaults, shouldOpenInExistingInstance } from "./cli"
|
import { optionDescriptions, parse, readConfigFile, setDefaults, shouldOpenInExistingInstance } from "./cli"
|
||||||
import { commit, version } from "./constants"
|
import { getVersionString, getVersionJsonString } from "./constants"
|
||||||
import { openInExistingInstance, runCodeServer, runVsCodeCli, shouldSpawnCliProcess } from "./main"
|
import { openInExistingInstance, runCodeServer, runVsCodeCli, shouldSpawnCliProcess } from "./main"
|
||||||
import { isChild, wrapper } from "./wrapper"
|
import { isChild, wrapper } from "./wrapper"
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ async function entry(): Promise<void> {
|
||||||
const args = await setDefaults(cliArgs, configArgs)
|
const args = await setDefaults(cliArgs, configArgs)
|
||||||
|
|
||||||
if (args.help) {
|
if (args.help) {
|
||||||
console.log("code-server", version, commit)
|
console.log("code-server", getVersionString())
|
||||||
console.log("")
|
console.log("")
|
||||||
console.log(`Usage: code-server [options] [path]`)
|
console.log(`Usage: code-server [options] [path]`)
|
||||||
console.log(` - Opening a directory: code-server ./path/to/your/project`)
|
console.log(` - Opening a directory: code-server ./path/to/your/project`)
|
||||||
|
@ -39,15 +39,9 @@ async function entry(): Promise<void> {
|
||||||
|
|
||||||
if (args.version) {
|
if (args.version) {
|
||||||
if (args.json) {
|
if (args.json) {
|
||||||
console.log(
|
console.log(getVersionJsonString())
|
||||||
JSON.stringify({
|
|
||||||
codeServer: version,
|
|
||||||
commit,
|
|
||||||
vscode: require("../../vendor/modules/code-oss-dev/package.json").version,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
console.log(version, commit)
|
console.log(getVersionString())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,9 @@ describe("constants", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should return a human-readable version string", () => {
|
it("should return a human-readable version string", () => {
|
||||||
expect(constants.getVersionString()).toStrictEqual(`${mockPackageJson.version} ${mockPackageJson.commit}`)
|
expect(constants.getVersionString()).toStrictEqual(
|
||||||
|
`${mockPackageJson.version} ${mockPackageJson.commit} with Code ${mockCodePackageJson.version}`,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should return a machine-readable version string", () => {
|
it("should return a machine-readable version string", () => {
|
||||||
|
@ -124,7 +126,7 @@ describe("constants", () => {
|
||||||
|
|
||||||
it("should return a human-readable version string", () => {
|
it("should return a human-readable version string", () => {
|
||||||
// this string is not super useful
|
// this string is not super useful
|
||||||
expect(constants.getVersionString()).toStrictEqual("development development")
|
expect(constants.getVersionString()).toStrictEqual("development development with Code development")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should return a machine-readable version string", () => {
|
it("should return a machine-readable version string", () => {
|
||||||
|
|
Loading…
Reference in New Issue