From c1ea517a2c10ea688c67eb4a99b38d2846fb3e36 Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 16 Apr 2020 18:43:31 +0200 Subject: [PATCH] stage sync + lint some files (#563) --- .eslintrc | 78 +++++++------- .gitignore | 3 + .gitlab-ci.yml | 11 +- package.json | 264 +++++++++++++++++++++++----------------------- scripts/s3sync.sh | 86 +++++++++++++++ 5 files changed, 266 insertions(+), 176 deletions(-) create mode 100755 scripts/s3sync.sh diff --git a/.eslintrc b/.eslintrc index e95117caf..7946be7db 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,17 +7,9 @@ }, "sourceType": "module" }, - "extends": [ - "eslint:recommended", - "plugin:flowtype/recommended" - ], + "extends": ["eslint:recommended", "plugin:flowtype/recommended"], "parser": "babel-eslint", - "plugins": [ - "standard", - "promise", - "flowtype", - "jest" - ], + "plugins": ["standard", "promise", "flowtype", "jest"], "env": { "es6": true, "node": true, @@ -25,35 +17,24 @@ "webextensions": true, "jest": true }, - "globals": { - - }, + "globals": {}, "rules": { "flowtype/define-flow-type": 1, "flowtype/use-flow-type": 1, - "flowtype/object-type-delimiter": [ - 2, - "semicolon" - ], - "flowtype/delimiter-dangle": [ + "flowtype/object-type-delimiter": [2, "semicolon"], + "flowtype/delimiter-dangle": [2, "always-multiline"], + "comma-dangle": [2, "always-multiline"], + "no-unused-vars": [ 2, - "always-multiline" + { + "args": "none", + "vars": "all" + } ], - "comma-dangle": [2, "always-multiline"], - "no-unused-vars": [2, { - "args": "none", - "vars": "all" - }], "no-console": 1, "quotes": [2, "single", "avoid-escape"], - "linebreak-style": [ - 2, - "unix" - ], - "semi": [ - 2, - "always" - ], + "linebreak-style": [2, "unix"], + "semi": [2, "always"], "accessor-pairs": 2, "arrow-spacing": [2, { "before": true, "after": true }], "block-spacing": [2, "always"], @@ -66,11 +47,11 @@ "eol-last": 2, "eqeqeq": [2, "allow-null"], "generator-star-spacing": [2, { "before": true, "after": true }], - "handle-callback-err": [2, "^(err|error)$" ], + "handle-callback-err": [2, "^(err|error)$"], "indent": [2, 4, { "SwitchCase": 1 }], "jsx-quotes": [2, "prefer-single"], "key-spacing": [2, { "beforeColon": false, "afterColon": true }], - "keyword-spacing": [2, {"before": true, "after": true}], + "keyword-spacing": [2, { "before": true, "after": true }], "new-cap": [2, { "newIsCap": true, "capIsNew": false }], "new-parens": 2, "no-array-constructor": 2, @@ -137,20 +118,41 @@ "no-unneeded-ternary": [2, { "defaultAssignment": false }], "no-unreachable": 2, "no-useless-call": 2, - "no-use-before-define": [2, {"functions": false, "classes": false }], + "no-use-before-define": [2, { "functions": false, "classes": false }], "no-var": 2, "no-with": 2, "one-var": [2, { "initialized": "never" }], - "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }], + "operator-linebreak": [ + 2, + "after", + { "overrides": { "?": "before", ":": "before" } } + ], "padded-blocks": [2, "never"], "prefer-const": 2, "semi-spacing": [2, { "before": false, "after": true }], "space-before-blocks": [2, "always"], - "space-before-function-paren": [2, {"anonymous": "always", "named": "never"}], + "space-before-function-paren": [ + 2, + { "anonymous": "always", "named": "never" } + ], "space-in-parens": [2, "never"], "space-infix-ops": 2, "space-unary-ops": [2, { "words": true, "nonwords": false }], - "spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], + "spaced-comment": [ + 2, + "always", + { + "markers": [ + "global", + "globals", + "eslint", + "eslint-disable", + "*package", + "!", + "," + ] + } + ], "use-isnan": 2, "valid-typeof": 2, "wrap-iife": [2, "any"], diff --git a/.gitignore b/.gitignore index c6341ec76..6b76da9dc 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ logs *.log .yarnclean coverage + +# Cache +__pycache__ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ddf3d737..091891b4f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,14 +38,13 @@ deploy review: - branches tags: - deploy - -# todo: does not work yet. I would like not to use image with docker installed and rather use +# todo: does not work yet. I would like not to use image with docker installed and rather use # docker mounted from parent container https://docs.gitlab.com/ee/ci/docker/using_docker_build.html -# but I'd say it is not configured on the runners at the moment +# but I'd say it is not configured on the runners at the moment # # test integration: # stage: test-integration -# dependencies: +# dependencies: # - deploy review # variables: # DOCKER_TLS_CERTDIR: '' @@ -53,5 +52,5 @@ deploy review: # - docker:dind # before_script: # - docker info -# script: -# - ./tests/run.sh ci \ No newline at end of file +# script: +# - ./tests/run.sh ci diff --git a/package.json b/package.json index c7171fc2b..0ad6d8863 100644 --- a/package.json +++ b/package.json @@ -1,134 +1,134 @@ { - "name": "trezor-connect", - "version": "8.1.1", - "author": "Trezor ", - "homepage": "https://github.com/trezor/connect", - "description": "High-level javascript interface for Trezor hardware wallet.", - "license": "SEE LICENSE IN LICENSE.md", - "private": true, - "repository": { - "type": "git", - "url": "git://github.com/trezor/connect.git" - }, - "bugs": { - "url": "https://github.com/trezor/connect/issues" - }, - "keywords": [ - "Trezor", - "trezor-connect", - "javascript" - ], - "main": "src/js/index.js", - "browser": { - "./lib/env/node": "./lib/env/browser", - "./lib/env/node/workers": "./lib/env/browser/workers", - "./lib/env/node/networkUtils": "./lib/env/browser/networkUtils" - }, - "react-native": { - "./lib/env/node": "./lib/env/react-native", - "./lib/env/node/workers": "./lib/env/react-native/workers", - "./lib/env/node/networkUtils": "./lib/env/react-native/networkUtils" - }, - "scripts": { - "dev": "webpack-dev-server --config ./webpack/config.dev.babel.js --mode development", - "build": "rm -rf build && webpack --config ./webpack/config.prod.babel.js --progress", - "build:node": "rm -rf build && webpack --config ./webpack/config.nodejs.babel.js --progress", - "build:react-native": "rm -rf build && webpack --config ./webpack/config.reactnative.babel.js --progress", - "build:inline": "webpack --config ./webpack/config.inline.babel.js --progress", - "build:npm": "rm -rf npm && babel-node ./scripts/build-npm.js && babel ./npm/lib --out-dir ./npm/lib", - "build:npm-extended": "rm -rf npm-extended && babel-node ./scripts/build-npm-extended.js && babel ./npm-extended/lib --out-dir ./npm-extended/lib", - "stats": "webpack --config ./webpack/config.prod.babel.js --json > build/stats.json", - "test": "bash ./src/__tests__/run.sh", - "test:unit": "jest --verbose -c jest.config.unit.js", - "test:integration": "./tests/run.sh", - "flow": "flow check src/js", - "flow-tests": "flow check src/__tests__", - "lint": "eslint src/js", - "lint:fix": "eslint --fix src/js", - "lint:tests": "eslint src/__tests__", - "lint:tests:fix": "eslint --fix src/__tests__" - }, - "devDependencies": { - "@babel/cli": "7.8.4", - "@babel/core": "7.8.7", - "@babel/node": "7.8.7", - "@babel/plugin-proposal-class-properties": "7.8.3", - "@babel/plugin-proposal-object-rest-spread": "7.8.3", - "@babel/plugin-transform-runtime": "7.8.3", - "@babel/preset-env": "7.8.7", - "@babel/preset-flow": "7.8.3", - "@trezor/blockchain-link": "^1.0.10", - "@trezor/rollout": "^1.0.4", - "@trezor/utxo-lib": "^0.1.0", - "babel-collect-imports": "https://github.com/szymonlesisz/babel-collect-imports", - "babel-eslint": "^10.1.0", - "babel-jest": "25.1.0", - "babel-loader": "^8.0.0", - "bchaddrjs": "0.4.7", - "bignumber.js": "^9.0.0", - "bowser": "2.9.0", - "copy-webpack-plugin": "5.1.1", - "css-loader": "3.4.2", - "es6-promise": "^4.2.2", - "eslint": "6.8.0", - "eslint-plugin-flowtype": "4.6.0", - "eslint-plugin-jest": "23.8.2", - "eslint-plugin-promise": "^4.1.1", - "eslint-plugin-standard": "^4.0.1", - "file-loader": "^6.0.0", - "flow-bin": "0.120.1", - "fs-extra": "^8.1.0", - "hd-wallet": "9.0.0", - "html-webpack-plugin": "^3.2.0", - "jasmine-core": "^3.5.0", - "jest": "25.1.0", - "karma": "^4.4.1", - "karma-babel-preprocessor": "^8.0.0", - "karma-chrome-launcher": "^3.1.0", - "karma-firefox-launcher": "1.3.0", - "karma-jasmine": "3.1.1", - "karma-jasmine-async": "^0.0.1", - "karma-safari-launcher": "^1.0.0", - "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^4.0.2", - "keccak": "^3.0.0", - "less": "3.11.1", - "less-loader": "^5.0.0", - "less-plugin-autoprefix": "^2.0.0", - "less-plugin-clean-css": "^1.5.1", - "mini-css-extract-plugin": "0.9.0", - "node-fetch": "^2.6.0", - "parse-uri": "^1.0.0", - "ripple-lib": "1.6.5", - "sharedworker-loader": "^2.1.1", - "style-loader": "1.1.3", - "terser-webpack-plugin": "2.3.5", - "tiny-worker": "^2.3.0", - "trezor-link": "1.7.0", - "uglify-es": "3.3.9", - "version-bump-prompt": "6.0.3", - "webpack": "^4.42.0", - "webpack-cli": "3.3.11", - "webpack-dev-server": "3.10.3", - "worker-loader": "2.0.0" - }, - "dependencies": { - "@babel/runtime": "^7.8.7", - "events": "^3.1.0", - "whatwg-fetch": "^3.0.0" - }, - "extendedDependencies": { - "@trezor/blockchain-link": "^1.0.10", - "@trezor/rollout": "^1.0.4", - "@trezor/utxo-lib": "^0.1.0", - "bchaddrjs": "0.4.7", - "bignumber.js": "^9.0.0", - "bowser": "^2.9.0", - "hd-wallet": "9.0.0", - "keccak": "^3.0.0", - "node-fetch": "^2.6.0", - "parse-uri": "^1.0.0", - "tiny-worker": "^2.3.0", - "trezor-link": "1.7.0" - } + "name": "trezor-connect", + "version": "8.1.1", + "author": "Trezor ", + "homepage": "https://github.com/trezor/connect", + "description": "High-level javascript interface for Trezor hardware wallet.", + "license": "SEE LICENSE IN LICENSE.md", + "private": true, + "repository": { + "type": "git", + "url": "git://github.com/trezor/connect.git" + }, + "bugs": { + "url": "https://github.com/trezor/connect/issues" + }, + "keywords": [ + "Trezor", + "trezor-connect", + "javascript" + ], + "main": "src/js/index.js", + "browser": { + "./lib/env/node": "./lib/env/browser", + "./lib/env/node/workers": "./lib/env/browser/workers", + "./lib/env/node/networkUtils": "./lib/env/browser/networkUtils" + }, + "react-native": { + "./lib/env/node": "./lib/env/react-native", + "./lib/env/node/workers": "./lib/env/react-native/workers", + "./lib/env/node/networkUtils": "./lib/env/react-native/networkUtils" + }, + "scripts": { + "dev": "webpack-dev-server --config ./webpack/config.dev.babel.js --mode development", + "build": "rm -rf build && webpack --config ./webpack/config.prod.babel.js --progress", + "build:node": "rm -rf build && webpack --config ./webpack/config.nodejs.babel.js --progress", + "build:react-native": "rm -rf build && webpack --config ./webpack/config.reactnative.babel.js --progress", + "build:inline": "webpack --config ./webpack/config.inline.babel.js --progress", + "build:npm": "rm -rf npm && babel-node ./scripts/build-npm.js && babel ./npm/lib --out-dir ./npm/lib", + "build:npm-extended": "rm -rf npm-extended && babel-node ./scripts/build-npm-extended.js && babel ./npm-extended/lib --out-dir ./npm-extended/lib", + "stats": "webpack --config ./webpack/config.prod.babel.js --json > build/stats.json", + "test": "bash ./src/__tests__/run.sh", + "test:unit": "jest --verbose -c jest.config.unit.js", + "test:integration": "./tests/run.sh", + "flow": "flow check src/js", + "flow-tests": "flow check src/__tests__", + "lint": "eslint src/js", + "lint:fix": "eslint --fix src/js", + "lint:tests": "eslint src/__tests__", + "lint:tests:fix": "eslint --fix src/__tests__" + }, + "devDependencies": { + "@babel/cli": "7.8.4", + "@babel/core": "7.8.7", + "@babel/node": "7.8.7", + "@babel/plugin-proposal-class-properties": "7.8.3", + "@babel/plugin-proposal-object-rest-spread": "7.8.3", + "@babel/plugin-transform-runtime": "7.8.3", + "@babel/preset-env": "7.8.7", + "@babel/preset-flow": "7.8.3", + "@trezor/blockchain-link": "^1.0.10", + "@trezor/rollout": "^1.0.4", + "@trezor/utxo-lib": "^0.1.0", + "babel-collect-imports": "https://github.com/szymonlesisz/babel-collect-imports", + "babel-eslint": "^10.1.0", + "babel-jest": "25.1.0", + "babel-loader": "^8.0.0", + "bchaddrjs": "0.4.7", + "bignumber.js": "^9.0.0", + "bowser": "2.9.0", + "copy-webpack-plugin": "5.1.1", + "css-loader": "3.4.2", + "es6-promise": "^4.2.2", + "eslint": "6.8.0", + "eslint-plugin-flowtype": "4.6.0", + "eslint-plugin-jest": "23.8.2", + "eslint-plugin-promise": "^4.1.1", + "eslint-plugin-standard": "^4.0.1", + "file-loader": "^6.0.0", + "flow-bin": "0.120.1", + "fs-extra": "^8.1.0", + "hd-wallet": "9.0.0", + "html-webpack-plugin": "^3.2.0", + "jasmine-core": "^3.5.0", + "jest": "25.1.0", + "karma": "^4.4.1", + "karma-babel-preprocessor": "^8.0.0", + "karma-chrome-launcher": "^3.1.0", + "karma-firefox-launcher": "1.3.0", + "karma-jasmine": "3.1.1", + "karma-jasmine-async": "^0.0.1", + "karma-safari-launcher": "^1.0.0", + "karma-sourcemap-loader": "^0.3.7", + "karma-webpack": "^4.0.2", + "keccak": "^3.0.0", + "less": "3.11.1", + "less-loader": "^5.0.0", + "less-plugin-autoprefix": "^2.0.0", + "less-plugin-clean-css": "^1.5.1", + "mini-css-extract-plugin": "0.9.0", + "node-fetch": "^2.6.0", + "parse-uri": "^1.0.0", + "ripple-lib": "1.6.5", + "sharedworker-loader": "^2.1.1", + "style-loader": "1.1.3", + "terser-webpack-plugin": "2.3.5", + "tiny-worker": "^2.3.0", + "trezor-link": "1.7.0", + "uglify-es": "3.3.9", + "version-bump-prompt": "6.0.3", + "webpack": "^4.42.0", + "webpack-cli": "3.3.11", + "webpack-dev-server": "3.10.3", + "worker-loader": "2.0.0" + }, + "dependencies": { + "@babel/runtime": "^7.8.7", + "events": "^3.1.0", + "whatwg-fetch": "^3.0.0" + }, + "extendedDependencies": { + "@trezor/blockchain-link": "^1.0.10", + "@trezor/rollout": "^1.0.4", + "@trezor/utxo-lib": "^0.1.0", + "bchaddrjs": "0.4.7", + "bignumber.js": "^9.0.0", + "bowser": "^2.9.0", + "hd-wallet": "9.0.0", + "keccak": "^3.0.0", + "node-fetch": "^2.6.0", + "parse-uri": "^1.0.0", + "tiny-worker": "^2.3.0", + "trezor-link": "1.7.0" + } } diff --git a/scripts/s3sync.sh b/scripts/s3sync.sh new file mode 100755 index 000000000..93b0f13af --- /dev/null +++ b/scripts/s3sync.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# Before first use: +# Install awscli (pip install awscli) +# Configure access credentials (aws configure), region is "eu-central-1" + +# Usage: +# ./s3sync.sh DESTINATION SOURCE [clear] +# @DESTINATION: required, destination server +# @SOURCE: required, build +# @CLEAR: optional, delete previous uploads +# ./s3sync.sh stage beta +# ./s3sync.sh stage stable +# ./s3sync.sh stage stable clear +# ./s3sync.sh beta beta +# ./s3sync.sh stable stable + +function confirm { + read -r -p "Are you sure? [y/N] " response + if [[ $response =~ ^(yes|y)$ ]]; then + echo "let's go!" + else + exit 2 + fi +} + + +# Validate params +if [ "x$1" == "x" ] || [ "x$2" == "x" ]; then + echo "Invalid params" + echo "./s3sync.sh stage|beta|stable beta|stable [clear]" + exit 1 +fi + +# Validate destination param +if [ "x$1" != "xstage" ] && [ "x$1" != "xbeta" ] && [ "x$1" != "xstable" ]; then + echo "Invalid destination: "$1 + echo "use: stage|beta|stable" + exit 1 +fi + +# Validate source param +if [ "x$2" != "xbeta" ] && [ "x$2" != "xstable" ]; then + echo "Invalid source: "$2 + echo "use: beta|stable" + exit 1 +fi + +# Set source directory +if [ "x$2" == "xbeta" ]; then + SOURCE=../build/ + +elif [ "x$2" == "xstable" ]; then + SOURCE=../build/ +fi + +# Set destination +if [ "x$1" == "xstage" ]; then + BUCKET=stage.mytrezor.com + DISTRIBUTION_ID="E24M0QWO692FQL" +elif [ "x$1" == "xbeta" ]; then + BUCKET=beta.mytrezor.com + DISTRIBUTION_ID="E1PONNHWUNCQ9M" +elif [ "x$2" == "xstable" ]; then + BUCKET=wallet.mytrezor.com + DISTRIBUTION_ID="EZM01GFTITGVD" +fi + +echo "sync "$SOURCE" with "$BUCKET"/connect" + +if [ "x$1" == "xbeta" ] || [ "x$1" == "xstable" ]; then + confirm +fi + +set -e +cd `dirname $0` + +if [ "x$3" == "x-clear" ]; then + aws s3 sync --delete --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/connect +else + aws s3 sync --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/connect +fi + +aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/connect/*' + +echo "DONE" \ No newline at end of file