Skip to content

Commit

Permalink
Upgrade RedwoodJS to 7.4.3 (#246)
Browse files Browse the repository at this point in the history
* RedwoodJS 7.4.3, WIP

* Node20, updated GraphQL type defs

* Removed prop-types package

* jest-dom includes, staging node20

* Migrate to server.ts file

* Remove RedwoodApolloProvider to fix test issue with 7.4.3

* Upgrade vite to patch CVE-2024-31207
  • Loading branch information
jakekreider authored May 6, 2024
1 parent 7347e8e commit 490351f
Show file tree
Hide file tree
Showing 17 changed files with 2,939 additions and 3,152 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.18.2
v20.12.2
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# base
# ------------------------------------------------
FROM node:18-bookworm-slim as base
FROM node:20-bookworm-slim as base

RUN apt-get update && apt-get install -y \
openssl \
Expand Down Expand Up @@ -86,7 +86,7 @@ CMD [ "node_modules/.bin/rw-server", "api", "--load-env-files" ]

# serve web
# ------------------------------------------------
FROM node:18-bookworm-slim as web_serve
FROM node:20-bookworm-slim as web_serve

USER node
WORKDIR /home/node/app
Expand Down
5 changes: 3 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"@opentelemetry/instrumentation": "^0.45.1",
"@passageidentity/passage-node": "2.9.0",
"@prisma/instrumentation": "^5.7.0",
"@redwoodjs/api": "6.4.2",
"@redwoodjs/graphql-server": "6.4.2",
"@redwoodjs/api": "7.4.3",
"@redwoodjs/api-server": "7.4.3",
"@redwoodjs/graphql-server": "7.4.3",
"dd-trace": "^4.20.0",
"exceljs": "^4.4.0"
}
Expand Down
52 changes: 0 additions & 52 deletions api/server.config.js

This file was deleted.

13 changes: 13 additions & 0 deletions api/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createServer } from '@redwoodjs/api-server'

import { logger } from 'src/lib/logger'

async function main() {
const server = await createServer({
logger,
})

await server.start()
}

main()
8 changes: 8 additions & 0 deletions api/types/graphql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type Scalars = {
Int: number;
Float: number;
BigInt: number;
Byte: Buffer;
Date: Date | string;
DateTime: Date | string;
JSON: Prisma.JsonValue;
Expand Down Expand Up @@ -794,6 +795,7 @@ export type ResolversTypes = {
Agency: ResolverTypeWrapper<MergePrismaWithSdlTypes<PrismaAgency, MakeRelationsOptional<Agency, AllMappedModels>, AllMappedModels>>;
BigInt: ResolverTypeWrapper<Scalars['BigInt']>;
Boolean: ResolverTypeWrapper<Scalars['Boolean']>;
Byte: ResolverTypeWrapper<Scalars['Byte']>;
CreateAgencyInput: CreateAgencyInput;
CreateExpenditureCategoryInput: CreateExpenditureCategoryInput;
CreateInputTemplateInput: CreateInputTemplateInput;
Expand Down Expand Up @@ -846,6 +848,7 @@ export type ResolversParentTypes = {
Agency: MergePrismaWithSdlTypes<PrismaAgency, MakeRelationsOptional<Agency, AllMappedModels>, AllMappedModels>;
BigInt: Scalars['BigInt'];
Boolean: Scalars['Boolean'];
Byte: Scalars['Byte'];
CreateAgencyInput: CreateAgencyInput;
CreateExpenditureCategoryInput: CreateExpenditureCategoryInput;
CreateInputTemplateInput: CreateInputTemplateInput;
Expand Down Expand Up @@ -924,6 +927,10 @@ export interface BigIntScalarConfig extends GraphQLScalarTypeConfig<ResolversTyp
name: 'BigInt';
}

export interface ByteScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Byte'], any> {
name: 'Byte';
}

export type CreateOrgAgencyAdminPayloadResolvers<ContextType = RedwoodGraphQLContext, ParentType extends ResolversParentTypes['CreateOrgAgencyAdminPayload'] = ResolversParentTypes['CreateOrgAgencyAdminPayload']> = {
agency: OptArgsResolverFn<Maybe<ResolversTypes['Agency']>, ParentType, ContextType>;
organization: OptArgsResolverFn<Maybe<ResolversTypes['Organization']>, ParentType, ContextType>;
Expand Down Expand Up @@ -1399,6 +1406,7 @@ export type UserRelationResolvers<ContextType = RedwoodGraphQLContext, ParentTyp
export type Resolvers<ContextType = RedwoodGraphQLContext> = {
Agency: AgencyResolvers<ContextType>;
BigInt: GraphQLScalarType;
Byte: GraphQLScalarType;
CreateOrgAgencyAdminPayload: CreateOrgAgencyAdminPayloadResolvers<ContextType>;
Date: GraphQLScalarType;
DateTime: GraphQLScalarType;
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Welcome to [RedwoodJS](https://redwoodjs.com)!

> **Prerequisites**
>
> - Redwood requires [Node.js](https://nodejs.org/en/) (=18.x) and [Yarn](https://yarnpkg.com/) (>=1.15)
> - Redwood requires [Node.js](https://nodejs.org/en/) (>20.x) and [Yarn](https://yarnpkg.com/) (>=1.15)
> - Are you on Windows? For best results, follow our [Windows development setup](https://redwoodjs.com/docs/how-to/windows-development-setup) guide
Start by installing dependencies:
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
},
"devDependencies": {
"@netlify/zip-it-and-ship-it": "^9.27.0",
"@redwoodjs/auth-custom-setup": "6.4.2",
"@redwoodjs/cli-storybook": "6.4.2",
"@redwoodjs/core": "6.4.2"
"@redwoodjs/auth-custom-setup": "7.4.3",
"@redwoodjs/cli-storybook": "7.4.3",
"@redwoodjs/core": "7.4.3"
},
"eslintConfig": {
"extends": "@redwoodjs/eslint-config",
"root": true
},
"engines": {
"node": "18.18.2",
"yarn": "1.22.19"
"node": "20.12.2"
},
"prisma": {
"seed": "yarn rw exec seed"
Expand Down
2 changes: 1 addition & 1 deletion terraform/production.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ postgres_query_logging_enabled = true

// General Lambda options
lambda_log_level = "debug"
lambda_js_runtime = "nodejs18.x"
lambda_js_runtime = "nodejs20.x"
lambda_py_runtime = "python3.12"
lambda_arch = "x86_64"

Expand Down
2 changes: 1 addition & 1 deletion terraform/staging.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postgres_query_logging_enabled = true

// General Lambda options
lambda_log_level = "debug"
lambda_js_runtime = "nodejs18.x"
lambda_js_runtime = "nodejs20.x"
lambda_py_runtime = "python3.12"
lambda_arch = "x86_64"

Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ variable "console_container_image" {
variable "lambda_js_runtime" {
description = "Lambda runtime for the target Node.js version."
type = string
default = "nodejs18.x"
default = "nodejs20.x"
}

variable "lambda_py_runtime" {
Expand Down
11 changes: 5 additions & 6 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@
"dependencies": {
"@datadog/browser-rum": "^5.4.0",
"@passageidentity/passage-elements": "^1.21.4",
"@redwoodjs/auth": "6.4.2",
"@redwoodjs/forms": "6.4.2",
"@redwoodjs/router": "6.4.2",
"@redwoodjs/web": "6.4.2",
"@redwoodjs/auth": "7.4.3",
"@redwoodjs/forms": "7.4.3",
"@redwoodjs/router": "7.4.3",
"@redwoodjs/web": "7.4.3",
"@tanstack/react-table": "^8.10.7",
"bootstrap": "^5.3.2",
"bootstrap-icons": "^1.11.2",
"humanize-string": "2.1.0",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-bootstrap": "^2.9.1",
"react-dom": "18.2.0"
},
"devDependencies": {
"@redwoodjs/vite": "6.4.2",
"@redwoodjs/vite": "7.4.3",
"@testing-library/react": "^14.2.1",
"@types/node": "^20.10.4",
"@types/react": "18.2.39",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { render } from '@redwoodjs/testing/web'
import { RedwoodApolloProvider } from '@redwoodjs/web/apollo'

import ReportingPeriodsPage from './ReportingPeriodsPage'

// Improve this test with help from the Redwood Testing Doc:
// https://redwoodjs.com/docs/testing#testing-pages-layouts
function apolloProvider(children) {
return <RedwoodApolloProvider>{children}</RedwoodApolloProvider>
}

describe('ReportingPeriodsPage', () => {
it('renders successfully', () => {
expect(() => {
render(apolloProvider(<ReportingPeriodsPage />))
render(<ReportingPeriodsPage />)
}).not.toThrow()
})
})
9 changes: 1 addition & 8 deletions web/src/pages/UploadTemplatePage/UploadTemplatePage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { render } from '@redwoodjs/testing/web'
import { RedwoodApolloProvider } from '@redwoodjs/web/apollo'

import UploadTemplatePage from './UploadTemplatePage'

// Improve this test with help from the Redwood Testing Doc:
// https://redwoodjs.com/docs/testing#testing-pages-layouts
function apolloProvider(children) {
return <RedwoodApolloProvider>{children}</RedwoodApolloProvider>
}

describe('UploadTemplatePage', () => {
it('renders successfully', () => {
expect(() => {
render(apolloProvider(<UploadTemplatePage id={1} />))
render(<UploadTemplatePage id={1} />)
}).not.toThrow()
})
})
4 changes: 2 additions & 2 deletions web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"types/*": ["./types/*", "../types/*"],
"@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/web"]
},
"typeRoots": ["../node_modules/@types", "./node_modules/@types"],
"types": ["jest", "@testing-library/jest-dom", "node"],
"typeRoots": ["../node_modules/@types", "./node_modules/@types", "../node_modules/@testing-library"],
"types": ["jest", "jest-dom", "node"],
"jsx": "preserve"
},
"include": [
Expand Down
1 change: 1 addition & 0 deletions web/types/graphql.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Scalars = {
Int: number;
Float: number;
BigInt: number;
Byte: Buffer;
Date: string;
DateTime: string;
JSON: Prisma.JsonValue;
Expand Down
Loading

0 comments on commit 490351f

Please sign in to comment.