embark-area-51/bin/embark

87 lines
2.4 KiB
Plaintext
Raw Normal View History

2015-05-24 13:03:43 +00:00
#!/usr/bin/env node
var program = require('commander');
var path = require('path');
var wrench = require('wrench');
var grunt = require('grunt');
require('shelljs/global');
2015-06-10 12:43:15 +00:00
var run = function(cmd) {
if (exec(cmd).code != 0) {
exit();
}
}
2015-05-24 13:03:43 +00:00
program
.version('0.5.0')
2015-05-24 13:03:43 +00:00
program.command('new [name]').description('New application').action(function(name) {
if (name === undefined) {
console.log("please specify the app name");
exit;
}
var prefPath = path.join(__dirname + '/../boilerplate');
var targetDir = "./" + name;
wrench.copyDirSyncRecursive(prefPath, targetDir);
cd(targetDir);
2015-06-10 12:43:15 +00:00
run('npm install');
2015-05-24 13:03:43 +00:00
console.log('\n\ninit complete');
});
program.command('deploy [env]').description('deploy contracts').action(function(env_) {
var env = env_ || 'development';
2015-06-10 12:43:15 +00:00
run("grunt deploy_contracts:" + env);
2015-05-24 13:03:43 +00:00
});
program.command('build [env]').description('build dapp').action(function(env_) {
var env = env_ || 'development';
2015-06-10 12:43:15 +00:00
run("grunt clean");
run("grunt deploy_contracts:" + env);
run('grunt build:' + env);
2015-05-24 13:03:43 +00:00
});
2015-06-10 12:37:14 +00:00
program.command('ipfs [env]').description('build dapp and make it available in ipfs').action(function(env_) {
2015-06-06 02:54:50 +00:00
var env = env_ || 'development';
2015-06-10 12:43:15 +00:00
run("grunt clean")
run("grunt deploy_contracts:" + env)
run('grunt build:' + env)
run('grunt ipfs:' + env)
2015-06-06 02:54:50 +00:00
});
2015-05-24 13:03:43 +00:00
program.command('run [env]').description('run dapp').action(function(env_) {
var env = env_ || 'development';
2015-06-10 12:43:15 +00:00
run('grunt deploy:' + env);
2015-05-24 13:03:43 +00:00
});
2015-06-20 12:35:49 +00:00
program.command('spec').description('run specs').action(function() {
run('jasmine');
});
2015-05-24 13:03:43 +00:00
program.command('blockchain [env]').description('run blockchain').action(function(env_) {
var env = env_ || 'development';
2015-06-10 12:43:15 +00:00
run('grunt blockchain:' + env);
2015-05-24 13:03:43 +00:00
});
2015-05-24 13:21:08 +00:00
program.command('demo').description('create a working dapp with a SimpleStorage contract').action(function() {
var boilerPath = path.join(__dirname + '/../boilerplate');
var demoPath = path.join(__dirname + '/../demo');
var targetDir = "./embark_demo";
wrench.copyDirSyncRecursive(boilerPath, targetDir);
2015-06-19 14:27:19 +00:00
wrench.copyDirSyncRecursive(demoPath + "/app", targetDir + "/app", {forceDelete: true});
wrench.copyDirSyncRecursive(demoPath + "/config", targetDir + "/config", {forceDelete: true});
wrench.copyDirSyncRecursive(demoPath + "/spec", targetDir + "/spec", {forceDelete: true});
2015-05-24 13:21:08 +00:00
cd(targetDir);
2015-06-10 12:43:15 +00:00
run('npm install');
2015-05-24 13:21:08 +00:00
console.log('\n\ninit complete');
});
2015-05-24 13:03:43 +00:00
program.parse(process.argv)
if (!process.argv.slice(2).length) {
program.outputHelp();
}