This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: ipfs version
flags + ipfs repo version
#1181
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f512285
initial implementation of repo version reporting. Just learned that i…
JonKrone 11be5c2
Refactor version to use ipfs.version, implement --number and --all fl…
JonKrone af2bfed
clean commands/version, write tests for version.
JonKrone f60e6c7
merge upstream
JonKrone 27fe0db
merge upstream
JonKrone 6c3e521
add test for . Just scaffolding, don't know how to get the correct ve…
JonKrone 880e696
merge origin
JonKrone 84b5641
Add tests for , found a bug, fixed it by flattening response of http …
JonKrone fc7b623
bump ipfs-api version, now has /repo/version route
JonKrone 67e2aab
lint; clean
JonKrone 15ee937
whoops. clean again
JonKrone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
'use strict' | ||
|
||
const boom = require('boom') | ||
|
||
exports = module.exports | ||
|
||
exports.version = (request, reply) => { | ||
const ipfs = request.server.app.ipfs | ||
|
||
ipfs.repo.version((err, version) => { | ||
if (err) { | ||
return reply(boom.badRequest(err)) | ||
} | ||
|
||
reply(version) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const expect = require('chai').expect | ||
const runOnAndOff = require('../utils/on-and-off') | ||
|
||
function getRepoVersion (repoPath) { | ||
const versionPath = path.join(repoPath, 'version') | ||
return String(fs.readFileSync(versionPath)) | ||
} | ||
|
||
describe('repo', () => runOnAndOff((thing) => { | ||
let ipfs | ||
let repoVersion | ||
|
||
before(() => { | ||
ipfs = thing.ipfs | ||
repoVersion = getRepoVersion(ipfs.repoPath) | ||
}) | ||
|
||
it('get the repo version', () => { | ||
return ipfs('repo version').then((out) => { | ||
expect(out).to.eql(`${repoVersion}\n`) | ||
}) | ||
}) | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JonKrone found the issue. Here you are assuming that IPFS has always been init when it is not the case always. the Sharness test is checking the version with ipfs offline and without init.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! In order to avoid the init constraint, go-ipfs accesses the repo version directly from a constant exposed by go-ipfs/repo so the repo version is available offline and without an initialized repo. Analogous to
const repoVersion = require('ipfs-repo').version
Unfortunately, there's no similar field exposed by the
js-ipfs-repo
package. We could read thejs-ipfs-repo/constants
file directly like we're doing withpkg.version
above or add the version as an export of thejs-ipfs-repo
package.If we need to be able to read the version w/o init, I think an export is the way to go and replace the dependence of
core/components/repo.version
on an initialized_repo
with justrequire('ipfs-repo').version
. Should we then add this version constant to the repo SPEC?Feels like a big change to not use the repo API, what are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can totally expose the constant, however, I do not think is the best approach. If we use the version from the module, then we might have a false positive where the module is signaling the latest repo version than the one that is inited.
I feel that the right way to do it is:
version
from the repoversion
from the constantThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I agree! I looked into what happens when the version is outdated and found that starting the daemon with an outdated
~./jsipfs/version
throws during startup. So even runningjs-ipfs --help
fails. test:echo "5" > ~/.jsipfs/version && jsipfs --help
.If that's expected behavior, I can't think of a case where you can run a cli command on an initialized but outdated repo, and we could safely report the constant
version
.I think you have the right of it, though, and we should aim for reporting the version of
~/.jsipfs/version
if the repo is initialized and maybe at some point in the future, change startup so that we delay opening the repo connection or make accessing the version independent of opening a repo?either way: ipfs/js-ipfs-repo#158