diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index bf88bd3a9b..9e5017dbb6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -62,7 +62,7 @@ jobs: run: yarn check-format - name: Compile - run: yarn compile + run: yarn check-types integration-test: runs-on: ubuntu-20.04 diff --git a/package.json b/package.json index 0875070577..bb9c60c927 100644 --- a/package.json +++ b/package.json @@ -5,24 +5,25 @@ "main": "build/src/index.js", "types": "build/src/index.d.ts", "files": [ - "build/src" + "build" ], "repository": { "url": "https://github.com/hyperledger/aries-framework-javascript", "type": "git" }, "scripts": { - "compile": "tsc", + "compile": "tsc --project tsconfig.build.json", + "check-types:build": "yarn compile --noEmit", + "check-types": "tsc --noEmit", "lint": "eslint .", "prettier": "prettier --ignore-path .gitignore '**/*.+(js|json|ts|md|yml|yaml)'", "format": "yarn prettier --write", "check-format": "yarn prettier --list-different", "test": "jest --verbose", "dev": "ts-node-dev --respawn --transpile-only ./tests/mediator.ts", - "prod:start": "node ./build/tests/mediator.js", - "prod:start-ws": "node ./build/tests/mediator-ws.js", - "prod:build": "rm -rf build && yarn compile", - "validate": "npm-run-all --parallel lint compile", + "mediator:start": "ts-node ./tests/mediator.ts", + "mediator:start-ws": "ts-node ./tests/mediator-ws.ts", + "validate": "npm-run-all --parallel lint check-types", "prepack": "rm -rf build && yarn compile", "release": "release-it", "prepare": "husky install" diff --git a/scripts/run-mediator.sh b/scripts/run-mediator.sh index e81bfed001..016d334d6e 100755 --- a/scripts/run-mediator.sh +++ b/scripts/run-mediator.sh @@ -13,7 +13,7 @@ if [[ "$AGENT" = "mediator01" ]] || [[ "$AGENT" = "alice" ]]; then WALLET_NAME=mediator01 WALLET_KEY=0000000000000000000000000Mediator01 PUBLIC_DID_SEED=00000000000000000000000Forward01 - MEDIATOR_COMMAND="prod:start" + MEDIATOR_COMMAND="mediator:start" elif [[ "$AGENT" = "mediator02" ]] || [[ "$AGENT" = "bob" ]]; then AGENT_ENDPOINT="${AGENT_ENDPOINT:-http://localhost:3002}" AGENT_HOST=http://localhost @@ -22,7 +22,7 @@ elif [[ "$AGENT" = "mediator02" ]] || [[ "$AGENT" = "bob" ]]; then WALLET_NAME=mediator02 WALLET_KEY=0000000000000000000000000Mediator02 PUBLIC_DID_SEED=00000000000000000000000Forward02 - MEDIATOR_COMMAND="prod:start" + MEDIATOR_COMMAND="mediator:start" elif [[ "$AGENT" = "mediator03" ]] || [[ "$AGENT" = "alice-ws" ]]; then AGENT_ENDPOINT="${AGENT_ENDPOINT:-http://localhost:3003}" AGENT_HOST=http://localhost @@ -32,7 +32,7 @@ elif [[ "$AGENT" = "mediator03" ]] || [[ "$AGENT" = "alice-ws" ]]; then WALLET_KEY=0000000000000000000000000Mediator03 PUBLIC_DID=DtWRdd6C5dN5vpcN6XRAvu PUBLIC_DID_SEED=00000000000000000000000Forward03 - MEDIATOR_COMMAND="prod:start-ws" + MEDIATOR_COMMAND="mediator:start-ws" elif [[ "$AGENT" = "mediator04" ]] || [[ "$AGENT" = "bob-ws" ]]; then AGENT_ENDPOINT="${AGENT_ENDPOINT:-http://localhost:3004}" AGENT_HOST=http://localhost @@ -42,15 +42,10 @@ elif [[ "$AGENT" = "mediator04" ]] || [[ "$AGENT" = "bob-ws" ]]; then WALLET_KEY=0000000000000000000000000Mediator04 PUBLIC_DID=SHbU5SEwdmkQkVQ1sMwSEv PUBLIC_DID_SEED=00000000000000000000000Forward04 - MEDIATOR_COMMAND="prod:start-ws" + MEDIATOR_COMMAND="mediator:start-ws" else echo "Please specify which agent you want to run. Choose from 'alice', 'alice-ws', 'bob' or 'bob-ws'." exit 1 fi -# Docker image already compiles. Not needed to do again -if [ "$RUN_MODE" != "docker" ]; then - ${YARN_COMMAND} prod:build -fi - AGENT_ENDPOINT=${AGENT_ENDPOINT} AGENT_HOST=${AGENT_HOST} AGENT_PORT=${AGENT_PORT} AGENT_LABEL=${AGENT_LABEL} WALLET_NAME=${WALLET_NAME} WALLET_KEY=${WALLET_KEY} PUBLIC_DID=${PUBLIC_DID} PUBLIC_DID_SEED=${PUBLIC_DID_SEED} ${YARN_COMMAND} ${MEDIATOR_COMMAND} diff --git a/src/modules/credentials/__tests__/StubWallet.ts b/src/modules/credentials/__tests__/StubWallet.ts index 02913ce81d..e63673efac 100644 --- a/src/modules/credentials/__tests__/StubWallet.ts +++ b/src/modules/credentials/__tests__/StubWallet.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import type { PackedMessage, UnpackedMessageContext } from '../../../types' +import type { Buffer } from '../../../utils/buffer' import type { Wallet } from '../../../wallet/Wallet' import type { DidConfig, WalletRecordOptions, WalletRecord, WalletQuery, LedgerRequest } from 'indy-sdk' diff --git a/types/borc.d.ts b/src/types/borc.d.ts similarity index 100% rename from types/borc.d.ts rename to src/types/borc.d.ts diff --git a/src/utils/__tests__/BufferEncoder.test.ts b/src/utils/__tests__/BufferEncoder.test.ts index e2b84cd85e..444e4c6fe4 100644 --- a/src/utils/__tests__/BufferEncoder.test.ts +++ b/src/utils/__tests__/BufferEncoder.test.ts @@ -1,4 +1,5 @@ import { BufferEncoder } from '../BufferEncoder' +import { Buffer } from '../buffer' describe('BufferEncoder', () => { const mockCredentialRequestBuffer = Buffer.from( diff --git a/src/utils/__tests__/JsonEncoder.test.ts b/src/utils/__tests__/JsonEncoder.test.ts index 0cdae77a8d..21e688adfc 100644 --- a/src/utils/__tests__/JsonEncoder.test.ts +++ b/src/utils/__tests__/JsonEncoder.test.ts @@ -1,4 +1,5 @@ import { JsonEncoder } from '../JsonEncoder' +import { Buffer } from '../buffer' describe('JsonEncoder', () => { const mockCredentialRequest = { diff --git a/src/wallet/IndyWallet.ts b/src/wallet/IndyWallet.ts index 7bafc7e4c3..b36abb1c51 100644 --- a/src/wallet/IndyWallet.ts +++ b/src/wallet/IndyWallet.ts @@ -1,5 +1,6 @@ import type { Logger } from '../logger' import type { PackedMessage, UnpackedMessageContext } from '../types' +import type { Buffer } from '../utils/buffer' import type { Wallet, DidInfo } from './Wallet' import type { default as Indy, diff --git a/src/wallet/Wallet.ts b/src/wallet/Wallet.ts index 2046d9fa97..f8e931302f 100644 --- a/src/wallet/Wallet.ts +++ b/src/wallet/Wallet.ts @@ -1,4 +1,5 @@ import type { PackedMessage, UnpackedMessageContext } from '../types' +import type { Buffer } from '../utils/buffer' import type { DidConfig, Did, diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000000..37fe4a87e5 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2017", + "module": "commonjs", + "lib": [], + "declaration": true, + "sourceMap": true, + "outDir": "./build", + "strict": true, + "resolveJsonModule": true, + "types": [], + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true + }, + "include": ["./src"], + "exclude": [ + "**/*.test.ts", + "**/__tests__/**", + "**/__mocks__/**", + "node_modules", + "**/node_modules", + "**/node_modules/**" + ] +} diff --git a/tsconfig.json b/tsconfig.json index b09ab5ca9b..23cad1270f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,8 @@ { + "extends": "./tsconfig.build.json", "compilerOptions": { - "target": "ES2017", - "module": "commonjs", - "lib": [], - "declaration": true, - "sourceMap": true, - "outDir": "./build", - "strict": true, - "typeRoots": ["node_modules/@types", "./types"], - "types": ["jest"], - "esModuleInterop": true, - "resolveJsonModule": true, - "experimentalDecorators": true, - "emitDecoratorMetadata": true - } + "types": ["jest"] + }, + "include": ["src", "types", "tests", "*.config.js"], + "exclude": ["node_modules", "build", "**/node_modules", "**/node_modules/**"] } diff --git a/types/util-inspect.d.ts b/types/util-inspect.d.ts deleted file mode 100644 index 497233898b..0000000000 --- a/types/util-inspect.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'util-inspect'