Requested PR fixes
Added catch to live-plugin-manager install promise running in child process Removed some `else`'s ;) Only showing solc downloading spinner when `--nodashboard` option is used. When installing package in main process and simultaneous downloads fail, all callbacks called with error. Updated logging in npmTimer.
This commit is contained in:
parent
4604ac2aa2
commit
a100dd4260
|
@ -0,0 +1,147 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Embark: Mocha All",
|
||||
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
||||
"args": [
|
||||
"--colors",
|
||||
"--no-timeouts",
|
||||
"${workspaceFolder}/test/"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Embark: Mocha Current File",
|
||||
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
|
||||
"args": [
|
||||
"--colors",
|
||||
"--no-timeouts",
|
||||
"${file}"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Embark: embark test",
|
||||
"autoAttachChildProcesses": true,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/lib/tests/test_embark",
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Test app: Embark test",
|
||||
"cwd": "${workspaceFolder}/test_apps/test_app/",
|
||||
"autoAttachChildProcesses": true,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/bin/embark",
|
||||
"args": [
|
||||
"test"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Test app: Embark new testapp123",
|
||||
"cwd": "${workspaceFolder}/test_apps/test_app/",
|
||||
"autoAttachChildProcesses": true,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/bin/embark",
|
||||
"args": [
|
||||
"new",
|
||||
"testapp123"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Test app: Embark upload",
|
||||
"cwd": "${workspaceFolder}/test_apps/test_app/",
|
||||
"autoAttachChildProcesses": true,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/bin/embark",
|
||||
"args": [
|
||||
"upload"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Test app: Embark run",
|
||||
"cwd": "${workspaceFolder}/test_apps/test_app/",
|
||||
"autoAttachChildProcesses": true,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/bin/embark",
|
||||
"args": [
|
||||
"run",
|
||||
"--nodashboard"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Embark demo from main repo: Embark run",
|
||||
"cwd": "${workspaceFolder}/../../embk-fw/embark/embark_demo/",
|
||||
"autoAttachChildProcesses": true,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/bin/embark",
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Embark demo from dapp-bin: Embark run",
|
||||
"cwd": "${workspaceFolder}/../../embk-fw/dapp-bin/embark_demo/",
|
||||
"autoAttachChildProcesses": false,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/bin/embark",
|
||||
"args": [
|
||||
"run",
|
||||
"--nodashboard"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Embark react routes demo: Embark run",
|
||||
"cwd": "${workspaceFolder}/../../emizzle/embark-demo-react-routes/",
|
||||
"autoAttachChildProcesses": true,
|
||||
//"preLaunchTask": "npm_install",
|
||||
"program": "${workspaceFolder}/bin/embark",
|
||||
"args": [
|
||||
"run"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
}
|
||||
|
||||
]
|
||||
}
|
|
@ -16,6 +16,7 @@ class Engine {
|
|||
this.logLevel = options.logLevel;
|
||||
this.events = options.events;
|
||||
this.context = options.context;
|
||||
this.useDashboard = options.useDashboard;
|
||||
}
|
||||
|
||||
init(_options) {
|
||||
|
@ -185,7 +186,7 @@ class Engine {
|
|||
this.ipc.serve();
|
||||
}
|
||||
|
||||
this.registerModule('solidity', {ipc: this.ipc});
|
||||
this.registerModule('solidity', {ipc: this.ipc, useDashboard: this.useDashboard});
|
||||
this.registerModule('vyper');
|
||||
this.registerModule('profiler');
|
||||
this.registerModule('fuzzer');
|
||||
|
|
|
@ -80,7 +80,8 @@ class Embark {
|
|||
embarkConfig: options.embarkConfig || 'embark.json',
|
||||
logFile: options.logFile,
|
||||
logLevel: options.logLevel,
|
||||
context: self.context
|
||||
context: self.context,
|
||||
useDashboard: options.useDashboard
|
||||
});
|
||||
engine.init();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ class Solidity {
|
|||
this.contractDirectories = embark.config.contractDirectories;
|
||||
this.solcAlreadyLoaded = false;
|
||||
this.solcW = null;
|
||||
this.useDashboard = options.useDashboard;
|
||||
|
||||
embark.registerCompiler(".sol", this.compile_solidity.bind(this));
|
||||
}
|
||||
|
@ -49,7 +50,7 @@ class Solidity {
|
|||
if (self.solcAlreadyLoaded) {
|
||||
return callback();
|
||||
}
|
||||
self.solcW = new SolcW({logger: self.logger, events: self.events, ipc: self.ipc});
|
||||
self.solcW = new SolcW({logger: self.logger, events: self.events, ipc: self.ipc, useDashboard: self.useDashboard});
|
||||
|
||||
self.logger.info(__("loading solc compiler") + "..");
|
||||
self.solcW.load_compiler(function (err) {
|
||||
|
|
|
@ -12,7 +12,7 @@ class SolcProcess extends ProcessWrapper {
|
|||
constructor(options){
|
||||
super();
|
||||
this._logger = options.logger;
|
||||
this._npm = options.npm;
|
||||
this._showSpinner = options.showSpinner === true;
|
||||
}
|
||||
|
||||
findImports(filename) {
|
||||
|
@ -34,11 +34,11 @@ class SolcProcess extends ProcessWrapper {
|
|||
|
||||
installAndLoadCompiler(solcVersion, packagePath){
|
||||
let self = this;
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let manager = new PluginManager({pluginsPath: packagePath});
|
||||
let timer;
|
||||
if (!fs.existsSync(packagePath)) {
|
||||
timer = new NpmTimer({logger: self._logger, packageName: 'solc', version: solcVersion, showSpinner: true});
|
||||
timer = new NpmTimer({logger: self._logger, packageName: 'solc', version: solcVersion, showSpinner: self._showSpinner});
|
||||
}
|
||||
|
||||
if(timer) timer.start();
|
||||
|
@ -46,7 +46,7 @@ class SolcProcess extends ProcessWrapper {
|
|||
self.solc = manager.require('solc');
|
||||
if(timer) timer.end();
|
||||
resolve();
|
||||
});
|
||||
}).catch(reject);
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ class SolcW {
|
|||
this.ipc = options.ipc;
|
||||
this.compilerLoaded = false;
|
||||
this.solcProcess = null;
|
||||
this.useDashboard = options.useDashboard;
|
||||
}
|
||||
|
||||
load_compiler(done) {
|
||||
|
@ -43,16 +44,15 @@ class SolcW {
|
|||
this.solcProcess.once("result", "initiated", () => {
|
||||
this.events.request("version:get:solc", function(solcVersion) {
|
||||
if (solcVersion === currentSolcVersion) {
|
||||
self.solcProcess.send({action: 'loadCompiler', requirePath: 'solc'});
|
||||
} else {
|
||||
self.events.request("version:getPackagePath", "solc", solcVersion, function(err, path) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
let requirePath = fs.dappPath(path);
|
||||
self.solcProcess.send({action: 'installAndLoadCompiler', solcVersion: solcVersion, packagePath: requirePath});
|
||||
});
|
||||
}
|
||||
return self.solcProcess.send({action: 'loadCompiler', requirePath: 'solc'});
|
||||
}
|
||||
self.events.request("version:getPackagePath", "solc", solcVersion, function(err, path) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
let requirePath = fs.dappPath(path);
|
||||
self.solcProcess.send({action: 'installAndLoadCompiler', solcVersion: solcVersion, packagePath: requirePath});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SolcW {
|
|||
self.compilerLoaded = true;
|
||||
done();
|
||||
});
|
||||
this.solcProcess.send({action: "init", options: {logger: self.logger}});
|
||||
this.solcProcess.send({action: "init", options: {logger: self.logger, showSpinner: !self.useDashboard}});
|
||||
|
||||
if (this.ipc.isServer()) {
|
||||
this.ipc.on('compile', self.compile.bind(this));
|
||||
|
|
|
@ -80,12 +80,10 @@ class Swarm {
|
|||
let currentPIterationVersion = require('../../../package.json').dependencies["p-iteration"];
|
||||
if (pIterationVersion !== currentPIterationVersion) {
|
||||
self.events.request("version:getPackageLocation", "p-iteration", pIterationVersion, function(err, location) {
|
||||
if(!err){
|
||||
self.embark.registerImportFile("p-iteration", fs.dappPath(location));
|
||||
}
|
||||
else{
|
||||
self.logger.error("Error getting package location for p-iteration: " + err);
|
||||
if(err){
|
||||
return self.logger.error("Error getting package location for p-iteration: " + err);
|
||||
}
|
||||
self.embark.registerImportFile("p-iteration", fs.dappPath(location));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -34,8 +34,7 @@ class Npm {
|
|||
if(this._isInstalling(packageName, version)){
|
||||
this._installing[packageName + version].push(callback);
|
||||
}else{
|
||||
this._installing[packageName + version] = new Array(callback);
|
||||
|
||||
this._installing[packageName + version] = [callback];
|
||||
|
||||
const timer = new NpmTimer({logger: this._logger, packageName: packageName, version: version});
|
||||
timer.start();
|
||||
|
@ -49,7 +48,9 @@ class Npm {
|
|||
delete this._installing[packageName + version];
|
||||
//callback(null, result.location);
|
||||
}).catch(err => {
|
||||
callback(err);
|
||||
this._installing[packageName + version].forEach((cb) => {
|
||||
cb(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ i18n.setOrDetectLocale('en');
|
|||
|
||||
class NpmTimer{
|
||||
constructor(options){
|
||||
this._logger = options.logger;
|
||||
this._logger = (options.logger && typeof options.logger.info == 'function') ? options.logger : console;
|
||||
this._packageName = options.packageName;
|
||||
this._version = options.version;
|
||||
this._showSpinner = options.showSpinner || false;
|
||||
|
@ -55,22 +55,13 @@ class NpmTimer{
|
|||
if(entry.duration > 4000){
|
||||
strDuration = strDuration.red;
|
||||
}
|
||||
this._log(strDuration);
|
||||
this._logger.info(strDuration);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
return this._observer;
|
||||
}
|
||||
|
||||
_log(msg){
|
||||
if(typeof this._logger.info == 'function'){
|
||||
this._logger.info(msg);
|
||||
}
|
||||
else{ // occurs in subprocess as functions are not serialised/deserialised properly
|
||||
console.log(msg.green);
|
||||
}
|
||||
}
|
||||
|
||||
start(){
|
||||
let self = this;
|
||||
|
@ -83,7 +74,7 @@ class NpmTimer{
|
|||
text: strDownloadStart
|
||||
}).start();
|
||||
}else{
|
||||
this._log(strDownloadStart);
|
||||
this._logger.info(strDownloadStart);
|
||||
}
|
||||
|
||||
// mark our start time
|
||||
|
|
Loading…
Reference in New Issue