Skip to content

Commit

Permalink
BG-11181: Typescript
Browse files Browse the repository at this point in the history
* Convert all source files from *.js to *.ts
* Set up eslint for typescript
* Configure prettier and precise-commits
* Add node 11 unit test run
* Update package entry point to built version
* Use Terser instead of Uglify for js minification
* Update webpack config for typescript
* Bump major version
* Remove unnecessary dependencies and files
* Move sjcl.min.js to src/vendor/
* Fix testing scripts to run all tests
* Require built version of expressApp from express entry point
* Copy sjcl.min.js to dist/src/vendor after running tsc
* Update drone config for typescript
* Lint test files, allow lint failures for tests
* Remove .travis.yml
* Remove asserts from non-test code
* Remove karma
  • Loading branch information
Tyler Levine committed Mar 25, 2019
1 parent a3d79f4 commit eea678a
Show file tree
Hide file tree
Showing 144 changed files with 3,724 additions and 3,817 deletions.
4 changes: 0 additions & 4 deletions .arcconfig

This file was deleted.

26 changes: 0 additions & 26 deletions .arclint

This file was deleted.

14 changes: 9 additions & 5 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local branches() = {
branch: [
"master",
"rel/*",
"prod/production"
"prod/production",
],
};

Expand Down Expand Up @@ -32,8 +32,9 @@ local UploadCoverage(version, tag="untagged", limit_branches=true) = {
CODECOV_TOKEN: { from_secret: "codecov" },
},
commands: [
"npx nyc report --reporter=text-lcov > coverage.lcov",
"npx codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F " + tag,
"npm install -g codecov",
"node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov",
"codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F " + tag,
],
[if limit_branches then "when"]: branches(),
};
Expand Down Expand Up @@ -71,7 +72,7 @@ local IntegrationTest(version, limit_branches=true) = {
BITGOJS_TEST_PASSWORD: { from_secret: "password" },
},
commands: [
"npx nyc -- node_modules/.bin/mocha --timeout 20000 --reporter list --exit --recursive test/v2/integration",
"npx nyc -- node_modules/.bin/mocha -r ts-node/register --timeout 20000 --reporter list --exit 'test/v2/integration/**/*.ts'",
],
[if limit_branches then "when"]: branches(),
},
Expand Down Expand Up @@ -100,15 +101,18 @@ local IntegrationTest(version, limit_branches=true) = {
name: "lint",
steps: [
BuildInfo("lts"),
Install("lts"),
{
name: "lint",
image: "node:lts",
commands: [
"npx eslint 'src/**/*.js'",
"npx eslint 'src/**/*.ts'",
"npx eslint 'test/**/*.ts' || true"
],
},
],
},
UnitTest("6"),
UnitTest("8"),
UnitTest("9"),
UnitTest("10"),
Expand Down
78 changes: 66 additions & 12 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,59 @@ steps:
- node --version
- npm --version

- name: install
image: node:lts
commands:
- npm install

- name: lint
image: node:lts
commands:
- "npx eslint 'src/**/*.js'"
- "npx eslint 'src/**/*.ts'"
- "npx eslint 'test/**/*.ts' || true"

---
kind: pipeline
name: unit tests (node:6)

platform:
os: linux
arch: amd64

steps:
- name: build information
image: node:6
commands:
- node --version
- npm --version

- name: install
image: node:6
commands:
- npm install

- name: unit tests
image: node:6
commands:
- npm run test-node
environment:
BITGOJS_TEST_PASSWORD:
from_secret: password

- name: upload coverage
image: node:6
commands:
- npm install -g codecov
- "node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov"
- "codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
environment:
CODECOV_TOKEN:
from_secret: codecov
when:
branch:
- master
- "rel/*"
- prod/production

---
kind: pipeline
Expand Down Expand Up @@ -74,8 +123,9 @@ steps:
- name: upload coverage
image: node:8
commands:
- "npx nyc report --reporter=text-lcov > coverage.lcov"
- "npx codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
- npm install -g codecov
- "node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov"
- "codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
environment:
CODECOV_TOKEN:
from_secret: codecov
Expand Down Expand Up @@ -116,8 +166,9 @@ steps:
- name: upload coverage
image: node:9
commands:
- "npx nyc report --reporter=text-lcov > coverage.lcov"
- "npx codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
- npm install -g codecov
- "node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov"
- "codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
environment:
CODECOV_TOKEN:
from_secret: codecov
Expand Down Expand Up @@ -158,8 +209,9 @@ steps:
- name: upload coverage
image: node:10
commands:
- "npx nyc report --reporter=text-lcov > coverage.lcov"
- "npx codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
- npm install -g codecov
- "node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov"
- "codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
environment:
CODECOV_TOKEN:
from_secret: codecov
Expand Down Expand Up @@ -200,8 +252,9 @@ steps:
- name: upload coverage
image: node:11
commands:
- "npx nyc report --reporter=text-lcov > coverage.lcov"
- "npx codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
- npm install -g codecov
- "node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov"
- "codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F unit"
environment:
CODECOV_TOKEN:
from_secret: codecov
Expand Down Expand Up @@ -244,7 +297,7 @@ steps:
- name: integration tests
image: node:10
commands:
- npx nyc -- node_modules/.bin/mocha --timeout 20000 --reporter list --exit --recursive test/v2/integration
- "npx nyc -- node_modules/.bin/mocha -r ts-node/register --timeout 20000 --reporter list --exit 'test/v2/integration/**/*.ts'"
environment:
BITGOJS_TEST_PASSWORD:
from_secret: password
Expand All @@ -257,8 +310,9 @@ steps:
- name: upload coverage
image: node:10
commands:
- "npx nyc report --reporter=text-lcov > coverage.lcov"
- "npx codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F integration"
- npm install -g codecov
- "node_modules/.bin/nyc report --reporter=text-lcov > coverage.lcov"
- "codecov -f coverage.lcov -t \"$CODECOV_TOKEN\" -F integration"
environment:
CODECOV_TOKEN:
from_secret: codecov
Expand Down
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
.idea
public
src/sjcl.min.js
src/vendor/sjcl.min.js
dist
browser
22 changes: 17 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@
"node": true,
"mocha": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"globals": {
"app": true, // BitGo side-effect from testutil
"ethUtil": true, // BitGo side-effect from testutil
"requireCommon": true
},
//"extends": "eslint:recommended", //possibly to be added in the future
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": 6
"ecmaVersion": 6,
"project": "./tsconfig.json"
},
"rules": {
"indent": ["error", 2, {"SwitchCase": 1, "MemberExpression": 0}],
"indent": ["warn", 2, {"SwitchCase": 1, "MemberExpression": 0}],
"linebreak-style": ["error", "unix"],
"semi": ["error", "always"],
"eqeqeq": ["warn", "always"],
Expand Down Expand Up @@ -56,7 +63,7 @@
"no-extra-semi": "error",
"radix": "error",
"comma-spacing": ["error", { "before": false, "after": true }],
"comma-dangle": ["error", "never"],
"comma-dangle": ["warn", "never"],
"no-multi-spaces": ["error", {"ignoreEOLComments": true}],
"keyword-spacing": ["error"],
"space-before-blocks": ["error"],
Expand All @@ -68,6 +75,11 @@
"space-before-function-paren": ["error", "never"],
"no-mixed-spaces-and-tabs": "error",
"no-dupe-keys": "error",
"no-redeclare": ["error", { "builtinGlobals": true }]
"no-redeclare": ["error", { "builtinGlobals": true }],
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/camelcase": "warn",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-function-return-type": "off"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ example/eth/test.js
*.iml
.nyc_output/
coverage.lcov
dist/
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine-strict=true
save-exact=true
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.json
*.yml
5 changes: 5 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
printWidth: 120
singleQuote: true
trailingComma: "es5"
requirePragma: true
insertPragma: true
13 changes: 0 additions & 13 deletions Dockerrun.aws.json

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Please join us on our [Slack channel](https://bitgodevs.slack.com) if you have q

# Installation

Please make sure you are running at least Node version 6 (`6.12.3` recommended) and NPM version 3 (`3.10.10` recommended).
Please make sure you are running at least Node version 8 (the latest LTS release is recommended) and NPM version 6.
We recommend using `nvm`, the [Node Version Manager](https://github.com/creationix/nvm/blob/master/README.markdown#installation), for setting your Node version.

`git clone https://github.com/BitGo/BitGoJS`
Expand Down
4 changes: 0 additions & 4 deletions TODO

This file was deleted.

2 changes: 1 addition & 1 deletion bin/bitgo-express
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const Promise = require('bluebird');

const { app, parseArgs, createBaseUri, createServer, startup } = require('../src/expressApp');
const { app, parseArgs, createBaseUri, createServer, startup } = require('../dist/src/expressApp');

if (require.main === module) {
(Promise.coroutine(function *main() {
Expand Down
Loading

0 comments on commit eea678a

Please sign in to comment.