hpy 0.0.1 → 1.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +761 -0
- package/dist/hpy.mjs +32289 -0
- package/package.json +37 -72
package/README.md
ADDED
|
@@ -0,0 +1,761 @@
|
|
|
1
|
+
# hpy
|
|
2
|
+
|
|
3
|
+
The HappyProto command line. One tool for the HappyProto ecosystem. It
|
|
4
|
+
publishes and manages **HappyView plugins** in the HappyProto registry, and
|
|
5
|
+
builds **HappyView apps** from a project directory and deploys them to a
|
|
6
|
+
HappyView instance. More commands for managing instances, and OAuth clients,
|
|
7
|
+
will be added later (see
|
|
8
|
+
[docs/roadmap/happyview-admin.md](docs/roadmap/happyview-admin.md)).
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
hpy registry login # sign in to the registry with your atproto account
|
|
12
|
+
hpy registry plugin init # describe your plugin for the registry
|
|
13
|
+
hpy registry plugin publish # publish the plugin in this directory
|
|
14
|
+
hpy registry plugin status # see what the registry has picked up
|
|
15
|
+
|
|
16
|
+
hpy happyview create --name my-app # start a HappyView app
|
|
17
|
+
hpy happyview dev # run it, from anywhere inside it
|
|
18
|
+
hpy happyview login --url https://api.example.com # sign in to your instance
|
|
19
|
+
hpy happyview deploy # make the instance match the project
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
**macOS, Linux (Homebrew)**
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
brew install happyproto/tap/hpy
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Debian, Ubuntu**
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
curl -fsSL https://happyproto.github.io/cli/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/hpy.gpg
|
|
34
|
+
echo "deb [signed-by=/usr/share/keyrings/hpy.gpg] https://happyproto.github.io/cli/deb stable main" | sudo tee /etc/apt/sources.list.d/hpy.list
|
|
35
|
+
sudo apt update && sudo apt install hpy
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Fedora, RHEL, CentOS**
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
sudo curl -fsSL https://happyproto.github.io/cli/hpy.repo -o /etc/yum.repos.d/hpy.repo
|
|
42
|
+
sudo dnf install hpy
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Upgrades then come with `apt upgrade` / `dnf upgrade`. Each release's `.deb`
|
|
46
|
+
and `.rpm` files are also attached to its GitHub Release, for installing
|
|
47
|
+
without the repository.
|
|
48
|
+
|
|
49
|
+
**Anything else (Linux, macOS)**
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
curl -fsSL https://happyproto.github.io/cli/install.sh | sh
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
On Alpine, or another Linux without glibc 2.31 or newer, the installer picks
|
|
56
|
+
the musl build, which needs the C++ runtime: `apk add libstdc++` first. (hpy
|
|
57
|
+
up to 1.0.0-alpha.32 was a static Rust binary and needed nothing.) The
|
|
58
|
+
installers and `hpy update` stop and say so when it is missing, so an older
|
|
59
|
+
copy that updates itself is left as it was until `libstdc++` is installed. On
|
|
60
|
+
glibc older than 2.31 there is no build that runs: use npm, below.
|
|
61
|
+
|
|
62
|
+
That installs the newest **stable** release, of which there is none until
|
|
63
|
+
`1.0.0` is cut — for now use the `beta` channel's installer, below.
|
|
64
|
+
|
|
65
|
+
`hpy` lands in `/usr/local/bin`. The release's own installer downloads it and
|
|
66
|
+
checks its checksum as you, in a temporary directory; then the script copies
|
|
67
|
+
it into place. When `/usr/local/bin` isn't writable by you (or, on a new
|
|
68
|
+
Apple-silicon Mac, doesn't exist yet), it says why and `sudo` asks for your
|
|
69
|
+
password once, for that copy alone. Nothing else runs as root, and the record
|
|
70
|
+
`hpy update` reads is written as you. Without a terminal, sudo can't ask, so
|
|
71
|
+
the script stops and prints the command to run instead.
|
|
72
|
+
|
|
73
|
+
To install without sudo, choose the directory yourself. `hpy` goes in its
|
|
74
|
+
`bin`, which you then add to your PATH:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
curl -fsSL https://happyproto.github.io/cli/install.sh | HPY_CLI_INSTALL_DIR="$HOME/.local" sh
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Earlier versions of this script installed into `~/.cargo/bin`. If you have
|
|
81
|
+
that copy, the script offers to remove it once the new one is in place, and
|
|
82
|
+
removes that one file only on a yes. A `~/.cargo/bin/hpy` that `cargo install`
|
|
83
|
+
built is left alone, with a warning that it may come first on your PATH.
|
|
84
|
+
|
|
85
|
+
**Windows**
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
powershell -ExecutionPolicy Bypass -c "irm https://happyproto.github.io/cli/install-beta.ps1 | iex"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
That installs the newest **beta** release. Once `1.0.0` is cut,
|
|
92
|
+
`install.ps1` in its place installs the newest stable one.
|
|
93
|
+
|
|
94
|
+
**With npm**
|
|
95
|
+
|
|
96
|
+
With Node 22.20 or newer (or 24.12 or newer):
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
npm install -g hpy@beta
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
npm keeps that copy up to date, so `hpy update` tells you the `npm` command
|
|
103
|
+
to run instead of replacing it. Prefer one of the options above when you
|
|
104
|
+
don't otherwise need Node: they install a single prebuilt binary.
|
|
105
|
+
|
|
106
|
+
**From source**
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
git clone https://github.com/happyproto/cli && cd cli
|
|
110
|
+
npm ci && npm run build
|
|
111
|
+
node dist/hpy.mjs --help
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Prereleases**
|
|
115
|
+
|
|
116
|
+
These install the stable channel. For the `beta` or `alpha` channel (see
|
|
117
|
+
[Updates](#updates)):
|
|
118
|
+
|
|
119
|
+
- Homebrew: `brew install happyproto/tap/hpy-beta` (or `hpy-alpha`).
|
|
120
|
+
- apt: write `beta` (or `alpha`) in place of `stable` in `hpy.list`.
|
|
121
|
+
- dnf: download `hpy-beta.repo` (or `hpy-alpha.repo`) in place of `hpy.repo`.
|
|
122
|
+
- The install script: `install-beta.sh` or `install-alpha.sh` in place of
|
|
123
|
+
`install.sh`, which is the whole difference:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
curl -fsSL https://happyproto.github.io/cli/install-beta.sh | sh
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- Windows: `install-beta.ps1` or `install-alpha.ps1` in place of
|
|
130
|
+
`install.ps1`:
|
|
131
|
+
|
|
132
|
+
```powershell
|
|
133
|
+
powershell -ExecutionPolicy Bypass -c "irm https://happyproto.github.io/cli/install-beta.ps1 | iex"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
After installing, `hpy update` keeps you on the channel you installed from, and
|
|
137
|
+
`hpy channel` moves you between them.
|
|
138
|
+
|
|
139
|
+
The Linux packages contain the glibc build, so they install on glibc
|
|
140
|
+
distributions (Debian, Ubuntu, Fedora and the like), on x86_64 and arm64. On
|
|
141
|
+
Alpine and other musl distributions, use the shell installer, which installs
|
|
142
|
+
the musl build (it needs `libstdc++`: `apk add libstdc++`).
|
|
143
|
+
|
|
144
|
+
## How publishing works
|
|
145
|
+
|
|
146
|
+
Your plugin lives in **your own atproto repo**, as `software.release`
|
|
147
|
+
records that the registry indexes:
|
|
148
|
+
|
|
149
|
+
| Record | Key | What it is |
|
|
150
|
+
| --- | --- | --- |
|
|
151
|
+
| `software.release.project` | `<name>` | The plugin as a whole. |
|
|
152
|
+
| `site.standard.publication` | `<name>` | Its display name, description and icon. |
|
|
153
|
+
| `at.happyproto.registry.project` | `<name>` | What the registry adds: plugin type, keywords, authors, security contacts. |
|
|
154
|
+
| `software.release.manifest` | TID | One build: the `.wasm` and its `manifest.json` (uploaded as blobs), images, license, sections and `requires`. |
|
|
155
|
+
| `software.release.version` | `<name>:<version>` | A version, pointing at its manifest. |
|
|
156
|
+
| `software.release.channel` | `<name>:<channel>` | Where `latest`, `beta` or `alpha` points. |
|
|
157
|
+
| `software.release.status` | TID | A lifecycle event: end of support, end of life, … |
|
|
158
|
+
| `site.standard.document` | TID | A version's changelog. |
|
|
159
|
+
|
|
160
|
+
`hpy` signs you in through the registry's HappyView
|
|
161
|
+
(`https://api.happyproto.at`). It writes through the registry's gateway
|
|
162
|
+
procedures, which check what you send against the indexer's rules, explain
|
|
163
|
+
any refusal, and then write the records to your repo for you:
|
|
164
|
+
|
|
165
|
+
| Procedure | Used by |
|
|
166
|
+
| --- | --- |
|
|
167
|
+
| `putProject` | `init`, `edit` and `publish`: the project, its publication and the registry's sidecar. |
|
|
168
|
+
| `publishRelease` | `publish`: the manifest, the version, the channel it moves and the changelog. |
|
|
169
|
+
| `promoteRelease` | `publish --promote`: a new version of an existing version's build. |
|
|
170
|
+
| `putStatus` | `lifecycle`: a lifecycle event, or the withdrawal of one. |
|
|
171
|
+
|
|
172
|
+
`hpy` checks the same rules locally first, so most mistakes show up before
|
|
173
|
+
anything leaves your machine. It then asks the registry for its verdict
|
|
174
|
+
before uploading a single byte. Every upload is checked against the CID the record names it by, and an image a previous
|
|
175
|
+
version or the project already holds isn't sent again. Once a version is
|
|
176
|
+
written, the registry copies its blobs and marks it `available`.
|
|
177
|
+
|
|
178
|
+
**Versions are immutable.** A published version can never be changed. If a
|
|
179
|
+
publish is cut off partway, run it again: the registry finishes the version
|
|
180
|
+
it started rather than refusing it.
|
|
181
|
+
|
|
182
|
+
**Channels** (`latest`, `beta`, `alpha`) say which version to install by
|
|
183
|
+
default. A publish moves one channel to the new version (`--track` picks it).
|
|
184
|
+
Installing from a channel, or `hpy happyview add`, resolves it to an exact
|
|
185
|
+
version.
|
|
186
|
+
|
|
187
|
+
**Signing in again.** The default `oauth.scope` covers the `software.release`
|
|
188
|
+
collections, which an older `hpy` login does not. After updating `hpy`, run
|
|
189
|
+
`hpy registry login` again, and export a new `HPY_CREDENTIAL` for CI with
|
|
190
|
+
`hpy registry login --export`.
|
|
191
|
+
|
|
192
|
+
## Quick start
|
|
193
|
+
|
|
194
|
+
From a plugin directory, meaning one with a `manifest.json`:
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
hpy registry login alice.bsky.social
|
|
198
|
+
hpy registry plugin init # prompts; writes [project] in hpy.toml and creates the project
|
|
199
|
+
cargo build --release --target wasm32-unknown-unknown
|
|
200
|
+
hpy registry plugin publish --wait # validates, uploads, writes the version, waits for "available"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Every prompt has a flag equivalent, so this also works without a terminal:
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
hpy registry plugin init --no-input \
|
|
207
|
+
--author "Ada <ada@example.com> (https://ada.dev)" \
|
|
208
|
+
--security security@example.com --keyword atproto --yes
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Commands
|
|
212
|
+
|
|
213
|
+
| Command | Does |
|
|
214
|
+
| --- | --- |
|
|
215
|
+
| `hpy registry login [handle]` | Signs in through your browser. `--no-browser` prints the URL instead of opening it. `--export` signs in for CI and prints a credential instead of saving it (see below). |
|
|
216
|
+
| `hpy registry logout` | Revokes the session and deletes stored credentials. |
|
|
217
|
+
| `hpy registry whoami` | Shows the account you're signed in as. |
|
|
218
|
+
| `hpy registry plugin init` | Writes `[project]` in `hpy.toml` and creates the project, but only if the registry doesn't have it yet (`--local-only` skips that). `--name` sets the project name; `--display-name`, `--description`, `--author`, `--security` and `--keyword` fill in the rest. |
|
|
219
|
+
| `hpy registry plugin show` | Shows the project as the registry has it. |
|
|
220
|
+
| `hpy registry plugin edit` | Edits the project: with flags (`--display-name`, `--description`, `--author`, `--security`, `--keyword`, `--remove-keyword`; `--name` picks the project) or in `$EDITOR`. `hpy.toml` follows only when its `[project]` is this project. |
|
|
221
|
+
| `hpy registry plugin pull` | Copies the registry's project into `[project]` in `hpy.toml`. |
|
|
222
|
+
| `hpy registry plugin publish` | Publishes a new version. `--track latest\|beta\|alpha` picks the channel it moves (default: `latest` for a stable version, else the prerelease's name, `beta` or `alpha`); `--promote <from>` republishes an existing version's build as `--version` instead of building; `--dry-run` prints what would be published; `--wait` polls until the version is available; `--version` overrides the version; `--wasm` points at the module. |
|
|
223
|
+
| `hpy registry plugin status [version]` | Lists versions from your repo and from the registry, with each one's availability and lifecycle state. |
|
|
224
|
+
| `hpy registry plugin lifecycle <version> <event>` | Records a lifecycle event for a version: `endOfDevelopment`, `endOfSupport`, `supersededBy` (with `--superseded-by <version>`), `endOfDistribution` or `endOfLife`, with an optional `--kind` and `--reason`. `--project <event>` records it for the whole project. `--withdraw <status at-uri>` withdraws one recorded in error. A version at `endOfDistribution` or `endOfLife` is no longer offered for install. |
|
|
225
|
+
| `hpy update` | Updates `hpy` to the newest release on your channel (see [Updates](#updates)). |
|
|
226
|
+
| `hpy channel [stable\|beta\|alpha]` | Shows your release channel, or switches to another. `--yes` skips the confirmation. |
|
|
227
|
+
|
|
228
|
+
Global flags: `--json` (machine-readable output on stdout), `--no-input`
|
|
229
|
+
(never prompt), and `-C <dir>`.
|
|
230
|
+
|
|
231
|
+
Exit codes: `0` ok, `1` runtime or remote failure, `2` usage or validation
|
|
232
|
+
error, `3` not logged in.
|
|
233
|
+
|
|
234
|
+
## HappyView projects
|
|
235
|
+
|
|
236
|
+
A HappyView app can be a directory: lexicons and scripts under `src/`,
|
|
237
|
+
configuration in `happyview.toml`, exact plugin versions in `happyview.lock`.
|
|
238
|
+
|
|
239
|
+
HappyView has no Windows build, so on Windows `dev`, `check`, `test` and
|
|
240
|
+
`types`, which run HappyView itself, refuse to start; run them under WSL. The
|
|
241
|
+
other commands, `deploy` among them, work on Windows.
|
|
242
|
+
|
|
243
|
+
| Command | Does |
|
|
244
|
+
| --- | --- |
|
|
245
|
+
| `hpy happyview create --name <dir>` | Scaffolds a project: `happyview.toml`, `.gitignore`, `.env.example`, and one query lexicon with its handler. Prompts for the superadmin (default: the account `hpy registry login` holds), interpreters (Lua preselected), libraries and app name; `--superadmin`, `--interpreter`, `--library`, `--app-name` and `--happyview-version` answer them without a terminal, and `--project <at-uri>` picks between projects that answer to one name. Each plugin follows its project's `latest` channel, or the only channel it has. Writes the lock but downloads nothing. |
|
|
246
|
+
| `hpy happyview dev` | Runs the project with its pinned HappyView, in the foreground. |
|
|
247
|
+
| `hpy happyview add <plugin>` | Adds interpreters or libraries to `happyview.toml` and the lock, keeping the file's comments and order. Each follows a channel (`--channel`, default `latest`) or is pinned to `--version`; `--project <at-uri>` picks between projects that answer to one name. Adding a plugin again moves it to its channel's current version. With no plugin (or as `install`), brings the lock up to date and downloads it. |
|
|
248
|
+
| `hpy happyview scaffold [nsid…]` | Writes a starter handler beside each query or procedure lexicon under `src/` that has none, or only beside the ones named (any other NSID is refused). It has the lexicon's basename and the language of the first `[interpreters]` entry (Lua, TypeScript or JavaScript). A query's handler answers `?uri=` with `db.get` and otherwise lists its collection through `happyview.db`; a procedure's creates a record with `happyview.record`. The collection is written into the file: `--collection <nsid>` names it for every handler the run writes; otherwise `hpy` asks, offering the project's record lexicons, and without a terminal writes the placeholder `COLLECTION` under a TODO comment and warns. An existing handler, in any language, is never replaced. If `happyview.toml` lacks a library a new handler calls, `hpy` offers to add it as `hpy happyview add` would, or without a terminal prints the command. |
|
|
249
|
+
| `hpy happyview check` | Builds the project without serving it; non-zero on any error. What CI runs. First warns of each query or procedure lexicon with no handler, naming the `scaffold` command that writes one; the warnings leave the exit code alone. |
|
|
250
|
+
| `hpy happyview test [--watch] [filter]` | Runs the project's tests. Needs a HappyView that has `happyview test`, which no release has yet; until one does, HappyView refuses it as an unknown command. |
|
|
251
|
+
| `hpy happyview login --url <instance> [handle]` | Signs in to an instance through your browser, as you do for the registry, so you can deploy to it. The handle defaults to the account `hpy registry login` holds; `--no-browser` prints the URL instead of opening it. For CI, `--key-stdin` signs in with an API key instead (see [Deploying from CI](#deploying-from-ci)). |
|
|
252
|
+
| `hpy happyview logout [--url <instance>]` | Signs out of the instance. |
|
|
253
|
+
| `hpy happyview whoami` | Lists the instances you're signed in to, and as whom. |
|
|
254
|
+
| `hpy happyview deploy [--url <instance>]` | Makes the instance match the project: its plugins from `happyview.lock`, then its lexicons, scripts and modules (see [Deploying](#deploying)). `--dry-run` shows the changes without making them; `--yes` skips the confirmation. |
|
|
255
|
+
| `hpy happyview env push [key…] [--url <instance>]` | Sends keys from the project's `.env` (or `--env-file <path>`) to the instance's script variables, which scripts read as `ctx.env`: every key, or only the ones named, each of which must be in the file. Before each key it asks `send KEY (new)?` or `send KEY (replaces existing)?`, defaulting to no; `--yes` sends them all without asking, and without a terminal it sends nothing unless given `--yes`. `--dry-run` lists each key as new or replacing an existing one; the instance shows values masked, so it can't say whether a value would change. Values are never shown, in the questions, the output, `--json` or an error. Keys come only from the file, never from your shell's environment, and a line HappyView can't read is refused by its line number. Exits non-zero if any key failed to send. |
|
|
256
|
+
| `hpy happyview pull [--url <instance>] [dir]` | Builds a project from what an instance serves now: its lexicons (a network lexicon goes in `[network_lexicons]`), scripts in their layout places, the interpreter modules scripts import (from a HappyView that serves `GET /admin/scripts/modules`; an older one gets a warning, and they have to be copied in by hand), plugins as `[interpreters]` and `[libraries]` with the lock resolved as `add` does, app name, superadmin and labelers. Only lexicon settings that differ from the defaults are written. Reads a v3 instance with your `hpy happyview login` sign-in. `--legacy` reads a v2 instance instead, with an API key from `HAPPYVIEW_API_KEY` (or `--api-key-env NAME`, else a hidden prompt) that has `lexicons:read`, `scripts:read`, `script-variables:read`, `plugins:read`, `labelers:read`, `users:read` and `settings:manage`; revoke it afterwards. It rewrites each script through the pinned HappyView's `happyview-codemod` and lists any it marked for a hand edit. A v2 plugin the official publisher has no registry project for is left out with a warning. Never pulls script variable values (their keys go to `.env.example`) or plugin secrets (it lists the ones to set). Refuses a directory that already has `happyview.toml`; `--diff` prints how the instance differs from it instead, and `--dry-run` prints what it would write. Ends by running `hpy happyview check`: the project is written either way, but a failed check makes the exit non-zero. |
|
|
257
|
+
| `hpy happyview types` | Writes editor types for the project into `.happyview/types/`, one directory per interpreter, so your editor's language server can check handlers against their lexicons, `ctx` and the installed libraries. Needs a HappyView that has `happyview types`. |
|
|
258
|
+
|
|
259
|
+
### Editor types
|
|
260
|
+
|
|
261
|
+
`hpy happyview dev` keeps `.happyview/types/` current as you work: HappyView
|
|
262
|
+
rewrites it after every build that changes what a script can see.
|
|
263
|
+
`hpy happyview types` writes it once, which is what to run before opening an
|
|
264
|
+
editor without the dev server, or in CI.
|
|
265
|
+
|
|
266
|
+
`dev`, `types` and `create` also write the settings file that points a
|
|
267
|
+
language server at those types, when the project does not have one yet:
|
|
268
|
+
`.luarc.json` for Lua (LuaLS) and `tsconfig.json` for TypeScript or
|
|
269
|
+
JavaScript. A file you already have is never changed; `hpy` says what to add
|
|
270
|
+
to it instead. The starter handler `create` writes already names its types.
|
|
271
|
+
|
|
272
|
+
`hv` is short for `happyview`. `dev`, `check`, `test` and `types` take `--locked`,
|
|
273
|
+
which fails instead of updating a lock that no longer matches
|
|
274
|
+
`happyview.toml`; use it in CI. They exit with HappyView's own exit code.
|
|
275
|
+
|
|
276
|
+
Each plugin in `happyview.toml` names its project by its publisher's DID and
|
|
277
|
+
its name, and follows a channel or is pinned to one version:
|
|
278
|
+
|
|
279
|
+
```toml
|
|
280
|
+
[interpreters]
|
|
281
|
+
lua = { did = "did:plc:mo7vq4jbioxwafy5zkcc3eux", name = "happyview-lua", channel = "latest" }
|
|
282
|
+
|
|
283
|
+
[libraries]
|
|
284
|
+
"happyview.db" = { did = "did:plc:mo7vq4jbioxwafy5zkcc3eux", name = "happyview-db", version = "1.2.0" }
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
A channel is resolved when the lock is written. The lock records the channel
|
|
288
|
+
it followed (`channel = "latest"`, left out for a pinned version) and keeps
|
|
289
|
+
that version until you `add` the plugin again, so `check` and `dev` stay
|
|
290
|
+
reproducible as the channel moves on; changing an entry's channel or version
|
|
291
|
+
in `happyview.toml` makes the lock out of date. A channel pointing at a
|
|
292
|
+
version its publisher has ended distribution of is refused. A pinned version
|
|
293
|
+
is used even then, with a warning, since pinning it was your call. A plain
|
|
294
|
+
version string (`lua = "^1"`), from before the `software.release` registry, is
|
|
295
|
+
refused with the table form to use instead, and so is a `happyview.lock` from
|
|
296
|
+
then: delete it and run `hpy happyview check`.
|
|
297
|
+
|
|
298
|
+
A library a plugin requires is resolved to the highest installable version in
|
|
299
|
+
the range it asks for. Such a range never matches a prerelease unless it names
|
|
300
|
+
one, such as `"^0.1.0-alpha.3"`.
|
|
301
|
+
|
|
302
|
+
HappyView binaries are cached at `~/.cache/hpy/happyview/<version>/`
|
|
303
|
+
(`HPY_CACHE_DIR` moves the cache) and checked against the `.sha256`
|
|
304
|
+
published with each release. Plugins come from the registry into
|
|
305
|
+
`~/.cache/hpy/plugins/<id>/<version>/`. Their module and `manifest.json` are
|
|
306
|
+
checked against the blob CIDs in `happyview.lock`, and a registry whose
|
|
307
|
+
version no longer matches the manifest record the lock names is refused.
|
|
308
|
+
`dev`, `check` and `test` link them into the project's `.happyview/plugins/`
|
|
309
|
+
(on Windows they copy them), which `hpy` owns: anything else placed there is
|
|
310
|
+
removed.
|
|
311
|
+
|
|
312
|
+
### A local network
|
|
313
|
+
|
|
314
|
+
`hpy happyview dev --network local` runs the project against a private
|
|
315
|
+
atproto network on this computer instead of the real one, so test writes
|
|
316
|
+
never reach your real PDS or anyone's Jetstream. It needs Docker (with
|
|
317
|
+
Compose v2) and Deno 2.8 or later, on macOS or Linux.
|
|
318
|
+
|
|
319
|
+
The network is [Atmosphere in a Box](https://tangled.org/kandake.africa/atmosphereinabox)
|
|
320
|
+
v0.7.1 with its `full-stack` preset: a PLC directory, a PDS, a relay and
|
|
321
|
+
Jetstream, with private DNS and TLS. `hpy` downloads it once per project into
|
|
322
|
+
its data directory (`~/.local/share/hpy/networks/`, or `HPY_DATA_DIR`) and runs
|
|
323
|
+
HappyView inside it at `https://happyview.atmosbox.internal`, with your project
|
|
324
|
+
directory mounted, so saving a file works as it does natively. Sign in as
|
|
325
|
+
`user1.pds1.atmosbox.test`, which is the superadmin; `dev` prints its
|
|
326
|
+
password when it starts in a terminal.
|
|
327
|
+
|
|
328
|
+
The first run walks you through two things `hpy` never does for you: adding
|
|
329
|
+
the sandbox's hostnames to `/etc/hosts`, and trusting its certificate
|
|
330
|
+
authority in your browser or OS. Later runs check both and reuse the
|
|
331
|
+
network's accounts and records. Ctrl-C stops the network and keeps its data;
|
|
332
|
+
`--reset` discards it (with confirmation, or `--yes`). The local network keeps
|
|
333
|
+
its own database in `.happyview/local-network/`, apart from the one `dev` uses
|
|
334
|
+
against the real network.
|
|
335
|
+
|
|
336
|
+
Only one local network can run at a time, since its browser relay holds
|
|
337
|
+
`127.0.0.1:443`.
|
|
338
|
+
|
|
339
|
+
Each project's network gets a `/24` under `172.30.0.0/16`, chosen from the
|
|
340
|
+
project's path. If that range is already in use on your computer, by a VPN or
|
|
341
|
+
another Docker network, `dev` refuses to start and names what holds it. Pick
|
|
342
|
+
another range with `--subnet`, such as `--subnet 10.40.0.0/24`. It must be a
|
|
343
|
+
private IPv4 network, from `/16` to `/28`. The network keeps that range, even
|
|
344
|
+
through `--reset`, until you give another. A network that already exists can
|
|
345
|
+
move only by being recreated, so use `--reset --subnet <CIDR>` for that.
|
|
346
|
+
|
|
347
|
+
### Deploying
|
|
348
|
+
|
|
349
|
+
`hpy happyview deploy` makes an instance match the project. Sign in to the
|
|
350
|
+
instance first, through your browser:
|
|
351
|
+
|
|
352
|
+
```sh
|
|
353
|
+
hpy happyview login --url https://api.example.com
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Your account must be one of the instance's admins; on HappyProto, the account
|
|
357
|
+
that created the instance is. The sign-in asks your PDS for HappyView's
|
|
358
|
+
instance-management permissions (`include:dev.happyview.adminFull`), so your
|
|
359
|
+
PDS must support atproto permission sets. A deploy can install plugins and replace the
|
|
360
|
+
project, and nothing else in the instance's dashboard.
|
|
361
|
+
|
|
362
|
+
A deploy shows everything it would change and asks before changing anything.
|
|
363
|
+
Then, in this order:
|
|
364
|
+
|
|
365
|
+
1. **Plugins.** Each plugin `happyview.lock` pins is installed at exactly its
|
|
366
|
+
locked version, after the plugins it depends on. One the instance doesn't
|
|
367
|
+
have is installed, one at another version is moved to the locked one, and
|
|
368
|
+
one installed under the same name from a URL or another publisher is
|
|
369
|
+
replaced. One the lock doesn't list is kept, unless you pass
|
|
370
|
+
`--prune-plugins`.
|
|
371
|
+
|
|
372
|
+
The plan lists the capabilities each plugin would be granted, and for one
|
|
373
|
+
being moved or replaced which of them the installed version did not have.
|
|
374
|
+
Confirming the deploy accepts them: HappyView grants a plugin only the
|
|
375
|
+
capabilities an install explicitly accepts, so `hpy` sends the set
|
|
376
|
+
`happyview.lock` records for that exact version. The lock pins the manifest
|
|
377
|
+
those came from, so what you review in the lock is what is accepted, and a
|
|
378
|
+
version whose manifest gained a capability after the lock was written is
|
|
379
|
+
refused by the instance rather than installed quietly. A lock written by an
|
|
380
|
+
hpy from before a deploy accepted them is refused with the plugins named;
|
|
381
|
+
`hpy happyview check` rewrites it, without moving any version it pins, and
|
|
382
|
+
`--locked` says the same rather than reporting a mismatch against
|
|
383
|
+
`happyview.toml` that isn't there.
|
|
384
|
+
2. **The project.** `happyview.toml`, everything under `src/` and the builds of
|
|
385
|
+
its `[modules]` (built first, as `hpy happyview build` does) go to the
|
|
386
|
+
instance in one piece. The instance checks the project with the same rules
|
|
387
|
+
`hpy happyview check` uses and switches to it all at once, or refuses it and
|
|
388
|
+
keeps the one it had. Lexicons and scripts you add in the dashboard are
|
|
389
|
+
kept; where the project defines the same one, the project's is used.
|
|
390
|
+
|
|
391
|
+
The lock must match `happyview.toml`, so a deploy installs what you tested;
|
|
392
|
+
run `hpy happyview add` to bring it up to date. A deploy stops at the first
|
|
393
|
+
change the instance refuses and says which changes it already made. If someone
|
|
394
|
+
else deploys between your preview and your deploy, yours is refused rather
|
|
395
|
+
than overwriting theirs; run it again.
|
|
396
|
+
|
|
397
|
+
A record lexicon is backfilled from the whole network only when
|
|
398
|
+
`happyview.toml` asks for it with `[lexicons."<nsid>"] backfill = true`, and
|
|
399
|
+
only the first time it is deployed. The preview lists every backfill a deploy
|
|
400
|
+
would start.
|
|
401
|
+
|
|
402
|
+
On a hosted instance, a deploy applies `[lexicons]`, `[scripts]`, `[modules]`,
|
|
403
|
+
`[network_lexicons]` and `[labels]` from `happyview.toml`. `[instance]`,
|
|
404
|
+
`[dev]`, `[jetstream]` and the HappyView version stay as the instance has
|
|
405
|
+
them; the preview warns when the project sets them.
|
|
406
|
+
|
|
407
|
+
With `--url` you choose the instance when you're signed in to several.
|
|
408
|
+
|
|
409
|
+
Your sign-ins are kept like your registry login: each one's key in the OS
|
|
410
|
+
keychain, under the service `hpy`, and the rest in `instances.json` in the
|
|
411
|
+
config directory, readable only by you. The instance keeps the session alive;
|
|
412
|
+
after about two weeks without one it asks you to sign in again.
|
|
413
|
+
|
|
414
|
+
#### Deploying from CI
|
|
415
|
+
|
|
416
|
+
CI has no browser, so it uses an API key. Create one in the instance's
|
|
417
|
+
dashboard with the `project:deploy`, `plugins:read` and `plugins:create`
|
|
418
|
+
permissions (and `plugins:delete` for `--prune-plugins`), store it as a
|
|
419
|
+
secret, and set `HPY_HV_URL` and `HPY_HV_API_KEY` for the deploy. To keep a
|
|
420
|
+
key on a machine instead, pipe it to `hpy happyview login --url <instance>
|
|
421
|
+
--key-stdin`.
|
|
422
|
+
|
|
423
|
+
## `hpy.toml`
|
|
424
|
+
|
|
425
|
+
This file sits next to `manifest.json`. `manifest.json` stays the file
|
|
426
|
+
HappyView's loader reads, and `hpy` takes the plugin's type, version,
|
|
427
|
+
capabilities and allowed hosts from it. `hpy.toml` holds what the registry
|
|
428
|
+
needs on top of that: `[project]` describes the plugin as a whole, and
|
|
429
|
+
`[release]` what every version carries.
|
|
430
|
+
|
|
431
|
+
`publish` creates the project from `[project]` when the registry doesn't
|
|
432
|
+
have it, and updates it when `[project]` has changed. `edit` changes it
|
|
433
|
+
directly, and `pull` copies it back into the file.
|
|
434
|
+
|
|
435
|
+
```toml
|
|
436
|
+
[project]
|
|
437
|
+
name = "happyview-atproto" # default: manifest id
|
|
438
|
+
display_name = "Atproto" # default: manifest name
|
|
439
|
+
description = "AT Protocol service resolution, blob download, labels, signing."
|
|
440
|
+
icon = { path = "assets/icon.png" }
|
|
441
|
+
keywords = ["atproto", "library"]
|
|
442
|
+
authors = [{ name = "Ada", url = "https://ada.dev", email = "ada@example.com" }]
|
|
443
|
+
security = [{ email = "security@example.com" }]
|
|
444
|
+
|
|
445
|
+
[release]
|
|
446
|
+
license = "MIT"
|
|
447
|
+
changelog = "CHANGELOG.md" # this version's entry becomes its changelog
|
|
448
|
+
|
|
449
|
+
[release.sections] # Markdown file paths, or { text = "…" }
|
|
450
|
+
description = "README.md"
|
|
451
|
+
installation = { text = "Add it with `hpy happyview add happyview.atproto`." }
|
|
452
|
+
|
|
453
|
+
[release.requires]
|
|
454
|
+
"env:happyview" = ">=3.0.0"
|
|
455
|
+
# "at://did:plc:…/software.release.project/happyview-http" = "^0.1"
|
|
456
|
+
|
|
457
|
+
[release.artifacts]
|
|
458
|
+
banner = { path = "assets/banner.png" }
|
|
459
|
+
screenshots = [{ path = "assets/shot1.png", alt = "…" }]
|
|
460
|
+
|
|
461
|
+
[build]
|
|
462
|
+
command = "cargo build --release --target wasm32-unknown-unknown -p happyview-atproto"
|
|
463
|
+
wasm = "../../target/wasm32-unknown-unknown/release/happyview_atproto.wasm"
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
An `hpy.toml` written by an older `hpy`, with a `[profile]` table, is refused
|
|
467
|
+
until its fields move to `[project]` and `[release]`.
|
|
468
|
+
|
|
469
|
+
If `[build] wasm` and `--wasm` are both absent, `hpy` uses the manifest's
|
|
470
|
+
`wasm_file`. Failing that, it looks for `<cargo target dir>/wasm32-*/release/<crate>.wasm`,
|
|
471
|
+
which also works in a workspace with a shared `target/`. If it finds more than
|
|
472
|
+
one candidate, it lists them and asks you to choose with `--wasm`.
|
|
473
|
+
|
|
474
|
+
## Publishing from CI
|
|
475
|
+
|
|
476
|
+
CI can't open a browser, so you sign in once for it:
|
|
477
|
+
|
|
478
|
+
```sh
|
|
479
|
+
hpy registry login --export # prints a credential; store it as a secret, e.g. HPY_CREDENTIAL
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
In CI, `HPY_CREDENTIAL` takes the place of a login:
|
|
483
|
+
|
|
484
|
+
```sh
|
|
485
|
+
HPY_CREDENTIAL=${{ secrets.HPY_CREDENTIAL }} \
|
|
486
|
+
hpy registry plugin publish --no-input --yes --no-build --wasm path/to/plugin.wasm
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
The credential acts as you, so treat it like a password. It is a session of
|
|
490
|
+
its own: revoking it doesn't sign you out anywhere else, and signing out
|
|
491
|
+
locally doesn't break CI. Revoke it with `HPY_CREDENTIAL=… hpy registry logout`, or
|
|
492
|
+
from the HappyView dashboard.
|
|
493
|
+
|
|
494
|
+
On GitHub Actions, [`happyproto/actions/plugin-publish`](https://github.com/happyproto/actions)
|
|
495
|
+
installs `hpy` and does the above in one step:
|
|
496
|
+
|
|
497
|
+
```yaml
|
|
498
|
+
- uses: happyproto/actions/plugin-publish@v1
|
|
499
|
+
with:
|
|
500
|
+
version: 1.2.0
|
|
501
|
+
credential: ${{ secrets.HPY_CREDENTIAL }}
|
|
502
|
+
hpy-channel: beta # until hpy 1.0.0 is out
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
## Updates
|
|
506
|
+
|
|
507
|
+
Every release is on one channel:
|
|
508
|
+
|
|
509
|
+
| Channel | Versions | Cut from |
|
|
510
|
+
| --- | --- | --- |
|
|
511
|
+
| `stable` | `1.2.0` | `main` |
|
|
512
|
+
| `beta` | `1.3.0-beta.1` | `beta` |
|
|
513
|
+
| `alpha` | `1.3.0-alpha.4` | `alpha` |
|
|
514
|
+
|
|
515
|
+
Channels are strict: `hpy` only ever offers the newest release on the channel
|
|
516
|
+
you follow, never a newer one from another channel. Until you choose one with
|
|
517
|
+
`hpy channel`, you follow the channel your installed version came from.
|
|
518
|
+
|
|
519
|
+
`hpy channel alpha` (or `beta`, or `stable`, which `main` also names) switches
|
|
520
|
+
channel and installs that channel's newest release. It asks first when the
|
|
521
|
+
channel is a prerelease channel, which can be unstable, or when its newest
|
|
522
|
+
release is older than the one you have. Without a terminal, pass `--yes`.
|
|
523
|
+
|
|
524
|
+
`hpy update` updates to the newest release on your channel now. Otherwise, on
|
|
525
|
+
the first command of each day (UTC), `hpy` checks GitHub for one. The check
|
|
526
|
+
runs alongside the command and never delays it by more than about two
|
|
527
|
+
seconds.
|
|
528
|
+
|
|
529
|
+
- **Installed with the install script, with cargo, or by hand:** `hpy`
|
|
530
|
+
downloads the release's own binary and puts it where this one is, and
|
|
531
|
+
`hpy channel` does the same for the channel you switch to. When that
|
|
532
|
+
directory isn't writable by you, as `/usr/local/bin` usually isn't, `hpy`
|
|
533
|
+
downloads the release as you and asks `sudo` to copy it over this one,
|
|
534
|
+
which prompts for your password; without a terminal it prints that command
|
|
535
|
+
and leaves `hpy` as it is. The daily check never asks for sudo: it tells you
|
|
536
|
+
to run `hpy update`. After replacing a
|
|
537
|
+
copy `cargo install` built, cargo still records the version it compiled, so
|
|
538
|
+
installing hpy with cargo again rebuilds from source over it.
|
|
539
|
+
- **Installed with npm:** npm owns that copy, so `hpy` prints the command to
|
|
540
|
+
run instead, e.g. `npm i -g hpy@beta`.
|
|
541
|
+
- **Installed with Homebrew, apt or dnf:** those track the files they own, and
|
|
542
|
+
their next upgrade would revert a binary swapped underneath them, so `hpy`
|
|
543
|
+
prints the command to run instead, e.g. `brew upgrade hpy`. Each channel has
|
|
544
|
+
its own Homebrew formula (`hpy`, `hpy-beta`, `hpy-alpha`) and its own apt
|
|
545
|
+
suite and yum repository.
|
|
546
|
+
|
|
547
|
+
The daily check is skipped in CI, when there's no terminal, and when
|
|
548
|
+
`HPY_NO_UPDATE_CHECK=1` is set.
|
|
549
|
+
|
|
550
|
+
## Configuration
|
|
551
|
+
|
|
552
|
+
`~/.config/hpy/config.toml` (`$XDG_CONFIG_HOME/hpy` if that's set,
|
|
553
|
+
`%APPDATA%\hpy` on Windows). Precedence: flag > environment > file > default.
|
|
554
|
+
|
|
555
|
+
| Key | Environment | Default |
|
|
556
|
+
| --- | --- | --- |
|
|
557
|
+
| `registry.url` | `HPY_REGISTRY_URL` | `https://api.happyproto.at` |
|
|
558
|
+
| `registry.client_key` | `HPY_CLIENT_KEY` | `hpy`'s API client on `api.happyproto.at` |
|
|
559
|
+
| `oauth.client_id` | `HPY_OAUTH_CLIENT_ID` | `https://happyproto.at/oauth/hpy/client-metadata.json` |
|
|
560
|
+
| `oauth.scope` | `HPY_OAUTH_SCOPE` | `atproto repo:software.release.project repo:software.release.manifest repo:software.release.version repo:software.release.channel repo:software.release.status repo:at.happyproto.registry.project repo:site.standard.publication repo:site.standard.document blob:application/wasm blob:application/json blob:image/*` |
|
|
561
|
+
| `oauth.redirect` | `HPY_OAUTH_REDIRECT` | `https://happyproto.at/oauth/hpy/callback` (the relay); or `loopback` |
|
|
562
|
+
| `oauth.client_auth` | `HPY_OAUTH_CLIENT_AUTH` | `assertion` (confidential, signed by HappyView); or `none` (public) |
|
|
563
|
+
| `credentials.store` | `HPY_CREDENTIAL_STORE` | `auto` (the OS keychain, falling back to the file); also `keychain` or `file` |
|
|
564
|
+
|
|
565
|
+
These are read from the environment only:
|
|
566
|
+
|
|
567
|
+
| Environment | Default |
|
|
568
|
+
| --- | --- |
|
|
569
|
+
| `HPY_CACHE_DIR` | `~/.cache/hpy` (`%LOCALAPPDATA%\hpy` on Windows): HappyView binaries and plugins |
|
|
570
|
+
| `HPY_HAPPYVIEW_REPO` | `gamesgamesgamesgamesgames/happyview`: the GitHub repository HappyView releases come from |
|
|
571
|
+
| `HPY_GITHUB_API` | `https://api.github.com`: where `create` looks for the newest HappyView release |
|
|
572
|
+
| `HPY_HV_URL` | None: the instance `hpy happyview deploy` acts on, when `--url` isn't given |
|
|
573
|
+
| `HPY_HV_API_KEY` | None: the instance's API key, used instead of a saved sign-in (for CI) |
|
|
574
|
+
| `HPY_HAPPYVIEW_DOWNLOAD` | `https://github.com/<HPY_HAPPYVIEW_REPO>/releases/download`: where binaries and their `.sha256` are downloaded from |
|
|
575
|
+
|
|
576
|
+
### Signing in: how the browser gets back to `hpy`
|
|
577
|
+
|
|
578
|
+
`hpy` signs in to your PDS as a *confidential* OAuth client, which the PDS
|
|
579
|
+
trusts with a long session (up to two years, versus two weeks for a public
|
|
580
|
+
client). HappyView signs the client assertion that proves it.
|
|
581
|
+
|
|
582
|
+
A confidential client must use an `https` redirect. So the PDS sends your
|
|
583
|
+
browser to `https://happyproto.at/oauth/hpy/callback`, a static page
|
|
584
|
+
(served by the `happyproto.at` site: `src/pages/oauth/hpy/callback.astro`, with its logic in `src/lib/hpy-relay.ts`). That page forwards the response to `hpy`
|
|
585
|
+
listening on `127.0.0.1`, at the port carried in the OAuth `state`. The page
|
|
586
|
+
never sees anything usable on its own: the code needs the PKCE verifier and
|
|
587
|
+
signing key that only the waiting `hpy` holds.
|
|
588
|
+
|
|
589
|
+
`hpy happyview login` signs in to an instance as a public client
|
|
590
|
+
(`https://happyproto.at/oauth/hpy-cli/client-metadata.json`), and comes back
|
|
591
|
+
through the same page. It could use a loopback redirect, but some PDSes accept
|
|
592
|
+
one only on the port it was registered with, and `hpy` listens on a different
|
|
593
|
+
port each time.
|
|
594
|
+
|
|
595
|
+
To run against an OAuth client of your own that is registered as a public
|
|
596
|
+
native app instead, set `HPY_OAUTH_REDIRECT=loopback` and
|
|
597
|
+
`HPY_OAUTH_CLIENT_AUTH=none`.
|
|
598
|
+
|
|
599
|
+
### Where your login is kept
|
|
600
|
+
|
|
601
|
+
Signing in gives `hpy` a signing key (a DPoP key) that the registry's
|
|
602
|
+
HappyView recognises you by; HappyView holds and refreshes your PDS session
|
|
603
|
+
itself. That key is the secret part:
|
|
604
|
+
|
|
605
|
+
- **The key** goes in the OS keychain: macOS Keychain, Windows Credential
|
|
606
|
+
Manager, or the Secret Service (GNOME Keyring, KWallet) on Linux. It is
|
|
607
|
+
stored under the service `hpy`.
|
|
608
|
+
- **Everything else** goes in `credentials.json` in the config directory,
|
|
609
|
+
readable only by you. That's your DID, your handle, your PDS, and an access
|
|
610
|
+
token that is useless without the key.
|
|
611
|
+
|
|
612
|
+
If there is no usable keychain, as on a headless server or in a container,
|
|
613
|
+
the key goes in `credentials.json` too, and `hpy registry login` tells you so. Set
|
|
614
|
+
`HPY_CREDENTIAL_STORE=keychain` to make that an error instead, or `file` to
|
|
615
|
+
skip the keychain entirely.
|
|
616
|
+
|
|
617
|
+
With the npm package on macOS, the program that creates the keychain item is
|
|
618
|
+
`node` itself, so the item trusts Node: any Node script you run can read the
|
|
619
|
+
key without a prompt, and a Node upgrade makes Keychain ask again. The
|
|
620
|
+
installed binaries don't share this, since each is its own program. If that
|
|
621
|
+
matters to you, use a binary install, or `HPY_CREDENTIAL_STORE=file`.
|
|
622
|
+
|
|
623
|
+
On macOS, after `hpy` updates itself, Keychain may ask once whether the new
|
|
624
|
+
`hpy` may use its key. Choose **Always Allow**. The macOS binaries are
|
|
625
|
+
signed ad hoc (`codesign --sign -`, which Apple silicon requires to run them at
|
|
626
|
+
all), not with a Developer ID, so macOS sees each update as a new app. The
|
|
627
|
+
install script and Homebrew download them with `curl`, which sets no
|
|
628
|
+
quarantine flag, so Gatekeeper doesn't stop them; a copy downloaded with a
|
|
629
|
+
browser would need `xattr -d com.apple.quarantine hpy` first.
|
|
630
|
+
|
|
631
|
+
## Development
|
|
632
|
+
|
|
633
|
+
hpy is TypeScript. It is developed and tested on Node, and ships two ways:
|
|
634
|
+
as the npm package `hpy`, and as single-file binaries compiled
|
|
635
|
+
with [Bun](https://bun.sh) for the install script, Homebrew, apt and dnf.
|
|
636
|
+
|
|
637
|
+
```sh
|
|
638
|
+
npm ci
|
|
639
|
+
npm run check # biome, tsc, the build and vitest; what CI runs
|
|
640
|
+
npm run build # dist/hpy.mjs, the npm package's bundle
|
|
641
|
+
node dist/hpy.mjs --help
|
|
642
|
+
npm run build:bun # a Bun-compiled binary for this machine, in dist/bun
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
| Directory | Responsibility |
|
|
646
|
+
| --- | --- |
|
|
647
|
+
| `src/plugin` | No network: reads `manifest.json` and `hpy.toml`, validates against the registry's rules, computes blob CIDs, builds what the gateway is sent. |
|
|
648
|
+
| `src/atproto` | Signing in through HappyView: DPoP keys, PKCE, atproto OAuth with HappyView-signed client assertions, identity resolution. Also the credential and keychain storage, the `Repo` (reads from your PDS, writes through HappyView), and the `Registry` (queries and publish procedures). |
|
|
649
|
+
| `src/project` | HappyView app projects: `happyview.toml`, the lockfile, scaffolding, script modules, the HappyView binary, and the local network. |
|
|
650
|
+
| `src/commands`, `src/cli.ts`, `src/main.ts` | The `hpy` command tree, prompts and output. |
|
|
651
|
+
| `src/core` | Shared pieces, including ports of the Rust crates whose exact output hpy's messages and files depend on: serde_json, toml and toml_edit, semver, imagesize. |
|
|
652
|
+
|
|
653
|
+
hpy was written in Rust up to 1.0.0-alpha.32. The TypeScript port keeps its
|
|
654
|
+
output byte for byte: `test/parity` runs every case in `test/parity/cases.txt`
|
|
655
|
+
through both the last Rust build and this one and compares exit codes,
|
|
656
|
+
stdout, stderr, the files written and the requests sent. CI builds the Rust
|
|
657
|
+
reference from the last `alpha` commit that has the crates.
|
|
658
|
+
|
|
659
|
+
```sh
|
|
660
|
+
RUST_HPY=/path/to/rust/hpy node test/parity/run.mjs --strict-stderr [--offline] [filter]
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
`test/LEDGER.md` maps each of the Rust tests to the TypeScript test that
|
|
664
|
+
carries its name.
|
|
665
|
+
|
|
666
|
+
### Manual verification
|
|
667
|
+
|
|
668
|
+
The automated tests use in-memory fakes for the PDS and the registry. Before
|
|
669
|
+
a release, run through the real flow once, using a scratch project name:
|
|
670
|
+
|
|
671
|
+
1. `hpy registry login <handle>` with a bsky.social account: the browser opens, you
|
|
672
|
+
approve, and `whoami` shows you with "key in the OS keychain". Keychain
|
|
673
|
+
Access (or your OS's equivalent) shows an `hpy` item. Repeat with an account
|
|
674
|
+
on a self-hosted PDS.
|
|
675
|
+
2. `hpy registry login --export`, then
|
|
676
|
+
`HPY_CREDENTIAL=<it> hpy registry whoami` shows "from HPY_CREDENTIAL".
|
|
677
|
+
3. In a scratch plugin directory: `hpy registry plugin init`, then `hpy registry plugin show`.
|
|
678
|
+
4. `hpy registry plugin edit --keyword test`, then `hpy registry plugin show`.
|
|
679
|
+
5. `hpy registry plugin publish --dry-run`, then `hpy registry plugin publish --wait`.
|
|
680
|
+
6. `hpy registry plugin status` shows the version as `available`.
|
|
681
|
+
7. `hpy registry plugin lifecycle <version> endOfDistribution`, then `status`
|
|
682
|
+
shows it `unavailable` and not installable; `lifecycle --withdraw <its uri>`
|
|
683
|
+
undoes it.
|
|
684
|
+
8. `hpy registry logout`: the keychain item is gone, and `whoami` exits with code 3.
|
|
685
|
+
`HPY_CREDENTIAL=<it> hpy registry logout` revokes the exported session.
|
|
686
|
+
|
|
687
|
+
### Releasing
|
|
688
|
+
|
|
689
|
+
Versions come from the commit history. This works the same way as HappyView.
|
|
690
|
+
On every push to `main` (stable), `beta` or `alpha` (prereleases), once the
|
|
691
|
+
tests pass, CI runs [semantic-release](https://semantic-release.gitbook.io).
|
|
692
|
+
It reads the [Conventional Commits](https://www.conventionalcommits.org) since
|
|
693
|
+
the last release:
|
|
694
|
+
|
|
695
|
+
- `fix:` makes a patch release.
|
|
696
|
+
- `feat:` makes a minor release.
|
|
697
|
+
- `feat!:` or a `BREAKING CHANGE:` footer makes a major release.
|
|
698
|
+
- Anything else makes no release.
|
|
699
|
+
|
|
700
|
+
semantic-release then sets the version in `package.json` and
|
|
701
|
+
`package-lock.json`, updates `CHANGELOG.md`, commits and tags `vX.Y.Z`, and
|
|
702
|
+
dispatches `release.yml`.
|
|
703
|
+
|
|
704
|
+
[dist](https://opensource.axo.dev/cargo-dist/) then compiles hpy with Bun for
|
|
705
|
+
every platform on GitHub-hosted runners (free, since this repository is public), creates the GitHub Release and updates the
|
|
706
|
+
Homebrew formula. After that, `publish-linux-packages.yml` builds the
|
|
707
|
+
`.deb`/`.rpm` packages, attaches them to the release, and publishes them to the
|
|
708
|
+
apt/yum repository on the `gh-pages` branch, and `publish-npm.yml` publishes
|
|
709
|
+
the npm package under its channel's dist-tag (`latest`, `beta` or `alpha`). Every release goes to its own
|
|
710
|
+
channel only: the `hpy`, `hpy-beta` or `hpy-alpha` formula, and the `stable`,
|
|
711
|
+
`beta` or `alpha` apt suite and yum repository (`packaging/channel.sh` decides
|
|
712
|
+
which). A prerelease no channel ships, such as `-rc.1`, gets packages attached
|
|
713
|
+
to its release and is published nowhere else.
|
|
714
|
+
|
|
715
|
+
`release.yml` is dist's generated workflow with one hand-added step:
|
|
716
|
+
`packaging/patch-installer.sh` adds the musl runtime check (libstdc++, glibc
|
|
717
|
+
2.31) to dist's shell installer before it is uploaded. `dist-workspace.toml`
|
|
718
|
+
pins dist and sets `allow-dirty = ["ci"]` so dist leaves the workflow alone.
|
|
719
|
+
After a dist upgrade, regenerate the workflow (`dist generate`), add that step
|
|
720
|
+
back, and run `packaging/test-musl-guard.sh` (CI's `packaging` job does): the
|
|
721
|
+
patch script fails if dist's installer template no longer has its anchors.
|
|
722
|
+
|
|
723
|
+
Never edit the version by hand. If `main` is ever protected, add a
|
|
724
|
+
`RELEASE_TOKEN` secret: a token that can push to it.
|
|
725
|
+
|
|
726
|
+
Repository setup:
|
|
727
|
+
|
|
728
|
+
- **Homebrew:** `publish-homebrew.yml` pushes the formula to
|
|
729
|
+
`happyproto/homebrew-tap` as the `happyproto-infra-bump` GitHub App, using a
|
|
730
|
+
short-lived token it mints each release. The app must be installed on the
|
|
731
|
+
tap with Contents: read and write. This repository needs the
|
|
732
|
+
`INFRA_APP_CLIENT_ID` variable and the `INFRA_APP_PRIVATE_KEY` secret, the
|
|
733
|
+
same pair `happyproto/provisioner` uses.
|
|
734
|
+
- **npm:** `publish-npm.yml` publishes with npm trusted publishing, so there
|
|
735
|
+
is no token secret. Set it up once on npmjs.com: the `hpy` package's
|
|
736
|
+
settings, Trusted publisher, GitHub Actions, repository `happyproto/cli`,
|
|
737
|
+
with both `release.yml` (the workflow that runs) and `publish-npm.yml` (the
|
|
738
|
+
reusable one it calls) registered. If a publish fails with `E404`, the
|
|
739
|
+
trusted publisher didn't match: check it, then re-run the failed job; a
|
|
740
|
+
re-run skips a version npm already has.
|
|
741
|
+
- **Package signing key:** this is done. The key "HappyProto Packages
|
|
742
|
+
<packages@happyproto.at>" has fingerprint
|
|
743
|
+
`63B93CEDA23E09CFC42AE8A18B83C3B38ACAB74C`, and its public half is
|
|
744
|
+
`packaging/hpy-packages.asc`. It is stored in the `LINUX_PACKAGES_GPG_KEY`
|
|
745
|
+
and `LINUX_PACKAGES_GPG_PASSPHRASE` secrets. Keep an offline backup:
|
|
746
|
+
replacing the key means every user re-imports `gpg.key`.
|
|
747
|
+
- **GitHub Pages:** after the first release (of any channel) creates the
|
|
748
|
+
`gh-pages` branch, enable Pages for it (Settings → Pages → Deploy from a
|
|
749
|
+
branch → `gh-pages` / root). To serve it from your own domain, set the custom domain there, set
|
|
750
|
+
the repository variable `LINUX_PACKAGES_URL` (e.g. `https://pkg.happyproto.at`),
|
|
751
|
+
and update the URLs in the Install section.
|
|
752
|
+
|
|
753
|
+
To re-publish packages for an existing release, run the *Publish Linux
|
|
754
|
+
packages* workflow by hand with its tag.
|
|
755
|
+
|
|
756
|
+
`packaging/test-repo.sh` tests the whole Linux path in Docker: it builds a
|
|
757
|
+
`hpy` with Bun, packages and publishes it to a local repository with a
|
|
758
|
+
throwaway key, installs it with `apt` on Debian and `dnf` on Fedora, then
|
|
759
|
+
publishes an alpha and a newer stable version and checks both upgrade within
|
|
760
|
+
their channel, then switches both to the alpha channel with the commands
|
|
761
|
+
`hpy channel` prints.
|