From 18f483be278d85b959f3f75abe4746c77ef67d69 Mon Sep 17 00:00:00 2001 From: serapath Date: Fri, 31 Mar 2017 06:31:43 +0700 Subject: [PATCH] ADD browserify livereload & refactor npm scripts --- .babelrc | 21 ---- README.md | 25 ++-- ci/browser_tests.sh | 3 +- package.json | 112 ++++++++++++++---- test/compiler-test.js | 2 +- test/gist-handler-test.js | 2 +- test/query-params-test.js | 2 +- .../staticAnalysisCommon-test.js | 4 +- test/util-test.js | 2 +- 9 files changed, 118 insertions(+), 55 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index c0a5a8fa58..0000000000 --- a/.babelrc +++ /dev/null @@ -1,21 +0,0 @@ -{ - "plugins": ["fast-async", - "check-es2015-constants", - "transform-es2015-arrow-functions", - "transform-es2015-block-scoped-functions", - "transform-es2015-block-scoping", - "transform-es2015-classes", - "transform-es2015-computed-properties", - "transform-es2015-destructuring", - "transform-es2015-duplicate-keys", - "transform-es2015-for-of", - "transform-es2015-function-name", - "transform-es2015-literals", - "transform-es2015-object-super", - "transform-es2015-parameters", - "transform-es2015-shorthand-properties", - "transform-es2015-spread", - "transform-es2015-sticky-regex", - "transform-es2015-unicode-regex", - ] -} \ No newline at end of file diff --git a/README.md b/README.md index 5b4dc94e2d..ac2dbf2751 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,21 @@ The `gh-pages` branch always has the latest stable build of Remix. It also conta Note: it contains the latest release of Solidity available at the time of the packaging. No other compiler versions are supported. -## Building -Many dependencies are only provided via npm: +## INSTALLATION: - npm install # fetch dependencies - npm run build # build application into build/app.js +Install npm and node.js (see https://docs.npmjs.com/getting-started/installing-node), then do: -Now point your browser to `index.html` to open the application. + * `git clone https://github.com/ethereum/browser-solidity` + * `cd browser-solidity` + * `npm install` - fetch dependencies & executes `npm run prepublish` to build the application + +## DEVELOPING: + +Run `npm start` and open `http://127.0.0.1:8080` in your browser. + +Then open your `text editor` and start developing. +The browser will automatically refresh when files are saved ### Troubleshooting building @@ -38,9 +45,13 @@ Run: ## Unit Testing -Register new unit test files in `test/index.js`. The tests are written using [tape](https://www.npmjs.com/package/tape). Run the tests via: +Register new unit test files in `test/index.js`. +The tests are written using [tape](https://www.npmjs.com/package/tape). + +Run the unit tests via: `npm test` - npm test +For local headless browser tests run `npm run test-browser` +(Requires selenium to be installed - can be done with `npm run selenium-install`) ## Browser Testing diff --git a/ci/browser_tests.sh b/ci/browser_tests.sh index b15fb5a0a6..d9fe75655e 100755 --- a/ci/browser_tests.sh +++ b/ci/browser_tests.sh @@ -20,7 +20,8 @@ while [ ! -f "$SAUCECONNECT_READYFILE" ]; do sleep .5 done -npm run browser-test-remote-parallel || TEST_EXITCODE=1 +# npm run browser-test-remote-parallel || TEST_EXITCODE=1 +npm run nightwatch_remote_parallel || TEST_EXITCODE=1 node ci/sauceDisconnect.js "$SAUCECONNECT_USERNAME" "$SAUCECONNECT_ACCESSKEY" "$SAUCECONNECT_JOBIDENTIFIER" diff --git a/package.json b/package.json index 9f7d180140..573381b810 100644 --- a/package.json +++ b/package.json @@ -3,24 +3,13 @@ "name": "browser-solidity", "version": "0.0.0", "description": "Minimalistic browser-based Solidity IDE", - "scripts": { - "browser-test": "nightwatch --config nightwatch.js --env local", - "browser-test-remote-chrome": "nightwatch --config nightwatch.js --env chrome", - "browser-test-remote-firefox": "nightwatch --config nightwatch.js --env default", - "browser-test-remote-ie": "nightwatch --config nightwatch.js --env ie", - "browser-test-remote-safari": "nightwatch --config nightwatch.js --env safari", - "browser-test-remote-parallel": "nightwatch --config nightwatch.js --env safari,ie,default,chrome", - "build": "mkdirp build; browserify src/index.js -g yo-yoify -o build/app.js -t [ babelify ]; babel --plugins=transform-es2015-template-literals build/app.js --out-file build/app.js", - "csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='assets/css/font-awesome.min.css' assets/css/", - "downloadsolc": "rm -f soljson.js; wget https://ethereum.github.io/solc-bin/soljson.js", - "lint": "standard", - "serve": "http-server .", - "test": "standard; babel src --out-dir babelify-src; node test/index.js" - }, "devDependencies": { "async": "^2.1.2", + "babel-cli": "^6.16.0", + "babel-eslint": "^7.1.1", + "babel-plugin-check-es2015-constants": "^6.8.0", "babel-plugin-transform-es2015-arrow-functions": "^6.8.0", "babel-plugin-transform-es2015-block-scoped-functions": "^6.8.0", @@ -41,30 +30,44 @@ "babel-plugin-transform-es2015-unicode-regex": "^6.11.0", "babel-plugin-transform-regenerator": "^6.16.1", "babel-polyfill": "^6.22.0", + + "babel-plugin-yo-yoify": "^0.3.3", + "babel-preset-es2015": "^6.24.0", + "babelify": "^7.3.0", "brace": "^0.8.0", "browserify": "^13.0.0", + "browserify-reload": "^1.0.3", "csslint": "^1.0.2", "ethereum-remix": "https://github.com/ethereum/remix", "ethereumjs-abi": "https://github.com/ethereumjs/ethereumjs-abi", - "ethereumjs-block": "^1.2.2", - "ethereumjs-tx": "^1.1.1", - "ethereumjs-util": "^4.4.0", - "ethereumjs-vm": "^2.0.1", + "ethereumjs-block": "https://github.com/ethereumjs/ethereumjs-block", + "ethereumjs-tx": "https://github.com/ethereumjs/ethereumjs-tx", + "ethereumjs-util": "https://github.com/ethereumjs/ethereumjs-util", + "ethereumjs-vm": "https://github.com/ethereumjs/ethereumjs-vm", + "execr": "^1.0.1", + "exorcist": "^0.4.0", "fast-async": "^6.1.2", "http-server": "0.9.0", "jquery": "^2.2.0", "js-base64": "^2.1.9", "mkdirp": "^0.5.1", "nightwatch": "^0.9.3", + "notify-error": "^1.2.0", + "npm-run-all": "^4.0.2", + "onchange": "^3.2.1", + "rimraf": "^2.6.1", + "selenium-standalone": "^6.0.1", "solc": "https://github.com/ethereum/solc-js", "standard": "^8.5.0", "swarmgw": "^0.2.0", "tape": "^4.5.1", + "uglify-js": "^2.8.16", + "uglifyify": "^3.0.4", + "watchify": "^3.9.0", "web3": "^0.18.0", "webworkify": "^1.2.1", - "yo-yo": "^1.2.2", - "yo-yoify": "^3.3.0" + "yo-yo": "^1.2.2" }, "repository": { "type": "git", @@ -88,5 +91,74 @@ "soljson.js" ], "parser": "babel-eslint" + }, + "babel": { + "plugins": [ + "transform-es2015-template-literals", + "transform-es2015-literals", + "transform-es2015-function-name", + "transform-es2015-arrow-functions", + "transform-es2015-block-scoped-functions", + "transform-es2015-classes", + "transform-es2015-object-super", + "transform-es2015-shorthand-properties", + "transform-es2015-duplicate-keys", + "transform-es2015-computed-properties", + "transform-es2015-for-of", + "transform-es2015-sticky-regex", + "transform-es2015-unicode-regex", + "check-es2015-constants", + "transform-es2015-spread", + "transform-es2015-parameters", + "transform-es2015-destructuring", + "transform-es2015-block-scoping" + ] + }, + "browserify": { + "transform": [ + ["babelify", { + "sourceMapsAbsolute": false, + "sourceMaps": true, + "plugins": [ + ["fast-async", { + "runtimePattern": null, + "compiler": { + "es7": true, + "noRuntime": true, + "promises": true, + "wrapAwait": true + } + }], + ["yo-yoify"] + ], + "presets": ["es2015"] + }], + ["uglifyify"] + ] + }, + "scripts": { + "build": "browserify src/index.js -d | npm run minify --silent | npm run sourcemap", + "browsertest": "sleep 5 && npm run nightwatch_local", + "csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='assets/css/font-awesome.min.css' assets/css/", + "downloadsolc": "rimraf soljson.js; wget https://ethereum.github.io/solc-bin/soljson.js", + "lint": "standard | notify-error", + "make-mock-compiler": "node ci/makeMockCompiler.js", + "minify": "uglifyjs --in-source-map inline --source-map-inline -c warnings=false", + "nightwatch_local": "nightwatch --config nightwatch.js --env local", + "nightwatch_remote_chrome": "nightwatch --config nightwatch.js --env chrome", + "nightwatch_remote_firefox": "nightwatch --config nightwatch.js --env default", + "nightwatch_remote_ie": "nightwatch --config nightwatch.js --env ie", + "nightwatch_remote_parallel": "nightwatch --config nightwatch.js --env ie,safari,chrome,default", + "nightwatch_remote_safari": "nightwatch --config nightwatch.js --env safari", + "onchange": "onchange build/app.js -- npm-run-all lint", + "prepublish": "mkdirp build; npm-run-all -ls downloadsolc make-mock-compiler build", + "selenium": "execr --silent selenium-standalone start", + "selenium-install": "selenium-standalone install", + "serve": "execr --silent http-server .", + "sourcemap": "exorcist --root ../ build/app.js.map > build/app.js", + "start": "npm-run-all -lpr serve watch onchange", + "test": "standard; npm run csslint; node test/index.js", + "test-browser": "npm-run-all -lpr selenium serve browsertest", + "watch": "watchify src/index.js -dv --delay 0 -p browserify-reload -o '| npm run sourcemap'" } } diff --git a/test/compiler-test.js b/test/compiler-test.js index 4664036d97..ecb5a027da 100644 --- a/test/compiler-test.js +++ b/test/compiler-test.js @@ -2,7 +2,7 @@ var test = require('tape') -var Compiler = require('../babelify-src/app/compiler') +var Compiler = require('../src/app/compiler') test('compiler.compile smoke', function (t) { t.plan(1) diff --git a/test/gist-handler-test.js b/test/gist-handler-test.js index 3ce54ecd14..76584e73ca 100644 --- a/test/gist-handler-test.js +++ b/test/gist-handler-test.js @@ -2,7 +2,7 @@ var test = require('tape') -var GistHandler = require('../babelify-src/app/gist-handler') +var GistHandler = require('../src/app/gist-handler') test('gistHandler.handleLoad with no gist param', function (t) { t.plan(1) diff --git a/test/query-params-test.js b/test/query-params-test.js index 72bd628136..4240c99507 100644 --- a/test/query-params-test.js +++ b/test/query-params-test.js @@ -2,7 +2,7 @@ var test = require('tape') -var QueryParams = require('../babelify-src/app/query-params') +var QueryParams = require('../src/app/query-params') test('queryParams.get', function (t) { t.plan(2) diff --git a/test/staticanalysis/staticAnalysisCommon-test.js b/test/staticanalysis/staticAnalysisCommon-test.js index b89f7c5f36..b815dce6c4 100644 --- a/test/staticanalysis/staticAnalysisCommon-test.js +++ b/test/staticanalysis/staticAnalysisCommon-test.js @@ -1,7 +1,7 @@ var test = require('tape') -var common = require('../../babelify-src/app/staticanalysis/modules/staticAnalysisCommon') -var utils = require('../../babelify-src/app/utils') +var common = require('../../src/app/staticanalysis/modules/staticAnalysisCommon') +var utils = require('../../src/app/utils') test('staticAnalysisCommon.helpers.buildFunctionSignature', function (t) { t.plan(7) diff --git a/test/util-test.js b/test/util-test.js index 4e0b9c5473..123f297db7 100644 --- a/test/util-test.js +++ b/test/util-test.js @@ -1,6 +1,6 @@ var test = require('tape') -var utils = require('../babelify-src/app/utils') +var utils = require('../src/app/utils') test('util.groupBy on valid input', function (t) { t.plan(1)