Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 9ffe848

Browse files
authored
feat: migrate to next AEgir (v12)
1 parent 06d2e0a commit 9ffe848

34 files changed

+277
-243
lines changed

.aegir.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
const factory = require('./test/ipfs-factory/tasks')
4+
35
module.exports = {
46
karma: {
57
files: [{
@@ -8,5 +10,9 @@ module.exports = {
810
served: true,
911
included: false
1012
}]
13+
},
14+
hooks: {
15+
pre: factory.start,
16+
post: factory.stop
1117
}
12-
}
18+
}

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ matrix:
1313
script:
1414
- npm run lint
1515
- npm run test
16-
- npm run coverage
17-
- make test
1816

1917
before_script:
2018
- export DISPLAY=:99.0

circle.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ machine:
22
node:
33
version: stable
44

5+
test:
6+
post:
7+
- npm run coverage -- --upload
8+
59
dependencies:
610
pre:
711
- google-chrome --version

examples/bundle-browserify/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var ipfs = IPFS()
66

77
function store () {
88
var toStore = document.getElementById('source').value
9-
ipfs.add(new Buffer(toStore), function (err, res) {
9+
ipfs.add(Buffer.from(toStore), function (err, res) {
1010
if (err || !res) {
1111
return console.error('ipfs add error', err, res)
1212
}

examples/bundle-webpack/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class App extends React.Component {
2525
protocol_version: res.protocolVersion
2626
})
2727
})
28-
ipfs.add([new Buffer(stringToUse)], (err, res) => {
28+
ipfs.add([Buffer.from(stringToUse)], (err, res) => {
2929
if (err) throw err
3030
const hash = res[0].hash
3131
this.setState({added_file_hash: hash})

examples/files-api/files-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
var ipfs = require('../../src')('localhost', 5001)
3+
const ipfs = require('../../src')('localhost', 5001)
44

55
ipfs.files.ls('/folder1', function (err, res) {
66
if (err) {

examples/name-api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const addAndPublish = (e) => {
5252
e.preventDefault()
5353

5454
let input = e.target.elements['text']
55-
let buffer = new Buffer(input.value)
55+
let buffer = Buffer.from(input.value)
5656

5757
showStatus('adding to IPFS...', COLORS.active)
5858

examples/upload-file-via-browser/src/App.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class App extends React.Component {
3030
let ipfsId
3131
const buffer = Buffer.from(reader.result)
3232
this.ipfsApi.add(buffer)
33-
.then((response) => {
34-
console.log(response)
35-
ipfsId = response[0].hash
36-
console.log(ipfsId)
37-
this.setState({added_file_hash: ipfsId})
38-
}).catch((err) => {
39-
console.error(err)
40-
})
33+
.then((response) => {
34+
console.log(response)
35+
ipfsId = response[0].hash
36+
console.log(ipfsId)
37+
this.setState({added_file_hash: ipfsId})
38+
}).catch((err) => {
39+
console.error(err)
40+
})
4141
}
4242

4343
arrayBufferToString (arrayBuffer) {
@@ -51,11 +51,11 @@ class App extends React.Component {
5151
render () {
5252
return (
5353
<div>
54-
<form id="captureMedia" onSubmit={this.handleSubmit}>
55-
<input type="file" onChange={this.captureFile} />
54+
<form id='captureMedia' onSubmit={this.handleSubmit}>
55+
<input type='file' onChange={this.captureFile} />
5656
</form>
5757
<div>
58-
<a target="_blank"
58+
<a target='_blank'
5959
href={'https://ipfs.io/ipfs/' + this.state.added_file_hash}>
6060
{this.state.added_file_hash}
6161
</a>

gulpfile.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
"http": "stream-http"
1111
},
1212
"scripts": {
13-
"test": "gulp test",
14-
"test:node": "gulp test:node",
15-
"test:browser": "gulp test:browser",
16-
"lint": "aegir-lint",
17-
"build": "gulp build",
18-
"release": "gulp release",
19-
"release-minor": "gulp release --type minor",
20-
"release-major": "gulp release --type major",
21-
"coverage": "gulp coverage",
22-
"coverage-publish": "aegir-coverage publish"
13+
"test": "aegir test --no-parallel",
14+
"test:node": "aegir test --target node --no-parallel",
15+
"test:browser": "aegir test --target browser",
16+
"lint": "aegir lint",
17+
"build": "aegir build",
18+
"release": "aegir release --no-parallel",
19+
"release-minor": "aegir release --type minor --no-parallel",
20+
"release-major": "aegir release --type major --no-parallel",
21+
"coverage": "aegir coverage --no-parallel --timeout 100000",
22+
"coverage-publish": "aegir coverage --provider coveralls --no-parallel --timeout 100000"
2323
},
2424
"dependencies": {
2525
"async": "^2.5.0",
@@ -36,13 +36,13 @@
3636
"is-ipfs": "^0.3.0",
3737
"is-stream": "^1.1.0",
3838
"lru-cache": "^4.1.1",
39-
"multiaddr": "^2.3.0",
39+
"multiaddr": "^3.0.0",
4040
"multihashes": "~0.4.9",
4141
"multipart-stream": "^2.0.1",
4242
"ndjson": "^1.5.0",
4343
"once": "^1.4.0",
44-
"peer-id": "~0.9.0",
45-
"peer-info": "~0.10.0",
44+
"peer-id": "~0.10.0",
45+
"peer-info": "~0.11.0",
4646
"promisify-es6": "^1.0.3",
4747
"pump": "^1.0.2",
4848
"qs": "^6.5.0",
@@ -52,21 +52,21 @@
5252
"tar-stream": "^1.5.4"
5353
},
5454
"engines": {
55-
"node": ">=4.0.0",
55+
"node": ">=6.0.0",
5656
"npm": ">=3.0.0"
5757
},
5858
"repository": {
5959
"type": "git",
6060
"url": "https://github.com/ipfs/js-ipfs-api"
6161
},
6262
"devDependencies": {
63-
"aegir": "^11.0.2",
63+
"aegir": "^12.0.2",
6464
"chai": "^4.1.2",
6565
"dirty-chai": "^2.0.1",
6666
"eslint-plugin-react": "^7.3.0",
6767
"gulp": "^3.9.1",
6868
"hapi": "^16.5.2",
69-
"interface-ipfs-core": "~0.31.16",
69+
"interface-ipfs-core": "~0.31.18",
7070
"ipfsd-ctl": "~0.22.0",
7171
"pre-commit": "^1.2.2",
7272
"socket.io": "^2.0.3",
@@ -136,4 +136,4 @@
136136
"url": "https://github.com/ipfs/js-ipfs-api/issues"
137137
},
138138
"homepage": "https://github.com/ipfs/js-ipfs-api"
139-
}
139+
}

src/config/replace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const promisify = require('promisify-es6')
66
module.exports = (send) => {
77
return promisify((config, callback) => {
88
if (typeof config === 'object') {
9-
config = streamifier.createReadStream(new Buffer(JSON.stringify(config)))
9+
config = streamifier.createReadStream(Buffer.from(JSON.stringify(config)))
1010
}
1111

1212
send({

src/object/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = (send) => {
4545
}
4646

4747
const links = result.Links.map((l) => {
48-
return new DAGLink(l.Name, l.Size, new Buffer(bs58.decode(l.Hash)))
48+
return new DAGLink(l.Name, l.Size, Buffer.from(bs58.decode(l.Hash)))
4949
})
5050

5151
DAGNode.create(result.Data, links, (err, node) => {

src/object/links.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = (send) => {
4646

4747
if (result.Links) {
4848
links = result.Links.map((l) => {
49-
return new DAGLink(l.Name, l.Size, new Buffer(bs58.decode(l.Hash)))
49+
return new DAGLink(l.Name, l.Size, Buffer.from(bs58.decode(l.Hash)))
5050
})
5151
}
5252
callback(null, links)

src/object/new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = (send) => {
2727
}
2828
data = (new Unixfs('directory')).marshal()
2929
} else {
30-
data = new Buffer(0)
30+
data = Buffer.alloc(0)
3131
}
3232

3333
DAGNode.create(data, (err, node) => {

src/object/put.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports = (send) => {
5252
if (Buffer.isBuffer(obj) && options.enc) {
5353
buf = obj
5454
} else {
55-
buf = new Buffer(JSON.stringify(tmpObj))
55+
buf = Buffer.from(JSON.stringify(tmpObj))
5656
}
5757
const enc = options.enc || 'json'
5858

@@ -87,7 +87,7 @@ module.exports = (send) => {
8787
})
8888
return
8989
} else {
90-
DAGNode.create(new Buffer(obj.Data), obj.Links, (err, _node) => {
90+
DAGNode.create(Buffer.from(obj.Data), obj.Links, (err, _node) => {
9191
if (err) {
9292
return callback(err)
9393
}

src/utils/get-dagnode.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,38 @@ module.exports = function (send, hash, callback) {
1414
// Retrieve the object and its data in parallel, then produce a DAGNode
1515
// instance using this information.
1616
parallel([
17-
function get (done) {
17+
(done) => {
1818
send({
1919
path: 'object/get',
2020
args: multihash
2121
}, done)
2222
},
23-
24-
function data (done) {
23+
(done) => {
2524
// WORKAROUND: request the object's data separately, since raw bits in JSON
2625
// are interpreted as UTF-8 and corrupt the data.
2726
// See https://github.com/ipfs/go-ipfs/issues/1582 for more details.
2827
send({
2928
path: 'object/data',
3029
args: multihash
3130
}, done)
32-
}],
33-
34-
function done (err, res) {
35-
if (err) {
36-
return callback(err)
37-
}
31+
}
32+
], (err, res) => {
33+
if (err) {
34+
return callback(err)
35+
}
3836

39-
var object = res[0]
40-
var stream = res[1]
37+
var object = res[0]
38+
var stream = res[1]
4139

42-
if (Buffer.isBuffer(stream)) {
43-
DAGNode.create(stream, object.Links, callback)
44-
} else {
45-
streamToValue(stream, (err, data) => {
46-
if (err) {
47-
return callback(err)
48-
}
49-
DAGNode.create(data, object.Links, callback)
50-
})
51-
}
52-
})
40+
if (Buffer.isBuffer(stream)) {
41+
DAGNode.create(stream, object.Links, callback)
42+
} else {
43+
streamToValue(stream, (err, data) => {
44+
if (err) {
45+
return callback(err)
46+
}
47+
DAGNode.create(data, object.Links, callback)
48+
})
49+
}
50+
})
5351
}

src/utils/get-files-stream.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ function headers (file) {
2525

2626
function strip (name, base) {
2727
const smallBase = base
28-
.split('/')
29-
.slice(0, -1)
30-
.join('/') + '/'
28+
.split('/')
29+
.slice(0, -1)
30+
.join('/') + '/'
3131
return name.replace(smallBase, '')
3232
}
3333

src/utils/pubsub-message-utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function deserializeFromBase64 (obj) {
2727
}
2828

2929
return {
30-
from: bs58.encode(new Buffer(obj.from, 'base64')).toString(),
31-
seqno: new Buffer(obj.seqno, 'base64'),
32-
data: new Buffer(obj.data, 'base64'),
30+
from: bs58.encode(Buffer.from(obj.from, 'base64')).toString(),
31+
seqno: Buffer.from(obj.seqno, 'base64'),
32+
data: Buffer.from(obj.data, 'base64'),
3333
topicCIDs: obj.topicIDs || obj.topicCIDs
3434
}
3535
}

test/bitswap.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ const expect = chai.expect
77
chai.use(dirtyChai)
88
const FactoryClient = require('./ipfs-factory/client')
99

10-
describe('.bitswap', () => {
10+
describe('.bitswap', function () {
11+
this.timeout(20 * 1000) // slow CI
1112
let ipfs
1213
let fc
1314

14-
before(function (done) {
15+
before((done) => {
1516
this.timeout(20 * 1000) // slow CI
1617
fc = new FactoryClient()
1718
fc.spawnNode((err, node) => {

test/bootstrap.spec.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ const FactoryClient = require('./ipfs-factory/client')
1111
const invalidArg = 'this/Is/So/Invalid/'
1212
const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'
1313

14-
describe('.bootstrap', () => {
14+
describe('.bootstrap', function () {
15+
this.timeout(100 * 1000)
16+
1517
let ipfs
1618
let fc
1719

18-
before(function (done) {
19-
this.timeout(20 * 1000) // slow CI
20+
before((done) => {
2021
fc = new FactoryClient()
2122
fc.spawnNode((err, node) => {
2223
expect(err).to.not.exist()
@@ -31,7 +32,9 @@ describe('.bootstrap', () => {
3132

3233
let peers
3334

34-
describe('Callback API', () => {
35+
describe('Callback API', function () {
36+
this.timeout(100 * 1000)
37+
3538
describe('.add', () => {
3639
it('returns an error when called with an invalid arg', (done) => {
3740
ipfs.bootstrap.add(invalidArg, (err) => {
@@ -112,7 +115,9 @@ describe('.bootstrap', () => {
112115
})
113116
})
114117

115-
describe('Promise API', () => {
118+
describe('Promise API', function () {
119+
this.timeout(100 * 1000)
120+
116121
describe('.add', () => {
117122
it('returns an error when called without args or options', () => {
118123
return ipfs.bootstrap.add(null)

0 commit comments

Comments
 (0)