Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@

## Local dev workflows

- Root dev: `npm run start` runs shared package watch, functions build-watch, Firebase emulators, then Vite after `healthCheck` is up (see `package.json` and `firebase.json`).
- Frontend-only: `npm run dev:vite` or `npm run dev:extractions-test` (see `package.json`).
- Functions: `cd functions && npm run build:watch` and `npm run serve` for emulators; deploy with `npm run deploy`.
- Shared package: `npm run build:shared` builds `functions/shared`, and `npm run build:shared:watch` keeps shared outputs fresh during local development.
- DB workflow: local functions connect to the shared dev SQL Server through a developer-managed Cloud SQL proxy; the repo does not manage schema migrations or seed data (see `functions/README.md`).
- Run tests with `npm run test` (see `vite.config.ts` for test config).
- Run linting with `npm run lint` (see `package.json`).
- Run type checks with `npm run check` (see `package.json`).
- Root dev: `pnpm start` runs shared package watch, functions build-watch, Firebase emulators, then Vite after `healthCheck` is up (see `package.json` and `firebase.json`).
- Frontend-only: `pnpm dev:vite` or `pnpm dev:extractions-test` (see `package.json`).
- Functions: `pnpm --filter @ugrc/wri-functions build:watch` and `pnpm --filter @ugrc/wri-functions serve` for emulators; deploy with `pnpm --filter @ugrc/wri-functions deploy`.
- Shared package: `pnpm build:shared` builds `functions/shared`, and `pnpm build:shared:watch` keeps shared outputs fresh during local development.
- DB workflow: local functions connect to the shared dev SQL Server through a developer-managed Cloud SQL proxy; forward-only schema and reference-data changes are managed with Knex migrations (see `functions/README.md`).
- Run tests with `pnpm test` (see `vite.config.ts` for test config).
- Run linting with `pnpm lint` (see `package.json`).
- Run type checks with `pnpm check` (see `package.json`).
- Run tests, linting, and type checks after every code change to verify correctness and catch issues early.

## Environment and auth conventions

- Root `.env.local` must define `VITE_FIREBASE_CONFIG` JSON (frontend bootstrap in `src/main.tsx`).
- Local auth is optional in development; set `DEV_USER_EMAIL` in `.env.local` to let `npm start` auto-load credentials from the dev database for the session (see `functions/README.md`).
- Local auth is optional in development; set `DEV_USER_EMAIL` in `.env.local` to let `pnpm start` auto-load credentials from the dev database for the session (see `functions/README.md`).
- `DATABASE_INFORMATION` is a Firebase secret with `user`, `password`, and `instance` for prod DB access (see `README.md`, `functions/src/database.ts`).

## Project-specific patterns
Expand All @@ -34,7 +34,7 @@
- Knex connection is cached across invocations and cleaned on process exit (see `functions/src/database.ts`).
- Map UI uses context providers (`MapProvider`, `ProjectProvider`, `FilterProvider`) and ArcGIS components from `@arcgis/map-components` (see `src/main.tsx`, `src/App.tsx`, `src/AppSearch.tsx`).
- Production base path is `/wri/` (see `vite.config.ts`), so keep asset and routing paths compatible.
- ArcGIS assets are copied into `public/js/ugrc/assets` via `npm run copy:arcgis` when needed.
- ArcGIS assets are copied into `public/js/ugrc/assets` via `pnpm copy:arcgis` when needed.

## Integration points

Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,25 @@ jobs:
with:
show-progress: false

- name: 📦 Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 12

- name: ⎔ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: lts/*
cache: npm
cache: pnpm

- name: 📥 Download dependencies
run: npm ci && cd functions && npm ci
run: pnpm install --frozen-lockfile

- name: 🧶 Lint
run: npm run lint
run: pnpm lint

- name: 🧪 Check types
run: npm run check
run: pnpm check

test-unit:
name: Unit tests
Expand All @@ -47,14 +52,19 @@ jobs:
with:
show-progress: false

- name: 📦 Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 12

- name: ⎔ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: lts/*
cache: npm
cache: pnpm

- name: 📥 Download dependencies
run: npm ci && cd functions && npm ci
run: pnpm install --frozen-lockfile

- name: 🧪 Run tests
run: npm test
run: pnpm test
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ Staging: [wri-stage.at.utah.gov](https://wri-stage.at.utah.gov)
1. Duplicate `.env.example` as `.env.local` in the root directory and fill in the required values
1. Start your Cloud SQL proxy for the at database
1. See `functions/README.md` for the local Firebase Functions and database requirements
1. Install dependencies with `pnpm install` in the root directory; this installs all workspace packages.

Set `DEV_USER_EMAIL` in `.env.local` if you want `npm start` to inject your local edit credentials from the dev database.
Set `DEV_USER_EMAIL` in `.env.local` if you want `pnpm start` to inject your local edit credentials from the dev database.

### Running Locally

1. Run `gcloud auth application-default login` and authenticate
1. Run `cloud-sql-proxy ut-dnr-dwr-wri-app-at:us-west3:nrgcwridbt -p 7777`
1. In a new tab, make sure you are in the WRI repo, and run `npm start`
1. In a new tab, make sure you are in the WRI repo, and run `pnpm start`
1. Navigate to http://localhost:5173/

### Publishing Services to ArcGIS Server
Expand Down Expand Up @@ -55,9 +56,6 @@ See `gptasks/Readme.md`
}
```

> [!WARNING]
> This project is currently using NPM. If it is switched to PNPM, then we will need to coordinate with DTS to update the deployment pipeline in Jenkins.

## Attribution

This project was developed with the assistance of [GitHub Copilot](https://github.com/features/copilot).
21 changes: 11 additions & 10 deletions functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ This directory contains Firebase Cloud Functions for the WRI (Watershed Restorat

## Available Scripts

### `npm run build`
Run these commands from the repository root, targeting the Functions workspace package:

### `pnpm --filter @ugrc/wri-functions build`

Builds the Firebase Functions TypeScript source into `lib/`.

### `npm run build:watch`
### `pnpm --filter @ugrc/wri-functions build:watch`

Watches the Firebase Functions TypeScript source and rebuilds on change.

### `npm run serve`
### `pnpm --filter @ugrc/wri-functions serve`

Builds the functions and starts the local Firebase Functions emulator.

Expand All @@ -36,7 +38,7 @@ The functions use Knex.js for runtime database operations.

## Local Development — Auth & `allowEdits`

In production the Java app injects `UserKey` and `Token` into a hidden `#user-data` form before the Vite bundle loads. Locally that form is empty, so `npm start` can optionally inject credentials from the dev database when `DEV_USER_EMAIL` is configured.
In production the Java app injects `UserKey` and `Token` into a hidden `#user-data` form before the Vite bundle loads. Locally that form is empty, so `pnpm start` can optionally inject credentials from the dev database when `DEV_USER_EMAIL` is configured.

Prerequisites:

Expand All @@ -50,7 +52,7 @@ Set this optional value in root `.env.local` if you want local edit credentials:
DEV_USER_EMAIL=your.email@example.com
```

When `DEV_USER_EMAIL` is set, `npm start` reads `UserKey` and `Token` for that user from the dev database and injects them into the local app session. If `DEV_USER_EMAIL` is omitted, the app still starts but runs without local credentials, which means edit operations remain unavailable.
When `DEV_USER_EMAIL` is set, `pnpm start` reads `UserKey` and `Token` for that user from the dev database and injects them into the local app session. If `DEV_USER_EMAIL` is omitted, the app still starts but runs without local credentials, which means edit operations remain unavailable.

### Local Development — Database Ownership

Expand All @@ -67,11 +69,10 @@ The functions package now includes a forward-only Knex migration framework for n
Available commands:

```bash
cd functions
npm run db:migrate:status
npm run db:migrate:latest
npm run db:migrate:rollback
npm run db:migrate:make -- migration_name
pnpm --filter @ugrc/wri-functions db:migrate:status
pnpm --filter @ugrc/wri-functions db:migrate:latest
pnpm --filter @ugrc/wri-functions db:migrate:rollback
pnpm --filter @ugrc/wri-functions db:migrate:make -- migration_name
```

Notes:
Expand Down
Loading
Loading