Skip to content

chore: Check starters on CI + Remove 2332 port override #192

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/check-starters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Starters Checks

on: pull_request

jobs:
check-starters:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- run: |
corepack enable
pnpm install

- name: Run checks for each starter
run: pnpm -r --filter="@redwoodjs/starter-*" check

- name: Test dev server for each starter
run: |
for starter in starters/*; do
if [ -d "$starter" ]; then
./scripts/check-starter-server.sh dev "$starter"
fi
done

- name: Test building and preview server for each starter
run: |
for starter in starters/*; do
if [ -d "$starter" ]; then
./scripts/check-starter-server.sh preview "$starter"
fi
done
6 changes: 3 additions & 3 deletions docs/src/content/docs/getting-started/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ Redwood is just a plugin for Vite, so you can use the same commands to run the d
```bash frame="none" showLineNumbers=false
VITE v6.2.0 ready in 500 ms

➜ Local: http://localhost:2332/
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
```

Access the development server in your browser, by default it's available at [http://localhost:2332](http://localhost:2332),
Access the development server in your browser, by default it's available at [http://localhost:5173](http://localhost:5173),
where you should see "Hello World" displayed on the page.

![Hello World](./images/hello-world.png)
Expand Down Expand Up @@ -116,7 +116,7 @@ import { route } from "@redwoodjs/sdk/router";
export default defineApp([route("/ping", () => <h1>Pong!</h1>)]);
```

Now when you navigate to [http://localhost:2332/ping](http://localhost:2332/ping) you should see "Pong!" displayed on the page.
Now when you navigate to [http://localhost:5173/ping](http://localhost:5173/ping) you should see "Pong!" displayed on the page.

<Aside type="tip">
You might have noticed that we returned JSX instead of a Response object. This
Expand Down
4 changes: 2 additions & 2 deletions experiments/ai-stream/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@redwoodjs/starter-minimal",
"name": "ai-stream",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand All @@ -21,7 +21,7 @@
"format": "prettier --write ./src"
},
"dependencies": {
"@redwoodjs/sdk": "0.0.30",
"@redwoodjs/sdk": "0.0.30-test.2",
"react": "19.0.0-rc-f2df5694-20240916",
"react-dom": "19.0.0-rc-f2df5694-20240916",
"react-server-dom-webpack": "19.0.0-rc-f2df5694-20240916"
Expand Down
2 changes: 1 addition & 1 deletion experiments/billable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@prisma/adapter-d1": "^6.3.1",
"@prisma/client": "^6.3.1",
"@radix-ui/react-slot": "^1.1.1",
"@redwoodjs/sdk": "0.0.30",
"@redwoodjs/sdk": "0.0.30-test.2",
"@types/lodash": "^4.17.13",
"aws4fetch": "^1.0.20",
"class-variance-authority": "^0.7.1",
Expand Down
2 changes: 1 addition & 1 deletion experiments/cutable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-toast": "^1.2.6",
"@radix-ui/themes": "^3.2.0",
"@redwoodjs/sdk": "0.0.30",
"@redwoodjs/sdk": "0.0.30-test.2",
"autoprefixer": "^10.4.20",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion experiments/realtime-poc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@prisma/adapter-d1": "^6.4.1",
"@prisma/client": "^6.4.1",
"@redwoodjs/sdk": "0.0.30",
"@redwoodjs/sdk": "0.0.30-test.2",
"@simplewebauthn/browser": "^13.1.0",
"@simplewebauthn/server": "^13.1.1",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion experiments/yt-dos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"__reset:release": "pnpm __reset && pnpm release"
},
"dependencies": {
"@redwoodjs/sdk": "0.0.30",
"@redwoodjs/sdk": "0.0.30-test.2",
"react": "19.0.0-rc-f2df5694-20240916",
"react-dom": "19.0.0-rc-f2df5694-20240916",
"react-server-dom-webpack": "19.0.0-rc-f2df5694-20240916"
Expand Down
4 changes: 2 additions & 2 deletions experiments/zoomshare/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@redwoodjs/starter-passkey-auth",
"name": "zoomshare",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand Down Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@prisma/adapter-d1": "^6.4.1",
"@prisma/client": "^6.4.1",
"@redwoodjs/sdk": "0.0.30",
"@redwoodjs/sdk": "0.0.30-test.2",
"@simplewebauthn/browser": "^13.1.0",
"@simplewebauthn/server": "^13.1.1",
"react": "19.0.0-rc-f2df5694-20240916",
Expand Down
64 changes: 32 additions & 32 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions scripts/check-starter-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
set -euo pipefail

# Parse arguments
mode="dev"
port=""
starter_dir=""

while [[ $# -gt 0 ]]; do
case $1 in
--port)
port="$2"
shift 2
;;
--mode)
mode="$2"
if [[ "$mode" != "dev" && "$mode" != "preview" ]]; then
echo "Error: mode must be either 'dev' or 'preview'"
exit 1
fi
shift 2
;;
*)
starter_dir="$1"
shift
;;
esac
done

if [ ! -d "$starter_dir" ]; then
echo "Error: $starter_dir is not a directory"
exit 1
fi

# Calculate port if not provided
if [ -z "$port" ]; then
starter_name=$(basename "$starter_dir")
port=$(( 3000 + $(echo "$starter_name" | cksum | cut -d' ' -f1) % 1000 ))
fi

# Kill miniflare process if it exists
kill_miniflare_process() {
pid=$(lsof -ti:9229 || true)
if [ ! -z "$pid" ]; then
echo "Killing process on port 9229"
kill "$pid" || true
fi
}

echo "Testing $starter_dir on port $port in $mode mode"

# Kill existing miniflare process and start the server
kill_miniflare_process
cd "$starter_dir"
pnpm "$mode" --port "$port" &
server_pid=$!

# Try to connect to the server with retries
max_attempts=30
attempt=1
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt/$max_attempts: Checking if server is up..."
if curl -s -f "http://localhost:$port" > /dev/null 2>&1; then
echo "✓ Server responded successfully"
kill $server_pid
exit 0
fi

# Check if server process is still running
if ! kill -0 $server_pid 2>/dev/null; then
echo "✗ Server process died unexpectedly"
exit 1
fi

sleep 2
attempt=$((attempt + 1))
done

echo "✗ Server failed to respond after $max_attempts attempts"
kill $server_pid
exit 1
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@redwoodjs/sdk",
"version": "0.0.30",
"version": "0.0.30-test.2",
"description": "",
"type": "module",
"bin": {
Expand Down
3 changes: 0 additions & 3 deletions sdk/src/lib/constants.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ export const VENDOR_ROOT_DIR = resolve(ROOT_DIR, "vendor");
export const VENDOR_SRC_DIR = resolve(VENDOR_ROOT_DIR, "src");
export const VENDOR_DIST_DIR = resolve(VENDOR_ROOT_DIR, "dist");

export const DEV_SERVER_PORT = 2332;
export const WORKER_DEV_SERVER_PORT = 5174;

export const VENDOR_REACT_SSR_PATH = resolve(VENDOR_DIST_DIR, "react-ssr.js");
12 changes: 8 additions & 4 deletions sdk/src/scripts/dev-init.mts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { $ } from "../lib/$.mjs";
import { pathExists } from "fs-extra";
import { readFile } from "fs/promises";
import { resolve } from "path";

export const initDev = async () => {
console.log("Initializing development environment...");

const isUsingPrisma = await pathExists(resolve(process.cwd(), "prisma"));
const pkg = JSON.parse(
await readFile(resolve(process.cwd(), "package.json"), "utf-8"),
);

if (isUsingPrisma) {
if (pkg.scripts?.["migrate:dev"]) {
await $`pnpm migrate:dev`;
await $`pnpm prisma generate`;
}

if (pkg.scripts?.["seed"]) {
await $`pnpm seed`;
}

Expand Down
4 changes: 3 additions & 1 deletion sdk/src/scripts/worker-run.mts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ export const runWorkerScript = async (relativeScriptPath: string) => {
configFile: false,
plugins: [
redwood({
port: 0,
configPath: tmpWorkerPath.path,
entry: {
worker: scriptPath,
},
}),
],
server: {
port: 0,
},
});

try {
Expand Down
5 changes: 0 additions & 5 deletions sdk/src/vite/configPlugin.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Plugin } from "vite";
import { resolve } from "node:path";
import { mergeConfig, InlineConfig } from "vite";

import { DEV_SERVER_PORT } from "../lib/constants.mjs";

const ignoreVirtualModules = {
name: "ignore-virtual-modules",
setup(build: any) {
Expand All @@ -19,15 +17,13 @@ export const configPlugin = ({
projectRootDir,
clientEntryPathname,
workerEntryPathname,
port,
isUsingPrisma,
}: {
mode: "development" | "production";
silent: boolean;
projectRootDir: string;
clientEntryPathname: string;
workerEntryPathname: string;
port: number;
isUsingPrisma: boolean;
}): Plugin => ({
name: "rw-sdk-config",
Expand Down Expand Up @@ -124,7 +120,6 @@ export const configPlugin = ({
},
server: {
hmr: true,
port: port ?? DEV_SERVER_PORT,
},
resolve: {
conditions: ["workerd"],
Expand Down
3 changes: 0 additions & 3 deletions sdk/src/vite/redwoodPlugin.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { InlineConfig } from "vite";
import reactPlugin from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";

import { DEV_SERVER_PORT } from "../lib/constants.mjs";
import { transformJsxScriptTagsPlugin } from "./transformJsxScriptTagsPlugin.mjs";
import { useServerPlugin } from "./useServerPlugin.mjs";
import { useClientPlugin } from "./useClientPlugin.mjs";
Expand All @@ -23,7 +22,6 @@ import { findWranglerConfig } from "../lib/findWranglerConfig.mjs";

export type RedwoodPluginOptions = {
silent?: boolean;
port?: number;
rootDir?: string;
mode?: "development" | "production";
configPath?: string;
Expand Down Expand Up @@ -69,7 +67,6 @@ export const redwoodPlugin = async (
projectRootDir,
clientEntryPathname,
workerEntryPathname,
port: options.port ?? DEV_SERVER_PORT,
isUsingPrisma,
}),
customReactBuildPlugin({ projectRootDir }),
Expand Down
46 changes: 14 additions & 32 deletions starters/drizzle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,13 @@ cd my-project-name
pnpm install
```

## Setting up your db

The starter includes a basic user model in `src/db/schema.ts`:

```typescript
export const users = sqliteTable("users", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
});
```

Set up your database:

```shell
pnpm migrate:new
pnpm migrate:dev
pnpm seed
```

These commands will:

- Create your initial migration
- Apply the migration to your database
- Seed your database with initial data

You should see your seeded data displayed in the browser.

## Running the dev server

```shell
pnpm dev
```

Point your browser to the URL displayed in the terminal (e.g. `http://localhost:2332/`). You should see a "Hello World" message in your browser.
Point your browser to the URL displayed in the terminal (e.g. `http://localhost:5173/`). You should see a "Hello World" message in your browser.

## Deploying your app

Expand Down Expand Up @@ -102,6 +71,19 @@ To get your Cloudflare credentials:

### Database Changes

The starter includes a basic user model in `src/db/schema.ts`:

```typescript
export const users = sqliteTable("users", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
});
```

When you need to make changes to your database schema:

1. Update your schema in `src/db/schema.ts`
Expand Down
Loading