diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..e937f25 --- /dev/null +++ b/.babelrc @@ -0,0 +1,64 @@ +{ + "presets": [ + [ + "@babel/env", + { + "modules": false, + "targets": { + "browsers": [">0.25%"] + }, + "useBuiltIns": "usage" + } + ], + "@babel/typescript" + ], + "env": { + "development": { + "plugins": ["@babel/transform-runtime"] + }, + "production": { + "plugins": ["@babel/transform-runtime", "transform-remove-console"] + }, + "test": { + "presets": [ + [ + "@babel/env", + { + "modules": "commonjs", + "targets": { + "node": "current" + } + } + ], + "@babel/typescript" + ] + } + }, + "plugins": [ + "@babel/plugin-syntax-dynamic-import", + "@babel/plugin-syntax-import-meta", + "@babel/plugin-proposal-class-properties", + "@babel/plugin-proposal-json-strings", + [ + "@babel/plugin-proposal-decorators", + { + "legacy": true + } + ], + "@babel/plugin-proposal-function-sent", + "@babel/plugin-proposal-export-namespace-from", + "@babel/plugin-proposal-numeric-separator", + "@babel/plugin-proposal-throw-expressions", + "@babel/plugin-proposal-export-default-from", + "@babel/plugin-proposal-logical-assignment-operators", + "@babel/plugin-proposal-optional-chaining", + [ + "@babel/plugin-proposal-pipeline-operator", + { + "proposal": "minimal" + } + ], + "@babel/plugin-proposal-nullish-coalescing-operator", + "@babel/plugin-proposal-do-expressions" + ] +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c46f349 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ + + +# Development folders and files # +################################# +.tmp/ +node_modules/ +package.json +.travis.yml +*.md \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..bbaef00 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,15 @@ +{ + "parser": "typescript", + "printWidth": 80, + "singleQuote": true, + "trailingComma": "all", + "arrowParens": "always", + "overrides": [ + { + "files": "*.json", + "options": { + "parser": "json" + } + } + ] +} diff --git a/.tsconfig.base.json b/.tsconfig.base.json new file mode 100644 index 0000000..d95b11a --- /dev/null +++ b/.tsconfig.base.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "baseUrl": ".", + "composite": true, + "declaration": true, + "declarationMap": true, + "downlevelIteration": true, + "emitDecoratorMetadata": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "preserveConstEnums": true, + "importHelpers": true, + "lib": ["esnext", "dom"], + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "paths": { + "*": ["typings/*", "includes/*"] + }, + "resolveJsonModule": true, + "noUnusedLocals": true, + "strict": true, + "target": "es5" + } + } \ No newline at end of file diff --git a/.tsconfig.json b/.tsconfig.json new file mode 100644 index 0000000..c5369ea --- /dev/null +++ b/.tsconfig.json @@ -0,0 +1,4 @@ +{ + "files": [], + "references": [] +} diff --git a/.tsconfig.test.json b/.tsconfig.test.json new file mode 100644 index 0000000..af56bfc --- /dev/null +++ b/.tsconfig.test.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.base.json", + "files": [], + "include": ["./typings/**/*.d.ts"], + "references": [] +} diff --git a/package.json b/package.json index a2fb525..df92c8a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,92 @@ { - "name": "root", + "description": "Root repository for the harmony-sdk-core", "private": true, + "workspaces": [ + "packages/*" + ], + "scripts": { + "bootstrap": "lerna bootstrap && yarn build", + "build": "yarn build:proto && yarn build:ts", + "build:ts": "tsc -b tsconfig.json", + "bundle": "ts-node -P scripts/tsconfig.json scripts/bundle.ts umd,esm", + "clean": "lerna clean --yes && lerna run clean && rimraf includes", + "schema": "ts-node -P scripts/tsconfig.json scripts/schema.ts core", + "test": "cross-env TEST_ENV=unit jest -c jest.config.js --rootDir=.", + "test:build": "cross-env TEST_ENV=unit jest -c jest.build.config.js", + "test:integration": "cross-env TEST_ENV=integration jest -c jest.iconfig.js --runInBand --verbose --collectCoverage=false", + "release": "yarn bootstrap && yarn bundle && lerna publish --exact", + "format": "prettier --write '**/*.{ts,tsx,js}' --config .prettierrc" + }, "devDependencies": { - "lerna": "^3.2.1" + "@babel/cli": "^7.0.0-beta.56", + "@babel/core": "7.0.0-beta.54", + "@babel/plugin-proposal-class-properties": "7.0.0-beta.54", + "@babel/plugin-proposal-decorators": "7.0.0-beta.54", + "@babel/plugin-proposal-do-expressions": "7.0.0-beta.54", + "@babel/plugin-proposal-export-default-from": "7.0.0-beta.54", + "@babel/plugin-proposal-export-namespace-from": "7.0.0-beta.54", + "@babel/plugin-proposal-function-sent": "7.0.0-beta.54", + "@babel/plugin-proposal-json-strings": "7.0.0-beta.54", + "@babel/plugin-proposal-logical-assignment-operators": "7.0.0-beta.54", + "@babel/plugin-proposal-nullish-coalescing-operator": "7.0.0-beta.54", + "@babel/plugin-proposal-numeric-separator": "7.0.0-beta.54", + "@babel/plugin-proposal-optional-chaining": "7.0.0-beta.54", + "@babel/plugin-proposal-pipeline-operator": "7.0.0-beta.54", + "@babel/plugin-proposal-throw-expressions": "7.0.0-beta.54", + "@babel/plugin-syntax-dynamic-import": "7.0.0-beta.54", + "@babel/plugin-syntax-import-meta": "7.0.0-beta.54", + "@babel/plugin-transform-runtime": "^7.0.0-beta.56", + "@babel/polyfill": "7.0.0-beta.54", + "@babel/preset-env": "7.0.0-beta.54", + "@babel/preset-typescript": "^7.0.0-beta.56", + "@babel/runtime": "^7.0.0-beta.56", + "@trust/webcrypto": "^0.9.2", + "@types/bn.js": "^4.11.3", + "@types/camelcase": "^4.1.0", + "@types/fancy-log": "^1.3.0", + "@types/glob": "^7.1.1", + "@types/glob-parent": "^3.1.0", + "@types/jest": "^23.3.1", + "@types/jest-json-schema": "^1.2.0", + "@types/node": "^10.5.6", + "@types/uuid": "^3.4.4", + "@types/valid-url": "^1.0.2", + "@types/webpack": "^4.4.17", + "babel-core": "^7.0.0-bridge.0", + "babel-jest": "^23.4.2", + "babel-loader": "^8.0.0-beta.0", + "babel-plugin-transform-remove-console": "^6.9.4", + "camelcase": "^5.0.0", + "cross-env": "^5.2.0", + "dotenv": "^6.0.0", + "fancy-log": "^1.3.2", + "glob": "^7.1.3", + "glob-parent": "^3.1.0", + "husky": "^1.1.2", + "jest": "^23.4.2", + "jest-fetch-mock": "^1.6.6", + "jest-json-schema": "^2.0.1", + "jest-watch-typeahead": "^0.2.0", + "lerna": "^3.4.0", + "mkdirp": "^0.5.1", + "prettier": "^1.14.3", + "pretty-quick": "^1.8.0", + "protobufjs": "^6.8.8", + "rimraf": "^2.6.2", + "rollup": "^0.66.6", + "rollup-plugin-alias": "^1.4.0", + "rollup-plugin-commonjs": "^9.2.0", + "rollup-plugin-json": "^3.1.0", + "rollup-plugin-node-globals": "^1.4.0", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-typescript2": "^0.17.1", + "ts-jest": "^23.1.3", + "ts-node": "^7.0.1", + "tslint": "^5.11.0", + "tslint-config-prettier": "^1.15.0", + "typescript": "^3.2", + "typescript-json-schema": "^0.32.0", + "webpack": "^4.20.2", + "webpack-command": "^0.4.1" } } diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..c27bf70 --- /dev/null +++ b/tslint.json @@ -0,0 +1,23 @@ +{ + "extends": ["tslint:latest", "tslint-config-prettier"], + "rules": { + "interface-name": [true, "never-prefix"], + "member-access": false, + "no-angle-bracket-type-assertion": false, + "no-bitwise": false, + "no-console": false, + "no-default-export": true, + "no-empty-interface": false, + "no-implicit-dependencies": true, + "no-submodule-imports": false, + "ordered-imports": [false], + "object-literal-sort-keys": false, + "object-literal-key-quotes": [true, "as-needed"], + "quotemark": [true, "single"], + "semicolon": [true, "always", "ignore-bound-class-methods"], + "jsx-boolean-value": false + }, + "linterOptions": { + "exclude": ["config/**/*.js", "node_modules/**/*.ts"] + } +}