npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@recodelabs/observatory-cli

v0.2.0

Published

observatory: build, preview and deploy Observable Framework sites from a data warehouse in R2

Readme

@recodelabs/observatory-cli

The observatory command: preview, build and deploy Observable Framework sites that read a warehouse in R2. Lifted from the ICR's campaignhq/deploy.sh and duckdb-wasm2.sh.

Install

The packages are on npm. In the project that holds your sites:

npm install @observablehq/[email protected] @recodelabs/observatory-cli @recodelabs/observatory-components

Node 22 or later.

The commands also use:

  • rclone, with a remote for the R2 bucket (r2 by default), for pull, build and deploy;
  • gh, signed in, the first time a site uses DuckDB (to download DuckDB-Wasm 2.0);
  • duckdb and whatever else the sites' data loaders call;
  • wrangler, through npx, when the config names a host Worker.

A project

observatory.config.js
package.json
sites/
  main/      observablehq.config.js, src/ (pages, src/data/ loaders)
  uganda/
worker/      optional: the Worker that serves the sites (wrangler config)
// observatory.config.js
export default {
  host: "https://dashboards.example.org",
  cloudflare: {
    bucket: "icr",              // the R2 bucket
    rclone: "r2",               // the rclone remote for it (default r2)
    sites: "_site/main/",       // where builds go in the bucket (default _site/)
    worker: "gate",             // optional: a folder to `wrangler deploy` after uploading
    d1: "observatory"           // optional: the gate's D1 database, migrated before the deploy
  },
  warehouses: {
    main: {r2: ""},                              // the bucket root
    uga:  {r2: "uga/", local: "../country/uganda/warehouse"}
  },
  sites: [
    {name: "main",   path: "/",    dir: "sites/main",   warehouse: "main", access: "public"},
    {name: "uganda", path: "/ug/", dir: "sites/uganda", warehouse: "uga",
     access: [{oidc: "uga", group: "/dashboards"}]},
    {name: "sl",     path: "/sl/", dir: "sites/sl"}   // no warehouse: its loaders find their own data
  ]
};
  • Bucket folders mirror the URLs. A site is uploaded to cloudflare.sites plus its path: /ug/ goes to _site/main/ug/.
  • Nested sites are separate. Uploading the site at / leaves the folders of the sites under it alone.
  • Unknown folders stop an upload. An upload would delete any folder whose index.html is not in the new build. If such a folder belongs to no configured site, the upload stops; --prune deletes it anyway. This catches a site missing from the config, at any depth.
  • access is read by the gate (phase 3). A site without it needs sign-in. observatory check lists each site's level.

Commands

| Command | What it does | |---|---| | observatory new <name> [--dir DIR] | Copies the template to sites/<name> and prints the config entry to add | | observatory dev <site> [--local] [--pull] [preview options…] | Framework's preview, with DuckDB 2.0 and DATA set. Data comes from the cached warehouse (pulled if there is none): --pull refreshes it, --local uses the warehouse's local copy. Other options, such as --port 3000 --host 0.0.0.0, go to observable preview | | observatory pull [<site>…] | Copies the sites' warehouses from R2 to ~/.cache/observatory/warehouses/ | | observatory build [<site>…] [--local] | Pulls, clears Framework's cached loader outputs, builds, and adds brotli copies of .wasm files. All sites when none are named | | observatory deploy [<site>…] [--local] [--skip-build] [--dry-run] [--prune] [--no-worker] | Builds and uploads each site. Then, in cloudflare.worker, applies the D1 migrations of cloudflare.d1 (with --dry-run, lists them) and runs wrangler deploy | | observatory check | Checks the config and each site's Framework config; prints each site's access, warehouse, bucket folder and nested sites |

The gate

The gate (@recodelabs/observatory-gate) is the Worker that serves the sites and decides who sees them. A project adds it in a folder of its own, named by cloudflare.worker:

// gate/worker.js
import {createGate} from "@recodelabs/observatory-gate";
import config from "../observatory.config.js";
export default createGate(config);
// gate/wrangler.jsonc
{
  "name": "dashboards",
  "main": "worker.js",
  "compatibility_date": "2026-09-01",
  "compatibility_flags": ["nodejs_compat"],
  "account_id": "…",
  "vars": {"BASE_URL": "https://dashboards.example.org"},
  "d1_databases": [{"binding": "DB", "database_name": "observatory", "database_id": "…",
    "migrations_dir": "../node_modules/@recodelabs/observatory-gate/migrations"}],
  "r2_buckets": [{"binding": "SITE", "bucket_name": "icr"}],
  "routes": [{"pattern": "dashboards.example.org", "custom_domain": true}]
}

Before the first deploy:

  1. Create the D1 database (npx wrangler d1 create observatory).
  2. Set the secrets:
    • BETTER_AUTH_SECRET: 32+ random characters;
    • RESEND_API_KEY, for email;
    • OIDC_<ID>_SECRET for each Keycloak provider.

See the gate's README for its access rules and sign-in.

Data loaders

The CLI sets DATA to the warehouse folder (parquet/, tiles/, manifest.json, catalog.sql) and DUCKDB_AGENT_MODE=0, which stops DuckDB's CLI from printing a banner into loader output when it runs under an AI agent. A loader reads a table from its first partition folder down, so files the producer keeps beside the data are skipped:

#!/usr/bin/env bash
set -euo pipefail
duckdb -c "COPY (
  SELECT id, name, population
  FROM read_parquet('$DATA/parquet/places/*=*/**/*.parquet', hive_partitioning=true, union_by_name=true)
) TO '/dev/stdout' (FORMAT parquet)"

Framework reuses a loader's output until the loader file changes. build and deploy clear every loader output in the site's cache (all but Framework's own _npm, _node, _jsr, _observablehq and _build.json), so every build reads the warehouse again. dev doesn't. To see new data in a running preview, delete the loader's output under src/.observablehq/cache/.

pull mirrors the warehouse into ~/.cache/observatory/warehouses/<remote>/<bucket>/<folder>. The bucket root is @root. Files the bucket no longer has are removed from the cache. The build output folder is Framework's output, dist by default.

DuckDB 2.0

Framework 1.13 comes with DuckDB-Wasm 1.29 (DuckDB 1.1.1). For a site with DuckDB pages, dev and build do the following:

  1. Change Framework in node_modules to load the "base" build of DuckDB-Wasm 2.0.
  2. Put the 2.0 engine, worker and module into the site's npm cache.

The first time a site is built, it is built twice: the first build fills Framework's npm cache.

The 2.0 files come from a DuckDB-Wasm CI run, are checked by sha256, and are kept in ~/.cache/observatory/duckdb-wasm2/. Set duckdb: {extensions: {json: null, parquet: null}} in each site's observablehq.config.js; check warns when it is missing. This step goes once DuckDB-Wasm 2.0 is on npm and Framework uses it.