Archived
1
0

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:
Jonathan Yu 2022-03-01 12:20:43 -08:00 committed by GitHub
parent 506d3f43ed
commit 2c785779b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 13 deletions

View File

@ -35,7 +35,7 @@ export const httpProxyUri =
* for outputting to the console.
*/
export function getVersionString(): string {
return [version, commit].join(" ")
return [version, commit, "with Code", codeVersion].join(" ")
}
/**

View File

@ -1,6 +1,6 @@
import { logger } from "@coder/logger"
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 { isChild, wrapper } from "./wrapper"
@ -24,7 +24,7 @@ async function entry(): Promise<void> {
const args = await setDefaults(cliArgs, configArgs)
if (args.help) {
console.log("code-server", version, commit)
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`)
@ -39,15 +39,9 @@ async function entry(): Promise<void> {
if (args.version) {
if (args.json) {
console.log(
JSON.stringify({
codeServer: version,
commit,
vscode: require("../../vendor/modules/code-oss-dev/package.json").version,
}),
)
console.log(getVersionJsonString())
} else {
console.log(version, commit)
console.log(getVersionString())
}
return
}

View File

@ -60,7 +60,9 @@ describe("constants", () => {
})
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", () => {
@ -124,7 +126,7 @@ describe("constants", () => {
it("should return a human-readable version string", () => {
// 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", () => {