Skip to content

Commit

Permalink
chore: Use yarn workspaces & add Turborepo
Browse files Browse the repository at this point in the history
- Fix eslint in UI project and fix identified issues
- Update prettier configs to new format
- Remove prettier eslint plugin as VSCode is configured to format on save
- Add GitHub workflow to check formatting
- Remove unused dependencies
- Update data folder referencing as the container structure has changed
  • Loading branch information
benscobie committed Nov 12, 2024
1 parent 9a96fb7 commit 3476c46
Show file tree
Hide file tree
Showing 51 changed files with 934 additions and 2,935 deletions.
5 changes: 3 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
node_modules
**/node_modules/
.git
data/
server/dist
ui/.next
Dockerfile
**/*.md
**/*.md
out/
35 changes: 35 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Code quality checks

on:
pull_request:
branches: [main]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
formatting:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Activate corepack
run: |
corepack install
corepack enable
- name: Install dependencies
run: yarn --immutable
- name: Check formatting
run: yarn turbo format:check
2 changes: 1 addition & 1 deletion .github/workflows/run_jest_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
run: yarn --immutable

- name: Run tests
run: yarn test
run: yarn turbo test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ node_modules
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.idea
.idea
.turbo
29 changes: 14 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All help is welcome and greatly appreciated! If you would like to contribute to
### Tools Required

- HTML/Typescript/Javascript editor
- [VSCode](https://code.visualstudio.com/) is recommended. Upon opening the project, a few extensions will be automatically recommended for install.
- [VSCode](https://code.visualstudio.com/) is recommended. Upon opening the project, a few extensions will be automatically recommended for install.
- [NodeJS](https://nodejs.org/en/download/) (Node 20.x or higher)
- [Git](https://git-scm.com/downloads)

Expand Down Expand Up @@ -43,35 +43,34 @@ All help is welcome and greatly appreciated! If you would like to contribute to
- `docs`
- `feature`
- `fix`
- `patch`
- `patch`

4. Activate the correct Yarn version. (*Note: In order to run `corepack enable`, you will need to be running cmd or Powershell as an Administrator.*)
4. Activate the correct Yarn version. (_Note: In order to run `corepack enable`, you will need to be running cmd or PowerShell as an Administrator._)

```bash
```bash
corepack install
corepack enable
```

5. Install dependencies

```bash
yarn
```bash
yarn
```

6. As of Maintainerr v2.0, the project looks to ensure you have read/write permissions on the `data` directory. This `data` directory does not exist when you first clone your fork. Before running the below commands, create a folder inside of your main Maintainerr directory named `data`, and ensure it has full permissions to the `Everyone` user.

```bash
example -> C:\Users\You\Documents\GitRepos\Maintainerr\data
```
```bash
example -> C:\Users\You\Documents\GitRepos\Maintainerr\data
```

7. Run the development commands (you will need two different cmd/Powershell terminals. One for each command.)
7. Run the development command

```bash
yarn dev:server
yarn dev:ui
yarn dev
```

- If the build fails with Powershell, try to use cmd instead.
- If the build fails with PowerShell, try to use cmd instead.

8. Make your code changes/improvements and test that they work as intended.

Expand All @@ -94,8 +93,8 @@ All help is welcome and greatly appreciated! If you would like to contribute to
- Always rebase your commit to the latest `main` branch. Do **not** merge `main` into your branch.
- It is your responsibility to keep your branch up-to-date. Your work will **not** be merged unless it is rebased off the latest `main` branch.
- You can create a "draft" pull request early to get feedback on your work.
- Your code **must** be formatted correctly, or the tests will fail.
- We use Prettier to format our code base. It should automatically run with a Git hook, but it is recommended to have the Prettier extension installed in your editor and format on save.
- Your code **must** be formatted correctly.
- We use Prettier to format our code base. It is recommended to have the Prettier extension installed in your editor and format on save.
- If you have questions or need help, you can reach out via [Discussions](https://github.com/jorenn92/Maintainerr/discussions) or our [Discord server](https://discord.gg/WP4ZW2QYwk).

### UI Text Style
Expand Down
40 changes: 23 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
FROM node:20-alpine3.19 AS base
LABEL Description="Contains the Maintainerr Docker image"

FROM base AS deps
FROM base AS pruner

WORKDIR /app

COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn/releases ./.yarn/releases

RUN apk --update --no-cache add python3 make g++ curl
RUN yarn global add turbo@^2
COPY . .

RUN yarn --immutable --network-timeout 99999999
RUN turbo prune @maintainerr/server --docker --out-dir ./out/server
RUN turbo prune @maintainerr/ui --docker --out-dir ./out/ui

FROM base AS builder

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .
COPY --from=pruner /app/out/server/json/ ./server
COPY --from=pruner /app/out/ui/json/ ./ui

RUN yarn build:server
RUN cd server && yarn install --network-timeout 99999999
RUN cd ui && yarn install --network-timeout 99999999
RUN cd server && yarn cache clean
RUN cd ui && yarn cache clean

RUN yarn build:ui
COPY --from=pruner /app/out/server/full/ ./server
COPY --from=pruner /app/out/ui/full/ ./ui

RUN cd ui && yarn turbo build --filter=@maintainerr/ui
RUN cd server && yarn turbo build --filter=@maintainerr/server

FROM base AS runner

WORKDIR /opt/app

# copy standalone UI
COPY --from=builder --chmod=777 --chown=node:node /app/ui/.next/standalone/ui ./ui
COPY --from=builder --chmod=777 --chown=node:node /app/ui/.next/static ./ui/.next/static
COPY --from=builder --chmod=777 --chown=node:node /app/ui/public ./ui/public
COPY --from=builder --chmod=777 --chown=node:node /app/ui/ui/.next/standalone ./ui
COPY --from=builder --chmod=777 --chown=node:node /app/ui/ui/.next/static ./ui/ui/.next/static
COPY --from=builder --chmod=777 --chown=node:node /app/ui/ui/public ./ui/ui/public

# Copy standalone server
COPY --from=builder --chmod=777 --chown=node:node /app/server/dist ./server
COPY --from=builder --chmod=777 --chown=node:node /app/node_modules ./node_modules
COPY --from=builder --chmod=777 --chown=node:node /app/package.json ./
COPY --from=builder --chmod=777 --chown=node:node /app/server ./server

# Create required directories
RUN mkdir -pm 777 /opt/data/logs && \
chown -R node:node /opt/data

RUN apk --update --no-cache add curl supervisor

COPY --from=builder /app/supervisord.conf /etc/supervisord.conf
COPY --from=pruner /app/supervisord.conf /etc/supervisord.conf

ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
Expand All @@ -61,6 +65,8 @@ ENV UI_PORT=${UI_PORT}
ARG GIT_SHA
ENV GIT_SHA=$GIT_SHA

ENV DATA_DIR=/opt/data

# container version type. develop, stable, edge,.. a release=stable
ARG VERSION_TAG=develop
ENV VERSION_TAG=$VERSION_TAG
Expand Down
127 changes: 14 additions & 113 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,128 +8,29 @@
"url": "https://github.com/jorenn92/Maintainerr.git"
},
"license": "MIT",
"installConfig": {
"hoistingLimits": "workspaces"
},
"scripts": {
"prebuild:server": "cd server && rimraf dist",
"dev:ui": "cd ui && next dev",
"dev:server": "cd server && nest start --watch",
"build:ui": "cd ui && next build",
"build:server": "cd server && nest build",
"start:ui": "cd ui && next start -p 80",
"start:server": "cd server && node dist/main",
"lint:ui": "cd ui && next lint",
"lint:server": "cd server && eslint \"{src,test}/**/*.ts\" --fix",
"test": "jest",
"test:clear": "jest --clearCache",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"migration:run": "ts-node node_modules/typeorm/cli.js migration:run -d ./datasource-config.ts",
"migration:revert": "ts-node node_modules/typeorm/cli.js migration:revert -d ./datasource-config.ts",
"migration:generate": "ts-node node_modules/typeorm/cli.js migration:generate --dataSource ./datasource-config.ts -p"
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"knip": "knip"
},
"dependencies": {
"@headlessui/react": "2.1.9",
"@heroicons/react": "^1.0.6",
"@monaco-editor/react": "^4.6.0",
"@nestjs/cli": "^10.4.5",
"@nestjs/common": "^10.4.4",
"@nestjs/core": "^10.4.7",
"@nestjs/platform-express": "^10.4.5",
"@nestjs/schedule": "^4.0.0",
"@nestjs/typeorm": "^10.0.2",
"@types/node": "^22.8.7",
"axios": "^1.7.7",
"bowser": "^2.11.0",
"chalk": "^4.1.2",
"cron": "3.1.3",
"cron-validator": "^1.3.1",
"crypto": "^1.0.1",
"http-server": "^14.1.1",
"lodash": "^4.17.21",
"nest-winston": "^1.10.0",
"next": "15.0.3",
"node-cache": "^5.1.2",
"path": "^0.12.7",
"plex-api": "^5.3.2",
"react": "18.2.0",
"react-dom": "18.3.1",
"react-select": "^5.8.0",
"react-toast-notifications": "^2.5.1",
"react-transition-group": "^4.4.5",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"sqlite3": "^5.1.6",
"typeorm": "^0.3.20",
"typescript": "^5.3.3",
"web-push": "^3.6.6",
"winston": "^3.16.0",
"winston-daily-rotate-file": "^5.0.0",
"xml2js": "^0.6.2",
"yaml": "^2.6.0"
"workspaces": [
"ui",
"server"
],
"engines": {
"node": ">=18"
},
"devDependencies": {
"@automock/jest": "^1.4.0",
"@babel/core": "^7.26.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.13.0",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.2.3",
"@nestjs/testing": "^10.4.7",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@svgr/webpack": "^8.1.0",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/typography": "^0.5.15",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.17.7",
"@types/react": "^18.2.73",
"@types/react-dom": "^18.3.0",
"@types/react-transition-group": "^4.4.11",
"@types/web-push": "^3.6.4",
"@types/xml2js": "^0.4.14",
"@typescript-eslint/eslint-plugin": "^8.12.0",
"@typescript-eslint/parser": "^8.8.1",
"autoprefixer": "10.4.20",
"eslint": "^9.12.0",
"eslint-config-next": "15.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
"monaco-editor": "0.51.0",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"@types/node": "^22.8.7",
"knip": "^5.36.5",
"semantic-release": "^24.2.0",
"source-map-support": "^0.5.21",
"tailwindcss": "^3.4.14",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "server/src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "./coverage",
"testEnvironment": "node"
"turbo": "^2.2.3",
"typescript": "^5.6.3"
},
"release": {
"plugins": [
Expand Down
4 changes: 0 additions & 4 deletions server/.prettierrc

This file was deleted.

Loading

0 comments on commit 3476c46

Please sign in to comment.