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
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ jobs:
working-directory: app
steps:
- uses: actions/checkout@v4
# pnpm at the version package.json's packageManager names.
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: app/package-lock.json
- run: npm ci
# npm test lints, then runs the app and most server tests.
- run: npm test
cache: pnpm
cache-dependency-path: app/pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
# pnpm test lints, then runs the app and most server tests.
- run: pnpm test
- run: node ../server/nutritionix.test.js
- run: npm run build
- run: pnpm run build
22 changes: 17 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ jobs:
exit 1
fi

# pnpm at the version package.json names, from the Corepack that ships with node,
# so the runner's PATH needs only node on it.
- name: pnpm on the PATH
run: |
set -euo pipefail
bin="$RUNNER_TEMP/corepack-bin"
mkdir -p "$bin"
corepack enable --install-directory "$bin" pnpm
echo "$bin" >> "$GITHUB_PATH"

- name: Pull
id: pull
run: |
Expand All @@ -71,20 +81,21 @@ jobs:
fi
echo "go=true" >> "$GITHUB_OUTPUT"
changed=$(git diff --name-only "$before" "$after")
printf '%s\n' "$changed" | grep -qE '(^|/)package(-lock)?\.json$' && echo "deps=true" >> "$GITHUB_OUTPUT" || true
printf '%s\n' "$changed" | grep -qE '(^|/)(package(-lock)?\.json|pnpm-(lock|workspace)\.yaml)$' && echo "deps=true" >> "$GITHUB_OUTPUT" || true
# What the iPhone app is built from: its own folder.
printf '%s\n' "$changed" | grep -qE '^mobile/' && echo "mobile=true" >> "$GITHUB_OUTPUT" || true
echo "Deploying $(git log --oneline -1) (was ${before:0:7})"
git log --oneline "$before..$after"

# The root's postinstall installs app/ (pnpm --dir app install).
- name: Install dependencies
if: steps.pull.outputs.deps == 'true'
run: |
npm ci --no-audit --no-fund
pnpm install --frozen-lockfile

- name: Build
if: steps.pull.outputs.go == 'true'
run: npm run build
run: pnpm run build

- name: Restart
if: steps.pull.outputs.go == 'true'
Expand Down Expand Up @@ -115,9 +126,10 @@ jobs:
echo "::warning::Rolling back to ${{ steps.pull.outputs.before }}"
git reset --hard --quiet "${{ steps.pull.outputs.before }}"
if [ "${{ steps.pull.outputs.deps }}" = true ]; then
npm ci --no-audit --no-fund
# The commit rolled back to may predate pnpm (it has a package-lock.json).
if [ -f app/pnpm-lock.yaml ]; then pnpm install --frozen-lockfile; else npm ci --no-audit --no-fund; fi
fi
npm run build
npm run build # the root's build script, whichever manager that commit used
if [ "$(uname)" = Darwin ]; then
launchctl kickstart -k "gui/$(id -u)/$DEPLOY_SERVICE"
else
Expand Down
18 changes: 12 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,31 @@ disk. Default port **8101**.
| Cached product photos — disposable, one JPEG per gtin | `data/images/` |

```bash
npm install && npm start # installs app/ deps, builds, serves on 8101
npm test # lint + every suite, including sign-in and fresh-install
npm run build # emits dist/ — A CHANGE IS NOT LIVE UNTIL YOU BUILD
pnpm install && pnpm start # installs app/ deps, builds, serves on 8101
pnpm test # lint + every suite, including sign-in and fresh-install
pnpm run build # emits dist/ — A CHANGE IS NOT LIVE UNTIL YOU BUILD
node scripts/basics.build.mjs # regenerate the generic-food catalog
npm run build:menus # optional chain menus (or name some: -- culvers chipotle)
pnpm run build:menus # optional chain menus (or name some: culvers chipotle)
```

**pnpm, not npm: never run `npm install` or `npm ci` at the root or in `app/`.** npm
ignores `pnpm-lock.yaml` and writes its own tree. `mobile/` is the exception: it stays
on npm (`npm ci` there): under pnpm its installed tree differed in 78 places (the bundle
itself came out the same), and EAS's cloud build would switch to pnpm, which only a real
build could check.

Operational detail (Docker, a systemd unit, backups, every env var) is in
`docs/self-hosting.md` and `.env.example`.

**`npm test` starts with `eslint src`, and it is one rule: `rules-of-hooks`.**
**`pnpm test` starts with `eslint src`, and it is one rule: `rules-of-hooks`.**
It caught a real crash the hour it went in: `FoodView` called a `useMemo` below
an early return, so the hook count changed the moment the store hydrated and
React blanked the whole app with a minified #310. No render test can see that:
server rendering runs each component once, with a fresh instance, so both
branches render perfectly on their own. Do not add a style config around it;
formatting opinions would bury the one rule that matters.

**`dist/` is served off disk, so `npm run build` is the step that makes app
**`dist/` is served off disk, so `pnpm run build` is the step that makes app
changes real.** Code in the repo, passing every test, while the phone runs a
weeks-old bundle is a real failure mode. `grep -o 'assets/[^"]*' dist/index.html`
shows which build is being served.
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ RUN apt-get update \
&& if [ "$WITH_CLAUDE" = "1" ]; then npm install -g @anthropic-ai/claude-code && npm cache clean --force; fi

WORKDIR /srv/krakatoa
COPY app/package.json app/package-lock.json app/
RUN npm --prefix app ci --no-audit --no-fund
RUN corepack enable pnpm
COPY app/package.json app/pnpm-lock.yaml app/pnpm-workspace.yaml app/
# Corepack takes pnpm's version from the package.json in the working directory.
RUN cd app && pnpm install --frozen-lockfile
COPY . .
RUN npm --prefix app run build \
RUN cd app && pnpm run build \
&& mkdir -p /data /home/node/.claude \
&& chown node:node /data /home/node/.claude

Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Formerly called **Fuel** (renamed 2026-10-02).
by a script. None of the numbers are typed by hand.
- **Restaurant menus (optional).** Build a bowl part by part or an order size by
size, and watch the total update. The menu data is not necessarily included:
`npm run build:menus` generates it from each chain's own published nutrition
`pnpm run build:menus` generates it from each chain's own published nutrition
information (see [Restaurant menus](docs/self-hosting.md#restaurant-menus-optional)).
Without it the app works as normal and the menu screen says none are built.
- **Nutrition label reader.** Photograph the Nutrition Facts panel and a headless
Expand Down Expand Up @@ -105,13 +105,14 @@ bugs that shaped them. Read it before changing anything substantial.

## Self-hosting quick start

You need Node.js 22 or newer.
You need Node.js 22 or newer and pnpm (`corepack enable pnpm` gives you the version
`package.json` names).

```bash
git clone https://github.com/ehonis/krakatoa.git
cd krakatoa
npm install # installs the frontend's build tools (the server has no dependencies)
npm start # builds the app, then serves it on port 8101
pnpm install # installs the frontend's build tools (the server has no dependencies)
pnpm start # builds the app, then serves it on port 8101
```

1. Look at the terminal. On first run the server prints a one-time link:
Expand Down Expand Up @@ -158,18 +159,21 @@ precedence over Settings. They are listed in [.env.example](.env.example).
data and backups, regenerating the content files, the optional integrations,
and running the app as a service.

For development, run the server (`npm run serve`) and, beside it, `npm run dev`,
For development, run the server (`pnpm run serve`) and, beside it, `pnpm run dev`,
which starts Vite on port 5173. Vite proxies `/api`, `/mcp`, `/login` and
`/setup` to the server on port 8101 (or `KRAKATOA_DEV_BACKEND`), keeping the
browser's Host header, so sign-in works through 5173 unchanged.

## Tests

```bash
npm test # eslint (rules-of-hooks), the app and server suites, sign-in and fresh-install tests
npm run build
pnpm test # eslint (rules-of-hooks), the app and server suites, sign-in and fresh-install tests
pnpm run build
```

The root and `app/` use pnpm, not npm: never run `npm install` or `npm ci` there (npm ignores
`pnpm-lock.yaml`). The iPhone app in `mobile/` is the exception and stays on npm.

These are the same steps CI runs (`.github/workflows/ci.yml`, from `app/`).

## License
Expand Down
Loading
Loading