From 9115e5984af30bebdef006f5a146e0465ffdf5b2 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 29 May 2016 20:56:06 -0400 Subject: [PATCH] move grunt-embark back to the main repo --- boilerplate/Gruntfile.coffee | 3 ++- boilerplate/package.json | 3 +-- grunt-embark/Gruntfile.coffee | 7 +++++++ grunt-embark/LICENSE | 22 ++++++++++++++++++++ grunt-embark/README.md | 30 ++++++++++++++++++++++++++++ grunt-embark/tasks/blockchain.coffee | 9 +++++++++ grunt-embark/tasks/deploy.coffee | 24 ++++++++++++++++++++++ grunt-embark/tasks/ipfs.coffee | 7 +++++++ 8 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 grunt-embark/Gruntfile.coffee create mode 100644 grunt-embark/LICENSE create mode 100644 grunt-embark/README.md create mode 100644 grunt-embark/tasks/blockchain.coffee create mode 100644 grunt-embark/tasks/deploy.coffee create mode 100644 grunt-embark/tasks/ipfs.coffee diff --git a/boilerplate/Gruntfile.coffee b/boilerplate/Gruntfile.coffee index daf1de9c3..0a4277360 100644 --- a/boilerplate/Gruntfile.coffee +++ b/boilerplate/Gruntfile.coffee @@ -1,8 +1,8 @@ module.exports = (grunt) -> grunt.option 'stack', true - grunt.loadNpmTasks "grunt-embark" grunt.loadTasks "tasks" + grunt.loadTasks "node_modules/embark-framework/grunt-embark/tasks" grunt.initConfig( files: @@ -114,3 +114,4 @@ module.exports = (grunt) -> grunt.registerTask "deploy", ["coffee", "deploy_contracts:"+env, "concat", "copy", "server", "watch"] grunt.registerTask "build", ["clean", "deploy_contracts:"+env, "coffee", "concat", "uglify", "copy"] + diff --git a/boilerplate/package.json b/boilerplate/package.json index addeb6741..73b3011e0 100644 --- a/boilerplate/package.json +++ b/boilerplate/package.json @@ -10,8 +10,7 @@ "license": "ISC", "homepage": "", "devDependencies": { - "embark-framework": "^1.0.2", - "grunt-embark": "^0.5.1", + "embark-framework": "/Users/iurimatias/Projects/embark-framework", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-coffee": "^0.13.0", "grunt-contrib-concat": "^0.5.1", diff --git a/grunt-embark/Gruntfile.coffee b/grunt-embark/Gruntfile.coffee new file mode 100644 index 000000000..806ee90f4 --- /dev/null +++ b/grunt-embark/Gruntfile.coffee @@ -0,0 +1,7 @@ +module.exports = (grunt) -> + + grunt.initConfig + "grunt-embark": {} + + grunt.loadTasks "tasks" + diff --git a/grunt-embark/LICENSE b/grunt-embark/LICENSE new file mode 100644 index 000000000..2c82caa0d --- /dev/null +++ b/grunt-embark/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 embark-framework + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/grunt-embark/README.md b/grunt-embark/README.md new file mode 100644 index 000000000..5641f8ee5 --- /dev/null +++ b/grunt-embark/README.md @@ -0,0 +1,30 @@ +# grunt-embark +grunt plugin for [Embark](https://github.com/iurimatias/embark-framework) - DApp Framework for Ethereum + +## Getting Started +From the same directory as your project's Gruntfile and package.json, install +this plugin with the following command: + +```bash +$ npm install embark-framework --save-dev +$ npm install grunt-embark --save-dev +``` + +Once that's done, add this line to your project's Gruntfile: + +```js +grunt.loadNpmTasks('grunt-embark'); +``` + +## Config +Inside your `Gruntfile.js` file, add a section named `deploy`, containing +the fields `contracts` and `dest`. + +### Here's an example that deploys contracts and generates the js client file + +```js +deploy: { + contracts: ["app/contracts/**/*.sol"], + dest: "embark_client.js" +} +``` diff --git a/grunt-embark/tasks/blockchain.coffee b/grunt-embark/tasks/blockchain.coffee new file mode 100644 index 000000000..4cc574cca --- /dev/null +++ b/grunt-embark/tasks/blockchain.coffee @@ -0,0 +1,9 @@ +module.exports = (grunt) -> + + grunt.registerTask "blockchain", "deploy ethereum node", (env_) => + env = env_ || "development" + Embark = require('embark-framework') + Embark.init() + Embark.blockchainConfig.loadConfigFile('config/blockchain.yml') + Embark.startBlockchain(env) + diff --git a/grunt-embark/tasks/deploy.coffee b/grunt-embark/tasks/deploy.coffee new file mode 100644 index 000000000..7335c971c --- /dev/null +++ b/grunt-embark/tasks/deploy.coffee @@ -0,0 +1,24 @@ +module.exports = (grunt) -> + + grunt.registerTask "deploy_contracts", "deploy code", (env_) -> + env = env_ || "development" + contractFiles = grunt.file.expand(grunt.config.get("deploy.contracts")); + destFile = grunt.config.get("deploy.dest"); + + Embark = require('embark-framework') + Embark.init() + Embark.blockchainConfig.loadConfigFile('config/blockchain.yml') + Embark.contractsConfig.loadConfigFile('config/contracts.yml') + + chainFile = Embark.blockchainConfig.blockchainConfig[env].chains || './chains.json' + + deployed = false + + done = @async() + Embark.deployContracts env, contractFiles, destFile, chainFile, true, true, (abi) => + grunt.file.write(destFile, abi) + + unless deployed + deployed = true + done() + diff --git a/grunt-embark/tasks/ipfs.coffee b/grunt-embark/tasks/ipfs.coffee new file mode 100644 index 000000000..f2b4dc2d7 --- /dev/null +++ b/grunt-embark/tasks/ipfs.coffee @@ -0,0 +1,7 @@ +module.exports = (grunt) -> + + grunt.registerTask "ipfs", "distribute into ipfs", (env_) => + env = env_ || "development" + Embark = require('embark-framework') + Embark.release.ipfs("dist/dapp/") +