diff --git a/.gitignore b/.gitignore index 93f1361991..3fb4744553 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules npm-debug.log +python_modules diff --git a/bin/remixd b/bin/remixd index 2dc24c632a..419c70a42b 100755 --- a/bin/remixd +++ b/bin/remixd @@ -4,6 +4,7 @@ var servicesList = require('../src/servicesList') var program = require('commander') var startmistGeth = require('../src/services/startMistGeth') var startFrontend = require('../src/services/startFrontend') +var vyper = require('../src/services/vyper') var fs = require('fs-extra') program @@ -12,6 +13,7 @@ program .option('--remix-ide ', 'URL of remix instance allowed to connect to this web sockect connection') .option('-s, --shared-folder ', 'Folder to share with Remix IDE') .option('--read-only', 'Treat shared folder as read-only (experimental)') +.option('--vyper', 'Run a local vyper compiler') .option('-m, --mist', 'start mist') .option('-g, --geth', 'start geth') .option('-p, --dev-path ', 'Folder used by mist/geth to start the development instance') @@ -27,6 +29,11 @@ program var killCallBack = [] +if (program.vyper) { + console.log('starting vyper compiler') + vyper() +} + if (!program.remixIde) { return console.log('\x1b[31m%s\x1b[0m', '[ERR] URL Remix IDE instance has to be provided.') } diff --git a/package.json b/package.json index 94c6738698..e7eae8ef0e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "./bin/remixd" + "start": "./bin/remixd", + "npip": "npip", + "install": "npip install" }, "repository": { "type": "git", @@ -32,10 +34,17 @@ "fs-extra": "^3.0.1", "isbinaryfile": "^3.0.2", "lerna": "^2.9.0", + "nopy": "^0.2.6", "serve": "7.0.0", "stdout": "0.0.3", "watch": "^1.0.2", "web3": "1.0.0-beta.27", "websocket": "^1.0.24" + }, + "python": { + "execPath": "python3", + "dependencies": { + "vyper": ">=0.1.0b3" + } } } diff --git a/src/services/vyper.js b/src/services/vyper.js new file mode 100644 index 0000000000..083b169ae9 --- /dev/null +++ b/src/services/vyper.js @@ -0,0 +1,35 @@ +var spawn = require('child_process').spawn +var stdout = require('stdout') + +module.exports = function () { + var vyperServer = run('./python_modules/bin/vyper-serve', []) + function kill () { + if (vyperServer) { + console.log('stopping vyper compiler') + vyperServer.kill() + } + } + return kill +} + +function run (app, args) { + var proc + try { + proc = spawn(app, args) + proc.on('error', (err) => { + console.log('\x1b[31m%s\x1b[0m', '[ERR] can\'t start ' + app + '. seems not installed') + console.log(err) + }) + proc.on('exit', function (code, signal) { + console.log('child process exited with ' + + `code ${code} and signal ${signal}`) + }) + proc.on('message', function (msg) { + console.log(`from ${app} : ${msg}`) + }) + proc.stdout.pipe(stdout()) + } catch (e) { + console.log(e) + } + return proc +}