This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path.aegir.cjs
86 lines (80 loc) · 2.29 KB
/
.aegir.cjs
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
'use strict'
const path = require('path')
const createServer = require('ipfsd-ctl').createServer
const signaler = require('libp2p-webrtc-star/src/sig-server')
/** @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') }
})
build.onResolve({ filter: /^ipfs$/ }, () => {
return { path: require.resolve(process.env.IPFS_JS_MODULE || 'ipfs') }
})
build.onResolve({ filter: /^ipfs-http-client$/ }, () => {
return { path: require.resolve(process.env.IPFS_JS_HTTP_MODULE || 'ipfs-http-client') }
})
}
}
]
}
const ipfsHttpModule = require(process.env.IPFS_JS_HTTP_MODULE || 'ipfs-http-client')
const ipfsModule = require(process.env.IPFS_JS_MODULE || 'ipfs')
/** @type {import('aegir').PartialOptions} */
module.exports = {
test: {
browser: {
config: {
buildConfig: esbuild
}
},
async before (options) {
if (options.runner !== 'node') {
const ipfsdServer = await createServer({
host: '127.0.0.1',
port: 43134
}, {
type: 'go',
test: true,
ipfsHttpModule
}, {
go: {
ipfsBin: process.env.IPFS_GO_EXEC || require(process.env.IPFS_GO_IPFS_MODULE || 'go-ipfs').path()
},
js: {
ipfsOptions: {
config: {
libp2p: {
dialer: {
dialTimeout: 60e3 // increase timeout because travis is slow
}
}
}
},
ipfsModule,
ipfsBin: process.env.IPFS_JS_EXEC || ipfsModule.path()
}
}).start()
const signalingServer = await signaler.start({
port: 24642,
host: '0.0.0.0',
metrics: false
})
return {
ipfsdServer,
signalingServer
}
}
},
async after (options, before) {
if (options.runner !== 'node') {
await before.ipfsdServer.stop()
await before.signalingServer.stop()
}
}
}
}