diff --git a/bin/embark b/bin/embark index 0eb7c3a3d..5b0273217 100644 --- a/bin/embark +++ b/bin/embark @@ -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); diff --git a/boilerplate/embark.yml b/boilerplate/embark.yml new file mode 100644 index 000000000..1b5b0178c --- /dev/null +++ b/boilerplate/embark.yml @@ -0,0 +1,5 @@ +type: "grunt" +contracts: ["app/contracts/**"] +output: "generated/tmp/abi.js" +blockchainConfig: "config/blockchain.yml" +contractsConfig: "config/contracts.yml" diff --git a/lib/deploy.js b/lib/deploy.js index 777474de1..6f3eb62d8 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -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; diff --git a/lib/index.js b/lib/index.js index 2c13fd7b0..b168f00d0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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 diff --git a/tasks/deploy.coffee b/tasks/deploy.coffee index c032775e5..8b92e293f 100644 --- a/tasks/deploy.coffee +++ b/tasks/deploy.coffee @@ -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);