Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/api-ski…
Browse files Browse the repository at this point in the history
…p-prebuild-try-2

* 'main' of github.com:redwoodjs/redwood:
  fix(server): error early on incompatible config (apiHost and apiUrl) (redwoodjs#9808)
  chore(esm): convert crwa to esm and bundle (redwoodjs#9786)
  chore(cli): More robust isAwaitable (redwoodjs#9806)
  chore(ci): Update task names to say "node 20" (redwoodjs#9805)
  Use TS for rebuild-test-project-fixture script (redwoodjs#9804)
  chore: bump TSTyche (redwoodjs#9803)
  docs(fragments): Typo, grammar and formatting fixes (redwoodjs#9802)
  • Loading branch information
dac09 committed Jan 8, 2024
2 parents 4fb918a + 5210e06 commit ee9b04d
Show file tree
Hide file tree
Showing 31 changed files with 529 additions and 483 deletions.
44 changes: 34 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]

name: 🏗 Build, lint, test / ${{ matrix.os }} / node 18 latest
name: 🏗 Build, lint, test / ${{ matrix.os }} / node 20 latest
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]

name: 🏗 Build, lint, test / ${{ matrix.os }} / node 18 latest
name: 🏗 Build, lint, test / ${{ matrix.os }} / node 20 latest
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -157,7 +157,7 @@ jobs:
matrix:
bundler: [vite, webpack]

name: 🌲 Tutorial E2E / ${{ matrix.bundler }} / node 18 latest
name: 🌲 Tutorial E2E / ${{ matrix.bundler }} / node 20 latest
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -236,7 +236,7 @@ jobs:
matrix:
bundler: [vite, webpack]

name: 🌲 Tutorial E2E / ${{ matrix.bundler }} / node 18 latest
name: 🌲 Tutorial E2E / ${{ matrix.bundler }} / node 20 latest
runs-on: ubuntu-latest

steps:
Expand All @@ -250,7 +250,7 @@ jobs:
os: [ubuntu-latest, windows-latest]
bundler: [vite, webpack]

name: 🔄 Smoke tests / ${{ matrix.os }} / ${{ matrix.bundler }} / node 18 latest
name: 🔄 Smoke tests / ${{ matrix.os }} / ${{ matrix.bundler }} / node 20 latest
runs-on: ${{ matrix.os }}

env:
Expand Down Expand Up @@ -428,7 +428,7 @@ jobs:
#
# ```
# env:
# RECORD_REPLAY_METADATA_TEST_RUN_TITLE: 🔄 Smoke tests / ${{ matrix.os }} / node 18 latest
# RECORD_REPLAY_METADATA_TEST_RUN_TITLE: 🔄 Smoke tests / ${{ matrix.os }} / node 20 latest
# RECORD_REPLAY_TEST_METRICS: 1
# ```
#
Expand All @@ -447,7 +447,7 @@ jobs:
os: [ubuntu-latest, windows-latest]
bundler: [vite, webpack]

name: 🔄 Smoke tests / ${{ matrix.os }} / ${{ matrix.bundler }} / node 18 latest
name: 🔄 Smoke tests / ${{ matrix.os }} / ${{ matrix.bundler }} / node 20 latest
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -460,7 +460,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]

name: 🔭 Telemetry check / ${{ matrix.os }} / node 18 latest
name: 🔭 Telemetry check / ${{ matrix.os }} / node 20 latest
runs-on: ${{ matrix.os }}

env:
Expand Down Expand Up @@ -507,7 +507,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]

name: 🔭 Telemetry check / ${{ matrix.os }} / node 18 latest
name: 🔭 Telemetry check / ${{ matrix.os }} / node 20 latest
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -751,11 +751,13 @@ jobs:
env:
PROJECT_PATH: ${{ env.PROJECT_PATH }}

- name: Prompt tests
- name: Install expect
run: |
sudo apt-get update
sudo apt-get install expect
- name: Prompt tests
run: |
./tests/e2e_prompts.sh
./tests/e2e_prompts_git.sh
./tests/e2e_prompts_m.sh
Expand All @@ -765,6 +767,28 @@ jobs:
env:
PROJECT_PATH: ${{ env.PROJECT_PATH }}

- name: ⬢ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Prompt tests
run: ./tests/e2e_prompts_node_less.sh
working-directory: ./packages/create-redwood-app
env:
PROJECT_PATH: ${{ env.PROJECT_PATH }}

- name: ⬢ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 21

- name: Prompt tests
run: ./tests/e2e_prompts_node_greater.sh
working-directory: ./packages/create-redwood-app
env:
PROJECT_PATH: ${{ env.PROJECT_PATH }}

crwa-skip:
needs: detect-changes
if: needs.detect-changes.outputs.onlydocs == 'true'
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.32",
"postcss": "^8.4.33",
"postcss-loader": "^7.3.4",
"prettier-plugin-tailwindcss": "0.4.1",
"tailwindcss": "^3.4.0"
"tailwindcss": "^3.4.1"
}
}
8 changes: 4 additions & 4 deletions docs/docs/graphql/fragments.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ import { fragment } from '@redwoodjs/web/apollo'

Access typename of fragment you registered.


```ts
import { typename } from '@redwoodjs/web/apollo'
```
Expand All @@ -166,6 +165,7 @@ fragment BookInfo on Book {
author
publicationYear
}
```

the `typename` is `Book`.

Expand Down Expand Up @@ -294,9 +294,9 @@ import possibleTypes from 'src/graphql/possibleTypes'
>
```

To generate the `src/graphql/possibleTypes`, configure the `redwood.toml`:
To generate the `src/graphql/possibleTypes` file, enable fragments in `redwood.toml`:

```toml title=redwood.roml
```toml title=redwood.toml
[graphql]
fragments=true
fragments = true
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"project:deps": "node ./tasks/framework-tools/frameworkDepsToProject.mjs",
"project:sync": "node ./tasks/framework-tools/frameworkSyncToProject.mjs",
"project:tarsync": "node ./tasks/framework-tools/tarsync.mjs",
"rebuild-test-project-fixture": "node ./tasks/test-project/rebuild-test-project-fixture.js",
"rebuild-test-project-fixture": "tsx ./tasks/test-project/rebuild-test-project-fixture.ts",
"release": "node ./tasks/release/release.mjs",
"release:compare": "node ./tasks/release/compare/compare.mjs",
"release:notes": "node ./tasks/release/generateReleaseNotes.mjs",
Expand Down Expand Up @@ -105,7 +105,7 @@
"ora": "7.0.1",
"prompts": "2.4.2",
"rimraf": "5.0.5",
"tstyche": "1.0.0-beta.3",
"tstyche": "1.0.0-beta.9",
"tsx": "4.6.2",
"typescript": "5.3.3",
"yargs": "17.7.2",
Expand Down
47 changes: 31 additions & 16 deletions packages/cli/src/commands/serveWebHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import execa from 'execa'

import { getPaths } from '@redwoodjs/project-config'

import { exitWithError } from '../lib/exit'

export const webSsrServerHandler = async () => {
await execa('yarn', ['rw-serve-fe'], {
cwd: getPaths().web.base,
Expand All @@ -11,21 +13,34 @@ export const webSsrServerHandler = async () => {
}

export const webServerHandler = async (argv) => {
await execa(
'yarn',
[
'rw-web-server',
'--port',
argv.port,
'--socket',
argv.socket,
'--api-host',
argv.apiHost,
],
{
cwd: getPaths().base,
stdio: 'inherit',
shell: true,
try {
await execa(
'yarn',
[
'rw-web-server',
'--port',
argv.port,
'--socket',
argv.socket,
'--api-host',
argv.apiHost,
],
{
cwd: getPaths().base,
stdio: 'inherit',
shell: true,
}
)
} catch (e) {
// `@redwoodjs/web-server` uses a custom error exit code to tell this handler that an error has already been handled.
// While any other exit code than `0` is considered an error, there seems to be some conventions around some of them
// like `127`, etc. We chose 64 because it's in the range where there deliberately aren't any previous conventions.
// See https://tldp.org/LDP/abs/html/exitcodes.html.
if (e.exitCode === 64) {
process.exitCode = 1
return
}
)

exitWithError(e)
}
}
72 changes: 31 additions & 41 deletions packages/create-redwood-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,35 @@

<h2 align="center">Ship today with architecture for tomorrow.</h2>

Redwood is an opinionated, edge-ready framework for modern multi-client applications, built on React, GraphQL, and Prisma with full TypeScript support and ready to go with zero config.
Redwood is an opinionated framework for modern multi-client applications, built on React, GraphQL, and Prisma with full TypeScript support and ready to go with zero config.

Want great developer experience and easy scaling? How about an integrated front- and back-end test suite, boilerplate code generators, component design, logging, API security + auth, and serverless or traditional deploy support? Redwood is here! Redwood works with the components and development workflow you love but with simple conventions and helpers to make your experience even better.

<br>

<h2>Quick Start</h2>

Redwood requires Node.js >=14.x <=16.x and Yarn v1.15 (or newer).
```console
yarn create redwood-app redwood-project
cd redwood-project
Redwood requires Node.js =20.x.

```bash
yarn create redwood-app my-redwood-app
cd my-redwood-app
yarn install
yarn redwood dev
```

<h3>Resources</h3>

- The [Redwood Tutorial](https://redwoodjs.com/docs/tutorial): The best way to learn Redwood
- The [Redwood Tutorial](https://redwoodjs.com/docs/tutorial): the best way to learn Redwood
- The [Redwood CLI](https://redwoodjs.com/docs/cli-commands): code generators, DB helpers, setup commands, and more
- [Documentation](https://redwoodjs.com/docs) and [How To's](https://redwoodjs.com/how-to/custom-function)
- Join the Community [Forums](https://community.redwoodjs.com) and [Chat](https://discord.gg/redwoodjs)

<br>

<h1>Contributing to create-redwood-app</h1>
<h2>Contributing to create-redwood-app</h2>

_Contributors are Welcome! Get started [here](https://redwoodjs.com/docs/contributing). And don't hesitate to ask for help on the forums and chat_
_Contributors are Welcome! Get started [here](https://redwoodjs.com/docs/contributing). And don't hesitate to ask for help on the forums and chat_.

**Table of Contents**
<!-- toc -->
- [Description](#description)
- [Package Leads](#package-leads)
- [Roadmap](#roadmap)
- [Local Development](#local-development)
- [Installation Script](#installation-script)
- [Template Codebase](#template-codebase)
Expand All @@ -60,55 +56,45 @@ _Contributors are Welcome! Get started [here](https://redwoodjs.com/docs/contrib
## Description

This package creates and installs a Redwood project, which is the entry point for anyone using Redwood. It has two parts:
- The installation script `create-redwood-app.js`
- Project template code in the `template/` directory

> _For information about contributing to the Redwood Framework in general, [please start here](https://redwoodjs.com/docs/contributing)._
## Package Leads
- [@peterp](https://github.com/peterp)
- [@thedavidprice](https://github.com/thedavidprice)

## Roadmap

v1 Priorities:
- convert `template/` codebase to TypeScript
- add option to install as either TypeScript or JavaScript project (defaults to TypeScript)
- add package tests, which may be accomplished by including in Cypress E2E CI
- The installation script [`src/create-redwood-app.js`](./src/create-redwood-app.js)
- Project template code in the [`templates/`](./templates/) directory

## Local Development

### Installation Script
The installation script is built with [Yargs](https://github.com/yargs/yargs)

The installation script is built with [Yargs](https://github.com/yargs/yargs).

### Template Codebase
The project codebase in `template/` uses [Yarn Workspace v1](https://classic.yarnpkg.com/en/docs/workspaces/) for a monorepo project containing the API and Web Sides. Redwood packages are included in `template/package.json`, `template/web/package.json`, and `template/api/package.json`, respectively.

### How to run create-redwood-app from your local repo and create a project
The project codebase in [`templates/`](./templates/) uses [Yarn Workspaces](https://yarnpkg.com/features/workspaces) for a monorepo project containing the API and Web Sides. Redwood packages are included in `templates/ts/package.json`, `templates/ts/web/package.json`, and `templates/ts/api/package.json`, respectively.

### How to run `create-redwood-app` from your local repo and create a project

First, run the following commands in the root of the monorepo:

```bash
yarn install
yarn build
```

Then, we need to navigate to the create redwood app package and build the script:
Then, navigate to the create redwood app package:

```bash
cd packages/create-redwood-app
yarn build
```

_Note:_ You can also use `yarn build:watch` instead of `yarn build` to watch for changes and rebuild automatically.

This will generate the `create-redwood-app.js` file inside the `dist` directory.
Run `yarn node` on the built file (`dist/create-redwood-app.js`) and pass in the path to the new project:

To use the script, run `node` on that file (dist/create-redwood-app.js) and pass in the path to the new project:
```bash
node dist/create-redwood-app.js /path/to/new/redwood-app
yarn node ./dist/create-redwood-app.js /path/to/new/redwood-app
```

> Note: the new project will install with the most recent major Redwood package version by default
> [!NOTE]
> the new project will install with the most recent major Redwood package version by default.
### How to run other published versions for debugging

By default yarn create will pick the latest stable version to run, but you can specify a different version via yarn too!

To try the canary version, run:
Expand All @@ -121,12 +107,16 @@ Note that this will still create a project with the latest stable version, but r
You can specify any tag or version instead of `@canary`

### Develop using the new project

There are three options for developing with the installed project:

**1. Upgrade the project to use the latest canary release**

```bash
cd /path/to/new/redwood-app
yarn rw upgrade -t canary
```

**2. Use the workflow and tools for local package development**
- [Local Development Instructions](https://github.com/redwoodjs/redwood/blob/main/CONTRIBUTING.md#local-development)

- [Local Development Instructions](https://github.com/redwoodjs/redwood/blob/main/CONTRIBUTING.md)
Loading

0 comments on commit ee9b04d

Please sign in to comment.