Skip to content

Commit

Permalink
refactor: restructure project to a true monorepo (#5626)
Browse files Browse the repository at this point in the history
* split ts files

* packages

* nomore workspace?

* blah

* build, exports

* declaration

* blargh

* turrrrbo

* fix fontawesome paths

* allow file in eslint, fix ts errors

* optimise package, update tsconfig

* fix ts

* update turbo config

* eslint split

* fix imports

* fix types

* lock

* add turbo task

* script

* test task

* pretty scripts

* update prettier ignore

* no cache for tests

* lint task

* turbo

* no out

* depend on env

* fix mono breaking things

* odl

* fix version dependency of mongodb-memory-server

* Revert "fix version dependency of mongodb-memory-server"

This reverts commit 52ffac4.

* update vitest-mongodb

* release scripts

* update ci

* update dev script

* ignore issues around firebase config

* add check ts tasks

* import isaxioserror

* shared types package

* replace tsnodedev with tsx

* fix import

* shared types

* module

* backend imports

* declaration

* node version

* test code

* assert json

* verbatim

* type

* lodash

* ts ver

* fix fix fix?

* remove assert

* remove module and resolution

* cleanup

* tsconfig

* fix frontend

* remove unecessary props

* more unused

* remove skiplib

* declaration map, dev script

* remove install scripts

* fix regex

* move shared types to package

* dont include shared types

* remove path

* update scripts

* test code

* test code

* fix backend types

* fully fix backend

* fix frontend d.ts

* add .js to imports

* remove module

* revert add .js

* update tsconfig

* use bundler module resolution

* almost all frontend types

* mooore

* date fns

* fix backend docker

* fix ape keys

* fix type

* clean rimraf type

* fix shared-types in workspace

* fix import resolving

* fix docker builds

* ignore type problems on slim-select until new version is released

* turrrrbo

* fix npm ci

* fix lint task

* expose env variables needed by frontend build

* fix dependencies

* package-lock

* backend watch ts and lint

* add fe and be build scripts to root

* fix dev not building packages

* shared-types missing eslint

* move shared types back to dev-deps

* add packages to labeler

* add packages step to ci

* typo

* filter update

* remove concurrently from root

* add scripts

* abbreviate

* rename

* yeet

* fixed path

* test pkg

* consistent ordering

* rename

* Revert "backend imports"

This reverts commit d715198.

* fix missing imports, remove last .js

* remove test package

---------

Co-authored-by: Christian Fehmer <[email protected]>
  • Loading branch information
Miodec and fehmer authored Jul 22, 2024
1 parent c96185e commit 3e88ac2
Show file tree
Hide file tree
Showing 164 changed files with 31,779 additions and 40,492 deletions.
112 changes: 0 additions & 112 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ docs:
frontend:
- any: ["frontend/**/*"]

packages:
- any: ["packages/**/*"]

local dev:
- any: ["**/gulpfile.js", "**/tsconfig.json"]
45 changes: 39 additions & 6 deletions .github/workflows/monkey-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Monkey CI

env:
NODE_VERSION: "18.19.1"
NODE_VERSION: "18.20.4"
RECAPTCHA_SITE_KEY: "6Lc-V8McAAAAAJ7s6LGNe7MBZnRiwbsbiWts87aj"

permissions:
Expand All @@ -28,6 +28,7 @@ jobs:
outputs:
should-build-be: ${{ steps.export-changes.outputs.should-build-be }}
should-build-fe: ${{ steps.export-changes.outputs.should-build-fe }}
should-build-pkg: ${{ steps.export-changes.outputs.should-build-pkg }}
assets-json: ${{ steps.export-changes.outputs.assets-json }}

steps:
Expand All @@ -40,8 +41,12 @@ jobs:
- 'frontend/**/*.json'
be-src:
- 'backend/**/*.{ts,js,json,lua,css,html}'
- 'backend/package.json'
fe-src:
- 'frontend/**/*.{ts,scss}'
- 'frontend/package.json'
pkg-src:
- 'packages/**/*'
anti-cheat:
- 'backend/**/anticheat/**'
Expand All @@ -52,6 +57,7 @@ jobs:
- name: Export changes
id: export-changes
run: |
echo "should-build-pkg=${{ steps.filter.outputs.pkg-src }}" >> $GITHUB_OUTPUT
echo "should-build-be=${{ steps.filter.outputs.be-src }}" >> $GITHUB_OUTPUT
echo "should-build-fe=${{ steps.filter.outputs.fe-src }}" >> $GITHUB_OUTPUT
echo "assets-json=${{ steps.filter.outputs.json }}" >> $GITHUB_OUTPUT
Expand All @@ -69,7 +75,7 @@ jobs:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm ci & cd backend && npm ci
run: npm ci

- name: Check pretty
run: npm run pretty-code-be
Expand All @@ -78,7 +84,7 @@ jobs:
run: npm run lint-be

- name: Build
run: npm run pr-check-build-be
run: npm run build-be

- name: Test
run: npm run test-be
Expand All @@ -100,7 +106,7 @@ jobs:
run: mv ./firebase-config-example.ts ./firebase-config.ts && cp ./firebase-config.ts ./firebase-config-live.ts

- name: Install dependencies
run: npm ci & cd frontend && npm ci
run: npm ci

- name: Check pretty
run: npm run pretty-code-fe
Expand All @@ -109,7 +115,7 @@ jobs:
run: npm run lint-fe

- name: Build
run: npm run pr-check-build-fe
run: npm run build-fe

- name: Test
run: npm run test-fe
Expand Down Expand Up @@ -141,7 +147,7 @@ jobs:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm ci & cd frontend && npm ci
run: npm ci

- name: Lint JSON
run: npm run pr-check-lint-json
Expand All @@ -158,6 +164,33 @@ jobs:
if: steps.filter.outputs.other-json == 'true'
run: npm run pr-check-other-json

ci-pkg:
name: ci-pkg
needs: [pre-ci]
runs-on: ubuntu-latest
if: needs.pre-ci.outputs.should-build-pkg == 'true'
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install dependencies
run: npm ci

- name: Check pretty
run: npm run pretty-code-pkg

- name: Check lint
run: npm run lint-pkg

- name: Build
run: npm run build-pkg

- name: Test
run: npm run test-pkg

on-failure:
permissions: write-all
name: on-failure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pretty-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18.19.1"
node-version: "18.20.4"

- name: Install dependencies
run: npm i [email protected] --save-dev --save-exact
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ copyAnticheatToDev.sh
# ignore generated fonts
frontend/src/webfonts-generated
frontend/static/webfonts-preview

.turbo
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.1
18.20.4
8 changes: 7 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.turbo
.github
*.md
docker/
*.min.js
*.min.css
layouts.ts
Expand All @@ -7,8 +11,10 @@ sound/*
node_modules
css/balloon.css
_list.json
backend/build
backend/logs
backend/coverage
backend/globalConfig.json
frontend/public
dist/
build/
frontend/coverage
4 changes: 1 addition & 3 deletions .release-it-fe.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"hooks": {
"before:init": [
"npm run lint-fe",
"npm run test-fe",
"cd frontend && npm run validate-json && npm run build"
"npx turbo lint test validate-json build --filter @monkeytype/frontend"
],
"before:release": [
"cd frontend && npx firebase deploy -P live --only hosting",
Expand Down
6 changes: 1 addition & 5 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"hooks": {
"before:init": [
"npm run lint",
"npm run test",
"cd frontend && npm run validate-json && npm run build"
],
"before:init": ["npx turbo lint test validate-json build"],
"before:release": [
"sh ./bin/deployBackend.sh",
"cd frontend && npx firebase deploy -P live --only hosting",
Expand Down
11 changes: 4 additions & 7 deletions CONTRIBUTING_ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

## Prerequisites

This contribution guide is for cases in which you need to test the functionality of your changes, or if you need to take screenshots of your changes. You will need a computer with a stable internet connection, a text editor, Git, and NodeJS with version 18.19.1. There are some additional requirements depending on what you're looking to contribute, such as Firebase for authentication, and Mongo and Docker for the backend. Read the below sections to understand how to set up each of these tools.
This contribution guide is for cases in which you need to test the functionality of your changes, or if you need to take screenshots of your changes. You will need a computer with a stable internet connection, a text editor, Git, and NodeJS with version 18.20.4. There are some additional requirements depending on what you're looking to contribute, such as Firebase for authentication, and Mongo and Docker for the backend. Read the below sections to understand how to set up each of these tools.

### Git

Expand All @@ -33,9 +33,9 @@ Git is optional but we recommend you utilize it. Monkeytype uses the Git source

### NodeJS and NPM

Currently, the project is using version `18.19.1 LTS`.
Currently, the project is using version `18.20.4 LTS`.

If you use `nvm` (if you use Windows, use [nvm-windows](https://github.com/coreybutler/nvm-windows)) then you can run `nvm install` and `nvm use` (you might need to specify the exact version eg: `nvm install 18.19.1` then `nvm use 18.19.1`) to use the version of Node.js in the `.nvmrc` file.
If you use `nvm` (if you use Windows, use [nvm-windows](https://github.com/coreybutler/nvm-windows)) then you can run `nvm install` and `nvm use` (you might need to specify the exact version eg: `nvm install 18.20.4` then `nvm use 18.20.4`) to use the version of Node.js in the `.nvmrc` file.

Alternatively, you can navigate to the NodeJS [website](https://nodejs.org/en/) to download it from there.

Expand Down Expand Up @@ -120,10 +120,7 @@ Its time to run Monkeytype. Just like with the databases, you can run the fronte

### Dependencies (if running manually)

Run `npm run install-all` in the project root to install all dependencies.

- If you are on Windows, use `npm run install-windows`.
- If neither works, you will have to run `npm install` in root, frontend, and backend directories.
Run `npm i` in the project root to install all dependencies.

### Both Frontend and Backend

Expand Down
2 changes: 1 addition & 1 deletion SELF_HOSTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Stop the running docker containers using `docker compose down` before making any
#uncomment to enable the account system, check the SELF_HOSTING.md file
- type: bind
source: ./serviceAccountKey.json
target: /src/credentials/serviceAccountKey.json
target: /app/backend/src/credentials/serviceAccountKey.json
read_only: true
```
Expand Down
16 changes: 16 additions & 0 deletions backend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ["@monkeytype/eslint-config"],
ignorePatterns: [
"node_modules/",
"dist/",
"build/",
"__tests__/",
"jest.config.ts",
"__migration__/",
],
rules: {
eqeqeq: "error",
},
};
2 changes: 1 addition & 1 deletion backend/docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:

api-server:
container_name: monkeytype-api-server
image: node:18.19.1
image: node:18.20.4
restart: on-failure
depends_on:
- redis
Expand Down
Loading

0 comments on commit 3e88ac2

Please sign in to comment.