joplock/scripts/setup-joplin-cli.sh
igor d0321d595d fix(joplin): stop Joplock destroying Joplin fields; guard encrypted/HTML/conflict items
Serializers rebuilt items from hard-coded values on every write, so one body edit
turned to-dos into plain notes, wiped author/source/location, flipped HTML notes to
markdown, reset order and overwrote source_application. Measured with the real
Joplin CLI synced through Joplock's proxy.

- app/items/joplinItem.js: Joplin's serialize format + pass-through of stored fields
  (including fields Joplock doesn't model: is_locked, user_data, application_data...)
- items carry their stored fields; user_updated_time only moves on a real edit
- Joplin E2EE items: locked placeholder, never written
- HTML notes: rendered through an allowlist sanitizer, read-only
- conflict copies hidden (and moved with a deleted notebook)
- restore from trash returned 404 for every trashed note (pre-existing): fixed
- opt-in integration harness driving the real Joplin CLI (npm run test:joplin)
2026-10-09 14:17:56 +13:00

27 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Installs the real Joplin terminal client (headless) for the opt-in compatibility
# tests in integration-tests/. It lives OUTSIDE the repo (default ~/.cache) so it
# never lands in node_modules or the Docker image.
#
# npm run setup:joplin-cli
# JOPLIN_CLI_DIR=/some/dir JOPLIN_CLI_VERSION=3.7.1 npm run setup:joplin-cli
set -euo pipefail
DIR="${JOPLIN_CLI_DIR:-$HOME/.cache/joplock-joplin-cli}"
VERSION="${JOPLIN_CLI_VERSION:-3.7.1}"
mkdir -p "$DIR"
cd "$DIR"
[ -f package.json ] || npm init -y >/dev/null
npm install "joplin@$VERSION" --no-audit --no-fund
# npm skips install scripts for transitive dependencies, so the CLI's sqlite3
# native binding has to be fetched explicitly (prebuilt download, source-build fallback).
if [ ! -d node_modules/sqlite3/lib/binding ]; then
( cd node_modules/sqlite3 && node ../@mapbox/node-pre-gyp/bin/node-pre-gyp install --fallback-to-build )
fi
PROFILE="$(mktemp -d)"
trap 'rm -rf "$PROFILE"' EXIT
./node_modules/.bin/joplin --profile "$PROFILE" version >/dev/null
echo "Joplin CLI $VERSION ready in $DIR"