DISCLOSURE: This app is not legally viable as specified. See Architectural Decisions.
Distribu-tip splits a weekly cash tip pool across the employees who worked that week, proportionally to hours, and reports how many $20, $10, $5 and $1 bills are needed to pay everyone with the fewest bills per person.
The app is a calculator and a record, not a payment system. Counting the tips, getting change from the bank, and handing out envelopes all happen outside it.
- Node: 26
- see ./.nvmrc for confirmation
- Expo
58.0.17 - Emulators/Simulators to test on. Some options:
- Android emulator
- iOS simulator
- Expo Go, a limited sandbox for trying out app development with Expo
Install dependencies and the husky + lint-staged pre-commit hooks:
npm ciSteps 1–5 are one-time. Then see Every session.
Requires:
- Windows 11 22H2+
- Android 11+ phone with Expo Go
- Until Expo Go 58 reaches Google Play, side-load it once
adbis connected (step 5):If that fails withnpx expo-go download android 58 adb install Expo-Go-58.*.apkINSTALL_FAILED_UPDATE_INCOMPATIBLE, runadb uninstall host.exp.exponentand install again. Once Play ships 58 there's nothing to undo; Play won't replace it with an older build.
- Until Expo Go 58 reaches Google Play, side-load it once
- PC and phone on the same Wi-Fi (if guest/campus Wi-Fi: use the tunnel fallback)
Clone under ~/ (e.g. ~/.../distribu-tip), not /mnt/c/.
In %UserProfile%\.wslconfig:
[wsl2]
networkingMode=mirroredRestart WSL (PowerShell):
wsl --shutdownCheck: ip addr in Ubuntu lists your Wi-Fi IP.
Admin PowerShell:
New-NetFirewallHyperVRule -Name "Metro" -DisplayName "Metro bundler (Expo)" -Direction Inbound -VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -Protocol TCP -LocalPorts 8081Check: Get-NetFirewallHyperVRule -Name "Metro". Remove: Remove-NetFirewallHyperVRule -Name "Metro".
sudo apt install -y unzip
curl -LO https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip -d ~/android-sdk
rm platform-tools-latest-linux.zip
echo 'export ANDROID_HOME="$HOME/android-sdk"' >> ~/.bashrc
echo 'export PATH="$ANDROID_HOME/platform-tools:$PATH"' >> ~/.bashrc
source ~/.bashrc
adb version-
Phone: Settings → About phone → tap Build number 7 times.
-
Developer options → Wireless debugging → on → Pair device with pairing code.
-
Pair with the IP:port from the pairing dialog, then enter the code:
adb pair <ip>:<pairing-port>
-
Check:
adb devices
Not listed? Use the IP:port from the main Wireless debugging screen:
adb connect <ip>:<port>
After a reboot or Wi-Fi change: turn Wireless debugging back on, re-run adb connect with the new port. No re-pairing.
npx expo startScan the QR code in Expo Go, or press a. The URL should be exp://<Wi-Fi IP>:8081; if not, recheck step 2.
Use only if LAN fails (slower, public URL):
npm i -g @expo/ngrok
npx expo start --tunnelnpm test # Run the full test suite
npm run test:app -- --selectProjects core # run core tests only
npm run test:tooling # run tests of tooling only
npm run test:app -- --selectProjects app-ios # run ios tests only
npm run test:app -- --selectProjects app-android # run android tests only
npm run typecheck # check for type errorsNote: Any jest run that skips the tooling project and doesn't set --experimental-vm-modules passes.
-
jestnow tests by project type -core,tooling,app-ios, andapp-android.coreandtoolingare set to use ts-jest, while all app related tests now usejest-expo's babel presets. -
npx jestby itself fails because running__tests__/core-boundary.test.tsrequiresNODE_OPTIONS=--experimental-vm-modulesto run. However, running jest with a globalNODE_OPTIONS=--experimental-vm-modulescauses tests using expo'srenderRouterto fail with the following output when working with actual routes:
Test suite failed to run: Must use import to load ES Module: …/standard-navigation/lib/src/index.js
Since the kids won't get along, I've separated them into two different npm scripts:
-
npm run test:tooling, which runs the tooling project with its much needed node environment -
npm run test:app, which runs everything except thetoolingproject (viajest --ignoreProjects tooling-- essentially ignoring the project that won't get along with the others). -
npm teststill gets to run the full test suite runningtest:toolingfirst, thentest:appafterward, so it gets to stay happy, too. -
When to revisit:
| Undo it when | What to Check | When to Check | Verification Test |
|---|---|---|---|
| Jest ESM support stops being experimental | The Jest ECMAScript Modules docs page drops the "experimental" banner and no longer tells us to run with --experimental-vm-modules. Jest depends on Node's vm.SourceTextModule here, so also look for that API being marked stable in a Node changelog. |
When upgrading Jest. I'm on jest ^30.5.2 right now, and jest-expo ties the Jest major to the Expo SDK, so this likely means each Expo SDK upgrade. Also check on each Node major upgrade (currently on 26). |
Remove NODE_OPTIONS=... from test:tooling and run it. |
| ESLint loads TS configs without a dynamic import | ESLint's release notes mention a change to how config files are loaded (look for "config loading", jiti, or "native TypeScript"). |
When ESLint updates. I've pinned ^10.11.0, so minor versions come in on any npm update |
When running the test suite without the flag, the misleading error 'jiti is required' that new ESLint({ cwd: ROOT }) throws in __tests__/core-boundary.test.ts goes away. |
| The boundary test moves to a child process (this is in my control now) | core-boundary.test.ts no longer imports ESLint from "eslint" and runs it as a subprocess instead (e.g. spawnSync of eslint --stdin --stdin-filename src/core/probe.ts --format json) and parses the JSON output. |
Whenever I decide to, really. Some things I might pay attention to: if the two-script setup causes friction via running npx jest I get confused about the failure or if the CI duplicates work; if I add a second tooling test that also needs the flag |
test:tooling works without the flag |
This repo was started with ts-jest - with it, we GAIN direct access to the TypeScript compiler, allowing the library to read the tsconfig and report type errors in tests, tightening the testing cycle. In comparison, babel-jest allows Jest to run against .ts files, but it strips the types without checking them.
The trade-off in choosing ts-jest is that it runs slower than babel-jest, and it is also currently locked to TypeScript 6 (see ts-jest section), which means it doesn't have access to TypeScript 7's improvements.
Note: As this application uses Expo, ts-jest is now used for core and tooling, while the app code runs on Babel via jest-expo. This loses the paired "test-and-typecheck" benefits for app code, but npm run typecheck is required to pass before any PR merge -- it uses tsc from TypeScript 7, and can also be run locally before every commit.
This package has two TypeScript versions installed side by side, a necessity for running ts-jest v29 alongside TypeScript 7.
ts-jest notes that Typescript 7.0 doesn't ship with the Javascript Compiler API ts-jest needs for its tooling. This is also why both Expo 57 and 58 don't bundle with TypeScript 7 - they're waiting on a public API as well. Taking up ts-jest's suggestion to install TypeScript 7 under an alias, this project includes it under @typescript/native, and calls its tsc directly in its package's npm run typecheck script.
This allows TS7's blazingly fast typecheck during development and CI while still providing TypeScript 6 so this repo's other libraries can still operate with TypeScript support.
Disclaimer:
The rules that currently govern how tips are distributed appear to conflict with Illinois law. This repo seeks to make sure they are isolated behind a single function so that a fix is contained. See ADR-001.
For decisions that helped shape this repo, see docs/adr/README.md