mirror of https://github.com/embarklabs/embark.git
move code generator to a module
This commit is contained in:
parent
b35d034692
commit
b48ec4c638
|
@ -158,23 +158,28 @@ class Engine {
|
|||
codeGeneratorService(_options) {
|
||||
let self = this;
|
||||
|
||||
const CodeGenerator = require('../contracts/code_generator.js');
|
||||
this.codeGenerator = new CodeGenerator({
|
||||
blockchainConfig: self.config.blockchainConfig,
|
||||
contractsConfig: self.config.contractsConfig,
|
||||
plugins: self.plugins,
|
||||
storageConfig: self.config.storageConfig,
|
||||
namesystemConfig: self.config.namesystemConfig,
|
||||
communicationConfig: self.config.communicationConfig,
|
||||
events: self.events,
|
||||
env: self.env
|
||||
});
|
||||
this.codeGenerator.listenToCommands();
|
||||
this.registerModule('code_generator', {plugins: self.plugins, env: self.env});
|
||||
//const CodeGenerator = require('../contracts/code_generator.js');
|
||||
//this.codeGenerator = new CodeGenerator({
|
||||
// blockchainConfig: self.config.blockchainConfig,
|
||||
// contractsConfig: self.config.contractsConfig,
|
||||
// plugins: self.plugins,
|
||||
// storageConfig: self.config.storageConfig,
|
||||
// namesystemConfig: self.config.namesystemConfig,
|
||||
// communicationConfig: self.config.communicationConfig,
|
||||
// events: self.events,
|
||||
// env: self.env
|
||||
//});
|
||||
//this.codeGenerator.listenToCommands();
|
||||
|
||||
const generateCode = function () {
|
||||
self.codeGenerator.buildEmbarkJS(function() {
|
||||
self.events.request("code-generator:embarkjs:build", () => {
|
||||
self.events.emit('code-generator-ready');
|
||||
});
|
||||
|
||||
//self.codeGenerator.buildEmbarkJS(function() {
|
||||
// self.events.emit('code-generator-ready');
|
||||
//});
|
||||
};
|
||||
const cargo = async.cargo((_tasks, callback) => {
|
||||
generateCode();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
let async = require('async');
|
||||
let fs = require('../core/fs.js');
|
||||
const utils = require('../utils/utils.js');
|
||||
let fs = require('../../core/fs.js');
|
||||
const utils = require('../../utils/utils.js');
|
||||
|
||||
require('ejs');
|
||||
const Templates = {
|
||||
|
@ -19,17 +19,24 @@ const Templates = {
|
|||
};
|
||||
|
||||
class CodeGenerator {
|
||||
constructor(options) {
|
||||
this.blockchainConfig = options.blockchainConfig || {};
|
||||
constructor(embark, options) {
|
||||
this.blockchainConfig = embark.config.blockchainConfig || {};
|
||||
this.rpcHost = this.blockchainConfig.rpcHost || '';
|
||||
this.rpcPort = this.blockchainConfig.rpcPort || '';
|
||||
this.contractsConfig = options.contractsConfig || {};
|
||||
this.storageConfig = options.storageConfig || {};
|
||||
this.communicationConfig = options.communicationConfig || {};
|
||||
this.namesystemConfig = options.namesystemConfig || {};
|
||||
this.contractsConfig = embark.config.contractsConfig || {};
|
||||
this.storageConfig = embark.config.storageConfig || {};
|
||||
this.communicationConfig = embark.config.communicationConfig || {};
|
||||
this.namesystemConfig = embark.config.namesystemConfig || {};
|
||||
this.env = options.env || 'development';
|
||||
this.plugins = options.plugins;
|
||||
this.events = options.events;
|
||||
this.events = embark.events;
|
||||
|
||||
this.listenToCommands();
|
||||
|
||||
const self = this;
|
||||
this.events.setCommandHandler("code-generator:embarkjs:build", (cb) => {
|
||||
self.buildEmbarkJS(cb);
|
||||
});
|
||||
}
|
||||
|
||||
listenToCommands() {
|
Loading…
Reference in New Issue