-
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
feat: move ipfs to peer deps #446
Changes from 5 commits
e1cd001
0606d3b
f9eb5ed
95a7bad
44f1431
6adceb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,9 +56,6 @@ | |
"debug": "^4.1.1", | ||
"execa": "^4.0.0", | ||
"fs-extra": "^8.1.0", | ||
"go-ipfs-dep": "~0.4.22", | ||
"ipfs": "0.40.0", | ||
"ipfs-http-client": "^41.0.0", | ||
"ipfs-utils": "^0.7.1", | ||
"ky": "^0.16.1", | ||
"ky-universal": "^0.3.0", | ||
|
@@ -77,6 +74,11 @@ | |
"husky": "^4.0.10", | ||
"lint-staged": "^10.0.2" | ||
}, | ||
"peerDependencies": { | ||
"go-ipfs-dep": "*", | ||
"ipfs": "*", | ||
"ipfs-http-client": "*" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...but I think you'll have to install all of these even if you use only 1 because the calls to require will fail? Do we need try/catches? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quite right. I think you'll need I've pushed a change that only requires |
||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ipfs/js-ipfsd-ctl.git" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,6 @@ const defaults = { | |
path: require.resolve('ipfs-http-client'), | ||
ref: require('ipfs-http-client') | ||
}, | ||
ipfsModule: { | ||
path: require.resolve('ipfs'), | ||
ref: require('ipfs') | ||
}, | ||
ipfsBin: findBin('go'), | ||
ipfsOptions: {} | ||
} | ||
|
||
|
@@ -46,11 +41,19 @@ class Factory { | |
/** @type ControllerOptions */ | ||
this.opts = merge(defaults, options) | ||
|
||
// conditionally include ipfs based on which type of daemon we will spawn when none has been specifed | ||
if ((this.opts.type === 'js' || this.opts.type === 'proc') && !this.opts.ipfsModule) { | ||
this.opts.ipfsModule = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will overwrite There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good shout, have pushed a fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just to avoid throwing when spawning go controllers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, when your project is only going to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this still fails when bundling (or at least warns depending on the bundler) and if the user wants to use js or proc they are forced to specify it in the factory constructor or else they get an error when calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've moved that clause to |
||
path: require.resolve('ipfs'), | ||
ref: require('ipfs') | ||
} | ||
} | ||
|
||
/** @type ControllerOptionsOverrides */ | ||
this.overrides = merge({ | ||
js: merge(this.opts, { type: 'js', ipfsBin: findBin('js') }), | ||
go: this.opts, | ||
proc: merge(this.opts, { type: 'proc', ipfsBin: findBin('js') }) | ||
js: merge(this.opts, { type: 'js', ipfsBin: findBin('js', this.opts.type === 'js') }), | ||
go: merge(this.opts, { type: 'go', ipfsBin: findBin('go', this.opts.type === 'go') }), | ||
proc: merge(this.opts, { type: 'proc', ipfsBin: findBin('js', this.opts.type === 'proc') }) | ||
}, overrides) | ||
|
||
/** @type ControllerDaemon[] */ | ||
|
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.
For discussion: we should install the versions this module depends on otherwise updating them may cause the tests for this module to break.
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.
Can do, though this module depends on
*
so it already does install the version this module depends on, for better or for worseWe could change it to be an actual version, but that would imply we require a certain version.
On that, looking through the code quickly, the API methods we call are:
ipfs.id
ipfs.version
ipfs.init
ipfs.start
ipfs.stop
I guess it's feasible that we could refactor those, but they are pretty low-churn.
The
.id
invocation looks a bit weird to me - it's used to set apeerId
property on a node which is then used by the tests so we could probably remove it (in another PR).We could probably remove
.version
too, as the caller can just invoke the API method themselves.