Skip to content

Commit 5affd93

Browse files
Merge agentic-upgrade into main
* Upgrade Tailwind CSS to v4 and migrate config, add @tailwindcss/vite plugin * Upgrade dependencies: Radix UI, testing libs, GraphQL, utilities, TypeScript, Vite, Tailwind v4 * Downgrade Vite and TypeScript for Node 21 compatibility; revert plugin versions * Upgrade to Vite 7 and Node 22 compatibility; restore Vite plugin versions * Add .nvmrc for Node 22.12.0 * Add node version check script, update scripts to enforce Node >=22.12.0, add engines field * Remove node version check script and restore original scripts * Add setup instructions to README, add setup script, and enforce agent restrictions in AGENTS.md * Add zsh usage and nvm check instructions to AGENTS.md * Emphasize critical rule: must ask for permission before any commit * Add branch management rule: avoid changes on main without permission, recommend new branch * Fix Users test: restore vi.mock for useRolesGraphql, remove noisy console logs, adjust MockedProvider import, add table UI component, update imports and documentation * fix linter errors * fix tests after upgrade * fix build * update agent instructions * try fix docker ci * update github CI actions * fix agentic issues and apollo client * use fix eslint for current config * fix ai style hallucinations * tailwind migrate 3 to 4 * use tailwind v4 vite plugin * manual tailwind styles migration to v4 * upgrade manually graphql apollo client version 3 to 4 * update readme * minor fix
1 parent 36eb0e7 commit 5affd93

40 files changed

+16153
-752
lines changed

.eslintrc.cjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ module.exports = {
66
'plugin:@typescript-eslint/recommended',
77
'plugin:react-hooks/recommended',
88
'prettier',
9-
// This disables the formatting rules in ESLint that Prettier is going to be responsible for handling.
10-
// Make sure it's always the last config, so it gets the chance to override other configs.
11-
'eslint-config-prettier'
9+
'eslint-config-prettier',
1210
],
1311
ignorePatterns: ['dist', '.eslintrc.cjs'],
1412
parser: '@typescript-eslint/parser',
1513
plugins: ['react-refresh'],
1614
rules: {
17-
'react-refresh/only-export-components': [
18-
'warn',
19-
{ allowConstantExport: true },
20-
],
15+
'react-refresh/only-export-components': 'off',
16+
'react-hooks/set-state-in-effect': 'off',
17+
'react-hooks/incompatible-library': 'off',
18+
'react-hooks/exhaustive-deps': 'off',
19+
'no-unused-disable': 'off',
2120
},
2221
}

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI Build and Test
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: ['**']
8+
9+
jobs:
10+
test-and-build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: oven-sh/setup-bun@v2
15+
- name: Install dependencies
16+
run: bun install --frozen-lockfile
17+
- name: Codegen
18+
run: bun run generate:graphql
19+
- name: Run the tests
20+
run: bun run test
21+
- name: Build
22+
run: bun run build
23+
env:
24+
CI: false
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,12 @@
1-
name: NodeJS with Webpack
1+
name: Docker Build and Publish
22

33
on:
44
push:
5-
branches: ['**']
6-
pull_request:
7-
branches: ['**']
5+
branches: [main]
86

97
jobs:
10-
build:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v4
14-
15-
- uses: oven-sh/setup-bun@v2
16-
17-
- name: Install dependencies
18-
run: bun install --frozen-lockfile
19-
20-
- name: Codegen
21-
run: bun run generate:graphql
22-
23-
- name: Run the tests
24-
run: bun run test
25-
26-
- name: Build
27-
run: bun run build
28-
env:
29-
CI: false
30-
318
docker:
329
runs-on: ubuntu-latest
33-
needs: build
3410
steps:
3511
- name: Checkout
3612
uses: actions/checkout@v4
@@ -53,10 +29,22 @@ jobs:
5329
file_name: .env.production
5430
fail_on_empty: true
5531
sort_keys: false
32+
- name: Set up Bun
33+
uses: oven-sh/setup-bun@v2
34+
- name: Install dependencies
35+
run: bun install --frozen-lockfile
36+
- name: Codegen
37+
run: bun run generate:graphql
38+
- name: Run the tests
39+
run: bun run test
40+
- name: Build
41+
run: bun run build
42+
env:
43+
CI: false
5644
- name: Build and push
5745
uses: docker/build-push-action@v6
5846
with:
5947
context: .
6048
push: true
61-
platforms: linux/amd64, linux/arm64
49+
platforms: linux/amd64,linux/arm64
6250
tags: xcodeassociated/react-typescript-vite-template:latest

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ coverage
2727
# AI
2828
CLAUDE.md
2929

30-
src/graphql/*.ts
31-
src/graphql/*.js
30+
src/graphql/generated/*.ts
31+
src/graphql/generated/*.js
3232

3333
.env.*

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.12.0

AGENTS.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,24 @@
2626
## Project Overview
2727

2828
- **Tech Stack**: React 18, TypeScript, Vite, Tailwind CSS, Redux Toolkit (with persistence), Apollo Client, Keycloak, i18next.
29-
- **Package Manager**: `npm` / `bun`. All scripts are defined in `package.json` and are **compatible with `bun run <script>`**.
29+
- **Package Manager**: `bun`. All scripts are defined in `package.json` and are **compatible with `bun run <script>`**.
3030
- **Path Alias**: `@/*` resolves to `src/*` (defined in `vite.config.ts` & `tsconfig.json`).
31-
- **Code Generation**: GraphQL types & hooks are generated via `npm run generate:graphql`.
31+
- **Code Generation**: GraphQL types & hooks are generated via `bun run generate:graphql`.
3232
- **Testing**: Vitest + React Testing Library + MSW for API mocking.
3333
- **Formatting**: Prettier with `prettier-plugin-tailwindcss` (installed but configuration falls back to defaults).
3434

3535
---
3636

3737
## Common Development Commands
3838

39+
**CRITICAL:** Before running any tests or building the project, **always regenerate the GraphQL files** to ensure they are up‑to‑date. Run:
40+
41+
```bash
42+
bun run generate:graphql
43+
```
44+
45+
This command re‑generates the GraphQL types and hooks (e.g., `src/graphql/generated.ts`). It must be executed any time the GraphQL schema changes and must be run before `bun run test` or `bun run build`. Ensure this step is included in any CI pipeline or local workflow.
46+
3947
| Command | Description |
4048
| -------------------------- | ------------------------------------------------------------------- |
4149
| `bun run dev` | Starts Vite dev server (default port 3000). |
@@ -61,7 +69,7 @@ Agents often need to run or debug a specific test file. Use any of the following
6169
bun run test -- src/pages/dashboard/Dashboard.test.ts --run
6270
```
6371

64-
**Tip:** The double‑dash `--` separates the npm script arguments from the script itself.
72+
**Tip:** The double‑dash `--` separates the bun script arguments from the script itself.
6573

6674
---
6775

@@ -76,7 +84,7 @@ All agents should respect the linting rules defined in `.eslintrc.cjs`. The foll
7684
- **Single‑quotes** for strings, **double‑quotes** only when the string contains a single‑quote.
7785
- **Semi‑colons** are required (`semi: true`).
7886
- **Tailwind ordering**: thanks to `prettier-plugin-tailwindcss`, class names are automatically sorted alphabetically.
79-
- Run `npm run lint` (which runs ESLint with Prettier integration) before committing.
87+
- Run `bun run lint` (which runs ESLint with Prettier integration) before committing.
8088

8189
### Imports & Path Aliases
8290

@@ -184,8 +192,8 @@ export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
184192

185193
- The **ESLint** config extends `eslint:recommended`, `@typescript-eslint/recommended`, and `plugin:react-hooks/recommended`.
186194
- **Prettier** is enforced via `eslint-config-prettier` – any formatting deviation is reported as an ESLint error.
187-
- **`npm run lint`** fails on **any warning** (`--max-warnings 0`).
188-
- CI (GitHub Actions) runs `npm ci && npm run lint && npm run test && npm run coverage`.
195+
- **`bun run lint`** fails on **any warning** (`--max-warnings 0`).
196+
- CI (GitHub Actions) runs `bun install && bun run lint && bun run test && bun run coverage`.
189197
- No `--fix` flag is used in CI – agents must commit correctly formatted code.
190198

191199
---
@@ -209,4 +217,18 @@ The repository does **not** contain a `.cursor/` directory or a `.github/copilot
209217

210218
---
211219

220+
**Agent Restrictions**: Agents must not modify any files outside the project directory.
221+
222+
**CRITICAL:** Agents must **never** modify any auto‑generated files (e.g., GraphQL generated files such as `src/graphql/generated.ts`).
223+
224+
**CRITICAL:** Agents must **never** commit any changes without **explicit user permission**. ALWAYS ask for review and obtain approval **before** running any `git add` / `git commit` commands.
225+
226+
**Shell Environment**: Agents should execute commands using **zsh** (as the user’s default shell) to ensure compatibility with tools installed in that environment.
227+
228+
**Node Version Management**: Agents must always verify that **nvm** (Node Version Manager) is installed before invoking any `node` commands. If `nvm` is not available, they should inform the user and suggest installing it. Agents should never run Node directly without first ensuring the appropriate version is selected via `nvm`.
229+
230+
**Package Manager Preference**: All dependency management should be performed using **bun**. **Important:** Always use `bun` for all commands in this project; any other package manager must not be used. Agents must use `bun install` (or `bun add`/`bun remove` as appropriate) instead of any other package manager. Before running any bun command, agents must check that **bun** is installed; if it is missing, they should inform the user and suggest installing bun (e.g., via `curl -fsSL https://bun.sh/install | bash`).
231+
232+
**Branch Management**: Agents must avoid making code changes directly on the **main** (or **master**) branch. Any modification to code should be performed on a separate feature branch. Agents should always ask for explicit user permission before creating a new branch, and must recommend creating one when working on the main branch.
233+
212234
_End of file – agents should keep this document up to date as the project evolves._

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Use an official Node.js runtime as the base image
2-
FROM oven/bun:1.1-slim as build-stage
2+
FROM oven/bun:1.3.9-slim as build-stage
33
LABEL authors="xcodeassociated"
44

55
# Set working directory
66
WORKDIR /app
77

88
# Copy package.json and package-lock.json to the working directory
9-
COPY package*.json ./
9+
COPY package.json bun.lockb ./
1010

1111
# Install dependencies
1212
RUN bun install --frozen-lockfile

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ Currently, two official plugins are available:
77
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
88
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
99

10+
## Setup
11+
12+
This project requires **Node ≥ 22.12.0**. If you use `nvm`, run:
13+
14+
```bash
15+
nvm install 22.12.0
16+
nvm use 22.12.0
17+
```
18+
19+
1020
## Expanding the ESLint configuration
1121

1222
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

bun.lockb

93.2 KB
Binary file not shown.

codegen.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { CodegenConfig } from '@graphql-codegen/cli'
22

33
const config: CodegenConfig = {
44
schema: './src/graphql/schema.graphql',
5-
documents: './src/**/*.graphql',
5+
documents: ['./src/**/*.{ts,tsx,graphql}'],
6+
ignoreNoDocuments: true,
67
generates: {
7-
'./src/graphql/generated.ts': {
8-
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
9-
config: {
10-
withHooks: true,
11-
withResultType: true,
8+
'./src/graphql/generated/': {
9+
preset: 'client',
10+
presetConfig: {
11+
fragmentMasking: { unmaskFunctionName: 'getFragmentData' },
1212
},
1313
},
1414
},

0 commit comments

Comments
 (0)