forked from ipfs/js-ipfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aegir.js
135 lines (130 loc) · 3.93 KB
/
.aegir.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
'use strict'
const getPort = require('aegir/utils/get-port')
const { createServer } = require('ipfsd-ctl')
const MockPreloadNode = require('./test/utils/mock-preload-node')
const PinningService = require('./test/utils/mock-pinning-service')
const EchoServer = require('aegir/utils/echo-server')
const webRTCStarSigServer = require('libp2p-webrtc-star/src/sig-server')
const path = require('path')
/** @type {import('aegir').Options["build"]["config"]} */
const esbuild = {
inject: [path.join(__dirname, '../../scripts/node-globals.js')],
plugins: [
{
name: 'node built ins',
setup (build) {
build.onResolve({ filter: /^stream$/ }, () => {
return { path: require.resolve('readable-stream') }
})
}
}
]
}
/** @type {import('aegir').PartialOptions} */
module.exports = {
test: {
browser: {
config: {
assets: '..',
buildConfig: esbuild
}
},
before: async (options) => {
const echoServer = new EchoServer()
const preloadNode = MockPreloadNode.createNode()
const pinningService = await PinningService.start()
await preloadNode.start()
await echoServer.start()
if (options.runner !== 'node') {
const ipfsdPort = await getPort()
const signalAPort = await getPort()
const signalBPort = await getPort()
const sigServerA = await webRTCStarSigServer.start({
host: '127.0.0.1',
port: signalAPort,
metrics: false
})
// the second signalling server is needed for the interface test 'should list peers only once even if they have multiple addresses'
const sigServerB = await webRTCStarSigServer.start({
host: '127.0.0.1',
port: signalBPort,
metrics: false
})
const ipfsdServer = await createServer({
host: '127.0.0.1',
port: ipfsdPort
}, {
type: 'js',
ipfsModule: require(__dirname),
ipfsHttpModule: require('ipfs-http-client'),
ipfsBin: path.join(__dirname, 'src', 'cli.js'),
ipfsOptions: {
libp2p: {
dialer: {
dialTimeout: 60e3 // increase timeout because travis is slow
}
}
}
}, {
go: {
ipfsBin: require('go-ipfs').path()
},
js: {
ipfsClientModule: require('ipfs-client')
}
}).start()
return {
env: {
PINNING_SERVICE_ENDPOINT: pinningService.endpoint,
PINNING_SERVIEC_KEY: pinningService.token,
ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}`,
IPFSD_SERVER: `http://127.0.0.1:${ipfsdPort}`,
SIGNALA_SERVER: `/ip4/127.0.0.1/tcp/${signalAPort}/ws/p2p-webrtc-star`,
SIGNALB_SERVER: `/ip4/127.0.0.1/tcp/${signalBPort}/ws/p2p-webrtc-star`
},
echoServer,
preloadNode,
pinningService,
ipfsdServer,
sigServerA,
sigServerB
}
}
return {
env: {
PINNING_SERVICE_ENDPOINT: pinningService.endpoint,
PINNING_SERVIEC_KEY: pinningService.token,
ECHO_SERVER: `http://${echoServer.host}:${echoServer.port}`
},
echoServer,
preloadNode,
pinningService
}
},
after: async (options, beforeResult) => {
await beforeResult.echoServer.stop()
await beforeResult.preloadNode.stop()
await PinningService.stop(beforeResult.pinningService)
if (options.runner !== 'node') {
await beforeResult.ipfsdServer.stop()
await beforeResult.sigServerA.stop()
await beforeResult.sigServerB.stop()
}
}
},
build: {
bundlesizeMax: '549KB',
config: esbuild
},
dependencyCheck: {
ignore: [
'assert',
'cross-env',
'rimraf',
'url',
'wrtc',
'electron-webrtc',
'ipfs-interop'
]
}
}