WebSocket client layer for Cockatrice, extracted from the webclient and distributed as standalone tarball releases on GitHub.
Sockatrice is published as a tarball asset on each GitHub Release (not to npmjs.com). Install a specific version directly from its release URL:
npm install https://github.com/Cockatrice/Sockatrice/releases/download/v1.2.3/cockatrice-sockatrice-1.2.3.tgzThe URL is recorded in your package.json and package-lock.json; upgrade by
replacing it with the next release. No registry account or authentication is
required. The tarball install does not run the prepare script, so
consumers do not need git submodules or buf.
Available releases: https://github.com/Cockatrice/Sockatrice/releases
git clone <sockatrice-url> Sockatrice
cd Sockatrice
npm installnpm install triggers the prepare script, which:
- Initializes the
vendor/cockatricesubmodule with sparse-checkout so onlylibcockatrice_protocol/is materialized. - Runs
buf generateto populatesrc/generated/from the proto sources.
If you ever need to refresh the submodule or regenerate manually:
npm run proto:submodule
npm run proto:generate| Script | Purpose |
|---|---|
npm test |
Unit tests (vitest, jsdom). |
npm run test:integration |
Integration tests against a mocked WebSocket. |
npm run lint |
ESLint with module boundaries. |
npm run build |
Bundles ESM via tsup, then emits .d.ts via tsc --emitDeclarationOnly. Proto generation runs separately in npm run prepare (on install). |
npm run proto:generate |
Runs buf generate. |
import {
WebClient,
SessionCommands,
RoomCommands,
GameCommands,
AdminCommands,
ModeratorCommands,
SessionEvents,
RoomEvents,
GameEvents,
setPendingOptions,
consumePendingOptions,
generateSalt,
passwordSaltSupported,
hashPassword,
} from '@cockatrice/sockatrice';
import { WebsocketTypes } from '@cockatrice/sockatrice/types';
import { Command_Login_ext, Command_LoginSchema } from '@cockatrice/sockatrice/generated';Releases are cut by the Release GitHub Actions workflow at
.github/workflows/release.yml. It runs on
manual dispatch from the Actions tab on master and accepts a bump input
(patch / minor / major).
The workflow:
- Checks out the repo with submodules.
- Runs
npm run lint,npm run test:coverage, andnpm run test:integration:coverage. Coverage thresholds in vitest.config.ts and vitest.integration.config.ts gate the release. - Bumps the version with
npm version <bump>, which creates a commit and an annotated tag. - Runs
npm pack(which triggersprepack→npm run build) to producecockatrice-sockatrice-<version>.tgz. - Pushes the version commit and tag back to
master. - Creates a GitHub Release with the
.tgzattached as an asset.
To reproduce a packaging step locally:
npm run lint
npm run test:coverage
npm run pack # → cockatrice-sockatrice-<version>.tgz in repo rootnpm pack runs the prepare script first (proto submodule + buf generate) and
then prepack (the build). Without git available or the submodule initialized,
src/generated/ will be empty and the build will fail.
GPL-2.0-or-later. See LICENSE.
src/generated/**— proto-generated code. Imports nothing from the rest of the repo (enforced byeslint-plugin-boundaries).- Everything else — may import from
src/generated/**only via relative paths pointing atsrc/generated/index.ts.