Skip to content

windorg/woc

Repository files navigation

WOC

Doc links

Local development setup

Install Docker, if you don't have it yet.

Then:

git submodule update --init --recursive   # pull submodules
volta install dotenv-cli                  # install dotenv
brew install postgres                     # install psql
docker compose up -d                      # run services

# Initialize the DB if it's empty
dotenv -e .env.development -- npx prisma db push

You should also run the GraphQL codegen watcher, at least until capaj/graphql-codegen-vscode#21 is fixed:

npm run gql:watch

If you want to remove the databases, run:

docker compose down
docker volume rm $(docker volume ls -q | grep woc_)

Local development - running the app

Check that the services are running:

docker compose ps

Then:

npm run dev

Local development - Tauri

Setting up:

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

rustup target add x86_64-apple-darwin aarch64-apple-darwin

Running in dev mode:

npm run dev
npm run tauri dev

Building the prod app:

# This is not necessary right now because we're building the app simply as a wrapper.
# rm .env
# NODE_ENV=production npm run build
# DATABASE_URL="postgresql://user:password@localhost:3999/db_dev" NODE_ENV=production npx next export

npx tauri build --debug                # --debug for the web inspector to work

Building a universal macOS binary:

npx tauri build --target universal-apple-darwin

Upgrading Tauri:

npm i -S -D @tauri-apps/cli@latest

cd src-tauri
cargo install cargo-edit  # provides cargo upgrade, needed only once
cargo upgrade

Generating icons:

npm run tauri icon public/icon-macos.png

Running tests locally

npx playwright install  # install browsers; only needed once

To run:

dotenv -e .env.development -- npx playwright test --workers=1

The server must be running for the tests to work. --workers=1 runs tests without parallelism — this is necessary because otherwise hot reloading messes things up.

Tests use the following users:

As of Jun 2023, the tests are flaky. You might be getting waiting for locator('text=Account') to be visible and then you try again several times and suddenly it works.

Connecting to local database

dotenv -e .env.development -- npx prisma studio

Upgrading dependencies

List outdated:

npm outdated

Do an interactive upgrade:

npx npm-upgrade

Rules:

  • Read changelogs for major version upgrades — some things are not going to be caught by TypeScript, eg. the command -> meta change in react-hotkeys-hook.

  • Don't upgrade ProseMirror stuff or @types/node.

Run npm i. Run npm run check. NOTE THAT THIS PROJECT DOES NOT USE YARN.

Troubleshooting:

  • "peer dependencies" with typescript-eslint: rm -rf package-lock.json node_modules/

Upgrading Tiptap

cd tiptap
git fetch --all

Note the commits in our fork:

git log --oneline | grep WOC:

Kill our commits with git reset <commit before our changes> --hard. (For example, smth like the unused-packages commit is hard to rebase. The @ts-nocheck commit has to be repeated every time anyway.)

Get upstream changes:

git rebase upstream/main

Copy all dependencies from tiptap/packages/pm/package.json into our package.json, and run npm i in the root.

Remove git hooks:

rm -rf .husky
git add .
git commit -m "WOC: Remove git hooks"

Add @ts-nocheck:

(cd ..; npm run tiptap-nocheck)
git add .
git commit -m "WOC: Add @ts-nocheck"

git cherry-pick our commits back.

At the root, check that things build: npm run build. Do npm run dev and check that the editor works.

NOTE: rm -rf tiptap/node_modules if you get weird errors.

Commit and update the submodule:

git push origin HEAD:main --force
(cd ..; git submodule update --remote tiptap)