Skip to content

Commit

Permalink
Release new frontend upon the world (#858)
Browse files Browse the repository at this point in the history
:shipit: 🎉
lowtorola authored Dec 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 876d515 commit 8fa36a7
Showing 327 changed files with 7,059 additions and 70,302 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@ env:
CACHE_NUMBER: 1

jobs:
unit-test-frontend2:
name: Frontend2 linting / unit tests
unit-test-frontend:
name: Frontend linting / unit tests
# Defines the type of runner the job runs on
runs-on: ubuntu-latest
steps:
@@ -44,16 +44,16 @@ jobs:
${{ runner.os }}-
- name: Install package dependencies
run: npm install
working-directory: ./frontend2
working-directory: ./frontend
- name: Check linting and formatting
# Custom script for checking the linting and formatting being in place
run: npm run lint
working-directory: ./frontend2
working-directory: ./frontend
# Run test cases and this could ensure minimum coverage as well if set
# This section should be un-commented when our frontend implements unit testing
# - name: Execute test cases
# run: npm run test
# working-directory: ./frontend2
# working-directory: ./frontend
lint:
name: Linter (pre-commit)
runs-on: ubuntu-latest
14 changes: 3 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -4,20 +4,12 @@ repos:
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
exclude: ^frontend2/src/api/_autogen
exclude: ^frontend/src/api/_autogen
- id: mixed-line-ending
args: ["--fix=lf"]
exclude: ^frontend2/src/api/_autogen
exclude: ^frontend/src/api/_autogen
- id: trailing-whitespace
exclude: ^frontend2/src/api/_autogen

# This is only used for the old frontend. The prettier check for frontend2 exists in ci.yml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
types_or: [css, html, javascript, json, jsx, markdown]
exclude: ^(frontend/public/assets|frontend2)
exclude: ^frontend/src/api/_autogen

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
6 changes: 3 additions & 3 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_THIS_URL=http://localhost:3000
REACT_APP_BACKEND_URL=http://localhost:8000
REACT_APP_REPLAY_URL=https://play.battlecode.org
VITE_THIS_URL=http://localhost:3000
VITE_BACKEND_URL=http://localhost:8000
VITE_REPLAY_URL=https://play.battlecode.org
6 changes: 3 additions & 3 deletions frontend/.env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_THIS_URL=https://play.battlecode.org
REACT_APP_BACKEND_URL=https://api.battlecode.org
REACT_APP_REPLAY_URL=https://play.battlecode.org
VITE_THIS_URL=https://play.battlecode.org
VITE_BACKEND_URL=https://api.battlecode.org
VITE_REPLAY_URL=https://play.battlecode.org
GENERATE_SOURCEMAP=false
137 changes: 16 additions & 121 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,130 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# dependencies
/node_modules
/.pnp
.pnp.js

# Optional REPL history
.node_repl_history
# testing
/coverage

# Output of 'npm pack'
*.tgz
# production
/build

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
*.log
File renamed without changes.
File renamed without changes.
43 changes: 40 additions & 3 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Legacy Battlecode Frontend
# Battlecode Frontend

Fully static frontend in React, based on `battlecode19/app`, using modified template from http://creative-tim.com.
The new and improved frontend, for the Battlecode competitor portal.

**This folder (and its frontend as a whole) will soon be no longer used or maintained. See #663 for tracking.**
## Local setup

See [docs/local-setup.md](docs/local-setup.md).

## Important scripts

See [docs/create-react-app.md](docs/create-react-app.md) or [package.json](./package.json) for lesser-used scripts.

You can run the scripts below in the project directory.

`npm run start`

Runs the app in the development mode. Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

`npm run lint`

Runs ESLint and Prettier checks.

`npm run format`

Applies ESLint and Prettier fixes.

`npm start`

Runs the app in the development mode. Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

## Codebase intro

See [docs/onboard.md](docs/onboard.md) for an introduction to the frontend codebase, in order to make changes. This is helpful not only for frontend devs themselves but also for **just a working knowledge of frontend features, even if you're not a frontend dev!**

## Generate API types

We use a bash script to generate API types / functions from our backend code automatically. To run the bash script, ensure you have followed all the setup setps in the top-level directory and in [docs/local-setup.md](docs/local-setup.md).

The following steps assume that you begin in the `galaxy` directory.

1. `cd ./frontend`
2. `./generate_types.sh` (runs the bash script)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions frontend2/generate_types.sh → frontend/generate_types.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Can't run the script? You may need to run `chmod +x generate_types.sh` to make this script executable.
# This script should be run from the frontend2 folder.
# This script should be run from the frontend folder.

# Exit the script if an error occurs
set -e
@@ -12,15 +12,15 @@ cd ../backend

echo "Generating OpenAPI 3.0 backend schema from siarnaq.."
# `conda run -n galaxy` runs the command inside the conda environment.
conda run -n galaxy python manage.py spectacular --file ../frontend2/schema.yml --validate
conda run -n galaxy python manage.py spectacular --file ../frontend/schema.yml --validate

cd ../frontend2
cd ../frontend

# Delete the types folder before regenerating it.
echo "Deleting the old types folder.."
rm -rf ./src/api/_autogen

# Generate types folder
echo "Generating typescript types from schema, placing them in frontend2/src/api/_autogen.."
echo "Generating typescript types from schema, placing them in frontend/src/api/_autogen.."
mkdir src/api/_autogen
conda run -n galaxy npx @openapitools/openapi-generator-cli generate -i schema.yml -o src/api/_autogen -g typescript-fetch --additional-properties=modelPropertyNaming=original --additional-properties=disallowAdditionalPropertiesIfNotPresent=false --additional-properties=stringEnums=true
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8fa36a7

Please sign in to comment.