mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-03 02:43:25 +00:00
fix linter complaints
This commit is contained in:
parent
4ae5757bae
commit
e3b9c01205
18
lib/cmd.js
18
lib/cmd.js
@ -1,11 +1,11 @@
|
|||||||
var program = require('commander');
|
let program = require('commander');
|
||||||
var colors = require('colors');
|
let colors = require('colors');
|
||||||
var shelljs = require('shelljs');
|
let shelljs = require('shelljs');
|
||||||
var promptly = require('promptly');
|
let promptly = require('promptly');
|
||||||
var path = require('path');
|
let path = require('path');
|
||||||
var Embark = require('../lib/index');
|
let Embark = require('../lib/index');
|
||||||
|
|
||||||
var Cmd = function() {
|
let Cmd = function() {
|
||||||
program.version(Embark.version);
|
program.version(Embark.version);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ Cmd.prototype.process = function(args) {
|
|||||||
|
|
||||||
Cmd.prototype.newApp = function(name) {
|
Cmd.prototype.newApp = function(name) {
|
||||||
|
|
||||||
var validateName = function (value) {
|
let validateName = function (value) {
|
||||||
try {
|
try {
|
||||||
if(value.match(/^[a-zA-Z\s\-]+$/)) return value;
|
if(value.match(/^[a-zA-Z\s\-]+$/)) return value;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -44,7 +44,7 @@ Cmd.prototype.newApp = function(name) {
|
|||||||
.description('new application')
|
.description('new application')
|
||||||
.action(function (name) {
|
.action(function (name) {
|
||||||
if (name === undefined) {
|
if (name === undefined) {
|
||||||
var parentDirectory = path.dirname(__dirname).split("/").pop();
|
let parentDirectory = path.dirname(__dirname).split("/").pop();
|
||||||
return promptly.prompt("Name your app (default is " + parentDirectory + "):", {
|
return promptly.prompt("Name your app (default is " + parentDirectory + "):", {
|
||||||
default: parentDirectory,
|
default: parentDirectory,
|
||||||
validator: validateName
|
validator: validateName
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
var colors = require('colors');
|
let colors = require('colors');
|
||||||
var shelljs = require('shelljs');
|
let shelljs = require('shelljs');
|
||||||
|
|
||||||
var fs = require('../../core/fs.js');
|
let fs = require('../../core/fs.js');
|
||||||
|
|
||||||
var GethCommands = require('./geth_commands.js');
|
let GethCommands = require('./geth_commands.js');
|
||||||
|
|
||||||
/*eslint complexity: ["error", 22]*/
|
/*eslint complexity: ["error", 22]*/
|
||||||
var Blockchain = function(options) {
|
let Blockchain = function(options) {
|
||||||
this.blockchainConfig = options.blockchainConfig;
|
this.blockchainConfig = options.blockchainConfig;
|
||||||
this.env = options.env || 'development';
|
this.env = options.env || 'development';
|
||||||
this.client = options.client;
|
this.client = options.client;
|
||||||
@ -41,20 +41,20 @@ Blockchain.prototype.runCommand = function(cmd) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Blockchain.prototype.run = function() {
|
Blockchain.prototype.run = function() {
|
||||||
var self = this;
|
let self = this;
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
|
console.log(("Embark Blockchain Using: " + this.client.name.underline).magenta);
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
console.log("===============================================================================".magenta);
|
console.log("===============================================================================".magenta);
|
||||||
var address = this.initChainAndGetAddress();
|
let address = this.initChainAndGetAddress();
|
||||||
this.client.mainCommand(address, function(cmd) {
|
this.client.mainCommand(address, function(cmd) {
|
||||||
self.runCommand(cmd);
|
self.runCommand(cmd);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockchain.prototype.initChainAndGetAddress = function() {
|
Blockchain.prototype.initChainAndGetAddress = function() {
|
||||||
var address = null, result;
|
let address = null, result;
|
||||||
|
|
||||||
// ensure datadir exists, bypassing the interactive liabilities prompt.
|
// ensure datadir exists, bypassing the interactive liabilities prompt.
|
||||||
this.datadir = '.embark/' + this.env + '/datadir';
|
this.datadir = '.embark/' + this.env + '/datadir';
|
||||||
@ -82,7 +82,7 @@ Blockchain.prototype.initChainAndGetAddress = function() {
|
|||||||
return address;
|
return address;
|
||||||
};
|
};
|
||||||
|
|
||||||
var BlockchainClient = function(blockchainConfig, client, env) {
|
let BlockchainClient = function(blockchainConfig, client, env) {
|
||||||
if (client === 'geth') {
|
if (client === 'geth') {
|
||||||
return new Blockchain({blockchainConfig: blockchainConfig, client: GethCommands, env: env});
|
return new Blockchain({blockchainConfig: blockchainConfig, client: GethCommands, env: env});
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
/*jshint esversion: 6, loopfunc: true */
|
/*jshint esversion: 6, loopfunc: true */
|
||||||
var async = require('../utils/async_extend.js');
|
let async = require('../utils/async_extend.js');
|
||||||
var SolcW = require('./solcW.js');
|
let SolcW = require('./solcW.js');
|
||||||
|
|
||||||
var Compiler = function(options) {
|
let Compiler = function(options) {
|
||||||
this.plugins = options.plugins;
|
this.plugins = options.plugins;
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
Compiler.prototype.compile_contracts = function(contractFiles, cb) {
|
Compiler.prototype.compile_contracts = function(contractFiles, cb) {
|
||||||
var self = this;
|
|
||||||
|
|
||||||
var available_compilers = {
|
let available_compilers = {
|
||||||
//".se": this.compile_serpent
|
//".se": this.compile_serpent
|
||||||
".sol": this.compile_solidity.bind(this)
|
".sol": this.compile_solidity.bind(this)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.plugins) {
|
if (this.plugins) {
|
||||||
var compilerPlugins = this.plugins.getPluginsFor('compilers');
|
let compilerPlugins = this.plugins.getPluginsFor('compilers');
|
||||||
if (compilerPlugins.length > 0) {
|
if (compilerPlugins.length > 0) {
|
||||||
compilerPlugins.forEach(function(plugin) {
|
compilerPlugins.forEach(function(plugin) {
|
||||||
plugin.compilers.forEach(function(compilerObject) {
|
plugin.compilers.forEach(function(compilerObject) {
|
||||||
@ -26,12 +25,12 @@ Compiler.prototype.compile_contracts = function(contractFiles, cb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var compiledObject = {};
|
let compiledObject = {};
|
||||||
|
|
||||||
async.eachObject(available_compilers,
|
async.eachObject(available_compilers,
|
||||||
function(extension, compiler, callback) {
|
function(extension, compiler, callback) {
|
||||||
// TODO: warn about files it doesn't know how to compile
|
// TODO: warn about files it doesn't know how to compile
|
||||||
var matchingFiles = contractFiles.filter(function(file) {
|
let matchingFiles = contractFiles.filter(function(file) {
|
||||||
return (file.filename.match(/\.[0-9a-z]+$/)[0] === extension);
|
return (file.filename.match(/\.[0-9a-z]+$/)[0] === extension);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -47,14 +46,14 @@ Compiler.prototype.compile_contracts = function(contractFiles, cb) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Compiler.prototype.compile_solidity = function(contractFiles, cb) {
|
Compiler.prototype.compile_solidity = function(contractFiles, cb) {
|
||||||
var self = this;
|
let self = this;
|
||||||
var input = {};
|
let input = {};
|
||||||
var solcW;
|
let solcW;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function prepareInput(callback) {
|
function prepareInput(callback) {
|
||||||
for (var i = 0; i < contractFiles.length; i++){
|
for (let i = 0; i < contractFiles.length; i++){
|
||||||
// TODO: this depends on the config
|
// TODO: this depends on the config
|
||||||
var filename = contractFiles[i].filename.replace('app/contracts/','');
|
let filename = contractFiles[i].filename.replace('app/contracts/','');
|
||||||
input[filename] = contractFiles[i].content.toString();
|
input[filename] = contractFiles[i].content.toString();
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
@ -81,12 +80,12 @@ Compiler.prototype.compile_solidity = function(contractFiles, cb) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
function createCompiledObject(output, callback) {
|
function createCompiledObject(output, callback) {
|
||||||
var json = output.contracts;
|
let json = output.contracts;
|
||||||
|
|
||||||
compiled_object = {};
|
let compiled_object = {};
|
||||||
|
|
||||||
for (var className in json) {
|
for (let className in json) {
|
||||||
var contract = json[className];
|
let contract = json[className];
|
||||||
|
|
||||||
compiled_object[className] = {};
|
compiled_object[className] = {};
|
||||||
compiled_object[className].code = contract.bytecode;
|
compiled_object[className].code = contract.bytecode;
|
||||||
|
@ -2,6 +2,7 @@ let async = require('async');
|
|||||||
|
|
||||||
let Deploy = require('./deploy.js');
|
let Deploy = require('./deploy.js');
|
||||||
let ContractsManager = require('./contracts.js');
|
let ContractsManager = require('./contracts.js');
|
||||||
|
const EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
let DeployManager = function(options) {
|
let DeployManager = function(options) {
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
@ -12,12 +13,15 @@ let DeployManager = function(options) {
|
|||||||
this.chainConfig = (options.trackContracts !== false) ? this.config.chainTracker : false;
|
this.chainConfig = (options.trackContracts !== false) ? this.config.chainTracker : false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DeployManager.prototype = Object.create(EventEmitter.prototype);
|
||||||
|
|
||||||
|
|
||||||
DeployManager.prototype.deployContracts = function(done) {
|
DeployManager.prototype.deployContracts = function(done) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) {
|
if (self.blockchainConfig === {} || self.blockchainConfig.enabled === false) {
|
||||||
self.logger.info("Blockchain component is disabled in the config".underline);
|
self.logger.info("Blockchain component is disabled in the config".underline);
|
||||||
Embark.emit('blockchainDisabled', {});
|
this.emit('blockchainDisabled', {});
|
||||||
return done();
|
return done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ DeployManager.prototype.deployContracts = function(done) {
|
|||||||
env: self.config.env
|
env: self.config.env
|
||||||
});
|
});
|
||||||
deploy.deployAll(function() {
|
deploy.deployAll(function() {
|
||||||
Embark.emit('contractsDeployed', contractsManager);
|
self.emit('contractsDeployed', contractsManager);
|
||||||
callback(null, contractsManager);
|
callback(null, contractsManager);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@
|
|||||||
"-W058": true,
|
"-W058": true,
|
||||||
"-W014": true,
|
"-W014": true,
|
||||||
"expr": true,
|
"expr": true,
|
||||||
"esversion": 6
|
"esversion": 6,
|
||||||
|
"unused": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user