Skip to content

Commit

Permalink
Re-factor build scripts to TypeScript (#202)
Browse files Browse the repository at this point in the history
* Re-factor scripts for building, development, linting, and cleaning to TypeScript

* Remove remnants of old test runner (ava)

* Re-factor scripts for unit testing to TypeScript

* Small cleanups

* Refactor to merge `ViewController` and `PayloadTransport` classes (#203)

* (feat): Added 'web3-core' package v1.5.2  to import the new AbstractProvider Type

* (feat): fix #83

* First step to refactoring 'PayloadTransport' into 'ViewController'

* Fix remaining tests

* Update 'peerDependencies' for @magic-sdk/commons

* Fix clean script

Co-authored-by: Adenekan Wonderful <[email protected]>

* Make script code more DRY

* Update TypeScript & make scripts more DRY

* Fix typo and add 'printSeparator' script utility

* Fix 'inject-env.ts' script following re-organization of code

* Remove outdated / unused dependencies from root PackageJSON

* Progress towards integrating microbundle

* Update build scripts to bundle all packages via microbundle

* Remove unnecessary console statement

* Run pre-commit hooks against all packages

* Add more memory for tasks spawned via 'wsrun'

* Raise the resource class in CI

* Try to fix ENOMEM errors in CI by limiting concurrency

* Replace 'p-limit' dependency with prior version (new version is ESM-only)

* Better caching in CircleCI

* Update test script to work with Yarn 2

* Fix tests related to ViewController refactor

* Reduce the CircleCI resource class back to medium

* Fix tests related to ViewController refactor

Co-authored-by: Adenekan Wonderful <[email protected]>
  • Loading branch information
smithki and adenekan41 authored Sep 10, 2021
1 parent 8de947d commit 608c423
Show file tree
Hide file tree
Showing 118 changed files with 23,398 additions and 17,799 deletions.
28 changes: 15 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ aliases: [
# CircleCI workspace.
&dependency-paths [
"node_modules",
"packages/@magic-sdk/commons/node_modules",
"packages/@magic-sdk/provider/node_modules",
"packages/@magic-sdk/react-native/node_modules",
"packages/@magic-sdk/types/node_modules",
"packages/magic-sdk/node_modules"
"packages/@magic-sdk/*/node_modules",
"packages/*/node_modules",
],

# List of Yarn cache paths that should be persisted to the
# CircleCI workspace cache.
&yarn-cache-paths [
".yarn/cache",
".yarn/unplugged",
],

# List of build output paths that should be persisted to the
# CircleCI workspace.
&build-output-paths [
"packages/@magic-sdk/commons/dist",
"packages/@magic-sdk/provider/dist",
"packages/@magic-sdk/react-native/dist",
"packages/@magic-sdk/types/dist",
"packages/magic-sdk/dist"
"packages/@magic-sdk/*/dist",
"packages/*/dist",
],

# NPM lockfile cache key (update "vN" => "vN+1" to cache-bust).
# Yarn lockfile cache key (update "vN" => "vN+1" to cache-bust).
&dependency-cache-key "v3-dependency-cache-{{ checksum \"yarn.lock\" }}",

&workspace-root "/home/circleci/project",
Expand Down Expand Up @@ -63,6 +64,7 @@ executors:
default:
docker:
- image: circleci/node:14.17.0-browsers
resource_class: medium

# --- Job definitions -------------------------------------------------------- #

Expand All @@ -80,7 +82,7 @@ jobs:
name: Install Module Dependencies
command: yarn install
- save_cache:
paths: *dependency-paths
paths: *yarn-cache-paths
key: *dependency-cache-key
- persist_to_workspace:
paths: *dependency-paths
Expand All @@ -105,7 +107,7 @@ jobs:
- run:
name: Apply semver updates (if any)
command: |
AUTO_VERSION=$(yarn --silent auto version)
AUTO_VERSION=$(yarn auto version)
if [[ $AUTO_VERSION ]]; then
yarn lerna version $(echo $AUTO_VERSION) --no-git-tag-version --yes
fi
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
**/node_modules
**/coverage
**/dist
**/.eslintrc.js
**/jest.config.ts
**/babel.config.js
42 changes: 24 additions & 18 deletions .eslintrc → .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
{
"root": true,
module.exports = {
root: true,

"extends": ["@ikscodes/eslint-config"],
extends: ["@ikscodes/eslint-config"],

"rules": {
"import/extensions": 0,
rules: {
// ESLint rules
"no-alert": 0,
"@typescript-eslint/await-thenable": 0,
"no-underscore-dangle": 0,
"no-useless-constructor": 0,
"@typescript-eslint/no-useless-constructor": 0,
"@typescript-eslint/no-empty-function": 0,
"class-methods-use-this": 0,

// Import rules
"import/extensions": 0,
"import/no-extraneous-dependencies": 0,

// TypeScript rules
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/no-unsafe-call": 0,
"@typescript-eslint/await-thenable": 0,
"@typescript-eslint/no-unsafe-return": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-floating-promises": 0,
"@typescript-eslint/no-unsafe-assignment": 0,
"@typescript-eslint/no-useless-constructor": 0,
"@typescript-eslint/no-unsafe-member-access": 0,
"@typescript-eslint/no-floating-promises": 0,
"@typescript-eslint/no-unsafe-call": 0,
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/restrict-template-expressions": 0,
"class-methods-use-this": 0,
"import/no-extraneous-dependencies": 0
},

"settings": {
settings: {
"import/resolver": {
"typescript": {
"directory": ["**/tsconfig.json"]
}
}
}
"directory": ["**/tsconfig.json"],
},
},
},
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
/package-lock.json
/**/package-lock.json
/**/yarn-error.log
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# Output files
/**/dist
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn wsrun --concurrency 1 --changedSince HEAD -c lint-staged
yarn wsrun:all --concurrency 1 --changedSince HEAD -c lint-staged
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

631 changes: 631 additions & 0 deletions .yarn/releases/yarn-berry.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
nmHoistingLimits: workspaces

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: ./.yarn/releases/yarn-berry.js
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ To ensure ESLint is able to properly lint source files in your VS Code developme
| ---------- | ----- | ----------- |
| `bootstrap` | `yarn bootstrap` | Install dependencies/set up a local development environment. |
| `wsrun` | `PKG=$PACKAGE_TARGET yarn wsrun` | Execute arbitrary scripts via `wsrun` for the specified package. |
| `wsrun:paths` | `PKG=$PACKAGE_TARGET yarn paths` | Print the relative paths to each project based on the value of `$PKG`. |
| `dev` | `PKG=$PACKAGE_TARGET yarn dev` | Start the specified package in development mode. |
| `build` | `PKG=$PACKAGE_TARGET yarn build` | Build the specified package for production, or all packages if `$PKG` is omitted. |
| `clean` | `PKG=$PACKAGE_TARGET yarn clean` | Run cleaning scripts for the specified package, or all packages if `$PKG` is omitted. Available flags: (`--cache`, `--test-artifacts`, `--deps`) |
| `lint` | `PKG=$PACKAGE_TARGET yarn lint` | Run the linter for the specified package, or all packages if `$PKG` is omitted. |
| `test` | `PKG=$PACKAGE_TARGET yarn test` | Run tests for the specified package, or all packages if `$PKG` is omitted. |
| `paths` | `PKG=$PACKAGE_TARGET yarn paths` | Print the relative paths to each project based on the value of `$PKG`. |

## Opening a Pull Request

Expand Down
2 changes: 0 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"packages": ["packages/@magic-sdk/*", "packages/magic-sdk"],
"workspaces": ["packages/@magic-sdk/*", "packages/magic-sdk"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true
Expand Down
56 changes: 30 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,72 @@
"name": "magic-sdk-monorepo",
"version": "0.0.0",
"scripts": {
"bootstrap": "yarn install && lerna link",
"wsrun": "wsrun --bin $INIT_CWD/scripts/wsrun/runner.sh -p $PKG",
"dev": "$INIT_CWD/scripts/clean.sh && $INIT_CWD/scripts/dev.sh",
"build": "$INIT_CWD/scripts/clean.sh && $INIT_CWD/scripts/build.sh",
"clean": "$INIT_CWD/scripts/clean.sh",
"lint": "$INIT_CWD/scripts/lint.sh",
"test": "$INIT_CWD/scripts/test.sh",
"paths": "yarn --silent wsrun --parallel --no-prefix -r -c $INIT_CWD/scripts/wsrun/resolve-paths.ts",
"postinstall": "husky install"
"wsrun": "$INIT_CWD/scripts/bin/wsrun-wrapper.ts",
"wsrun:all": "$INIT_CWD/scripts/bin/wsrun-wrapper.ts --all",
"wsrun:paths": "yarn wsrun --stages --no-prefix -r -c $INIT_CWD/scripts/bin/wsrun/resolve-paths.ts",
"dev": "$INIT_CWD/scripts/bin/clean.ts && $INIT_CWD/scripts/bin/dev.ts",
"build": "$INIT_CWD/scripts/bin/clean.ts && $INIT_CWD/scripts/bin/build.ts",
"clean": "$INIT_CWD/scripts/bin/clean.ts",
"lint": "$INIT_CWD/scripts/bin/lint.ts",
"test": "$INIT_CWD/scripts/bin/test.ts",
"postinstall": "husky install && lerna link"
},
"devDependencies": {
"@ikscodes/browser-env": "~0.3.1",
"@ikscodes/eslint-config": "~7.0.0",
"@ikscodes/prettier-config": "~2.0.0",
"@ikscodes/eslint-config": "~7.0.2",
"@ikscodes/prettier-config": "~2.0.1",
"@istanbuljs/nyc-config-typescript": "~0.1.3",
"@types/inquirer": "^8.1.1",
"@types/is-ci": "^3.0.0",
"@types/jest": "^27.0.0",
"@types/jsdom": "~12.2.4",
"@types/lodash": "^4.14.172",
"@types/react": "^16.9.34",
"@types/react-native": "^0.62.2",
"@types/rimraf": "^3.0.2",
"@types/tsc-watch": "^4.2.0",
"@types/whatwg-url": "^6.4.0",
"@typescript-eslint/eslint-plugin": "~3.4.0",
"auto": "^10.31.0",
"ava": "3.11.0",
"boxen-cli": "^1.0.0",
"chalk": "~4.1.2",
"eslint": "~7.3.1",
"eslint-import-resolver-typescript": "~2.0.0",
"eslint-plugin-import": "~2.21.0",
"eslint-plugin-jsx-a11y": "~6.3.1",
"eslint-plugin-prettier": "~3.1.4",
"eslint-plugin-react": "~7.20.0",
"eslint-plugin-react-hooks": "~4.0.4",
"find-glob": "^2.1.0",
"glob": "^7.1.6",
"execa": "~5.1.1",
"husky": "^7.0.1",
"inquirer": "^8.1.2",
"is-ci": "^3.0.0",
"jest": "^27.0.6",
"lerna": "^3.21.0",
"lint-staged": "^10.0.7",
"microbundle": "0.12.0",
"lodash": "^4.17.21",
"meow": "9.0.0",
"microbundle": "0.13.3",
"npm-run-all": "^4.1.5",
"nyc": "13.1.0",
"prettier": "~2.0.5",
"ora": "~5.4.1",
"p-limit": "^3.1.0",
"prettier": "~2.3.2",
"react": "^16.13.1",
"react-native": "^0.62.2",
"regenerator-runtime": "0.13.9",
"replace-in-file": "^6.1.0",
"rimraf": "~3.0.0",
"rimraf": "~3.0.2",
"ts-jest": "^27.0.4",
"ts-node": "^10.2.0",
"tsc-watch": "^4.2.9",
"typed-emitter": "^1.0.0",
"typescript": "~3.8.3",
"tslib": "^2.3.1",
"typescript": "~4.4.2",
"wsrun": "^5.2.1"
},
"workspaces": {
"packages": [
"packages/@magic-sdk/*",
"packages/magic-sdk"
],
"nohoist": [
"@magic-sdk/react-native/buffer",
"@magic-sdk/react-native/buffer/**",
"@magic-sdk/react-native/process",
"@magic-sdk/react-native/process/**"
]
},
"repository": "magiclabs/magic-js",
Expand Down
1 change: 1 addition & 0 deletions packages/@magic-sdk/commons/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/coverage
/dist
/.eslintrc.js
/jest.config.ts
2 changes: 1 addition & 1 deletion packages/@magic-sdk/commons/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['../../../.eslintrc'],
extends: ['../../../.eslintrc.js'],
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
Expand Down
15 changes: 9 additions & 6 deletions packages/@magic-sdk/commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
"dist/**/*.d.ts"
],
"target": "web",
"main": "dist/cjs/index.js",
"module": "dist/es/index.js",
"types": "dist/es/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"types": "./dist/types/index.d.ts",
"devDependencies": {
"@magic-sdk/provider": ">=4.3.0",
"@magic-sdk/types": ">=3.1.1"
},
"peerDependencies": {
"@magic-sdk/provider": "^4.3.0",
"@magic-sdk/types": "^3.1.1",
"tslib": "^2.0.3"
"@magic-sdk/provider": ">=4.3.0",
"@magic-sdk/types": ">=3.1.1"
},
"gitHead": "1ef062ea699d48d5e9a9375a93b7c147632b05ca"
}
18 changes: 0 additions & 18 deletions packages/@magic-sdk/commons/tsconfig.cjs.json

This file was deleted.

7 changes: 4 additions & 3 deletions packages/@magic-sdk/commons/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"extends": "../../../tsconfig.settings.json",

"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist/es"
"rootDir": "src",
"outDir": "dist/es",
"declarationDir": "dist/types",
},

"include": [
"./src/**/*.ts",
"src/**/*.ts",
],

"references": [
Expand Down
1 change: 1 addition & 0 deletions packages/@magic-sdk/provider/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
/coverage
/dist
/.eslintrc.js
/jest.config.ts
2 changes: 1 addition & 1 deletion packages/@magic-sdk/provider/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['../../../.eslintrc'],
extends: ['../../../.eslintrc.js'],
parserOptions: {
project: ['./tsconfig.json', './test/tsconfig.json'],
tsconfigRootDir: __dirname,
Expand Down
Loading

0 comments on commit 608c423

Please sign in to comment.