Skip to content

Commit 1cd3f0c

Browse files
committed
chore: add local dev scripts, tests in CI, and n8n preview tooling
Add n8n-node dev wrapper, tickets smoke test script, Node 22 pin, README testing docs, CI test step, and @n8n/node-cli dev dependency.
1 parent cea97b3 commit 1cd3f0c

9 files changed

Lines changed: 3587 additions & 52 deletions

File tree

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# HaloPSA OAuth credentials for local smoke testing (scripts/smoke-tickets-getall.mjs).
2+
# Copy to .env and fill in values. Never commit .env.
3+
4+
HALO_BASE_URL=https://your-instance.halopsa.com
5+
HALO_CLIENT_ID=
6+
HALO_CLIENT_SECRET=
7+
HALO_SCOPE=all
8+
9+
# Optional filters (defaults match Allixo bug report)
10+
HALO_REQUESTTYPE_ID=40
11+
HALO_OPEN_ONLY=true

.github/workflows/supply-chain.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,8 @@ jobs:
4747
- name: Build
4848
run: pnpm run build
4949

50+
- name: Test
51+
run: pnpm test
52+
5053
- name: Lint
5154
run: pnpm run lint

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Node.js dependencies
22
/node_modules
3+
.pnpm-store
34

45
# Other package managers (this repo uses pnpm only — see SECURITY.md)
56
package-lock.json
@@ -13,7 +14,7 @@ bun.lockb
1314
/build
1415
/lib
1516

16-
# Logs and temporary files
17+
# Logs, local env, and temporary files
1718
*.log
1819
.DS_Store
1920
.env

.nvmrc

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

README.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,66 @@ pnpm run build
1515

1616
Use **pnpm only** for installs in this repo. With Corepack enabled, `npm install` and `yarn install` are rejected. Do not commit `package-lock.json` or `yarn.lock` (see [SECURITY.md](SECURITY.md)).
1717

18-
### Live preview with `n8n-node dev`
18+
### Testing locally
19+
20+
**Unit tests** (no HaloPSA credentials required):
1921

2022
```bash
21-
n8n-node dev
23+
pnpm test
2224
```
2325

24-
Requires **Node.js 22.22.3+**.
26+
**Live n8n preview** — runs n8n at http://localhost:5678 with this node linked for hot reload:
27+
28+
```bash
29+
pnpm run dev
30+
```
31+
32+
Use **Node.js 22 LTS** (`nvm use` reads `.nvmrc`). Node 23+ is not supported by n8n’s native dependencies.
33+
34+
**First run takes several minutes.** `n8n-node dev` downloads n8n via `npx` into `~/.n8n-node-cli`. You will see many `npm warn` lines about peer dependencies — that is normal. Wait until the n8n panel shows:
35+
36+
```
37+
Editor is now accessible via: http://localhost:5678
38+
```
39+
40+
Do not stop the process during the install. If you see `Shutting down gracefully` with exit code 1, you likely interrupted it with Ctrl+C before n8n finished starting.
41+
42+
Prefer **`pnpm run dev`** over a globally installed `n8n-node` so the CLI version matches this repo.
43+
44+
Configure HaloPSA OAuth credentials in the n8n UI, then test **Tickets → Get Many** with filters and **Return All** enabled.
45+
46+
Open **http://localhost:5678** (not `127.0.0.1` or a LAN IP). `pnpm run dev` sets `N8N_SECURE_COOKIE=false` for local HTTP so Safari and other browsers can sign in. To keep secure cookies enabled, set `N8N_SECURE_COOKIE=true` yourself and use HTTPS.
47+
48+
If the node does not appear after changes:
49+
50+
```bash
51+
rm -rf ~/.n8n-node-cli/.n8n/custom
52+
pnpm run dev
53+
```
54+
55+
**Already running n8n elsewhere** (Docker, etc.):
56+
57+
```bash
58+
pnpm run build
59+
pnpm run dev:external
60+
```
61+
62+
Set `N8N_DEV_RELOAD=true` and point your n8n instance’s custom extensions folder at `~/.n8n-node-cli/.n8n/custom` (or symlink this repo into your instance’s custom nodes directory).
63+
64+
Use `pnpm run watch` for TypeScript watch mode only (no n8n).
65+
66+
**Smoke test against a live HaloPSA instance** (validates the tickets getAll filter + bulk-fetch query shape):
67+
68+
```bash
69+
cp .env.example .env # fill in HALO_BASE_URL, HALO_CLIENT_ID, HALO_CLIENT_SECRET
70+
pnpm test:smoke
71+
```
72+
73+
Optional: `HALO_REQUESTTYPE_ID`, `HALO_OPEN_ONLY` (see `.env.example`).
74+
75+
### Live preview with `n8n-node dev`
76+
77+
Same as `pnpm run dev` above. Requires **Node.js 22.22.3+** (22.x LTS recommended).
2578

2679
## Installation
2780

@@ -63,7 +116,7 @@ Operations that support **Filters** also expose **Filters (JSON)** for runtime v
63116

64117
Use the JSON fields when driving values from webhooks, upstream nodes, or expressions; use the UI collections for static values.
65118

66-
**Return All** on list operations paginates through the HaloPSA API automatically (1000 rows per page).
119+
**Return All** on list operations fetches up to 1000 rows in a single request, then continues with paginated requests (100 per page) when more records exist.
67120

68121
## Supported Operations
69122

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@
2727
"scripts": {
2828
"audit:supply-chain": "node scripts/check-supply-chain.mjs",
2929
"build": "pnpm exec rimraf dist && pnpm exec tsc && pnpm exec gulp build:icons",
30-
"dev": "pnpm exec tsc --watch",
30+
"dev": "node scripts/n8n-dev.mjs",
31+
"dev:external": "N8N_DEV_RELOAD=true N8N_SECURE_COOKIE=false node scripts/n8n-dev.mjs --external-n8n",
32+
"watch": "pnpm exec tsc --watch",
3133
"format": "pnpm exec prettier nodes credentials --write",
3234
"lint": "pnpm exec eslint nodes credentials package.json",
3335
"lintfix": "pnpm exec eslint nodes credentials package.json --fix",
3436
"test": "pnpm exec tsc && node --test dist/test/*.test.js",
37+
"test:smoke": "node --env-file=.env scripts/smoke-tickets-getall.mjs",
3538
"prepublishOnly": "pnpm run audit:supply-chain && pnpm run build && pnpm exec eslint -c eslint.config.prepublish.mjs nodes credentials package.json"
3639
},
3740
"files": [
@@ -51,6 +54,7 @@
5154
},
5255
"devDependencies": {
5356
"@n8n/eslint-plugin-community-nodes": "0.18.0",
57+
"@n8n/node-cli": "0.34.0",
5458
"@types/node": "25.9.2",
5559
"@typescript-eslint/parser": "8.60.1",
5660
"eslint": "10.4.1",

0 commit comments

Comments
 (0)