Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-86dt279a1- Fix WalletConnectSdk Examples Build #110

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/check-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main

env:
NODE_VERSION: 16.x
NODE_VERSION: 18.x

jobs:
build-and-test:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 5 additions & 6 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
112 changes: 108 additions & 4 deletions e2e/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions e2e/src/helpers/CommandsHelper.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
3 changes: 3 additions & 0 deletions e2e/src/scripts/examplesBuild.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runCommandInEachExampleProj } from '../helpers/CommandsHelper'

runCommandInEachExampleProj('pnpm build')
3 changes: 3 additions & 0 deletions e2e/src/scripts/examplesClean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { removeLibsCash } from '../helpers/CommandsHelper'

removeLibsCash()
3 changes: 3 additions & 0 deletions e2e/src/scripts/examplesInstall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runCommandInEachExampleProj } from '../helpers/CommandsHelper'

runCommandInEachExampleProj('pnpm i')
4 changes: 4 additions & 0 deletions e2e/src/scripts/examplesRun.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { execSync } from 'child_process'
import { RUN_CONCURRENTLY_COMMAND } from '../constants/DevConstants'

execSync(RUN_CONCURRENTLY_COMMAND, { stdio: 'inherit' })
9 changes: 9 additions & 0 deletions e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"lib": ["ESNext"],
"outDir": "./dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions examples/wc-wallet-react/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
8 changes: 5 additions & 3 deletions examples/wc-wallet-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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"
}
}
Loading