mirror of https://github.com/embarklabs/embark.git
add support for main config file
This commit is contained in:
parent
4492db4603
commit
ce681de06b
15
bin/embark
15
bin/embark
|
@ -5,6 +5,7 @@ var path = require('path');
|
||||||
var wrench = require('wrench');
|
var wrench = require('wrench');
|
||||||
var grunt = require('grunt');
|
var grunt = require('grunt');
|
||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
|
var readYaml = require('read-yaml');
|
||||||
|
|
||||||
var run = function(cmd) {
|
var run = function(cmd) {
|
||||||
if (exec(cmd).code != 0) {
|
if (exec(cmd).code != 0) {
|
||||||
|
@ -29,6 +30,20 @@ program.command('new [name]').description('New application').action(function(nam
|
||||||
console.log('\n\ninit complete');
|
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_) {
|
program.command('deploy [env]').description('deploy contracts').action(function(env_) {
|
||||||
var env = env_ || 'development';
|
var env = env_ || 'development';
|
||||||
run("grunt deploy_contracts:" + env);
|
run("grunt deploy_contracts:" + env);
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
type: "grunt"
|
||||||
|
contracts: ["app/contracts/**"]
|
||||||
|
output: "generated/tmp/abi.js"
|
||||||
|
blockchainConfig: "config/blockchain.yml"
|
||||||
|
contractsConfig: "config/contracts.yml"
|
|
@ -85,9 +85,9 @@ Deploy.prototype.generate_abi_file = function() {
|
||||||
|
|
||||||
var abi = JSON.stringify(contract.compiled.info.abiDefinition);
|
var abi = JSON.stringify(contract.compiled.info.abiDefinition);
|
||||||
var contractAddress = deployedContract;
|
var contractAddress = deployedContract;
|
||||||
result += "var " + className + "Abi = " + abi + ";";
|
result += className + "Abi = " + abi + ";";
|
||||||
result += "var " + className + "Contract = web3.eth.contract(" + className + "Abi);";
|
result += className + "Contract = web3.eth.contract(" + className + "Abi);";
|
||||||
result += "var " + className + " = " + className + "Contract.at('" + contractAddress + "');";
|
result += className + " = " + className + "Contract.at('" + contractAddress + "');";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -35,11 +35,11 @@ Embark = {
|
||||||
chain.startChain();
|
chain.startChain();
|
||||||
},
|
},
|
||||||
|
|
||||||
deployContracts: function(env, contractFiles) {
|
deployContracts: function(env, contractFiles, destFile) {
|
||||||
this.contractsConfig.init(env, contractFiles);
|
this.contractsConfig.init(contractFiles);
|
||||||
var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig);
|
var deploy = new Deploy(env, contractFiles, this.blockchainConfig.config(env), this.contractsConfig);
|
||||||
deploy.deploy_contracts(env);
|
deploy.deploy_contracts(env);
|
||||||
return deploy.generate_abi_file();
|
return deploy.generate_abi_file(destFile);
|
||||||
},
|
},
|
||||||
|
|
||||||
release: Release
|
release: Release
|
||||||
|
|
|
@ -11,6 +11,7 @@ module.exports = (grunt) ->
|
||||||
Embark.init()
|
Embark.init()
|
||||||
Embark.blockchainConfig.loadConfigFile('config/blockchain.yml')
|
Embark.blockchainConfig.loadConfigFile('config/blockchain.yml')
|
||||||
Embark.contractsConfig.loadConfigFile('config/contracts.yml')
|
Embark.contractsConfig.loadConfigFile('config/contracts.yml')
|
||||||
|
#abi = Embark.deployContracts(env, contractFiles, destFile)
|
||||||
abi = Embark.deployContracts(env, contractFiles, destFile)
|
abi = Embark.deployContracts(env, contractFiles, destFile)
|
||||||
grunt.file.write(destFile, abi);
|
grunt.file.write(destFile, abi);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue