Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/graphql…
Browse files Browse the repository at this point in the history
…-codegen

* 'main' of github.com:redwoodjs/redwood:
  Removes console warnings in webhook verifiers (redwoodjs#2563)
  build(deps): bump eslint from 7.26.0 to 7.27.0 (redwoodjs#2610)
  CONTRIBUTING.md: styling tweaks for improved readability and consistency (redwoodjs#2608)
  build(deps): bump esbuild from 0.11.21 to 0.12.1 (redwoodjs#2579)
  Cache magic.link's token  (redwoodjs#2555)
  build(deps): bump @babel/plugin-transform-runtime from 7.14.2 to 7.14.3 (redwoodjs#2603)
  build(deps): bump @types/node from 15.3.1 to 15.6.0 (redwoodjs#2601)
  eslint-plugin-import 2.23.2 with lint fixes (redwoodjs#2604)
  build(deps): bump @apollo/client from 3.3.18 to 3.3.19 (redwoodjs#2576)
  build(deps): bump apollo-server-lambda from 2.22.2 to 2.24.1 (redwoodjs#2580)
  build(deps): bump babel-plugin-graphql-tag from 3.2.0 to 3.3.0 (redwoodjs#2600)
  build(deps): bump @babel/cli from 7.13.16 to 7.14.3 (redwoodjs#2578)
  build(deps-dev): bump @types/lodash from 4.14.169 to 4.14.170 (redwoodjs#2597)
  build(deps-dev): bump @types/findup-sync from 2.0.2 to 4.0.0 (redwoodjs#2574)
  Aggregate Dependabot misc patch minor upgrades (redwoodjs#2596)
  CONTRIBUTING.md: add missing char (redwoodjs#2594)
  changes test command instructions to reference run-e2e instead of test-tutorial (redwoodjs#2593)
  • Loading branch information
dac09 committed May 24, 2021
2 parents af6c749 + b9b5a7a commit 2a14dd2
Show file tree
Hide file tree
Showing 64 changed files with 488 additions and 642 deletions.
49 changes: 32 additions & 17 deletions CONTRIBUTING.md
Expand Up @@ -15,6 +15,9 @@ Before interacting with the Redwood community, please read and understand our [C
- [Copy and Watch](#copy-and-watch)
- [cp](#cp)
- [Specifying a RW_PATH](#specifying-a-rw_path)
- [On **Linux**](#on-linux)
- [On **MacOS**](#on-macos)
- [On **Windows**](#on-windows)
- [Local Package Registry Emulation](#local-package-registry-emulation)
- [Running a Local NPM Registry](#running-a-local-npm-registry)
- [Publishing a Package](#publishing-a-package)
Expand All @@ -29,14 +32,15 @@ Before interacting with the Redwood community, please read and understand our [C
- [copy:watch (cpw)](#copywatch-cpw)
- [fix-bins (fix)](#fix-bins-fix)
- [install (i)](#install-i)
- [link](#link)

## Local Development

### Code Organization

As a Redwood user, you're already familiar with the codebase created by `yarn create redwood-app`. In this document, we'll refer to that codebase as a 'Redwood App'. As a contributor, you'll have to gain familiarity with another codebase: the Redwood Framework.

The Redwood Framework lives in the monorepo redwoodjs/redwood (which is where you're probably reading this). It contains all the packages that make Redwood Apps work the way they do. In a typical Redwood App, you can find the Redwood Framework in `./node_modules/@redwoodjs`.
The Redwood Framework lives in the monorepo `redwoodjs/redwood` (which is where you're probably reading this). It contains all the packages that make Redwood Apps work the way they do. In a typical Redwood App, you can find the Redwood Framework in `./node_modules/@redwoodjs`.

Throughout this document, we'll assume your local copy of the Redwood Framework is in a directory called `redwood` and your Redwood App is in a directory called `redwood-app`.

Expand Down Expand Up @@ -175,7 +179,7 @@ Then, you can restore your Redwood App to its original state by deleting `./node

If you are on Windows and not using WSL, you will have to use `rwt cp` (this is tracked in [issue #701](https://github.com/redwoodjs/redwood/issues/701)). This method, unfortunately, will not let you see your changes live.

Also, you most likely first have to [install rsync](https://tlundberg.com/blog/2020-06-15/installing-rsync-on-windows/).
Also, you most likely first have to [install `rsync`](https://tlundberg.com/blog/2020-06-15/installing-rsync-on-windows/).

Each time you make a change to your local Redwood Framework, you'll have to build it:

Expand All @@ -199,15 +203,15 @@ When you're done, you can restore your Redwood App to its original state by dele

You can avoid having to provide the path to `redwood` by defining an `RW_PATH` environment variable on your system.

_On Linux_
##### On **Linux**

Add the following line to your `~/.bashrc`:

```terminal
export RW_PATH=”$HOME/path/to/redwood/framework”
```

Where /path/to/redwood/framework is replaced by the path to your local copy of the Redwood Framework.
Where `/path/to/redwood/framework` is replaced by the path to your local copy of the Redwood Framework.

Then, in your Redwood App or example app, you can just run:

Expand All @@ -221,15 +225,15 @@ or
yarn rwt copy:watch
```

_On Mac_
##### On **MacOS**

Add the following line to your `~/.bash_profile`:

```terminal
export RW_PATH=”$HOME/path/to/redwood/framework”
```

Where /path/to/redwood/framework is replaced by the path to your local copy of the Redwood Framework.
Where `/path/to/redwood/framework` is replaced by the path to your local copy of the Redwood Framework.

Then, in your Redwood App or example app, you can just run:

Expand All @@ -243,19 +247,21 @@ or
yarn rwt copy:watch
```

_On Windows_
##### On **Windows**

[Todo: please contribute a PR if you can help.]
> **TODO**
>
> please contribute a PR if you can help.
### Local Package Registry Emulation

Sometimes you'll want to test the full package-development workflow: building, publishing, and installing all the packages in your local copy of the Redwood Framework in your Redwood App. We accomodate this using a local NPM registry called [Verdaccio](https://github.com/verdaccio/verdaccio).
Sometimes you'll want to test the full package-development workflow: building, publishing, and installing all the packages in your local copy of the Redwood Framework in your Redwood App. We accommodate this using a local NPM registry called [**Verdaccio**](https://github.com/verdaccio/verdaccio).

You might also have to use this workflow if you've installed or upgraded one of Redwood's dependencies.

#### Running a Local NPM Registry

First, install Verdaccio:
First, install `Verdaccio`:

```terminal
yarn global add verdaccio
Expand All @@ -267,7 +273,7 @@ Then, in your local copy of the Redwood Framework, run:
./tasks/run-local-npm
```

This starts Verdaccio (http://localhost:4873) with our configuration file.
This starts `Verdaccio` (on http://localhost:4873) with our configuration file.

#### Publishing a Package

Expand Down Expand Up @@ -323,14 +329,14 @@ yarn rw dev web
We're using Cypress to test the steps that we recommend in the tutorial. Run the command by doing the following:

```terminal
./tasks/test-tutorial
./tasks/run-e2e
```

This creates a new project in a tmp directory using `yarn create redwood-app ...` Once installed, it then upgrades the project to the most recent `canary` release, which means it will use the current code in the `main` branch. Once the upgrade is complete (and successful), it will start Cypress for the E2E tests.
This creates a new project in a temporary directory using `yarn create redwood-app ...` Once installed, it then upgrades the project to the most recent `canary` release, which means it will use the current code in the `main` branch. Once the upgrade is complete (and successful), it will start Cypress for the E2E tests.


```terminal
./tasks/test-tutorial /path/to/app
./tasks/run-e2e /path/to/app
```

Use this `path/to/app` option to run the same Cypress E2E tests against a local project. In this case, the command will _not_ upgrade the project to the `canary` release — it will use the project's installed packages. Chose this option if you have modified code (and packages) you want to test locally.
Expand All @@ -355,15 +361,22 @@ yarn build
yarn lerna publish from-package
```

This 1) changes the version of **all the packages** (even those that haven't changed), 2) changes the version of the packages within the CRWA Template, 3) Commits, Tags, and Pushes to GH, and 4) publishes all packages to NPM.
This...
1) changes the version of **all the packages** (even those that haven't changed),
2) changes the version of the packages within the CRWA Template
3) Commits, Tags, and Pushes to GH
4) and finally publishes all packages to NPM.

### Troubleshooting

If something went wrong you can use `yarn lerna publish from-package` to publish the packages that aren't already in the registry.

## CLI Reference: `redwood-tools`

This CLI Reference section covers the `redwood-tools` command options. For `redwood` options, see the [CLI Reference on redwoodjs.com](https://redwoodjs.com/reference/command-line-interface).

> This section covers the `redwood-tools` command options.
>
> For `redwood` options, see the [CLI Reference on redwoodjs.com](https://redwoodjs.com/reference/command-line-interface).
### redwood-tools (rwt)

Expand Down Expand Up @@ -437,4 +450,6 @@ Link the Redwood Framework path to this project and watch it for changes.
yarn rwt link [RW_PATH]
```

You can avoid having to provide `RW_PATH` by defining an environment variable on your system. See [Specifying a `RW_PATH`](#specifying-a-rw_path).
You can avoid having to provide `RW_PATH` by defining an environment variable on your system. See
[Specifying a `RW_PATH`](#specifying-a-rw_path).

8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -17,12 +17,12 @@
"packages/*"
],
"devDependencies": {
"@babel/cli": "7.13.16",
"@babel/core": "7.14.2",
"@babel/cli": "7.14.3",
"@babel/core": "7.14.3",
"@babel/node": "7.14.2",
"@babel/plugin-proposal-class-properties": "7.13.0",
"@babel/plugin-proposal-decorators": "7.14.2",
"@babel/plugin-transform-runtime": "7.14.2",
"@babel/plugin-transform-runtime": "7.14.3",
"@babel/preset-env": "7.14.2",
"@babel/preset-react": "7.13.13",
"@babel/preset-typescript": "7.13.0",
Expand All @@ -46,7 +46,7 @@
"rimraf": "^3.0.2",
"ttypescript": "^1.5.12",
"typescript": "^4.2.4",
"typescript-transform-paths": "^2.2.3",
"typescript-transform-paths": "^2.2.4",
"whatwg-fetch": "3.4.1"
},
"resolutions": {
Expand Down
3 changes: 1 addition & 2 deletions packages/api-server/src/app.ts
@@ -1,7 +1,6 @@
import express from 'express'
import morgan from 'morgan'

import type { Response, Request, Application } from 'express'
import morgan from 'morgan'

// Base express app, with common config
const createApp = (): Application => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/src/error.ts
@@ -1,5 +1,5 @@
import forTerminal from 'youch-terminal'
import Youch from 'youch'
import forTerminal from 'youch-terminal'

/**
* This function will print a pretty version of an error in the terminal.
Expand Down
1 change: 0 additions & 1 deletion packages/api-server/src/handler.ts
Expand Up @@ -5,7 +5,6 @@ import withApiProxy from './middleware/withApiProxy'
import withFunctions from './middleware/withFunctions'
import withWebServer from './middleware/withWebServer'
import { startServer } from './server'

import type { HttpServerParams } from './server'

/*
Expand Down
3 changes: 1 addition & 2 deletions packages/api-server/src/middleware/withApiProxy.ts
@@ -1,6 +1,5 @@
import { createProxyMiddleware } from 'http-proxy-middleware'

import type { Application } from 'express'
import { createProxyMiddleware } from 'http-proxy-middleware'

interface ApiProxyOptions {
apiProxyPath: string
Expand Down
5 changes: 2 additions & 3 deletions packages/api-server/src/middleware/withFunctions.ts
@@ -1,16 +1,15 @@
import path from 'path'

import type { Handler } from 'aws-lambda'
import bodyParser from 'body-parser'
import type { Application, Request, Response } from 'express'
import glob from 'glob'
import escape from 'lodash.escape'

import { getPaths } from '@redwoodjs/internal'

import { requestHandler } from '../requestHandlers/awsLambda'

import type { Handler } from 'aws-lambda'
import type { Application, Request, Response } from 'express'

export type Lambdas = Record<string, Handler>
const LAMBDA_FUNCTIONS: Lambdas = {}

Expand Down
3 changes: 1 addition & 2 deletions packages/api-server/src/middleware/withWebServer.ts
Expand Up @@ -2,11 +2,10 @@ import fs from 'fs'
import path from 'path'

import express from 'express'
import type { Application } from 'express'

import { getPaths } from '@redwoodjs/internal'

import type { Application } from 'express'

const withWebServer = (app: Application) => {
const indexContent = fs.readFileSync(
path.join(getPaths().web.dist, '/index.html'),
Expand Down
7 changes: 3 additions & 4 deletions packages/api-server/src/requestHandlers/awsLambda.ts
@@ -1,13 +1,12 @@
import qs from 'qs'

import { handleError } from '../error'

import type {
APIGatewayProxyResult,
APIGatewayProxyEvent,
Handler,
} from 'aws-lambda'
import type { Response, Request } from 'express'
import qs from 'qs'

import { handleError } from '../error'

export const parseBody = (rawBody: string | Buffer) => {
if (typeof rawBody === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Expand Up @@ -13,7 +13,7 @@
"@graphql-tools/merge": "6.2.14",
"@prisma/client": "2.23.0",
"@types/pino": "^6.3.8",
"apollo-server-lambda": "2.22.2",
"apollo-server-lambda": "2.24.1",
"core-js": "3.12.1",
"graphql": "15.5.0",
"graphql-scalars": "1.9.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/auth/decoders/index.ts
@@ -1,3 +1,5 @@
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import type { GlobalContext } from 'src/globalContext'
Expand All @@ -9,7 +11,6 @@ import { netlify } from './netlify'
import { nhost } from './nhost'
import { supabase } from './supabase'

import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'
const noop = (token: string) => token

interface Req {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/auth/decoders/netlify.ts
@@ -1,6 +1,6 @@
import type { Context as LambdaContext, ClientContext } from 'aws-lambda'
import jwt, { TokenExpiredError } from 'jsonwebtoken'

import type { Context as LambdaContext, ClientContext } from 'aws-lambda'
// import type { TokenExpiredError } from 'jsonwebtoken'

type NetlifyContext = ClientContext & {
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/auth/index.ts
@@ -1,11 +1,11 @@
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import type { GlobalContext } from 'src/globalContext'

import { decodeToken } from './decoders'

import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

// This is shared by `@redwoodjs/web`
const AUTH_PROVIDER_HEADER = 'auth-provider'

Expand Down
11 changes: 5 additions & 6 deletions packages/api/src/auth/verifiers/common.ts
@@ -1,15 +1,14 @@
import jwtVerifier from './jwtVerifier'
import secretKeyVerifier from './secretKeyVerifier'
import sha1Verifier from './sha1Verifier'
import sha256Verifier from './sha256Verifier'
import skipVerifier from './skipVerifier'
import timestampSchemeVerifier from './timestampSchemeVerifier'

import type { JwtVerifier } from './jwtVerifier'
import secretKeyVerifier from './secretKeyVerifier'
import type { SecretKeyVerifier } from './secretKeyVerifier'
import sha1Verifier from './sha1Verifier'
import type { Sha1Verifier } from './sha1Verifier'
import sha256Verifier from './sha256Verifier'
import type { Sha256Verifier } from './sha256Verifier'
import skipVerifier from './skipVerifier'
import type { SkipVerifier } from './skipVerifier'
import timestampSchemeVerifier from './timestampSchemeVerifier'
import type { TimestampSchemeVerifier } from './timestampSchemeVerifier'

export const verifierLookup = {
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/auth/verifiers/index.ts
@@ -1,5 +1,4 @@
import { verifierLookup } from './common'

import type {
SupportedVerifierTypes,
VerifyOptions,
Expand Down
1 change: 0 additions & 1 deletion packages/api/src/auth/verifiers/jwtVerifier.ts
Expand Up @@ -5,7 +5,6 @@ import {
WebhookVerificationError,
DEFAULT_WEBHOOK_SECRET,
} from './common'

import type { WebhookVerifier, VerifyOptions } from './common'

export interface JwtVerifier extends WebhookVerifier {
Expand Down
4 changes: 0 additions & 4 deletions packages/api/src/auth/verifiers/secretKeyVerifier.ts
@@ -1,5 +1,4 @@
import { WebhookVerificationError, DEFAULT_WEBHOOK_SECRET } from './common'

import type { WebhookVerifier, VerifyOptions } from './common'

export interface SecretKeyVerifier extends WebhookVerifier {
Expand All @@ -18,9 +17,6 @@ export const secretKeyVerifier = (
): SecretKeyVerifier => {
return {
sign: ({ secret }) => {
console.warn(
`With the SecretKeyVerifier verifier, your body isn't signed with a secret`
)
return secret
},
verify: ({ signature, secret = DEFAULT_WEBHOOK_SECRET }) => {
Expand Down

0 comments on commit 2a14dd2

Please sign in to comment.