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

Commit

Permalink
feat: add interface and http client versions to version output
Browse files Browse the repository at this point in the history
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
  • Loading branch information
achingbrain committed Jun 25, 2020
1 parent 343bd45 commit 2f04471
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/ipfs/src/cli/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
})

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

if (repo) {
// go-ipfs prints only the number, even without the --number flag.
Expand All @@ -51,9 +51,15 @@ module.exports = {
print(parsedVersion)
} else if (all) {
print(`js-ipfs version: ${parsedVersion}`)
print(`interface-ipfs-core version: ${data['interface-ipfs-core']}`)
print(`ipfs-http-client version: ${data['ipfs-http-client']}`)
print(`Repo version: ${data.repo}`)
print(`System version: ${os.arch()}/${os.platform()}`)
print(`Node.js version: ${process.version}`)

if (data.commit) {
print(`Commit: ${data.commit}`)
}
} else {
print(`js-ipfs version: ${parsedVersion}`)
}
Expand Down
5 changes: 3 additions & 2 deletions packages/ipfs/src/core/components/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
const pkg = require('../../../package.json')
const { withTimeoutOption } = require('../utils')

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

return {
version: pkg.version,
repo: repoVersion,
commit: ''
commit: pkg.gitHead || '', // is defined in published versions,
'interface-ipfs-core': pkg.devDependencies['interface-ipfs-core'],
'ipfs-http-client': pkg.dependencies['ipfs-http-client']
}
})
}

0 comments on commit 2f04471

Please sign in to comment.