Skip to content

About

Helping you calculate and distribute your tips - faster

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Distribu-tip

Continuous Integration Workflow Status Badge

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.

Prerequisites

  • Node: 26
    • see ./.nvmrc for confirmation
  • Expo 58.0.17
  • Emulators/Simulators to test on. Some options:

Development Setup

Install dependencies and the husky + lint-staged pre-commit hooks:

npm ci

Running the app on an Android phone from WSL 2

Steps 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 adb is connected (step 5):
      npx expo-go download android 58
      adb install Expo-Go-58.*.apk
      If that fails with INSTALL_FAILED_UPDATE_INCOMPATIBLE, run adb uninstall host.exp.exponent and install again. Once Play ships 58 there's nothing to undo; Play won't replace it with an older build.
  • PC and phone on the same Wi-Fi (if guest/campus Wi-Fi: use the tunnel fallback)

1. Keep the repo in the Linux filesystem

Clone under ~/ (e.g. ~/.../distribu-tip), not /mnt/c/.

2. Turn on mirrored networking

In %UserProfile%\.wslconfig:

[wsl2]
networkingMode=mirrored

Restart WSL (PowerShell):

wsl --shutdown

Check: ip addr in Ubuntu lists your Wi-Fi IP.

3. Open Metro's port in the Hyper-V firewall

Admin PowerShell:

New-NetFirewallHyperVRule -Name "Metro" -DisplayName "Metro bundler (Expo)" -Direction Inbound -VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -Protocol TCP -LocalPorts 8081

Check: Get-NetFirewallHyperVRule -Name "Metro". Remove: Remove-NetFirewallHyperVRule -Name "Metro".

4. Install Android platform-tools (adb) in WSL

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

5. Pair the phone over Wi-Fi

  1. Phone: Settings → About phone → tap Build number 7 times.

  2. Developer options → Wireless debugging → on → Pair device with pairing code.

  3. Pair with the IP:port from the pairing dialog, then enter the code:

    adb pair <ip>:<pairing-port>
  4. 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.

Every session

npx expo start

Scan the QR code in Expo Go, or press a. The URL should be exp://<Wi-Fi IP>:8081; if not, recheck step 2.

Fallback: --tunnel

Use only if LAN fails (slower, public URL):

npm i -g @expo/ngrok
npx expo start --tunnel

Running Tests

npm 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 errors

Note: Any jest run that skips the tooling project and doesn't set --experimental-vm-modules passes.

  • jest now tests by project type - core, tooling, app-ios, and app-android. core and tooling are set to use ts-jest, while all app related tests now use jest-expo's babel presets.

  • npx jest by itself fails because running __tests__/core-boundary.test.ts requires NODE_OPTIONS=--experimental-vm-modules to run. However, running jest with a global NODE_OPTIONS=--experimental-vm-modules causes tests using expo's renderRouter to 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 the tooling project (via jest --ignoreProjects tooling -- essentially ignoring the project that won't get along with the others).

  • npm test still gets to run the full test suite running test:tooling first, then test:app afterward, 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

Note on ts-jest

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.

ts-jest's unique dependency configuration

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.

Architectural Decisions

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

About

Helping you calculate and distribute your tips - faster

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages