Skip to content

Commit

Permalink
feat: [EXC-23] CICD and playwright for nextjs passport example (#1990)
Browse files Browse the repository at this point in the history
Co-authored-by: Craig M. <[email protected]>
  • Loading branch information
zaidarain1 and proletesseract authored Jul 29, 2024
1 parent 867409e commit 02ae209
Show file tree
Hide file tree
Showing 76 changed files with 5,190 additions and 144,879 deletions.
16 changes: 13 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
"no-plusplus": ["off"],
"max-classes-per-file": ["off"],
"max-len": [
"error",
"error",
{ "code": 120, "ignoreComments": true, "ignoreTrailingComments": true }
],
],
"react/button-has-type": ["off"],
"no-restricted-syntax": [
"error",
"ForInStatement",
Expand All @@ -30,5 +31,14 @@
],
"import/no-extraneous-dependencies": ["off"],
"@typescript-eslint/return-await": ["off"]
}
},
"overrides": [
{
"files": ["./examples/passport/**"],
"rules": {
"@typescript-eslint/no-unused-vars": "warn",
"no-underscore-dangle": "warn"
}
}
]
}
53 changes: 53 additions & 0 deletions .github/workflows/build-lint-and-test-passport-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build lint and test all passport examples

on:
pull_request:
branches: [main]
merge_group:
branches: [main]

jobs:
build:
name: Build
runs-on: ubuntu-latest-4-cores
env:
NODE_OPTIONS: --max-old-space-size=14366
steps:
- name: Checkout
uses: actions/checkout@v4

- name: setup
uses: ./.github/actions/pr-setup

- name: Build passport examples
run: yarn build:examples:passport

lint:
name: Lint
runs-on: ubuntu-latest-4-cores
env:
NODE_OPTIONS: --max-old-space-size=14366
steps:
- name: Checkout
uses: actions/checkout@v4

- name: setup
uses: ./.github/actions/pr-setup

- name: Lint passport examples
run: yarn lint:examples:passport

test:
name: Test
runs-on: ubuntu-latest-4-cores
env:
NODE_OPTIONS: --max-old-space-size=14366
steps:
- name: Checkout
uses: actions/checkout@v4

- name: setup
uses: ./.github/actions/pr-setup

- name: Test passport examples
run: yarn test:examples:passport
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ cache/
*version.properties

.pnp.*
.yarn/
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.yarn/cache
.yarn/install-state.gz

.yalc
yalc.lock
Expand Down
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.1.cjs
24 changes: 12 additions & 12 deletions examples/passport/identity-with-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "identity-with-nextjs",
"name": "@examples/identity-with-nextjs",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "14.2.5",
"react": "^18",
"react-dom": "^18"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@imtbl/sdk": "latest",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"autoprefixer": "^10.4.19",
"eslint": "^8",
"eslint-config-next": "14.2.5",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.6",
"typescript": "^5"
},
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"start": "next start"
}
}
43 changes: 28 additions & 15 deletions examples/passport/identity-with-nextjs/src/context/passport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {
createContext, ReactNode, useCallback, useContext,
useMemo,
} from 'react';
import { config, passport } from '@imtbl/sdk';
import { ethers } from 'ethers';
Expand Down Expand Up @@ -134,22 +135,34 @@ export function PassportProvider({ children }: { children: ReactNode }) {
window.alert(`userProfile: ${JSON.stringify(userProfile)}`);
}, [passportInstance]);

const providerValue = useMemo(() => ({
passportInstance,
passportSilentInstance,
login,
logout,
logoutSilent,
loginWithoutWallet,
loginWithEthersjs,
getIdToken,
getAccessToken,
getLinkedAddresses,
getUserInfo,
}), [
passportInstance,
passportSilentInstance,
login,
logout,
logoutSilent,
loginWithoutWallet,
loginWithEthersjs,
getIdToken,
getAccessToken,
getLinkedAddresses,
getUserInfo,
]);

return (
<PassportContext.Provider
value={{
passportInstance,
passportSilentInstance,
login,
logout,
logoutSilent,
loginWithoutWallet,
loginWithEthersjs,
getIdToken,
getAccessToken,
getLinkedAddresses,
getUserInfo,
}}
>
<PassportContext.Provider value={providerValue}>
{children}
</PassportContext.Provider>
);
Expand Down
Loading

0 comments on commit 02ae209

Please sign in to comment.