Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to nextjs15/react19 #48

Merged
merged 37 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
11aa532
add pre:push comamnd; clean codebase before pushing
nathanstitt Oct 7, 2024
bc4f3b2
add pre:push comamnd; clean codebase before pushing
nathanstitt Oct 7, 2024
df1e5fd
document preferred way to "fork"
nathanstitt Oct 14, 2024
f515660
add remote if it's missing
nathanstitt Oct 14, 2024
804bc69
add lint-staged configuration
nathanstitt Oct 18, 2024
df687d9
enable github annotations reporters
nathanstitt Oct 18, 2024
37ae4c7
add an example Dockerfile for production build
nathanstitt Oct 21, 2024
4e524c7
Merge pull request #3 from safeinsights/document-bootstrap
nathanstitt Dec 13, 2024
241b939
Merge pull request #2 from safeinsights/pre-push
nathanstitt Dec 13, 2024
af9cab9
lint README, fixes indentation mainly
nathanstitt Dec 13, 2024
c6e9590
upgrade to nextjs15/react19
nathanstitt Dec 13, 2024
b097129
remove unused vanilla css styles
nathanstitt Dec 13, 2024
f33f168
use mantine's layer styles
nathanstitt Dec 13, 2024
d2aaef6
sort package.json
nathanstitt Dec 13, 2024
f936bbd
add .env to gitignore
nathanstitt Dec 13, 2024
6bbf47b
Merge remote-tracking branch 'template/update-all-the-things'
nathanstitt Dec 13, 2024
3e02ecc
Merge remote-tracking branch 'template/update-all-the-things'
nathanstitt Dec 13, 2024
15bef5a
move panda generated files to src/styles/generated
nathanstitt Dec 13, 2024
bf8078f
Merge remote-tracking branch 'template/update-all-the-things' into up…
nathanstitt Dec 13, 2024
a9eac8f
fix lint and typecheck errors
nathanstitt Dec 13, 2024
7e34e20
move panda generated files to src/styles/generated
nathanstitt Dec 13, 2024
cc5d6f3
Merge remote-tracking branch 'template/update-all-the-things' into up…
nathanstitt Dec 13, 2024
6290bd9
move panda generated files to src/styles/generated
nathanstitt Dec 13, 2024
9c9c280
Merge remote-tracking branch 'template/update-all-the-things' into up…
nathanstitt Dec 13, 2024
fe1397b
copy panda config
nathanstitt Dec 13, 2024
2731648
fix lint and typecheck errors
nathanstitt Dec 13, 2024
7b1a7ad
replace vanilla-extract with pandacss
nathanstitt Dec 13, 2024
62c4924
replace any in catch with unknown and typeguards
nathanstitt Dec 13, 2024
7699fe9
lint
nathanstitt Dec 13, 2024
3f8d7d2
copy panda file
nathanstitt Dec 13, 2024
26ec5fa
reading params is now async
nathanstitt Dec 13, 2024
2e22874
file changed after `npm install`
nathanstitt Dec 14, 2024
087a7cf
add codemod to upgrade script
nathanstitt Dec 14, 2024
89e228c
Merge pull request #4 from safeinsights/update-all-the-things
nathanstitt Dec 14, 2024
1ff98f1
add codemod to upgrade script
nathanstitt Dec 14, 2024
b41ceba
Merge remote-tracking branch 'template/main' into update-all-the-things
nathanstitt Dec 14, 2024
1b24965
remove unneeded overrides
nathanstitt Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .eslintrc.json

This file was deleted.

7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.env*
.DS_Store
.idea
*.log
tmp/
.env.local

.next/
test-results/
*.tern-port
Expand All @@ -14,7 +13,7 @@ yarn-error.log*
*.tsbuildinfo
.npm
.eslintcache
package-lock.json
coverage/
playwright-report/
.env
.parcel-cache
src/styles/generated
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:22-bookworm AS base
WORKDIR /app


COPY package.json package-lock.json ./
COPY package.json package-lock.json panda.config.ts ./

RUN npm install

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y curl jq && rm -rf /var/lib/apt/lists/*

FROM base AS npm

COPY package.json package-lock.json* ./
COPY package.json package-lock.json panda.config.ts ./
RUN npm ci

FROM base AS builder
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ The management app (also called Basic Management App or BMA) serves as an interf

It’s responsible for:

- Researcher creates/modifies/deletes study
- Member is notified when a study proposal is submitted
- Researcher is notified when study is approved
- Member reviews/approves/denies study
- Reports study status in response to enclave's SetupApp requests
- Researcher creates/modifies/deletes study
- Member is notified when a study proposal is submitted
- Researcher is notified when study is approved
- Member reviews/approves/denies study
- Reports study status in response to enclave's SetupApp requests

# Development

Expand Down Expand Up @@ -39,10 +39,10 @@ Otherwise you can use Docker compose to run the app and a postgresql database by

Other useful commands:

- `docker compose build` will rebuild the docker image, needs to be ran after packages are installed
- `docker compose exec mgmnt-app ./bin/migrate-dev-db` runs migrations (needs running `docker compose up` at same time)
- `docker volume rm management-app_pgdata` will delete the database, allowing it to be migrated freshly
- `docker compose down -v --rmi all` "reset switch" (e.g. on DB errors) this command stops and removes Docker containers, networks, volumes, and all images used by the Docker Compose services.
- `docker compose build` will rebuild the docker image, needs to be ran after packages are installed
- `docker compose exec mgmnt-app ./bin/migrate-dev-db` runs migrations (needs running `docker compose up` at same time)
- `docker volume rm management-app_pgdata` will delete the database, allowing it to be migrated freshly
- `docker compose down -v --rmi all` "reset switch" (e.g. on DB errors) this command stops and removes Docker containers, networks, volumes, and all images used by the Docker Compose services.

Open [http://localhost:4000](http://localhost:4000) with your browser to see the result.

Expand All @@ -52,7 +52,7 @@ This project uses [`next/font`](https://nextjs.org/docs/app/building-your-applic

### Enclave API Routes

- Api routes are protected by an authorization header containing a JWT Bearer which is signed with a RSA private key held be the member. The public key is stored in the members record accessed at the admin page at /admin/members
- Api routes are protected by an authorization header containing a JWT Bearer which is signed with a RSA private key held be the member. The public key is stored in the members record accessed at the admin page at /admin/members

To generate a public private key you can run:

Expand All @@ -65,8 +65,8 @@ openssl rsa -pubout -in private_key.pem -out public_key.pem

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

Expand All @@ -87,9 +87,9 @@ The new way to deploy is from the IaC repo, run:

There are a few CLI applications to debug the API end endpoints:

- npx tsx bin/debug/fetch-runnable.ts -u https://pilot.safeinsights.org/ -m openstax -k <path to private key>
- npx tsx bin/debug/set-status.ts -o https://pilot.safeinsights.org -m openstax -k <path to private key> -s <status: RUNNING | ERRORED> -r <uuid of run>
- npx tsx bin/debug/upload-results.ts -o https://pilot.safeinsights.org -m openstax -k <path to private key> -r <uuid of run> -f <path to file to upload as results>
- npx tsx bin/debug/fetch-runnable.ts -u https://pilot.safeinsights.org/ -m openstax -k <path to private key>
- npx tsx bin/debug/set-status.ts -o https://pilot.safeinsights.org -m openstax -k <path to private key> -s <status: RUNNING | ERRORED> -r <uuid of run>
- npx tsx bin/debug/upload-results.ts -o https://pilot.safeinsights.org -m openstax -k <path to private key> -r <uuid of run> -f <path to file to upload as results>

**Currently** it is possible to upload results and then set status back to RUNNING to force the run to re-appear in the runnable api results and repeatedly upload files. while useful for testing, do not depend on that behaviour: it's likely we'll not allow it in later versions.

Expand Down
3 changes: 3 additions & 0 deletions bin/apply-updates-from-template
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
set -e

git merge template/main

# https://nextjs.org/docs/app/building-your-application/upgrading/codemods#migrate-to-async-dynamic-apis
npx @next/codemod@latest next-async-request-api
5 changes: 4 additions & 1 deletion bin/bootstrap-from-app-template
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

set -e
# this script lacks 'set -e' on purpose to allow for manual intervention
# we want to proceed even if the main remote may not exist and template may have already been setup

git remote remove main

git remote remove origin

Expand Down
15 changes: 13 additions & 2 deletions bin/update-app-from-template
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

set -e

git fetch template
REMOTE_NAME="template"
REMOTE_URL="[email protected]:safeinsights/app-template.git"

git checkout template/main bin/apply-updates-from-template
# Check if the remote exists
if git remote get-url $REMOTE_NAME &>/dev/null; then
echo "Remote '$REMOTE_NAME' already exists."
else
echo "Remote '$REMOTE_NAME' does not exist. Adding remote..."
git remote add $REMOTE_NAME $REMOTE_URL
fi

git fetch $REMOTE_NAME

git checkout $REMOTE_NAME/main bin/apply-updates-from-template

./bin/apply-updates-from-template

Expand Down
23 changes: 23 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// eslint.config.mjs
import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat({
// import.meta.dirname is available after Node.js v20.11.0
baseDirectory: import.meta.dirname,
})

/** @type {import('eslint').Linter.Config[]} */
export default [
{
ignores: ['src/styles/generated/'],
},
...compat.extends('next/core-web-vitals'),
...compat.extends('next/typescript'),
{
rules: {
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-unused-vars': ['error', { ignoreRestSiblings: true, varsIgnorePattern: '_+', argsIgnorePattern: '^_' }],
semi: ['error', 'never'],
},
},
]
4 changes: 4 additions & 0 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
'*.{js,jsx,ts,tsx,md,html,css}': ['prettier --write', 'eslint --fix'],
'*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
}
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
5 changes: 1 addition & 4 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { withSentryConfig } from '@sentry/nextjs'
import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin'

const withVanillaExtract = createVanillaExtractPlugin()

/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
}

export default withSentryConfig(withVanillaExtract(nextConfig), {
export default withSentryConfig(nextConfig, {
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

Expand Down
Loading
Loading