Skip to content

Commit

Permalink
feat!: Nx workspaces migration 🛠 (#2965)
Browse files Browse the repository at this point in the history
* fix(twap): display actual value for num of parts and custom deadline

* chore: align project structure corresponding to nx

* chore: fix project files to fit Vite

* chore: update npm deps

* chore: fix configs

* chore: remove invalid files

* chore: temporary add lingui config to root

* chore: temporary script

* chore: temporary script

* chore: fix CI scripts

* chore: fix jest preset

* chore: fix run-many scripts

* ci: fix cypress and lint

* ci: fix cypress

* chore: try to fix cypress CI

* chore: try to fix cypress CI

* chore: fix jest snapshots

* chore: try to fix cypress CI

* chore: disable cypress video

* chore: update editorconfig

* chore: build i18n before bundle

* fix: fix locale file loading

* chore: fix cypress baseUrl

* chore: fix husky version

* chore: merge develop

* chore: merge develop

* chore: fix e2e tests

* chore: disable VitePWA for dev

* chore: fix e2e

* chore: fix e2e

* chore: fix e2e

* chore: fix e2e

* fix: fix deps for WalletConnect

* fix: fix tests

* fix: fix global

* chore: fix i18n key

* chore: fix i18n key

* chore: fix Buffer

* chore: fix test

* chore: fix SW

* chore: fix test

* chore: test commit to trigger cache

* chore: move version to root package.json

* chore: split bundle into vendor/core-vendor/other

* chore: split vendor bundle

* fix: fix wc2 init

* chore: patch @walletconnect/universal-provider

* chore: expose `yarn preview` command used to build and serve a local version

* chore: delete patch

* fix: fix walletconnects

* feat: use original SW config

* chore: test commit

* chore: test commit

* chore: test commit

* fix: fix isChunkLoadError

---------

Co-authored-by: Alfetopito <[email protected]>
  • Loading branch information
shoom3301 and alfetopito authored Aug 10, 2023
1 parent 36975f7 commit f6f4e4d
Show file tree
Hide file tree
Showing 1,824 changed files with 6,685 additions and 9,977 deletions.
8 changes: 6 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Editor configuration, see https://editorconfig.org
# Editor configuration, see http://editorconfig.org
root = true

[*]
Expand All @@ -9,7 +9,11 @@ insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf

[*.md]
max_line_length = off
trim_trailing_whitespace = false

[{*.ts,*.tsx}]
ij_typescript_force_quote_style = true
ij_typescript_use_double_quotes = false
ij_typescript_use_semicolon_after_statement = false
ij_typescript_use_semicolon_after_statement = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
112 changes: 27 additions & 85 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,93 +1,35 @@
{
"extends": ["react-app", "react-app/jest", "plugin:cypress/recommended"],
"plugins": ["unused-imports"],
"ignorePatterns": ["node_modules/", "dist/", "build", "coverage", "./", "cypress/", "src/libs/abis/src/generated"],
"rules": {
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "ethers",
"message": "Please import from '@ethersproject/module' directly to support tree-shaking."
},
{
"name": "styled-components",
"message": "Please import from styled-components/macro."
}
],
"patterns": [
{
"group": ["**/dist"],
"message": "Do not import from dist/ - this is an implementation detail, and breaks tree-shaking."
},
{
"group": ["!styled-components/macro"]
}
]
}
],
"no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
],
"import/order": [
"error",
{
"pathGroups": [
{
"pattern": "{@cowprotocol,@uniswap,@safe-global,@ethersproject,@web3-react}/**",
"group": "external",
"position": "before"
},
{
"pattern": "{react,jotai,jotai/*}",
"group": "external",
"position": "before"
},
{
"pattern": "legacy/**",
"group": "external",
"position": "after"
},
{
"pattern": "modules/**",
"group": "builtin",
"position": "after"
},
{
"pattern": "{api,abis,common,constants,legacy,lib,pages,types,utils}/**",
"group": "internal",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["react"],
"groups": ["external", "builtin", "internal", "sibling", "parent", "object", "index", "type"],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"newlines-between": "always"
}
],
"prefer-const": "error",
"no-unneeded-ternary": "error",
"no-var": "error"
},
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["cypress/**", "cypress-custom/**"],
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"jest/valid-expect": 0,
"testing-library/await-async-utils": 0
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
}
]
}
24 changes: 7 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,9 @@ jobs:
src/locales
key: ${{ runner.os }}-generatedFiles-${{ hashFiles('**/yarn.lock') }}

- name: Run linters
uses: wearerequired/lint-action@v2
with:
github_token: ${{ secrets.github_token }}
eslint: true
eslint_args: "-c .eslintrc.json ."
auto_fix: ${{ github.event_name == 'pull_request' }}
prettier: true


- name: Run eslint
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != github.repository_owner }}
run: yarn eslint .
run: yarn lint

vercel-dev:
# Deploys to Vercel dev environment
Expand Down Expand Up @@ -211,18 +201,18 @@ jobs:
if: steps.cypress-deps.outcome == 'failure'
run: npx cypress install

- name: Start server in the background
run: yarn start &

# Actually run tests, building repo
- name: Cypress run
id: cypress-run
uses: cypress-io/github-action@v5.0.5
uses: cypress-io/github-action@v5.8.3
with:
# Uncomment to test the production release. Right now, it doens't work the automatic "connection"
# very likely it's related to Web3StatusMod!
# when un-commenting this, we need to uncomment also the "Download website" I added in this PR and prevent cypres from buildig the project again
# start: yarn serve:ci
start: yarn start
wait-on: http://localhost:3000
wait-on-timeout: 200
install: false
working-directory: apps/cowswap-frontend-e2e
env:
CYPRESS_INTEGRATION_TEST_PRIVATE_KEY: ${{ secrets.CYPRESS_INTEGRATION_TEST_PRIVATE_KEY }}
CYPRESS_INTEGRATION_TESTS_INFURA_KEY: ${{ secrets.CYPRESS_INTEGRATION_TESTS_INFURA_KEY }}
Expand Down
84 changes: 32 additions & 52 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,60 +1,40 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.
# See http://help.github.com/ignore-files/ for more about ignoring files.

# generated contract types
/src/lib/locales/**/*.js
/src/lib/locales/**/en-US.po
/src/lib/locales/**/pseudo.po
/src/locales/**/*.js
/src/locales/**/*.ts
/src/locales/**/*.json
/src/locales/**/en-US.po
/src/locales/**/pseudo.po
# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# testing
/coverage
cypress.env.json

# builds
/build
/dts
/public/cosmos
/dist
# IDEs and editors
/.idea
.swc
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

/.netlify

npm-debug.log*
yarn-debug.log*
yarn-error.log*

notes.txt
.idea/

.vscode/

package-lock.json

cypress/videos
cypress/screenshots
cypress/fixtures/example.json
cypress-custom/videos
cypress-custom/screenshots
cypress-custom/fixtures/example.json

.yalc*
yalc.lock

# public
public/version.json
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# vercel
.vercel
# System Files
.DS_Store
Thumbs.db
25 changes: 3 additions & 22 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
# generated stuff
/src/state/data/generated.ts
build
.git
.github
src/**/*.d.ts
src/**/docs/*
src/abis
src/legacy/abis
src/legacy/types
CHANGELOG.md

# inherited from uniswap, better not touch it
public_uniswap/index.html
public/index.html

# Every commit this is changed. NO MORE!
tsconfig.json

# local stuff
.yalc
.vscode
# Add files here to ignore them from prettier formatting
/dist
/coverage
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Please see the:
- [CoW Protocol: Smart contracts](https://github.com/cowprotocol/contracts)
- [CoW Protocol: Services](https://github.com/cowprotocol/services)

You can block an entire list of tokens by passing in a tokenlist like [here](./src/constants/lists.ts) or you can block specific tokens by adding them to [unsupported.tokenlist.json](./src/constants/tokenLists/unsupported.tokenlist.json).
You can block an entire list of tokens by passing in a tokenlist like [here](apps/cowswap-frontend/src/constants/lists.ts) or you can block specific tokens by adding them to [unsupported.tokenlist.json](apps/cowswap-frontend/src/constants/tokenLists/unsupported.tokenlist.json).

### Install Dependencies

Expand Down Expand Up @@ -176,7 +176,7 @@ To update its content:

## Service worker

In case of problems with the service worker cache you force a reset using [emergency.js](public/emergency.js)
In case of problems with the service worker cache you force a reset using [emergency.js](apps/cowswap-frontend/public/emergency.js)
The plan:

1. `const resetCacheInCaseOfEmergency = false` - change `false` to `true`
Expand All @@ -197,5 +197,5 @@ REACT_APP_WALLET_CONNECT_V1_BRIDGE='https://bridge.walletconnect.org'
## Documentation

1. [Oveall Architecture](docs/architecture-overview.md)
2. [Amounts formatting](src/utils/amountFormat/README.md)
3. [ABIs](src/libs/abis/README.md)
2. [Amounts formatting](apps/cowswap-frontend/src/utils/amountFormat/README.md)
3. [ABIs](libs/abis/README.md)
Empty file added apps/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions apps/cowswap-frontend-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"cypress/unsafe-to-chain-command": "off"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
}
]
}
1 change: 1 addition & 0 deletions apps/cowswap-frontend-e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cypress.env.json
16 changes: 16 additions & 0 deletions apps/cowswap-frontend-e2e/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from 'cypress'
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'

export default defineConfig({
e2e: {
...nxE2EPreset(__dirname, {
bundler: 'vite',
}),
specPattern: ['src/**/*.test.{js,jsx,ts,tsx}'],
baseUrl: 'http://localhost:3000',
supportFile: 'src/support/index.ts',
video: false,
screenshotOnRunFailure: false,
defaultCommandTimeout: 15_000
},
})
8 changes: 8 additions & 0 deletions apps/cowswap-frontend-e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@cowprotocol/cowswap-e2e",
"version": "0.0.1",
"description": "CoW Swap e2e tests",
"main": "index.js",
"author": "",
"license": "ISC"
}
Loading

0 comments on commit f6f4e4d

Please sign in to comment.