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

Feat/bootstrap #1

Merged
merged 2 commits into from
Jul 24, 2023
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
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"image": "mcr.microsoft.com/devcontainers/universal:2",
"features": {
"ghcr.io/devcontainers-contrib/features/pnpm:2": {},
"ghcr.io/devcontainers-contrib/features/nx-npm:1": {}
},
"forwardPorts": [
4200
],
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"nrwl.angular-console",
"esbenp.prettier-vscode",
"quicktype.quicktype",
"oderwat.indent-rainbow",
"eamodio.gitlens",
"vscodevim.vim"
]
}
},

}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
35 changes: 35 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@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": {}
}
]
}
27 changes: 27 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and Deploy Storybook
on:
push
jobs:
deploy-storybook:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Init 🖥
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build Storybook
run: pnpm build-storybook
- name: Deploy 🚀
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist/storybook/shared-storybook
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
dist
tmp
/out-tsc

# dependencies
node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

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

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

# System Files
.DS_Store
Thumbs.db
2 changes: 2 additions & 0 deletions .npmrc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is strict-peer-dependencies the same as legacy-peer-deps or is that something different? I'd like to try keep the correct peer deps if we can without bypassing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's pretty much it. It is part of the boilerplate generated by NX. I can remove it, at least for now it shouldn't break anything

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
strict-peer-dependencies=false
auto-install-peers=true
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Add files here to ignore them from prettier formatting
/dist
/coverage
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
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"
]
}
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
# origin-defi
# Origin Defi

## Start any the app

To start the development server run `nx serve ousd` or `nx serve oeth`. Open your browser and navigate to http://localhost:4200/. Happy coding!

## Storybook

There is a shared storybook aggregator that can run all the stories across all the libraries, run
`pnpm storybook`. If you want to run storybook for one individual library (eg: ousd) simply run `pnpm nx storybook defi-ousd` (basically the command is `pnpm nx storybook name-of-the-lib`).

## Translations

Basic translation setup was added to the repo. It might require some changes depending on how we would structure our translations and our modules, but for now it extracts and compiles translations available in the `apps` folder and the appropriate module in in `libs/defi/module-name`.

## Running tasks

To execute tasks with Nx use the following syntax:

```
nx <target> <project> <...options>
```

You can also run multiple targets:

```
nx run-many -t <target1> <target2>
```

..or add `-p` to filter specific projects

```
nx run-many -t <target1> <target2> -p <proj1> <proj2>
```

Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/core-features/run-tasks).
Empty file added apps/.gitkeep
Empty file.
18 changes: 18 additions & 0 deletions apps/oeth/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
16 changes: 16 additions & 0 deletions apps/oeth/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Oeth</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="stylesheet" href="/src/styles.css" />
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
85 changes: 85 additions & 0 deletions apps/oeth/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"name": "oeth",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/oeth/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/vite:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/apps/oeth"
},
"configurations": {
"development": {
"mode": "development"
},
"production": {
"mode": "production"
}
}
},
"serve": {
"executor": "@nx/vite:dev-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "oeth:build"
},
"configurations": {
"development": {
"buildTarget": "oeth:build:development",
"hmr": true,
"host": true
},
"production": {
"buildTarget": "oeth:build:production",
"hmr": false
}
}
},
"preview": {
"executor": "@nx/vite:preview-server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "oeth:build"
},
"configurations": {
"development": {
"buildTarget": "oeth:build:development"
},
"production": {
"buildTarget": "oeth:build:production"
}
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["coverage/apps/oeth"],
"options": {
"passWithNoTests": true,
"reportsDirectory": "../../coverage/apps/oeth"
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/oeth/**/*.{ts,tsx,js,jsx}"]
}
},
"i18n-extract": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm formatjs extract '{apps/oeth,libs/defi/oeth}/**/!(*.d).{ts,tsx}' --out-file apps/oeth/src/lang/en.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'"
}
},
"i18n-compile": {
"executor": "nx:run-commands",
"options": {
"command": "pnpm formatjs compile 'apps/oeth/src/lang/en.json' --out-file apps/oeth/src/lang/enUS.json"
}
}
},
"tags": []
}
Binary file added apps/oeth/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions apps/oeth/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// placeholder component until we actually start migration
export function OUSDRoot() {
return <h1>ousd</h1>
}
8 changes: 8 additions & 0 deletions apps/oeth/src/lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"xomxyH": {
"defaultMessage": "Welcome to DefiOeth!"
},
"y6cogA": {
"defaultMessage": "test OEth"
}
}
4 changes: 4 additions & 0 deletions apps/oeth/src/lang/enUS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"xomxyH": "Welcome to DefiOeth!",
"y6cogA": "test OEth"
}
3 changes: 3 additions & 0 deletions apps/oeth/src/lang/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as en from './enUS.json';

export { en };
31 changes: 31 additions & 0 deletions apps/oeth/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { OethRoot } from './views/root';
import { QueryClientProvider } from '@tanstack/react-query';
import { queryClient } from '@origin/shared/data-access';
import { theme } from '@origin/shared/theme';
import {
CssBaseline,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material';
import { IntlProvider } from 'react-intl';
import { en } from './lang';

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<StrictMode>
<IntlProvider messages={en} locale="en" defaultLocale="en">
<BrowserRouter>
<QueryClientProvider client={queryClient}>
<CssVarsProvider theme={theme} defaultMode="dark">
<CssBaseline />
<OethRoot />
</CssVarsProvider>
</QueryClientProvider>
</BrowserRouter>
</IntlProvider>
</StrictMode>
);
13 changes: 13 additions & 0 deletions apps/oeth/src/views/root/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// placeholder component until we actually start migration
import { DefiOeth } from '@origin/defi/oeth';
import { useIntl } from 'react-intl';

export function OethRoot() {
const intl = useIntl();
return (
<>
<h1>{intl.formatMessage({ defaultMessage: 'test OEth' })}</h1>
<DefiOeth />
</>
);
}
Loading