From 4c82f309e00f5530a389f5b0e2f6a2d7f4d90b31 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 29 Mar 2018 19:42:47 -0400 Subject: [PATCH] add --simple option --- lib/cmd.js | 16 ++++++++++---- templates/simple/.gitignore | 5 +++++ templates/simple/chains.json | 1 + templates/simple/contracts.json | 20 ++++++++++++++++++ templates/simple/contracts/.gitkeep | 0 templates/simple/embark.json | 7 +++++++ templates/simple/package.json | 13 ++++++++++++ templates/simple/test/contract_spec.js | 29 ++++++++++++++++++++++++++ 8 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 templates/simple/.gitignore create mode 100644 templates/simple/chains.json create mode 100644 templates/simple/contracts.json create mode 100644 templates/simple/contracts/.gitkeep create mode 100644 templates/simple/embark.json create mode 100644 templates/simple/package.json create mode 100644 templates/simple/test/contract_spec.js diff --git a/lib/cmd.js b/lib/cmd.js index 8f350b72f..bdd64ac85 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -43,7 +43,8 @@ class Cmd { program .command('new [name]') .description('new application') - .action(function (name) { + .option('--simple', 'create a barebones project meant only for contract development') + .action(function (name, options) { if (name === undefined) { return promptly.prompt("Name your app (default is embarkDApp):", { default: "embarkDApp", @@ -56,13 +57,20 @@ class Cmd { err.retry(); } else { //slightly different assignment of name since it comes from child prompt - embark.generateTemplate('boilerplate', './', inputvalue); + if (options.simple) { + embark.generateTemplate('simple', './', inputvalue); + } else { + embark.generateTemplate('boilerplate', './', inputvalue); + } } }); } else { - embark.generateTemplate('boilerplate', './', name); + if (options.simple) { + embark.generateTemplate('simple', './', name); + } else { + embark.generateTemplate('boilerplate', './', name); + } } - }); } diff --git a/templates/simple/.gitignore b/templates/simple/.gitignore new file mode 100644 index 000000000..77bcafb1a --- /dev/null +++ b/templates/simple/.gitignore @@ -0,0 +1,5 @@ +.embark/ +node_modules/ +dist/ +config/production/password +config/livenet/password diff --git a/templates/simple/chains.json b/templates/simple/chains.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/templates/simple/chains.json @@ -0,0 +1 @@ +{} diff --git a/templates/simple/contracts.json b/templates/simple/contracts.json new file mode 100644 index 000000000..41db174dd --- /dev/null +++ b/templates/simple/contracts.json @@ -0,0 +1,20 @@ +{ + "default": { + "versions": { + "web3.js": "1.0.0-beta", + "solc": "0.4.17" + }, + "deployment": { + "host": "localhost", + "port": 8545, + "type": "rpc" + }, + "dappConnection": [ + "$WEB3", + "http://localhost:8545" + ], + "gas": "auto", + "contracts": { + } + } +} diff --git a/templates/simple/contracts/.gitkeep b/templates/simple/contracts/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/templates/simple/embark.json b/templates/simple/embark.json new file mode 100644 index 000000000..1bf27d8f8 --- /dev/null +++ b/templates/simple/embark.json @@ -0,0 +1,7 @@ +{ + "contracts": ["contracts/**"], + "app": {}, + "buildDir": "build/", + "config": "./", + "plugins": {} +} diff --git a/templates/simple/package.json b/templates/simple/package.json new file mode 100644 index 000000000..46a574886 --- /dev/null +++ b/templates/simple/package.json @@ -0,0 +1,13 @@ +{ + "name": "%APP_NAME%", + "version": "0.0.1", + "description": "", + "scripts": { + "test": "embark test" + }, + "author": "", + "license": "ISC", + "homepage": "", + "devDependencies": { + } +} diff --git a/templates/simple/test/contract_spec.js b/templates/simple/test/contract_spec.js new file mode 100644 index 000000000..8c5ed27f9 --- /dev/null +++ b/templates/simple/test/contract_spec.js @@ -0,0 +1,29 @@ +//describe("SimpleStorage", function() { +// this.timeout(0); +// before(function(done) { +// this.timeout(0); +// var contractsConfig = { +// "SimpleStorage": { +// args: [100] +// } +// }; +// EmbarkSpec.deployAll(contractsConfig, () => { done() }); +// }); +// +// it("should set constructor value", function(done) { +// SimpleStorage.methods.storedData().call().then(function(result) { +// assert.equal(result, 100); +// done(); +// }); +// }); +// +// it("set storage value", function(done) { +// SimpleStorage.methods.set(150).send().then(function() { +// SimpleStorage.methods.get().call().then(function(result) { +// assert.equal(result, 150); +// done(); +// }); +// }); +// }); +// +//});