-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New API + use bin-wrapper (bundle in all arch without any concern) + global install #89
Conversation
Ok, looks like the 0.4.2 issue is a known one ipfs/kubo#2748 |
"ipfs-api": "^4.1.0", | ||
"multiaddr": "^2.0.0", | ||
"rimraf": "^2.4.5", | ||
"run-series": "^1.1.4", | ||
"shutdown": "^0.2.4", | ||
"subcomandante": "^1.0.5" | ||
"subcomandante": "^1.0.5", |
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.
do we still need this module with bin-wrapper?
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.
Yeah, because despite having a run method (which is poorly named in my opinion) this will only act like a search for the binary and run a test command to check everything is ok (usually --version
or version
in our case), not considering any outputs and such. So we still need something to run the command itself and, as we already use subcomandante
, I assume it's probably the best choice.
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.
I just filed an issue with node-core about not cleaning up spawned processes. So maybe in a near future we don't need it anymore :)
nodejs/node#7951
This is awesome @JGAntunes :D Yeah, the issue with |
@@ -322,7 +322,7 @@ describe('external ipfs binaray', () => { | |||
ipfsd.local((err, node) => { | |||
if (err) throw err | |||
|
|||
assert.equal(node.exec, '/some/path') | |||
assert.equal(node.exec, '/some/path/ipfs') |
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.
Could you change from assert
to expect
?
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.
Sure thing 👍
@diasdavid as for the documentation, sure! I'll give it a look once all this stuff is sorted out. |
Thank you :) |
@@ -0,0 +1,16 @@ | |||
'use strict' |
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.
All files should be under src
Ok, let me know what you all think. Still missing documentation and further testing @diasdavid @dignifiedquire |
While building some more tests I've noticed there's an issue with the way |
@JGAntunes Do we still need to use subcomandante with bin-wrapper? Let's make this PR work with 0.4.3-rc1, so that we can use it to test js-ipfs-api as well Do you need help with the documentation part? |
@diasdavid we still need something to run and exec the commands, the bin-wrapper Alright, I'll update the binary for 0.4.3-rc1 I was waiting for some feedback on the matters above so I can start documenting stuff. If the API will remain unchanged I can start working on that right away. |
config.baseUrl = 'https://dist.ipfs.io/go-ipfs/' + | ||
config.version + | ||
'/go-ipfs_' + | ||
config.version + '_' |
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.
Could use path.join
const distPage = 'https://dist.ipfs.io'
const version = config.version
config.baseUrl = path.join(distPage, 'go-ipfs', version, `go-ipfs_${version}`)
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.
Unfortunately path.join
when used on URLs strips down the //
to /
and invalidates it. The result would be https:/dist.ipfs.io/go-ipfs/v0.4.1/go-ipfs_v0.4.1
. I can leave the protocol aside, join it later and join everything else with path.join
if you think that's worth it.
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.
oh right, I forgot about that :( No it's not worth it then, but you could instead do [..].join('/')
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.
Yeah, true! I was also thinking on using template strings, something like:
const version = config.version
config.baseUrl = `https://dist.ipfs.io/go-ipfs/${version}/go-ipfs_${version}_`
Do you prefer this or the Array.join
?
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.
I think the just template strings is actually much more readable in this case :)
@JGAntunes you can run any command with bin-wrapper -- https://www.npmjs.com/package/bin-wrapper#runcmd-callback -- too, running run('daemon', () =>) will keep the daemon process till it is closed. Check how Akasha did it https://github.com/AkashaProject/ipfs-connector/blob/master/src/IpfsConnector.js |
@diasdavid we just need to ensure that it closes the process when the parent process dies (which is why node-subcommandante exists in the first place) |
@diasdavid if you check the bin-wrapper source code the I've already looked at how Akasha did it and if you look at it they also don't use bin-wrapper |
@JGAntunes got it, thank you :) |
We need to at least:
|
We also need:
|
This PR should fix the issues around node-subcomandate jbenet/node-subcomandante#5. FYI @dignifiedquire @diasdavid |
@JGAntunes can you please add the |
@JGAntunes as soon as sindresorhus/execa#53 is merged and released I suggest using that instead of subcomandante to spawn and control the daemon. It's a much nicer and well maintained module. |
Hey folks, sorry for being kind of away towards the end of this week. @dignifiedquire will update the aegir module during this weekend and make the change to execa once your PR is merged 👍 I'll also try to give it a go on the documentation. |
Thank you @JGAntunes for the great work here. We have updated go-ipfs-dep to include a lot of the things we learned from here and more, so we don't need to implement all the binary handling here :) Again thank you for all the work and keeping with us. In terms of the actual interface changes I think we will want to go with the ideas here: ipfs/js-ipfs#556 |
Merged #140, closing this one. @JGAntunes again thank you for helping out with these issues and my apologies for the huge lag from PR to actually getting something merged in, this module is highly sensible as it touches running processes at the OS level and so improvements have to happen slowly (execa vs subcomandante), as for the remaining features added, as @dignifiedquire noted, they were added to npm-go-ipfs-dep, which is now capable of picking the right dist through a package.json value. Again, thank you <3 |
Np folks, glad I could help out anyway 👍 |
[WIP]
This should close #78, it's still a work in progress but let me know what you think so far.
There are still some issues though and further testing is needed. Also somehow the ipfs init command hangs for version 0.4.2, still have to look at what's going on with it.