diff --git a/.eslintignore b/.eslintignore index 4c57cab02..a89715365 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,5 +6,6 @@ distribution node_modules LICENSE CODE_OF_CONDUCT.md +scripts packages/p2p/source/hapi-nes diff --git a/.github/workflows/deps.yml b/.github/workflows/deps.yml new file mode 100644 index 000000000..337799f9a --- /dev/null +++ b/.github/workflows/deps.yml @@ -0,0 +1,52 @@ +jobs: + source: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + run_install: false + version: latest + - name: Get pnpm store directory + id: pnpm-cache + run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + shell: bash + - name: Cache pnpm modules + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + restore-keys: ${{ runner.os }}-pnpm- + - name: Cache lerna + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-lerna + path: ./.cache + restore-keys: ${{ runner.os }}-lerna- + - name: Install dependencies + run: pnpm install + - name: Build + run: pnpm run build + - name: Check dependencies + run: pnpm run deps:check + strategy: + matrix: + node-version: + - 20.x +name: Dependencies +on: + pull_request: + types: + - ready_for_review + - synchronize + - opened + push: + branches: + - main + - develop diff --git a/package.json b/package.json index 496696389..1547db1be 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,8 @@ "clean:all": "pnpm run clean && pnpm run clean:node_modules && rm -r .cache", "clean:node_modules": "del packages/*/node_modules && del node_modules", "deps": "cross-env-shell ./scripts/deps/update.sh", - "deps:missing": "node ./scripts/deps/missing.js", + "deps:check": "node ./scripts/deps/check.js", "deps:types": "./node_modules/typesync/bin/typesync", - "deps:unused": "node ./scripts/deps/unused.js", "docker": "node ./scripts/docker/generate-docker.js", "format": "pnpm run lint && pnpm run prettier", "lint": "eslint packages/*/source --ext .ts --ignore-pattern *.test.ts --fix", diff --git a/packages/api-database/package.json b/packages/api-database/package.json index de7a7a6e3..6c3729987 100644 --- a/packages/api-database/package.json +++ b/packages/api-database/package.json @@ -24,10 +24,8 @@ "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", "dayjs": "1.11.10", "pg": "8.11.3", - "reflect-metadata": "0.2.0", "typeorm": "0.3.17" }, "devDependencies": { diff --git a/packages/api-development/package.json b/packages/api-development/package.json index 88ccfb800..e2a2e01b4 100644 --- a/packages/api-development/package.json +++ b/packages/api-development/package.json @@ -22,20 +22,15 @@ "dependencies": { "@hapi/boom": "10.0.1", "@hapi/hapi": "21.3.2", - "@hapi/hoek": "11.0.4", "@mainsail/api-common": "workspace:*", "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/transactions": "workspace:*", - "@mainsail/utils": "workspace:*", "joi": "17.11.0", - "nanomatch": "1.2.13", - "rate-limiter-flexible": "3.0.6", "semver": "7.5.4" }, "devDependencies": { - "@types/ip": "1.1.3", "@types/semver": "7.5.6", "uvu": "^0.5.6" }, diff --git a/packages/api-http/package.json b/packages/api-http/package.json index 565c9b1ef..384e4293f 100644 --- a/packages/api-http/package.json +++ b/packages/api-http/package.json @@ -24,7 +24,6 @@ "dependencies": { "@hapi/boom": "10.0.1", "@hapi/hapi": "21.3.2", - "@hapi/hoek": "11.0.4", "@mainsail/api-common": "workspace:*", "@mainsail/api-database": "workspace:*", "@mainsail/container": "workspace:*", @@ -32,9 +31,7 @@ "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", "dayjs": "1.11.10", - "joi": "17.11.0", - "nanomatch": "1.2.13", - "rate-limiter-flexible": "3.0.6" + "joi": "17.11.0" }, "devDependencies": { "@types/ip": "1.1.3", diff --git a/packages/api-transaction-pool/package.json b/packages/api-transaction-pool/package.json index 4ea84ec4b..93ae3836e 100644 --- a/packages/api-transaction-pool/package.json +++ b/packages/api-transaction-pool/package.json @@ -22,23 +22,15 @@ "dependencies": { "@hapi/boom": "10.0.1", "@hapi/hapi": "21.3.2", - "@hapi/hoek": "11.0.4", "@mainsail/api-common": "workspace:*", - "@mainsail/api-database": "workspace:*", "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", - "@mainsail/transactions": "workspace:*", - "@mainsail/utils": "workspace:*", - "dayjs": "1.11.10", - "joi": "17.11.0", - "nanomatch": "1.2.13", - "rate-limiter-flexible": "3.0.6" + "joi": "17.11.0" }, "devDependencies": { "@types/ip": "1.1.3", "@types/semver": "7.5.6", - "got": "11.8.6", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/api/package.json b/packages/api/package.json index d6750aec9..a1e87e64b 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -29,31 +29,31 @@ "@mainsail/api-database": "workspace:*", "@mainsail/api-http": "workspace:*", "@mainsail/cli": "workspace:*", - "@mainsail/configuration-generator": "workspace:*", "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/logger-pino": "workspace:*", - "@mainsail/test-framework": "workspace:*", "@mainsail/utils": "workspace:*", "boxen": "4.2.0", - "cross-env": "7.0.3", "dayjs": "1.11.10", "envfile": "7.0.0", - "execa": "5.1.1", "fs-extra": "11.2.0", "joi": "17.11.0", - "kleur": "4.1.5", - "prompts": "2.4.2", - "tmp": "0.2.1", - "uvu": "^0.5.6" + "kleur": "4.1.5" }, "devDependencies": { + "@mainsail/test-framework": "workspace:*", "@types/boxen": "3.0.1", "@types/execa": "2.0.0", "@types/fs-extra": "11.0.4", "@types/prompts": "2.4.9", - "@types/tmp": "0.2.6" + "@types/tmp": "0.2.6", + "cross-env": "7.0.3", + "env-paths": "2.2.1", + "execa": "5.1.1", + "prompts": "2.4.2", + "tmp": "0.2.1", + "uvu": "^0.5.6" }, "peerDependencies": { "pm2": "^5.3.0" diff --git a/packages/configuration-generator/package.json b/packages/configuration-generator/package.json index 9ae1b8983..7a04a3ab4 100644 --- a/packages/configuration-generator/package.json +++ b/packages/configuration-generator/package.json @@ -49,7 +49,6 @@ "@mainsail/validation": "workspace:*", "bip39": "3.1.0", "dayjs": "1.11.10", - "env-paths": "2.2.1", "envfile": "7.0.0", "fs-extra": "11.2.0" }, @@ -57,6 +56,7 @@ "@types/env-paths": "2.1.0", "@types/fs-extra": "11.0.4", "@types/tmp": "0.2.6", + "env-paths": "2.2.1", "tmp": "0.2.1", "uvu": "^0.5.6" }, diff --git a/packages/consensus/package.json b/packages/consensus/package.json index d1b4fc4f7..1dbc3bd99 100644 --- a/packages/consensus/package.json +++ b/packages/consensus/package.json @@ -23,15 +23,11 @@ "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", "dayjs": "1.11.10", - "delay": "5.0.0", "lmdb": "2.9.2" }, "devDependencies": { "@mainsail/test-framework": "workspace:*", - "@types/delay": "3.1.0", - "@types/seedrandom": "^3.0.8", "rewiremock": "3.14.5", "uvu": "^0.5.6" }, diff --git a/packages/container/package.json b/packages/container/package.json index 6dd6ff196..0eeaf6e20 100644 --- a/packages/container/package.json +++ b/packages/container/package.json @@ -21,7 +21,9 @@ }, "dependencies": { "inversify": "6.0.2", - "reflect-metadata": "0.2.0", + "reflect-metadata": "0.2.0" + }, + "devDependencies": { "uvu": "^0.5.6" }, "engines": { diff --git a/packages/core/package.json b/packages/core/package.json index b19068581..d7cdc0547 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -80,7 +80,6 @@ "@mainsail/proposer": "workspace:*", "@mainsail/serializer": "workspace:*", "@mainsail/state": "workspace:*", - "@mainsail/test-framework": "workspace:*", "@mainsail/transaction-pool": "workspace:*", "@mainsail/transactions": "workspace:*", "@mainsail/utils": "workspace:*", @@ -91,25 +90,26 @@ "@mainsail/webhooks": "workspace:*", "bip39": "3.1.0", "boxen": "4.2.0", - "cross-env": "7.0.3", "dayjs": "1.11.10", "env-paths": "2.2.1", "envfile": "7.0.0", - "execa": "5.1.1", "fs-extra": "11.2.0", "joi": "17.11.0", "kleur": "4.1.5", - "prompts": "2.4.2", - "tmp": "0.2.1", - "uvu": "^0.5.6" + "prompts": "2.4.2" }, "devDependencies": { + "@mainsail/test-framework": "workspace:*", "@types/boxen": "3.0.1", "@types/env-paths": "2.1.0", "@types/execa": "2.0.0", "@types/fs-extra": "11.0.4", "@types/prompts": "2.4.9", - "@types/tmp": "0.2.6" + "@types/tmp": "0.2.6", + "cross-env": "7.0.3", + "execa": "5.1.1", + "tmp": "0.2.1", + "uvu": "^0.5.6" }, "peerDependencies": { "pm2": "^5.3.0" diff --git a/packages/crypto-address-keccak256/package.json b/packages/crypto-address-keccak256/package.json index cbb026fd4..035f5312e 100644 --- a/packages/crypto-address-keccak256/package.json +++ b/packages/crypto-address-keccak256/package.json @@ -22,12 +22,12 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", "ethers": "^6.9.0" }, "devDependencies": { + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-key-pair-ecdsa": "workspace:*", "@mainsail/crypto-key-pair-schnorr": "workspace:*", "@mainsail/crypto-validation": "workspace:*", diff --git a/packages/crypto-block/package.json b/packages/crypto-block/package.json index e69cd9889..75b0a21a0 100644 --- a/packages/crypto-block/package.json +++ b/packages/crypto-block/package.json @@ -22,17 +22,17 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-transaction": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", - "@mainsail/validation": "workspace:*", "ajv": "8.12.0" }, "devDependencies": { "@mainsail/crypto-address-bech32m": "workspace:*", + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-key-pair-schnorr": "workspace:*", "@mainsail/crypto-validation": "workspace:*", + "@mainsail/validation": "workspace:*", "@types/lodash.clone": "^4.5.9", "lodash.clone": "^4.5.0", "uvu": "^0.5.6" diff --git a/packages/crypto-commit/package.json b/packages/crypto-commit/package.json index dcfd894d4..b08bf51b4 100644 --- a/packages/crypto-commit/package.json +++ b/packages/crypto-commit/package.json @@ -22,15 +22,10 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-block": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", - "ajv": "8.12.0" + "@mainsail/utils": "workspace:*" }, "devDependencies": { - "@mainsail/crypto-validation": "workspace:*", - "@mainsail/validation": "workspace:*", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/crypto-consensus-bls12-381/package.json b/packages/crypto-consensus-bls12-381/package.json index ba84c3af8..4c27d335b 100644 --- a/packages/crypto-consensus-bls12-381/package.json +++ b/packages/crypto-consensus-bls12-381/package.json @@ -24,13 +24,7 @@ "@mainsail/contracts": "workspace:*", "@mainsail/crypto-key-pair-bls12-381": "workspace:*", "@mainsail/crypto-signature-bls12-381": "workspace:*", - "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", - "ajv": "8.12.0", - "dayjs": "1.11.10", - "inversify": "6.0.2", - "reflect-metadata": "0.2.0", - "type-fest": "4.8.3" + "@mainsail/kernel": "workspace:*" }, "devDependencies": { "uvu": "^0.5.6" diff --git a/packages/crypto-key-pair-bls12-381/package.json b/packages/crypto-key-pair-bls12-381/package.json index 5342f963b..533049524 100644 --- a/packages/crypto-key-pair-bls12-381/package.json +++ b/packages/crypto-key-pair-bls12-381/package.json @@ -23,7 +23,6 @@ "@chainsafe/blst": "^0.2.9", "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", "@scure/bip39": "^1.2.1", @@ -31,6 +30,7 @@ "wif": "^4.0.0" }, "devDependencies": { + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", "@types/wif": "^2.0.5", diff --git a/packages/crypto-key-pair-ecdsa/package.json b/packages/crypto-key-pair-ecdsa/package.json index e20be3451..13e39a862 100644 --- a/packages/crypto-key-pair-ecdsa/package.json +++ b/packages/crypto-key-pair-ecdsa/package.json @@ -22,13 +22,13 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", "bcrypto": "5.5.2", "wif": "^4.0.0" }, "devDependencies": { + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", "@types/wif": "^2.0.5", diff --git a/packages/crypto-key-pair-ed25519/package.json b/packages/crypto-key-pair-ed25519/package.json index 2b55d1800..2db50cece 100644 --- a/packages/crypto-key-pair-ed25519/package.json +++ b/packages/crypto-key-pair-ed25519/package.json @@ -22,7 +22,6 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", "@noble/ed25519": "^2.0.0", @@ -31,6 +30,7 @@ "wif": "^4.0.0" }, "devDependencies": { + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", "@types/wif": "^2.0.5", diff --git a/packages/crypto-key-pair-schnorr/package.json b/packages/crypto-key-pair-schnorr/package.json index da835995b..f78c485f1 100644 --- a/packages/crypto-key-pair-schnorr/package.json +++ b/packages/crypto-key-pair-schnorr/package.json @@ -22,13 +22,13 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", "bcrypto": "5.5.2", "wif": "^4.0.0" }, "devDependencies": { + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", "@types/wif": "^2.0.5", diff --git a/packages/crypto-messages/package.json b/packages/crypto-messages/package.json index d9d0a48e2..b50da315d 100644 --- a/packages/crypto-messages/package.json +++ b/packages/crypto-messages/package.json @@ -22,18 +22,16 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-block": "workspace:*", - "@mainsail/crypto-config": "workspace:*", - "@mainsail/crypto-consensus-bls12-381": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", - "ajv": "8.12.0", - "delay": "5.0.0" + "ajv": "8.12.0" }, "devDependencies": { + "@mainsail/crypto-block": "workspace:*", + "@mainsail/crypto-config": "workspace:*", + "@mainsail/crypto-consensus-bls12-381": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", - "@types/delay": "3.1.0", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/crypto-transaction-multi-payment/package.json b/packages/crypto-transaction-multi-payment/package.json index 7908dd314..616507c5f 100644 --- a/packages/crypto-transaction-multi-payment/package.json +++ b/packages/crypto-transaction-multi-payment/package.json @@ -22,7 +22,6 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-transaction": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/transactions": "workspace:*", @@ -31,6 +30,7 @@ }, "devDependencies": { "@mainsail/crypto-address-bech32m": "workspace:*", + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-key-pair-schnorr": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", diff --git a/packages/crypto-transaction-multi-signature-registration/package.json b/packages/crypto-transaction-multi-signature-registration/package.json index 45187d062..33261019f 100644 --- a/packages/crypto-transaction-multi-signature-registration/package.json +++ b/packages/crypto-transaction-multi-signature-registration/package.json @@ -22,7 +22,6 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-transaction": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/transactions": "workspace:*", @@ -30,6 +29,7 @@ }, "devDependencies": { "@mainsail/crypto-address-bech32m": "workspace:*", + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-key-pair-schnorr": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", diff --git a/packages/crypto-transaction-username-registration/package.json b/packages/crypto-transaction-username-registration/package.json index b98b15658..f9be2ce5b 100644 --- a/packages/crypto-transaction-username-registration/package.json +++ b/packages/crypto-transaction-username-registration/package.json @@ -28,9 +28,7 @@ "@mainsail/utils": "workspace:*" }, "devDependencies": { - "@mainsail/crypto-address-bech32m": "workspace:*", "@mainsail/crypto-config": "workspace:*", - "@mainsail/crypto-key-pair-schnorr": "workspace:*", "@mainsail/crypto-validation": "workspace:*", "@mainsail/validation": "workspace:*", "uvu": "^0.5.6" diff --git a/packages/crypto-transaction-username-resignation/package.json b/packages/crypto-transaction-username-resignation/package.json index 63cc50214..3df7d9795 100644 --- a/packages/crypto-transaction-username-resignation/package.json +++ b/packages/crypto-transaction-username-resignation/package.json @@ -29,11 +29,6 @@ "@mainsail/utils": "workspace:*" }, "devDependencies": { - "@mainsail/crypto-address-bech32m": "workspace:*", - "@mainsail/crypto-config": "workspace:*", - "@mainsail/crypto-key-pair-schnorr": "workspace:*", - "@mainsail/crypto-validation": "workspace:*", - "@mainsail/validation": "workspace:*", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/crypto-transaction/package.json b/packages/crypto-transaction/package.json index a0115956a..6499f148e 100644 --- a/packages/crypto-transaction/package.json +++ b/packages/crypto-transaction/package.json @@ -22,15 +22,15 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", - "@mainsail/crypto-validation": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", - "@mainsail/validation": "workspace:*", "ajv": "8.12.0" }, "devDependencies": { + "@mainsail/crypto-config": "workspace:*", "@mainsail/crypto-key-pair-schnorr": "workspace:*", + "@mainsail/crypto-validation": "workspace:*", + "@mainsail/validation": "workspace:*", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/crypto-validation/package.json b/packages/crypto-validation/package.json index bee27576c..38c63e2f8 100644 --- a/packages/crypto-validation/package.json +++ b/packages/crypto-validation/package.json @@ -21,14 +21,14 @@ }, "dependencies": { "@mainsail/contracts": "workspace:*", - "@mainsail/crypto-config": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", - "ajv": "8.12.0", - "uvu": "^0.5.6" + "ajv": "8.12.0" }, "devDependencies": { - "@mainsail/validation": "workspace:*" + "@mainsail/crypto-config": "workspace:*", + "@mainsail/validation": "workspace:*", + "uvu": "^0.5.6" }, "engines": { "node": ">=20.x" diff --git a/packages/crypto-worker/package.json b/packages/crypto-worker/package.json index 3f4445704..1c6746f60 100644 --- a/packages/crypto-worker/package.json +++ b/packages/crypto-worker/package.json @@ -21,7 +21,8 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/kernel": "workspace:*" + "@mainsail/kernel": "workspace:*", + "joi": "17.11.0" }, "devDependencies": { "@types/chance": "1.1.6", @@ -30,7 +31,6 @@ "@types/lodash.clonedeep": "4.5.9", "@types/sinon": "^17.0.2", "@types/tmp": "0.2.6", - "joi": "17.11.0", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/database/package.json b/packages/database/package.json index 361a5ddc7..f9bab19d8 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -23,7 +23,6 @@ "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", "lmdb": "2.9.2" }, "devDependencies": { diff --git a/packages/logger-pino/package.json b/packages/logger-pino/package.json index 4accd11ff..5a47090c4 100644 --- a/packages/logger-pino/package.json +++ b/packages/logger-pino/package.json @@ -23,7 +23,6 @@ "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", "chalk": "^4.1.2", - "fs-extra": "11.2.0", "joi": "17.11.0", "pino": "8.17.0", "pino-pretty": "10.2.3", @@ -46,6 +45,7 @@ "@types/split2": "4.2.3", "@types/tmp": "0.2.6", "capture-console": "1.0.2", + "fs-extra": "11.2.0", "import-fresh": "3.3.0", "tmp": "0.2.1", "uvu": "^0.5.6" diff --git a/packages/p2p/package.json b/packages/p2p/package.json index 9f42e8c5d..b62d0e723 100644 --- a/packages/p2p/package.json +++ b/packages/p2p/package.json @@ -39,7 +39,6 @@ "ipaddr.js": "2.1.0", "joi": "17.11.0", "long": "^5.2.3", - "pluralize": "8.0.0", "protobufjs": "7.2.5", "rate-limiter-flexible": "3.0.6", "semver": "7.5.4", @@ -50,7 +49,6 @@ "@types/delay": "3.1.0", "@types/hapi__sntp": "3.1.4", "@types/ip": "1.1.3", - "@types/pluralize": "0.0.33", "@types/semver": "7.5.6", "@types/ws": "8.5.10", "import-fresh": "3.3.0", diff --git a/packages/processor/package.json b/packages/processor/package.json index 0045914ad..14a831ab6 100644 --- a/packages/processor/package.json +++ b/packages/processor/package.json @@ -23,11 +23,9 @@ "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", - "@mainsail/state": "workspace:*", "@mainsail/utils": "workspace:*" }, "devDependencies": { - "@mainsail/crypto-config": "workspace:*", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/proposer/package.json b/packages/proposer/package.json index 003d3dc56..f0b10b669 100644 --- a/packages/proposer/package.json +++ b/packages/proposer/package.json @@ -28,7 +28,6 @@ "devDependencies": { "@mainsail/test-framework": "workspace:*", "@types/seedrandom": "^3.0.8", - "import-fresh": "3.3.0", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/test-framework/package.json b/packages/test-framework/package.json index 139cbfdb7..41f139da5 100644 --- a/packages/test-framework/package.json +++ b/packages/test-framework/package.json @@ -24,7 +24,6 @@ "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/crypto-config": "workspace:*", - "@mainsail/crypto-messages": "workspace:*", "@mainsail/crypto-transaction": "workspace:*", "@mainsail/crypto-transaction-multi-payment": "workspace:*", "@mainsail/crypto-transaction-multi-signature-registration": "workspace:*", @@ -36,9 +35,7 @@ "@mainsail/p2p": "workspace:*", "@mainsail/state": "workspace:*", "@mainsail/utils": "workspace:*", - "@mainsail/validation": "workspace:*", "bip39": "3.1.0", - "chance": "1.1.11", "concordance": "~5.0.4", "dayjs": "1.11.10", "fast-memoize": "2.5.2", @@ -53,6 +50,7 @@ "zod": "~3.22.4" }, "devDependencies": { + "@mainsail/validation": "workspace:*", "@types/chance": "1.1.6", "@types/fs-extra": "11.0.4", "@types/got": "9.6.12", diff --git a/packages/transaction-pool/package.json b/packages/transaction-pool/package.json index dbd5e79c2..e2828fd37 100644 --- a/packages/transaction-pool/package.json +++ b/packages/transaction-pool/package.json @@ -23,13 +23,13 @@ "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", "better-sqlite3": "9.2.2", "fs-extra": "11.2.0", "joi": "17.11.0" }, "devDependencies": { "@mainsail/crypto-config": "workspace:*", + "@mainsail/utils": "workspace:*", "@types/better-sqlite3": "7.6.8", "@types/fs-extra": "11.0.4", "import-fresh": "3.3.0", diff --git a/packages/utils/benchmark/index.js b/packages/utils/benchmark/index.js index 6afa81948..b2319f16b 100644 --- a/packages/utils/benchmark/index.js +++ b/packages/utils/benchmark/index.js @@ -15,6 +15,6 @@ run(async () => { } } - bench.logMem(); - bench.getTime(); + // bench.logMem(); + // bench.getTime(); }); diff --git a/packages/utils/package.json b/packages/utils/package.json index 7ea05bfae..7483c62c6 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -31,10 +31,15 @@ "devDependencies": { "@hapi/boom": "10.0.1", "@hapi/hapi": "21.3.2", - "@types/benchmark": "^2.1.5", "@types/deepmerge": "^2.2.0", - "benchmark": "^2.1.4", + "big-number": "2.0.0", "bignumber.js": "^9.1.2", + "hyperid": "3.2.0", + "jsbi": "4.3.0", + "lodash": "4.17.21", + "micro-bmark": "0.3.1", + "pluralize": "8.0.0", + "random-object": "1.3.4", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/validator-set-static/package.json b/packages/validator-set-static/package.json index 5f0500034..641806236 100644 --- a/packages/validator-set-static/package.json +++ b/packages/validator-set-static/package.json @@ -22,13 +22,10 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", - "delay": "5.0.0" + "@mainsail/kernel": "workspace:*" }, "devDependencies": { "@mainsail/test-framework": "workspace:*", - "@types/delay": "3.1.0", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/validator-set-static/source/validator-set.test.ts b/packages/validator-set-static/source/validator-set.test.ts index ddc521026..9f4cdc112 100644 --- a/packages/validator-set-static/source/validator-set.test.ts +++ b/packages/validator-set-static/source/validator-set.test.ts @@ -1,7 +1,7 @@ import { Contracts, Identifiers } from "@mainsail/contracts"; +import { describe, Sandbox } from "@mainsail/test-framework"; import { validatorWalletFactory } from "../../state/source/wallets/factory"; -import { describe, Sandbox } from "../../test-framework"; import { ValidatorSet } from "./validator-set"; describe<{ diff --git a/packages/validator-set-vote-weighted/package.json b/packages/validator-set-vote-weighted/package.json index 0d0be3b11..5c75a1706 100644 --- a/packages/validator-set-vote-weighted/package.json +++ b/packages/validator-set-vote-weighted/package.json @@ -22,13 +22,11 @@ "dependencies": { "@mainsail/container": "workspace:*", "@mainsail/contracts": "workspace:*", - "@mainsail/kernel": "workspace:*", - "@mainsail/utils": "workspace:*", - "delay": "5.0.0" + "@mainsail/kernel": "workspace:*" }, "devDependencies": { "@mainsail/test-framework": "workspace:*", - "@types/delay": "3.1.0", + "@mainsail/utils": "workspace:*", "@types/sinon": "^17.0.2", "sinon": "^17.0.1", "uvu": "^0.5.6" diff --git a/packages/validator-set-vote-weighted/source/validator-set.test.ts b/packages/validator-set-vote-weighted/source/validator-set.test.ts index 7fae90f17..3179c7b0a 100644 --- a/packages/validator-set-vote-weighted/source/validator-set.test.ts +++ b/packages/validator-set-vote-weighted/source/validator-set.test.ts @@ -1,5 +1,6 @@ import { injectable, Selectors } from "@mainsail/container"; import { Contracts, Identifiers } from "@mainsail/contracts"; +import { describe, getAttributeRepository, getIndexSet, Sandbox } from "@mainsail/test-framework"; import { BigNumber } from "@mainsail/utils"; import { spy } from "sinon"; @@ -8,7 +9,6 @@ import { KeyPairFactory } from "../../crypto-key-pair-schnorr/source/pair"; import { PublicKeyFactory } from "../../crypto-key-pair-schnorr/source/public"; import { Wallets } from "../../state"; import { validatorWalletFactory, walletFactory } from "../../state/source/wallets/factory"; -import { describe, getAttributeRepository, getIndexSet, Sandbox } from "../../test-framework"; import { buildValidatorAndVoteWallets } from "../test/build-validator-and-vote-balances"; import { ValidatorSet } from "./validator-set"; diff --git a/packages/validator/package.json b/packages/validator/package.json index 02f652243..70140cd60 100644 --- a/packages/validator/package.json +++ b/packages/validator/package.json @@ -24,12 +24,10 @@ "@mainsail/contracts": "workspace:*", "@mainsail/kernel": "workspace:*", "@mainsail/utils": "workspace:*", - "dayjs": "1.11.10", - "delay": "5.0.0" + "dayjs": "1.11.10" }, "devDependencies": { "@mainsail/test-framework": "workspace:*", - "@types/delay": "3.1.0", "uvu": "^0.5.6" }, "engines": { diff --git a/packages/validator/source/validator-repository.test.ts b/packages/validator/source/validator-repository.test.ts index 9cee7fb21..3d119634c 100644 --- a/packages/validator/source/validator-repository.test.ts +++ b/packages/validator/source/validator-repository.test.ts @@ -1,6 +1,6 @@ import { Contracts } from "@mainsail/contracts"; +import { describe, Sandbox } from "@mainsail/test-framework"; -import { describe, Sandbox } from "../../test-framework"; import { validatorKeys } from "../test/fixtures/validator-keys"; import { prepareSandbox } from "../test/helpers/prepare-sandbox"; import { Validator } from "./validator"; @@ -13,10 +13,10 @@ describe<{ beforeEach(async (context) => { await prepareSandbox(context); - const validators: Contracts.Consensus.IValidator[] = []; + const validators: Contracts.Validator.Validator[] = []; for (const { consensusKeyPair } of validatorKeys) { validators.push( - context.sandbox.app.resolve(Validator).configure(consensusKeyPair), + context.sandbox.app.resolve(Validator).configure(consensusKeyPair), ); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 84c8fad10..e9b8f1aa3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -116,9 +116,6 @@ importers: '@mainsail/cli': specifier: workspace:* version: link:../cli - '@mainsail/configuration-generator': - specifier: workspace:* - version: link:../configuration-generator '@mainsail/container': specifier: workspace:* version: link:../container @@ -131,27 +128,18 @@ importers: '@mainsail/logger-pino': specifier: workspace:* version: link:../logger-pino - '@mainsail/test-framework': - specifier: workspace:* - version: link:../test-framework '@mainsail/utils': specifier: workspace:* version: link:../utils boxen: specifier: 4.2.0 version: 4.2.0 - cross-env: - specifier: 7.0.3 - version: 7.0.3 dayjs: specifier: 1.11.10 version: 1.11.10 envfile: specifier: 7.0.0 version: 7.0.0 - execa: - specifier: 5.1.1 - version: 5.1.1 fs-extra: specifier: 11.2.0 version: 11.2.0 @@ -164,16 +152,10 @@ importers: pm2: specifier: ^5.3.0 version: 5.3.0 - prompts: - specifier: 2.4.2 - version: 2.4.2 - tmp: - specifier: 0.2.1 - version: 0.2.1 - uvu: - specifier: ^0.5.6 - version: 0.5.6 devDependencies: + '@mainsail/test-framework': + specifier: workspace:* + version: link:../test-framework '@types/boxen': specifier: 3.0.1 version: 3.0.1 @@ -189,6 +171,24 @@ importers: '@types/tmp': specifier: 0.2.6 version: 0.2.6 + cross-env: + specifier: 7.0.3 + version: 7.0.3 + env-paths: + specifier: 2.2.1 + version: 2.2.1 + execa: + specifier: 5.1.1 + version: 5.1.1 + prompts: + specifier: 2.4.2 + version: 2.4.2 + tmp: + specifier: 0.2.1 + version: 0.2.1 + uvu: + specifier: ^0.5.6 + version: 0.5.6 packages/api-common: dependencies: @@ -247,18 +247,12 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/utils': - specifier: workspace:* - version: link:../utils dayjs: specifier: 1.11.10 version: 1.11.10 pg: specifier: 8.11.3 version: 8.11.3 - reflect-metadata: - specifier: 0.2.0 - version: 0.2.0 typeorm: specifier: 0.3.17 version: 0.3.17(pg@8.11.3) @@ -278,9 +272,6 @@ importers: '@hapi/hapi': specifier: 21.3.2 version: 21.3.2 - '@hapi/hoek': - specifier: 11.0.4 - version: 11.0.4 '@mainsail/api-common': specifier: workspace:* version: link:../api-common @@ -296,25 +287,13 @@ importers: '@mainsail/transactions': specifier: workspace:* version: link:../transactions - '@mainsail/utils': - specifier: workspace:* - version: link:../utils joi: specifier: 17.11.0 version: 17.11.0 - nanomatch: - specifier: 1.2.13 - version: 1.2.13 - rate-limiter-flexible: - specifier: 3.0.6 - version: 3.0.6 semver: specifier: 7.5.4 version: 7.5.4 devDependencies: - '@types/ip': - specifier: 1.1.3 - version: 1.1.3 '@types/semver': specifier: 7.5.6 version: 7.5.6 @@ -330,9 +309,6 @@ importers: '@hapi/hapi': specifier: 21.3.2 version: 21.3.2 - '@hapi/hoek': - specifier: 11.0.4 - version: 11.0.4 '@mainsail/api-common': specifier: workspace:* version: link:../api-common @@ -357,12 +333,6 @@ importers: joi: specifier: 17.11.0 version: 17.11.0 - nanomatch: - specifier: 1.2.13 - version: 1.2.13 - rate-limiter-flexible: - specifier: 3.0.6 - version: 3.0.6 devDependencies: '@types/ip': specifier: 1.1.3 @@ -407,15 +377,9 @@ importers: '@hapi/hapi': specifier: 21.3.2 version: 21.3.2 - '@hapi/hoek': - specifier: 11.0.4 - version: 11.0.4 '@mainsail/api-common': specifier: workspace:* version: link:../api-common - '@mainsail/api-database': - specifier: workspace:* - version: link:../api-database '@mainsail/container': specifier: workspace:* version: link:../container @@ -425,24 +389,9 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/transactions': - specifier: workspace:* - version: link:../transactions - '@mainsail/utils': - specifier: workspace:* - version: link:../utils - dayjs: - specifier: 1.11.10 - version: 1.11.10 joi: specifier: 17.11.0 version: 17.11.0 - nanomatch: - specifier: 1.2.13 - version: 1.2.13 - rate-limiter-flexible: - specifier: 3.0.6 - version: 3.0.6 devDependencies: '@types/ip': specifier: 1.1.3 @@ -450,9 +399,6 @@ importers: '@types/semver': specifier: 7.5.6 version: 7.5.6 - got: - specifier: 11.8.6 - version: 11.8.6 uvu: specifier: ^0.5.6 version: 0.5.6 @@ -699,9 +645,6 @@ importers: dayjs: specifier: 1.11.10 version: 1.11.10 - env-paths: - specifier: 2.2.1 - version: 2.2.1 envfile: specifier: 7.0.0 version: 7.0.0 @@ -718,6 +661,9 @@ importers: '@types/tmp': specifier: 0.2.6 version: 0.2.6 + env-paths: + specifier: 2.2.1 + version: 2.2.1 tmp: specifier: 0.2.1 version: 0.2.1 @@ -736,15 +682,9 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/utils': - specifier: workspace:* - version: link:../utils dayjs: specifier: 1.11.10 version: 1.11.10 - delay: - specifier: 5.0.0 - version: 5.0.0 lmdb: specifier: 2.9.2 version: 2.9.2 @@ -752,12 +692,6 @@ importers: '@mainsail/test-framework': specifier: workspace:* version: link:../test-framework - '@types/delay': - specifier: 3.1.0 - version: 3.1.0 - '@types/seedrandom': - specifier: ^3.0.8 - version: 3.0.8 rewiremock: specifier: 3.14.5 version: 3.14.5 @@ -773,6 +707,7 @@ importers: reflect-metadata: specifier: 0.2.0 version: 0.2.0 + devDependencies: uvu: specifier: ^0.5.6 version: 0.5.6 @@ -969,9 +904,6 @@ importers: '@mainsail/state': specifier: workspace:* version: link:../state - '@mainsail/test-framework': - specifier: workspace:* - version: link:../test-framework '@mainsail/transaction-pool': specifier: workspace:* version: link:../transaction-pool @@ -1002,9 +934,6 @@ importers: boxen: specifier: 4.2.0 version: 4.2.0 - cross-env: - specifier: 7.0.3 - version: 7.0.3 dayjs: specifier: 1.11.10 version: 1.11.10 @@ -1014,9 +943,6 @@ importers: envfile: specifier: 7.0.0 version: 7.0.0 - execa: - specifier: 5.1.1 - version: 5.1.1 fs-extra: specifier: 11.2.0 version: 11.2.0 @@ -1032,13 +958,10 @@ importers: prompts: specifier: 2.4.2 version: 2.4.2 - tmp: - specifier: 0.2.1 - version: 0.2.1 - uvu: - specifier: ^0.5.6 - version: 0.5.6 devDependencies: + '@mainsail/test-framework': + specifier: workspace:* + version: link:../test-framework '@types/boxen': specifier: 3.0.1 version: 3.0.1 @@ -1057,6 +980,18 @@ importers: '@types/tmp': specifier: 0.2.6 version: 0.2.6 + cross-env: + specifier: 7.0.3 + version: 7.0.3 + execa: + specifier: 5.1.1 + version: 5.1.1 + tmp: + specifier: 0.2.1 + version: 0.2.1 + uvu: + specifier: ^0.5.6 + version: 0.5.6 packages/crypto-address-base58: dependencies: @@ -1189,9 +1124,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/kernel': specifier: workspace:* version: link:../kernel @@ -1202,6 +1134,9 @@ importers: specifier: ^6.9.0 version: 6.9.0 devDependencies: + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-key-pair-ecdsa': specifier: workspace:* version: link:../crypto-key-pair-ecdsa @@ -1272,9 +1207,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/crypto-transaction': specifier: workspace:* version: link:../crypto-transaction @@ -1284,9 +1216,6 @@ importers: '@mainsail/utils': specifier: workspace:* version: link:../utils - '@mainsail/validation': - specifier: workspace:* - version: link:../validation ajv: specifier: 8.12.0 version: 8.12.0 @@ -1294,12 +1223,18 @@ importers: '@mainsail/crypto-address-bech32m': specifier: workspace:* version: link:../crypto-address-bech32m + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-key-pair-schnorr': specifier: workspace:* version: link:../crypto-key-pair-schnorr '@mainsail/crypto-validation': specifier: workspace:* version: link:../crypto-validation + '@mainsail/validation': + specifier: workspace:* + version: link:../validation '@types/lodash.clone': specifier: ^4.5.9 version: 4.5.9 @@ -1318,28 +1253,13 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-block': - specifier: workspace:* - version: link:../crypto-block - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/kernel': specifier: workspace:* version: link:../kernel '@mainsail/utils': specifier: workspace:* version: link:../utils - ajv: - specifier: 8.12.0 - version: 8.12.0 devDependencies: - '@mainsail/crypto-validation': - specifier: workspace:* - version: link:../crypto-validation - '@mainsail/validation': - specifier: workspace:* - version: link:../validation uvu: specifier: ^0.5.6 version: 0.5.6 @@ -1401,24 +1321,6 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/utils': - specifier: workspace:* - version: link:../utils - ajv: - specifier: 8.12.0 - version: 8.12.0 - dayjs: - specifier: 1.11.10 - version: 1.11.10 - inversify: - specifier: 6.0.2 - version: 6.0.2 - reflect-metadata: - specifier: 0.2.0 - version: 0.2.0 - type-fest: - specifier: 4.8.3 - version: 4.8.3 devDependencies: uvu: specifier: ^0.5.6 @@ -1492,9 +1394,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/kernel': specifier: workspace:* version: link:../kernel @@ -1511,6 +1410,9 @@ importers: specifier: ^4.0.0 version: 4.0.0 devDependencies: + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-validation': specifier: workspace:* version: link:../crypto-validation @@ -1535,9 +1437,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/kernel': specifier: workspace:* version: link:../kernel @@ -1551,6 +1450,9 @@ importers: specifier: ^4.0.0 version: 4.0.0 devDependencies: + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-validation': specifier: workspace:* version: link:../crypto-validation @@ -1575,9 +1477,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/kernel': specifier: workspace:* version: link:../kernel @@ -1597,6 +1496,9 @@ importers: specifier: ^4.0.0 version: 4.0.0 devDependencies: + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-validation': specifier: workspace:* version: link:../crypto-validation @@ -1621,9 +1523,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/kernel': specifier: workspace:* version: link:../kernel @@ -1637,6 +1536,9 @@ importers: specifier: ^4.0.0 version: 4.0.0 devDependencies: + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-validation': specifier: workspace:* version: link:../crypto-validation @@ -1661,15 +1563,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-block': - specifier: workspace:* - version: link:../crypto-block - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config - '@mainsail/crypto-consensus-bls12-381': - specifier: workspace:* - version: link:../crypto-consensus-bls12-381 '@mainsail/kernel': specifier: workspace:* version: link:../kernel @@ -1679,19 +1572,22 @@ importers: ajv: specifier: 8.12.0 version: 8.12.0 - delay: - specifier: 5.0.0 - version: 5.0.0 devDependencies: + '@mainsail/crypto-block': + specifier: workspace:* + version: link:../crypto-block + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config + '@mainsail/crypto-consensus-bls12-381': + specifier: workspace:* + version: link:../crypto-consensus-bls12-381 '@mainsail/crypto-validation': specifier: workspace:* version: link:../crypto-validation '@mainsail/validation': specifier: workspace:* version: link:../validation - '@types/delay': - specifier: 3.1.0 - version: 3.1.0 uvu: specifier: ^0.5.6 version: 0.5.6 @@ -1817,28 +1713,28 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config - '@mainsail/crypto-validation': - specifier: workspace:* - version: link:../crypto-validation '@mainsail/kernel': specifier: workspace:* version: link:../kernel '@mainsail/utils': specifier: workspace:* version: link:../utils - '@mainsail/validation': - specifier: workspace:* - version: link:../validation ajv: specifier: 8.12.0 version: 8.12.0 devDependencies: + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-key-pair-schnorr': specifier: workspace:* version: link:../crypto-key-pair-schnorr + '@mainsail/crypto-validation': + specifier: workspace:* + version: link:../crypto-validation + '@mainsail/validation': + specifier: workspace:* + version: link:../validation uvu: specifier: ^0.5.6 version: 0.5.6 @@ -1851,9 +1747,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/crypto-transaction': specifier: workspace:* version: link:../crypto-transaction @@ -1873,6 +1766,9 @@ importers: '@mainsail/crypto-address-bech32m': specifier: workspace:* version: link:../crypto-address-bech32m + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-key-pair-schnorr': specifier: workspace:* version: link:../crypto-key-pair-schnorr @@ -1894,9 +1790,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/crypto-transaction': specifier: workspace:* version: link:../crypto-transaction @@ -1913,6 +1806,9 @@ importers: '@mainsail/crypto-address-bech32m': specifier: workspace:* version: link:../crypto-address-bech32m + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/crypto-key-pair-schnorr': specifier: workspace:* version: link:../crypto-key-pair-schnorr @@ -1987,15 +1883,9 @@ importers: specifier: workspace:* version: link:../utils devDependencies: - '@mainsail/crypto-address-bech32m': - specifier: workspace:* - version: link:../crypto-address-bech32m '@mainsail/crypto-config': specifier: workspace:* version: link:../crypto-config - '@mainsail/crypto-key-pair-schnorr': - specifier: workspace:* - version: link:../crypto-key-pair-schnorr '@mainsail/crypto-validation': specifier: workspace:* version: link:../crypto-validation @@ -2030,21 +1920,6 @@ importers: specifier: workspace:* version: link:../utils devDependencies: - '@mainsail/crypto-address-bech32m': - specifier: workspace:* - version: link:../crypto-address-bech32m - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config - '@mainsail/crypto-key-pair-schnorr': - specifier: workspace:* - version: link:../crypto-key-pair-schnorr - '@mainsail/crypto-validation': - specifier: workspace:* - version: link:../crypto-validation - '@mainsail/validation': - specifier: workspace:* - version: link:../validation uvu: specifier: ^0.5.6 version: 0.5.6 @@ -2183,9 +2058,6 @@ importers: '@mainsail/contracts': specifier: workspace:* version: link:../contracts - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config '@mainsail/kernel': specifier: workspace:* version: link:../kernel @@ -2195,13 +2067,16 @@ importers: ajv: specifier: 8.12.0 version: 8.12.0 - uvu: - specifier: ^0.5.6 - version: 0.5.6 devDependencies: + '@mainsail/crypto-config': + specifier: workspace:* + version: link:../crypto-config '@mainsail/validation': specifier: workspace:* version: link:../validation + uvu: + specifier: ^0.5.6 + version: 0.5.6 packages/crypto-wif: dependencies: @@ -2242,6 +2117,9 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel + joi: + specifier: 17.11.0 + version: 17.11.0 devDependencies: '@types/chance': specifier: 1.1.6 @@ -2261,9 +2139,6 @@ importers: '@types/tmp': specifier: 0.2.6 version: 0.2.6 - joi: - specifier: 17.11.0 - version: 17.11.0 uvu: specifier: ^0.5.6 version: 0.5.6 @@ -2279,9 +2154,6 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/utils': - specifier: workspace:* - version: link:../utils lmdb: specifier: 2.9.2 version: 2.9.2 @@ -2553,9 +2425,6 @@ importers: chalk: specifier: ^4.1.2 version: 4.1.2 - fs-extra: - specifier: 11.2.0 - version: 11.2.0 joi: specifier: 17.11.0 version: 17.11.0 @@ -2617,6 +2486,9 @@ importers: capture-console: specifier: 1.0.2 version: 1.0.2 + fs-extra: + specifier: 11.2.0 + version: 11.2.0 import-fresh: specifier: 3.3.0 version: 3.3.0 @@ -2743,9 +2615,6 @@ importers: long: specifier: ^5.2.3 version: 5.2.3 - pluralize: - specifier: 8.0.0 - version: 8.0.0 protobufjs: specifier: 7.2.5 version: 7.2.5 @@ -2771,9 +2640,6 @@ importers: '@types/ip': specifier: 1.1.3 version: 1.1.3 - '@types/pluralize': - specifier: 0.0.33 - version: 0.0.33 '@types/semver': specifier: 7.5.6 version: 7.5.6 @@ -2804,16 +2670,10 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/state': - specifier: workspace:* - version: link:../state '@mainsail/utils': specifier: workspace:* version: link:../utils devDependencies: - '@mainsail/crypto-config': - specifier: workspace:* - version: link:../crypto-config uvu: specifier: ^0.5.6 version: 0.5.6 @@ -2839,9 +2699,6 @@ importers: '@types/seedrandom': specifier: ^3.0.8 version: 3.0.8 - import-fresh: - specifier: 3.3.0 - version: 3.3.0 uvu: specifier: ^0.5.6 version: 0.5.6 @@ -2922,9 +2779,6 @@ importers: '@mainsail/crypto-config': specifier: workspace:* version: link:../crypto-config - '@mainsail/crypto-messages': - specifier: workspace:* - version: link:../crypto-messages '@mainsail/crypto-transaction': specifier: workspace:* version: link:../crypto-transaction @@ -2958,15 +2812,9 @@ importers: '@mainsail/utils': specifier: workspace:* version: link:../utils - '@mainsail/validation': - specifier: workspace:* - version: link:../validation bip39: specifier: 3.1.0 version: 3.1.0 - chance: - specifier: 1.1.11 - version: 1.1.11 concordance: specifier: ~5.0.4 version: 5.0.4 @@ -3004,6 +2852,9 @@ importers: specifier: ~3.22.4 version: 3.22.4 devDependencies: + '@mainsail/validation': + specifier: workspace:* + version: link:../validation '@types/chance': specifier: 1.1.6 version: 1.1.6 @@ -3037,9 +2888,6 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/utils': - specifier: workspace:* - version: link:../utils better-sqlite3: specifier: 9.2.2 version: 9.2.2 @@ -3053,6 +2901,9 @@ importers: '@mainsail/crypto-config': specifier: workspace:* version: link:../crypto-config + '@mainsail/utils': + specifier: workspace:* + version: link:../utils '@types/better-sqlite3': specifier: 7.6.8 version: 7.6.8 @@ -3118,18 +2969,33 @@ importers: '@hapi/hapi': specifier: 21.3.2 version: 21.3.2 - '@types/benchmark': - specifier: ^2.1.5 - version: 2.1.5 '@types/deepmerge': specifier: ^2.2.0 version: 2.2.0 - benchmark: - specifier: ^2.1.4 - version: 2.1.4 + big-number: + specifier: 2.0.0 + version: 2.0.0 bignumber.js: specifier: ^9.1.2 version: 9.1.2 + hyperid: + specifier: 3.2.0 + version: 3.2.0 + jsbi: + specifier: 4.3.0 + version: 4.3.0 + lodash: + specifier: 4.17.21 + version: 4.17.21 + micro-bmark: + specifier: 0.3.1 + version: 0.3.1 + pluralize: + specifier: 8.0.0 + version: 8.0.0 + random-object: + specifier: 1.3.4 + version: 1.3.4 uvu: specifier: ^0.5.6 version: 0.5.6 @@ -3176,16 +3042,10 @@ importers: dayjs: specifier: 1.11.10 version: 1.11.10 - delay: - specifier: 5.0.0 - version: 5.0.0 devDependencies: '@mainsail/test-framework': specifier: workspace:* version: link:../test-framework - '@types/delay': - specifier: 3.1.0 - version: 3.1.0 uvu: specifier: ^0.5.6 version: 0.5.6 @@ -3201,19 +3061,10 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/utils': - specifier: workspace:* - version: link:../utils - delay: - specifier: 5.0.0 - version: 5.0.0 devDependencies: '@mainsail/test-framework': specifier: workspace:* version: link:../test-framework - '@types/delay': - specifier: 3.1.0 - version: 3.1.0 uvu: specifier: ^0.5.6 version: 0.5.6 @@ -3229,19 +3080,13 @@ importers: '@mainsail/kernel': specifier: workspace:* version: link:../kernel - '@mainsail/utils': - specifier: workspace:* - version: link:../utils - delay: - specifier: 5.0.0 - version: 5.0.0 devDependencies: '@mainsail/test-framework': specifier: workspace:* version: link:../test-framework - '@types/delay': - specifier: 3.1.0 - version: 3.1.0 + '@mainsail/utils': + specifier: workspace:* + version: link:../utils '@types/sinon': specifier: ^17.0.2 version: 17.0.2 @@ -5090,10 +4935,6 @@ packages: minimatch: 9.0.3 dev: true - /@types/benchmark@2.1.5: - resolution: {integrity: sha512-cKio2eFB3v7qmKcvIHLUMw/dIx/8bhWPuzpzRT4unCPRTD8VdA9Zb0afxpcxOqR4PixRS7yT42FqGS8BYL8g1w==} - dev: true - /@types/better-sqlite3@7.6.8: resolution: {integrity: sha512-ASndM4rdGrzk7iXXqyNC4fbwt4UEjpK0i3j4q4FyeQrLAthfB6s7EF135ZJE0qQxtKIMFwmyT6x0switET7uIw==} dependencies: @@ -5380,10 +5221,6 @@ packages: pino: 8.17.0 dev: true - /@types/pluralize@0.0.33: - resolution: {integrity: sha512-JOqsl+ZoCpP4e8TDke9W79FDcSgPAR0l6pixx2JHkhnRjvShyYiAYw2LVsnA7K08Y6DeOnaU6ujmENO4os/cYg==} - dev: true - /@types/prompts@2.4.9: resolution: {integrity: sha512-qTxFi6Buiu8+50/+3DGIWLHM6QuWsEKugJnnP6iv2Mc4ncxE4A/OJkjuVOA+5X0X1S/nq5VJRa8Lu+nwcvbrKA==} dependencies: @@ -6385,13 +6222,6 @@ packages: resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} dev: true - /benchmark@2.1.4: - resolution: {integrity: sha512-l9MlfN4M1K/H2fbhfMy3B7vJd6AGKJVQn2h6Sg/Yx+KckoUA7ewS5Vv6TjSq18ooE1kS9hhAlQRH3AkXIh/aOQ==} - dependencies: - lodash: 4.17.21 - platform: 1.3.6 - dev: true - /better-sqlite3@9.2.2: resolution: {integrity: sha512-qwjWB46il0lsDkeB4rSRI96HyDQr8sxeu1MkBVLMrwusq1KRu4Bpt1TMI+8zIJkDUtZ3umjAkaEjIlokZKWCQw==} requiresBuild: true @@ -6405,6 +6235,10 @@ packages: engines: {node: '>=0.6'} dev: true + /big-number@2.0.0: + resolution: {integrity: sha512-C67Su0g+XsmXADX/UM9L/+xSbqqwq0D/qGJs2ky6Noy2FDuCZnC38ZSXODiaBvqWma2VYRZEXgm4H74PS6tCDg==} + dev: true + /bignumber.js@9.1.2: resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==} dev: true @@ -6979,10 +6813,6 @@ packages: engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} dev: true - /chance@1.1.11: - resolution: {integrity: sha512-kqTg3WWywappJPqtgrdvbA380VoXO2eu9VCV895JgbyHsaErXdyHK9LOZ911OvAk6L0obK7kDk9CGs8+oBawVA==} - dev: false - /chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} dev: true @@ -7597,6 +7427,7 @@ packages: hasBin: true dependencies: cross-spawn: 7.0.3 + dev: true /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} @@ -10287,6 +10118,14 @@ packages: hasBin: true dev: true + /hyperid@3.2.0: + resolution: {integrity: sha512-PdTtDo+Rmza9nEhTunaDSUKwbC69TIzLEpZUwiB6f+0oqmY0UPfhyHCPt6K1NQ4WFv5yJBTG5vELztVWP+nEVQ==} + dependencies: + buffer: 5.7.1 + uuid: 8.3.2 + uuid-parse: 1.1.0 + dev: true + /iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -11062,6 +10901,10 @@ packages: xmlcreate: 2.0.4 dev: true + /jsbi@4.3.0: + resolution: {integrity: sha512-SnZNcinB4RIcnEyZqFPdGPVgrg2AcnykiBy0sHVJQKHYeaLUvi3Exj+iaPpLnFVkDPZIV4U0yvgC9/R4uEAZ9g==} + dev: true + /jsdoc@4.0.2: resolution: {integrity: sha512-e8cIg2z62InH7azBBi3EsSEqrKx+nUtAS5bBcYTSpZFA+vhNPyhv8PTFZ0WsjOPDj04/dOLlm08EDcQJDqaGQg==} engines: {node: '>=12.0.0'} @@ -12036,6 +11879,10 @@ packages: engines: {node: '>= 8'} dev: true + /micro-bmark@0.3.1: + resolution: {integrity: sha512-bNaKObD4yPAAPrpEqp5jO6LJ2sEFgLoFSmRjEY809mJ62+2AehI/K3+RlVpN3Oo92RHpgC2RQhj6b1Tb4dmo+w==} + dev: true + /micro-memoize@2.1.2: resolution: {integrity: sha512-COjNutiFgnDHXZEIM/jYuZPwq2h8zMUeScf6Sh6so98a+REqdlpaNS7Cb2ffGfK5I+xfgoA3Rx49NGuNJTJq3w==} dev: false @@ -13832,10 +13679,6 @@ packages: find-up: 4.1.0 dev: true - /platform@1.3.6: - resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==} - dev: true - /please-upgrade-node@3.2.0: resolution: {integrity: sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==} dependencies: @@ -13845,6 +13688,7 @@ packages: /pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} + dev: true /pm2-axon-rpc@0.7.1: resolution: {integrity: sha512-FbLvW60w+vEyvMjP/xom2UPhUN/2bVpdtLfKJeYM3gwzYhoTEEChCOICfFzxkxuoEleOlnpjie+n1nue91bDQw==} @@ -14207,7 +14051,6 @@ packages: dependencies: kleur: 3.0.3 sisteransi: 1.0.5 - dev: false /promzard@0.3.0: resolution: {integrity: sha512-JZeYqd7UAcHCwI+sTOeUDYkvEU+1bQ7iE0UT1MgB/tERkAPkesW46MrpIySzODi+owTjZtiF8Ay5j9m60KmMBw==} @@ -14362,6 +14205,10 @@ packages: resolution: {integrity: sha512-twwRO/ilhlG/FIgYeKGFqyHhoEhqgnKVkcmqMKi2r524gz3ZbDTcyFt38E9xjJI2vT+KbRNHVbnJ/e0I25Azwg==} dev: true + /random-object@1.3.4: + resolution: {integrity: sha512-OLAiU6kbUqBT1Pwv+R9KmCKFLOeauyt6MxDe+c35kERwRvO/8yY5WTfkey7QRVm5Gt3S0FMqzwPee0estFTRPg==} + dev: true + /randombytes@2.0.3: resolution: {integrity: sha512-lDVjxQQFoCG1jcrP06LNo2lbWp4QTShEXnhActFBwYuHprllQV6VUpwreApsYqCgD+N1mHoqJ/BI/4eV4R2GYg==} dev: true @@ -16443,6 +16290,10 @@ packages: inherits: 2.0.3 dev: true + /uuid-parse@1.1.0: + resolution: {integrity: sha512-OdmXxA8rDsQ7YpNVbKSJkNzTw2I+S5WsbMDnCtIWSQaosNAcWtFuI/YK1TjzUI6nbkgiqEyh8gWngfcv8Asd9A==} + dev: true + /uuid@3.4.0: resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. diff --git a/scripts/deps/check.js b/scripts/deps/check.js new file mode 100644 index 000000000..f0380c8a5 --- /dev/null +++ b/scripts/deps/check.js @@ -0,0 +1,266 @@ +const depcheck = require("depcheck"); +const { resolve, join } = require("path"); +const { readdirSync, lstatSync } = require("fs"); + +// Dependency categorization: +// USAGE in code -> Type: +// - Source -> Used in source code, but not in tests +// - Test -> not used in source code, but only in tests +// - Both -> Used in both source code and tests +// * NOTE: We are using testOnly flag, because Source & Both can be treated the same and should be registered in dependencies + +// INVALID CASES: +// Unused -> Not used in source code or tests -> (should be removed from dependencies && devDependencies) + +// Unused -> Unused in the source code & registered in dependencies -> (should be removed from dependencies) +// UnusedDev -> Unused in tests & registered in devDependencies -> (should be removed from devDependencies) + +// Missing: -> Used in source code (& tests -> Both Type || Source Type) , but not registered in dependencies or devDependencies -> (should be added to dependencies) +// MissingDev: -> Used in tests (Test Type), but not registered in devDependencies -> (should be added to devDependencies) + +// MissingException: Registered as exception, but not registered in dependencies +// MissingDevException: Registered as exception, but not registered in devDependencies + +// VALID CASES: +// Used -> Used in source code & tests and registered in dependencies +// UsedDev -> Used in tests and registered in devDependencies +// Exceptions: Not used in code (Unused type), but required for build or other purposes + +const EXCEPTIONS = { + "@mainsail/api": { + dependencies: ["@mainsail/logger-pino", "@mainsail/api-database", "@mainsail/api-http"], + devDependencies: [], + }, + "@mainsail/configuration-generator": { + dependencies: ["@mainsail/crypto-key-pair-ecdsa", "@mainsail/crypto-signature-schnorr-secp256k1"], + devDependencies: [], + }, + "@mainsail/core": { + dependencies: [ + "@mainsail/api-common", + "@mainsail/api-database", + "@mainsail/api-development", + "@mainsail/api-http", + "@mainsail/api-sync", + "@mainsail/api-transaction-pool", + "@mainsail/bootstrap", + "@mainsail/consensus", + "@mainsail/crypto-address-base58", + "@mainsail/crypto-address-bech32m", + "@mainsail/crypto-address-keccak256", + "@mainsail/crypto-address-ss58", + "@mainsail/crypto-block", + "@mainsail/crypto-commit", + "@mainsail/crypto-config", + "@mainsail/crypto-consensus-bls12-381", + "@mainsail/crypto-hash-bcrypto", + "@mainsail/crypto-hash-noble", + "@mainsail/crypto-hash-wasm", + "@mainsail/crypto-key-pair-bls12-381", + "@mainsail/crypto-key-pair-ecdsa", + "@mainsail/crypto-key-pair-ed25519", + "@mainsail/crypto-key-pair-schnorr", + "@mainsail/crypto-messages", + "@mainsail/crypto-signature-schnorr", + "@mainsail/crypto-signature-schnorr-secp256k1", + "@mainsail/crypto-transaction", + "@mainsail/crypto-transaction-multi-payment", + "@mainsail/crypto-transaction-multi-signature-registration", + "@mainsail/crypto-transaction-transfer", + "@mainsail/crypto-transaction-username-registration", + "@mainsail/crypto-transaction-username-resignation", + "@mainsail/crypto-transaction-validator-registration", + "@mainsail/crypto-transaction-validator-resignation", + "@mainsail/crypto-transaction-vote", + "@mainsail/crypto-validation", + "@mainsail/crypto-wif", + "@mainsail/crypto-worker", + "@mainsail/database", + "@mainsail/fees", + "@mainsail/fees-static", + "@mainsail/logger-pino", + "@mainsail/networking-dns", + "@mainsail/networking-ntp", + "@mainsail/p2p", + "@mainsail/processor", + "@mainsail/proposer", + "@mainsail/serializer", + "@mainsail/state", + "@mainsail/transaction-pool", + "@mainsail/transactions", + "@mainsail/validation", + "@mainsail/validator", + "@mainsail/validator-set-static", + "@mainsail/validator-set-vote-weighted", + "@mainsail/webhooks", + ], + devDependencies: [], + }, +}; + +class Package { + constructor(packageJson, imports) { + this.name = packageJson.name; + this.dependencies = packageJson.dependencies ? Object.keys(packageJson.dependencies) : []; + this.devDependencies = packageJson.devDependencies + ? Object.keys(packageJson.devDependencies).filter((x) => !x.startsWith("@types/")) + : []; + this.imports = imports; + + this.exceptions = this.findExceptions(); + this.devExceptions = this.findDevExceptions(); + + const result = this.getResult(); + this.used = result.used; + this.unused = result.unused; + this.missing = result.missing; + + const devResult = this.getDevResult(); + this.devUsed = devResult.used; + this.devUnused = devResult.unused; + this.devMissing = devResult.missing; + } + + pass() { + return ( + this.unused.length === 0 && + this.missing.length === 0 && + this.devUnused.length === 0 && + this.devMissing.length === 0 + ); + } + + findExceptions() { + const exception = EXCEPTIONS[this.name]; + return exception ? exception.dependencies : []; + } + + findDevExceptions() { + const exception = EXCEPTIONS[this.name]; + return exception ? exception.devDependencies : []; + } + + getResult() { + const used = []; + const unused = []; + const missing = []; + + const importNames = this.imports.filter((dep) => !dep.testOnly).map((dep) => dep.name); + const combined = new Set([...importNames, ...this.dependencies]); + + for (const dep of combined.values()) { + if (importNames.includes(dep) && this.dependencies.includes(dep)) { + used.push(dep); + continue; + } + + if (importNames.includes(dep)) { + missing.push(dep); + } else if (!this.exceptions.includes(dep)) { + unused.push(dep); + } + } + + return { + used, + unused, + missing, + }; + } + + getDevResult() { + const used = []; + const unused = []; + const missing = []; + + const importNames = this.imports.filter((dep) => dep.testOnly).map((dep) => dep.name); + const combined = new Set([...importNames, ...this.devDependencies]); + + for (const dep of combined.values()) { + if (importNames.includes(dep) && this.devDependencies.includes(dep)) { + used.push(dep); + continue; + } + + if (importNames.includes(dep)) { + missing.push(dep); + } else if (!this.devExceptions.includes(dep)) { + unused.push(dep); + } + } + + return { + used, + unused, + missing, + }; + } +} + +class Import { + constructor(name, paths) { + this.name = name; + this.paths = paths; + this.testOnly = this.isTestOnly(); + } + + isTestOnly() { + return this.paths.every((path) => path.endsWith(".test.ts") || !path.includes("/source/")); + } +} + +const main = async () => { + const source = resolve(__dirname, "../../packages"); + + const pkgs = readdirSync(source) + .filter((name) => lstatSync(`${source}/${name}`).isDirectory()) + .sort(); + + let pass = true; + + for (const pkg of pkgs) { + const packageJson = require(join(source, pkg, "package.json")); + + await depcheck( + join(source, pkg), + { + ignoreDirs: ["node_modules", "distribution"], + ignoreMatches: ["@types/*"], + }, + (result) => { + const imports = Object.keys(result.using).map((name) => new Import(name, result.using[name])); + const package = new Package(packageJson, imports); + + if (!package.pass()) { + pass = false; + console.log("Package: ", package.name); + + const { missing, unused, devMissing, devUnused } = package; + + console.log({ + missing, + unused, + devMissing, + devUnused, + }); + } + + // console.log("Used: ", package.used); + // console.log("Missing: ", package.missing); + // console.log("Unused: ", package.unused); + // console.log("Exceptions: ", package.exceptions); + + // console.log("DevUsed: ", package.devUsed); + // console.log("DevMissing: ", package.devMissing); + // console.log("DevUnused: ", package.devUnused); + // console.log("DevExceptions: ", package.devExceptions); + }, + ); + } + + if (!pass) { + process.exit(1); + } +}; + +main(); diff --git a/scripts/deps/missing.js b/scripts/deps/missing.js deleted file mode 100644 index 727e0e0de..000000000 --- a/scripts/deps/missing.js +++ /dev/null @@ -1,32 +0,0 @@ -const depcheck = require("depcheck"); -const { resolve } = require("path"); -const { lstatSync, readdirSync } = require("fs"); - -const source = resolve(__dirname, "../../packages"); - -const pkgs = readdirSync(source) - .filter((name) => lstatSync(`${source}/${name}`).isDirectory()) - .sort(); - -for (const pkg of pkgs) { - depcheck( - `${source}/${pkg}`, - { - ignoreDirs: ["__tests__", "benchmark", "distribution", "docker", "scripts"], - ignoreMatches: ["@types/*"], - }, - (unused) => { - const missing = Object.keys(unused.missing); - - if (missing.length > 0) { - console.log(`[FAIL] ${pkg}`); - - for (const dep of missing) { - console.log(`lerna add ${dep} --scope=@mainsail/${pkg}`); - } - } else { - console.log(`[PASS] ${pkg}`); - } - }, - ); -} diff --git a/scripts/deps/unused.js b/scripts/deps/unused.js deleted file mode 100644 index dd7bb49bc..000000000 --- a/scripts/deps/unused.js +++ /dev/null @@ -1,50 +0,0 @@ -const depcheck = require("depcheck"); -const { - resolve -} = require("path"); -const { - lstatSync, - readdirSync -} = require("fs"); - -const source = resolve(__dirname, "../../packages"); - -const pkgs = readdirSync(source) - .filter(name => lstatSync(`${source}/${name}`).isDirectory()) - .sort(); - -for (const pkg of pkgs) { - depcheck(`${source}/${pkg}`, { - ignoreDirs: [ - '__tests__', - 'benchmark', - 'dist', - 'docker', - 'scripts', - ], - ignoreMatches: [ - '@types/*' - ], - }, unused => { - const dependencies = Object.values(unused.dependencies); - const devDependencies = Object.values(unused.devDependencies); - - if (dependencies || devDependencies) { - console.log(`[FAIL] ${pkg}`) - - if (dependencies.length > 0) { - for (const dep of dependencies) { - console.log(`[PRO] ${dep}`) - } - } - - if (devDependencies.length > 0) { - for (const dep of devDependencies) { - console.log(`[DEV] ${dep}`) - } - } - } else { - console.log(`[PASS] ${pkg}`) - } - }); -}