From 7e78ea8017f398fa88c3361857204d0afc42fb11 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Mon, 29 Mar 2021 16:46:15 +0200 Subject: [PATCH 01/25] Update year in LICENSE (#2135) --- LICENSE | 2 +- packages/create-redwood-app/template/LICENSE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index f943bbba4cb0..f6d95dc029ed 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Redwood +Copyright (c) 2021 Redwood Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/packages/create-redwood-app/template/LICENSE b/packages/create-redwood-app/template/LICENSE index f943bbba4cb0..f6d95dc029ed 100644 --- a/packages/create-redwood-app/template/LICENSE +++ b/packages/create-redwood-app/template/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Redwood +Copyright (c) 2021 Redwood Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d6f0cdc6676bc53b9bf0e4e0f4361d2fec6dbb94 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Mon, 29 Mar 2021 16:54:49 +0200 Subject: [PATCH 02/25] useParams should always be populated. (#2142) * Add failing test case for empty params. * Add some clarifications for failing test. * Set params before loading a new route. * Update packages/router/src/__tests__/router.test.tsx Co-authored-by: Tobbe Lundberg * Add params test case for Set. * Make tests start on initial location, instead of "/". * Fix engrish. * No longer set params in pageLoader. * Add top-level routes structure. * Calculate params on location, and router-state changes. * Fix type errors. * Revert this change. * Take search params into account. * Update packages/router/src/router-context.tsx Co-authored-by: Tobbe Lundberg * Remove ts-ignore-error. Co-authored-by: Tobbe Lundberg --- packages/router/src/__tests__/router.test.tsx | 44 +++++++++++++++++++ packages/router/src/params.tsx | 37 +++++++++++++--- packages/router/src/router-context.tsx | 16 ++++++- packages/router/src/router.tsx | 2 +- 4 files changed, 89 insertions(+), 10 deletions(-) diff --git a/packages/router/src/__tests__/router.test.tsx b/packages/router/src/__tests__/router.test.tsx index 089c12f054e2..d5982f6486d7 100644 --- a/packages/router/src/__tests__/router.test.tsx +++ b/packages/router/src/__tests__/router.test.tsx @@ -464,3 +464,47 @@ test('renders first matching route only', async () => { await waitFor(() => screen.getByText('About Page')) expect(screen.queryByText(/param/)).not.toBeInTheDocument() }) + +test('params should never be an empty object', async (done) => { + const ParamPage = () => { + const params = useParams() + expect(params).not.toEqual({}) + done() + return null + } + + const TestRouter = () => ( + // @ts-expect-error - Meh. + + + + ) + + act(() => navigate('/test/1')) + render() +}) + +test('params should never be an empty object in Set', async (done) => { + const ParamPage = () => { + return null + } + + const SetWithUseParams = ({ children }) => { + const params = useParams() + expect(params).not.toEqual({}) + done() + return children + } + + const TestRouter = () => ( + // @ts-expect-error - Meh. + + + + + + ) + + act(() => navigate('/test/1')) + render() +}) diff --git a/packages/router/src/params.tsx b/packages/router/src/params.tsx index 2ab860e1d39c..394a0a4aaac4 100644 --- a/packages/router/src/params.tsx +++ b/packages/router/src/params.tsx @@ -1,18 +1,41 @@ import React, { useState, useContext } from 'react' -import { createNamedContext } from './internal' +import { useLocation } from 'src/location' +import { useRouterState } from 'src/router-context' + +import { createNamedContext, matchPath, parseSearch } from './internal' export interface ParamsContextProps { - params: Record | undefined - setParams: (newParams: Record | undefined) => void + params: Record + setParams: (newParams: Record) => void } export const ParamsContext = createNamedContext('Params') export const ParamsProvider: React.FC = ({ children }) => { - const [params, setParams] = useState | undefined>( - undefined - ) + const { routes, paramTypes } = useRouterState() + const location = useLocation() + + let initialParams = parseSearch(location.search) + + for (const route of routes) { + if (route.path) { + const { match, params } = matchPath( + route.path, + location.pathname, + paramTypes + ) + + if (match) { + initialParams = { + ...initialParams, + ...params, + } + } + } + } + + const [params, setParams] = useState>(initialParams) return ( @@ -28,5 +51,5 @@ export const useParams = () => { throw new Error('useParams must be used within a ParamsProvider') } - return paramsContext.params || {} + return paramsContext.params } diff --git a/packages/router/src/router-context.tsx b/packages/router/src/router-context.tsx index a6beba0810af..4cd3a5827e39 100644 --- a/packages/router/src/router-context.tsx +++ b/packages/router/src/router-context.tsx @@ -2,7 +2,9 @@ import React, { useReducer, createContext, useContext } from 'react' import { useAuth } from '@redwoodjs/auth' -import { ParamType } from './internal' +import type { ParamType } from 'src/internal' +import { isRoute, PageType } from 'src/router' +import { flattenAll } from 'src/util' const DEFAULT_PAGE_LOADING_DELAY = 1000 // milliseconds @@ -10,6 +12,7 @@ export interface RouterState { paramTypes?: Record pageLoadingDelay?: number useAuth: typeof useAuth + routes: Array<{ name?: string; path?: string; page?: PageType }> } const RouterStateContext = createContext(undefined) @@ -22,7 +25,7 @@ const RouterSetContext = createContext< React.Dispatch> | undefined >(undefined) -interface ProviderProps extends Omit { +interface ProviderProps extends Omit { useAuth?: typeof useAuth } @@ -36,10 +39,19 @@ export const RouterContextProvider: React.FC = ({ pageLoadingDelay = DEFAULT_PAGE_LOADING_DELAY, children, }) => { + // Create an internal representation of all the routes and paths. + const routes = flattenAll(children) + .filter(isRoute) + .map((route) => { + const { name, path, page } = route.props + return { name, path, page } + }) + const [state, setState] = useReducer(stateReducer, { useAuth: customUseAuth || useAuth, paramTypes, pageLoadingDelay, + routes, }) return ( diff --git a/packages/router/src/router.tsx b/packages/router/src/router.tsx index c508ec2e8882..7b288442fb86 100644 --- a/packages/router/src/router.tsx +++ b/packages/router/src/router.tsx @@ -326,4 +326,4 @@ const normalizePage = (specOrPage: Spec | React.ComponentType): Spec => { } } -export { Router, Route, Private, namedRoutes as routes, isRoute } +export { Router, Route, Private, namedRoutes as routes, isRoute, PageType } From 29b7aa17109c5dddc3dd8e10a2ba9358ab560839 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Mon, 29 Mar 2021 17:22:02 +0200 Subject: [PATCH 03/25] Router: Populate `routes` for tests (#2133) Fixes #2131 --- packages/testing/src/MockRouter.tsx | 30 +++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/testing/src/MockRouter.tsx b/packages/testing/src/MockRouter.tsx index d0f9e2925b43..f11782befb61 100644 --- a/packages/testing/src/MockRouter.tsx +++ b/packages/testing/src/MockRouter.tsx @@ -3,35 +3,31 @@ import React from 'react' // Bypass the `main` field in `package.json` because we alias `@redwoodjs/router` // for jest and Storybook. Not doing so would cause an infinite loop. -// See: ./packages/core/config/jest.config.web.js +// See: ./packages/core/config/src/configs/browser/jest.createConfig.ts // @ts-ignore -import { Private, Route } from '@redwoodjs/router/dist/index' +import { isRoute } from '@redwoodjs/router/dist/router' +import { flattenAll, replaceParams } from '@redwoodjs/router/dist/util' // @ts-ignore export * from '@redwoodjs/router/dist/index' export const routes: { [routeName: string]: () => string } = {} -const getPrivateRoutes = (children: React.ReactNode) => - (React.Children.toArray(children) as React.ReactElement[]) - .filter((child) => child.type === Private) - .map((child) => child.props.children) - .flat(Infinity) - /** * We overwrite the default `Router` export. * It populates the `routes.()` utility object. */ export const Router: React.FunctionComponent = ({ children }) => { - // get all children from blocks. - const privateRoutes = getPrivateRoutes(children) + const flatChildArray = flattenAll(children) + + flatChildArray.forEach((child) => { + if (isRoute(child)) { + const { name, path } = child.props - const normalRoutes = (React.Children.toArray( - children - ) as React.ReactElement[]).filter((child) => child.type === Route) + if (name && path) { + routes[name] = (args = {}) => replaceParams(path, args) + } + } + }) - for (const child of [...privateRoutes, ...normalRoutes]) { - const { name } = child.props - routes[name] = () => name - } return <> } From b4323d4c0f92ac7fd2ed58f442ab27244e9371d6 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Mon, 29 Mar 2021 18:19:51 +0200 Subject: [PATCH 04/25] v0.28.2 (#2143) * Install @redwoodjs/api-server as a dependency and add lockfile. (#2129) * Include api-server as a dependecy. * Pin apollo-server-core. * v0.28.1 * useParams should always be populated. (#2142) * Add failing test case for empty params. * Add some clarifications for failing test. * Set params before loading a new route. * Update packages/router/src/__tests__/router.test.tsx Co-authored-by: Tobbe Lundberg * Add params test case for Set. * Make tests start on initial location, instead of "/". * Fix engrish. * No longer set params in pageLoader. * Add top-level routes structure. * Calculate params on location, and router-state changes. * Fix type errors. * Revert this change. * Take search params into account. * Update packages/router/src/router-context.tsx Co-authored-by: Tobbe Lundberg * Remove ts-ignore-error. Co-authored-by: Tobbe Lundberg * Router: Populate `routes` for tests (#2133) Fixes #2131 * v0.28.2 Co-authored-by: Tobbe Lundberg --- lerna.json | 2 +- packages/api-server/package.json | 2 +- packages/api/package.json | 8 ++++---- packages/auth/package.json | 2 +- packages/cli/package.json | 8 ++++---- packages/core/package.json | 12 ++++++------ packages/create-redwood-app/package.json | 4 ++-- .../create-redwood-app/template/api/package.json | 4 ++-- packages/create-redwood-app/template/package.json | 2 +- .../create-redwood-app/template/web/package.json | 6 +++--- packages/dev-server/package.json | 4 ++-- packages/eslint-config/package.json | 4 ++-- packages/eslint-plugin-redwood/package.json | 2 +- packages/forms/package.json | 2 +- packages/internal/package.json | 2 +- packages/prerender/package.json | 12 ++++++------ packages/router/package.json | 4 ++-- packages/structure/package.json | 4 ++-- packages/testing/package.json | 10 +++++----- packages/web/package.json | 4 ++-- 20 files changed, 49 insertions(+), 49 deletions(-) diff --git a/lerna.json b/lerna.json index 5cc4a00a1827..4a14f635649d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.28.1", + "version": "0.28.2", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/packages/api-server/package.json b/packages/api-server/package.json index d9d9ed2781e7..6bf7d92cad30 100644 --- a/packages/api-server/package.json +++ b/packages/api-server/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/api-server", "description": "Redwood's HTTP server for Serverless Functions", - "version": "0.28.1", + "version": "0.28.2", "bin": { "api-server": "./dist/index.js", "rw-api-server": "./dist/index.js", diff --git a/packages/api/package.json b/packages/api/package.json index 9e85ef8beb9f..e6853da1c8c7 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/api", - "version": "0.28.1", + "version": "0.28.2", "files": [ "dist", "logger" @@ -11,7 +11,7 @@ "dependencies": { "@graphql-tools/merge": "6.2.10", "@prisma/client": "2.19.0", - "@redwoodjs/internal": "^0.28.1", + "@redwoodjs/internal": "^0.28.2", "@types/pino": "^6.3.6", "apollo-server-lambda": "2.18.2", "core-js": "3.6.5", @@ -25,8 +25,8 @@ "pino-pretty": "^4.7.0" }, "devDependencies": { - "@redwoodjs/auth": "^0.28.1", - "@redwoodjs/dev-server": "^0.28.1", + "@redwoodjs/auth": "^0.28.2", + "@redwoodjs/dev-server": "^0.28.2", "@types/jsonwebtoken": "^8.3.9", "@types/lodash.merge": "^4.6.6", "@types/lodash.omitby": "^4.6.6", diff --git a/packages/auth/package.json b/packages/auth/package.json index e389ec11f6f4..5670903365c3 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/auth", - "version": "0.28.1", + "version": "0.28.2", "files": [ "dist" ], diff --git a/packages/cli/package.json b/packages/cli/package.json index 34f739c297fa..a37794468c05 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/cli", "description": "The Redwood Command Line", - "version": "0.28.1", + "version": "0.28.2", "license": "MIT", "bin": { "redwood": "./dist/index.js", @@ -14,9 +14,9 @@ ], "dependencies": { "@prisma/sdk": "2.19.0", - "@redwoodjs/internal": "^0.28.1", - "@redwoodjs/prerender": "^0.28.1", - "@redwoodjs/structure": "^0.28.1", + "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/prerender": "^0.28.2", + "@redwoodjs/structure": "^0.28.2", "boxen": "^4.2.0", "camelcase": "^6.0.0", "chalk": "^4.1.0", diff --git a/packages/core/package.json b/packages/core/package.json index 3c06acf3bef5..bdcd5ccbadb6 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/core", - "version": "0.28.1", + "version": "0.28.2", "license": "MIT", "files": [ "config", @@ -23,11 +23,11 @@ "@babel/preset-typescript": "^7.10.4", "@babel/runtime-corejs3": "^7.11.2", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", - "@redwoodjs/cli": "^0.28.1", - "@redwoodjs/dev-server": "^0.28.1", - "@redwoodjs/eslint-config": "^0.28.1", - "@redwoodjs/internal": "^0.28.1", - "@redwoodjs/testing": "^0.28.1", + "@redwoodjs/cli": "^0.28.2", + "@redwoodjs/dev-server": "^0.28.2", + "@redwoodjs/eslint-config": "^0.28.2", + "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/testing": "^0.28.2", "@storybook/addon-a11y": "^6.1.19", "@storybook/react": "^6.1.21", "@testing-library/jest-dom": "5.11.6", diff --git a/packages/create-redwood-app/package.json b/packages/create-redwood-app/package.json index 0270e91a5d39..49e836cb709a 100644 --- a/packages/create-redwood-app/package.json +++ b/packages/create-redwood-app/package.json @@ -1,6 +1,6 @@ { "name": "create-redwood-app", - "version": "0.28.1", + "version": "0.28.2", "license": "MIT", "bin": "./dist/create-redwood-app.js", "files": [ @@ -9,7 +9,7 @@ ], "dependencies": { "@babel/runtime-corejs3": "^7.9.2", - "@redwoodjs/internal": "^0.28.1", + "@redwoodjs/internal": "^0.28.2", "axios": "^0.20.0", "chalk": "^4.1.0", "check-node-version": "^4.0.2", diff --git a/packages/create-redwood-app/template/api/package.json b/packages/create-redwood-app/template/api/package.json index 90f5dac49ff6..9028f67dde9c 100644 --- a/packages/create-redwood-app/template/api/package.json +++ b/packages/create-redwood-app/template/api/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "dependencies": { - "@redwoodjs/api": "^0.28.1", - "@redwoodjs/api-server": "^0.28.1" + "@redwoodjs/api": "^0.28.2", + "@redwoodjs/api-server": "^0.28.2" } } \ No newline at end of file diff --git a/packages/create-redwood-app/template/package.json b/packages/create-redwood-app/template/package.json index 80a7a6e1ae52..450a694bca8c 100644 --- a/packages/create-redwood-app/template/package.json +++ b/packages/create-redwood-app/template/package.json @@ -8,7 +8,7 @@ ] }, "devDependencies": { - "@redwoodjs/core": "^0.28.1" + "@redwoodjs/core": "^0.28.2" }, "eslintConfig": { "extends": "@redwoodjs/eslint-config", diff --git a/packages/create-redwood-app/template/web/package.json b/packages/create-redwood-app/template/web/package.json index 9aeb895de914..1f758299a3ce 100644 --- a/packages/create-redwood-app/template/web/package.json +++ b/packages/create-redwood-app/template/web/package.json @@ -13,9 +13,9 @@ ] }, "dependencies": { - "@redwoodjs/forms": "^0.28.1", - "@redwoodjs/router": "^0.28.1", - "@redwoodjs/web": "^0.28.1", + "@redwoodjs/forms": "^0.28.2", + "@redwoodjs/router": "^0.28.2", + "@redwoodjs/web": "^0.28.2", "prop-types": "^15.7.2", "react": "^17.0.1", "react-dom": "^17.0.1" diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index 993d3eaebdfc..65d6493a7541 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/dev-server", "description": "Redwood's HTTP server for serverless Functions", - "version": "0.28.1", + "version": "0.28.2", "bin": { "dev-server": "./dist/main.js" }, @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "@babel/register": "^7.9.0", - "@redwoodjs/internal": "^0.28.1", + "@redwoodjs/internal": "^0.28.2", "body-parser": "^1.19.0", "chokidar": "^3.4.3", "express": "^4.17.1", diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index b829daeb10dd..e31a7a005733 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,10 +1,10 @@ { "name": "@redwoodjs/eslint-config", - "version": "0.28.1", + "version": "0.28.2", "main": "index.js", "license": "MIT", "dependencies": { - "@redwoodjs/eslint-plugin-redwood": "^0.28.1", + "@redwoodjs/eslint-plugin-redwood": "^0.28.2", "@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/parser": "^4.0.1", "babel-eslint": "^10.1.0", diff --git a/packages/eslint-plugin-redwood/package.json b/packages/eslint-plugin-redwood/package.json index 1ce7c785c29a..78ea73734a7c 100644 --- a/packages/eslint-plugin-redwood/package.json +++ b/packages/eslint-plugin-redwood/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/eslint-plugin-redwood", - "version": "0.28.1", + "version": "0.28.2", "description": "eslint plugin for Redwood rules.", "files": [ "dist" diff --git a/packages/forms/package.json b/packages/forms/package.json index 7a7eeb7263d1..8375c15cb6b5 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/forms", - "version": "0.28.1", + "version": "0.28.2", "files": [ "dist", "src/index.d.ts" diff --git a/packages/internal/package.json b/packages/internal/package.json index 3446d4b6096e..a5c79378cab1 100644 --- a/packages/internal/package.json +++ b/packages/internal/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/internal", - "version": "0.28.1", + "version": "0.28.2", "files": [ "dist" ], diff --git a/packages/prerender/package.json b/packages/prerender/package.json index 33b98570ca57..38c1c4ceab84 100644 --- a/packages/prerender/package.json +++ b/packages/prerender/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/prerender", "description": "RedwoodJS prerender", - "version": "0.28.1", + "version": "0.28.2", "license": "MIT", "files": [ "dist", @@ -14,11 +14,11 @@ }, "dependencies": { "@babel/register": "^7.9.0", - "@redwoodjs/auth": "^0.28.1", - "@redwoodjs/internal": "^0.28.1", - "@redwoodjs/router": "^0.28.1", - "@redwoodjs/structure": "^0.28.1", - "@redwoodjs/web": "^0.28.1", + "@redwoodjs/auth": "^0.28.2", + "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/router": "^0.28.2", + "@redwoodjs/structure": "^0.28.2", + "@redwoodjs/web": "^0.28.2", "babel-plugin-ignore-html-and-css-imports": "^0.1.0", "node-fetch": "^2.6.1" }, diff --git a/packages/router/package.json b/packages/router/package.json index c06d632efb93..be5c79e6f2c0 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/router", - "version": "0.28.1", + "version": "0.28.2", "files": [ "dist" ], @@ -9,7 +9,7 @@ "license": "MIT", "dependencies": { "@reach/skip-nav": "^0.13.2", - "@redwoodjs/auth": "^0.28.1", + "@redwoodjs/auth": "^0.28.2", "core-js": "3.6.5", "lodash.isequal": "^4.5.0" }, diff --git a/packages/structure/package.json b/packages/structure/package.json index 9f1b22e9b682..5d2125a0f78c 100644 --- a/packages/structure/package.json +++ b/packages/structure/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/structure", "description": "noun: the arrangement of and relations between the parts or elements of something complex", - "version": "0.28.1", + "version": "0.28.2", "license": "MIT", "main": "dist/index.js", "files": [ @@ -10,7 +10,7 @@ "types": "./dist/index.d.ts", "dependencies": { "@prisma/sdk": "2.19.0", - "@redwoodjs/internal": "^0.28.1", + "@redwoodjs/internal": "^0.28.2", "@types/line-column": "^1.0.0", "camelcase": "^6.0.0", "deepmerge": "^4.2.2", diff --git a/packages/testing/package.json b/packages/testing/package.json index b7762bec07de..bcaa9a70621b 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/testing", "description": "Tools, wrappers and configuration for testing a Redwood project.", - "version": "0.28.1", + "version": "0.28.2", "files": [ "dist" ], @@ -9,10 +9,10 @@ "types": "dist/index.d.ts", "license": "MIT", "dependencies": { - "@redwoodjs/auth": "^0.28.1", - "@redwoodjs/internal": "^0.28.1", - "@redwoodjs/router": "^0.28.1", - "@redwoodjs/web": "^0.28.1", + "@redwoodjs/auth": "^0.28.2", + "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/router": "^0.28.2", + "@redwoodjs/web": "^0.28.2", "@testing-library/react": "11.2.2", "@types/react": "17.0.3", "msw": "^0.21.2" diff --git a/packages/web/package.json b/packages/web/package.json index 0a440f95b7a7..12cd5ad7494b 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/web", - "version": "0.28.1", + "version": "0.28.2", "files": [ "dist", "apollo", @@ -12,7 +12,7 @@ "license": "MIT", "dependencies": { "@apollo/client": "^3.3.11", - "@redwoodjs/auth": "^0.28.1", + "@redwoodjs/auth": "^0.28.2", "core-js": "3.6.5", "graphql": "^15.3.0", "proptypes": "^1.1.0", From 423ae0abae2bbb817b33f6dcb838aa7eef460662 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Mon, 29 Mar 2021 22:31:13 +0200 Subject: [PATCH 05/25] Make understand authentication. (#2147) * Add test for Set and authentication. * Make set understand auth. * Fix race condition in useParams. --- packages/router/src/Set.tsx | 59 ++++++++++++------- packages/router/src/__tests__/router.test.tsx | 36 +++++++++++ packages/router/src/page-loader.tsx | 4 +- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/packages/router/src/Set.tsx b/packages/router/src/Set.tsx index 14a7200743b4..470d6ec68df0 100644 --- a/packages/router/src/Set.tsx +++ b/packages/router/src/Set.tsx @@ -1,6 +1,8 @@ import React, { ReactElement, ReactNode, FunctionComponentElement } from 'react' +import { Redirect } from './links' import { useLocation } from './location' +import { usePrivate } from './private-context' import { isRoute } from './router' import { useRouterState } from './router-context' import { flattenAll, matchPath } from './util' @@ -20,33 +22,48 @@ interface Props { export const Set: React.FC = ({ children, wrap }) => { const routerState = useRouterState() const location = useLocation() - const wrappers = Array.isArray(wrap) ? wrap : [wrap] + const { loading } = routerState.useAuth() + const { isPrivate, unauthorized, unauthenticated } = usePrivate() + const wrappers = Array.isArray(wrap) ? wrap : [wrap] // slap the wrappers in an array const flatChildArray = flattenAll(children) + const routes = flatChildArray + .filter(isRoute) + .filter((r) => typeof r.props.path !== 'undefined') - const matchingChildRoute = flatChildArray.some((child) => { - if (isRoute(child)) { - const { path } = child.props + for (const route of routes) { + const path = route.props.path as string - if (path) { - const { match } = matchPath( - path, - location.pathname, - routerState.paramTypes - ) + const { match } = matchPath(path, location.pathname, routerState.paramTypes) + if (match) { + if (isPrivate && unauthorized()) { + if (loading) { + return route.props?.whileLoading?.() || null + } else { + const currentLocation = + global.location.pathname + + encodeURIComponent(global.location.search) - if (match) { - return true + const unauthenticatedRoute = routerState.routes.filter( + ({ name }) => unauthenticated === name + )[0] + + return ( + + ) } } - } - return false - }) - - return matchingChildRoute - ? wrappers.reduceRight((acc, wrapper) => { - return React.createElement(wrapper, undefined, acc ? acc : children) - }, undefined) || null - : null + // Expand and nest the wrapped elements. + return ( + wrappers.reduceRight((acc, wrapper) => { + return React.createElement(wrapper, undefined, acc ? acc : children) + }, undefined) || null + ) + } + } + // No match, no render. + return null } diff --git a/packages/router/src/__tests__/router.test.tsx b/packages/router/src/__tests__/router.test.tsx index d5982f6486d7..4ecbfd24a2e2 100644 --- a/packages/router/src/__tests__/router.test.tsx +++ b/packages/router/src/__tests__/router.test.tsx @@ -508,3 +508,39 @@ test('params should never be an empty object in Set', async (done) => { act(() => navigate('/test/1')) render() }) + +test('Set is not rendered for unauthenticated user.', async () => { + // not authenticated. + mockAuth(false) + + const ParamPage = () => { + // This should never be called. We should be redirect to login instead. + expect(false).toBe(true) + return null + } + + const SetWithUseParams = ({ children }) => { + // This should never be called. We should be redirect to login instead. + expect(false).toBe(true) + return children + } + + const TestRouter = () => ( + // @ts-expect-error - Meh. + + + + + + +
home
} name="home" /> +
auth thyself
} name="login" /> +
+ ) + + const screen = render() + act(() => navigate('/')) + act(() => navigate('/test/1')) + + await waitFor(() => screen.getByText(/auth thyself/)) +}) diff --git a/packages/router/src/page-loader.tsx b/packages/router/src/page-loader.tsx index edafcfe61770..b92f43758a21 100644 --- a/packages/router/src/page-loader.tsx +++ b/packages/router/src/page-loader.tsx @@ -128,14 +128,14 @@ export class PageLoader extends React.Component { // Remove the timeout because the page has loaded. this.clearLoadingTimeout() + this.context.setParams(props.params) + this.setState({ pageName: name, Page: module.default, slowModuleImport: false, params: props.params, }) - - this.context.setParams(props.params) } render() { From eb0e0a9917b82b7b1af76a596824e7c0e15c7bfd Mon Sep 17 00:00:00 2001 From: David Price Date: Mon, 29 Mar 2021 18:05:20 -0700 Subject: [PATCH 06/25] update CRWA quick-start Node requirement (#2151) --- packages/create-redwood-app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-redwood-app/README.md b/packages/create-redwood-app/README.md index 920339910c18..e54948c0bf53 100644 --- a/packages/create-redwood-app/README.md +++ b/packages/create-redwood-app/README.md @@ -24,7 +24,7 @@ Do you love the Jamstack philosophy but need a database-backed web app? Want gre

Quick Start

-Redwood requires Node.js v12 and Yarn v1.15 (or newer). +Redwood requires Node.js v14 and Yarn v1.15 (or newer). ```console yarn create redwood-app redwood-project cd redwood-project From cbde257608a1c770a65d3f8e323e9ee4b90932ed Mon Sep 17 00:00:00 2001 From: Kris Coulson Date: Tue, 30 Mar 2021 02:40:52 -0700 Subject: [PATCH 07/25] Recalculate param on location change (#2152) * update params contexts directly in the context provider * update variable names * simplify imports * Update packages/router/src/__tests__/router.test.tsx Remove only, so we can test these against all tests. * Update packages/router/src/params.tsx Co-authored-by: Tobbe Lundberg * Update packages/router/src/params.tsx Co-authored-by: Tobbe Lundberg * Remove unused params context. * Name param variables properly. * Fix comment now that we've fixed test. * Remove this unused import. * Keep params order the same as before. Co-authored-by: Peter Pistorius Co-authored-by: Tobbe Lundberg --- packages/router/src/__tests__/router.test.tsx | 30 +++++++++++++++++++ packages/router/src/page-loader.tsx | 15 ++++------ packages/router/src/params.tsx | 29 +++++++++--------- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/packages/router/src/__tests__/router.test.tsx b/packages/router/src/__tests__/router.test.tsx index 4ecbfd24a2e2..95f4e73bf1b5 100644 --- a/packages/router/src/__tests__/router.test.tsx +++ b/packages/router/src/__tests__/router.test.tsx @@ -509,6 +509,36 @@ test('params should never be an empty object in Set', async (done) => { render() }) +test('params should never be an empty object in Set', async () => { + const ParamPage = () => { + const { documentId } = useParams() + return 'documentId: ' + documentId + } + + const SetWithUseParams = ({ children }) => { + const params = useParams() + // 1st run: { documentId: '1' } + // 2rd run: { documentId: '2' } + expect(params).not.toEqual({}) + return children + } + + const TestRouter = () => ( + // @ts-expect-error - Meh. + + + + + } name="home" /> + + ) + + act(() => navigate('/test/1')) + const screen = render() + act(() => navigate('/')) + await waitFor(() => screen.getByText(/documentId: 2/)) +}) + test('Set is not rendered for unauthenticated user.', async () => { // not authenticated. mockAuth(false) diff --git a/packages/router/src/page-loader.tsx b/packages/router/src/page-loader.tsx index b92f43758a21..7951fc74dcbc 100644 --- a/packages/router/src/page-loader.tsx +++ b/packages/router/src/page-loader.tsx @@ -2,12 +2,7 @@ import React, { useContext } from 'react' import isEqual from 'lodash.isequal' -import { - createNamedContext, - ParamsContext, - Spec, - getAnnouncement, -} from './internal' +import { createNamedContext, Spec, getAnnouncement } from './internal' export interface PageLoadingContextInterface { loading: boolean @@ -50,8 +45,6 @@ export class PageLoader extends React.Component { slowModuleImport: false, } - static contextType = ParamsContext - loadingTimeout?: number = undefined propsChanged = (p1: Props, p2: Props) => { @@ -103,6 +96,10 @@ export class PageLoader extends React.Component { } } + componentWillUnmount() { + this.setState = () => {} // Prevent updating state after component has been unmounted. + } + clearLoadingTimeout = () => { if (this.loadingTimeout) { clearTimeout(this.loadingTimeout) @@ -128,8 +125,6 @@ export class PageLoader extends React.Component { // Remove the timeout because the page has loaded. this.clearLoadingTimeout() - this.context.setParams(props.params) - this.setState({ pageName: name, Page: module.default, diff --git a/packages/router/src/params.tsx b/packages/router/src/params.tsx index 394a0a4aaac4..6efa5318cd36 100644 --- a/packages/router/src/params.tsx +++ b/packages/router/src/params.tsx @@ -1,13 +1,11 @@ -import React, { useState, useContext } from 'react' - -import { useLocation } from 'src/location' -import { useRouterState } from 'src/router-context' +import React, { useContext } from 'react' import { createNamedContext, matchPath, parseSearch } from './internal' +import { useLocation } from './location' +import { useRouterState } from './router-context' export interface ParamsContextProps { params: Record - setParams: (newParams: Record) => void } export const ParamsContext = createNamedContext('Params') @@ -16,7 +14,8 @@ export const ParamsProvider: React.FC = ({ children }) => { const { routes, paramTypes } = useRouterState() const location = useLocation() - let initialParams = parseSearch(location.search) + let pathParams = {} + const searchParams = parseSearch(location.search) for (const route of routes) { if (route.path) { @@ -26,19 +25,21 @@ export const ParamsProvider: React.FC = ({ children }) => { paramTypes ) - if (match) { - initialParams = { - ...initialParams, - ...params, - } + if (match && typeof params !== 'undefined') { + pathParams = params } } } - const [params, setParams] = useState>(initialParams) - return ( - + {children} ) From b8f1209557641465e026d064f8ebeaecdffb2497 Mon Sep 17 00:00:00 2001 From: David Price Date: Tue, 30 Mar 2021 02:55:14 -0700 Subject: [PATCH 08/25] upgrade apollo-server-lambda; remove resolution (#2153) Co-authored-by: Peter Pistorius --- packages/api/package.json | 2 +- .../create-redwood-app/template/package.json | 6 +- .../create-redwood-app/template/yarn.lock | 168 +++++++++--------- yarn.lock | 133 +++++++------- 4 files changed, 149 insertions(+), 160 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index e6853da1c8c7..158a6f0ee24d 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -13,7 +13,7 @@ "@prisma/client": "2.19.0", "@redwoodjs/internal": "^0.28.2", "@types/pino": "^6.3.6", - "apollo-server-lambda": "2.18.2", + "apollo-server-lambda": "2.22.2", "core-js": "3.6.5", "graphql": "15.5.0", "graphql-scalars": "1.9.0", diff --git a/packages/create-redwood-app/template/package.json b/packages/create-redwood-app/template/package.json index 450a694bca8c..d618d142ba50 100644 --- a/packages/create-redwood-app/template/package.json +++ b/packages/create-redwood-app/template/package.json @@ -20,8 +20,6 @@ }, "resolutions": { "react": "17.0.1", - "react-dom": "17.0.1", - "// Temporary fix for": "https://github.com/redwoodjs/redwood/issues/2127", - "apollo-server-core": "2.21.2" + "react-dom": "17.0.1" } -} \ No newline at end of file +} diff --git a/packages/create-redwood-app/template/yarn.lock b/packages/create-redwood-app/template/yarn.lock index 851cff0b7828..b7c1b0f43184 100644 --- a/packages/create-redwood-app/template/yarn.lock +++ b/packages/create-redwood-app/template/yarn.lock @@ -1782,10 +1782,10 @@ tslib "^2.1.0" warning "^4.0.3" -"@redwoodjs/api-server@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/api-server/-/api-server-0.28.0.tgz#29ee2dc206066a4636725835a8e85f40beb5d6bf" - integrity sha512-Tb9j2k13rRfXPYRBU4kaheUIUNTMpQyojaTaE2QVAX7Jc8muueLnQIkDcQasAJFBQUqMdt+kp6PkrMS6vE9qMA== +"@redwoodjs/api-server@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/api-server/-/api-server-0.28.2.tgz#5c66b5fec74f2c17d086019b31ff9181f1cc8dc3" + integrity sha512-h3fD8xrZ55aGBc5YXfz92+wdL5iH42uAqE+dm5abdQRAyaiIIwSXoUtdezk5h6F66zj9lV2aQniAIffqUjZ0Lw== dependencies: body-parser "^1.19.0" chokidar "3.5.1" @@ -1799,14 +1799,14 @@ youch "^2.1.1" youch-terminal "^1.0.1" -"@redwoodjs/api@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/api/-/api-0.28.0.tgz#427e2639b37d761b6d99a53524d3205917369fc0" - integrity sha512-re1u/FeYE/pJQ+GQSgZcLm1t/8Figgm64oa1MuSD5IuTZ7YnbS2TNjA7Q8JU71Fan3xJGugtxD4RVk+Ye+gsvw== +"@redwoodjs/api@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/api/-/api-0.28.2.tgz#2e08e770927a1b68138c9916fa7d26172705c277" + integrity sha512-+i0Y75D/akB5hekDPIVWKoFw4nDyY35xSksqWy5Ev/neteIheLxo5TBa+fZYKVokoCu1pUCbfA2iBQgZNPqxwg== dependencies: "@graphql-tools/merge" "6.2.10" "@prisma/client" "2.19.0" - "@redwoodjs/internal" "^0.28.0" + "@redwoodjs/internal" "^0.28.2" "@types/pino" "^6.3.6" apollo-server-lambda "2.18.2" core-js "3.6.5" @@ -1819,20 +1819,20 @@ pino "^6.11.1" pino-pretty "^4.7.0" -"@redwoodjs/auth@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/auth/-/auth-0.28.0.tgz#1360dad65df9981d98b3fe9e44c96c4388790b9a" - integrity sha512-TiBDrszWdWBBpdtQt5+/eeZPgS9iATRzLCY7VjnlJu4R+PMzH/iIxRzNoN/oWx6Xv4fjs6uIdFSSPm+R2d8H7A== +"@redwoodjs/auth@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/auth/-/auth-0.28.2.tgz#8a90767cc261cc511e235060b7bc673a24da5cb4" + integrity sha512-AqKtEG5BdIyK8XyxgetpIasTMwRQHCOt5Cjf5sYyj0sk2csTT/jbSORTGEXwuZBef6WnWJiTgS8U1UnQhdD6hQ== -"@redwoodjs/cli@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/cli/-/cli-0.28.0.tgz#5b816caae2835a067d504b48f3f5c38da15c3af5" - integrity sha512-2mAFt0eXtriOTbw+Sh643jXKPdlZHlfJbVLYZKH83xSe0RsLW9L0+aCUBdMtN0jjR7TWjyzX05tVoHPJA4VxMA== +"@redwoodjs/cli@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/cli/-/cli-0.28.2.tgz#2777e74fe00177c601568abd1dad46882ad373b7" + integrity sha512-E9nfdYuL2QzGkWuoymHCLI8G248BluiZEVi/+t0owQ7jvT0Y8CiJTU7jcSg5OG1JWsQacZLFsN+GLSt1uLRR0Q== dependencies: "@prisma/sdk" "2.19.0" - "@redwoodjs/internal" "^0.28.0" - "@redwoodjs/prerender" "^0.28.0" - "@redwoodjs/structure" "^0.28.0" + "@redwoodjs/internal" "^0.28.2" + "@redwoodjs/prerender" "^0.28.2" + "@redwoodjs/structure" "^0.28.2" boxen "^4.2.0" camelcase "^6.0.0" chalk "^4.1.0" @@ -1857,10 +1857,10 @@ terminal-link "^2.1.1" yargs "^16.0.3" -"@redwoodjs/core@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/core/-/core-0.28.0.tgz#77d16f562c379a16d79dffda68fbd807ed4b689a" - integrity sha512-pilFGA5egzsS5Xwvr/Rqd+RPQ5Ge4Q+Kg7W+8Epnqik99kjzQ+F3hDnXFBAwbsoTpfQBeqrWVVS9Bf26/43oZA== +"@redwoodjs/core@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/core/-/core-0.28.2.tgz#951952908b53865eaa0f753ddd3a7044fead38f7" + integrity sha512-Y6PpjZPkDhwO3YwfjuziXG44ZAyjTfPLlhGV8yRLqhHcbzFPt337lVNLLgWotjJp3jf9lN4N0dikbx/9qTPNfg== dependencies: "@babel/cli" "^7.11.6" "@babel/core" "^7.11.6" @@ -1872,11 +1872,11 @@ "@babel/preset-typescript" "^7.10.4" "@babel/runtime-corejs3" "^7.11.2" "@pmmmwh/react-refresh-webpack-plugin" "^0.4.3" - "@redwoodjs/cli" "^0.28.0" - "@redwoodjs/dev-server" "^0.28.0" - "@redwoodjs/eslint-config" "^0.28.0" - "@redwoodjs/internal" "^0.28.0" - "@redwoodjs/testing" "^0.28.0" + "@redwoodjs/cli" "^0.28.2" + "@redwoodjs/dev-server" "^0.28.2" + "@redwoodjs/eslint-config" "^0.28.2" + "@redwoodjs/internal" "^0.28.2" + "@redwoodjs/testing" "^0.28.2" "@storybook/addon-a11y" "^6.1.19" "@storybook/react" "^6.1.21" "@testing-library/jest-dom" "5.11.6" @@ -1925,13 +1925,13 @@ webpack-retry-chunk-load-plugin "^1.4.0" whatwg-fetch "^3.5.0" -"@redwoodjs/dev-server@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/dev-server/-/dev-server-0.28.0.tgz#c339c0b0ae6bf6e80d492d1aeed97db76d27c4cb" - integrity sha512-GJu/TOkjfxjsbMCcIAXK5YKISfwrCVKGzvnJPH9YH1yuKReWjUgb+Ai1X6E5ZTulEBkCVhaOsuNgtG9zFDuRyw== +"@redwoodjs/dev-server@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/dev-server/-/dev-server-0.28.2.tgz#c3480684e6fe3e866c2dc3617b539f65fc26f794" + integrity sha512-sMb3LTA4bvDBcIsl1kNRJJaH4wcngg46TQFAHVfa5xT3HOzPQoCXR0dstaG++Imf3frQiOH1U95azIE6JQXyzw== dependencies: "@babel/register" "^7.9.0" - "@redwoodjs/internal" "^0.28.0" + "@redwoodjs/internal" "^0.28.2" body-parser "^1.19.0" chokidar "^3.4.3" express "^4.17.1" @@ -1942,12 +1942,12 @@ youch "^2.1.1" youch-terminal "^1.0.1" -"@redwoodjs/eslint-config@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-config/-/eslint-config-0.28.0.tgz#1926e83a9cfaaf4897ccbe08b4f36acdad2ae064" - integrity sha512-HueUYOoWzISvtdeMmtjlwYH1Cp/T4KITYHLnqgZUvg6YdLil6+ObmwRuCd8pmX6Tgi/tAoXqscr1GqKCaPSNZA== +"@redwoodjs/eslint-config@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-config/-/eslint-config-0.28.2.tgz#7a718a1a70fd7fe73cf9d6ab7bcb47ccd10be5e1" + integrity sha512-4NbKWS8B0EGMoiWYGM+chhSDxdIB20acMvZUlFHz7S3wNrh8o0soPym9R0s//zLVsmhluyJijOzfHPBnrtd6fA== dependencies: - "@redwoodjs/eslint-plugin-redwood" "^0.28.0" + "@redwoodjs/eslint-plugin-redwood" "^0.28.2" "@typescript-eslint/eslint-plugin" "^4.0.1" "@typescript-eslint/parser" "^4.0.1" babel-eslint "^10.1.0" @@ -1963,25 +1963,25 @@ eslint-plugin-react-hooks "^4.1.0" prettier "^2.1.1" -"@redwoodjs/eslint-plugin-redwood@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-plugin-redwood/-/eslint-plugin-redwood-0.28.0.tgz#8d543f2aa28f160c3f6bae7c9c5dc2b6c6199535" - integrity sha512-GhFNRsHUl2qeA4o3jkbLnjmvNjcWp20I6PvWSBZj6ZZlLKn1iZqeBkJr9gMRkmBWHav3YX/xV7hq95FWa3bFhg== +"@redwoodjs/eslint-plugin-redwood@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-plugin-redwood/-/eslint-plugin-redwood-0.28.2.tgz#14d9edc141ccc4e3f3e24877766e9b7103a4622b" + integrity sha512-oJFdDAjUmvc1c4L4fBCtrfpFrAK7iNhZTD3H7iqBr5Cc1z08RbV6LnGHz4CetV4TwXHLWnRYX/a++incvNjxQw== -"@redwoodjs/forms@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/forms/-/forms-0.28.0.tgz#106d782a3c1a7d2925f72a72d9ef6db3e9e34600" - integrity sha512-1vKJuizOfuznErfIN7B5C4p5WR+9kduWs5bytkNAkjKko3/cDY5eB0+fi2ci9zZer5s86ZagS8sJWuBQWyeC2g== +"@redwoodjs/forms@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/forms/-/forms-0.28.2.tgz#febc056029ddc523a353ac3568231d5cf24db766" + integrity sha512-I+bNAMrqLdRBoIYuJAAF1mWpqV0bJbGuHMioiRxV/SQnSQCvdSemXNoIDueeDvURBpEjwCGb9Ov/dyS6HZT38A== dependencies: "@types/pascalcase" "^1.0.0" core-js "3.6.5" pascalcase "1.0.0" react-hook-form "^6.9.5" -"@redwoodjs/internal@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/internal/-/internal-0.28.0.tgz#70d42f5a4502e9026f51895f6a59c0f474024725" - integrity sha512-0VrS5VqGAmKlqEhX5iHKQAISEIltnq7rEls5WrVNXZ/9P6W5tbPFZqgNSp2gzw6FCH+LgVPy3r57knkGI6AyZg== +"@redwoodjs/internal@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/internal/-/internal-0.28.2.tgz#439eb96bcdd525d1f4724b6868b2f68427f1380b" + integrity sha512-gQOESZxAa9XApVFSs0fwSS1a+CdHy+4wgULHVg0qaa/Q314wG3phqoHwUWYg2+0rF+66ZxI4v8rg7WEe8SkrbQ== dependencies: "@babel/plugin-transform-typescript" "^7.11.6" deepmerge "^4.2.2" @@ -1990,37 +1990,37 @@ kill-port "^1.6.1" toml "^3.0.0" -"@redwoodjs/prerender@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/prerender/-/prerender-0.28.0.tgz#72bc9a709f42379e24bcd18765b3965a5674e36d" - integrity sha512-gGBV1w92rbVNf7GHIMHuWlTYYS3Q0wKLFP8xomazzlma5sXfwGnAMY8xRx9XdlzF6AL+jTKbrn4f9tx4EU4oAQ== +"@redwoodjs/prerender@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/prerender/-/prerender-0.28.2.tgz#489369f3cac85bf0956a41100edc8b8dfea2119e" + integrity sha512-W7b0ZtAL/a4rO9OMEh14F+EQa2iITpmcQMpksaPj6Rh3oeC5Xdy9VZ1qEbvEBRF1XMnNiwX0V2SaZgNcOvQbwQ== dependencies: "@babel/register" "^7.9.0" - "@redwoodjs/auth" "^0.28.0" - "@redwoodjs/internal" "^0.28.0" - "@redwoodjs/router" "^0.28.0" - "@redwoodjs/structure" "^0.28.0" - "@redwoodjs/web" "^0.28.0" + "@redwoodjs/auth" "^0.28.2" + "@redwoodjs/internal" "^0.28.2" + "@redwoodjs/router" "^0.28.2" + "@redwoodjs/structure" "^0.28.2" + "@redwoodjs/web" "^0.28.2" babel-plugin-ignore-html-and-css-imports "^0.1.0" node-fetch "^2.6.1" -"@redwoodjs/router@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/router/-/router-0.28.0.tgz#9437b01401a6755b6d94e85b0daa455c6ad88a49" - integrity sha512-fuO+BucZvo+bb1IHAK0ZsT7JAzojqP4pNPCNwS/55/oomKdPXDmk4tBHBzKID5RoGLAcio3OmZhE4p1UCNWKLQ== +"@redwoodjs/router@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/router/-/router-0.28.2.tgz#b4a65fb77312921d0c1153e009b0d531cf28e336" + integrity sha512-uahtinqcH0xW63NGylGW3NM41ZdRlhLjA6jumRIpqjd8bPlXYCoNlLfVCM4cvVn84V/t9FCdp/mvBXgMtHzn9Q== dependencies: "@reach/skip-nav" "^0.13.2" - "@redwoodjs/auth" "^0.28.0" + "@redwoodjs/auth" "^0.28.2" core-js "3.6.5" lodash.isequal "^4.5.0" -"@redwoodjs/structure@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/structure/-/structure-0.28.0.tgz#c93ccc7e8720b6d550cf63b0b1205d3545466590" - integrity sha512-OHAzP8TmI/ghlhwIoxmW32+Dd82NWBHnhI9HVrBI8BzkcL9fokwugHlQiPfesc31TA5M32rJglaVZbriRmMJlg== +"@redwoodjs/structure@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/structure/-/structure-0.28.2.tgz#b9d3a58304fa02d0009dc934a71c3ef74a1b2e3a" + integrity sha512-+E7r6VAbVOHoxLkYfmKSHpgI6bbUnN+0eGeX2RiuiyHO1RnADAFgZxEAVjEmaTuGAwEZacwqdZeIfnjSTPgpUg== dependencies: "@prisma/sdk" "2.19.0" - "@redwoodjs/internal" "^0.28.0" + "@redwoodjs/internal" "^0.28.2" "@types/line-column" "^1.0.0" camelcase "^6.0.0" deepmerge "^4.2.2" @@ -2041,26 +2041,26 @@ vscode-languageserver-types "3.15.1" yargs-parser "^18.1.3" -"@redwoodjs/testing@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/testing/-/testing-0.28.0.tgz#f963a7445d67ccbcdd9948bb5802b876678e6644" - integrity sha512-cc2WoK1Y3m3RG5Y7zNU4FcLoqOM/ZTJtYqo6TKT0qzp7jLtzK1zUZdSU4+opsf3+p/mZidrwFNQVXsrTlzqOEA== +"@redwoodjs/testing@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/testing/-/testing-0.28.2.tgz#decd0e4d825ccf1adc755554d7bf95c647d0a769" + integrity sha512-YRNleZQiV64OCFUHrm3tfRAAdU41x/1gfUqAkSQFPac/oSgUznsMNPbsuh/woSY0GXWAX8UOZPX0aW7yRDmYSg== dependencies: - "@redwoodjs/auth" "^0.28.0" - "@redwoodjs/internal" "^0.28.0" - "@redwoodjs/router" "^0.28.0" - "@redwoodjs/web" "^0.28.0" + "@redwoodjs/auth" "^0.28.2" + "@redwoodjs/internal" "^0.28.2" + "@redwoodjs/router" "^0.28.2" + "@redwoodjs/web" "^0.28.2" "@testing-library/react" "11.2.2" "@types/react" "17.0.3" msw "^0.21.2" -"@redwoodjs/web@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@redwoodjs/web/-/web-0.28.0.tgz#e67f46c64fd6676c7afb0ea34b0f08bdfb13324d" - integrity sha512-X8QEskhgOl2g+a2YgoNYS34AzdYfrgz53DYXmOW2GPttjc+ry44S7gyjnkR5X+asleeWJGeRPCe7lrJtOqdM+A== +"@redwoodjs/web@^0.28.2": + version "0.28.2" + resolved "https://registry.yarnpkg.com/@redwoodjs/web/-/web-0.28.2.tgz#7e5856a65631f0699d8f0047d59bd2df2a3b127e" + integrity sha512-iFc0iHN9We9PUK8/hBnxC0wahB+1OLan07g2MMPPUIaZdJqJjmR/w8lF0WRrtgP+PNdevOfHmobvEYx5bd9Uyg== dependencies: "@apollo/client" "^3.3.11" - "@redwoodjs/auth" "^0.28.0" + "@redwoodjs/auth" "^0.28.2" core-js "3.6.5" graphql "^15.3.0" proptypes "^1.1.0" @@ -3610,7 +3610,7 @@ apollo-server-caching@^0.5.3: dependencies: lru-cache "^6.0.0" -apollo-server-core@2.21.2, apollo-server-core@^2.18.2: +apollo-server-core@^2.18.2: version "2.21.2" resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.21.2.tgz#9f44bdcb4d5467a426f0fecd112afc95479d4b07" integrity sha512-jIXMVQPOUzIOl4El/mzSixxJ5IDrqSk3L9uJ1U+ncwiQj0IjtkkyDSuYngcgyEi+KfO2lAzxeOiAy9fIjjkC2A== diff --git a/yarn.lock b/yarn.lock index 8fbfcf4a9bf9..3dc659186ca2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -47,13 +47,6 @@ dependencies: apollo-env "^0.6.6" -"@apollographql/graphql-playground-html@1.6.26": - version "1.6.26" - resolved "https://registry.yarnpkg.com/@apollographql/graphql-playground-html/-/graphql-playground-html-1.6.26.tgz#2f7b610392e2a872722912fc342b43cf8d641cb3" - integrity sha512-XAwXOIab51QyhBxnxySdK3nuMEUohhDsHQ5Rbco/V1vjlP75zZ0ZLHD9dTpXTN8uxKxopb2lUvJTq+M4g2Q0HQ== - dependencies: - xss "^1.0.6" - "@apollographql/graphql-playground-html@1.6.27": version "1.6.27" resolved "https://registry.yarnpkg.com/@apollographql/graphql-playground-html/-/graphql-playground-html-1.6.27.tgz#bc9ab60e9445aa2a8813b4e94f152fa72b756335" @@ -1921,6 +1914,11 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@josephg/resolvable@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@josephg/resolvable/-/resolvable-1.0.0.tgz#cd75b09cfad18cd945de9221d403203aa07e3d0a" + integrity sha512-OfTtjoqB2doov5aTJxkyAMK8dXoo7CjCUQSYUEtiY34jbWduOGV7+168tmCT8COMsUEd5DMSFg/0iAOPCBTNAQ== + "@lerna/add@3.21.0": version "3.21.0" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.21.0.tgz#27007bde71cc7b0a2969ab3c2f0ae41578b4577b" @@ -4790,20 +4788,20 @@ anymatch@^3.0.3, anymatch@~3.1.1: normalize-path "^3.0.0" picomatch "^2.0.4" -apollo-cache-control@^0.11.6: - version "0.11.6" - resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.11.6.tgz#f7bdf924272af47ac474cf3f3f35cfc038cc9485" - integrity sha512-YZ+uuIG+fPy+mkpBS2qKF0v1qlzZ3PW6xZVaDukeK3ed3iAs4L/2YnkTqau3OmoF/VPzX2FmSkocX/OVd59YSw== +apollo-cache-control@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.12.0.tgz#45aea0a232d0704e33c2b1a3c428a5500b29818c" + integrity sha512-kClF5rfAm159Nboul1LxA+l58Tjz0M8L1GUknEMpZt0UHhILLAn3BfcG3ToX4TbNoR9M57kKMUcbPWLdy3Up7w== dependencies: apollo-server-env "^3.0.0" - apollo-server-plugin-base "^0.10.4" + apollo-server-plugin-base "^0.11.0" -apollo-datasource@^0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-0.7.3.tgz#c824eb1457bdee5a3173ced0e35e594547e687a0" - integrity sha512-PE0ucdZYjHjUyXrFWRwT02yLcx2DACsZ0jm1Mp/0m/I9nZu/fEkvJxfsryXB6JndpmQO77gQHixf/xGCN976kA== +apollo-datasource@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-0.8.0.tgz#8cf9103e83558bd30b3b522cb8ec80725c3160ce" + integrity sha512-gXgsGVLuejLc138z/2jUjPAzadDQxWbcLJyBgaQsg5BaXJNkv5uW/NjiSPk00cK51hyZrb0Xx8a+L+wPk2qIBA== dependencies: - apollo-server-caching "^0.5.3" + apollo-server-caching "^0.6.0" apollo-server-env "^3.0.0" apollo-env@^0.6.6: @@ -4841,35 +4839,36 @@ apollo-reporting-protobuf@^0.6.2: dependencies: "@apollo/protobufjs" "^1.0.3" -apollo-server-caching@^0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/apollo-server-caching/-/apollo-server-caching-0.5.3.tgz#cf42a77ad09a46290a246810075eaa029b5305e1" - integrity sha512-iMi3087iphDAI0U2iSBE9qtx9kQoMMEWr6w+LwXruBD95ek9DWyj7OeC2U/ngLjRsXM43DoBDXlu7R+uMjahrQ== +apollo-server-caching@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/apollo-server-caching/-/apollo-server-caching-0.6.0.tgz#3140a023ce0be8c43ba0b2f5be9cc5d15d1a32f6" + integrity sha512-SfjKaccrhRzUQ8TAke9FrYppp4pZV3Rp8KCs+4Ox3kGtbco68acRPJkiYYtSVc4idR8XNAUOOVfAEZVNHdZQKQ== dependencies: lru-cache "^6.0.0" -apollo-server-core@^2.18.2: - version "2.21.2" - resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.21.2.tgz#9f44bdcb4d5467a426f0fecd112afc95479d4b07" - integrity sha512-jIXMVQPOUzIOl4El/mzSixxJ5IDrqSk3L9uJ1U+ncwiQj0IjtkkyDSuYngcgyEi+KfO2lAzxeOiAy9fIjjkC2A== +apollo-server-core@^2.22.2: + version "2.22.2" + resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.22.2.tgz#daee67a17aa4f1bf0df3e448e237a37324906b5d" + integrity sha512-YPrhfN+I5vUerc4c0I6pd89fdqP5UNYCt/+MGv4bDA/a0kOCLvzylkQ3NlEepK1fewtqf4QO+S1LscC8vMmYdg== dependencies: "@apollographql/apollo-tools" "^0.4.3" "@apollographql/graphql-playground-html" "1.6.27" "@apollographql/graphql-upload-8-fork" "^8.1.3" + "@josephg/resolvable" "^1.0.0" "@types/ws" "^7.0.0" - apollo-cache-control "^0.11.6" - apollo-datasource "^0.7.3" + apollo-cache-control "^0.12.0" + apollo-datasource "^0.8.0" apollo-graphql "^0.6.0" apollo-reporting-protobuf "^0.6.2" - apollo-server-caching "^0.5.3" + apollo-server-caching "^0.6.0" apollo-server-env "^3.0.0" apollo-server-errors "^2.4.2" - apollo-server-plugin-base "^0.10.4" - apollo-server-types "^0.6.3" - apollo-tracing "^0.12.2" + apollo-server-plugin-base "^0.11.0" + apollo-server-types "^0.7.0" + apollo-tracing "^0.13.0" async-retry "^1.2.1" fast-json-stable-stringify "^2.0.0" - graphql-extensions "^0.12.8" + graphql-extensions "^0.13.0" graphql-tag "^2.11.0" graphql-tools "^4.0.8" loglevel "^1.6.7" @@ -4879,14 +4878,6 @@ apollo-server-core@^2.18.2: uuid "^8.0.0" ws "^6.0.0" -apollo-server-env@^2.4.5: - version "2.4.5" - resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-2.4.5.tgz#73730b4f0439094a2272a9d0caa4079d4b661d5f" - integrity sha512-nfNhmGPzbq3xCEWT8eRpoHXIPNcNy3QcEoBlzVMjeglrBGryLG2LXwBSPnVmTRRrzUYugX0ULBtgE3rBFNoUgA== - dependencies: - node-fetch "^2.1.2" - util.promisify "^1.0.0" - apollo-server-env@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-3.0.0.tgz#0157c51f52b63aee39af190760acf789ffc744d9" @@ -4900,41 +4891,41 @@ apollo-server-errors@^2.4.2: resolved "https://registry.yarnpkg.com/apollo-server-errors/-/apollo-server-errors-2.4.2.tgz#1128738a1d14da989f58420896d70524784eabe5" integrity sha512-FeGxW3Batn6sUtX3OVVUm7o56EgjxDlmgpTLNyWcLb0j6P8mw9oLNyAm3B+deHA4KNdNHO5BmHS2g1SJYjqPCQ== -apollo-server-lambda@2.18.2: - version "2.18.2" - resolved "https://registry.yarnpkg.com/apollo-server-lambda/-/apollo-server-lambda-2.18.2.tgz#3d89afd49ac617b44b141949d9acae6d77d671e6" - integrity sha512-w1PxAAyrNLXOTeKl+Kp4fp37CGuAwn/ubSsWv+dz9fLgs/AXnPhb9B9mWCwLW5LOBOTWH7zYDqtSNqs/J7+r1Q== +apollo-server-lambda@2.22.2: + version "2.22.2" + resolved "https://registry.yarnpkg.com/apollo-server-lambda/-/apollo-server-lambda-2.22.2.tgz#8beb0f2cfbb9048ae8dfa609afbfcb8fa42de622" + integrity sha512-QOVHg6u1+jqnY6c+fb4njUtfQEQr118guerDveZgG3vQP1t8/AtYDT33m03JhsKWRkzZjOgj5cs0RA1iSYw7cg== dependencies: - "@apollographql/graphql-playground-html" "1.6.26" + "@apollographql/graphql-playground-html" "1.6.27" "@types/aws-lambda" "^8.10.31" - apollo-server-core "^2.18.2" - apollo-server-env "^2.4.5" - apollo-server-types "^0.6.0" - graphql-tools "^4.0.0" + apollo-server-core "^2.22.2" + apollo-server-env "^3.0.0" + apollo-server-types "^0.7.0" + graphql-tools "^4.0.8" -apollo-server-plugin-base@^0.10.4: - version "0.10.4" - resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.10.4.tgz#fbf73f64f95537ca9f9639dd7c535eb5eeb95dcd" - integrity sha512-HRhbyHgHFTLP0ImubQObYhSgpmVH4Rk1BinnceZmwudIVLKrqayIVOELdyext/QnSmmzg5W7vF3NLGBcVGMqDg== +apollo-server-plugin-base@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.11.0.tgz#6ceeb4d5f643ed739fd00e8b26d9981186c200d0" + integrity sha512-Du68x0XCyQ6EWlgoL9Z+1s8fJfXgY131QbKP7ao617StQPzwB0aGCwxBDfcMt1A75VXf4TkvV1rdUH5YeJFlhQ== dependencies: - apollo-server-types "^0.6.3" + apollo-server-types "^0.7.0" -apollo-server-types@^0.6.0, apollo-server-types@^0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/apollo-server-types/-/apollo-server-types-0.6.3.tgz#f7aa25ff7157863264d01a77d7934aa6e13399e8" - integrity sha512-aVR7SlSGGY41E1f11YYz5bvwA89uGmkVUtzMiklDhZ7IgRJhysT5Dflt5IuwDxp+NdQkIhVCErUXakopocFLAg== +apollo-server-types@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/apollo-server-types/-/apollo-server-types-0.7.0.tgz#a9b62974ada5da5edb6157a41d8ddb993b57203a" + integrity sha512-pJ6ri2N4xJ+e2PUUPHeCNpMDzHUagJyn0DDZGQmXDz6aoMlSd4B2KUvK81hHyHkw3wHk9clgcpfM9hKqbfZweA== dependencies: apollo-reporting-protobuf "^0.6.2" - apollo-server-caching "^0.5.3" + apollo-server-caching "^0.6.0" apollo-server-env "^3.0.0" -apollo-tracing@^0.12.2: - version "0.12.2" - resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.12.2.tgz#a261c3970bb421b6dadf50cd85d75b2567a7e52c" - integrity sha512-SYN4o0C0wR1fyS3+P0FthyvsQVHFopdmN3IU64IaspR/RZScPxZ3Ae8uu++fTvkQflAkglnFM0aX6DkZERBp6w== +apollo-tracing@^0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.13.0.tgz#8621b1ae351f862bb48b6de7a85696288977d148" + integrity sha512-28z4T+XfLQ6t696usU0nTFDxVN8BfF3o74d2p/zsT4eu1OuoyoDOEmVJqdInmVRpyTJK0tDEOjkIuDJJHZftog== dependencies: apollo-server-env "^3.0.0" - apollo-server-plugin-base "^0.10.4" + apollo-server-plugin-base "^0.11.0" apollo-utilities@^1.0.1, apollo-utilities@^1.3.0: version "1.3.4" @@ -10138,14 +10129,14 @@ graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1. resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== -graphql-extensions@^0.12.8: - version "0.12.8" - resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.12.8.tgz#9cdc2c43d8fe5e0f6c3177a004ac011da2a8aa0f" - integrity sha512-xjsSaB6yKt9jarFNNdivl2VOx52WySYhxPgf8Y16g6GKZyAzBoIFiwyGw5PJDlOSUa6cpmzn6o7z8fVMbSAbkg== +graphql-extensions@^0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.13.0.tgz#34d7f9c1bf49d09c4f1fa8b5d33e6c961a1889fb" + integrity sha512-Bb7E97nvfX4gtrIdZ/i5YFlqOd6MGzrw8ED+t4wQVraYje6NQ+8P8MHMOV2WZLfbW8zsNTx8NdnnlbsdH5siag== dependencies: "@apollographql/apollo-tools" "^0.4.3" apollo-server-env "^3.0.0" - apollo-server-types "^0.6.3" + apollo-server-types "^0.7.0" graphql-scalars@1.9.0: version "1.9.0" @@ -10166,7 +10157,7 @@ graphql-tag@^2.12.0: dependencies: tslib "^1.14.1" -graphql-tools@^4.0.0, graphql-tools@^4.0.8: +graphql-tools@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-4.0.8.tgz#e7fb9f0d43408fb0878ba66b522ce871bafe9d30" integrity sha512-MW+ioleBrwhRjalKjYaLQbr+920pHBgy9vM/n47sswtns8+96sRn5M/G+J1eu7IMeKWiN/9p6tmwCHU7552VJg== @@ -19063,7 +19054,7 @@ xregexp@4.0.0: resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020" integrity sha512-PHyM+sQouu7xspQQwELlGwwd05mXUFqwFYfqPO0cC7x4fxyHnnuetmQr6CjJiafIDoH4MogHb9dOoJzR/Y4rFg== -xss@^1.0.6, xss@^1.0.8: +xss@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/xss/-/xss-1.0.8.tgz#32feb87feb74b3dcd3d404b7a68ababf10700535" integrity sha512-3MgPdaXV8rfQ/pNn16Eio6VXYPTkqwa0vc7GkiymmY/DqR1SE/7VPAAVZz1GJsJFrllMYO3RHfEaiUGjab6TNw== From b4a63efe7057fa182a2257f7dbbf67784658efb5 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Tue, 30 Mar 2021 16:19:07 +0100 Subject: [PATCH 09/25] Fix: named routes types (#2154) * Fix named routes typing | Now adds params to types * Add setup command for creating tsconfigs * Lint fix * PR Comments | Further Lint fixes --- .../src/commands/setup/tsconfig/tsconfig.js | 71 +++++++++++++++++++ packages/cli/src/lib/index.js | 37 ++++++++++ ...babel-plugin-redwood-routes-auto-loader.ts | 12 +++- .../template/web/tsconfig.json | 4 +- packages/router/src/index.ts | 15 ++++ packages/router/src/router.tsx | 14 +--- 6 files changed, 137 insertions(+), 16 deletions(-) create mode 100644 packages/cli/src/commands/setup/tsconfig/tsconfig.js diff --git a/packages/cli/src/commands/setup/tsconfig/tsconfig.js b/packages/cli/src/commands/setup/tsconfig/tsconfig.js new file mode 100644 index 000000000000..c6dd3c473b56 --- /dev/null +++ b/packages/cli/src/commands/setup/tsconfig/tsconfig.js @@ -0,0 +1,71 @@ +import path from 'path' + +import chalk from 'chalk' +import Listr from 'listr' + +import { + getInstalledRedwoodVersion, + getPaths, + saveRemoteFileToDisk, +} from 'src/lib' +import c from 'src/lib/colors' + +export const command = 'tsconfig' + +export const description = 'Setup tsconfig for web and api sides' + +export const builder = (yargs) => { + yargs.option('force', { + alias: 'f', + default: false, + description: 'Overwrite existing tsconfig.json files', + type: 'boolean', + }) +} + +export const handler = async ({ force }) => { + const CRWA_TEMPLATE_URL = `https://raw.githubusercontent.com/redwoodjs/redwood/v${getInstalledRedwoodVersion()}/packages/create-redwood-app/template` + + const tasks = new Listr([ + { + title: 'Creating tsconfig in web', + task: () => { + const webConfigPath = path.join(getPaths().web.base, 'tsconfig.json') + + const templateUrl = `${CRWA_TEMPLATE_URL}/web/tsconfig.json` + + return saveRemoteFileToDisk(templateUrl, webConfigPath, { + overwriteExisting: force, + }) + }, + }, + { + title: 'Creating tsconfig in api', + task: () => { + const webConfigPath = path.join(getPaths().api.base, 'tsconfig.json') + + const templateUrl = `${CRWA_TEMPLATE_URL}/api/tsconfig.json` + + return saveRemoteFileToDisk(templateUrl, webConfigPath, { + overwriteExisting: force, + }) + }, + }, + { + title: 'One more thing...', + task: (_ctx, task) => { + task.title = `One more thing...\n + ${c.green('Quick link to the docs on configuring TypeScript')} + ${chalk.hex('#e8e8e8')('https://redwoodjs.com/docs/typescript')} + ` + }, + }, + ]) + + try { + await tasks.run() + } catch (e) { + console.error(c.error(e.message)) + process.exit(e?.exitCode || 1) + } +} diff --git a/packages/cli/src/lib/index.js b/packages/cli/src/lib/index.js index ca52aef6a486..7670fd80ce2d 100644 --- a/packages/cli/src/lib/index.js +++ b/packages/cli/src/lib/index.js @@ -1,4 +1,5 @@ import fs from 'fs' +import https from 'https' import path from 'path' import * as babel from '@babel/core' @@ -226,6 +227,42 @@ export const writeFile = ( task.title = `Successfully wrote file \`./${path.relative(base, target)}\`` } +export const saveRemoteFileToDisk = ( + url, + localPath, + { overwriteExisting = false } = {} +) => { + if (!overwriteExisting && fs.existsSync(localPath)) { + throw new Error(`${localPath} already exists.`) + } + + const file = fs.createWriteStream(localPath) + const downloadPromise = new Promise((resolve, reject) => + https.get(url, (response) => { + if (response.statusCode === 200) { + response.pipe(file) + resolve() + } else { + reject( + new Error(`${url} responded with status code ${response.statusCode}`) + ) + } + }) + ) + + return downloadPromise +} + +export const getInstalledRedwoodVersion = () => { + try { + const packageJson = require('../../package.json') + return packageJson.version + } catch (e) { + console.error(c.error('Could not find installed redwood version')) + process.exit(1) + } +} + export const bytes = (contents) => Buffer.byteLength(contents, 'utf8') /** diff --git a/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts b/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts index c195b56e052f..933f48ce40b4 100644 --- a/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts +++ b/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts @@ -11,6 +11,9 @@ interface PluginOptions { useStaticImports?: boolean } +const RouteParameterTypeParser = + 'type ParseRouteParameters = Route extends `${string}/{${infer Param}:${string}}/${infer Rest}` ? { [Entry in Param | keyof ParseRouteParameters<`/${Rest}`>]: string } : Route extends `${string}/{${infer Param}:${string}}` ? { [Entry in Param]: string } : Route extends `${string}/{${infer Param}}` ? { [Entry in Param]: string } : Record' + export default function ( { types: t }: { types: typeof types }, { project, useStaticImports = false }: PluginOptions @@ -61,7 +64,10 @@ export default function ( const availableRoutes = project .getRouter() .routes.filter((r) => !r.isNotFound) - .map((r) => `${r.name}: () => "${r.path}"`) + .map( + (r) => + `${r.name}: (params?: ParseRouteParameters<"${r.path}">) => "${r.path}"` + ) const pageImports = pages.map( (page) => `import type ${page.const}Type from '${page.importPath}'` @@ -71,6 +77,10 @@ export default function ( ) const typeDefContent = ` + import '@redwoodjs/router' + + ${RouteParameterTypeParser} + declare module '@redwoodjs/router' { interface AvailableRoutes { ${availableRoutes.join('\n ')} diff --git a/packages/create-redwood-app/template/web/tsconfig.json b/packages/create-redwood-app/template/web/tsconfig.json index 2bdf5c4c3b5a..5dd2d6ff813c 100644 --- a/packages/create-redwood-app/template/web/tsconfig.json +++ b/packages/create-redwood-app/template/web/tsconfig.json @@ -14,5 +14,5 @@ "types": ["jest"], "jsx": "preserve", }, - "include": ["src", "../.redwood/globals"] -} \ No newline at end of file + "include": ["src", "../.redwood/**/*"] +} diff --git a/packages/router/src/index.ts b/packages/router/src/index.ts index 714e8ca45780..556674efd446 100644 --- a/packages/router/src/index.ts +++ b/packages/router/src/index.ts @@ -25,4 +25,19 @@ export { usePageLoadingContext } from './page-loader' export { default as RouteAnnouncement } from './route-announcement' export * from './route-announcement' +/** + * A more specific interface will be generated by + * babel-plugin-redwood-routes-auto-loader when a redwood project is built + * + * @example + * interface AvailableRoutes { + * home: (params?: ParseRouteParameters<"/">) => "/" + * post: (params?: ParseRouteParameters<"/posts/{id:Int}">) => "/posts/{id:Int}" + * } + */ +// Keep this in index.ts so it can be extended with declaration merging +export interface AvailableRoutes { + [key: string]: (args?: Record) => string +} + export { SkipNavLink, SkipNavContent } from '@reach/skip-nav' diff --git a/packages/router/src/router.tsx b/packages/router/src/router.tsx index 7b288442fb86..c5ca3290a3b6 100644 --- a/packages/router/src/router.tsx +++ b/packages/router/src/router.tsx @@ -21,19 +21,7 @@ import { import { SplashPage } from './splash-page' import { flattenAll, isReactElement } from './util' -/** - * A more specific interface will be generated by - * babel-plugin-redwood-routes-auto-loader when a redwood project is built - * - * @example - * interface AvailableRoutes { - * home: () => "/" - * test: () => "/test" - * } - */ -interface AvailableRoutes { - [key: string]: (args?: Record) => string -} +import type { AvailableRoutes } from './index' // namedRoutes is populated at run-time by iterating over the `` // components, and appending them to this object. From bcf0ebb64e01c5f62983c7fa82b696ed3df95d34 Mon Sep 17 00:00:00 2001 From: Curtis Reimer <51102303+cjreimer@users.noreply.github.com> Date: Tue, 30 Mar 2021 14:12:14 -0500 Subject: [PATCH 10/25] Adding Transform Capability to SelectField (#2138) * Added transformValue capability to SelectField * Added transformValue capability to SelectField * fixed lint error Co-authored-by: Tobbe Lundberg --- packages/forms/src/__tests__/form.test.tsx | 38 +++++++++++++++++++--- packages/forms/src/index.tsx | 15 +++++++-- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/packages/forms/src/__tests__/form.test.tsx b/packages/forms/src/__tests__/form.test.tsx index e7b51c3d32ca..73ae0cd68d05 100644 --- a/packages/forms/src/__tests__/form.test.tsx +++ b/packages/forms/src/__tests__/form.test.tsx @@ -19,6 +19,7 @@ import { TextAreaField, DatetimeLocalField, DateField, + SelectField, Submit, } from '../index' @@ -50,6 +51,17 @@ describe('Form', () => { defaultValue="2021-04-16T12:34" /> + + + + + + + + + + + Save ) @@ -116,7 +128,7 @@ describe('Form', () => { await waitFor(() => expect(mockFn).toHaveBeenCalledTimes(1)) }) - it('coerces user-supplied values', async () => { + it('renders and coerces user-supplied values', async () => { const mockFn = jest.fn() render() @@ -124,6 +136,12 @@ describe('Form', () => { userEvent.type(screen.getByDisplayValue('text'), 'text') userEvent.type(screen.getByDisplayValue('42'), '24') userEvent.type(screen.getByDisplayValue('3.14'), '1592') + fireEvent.change(screen.getByTestId('select1'), { + target: { value: 'Option 2' }, + }) + fireEvent.change(screen.getByTestId('select2'), { + target: { value: 3 }, + }) fireEvent.click(screen.getByText('Save')) await waitFor(() => expect(mockFn).toHaveBeenCalledTimes(1)) @@ -132,6 +150,8 @@ describe('Form', () => { text: 'texttext', number: 4224, // i.e. NOT "4224" floatText: 3.141592, + select1: 'Option 2', + select2: 3, checkbox: true, json: { key_one: 'value1', @@ -170,15 +190,25 @@ describe('Form', () => { it('lets users pass custom coercion functions', async () => { const mockFn = jest.fn() - const coercionFunction = (value) => parseInt(value.replace('_', ''), 10) + const coercionFunctionNumber = (value) => + parseInt(value.replace('_', ''), 10) + const coercionFunctionText = (value) => value.replace('_', '-') render(
+ + + + Save ) @@ -187,7 +217,7 @@ describe('Form', () => { await waitFor(() => expect(mockFn).toHaveBeenCalledTimes(1)) expect(mockFn).toBeCalledWith( - { tf: 123456 }, + { tf: 123456, select: 'Option-2' }, expect.anything() // event that triggered the onSubmit call ) }) diff --git a/packages/forms/src/index.tsx b/packages/forms/src/index.tsx index acc923c9021e..5de34a7b0c91 100644 --- a/packages/forms/src/index.tsx +++ b/packages/forms/src/index.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, forwardRef } from 'react' +import React, { useContext, forwardRef } from 'react' import pascalcase from 'pascalcase' import { @@ -82,7 +82,7 @@ const inputTagProps = ( const contextError = fieldErrorsContext[props.name] // eslint-disable-next-line react-hooks/rules-of-hooks - useEffect(() => { + React.useEffect(() => { if (contextError) { setError(props.name, { type: 'server', message: contextError }) } @@ -233,7 +233,7 @@ const TextAreaField = forwardRef< const { register } = useFormContext() const { setCoercion } = useCoercion() - useEffect(() => { + React.useEffect(() => { if (process.env.NODE_ENV !== 'production' && props.dataType !== undefined) { console.warn( 'Using the "dataType" prop on form input fields is deprecated. Use "transformValue" instead.' @@ -271,6 +271,15 @@ const SelectField = forwardRef< ValidatableFieldProps & React.SelectHTMLAttributes >((props, ref) => { const { register } = useFormContext() + const { setCoercion } = useCoercion() + + React.useEffect(() => { + setCoercion({ + name: props.name, + transformValue: props.transformValue, + }) + }, [setCoercion, props.name, props.transformValue]) + const tagProps = inputTagProps(props) return ( From e1d9cde29f568122e9427cd552561ebc1cb9ff75 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Tue, 30 Mar 2021 22:53:04 +0100 Subject: [PATCH 11/25] Fix github version tag for canary builds (#2156) Co-authored-by: David Price --- packages/cli/src/commands/setup/tsconfig/tsconfig.js | 7 ++++++- packages/cli/src/lib/index.js | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/setup/tsconfig/tsconfig.js b/packages/cli/src/commands/setup/tsconfig/tsconfig.js index c6dd3c473b56..86f92bf30c3f 100644 --- a/packages/cli/src/commands/setup/tsconfig/tsconfig.js +++ b/packages/cli/src/commands/setup/tsconfig/tsconfig.js @@ -24,7 +24,12 @@ export const builder = (yargs) => { } export const handler = async ({ force }) => { - const CRWA_TEMPLATE_URL = `https://raw.githubusercontent.com/redwoodjs/redwood/v${getInstalledRedwoodVersion()}/packages/create-redwood-app/template` + const installedRwVersion = getInstalledRedwoodVersion() + const GITHUB_VERSION_TAG = installedRwVersion.match('canary') + ? 'main' + : `v${installedRwVersion}` + + const CRWA_TEMPLATE_URL = `https://raw.githubusercontent.com/redwoodjs/redwood/${GITHUB_VERSION_TAG}/packages/create-redwood-app/template` const tasks = new Listr([ { diff --git a/packages/cli/src/lib/index.js b/packages/cli/src/lib/index.js index 7670fd80ce2d..52670427fa7c 100644 --- a/packages/cli/src/lib/index.js +++ b/packages/cli/src/lib/index.js @@ -236,11 +236,10 @@ export const saveRemoteFileToDisk = ( throw new Error(`${localPath} already exists.`) } - const file = fs.createWriteStream(localPath) const downloadPromise = new Promise((resolve, reject) => https.get(url, (response) => { if (response.statusCode === 200) { - response.pipe(file) + response.pipe(fs.createWriteStream(localPath)) resolve() } else { reject( From c0939df72b46b358afa9a8b0c52d2383e124376d Mon Sep 17 00:00:00 2001 From: David Price Date: Tue, 30 Mar 2021 18:45:34 -0700 Subject: [PATCH 12/25] v0.28.3 (#2158) * Install @redwoodjs/api-server as a dependency and add lockfile. (#2129) * Include api-server as a dependecy. * Pin apollo-server-core. * v0.28.1 * useParams should always be populated. (#2142) * Add failing test case for empty params. * Add some clarifications for failing test. * Set params before loading a new route. * Update packages/router/src/__tests__/router.test.tsx Co-authored-by: Tobbe Lundberg * Add params test case for Set. * Make tests start on initial location, instead of "/". * Fix engrish. * No longer set params in pageLoader. * Add top-level routes structure. * Calculate params on location, and router-state changes. * Fix type errors. * Revert this change. * Take search params into account. * Update packages/router/src/router-context.tsx Co-authored-by: Tobbe Lundberg * Remove ts-ignore-error. Co-authored-by: Tobbe Lundberg * Router: Populate `routes` for tests (#2133) Fixes #2131 * v0.28.2 * Make understand authentication. (#2147) * Add test for Set and authentication. * Make set understand auth. * Fix race condition in useParams. * Recalculate param on location change (#2152) * update params contexts directly in the context provider * update variable names * simplify imports * Update packages/router/src/__tests__/router.test.tsx Remove only, so we can test these against all tests. * Update packages/router/src/params.tsx Co-authored-by: Tobbe Lundberg * Update packages/router/src/params.tsx Co-authored-by: Tobbe Lundberg * Remove unused params context. * Name param variables properly. * Fix comment now that we've fixed test. * Remove this unused import. * Keep params order the same as before. Co-authored-by: Peter Pistorius Co-authored-by: Tobbe Lundberg * upgrade apollo-server-lambda; remove resolution (#2153) Co-authored-by: Peter Pistorius * Fix: named routes types (#2154) * Fix named routes typing | Now adds params to types * Add setup command for creating tsconfigs * Lint fix * PR Comments | Further Lint fixes * Fix github version tag for canary builds (#2156) Co-authored-by: David Price * v0.28.3 * update template/yarn.lock v0.28.3 Co-authored-by: Peter Pistorius Co-authored-by: Tobbe Lundberg Co-authored-by: Kris Coulson Co-authored-by: Daniel Choudhury --- lerna.json | 2 +- packages/api-server/package.json | 2 +- packages/api/package.json | 8 +- packages/auth/package.json | 2 +- packages/cli/package.json | 8 +- packages/core/package.json | 12 +- packages/create-redwood-app/package.json | 4 +- .../template/api/package.json | 4 +- .../create-redwood-app/template/package.json | 2 +- .../template/web/package.json | 6 +- .../create-redwood-app/template/yarn.lock | 301 +++++++++--------- packages/dev-server/package.json | 4 +- packages/eslint-config/package.json | 4 +- packages/eslint-plugin-redwood/package.json | 2 +- packages/forms/package.json | 2 +- packages/internal/package.json | 2 +- packages/prerender/package.json | 12 +- packages/router/package.json | 4 +- packages/structure/package.json | 4 +- packages/testing/package.json | 10 +- packages/web/package.json | 4 +- 21 files changed, 195 insertions(+), 204 deletions(-) diff --git a/lerna.json b/lerna.json index 4a14f635649d..b203bfd9d13f 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.28.2", + "version": "0.28.3", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/packages/api-server/package.json b/packages/api-server/package.json index 6bf7d92cad30..e357f6135b14 100644 --- a/packages/api-server/package.json +++ b/packages/api-server/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/api-server", "description": "Redwood's HTTP server for Serverless Functions", - "version": "0.28.2", + "version": "0.28.3", "bin": { "api-server": "./dist/index.js", "rw-api-server": "./dist/index.js", diff --git a/packages/api/package.json b/packages/api/package.json index 158a6f0ee24d..9858d8c25e77 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/api", - "version": "0.28.2", + "version": "0.28.3", "files": [ "dist", "logger" @@ -11,7 +11,7 @@ "dependencies": { "@graphql-tools/merge": "6.2.10", "@prisma/client": "2.19.0", - "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/internal": "^0.28.3", "@types/pino": "^6.3.6", "apollo-server-lambda": "2.22.2", "core-js": "3.6.5", @@ -25,8 +25,8 @@ "pino-pretty": "^4.7.0" }, "devDependencies": { - "@redwoodjs/auth": "^0.28.2", - "@redwoodjs/dev-server": "^0.28.2", + "@redwoodjs/auth": "^0.28.3", + "@redwoodjs/dev-server": "^0.28.3", "@types/jsonwebtoken": "^8.3.9", "@types/lodash.merge": "^4.6.6", "@types/lodash.omitby": "^4.6.6", diff --git a/packages/auth/package.json b/packages/auth/package.json index 5670903365c3..1ec298cc96fe 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/auth", - "version": "0.28.2", + "version": "0.28.3", "files": [ "dist" ], diff --git a/packages/cli/package.json b/packages/cli/package.json index a37794468c05..87ccbfb3e7c6 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/cli", "description": "The Redwood Command Line", - "version": "0.28.2", + "version": "0.28.3", "license": "MIT", "bin": { "redwood": "./dist/index.js", @@ -14,9 +14,9 @@ ], "dependencies": { "@prisma/sdk": "2.19.0", - "@redwoodjs/internal": "^0.28.2", - "@redwoodjs/prerender": "^0.28.2", - "@redwoodjs/structure": "^0.28.2", + "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/prerender": "^0.28.3", + "@redwoodjs/structure": "^0.28.3", "boxen": "^4.2.0", "camelcase": "^6.0.0", "chalk": "^4.1.0", diff --git a/packages/core/package.json b/packages/core/package.json index bdcd5ccbadb6..a6171e4f5c5a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/core", - "version": "0.28.2", + "version": "0.28.3", "license": "MIT", "files": [ "config", @@ -23,11 +23,11 @@ "@babel/preset-typescript": "^7.10.4", "@babel/runtime-corejs3": "^7.11.2", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", - "@redwoodjs/cli": "^0.28.2", - "@redwoodjs/dev-server": "^0.28.2", - "@redwoodjs/eslint-config": "^0.28.2", - "@redwoodjs/internal": "^0.28.2", - "@redwoodjs/testing": "^0.28.2", + "@redwoodjs/cli": "^0.28.3", + "@redwoodjs/dev-server": "^0.28.3", + "@redwoodjs/eslint-config": "^0.28.3", + "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/testing": "^0.28.3", "@storybook/addon-a11y": "^6.1.19", "@storybook/react": "^6.1.21", "@testing-library/jest-dom": "5.11.6", diff --git a/packages/create-redwood-app/package.json b/packages/create-redwood-app/package.json index 49e836cb709a..6434880862d4 100644 --- a/packages/create-redwood-app/package.json +++ b/packages/create-redwood-app/package.json @@ -1,6 +1,6 @@ { "name": "create-redwood-app", - "version": "0.28.2", + "version": "0.28.3", "license": "MIT", "bin": "./dist/create-redwood-app.js", "files": [ @@ -9,7 +9,7 @@ ], "dependencies": { "@babel/runtime-corejs3": "^7.9.2", - "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/internal": "^0.28.3", "axios": "^0.20.0", "chalk": "^4.1.0", "check-node-version": "^4.0.2", diff --git a/packages/create-redwood-app/template/api/package.json b/packages/create-redwood-app/template/api/package.json index 9028f67dde9c..8fba5c402b69 100644 --- a/packages/create-redwood-app/template/api/package.json +++ b/packages/create-redwood-app/template/api/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "dependencies": { - "@redwoodjs/api": "^0.28.2", - "@redwoodjs/api-server": "^0.28.2" + "@redwoodjs/api": "^0.28.3", + "@redwoodjs/api-server": "^0.28.3" } } \ No newline at end of file diff --git a/packages/create-redwood-app/template/package.json b/packages/create-redwood-app/template/package.json index d618d142ba50..3e358830b65e 100644 --- a/packages/create-redwood-app/template/package.json +++ b/packages/create-redwood-app/template/package.json @@ -8,7 +8,7 @@ ] }, "devDependencies": { - "@redwoodjs/core": "^0.28.2" + "@redwoodjs/core": "^0.28.3" }, "eslintConfig": { "extends": "@redwoodjs/eslint-config", diff --git a/packages/create-redwood-app/template/web/package.json b/packages/create-redwood-app/template/web/package.json index 1f758299a3ce..1e645032a2ca 100644 --- a/packages/create-redwood-app/template/web/package.json +++ b/packages/create-redwood-app/template/web/package.json @@ -13,9 +13,9 @@ ] }, "dependencies": { - "@redwoodjs/forms": "^0.28.2", - "@redwoodjs/router": "^0.28.2", - "@redwoodjs/web": "^0.28.2", + "@redwoodjs/forms": "^0.28.3", + "@redwoodjs/router": "^0.28.3", + "@redwoodjs/web": "^0.28.3", "prop-types": "^15.7.2", "react": "^17.0.1", "react-dom": "^17.0.1" diff --git a/packages/create-redwood-app/template/yarn.lock b/packages/create-redwood-app/template/yarn.lock index b7c1b0f43184..1eb7f3041419 100644 --- a/packages/create-redwood-app/template/yarn.lock +++ b/packages/create-redwood-app/template/yarn.lock @@ -47,13 +47,6 @@ dependencies: apollo-env "^0.6.6" -"@apollographql/graphql-playground-html@1.6.26": - version "1.6.26" - resolved "https://registry.yarnpkg.com/@apollographql/graphql-playground-html/-/graphql-playground-html-1.6.26.tgz#2f7b610392e2a872722912fc342b43cf8d641cb3" - integrity sha512-XAwXOIab51QyhBxnxySdK3nuMEUohhDsHQ5Rbco/V1vjlP75zZ0ZLHD9dTpXTN8uxKxopb2lUvJTq+M4g2Q0HQ== - dependencies: - xss "^1.0.6" - "@apollographql/graphql-playground-html@1.6.27": version "1.6.27" resolved "https://registry.yarnpkg.com/@apollographql/graphql-playground-html/-/graphql-playground-html-1.6.27.tgz#bc9ab60e9445aa2a8813b4e94f152fa72b756335" @@ -1497,6 +1490,11 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@josephg/resolvable@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@josephg/resolvable/-/resolvable-1.0.0.tgz#cd75b09cfad18cd945de9221d403203aa07e3d0a" + integrity sha512-OfTtjoqB2doov5aTJxkyAMK8dXoo7CjCUQSYUEtiY34jbWduOGV7+168tmCT8COMsUEd5DMSFg/0iAOPCBTNAQ== + "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" @@ -1782,10 +1780,10 @@ tslib "^2.1.0" warning "^4.0.3" -"@redwoodjs/api-server@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/api-server/-/api-server-0.28.2.tgz#5c66b5fec74f2c17d086019b31ff9181f1cc8dc3" - integrity sha512-h3fD8xrZ55aGBc5YXfz92+wdL5iH42uAqE+dm5abdQRAyaiIIwSXoUtdezk5h6F66zj9lV2aQniAIffqUjZ0Lw== +"@redwoodjs/api-server@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/api-server/-/api-server-0.28.3.tgz#893988d0e18bbea6a5610c37d5c79cfa003c43c1" + integrity sha512-t9u5XqoM7r7BRVI7xTOn+TdQTY4fAGeu9wN/0zVqMbuYUiycz5z8GBk1zZD7/j1WjvzIH/XcWFMx/m2eQWz1pQ== dependencies: body-parser "^1.19.0" chokidar "3.5.1" @@ -1799,16 +1797,16 @@ youch "^2.1.1" youch-terminal "^1.0.1" -"@redwoodjs/api@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/api/-/api-0.28.2.tgz#2e08e770927a1b68138c9916fa7d26172705c277" - integrity sha512-+i0Y75D/akB5hekDPIVWKoFw4nDyY35xSksqWy5Ev/neteIheLxo5TBa+fZYKVokoCu1pUCbfA2iBQgZNPqxwg== +"@redwoodjs/api@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/api/-/api-0.28.3.tgz#0c9e3d8d970ecdebaa4860f29ac4a256d9aa00db" + integrity sha512-czNfX68T6++DNdO1ISV+dRPX7KGI2CuN4zpEZGDI4ug3IDzwt9kw5pcvp201l4lMhS/IINlYIAaqXyyB3Iywlw== dependencies: "@graphql-tools/merge" "6.2.10" "@prisma/client" "2.19.0" - "@redwoodjs/internal" "^0.28.2" + "@redwoodjs/internal" "^0.28.3" "@types/pino" "^6.3.6" - apollo-server-lambda "2.18.2" + apollo-server-lambda "2.22.2" core-js "3.6.5" graphql "15.5.0" graphql-scalars "1.9.0" @@ -1819,20 +1817,20 @@ pino "^6.11.1" pino-pretty "^4.7.0" -"@redwoodjs/auth@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/auth/-/auth-0.28.2.tgz#8a90767cc261cc511e235060b7bc673a24da5cb4" - integrity sha512-AqKtEG5BdIyK8XyxgetpIasTMwRQHCOt5Cjf5sYyj0sk2csTT/jbSORTGEXwuZBef6WnWJiTgS8U1UnQhdD6hQ== +"@redwoodjs/auth@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/auth/-/auth-0.28.3.tgz#e23477061f8689841d856df96f76a4fc82adf2dc" + integrity sha512-PYWwQE+4kCp7NOnr26bs8bMU2A8DDLuntm7mRv45naefsK4nBsTxzfdHbOZ20OnosQEj5IT/5syiowWN1NKMXw== -"@redwoodjs/cli@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/cli/-/cli-0.28.2.tgz#2777e74fe00177c601568abd1dad46882ad373b7" - integrity sha512-E9nfdYuL2QzGkWuoymHCLI8G248BluiZEVi/+t0owQ7jvT0Y8CiJTU7jcSg5OG1JWsQacZLFsN+GLSt1uLRR0Q== +"@redwoodjs/cli@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/cli/-/cli-0.28.3.tgz#a9a9c975ee2a9119acc3ffdbd25d7611ccc761ad" + integrity sha512-rEqZYhS0n6nNpxBtX0Kbq7frigqMI3rjc5kkVdPSu5i8bcIWxGcSj7eImoj8106z12wr5mw4mopNO7NvLba6EQ== dependencies: "@prisma/sdk" "2.19.0" - "@redwoodjs/internal" "^0.28.2" - "@redwoodjs/prerender" "^0.28.2" - "@redwoodjs/structure" "^0.28.2" + "@redwoodjs/internal" "^0.28.3" + "@redwoodjs/prerender" "^0.28.3" + "@redwoodjs/structure" "^0.28.3" boxen "^4.2.0" camelcase "^6.0.0" chalk "^4.1.0" @@ -1857,10 +1855,10 @@ terminal-link "^2.1.1" yargs "^16.0.3" -"@redwoodjs/core@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/core/-/core-0.28.2.tgz#951952908b53865eaa0f753ddd3a7044fead38f7" - integrity sha512-Y6PpjZPkDhwO3YwfjuziXG44ZAyjTfPLlhGV8yRLqhHcbzFPt337lVNLLgWotjJp3jf9lN4N0dikbx/9qTPNfg== +"@redwoodjs/core@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/core/-/core-0.28.3.tgz#61cc00d176d33d68249ba4ed1f5fc3510cd13fca" + integrity sha512-nSsMubOEv++sFsOEkXWAK9EpCXzQsBX0aenR8Xk6aRmn+1CEUCPxaR4jkjqk9nL7qBfqM2iswcCzdaEaY3NW5A== dependencies: "@babel/cli" "^7.11.6" "@babel/core" "^7.11.6" @@ -1872,11 +1870,11 @@ "@babel/preset-typescript" "^7.10.4" "@babel/runtime-corejs3" "^7.11.2" "@pmmmwh/react-refresh-webpack-plugin" "^0.4.3" - "@redwoodjs/cli" "^0.28.2" - "@redwoodjs/dev-server" "^0.28.2" - "@redwoodjs/eslint-config" "^0.28.2" - "@redwoodjs/internal" "^0.28.2" - "@redwoodjs/testing" "^0.28.2" + "@redwoodjs/cli" "^0.28.3" + "@redwoodjs/dev-server" "^0.28.3" + "@redwoodjs/eslint-config" "^0.28.3" + "@redwoodjs/internal" "^0.28.3" + "@redwoodjs/testing" "^0.28.3" "@storybook/addon-a11y" "^6.1.19" "@storybook/react" "^6.1.21" "@testing-library/jest-dom" "5.11.6" @@ -1925,13 +1923,13 @@ webpack-retry-chunk-load-plugin "^1.4.0" whatwg-fetch "^3.5.0" -"@redwoodjs/dev-server@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/dev-server/-/dev-server-0.28.2.tgz#c3480684e6fe3e866c2dc3617b539f65fc26f794" - integrity sha512-sMb3LTA4bvDBcIsl1kNRJJaH4wcngg46TQFAHVfa5xT3HOzPQoCXR0dstaG++Imf3frQiOH1U95azIE6JQXyzw== +"@redwoodjs/dev-server@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/dev-server/-/dev-server-0.28.3.tgz#f7fcf781aed13be3812827c5f61e53a045207695" + integrity sha512-cp2I4t+hLABanirVtW4nxjvWMzk/AUBM5Pq4H+XIN+yIwuCUB7MnQLWnNZK0DRZwk10Xz4gkVfR8YJV7XShJaQ== dependencies: "@babel/register" "^7.9.0" - "@redwoodjs/internal" "^0.28.2" + "@redwoodjs/internal" "^0.28.3" body-parser "^1.19.0" chokidar "^3.4.3" express "^4.17.1" @@ -1942,12 +1940,12 @@ youch "^2.1.1" youch-terminal "^1.0.1" -"@redwoodjs/eslint-config@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-config/-/eslint-config-0.28.2.tgz#7a718a1a70fd7fe73cf9d6ab7bcb47ccd10be5e1" - integrity sha512-4NbKWS8B0EGMoiWYGM+chhSDxdIB20acMvZUlFHz7S3wNrh8o0soPym9R0s//zLVsmhluyJijOzfHPBnrtd6fA== +"@redwoodjs/eslint-config@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-config/-/eslint-config-0.28.3.tgz#76a663288d92dda56aedbc2847b24a3d35433410" + integrity sha512-neuFMY9vlVxPUWHZxbp0bBrgh5uYbFSAUXHCrJ3xdoA6rcuk0Vn3s2on8o4Lp9fJRZhP8uwj4xf8Wp3rNnLu6w== dependencies: - "@redwoodjs/eslint-plugin-redwood" "^0.28.2" + "@redwoodjs/eslint-plugin-redwood" "^0.28.3" "@typescript-eslint/eslint-plugin" "^4.0.1" "@typescript-eslint/parser" "^4.0.1" babel-eslint "^10.1.0" @@ -1963,25 +1961,25 @@ eslint-plugin-react-hooks "^4.1.0" prettier "^2.1.1" -"@redwoodjs/eslint-plugin-redwood@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-plugin-redwood/-/eslint-plugin-redwood-0.28.2.tgz#14d9edc141ccc4e3f3e24877766e9b7103a4622b" - integrity sha512-oJFdDAjUmvc1c4L4fBCtrfpFrAK7iNhZTD3H7iqBr5Cc1z08RbV6LnGHz4CetV4TwXHLWnRYX/a++incvNjxQw== +"@redwoodjs/eslint-plugin-redwood@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-plugin-redwood/-/eslint-plugin-redwood-0.28.3.tgz#5bf62c7b5c1d1d6b47f8f3a70d70dad2870f49f2" + integrity sha512-yORDCZ8qz5i0LpiRdUtmZ0JrqWYmdz3igEg0YnVIn3fgnQZgm6idilJqfPVB1TyJZ9FTwDzcGOMqWyfyfhtXEQ== -"@redwoodjs/forms@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/forms/-/forms-0.28.2.tgz#febc056029ddc523a353ac3568231d5cf24db766" - integrity sha512-I+bNAMrqLdRBoIYuJAAF1mWpqV0bJbGuHMioiRxV/SQnSQCvdSemXNoIDueeDvURBpEjwCGb9Ov/dyS6HZT38A== +"@redwoodjs/forms@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/forms/-/forms-0.28.3.tgz#356ba7aa661d2101c14ea8897a07e96dc052b0f2" + integrity sha512-FxJEI8CAArcUK531FPqFEFPH3BvI+mLLKjU6jJTlg4w8c2IimSpptO3BQL4FginaWEXJy/c7OW/NAURoTZBjIg== dependencies: "@types/pascalcase" "^1.0.0" core-js "3.6.5" pascalcase "1.0.0" react-hook-form "^6.9.5" -"@redwoodjs/internal@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/internal/-/internal-0.28.2.tgz#439eb96bcdd525d1f4724b6868b2f68427f1380b" - integrity sha512-gQOESZxAa9XApVFSs0fwSS1a+CdHy+4wgULHVg0qaa/Q314wG3phqoHwUWYg2+0rF+66ZxI4v8rg7WEe8SkrbQ== +"@redwoodjs/internal@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/internal/-/internal-0.28.3.tgz#a08887663ddfb588f6b89a98af9df907c8ab8b8f" + integrity sha512-M57+uSQZoOAZDunUFYxXX11jXh3F9v7UCZ2SZjDUkrG9hZBnPOHLQqzKcZTSvjTA3edKlgc8CmuqryhKLUQWFg== dependencies: "@babel/plugin-transform-typescript" "^7.11.6" deepmerge "^4.2.2" @@ -1990,37 +1988,37 @@ kill-port "^1.6.1" toml "^3.0.0" -"@redwoodjs/prerender@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/prerender/-/prerender-0.28.2.tgz#489369f3cac85bf0956a41100edc8b8dfea2119e" - integrity sha512-W7b0ZtAL/a4rO9OMEh14F+EQa2iITpmcQMpksaPj6Rh3oeC5Xdy9VZ1qEbvEBRF1XMnNiwX0V2SaZgNcOvQbwQ== +"@redwoodjs/prerender@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/prerender/-/prerender-0.28.3.tgz#0f3af9917575a18388a47c620c086a94f6a39490" + integrity sha512-QTZ7GzO6yXeQ3TavPpZbobghXPJPVxPSG5c6lpLzj5y4qXTF+xeNkRaijOc+5GMztk3cYcidG+usj9xHtzJ5Fg== dependencies: "@babel/register" "^7.9.0" - "@redwoodjs/auth" "^0.28.2" - "@redwoodjs/internal" "^0.28.2" - "@redwoodjs/router" "^0.28.2" - "@redwoodjs/structure" "^0.28.2" - "@redwoodjs/web" "^0.28.2" + "@redwoodjs/auth" "^0.28.3" + "@redwoodjs/internal" "^0.28.3" + "@redwoodjs/router" "^0.28.3" + "@redwoodjs/structure" "^0.28.3" + "@redwoodjs/web" "^0.28.3" babel-plugin-ignore-html-and-css-imports "^0.1.0" node-fetch "^2.6.1" -"@redwoodjs/router@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/router/-/router-0.28.2.tgz#b4a65fb77312921d0c1153e009b0d531cf28e336" - integrity sha512-uahtinqcH0xW63NGylGW3NM41ZdRlhLjA6jumRIpqjd8bPlXYCoNlLfVCM4cvVn84V/t9FCdp/mvBXgMtHzn9Q== +"@redwoodjs/router@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/router/-/router-0.28.3.tgz#e2b1856995ce3886d5a4bfba5e17922c8cbdd93c" + integrity sha512-Kss7mDYSrayMqIETGevOKYW1p7tdKgYJpAR1W6cJfgTWqVBv+WMqPVCbSD88VmkFQDc8SLVUUolNEPZGqGpV4Q== dependencies: "@reach/skip-nav" "^0.13.2" - "@redwoodjs/auth" "^0.28.2" + "@redwoodjs/auth" "^0.28.3" core-js "3.6.5" lodash.isequal "^4.5.0" -"@redwoodjs/structure@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/structure/-/structure-0.28.2.tgz#b9d3a58304fa02d0009dc934a71c3ef74a1b2e3a" - integrity sha512-+E7r6VAbVOHoxLkYfmKSHpgI6bbUnN+0eGeX2RiuiyHO1RnADAFgZxEAVjEmaTuGAwEZacwqdZeIfnjSTPgpUg== +"@redwoodjs/structure@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/structure/-/structure-0.28.3.tgz#c7651ee1055940cbedeec2f051344cc6a3a83e6a" + integrity sha512-ocLfj5lYcVbHLoIpzBKm/7SDsMympruKv6iLQVFv44kqphJ/oaHgGZARj/9ddNYAhMmp+UdDJHFXPCjF3Sjy5A== dependencies: "@prisma/sdk" "2.19.0" - "@redwoodjs/internal" "^0.28.2" + "@redwoodjs/internal" "^0.28.3" "@types/line-column" "^1.0.0" camelcase "^6.0.0" deepmerge "^4.2.2" @@ -2041,26 +2039,26 @@ vscode-languageserver-types "3.15.1" yargs-parser "^18.1.3" -"@redwoodjs/testing@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/testing/-/testing-0.28.2.tgz#decd0e4d825ccf1adc755554d7bf95c647d0a769" - integrity sha512-YRNleZQiV64OCFUHrm3tfRAAdU41x/1gfUqAkSQFPac/oSgUznsMNPbsuh/woSY0GXWAX8UOZPX0aW7yRDmYSg== +"@redwoodjs/testing@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/testing/-/testing-0.28.3.tgz#545cd1d889bf9834caec56f44bbc2863cac85655" + integrity sha512-FAir8ssWzKOBNXKRWOeBbX3G8dc59K2Bo8R1rQAgndsvr/6mNp4Sg7kR4TG9WFv3MP5ZVm3YY/83nmTnXirAyQ== dependencies: - "@redwoodjs/auth" "^0.28.2" - "@redwoodjs/internal" "^0.28.2" - "@redwoodjs/router" "^0.28.2" - "@redwoodjs/web" "^0.28.2" + "@redwoodjs/auth" "^0.28.3" + "@redwoodjs/internal" "^0.28.3" + "@redwoodjs/router" "^0.28.3" + "@redwoodjs/web" "^0.28.3" "@testing-library/react" "11.2.2" "@types/react" "17.0.3" msw "^0.21.2" -"@redwoodjs/web@^0.28.2": - version "0.28.2" - resolved "https://registry.yarnpkg.com/@redwoodjs/web/-/web-0.28.2.tgz#7e5856a65631f0699d8f0047d59bd2df2a3b127e" - integrity sha512-iFc0iHN9We9PUK8/hBnxC0wahB+1OLan07g2MMPPUIaZdJqJjmR/w8lF0WRrtgP+PNdevOfHmobvEYx5bd9Uyg== +"@redwoodjs/web@^0.28.3": + version "0.28.3" + resolved "https://registry.yarnpkg.com/@redwoodjs/web/-/web-0.28.3.tgz#ab9ba12928273898bc6ce135807c29e517cd6034" + integrity sha512-wWgGUE04ljaDkgwajY8pmih8UL7fNZlrJQbjG8Gi6kJyp2rDJ37+DDNP2yNGMSTr/szUPkoriLaJmZ1ahMyeJA== dependencies: "@apollo/client" "^3.3.11" - "@redwoodjs/auth" "^0.28.2" + "@redwoodjs/auth" "^0.28.3" core-js "3.6.5" graphql "^15.3.0" proptypes "^1.1.0" @@ -3552,20 +3550,20 @@ anymatch@^3.0.3, anymatch@~3.1.1: normalize-path "^3.0.0" picomatch "^2.0.4" -apollo-cache-control@^0.11.6: - version "0.11.6" - resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.11.6.tgz#f7bdf924272af47ac474cf3f3f35cfc038cc9485" - integrity sha512-YZ+uuIG+fPy+mkpBS2qKF0v1qlzZ3PW6xZVaDukeK3ed3iAs4L/2YnkTqau3OmoF/VPzX2FmSkocX/OVd59YSw== +apollo-cache-control@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/apollo-cache-control/-/apollo-cache-control-0.12.0.tgz#45aea0a232d0704e33c2b1a3c428a5500b29818c" + integrity sha512-kClF5rfAm159Nboul1LxA+l58Tjz0M8L1GUknEMpZt0UHhILLAn3BfcG3ToX4TbNoR9M57kKMUcbPWLdy3Up7w== dependencies: apollo-server-env "^3.0.0" - apollo-server-plugin-base "^0.10.4" + apollo-server-plugin-base "^0.11.0" -apollo-datasource@^0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-0.7.3.tgz#c824eb1457bdee5a3173ced0e35e594547e687a0" - integrity sha512-PE0ucdZYjHjUyXrFWRwT02yLcx2DACsZ0jm1Mp/0m/I9nZu/fEkvJxfsryXB6JndpmQO77gQHixf/xGCN976kA== +apollo-datasource@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-0.8.0.tgz#8cf9103e83558bd30b3b522cb8ec80725c3160ce" + integrity sha512-gXgsGVLuejLc138z/2jUjPAzadDQxWbcLJyBgaQsg5BaXJNkv5uW/NjiSPk00cK51hyZrb0Xx8a+L+wPk2qIBA== dependencies: - apollo-server-caching "^0.5.3" + apollo-server-caching "^0.6.0" apollo-server-env "^3.0.0" apollo-env@^0.6.6: @@ -3603,35 +3601,36 @@ apollo-reporting-protobuf@^0.6.2: dependencies: "@apollo/protobufjs" "^1.0.3" -apollo-server-caching@^0.5.3: - version "0.5.3" - resolved "https://registry.yarnpkg.com/apollo-server-caching/-/apollo-server-caching-0.5.3.tgz#cf42a77ad09a46290a246810075eaa029b5305e1" - integrity sha512-iMi3087iphDAI0U2iSBE9qtx9kQoMMEWr6w+LwXruBD95ek9DWyj7OeC2U/ngLjRsXM43DoBDXlu7R+uMjahrQ== +apollo-server-caching@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/apollo-server-caching/-/apollo-server-caching-0.6.0.tgz#3140a023ce0be8c43ba0b2f5be9cc5d15d1a32f6" + integrity sha512-SfjKaccrhRzUQ8TAke9FrYppp4pZV3Rp8KCs+4Ox3kGtbco68acRPJkiYYtSVc4idR8XNAUOOVfAEZVNHdZQKQ== dependencies: lru-cache "^6.0.0" -apollo-server-core@^2.18.2: - version "2.21.2" - resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.21.2.tgz#9f44bdcb4d5467a426f0fecd112afc95479d4b07" - integrity sha512-jIXMVQPOUzIOl4El/mzSixxJ5IDrqSk3L9uJ1U+ncwiQj0IjtkkyDSuYngcgyEi+KfO2lAzxeOiAy9fIjjkC2A== +apollo-server-core@^2.22.2: + version "2.22.2" + resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-2.22.2.tgz#daee67a17aa4f1bf0df3e448e237a37324906b5d" + integrity sha512-YPrhfN+I5vUerc4c0I6pd89fdqP5UNYCt/+MGv4bDA/a0kOCLvzylkQ3NlEepK1fewtqf4QO+S1LscC8vMmYdg== dependencies: "@apollographql/apollo-tools" "^0.4.3" "@apollographql/graphql-playground-html" "1.6.27" "@apollographql/graphql-upload-8-fork" "^8.1.3" + "@josephg/resolvable" "^1.0.0" "@types/ws" "^7.0.0" - apollo-cache-control "^0.11.6" - apollo-datasource "^0.7.3" + apollo-cache-control "^0.12.0" + apollo-datasource "^0.8.0" apollo-graphql "^0.6.0" apollo-reporting-protobuf "^0.6.2" - apollo-server-caching "^0.5.3" + apollo-server-caching "^0.6.0" apollo-server-env "^3.0.0" apollo-server-errors "^2.4.2" - apollo-server-plugin-base "^0.10.4" - apollo-server-types "^0.6.3" - apollo-tracing "^0.12.2" + apollo-server-plugin-base "^0.11.0" + apollo-server-types "^0.7.0" + apollo-tracing "^0.13.0" async-retry "^1.2.1" fast-json-stable-stringify "^2.0.0" - graphql-extensions "^0.12.8" + graphql-extensions "^0.13.0" graphql-tag "^2.11.0" graphql-tools "^4.0.8" loglevel "^1.6.7" @@ -3641,14 +3640,6 @@ apollo-server-core@^2.18.2: uuid "^8.0.0" ws "^6.0.0" -apollo-server-env@^2.4.5: - version "2.4.5" - resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-2.4.5.tgz#73730b4f0439094a2272a9d0caa4079d4b661d5f" - integrity sha512-nfNhmGPzbq3xCEWT8eRpoHXIPNcNy3QcEoBlzVMjeglrBGryLG2LXwBSPnVmTRRrzUYugX0ULBtgE3rBFNoUgA== - dependencies: - node-fetch "^2.1.2" - util.promisify "^1.0.0" - apollo-server-env@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-3.0.0.tgz#0157c51f52b63aee39af190760acf789ffc744d9" @@ -3662,41 +3653,41 @@ apollo-server-errors@^2.4.2: resolved "https://registry.yarnpkg.com/apollo-server-errors/-/apollo-server-errors-2.4.2.tgz#1128738a1d14da989f58420896d70524784eabe5" integrity sha512-FeGxW3Batn6sUtX3OVVUm7o56EgjxDlmgpTLNyWcLb0j6P8mw9oLNyAm3B+deHA4KNdNHO5BmHS2g1SJYjqPCQ== -apollo-server-lambda@2.18.2: - version "2.18.2" - resolved "https://registry.yarnpkg.com/apollo-server-lambda/-/apollo-server-lambda-2.18.2.tgz#3d89afd49ac617b44b141949d9acae6d77d671e6" - integrity sha512-w1PxAAyrNLXOTeKl+Kp4fp37CGuAwn/ubSsWv+dz9fLgs/AXnPhb9B9mWCwLW5LOBOTWH7zYDqtSNqs/J7+r1Q== +apollo-server-lambda@2.22.2: + version "2.22.2" + resolved "https://registry.yarnpkg.com/apollo-server-lambda/-/apollo-server-lambda-2.22.2.tgz#8beb0f2cfbb9048ae8dfa609afbfcb8fa42de622" + integrity sha512-QOVHg6u1+jqnY6c+fb4njUtfQEQr118guerDveZgG3vQP1t8/AtYDT33m03JhsKWRkzZjOgj5cs0RA1iSYw7cg== dependencies: - "@apollographql/graphql-playground-html" "1.6.26" + "@apollographql/graphql-playground-html" "1.6.27" "@types/aws-lambda" "^8.10.31" - apollo-server-core "^2.18.2" - apollo-server-env "^2.4.5" - apollo-server-types "^0.6.0" - graphql-tools "^4.0.0" + apollo-server-core "^2.22.2" + apollo-server-env "^3.0.0" + apollo-server-types "^0.7.0" + graphql-tools "^4.0.8" -apollo-server-plugin-base@^0.10.4: - version "0.10.4" - resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.10.4.tgz#fbf73f64f95537ca9f9639dd7c535eb5eeb95dcd" - integrity sha512-HRhbyHgHFTLP0ImubQObYhSgpmVH4Rk1BinnceZmwudIVLKrqayIVOELdyext/QnSmmzg5W7vF3NLGBcVGMqDg== +apollo-server-plugin-base@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-0.11.0.tgz#6ceeb4d5f643ed739fd00e8b26d9981186c200d0" + integrity sha512-Du68x0XCyQ6EWlgoL9Z+1s8fJfXgY131QbKP7ao617StQPzwB0aGCwxBDfcMt1A75VXf4TkvV1rdUH5YeJFlhQ== dependencies: - apollo-server-types "^0.6.3" + apollo-server-types "^0.7.0" -apollo-server-types@^0.6.0, apollo-server-types@^0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/apollo-server-types/-/apollo-server-types-0.6.3.tgz#f7aa25ff7157863264d01a77d7934aa6e13399e8" - integrity sha512-aVR7SlSGGY41E1f11YYz5bvwA89uGmkVUtzMiklDhZ7IgRJhysT5Dflt5IuwDxp+NdQkIhVCErUXakopocFLAg== +apollo-server-types@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/apollo-server-types/-/apollo-server-types-0.7.0.tgz#a9b62974ada5da5edb6157a41d8ddb993b57203a" + integrity sha512-pJ6ri2N4xJ+e2PUUPHeCNpMDzHUagJyn0DDZGQmXDz6aoMlSd4B2KUvK81hHyHkw3wHk9clgcpfM9hKqbfZweA== dependencies: apollo-reporting-protobuf "^0.6.2" - apollo-server-caching "^0.5.3" + apollo-server-caching "^0.6.0" apollo-server-env "^3.0.0" -apollo-tracing@^0.12.2: - version "0.12.2" - resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.12.2.tgz#a261c3970bb421b6dadf50cd85d75b2567a7e52c" - integrity sha512-SYN4o0C0wR1fyS3+P0FthyvsQVHFopdmN3IU64IaspR/RZScPxZ3Ae8uu++fTvkQflAkglnFM0aX6DkZERBp6w== +apollo-tracing@^0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/apollo-tracing/-/apollo-tracing-0.13.0.tgz#8621b1ae351f862bb48b6de7a85696288977d148" + integrity sha512-28z4T+XfLQ6t696usU0nTFDxVN8BfF3o74d2p/zsT4eu1OuoyoDOEmVJqdInmVRpyTJK0tDEOjkIuDJJHZftog== dependencies: apollo-server-env "^3.0.0" - apollo-server-plugin-base "^0.10.4" + apollo-server-plugin-base "^0.11.0" apollo-utilities@^1.0.1, apollo-utilities@^1.3.0: version "1.3.4" @@ -7967,14 +7958,14 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6 resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== -graphql-extensions@^0.12.8: - version "0.12.8" - resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.12.8.tgz#9cdc2c43d8fe5e0f6c3177a004ac011da2a8aa0f" - integrity sha512-xjsSaB6yKt9jarFNNdivl2VOx52WySYhxPgf8Y16g6GKZyAzBoIFiwyGw5PJDlOSUa6cpmzn6o7z8fVMbSAbkg== +graphql-extensions@^0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.13.0.tgz#34d7f9c1bf49d09c4f1fa8b5d33e6c961a1889fb" + integrity sha512-Bb7E97nvfX4gtrIdZ/i5YFlqOd6MGzrw8ED+t4wQVraYje6NQ+8P8MHMOV2WZLfbW8zsNTx8NdnnlbsdH5siag== dependencies: "@apollographql/apollo-tools" "^0.4.3" apollo-server-env "^3.0.0" - apollo-server-types "^0.6.3" + apollo-server-types "^0.7.0" graphql-scalars@1.9.0: version "1.9.0" @@ -7990,7 +7981,7 @@ graphql-tag@^2.10.3, graphql-tag@^2.11.0, graphql-tag@^2.12.0: dependencies: tslib "^2.1.0" -graphql-tools@^4.0.0, graphql-tools@^4.0.8: +graphql-tools@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-4.0.8.tgz#e7fb9f0d43408fb0878ba66b522ce871bafe9d30" integrity sha512-MW+ioleBrwhRjalKjYaLQbr+920pHBgy9vM/n47sswtns8+96sRn5M/G+J1eu7IMeKWiN/9p6tmwCHU7552VJg== @@ -15177,7 +15168,7 @@ xregexp@4.0.0: resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020" integrity sha512-PHyM+sQouu7xspQQwELlGwwd05mXUFqwFYfqPO0cC7x4fxyHnnuetmQr6CjJiafIDoH4MogHb9dOoJzR/Y4rFg== -xss@^1.0.6, xss@^1.0.8: +xss@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/xss/-/xss-1.0.8.tgz#32feb87feb74b3dcd3d404b7a68ababf10700535" integrity sha512-3MgPdaXV8rfQ/pNn16Eio6VXYPTkqwa0vc7GkiymmY/DqR1SE/7VPAAVZz1GJsJFrllMYO3RHfEaiUGjab6TNw== diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index 65d6493a7541..82df3669bef8 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/dev-server", "description": "Redwood's HTTP server for serverless Functions", - "version": "0.28.2", + "version": "0.28.3", "bin": { "dev-server": "./dist/main.js" }, @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "@babel/register": "^7.9.0", - "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/internal": "^0.28.3", "body-parser": "^1.19.0", "chokidar": "^3.4.3", "express": "^4.17.1", diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index e31a7a005733..69d8e481d67b 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,10 +1,10 @@ { "name": "@redwoodjs/eslint-config", - "version": "0.28.2", + "version": "0.28.3", "main": "index.js", "license": "MIT", "dependencies": { - "@redwoodjs/eslint-plugin-redwood": "^0.28.2", + "@redwoodjs/eslint-plugin-redwood": "^0.28.3", "@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/parser": "^4.0.1", "babel-eslint": "^10.1.0", diff --git a/packages/eslint-plugin-redwood/package.json b/packages/eslint-plugin-redwood/package.json index 78ea73734a7c..ecb6a1bd84c3 100644 --- a/packages/eslint-plugin-redwood/package.json +++ b/packages/eslint-plugin-redwood/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/eslint-plugin-redwood", - "version": "0.28.2", + "version": "0.28.3", "description": "eslint plugin for Redwood rules.", "files": [ "dist" diff --git a/packages/forms/package.json b/packages/forms/package.json index 8375c15cb6b5..48d6cc300b7a 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/forms", - "version": "0.28.2", + "version": "0.28.3", "files": [ "dist", "src/index.d.ts" diff --git a/packages/internal/package.json b/packages/internal/package.json index a5c79378cab1..d28e4b4ec527 100644 --- a/packages/internal/package.json +++ b/packages/internal/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/internal", - "version": "0.28.2", + "version": "0.28.3", "files": [ "dist" ], diff --git a/packages/prerender/package.json b/packages/prerender/package.json index 38c1c4ceab84..ccf73f9473e4 100644 --- a/packages/prerender/package.json +++ b/packages/prerender/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/prerender", "description": "RedwoodJS prerender", - "version": "0.28.2", + "version": "0.28.3", "license": "MIT", "files": [ "dist", @@ -14,11 +14,11 @@ }, "dependencies": { "@babel/register": "^7.9.0", - "@redwoodjs/auth": "^0.28.2", - "@redwoodjs/internal": "^0.28.2", - "@redwoodjs/router": "^0.28.2", - "@redwoodjs/structure": "^0.28.2", - "@redwoodjs/web": "^0.28.2", + "@redwoodjs/auth": "^0.28.3", + "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/router": "^0.28.3", + "@redwoodjs/structure": "^0.28.3", + "@redwoodjs/web": "^0.28.3", "babel-plugin-ignore-html-and-css-imports": "^0.1.0", "node-fetch": "^2.6.1" }, diff --git a/packages/router/package.json b/packages/router/package.json index be5c79e6f2c0..12a863523e4e 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/router", - "version": "0.28.2", + "version": "0.28.3", "files": [ "dist" ], @@ -9,7 +9,7 @@ "license": "MIT", "dependencies": { "@reach/skip-nav": "^0.13.2", - "@redwoodjs/auth": "^0.28.2", + "@redwoodjs/auth": "^0.28.3", "core-js": "3.6.5", "lodash.isequal": "^4.5.0" }, diff --git a/packages/structure/package.json b/packages/structure/package.json index 5d2125a0f78c..39e8dc5b6ede 100644 --- a/packages/structure/package.json +++ b/packages/structure/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/structure", "description": "noun: the arrangement of and relations between the parts or elements of something complex", - "version": "0.28.2", + "version": "0.28.3", "license": "MIT", "main": "dist/index.js", "files": [ @@ -10,7 +10,7 @@ "types": "./dist/index.d.ts", "dependencies": { "@prisma/sdk": "2.19.0", - "@redwoodjs/internal": "^0.28.2", + "@redwoodjs/internal": "^0.28.3", "@types/line-column": "^1.0.0", "camelcase": "^6.0.0", "deepmerge": "^4.2.2", diff --git a/packages/testing/package.json b/packages/testing/package.json index bcaa9a70621b..45ff164bb73f 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/testing", "description": "Tools, wrappers and configuration for testing a Redwood project.", - "version": "0.28.2", + "version": "0.28.3", "files": [ "dist" ], @@ -9,10 +9,10 @@ "types": "dist/index.d.ts", "license": "MIT", "dependencies": { - "@redwoodjs/auth": "^0.28.2", - "@redwoodjs/internal": "^0.28.2", - "@redwoodjs/router": "^0.28.2", - "@redwoodjs/web": "^0.28.2", + "@redwoodjs/auth": "^0.28.3", + "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/router": "^0.28.3", + "@redwoodjs/web": "^0.28.3", "@testing-library/react": "11.2.2", "@types/react": "17.0.3", "msw": "^0.21.2" diff --git a/packages/web/package.json b/packages/web/package.json index 12cd5ad7494b..7df19a0fa703 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/web", - "version": "0.28.2", + "version": "0.28.3", "files": [ "dist", "apollo", @@ -12,7 +12,7 @@ "license": "MIT", "dependencies": { "@apollo/client": "^3.3.11", - "@redwoodjs/auth": "^0.28.2", + "@redwoodjs/auth": "^0.28.3", "core-js": "3.6.5", "graphql": "^15.3.0", "proptypes": "^1.1.0", From f1149a9fcc2483b6f1a5bdaa4531026eeab5385f Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Wed, 31 Mar 2021 18:34:08 +0100 Subject: [PATCH 13/25] Improved yarn rwt link, with selective copy (#2122) * First attempt: try selective copy + build with esbuild to destination * Remove build:watch command * Switch back to babel | Allow watch mode --- package.json | 2 + packages/api-server/package.json | 1 + packages/api/package.json | 1 + packages/auth/package.json | 1 + packages/cli/package.json | 1 + packages/cli/src/redwood-tools.js | 182 +++++++++++--------- packages/core/package.json | 1 + packages/dev-server/package.json | 1 + packages/eslint-config/package.json | 4 + packages/eslint-plugin-redwood/package.json | 1 + packages/forms/package.json | 1 + packages/internal/package.json | 1 + packages/prerender/package.json | 1 + packages/router/package.json | 1 + packages/structure/package.json | 1 + packages/testing/package.json | 1 + packages/web/package.json | 1 + tasks/build-link | 104 +++++++++++ yarn.lock | 14 +- 19 files changed, 235 insertions(+), 85 deletions(-) create mode 100755 tasks/build-link diff --git a/package.json b/package.json index 4c53399b2c1c..0517e98d8c6f 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "build:types": "ttsc --build --verbose", "build:clean": "rimraf ./packages/**/dist", "build:watch": "lerna run build:watch --parallel; ttsc --build", + "build:link": "lerna run 'build:link' --parallel", "test": "lerna run test --stream -- --colors --maxWorkers=4", "lint": "cross-env __REDWOOD__CONFIG_PATH=packages/create-redwood-app/template eslint -c .eslintrc.js packages", "lint:fix": "cross-env __REDWOOD__CONFIG_PATH=packages/create-redwood-app/template eslint -c .eslintrc.js --fix packages" @@ -41,6 +42,7 @@ "lerna": "^3.20.2", "msw": "0.21.2", "nodemon": "^2.0.6", + "npm-packlist": "^2.1.5", "rimraf": "^3.0.2", "ttypescript": "^1.5.12", "typescript": "^4.1.3", diff --git a/packages/api-server/package.json b/packages/api-server/package.json index e357f6135b14..d18de42df4f5 100644 --- a/packages/api-server/package.json +++ b/packages/api-server/package.json @@ -37,6 +37,7 @@ "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build && yarn fix:permissions\"", + "build:link": "../../tasks/build-link", "fix:permissions": "chmod +x dist/index.js; chmod +x dist/watch.js" }, "gitHead": "c235e7d7186e5e258764699c0e0e1d5cc0fdd0b5" diff --git a/packages/api/package.json b/packages/api/package.json index 9858d8c25e77..161fa5da0f84 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -43,6 +43,7 @@ "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", + "build:link": "../../tasks/build-link", "test": "jest", "test:watch": "yarn test --watch" }, diff --git a/packages/auth/package.json b/packages/auth/package.json index 1ec298cc96fe..0509e95fd068 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -25,6 +25,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/cli/package.json b/packages/cli/package.json index 87ccbfb3e7c6..de0916f932a6 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -50,6 +50,7 @@ "prepublishOnly": "yarn build", "build:clean-dist": "yarn rimraf 'dist/**/*/__tests__'", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\" --copy-files --no-copy-ignored && yarn build:clean-dist", + "build:link": "../../tasks/build-link", "fix:permissions": "chmod +x dist/index.js dist/redwood-tools.js", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build && yarn fix:permissions\"", "test": "jest", diff --git a/packages/cli/src/redwood-tools.js b/packages/cli/src/redwood-tools.js index f4dec767bbd5..b763df52a0aa 100644 --- a/packages/cli/src/redwood-tools.js +++ b/packages/cli/src/redwood-tools.js @@ -153,61 +153,20 @@ const rwtLink = async (yargs) => { console.log(`\n Redwood Framework Path: ${c.info(frameworkPath)}`) - const frameworkPackagesPath = path.join(frameworkPath, 'packages') - - const symLinkPath = path.join(getPaths().base, 'redwood') - - // Make sure we don't double create the symlink - // Also makes sure we use the latest path passed to link - if (fs.existsSync(symLinkPath)) { - if (fs.lstatSync(symLinkPath).isSymbolicLink()) { - console.log(c.info(' 🔗 Removing old symlink. Will recreate a new one')) - rimraf.sync(symLinkPath) - } else { - // Throw an error if it looks like there was a file/folder called redwood - console.error( - c.error( - "\n 🛑 Looks like there's something called `redwood` at the root of your project." - ) + - '\n This is where we symlink redwood packages. Please remove this and rerun the command \n' - ) - - process.exit(1) - } - } + const frameworkPackagesPath = path.join(frameworkPath, 'packages/') + const projectPackagesPath = path.join(getPaths().base, 'redwood') console.log( - `Linking your local Redwood build from ${c.info(frameworkPackagesPath)} \n` + `Copying your local Redwood build from ${c.info(frameworkPackagesPath)} \n` ) - fs.symlinkSync(frameworkPackagesPath, symLinkPath) - updateProjectWithResolutions(frameworkPath) - - // Unlink framework repo, when process cancelled - process.on('SIGINT', rwtUnlink) - - // Let workspaces do the link - await execa('yarn install', { - shell: true, - stdio: 'inherit', - cleanup: true, - cwd: getPaths().base, - }) + if (!fs.existsSync(projectPackagesPath)) { + fs.mkdirSync(projectPackagesPath) + } - fixBinaryPermissions(getPaths().base) + updateProjectWithResolutions(frameworkPackagesPath) - const message = ` - ${c.bold('🚀 Go Forth and Contribute!')}\n - 🏗 Building your local redwood repo..\n - Contributing doc: ${c.underline('https://redwoodjs.com/docs/contributing')} - ` - console.log( - boxen(message, { - padding: { top: 0, bottom: 0, right: 1, left: 1 }, - margin: 1, - borderColour: 'gray', - }) - ) + addRedwoodFolderToGitIgnore() if (clean) { await execa('yarn build:clean', { @@ -218,22 +177,45 @@ const rwtLink = async (yargs) => { }) } - const buildCommand = watch ? 'yarn build:watch' : 'yarn build' + // Unlink framework repo, when process cancelled + process.on('SIGINT', () => { + const message = ` + 🙏 Thanks for contributing..\n + Please run ${c.green('yarn rwt unlink')} to restore your project + ` + console.log( + boxen(message, { + padding: { top: 0, bottom: 0, right: 1, left: 1 }, + margin: 1, + borderColour: 'gray', + }) + ) + }) + + // Delete existing redwood folders in node_modules + rimraf.sync(path.join(getPaths().base, 'node_modules/@redwoodjs/')) - execa(buildCommand, { + await execa('yarn build:link', ['-- --', '--dest', projectPackagesPath], { shell: true, stdio: 'inherit', cleanup: true, cwd: frameworkPath, }) -} -// This should be synchronous -const rwtUnlink = () => { + // Let workspaces do the link + await execa('yarn install', ['--pure-lockfile'], { + shell: true, + stdio: 'inherit', + cleanup: true, + cwd: getPaths().base, + }) + + fixBinaryPermissions(getPaths().base) + const message = ` - 🙏 Thanks for contributing..\n - Unlinking framework. \n - ${c.green('Re-run yarn install if this fails')} + ${c.bold('🚀 Go Forth and Contribute!')}\n + 🔗 Your project is linked!\n + Contributing doc: ${c.underline('https://redwoodjs.com/docs/contributing')} ` console.log( boxen(message, { @@ -243,21 +225,34 @@ const rwtUnlink = () => { }) ) - const symLinkPath = path.join(getPaths().base, 'redwood') - if ( - fs.existsSync(symLinkPath) && - fs.lstatSync(symLinkPath).isSymbolicLink() - ) { - // remove resolutions we added in link - updateProjectWithResolutions( - path.join(fs.readlinkSync(symLinkPath), '../'), - true + if (watch) { + // Restart build:link scripts in watchmode + execa( + 'yarn build:link', + ['-- --', '--dest', projectPackagesPath, '--watch'], + { + shell: true, + stdio: 'inherit', + cleanup: true, + cwd: frameworkPath, + } ) + } +} - rimraf.sync(symLinkPath) +// This should be synchronous +const rwtUnlink = () => { + const linkedPackagesPath = path.join(getPaths().base, 'redwood') + if (fs.existsSync(linkedPackagesPath)) { + // remove resolutions we added in link + updateProjectWithResolutions(linkedPackagesPath, true) + + rimraf.sync(path.join(getPaths().base, 'node_modules/@redwoodjs')) + + rimraf.sync(linkedPackagesPath) } - execa.sync('yarn install', { + execa.sync('yarn install', ['--check-files'], { shell: true, stdio: 'inherit', cleanup: true, @@ -299,27 +294,46 @@ const rwtInstall = ({ packageName }) => { ) } -const getRwPackageResolutions = (frameworkPath) => { - const frameworkVersion = require(path.join( - frameworkPath, - 'packages/cli/package.json' - )).version - const packageFolders = fs.readdirSync(path.join(frameworkPath, 'packages')) +const addRedwoodFolderToGitIgnore = () => { + const gitIgnore = fs.readFileSync( + path.join(getPaths().base, '.gitignore'), + 'utf-8' + ) + + if (gitIgnore.includes('redwood/*')) { + console.log('Redwood folder already in gitignore') + } else { + console.log('Adding `redwood/*` to .gitignore...') + fs.appendFileSync(path.join(getPaths().base, '.gitignore'), 'redwood/*') + } +} + +const getRwPackagesToLink = (packagesPath) => { + const packageFolders = fs.readdirSync(packagesPath) - const rwResolutions = {} - packageFolders + return packageFolders .filter((folderName) => folderName !== 'create-redwood-app') - .forEach((packageFolder) => { - rwResolutions[`@redwoodjs/${packageFolder}`] = frameworkVersion + .filter((item) => !/(^|\/)\.[^\/\.]/g.test(item)) // filter hidden files + .map((packageFolder) => { + return `@redwoodjs/${packageFolder}` }) - - return rwResolutions } -const updateProjectWithResolutions = (frameworkPath, remove) => { +const updateProjectWithResolutions = (redwoodPackagesPath, remove) => { const pkgJSONPath = path.join(getPaths().base, 'package.json') const packageJSON = require(pkgJSONPath) - const frameworkRepoResolutions = getRwPackageResolutions(frameworkPath) + + const frameworkVersion = require(path.join( + redwoodPackagesPath, + 'cli/package.json' + )).version + + const frameworkRepoResolutions = getRwPackagesToLink( + redwoodPackagesPath + ).reduce((resolutions, packageName) => { + resolutions[packageName] = frameworkVersion + return resolutions + }, {}) let resolutions = packageJSON.resolutions let packages = packageJSON.workspaces.packages @@ -334,7 +348,9 @@ const updateProjectWithResolutions = (frameworkPath, remove) => { ...resolutions, ...frameworkRepoResolutions, } - packages.push('redwood/*') + if (!packages.includes('redwood/*')) { + packages.push('redwood/*') + } } const updatedPackageJSON = { diff --git a/packages/core/package.json b/packages/core/package.json index a6171e4f5c5a..d9155eafaef4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -86,6 +86,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index 82df3669bef8..f09b0e73cfe9 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -34,6 +34,7 @@ "build": "yarn build:js", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build && yarn fix:permissions\"", "fix:permissions": "chmod +x dist/main.js" }, diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 69d8e481d67b..f6b52689668f 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -20,5 +20,9 @@ "eslint-plugin-react-hooks": "^4.1.0", "prettier": "^2.1.1" }, + "scripts": { + "build:link": "../../tasks/build-link", + "build": "echo 'Nothing to build..'" + }, "gitHead": "c235e7d7186e5e258764699c0e0e1d5cc0fdd0b5" } diff --git a/packages/eslint-plugin-redwood/package.json b/packages/eslint-plugin-redwood/package.json index ecb6a1bd84c3..f04de6deaacc 100644 --- a/packages/eslint-plugin-redwood/package.json +++ b/packages/eslint-plugin-redwood/package.json @@ -14,6 +14,7 @@ "build": "yarn build:js", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist", + "build:link": "../../tasks/build-link", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build\"" } } diff --git a/packages/forms/package.json b/packages/forms/package.json index 48d6cc300b7a..665c854b5778 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -18,6 +18,7 @@ "build": "yarn build:js", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", "test:watch": "yarn test --watch" diff --git a/packages/internal/package.json b/packages/internal/package.json index d28e4b4ec527..99b9324585e6 100644 --- a/packages/internal/package.json +++ b/packages/internal/package.json @@ -27,6 +27,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/prerender/package.json b/packages/prerender/package.json index ccf73f9473e4..5921b8f45072 100644 --- a/packages/prerender/package.json +++ b/packages/prerender/package.json @@ -26,6 +26,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx,.jsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/router/package.json b/packages/router/package.json index 12a863523e4e..5004f6794511 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -23,6 +23,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/structure/package.json b/packages/structure/package.json index 39e8dc5b6ede..a647aa8477f8 100644 --- a/packages/structure/package.json +++ b/packages/structure/package.json @@ -48,6 +48,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/testing/package.json b/packages/testing/package.json index 45ff164bb73f..a11d26ee0a18 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -21,6 +21,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext 'js,ts,tsx' --ignore dist --exec 'yarn build'", "test": "jest", diff --git a/packages/web/package.json b/packages/web/package.json index 7df19a0fa703..6159c6e5449d 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -28,6 +28,7 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", + "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/tasks/build-link b/tasks/build-link new file mode 100755 index 000000000000..53f7f2b110b5 --- /dev/null +++ b/tasks/build-link @@ -0,0 +1,104 @@ +#!/usr/bin/env node +/* eslint-env node, es6*/ + +const fs = require('fs') +const path = require('path') + +const chokidar = require('chokidar') +const execa = require('execa') +const { glob } = require('glob') +const _ = require('lodash') +const packlist = require('npm-packlist') +const yargs = require('yargs') + +const args = yargs + .option('watch', { default: false, type: 'boolean', alias: 'w' }) + .option('dest', { required: true, type: 'string', alias: 'd' }) + .command('build-link') + .example('build-link --dest /tmp/redwood-app/packages') + .help() + .strict().argv + +const { dest, watch } = args + +const CURRENT_DIR = process.cwd() +const pkgJson = require(path.join(CURRENT_DIR, 'package.json')) +const OUT_DIR = path.join(dest, `/${pkgJson.name.replace('@redwoodjs/', '')}`) + +const srcFiles = glob + .sync('src/**/*.{ts,js,tsx,jsx,json}', { + cwd: CURRENT_DIR, + ignore: [ + '**/*.test.ts', + '**/*.test.js', + '**/__fixtures__/**', + '**/__tests__/**', + ], + }) + .map((filePath) => `./${filePath}`) + +const buildAndCopy = () => + execa('yarn build', { + shell: true, + stdio: 'inherit', + cleanup: true, + cwd: CURRENT_DIR, + }).then(() => { + if ('bin' in pkgJson) { + // Chmod if package has bins + execa('yarn fix:permissions', { + cwd: CURRENT_DIR, + }) + } + return packlist({ path: CURRENT_DIR }).then((files) => { + files.forEach((file) => { + copyToDest(file, OUT_DIR) + }) + return files + }) + }) + +// Creates folders where required, before copying +const copyToDest = (src, dest) => { + const dirName = path.dirname(path.join(dest, `/${src}`)) + const fileName = path.basename(src) + + const exist = fs.existsSync(dirName) + if (!exist) { + fs.mkdirSync(dirName, { recursive: true }) + } + + fs.copyFileSync(src, path.join(dirName, fileName)) +} + +// Assigned if watch is true +let watchHandle + +process.on('SIGINT', () => { + watchHandle?.cancel() +}) + +// @Note: +// --watch flag starts the watcher, but won't build until change detected +if (watch) { + // Start watcher + packlist({ path: CURRENT_DIR }).then((files) => { + const filesToWatch = [ + ...srcFiles, + ...files.filter((fileName) => !fileName.match('dist/')), + ] + + watchHandle = chokidar + .watch(filesToWatch, { + persistent: true, + }) + .on( + 'change', + _.debounce(() => { + buildAndCopy() + }, 500) + ) + }) +} else { + buildAndCopy() +} diff --git a/yarn.lock b/yarn.lock index 3dc659186ca2..9ae1ddc14d0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10704,7 +10704,7 @@ ignore-by-default@^1.0.1: resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" integrity sha1-SMptcvbGo68Aqa1K5odr44ieKwk= -ignore-walk@^3.0.1: +ignore-walk@^3.0.1, ignore-walk@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37" integrity sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw== @@ -13791,7 +13791,7 @@ normalize-url@^4.1.0: resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== -npm-bundled@^1.0.1: +npm-bundled@^1.0.1, npm-bundled@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.1.tgz#1edd570865a94cdb1bc8220775e29466c9fb234b" integrity sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA== @@ -13836,6 +13836,16 @@ npm-packlist@^1.4.4: npm-bundled "^1.0.1" npm-normalize-package-bin "^1.0.1" +npm-packlist@^2.1.5: + version "2.1.5" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-2.1.5.tgz#43ef5bbb9f59b7c0ef91e0905f1dd707b4cfb33c" + integrity sha512-KCfK3Vi2F+PH1klYauoQzg81GQ8/GGjQRKYY6tRnpQUPKTs/1gBZSRWtTEd7jGdSn1LZL7gpAmJT+BcS55k2XQ== + dependencies: + glob "^7.1.6" + ignore-walk "^3.0.3" + npm-bundled "^1.1.1" + npm-normalize-package-bin "^1.0.1" + npm-pick-manifest@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/npm-pick-manifest/-/npm-pick-manifest-3.0.2.tgz#f4d9e5fd4be2153e5f4e5f9b7be8dc419a99abb7" From 6a40b47470d2c70824290ad654943cdb1077e959 Mon Sep 17 00:00:00 2001 From: David Price Date: Thu, 1 Apr 2021 06:25:26 -0700 Subject: [PATCH 14/25] add storybook output dir option (#2168) --- packages/cli/src/commands/storybook.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/storybook.js b/packages/cli/src/commands/storybook.js index 38bca5f9c112..49ccc69150f1 100644 --- a/packages/cli/src/commands/storybook.js +++ b/packages/cli/src/commands/storybook.js @@ -26,9 +26,14 @@ export const builder = (yargs) => { type: 'integer', default: 7910, }) + .option('build-directory', { + describe: 'Directory in web/ to store static files', + type: 'string', + default: 'storybook-static', + }) } -export const handler = ({ open, port, build }) => { +export const handler = ({ open, port, build, buildDirectory }) => { const cwd = getPaths().web.base const staticAssetsFolder = path.join(getPaths().web.base, 'public') @@ -46,7 +51,9 @@ export const handler = ({ open, port, build }) => { '--config-dir ../node_modules/@redwoodjs/core/config/storybook', !build && `--port ${port}`, !build && '--no-version-updates', - `--static-dir "${staticAssetsFolder}"`, + !build && `--static-dir "${staticAssetsFolder}"`, + build && + `--output-dir "${path.join(getPaths().web.base, buildDirectory)}"`, !open && '--ci', ].filter(Boolean), { From 7d360583f5b504a450fdfb6b1bde67f096d0b288 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Thu, 1 Apr 2021 15:25:47 +0200 Subject: [PATCH 15/25] Just decode, not verify, auth0 token during development and test. (#2172) * Just decode, not verify, auth0 token during development and test. * Test that decode is not called in production. --- packages/api/src/auth/decoders/auth0.test.ts | 23 +++++++ packages/api/src/auth/decoders/auth0.ts | 63 ++++++++++++-------- 2 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 packages/api/src/auth/decoders/auth0.test.ts diff --git a/packages/api/src/auth/decoders/auth0.test.ts b/packages/api/src/auth/decoders/auth0.test.ts new file mode 100644 index 000000000000..2b50169b6941 --- /dev/null +++ b/packages/api/src/auth/decoders/auth0.test.ts @@ -0,0 +1,23 @@ +import jwt from 'jsonwebtoken' + +import { verifyAuth0Token } from './auth0' + +jest.mock('jsonwebtoken', () => ({ + verify: jest.fn(), + decode: jest.fn(), +})) + +test.only('verify, and not decode, should be called in production', () => { + const { NODE_ENV } = process.env + process.env.NODE_ENV = 'production' + process.env.AUTH0_DOMAIN = 'redwoodjs.com' + process.env.AUTH0_AUDIENCE = 'michael bolton' + + // @ts-expect-error Ingore this error. + verifyAuth0Token({}) + + expect(jwt.decode).not.toBeCalled() + expect(jwt.verify).toBeCalled() + + process.env.NODE_ENV = NODE_ENV +}) diff --git a/packages/api/src/auth/decoders/auth0.ts b/packages/api/src/auth/decoders/auth0.ts index 4de3dcffe1cf..21945fe33eb4 100644 --- a/packages/api/src/auth/decoders/auth0.ts +++ b/packages/api/src/auth/decoders/auth0.ts @@ -33,33 +33,44 @@ export const verifyAuth0Token = ( ) } - const client = jwksClient({ - jwksUri: `https://${AUTH0_DOMAIN}/.well-known/jwks.json`, - }) - - jwt.verify( - bearerToken, - (header, callback) => { - client.getSigningKey(header.kid as string, (error, key) => { - callback(error, key.getPublicKey()) - }) - }, - { - audience: AUTH0_AUDIENCE, - issuer: `https://${AUTH0_DOMAIN}/`, - algorithms: ['RS256'], - }, - (verifyError, decoded) => { - if (verifyError) { - return reject(verifyError) + if ( + process.env.NODE_ENV === 'development' || + process.env.NODE_ENV === 'test' + ) { + const decoded = jwt.decode(bearerToken) + resolve( + typeof decoded === 'undefined' + ? null + : (decoded as Record) + ) + } else { + const client = jwksClient({ + jwksUri: `https://${AUTH0_DOMAIN}/.well-known/jwks.json`, + }) + jwt.verify( + bearerToken, + (header, callback) => { + client.getSigningKey(header.kid as string, (error, key) => { + callback(error, key.getPublicKey()) + }) + }, + { + audience: AUTH0_AUDIENCE, + issuer: `https://${AUTH0_DOMAIN}/`, + algorithms: ['RS256'], + }, + (verifyError, decoded) => { + if (verifyError) { + return reject(verifyError) + } + resolve( + typeof decoded === 'undefined' + ? null + : (decoded as Record) + ) } - resolve( - typeof decoded === 'undefined' - ? null - : (decoded as Record) - ) - } - ) + ) + } }) } From 4ab7a9fe9b1d07b447eaeed5098657b663b924c3 Mon Sep 17 00:00:00 2001 From: Johan Eliasson Date: Thu, 1 Apr 2021 15:45:34 +0200 Subject: [PATCH 16/25] Add root-path to api-server (#1691) * Adding inital solution to routePrefix * Don't run PR build actions on forks * Aligning arguments with main branch * Making it more readable * Handling routePrefix without starting slash (/) * Fixing lint errors * Removing debugging * Cleaning up * Minor text and docs changes * Typo. Oopise. * Refactoring using yargs coerce * Updating comment ty @Tobbe Co-authored-by: Tobbe Lundberg * Cleaner way of handling slash * Passing rootPath as argument to http and reverting the way we construct root path Co-authored-by: Tobbe Lundberg Co-authored-by: Peter Pistorius --- packages/api-server/src/http.ts | 9 ++++++--- packages/api-server/src/index.ts | 21 +++++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/api-server/src/http.ts b/packages/api-server/src/http.ts index c2c09ac5c396..11ad4d506153 100644 --- a/packages/api-server/src/http.ts +++ b/packages/api-server/src/http.ts @@ -10,10 +10,11 @@ import escape from 'lodash.escape' import morgan from 'morgan' import { getPaths } from '@redwoodjs/internal' -const rwjsPaths = getPaths() import { requestHandler } from './requestHandlers/awsLambda' +const rwjsPaths = getPaths() + export type Lambdas = Record const LAMBDA_FUNCTIONS: Lambdas = {} export const setLambdaFunctions = (foundFunctions: string[]) => { @@ -46,9 +47,11 @@ const lambdaRequestHandler = async (req: Request, res: Response) => { export const http = ({ port = 8911, socket, + rootPath, }: { port: number socket?: string + rootPath?: string }) => { const app = express() @@ -67,8 +70,8 @@ export const http = ({ app.use(morgan('dev')) - app.all('/:routeName', lambdaRequestHandler) - app.all('/:routeName/*', lambdaRequestHandler) + app.all(`${rootPath}:routeName`, lambdaRequestHandler) + app.all(`${rootPath}:routeName/*`, lambdaRequestHandler) const server = app .listen(socket || port, () => { diff --git a/packages/api-server/src/index.ts b/packages/api-server/src/index.ts index f4399aa42eeb..274cbfadd290 100644 --- a/packages/api-server/src/index.ts +++ b/packages/api-server/src/index.ts @@ -11,15 +11,28 @@ if (process.argv0 === 'api-server') { console.log() } -const { port, socket } = yargs +const { port, socket, rootPath } = yargs .option('port', { default: 8911, type: 'number', alias: 'p' }) - .option('socket', { type: 'string' }).argv + .option('socket', { type: 'string' }) + .option('rootPath', { + alias: 'root-path', + default: '/', + type: 'string', + desc: 'Root path where your api functions are served', + }) + .coerce('rootPath', (path) => { + // Make sure that we create a root path that starts and ends with a slash (/) + const prefix = path.charAt(0) !== '/' ? '/' : '' + const suffix = path.charAt(path.length - 1) !== '/' ? '/' : '' -http({ port, socket }).on('listening', () => { + return `${prefix}${path}${suffix}` + }).argv + +http({ port, socket, rootPath }).on('listening', () => { if (socket) { console.log(`Listening on ${socket}`) } else { - console.log(`Listening on http://localhost:${port}`) + console.log(`Listening on http://localhost:${port}${rootPath}`) } console.log() }) From bd647d54fb2b857b7aa3d4e9f29fddb29ef9f7e0 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Thu, 1 Apr 2021 15:57:07 +0200 Subject: [PATCH 17/25] Set: Forward props to wrapper components (#2125) * Set: Forward props to wrapper components * Set: no `unknown` types --- packages/router/src/Set.tsx | 23 ++++---- packages/router/src/__tests__/set.test.tsx | 63 ++++++++++++++++++++++ 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/packages/router/src/Set.tsx b/packages/router/src/Set.tsx index 470d6ec68df0..fd5ba6ed3bd3 100644 --- a/packages/router/src/Set.tsx +++ b/packages/router/src/Set.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, ReactNode, FunctionComponentElement } from 'react' +import React, { ReactElement, ReactNode } from 'react' import { Redirect } from './links' import { useLocation } from './location' @@ -7,19 +7,19 @@ import { isRoute } from './router' import { useRouterState } from './router-context' import { flattenAll, matchPath } from './util' -interface PropsWithChildren { - children: ReactNode -} +type WrapperType = ( + props: WTProps & { children: ReactNode } +) => ReactElement | null -type WrapperType = (props: { children: any }) => ReactElement | null -type ReduceType = FunctionComponentElement | undefined +type ReduceType = ReactElement | undefined -interface Props { - wrap: WrapperType | WrapperType[] +type SetProps

= P & { + wrap: WrapperType

| WrapperType

[] children: ReactNode } -export const Set: React.FC = ({ children, wrap }) => { +export function Set(props: SetProps) { + const { wrap, children, ...rest } = props const routerState = useRouterState() const location = useLocation() const { loading } = routerState.useAuth() @@ -59,7 +59,10 @@ export const Set: React.FC = ({ children, wrap }) => { // Expand and nest the wrapped elements. return ( wrappers.reduceRight((acc, wrapper) => { - return React.createElement(wrapper, undefined, acc ? acc : children) + return React.createElement(wrapper, { + ...rest, + children: acc ? acc : children, + } as SetProps) }, undefined) || null ) } diff --git a/packages/router/src/__tests__/set.test.tsx b/packages/router/src/__tests__/set.test.tsx index 0d8256e5dd05..9a7190824617 100644 --- a/packages/router/src/__tests__/set.test.tsx +++ b/packages/router/src/__tests__/set.test.tsx @@ -90,3 +90,66 @@ test('wraps components in other components', async () => { `) }) + +test('passes props to wrappers', async () => { + interface Props { + propOne: string + propTwo: string + } + + const PropWrapper: React.FC = ({ children, propOne, propTwo }) => ( +

+

Prop Wrapper

+

1:{propOne}

+

2:{propTwo}

+ {children} +
+ ) + const TestSet = () => ( + + + + + + ) + + const screen = render() + + await waitFor(() => screen.getByText('ChildA')) + + expect(screen.container).toMatchInlineSnapshot(` +
+
+

+ Prop Wrapper +

+

+ 1: + une +

+

+ 2: + deux +

+
+

+ Global Layout +

+

+ ChildA +

+ +
+
+ `) +}) From a226c3aa28523d7562265b68552c07c80a4dd9b7 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Thu, 1 Apr 2021 15:58:14 +0200 Subject: [PATCH 18/25] Remove '.only.' --- packages/api/src/auth/decoders/auth0.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/auth/decoders/auth0.test.ts b/packages/api/src/auth/decoders/auth0.test.ts index 2b50169b6941..b1b3c9626f22 100644 --- a/packages/api/src/auth/decoders/auth0.test.ts +++ b/packages/api/src/auth/decoders/auth0.test.ts @@ -7,7 +7,7 @@ jest.mock('jsonwebtoken', () => ({ decode: jest.fn(), })) -test.only('verify, and not decode, should be called in production', () => { +test('verify, and not decode, should be called in production', () => { const { NODE_ENV } = process.env process.env.NODE_ENV = 'production' process.env.AUTH0_DOMAIN = 'redwoodjs.com' From b90d5e6cbc9d80cc3913376d25216f2bd880eb30 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Thu, 1 Apr 2021 17:52:40 +0200 Subject: [PATCH 19/25] Router: routes is not a prop (#2173) --- packages/router/src/router-context.tsx | 5 +++-- packages/router/src/router.tsx | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/router/src/router-context.tsx b/packages/router/src/router-context.tsx index 4cd3a5827e39..9ba252fdfd76 100644 --- a/packages/router/src/router-context.tsx +++ b/packages/router/src/router-context.tsx @@ -25,7 +25,8 @@ const RouterSetContext = createContext< React.Dispatch> | undefined >(undefined) -interface ProviderProps extends Omit { +export interface RouterContextProviderProps + extends Omit { useAuth?: typeof useAuth } @@ -33,7 +34,7 @@ function stateReducer(state: RouterState, newState: Partial) { return { ...state, ...newState } } -export const RouterContextProvider: React.FC = ({ +export const RouterContextProvider: React.FC = ({ useAuth: customUseAuth, paramTypes, pageLoadingDelay = DEFAULT_PAGE_LOADING_DELAY, diff --git a/packages/router/src/router.tsx b/packages/router/src/router.tsx index c5ca3290a3b6..81ab1207e968 100644 --- a/packages/router/src/router.tsx +++ b/packages/router/src/router.tsx @@ -15,7 +15,7 @@ import { PrivateContextProvider, usePrivate } from './private-context' import { RouteNameProvider, useRouteName } from './RouteNameContext' import { RouterContextProvider, - RouterState, + RouterContextProviderProps, useRouterState, } from './router-context' import { SplashPage } from './splash-page' @@ -177,7 +177,7 @@ function isRoute( return isReactElement(node) && node.type === Route } -interface RouterProps extends RouterState {} +interface RouterProps extends RouterContextProviderProps {} const Router: React.FC = ({ useAuth, From 8c42d93da7eef4396907949f6ce29c3504fe3191 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Thu, 1 Apr 2021 19:08:13 +0200 Subject: [PATCH 20/25] Router tests: Don't use window.__REDWOOD__USE_AUTH (#2174) * Router tests: Don't use window.__REDWOOD__USE_AUTH * Router tests: mockUseAuth --- packages/router/src/__tests__/router.test.tsx | 54 +++++++------------ 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/packages/router/src/__tests__/router.test.tsx b/packages/router/src/__tests__/router.test.tsx index 95f4e73bf1b5..650e599304c5 100644 --- a/packages/router/src/__tests__/router.test.tsx +++ b/packages/router/src/__tests__/router.test.tsx @@ -31,6 +31,9 @@ function createDummyAuthContextValues(partial: Partial) { return { ...authContextValues, ...partial } } +const mockUseAuth = (isAuthenticated = false, loading = false) => () => + createDummyAuthContextValues({ loading, isAuthenticated }) + // SETUP const HomePage = () =>

Home Page

const LoginPage = () =>

Login Page

@@ -38,13 +41,6 @@ const AboutPage = () =>

About Page

const PrivatePage = () =>

Private Page

const RedirectPage = () => const NotFoundPage = () =>

404

-const mockAuth = (isAuthenticated = false) => { - window.__REDWOOD__USE_AUTH = () => - createDummyAuthContextValues({ - loading: false, - isAuthenticated, - }) -} beforeEach(() => { window.history.pushState({}, null, '/') @@ -52,8 +48,6 @@ beforeEach(() => { }) test('inits routes and navigates as expected', async () => { - mockAuth(false) - const ParamPage = ({ value, q }: { value: string; q: string }) => { const params = useParams() @@ -66,7 +60,7 @@ test('inits routes and navigates as expected', async () => { } const TestRouter = () => ( - + @@ -123,9 +117,8 @@ test('inits routes and navigates as expected', async () => { }) test('unauthenticated user is redirected away from private page', async () => { - mockAuth(false) const TestRouter = () => ( - + @@ -152,9 +145,8 @@ test('unauthenticated user is redirected away from private page', async () => { }) test('unauthenticated user is redirected including search params', async () => { - mockAuth(false) const TestRouter = () => ( - + @@ -182,9 +174,8 @@ test('unauthenticated user is redirected including search params', async () => { }) test('authenticated user can access private page', async () => { - mockAuth(true) const TestRouter = () => ( - + @@ -207,7 +198,7 @@ test('authenticated user can access private page', async () => { test('can display a loading screen whilst waiting for auth', async () => { const TestRouter = () => ( - createDummyAuthContextValues({ loading: true })}> + { }) test('inits routes two private routes with a space in between and loads as expected', async () => { - mockAuth(false) const TestRouter = () => ( - + @@ -259,7 +249,6 @@ test('inits routes two private routes with a space in between and loads as expec }) test('supports ', async () => { - mockAuth(false) const GlobalLayout = ({ children }) => (

Global Layout

@@ -268,7 +257,7 @@ test('supports ', async () => { ) const TestRouter = () => ( - + @@ -332,7 +321,7 @@ test("Doesn't destroy when navigating inside, but does when navigating bet const TestRouter = () => { return ( - + @@ -373,7 +362,7 @@ test('can use named routes for navigating', async () => { } const TestRouter = () => ( - + @@ -413,7 +402,7 @@ test('renders only active path', async () => { } const TestRouter = () => ( - + @@ -448,7 +437,7 @@ test('renders first matching route only', async () => { const ParamPage = ({ param }: { param: string }) =>
param {param}
const TestRouter = () => ( - + @@ -474,8 +463,7 @@ test('params should never be an empty object', async (done) => { } const TestRouter = () => ( - // @ts-expect-error - Meh. - + ) @@ -497,8 +485,7 @@ test('params should never be an empty object in Set', async (done) => { } const TestRouter = () => ( - // @ts-expect-error - Meh. - + @@ -524,8 +511,7 @@ test('params should never be an empty object in Set', async () => { } const TestRouter = () => ( - // @ts-expect-error - Meh. - + @@ -540,9 +526,6 @@ test('params should never be an empty object in Set', async () => { }) test('Set is not rendered for unauthenticated user.', async () => { - // not authenticated. - mockAuth(false) - const ParamPage = () => { // This should never be called. We should be redirect to login instead. expect(false).toBe(true) @@ -556,8 +539,7 @@ test('Set is not rendered for unauthenticated user.', async () => { } const TestRouter = () => ( - // @ts-expect-error - Meh. - + From fb97c8a463efd63f3dd160e5b16424cdcbcc873c Mon Sep 17 00:00:00 2001 From: David Price Date: Thu, 1 Apr 2021 13:01:12 -0700 Subject: [PATCH 21/25] change default output directory (#2176) --- packages/cli/src/commands/storybook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/commands/storybook.js b/packages/cli/src/commands/storybook.js index 49ccc69150f1..5702fdbb7bae 100644 --- a/packages/cli/src/commands/storybook.js +++ b/packages/cli/src/commands/storybook.js @@ -29,7 +29,7 @@ export const builder = (yargs) => { .option('build-directory', { describe: 'Directory in web/ to store static files', type: 'string', - default: 'storybook-static', + default: 'public/storybook', }) } From 8f80e6cdc43b90e182a63f82f454be972316ff25 Mon Sep 17 00:00:00 2001 From: David Price Date: Thu, 1 Apr 2021 19:04:27 -0700 Subject: [PATCH 22/25] v0.28.4 (#2178) * Install @redwoodjs/api-server as a dependency and add lockfile. (#2129) * Include api-server as a dependecy. * Pin apollo-server-core. * v0.28.1 * useParams should always be populated. (#2142) * Add failing test case for empty params. * Add some clarifications for failing test. * Set params before loading a new route. * Update packages/router/src/__tests__/router.test.tsx Co-authored-by: Tobbe Lundberg * Add params test case for Set. * Make tests start on initial location, instead of "/". * Fix engrish. * No longer set params in pageLoader. * Add top-level routes structure. * Calculate params on location, and router-state changes. * Fix type errors. * Revert this change. * Take search params into account. * Update packages/router/src/router-context.tsx Co-authored-by: Tobbe Lundberg * Remove ts-ignore-error. Co-authored-by: Tobbe Lundberg * Router: Populate `routes` for tests (#2133) Fixes #2131 * v0.28.2 * Make understand authentication. (#2147) * Add test for Set and authentication. * Make set understand auth. * Fix race condition in useParams. * Recalculate param on location change (#2152) * update params contexts directly in the context provider * update variable names * simplify imports * Update packages/router/src/__tests__/router.test.tsx Remove only, so we can test these against all tests. * Update packages/router/src/params.tsx Co-authored-by: Tobbe Lundberg * Update packages/router/src/params.tsx Co-authored-by: Tobbe Lundberg * Remove unused params context. * Name param variables properly. * Fix comment now that we've fixed test. * Remove this unused import. * Keep params order the same as before. Co-authored-by: Peter Pistorius Co-authored-by: Tobbe Lundberg * upgrade apollo-server-lambda; remove resolution (#2153) Co-authored-by: Peter Pistorius * Fix: named routes types (#2154) * Fix named routes typing | Now adds params to types * Add setup command for creating tsconfigs * Lint fix * PR Comments | Further Lint fixes * Fix github version tag for canary builds (#2156) Co-authored-by: David Price * v0.28.3 * Router: routes is not a prop (#2173) * v0.28.4 Co-authored-by: Peter Pistorius Co-authored-by: Tobbe Lundberg Co-authored-by: Kris Coulson Co-authored-by: Daniel Choudhury --- lerna.json | 2 +- packages/api-server/package.json | 2 +- packages/api/package.json | 8 ++++---- packages/auth/package.json | 2 +- packages/cli/package.json | 8 ++++---- packages/core/package.json | 12 ++++++------ packages/create-redwood-app/package.json | 4 ++-- .../create-redwood-app/template/api/package.json | 4 ++-- packages/create-redwood-app/template/package.json | 2 +- .../create-redwood-app/template/web/package.json | 6 +++--- packages/dev-server/package.json | 4 ++-- packages/eslint-config/package.json | 4 ++-- packages/eslint-plugin-redwood/package.json | 2 +- packages/forms/package.json | 2 +- packages/internal/package.json | 2 +- packages/prerender/package.json | 12 ++++++------ packages/router/package.json | 4 ++-- packages/structure/package.json | 4 ++-- packages/testing/package.json | 10 +++++----- packages/web/package.json | 4 ++-- 20 files changed, 49 insertions(+), 49 deletions(-) diff --git a/lerna.json b/lerna.json index b203bfd9d13f..2f87f7038b10 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.28.3", + "version": "0.28.4", "npmClient": "yarn", "useWorkspaces": true, "command": { diff --git a/packages/api-server/package.json b/packages/api-server/package.json index d18de42df4f5..535dac642394 100644 --- a/packages/api-server/package.json +++ b/packages/api-server/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/api-server", "description": "Redwood's HTTP server for Serverless Functions", - "version": "0.28.3", + "version": "0.28.4", "bin": { "api-server": "./dist/index.js", "rw-api-server": "./dist/index.js", diff --git a/packages/api/package.json b/packages/api/package.json index 161fa5da0f84..013d1bf85242 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/api", - "version": "0.28.3", + "version": "0.28.4", "files": [ "dist", "logger" @@ -11,7 +11,7 @@ "dependencies": { "@graphql-tools/merge": "6.2.10", "@prisma/client": "2.19.0", - "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/internal": "^0.28.4", "@types/pino": "^6.3.6", "apollo-server-lambda": "2.22.2", "core-js": "3.6.5", @@ -25,8 +25,8 @@ "pino-pretty": "^4.7.0" }, "devDependencies": { - "@redwoodjs/auth": "^0.28.3", - "@redwoodjs/dev-server": "^0.28.3", + "@redwoodjs/auth": "^0.28.4", + "@redwoodjs/dev-server": "^0.28.4", "@types/jsonwebtoken": "^8.3.9", "@types/lodash.merge": "^4.6.6", "@types/lodash.omitby": "^4.6.6", diff --git a/packages/auth/package.json b/packages/auth/package.json index 0509e95fd068..9716385cd167 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/auth", - "version": "0.28.3", + "version": "0.28.4", "files": [ "dist" ], diff --git a/packages/cli/package.json b/packages/cli/package.json index de0916f932a6..234ed6b65a43 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/cli", "description": "The Redwood Command Line", - "version": "0.28.3", + "version": "0.28.4", "license": "MIT", "bin": { "redwood": "./dist/index.js", @@ -14,9 +14,9 @@ ], "dependencies": { "@prisma/sdk": "2.19.0", - "@redwoodjs/internal": "^0.28.3", - "@redwoodjs/prerender": "^0.28.3", - "@redwoodjs/structure": "^0.28.3", + "@redwoodjs/internal": "^0.28.4", + "@redwoodjs/prerender": "^0.28.4", + "@redwoodjs/structure": "^0.28.4", "boxen": "^4.2.0", "camelcase": "^6.0.0", "chalk": "^4.1.0", diff --git a/packages/core/package.json b/packages/core/package.json index d9155eafaef4..ae862f99db75 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/core", - "version": "0.28.3", + "version": "0.28.4", "license": "MIT", "files": [ "config", @@ -23,11 +23,11 @@ "@babel/preset-typescript": "^7.10.4", "@babel/runtime-corejs3": "^7.11.2", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", - "@redwoodjs/cli": "^0.28.3", - "@redwoodjs/dev-server": "^0.28.3", - "@redwoodjs/eslint-config": "^0.28.3", - "@redwoodjs/internal": "^0.28.3", - "@redwoodjs/testing": "^0.28.3", + "@redwoodjs/cli": "^0.28.4", + "@redwoodjs/dev-server": "^0.28.4", + "@redwoodjs/eslint-config": "^0.28.4", + "@redwoodjs/internal": "^0.28.4", + "@redwoodjs/testing": "^0.28.4", "@storybook/addon-a11y": "^6.1.19", "@storybook/react": "^6.1.21", "@testing-library/jest-dom": "5.11.6", diff --git a/packages/create-redwood-app/package.json b/packages/create-redwood-app/package.json index 6434880862d4..e1241577268f 100644 --- a/packages/create-redwood-app/package.json +++ b/packages/create-redwood-app/package.json @@ -1,6 +1,6 @@ { "name": "create-redwood-app", - "version": "0.28.3", + "version": "0.28.4", "license": "MIT", "bin": "./dist/create-redwood-app.js", "files": [ @@ -9,7 +9,7 @@ ], "dependencies": { "@babel/runtime-corejs3": "^7.9.2", - "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/internal": "^0.28.4", "axios": "^0.20.0", "chalk": "^4.1.0", "check-node-version": "^4.0.2", diff --git a/packages/create-redwood-app/template/api/package.json b/packages/create-redwood-app/template/api/package.json index 8fba5c402b69..e2aade7e7e33 100644 --- a/packages/create-redwood-app/template/api/package.json +++ b/packages/create-redwood-app/template/api/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "dependencies": { - "@redwoodjs/api": "^0.28.3", - "@redwoodjs/api-server": "^0.28.3" + "@redwoodjs/api": "^0.28.4", + "@redwoodjs/api-server": "^0.28.4" } } \ No newline at end of file diff --git a/packages/create-redwood-app/template/package.json b/packages/create-redwood-app/template/package.json index 3e358830b65e..a156cef5cbd1 100644 --- a/packages/create-redwood-app/template/package.json +++ b/packages/create-redwood-app/template/package.json @@ -8,7 +8,7 @@ ] }, "devDependencies": { - "@redwoodjs/core": "^0.28.3" + "@redwoodjs/core": "^0.28.4" }, "eslintConfig": { "extends": "@redwoodjs/eslint-config", diff --git a/packages/create-redwood-app/template/web/package.json b/packages/create-redwood-app/template/web/package.json index 1e645032a2ca..9f36074bf8db 100644 --- a/packages/create-redwood-app/template/web/package.json +++ b/packages/create-redwood-app/template/web/package.json @@ -13,9 +13,9 @@ ] }, "dependencies": { - "@redwoodjs/forms": "^0.28.3", - "@redwoodjs/router": "^0.28.3", - "@redwoodjs/web": "^0.28.3", + "@redwoodjs/forms": "^0.28.4", + "@redwoodjs/router": "^0.28.4", + "@redwoodjs/web": "^0.28.4", "prop-types": "^15.7.2", "react": "^17.0.1", "react-dom": "^17.0.1" diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index f09b0e73cfe9..91b0a12e3f3d 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/dev-server", "description": "Redwood's HTTP server for serverless Functions", - "version": "0.28.3", + "version": "0.28.4", "bin": { "dev-server": "./dist/main.js" }, @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "@babel/register": "^7.9.0", - "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/internal": "^0.28.4", "body-parser": "^1.19.0", "chokidar": "^3.4.3", "express": "^4.17.1", diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index f6b52689668f..ddba8376e839 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,10 +1,10 @@ { "name": "@redwoodjs/eslint-config", - "version": "0.28.3", + "version": "0.28.4", "main": "index.js", "license": "MIT", "dependencies": { - "@redwoodjs/eslint-plugin-redwood": "^0.28.3", + "@redwoodjs/eslint-plugin-redwood": "^0.28.4", "@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/parser": "^4.0.1", "babel-eslint": "^10.1.0", diff --git a/packages/eslint-plugin-redwood/package.json b/packages/eslint-plugin-redwood/package.json index f04de6deaacc..b05b77a48cd0 100644 --- a/packages/eslint-plugin-redwood/package.json +++ b/packages/eslint-plugin-redwood/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/eslint-plugin-redwood", - "version": "0.28.3", + "version": "0.28.4", "description": "eslint plugin for Redwood rules.", "files": [ "dist" diff --git a/packages/forms/package.json b/packages/forms/package.json index 665c854b5778..d7c516a8428f 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/forms", - "version": "0.28.3", + "version": "0.28.4", "files": [ "dist", "src/index.d.ts" diff --git a/packages/internal/package.json b/packages/internal/package.json index 99b9324585e6..eb8d4a5095f9 100644 --- a/packages/internal/package.json +++ b/packages/internal/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/internal", - "version": "0.28.3", + "version": "0.28.4", "files": [ "dist" ], diff --git a/packages/prerender/package.json b/packages/prerender/package.json index 5921b8f45072..8f38d06c0864 100644 --- a/packages/prerender/package.json +++ b/packages/prerender/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/prerender", "description": "RedwoodJS prerender", - "version": "0.28.3", + "version": "0.28.4", "license": "MIT", "files": [ "dist", @@ -14,11 +14,11 @@ }, "dependencies": { "@babel/register": "^7.9.0", - "@redwoodjs/auth": "^0.28.3", - "@redwoodjs/internal": "^0.28.3", - "@redwoodjs/router": "^0.28.3", - "@redwoodjs/structure": "^0.28.3", - "@redwoodjs/web": "^0.28.3", + "@redwoodjs/auth": "^0.28.4", + "@redwoodjs/internal": "^0.28.4", + "@redwoodjs/router": "^0.28.4", + "@redwoodjs/structure": "^0.28.4", + "@redwoodjs/web": "^0.28.4", "babel-plugin-ignore-html-and-css-imports": "^0.1.0", "node-fetch": "^2.6.1" }, diff --git a/packages/router/package.json b/packages/router/package.json index 5004f6794511..e903109b8d24 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/router", - "version": "0.28.3", + "version": "0.28.4", "files": [ "dist" ], @@ -9,7 +9,7 @@ "license": "MIT", "dependencies": { "@reach/skip-nav": "^0.13.2", - "@redwoodjs/auth": "^0.28.3", + "@redwoodjs/auth": "^0.28.4", "core-js": "3.6.5", "lodash.isequal": "^4.5.0" }, diff --git a/packages/structure/package.json b/packages/structure/package.json index a647aa8477f8..0f5142e1c812 100644 --- a/packages/structure/package.json +++ b/packages/structure/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/structure", "description": "noun: the arrangement of and relations between the parts or elements of something complex", - "version": "0.28.3", + "version": "0.28.4", "license": "MIT", "main": "dist/index.js", "files": [ @@ -10,7 +10,7 @@ "types": "./dist/index.d.ts", "dependencies": { "@prisma/sdk": "2.19.0", - "@redwoodjs/internal": "^0.28.3", + "@redwoodjs/internal": "^0.28.4", "@types/line-column": "^1.0.0", "camelcase": "^6.0.0", "deepmerge": "^4.2.2", diff --git a/packages/testing/package.json b/packages/testing/package.json index a11d26ee0a18..5fd29853c4ac 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,7 +1,7 @@ { "name": "@redwoodjs/testing", "description": "Tools, wrappers and configuration for testing a Redwood project.", - "version": "0.28.3", + "version": "0.28.4", "files": [ "dist" ], @@ -9,10 +9,10 @@ "types": "dist/index.d.ts", "license": "MIT", "dependencies": { - "@redwoodjs/auth": "^0.28.3", - "@redwoodjs/internal": "^0.28.3", - "@redwoodjs/router": "^0.28.3", - "@redwoodjs/web": "^0.28.3", + "@redwoodjs/auth": "^0.28.4", + "@redwoodjs/internal": "^0.28.4", + "@redwoodjs/router": "^0.28.4", + "@redwoodjs/web": "^0.28.4", "@testing-library/react": "11.2.2", "@types/react": "17.0.3", "msw": "^0.21.2" diff --git a/packages/web/package.json b/packages/web/package.json index 6159c6e5449d..066b98ef58e4 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@redwoodjs/web", - "version": "0.28.3", + "version": "0.28.4", "files": [ "dist", "apollo", @@ -12,7 +12,7 @@ "license": "MIT", "dependencies": { "@apollo/client": "^3.3.11", - "@redwoodjs/auth": "^0.28.3", + "@redwoodjs/auth": "^0.28.4", "core-js": "3.6.5", "graphql": "^15.3.0", "proptypes": "^1.1.0", From 665c556fae7908db85694f9b1327c82f10f6f00e Mon Sep 17 00:00:00 2001 From: David Price Date: Thu, 1 Apr 2021 19:08:30 -0700 Subject: [PATCH 23/25] update template yarn.lock v0.28.4 (#2179) --- .../create-redwood-app/template/yarn.lock | 166 +++++++++--------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/packages/create-redwood-app/template/yarn.lock b/packages/create-redwood-app/template/yarn.lock index 1eb7f3041419..dfddde584e64 100644 --- a/packages/create-redwood-app/template/yarn.lock +++ b/packages/create-redwood-app/template/yarn.lock @@ -1780,10 +1780,10 @@ tslib "^2.1.0" warning "^4.0.3" -"@redwoodjs/api-server@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/api-server/-/api-server-0.28.3.tgz#893988d0e18bbea6a5610c37d5c79cfa003c43c1" - integrity sha512-t9u5XqoM7r7BRVI7xTOn+TdQTY4fAGeu9wN/0zVqMbuYUiycz5z8GBk1zZD7/j1WjvzIH/XcWFMx/m2eQWz1pQ== +"@redwoodjs/api-server@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/api-server/-/api-server-0.28.4.tgz#6f7009eb0918d13fc3b4fc30dab28483717fb386" + integrity sha512-z2x42hW7T5NiNccwCN74kM5o7qVL/KIIVZimQFmfWWIOHGD0CxV85Hob1/cYFsgMUEdfVdX81r1/+F/v9g4E8g== dependencies: body-parser "^1.19.0" chokidar "3.5.1" @@ -1797,14 +1797,14 @@ youch "^2.1.1" youch-terminal "^1.0.1" -"@redwoodjs/api@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/api/-/api-0.28.3.tgz#0c9e3d8d970ecdebaa4860f29ac4a256d9aa00db" - integrity sha512-czNfX68T6++DNdO1ISV+dRPX7KGI2CuN4zpEZGDI4ug3IDzwt9kw5pcvp201l4lMhS/IINlYIAaqXyyB3Iywlw== +"@redwoodjs/api@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/api/-/api-0.28.4.tgz#224d7e8b4277d2a43d9a2e1ee2f4dcb07aa68bbf" + integrity sha512-fwX6fwd2huCk3S7DH5b9qHkVyyYkruMrYWDDBxCX642I8Q1oLNeoYn6YZo+SMKA9XbvSD9e77rxMGRqL9kliJw== dependencies: "@graphql-tools/merge" "6.2.10" "@prisma/client" "2.19.0" - "@redwoodjs/internal" "^0.28.3" + "@redwoodjs/internal" "^0.28.4" "@types/pino" "^6.3.6" apollo-server-lambda "2.22.2" core-js "3.6.5" @@ -1817,20 +1817,20 @@ pino "^6.11.1" pino-pretty "^4.7.0" -"@redwoodjs/auth@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/auth/-/auth-0.28.3.tgz#e23477061f8689841d856df96f76a4fc82adf2dc" - integrity sha512-PYWwQE+4kCp7NOnr26bs8bMU2A8DDLuntm7mRv45naefsK4nBsTxzfdHbOZ20OnosQEj5IT/5syiowWN1NKMXw== +"@redwoodjs/auth@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/auth/-/auth-0.28.4.tgz#47e26101eb4acf9134f2fe0d2a2aaa626071745d" + integrity sha512-jJACmtbpyUXX27c1R+wCuwZfWv1K7OOGPi0ulGYHR9iDBhnBIds4MbXlHsOJ0ij4T3sf8zxl8l/1Hu6iOAT7JA== -"@redwoodjs/cli@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/cli/-/cli-0.28.3.tgz#a9a9c975ee2a9119acc3ffdbd25d7611ccc761ad" - integrity sha512-rEqZYhS0n6nNpxBtX0Kbq7frigqMI3rjc5kkVdPSu5i8bcIWxGcSj7eImoj8106z12wr5mw4mopNO7NvLba6EQ== +"@redwoodjs/cli@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/cli/-/cli-0.28.4.tgz#6b0e8c26ed697b567dfbc876067431a99b17dc96" + integrity sha512-X+AgXhGahH/pTYtXfowB1goVGCF3V30V/nd2PYRQ/m5XXkT/9vPeZAyk8xWZJiert8WNavQQA3ag6EzTO060fw== dependencies: "@prisma/sdk" "2.19.0" - "@redwoodjs/internal" "^0.28.3" - "@redwoodjs/prerender" "^0.28.3" - "@redwoodjs/structure" "^0.28.3" + "@redwoodjs/internal" "^0.28.4" + "@redwoodjs/prerender" "^0.28.4" + "@redwoodjs/structure" "^0.28.4" boxen "^4.2.0" camelcase "^6.0.0" chalk "^4.1.0" @@ -1855,10 +1855,10 @@ terminal-link "^2.1.1" yargs "^16.0.3" -"@redwoodjs/core@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/core/-/core-0.28.3.tgz#61cc00d176d33d68249ba4ed1f5fc3510cd13fca" - integrity sha512-nSsMubOEv++sFsOEkXWAK9EpCXzQsBX0aenR8Xk6aRmn+1CEUCPxaR4jkjqk9nL7qBfqM2iswcCzdaEaY3NW5A== +"@redwoodjs/core@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/core/-/core-0.28.4.tgz#7002c5cb53c0281d71870febeea876c7c1906cf6" + integrity sha512-EVte9VSUugbCndtPrK7kuwsAOM3qEnPSgdPLBRmINeKSI3alxLVgK0kLXAwyteUp+Qg737bvyrqITRKehcwSNA== dependencies: "@babel/cli" "^7.11.6" "@babel/core" "^7.11.6" @@ -1870,11 +1870,11 @@ "@babel/preset-typescript" "^7.10.4" "@babel/runtime-corejs3" "^7.11.2" "@pmmmwh/react-refresh-webpack-plugin" "^0.4.3" - "@redwoodjs/cli" "^0.28.3" - "@redwoodjs/dev-server" "^0.28.3" - "@redwoodjs/eslint-config" "^0.28.3" - "@redwoodjs/internal" "^0.28.3" - "@redwoodjs/testing" "^0.28.3" + "@redwoodjs/cli" "^0.28.4" + "@redwoodjs/dev-server" "^0.28.4" + "@redwoodjs/eslint-config" "^0.28.4" + "@redwoodjs/internal" "^0.28.4" + "@redwoodjs/testing" "^0.28.4" "@storybook/addon-a11y" "^6.1.19" "@storybook/react" "^6.1.21" "@testing-library/jest-dom" "5.11.6" @@ -1923,13 +1923,13 @@ webpack-retry-chunk-load-plugin "^1.4.0" whatwg-fetch "^3.5.0" -"@redwoodjs/dev-server@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/dev-server/-/dev-server-0.28.3.tgz#f7fcf781aed13be3812827c5f61e53a045207695" - integrity sha512-cp2I4t+hLABanirVtW4nxjvWMzk/AUBM5Pq4H+XIN+yIwuCUB7MnQLWnNZK0DRZwk10Xz4gkVfR8YJV7XShJaQ== +"@redwoodjs/dev-server@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/dev-server/-/dev-server-0.28.4.tgz#569f0a338a74be829d8d9010731546bd1a8c2e67" + integrity sha512-q3joP66VKrpWRXk8FiRPQcAtXrM73V6jdKjj1Pt0CazuyvBxNCP6yQ80E9a7GhpkvK6kCjR9HWU/jggIU1BYFQ== dependencies: "@babel/register" "^7.9.0" - "@redwoodjs/internal" "^0.28.3" + "@redwoodjs/internal" "^0.28.4" body-parser "^1.19.0" chokidar "^3.4.3" express "^4.17.1" @@ -1940,12 +1940,12 @@ youch "^2.1.1" youch-terminal "^1.0.1" -"@redwoodjs/eslint-config@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-config/-/eslint-config-0.28.3.tgz#76a663288d92dda56aedbc2847b24a3d35433410" - integrity sha512-neuFMY9vlVxPUWHZxbp0bBrgh5uYbFSAUXHCrJ3xdoA6rcuk0Vn3s2on8o4Lp9fJRZhP8uwj4xf8Wp3rNnLu6w== +"@redwoodjs/eslint-config@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-config/-/eslint-config-0.28.4.tgz#53f14bbd2c909b53e89c24df5792d5058ee6312b" + integrity sha512-woFm/q15c64BMu+nb6ES09RdyJYSK2blG7EmdhIOeM1clAbktPuf2SvogmQq8k7Hm4/eEqqjULkf0nJb7ABAvw== dependencies: - "@redwoodjs/eslint-plugin-redwood" "^0.28.3" + "@redwoodjs/eslint-plugin-redwood" "^0.28.4" "@typescript-eslint/eslint-plugin" "^4.0.1" "@typescript-eslint/parser" "^4.0.1" babel-eslint "^10.1.0" @@ -1961,25 +1961,25 @@ eslint-plugin-react-hooks "^4.1.0" prettier "^2.1.1" -"@redwoodjs/eslint-plugin-redwood@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-plugin-redwood/-/eslint-plugin-redwood-0.28.3.tgz#5bf62c7b5c1d1d6b47f8f3a70d70dad2870f49f2" - integrity sha512-yORDCZ8qz5i0LpiRdUtmZ0JrqWYmdz3igEg0YnVIn3fgnQZgm6idilJqfPVB1TyJZ9FTwDzcGOMqWyfyfhtXEQ== +"@redwoodjs/eslint-plugin-redwood@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/eslint-plugin-redwood/-/eslint-plugin-redwood-0.28.4.tgz#a6125d84e79dabc04500ef3ac8736bccbe7bb35d" + integrity sha512-XWPzBXczdRHkRM0Lw9nfS3TSCSpUdVUi09XgdvQ21HwPIqLJcgmFMN/t7/1WG+9ExcYjDaglVGOJDawT1EYNGQ== -"@redwoodjs/forms@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/forms/-/forms-0.28.3.tgz#356ba7aa661d2101c14ea8897a07e96dc052b0f2" - integrity sha512-FxJEI8CAArcUK531FPqFEFPH3BvI+mLLKjU6jJTlg4w8c2IimSpptO3BQL4FginaWEXJy/c7OW/NAURoTZBjIg== +"@redwoodjs/forms@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/forms/-/forms-0.28.4.tgz#6f1893c72b911b4622ef2938b5b30fc7d095ccf3" + integrity sha512-/FYuXf5T1QZxmM6RmRe8evP7p4CPwYo8guLN+yrGA0TOvsGt8Mu/JHMRgFyDyw7WU6VX9+fTNtk5kBWqeYi/rg== dependencies: "@types/pascalcase" "^1.0.0" core-js "3.6.5" pascalcase "1.0.0" react-hook-form "^6.9.5" -"@redwoodjs/internal@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/internal/-/internal-0.28.3.tgz#a08887663ddfb588f6b89a98af9df907c8ab8b8f" - integrity sha512-M57+uSQZoOAZDunUFYxXX11jXh3F9v7UCZ2SZjDUkrG9hZBnPOHLQqzKcZTSvjTA3edKlgc8CmuqryhKLUQWFg== +"@redwoodjs/internal@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/internal/-/internal-0.28.4.tgz#bdb8c285577a7986742172af109687b273210690" + integrity sha512-j4eGg1C1v7T7NhqRdOF9v1SUSY9STBKsVFrSxAAG57y4A3w43Vf1XOycqS/pLOA3TNkiqGTUAjJaRpEbbwfAGA== dependencies: "@babel/plugin-transform-typescript" "^7.11.6" deepmerge "^4.2.2" @@ -1988,37 +1988,37 @@ kill-port "^1.6.1" toml "^3.0.0" -"@redwoodjs/prerender@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/prerender/-/prerender-0.28.3.tgz#0f3af9917575a18388a47c620c086a94f6a39490" - integrity sha512-QTZ7GzO6yXeQ3TavPpZbobghXPJPVxPSG5c6lpLzj5y4qXTF+xeNkRaijOc+5GMztk3cYcidG+usj9xHtzJ5Fg== +"@redwoodjs/prerender@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/prerender/-/prerender-0.28.4.tgz#ea12d907094541e98708540e20ee44838317b505" + integrity sha512-jybmq0TBUMj1cguMUVQWovAhNT/1FaVT92W8gPW0StXfuAt8xDmtUBEDOtbh/z2qJcroGgES60/pKxmSYV3O7g== dependencies: "@babel/register" "^7.9.0" - "@redwoodjs/auth" "^0.28.3" - "@redwoodjs/internal" "^0.28.3" - "@redwoodjs/router" "^0.28.3" - "@redwoodjs/structure" "^0.28.3" - "@redwoodjs/web" "^0.28.3" + "@redwoodjs/auth" "^0.28.4" + "@redwoodjs/internal" "^0.28.4" + "@redwoodjs/router" "^0.28.4" + "@redwoodjs/structure" "^0.28.4" + "@redwoodjs/web" "^0.28.4" babel-plugin-ignore-html-and-css-imports "^0.1.0" node-fetch "^2.6.1" -"@redwoodjs/router@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/router/-/router-0.28.3.tgz#e2b1856995ce3886d5a4bfba5e17922c8cbdd93c" - integrity sha512-Kss7mDYSrayMqIETGevOKYW1p7tdKgYJpAR1W6cJfgTWqVBv+WMqPVCbSD88VmkFQDc8SLVUUolNEPZGqGpV4Q== +"@redwoodjs/router@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/router/-/router-0.28.4.tgz#fd0d9ce7bdbf2af512718b8e6c9955ca1642815b" + integrity sha512-skMbYSlD8Opdr/YrAt9C4WDuuhbezq06N8HL3Bm7Uh7fIsLqC7NrA8xwhhkfn9fU6Uhy66Jimx/YslCGikHlvw== dependencies: "@reach/skip-nav" "^0.13.2" - "@redwoodjs/auth" "^0.28.3" + "@redwoodjs/auth" "^0.28.4" core-js "3.6.5" lodash.isequal "^4.5.0" -"@redwoodjs/structure@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/structure/-/structure-0.28.3.tgz#c7651ee1055940cbedeec2f051344cc6a3a83e6a" - integrity sha512-ocLfj5lYcVbHLoIpzBKm/7SDsMympruKv6iLQVFv44kqphJ/oaHgGZARj/9ddNYAhMmp+UdDJHFXPCjF3Sjy5A== +"@redwoodjs/structure@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/structure/-/structure-0.28.4.tgz#b68cb5238545ca175d0f857fefbb32ddd8a7411e" + integrity sha512-XWaCpoLE35TyBztji5DVp63d1Go8IJ3WgxGyZBBuGijSz7Ox3nZhsV3elbHLL7WCm7lvFisZS2fstvupZ0ij9g== dependencies: "@prisma/sdk" "2.19.0" - "@redwoodjs/internal" "^0.28.3" + "@redwoodjs/internal" "^0.28.4" "@types/line-column" "^1.0.0" camelcase "^6.0.0" deepmerge "^4.2.2" @@ -2039,26 +2039,26 @@ vscode-languageserver-types "3.15.1" yargs-parser "^18.1.3" -"@redwoodjs/testing@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/testing/-/testing-0.28.3.tgz#545cd1d889bf9834caec56f44bbc2863cac85655" - integrity sha512-FAir8ssWzKOBNXKRWOeBbX3G8dc59K2Bo8R1rQAgndsvr/6mNp4Sg7kR4TG9WFv3MP5ZVm3YY/83nmTnXirAyQ== +"@redwoodjs/testing@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/testing/-/testing-0.28.4.tgz#5ef22f8429255d4da26e5b874838f81e7765c879" + integrity sha512-UpPR3H4gDML6g2EpqErQcXhf8sHDUgLBiBQ8fn8xwQCuGPFdnph9xp2o0pLQDLt7IdsfWBFAJ3XVV9KZkCQqcA== dependencies: - "@redwoodjs/auth" "^0.28.3" - "@redwoodjs/internal" "^0.28.3" - "@redwoodjs/router" "^0.28.3" - "@redwoodjs/web" "^0.28.3" + "@redwoodjs/auth" "^0.28.4" + "@redwoodjs/internal" "^0.28.4" + "@redwoodjs/router" "^0.28.4" + "@redwoodjs/web" "^0.28.4" "@testing-library/react" "11.2.2" "@types/react" "17.0.3" msw "^0.21.2" -"@redwoodjs/web@^0.28.3": - version "0.28.3" - resolved "https://registry.yarnpkg.com/@redwoodjs/web/-/web-0.28.3.tgz#ab9ba12928273898bc6ce135807c29e517cd6034" - integrity sha512-wWgGUE04ljaDkgwajY8pmih8UL7fNZlrJQbjG8Gi6kJyp2rDJ37+DDNP2yNGMSTr/szUPkoriLaJmZ1ahMyeJA== +"@redwoodjs/web@^0.28.4": + version "0.28.4" + resolved "https://registry.yarnpkg.com/@redwoodjs/web/-/web-0.28.4.tgz#201486ad93d2eaa3bea31f5f24e2549743495bf8" + integrity sha512-pTI3bpvDfJGn8GO1xoNUxAax/V7Zzd5JM8M9CCGQhvYxqxdPds5pLZbNRfI75uVQkn9t8Rufs1kcMPi7pfbleQ== dependencies: "@apollo/client" "^3.3.11" - "@redwoodjs/auth" "^0.28.3" + "@redwoodjs/auth" "^0.28.4" core-js "3.6.5" graphql "^15.3.0" proptypes "^1.1.0" From 45667fe2fdbfa742f1ed8e50b378c4a3d606b90c Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Fri, 2 Apr 2021 17:42:15 +0100 Subject: [PATCH 24/25] Fix rwt link performance issues (#2200) * Remove build:link from packages * Update build-link to use single watcher * Remove empty spaces from package.json * Update rwt to use new way to invoke build-link * Pass only flag from rwt link * Also check files on yarn install during link --- package.json | 2 +- packages/api-server/package.json | 1 - packages/api/package.json | 1 - packages/auth/package.json | 1 - packages/cli/package.json | 1 - packages/cli/src/redwood-tools.js | 29 +++- packages/core/package.json | 1 - packages/dev-server/package.json | 1 - packages/eslint-config/package.json | 1 - packages/eslint-plugin-redwood/package.json | 1 - packages/forms/package.json | 1 - packages/internal/package.json | 1 - packages/prerender/package.json | 1 - packages/router/package.json | 1 - packages/structure/package.json | 1 - packages/testing/package.json | 1 - packages/web/package.json | 1 - tasks/build-link | 183 ++++++++++++++------ 18 files changed, 147 insertions(+), 82 deletions(-) diff --git a/package.json b/package.json index 0517e98d8c6f..e29c78137cc9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "build:types": "ttsc --build --verbose", "build:clean": "rimraf ./packages/**/dist", "build:watch": "lerna run build:watch --parallel; ttsc --build", - "build:link": "lerna run 'build:link' --parallel", + "build:link": "./tasks/build-link", "test": "lerna run test --stream -- --colors --maxWorkers=4", "lint": "cross-env __REDWOOD__CONFIG_PATH=packages/create-redwood-app/template eslint -c .eslintrc.js packages", "lint:fix": "cross-env __REDWOOD__CONFIG_PATH=packages/create-redwood-app/template eslint -c .eslintrc.js --fix packages" diff --git a/packages/api-server/package.json b/packages/api-server/package.json index 535dac642394..59959c512fd7 100644 --- a/packages/api-server/package.json +++ b/packages/api-server/package.json @@ -37,7 +37,6 @@ "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build && yarn fix:permissions\"", - "build:link": "../../tasks/build-link", "fix:permissions": "chmod +x dist/index.js; chmod +x dist/watch.js" }, "gitHead": "c235e7d7186e5e258764699c0e0e1d5cc0fdd0b5" diff --git a/packages/api/package.json b/packages/api/package.json index 013d1bf85242..9023d5d31954 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -43,7 +43,6 @@ "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", - "build:link": "../../tasks/build-link", "test": "jest", "test:watch": "yarn test --watch" }, diff --git a/packages/auth/package.json b/packages/auth/package.json index 9716385cd167..994ba5a7041f 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -25,7 +25,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/cli/package.json b/packages/cli/package.json index 234ed6b65a43..be66e9814b27 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -50,7 +50,6 @@ "prepublishOnly": "yarn build", "build:clean-dist": "yarn rimraf 'dist/**/*/__tests__'", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\" --copy-files --no-copy-ignored && yarn build:clean-dist", - "build:link": "../../tasks/build-link", "fix:permissions": "chmod +x dist/index.js dist/redwood-tools.js", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build && yarn fix:permissions\"", "test": "jest", diff --git a/packages/cli/src/redwood-tools.js b/packages/cli/src/redwood-tools.js index b763df52a0aa..685bda8374ec 100644 --- a/packages/cli/src/redwood-tools.js +++ b/packages/cli/src/redwood-tools.js @@ -141,7 +141,7 @@ const rwtCopyWatch = ({ RW_PATH = process.env.RW_PATH }) => { const rwtLink = async (yargs) => { const RW_PATH = yargs.RW_PATH || process.env.RW_PATH - const { clean, watch } = yargs + const { clean, watch, only } = yargs if (!RW_PATH) { console.error(c.error('You must specify a path to your local redwood repo')) @@ -195,15 +195,21 @@ const rwtLink = async (yargs) => { // Delete existing redwood folders in node_modules rimraf.sync(path.join(getPaths().base, 'node_modules/@redwoodjs/')) - await execa('yarn build:link', ['-- --', '--dest', projectPackagesPath], { - shell: true, - stdio: 'inherit', - cleanup: true, - cwd: frameworkPath, - }) + const onlyParams = only ? ['--only', only] : [] + + await execa( + 'yarn build:link', + ['--dest', projectPackagesPath, ...onlyParams], + { + shell: true, + stdio: 'inherit', + cleanup: true, + cwd: frameworkPath, + } + ) // Let workspaces do the link - await execa('yarn install', ['--pure-lockfile'], { + await execa('yarn install', ['--pure-lockfile', '--check-files'], { shell: true, stdio: 'inherit', cleanup: true, @@ -229,7 +235,7 @@ const rwtLink = async (yargs) => { // Restart build:link scripts in watchmode execa( 'yarn build:link', - ['-- --', '--dest', projectPackagesPath, '--watch'], + ['--dest', projectPackagesPath, '--watch', ...onlyParams], { shell: true, stdio: 'inherit', @@ -400,6 +406,11 @@ yargs description: 'Build and watch the supplied redwood repo', default: true, }) + .option('only', { + alias: 'only', + type: 'string', + description: 'Specify folder to link from RW_PATH/packages', + }) }, desc: 'Run your local version of redwood in this project', handler: rwtLink, diff --git a/packages/core/package.json b/packages/core/package.json index ae862f99db75..1cc6d2694433 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -86,7 +86,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index 91b0a12e3f3d..bc98396774bd 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -34,7 +34,6 @@ "build": "yarn build:js", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build && yarn fix:permissions\"", "fix:permissions": "chmod +x dist/main.js" }, diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index ddba8376e839..270bcdb8a10f 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -21,7 +21,6 @@ "prettier": "^2.1.1" }, "scripts": { - "build:link": "../../tasks/build-link", "build": "echo 'Nothing to build..'" }, "gitHead": "c235e7d7186e5e258764699c0e0e1d5cc0fdd0b5" diff --git a/packages/eslint-plugin-redwood/package.json b/packages/eslint-plugin-redwood/package.json index b05b77a48cd0..23a001e86db9 100644 --- a/packages/eslint-plugin-redwood/package.json +++ b/packages/eslint-plugin-redwood/package.json @@ -14,7 +14,6 @@ "build": "yarn build:js", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist", - "build:link": "../../tasks/build-link", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build\"" } } diff --git a/packages/forms/package.json b/packages/forms/package.json index d7c516a8428f..9e9858ad0380 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -18,7 +18,6 @@ "build": "yarn build:js", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", "test:watch": "yarn test --watch" diff --git a/packages/internal/package.json b/packages/internal/package.json index eb8d4a5095f9..c2339d2c282d 100644 --- a/packages/internal/package.json +++ b/packages/internal/package.json @@ -27,7 +27,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/prerender/package.json b/packages/prerender/package.json index 8f38d06c0864..fbd399339902 100644 --- a/packages/prerender/package.json +++ b/packages/prerender/package.json @@ -26,7 +26,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx,.jsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx,template\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/router/package.json b/packages/router/package.json index e903109b8d24..0cd1c858b493 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -23,7 +23,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/structure/package.json b/packages/structure/package.json index 0f5142e1c812..44f2cee42b99 100644 --- a/packages/structure/package.json +++ b/packages/structure/package.json @@ -48,7 +48,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/packages/testing/package.json b/packages/testing/package.json index 5fd29853c4ac..bf39f5ef919a 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -21,7 +21,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext 'js,ts,tsx' --ignore dist --exec 'yarn build'", "test": "jest", diff --git a/packages/web/package.json b/packages/web/package.json index 066b98ef58e4..b927067231ee 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -28,7 +28,6 @@ "build": "yarn build:js && yarn build:types", "prepublishOnly": "yarn cross-env NODE_ENV=production yarn build", "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"", - "build:link": "../../tasks/build-link", "build:types": "ttsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "test": "jest", diff --git a/tasks/build-link b/tasks/build-link index 53f7f2b110b5..ba348b29ec17 100755 --- a/tasks/build-link +++ b/tasks/build-link @@ -1,6 +1,6 @@ #!/usr/bin/env node /* eslint-env node, es6*/ - +//@ts-check const fs = require('fs') const path = require('path') @@ -14,91 +14,160 @@ const yargs = require('yargs') const args = yargs .option('watch', { default: false, type: 'boolean', alias: 'w' }) .option('dest', { required: true, type: 'string', alias: 'd' }) - .command('build-link') - .example('build-link --dest /tmp/redwood-app/packages') + .option('only', { required: false, type: 'string', alias: 'o' }) + // .command('build-link') + // .example('build-link --dest /tmp/redwood-app/packages') .help() .strict().argv -const { dest, watch } = args +const { dest, watch, only } = args -const CURRENT_DIR = process.cwd() -const pkgJson = require(path.join(CURRENT_DIR, 'package.json')) -const OUT_DIR = path.join(dest, `/${pkgJson.name.replace('@redwoodjs/', '')}`) +const RW_BASEPATH = path.join(__dirname, '../') -const srcFiles = glob - .sync('src/**/*.{ts,js,tsx,jsx,json}', { - cwd: CURRENT_DIR, - ignore: [ - '**/*.test.ts', - '**/*.test.js', - '**/__fixtures__/**', - '**/__tests__/**', - ], +const packagePaths = glob + .sync('packages/*', { + cwd: RW_BASEPATH, }) - .map((filePath) => `./${filePath}`) + .filter((packagePath) => (only ? packagePath.includes(only) : true)) + .filter((packageName) => !packageName.includes('create-redwood-app')) -const buildAndCopy = () => - execa('yarn build', { +const buildAllTypes = () => + execa('yarn build:types', { shell: true, stdio: 'inherit', cleanup: true, - cwd: CURRENT_DIR, - }).then(() => { - if ('bin' in pkgJson) { - // Chmod if package has bins - execa('yarn fix:permissions', { - cwd: CURRENT_DIR, - }) - } - return packlist({ path: CURRENT_DIR }).then((files) => { - files.forEach((file) => { - copyToDest(file, OUT_DIR) - }) - return files - }) + cwd: RW_BASEPATH, }) +const build = async ({ packageFolderName, types }) => { + const execaOptionsForBase = { + shell: true, + stdio: 'inherit', + cleanup: true, + cwd: RW_BASEPATH, + } + + await execa( + 'yarn lerna run', + [ + types ? 'build' : 'build:js', + '--parallel', + packageFolderName && `--scope @redwoodjs/${packageFolderName}`, + ], + execaOptionsForBase + ) + + return execa( + 'yarn lerna run', + [ + 'fix:permissions', + '--parallel', + packageFolderName && `--scope @redwoodjs/${packageFolderName}`, + ], + execaOptionsForBase + ) +} + +const copyDistFiles = ({ packageFolderName }) => { + return Promise.all( + packagePaths + // Only copy things in the package specified by --only + // If not, run it for all packages + .filter((packagePath) => + packageFolderName ? packagePath.includes(packageFolderName) : true + ) + .map((packagePath) => { + const pkgJson = require(path.join( + RW_BASEPATH, + packagePath, + 'package.json' + )) + + return packlist({ path: packagePath }).then((files) => { + const destinationDir = path.join( + dest, + `/${pkgJson.name.replace('@redwoodjs/', '')}` + ) + + files.forEach((file) => { + copyPackageFileToDest(packagePath, file, destinationDir) + }) + return files + }) + }) + ) +} + // Creates folders where required, before copying -const copyToDest = (src, dest) => { - const dirName = path.dirname(path.join(dest, `/${src}`)) - const fileName = path.basename(src) +const copyPackageFileToDest = (packagePath, relativeSrc, dest) => { + const dirName = path.dirname(path.join(dest, `/${relativeSrc}`)) + const fileName = path.basename(relativeSrc) const exist = fs.existsSync(dirName) if (!exist) { fs.mkdirSync(dirName, { recursive: true }) } - fs.copyFileSync(src, path.join(dirName, fileName)) + fs.copyFileSync( + path.join(RW_BASEPATH, packagePath, relativeSrc), + path.join(dirName, fileName) + ) } // Assigned if watch is true let watchHandle process.on('SIGINT', () => { - watchHandle?.cancel() + watchHandle?.close() }) +const runAsync = async () => { + // STEP 1: Run build:types from root of framework + + if (!only) { + await buildAllTypes() + } + // STEP 2: Run yarn lerna run build --parallel, ignore types as they've just been built + await build({ + packageFolderName: only, + types: only ? true : false, + }) + + await copyDistFiles({ + packageFolderName: only, + }) +} + +const onChange = _.debounce((packageFolderName) => { + console.log('Building 📦', packageFolderName) + build({ packageFolderName, types: true }) + copyDistFiles({ packageFolderName }) +}, 200) + // @Note: // --watch flag starts the watcher, but won't build until change detected +const packageNameRegex = /^^packages\/(\w+-?\w*)\/?/ + if (watch) { - // Start watcher - packlist({ path: CURRENT_DIR }).then((files) => { - const filesToWatch = [ - ...srcFiles, - ...files.filter((fileName) => !fileName.match('dist/')), - ] - - watchHandle = chokidar - .watch(filesToWatch, { - persistent: true, - }) - .on( - 'change', - _.debounce(() => { - buildAndCopy() - }, 500) - ) - }) + // Start watcher for packages/*, ignore dist + // if file changed in package/{packageName}, run build and copy for packageName + + watchHandle = chokidar + .watch(packagePaths, { + persistent: true, + ignored: [ + '**/*.test.ts', + '**/*.test.js', + '**/__fixtures__/**', + '**/__tests__/**', + '**/dist/**', + ], + }) + .on('change', (fileName) => { + const dirName = path.dirname(fileName) + const packageFolderName = packageNameRegex.exec(dirName)[1] + onChange(packageFolderName) + }) } else { - buildAndCopy() + runAsync() } From 46427975c0a546435d6d574413b363d78432a881 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Fri, 2 Apr 2021 18:22:07 +0100 Subject: [PATCH 25/25] Improved types | Handling for Boolean and Float route params (#2177) * Improved types | Handling for Boolean and Float route params * Match case * Update regex for float and bool * Fix type RouteParams for nested params * Add test for nested parsed params * Fix typo --- ...babel-plugin-redwood-routes-auto-loader.ts | 8 +- packages/router/src/__tests__/util.test.ts | 89 ++++++++++++++++++- packages/router/src/index.ts | 8 +- packages/router/src/util.ts | 24 +++-- 4 files changed, 117 insertions(+), 12 deletions(-) diff --git a/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts b/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts index 933f48ce40b4..99fb990b1694 100644 --- a/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts +++ b/packages/core/src/babelPlugins/babel-plugin-redwood-routes-auto-loader.ts @@ -11,8 +11,11 @@ interface PluginOptions { useStaticImports?: boolean } +// Use ' because I don't want to escape ` const RouteParameterTypeParser = - 'type ParseRouteParameters = Route extends `${string}/{${infer Param}:${string}}/${infer Rest}` ? { [Entry in Param | keyof ParseRouteParameters<`/${Rest}`>]: string } : Route extends `${string}/{${infer Param}:${string}}` ? { [Entry in Param]: string } : Route extends `${string}/{${infer Param}}` ? { [Entry in Param]: string } : Record' + 'type ParamType = constraint extends "Int" ? number : constraint extends "Boolean" ? boolean : constraint extends "Float" ? number : string;' + + '\n' + + 'type RouteParams = Route extends `${string}/{${infer Param}:${infer Constraint}}/${infer Rest}` ? { [Entry in Param]: ParamType } & RouteParams<`/${Rest}`> : Route extends `${string}/{${infer Param}:${infer Constraint}}` ? { [Entry in Param]: ParamType } : Route extends `${string}/{${infer Param}}/${infer Rest}` ? { [Entry in Param]: string } & RouteParams<`/${Rest}`> : {}' export default function ( { types: t }: { types: typeof types }, @@ -66,7 +69,7 @@ export default function ( .routes.filter((r) => !r.isNotFound) .map( (r) => - `${r.name}: (params?: ParseRouteParameters<"${r.path}">) => "${r.path}"` + `${r.name}: (params?: RouteParams<"${r.path}"> & QueryParams) => "${r.path}"` ) const pageImports = pages.map( @@ -80,6 +83,7 @@ export default function ( import '@redwoodjs/router' ${RouteParameterTypeParser} + type QueryParams = Record declare module '@redwoodjs/router' { interface AvailableRoutes { diff --git a/packages/router/src/__tests__/util.test.ts b/packages/router/src/__tests__/util.test.ts index adabc33698c6..e8dab5fa1b9a 100644 --- a/packages/router/src/__tests__/util.test.ts +++ b/packages/router/src/__tests__/util.test.ts @@ -27,7 +27,7 @@ describe('matchPath', () => { ).toEqual({ match: true, params: { day: '07', month: '12', year: '2019' } }) }) - it('transforms a param based on the specified transform', () => { + it('transforms a param for Int', () => { expect(matchPath('/post/{id}', '/post/1337')).toEqual({ match: true, params: { id: '1337' }, @@ -38,6 +38,93 @@ describe('matchPath', () => { params: { id: 1337 }, }) }) + + it('transforms a param for Boolean', () => { + expect(matchPath('/signedUp/{status:Boolean}', '/signedUp/true')).toEqual({ + match: true, + params: { + status: true, + }, + }) + + expect(matchPath('/signedUp/{status:Boolean}', '/signedUp/false')).toEqual({ + match: true, + params: { + status: false, + }, + }) + + expect( + matchPath('/signedUp/{status:Boolean}', '/signedUp/somethingElse') + ).toEqual({ + match: false, + }) + }) + + it('transforms a param for Floats', () => { + expect( + matchPath('/version/{floatyMcFloat:Float}', '/version/1.58') + ).toEqual({ + match: true, + params: { + floatyMcFloat: 1.58, + }, + }) + + expect(matchPath('/version/{floatyMcFloat:Float}', '/version/626')).toEqual( + { + match: true, + params: { + floatyMcFloat: 626, + }, + } + ) + + expect( + matchPath('/version/{floatyMcFloat:Float}', '/version/+0.92') + ).toEqual({ + match: true, + params: { + floatyMcFloat: 0.92, + }, + }) + + expect( + matchPath('/version/{floatyMcFloat:Float}', '/version/-5.5') + ).toEqual({ + match: true, + params: { + floatyMcFloat: -5.5, + }, + }) + + expect(matchPath('/version/{floatyMcFloat:Float}', '/version/4e8')).toEqual( + { + match: true, + params: { + floatyMcFloat: 4e8, + }, + } + ) + + expect( + matchPath('/version/{floatyMcFloat:Float}', '/version/noMatchMe') + ).toEqual({ + match: false, + }) + }) + + it('handles multiple typed params', () => { + expect( + matchPath( + '/dashboard/document/{id:Int}/{version:Float}/edit/{edit:Boolean}', + '/dashboard/document/44/1.8/edit/false' + ) + ).toEqual({ + match: true, + params: { id: 44, version: 1.8, edit: false }, + }) + }) }) describe('validatePath', () => { diff --git a/packages/router/src/index.ts b/packages/router/src/index.ts index 556674efd446..2847a2f2c826 100644 --- a/packages/router/src/index.ts +++ b/packages/router/src/index.ts @@ -31,13 +31,15 @@ export * from './route-announcement' * * @example * interface AvailableRoutes { - * home: (params?: ParseRouteParameters<"/">) => "/" - * post: (params?: ParseRouteParameters<"/posts/{id:Int}">) => "/posts/{id:Int}" + * home: (params?: RouteParams<"/">) => "/" + * post: (params?: RouteParams<"/posts/{id:Int}">) => "/posts/{id:Int}" * } */ // Keep this in index.ts so it can be extended with declaration merging export interface AvailableRoutes { - [key: string]: (args?: Record) => string + [key: string]: ( + args?: Record + ) => string } export { SkipNavLink, SkipNavContent } from '@reach/skip-nav' diff --git a/packages/router/src/util.ts b/packages/router/src/util.ts index 2e5d5592ed82..af0ed1379a70 100644 --- a/packages/router/src/util.ts +++ b/packages/router/src/util.ts @@ -31,13 +31,23 @@ export interface ParamType { } /** Definitions of the core param types. */ -const coreParamTypes: Record = { +const coreParamTypes = { Int: { constraint: /\d+/, transform: Number, }, + Float: { + constraint: /[-+]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/, + transform: Number, + }, + Boolean: { + constraint: /true|false/, + transform: (boolAsString: string) => boolAsString === 'true', + }, } +type SupportedRouterParamTypes = keyof typeof coreParamTypes + /** * Determine if the given route is a match for the given pathname. If so, * extract any named params and return them in an object. @@ -70,12 +80,14 @@ const matchPath = ( // Map all params from the route to their type constraint regex to create a "type-constrained route" regexp for (const [name, type] of routeParams) { let typeRegex = '[^/]+' - const constraint = type && allParamTypes[type].constraint + // Undefined constraint if not supported + // So leaves it as string + const constraint = + type && allParamTypes[type as SupportedRouterParamTypes]?.constraint if (constraint) { - // Get the type - typeRegex = constraint.toString() || '/[^/]+/' - typeRegex = typeRegex.substring(1, typeRegex.length - 1) + // Get the regex as a string + typeRegex = constraint.source || '[^/]+' } typeConstrainedRoute = typeConstrainedRoute.replace( @@ -98,7 +110,7 @@ const matchPath = ( const params = providedParams.reduce>( (acc, value, index) => { const [name, transformName] = routeParams[index] - const typeInfo = allParamTypes[transformName] + const typeInfo = allParamTypes[transformName as SupportedRouterParamTypes] let transformedValue: string | unknown = value if (typeInfo && typeof typeInfo.transform === 'function') {