Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

docs: updated examples to new api #2729

Merged
merged 56 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5c2a71a
docs: updated examples to new api
achingbrain Jan 23, 2020
4597d88
chore: fix linting
achingbrain Jan 24, 2020
17e336c
chore: update deps
achingbrain Jan 24, 2020
e732978
chore: update gh urls
achingbrain Jan 24, 2020
732e786
chore: http gh urls maybe
achingbrain Jan 24, 2020
82326a3
chore: revert previous
achingbrain Jan 24, 2020
45a6f26
chore: use correct gh url
achingbrain Jan 24, 2020
ef65183
chore: update dep version
achingbrain Jan 24, 2020
f3e9c76
fix: fix failing tests
achingbrain Jan 24, 2020
2346488
chore: remove gh url
achingbrain Jan 24, 2020
a9ac189
docs: update module maintainers
achingbrain Jan 27, 2020
ba3998d
fix: returns string peer ids from all api methods
achingbrain Jan 27, 2020
3ce9db4
docs: update module maintainers
achingbrain Jan 27, 2020
7f79b69
chore: fix linter
achingbrain Jan 27, 2020
6597e37
chore: run pubsub room tests against master
achingbrain Jan 27, 2020
4a42063
fix: fix circuit relaying test
achingbrain Jan 28, 2020
7064f6b
fix: really fix circuit relay test
achingbrain Jan 28, 2020
cdc767d
wip: add debug
achingbrain Jan 28, 2020
a404a36
wip: debug only test job and restore gh versions
achingbrain Jan 28, 2020
6b0de9f
fix: fix exchange files in browser test
achingbrain Jan 28, 2020
0c30d05
chore: remove gh urls
achingbrain Jan 28, 2020
bc7e62d
wip: really force kill daemon
achingbrain Jan 28, 2020
a1d52de
chore: correct branch name
achingbrain Jan 28, 2020
92bc015
chore: make unhandled rejections fail tests
achingbrain Jan 28, 2020
dcf052f
chore: if debug is enabled do not treat stderr output as error
achingbrain Jan 28, 2020
b831a03
chore: skip silent test when debug log is turned on
achingbrain Jan 28, 2020
0c352f2
Merge remote-tracking branch 'origin/master' into refactor/async-exam…
achingbrain Jan 28, 2020
db52fba
chore: update deps
achingbrain Jan 29, 2020
41a738e
fix: peer ids are strings, do not stringify them
achingbrain Jan 29, 2020
b6988ee
fix: use gh url for ipfsd-ctl
achingbrain Jan 29, 2020
b5d76a3
fix: use version of interface tests without js-ipfs
achingbrain Jan 29, 2020
684b873
chore: remove debug env var
achingbrain Jan 30, 2020
2b6f0e9
fix: start webrtc sigserve during tests so browsers can dial things
achingbrain Jan 30, 2020
7b868a3
fix: include go-ipfs-dep for interop testing
achingbrain Jan 31, 2020
602f761
fix: specify ipfs js module for interop tests
achingbrain Jan 31, 2020
acd2409
fix: simplify interop test runs
achingbrain Jan 31, 2020
192d4fa
fix: update sigserver url
achingbrain Jan 31, 2020
2bb99f5
fix: use ws and not wss
achingbrain Jan 31, 2020
4f7fbe7
Update test/utils/factory.js
achingbrain Jan 31, 2020
2671356
chore: remove gh urls
achingbrain Jan 31, 2020
bf9ac59
fix: fix up ipfsd-ctl config for browser tests
achingbrain Jan 31, 2020
dd0eb4e
fix: increase dialer timeout in tests
achingbrain Jan 31, 2020
b0e2ee5
chore: enable libp2p debug for chrome build
achingbrain Jan 31, 2020
cbb6f24
chore: fail fast on browser builds
achingbrain Jan 31, 2020
5aa630d
chore: just run the failing tests
achingbrain Jan 31, 2020
6f7aca2
chore: split webworker tests out from browsers
achingbrain Feb 1, 2020
67e2bd8
fix: use go nodes with webworker interface tests
achingbrain Feb 2, 2020
75727b8
fix: use js for pubsub tests as before
achingbrain Feb 2, 2020
57277ef
fix: go-ipfs pubsub is no longer experimental
achingbrain Feb 3, 2020
e629d4a
fix: configure go-ipfs bin for ipfsd server
achingbrain Feb 3, 2020
b3cb06d
refactor: use string template
achingbrain Feb 3, 2020
30036f5
fix: update interface tests and remove only
achingbrain Feb 3, 2020
2b53ccb
chore: update ipfs-interop dep
Feb 3, 2020
e154bf5
fix: hls example
Feb 3, 2020
8f57ee3
fix: use libp2p with ping patch
achingbrain Feb 3, 2020
67e073d
chore: remove gh version
achingbrain Feb 3, 2020
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
70 changes: 61 additions & 9 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
'use strict'

const IPFSFactory = require('ipfsd-ctl')
const { createServer } = require('ipfsd-ctl')
const MockPreloadNode = require('./test/utils/mock-preload-node')
const EchoServer = require('interface-ipfs-core/src/utils/echo-http-server')
const webRTCStarSigServer = require('libp2p-webrtc-star/src/sig-server')
const path = require('path')
const webpack = require('webpack')
const os = require('os')

const ipfsdServer = IPFSFactory.createServer()
const preloadNode = MockPreloadNode.createNode()
const echoServer = EchoServer.createServer()

// the second signalling server is needed for the inferface test 'should list peers only once even if they have multiple addresses'
let sigServerA
let sigServerB
let ipfsdServer

module.exports = {
bundlesize: { maxSize: '652kB' },
webpack: {
resolve: {
mainFields: ['browser', 'main'],
aliasFields: ['browser', 'browser-all-ipld-formats'],
}
},
...(process.env.NODE_ENV === 'test' ? {
plugins: [
new webpack.EnvironmentPlugin(['DEBUG'])
]
} : {})
},
karma: {
files: [{
Expand All @@ -39,14 +52,53 @@ module.exports = {
},
browser: {
pre: async () => {
await ipfsdServer.start()
await preloadNode.start()
await echoServer.start()
await preloadNode.start()
await echoServer.start()
sigServerA = await webRTCStarSigServer.start({
host: '127.0.0.1',
port: 14579,
metrics: false
})
sigServerB = await webRTCStarSigServer.start({
host: '127.0.0.1',
port: 14578,
metrics: false
})
ipfsdServer = await createServer({
host: '127.0.0.1',
port: 43134
}, {
type: 'js',
ipfsModule: {
path: __dirname,
ref: require(__dirname)
},
ipfsHttpModule: {
path: require.resolve('ipfs-http-client'),
ref: require('ipfs-http-client')
},
ipfsBin: path.join(__dirname, 'src', 'cli', 'bin.js'),
ipfsOptions: {
config: {
libp2p: {
dialer: {
dialTimeout: 60e3 // increase timeout because travis is slow
}
}
}
}
}, {
go: {
ipfsBin: require.resolve(`go-ipfs-dep/go-ipfs/ipfs${os.platform() === 'win32' ? '.exe' : ''}`)
}
}).start()
},
post: async () => {
await ipfsdServer.stop()
await preloadNode.stop()
await echoServer.stop()
await ipfsdServer.stop()
await preloadNode.stop()
await echoServer.stop()
await sigServerA.stop()
await sigServerB.stop()
}
}
}
Expand Down
48 changes: 21 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,28 @@ jobs:
addons:
chrome: stable
script:
- npx aegir test -t browser -t webworker
- npx aegir test -t browser --bail

- stage: test
name: chrome webworker
addons:
chrome: stable
script:
- npx aegir test -t webworker --bail

- stage: test
name: firefox
addons:
firefox: latest
script:
- npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
- npx aegir test -t browser --bail -- --browsers FirefoxHeadless

- stage: test
name: firefox webworker
addons:
firefox: latest
script:
- npx aegir test -t webworker --bail -- --browsers FirefoxHeadless

- stage: test
name: electron-main
Expand All @@ -76,44 +90,24 @@ jobs:
- stage: test
name: interop - node
script:
- mkdir -p node_modules/ipfs-interop/node_modules
- ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- export IPFS_REUSEPORT=false
- cd node_modules/ipfs-interop
- npx aegir test -t node --bail
- npm run test:interop:node -- --bail

- stage: test
name: interop - browser
script:
- mkdir -p node_modules/ipfs-interop/node_modules
- ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- export IPFS_REUSEPORT=false
- cd node_modules/ipfs-interop
- npx aegir test -t browser --bail
- npm run test:interop:browser -- --bail

- stage: test
name: interop - electron-main
os: osx
script:
- mkdir -p node_modules/ipfs-interop/node_modules
- ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- export IPFS_REUSEPORT=false
- cd node_modules/ipfs-interop
- npx aegir test -t electron-main -f ./test/node.js --bail --timeout 10000
- npm run test:interop:electron-main -- --bail --timeout 10000

- stage: test
name: interop - electron-renderer
os: osx
script:
- mkdir -p node_modules/ipfs-interop/node_modules
- ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- export IPFS_REUSEPORT=false
- cd node_modules/ipfs-interop
- npx aegir test -t electron-renderer -f ./test/browser.js --bail --timeout 10000
- npm run test:interop:electron-renderer -- --bail --timeout 10000

- stage: test
name: external - ipfs-companion
Expand All @@ -128,7 +122,7 @@ jobs:
- stage: test
name: external - ipfs-pubsub-room
script:
- npm run test:external -- ipfs-pubsub-room https://github.com/ipfs-shipyard/ipfs-pubsub-room.git --branch upgrade-to-latest-js-ipfs-rc
- npm run test:external -- ipfs-pubsub-room https://github.com/ipfs-shipyard/ipfs-pubsub-room.git

- stage: test
name: external - peer-base
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<br>
</p>

### Project status - `Alpha`
### Project status - `Alpha` <!-- omit in toc -->

We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉..

Expand All @@ -40,19 +40,16 @@ We've come a long way, but this project is still in Alpha, lots of development i

[**`Weekly Core Implementations Call`**](https://github.com/ipfs/team-mgmt/issues/992)

## Tech Lead
## Tech Lead <!-- omit in toc -->

[David Dias](https://github.com/daviddias)

## Lead Maintainer
## Lead Maintainer <!-- omit in toc -->

[Alan Shaw](https://github.com/alanshaw)

## Table of Contents
## Table of Contents <!-- omit in toc -->

- [Tech Lead](#tech-lead)
- [Lead Maintainer](#lead-maintainer)
- [Table of Contents](#table-of-contents)
- [Install](#install)
- [npm](#npm)
- [Use in Node.js](#use-in-nodejs)
Expand All @@ -66,6 +63,7 @@ We've come a long way, but this project is still in Alpha, lots of development i
- [API](#api)
- [IPFS Constructor](#ipfs-constructor)
- [`options.repo`](#optionsrepo)
- [`options.repoAutoMigrate`](#optionsrepoautomigrate)
- [`options.init`](#optionsinit)
- [`options.start`](#optionsstart)
- [`options.pass`](#optionspass)
Expand Down Expand Up @@ -1106,7 +1104,7 @@ Listing of the main packages used in the IPFS ecosystem. There are also three sp
| [`ipfs-mfs`](//github.com/ipfs/js-ipfs-mfs) | [![npm](https://img.shields.io/npm/v/ipfs-mfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-mfs/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-mfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-mfs) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-mfs.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-mfs) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-mfs/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-mfs) | [Alex Potsides](mailto:alex.potsides@protocol.ai) |
| [`ipfs-unixfs`](//github.com/ipfs/js-ipfs-unixfs) | [![npm](https://img.shields.io/npm/v/ipfs-unixfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-unixfs/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-unixfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-unixfs) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-unixfs.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-unixfs) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-unixfs/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-unixfs) | [Alex Potsides](mailto:alex.potsides@protocol.ai) |
| **Repo** |
| [`ipfs-repo`](//github.com/ipfs/js-ipfs-repo) | [![npm](https://img.shields.io/npm/v/ipfs-repo.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-repo/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-repo.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-repo.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-repo) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-repo/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-repo) | [Jacob Heun](mailto:jacobheun@gmail.com) |
| [`ipfs-repo`](//github.com/ipfs/js-ipfs-repo) | [![npm](https://img.shields.io/npm/v/ipfs-repo.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-repo/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-repo.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-repo.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-repo) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-repo/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-repo) | [Alex Potsides](mailto:alex.potsides@protocol.ai) |
| **Exchange** |
| [`ipfs-block-service`](//github.com/ipfs/js-ipfs-block-service) | [![npm](https://img.shields.io/npm/v/ipfs-block-service.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-block-service/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-block-service.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-block-service) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-block-service.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-block-service) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-block-service/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-block-service) | [Volker Mische](mailto:volker.mische@gmail.com) |
| [`ipfs-block`](//github.com/ipfs/js-ipfs-block) | [![npm](https://img.shields.io/npm/v/ipfs-block.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-block/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-block.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-block) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-block.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-block) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-block/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-block) | [Volker Mische](mailto:volker.mische@gmail.com) |
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-video-streaming/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<body>
<video id="video" controls></video>
<script src="../../dist/index.js"></script>
<script src="https://unpkg.com/hlsjs-ipfs-loader@0.1.4/dist/index.js"></script>
<script src="https://unpkg.com/hlsjs-ipfs-loader@0.2.3/dist/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="streaming.js"></script>
</body>
Expand Down
1 change: 0 additions & 1 deletion examples/browser-video-streaming/streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/* global Hls Ipfs HlsjsIpfsLoader */
/* eslint-env browser */

document.addEventListener('DOMContentLoaded', async () => {
const testHash = 'QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K'
const repoPath = 'ipfs-' + Math.random()
Expand Down
2 changes: 1 addition & 1 deletion examples/circuit-relaying/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "MIT",
"dependencies": {
"ipfs": "file:../../",
"ipfs-pubsub-room": "^1.4.0"
"ipfs-pubsub-room": "^2.0.1"
},
"devDependencies": {
"aegir": "^20.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/circuit-relaying/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const mkRoomName = (name) => {

module.exports = (ipfs, peersSet) => {
const createRoom = (name) => {
const room = Room(ipfs, mkRoomName(name))
const room = new Room(ipfs, mkRoomName(name))

room.on('peer joined', (peer) => {
console.log('peer ' + peer + ' joined')
Expand Down
4 changes: 3 additions & 1 deletion examples/circuit-relaying/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ async function runTest () {

try {
const id = await ipfsd.api.id()
const address = id.addresses.filter(addr => addr.includes('/ws/ipfs/Qm')).pop()
const address = id.addresses
.map(ma => ma.toString())
.find(addr => addr.includes('/ws/p2p/Qm'))

if (!address) {
throw new Error(`Could not find web socket address in ${id.addresses}`)
Expand Down
19 changes: 10 additions & 9 deletions examples/custom-ipfs-repo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const IPFS = require('ipfs')
const Repo = require('ipfs-repo')
const fsLock = require('ipfs-repo/src/lock')
const all = require('it-all')

// Create our custom options
const customRepositoryOptions = {
Expand Down Expand Up @@ -79,19 +80,19 @@ async function main () {
console.log('Version:', version)

// Once we have the version, let's add a file to IPFS
const filesAdded = await node.add({
for await (const file of node.add({
path: 'test-data.txt',
content: Buffer.from('We are using a customized repo!')
})

// Log out the added files metadata and cat the file from IPFS
console.log('\nAdded file:', filesAdded[0].path, filesAdded[0].hash)
})) {
// Log out the added files metadata and cat the file from IPFS
console.log('\nAdded file:', file.path, file.cid)

const data = await node.cat(filesAdded[0].hash)
const data = Buffer.concat(await all(node.cat(file.cid)))

// Print out the files contents to console
console.log('\nFetched file content:')
process.stdout.write(data)
// Print out the files contents to console
console.log('\nFetched file content:')
process.stdout.write(data)
}

// After everything is done, shut the node down
console.log('\n\nStopping the node')
Expand Down
3 changes: 2 additions & 1 deletion examples/custom-ipfs-repo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"dependencies": {
"datastore-fs": "^0.9.1",
"ipfs": "file:../../",
"ipfs-repo": "^0.28.0"
"ipfs-repo": "^0.28.0",
"it-all": "^1.0.1"
},
"devDependencies": {
"execa": "^3.2.0"
Expand Down
16 changes: 4 additions & 12 deletions examples/custom-libp2p/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict'

const Libp2p = require('libp2p')
const IPFS = require('ipfs')
const IPFS = require('../../')
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
const WebSocketStar = require('libp2p-websocket-star')
const Bootstrap = require('libp2p-bootstrap')
const SPDY = require('libp2p-spdy')
const KadDHT = require('libp2p-kad-dht')
const MPLEX = require('pull-mplex')
const MPLEX = require('libp2p-mplex')
const SECIO = require('libp2p-secio')

/**
Expand All @@ -32,11 +31,6 @@ const libp2pBundle = (opts) => {
const peerBook = opts.peerBook
const bootstrapList = opts.config.Bootstrap

// Create our WebSocketStar transport and give it our PeerId, straight from the ipfs node
const wsstar = new WebSocketStar({
id: peerInfo.id
})

// Build and return our libp2p node
return new Libp2p({
peerInfo,
Expand All @@ -49,8 +43,7 @@ const libp2pBundle = (opts) => {
},
modules: {
transport: [
TCP,
wsstar
TCP
],
streamMuxer: [
MPLEX,
Expand All @@ -61,8 +54,7 @@ const libp2pBundle = (opts) => {
],
peerDiscovery: [
MulticastDNS,
Bootstrap,
wsstar.discovery
Bootstrap
],
dht: KadDHT
},
Expand Down
Loading