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

Commit 0e27751

Browse files
author
Alan Shaw
committed
refactor: no separate boot procedure
1 parent e6383cd commit 0e27751

23 files changed

+548
-1285
lines changed

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
],
1616
"main": "src/core/index.js",
1717
"browser": {
18-
"./src/core/components/init-assets.js": false,
1918
"./src/core/runtime/init-assets-nodejs.js": "./src/core/runtime/init-assets-browser.js",
2019
"./src/core/runtime/add-from-fs-nodejs.js": "./src/core/runtime/add-from-fs-browser.js",
2120
"./src/core/runtime/config-nodejs.js": "./src/core/runtime/config-browser.js",
@@ -26,7 +25,8 @@
2625
"./src/core/runtime/repo-nodejs.js": "./src/core/runtime/repo-browser.js",
2726
"./src/core/runtime/ipld-nodejs.js": "./src/core/runtime/ipld-browser.js",
2827
"./test/utils/create-repo-nodejs.js": "./test/utils/create-repo-browser.js",
29-
"stream": "readable-stream"
28+
"stream": "readable-stream",
29+
"ipfs-utils/src/files/glob-source": false
3030
},
3131
"browser-all-ipld-formats": {
3232
"./src/core/runtime/ipld-browser.js": "./src/core/runtime/ipld-browser-all.js"
@@ -100,15 +100,15 @@
100100
"ipfs-bitswap": "^0.26.0",
101101
"ipfs-block": "~0.8.1",
102102
"ipfs-block-service": "~0.16.0",
103-
"ipfs-http-client": "^38.2.0",
103+
"ipfs-http-client": "github:ipfs/js-ipfs-http-client#refactor/async-iterables2",
104104
"ipfs-http-response": "~0.3.1",
105105
"ipfs-mfs": "^0.13.0",
106106
"ipfs-multipart": "^0.2.0",
107107
"ipfs-repo": "^0.28.0",
108108
"ipfs-unixfs": "~0.1.16",
109109
"ipfs-unixfs-exporter": "^0.38.0",
110110
"ipfs-unixfs-importer": "^0.40.0",
111-
"ipfs-utils": "~0.4.0",
111+
"ipfs-utils": "^0.5.0",
112112
"ipld": "~0.25.0",
113113
"ipld-bitcoin": "~0.3.0",
114114
"ipld-dag-cbor": "~0.15.0",
@@ -204,9 +204,9 @@
204204
"execa": "^2.0.4",
205205
"form-data": "^2.5.1",
206206
"hat": "0.0.3",
207-
"interface-ipfs-core": "^0.117.2",
207+
"interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#refactor/async-iterables",
208208
"ipfs-interop": "^0.1.1",
209-
"ipfsd-ctl": "^0.47.2",
209+
"ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#fix/do-not-call-shutdown-twice",
210210
"libp2p-websocket-star": "~0.10.2",
211211
"ncp": "^2.0.0",
212212
"p-event": "^4.1.0",

src/cli/commands/add.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ module.exports = {
159159
let finalHash
160160

161161
try {
162-
for await (const file of ipfs._addAsyncIterator(source, options)) {
162+
for await (const file of ipfs.add(source, options)) {
163163
if (argv.silent) {
164164
continue
165165
}
@@ -184,7 +184,7 @@ module.exports = {
184184
bar.terminate()
185185
}
186186

187-
// Tweak the error message and add more relevant infor for the CLI
187+
// Tweak the error message and add more relevant info for the CLI
188188
if (err.code === 'ERR_DIR_NON_RECURSIVE') {
189189
err.message = `'${err.path}' is a directory, use the '-r' flag to specify directories`
190190
}

src/cli/commands/init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
const IPFS = require('../../core')
6666
const Repo = require('ipfs-repo')
6767

68-
const node = new IPFS({
68+
const node = await IPFS.create({
6969
repo: new Repo(path),
7070
init: false,
7171
start: false,

src/cli/daemon.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,7 @@ class Daemon {
5555

5656
// start the daemon
5757
const ipfsOpts = Object.assign({ }, this._options, { init: true, start: true, libp2p })
58-
const ipfs = new IPFS(ipfsOpts)
59-
60-
await new Promise((resolve, reject) => {
61-
ipfs.once('error', err => {
62-
this._log('error starting core', err)
63-
err.code = 'ENOENT'
64-
reject(err)
65-
})
66-
ipfs.once('start', resolve)
67-
})
68-
69-
this._ipfs = ipfs
58+
const ipfs = this._ipfs = await IPFS.create(ipfsOpts)
7059

7160
// start HTTP servers (if API or Gateway is enabled in options)
7261
const httpApi = new HttpApi(ipfs, ipfsOpts)

src/core/api-manager.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ module.exports = class ApiManager {
33
this._api = {}
44
this._onUndef = () => undefined
55
this.api = new Proxy({}, {
6-
get (target, prop) {
7-
return target[prop] === undefined
8-
? this._onUndef(prop)
9-
: target[prop]
10-
}
6+
get: (_, prop) => {
7+
if (prop === 'then') return undefined // Not a promise!
8+
return this._api[prop] === undefined ? this._onUndef(prop) : this._api[prop]
9+
},
10+
has: (_, prop) => prop in this._api
1111
})
1212
}
1313

src/core/boot.js

-90
This file was deleted.

src/core/components-ipfsx/index.js

-15
This file was deleted.

0 commit comments

Comments
 (0)