From 337b3436774d9af584054ae995369d98ea886dec Mon Sep 17 00:00:00 2001 From: Leonidas Conde <80922146+LeonardoDizConde@users.noreply.github.com> Date: Wed, 27 Mar 2024 20:05:14 -0300 Subject: [PATCH] CU-86dt279a1- Fix WalletConnectSdk Examples Build --- .github/workflows/check-build-and-test.yml | 6 +- .github/workflows/main.yml | 4 +- e2e/package.json | 11 +- e2e/pnpm-lock.yaml | 112 ++++++++++++++++++- e2e/src/helpers/CommandsHelper.ts | 47 ++++++++ e2e/src/scripts/examplesBuild.ts | 3 + e2e/src/scripts/examplesClean.ts | 3 + e2e/src/scripts/examplesInstall.ts | 3 + e2e/src/scripts/examplesRun.ts | 4 + e2e/tsconfig.json | 9 ++ examples/wc-wallet-react/config-overrides.js | 1 + examples/wc-wallet-react/package.json | 8 +- 12 files changed, 193 insertions(+), 18 deletions(-) create mode 100644 e2e/src/helpers/CommandsHelper.ts create mode 100644 e2e/src/scripts/examplesBuild.ts create mode 100644 e2e/src/scripts/examplesClean.ts create mode 100644 e2e/src/scripts/examplesInstall.ts create mode 100644 e2e/src/scripts/examplesRun.ts create mode 100644 e2e/tsconfig.json diff --git a/.github/workflows/check-build-and-test.yml b/.github/workflows/check-build-and-test.yml index 0f86a68..1da513e 100644 --- a/.github/workflows/check-build-and-test.yml +++ b/.github/workflows/check-build-and-test.yml @@ -5,7 +5,7 @@ on: - main env: - NODE_VERSION: 16.x + NODE_VERSION: 18.x jobs: build-and-test: @@ -39,10 +39,10 @@ jobs: run: pnpm i - name: Install Examples Dependencies working-directory: ./e2e - run: pnpm ex:install:unix + run: pnpm ex:install - name: Build Examples working-directory: ./e2e - run: pnpm ex:build:unix + run: pnpm ex:build - name: Test E2E working-directory: ./e2e run: pnpm test:headless diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9805443..31d1e6b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,5 +18,5 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4" - exclude: "**/*.json, **/*.md" # Optional: exclude patterns separated by commas + OPENAI_API_MODEL: 'gpt-4' # Optional: defaults to "gpt-4" + exclude: '**/*.json, **/*.md' # Optional: exclude patterns separated by commas diff --git a/e2e/package.json b/e2e/package.json index da09c17..8d2989d 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -4,12 +4,10 @@ "description": "wallet-connect-sdk e2e(end to end) tester", "private": true, "scripts": { - "ex:build:unix": "cd ../examples && for d in */; do (cd \"$d\" && pnpm build && cd ..); done", - "ex:build:windows": "cd ../examples && for /d %i in (*) do (cd %i && pnpm build && cd ..)", - "ex:clean:unix": "rush purge && cd ../examples && for d in */; do (cd \"$d\" && rm -rf node_modules pnpm-lock.yaml && cd ..); done", - "ex:clean:windows": "rush purge && cd ../examples && for /d %i in (*) do (cd %i && rm -rf node_modules pnpm-lock.yaml && cd ..)", - "ex:install:unix": "cd ../examples && for d in */; do (cd \"$d\" && pnpm install && cd ..); done", - "ex:install:windows": "cd ../examples && for /d %i in (*) do (cd %i && pnpm install && cd ..)", + "ex:build": "ts-node src/scripts/examplesBuild.ts", + "ex:clean": "ts-node src/scripts/examplesClean.ts && rush purge", + "ex:install": "ts-node src/scripts/examplesInstall.ts", + "ex:run": "ts-node src/scripts/examplesRun.ts", "format": "prettier . --write && eslint --fix", "lint": "prettier . --check && eslint", "prepare": "npm install serve -g && pnpm exec playwright install", @@ -26,6 +24,7 @@ "eslint": "^8.50.0", "playwright": "^1.38.1", "prettier": "^3.0.3", + "ts-node": "10.9.1", "typescript": "^5.2.2" }, "dependencies": { diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 14ce23c..ed2f8cb 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: concurrently: specifier: ^8.2.1 @@ -30,6 +34,9 @@ devDependencies: prettier: specifier: ^3.0.3 version: 3.0.3 + ts-node: + specifier: 10.9.1 + version: 10.9.1(@types/node@20.8.2)(typescript@5.2.2) typescript: specifier: ^5.2.2 version: 5.2.2 @@ -48,6 +55,13 @@ packages: regenerator-runtime: 0.14.0 dev: false + /@cspotcode/source-map-support@0.8.1: + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + dev: true + /@eslint-community/eslint-utils@4.4.0(eslint@8.50.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -105,6 +119,22 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@jridgewell/resolve-uri@3.1.2: + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + dev: true + + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: true + + /@jridgewell/trace-mapping@0.3.9: + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.4.15 + dev: true + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -134,6 +164,22 @@ packages: playwright: 1.38.1 dev: true + /@tsconfig/node10@1.0.10: + resolution: {integrity: sha512-PiaIWIoPvO6qm6t114ropMCagj6YAF24j9OkCA2mJDXFnlionEwhsBCJ8yek4aib575BI3OkART/90WsgHgLWw==} + dev: true + + /@tsconfig/node12@1.0.11: + resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} + dev: true + + /@tsconfig/node14@1.0.3: + resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} + dev: true + + /@tsconfig/node16@1.0.4: + resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + dev: true + /@types/json-schema@7.0.13: resolution: {integrity: sha512-RbSSoHliUbnXj3ny0CNFOoxrIDV6SUGyStHsvDqosw6CkdPV8TtWGlfecuK4ToyMEAql6pzNxgCFKanovUzlgQ==} dev: true @@ -285,6 +331,11 @@ packages: acorn: 8.10.0 dev: true + /acorn-walk@8.3.2: + resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} + engines: {node: '>=0.4.0'} + dev: true + /acorn@8.10.0: resolution: {integrity: sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==} engines: {node: '>=0.4.0'} @@ -310,6 +361,10 @@ packages: dependencies: color-convert: 2.0.1 + /arg@4.1.3: + resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} + dev: true + /argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true @@ -387,6 +442,10 @@ packages: yargs: 17.7.2 dev: false + /create-require@1.1.1: + resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + dev: true + /cross-env@7.0.3: resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} @@ -426,6 +485,11 @@ packages: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true + /diff@4.0.2: + resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} + engines: {node: '>=0.3.1'} + dev: true + /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -793,6 +857,10 @@ packages: yallist: 4.0.0 dev: true + /make-error@1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + dev: true + /merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} @@ -1046,6 +1114,37 @@ packages: typescript: 5.2.2 dev: true + /ts-node@10.9.1(@types/node@20.8.2)(typescript@5.2.2): + resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.10 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 20.8.2 + acorn: 8.10.0 + acorn-walk: 8.3.2 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.2.2 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + dev: true + /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} dev: false @@ -1074,6 +1173,10 @@ packages: punycode: 2.3.0 dev: true + /v8-compile-cache-lib@3.0.1: + resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + dev: true + /which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -1121,11 +1224,12 @@ packages: yargs-parser: 21.1.1 dev: false + /yn@3.1.1: + resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} + engines: {node: '>=6'} + dev: true + /yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} dev: true - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false diff --git a/e2e/src/helpers/CommandsHelper.ts b/e2e/src/helpers/CommandsHelper.ts new file mode 100644 index 0000000..624e516 --- /dev/null +++ b/e2e/src/helpers/CommandsHelper.ts @@ -0,0 +1,47 @@ +import * as fs from 'fs' +import { execSync } from 'child_process' +import * as path from 'path' +import { EXAMPLES_PATH } from '../constants/PathsDefinitions' + +const examplesPath = path.posix.normalize(EXAMPLES_PATH) + +function getAllExamples(): string[] { + return fs.readdirSync(examplesPath) +} +export function runCommandInEachExampleProj(cmd: string) { + let error = false + const packages = getAllExamples() + for (const lib of packages) { + try { + const pathLib = path.posix.join(examplesPath, lib) + execSync(`${cmd}`, { cwd: pathLib, stdio: 'inherit' }) + } catch { + error = true + } + } + if (error) { + console.error('\nPlease, check the errors above before committing/pushing!\n') + process.exitCode = 1 + } +} + +export function removeLibsCash() { + let error = false + const packages = getAllExamples() + for (const lib of packages) { + try { + console.log(`Cleaning libs cash from ${lib}\n`) + const pathLib = path.posix.join(examplesPath, lib) + const nodeModules = path.posix.join(pathLib, 'node_modules') + const packageManagerLock = path.posix.join(pathLib, 'pnpm-lock.yaml') + if (fs.existsSync(nodeModules)) fs.rmSync(nodeModules, { recursive: true }) + if (fs.existsSync(packageManagerLock)) fs.rmSync(packageManagerLock) + } catch { + error = true + } + } + if (error) { + console.error('\nPlease, check the errors above before committing/pushing!\n') + process.exitCode = 1 + } +} diff --git a/e2e/src/scripts/examplesBuild.ts b/e2e/src/scripts/examplesBuild.ts new file mode 100644 index 0000000..d8d3835 --- /dev/null +++ b/e2e/src/scripts/examplesBuild.ts @@ -0,0 +1,3 @@ +import { runCommandInEachExampleProj } from '../helpers/CommandsHelper' + +runCommandInEachExampleProj('pnpm build') diff --git a/e2e/src/scripts/examplesClean.ts b/e2e/src/scripts/examplesClean.ts new file mode 100644 index 0000000..039830e --- /dev/null +++ b/e2e/src/scripts/examplesClean.ts @@ -0,0 +1,3 @@ +import { removeLibsCash } from '../helpers/CommandsHelper' + +removeLibsCash() diff --git a/e2e/src/scripts/examplesInstall.ts b/e2e/src/scripts/examplesInstall.ts new file mode 100644 index 0000000..7eba4a5 --- /dev/null +++ b/e2e/src/scripts/examplesInstall.ts @@ -0,0 +1,3 @@ +import { runCommandInEachExampleProj } from '../helpers/CommandsHelper' + +runCommandInEachExampleProj('pnpm i') diff --git a/e2e/src/scripts/examplesRun.ts b/e2e/src/scripts/examplesRun.ts new file mode 100644 index 0000000..01b045b --- /dev/null +++ b/e2e/src/scripts/examplesRun.ts @@ -0,0 +1,4 @@ +import { execSync } from 'child_process' +import { RUN_CONCURRENTLY_COMMAND } from '../constants/DevConstants' + +execSync(RUN_CONCURRENTLY_COMMAND, { stdio: 'inherit' }) diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json new file mode 100644 index 0000000..6f1ca3a --- /dev/null +++ b/e2e/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "lib": ["ESNext"], + "outDir": "./dist" + }, + "include": ["src/**/*"], + "exclude": ["node_modules"] +} diff --git a/examples/wc-wallet-react/config-overrides.js b/examples/wc-wallet-react/config-overrides.js index 0e7c09f..ee680b6 100644 --- a/examples/wc-wallet-react/config-overrides.js +++ b/examples/wc-wallet-react/config-overrides.js @@ -4,6 +4,7 @@ module.exports = function override(config) { resolve: { fullySpecified: false, fallback: { + vm: require.resolve('vm-browserify'), crypto: require.resolve('crypto-browserify'), querystring: require.resolve('querystring-es3'), stream: require.resolve('stream-browserify'), diff --git a/examples/wc-wallet-react/package.json b/examples/wc-wallet-react/package.json index 253a32d..f9e818d 100644 --- a/examples/wc-wallet-react/package.json +++ b/examples/wc-wallet-react/package.json @@ -44,7 +44,8 @@ "react-scripts": "^5.0.1", "stream-browserify": "^3.0.0", "styled-components": "^5.2.0", - "typescript": "^4.2.3" + "typescript": "^4.2.3", + "vm-browserify": "^1.1.2" }, "eslintConfig": { "extends": [ @@ -73,10 +74,11 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^3.4.0", "prettier": "^2.3.1", - "react-app-rewired": "^2.2.1" + "react-app-rewired": "2.2.1" }, "resolutions": { "@cityofzion/wallet-connect-sdk-wallet-core": "file:../../packages/wallet-connect-sdk-wallet-core", - "@cityofzion/wallet-connect-sdk-core": "file:../../packages/wallet-connect-sdk-core" + "@cityofzion/wallet-connect-sdk-core": "file:../../packages/wallet-connect-sdk-core", + "readable-stream": "4.4.2" } }