Skip to content

Commit

Permalink
重組儲存庫並新增新的後端
Browse files Browse the repository at this point in the history
  • Loading branch information
igncp committed May 19, 2024
1 parent 673ac9d commit bf53bc3
Show file tree
Hide file tree
Showing 272 changed files with 8,086 additions and 81,046 deletions.
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#NEXT_PUBLIC_BACKEND_URL=http://localhos:9000
NEXT_PUBLIC_BACKEND_URL=https://api.learn-languages-writing.com
NEXT_PUBLIC_GOOGLE_CLIENT_ID=128663644139-o8phiqm9vbn3onkrj0ehircqi59sm319.apps.googleusercontent.com

GOOGLE_CLIENT_SECRET=YOUR_GOOGLE_CLIENT_SECRET
LOGGER_LEVEL=debug
JWT_SECRET=some_secret
TOKEN_MAXAGE=3600
TOKEN_EXPIRED_IN=3600
CLIENT_ORIGIN=http://localhost:3000
DATABASE_URL=writing-trainer.db
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "Loading mahjong flake"
use flake
8 changes: 7 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
packages
node_modules
gh_pages
storybook-static
coverage
coverage-ts
.next
out
dist
27 changes: 24 additions & 3 deletions helpers/eslintConfig.js → .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ const tsRules = {

module.exports = {
env: {
node: true,
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:jest/recommended',
'plugin:@typescript-eslint/recommended',
Expand Down Expand Up @@ -99,6 +100,7 @@ module.exports = {
'newline-before-return': 2,
'no-console': 2,
'no-extra-semi': 0,

'no-useless-return': 2,
'padding-line-between-statements': [
'error',
Expand All @@ -118,8 +120,6 @@ module.exports = {
prev: '*',
},
],
'prefer-template': 2,
'prettier/prettier': 'error',

'perfectionist/sort-array-includes': 2,
'perfectionist/sort-classes': 2,
Expand All @@ -129,5 +129,26 @@ module.exports = {
'perfectionist/sort-named-exports': 2,
'perfectionist/sort-object-types': 2,
'perfectionist/sort-objects': 2,

'prefer-template': 2,
'prettier/prettier': 'error',

'react/jsx-no-target-blank': 0,
'react/jsx-sort-props': 2,
'react/no-unescaped-entities': 0,
'react/prop-types': 0,
'react/react-in-jsx-scope': 0,
},

settings: {
'import/resolver': {
alias: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
map: [['#', './src/']],
},
},
react: {
version: 'detect',
},
},
}
41 changes: 41 additions & 0 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy Backend
on:
push:
branches:
- main
paths:
- '.github/workflows/deploy-backend.yml'
- 'Cargo.lock'
- 'Cargo.toml'
- 'scripts/ci/build_docker.sh'
- 'src/backend/**'

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Install 🚧
run: |
touch ./is-ci-rust
nix develop path:$(pwd) -c rustup install stable
- name: Check 🔧
run: |
nix develop path:$(pwd) -c bash -c 'cargo clippy --release'
- name: Build and publish docker image
run: |
nix develop path:$(pwd) -c bash -c scripts/ci/build_docker.sh
21 changes: 19 additions & 2 deletions .github/workflows/deploy-to-ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ on:
push:
branches:
- main
paths:
- '.github/workflows/deploy-to-ghpages.yml'
- 'package-lock.json'
- 'package.json'
- 'src/core/**'
- 'src/pages/**'
- 'src/react-ui/**'
- 'src/web-app/**'
- 'tsconfig.json'

jobs:
build-and-deploy:
Expand All @@ -11,13 +20,21 @@ jobs:
- name: Checkout 🛎️
uses: actions/checkout@v3

- uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Install 🚧
run: |
npm install
touch ./is-ci-nodejs
nix develop path:$(pwd) -c npm install
- name: Build 🔧
run: |
bash helpers/ci/gh_actions.sh
nix develop path:$(pwd) -c bash scripts/ci/gh_pages_action.sh
env:
NEXT_PUBLIC_BACKEND_URL: 'https://api.learn-languages-writing.com'
NEXT_PUBLIC_GOOGLE_CLIENT_ID: '128663644139-o8phiqm9vbn3onkrj0ehircqi59sm319.apps.googleusercontent.com'

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
node_modules
gh_pages
storybook-static
coverage
coverage-ts
.next
out
dist

/target
.direnv
.env
writing-trainer.db
5 changes: 4 additions & 1 deletion packages/react-ui/.storybook/main.js → .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const configStorybook = {
},
'stories': ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
webpackFinal: async config => {
Object.assign(config.resolve.alias)
Object.assign(config.resolve.alias, {
'#': path.resolve(__dirname, '../src'),
'@': path.resolve(__dirname, '../src/chrome-extension'),
})

config.module.rules.push(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../src/tailwind.css'
import '../src/react-ui/tailwind.css'

/** @type { import('@storybook/react').Preview } */
const preview = {
Expand Down
Loading

0 comments on commit bf53bc3

Please sign in to comment.