From 1dec93edd4a2e8e3a76ba5fc223b5c816cbcdf6c Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Sat, 17 Oct 2015 00:56:29 -0400 Subject: [PATCH 1/5] bitcore -> bitcore-lib --- README.md | 21 +++++++++++---------- benchmarks/blockhandler.js | 2 +- docs/index.md | 18 +++++++++--------- docs/services.md | 6 +++--- integration/p2p.js | 2 +- integration/regtest-node.js | 2 +- integration/regtest.js | 2 +- lib/node.js | 2 +- lib/scaffold/add.js | 2 +- lib/scaffold/create.js | 4 ++-- lib/scaffold/find-config.js | 2 +- lib/scaffold/remove.js | 2 +- lib/scaffold/start.js | 2 +- lib/services/address/history.js | 4 ++-- lib/services/address/index.js | 2 +- lib/services/bitcoind.js | 2 +- lib/services/db.js | 2 +- lib/transaction.js | 2 +- package.json | 4 ++-- test/node.unit.js | 2 +- test/scaffold/add.integration.js | 2 +- test/services/address/index.unit.js | 2 +- test/services/db.unit.js | 5 ++--- 23 files changed, 47 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 1d4de809..2478c459 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ A Bitcoin full node for building applications and services with Node.js. A node ## Install ```bash -npm install -g bitcore-node@latest -bitcore-node start +npm install -g bitcore +bitcore start ``` Note: For your convenience, we distribute binaries for x86_64 Linux and x86_64 Mac OS X. Upon npm install, the binaries for your platform will be downloaded. For more detailed installation instructions, or if you want to compile the project yourself, then please see the [Build & Install](docs/build.md) documentation to build the project from source. @@ -16,34 +16,35 @@ Note: For your convenience, we distribute binaries for x86_64 Linux and x86_64 M - Node.js v0.12 - ~100GB of disk storage -- ~1GB of RAM +- ~4GB of RAM - Mac OS X >= 10.9, Ubuntu >= 12.04 (libc >= 2.15 and libstdc++ >= 6.0.16) ## Configuration -Bitcore Node includes a Command Line Interface (CLI) for managing, configuring and interfacing with your Bitcore Node. +Bitcore includes a Command Line Interface (CLI) for managing, configuring and interfacing with your Bitcore Node. ```bash -bitcore-node create -d mynode "My Node" +bitcore create -d mynode cd mynode -bitcore-node add -bitcore-node add https://github.com/yourname/helloworld +bitcore add +bitcore add https://github.com/yourname/helloworld ``` This will create a directory with configuration files for your node and install the necessary dependencies. For more information about (and developing) services, please see the [Service Documentation](docs/services.md). -To start bitcore-node as a daemon: +To start bitcore as a daemon: ```bash -bitcore-node start --daemon +bitcore start --daemon ``` ## Add-on Services -There are several add-on services available to extend the functionality of Bitcore Node: +There are several add-on services available to extend the functionality of Bitcore: - [Insight API](https://github.com/bitpay/insight-api/tree/v0.3.0) - [Insight UI](https://github.com/bitpay/insight/tree/v0.3.0) +- [Bitcore Wallet Service](https://github.com/bitpay/bitcore-wallet-service) ## Documentation diff --git a/benchmarks/blockhandler.js b/benchmarks/blockhandler.js index f1ba07c4..3b46e750 100644 --- a/benchmarks/blockhandler.js +++ b/benchmarks/blockhandler.js @@ -3,7 +3,7 @@ var benchmark = require('benchmark'); var async = require('async'); var sinon = require('sinon'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var Block = bitcore.Block; var AddressService = require('../lib/services/address'); var maxTime = 20; diff --git a/docs/index.md b/docs/index.md index 65869f3f..2a5363d6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,8 +6,8 @@ A Bitcoin full node for building applications and services with Node.js. A node ## Install ```bash -npm install -g bitcore-node@latest -bitcore-node start +npm install -g bitcore +bitcore start ``` Note: For your convenience, we distribute binaries for x86_64 Linux and x86_64 Mac OS X. Upon npm install, the binaries for your platform will be downloaded. For more detailed installation instructions, or if you want to compile the project yourself, then please see the [Build & Install](build.md) documentation to build the project from source. @@ -16,26 +16,26 @@ Note: For your convenience, we distribute binaries for x86_64 Linux and x86_64 M - Node.js v0.12 - ~100GB of disk storage -- ~1GB of RAM +- ~4GB of RAM - Mac OS X >= 10.9, Ubuntu >= 12.04 (libc >= 2.15 and libstdc++ >= 6.0.16) ## Configuration -Bitcore Node includes a Command Line Interface (CLI) for managing, configuring and interfacing with your Bitcore Node. +Bitcore includes a Command Line Interface (CLI) for managing, configuring and interfacing with your Bitcore Node. ```bash -bitcore-node create -d mynode "My Node" +bitcore create -d mynode cd mynode -bitcore-node add -bitcore-node add https://github.com/yourname/helloworld +bitcore add +bitcore add https://github.com/yourname/helloworld ``` This will create a directory with configuration files for your node and install the necessary dependencies. For more information about (and developing) services, please see the [Service Documentation](services.md). -To start bitcore-node as a daemon: +To start bitcore as a daemon: ```bash -bitcore-node start --daemon +bitcore start --daemon ``` ## Add-on Services diff --git a/docs/services.md b/docs/services.md index dc0b3b6d..4de1dbf4 100644 --- a/docs/services.md +++ b/docs/services.md @@ -28,7 +28,7 @@ Services correspond with a Node.js module as described in 'package.json', for ex ```json { "dependencies": { - "bitcore": "^0.13.1", + "bitcore-lib": "^0.13.7", "bitcore-node": "^0.2.0", "insight-api": "^3.0.0" } @@ -47,8 +47,8 @@ var bitcore = require('bitcore-node'); //Services var Address = bitcore.services.Address; var Bitcoin = bitcore.services.Bitcoin; -var DB = bitcore.services.DB; -var Web = bitcore.services.Web; +var DB = bitcore.services.DB; +var Web = bitcore.services.Web; var myNode = new bitcore.Node({ datadir: '~/.bitcore', diff --git a/integration/p2p.js b/integration/p2p.js index 0de4cb1e..b578b908 100644 --- a/integration/p2p.js +++ b/integration/p2p.js @@ -11,7 +11,7 @@ var p2p = require('bitcore-p2p'); var Peer = p2p.Peer; var Messages = p2p.Messages; var chai = require('chai'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var Transaction = bitcore.Transaction; var BN = bitcore.crypto.BN; var async = require('async'); diff --git a/integration/regtest-node.js b/integration/regtest-node.js index e6c8dacb..fa7dd3fe 100644 --- a/integration/regtest-node.js +++ b/integration/regtest-node.js @@ -16,7 +16,7 @@ if (process.env.BITCORENODE_ENV !== 'test') { } var chai = require('chai'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var rimraf = require('rimraf'); var node; diff --git a/integration/regtest.js b/integration/regtest.js index 64f67f27..9b80ac10 100644 --- a/integration/regtest.js +++ b/integration/regtest.js @@ -14,7 +14,7 @@ if (process.env.BITCORENODE_ENV !== 'test') { } var chai = require('chai'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var BN = bitcore.crypto.BN; var async = require('async'); var rimraf = require('rimraf'); diff --git a/lib/node.js b/lib/node.js index 6d3aaa83..7853dc11 100644 --- a/lib/node.js +++ b/lib/node.js @@ -3,7 +3,7 @@ var util = require('util'); var EventEmitter = require('events').EventEmitter; var async = require('async'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var Networks = bitcore.Networks; var $ = bitcore.util.preconditions; var _ = bitcore.deps._; diff --git a/lib/scaffold/add.js b/lib/scaffold/add.js index b5d1b0d5..5d0e6eea 100644 --- a/lib/scaffold/add.js +++ b/lib/scaffold/add.js @@ -4,7 +4,7 @@ var async = require('async'); var fs = require('fs'); var path = require('path'); var spawn = require('child_process').spawn; -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; diff --git a/lib/scaffold/create.js b/lib/scaffold/create.js index 12491b92..35f41a41 100644 --- a/lib/scaffold/create.js +++ b/lib/scaffold/create.js @@ -1,7 +1,7 @@ 'use strict'; var spawn = require('child_process').spawn; -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var async = require('async'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; @@ -20,7 +20,7 @@ if (packageFile.version.match('-dev')) { var BASE_PACKAGE = { dependencies: { - 'bitcore': '^' + bitcore.version, + 'bitcore-lib': '^' + bitcore.version, 'bitcore-node': version } }; diff --git a/lib/scaffold/find-config.js b/lib/scaffold/find-config.js index 6a947ad7..f1c70b53 100644 --- a/lib/scaffold/find-config.js +++ b/lib/scaffold/find-config.js @@ -1,6 +1,6 @@ 'use strict'; -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; var path = require('path'); diff --git a/lib/scaffold/remove.js b/lib/scaffold/remove.js index 4fd84d77..d17dabf4 100644 --- a/lib/scaffold/remove.js +++ b/lib/scaffold/remove.js @@ -5,7 +5,7 @@ var fs = require('fs'); var npm = require('npm'); var path = require('path'); var spawn = require('child_process').spawn; -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; diff --git a/lib/scaffold/start.js b/lib/scaffold/start.js index 0d24228e..9949347b 100644 --- a/lib/scaffold/start.js +++ b/lib/scaffold/start.js @@ -3,7 +3,7 @@ var path = require('path'); var BitcoreNode = require('../node'); var index = require('../'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var _ = bitcore.deps._; var $ = bitcore.util.preconditions; var log = index.log; diff --git a/lib/services/address/history.js b/lib/services/address/history.js index 751d6cd4..61e77158 100644 --- a/lib/services/address/history.js +++ b/lib/services/address/history.js @@ -1,6 +1,6 @@ 'use strict'; -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var async = require('async'); var _ = bitcore.deps._; @@ -228,7 +228,7 @@ AddressHistory.prototype.getDetailedInfo = function(txInfo, next) { height: transaction.__height, confirmations: self.getConfirmationsDetail(transaction), timestamp: transaction.__timestamp, - // TODO bitcore should return null instead of throwing error on coinbase + // TODO bitcore-lib should return null instead of throwing error on coinbase fees: !transaction.isCoinbase() ? transaction.getFee() : null, tx: transaction }); diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 9b15e569..11d973cd 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -7,7 +7,7 @@ var index = require('../../'); var log = index.log; var errors = index.errors; var Transaction = require('../../transaction'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var levelup = require('levelup'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index 51edd638..87e7ebc9 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -4,7 +4,7 @@ var fs = require('fs'); var util = require('util'); var bindings = require('bindings')('bitcoind.node'); var mkdirp = require('mkdirp'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var $ = bitcore.util.preconditions; var index = require('../'); var log = index.log; diff --git a/lib/services/db.js b/lib/services/db.js index c78b6f33..8ad70bd5 100644 --- a/lib/services/db.js +++ b/lib/services/db.js @@ -6,7 +6,7 @@ var async = require('async'); var levelup = require('levelup'); var leveldown = require('leveldown'); var mkdirp = require('mkdirp'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var BufferUtil = bitcore.util.buffer; var Networks = bitcore.Networks; var Block = bitcore.Block; diff --git a/lib/transaction.js b/lib/transaction.js index ae3fd89d..bc7bda44 100644 --- a/lib/transaction.js +++ b/lib/transaction.js @@ -2,7 +2,7 @@ var async = require('async'); var levelup = require('levelup'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var Transaction = bitcore.Transaction; Transaction.prototype.populateInputs = function(db, poolTransactions, callback) { diff --git a/package.json b/package.json index 668677e6..427891c8 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "dependencies": { "async": "^1.3.0", "bindings": "^1.2.1", - "bitcore": "^0.13.0", + "bitcore-lib": "^0.13.7", "body-parser": "^1.13.3", "colors": "^1.1.2", "commander": "^2.8.1", @@ -73,7 +73,7 @@ "proxyquire": "^1.3.1", "rimraf": "^2.4.2", "sinon": "^1.15.4", - "bitcore-p2p": "^0.15.1" + "bitcore-p2p": "~1.0.0" }, "engines": { "node": ">=0.12.0" diff --git a/test/node.unit.js b/test/node.unit.js index 6593f7b5..4a20f37e 100644 --- a/test/node.unit.js +++ b/test/node.unit.js @@ -2,7 +2,7 @@ var should = require('chai').should(); var sinon = require('sinon'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var Networks = bitcore.Networks; var proxyquire = require('proxyquire'); var util = require('util'); diff --git a/test/scaffold/add.integration.js b/test/scaffold/add.integration.js index 34bbb1a4..21ef4ad7 100644 --- a/test/scaffold/add.integration.js +++ b/test/scaffold/add.integration.js @@ -94,7 +94,7 @@ describe('#add', function() { var callCount = 0; var oldPackage = { dependencies: { - 'bitcore': '^v0.13.1', + 'bitcore-lib': '^v0.13.7', 'bitcore-node': '^v0.2.0' } }; diff --git a/test/services/address/index.unit.js b/test/services/address/index.unit.js index 5add2cce..41e65307 100644 --- a/test/services/address/index.unit.js +++ b/test/services/address/index.unit.js @@ -6,7 +6,7 @@ var proxyquire = require('proxyquire'); var bitcorenode = require('../../../'); var AddressService = bitcorenode.services.Address; var blockData = require('../../data/livenet-345003.json'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var Script = bitcore.Script; var Address = bitcore.Address; var Networks = bitcore.Networks; diff --git a/test/services/db.unit.js b/test/services/db.unit.js index a5032845..0d5ea257 100644 --- a/test/services/db.unit.js +++ b/test/services/db.unit.js @@ -7,18 +7,17 @@ var proxyquire = require('proxyquire'); var index = require('../../'); var DB = index.services.DB; var blockData = require('../data/livenet-345003.json'); -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var Networks = bitcore.Networks; var Block = bitcore.Block; var BufferUtil = bitcore.util.buffer; +var Transaction = bitcore.Transaction; var transactionData = require('../data/bitcoin-transactions.json'); var chainHashes = require('../data/hashes.json'); var chainData = require('../data/testnet-blocks.json'); var errors = index.errors; var memdown = require('memdown'); var levelup = require('levelup'); -var bitcore = require('bitcore'); -var Transaction = bitcore.Transaction; describe('DB Service', function() { From 58894bc4b299cbc5e83c9a292f1e0c5f2aa9588b Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Sat, 17 Oct 2015 08:15:25 -0400 Subject: [PATCH 2/5] Expose cli methods. --- bin/bitcore-node | 5 +++++ cli/bitcore-node.js | 44 ---------------------------------------- docs/index.md | 4 ++-- docs/scaffold.md | 8 ++------ index.js | 5 ++++- lib/cli/bitcore.js | 40 ++++++++++++++++++++++++++++++++++++ lib/cli/bitcored.js | 40 ++++++++++++++++++++++++++++++++++++ lib/cli/daemon.js | 36 ++++++++++++++++++++++++++++++++ {cli => lib/cli}/main.js | 15 +++++++------- lib/scaffold/create.js | 4 ++-- package.json | 5 +++-- 11 files changed, 142 insertions(+), 64 deletions(-) create mode 100755 bin/bitcore-node delete mode 100755 cli/bitcore-node.js create mode 100644 lib/cli/bitcore.js create mode 100644 lib/cli/bitcored.js create mode 100644 lib/cli/daemon.js rename {cli => lib/cli}/main.js (93%) diff --git a/bin/bitcore-node b/bin/bitcore-node new file mode 100755 index 00000000..9d968099 --- /dev/null +++ b/bin/bitcore-node @@ -0,0 +1,5 @@ +#!/usr/bin/env node +// vi: ft=javascript -*- mode: JavaScript; -*- + +var node = require('..'); +node.cli.bitcore(); diff --git a/cli/bitcore-node.js b/cli/bitcore-node.js deleted file mode 100755 index a99704ed..00000000 --- a/cli/bitcore-node.js +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -var semver = require('semver'); -var Liftoff = require('liftoff'); -var cliPackage = require('../package.json'); - -var liftoff = new Liftoff({ - name: 'bitcore-node', - moduleName: 'bitcore-node', - configName: 'bitcore-node', - processTitle: 'bitcore-node' -}).on('require', function (name, module) { - console.log('Loading:', name); -}).on('requireFail', function (name, err) { - console.log('Unable to load:', name, err); -}).on('respawn', function (flags, child) { - console.log('Detected node flags:', flags); - console.log('Respawned to PID:', child.pid); -}); - -liftoff.launch({ - cwd: process.cwd() -}, function(env){ - - var bitcorenode; - if (env.modulePackage && env.configPath) { - // use the local version - if (semver.gt(cliPackage.version, env.modulePackage.version)) { - throw new Error( - 'Version mismatch, global bitcore-node is ' + cliPackage.version + - ' and local bitcore-node is ' + env.modulePackage.version - ); - } - bitcorenode = require(env.modulePath); - } else { - // use the global version - bitcorenode = require('..'); - } - - bitcorenode.cli.main(); - -}); diff --git a/docs/index.md b/docs/index.md index 2a5363d6..7d87ebbe 100644 --- a/docs/index.md +++ b/docs/index.md @@ -26,8 +26,8 @@ Bitcore includes a Command Line Interface (CLI) for managing, configuring and in ```bash bitcore create -d mynode cd mynode -bitcore add -bitcore add https://github.com/yourname/helloworld +bitcore install +bitcore install https://github.com/yourname/helloworld ``` This will create a directory with configuration files for your node and install the necessary dependencies. For more information about (and developing) services, please see the [Service Documentation](services.md). diff --git a/docs/scaffold.md b/docs/scaffold.md index e38c0b3a..d44b74e0 100644 --- a/docs/scaffold.md +++ b/docs/scaffold.md @@ -6,11 +6,7 @@ description: Description of functions for Bitcore Node configuration A collection of functions for creating, managing, starting, stopping and interacting with a Bitcore Node. -## Create - -This function will create a new directory and the initial configuration files/directories, including 'bitcore-node.json', 'package.json', 'bitcoin.conf', install the necessary Node.js modules, and create a data directory. - -## Add +## Install This function will add a service to a node by installing the necessary dependencies and modifying the `bitcore-node.json` configuration. @@ -26,7 +22,7 @@ This function will recursively find a configuration `bitcore-node.json` file in This function will return a default configuration with the default services based on environment variables, and will default to using the standard `~/.bitcoin` data directory. -## Remove +## Uninstall This function will remove a service from a node by uninstalling the necessary dependencies and modifying the `bitcore-node.json` configuration. diff --git a/index.js b/index.js index cda89377..da3b0539 100644 --- a/index.js +++ b/index.js @@ -22,4 +22,7 @@ module.exports.scaffold.findConfig = require('./lib/scaffold/find-config'); module.exports.scaffold.defaultConfig = require('./lib/scaffold/default-config'); module.exports.cli = {}; -module.exports.cli.main = require('./cli/main'); +module.exports.cli.main = require('./lib/cli/main'); +module.exports.cli.daemon = require('./lib/cli/daemon'); +module.exports.cli.bitcore = require('./lib/cli/bitcore'); +module.exports.cli.bitcored = require('./lib/cli/bitcored'); diff --git a/lib/cli/bitcore.js b/lib/cli/bitcore.js new file mode 100644 index 00000000..df3ea894 --- /dev/null +++ b/lib/cli/bitcore.js @@ -0,0 +1,40 @@ +'use strict'; + +var Liftoff = require('liftoff'); + +function main() { + + var liftoff = new Liftoff({ + name: 'bitcore', + moduleName: 'bitcore-node', + configName: 'bitcore-node', + processTitle: 'bitcore' + }).on('require', function (name, module) { + console.log('Loading:', name); + }).on('requireFail', function (name, err) { + console.log('Unable to load:', name, err); + }).on('respawn', function (flags, child) { + console.log('Detected node flags:', flags); + console.log('Respawned to PID:', child.pid); + }); + + liftoff.launch({ + cwd: process.cwd() + }, function(env){ + + var node; + if (env.modulePackage && env.configPath) { + // use the configured version + node = require(env.modulePath); + } else { + // use this version + node = require('..'); + } + + node.cli.main(); + + }); + +} + +module.exports = main; diff --git a/lib/cli/bitcored.js b/lib/cli/bitcored.js new file mode 100644 index 00000000..277e4f0a --- /dev/null +++ b/lib/cli/bitcored.js @@ -0,0 +1,40 @@ +'use strict'; + +var Liftoff = require('liftoff'); + +function main() { + + var liftoff = new Liftoff({ + name: 'bitcored', + moduleName: 'bitcore-node', + configName: 'bitcore-node', + processTitle: 'bitcored' + }).on('require', function (name, module) { + console.log('Loading:', name); + }).on('requireFail', function (name, err) { + console.log('Unable to load:', name, err); + }).on('respawn', function (flags, child) { + console.log('Detected node flags:', flags); + console.log('Respawned to PID:', child.pid); + }); + + liftoff.launch({ + cwd: process.cwd() + }, function(env){ + + var node; + if (env.modulePackage && env.configPath) { + // use the configured version + node = require(env.modulePath); + } else { + // use this version + node = require('..'); + } + + node.cli.daemon(); + + }); + +} + +module.exports = main; diff --git a/lib/cli/daemon.js b/lib/cli/daemon.js new file mode 100644 index 00000000..cd12c547 --- /dev/null +++ b/lib/cli/daemon.js @@ -0,0 +1,36 @@ +'use strict'; + +var program = require('commander'); +var path = require('path'); +var bitcore = require('..'); + +function main() { + /* jshint maxstatements: 100 */ + + var version = bitcore.version; + var start = bitcore.scaffold.start; + var findConfig = bitcore.scaffold.findConfig; + var defaultConfig = bitcore.scaffold.defaultConfig; + + program + .version(version) + .description('Start the current node') + .option('-c, --config ', 'Specify the directory with Bitcore Node configuration') + .option('-d, --daemon', 'Make bitcore a daemon (running in the background)'); + + program.parse(process.argv); + + if (program.config) { + program.config = path.resolve(process.cwd(), program.config); + } + var configInfo = findConfig(program.config || process.cwd()); + if (!configInfo) { + configInfo = defaultConfig(); + } + if(program.daemon) { + configInfo.config.daemon = true; + } + start(configInfo); +} + +module.exports = main; diff --git a/cli/main.js b/lib/cli/main.js similarity index 93% rename from cli/main.js rename to lib/cli/main.js index 8eb36763..66be97d4 100644 --- a/cli/main.js +++ b/lib/cli/main.js @@ -20,17 +20,18 @@ function main() { .version(version); program - .command('create [name]') + .command('create ') .description('Create a new node') .option('-d, --datadir ', 'Specify the bitcoin database directory') - .action(function(dirname, name, cmd){ + .action(function(dirname, cmd){ + console.log('dirname', dirname); + console.log('cmd', cmd); if (cmd.datadir) { cmd.datadir = path.resolve(process.cwd(), cmd.datadir); } var opts = { cwd: process.cwd(), dirname: dirname, - name: name, datadir: cmd.datadir || './data', isGlobal: false }; @@ -62,8 +63,8 @@ function main() { }); program - .command('add ') - .alias('install') + .command('install ') + .alias('add') .description('Install a service for the current node') .action(function(services){ var configInfo = findConfig(process.cwd()); @@ -89,8 +90,8 @@ function main() { }); program - .command('remove ') - .alias('uninstall') + .command('uninstall ') + .alias('remove') .description('Uninstall a service for the current node') .action(function(services){ var configInfo = findConfig(process.cwd()); diff --git a/lib/scaffold/create.js b/lib/scaffold/create.js index 35f41a41..12491b92 100644 --- a/lib/scaffold/create.js +++ b/lib/scaffold/create.js @@ -1,7 +1,7 @@ 'use strict'; var spawn = require('child_process').spawn; -var bitcore = require('bitcore-lib'); +var bitcore = require('bitcore'); var async = require('async'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; @@ -20,7 +20,7 @@ if (packageFile.version.match('-dev')) { var BASE_PACKAGE = { dependencies: { - 'bitcore-lib': '^' + bitcore.version, + 'bitcore': '^' + bitcore.version, 'bitcore-node': version } }; diff --git a/package.json b/package.json index 427891c8..0fe2f081 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "version": "0.2.0-dev", "lastBuild": "0.2.0-beta.11", "main": "./index.js", - "bin": "./cli/bitcore-node.js", "repository": "git://github.com/bitpay/bitcore-node.git", "homepage": "https://github.com/bitpay/bitcore-node.js", "bugs": { @@ -28,6 +27,9 @@ "email": "patrick@bitpay.com" } ], + "bin": { + "bitcore-node": "./bin/bitcore-node" + }, "scripts": { "install": "./bin/install", "build": "./bin/build", @@ -54,7 +56,6 @@ "express": "^4.13.3", "leveldown": "^1.4.1", "levelup": "^1.2.1", - "liftoff": "^2.1.0", "memdown": "^1.0.0", "mkdirp": "0.5.0", "nan": "^2.0.9", From 95b5bfbfcb18c144c3452ec10d0266e172c3b566 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Sun, 18 Oct 2015 16:28:24 -0400 Subject: [PATCH 3/5] Fix library reference. --- lib/scaffold/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scaffold/create.js b/lib/scaffold/create.js index 12491b92..64bb07ee 100644 --- a/lib/scaffold/create.js +++ b/lib/scaffold/create.js @@ -1,7 +1,7 @@ 'use strict'; var spawn = require('child_process').spawn; -var bitcore = require('bitcore'); +var bitcore = require('bitcore-lib'); var async = require('async'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; From d05d617f1265512bfc0c1b7e1ee2212cc71a0d59 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Sun, 18 Oct 2015 16:31:33 -0400 Subject: [PATCH 4/5] Add liftoff to package.json. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0fe2f081..8f7de0bd 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "express": "^4.13.3", "leveldown": "^1.4.1", "levelup": "^1.2.1", + "liftoff": "^2.2.0", "memdown": "^1.0.0", "mkdirp": "0.5.0", "nan": "^2.0.9", From 57b832021ffd506275101b68ae25e82492cd9d58 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Sun, 18 Oct 2015 17:54:14 -0400 Subject: [PATCH 5/5] Reference the bin included with standalone bitcore-node. --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2478c459..3d1b9134 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ A Bitcoin full node for building applications and services with Node.js. A node ## Install ```bash -npm install -g bitcore -bitcore start +npm install -g bitcore-node +bitcore-node start ``` Note: For your convenience, we distribute binaries for x86_64 Linux and x86_64 Mac OS X. Upon npm install, the binaries for your platform will be downloaded. For more detailed installation instructions, or if you want to compile the project yourself, then please see the [Build & Install](docs/build.md) documentation to build the project from source. @@ -24,18 +24,18 @@ Note: For your convenience, we distribute binaries for x86_64 Linux and x86_64 M Bitcore includes a Command Line Interface (CLI) for managing, configuring and interfacing with your Bitcore Node. ```bash -bitcore create -d mynode +bitcore-node create -d mynode cd mynode -bitcore add -bitcore add https://github.com/yourname/helloworld +bitcore-node add +bitcore-node add https://github.com/yourname/helloworld ``` This will create a directory with configuration files for your node and install the necessary dependencies. For more information about (and developing) services, please see the [Service Documentation](docs/services.md). -To start bitcore as a daemon: +To start bitcore-node as a daemon: ```bash -bitcore start --daemon +bitcore-node start --daemon ``` ## Add-on Services