add support for main config file

This commit is contained in:
Iuri Matias 2015-07-07 06:51:03 -04:00
parent 4492db4603
commit ce681de06b
5 changed files with 27 additions and 6 deletions

View File

@ -5,6 +5,7 @@ var path = require('path');
var wrench = require('wrench');
var grunt = require('grunt');
require('shelljs/global');
var readYaml = require('read-yaml');
var run = function(cmd) {
if (exec(cmd).code != 0) {
@ -29,6 +30,20 @@ program.command('new [name]').description('New application').action(function(nam
console.log('\n\ninit complete');
});
program.command('meteor [env]').description('experimental meteor cmd').action(function(env_) {
var env = env_ || 'development';
var embarkConfig = readYaml.sync("./embark.yml");
contractFiles = grunt.file.expand(embarkConfig.contracts);
destFile = embarkConfig.output
Embark = require('embark-framework')
Embark.init()
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig)
abi = Embark.deployContracts(env, contractFiles, destFile)
grunt.file.write(destFile, abi);
});
program.command('deploy [env]').description('deploy contracts').action(function(env_) {
var env = env_ || 'development';
run("grunt deploy_contracts:" + env);

5
boilerplate/embark.yml Normal file
View File

@ -0,0 +1,5 @@
type: "grunt"
contracts: ["app/contracts/**"]
output: "generated/tmp/abi.js"
blockchainConfig: "config/blockchain.yml"
contractsConfig: "config/contracts.yml"

View File

@ -85,9 +85,9 @@ Deploy.prototype.generate_abi_file = function() {
var abi = JSON.stringify(contract.compiled.info.abiDefinition);
var contractAddress = deployedContract;
result += "var " + className + "Abi = " + abi + ";";
result += "var " + className + "Contract = web3.eth.contract(" + className + "Abi);";
result += "var " + className + " = " + className + "Contract.at('" + contractAddress + "');";
result += className + "Abi = " + abi + ";";
result += className + "Contract = web3.eth.contract(" + className + "Abi);";
result += className + " = " + className + "Contract.at('" + contractAddress + "');";
}
return result;

View File

@ -35,11 +35,11 @@ Embark = {
chain.startChain();
},
deployContracts: function(env, contractFiles) {
this.contractsConfig.init(env, contractFiles);
deployContracts: function(env, contractFiles, destFile) {
this.contractsConfig.init(contractFiles);
var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig);
deploy.deploy_contracts(env);
return deploy.generate_abi_file();
return deploy.generate_abi_file(destFile);
},
release: Release

View File

@ -11,6 +11,7 @@ module.exports = (grunt) ->
Embark.init()
Embark.blockchainConfig.loadConfigFile('config/blockchain.yml')
Embark.contractsConfig.loadConfigFile('config/contracts.yml')
#abi = Embark.deployContracts(env, contractFiles, destFile)
abi = Embark.deployContracts(env, contractFiles, destFile)
grunt.file.write(destFile, abi);