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

Commit cfc5cfc

Browse files
committed
feat: aegir-next
1 parent 688d918 commit cfc5cfc

35 files changed

+280
-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+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
package-lock.json
2+
yarn.lock
3+
14
**/node_modules
25
**/*.log
36
test/setup/tmp-disposable-nodes-addrs.json

.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",
@@ -37,7 +37,7 @@
3737
"is-stream": "^1.1.0",
3838
"lru-cache": "^4.1.1",
3939
"multiaddr": "^2.3.0",
40-
"multihashes": "~0.4.5",
40+
"multihashes": "~0.4.8",
4141
"multipart-stream": "^2.0.1",
4242
"ndjson": "^1.5.0",
4343
"once": "^1.4.0",
@@ -52,26 +52,26 @@
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.1",
6565
"dirty-chai": "^2.0.1",
66-
"eslint-plugin-react": "^7.1.0",
66+
"eslint-plugin-react": "^7.3.0",
6767
"gulp": "^3.9.1",
6868
"hapi": "^16.5.2",
69-
"interface-ipfs-core": "~0.30.1",
69+
"interface-ipfs-core": "~0.31.8",
7070
"ipfsd-ctl": "~0.21.0",
7171
"pre-commit": "^1.2.2",
7272
"socket.io": "^2.0.3",
7373
"socket.io-client": "^2.0.3",
74-
"stream-equal": "^1.0.0"
74+
"stream-equal": "^1.0.1"
7575
},
7676
"pre-commit": [
7777
"lint",
@@ -134,4 +134,4 @@
134134
"url": "https://github.com/ipfs/js-ipfs-api/issues"
135135
},
136136
"homepage": "https://github.com/ipfs/js-ipfs-api"
137-
}
137+
}

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
@@ -8,40 +8,38 @@ module.exports = function (send, hash, callback) {
88
// Retrieve the object and its data in parallel, then produce a DAGNode
99
// instance using this information.
1010
parallel([
11-
function get (done) {
11+
(done) => {
1212
send({
1313
path: 'object/get',
1414
args: hash
1515
}, done)
1616
},
17-
18-
function data (done) {
17+
(done) => {
1918
// WORKAROUND: request the object's data separately, since raw bits in JSON
2019
// are interpreted as UTF-8 and corrupt the data.
2120
// See https://github.com/ipfs/go-ipfs/issues/1582 for more details.
2221
send({
2322
path: 'object/data',
2423
args: hash
2524
}, done)
26-
}],
27-
28-
function done (err, res) {
29-
if (err) {
30-
return callback(err)
31-
}
25+
}
26+
], (err, res) => {
27+
if (err) {
28+
return callback(err)
29+
}
3230

33-
var object = res[0]
34-
var stream = res[1]
31+
var object = res[0]
32+
var stream = res[1]
3533

36-
if (Buffer.isBuffer(stream)) {
37-
DAGNode.create(stream, object.Links, callback)
38-
} else {
39-
streamToValue(stream, (err, data) => {
40-
if (err) {
41-
return callback(err)
42-
}
43-
DAGNode.create(data, object.Links, callback)
44-
})
45-
}
46-
})
34+
if (Buffer.isBuffer(stream)) {
35+
DAGNode.create(stream, object.Links, callback)
36+
} else {
37+
streamToValue(stream, (err, data) => {
38+
if (err) {
39+
return callback(err)
40+
}
41+
DAGNode.create(data, object.Links, callback)
42+
})
43+
}
44+
})
4745
}

src/utils/get-files-stream.js

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

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

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) => {

0 commit comments

Comments
 (0)