Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 1d780d6

Browse files
committed
feat: add interface and http client versions to version output
Adds `interface-ipfs-core` and `ipfs-http-client` versions to the output of the `ipfs version` command, also the git commit id if it's available. Closes #2878
1 parent 343bd45 commit 1d780d6

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

packages/ipfs/src/cli/commands/version.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
})
4343

4444
const withCommit = all || commit
45-
const parsedVersion = `${data.version}${withCommit ? `-${data.commit}` : ''}`
45+
const parsedVersion = `${data.version}${withCommit && data.commit ? `-${data.commit}` : ''}`
4646

4747
if (repo) {
4848
// go-ipfs prints only the number, even without the --number flag.
@@ -51,9 +51,15 @@ module.exports = {
5151
print(parsedVersion)
5252
} else if (all) {
5353
print(`js-ipfs version: ${parsedVersion}`)
54+
print(`interface-ipfs-core version: ${data['interface-ipfs-core']}`)
55+
print(`ipfs-http-client version: ${data['ipfs-http-client']}`)
5456
print(`Repo version: ${data.repo}`)
5557
print(`System version: ${os.arch()}/${os.platform()}`)
5658
print(`Node.js version: ${process.version}`)
59+
60+
if (data.commit) {
61+
print(`Commit: ${data.commit}`)
62+
}
5763
} else {
5864
print(`js-ipfs version: ${parsedVersion}`)
5965
}

packages/ipfs/src/core/components/version.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
const pkg = require('../../../package.json')
44
const { withTimeoutOption } = require('../utils')
55

6-
// TODO add the commit hash of the current ipfs version to the response.
76
module.exports = ({ repo }) => {
87
return withTimeoutOption(async function version (options) {
98
const repoVersion = await repo.version.get(options)
109

1110
return {
1211
version: pkg.version,
1312
repo: repoVersion,
14-
commit: ''
13+
commit: pkg.gitHead || '', // is defined in published versions,
14+
'interface-ipfs-core': pkg.devDependencies['interface-ipfs-core'],
15+
'ipfs-http-client': pkg.dependencies['ipfs-http-client']
1516
}
1617
})
1718
}

packages/ipfs/src/http/api/resources/version.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ module.exports = {
3737
return h.response({
3838
Version: version.version,
3939
Commit: version.commit,
40-
Repo: version.repo
40+
Repo: version.repo,
41+
'ipfs-http-client': version['ipfs-http-client'],
42+
'interface-ipfs-core': version['interface-ipfs-core']
4143
})
4244
}
4345
}

0 commit comments

Comments
 (0)