diff --git a/.github/workflows/test-release-sync.yaml b/.github/workflows/test-release-sync.yaml index d31f6d33b..0ccde1fd8 100644 --- a/.github/workflows/test-release-sync.yaml +++ b/.github/workflows/test-release-sync.yaml @@ -4,11 +4,13 @@ on: pull_request: paths: - "**" + - ".github/workflows/**" push: branches: - main paths: - "**" + - ".github/workflows/**" jobs: update-lock-file: @@ -62,16 +64,19 @@ jobs: # Wait to see if the lock file should be updated before running checks: needs: "update-lock-file" runs-on: "ubuntu-22.04" + strategy: + matrix: + node-version: ["18.x", "20.x"] steps: - name: "Checkout" uses: "actions/checkout@v3" with: ref: ${{ needs.update-lock-file.outputs.VERIFIED_LOCK_COMMIT }} - - name: "Setup Node" + - name: "Setup Node v${{ matrix.node-version }}" uses: "actions/setup-node@v3" with: - node-version-file: ".nvmrc" + node-version: ${{ matrix.node-version }} cache: "yarn" cache-dependency-path: "yarn.lock" @@ -80,17 +85,6 @@ jobs: with: cwd: "." - - name: Restore turbo cache - uses: actions/cache@v3 - with: - path: ./node_modules/.cache/turbo - # see https://bit.ly/43Til68 - we only need a single cache for all turbo files - # but the cache still needs a unique id in order for it to properly save each time. - # restore-keys will always take the latest matching cache: - key: turbo-checks-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well - restore-keys: | - turbo-checks-${{ runner.os }} - - name: Setup .lightsparkenv file run: | echo 'export LIGHTSPARK_WALLET_BASE_URL="api.dev.dev.sparkinfra.net"' > ~/.lightsparkenv @@ -122,16 +116,19 @@ jobs: # Wait to see if the lock file should be updated before running checks: needs: "update-lock-file" runs-on: "ubuntu-22.04" + strategy: + matrix: + node-version: ["18.x", "20.x"] steps: - name: "Checkout" uses: "actions/checkout@v3" with: ref: ${{ needs.update-lock-file.outputs.VERIFIED_LOCK_COMMIT }} - - name: "Setup Node" + - name: "Setup Node v${{ matrix.node-version }}" uses: "actions/setup-node@v3" with: - node-version-file: ".nvmrc" + node-version: ${{ matrix.node-version }} cache: "yarn" cache-dependency-path: "yarn.lock" @@ -140,17 +137,6 @@ jobs: with: cwd: "." - - name: Restore turbo cache - uses: actions/cache@v3 - with: - path: ./node_modules/.cache/turbo - # see https://bit.ly/43Til68 - we only need a single cache for all turbo files - # but the cache still needs a unique id in order for it to properly save each time. - # restore-keys will always take the latest matching cache: - key: turbo-build-${{ runner.os }}-${{ github.run_id }} # Can use time based key as well - restore-keys: | - turbo-build-${{ runner.os }} - - run: "yarn build" # - name: "Notify failure on Slack" diff --git a/apps/examples/remote-signing-server/package.json b/apps/examples/remote-signing-server/package.json index a97bf75a8..fc780eaf2 100644 --- a/apps/examples/remote-signing-server/package.json +++ b/apps/examples/remote-signing-server/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "scripts": { - "start": "nodemon --watch 'src/*.ts' --exec 'ts-node' src/startServer.ts", + "start": "./start.sh", "test:start": "./test.sh start", "test": "./test.sh test" }, diff --git a/apps/examples/remote-signing-server/start.sh b/apps/examples/remote-signing-server/start.sh new file mode 100755 index 000000000..f259faccd --- /dev/null +++ b/apps/examples/remote-signing-server/start.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# See https://github.com/TypeStrong/ts-node/issues/1997#issuecomment-1774047586 +# ts-node has a known issue with es modules in Node.js 20 and above so we need to +# run with a different command to workaround with a warning: + +# Get the Node.js version and remove the 'v' prefix +NODE_VERSION=$(node -v | cut -c 2-) + +# Split the version string into major, minor, and patch numbers +IFS='.' read -ra VERSION_PARTS <<< "$NODE_VERSION" + +if (( ${VERSION_PARTS[0]} >= 20 )); then + CMD="node --loader ts-node/esm" +elif (( ${VERSION_PARTS[0]} == 18 )); then + CMD="ts-node" +else + echo "Only Node.js versions 18 and above are supported" +fi + +yarn nodemon --watch 'src/*.ts' --exec $CMD src/startServer.ts diff --git a/apps/examples/uma-vasp/package.json b/apps/examples/uma-vasp/package.json index 00dad8414..5339be171 100644 --- a/apps/examples/uma-vasp/package.json +++ b/apps/examples/uma-vasp/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "scripts": { - "start": "nodemon --watch 'src/*.ts' --exec 'ts-node' src/startServer.ts", + "start": "./start.sh", "test:start": "./test.sh start", "test": "./test.sh test" }, diff --git a/apps/examples/uma-vasp/start.sh b/apps/examples/uma-vasp/start.sh new file mode 100755 index 000000000..f259faccd --- /dev/null +++ b/apps/examples/uma-vasp/start.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# See https://github.com/TypeStrong/ts-node/issues/1997#issuecomment-1774047586 +# ts-node has a known issue with es modules in Node.js 20 and above so we need to +# run with a different command to workaround with a warning: + +# Get the Node.js version and remove the 'v' prefix +NODE_VERSION=$(node -v | cut -c 2-) + +# Split the version string into major, minor, and patch numbers +IFS='.' read -ra VERSION_PARTS <<< "$NODE_VERSION" + +if (( ${VERSION_PARTS[0]} >= 20 )); then + CMD="node --loader ts-node/esm" +elif (( ${VERSION_PARTS[0]} == 18 )); then + CMD="ts-node" +else + echo "Only Node.js versions 18 and above are supported" +fi + +yarn nodemon --watch 'src/*.ts' --exec $CMD src/startServer.ts diff --git a/packages/lightspark-cli/package.json b/packages/lightspark-cli/package.json index 42b3ef4a5..84a35dad6 100644 --- a/packages/lightspark-cli/package.json +++ b/packages/lightspark-cli/package.json @@ -9,8 +9,8 @@ "scripts": { "build": "tsc -p .", "clean": "rm -rf .turbo && rm -rf dist", - "dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "cli": "ts-node src/index.ts", + "cli:watch": "nodemon --watch 'src/**/*.ts' --exec 'node --loader ts-node/esm' src/index.ts", + "cli": "node --loader ts-node/esm src/index.ts", "format:fix": "prettier src --write", "format": "prettier src --check", "lint:fix": "eslint --fix .", diff --git a/packages/lightspark-sdk/package.json b/packages/lightspark-sdk/package.json index a931f2ecd..23cf9b4a0 100644 --- a/packages/lightspark-sdk/package.json +++ b/packages/lightspark-sdk/package.json @@ -112,7 +112,6 @@ "prettier": "3.0.2", "prettier-plugin-organize-imports": "^3.2.2", "ts-jest": "^29.1.1", - "ts-node": "^10.9.1", "tsc-absolute": "^1.0.1", "tsup": "^6.7.0", "typedoc": "^0.24.7", diff --git a/packages/wallet-cli/package.json b/packages/wallet-cli/package.json index e254562a2..7c97cb1ea 100644 --- a/packages/wallet-cli/package.json +++ b/packages/wallet-cli/package.json @@ -9,8 +9,8 @@ "scripts": { "build": "tsc -p .", "clean": "rm -rf .turbo && rm -rf dist", - "dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", - "cli": "ts-node src/index.ts", + "cli:watch": "nodemon --watch 'src/**/*.ts' --exec 'node --loader ts-node/esm' src/index.ts", + "cli": "node --loader ts-node/esm src/index.ts", "format:fix": "prettier src --write", "format": "prettier src --check", "lint:fix": "eslint --fix .", diff --git a/yarn.lock b/yarn.lock index 590225e1f..d7310dac2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3750,7 +3750,6 @@ __metadata: prettier: 3.0.2 prettier-plugin-organize-imports: ^3.2.2 ts-jest: ^29.1.1 - ts-node: ^10.9.1 tsc-absolute: ^1.0.1 tsup: ^6.7.0 typedoc: ^0.24.7