Sanely is a pnpm and Turborepo monorepo for the @sanely/* libraries. Each package starts from the keel library template, with tsdown, vitest, and Changesets. Adamantite and Packref are set up at the root.
Read CONTRIBUTING.md for workspace changes and releases, and CODING_STANDARDS.md for decisions that need human review.
The status shows whether a package is published to npm or still private.
| Package | What it does | Replaces | Status |
|---|---|---|---|
@sanely/try |
A better try/catch for TypeScript. | tryharder |
Published |
@sanely/errors |
Extensible error handling for TypeScript. | faultier |
Published |
@sanely/ratelimit |
Atomic rate limiting with pluggable stores. | richter |
Published |
@sanely/flags |
Type-safe feature flag library for TypeScript applications. | gated |
Published |
@sanely/duration |
Parse human-readable time expressions into any unit, and format durations into human-readable strings. | humanspan |
Published |
@sanely/cron |
Type-safe schedules that compile to exact cron expressions. | None | Published |
@sanely/rpc |
Type-safe RPC from a Standard Schema contract, over any transport: Electron IPC, workers, WebSockets, HTTP, or message queues. | typedport |
Published |
@sanely/skew |
Keep your deployments fresh. | crispen |
Published |
@sanely/request |
Read the client IP address and location from a request. | None | Published |
@sanely/words |
Generate friendly, safe-for-work names from curated word lists. | None | Published |
The private @sanely/core workspace holds shared definitions.
Libraries can reuse internal workspaces without adding third-party runtime dependencies.
Cron, duration, ratelimit, and skew bundle core's JavaScript and types, so consumers install each library on its own.
- Run
pnpm run generate new-package. It asks for the name, emoji, and description, then createspackages/<name>from the starter and installs dependencies. To skip the prompts, pass the answers in order, such aspnpm run generate new-package --args cache ๐๏ธ "A small cache". - Replace the example in
src/with the library. - Add the package to the table above.
- When the package is ready to publish, remove
privatefrom itspackage.jsonwithout a changeset. - Publish version
0.0.1once by hand. npm accepts a trusted publisher only for a package that exists. Runnpm login, build the package, and runpnpm publish --access publicinpackages/<name>. - Make
release.ymlthe trusted publisher withnpm trust github @sanely/<name> --file release.yml --repo adelrodriguez/sanely --allow-publish. This needs npm 11.15.0 or later and 2FA on your npm account. After that,release.ymlpublishes each new version.
- Package source entry points correspond to the exports in
package.json. See the package structure reference for source and test ownership. src/lib/holds the library logic. Oxlint checks its declared dependency direction withno-restricted-imports.- Code imports with
#subpath imports, such as#lib/shared/errors.ts. - Tests sit in a
__tests__/folder beside the file they test, with the same name.src/__tests__/types.test-d.tstests the public types withexpectTypeOf. scripts/holds the build and compatibility checks that packages share, andsetup-repo.sh, which creates or updates themainruleset on GitHub.turbo/generators/holds thenew-packagegenerator. Its templates are the starter for every package.tooling/tsconfig/holds the TypeScript configurations. Each package'stsconfig.jsonextends@tooling/tsconfig/library.json, and the roottsconfig.jsonextends@tooling/tsconfig/base.json.
Run these from the root. Turborepo runs the package tasks and caches their results. Run pnpm run build before pnpm run check, because type-aware lint reads the built types of a workspace dependency.
| Script | What it does |
|---|---|
pnpm run check |
Formatting, lint, and types, including types.test-d.ts |
pnpm run fix |
Formatting and safe lint fixes |
pnpm run analyze |
Package consistency, and unused files, exports, and dependencies |
pnpm run build |
Builds every package |
pnpm run dev |
Rebuilds every package when its source changes |
pnpm run test |
Tests for the custom lint rules, then unit tests |
pnpm run test:compat |
Runs each built package with the globals of the engines.node floor |
pnpm run build:verify |
Builds, packs, installs, and type-checks each package as a consumer |
pnpm run generate |
Runs a Turborepo generator, such as new-package |
pnpm run bump:deps |
Updates dependencies in every workspace, with a prompt |
| Workflow | Jobs |
|---|---|
adamantite.yml |
check, analyze |
test.yml |
unit, types-perf, a compat (<package>) job for each package, and compat, which reports them all |
build.yml |
build |
release.yml |
Waits for the adamantite, test, and build workflows, then versions or publishes with Changesets |
ratelimit-stores.yml |
Store and runtime tests for @sanely/ratelimit, when core, duration, or ratelimit changes |
ratelimit-performance-check.yml |
Ratelimit benchmarks on a pull request with the performance-check label |
try-benchmarks.yml |
@sanely/try benchmarks, weekly or on demand |
pullfrog.yml |
Pullfrog review agent, on demand |