Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The big refactor! #200

Merged
merged 37 commits into from
Feb 12, 2018
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
012c327
part I of the big refactor!
daviddias Feb 7, 2018
5040d41
foundation for browser tsts
daviddias Feb 7, 2018
df9ffa0
SLAAAAY the 🐉🐉🐉
daviddias Feb 9, 2018
caca0e2
add-retrieve
daviddias Feb 9, 2018
d72ab8a
test: api.node
daviddias Feb 9, 2018
06f70a2
docs: trim the readme
daviddias Feb 9, 2018
2582dbf
moar refactor
daviddias Feb 9, 2018
9f6632c
test: remote endpoint tests
daviddias Feb 9, 2018
56c618e
start spinning browser tests again
daviddias Feb 9, 2018
b0da61a
I am finally happy with the structure of this project
daviddias Feb 9, 2018
a9f6031
fix tests in node as well as resolve a couple of todos
dryajov Feb 9, 2018
7c149a1
feat: implemented the version method for factory-in-proc
dryajov Feb 9, 2018
664d8ed
fix: `daemon exec path should match type` test
dryajov Feb 9, 2018
e476440
lint
dryajov Feb 9, 2018
aab54af
doc
dryajov Feb 9, 2018
fc49b3b
fix: get proc version from package.json
dryajov Feb 9, 2018
c8083df
test: browser tests are working again
daviddias Feb 10, 2018
8ff1976
test: more browser testing
daviddias Feb 10, 2018
2a00842
feat: added `version` endpoint
dryajov Feb 10, 2018
37194d3
experiment
dryajov Feb 10, 2018
7ee051f
feat: add tmpDir endpoint to be able to generate tmp repos in browser
dryajov Feb 10, 2018
97ab8ed
chore
daviddias Feb 12, 2018
581945e
test: fix spawn options tests
daviddias Feb 12, 2018
4d87386
dont delete addrs
daviddias Feb 12, 2018
8cc19eb
docs: polish the readme
daviddias Feb 12, 2018
12ef363
chore
daviddias Feb 12, 2018
63f5243
test: all running
daviddias Feb 12, 2018
5738822
test: all passing locally
daviddias Feb 12, 2018
bea0caf
bump timeouts
daviddias Feb 12, 2018
1463b98
test: add prefix back to repo name
daviddias Feb 12, 2018
19a4133
chore
daviddias Feb 12, 2018
ce7b68c
chore: timeout dance
daviddias Feb 12, 2018
d2f8680
fix: tmp dir
daviddias Feb 12, 2018
d9ada2e
real timeout
daviddias Feb 12, 2018
dd20ef7
feat: do not depend on any locally initalized daemon
daviddias Feb 12, 2018
30c25c6
chore
daviddias Feb 12, 2018
f9d3eb4
now yes
daviddias Feb 12, 2018
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
26 changes: 11 additions & 15 deletions src/factory-in-proc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const defaults = require('lodash.defaultsdeep')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why duplicate if factory-in-proc share %90+ code with factory-daemon?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a base class then. The main reason is that you want to avoid having factory-daemon being loaded in the browser (and all of its dependencies).

const clone = require('lodash.clone')
const waterfall = require('async/waterfall')
const series = require('async/series')
const path = require('path')
const tmpDir = require('./utils/tmp-dir')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This brought the os module to the browser.


Expand Down Expand Up @@ -101,9 +101,12 @@ class FactoryInProc {
? options.init
: true

if (!options.disposable) {
if (options.disposable) {
options.config = defaults({}, options.config, defaultConfig)
} else {
const nonDisposableConfig = clone(defaultConfig)
delete nonDisposableConfig.Addresses
// TODO why delete the addrs here???
// delete nonDisposableConfig.Addresses
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dryajov why were you deleting the addrs here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because at some point we wanted non-disposable nodes to use js-ipfs or go-ipfs default ports and not random ports.


options.init = false
options.start = false
Expand All @@ -115,32 +118,25 @@ class FactoryInProc {

options.repoPath = options.repoPath || (process.env.IPFS_PATH || defaultRepo)
options.config = defaults({}, options.config, nonDisposableConfig)
} else {
options.config = defaults({}, options.config, defaultConfig)
}

let node
options.type = this.type
options.exec = options.exec || this.exec

if (typeof options.exec !== 'function') {
return callback(new Error(`'type' proc requires 'exec' to be a coderef`))
}

node = new Node(options)
const node = new Node(options)

waterfall([
series([
(cb) => options.init
? node.init(cb)
: cb(null, node),
(node, cb) => options.start
: cb(),
(cb) => options.start
? node.start(options.args, cb)
: cb()
], (err) => {
if (err) { return callback(err) }

callback(null, node)
})
], (err) => callback(err, node))
}
}

Expand Down