mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-10 14:06:10 +00:00
Installing react packages automatically
This commit is contained in:
parent
deb9c9a838
commit
e5e8d21765
@ -463,7 +463,6 @@ class EmbarkController {
|
||||
engine.startService("pipeline");
|
||||
engine.startService("deployment", {onlyCompile: true});
|
||||
engine.startService("web3");
|
||||
engine.startService("codeGenerator");
|
||||
|
||||
engine.events.request('deploy:contracts', callback);
|
||||
}
|
||||
@ -474,7 +473,6 @@ class EmbarkController {
|
||||
} else {
|
||||
let scaffold = new Scaffolding(engine, options);
|
||||
scaffold.generate(options.contract, options.overwrite);
|
||||
process.exit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -39,8 +39,10 @@ class Scaffolding {
|
||||
|
||||
const contract = contractsList.find(x => x.className === contractName);
|
||||
try {
|
||||
build(contract, overwrite);
|
||||
build(contract, overwrite, () => {
|
||||
this.engine.logger.info(__("finished generating the UI").underline);
|
||||
process.exit();
|
||||
});
|
||||
} catch(err){
|
||||
this.engine.logger.error(err.message);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
const Handlebars = require('handlebars');
|
||||
const fs = require('../../core/fs');
|
||||
let utils = require('../../utils/utils.js');
|
||||
|
||||
|
||||
Handlebars.registerHelper('capitalize', function(word) {
|
||||
return word.charAt(0).toUpperCase() + word.slice(1);
|
||||
@ -64,7 +66,14 @@ class ScaffoldingReact {
|
||||
fs.writeFileSync(filePath, result);
|
||||
}
|
||||
|
||||
build(contract, overwrite){
|
||||
build(contract, overwrite, cb){
|
||||
const packageInstallCmd = 'npm install react react-bootstrap react-dom';
|
||||
utils.runCmd(packageInstallCmd, null, (err) => {
|
||||
if (err) {
|
||||
this.embark.logger.error(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const filename = contract.className.toLowerCase();
|
||||
|
||||
this._generateFile(contract, 'index.html.tpl', 'html',
|
||||
@ -80,7 +89,6 @@ class ScaffoldingReact {
|
||||
'functions': contract.abiDefinition.filter(x => x.type === 'function')
|
||||
}, overwrite);
|
||||
|
||||
|
||||
// Update config
|
||||
const contents = fs.readFileSync("./embark.json");
|
||||
let embarkJson = JSON.parse(contents);
|
||||
@ -92,6 +100,8 @@ class ScaffoldingReact {
|
||||
this.embark.logger.info(filename + ".html generated");
|
||||
this.embark.logger.info(filename + ".js generated");
|
||||
|
||||
cb();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,14 +160,7 @@ class {{capitalize name}}Form{{@index}} extends Component {
|
||||
|
||||
{{/each}}
|
||||
|
||||
class {{contractName}}UI extends Component {
|
||||
constructor (props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
};
|
||||
}
|
||||
|
||||
render(){
|
||||
function {{contractName}}UI(props) {
|
||||
return (<div>
|
||||
<h1>{{title}}</h1>
|
||||
{{#each functions}}
|
||||
@ -175,7 +168,6 @@ class {{contractName}}UI extends Component {
|
||||
{{/each}}
|
||||
</div>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReactDOM.render(<{{contractName}}UI />, document.getElementById('app'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user