Skip to content

Commit

Permalink
feat: move sources into apps folder (#1503)
Browse files Browse the repository at this point in the history
* feat: remove old frontend sources

* feat: move sources into apps folder

* chore: remove vue things

* fix: update pnpm filter

* chore: move caddyfile into infra folder
  • Loading branch information
dotoleeoak authored Mar 5, 2024
1 parent 94f4387 commit 8de3ae0
Show file tree
Hide file tree
Showing 745 changed files with 705 additions and 13,730 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"golang.go",
"hashicorp.terraform",
"ms-azuretools.vscode-docker",
"prisma.prisma",
"Vue.volar"
"prisma.prisma"
]
}
},
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile
file: ./apps/backend/Dockerfile
push: true
build-args: 'target=client'
tags: ghcr.io/${{ github.repository_owner }}/codedang-client-api:latest
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile
file: ./apps/backend/Dockerfile
push: true
build-args: 'target=admin'
tags: ghcr.io/${{ github.repository_owner }}/codedang-admin-api:latest
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
docker-compose.yml
scripts/deploy.sh
.env.development
Caddyfile
apps/infra/stage/Caddyfile
grafana-logs/promtail/promtail-config.yml
- name: Load dotenv from secret
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
docker compose --profile deploy up promtail -d --no-deps
- name: Copy Caddyfile into Caddy Container
run: docker cp ./Caddyfile caddy:/etc/caddy/Caddyfile
run: docker cp ./apps/infra/stage/Caddyfile caddy:/etc/caddy/Caddyfile

- name: Graceful reload Caddy
run: docker exec -w /etc/caddy caddy caddy reload
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile
file: ./apps/backend/Dockerfile
push: true
build-args: 'target=client'
tags: ${{ steps.login-ecr.outputs.registry }}/codedang-client-api:latest
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Build and push image
uses: docker/build-push-action@v5
with:
file: ./backend/Dockerfile
file: ./apps/backend/Dockerfile
push: true
build-args: 'target=admin'
tags: ${{ steps.login-ecr.outputs.registry }}/codedang-admin-api:latest
Expand Down
46 changes: 19 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,38 @@ jobs:

strategy:
matrix:
target: [frontend, frontend-client, backend, backend-admin]
target: [frontend, backend, backend-admin]

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-pnpm

- name: Generate Prisma Client
if: ${{ matrix.target == 'backend' || matrix.target == 'backend-admin' }}
run: pnpm --filter backend exec prisma generate
run: pnpm --filter="@codedang/backend" exec prisma generate

- name: Setup Next.js build cache
if: ${{ matrix.target == 'frontend-client' }}
if: ${{ matrix.target == 'frontend' }}
uses: actions/cache@v4
with:
path: frontend-client/.next/cache
path: apps/frontend/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-
- name: Load Next.js environment
if: ${{ matrix.target == 'frontend-client' }}
if: ${{ matrix.target == 'frontend' }}
run: |
echo "NEXT_PUBLIC_BASEURL=https://dev-aws.codedang.com/api" >> frontend-client/.env
echo "NEXT_PUBLIC_GQL_BASEURL=https://dev-aws.codedang.com/graphql" >> frontend-client/.env
echo "NEXT_URL=https://dev.codedang.com" >> frontend-client/.env
echo "NEXT_PUBLIC_BASEURL=https://dev-aws.codedang.com/api" >> apps/frontend/.env
echo "NEXT_PUBLIC_GQL_BASEURL=https://dev-aws.codedang.com/graphql" >> apps/frontend/.env
echo "NEXT_URL=https://dev.codedang.com" >> apps/frontend/.env
# If target is backend-admin, run `pnpm --filter backend build admin`
# For other targets, run `pnpm --filter <target> build`
- name: Build (backend admin)
if: ${{ matrix.target == 'backend-admin' }}
run: pnpm --filter backend build admin
run: pnpm --filter="@codedang/backend" build admin
- name: Build
if: ${{ matrix.target != 'backend-admin' }}
run: pnpm --filter ${{ matrix.target }} build
run: pnpm --filter="apps/${{ matrix.target }}" build

typecheck:
name: Typecheck
Expand All @@ -57,15 +55,12 @@ jobs:
- uses: ./.github/actions/setup-pnpm

- name: Generate Prisma Client
run: pnpm --filter backend exec prisma generate
run: pnpm --filter="@codedang/backend" exec prisma generate

- name: Check types (backend)
run: pnpm --filter backend exec tsc --noEmit
- name: Check types (backend) # For spec files
run: pnpm --filter="@codedang/backend" exec tsc --noEmit

- name: Check types (frontend)
run: pnpm --filter frontend exec vue-tsc --noEmit

# Typecheck is not performed for frontend-client intentionally.
# Typecheck is not performed for frontend intentionally.
# Check: https://github.com/vercel/next.js/issues/53959
# Unlike backend, we don't have spec file to check types.
# So typechecking performed in the build step is enough.
Expand All @@ -81,8 +76,8 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: iris/go.mod
cache-dependency-path: iris/go.sum
go-version-file: apps/iris/go.mod
cache-dependency-path: apps/iris/go.sum

- name: Lint pull request title
if: ${{ github.event_name == 'pull_request' }}
Expand All @@ -98,7 +93,7 @@ jobs:
echo " go fmt ./..."
exit 1
fi
working-directory: ./iris
working-directory: ./apps/iris

- name: Lint (Node.js)
run: pnpm lint
Expand Down Expand Up @@ -127,7 +122,7 @@ jobs:

- name: Check Prisma Migration
run: |
pnpm --filter backend exec prisma migrate diff \
pnpm --filter="@codedang/backend" exec prisma migrate diff \
--from-migrations ./prisma/migrations \
--to-schema-datamodel ./prisma/schema.prisma \
--shadow-database-url ${{ env.DATABASE_URL }} \
Expand All @@ -136,10 +131,7 @@ jobs:
"Please run 'pnpm prisma migrate dev' locally and commit the changes." && exit 1)
- name: Migrate Prisma
run: pnpm --filter backend exec prisma migrate reset --force

- name: Check types in Typescript
run: pnpm --filter backend exec tsc --noEmit
run: pnpm --filter="@codedang/backend" exec prisma migrate reset --force

- name: Test
run: pnpm -r test
1 change: 0 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ vscode:
- hashicorp.terraform
- ms-azuretools.vscode-docker
- prisma.prisma
- Vue.volar
17 changes: 5 additions & 12 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name": "Backend Client",
"runtimeExecutable": "pnpm",
"runtimeArgs": ["run", "start:debug"],
"cwd": "${workspaceFolder}/backend",
"cwd": "${workspaceFolder}/apps/backend",
"console": "integratedTerminal"
},
{
Expand All @@ -19,7 +19,7 @@
"name": "Backend Admin",
"runtimeExecutable": "pnpm",
"runtimeArgs": ["run", "start:debug", "admin"],
"cwd": "${workspaceFolder}/backend",
"cwd": "${workspaceFolder}/apps/backend",
"console": "integratedTerminal"
},
{
Expand All @@ -28,22 +28,15 @@
"name": "Backend Test 🧪",
"runtimeExecutable": "pnpm",
"runtimeArgs": ["run", "test:debug"],
"cwd": "${workspaceFolder}/backend",
"cwd": "${workspaceFolder}/apps/backend",
"console": "integratedTerminal"
},
{
"type": "chrome",
"request": "launch",
"name": "Frontend (Vue.js)",
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}/frontend/src"
},
{
"type": "go",
"request": "launch",
"name": "Iris 🐶",
"cwd": "${workspaceFolder}/iris",
"program": "${workspaceFolder}/iris/main.go",
"cwd": "${workspaceFolder}/apps/iris",
"program": "${workspaceFolder}/apps/iris/main.go",
"console": "integratedTerminal",
"asRoot": true,
"envFile": "${workspaceFolder}/.env"
Expand Down
2 changes: 1 addition & 1 deletion apollo.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
client: {
includes: ['./frontend-client/**/*.ts', './frontend-client/**/*.tsx'],
includes: ['./apps/frontend/**/*.ts', './apps/frontend/**/*.tsx'],
excludes: ['**/__generated__/**'],
service: {
name: 'codedang-graphql-app',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions backend/Dockerfile → apps/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [NOTE] Build image from the root directory of this repository.
# ex) `docker build -f backend/Dockerfile .`
# ex) `docker build -f apps/backend/Dockerfile .`

### BUILDER ###
ARG target=client
Expand All @@ -11,7 +11,7 @@ COPY . /build
WORKDIR /build

RUN corepack enable
RUN pnpm --filter=backend deploy out
RUN pnpm --filter="@codedang/backend" deploy out

WORKDIR /build/out
RUN npx prisma generate
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions backend/package.json → apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "backend",
"name": "@codedang/backend",
"private": true,
"scripts": {
"build": "nest build",
Expand All @@ -9,7 +9,7 @@
"start:prod": "node dist/apps/backend/main",
"start:testdb": "cross-env DATABASE_URL=$TEST_DATABASE_URL nest start",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"pretest": "echo \"y\" | cross-env DATABASE_URL=$TEST_DATABASE_URL pnpm --filter backend exec prisma migrate reset --force",
"pretest": "cross-env DATABASE_URL=$TEST_DATABASE_URL prisma migrate reset --force",
"test": "pnpm run pretest && cross-env DATABASE_URL=$TEST_DATABASE_URL mocha \"*/**/*.spec.ts\"",
"test:watch": "pnpm run pretest && cross-env DATABASE_URL=$TEST_DATABASE_URL mocha --watch \"*/**/*.spec.ts\"",
"test:debug": "pnpm run pretest && cross-env DATABASE_URL=$TEST_DATABASE_URL mocha --inspect \"*/**/*.spec.ts\"",
Expand Down
Loading

0 comments on commit 8de3ae0

Please sign in to comment.