Skip to content

Commit 742cf8e

Browse files
committed
chore: fix tasks
1 parent c5b9b80 commit 742cf8e

File tree

19 files changed

+107
-70
lines changed

19 files changed

+107
-70
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,25 @@ jobs:
2222
# This enables task distribution via Nx Cloud
2323
# Run this command as early as possible, before dependencies are installed
2424
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
25-
# Uncomment this line to enable task distribution
26-
# - run: npx nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="e2e-ci"
25+
- run: npx nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="e2e-ci"
2726

2827
# Cache node_modules
29-
- uses: actions/setup-node@v4
28+
- uses: pnpm/action-setup@v4
29+
name: Install pnpm
3030
with:
31-
node-version: 20
32-
cache: 'npm'
31+
run_install: false
3332

34-
- run: npm ci --legacy-peer-deps
33+
- name: Install Node.js
34+
uses: actions/setup-node@v5
35+
with:
36+
cache: 'pnpm'
37+
38+
- run: pnpm install
3539
- run: npx playwright install --with-deps
3640

3741
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
3842
# - run: npx nx-cloud record -- echo Hello World
39-
# When you enable task distribution, run the e2e-ci task instead of e2e
40-
- run: npx nx run-many -t lint test build typecheck e2e
43+
- run: npx nx run-many -t lint test build typecheck e2e-ci
4144
# Nx Cloud recommends fixes for failures to help you get CI green faster. Learn more: https://nx.dev/ci/features/self-healing-ci
4245
- run: npx nx fix-ci
43-
if: always()
46+
if: always()

.github/workflows/nx-migrate.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ jobs:
5151
if: ${{ steps.nx-workspace-package-check.outputs.was-changed == 'true' }}
5252
uses: actions/setup-node@v5
5353
with:
54-
# Use the volta.node property as the source of truth
55-
node-version-file: 'package.json'
5654
cache: 'pnpm'
5755

5856
- name: Run nx migrate if @nx/workspace changed and commit the results
@@ -80,7 +78,6 @@ jobs:
8078
# Sometimes Nx can require config formatting changes after a migrate command
8179
# We need to expect lock file changes to be applicable
8280
pnpm install --ignore-scripts --frozen-lockfile=false
83-
pnpm nx format
8481
8582
# migrations.json may or may not exist after running nx migrate
8683
if [ -f migrations.json ]; then
@@ -90,9 +87,6 @@ jobs:
9087
rm migrations.json
9188
fi
9289
93-
# Ensure all the changed files are formatted appropriately
94-
pnpm format
95-
9690
# Commit all the changes to the PR (see note on not being able to use secrets.GITHUB_TOKEN for this)
9791
git config --global user.email "[email protected]"
9892
git config --global user.name "Coly010"

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
run_install: false
2525

26-
- name: Install Node.js per package.json
26+
- name: Install Node.js
2727
uses: actions/setup-node@v5
2828
with:
2929
cache: 'pnpm'

README.md

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Nx React Template Repository
1+
# Nx React Repository
22

33
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
44

5-
✨ A template repository showcasing key [Nx](https://nx.dev) features for React monorepos ✨
5+
✨ A repository showcasing key [Nx](https://nx.dev) features for React monorepos ✨
66

77
## 📦 Project Overview
88

9-
This template demonstrates a production-ready React monorepo with:
9+
This repository demonstrates a production-ready React monorepo with:
1010

1111
- **2 Applications**
1212
- `shop` - React e-commerce application with product listings and detail views
@@ -35,34 +35,34 @@ cd react-template
3535
npm install
3636

3737
# Serve the React shop application
38-
nx serve shop
38+
npx nx serve shop
3939

4040
# Serve the API backend
41-
nx serve api
41+
npx nx serve api
4242

4343
# Build all projects
44-
nx run-many -t build
44+
npx nx run-many -t build
4545

4646
# Run tests
47-
nx run-many -t test
47+
npx nx run-many -t test
4848

4949
# Lint all projects
50-
nx run-many -t lint
50+
npx nx run-many -t lint
5151

5252
# Run e2e tests
53-
nx e2e shop-e2e
53+
npx nx e2e shop-e2e
5454

5555
# Run tasks in parallel
5656

57-
nx run-many -t lint test build e2e --parallel=3
57+
npx nx run-many -t lint test build e2e --parallel=3
5858

5959
# Visualize the project graph
60-
nx graph
60+
npx nx graph
6161
```
6262

6363
## ⭐ Featured Nx Capabilities
6464

65-
This template showcases several powerful Nx features:
65+
This repository showcases several powerful Nx features:
6666

6767
### 1. 🔒 Module Boundaries
6868

@@ -78,10 +78,10 @@ Enforces architectural constraints using tags. Each project has specific depende
7878
**Try it out:**
7979
```bash
8080
# See the current project graph and boundaries
81-
nx graph
81+
npx nx graph
8282

8383
# View a specific project's details
84-
nx show project shop --web
84+
npx nx show project shop --web
8585
```
8686

8787
[Learn more about module boundaries →](https://nx.dev/features/enforce-module-boundaries)
@@ -92,13 +92,13 @@ The API project includes Docker support with automated targets and release manag
9292

9393
```bash
9494
# Build Docker image
95-
nx docker:build api
95+
npx nx docker:build api
9696

9797
# Run Docker container
98-
nx docker:run api
98+
npx nx docker:run api
9999

100100
# Release with automatic Docker image versioning
101-
nx release
101+
npx nx release
102102
```
103103

104104
**Nx Release for Docker:** The repository is configured to use Nx Release for managing Docker image versioning and publishing. When running `nx release`, Docker images for the API project are automatically versioned and published based on the release configuration in `nx.json`. This integrates seamlessly with semantic versioning and changelog generation.
@@ -111,10 +111,10 @@ End-to-end testing with Playwright is pre-configured:
111111

112112
```bash
113113
# Run e2e tests
114-
nx e2e shop-e2e
114+
npx nx e2e shop-e2e
115115

116116
# Run e2e tests in CI mode
117-
nx e2e-ci shop-e2e
117+
npx nx e2e-ci shop-e2e
118118
```
119119

120120
[Learn more about E2E testing →](https://nx.dev/technologies/test-tools/playwright/introduction#e2e-testing)
@@ -125,10 +125,10 @@ Fast unit testing with Vitest for React libraries:
125125

126126
```bash
127127
# Test a specific library
128-
nx test shop-data
128+
npx nx test shop-data
129129

130130
# Test all projects
131-
nx run-many -t test
131+
npx nx run-many -t test
132132
```
133133

134134
[Learn more about Vite testing →](https://nx.dev/recipes/vite)
@@ -189,29 +189,29 @@ This repository uses tags to enforce module boundaries:
189189

190190
```bash
191191
# Project exploration
192-
nx graph # Interactive dependency graph
193-
nx list # List installed plugins
194-
nx show project shop --web # View project details
192+
npx nx graph # Interactive dependency graph
193+
npx nx list # List installed plugins
194+
npx nx show project shop --web # View project details
195195

196196
# Development
197-
nx serve shop # Serve React app
198-
nx serve api # Serve backend API
199-
nx build shop # Build React app
200-
nx test shop-data # Test a specific library
201-
nx lint shop-feature-products # Lint a specific library
197+
npx nx serve shop # Serve React app
198+
npx nx serve api # Serve backend API
199+
npx nx build shop # Build React app
200+
npx nx test shop-data # Test a specific library
201+
npx nx lint shop-feature-products # Lint a specific library
202202

203203
# Running multiple tasks
204-
nx run-many -t build # Build all projects
205-
nx run-many -t test --parallel=3 # Test in parallel
206-
nx run-many -t lint test build # Run multiple targets
204+
npx nx run-many -t build # Build all projects
205+
npx nx run-many -t test --parallel=3 # Test in parallel
206+
npx nx run-many -t lint test build # Run multiple targets
207207

208208
# Affected commands (great for CI)
209-
nx affected -t build # Build only affected projects
210-
nx affected -t test # Test only affected projects
209+
npx nx affected -t build # Build only affected projects
210+
npx nx affected -t test # Test only affected projects
211211

212212
# Docker operations
213-
nx docker:build api # Build Docker image
214-
nx docker:run api # Run Docker container
213+
npx nx docker:build api # Build Docker image
214+
npx nx docker:run api # Run Docker container
215215
```
216216

217217
## 🎯 Adding New Features
@@ -238,6 +238,28 @@ npx nx g @nx/node:lib my-api-lib
238238

239239
You can use `npx nx list` to see all available plugins and `npx nx list <plugin-name>` to see all generators for a specific plugin.
240240

241+
## Nx Cloud
242+
243+
244+
Nx Cloud ensures a [fast and scalable CI](https://nx.dev/ci/intro/why-nx-cloud?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) pipeline. It includes features such as:
245+
246+
- [Remote caching](https://nx.dev/ci/features/remote-cache?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
247+
- [Task distribution across multiple machines](https://nx.dev/ci/features/distribute-task-execution?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
248+
- [Automated e2e test splitting](https://nx.dev/ci/features/split-e2e-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
249+
- [Task flakiness detection and rerunning](https://nx.dev/ci/features/flaky-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
250+
251+
### Set up CI (non-Github Actions CI)
252+
253+
**Note:** This is only required if your CI provider is not GitHub Actions.
254+
255+
Use the following command to configure a CI workflow for your workspace:
256+
257+
```sh
258+
npx nx g ci-workflow
259+
```
260+
261+
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
262+
241263
## Install Nx Console
242264

243265
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
@@ -262,4 +284,4 @@ Join the Nx community:
262284
- [X (Twitter)](https://twitter.com/nxdevtools)
263285
- [LinkedIn](https://www.linkedin.com/company/nrwl)
264286
- [YouTube](https://www.youtube.com/@nxdevtools)
265-
- [Blog](https://nx.dev/blog)
287+
- [Blog](https://nx.dev/blog)

apps/shop-e2e/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default [
55
playwright.configs['flat/recommended'],
66
...baseConfig,
77
{
8-
files: ['**/*.ts', '**/*.js'],
8+
files: ['src/**/*.ts', 'src/**/*.js'],
99
// Override or add rules here
1010
rules: {},
1111
},

apps/shop/tsconfig.spec.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
"@nx/react/typings/cssmodule.d.ts",
1212
"@nx/react/typings/image.d.ts"
1313
],
14+
"lib": ["es2022", "dom"],
1415
"jsx": "react-jsx"
1516
},
1617
"include": [
1718
"vite.config.ts",
1819
"vite.config.mts",
1920
"vitest.config.ts",
2021
"vitest.config.mts",
22+
"src/test-setup.ts",
2123
"src/**/*.test.ts",
2224
"src/**/*.spec.ts",
2325
"src/**/*.test.tsx",

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default [
1010
'**/vite.config.*.timestamp*',
1111
'**/vitest.config.*.timestamp*',
1212
'**/test-output',
13+
'**/out-tsc'
1314
],
1415
},
1516
{

libs/api/products/src/lib/products.service.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, it, expect, beforeEach } from '@jest/globals';
21
import { ProductsService } from './products.service';
32
// eslint-disable-next-line
43
import { ProductFilter } from '@org/models';

libs/shared/test-utils/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
},
1313
"./package.json": "./package.json"
1414
},
15+
"devDependencies": {
16+
"@org/models": "workspace:*"
17+
},
1518
"nx": {
1619
"sourceRoot": "libs/shared/test-utils/src",
1720
"projectType": "library",

libs/shared/test-utils/src/lib/test-render.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactElement } from 'react';
2-
import { render, RenderOptions } from '@testing-library/react';
2+
import {render, RenderOptions, RenderResult} from '@testing-library/react';
33
import { BrowserRouter } from 'react-router-dom';
44

55
interface AllTheProvidersProps {
@@ -13,9 +13,9 @@ function AllTheProviders({ children }: AllTheProvidersProps) {
1313
export function renderWithRouter(
1414
ui: ReactElement,
1515
options?: Omit<RenderOptions, 'wrapper'>
16-
) {
16+
): RenderResult {
1717
return render(ui, { wrapper: AllTheProviders, ...options });
1818
}
1919

2020
export * from '@testing-library/react';
21-
export { renderWithRouter as render };
21+
export { renderWithRouter as render };

0 commit comments

Comments
 (0)