| … | … | @@ -0,0 +1,74 @@ |
| 1 | # hyper-deploy |
| 2 | |
| 3 | P2P release distribution — serve build artifacts to peers over Hyperswarm, built on |
| 4 | [hyper-overlay](../hyper-overlay). |
| 5 | |
| 6 | Point it at a directory. It content-hashes what it finds, announces a topic, and serves the |
| 7 | files to whoever joins. Files ≥ 1 MB are FastCDC-chunked so a transfer resumes rather than |
| 8 | restarts; smaller files move as whole blobs. Dedup is per-file, by hash. |
| 9 | |
| 10 | ## Install |
| 11 | |
| 12 | ```sh |
| 13 | npm install hyper-deploy |
| 14 | ``` |
| 15 | |
| 16 | ## Usage |
| 17 | |
| 18 | ```js |
| 19 | import { DeployServer, DeployClient } from 'hyper-deploy' |
| 20 | |
| 21 | // serve a build directory |
| 22 | const server = new DeployServer('./build') |
| 23 | await server.ready() |
| 24 | console.log(server.topic.toString('hex')) |
| 25 | |
| 26 | // pull it somewhere else |
| 27 | const client = new DeployClient(topic) |
| 28 | await client.ready() |
| 29 | await client.pull('./out') |
| 30 | ``` |
| 31 | |
| 32 | ## API |
| 33 | |
| 34 | #### `new DeployServer(dir, [options])` |
| 35 | |
| 36 | `ReadyResource`. Scans `dir` and serves it. |
| 37 | |
| 38 | ```js |
| 39 | { |
| 40 | topic, // 32 bytes; a random one is generated if omitted |
| 41 | swarm, // an existing Hyperswarm; one is created and owned if omitted |
| 42 | corestore, // likewise |
| 43 | enableTrees // attach hyper-overlay/v2 for tree + content-by-hash requests (default true) |
| 44 | } |
| 45 | ``` |
| 46 | |
| 47 | #### `await server.rescan()` |
| 48 | |
| 49 | Re-scan the directory. Incremental — unchanged files are not re-hashed. |
| 50 | |
| 51 | #### `server.serveOnConnection(conn)` |
| 52 | |
| 53 | Serve over a connection you already have, rather than one the swarm handed you. Safe to call |
| 54 | more than once per connection. |
| 55 | |
| 56 | #### `new DeployClient(topic, [options])` |
| 57 | #### `await client.pull(dir)` |
| 58 | |
| 59 | ## Test |
| 60 | |
| 61 | ⚠ `npm test` is **broken**: it runs `brittle`, which is Node, and this package imports |
| 62 | `bare-fs`. Use the Bare runner: |
| 63 | |
| 64 | ```sh |
| 65 | npx brittle-bare test/basic.test.js |
| 66 | ``` |
| 67 | |
| 68 | Measured: 24 asserts across six files pass (`basic`, `connection-release`, |
| 69 | `incremental-rescan`, `manifest-boot`, `overlay-map-cache`, `tree-publish`). |
| 70 | `e2e-release-sync` and `symlink-serve` error out. |
| 71 | |
| 72 | ## License |
| 73 | |
| 74 | Not yet declared. |