remove grunt; use grunt plugin

This commit is contained in:
Iuri Matias 2015-07-14 19:43:21 -04:00
parent b5f7d32d65
commit 9579ea3b91
10 changed files with 93 additions and 205 deletions

View File

@ -15,7 +15,7 @@ var run = function(cmd) {
} }
program program
.version('0.5.0') .version('0.6.0')
program.command('new [name]').description('New application').action(function(name) { program.command('new [name]').description('New application').action(function(name) {
if (name === undefined) { if (name === undefined) {

View File

@ -1,54 +1,102 @@
module.exports = (grunt) -> module.exports = (grunt) ->
grunt.loadNpmTasks "embark-framework" grunt.loadNpmTasks "grunt-embark"
grunt.initConfig( grunt.initConfig(
@initEmbarkConfig( files:
files: web3:
js: "node_modules/embark-framework/js/web3.js"
src: [
"app/js/**/*.js"
]
css: js:
src: [ src: [
"app/css/**/*.css" "app/js/**/*.js"
] ]
html: css:
src: [ src: [
"app/html/**/*.html" "app/css/**/*.css"
] ]
contracts: html:
src: [ src: [
"app/contracts/**/*.sol" "app/html/**/*.html"
] ]
concat: coffee:
app: dest: "generated/dapp/compiled-coffee"
src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"] compiled: [
dest: "generated/dapp/js/app.min.js" "generated/dapp/compiled-coffee/app.coffee"
css: "generated/dapp/compiled-coffee/**/*.js"
src: "<%= files.css.src %>" ]
dest: "generated/dapp/css/app.min.css"
copy: contracts:
html: src: [
files: "app/contracts/**/*.sol"
"generated/dapp/index.html" : "<%= files.html.src %>" ]
"dist/dapp/index.html" : "<%= files.html.src %>"
css:
files:
"dist/dapp/css/app.min.css" : "<%= files.css.src %>"
contracts:
files:
"dist/contracts/": '<%= files.contracts.src %>'
deploy: coffee:
contracts: '<%= files.contracts.src %>' compile:
dest: 'generated/tmp/abi.js' expand: true
) cwd: 'coffee'
src: '**/*.coffee'
dest: '<%= files.coffee.dest %>'
ext: '.js'
concat:
app:
src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"]
dest: "generated/dapp/js/app.min.js"
css:
src: "<%= files.css.src %>"
dest: "generated/dapp/css/app.min.css"
watch:
options:
livereload: true
html:
files: ["<%= files.html.src %>"]
tasks: ["copy"]
js:
files: ["<%= files.js.src %>"]
tasks: ["concat"]
css:
files: ["<%= concat.css.src %>"]
tasks: ["concat"]
coffee:
files: ["coffee/**/*.coffee"]
tasks: ["coffee", "concat"]
contracts:
files: ["<%= files.contracts.src %>"]
tasks: ["deploy", "concat", "copy"]
copy:
html:
files:
"generated/dapp/index.html" : "<%= files.html.src %>"
"dist/dapp/index.html" : "<%= files.html.src %>"
css:
files:
"dist/dapp/css/app.min.css" : "<%= files.css.src %>"
contracts:
files:
"dist/contracts/": '<%= files.contracts.src %>'
uglify:
dist:
src: "<%= concat.app.dest %>" # input from the concat process
dest: "dist/dapp/js/app.min.js"
clean:
workspaces: ["dist", "generated"]
deploy:
contracts: '<%= files.contracts.src %>'
dest: 'generated/tmp/abi.js'
) )
# loading external tasks (aka: plugins) # loading external tasks (aka: plugins)

View File

@ -10,7 +10,8 @@
"license": "ISC", "license": "ISC",
"homepage": "", "homepage": "",
"devDependencies": { "devDependencies": {
"embark-framework": "iurimatias/embark-framework#develop", "embark-framework": "/Users/iurimatias/Projects/embark-framework",
"grunt-embark": "/Users/iurimatias/Projects/grunt-embark",
"grunt-contrib-clean": "^0.6.0", "grunt-contrib-clean": "^0.6.0",
"grunt-contrib-coffee": "^0.13.0", "grunt-contrib-coffee": "^0.13.0",
"grunt-contrib-concat": "^0.5.1", "grunt-contrib-concat": "^0.5.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "embark-framework", "name": "embark-framework",
"version": "0.5.0", "version": "0.6.0",
"description": "", "description": "",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"

View File

@ -1,102 +0,0 @@
module.exports = (grunt) ->
@embarkConfig =
files:
web3:
"node_modules/embark-framework/js/web3.js"
js:
src: [
"app/js/**/*.js"
]
css:
src: [
"app/css/**/*.css"
]
html:
src: [
"app/html/**/*.html"
]
coffee:
dest: "generated/dapp/compiled-coffee"
compiled: [
"generated/dapp/compiled-coffee/app.coffee"
"generated/dapp/compiled-coffee/**/*.js"
]
contracts:
src: [
"app/contracts/**/*.sol"
]
coffee:
compile:
expand: true
cwd: 'coffee'
src: '**/*.coffee'
dest: '<%= files.coffee.dest %>'
ext: '.js'
concat:
app:
src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"]
dest: "generated/dapp/js/app.min.js"
css:
src: "<%= files.css.src %>"
dest: "generated/dapp/css/app.min.css"
watch:
options:
livereload: true
html:
files: ["<%= files.html.src %>"]
tasks: ["copy"]
js:
files: ["<%= files.js.src %>"]
tasks: ["concat"]
css:
files: ["<%= concat.css.src %>"]
tasks: ["concat"]
coffee:
files: ["coffee/**/*.coffee"]
tasks: ["coffee", "concat"]
contracts:
files: ["<%= files.contracts.src %>"]
tasks: ["deploy", "concat", "copy"]
copy:
html:
files:
"generated/dapp/index.html" : "<%= files.html.src %>"
"dist/dapp/index.html" : "<%= files.html.src %>"
css:
files:
"dist/dapp/css/app.min.css" : "<%= files.css.src %>"
contracts:
files:
"dist/contracts/": '<%= files.contracts.src %>'
uglify:
dist:
src: "<%= concat.app.dest %>" # input from the concat process
dest: "dist/dapp/js/app.min.js"
clean:
workspaces: ["dist", "generated"]
deploy:
contracts: '<%= files.contracts.src %>'
dest: 'generated/tmp/abi.js'
@initEmbarkConfig = (userConfig) =>
hashmerge = require('hashmerge')
hashmerge(@embarkConfig, userConfig)

View File

@ -1,9 +0,0 @@
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)

View File

@ -1,17 +0,0 @@
module.exports = (grunt) ->
web3 = require('web3')
readYaml = require('read-yaml');
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')
#abi = Embark.deployContracts(env, contractFiles, destFile)
abi = Embark.deployContracts(env, contractFiles, destFile)
grunt.file.write(destFile, abi);

View File

@ -1,7 +0,0 @@
module.exports = (grunt) ->
grunt.registerTask "ipfs", "distribute into ipfs", (env_) =>
env = env_ || "development"
Embark = require('embark-framework')
Embark.release.ipfs("dist/dapp/")

View File

@ -1,21 +0,0 @@
module.exports = (grunt) ->
express = require("express")
compression = require("compression")
readYaml = require('read-yaml')
grunt.registerTask "server", "static file development server", =>
serverConfig = readYaml.sync("config/server.yml")
webPort = serverConfig.port || 8000
webHost = serverConfig.host || 'localhost'
webRoot = "generated/dapp"
app = express()
app.use(compression())
app.use(express.static("" + (process.cwd()) + "/" + webRoot))
app.listen(webPort, webHost)
grunt.log.writeln("Running web server on port http://#{webHost}:#{webPort}")
return app

View File

@ -1,5 +0,0 @@
module.exports = (grunt) ->
grunt.registerTask "deploy", ["coffee", "deploy_contracts", "concat", "copy", "server", "watch"]
grunt.registerTask "build", ["clean", "deploy_contracts", "coffee", "concat", "uglify", "copy"]