pnpm-plugin-patchwork
v0.1.0
Published
pnpm custom resolver/fetcher for patchwork (automerge) filesystem
Readme
pnpm-plugin-patchwork
Warning: chee has not read line 1 of this codebase. It was entirely written by the computer.
A pnpm custom resolver and fetcher for installing packages from a patchwork filesystem (automerge-repo).
Specify dependencies as automerge:<documentId> in your package.json and pnpm will resolve and fetch them from the automerge sync server.
Requirements
- pnpm v11 (beta.2+) — uses the top-level
resolvers/fetchersplugin API
Setup
- Add
pnpm-plugin-patchworkas a config dependency in yourpnpm-workspace.yaml:
configDependencies:
pnpm-plugin-patchwork: "0.1.0"- Add automerge dependencies to your
package.json:
{
"dependencies": {
"@patchwork/chat": "automerge:6iXwddwF9cwrjmM5yqp2xUENxUY"
}
}- Run
pnpm install.
How it works
Resolver: Detects
automerge:specifiers, connects to the automerge sync server, reads the folder document'spackage.jsonto get the package manifest, and returns acustom:automergeresolution.Fetcher: Connects to the sync server, recursively walks the automerge folder document tree to collect all files, packs them into a tarball, and delegates to pnpm's built-in
localTarballfetcher.Caching: The document ID + heads hash is used as the resolution ID in the lockfile, so installs are cached until the document changes.
Subpath resolution
You can resolve a subfolder of a folder document as the package root:
{
"dependencies": {
"my-pkg": "automerge:6iXwddwF9cwrjmM5yqp2xUENxUY/dist"
}
}Configuration
The sync server defaults to wss://sync3.automerge.org. To use a different server, add a pushwork.server field to your package.json:
{
"pushwork": {
"server": "wss://my-sync-server.example.com"
}
}Or set the PATCHWORK_SYNC_SERVER environment variable (takes precedence):
PATCHWORK_SYNC_SERVER=wss://my-sync-server.example.com pnpm installTests
pnpm testUnit tests use a mocked automerge repo. The e2e test runs pnpm install in test/fixture/ against the real sync server.
