merge develop branch

This commit is contained in:
Todd Baur 2017-03-30 20:26:03 +09:00
commit 648b27920c
6 changed files with 82 additions and 48 deletions

29
Class Hierarchy.mmd Normal file
View File

@ -0,0 +1,29 @@
Mind Map generated by NB MindMap plugin
> __version__=`1.1`,showJumps=`true`
---
# Embark
## Config
## CLI
## Engine
> leftSide=`true`
### Plugins
#### DefaultLogger
#### DefaultPipeline
### Services
## DefaultLogger
## Utils
> leftSide=`true`
## DeployManager

View File

@ -9,9 +9,9 @@ What is Embark
Embark is a framework that allows you to easily develop and deploy Decentralized Applications (DApps).
A Decentralized Application is serverless html5 application that uses one or more decentralized technologies.
A Decentralized Application is a serverless html5 application that uses one or more decentralized technologies.
Embark currently integrates with EVM blockchains (Ethereum), Decentralized Storages (IPFS), and Decentralizaed communication platforms (Whisper and Orbit). Swarm is supported for deployment.
Embark currently integrates with EVM blockchains (Ethereum), Decentralized Storages (IPFS), and Decentralized communication platforms (Whisper and Orbit). Swarm is supported for deployment.
With Embark you can:
@ -19,12 +19,12 @@ With Embark you can:
* Automatically deploy contracts and make them available in your JS code. Embark watches for changes, and if you update a contract, Embark will automatically redeploy the contracts (if needed) and the dapp.
* Contracts are available in JS with Promises.
* Do Test Driven Development with Contracts using Javascript.
* Keep track of deployed contracts, deploy only when truly needed.
* Keep track of deployed contracts; deploy only when truly needed.
* Manage different chains (e.g testnet, private net, livenet)
* Easily manage complex systems of interdependent contracts.
**Decentralized Storage (IPFS)**
* Easily Store & Retrieve Data on the DApp through EmbarkJS. Includin uploading and retrieving files.
* Easily Store & Retrieve Data on the DApp through EmbarkJS. Including uploading and retrieving files.
* Deploy the full application to IPFS or Swarm.
@ -69,7 +69,7 @@ $ npm -g install ethereumjs-testrpc
See [Complete Installation Instructions](https://github.com/iurimatias/embark-framework/wiki/Installation).
**updating from embark 1**
**updating from Embark 1**
Embark's npm package has changed from ```embark-framework``` to ```embark```, this sometimes can create conflicts. To update first uninstall embark-framework 1 to avoid any conflicts. ```npm uninstall -g embark-framework``` then ```npm install -g embark```
@ -97,7 +97,7 @@ Alternatively, to use an ethereum rpc simulator simply run:
$ embark simulator
```
By default embark blockchain will mine a minimum amount of ether and will only mine when new transactions come in. This is quite usefull to keep a low CPU. The option can be configured at ```config/blockchain.json```. Note that running a real node requires at least 2GB of free ram, please take this into account if running it in a VM.
By default Embark blockchain will mine a minimum amount of ether and will only mine when new transactions come in. This is quite useful to keep a low CPU. The option can be configured at ```config/blockchain.json```. Note that running a real node requires at least 2GB of free ram, please take this into account if running it in a VM.
Then, in another command line:
@ -106,7 +106,7 @@ $ embark run
```
This will automatically deploy the contracts, update their JS bindings and deploy your DApp to a local server at http://localhost:8000
Note that if you update your code it will automatically be re-deployed, contracts included. There is no need to restart embark, refreshing the page on the browser will do.
Note that if you update your code, it will automatically be re-deployed, contracts included. There is no need to restart embark, refreshing the page on the browser will do.
Dashboard
=====
@ -115,20 +115,20 @@ Embark 2 comes with a terminal dashboard.
![Dashboard](http://i.imgur.com/s4OQZpu.jpg)
The dashboard will tell you the state of your contracts, the enviroment you are using, and what embark is doing at the moment.
The dashboard will tell you the state of your contracts, the environment you are using, and what Embark is doing at the moment.
**available services**
Available Services will display the services available to your dapp in green, if one of these is down then it will be displayed in red.
Available Services will display the services available to your dapp in green. If a service is down, then it will be displayed in red.
**logs and console**
There is a console at the bottom which can be used to interact with contracts or with embark itself. type ```help``` to see a list of available commands, more commands will be added with each version of Embark.
There is a console at the bottom which can be used to interact with contracts or with Embark itself. Type ```help``` to see a list of available commands. More commands will be added with each version of Embark.
Creating a new DApp
======
If you want to create a blank new app.
If you want to create a blank new app:
```Bash
$ embark new AppName
@ -154,7 +154,7 @@ DApp Structure
|___ #contracts tests
```
Solidity/Serpent files in the contracts directory will automatically be deployed with embark run. Changes in any files will automatically be reflected in app, changes to contracts will result in a redeployment and update of their JS Bindings
Solidity/Serpent files in the contracts directory will automatically be deployed with Embark run. Changes in any files will automatically be reflected in app, changes to contracts will result in a redeployment and update of their JS Bindings
Libraries and languages available
======
@ -278,7 +278,7 @@ You can now deploy many instances of the same contract. e.g
...
```
Contracts addresses can be defined, If an address is defined the contract wouldn't be deployed but its defined address will be used instead.
Contracts addresses can be defined. If an address is defined, Embark uses the defined address instead of deploying the contract.
```Json
@ -347,7 +347,7 @@ EmbarkJS - Storage
**initialization**
The current available storage is IPFS. it can be initialized as
The current available storage is IPFS. It can be initialized as
```Javascript
EmbarkJS.Storage.setProvider('ipfs',{server: 'localhost', port: '5001'})
@ -432,13 +432,15 @@ Tests
You can run specs with ```embark test```, it will run any test files under ```test/```.
Embark includes a testing lib to fastly run & test your contracts in a EVM.
Embark includes a testing lib to rapidly run & test your contracts in a EVM.
```Javascript
# test/simple_storage_spec.js
var assert = require('assert');
var EmbarkSpec = require('embark/lib/core/test.js');
var Embark = require('embark');
var EmbarkSpec = Embark.initTests();
var web3 = EmbarkSpec.web3;
describe("SimpleStorage", function() {
before(function(done) {
@ -531,20 +533,20 @@ To deploy a dapp to SWARM, all you need to do is run a local SWARM node and then
Plugins
======
It's possible to extend Embarks functionality with plugins. For example the following is possible:
It's possible to extend Embark's functionality with plugins. For example, the following is possible:
* plugin to add support for es6, jsx, coffescript, etc (``embark.registerPipeline``)
* plugin to add standard contracts or a contract framework (``embark.registerContractConfiguration`` and ``embark.addContractFile``)
* plugin to make some contracts available in all environments for use by other contracts or the dapp itself e.g a Token, a DAO, ENS, etc.. (``embark.registerContractConfiguration`` and ``embark.addContractFile``)
* plugin to add a libraries such as react or boostrap (``embark.addFileToPipeline``)
* plugin to add a libraries such as react or bootstrap (``embark.addFileToPipeline``)
* plugin to specify a particular web3 initialization for special provider uses (``embark.registerClientWeb3Provider``)
* plugin to create a different contract wrapper (``embark.registerContractsGeneration``)
* plugin to add new console commands (``embark.registerConsoleCommand``)
* plugin to add support for another contract language such as viper, LLL, etc (``embark.registerCompiler``)
For more information on how to develop your own plugin please see the [plugin documentation](http://embark.readthedocs.io/en/latest/plugins.html)
For more information on how to develop your own plugin, please see the [plugin documentation](http://embark.readthedocs.io/en/latest/plugins.html)
Donations
======
If you like Embark please consider donating to 0x8811FdF0F988f0CD1B7E9DE252ABfA5b18c1cDb1
If you like Embark, please consider donating to 0x8811FdF0F988f0CD1B7E9DE252ABfA5b18c1cDb1

View File

@ -47,18 +47,18 @@ class Blockchain {
return shelljs.exec(cmd);
}
run() {
let self = this;
console.log("===============================================================================".magenta);
console.log("===============================================================================".magenta);
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
console.log("===============================================================================".magenta);
console.log("===============================================================================".magenta);
let address = this.initChainAndGetAddress();
this.client.mainCommand(address, function (cmd) {
self.runCommand(cmd);
});
}
run () {
var self = this;
console.log("===============================================================================".magenta);
console.log("===============================================================================".magenta);
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
console.log("===============================================================================".magenta);
console.log("===============================================================================".magenta);
let address = this.initChainAndGetAddress();
this.client.mainCommand(address, function(cmd) {
shelljs.exec(cmd, {async : true});
});
};
initChainAndGetAddress() {
let address = null, result;
@ -90,5 +90,5 @@ class Blockchain {
}
}
module.exports = Blockchain;
module.exports = BlockchainClient;

View File

@ -12,7 +12,7 @@ class Simulator {
cmds.push("-h " + (this.blockchainConfig.rpcHost || options.host || 'localhost'));
cmds.push("-a " + (options.num || 10));
shelljs.exec('testrpc ' + cmds.join(' '));
shelljs.exec('testrpc ' + cmds.join(' '), {async : true});
}
}

View File

@ -9,20 +9,21 @@ class TemplateGenerator {
generate(destinationFolder, name) {
let templatePath = fs.embarkPath(this.templateName);
console.log('Initializing Embark Template....'.green);
let fspath = utils.joinPath(destinationFolder, name);
fs.copySync(templatePath, destinationFolder + name);
utils.cd(destinationFolder + name);
fs.copySync(templatePath, fspath);
utils.cd(fspath);
utils.sed('package.json', '%APP_NAME%', name);
console.log('Installing packages.. this can take a few seconds'.green);
utils.runCmd('npm install');
console.log('Init complete'.green);
console.log('\nApp ready at '.green + destinationFolder + name);
console.log('\nApp ready at '.green + fspath);
if (name === 'embark_demo') {
console.log('-------------------'.yellow);
console.log('Next steps:'.green);
console.log(('-> ' + ('cd ' + destinationFolder + name).bold.cyan).green);
console.log(('-> ' + ('cd ' + fspath).bold.cyan).green);
console.log('-> '.green + 'embark blockchain'.bold.cyan + ' or '.green + 'embark simulator'.bold.cyan);
console.log('open another console in the same directory and run'.green);
console.log('-> '.green + 'embark run'.bold.cyan);

View File

@ -47,7 +47,7 @@ class Embark {
let Engine = require('./core/engine');
let engine = new Engine({
env: options.env,
embarkConfig: 'embark.json'
embarkConfig: options.embarkConfig || 'embark.json'
});
engine.init();
@ -112,17 +112,18 @@ class Embark {
port: options.serverPort
});
}
callback();
callback(err);
});
}
], function (err) {
], function (err, result) {
if (err) {
engine.logger.error(err.message);
engine.logger.info(err.stack);
} else {
engine.logger.setStatus("Ready".green);
engine.logger.info("Looking for documentation? you can find it at ".cyan + "http://embark.readthedocs.io/".green.underline);
engine.logger.info("Ready".underline);
Embark.emit('firstDeploymentDone');
engine.events.emit('firstDeploymentDone');
}
});
};
@ -144,6 +145,7 @@ class Embark {
engine.logger.info("loaded plugins: " + pluginList.join(", "));
}
engine.startService("web3");
engine.startService("pipeline");
engine.startService("abi");
engine.startService("deployment");
@ -151,24 +153,25 @@ class Embark {
},
function deploy(callback) {
engine.deployManager.deployContracts(function () {
callback();
callback(err);
});
}
], function (err) {
], function (err, result) {
if (err) {
engine.logger.error(err.message);
engine.logger.debug(err.stack);
} else {
engine.logger.info("finished building".underline);
}
// needed due to child processes
process.exit();
});
};
}
this.initTests = function (options) {
this.initTests = function () {
let Test = require('./core/test.js');
return new Test(options);
};
}
// TODO: should deploy if it hasn't already
this.upload = function (platform) {
@ -202,4 +205,3 @@ class Embark {
Embark.prototype = Object.create(EventEmitter.prototype);
module.exports = Embark;