Skip to content

Commit b23547d

Browse files
committed
chore: use tsx for all Nx commands to be able to execute local plugins same as other projects
1 parent 3dbf378 commit b23547d

File tree

10 files changed

+65
-7
lines changed

10 files changed

+65
-7
lines changed

.env.example

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
# for uploading to portal
1+
# Example environment variables
2+
# These are for reference only - use .env.local for local development
3+
4+
# For uploading to Code PushUp portal
25
CP_API_KEY=
6+
7+
# Note: For local development with tsx/TypeScript execution,
8+
# copy .env.local.example to .env.local and configure NODE_OPTIONS there

.env.local.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Local development environment variables
2+
# Copy this to .env.local (gitignored) and customize for your setup
3+
4+
# Enable tsx for TypeScript execution in Nx
5+
# This allows running local generator/executor directly as .ts files without pre-compilation
6+
# This allowes the local plugins to import files with .js extensions (same as the packages in the repository)
7+
NODE_OPTIONS=--import tsx
8+
# This is used to resolve the paths in the local generator/executor so local packages can be imported as path aliases
9+
TSX_TSCONFIG_PATH=tsconfig.base.json
10+
11+
# Local API keys (optional - only if testing upload features)
12+
# CP_API_KEY=your_api_key_here

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
env:
1010
NX_NON_NATIVE_HASHER: true
1111
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
12+
NODE_OPTIONS: --import tsx
13+
TSX_TSCONFIG_PATH: tsconfig.base.json
1214

1315
jobs:
1416
format:

.github/workflows/code-pushup-fork.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ on:
1313

1414
env:
1515
NX_NON_NATIVE_HASHER: true
16+
NODE_OPTIONS: --import tsx
17+
TSX_TSCONFIG_PATH: tsconfig.base.json
1618

1719
permissions:
1820
pull-requests: write

.github/workflows/code-pushup.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
env:
1010
NX_NON_NATIVE_HASHER: true
1111
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
12+
NODE_OPTIONS: --import tsx
13+
TSX_TSCONFIG_PATH: tsconfig.base.json
1214

1315
permissions:
1416
pull-requests: write

.github/workflows/coverage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
env:
88
NX_NON_NATIVE_HASHER: true
99
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
10+
NODE_OPTIONS: --import tsx
11+
TSX_TSCONFIG_PATH: tsconfig.base.json
1012

1113
jobs:
1214
list-packages:

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ permissions:
1818
env:
1919
NX_NON_NATIVE_HASHER: true
2020
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
21+
NODE_OPTIONS: --import tsx
22+
TSX_TSCONFIG_PATH: tsconfig.base.json
2123

2224
jobs:
2325
publish:

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
env:
1818
NX_NON_NATIVE_HASHER: true
1919
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
20+
NODE_OPTIONS: --import tsx
21+
TSX_TSCONFIG_PATH: tsconfig.base.json
2022
steps:
2123
- name: Authenticate as "Code PushUp Bot" GitHub App
2224
uses: actions/create-github-app-token@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

33
.env
4+
.env.local
45
.npmrc
56

67
# compiled output

CONTRIBUTING.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,38 @@ npm install
1616

1717
This table provides a quick overview of the environmental setup, with detailed explanations in the corresponding sections.
1818

19-
| Feature | Local Default | CI Default | Description |
20-
| ------------------------------- | ------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------- |
21-
| `env.INCLUDE_SLOW_TESTS` **❗️** | `false` | `true` | Controls inclusion of long-running tests. Overridden by setting. Details in the [Testing](#Testing) section. |
22-
| `env.CUSTOM_CHROME_PATH` | N/A | Windows **❗️❗️** | Path to Chrome executable. See [plugin-lighthouse/CONTRIBUTING.md](./packages/plugin-lighthouse/CONTRIBUTING.md#chrome-path). |
23-
| Quality Pipeline | Off | On | Runs all plugins against the codebase. |
19+
| Feature | Local Default | CI Default | Description |
20+
| ------------------------------- | ------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
21+
| `NODE_OPTIONS` **⚙️** | Set in `.env.local` | Set globally in workflows | `--import tsx` - Enables TypeScript execution for local Nx plugins and generators. **Required for development.** |
22+
| `TSX_TSCONFIG_PATH` **⚙️** | Set in `.env.local` | Set globally in workflows | `tsconfig.base.json` - Resolves TypeScript path aliases for local packages. **Required for development.** |
23+
| `env.INCLUDE_SLOW_TESTS` **❗️** | `false` | `true` | Controls inclusion of long-running tests. Overridden by setting. Details in the [Testing](#Testing) section. |
24+
| `env.CUSTOM_CHROME_PATH` | N/A | Windows **❗️❗️** | Path to Chrome executable. See [plugin-lighthouse/CONTRIBUTING.md](./packages/plugin-lighthouse/CONTRIBUTING.md#chrome-path). |
25+
| Quality Pipeline | Off | On | Runs all plugins against the codebase. |
26+
27+
**⚙️** TypeScript Execution Setup (Required)
28+
29+
This project uses local Nx plugins and generators written in TypeScript. To run them, you need:
30+
31+
1. **Create `.env.local`** (gitignored, local-only):
32+
33+
```sh
34+
cp .env.local.example .env.local
35+
```
36+
37+
2. **The file includes** (already configured in the example):
38+
39+
```sh
40+
NODE_OPTIONS=--import tsx
41+
TSX_TSCONFIG_PATH=tsconfig.base.json
42+
```
43+
44+
3. **Why these are needed**:
45+
- `NODE_OPTIONS` - Allows importing TypeScript files with `.js` extensions (used throughout the repo)
46+
- `TSX_TSCONFIG_PATH` - Enables path aliases like `@code-pushup/models` in generators/executors
47+
48+
4. **CI Configuration**:
49+
- Both variables are set **globally** in all GitHub Actions workflows
50+
- Ensures consistent behavior between local development and CI
2451

2552
**❗️** Test Inclusion Logic
2653

@@ -66,7 +93,7 @@ Some of the plugins have a longer runtime. In order to ensure better DX, longer
6693

6794
You can control the execution of long-running tests over the `INCLUDE_SLOW_TESTS` environment variable.
6895

69-
To change this setup, open (or create) the `.env` file in the root folder.
96+
To change this setup, open your `.env.local` file in the root folder (or copy from `.env.local.example` if it doesn't exist).
7097
Edit or add the environment variable there as follows: `INCLUDE_SLOW_TESTS=true`.
7198

7299
## Git

0 commit comments

Comments
 (0)