Skip to content
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

fix: downgrade ky #451

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const createServer = require('./src').createServer

const server = createServer() // using defaults
module.exports = {
bundlesize: { maxSize: '930kB' },
bundlesize: { maxSize: '35kB' },
karma: {
files: [{
pattern: 'test/fixtures/**/*',
Expand All @@ -16,5 +16,12 @@ module.exports = {
hooks: {
pre: () => server.start(),
post: () => server.stop()
},
webpack: process.env.NODE_ENV === 'test' ? undefined : {
externals: {
ipfs: 'ipfs',
'ipfs-http-client': 'ipfs-http-client',
'go-ipfs-dep': 'go-ipfs-dep'
}
}
}
20 changes: 1 addition & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,13 @@ os:
- windows

script:
- npm install ipfs
- npm install ipfs-http-client
- npm install go-ipfs-dep
- npx nyc -s npm run test:node -- --timeout 60000
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

jobs:
include:
- stage: check
script:
- npm install ipfs
- npm install ipfs-http-client
- npm install go-ipfs-dep
- npx aegir build --bundlesize
- npx aegir commitlint --travis
- npx aegir dep-check
Expand All @@ -42,37 +36,25 @@ jobs:
addons:
chrome: stable
script:
- npm install ipfs
- npm install ipfs-http-client
- npm install go-ipfs-dep
- npx aegir test -t browser -t webworker --bail --timeout 60000

- stage: test
name: firefox
addons:
firefox: latest
script:
- npm install ipfs
- npm install ipfs-http-client
- npm install go-ipfs-dep
- npx aegir test -t browser -t webworker --bail --timeout 60000 -- --browsers FirefoxHeadless

- stage: test
name: electron-main
os: osx
script:
- npm install ipfs
- npm install ipfs-http-client
- npm install go-ipfs-dep
- npx aegir test -t electron-main --bail --timeout 60000

- stage: test
name: electron-renderer
os: osx
script:
- npm install ipfs
- npm install ipfs-http-client
- npm install go-ipfs-dep
- npx aegir test -t electron-renderer --bail --timeout 60000
notifications:
email: false
email: false
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"execa": "^4.0.0",
"fs-extra": "^8.1.0",
"ipfs-utils": "^0.7.1",
"ky": "^0.16.1",
"ky": "^0.15.0",
"ky-universal": "^0.3.0",
"merge-options": "^2.0.0",
"multiaddr": "^7.2.1",
Expand All @@ -71,7 +71,10 @@
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"dirty-chai": "^2.0.1",
"go-ipfs-dep": "^0.4.22",
"husky": "^4.0.10",
"ipfs": "^0.40.0",
"ipfs-http-client": "^42.0.0-pre.0",
"lint-staged": "^10.0.2"
},
"peerDependencies": {
Expand Down
91 changes: 61 additions & 30 deletions src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ const defaults = {
type: 'go',
env: {},
args: [],
ipfsHttpModule: {
path: require.resolve('ipfs-http-client'),
ref: require('ipfs-http-client')
},
ipfsModule: {},
ipfsOptions: {},
forceKill: true,
forceKillTimeout: 5000
Expand All @@ -51,14 +46,6 @@ class Factory {
proc: merge(this.opts, { type: 'proc' })
}, overrides)

if (!this.overrides.js.ipfsBin) {
this.overrides.js.ipfsBin = findBin('js', this.opts.type === 'js')
}

if (!this.overrides.go.ipfsBin) {
this.overrides.go.ipfsBin = findBin('go', this.opts.type === 'go')
}

/** @type ControllerDaemon[] */
this.controllers = []
}
Expand Down Expand Up @@ -87,18 +74,39 @@ class Factory {
}

async _spawnRemote (options) {
const res = await ky.post(
`${options.endpoint}/spawn`,
{
json: {
...options,
// avoid recursive spawning
remote: false,
// do not send code refs over http
ipfsModule: { ...options.ipfsModule, ref: undefined },
ipfsHttpModule: { ...options.ipfsHttpModule, ref: undefined }
const opts = {
json: {
...options,
// avoid recursive spawning
remote: false
}
}

if (options.ipfsModule) {
delete opts.ipfsModule

if (options.ipfsModule.path) {
opts.ipfsModule = {
path: options.ipfsModule.path
// n.b. no ref property - do not send code refs over http
}
}
}

if (options.ipfsHttpModule) {
delete opts.ipfsHttpModule

if (options.ipfsHttpModule.path) {
opts.ipfsHttpModule = {
path: options.ipfsHttpModule.path
// n.b. no ref property - do not send code refs over http
}
}
}

const res = await ky.post(
`${options.endpoint}/spawn`,
opts
).json()
return new ControllerRemote(
options.endpoint,
Expand All @@ -116,16 +124,39 @@ class Factory {
const type = options.type || this.opts.type
const opts = merge(
this.overrides[type],
// conditionally include ipfs based on which type of daemon we will spawn when none has been specifed
(type === 'js' || type === 'proc') ? {
ipfsModule: {
path: require.resolve('ipfs'),
ref: require('ipfs')
}
} : {},
options
)

// conditionally include ipfs based on which type of daemon we will spawn when none has been specified
if ((opts.type === 'js' || opts.type === 'proc') && !opts.ipfsModule) {
opts.ipfsModule = {}
}

if (opts.ipfsModule) {
if (!opts.ipfsModule.path) {
opts.ipfsModule.path = require.resolve('ipfs')
}

if (!opts.ipfsModule.ref) {
opts.ipfsModule.ref = require('ipfs')
}
}

// only include the http api client if it has not been specified as an option
// for example if we are testing the http api client itself we should not try
// to require 'ipfs-http-client'
if (!opts.ipfsHttpModule) {
opts.ipfsHttpModule = {
path: require.resolve('ipfs-http-client'),
ref: require('ipfs-http-client')
}
}

// find ipfs binary if not specified
if (opts.type !== 'proc' && !opts.ipfsBin) {
opts.ipfsBin = findBin(opts.type, true)
}

// IPFS options defaults
const ipfsOptions = merge(
{
Expand Down