Skip to content

Commit ec349a8

Browse files
committed
chore: updating docs for the new way to run the UI
1 parent fd1fb85 commit ec349a8

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,52 @@ And when creating apps with a starter:
3535
```bash
3636
node [root of the monorepo]/cli/create-tsrouter-app/dist/index.js app-js --starter http://localhost:9080/starter.json
3737
```
38+
39+
# Developing on the CTA UI
40+
41+
The CTA UI is somewhat tricky to develop on because it's both a web server and a React app. You need to run the CLI in "API" model and then the React app in dev mode, as well as the whole monorepo in watch mode.
42+
43+
## Starting the API Server
44+
45+
Let's start off with how to run the CLI in "API" mode. Here we are running the CLI in an empty directory in app creation mode.
46+
47+
```bash
48+
CTA_DISABLE_UI=true node ../create-tsrouter-app/cli/create-tsrouter-app/dist/index.js --ui
49+
```
50+
51+
If this is working you will see the following output:
52+
53+
```
54+
Create TanStack API is running on http://localhost:8080
55+
```
56+
57+
Note that it say "Create TanStack **API**" and not "Create TanStack **App**". This is important. This means that the CLI is providing API endpoints, but **not** serving the static build files of the React app.
58+
59+
Here is the same command for the `add` mode:
60+
61+
```bash
62+
CTA_DISABLE_UI=true node ../create-tsrouter-app/cli/create-tsrouter-app/dist/index.js add --ui
63+
```
64+
65+
## Starting the React App
66+
67+
Now that we have the API server running, we can start the React app in dev mode.
68+
69+
```bash
70+
cd packages/cta-ui
71+
pnpm dev:ui
72+
```
73+
74+
At this poing you should be able to navigate to `http://localhost:3000` and see the React app connected to the API server on `http://localhost:8080`.
75+
76+
## Running the Monorepo in Watch Mode
77+
78+
At the top level of the monorepo, run the following command to start the build in watch mode.
79+
80+
```bash
81+
pnpm dev
82+
```
83+
84+
This will build the monorepo and watch for changes in any of the libraries. (It will **not** build changes for the React app within the `cta-ui` package.)
85+
86+
This is important because you might need to change API endpoints in the CTA library, or in the engine. If you do make those kinds of changes then the you will need to re-run the CLI in "API" mode to pick up the changes.

packages/cta-ui/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Create TanStack App - User Interface
2+
3+
This is an odd package because it's both a library that runs a web server, as well as a React SPA app that builds using Vite.
4+
5+
## Script Commands
6+
7+
| Command | Description |
8+
| -------------------- | ---------------------------------------------- |
9+
| `pnpm build` | Builds **both** the library and the React app |
10+
| `pnpm build:ui` | Builds the React app only |
11+
| `pnpm build:lib` | Builds just the `lib` directory |
12+
| `pnpm dev:ui` | Uses Vite to run the React app in dev mode |
13+
| `pnpm dev` | Builds the `lib` directory in watch mode |
14+
| `pnpm test` | Runs the tests |
15+
| `pnpm test:watch` | Runs the tests in watch mode |
16+
| `pnpm test:coverage` | Runs the tests and generates a coverage report |
17+
18+
## Dev vs Prod Mode
19+
20+
The only difference between dev and prod mode (outside of the usual minification and tree-shaking that goes into prod builds) is that in development mode the `src/lib/api.ts` uses a base URL of `http://localhost:8080` to point at the CLI running in API mode.

packages/cta-ui/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"build:lib": "tsc -p tsconfig.lib.json",
1010
"dev": "tsc --watch -p tsconfig.lib.json",
1111
"dev:ui": "VITE_API_BASE_URL=http://localhost:8080 vite dev",
12-
"build:server": "tsc -p tsconfig.api-server.json",
1312
"test": "vitest run",
1413
"test:watch": "vitest",
1514
"test:coverage": "vitest run --coverage"

0 commit comments

Comments
 (0)