mirror of https://github.com/embarklabs/embark.git
Addid basic templating to start building UI from here
This commit is contained in:
parent
8861588726
commit
94eca4751a
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
|
||||
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
|
||||
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -2,7 +2,7 @@ const fs = require('fs');
|
|||
|
||||
const commandName = "generate-ui";
|
||||
|
||||
const formatReplyMsg = (message) => commandName + ": " + message;
|
||||
const errorMessage = (message) => new Error(commandName + ": " + message);
|
||||
|
||||
class Scaffolding {
|
||||
constructor(embark, options){
|
||||
|
@ -12,15 +12,6 @@ class Scaffolding {
|
|||
this.frameworkPlugin = null;
|
||||
}
|
||||
|
||||
createDirectories(contractName){
|
||||
const dir = './app/' + contractName;
|
||||
if (!fs.existsSync(dir)){
|
||||
fs.mkdirSync(dir);
|
||||
} else {
|
||||
throw formatReplyMsg("directory ./app/" + contractName + " already exists");
|
||||
}
|
||||
}
|
||||
|
||||
isContract(contractName){
|
||||
return this.embark.config.contractsConfig.contracts[contractName] !== undefined;
|
||||
}
|
||||
|
@ -34,26 +25,25 @@ class Scaffolding {
|
|||
} else {
|
||||
let plugins = this.embark.plugins.getPluginsFor(this.framework);
|
||||
if(plugins.length !== 1){
|
||||
return formatReplyMsg("Could not find plugin for framework '" + this.framework + "'");
|
||||
throw errorMessage("Could not find plugin for framework '" + this.framework + "'");
|
||||
}
|
||||
frameworkPlugin = plugins[0].pluginModule;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if(!this.isContract(contractName)){
|
||||
return formatReplyMsg("contract '" + contractName + "' does not exist");
|
||||
return errorMessage("contract '" + contractName + "' does not exist");
|
||||
}
|
||||
|
||||
const contract = this.embark.config.contractsConfig.contracts[contractName];
|
||||
|
||||
this.createDirectories(contractName);
|
||||
try {
|
||||
let uiFramework = new frameworkPlugin(this.embark, this.options);
|
||||
uiFramework.build(contract);
|
||||
let result = uiFramework.build(contract);
|
||||
this.embark.logger.info(result);
|
||||
} catch(err){
|
||||
return err;
|
||||
throw errorMessage(err);
|
||||
}
|
||||
|
||||
return formatReplyMsg("done!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
"http-proxy": "1.17.0",
|
||||
"http-shutdown": "1.2.0",
|
||||
"i18n": "0.8.3",
|
||||
"handlebars": "^4.0.11",
|
||||
"ipfs-api": "17.2.4",
|
||||
"is-valid-domain": "0.0.5",
|
||||
"istanbul": "0.4.5",
|
||||
|
|
Loading…
Reference in New Issue