@absolutejs/deploy 0.2.0 → 0.3.1

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/README.md CHANGED
@@ -154,6 +154,40 @@ interface so you can BYO `request(method, path, body?)` for retry /
154
154
  observability — the bundled `createDigitalOceanClient(token)` is just
155
155
  a sensible default.
156
156
 
157
+ ## `@absolutejs/deploy/hetzner` — provision-or-reuse from code (0.3.0)
158
+
159
+ Same shape as the DigitalOcean adapter, Hetzner Cloud v1 API
160
+ mappings underneath. Hetzner-specific differences: locations
161
+ (`nbg1` / `fsn1` / `hel1` / `ash` / `hil`), server types
162
+ (`cx22` / `cpx11` / `ccx13` / …), labels (key-value, not array),
163
+ and public-net IPv4/IPv6 are independently toggleable.
164
+
165
+ ```ts
166
+ import { createDeployer } from '@absolutejs/deploy';
167
+ import { hetznerTarget } from '@absolutejs/deploy/hetzner';
168
+
169
+ const target = await hetznerTarget({
170
+ token: process.env.HETZNER_TOKEN!,
171
+ name: 'absolutejs-prod-1',
172
+ location: 'nbg1',
173
+ serverType: 'cx22',
174
+ image: 'ubuntu-22.04',
175
+ sshKeys: [process.env.HETZNER_KEY_FINGERPRINT!],
176
+ labels: { env: 'prod', team: 'platform' },
177
+ userData: '#!/bin/bash\ncurl -fsSL https://bun.sh/install | bash',
178
+ });
179
+
180
+ const deployer = createDeployer({ appName: 'my-app', target });
181
+ await deployer.deploy({ source: { kind: 'directory', path: './build' } });
182
+ await target.destroy();
183
+ ```
184
+
185
+ Hetzner enforces unique server names per project, so the
186
+ idempotency contract is structural — `name` collisions never
187
+ happen. Admin helpers: `listHetznerServers({ token, labelSelector?
188
+ })` (Hetzner's `'env=prod'` / `'env in (prod,staging)'` syntax);
189
+ `destroyHetznerServer({ token, id })` (404 idempotent success).
190
+
157
191
  ## DigitalOcean Droplet — first deploy (manual)
158
192
 
159
193
  Assuming a fresh Ubuntu/Debian Droplet:
@@ -173,9 +207,9 @@ bun run my-deploy-script.ts
173
207
 
174
208
  The first run creates `/srv/<appName>/releases/<id>/`, drops a systemd unit at `/etc/systemd/system/<appName>.service` (if you're using `systemdManager`), starts the service, and probes. Subsequent runs just add a new release dir and swap the symlink.
175
209
 
176
- ## What v0.2.0 does NOT include
210
+ ## What v0.3.0 does NOT include
177
211
 
178
- - Provider-specific HTTP-API adapters beyond DigitalOcean (Cloudflare Workers, Fly Machines, AWS Fargate, GCP Cloud Run). Hetzner / Linode / Vultr follow the same shape as `digitalOceanTarget` and are next on the list.
212
+ - Provider-specific HTTP-API adapters beyond DigitalOcean + Hetzner (Cloudflare Workers, Fly Machines, AWS Fargate, GCP Cloud Run). Linode / Vultr follow the same shape and are next on the list.
179
213
  - Bun installation on the remote — caller does it once, out of band.
180
214
  - Multi-target / fan-out deploys (caller iterates).
181
215
  - Zero-downtime port-swap (start new release on a fresh port, then nginx-reload). The default pipeline does stop-then-start; for true zero-downtime, replace the `restart` step.
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Shared "cloud-provider Target" plumbing used by the
3
+ * provider-specific adapters (`./digitalocean`, `./hetzner`, future
4
+ * `./linode`, `./vultr`, etc.).
5
+ *
6
+ * The provider supplies a small `CloudTargetHooks` bag that knows
7
+ * the provider's:
8
+ *
9
+ * - find-by-name lookup
10
+ * - create call (closure over create params)
11
+ * - fetch-by-id (used to poll for `active`)
12
+ * - destroy-by-id
13
+ * - status + ipv4 + id extraction from the provider's Server shape
14
+ * - readiness predicate (status reached the terminal "running" value)
15
+ *
16
+ * `createCloudTarget()` does the universal machinery: provision-or-
17
+ * reuse, poll until ready + IPv4, wait for SSH probe, build
18
+ * `sshTarget` against the IPv4, return the Target wrapped with
19
+ * `{ id, ipv4, destroy() }`.
20
+ *
21
+ * The public adapter (e.g. `digitalOceanTarget`) is a 30-line facade
22
+ * that wires its provider-specific bits and renames `id` → `dropletId`
23
+ * on the way out.
24
+ */
25
+ import type { Target } from './targets';
26
+ /** Provider-specific hooks. Keep these pure of network IO timing — the helper schedules. */
27
+ export type CloudTargetHooks<Server> = {
28
+ /** Find a server by name. Returns undefined if absent. */
29
+ findByName: (name: string) => Promise<Server | undefined>;
30
+ /** Create the server. Closure over provider-specific create params. */
31
+ create: () => Promise<Server>;
32
+ /** Fetch a fresh copy of the server by id. Used to poll. */
33
+ fetch: (id: number) => Promise<Server>;
34
+ /** Destroy a server by id. 404 should be treated as idempotent success. */
35
+ destroy: (id: number) => Promise<void>;
36
+ /** True when the server has reached its terminal "running" status. */
37
+ isReady: (server: Server) => boolean;
38
+ /** Extract the numeric id. */
39
+ getId: (server: Server) => number;
40
+ /** Extract the public IPv4. Returns undefined while one is being assigned. */
41
+ getIpv4: (server: Server) => string | undefined;
42
+ /** Extract the current status as a string (for log lines). */
43
+ getStatus: (server: Server) => string;
44
+ };
45
+ export type CloudTargetOptions = {
46
+ /** Provider's idempotency key (server name). */
47
+ name: string;
48
+ /** Region / location label — used in the "creating" log line. */
49
+ region: string;
50
+ /** SSH login user. Default `'root'`. */
51
+ user?: string;
52
+ /** SSH identity file. */
53
+ identity?: string;
54
+ /** SSH port. Default 22. */
55
+ port?: number;
56
+ /** Default 5 min. */
57
+ provisionTimeoutMs?: number;
58
+ /** Default 2 min. */
59
+ sshReadinessTimeoutMs?: number;
60
+ /** Default 5 s. */
61
+ pollIntervalMs?: number;
62
+ /** Called with status updates. */
63
+ onLog?: (line: string) => void;
64
+ /** Override SSH probe — tests skip real TCP IO. */
65
+ probeSsh?: (host: string, port: number) => Promise<boolean>;
66
+ /** Override sleep — tests skip real waits. */
67
+ sleep?: (ms: number) => Promise<void>;
68
+ /** Override clock — tests inject deterministic timestamps. */
69
+ now?: () => number;
70
+ /**
71
+ * Short log prefix, e.g. `'[do]'` or `'[hetzner]'`. Threaded through
72
+ * every log line so multi-provider deploys distinguish output.
73
+ */
74
+ logPrefix: string;
75
+ /**
76
+ * Provider's word for the entity in log copy — `'droplet'` for DO,
77
+ * `'server'` for Hetzner. Preserves provider-accurate output.
78
+ */
79
+ entityWord: string;
80
+ /**
81
+ * Build the Target's `description` field. Receives the resolved
82
+ * IPv4 + the wrapped sshTarget description.
83
+ */
84
+ describeTarget: (sshDescription: string) => string;
85
+ };
86
+ export type CloudTargetResult = {
87
+ id: number;
88
+ ipv4: string;
89
+ description: string;
90
+ exec: Target['exec'];
91
+ upload: Target['upload'];
92
+ close?: Target['close'];
93
+ destroy: () => Promise<void>;
94
+ };
95
+ /**
96
+ * The shared provision-or-reuse + wait-for-ready + wait-for-SSH
97
+ * pipeline. Provider-specific adapters wire their `CloudTargetHooks`
98
+ * + their option-shape mapping and return a typed result.
99
+ */
100
+ export declare const createCloudTarget: <Server>(hooks: CloudTargetHooks<Server>, options: CloudTargetOptions) => Promise<CloudTargetResult>;
@@ -175,6 +175,102 @@ var sshTarget = (options) => {
175
175
  };
176
176
  };
177
177
 
178
+ // src/cloudTarget.ts
179
+ var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
180
+ var defaultProbeSsh = async (host, port) => {
181
+ const PROBE_TIMEOUT_MS = 2000;
182
+ return new Promise((resolve) => {
183
+ let settled = false;
184
+ const settle = (value) => {
185
+ if (settled)
186
+ return;
187
+ settled = true;
188
+ resolve(value);
189
+ };
190
+ const timer = setTimeout(() => settle(false), PROBE_TIMEOUT_MS);
191
+ Bun.connect({
192
+ hostname: host,
193
+ port,
194
+ socket: {
195
+ data: () => {},
196
+ error: () => {
197
+ clearTimeout(timer);
198
+ settle(false);
199
+ },
200
+ open: (socket) => {
201
+ clearTimeout(timer);
202
+ socket.end();
203
+ settle(true);
204
+ }
205
+ }
206
+ }).catch(() => {
207
+ clearTimeout(timer);
208
+ settle(false);
209
+ });
210
+ });
211
+ };
212
+ var createCloudTarget = async (hooks, options) => {
213
+ const log = options.onLog ?? (() => {});
214
+ const probeSsh = options.probeSsh ?? defaultProbeSsh;
215
+ const sleep = options.sleep ?? defaultSleep;
216
+ const now = options.now ?? Date.now;
217
+ const pollMs = options.pollIntervalMs ?? 5000;
218
+ const provisionTimeout = options.provisionTimeoutMs ?? 5 * 60000;
219
+ const sshTimeout = options.sshReadinessTimeoutMs ?? 2 * 60000;
220
+ const port = options.port ?? 22;
221
+ const prefix = options.logPrefix;
222
+ const noun = options.entityWord;
223
+ const existing = await hooks.findByName(options.name);
224
+ let current;
225
+ if (existing === undefined) {
226
+ log(`${prefix} creating ${noun} "${options.name}" in ${options.region}`);
227
+ current = await hooks.create();
228
+ } else {
229
+ log(`${prefix} reusing ${noun} "${options.name}" (id ${hooks.getId(existing)}, status ${hooks.getStatus(existing)})`);
230
+ current = existing;
231
+ }
232
+ const provisionStart = now();
233
+ let ipv4 = hooks.getIpv4(current);
234
+ while (!hooks.isReady(current) || ipv4 === undefined) {
235
+ if (now() - provisionStart > provisionTimeout) {
236
+ throw new Error(`${prefix} provision timeout after ${provisionTimeout}ms \u2014 ${noun} ${hooks.getId(current)} status "${hooks.getStatus(current)}", ipv4 ${ipv4 ?? "(unassigned)"}`);
237
+ }
238
+ await sleep(pollMs);
239
+ current = await hooks.fetch(hooks.getId(current));
240
+ ipv4 = hooks.getIpv4(current);
241
+ log(`${prefix} poll: status=${hooks.getStatus(current)} ipv4=${ipv4 ?? "(none yet)"}`);
242
+ }
243
+ log(`${prefix} ${noun} ready at ${ipv4}`);
244
+ const sshStart = now();
245
+ while (!await probeSsh(ipv4, port)) {
246
+ if (now() - sshStart > sshTimeout) {
247
+ throw new Error(`${prefix} SSH readiness timeout after ${sshTimeout}ms \u2014 ${ipv4}:${port} did not accept connections`);
248
+ }
249
+ await sleep(pollMs);
250
+ log(`${prefix} waiting on ssh ${ipv4}:${port}`);
251
+ }
252
+ log(`${prefix} ssh ready at ${ipv4}:${port}`);
253
+ const ssh = sshTarget({
254
+ host: ipv4,
255
+ ...options.user !== undefined ? { user: options.user } : {},
256
+ ...options.identity !== undefined ? { identity: options.identity } : {},
257
+ ...options.port !== undefined ? { port: options.port } : {}
258
+ });
259
+ const id = hooks.getId(current);
260
+ const resolvedIpv4 = ipv4;
261
+ return {
262
+ description: options.describeTarget(ssh.description),
263
+ destroy: () => hooks.destroy(id).then(() => {
264
+ log(`${prefix} destroyed ${noun} ${id}`);
265
+ }),
266
+ exec: ssh.exec,
267
+ id,
268
+ ipv4: resolvedIpv4,
269
+ upload: ssh.upload,
270
+ ...ssh.close !== undefined ? { close: ssh.close } : {}
271
+ };
272
+ };
273
+
178
274
  // src/digitalocean.ts
179
275
  var DO_API_BASE = "https://api.digitalocean.com/v2";
180
276
 
@@ -223,39 +319,6 @@ var resolveClient = (options) => {
223
319
  throw new Error("[deploy/digitalocean] either `token` or `client` must be provided");
224
320
  };
225
321
  var publicIpv4 = (droplet) => droplet.networks.v4.find((net) => net.type === "public")?.ip_address;
226
- var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
227
- var defaultProbeSsh = async (host, port) => {
228
- const PROBE_TIMEOUT_MS = 2000;
229
- return new Promise((resolve) => {
230
- let settled = false;
231
- const settle = (value) => {
232
- if (settled)
233
- return;
234
- settled = true;
235
- resolve(value);
236
- };
237
- const timer = setTimeout(() => settle(false), PROBE_TIMEOUT_MS);
238
- Bun.connect({
239
- hostname: host,
240
- port,
241
- socket: {
242
- data: () => {},
243
- error: () => {
244
- clearTimeout(timer);
245
- settle(false);
246
- },
247
- open: (socket) => {
248
- clearTimeout(timer);
249
- socket.end();
250
- settle(true);
251
- }
252
- }
253
- }).catch(() => {
254
- clearTimeout(timer);
255
- settle(false);
256
- });
257
- });
258
- };
259
322
  var findDigitalOceanDroplet = async (client, name) => {
260
323
  const body = await client.request("GET", `/droplets?name=${encodeURIComponent(name)}`);
261
324
  const matches = body.droplets.filter((droplet) => droplet.name === name);
@@ -285,75 +348,58 @@ var destroyDigitalOceanDroplet = async (options) => {
285
348
  };
286
349
  var digitalOceanTarget = async (options) => {
287
350
  const client = resolveClient(options);
288
- const log = options.onLog ?? (() => {});
289
- const probeSsh = options.probeSsh ?? defaultProbeSsh;
290
- const sleep = options.sleep ?? defaultSleep;
291
- const now = options.now ?? Date.now;
292
- const pollMs = options.pollIntervalMs ?? 5000;
293
- const provisionTimeout = options.provisionTimeoutMs ?? 5 * 60000;
294
- const sshTimeout = options.sshReadinessTimeoutMs ?? 2 * 60000;
295
- const port = options.port ?? 22;
296
- const existing = await findDigitalOceanDroplet(client, options.name);
297
- let current;
298
- if (existing === undefined) {
299
- log(`[do] creating droplet "${options.name}" in ${options.region}`);
300
- const created = await client.request("POST", "/droplets", {
301
- name: options.name,
302
- region: options.region,
303
- size: options.size,
304
- image: options.image,
305
- ssh_keys: [...options.sshKeys],
306
- ...options.tags !== undefined ? { tags: [...options.tags] } : {},
307
- ...options.userData !== undefined ? { user_data: options.userData } : {},
308
- ...options.vpcUuid !== undefined ? { vpc_uuid: options.vpcUuid } : {},
309
- ...options.ipv6 === true ? { ipv6: true } : {},
310
- ...options.monitoring === true ? { monitoring: true } : {}
311
- });
312
- current = created.droplet;
313
- } else {
314
- log(`[do] reusing droplet "${options.name}" (id ${existing.id}, status ${existing.status})`);
315
- current = existing;
316
- }
317
- const provisionStart = now();
318
- let ipv4 = publicIpv4(current);
319
- while (current.status !== "active" || ipv4 === undefined) {
320
- if (now() - provisionStart > provisionTimeout) {
321
- throw new Error(`[deploy/digitalocean] provision timeout after ${provisionTimeout}ms \u2014 droplet ${current.id} status "${current.status}", ipv4 ${ipv4 ?? "(unassigned)"}`);
322
- }
323
- await sleep(pollMs);
324
- const refreshed = await client.request("GET", `/droplets/${current.id}`);
325
- current = refreshed.droplet;
326
- ipv4 = publicIpv4(current);
327
- log(`[do] poll: status=${current.status} ipv4=${ipv4 ?? "(none yet)"}`);
328
- }
329
- log(`[do] droplet active at ${ipv4}`);
330
- const sshStart = now();
331
- while (!await probeSsh(ipv4, port)) {
332
- if (now() - sshStart > sshTimeout) {
333
- throw new Error(`[deploy/digitalocean] SSH readiness timeout after ${sshTimeout}ms \u2014 ${ipv4}:${port} did not accept connections`);
334
- }
335
- await sleep(pollMs);
336
- log(`[do] waiting on ssh ${ipv4}:${port}`);
337
- }
338
- log(`[do] ssh ready at ${ipv4}:${port}`);
339
- const ssh = sshTarget({
340
- host: ipv4,
351
+ const hooks = {
352
+ create: async () => {
353
+ const created = await client.request("POST", "/droplets", {
354
+ name: options.name,
355
+ region: options.region,
356
+ size: options.size,
357
+ image: options.image,
358
+ ssh_keys: [...options.sshKeys],
359
+ ...options.tags !== undefined ? { tags: [...options.tags] } : {},
360
+ ...options.userData !== undefined ? { user_data: options.userData } : {},
361
+ ...options.vpcUuid !== undefined ? { vpc_uuid: options.vpcUuid } : {},
362
+ ...options.ipv6 === true ? { ipv6: true } : {},
363
+ ...options.monitoring === true ? { monitoring: true } : {}
364
+ });
365
+ return created.droplet;
366
+ },
367
+ destroy: (id) => destroyDigitalOceanDroplet({ client, id }),
368
+ fetch: async (id) => {
369
+ const refreshed = await client.request("GET", `/droplets/${id}`);
370
+ return refreshed.droplet;
371
+ },
372
+ findByName: (name) => findDigitalOceanDroplet(client, name),
373
+ getId: (droplet) => droplet.id,
374
+ getIpv4: publicIpv4,
375
+ getStatus: (droplet) => droplet.status,
376
+ isReady: (droplet) => droplet.status === "active"
377
+ };
378
+ const result = await createCloudTarget(hooks, {
379
+ describeTarget: (sshDescription) => `digitalocean droplet "${options.name}" (${sshDescription})`,
380
+ entityWord: "droplet",
381
+ logPrefix: "[do]",
382
+ name: options.name,
383
+ region: options.region,
341
384
  ...options.user !== undefined ? { user: options.user } : {},
342
385
  ...options.identity !== undefined ? { identity: options.identity } : {},
343
- ...options.port !== undefined ? { port: options.port } : {}
386
+ ...options.port !== undefined ? { port: options.port } : {},
387
+ ...options.provisionTimeoutMs !== undefined ? { provisionTimeoutMs: options.provisionTimeoutMs } : {},
388
+ ...options.sshReadinessTimeoutMs !== undefined ? { sshReadinessTimeoutMs: options.sshReadinessTimeoutMs } : {},
389
+ ...options.pollIntervalMs !== undefined ? { pollIntervalMs: options.pollIntervalMs } : {},
390
+ ...options.onLog !== undefined ? { onLog: options.onLog } : {},
391
+ ...options.probeSsh !== undefined ? { probeSsh: options.probeSsh } : {},
392
+ ...options.sleep !== undefined ? { sleep: options.sleep } : {},
393
+ ...options.now !== undefined ? { now: options.now } : {}
344
394
  });
345
- const dropletId = current.id;
346
- const resolvedIpv4 = ipv4;
347
395
  return {
348
- description: `digitalocean droplet "${options.name}" (${ssh.description})`,
349
- dropletId,
350
- ipv4: resolvedIpv4,
351
- destroy: () => destroyDigitalOceanDroplet({ client, id: dropletId }).then(() => {
352
- log(`[do] destroyed droplet ${dropletId}`);
353
- }),
354
- exec: ssh.exec,
355
- upload: ssh.upload,
356
- ...ssh.close !== undefined ? { close: ssh.close } : {}
396
+ description: result.description,
397
+ destroy: result.destroy,
398
+ dropletId: result.id,
399
+ exec: result.exec,
400
+ ipv4: result.ipv4,
401
+ upload: result.upload,
402
+ ...result.close !== undefined ? { close: result.close } : {}
357
403
  };
358
404
  };
359
405
  export {
@@ -365,5 +411,5 @@ export {
365
411
  DigitalOceanError
366
412
  };
367
413
 
368
- //# debugId=54E293FAC3F67A4164756E2164756E21
414
+ //# debugId=11BAD4DF4C10A79B64756E2164756E21
369
415
  //# sourceMappingURL=digitalocean.js.map
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/targets.ts", "../src/digitalocean.ts"],
3
+ "sources": ["../src/targets.ts", "../src/cloudTarget.ts", "../src/digitalocean.ts"],
4
4
  "sourcesContent": [
5
5
  "/**\n * Target interface + bundled adapters (localTarget, sshTarget).\n *\n * A Target is the narrowest abstraction over \"a place I can deploy to\":\n *\n * - `exec(cmd, opts?)` — run a shell command, capture stdout/stderr/exitCode.\n * - `upload(localPath, remotePath, opts?)` — copy a local file or directory\n * to the target. Implementation is free to use whatever is fast (rsync,\n * scp, mv).\n * - `close?()` — optional teardown.\n *\n * Two adapters are bundled:\n *\n * - `localTarget` runs in a temp directory on the local filesystem. Useful\n * for tests and for \"deploy\" workflows that happen on the same host.\n * - `sshTarget` shells out to the system `ssh` and `rsync` binaries. No\n * `ssh2` npm dependency — the controller machine just needs `ssh` and\n * (optionally) `rsync` in PATH, which is universal on Mac/Linux/WSL.\n *\n * Provider-specific targets (Cloudflare Workers HTTP API, Fly Machines API,\n * AWS Fargate) don't fit \"exec + upload\" and ship as siblings later.\n */\n\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport type ExecOptions = {\n\t/** Working directory on the target. Default: target's root. */\n\tcwd?: string;\n\t/** Env vars to set for this command (merged onto target.env). */\n\tenv?: Record<string, string>;\n\t/** Hard kill after this many ms. Default 600_000 (10 min). 0 disables. */\n\ttimeoutMs?: number;\n\t/** Pipe stdout/stderr through here as it streams (lines, newline-stripped). */\n\tonLog?: (line: string, stream: 'stdout' | 'stderr') => void;\n\t/** Stdin payload — a string is written verbatim. */\n\tstdin?: string;\n};\n\nexport type ExecResult = {\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n};\n\nexport type UploadOptions = {\n\t/** Exclude paths matching these globs from a directory upload. */\n\texclude?: string[];\n\t/** When uploading a directory, delete remote files not present locally. */\n\tdeleteOrphans?: boolean;\n};\n\nexport type Target = {\n\t/** Human-readable description (e.g. \"ssh root@droplet-1.example.com\"). */\n\treadonly description: string;\n\texec: (cmd: string, opts?: ExecOptions) => Promise<ExecResult>;\n\tupload: (localPath: string, remotePath: string, opts?: UploadOptions) => Promise<void>;\n\tclose?: () => Promise<void>;\n};\n\n// -----------------------------------------------------------------------------\n// localTarget\n// -----------------------------------------------------------------------------\n\nexport type LocalTargetOptions = {\n\t/** Root directory the target operates in. Created if missing. */\n\troot: string;\n\t/** Env merged into every exec. */\n\tenv?: Record<string, string>;\n};\n\nconst decodeChunks = async (\n\treader: ReadableStream<Uint8Array> | null,\n\tonLine: ((line: string) => void) | undefined,\n): Promise<string> => {\n\tif (!reader) return '';\n\tconst decoder = new TextDecoder();\n\tlet buffer = '';\n\tlet collected = '';\n\tconst stream = reader.getReader();\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await stream.read();\n\t\t\tif (done) break;\n\t\t\tconst chunk = decoder.decode(value, { stream: true });\n\t\t\tcollected += chunk;\n\t\t\tif (!onLine) continue;\n\t\t\tbuffer += chunk;\n\t\t\tlet newline = buffer.indexOf('\\n');\n\t\t\twhile (newline !== -1) {\n\t\t\t\tconst line = buffer.slice(0, newline).replace(/\\r$/, '');\n\t\t\t\tif (line.length > 0) onLine(line);\n\t\t\t\tbuffer = buffer.slice(newline + 1);\n\t\t\t\tnewline = buffer.indexOf('\\n');\n\t\t\t}\n\t\t}\n\t\tconst tail = decoder.decode();\n\t\tcollected += tail;\n\t\tif (onLine && (buffer + tail).length > 0) onLine((buffer + tail).replace(/\\r$/, ''));\n\t} finally {\n\t\tstream.releaseLock();\n\t}\n\treturn collected;\n};\n\nconst runSpawn = async (\n\targv: string[],\n\toptions: {\n\t\tcwd?: string;\n\t\tenv?: Record<string, string>;\n\t\ttimeoutMs?: number;\n\t\tonLog?: ExecOptions['onLog'];\n\t\tstdin?: string;\n\t},\n): Promise<ExecResult> => {\n\tconst proc = Bun.spawn(argv, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tstderr: 'pipe',\n\t\tstdin: options.stdin === undefined ? 'ignore' : 'pipe',\n\t\tstdout: 'pipe',\n\t});\n\n\tif (options.stdin !== undefined && proc.stdin) {\n\t\t// Bun.spawn returns a FileSink for piped stdin — `write` + `end`, not a\n\t\t// WritableStream. (We use a permissive cast because @types/bun's\n\t\t// Subprocess.stdin discriminant flips based on the stdin generic.)\n\t\tconst sink = proc.stdin as unknown as {\n\t\t\twrite: (chunk: string | Uint8Array) => number | Promise<number>;\n\t\t\tend: () => void | Promise<void>;\n\t\t};\n\t\tconst wrote = sink.write(options.stdin);\n\t\tif (wrote && typeof (wrote as Promise<number>).then === 'function') {\n\t\t\tawait wrote;\n\t\t}\n\t\tconst ended = sink.end();\n\t\tif (ended && typeof (ended as Promise<void>).then === 'function') {\n\t\t\tawait ended;\n\t\t}\n\t}\n\n\tconst timeout = options.timeoutMs ?? 600_000;\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tif (timeout > 0) {\n\t\ttimer = setTimeout(() => {\n\t\t\ttry { proc.kill(); } catch { /* already gone */ }\n\t\t}, timeout);\n\t}\n\n\tconst stdoutPromise = decodeChunks(\n\t\tproc.stdout as unknown as ReadableStream<Uint8Array>,\n\t\toptions.onLog ? (line) => options.onLog!(line, 'stdout') : undefined,\n\t);\n\tconst stderrPromise = decodeChunks(\n\t\tproc.stderr as unknown as ReadableStream<Uint8Array>,\n\t\toptions.onLog ? (line) => options.onLog!(line, 'stderr') : undefined,\n\t);\n\n\tconst [stdout, stderr, exitCode] = await Promise.all([\n\t\tstdoutPromise,\n\t\tstderrPromise,\n\t\tproc.exited,\n\t]);\n\tif (timer) clearTimeout(timer);\n\n\treturn { exitCode: exitCode ?? -1, stderr, stdout };\n};\n\nexport const localTarget = (options: LocalTargetOptions): Target => {\n\tconst baseEnv = { ...options.env };\n\tconst ensureRoot = async () => { await mkdir(options.root, { recursive: true }); };\n\n\treturn {\n\t\tdescription: `local ${options.root}`,\n\t\texec: async (cmd, opts) => {\n\t\t\tawait ensureRoot();\n\t\t\treturn runSpawn(['sh', '-c', cmd], {\n\t\t\t\tcwd: opts?.cwd ?? options.root,\n\t\t\t\tenv: { ...process.env, ...baseEnv, ...(opts?.env ?? {}) } as Record<string, string>,\n\t\t\t\tonLog: opts?.onLog,\n\t\t\t\tstdin: opts?.stdin,\n\t\t\t\ttimeoutMs: opts?.timeoutMs,\n\t\t\t});\n\t\t},\n\t\tupload: async (localPath, remotePath, opts) => {\n\t\t\tawait ensureRoot();\n\t\t\tconst dest = remotePath.startsWith('/') ? remotePath : join(options.root, remotePath);\n\t\t\tconst argv = ['rsync', '-a'];\n\t\t\tif (opts?.deleteOrphans) argv.push('--delete');\n\t\t\tfor (const pattern of opts?.exclude ?? []) argv.push('--exclude', pattern);\n\t\t\t// rsync semantics: a trailing slash on the source copies *contents*; without it the dir itself is nested.\n\t\t\targv.push(localPath, dest);\n\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`local upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t}\n\t\t},\n\t};\n};\n\n// -----------------------------------------------------------------------------\n// sshTarget\n// -----------------------------------------------------------------------------\n\nexport type SshTargetOptions = {\n\t/** Hostname or IP of the remote. */\n\thost: string;\n\t/** Login user. Default `root`. */\n\tuser?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\t/** Path to SSH identity file. Default: ssh's own search. */\n\tidentity?: string;\n\t/** Extra flags appended to every `ssh` invocation. */\n\tsshFlags?: string[];\n\t/**\n\t * Use rsync for `upload`. Default true. When false, falls back to `scp`\n\t * which is universal but doesn't support delete / exclude.\n\t */\n\trsync?: boolean;\n\t/**\n\t * Env vars to forward via `ssh -o SendEnv=...`. Most remote sshd configs\n\t * accept only `LANG` and `LC_*` by default; for app env vars use the\n\t * step `env` option instead, which prepends `KEY=value` to the command.\n\t */\n\tforwardEnv?: string[];\n};\n\nconst sshTargetString = (options: SshTargetOptions): string => {\n\tconst user = options.user ?? 'root';\n\treturn `${user}@${options.host}`;\n};\n\nconst sshBaseFlags = (options: SshTargetOptions): string[] => {\n\tconst flags: string[] = [];\n\tif (options.port !== undefined && options.port !== 22) flags.push('-p', String(options.port));\n\tif (options.identity !== undefined) flags.push('-i', options.identity);\n\t// Never get stuck on a host-key prompt; treat unknown hosts as a fatal config issue rather than a UX detour.\n\tflags.push('-o', 'BatchMode=yes', '-o', 'StrictHostKeyChecking=accept-new');\n\tfor (const flag of options.sshFlags ?? []) flags.push(flag);\n\treturn flags;\n};\n\nconst shellQuote = (value: string): string => `'${value.replace(/'/g, `'\\\\''`)}'`;\n\nconst buildRemoteCmd = (cmd: string, opts: ExecOptions | undefined): string => {\n\tconst env = opts?.env;\n\tconst envPrefix = env\n\t\t? Object.entries(env).map(([k, v]) => `${k}=${shellQuote(v)}`).join(' ') + ' '\n\t\t: '';\n\tif (opts?.cwd) {\n\t\treturn `cd ${shellQuote(opts.cwd)} && ${envPrefix}${cmd}`;\n\t}\n\treturn `${envPrefix}${cmd}`;\n};\n\nexport const sshTarget = (options: SshTargetOptions): Target => {\n\tconst remote = sshTargetString(options);\n\tconst useRsync = options.rsync ?? true;\n\n\treturn {\n\t\tdescription: `ssh ${remote}${options.port && options.port !== 22 ? `:${options.port}` : ''}`,\n\t\texec: async (cmd, opts) => {\n\t\t\tconst argv = ['ssh', ...sshBaseFlags(options)];\n\t\t\tfor (const name of options.forwardEnv ?? []) argv.push('-o', `SendEnv=${name}`);\n\t\t\targv.push(remote, buildRemoteCmd(cmd, opts));\n\t\t\treturn runSpawn(argv, {\n\t\t\t\tonLog: opts?.onLog,\n\t\t\t\tstdin: opts?.stdin,\n\t\t\t\ttimeoutMs: opts?.timeoutMs,\n\t\t\t});\n\t\t},\n\t\tupload: async (localPath, remotePath, opts) => {\n\t\t\tif (useRsync) {\n\t\t\t\tconst sshCmd = ['ssh', ...sshBaseFlags(options)].map((part) => part.includes(' ') ? `'${part}'` : part).join(' ');\n\t\t\t\tconst argv = ['rsync', '-az', '-e', sshCmd];\n\t\t\t\tif (opts?.deleteOrphans) argv.push('--delete');\n\t\t\t\tfor (const pattern of opts?.exclude ?? []) argv.push('--exclude', pattern);\n\t\t\t\targv.push(localPath, `${remote}:${remotePath}`);\n\t\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\t\tif (result.exitCode !== 0) {\n\t\t\t\t\tthrow new Error(`rsync upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// scp fallback — no exclude, no delete. We still need -r to copy directories.\n\t\t\tconst argv = ['scp', '-r', ...sshBaseFlags(options), localPath, `${remote}:${remotePath}`];\n\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`scp upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t}\n\t\t},\n\t};\n};\n",
6
- "/**\n * @absolutejs/deploy/digitalocean — provision-or-reuse Target adapter\n * for DigitalOcean droplets.\n *\n * What it does:\n *\n * 1. Looks up a droplet by `name`. If present and active, reuses it.\n * 2. If not present, creates it via the DO v2 API and waits for\n * `status === 'active'` with a public IPv4 assigned.\n * 3. Waits for SSH readiness (TCP connect on port 22 with backoff,\n * or a caller-supplied probe).\n * 4. Returns a Target that wraps sshTarget against the droplet's\n * public IPv4, plus `dropletId`, `ipv4`, and a `destroy()` helper.\n *\n * Idempotent by name — calling twice with the same name returns the\n * same droplet, no duplicates created. If multiple droplets share\n * the name, throws (the caller has drifted state to clean up).\n *\n * Narrow DigitalOceanClientLike interface keeps the dots-on-the-i\n * SDK out as a hard dep. Default client uses `fetch` against\n * `api.digitalocean.com`; pass your own for retry / observability.\n */\n\nimport type { Target } from './targets';\nimport { sshTarget } from './targets';\n\nconst DO_API_BASE = 'https://api.digitalocean.com/v2';\n\n/**\n * Minimal subset of DO API calls we make. Lets callers BYO a client\n * with retry / observability / etc. (e.g. wrap got, undici, or a\n * tenant-scoped client that injects different tokens per call).\n */\nexport type DigitalOceanClientLike = {\n\trequest: <T = unknown>(\n\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\tpath: string,\n\t\tbody?: unknown\n\t) => Promise<T>;\n};\n\n/** A DigitalOcean droplet record, narrowed to what we inspect. */\nexport type DigitalOceanDroplet = {\n\tid: number;\n\tname: string;\n\tstatus: 'new' | 'active' | 'off' | 'archive';\n\tregion?: { slug: string };\n\tsize_slug?: string;\n\tnetworks: {\n\t\tv4: Array<{ ip_address: string; type: 'public' | 'private' }>;\n\t\tv6?: Array<{ ip_address: string; type: 'public' | 'private' }>;\n\t};\n\ttags?: string[];\n};\n\nexport type DigitalOceanTargetOptions = {\n\t/** API token (https://cloud.digitalocean.com/account/api/tokens). Required unless `client` is set. */\n\ttoken?: string;\n\t/** Custom client. Overrides token-built default. */\n\tclient?: DigitalOceanClientLike;\n\n\t// ── Droplet shape ────────────────────────────────────────────────\n\t/** Droplet name. Also the idempotency key. */\n\tname: string;\n\t/** Region slug — `'nyc3'`, `'sfo3'`, `'ams3'`, etc. */\n\tregion: string;\n\t/** Size slug — `'s-1vcpu-1gb'`, `'s-2vcpu-4gb'`, etc. */\n\tsize: string;\n\t/** Image slug, snapshot id, or backup id. e.g. `'ubuntu-22-04-x64'`. */\n\timage: string | number;\n\t/** SSH key fingerprints OR numeric ids. At least one required to ssh in. */\n\tsshKeys: ReadonlyArray<string | number>;\n\t/** Tags applied at creation. Useful for `listDroplets({ tag })`. */\n\ttags?: ReadonlyArray<string>;\n\t/** cloud-init user data — a shell script or YAML config. */\n\tuserData?: string;\n\t/** VPC UUID. Defaults to the account's default VPC for the region. */\n\tvpcUuid?: string;\n\t/** Enable IPv6. Default false. */\n\tipv6?: boolean;\n\t/** Enable monitoring agent. Default false. */\n\tmonitoring?: boolean;\n\n\t// ── SSH wrap ────────────────────────────────────────────────────\n\t/** SSH login user. Default `'root'`. */\n\tuser?: string;\n\t/** Path to SSH identity file forwarded to sshTarget. */\n\tidentity?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\n\t// ── Timing ──────────────────────────────────────────────────────\n\t/** Max time to wait for droplet `active` + IPv4. Default 5 min. */\n\tprovisionTimeoutMs?: number;\n\t/** Max time to wait for SSH probe to succeed. Default 2 min. */\n\tsshReadinessTimeoutMs?: number;\n\t/** Poll interval for provision + ssh probe. Default 5 s. */\n\tpollIntervalMs?: number;\n\n\t// ── Observability + injection points ───────────────────────────\n\t/** Called with status updates (one line each). Default: noop. */\n\tonLog?: (line: string) => void;\n\t/**\n\t * Override the SSH readiness probe. Default opens a TCP socket to\n\t * `host:port`. Tests pass a fake probe to skip real network IO.\n\t */\n\tprobeSsh?: (host: string, port: number) => Promise<boolean>;\n\t/**\n\t * Sleep used between polls. Default `setTimeout`-based. Tests can\n\t * pass a synchronous resolver to skip real waits.\n\t */\n\tsleep?: (ms: number) => Promise<void>;\n\t/** Wall clock. Defaults to `Date.now`. Tests can swap. */\n\tnow?: () => number;\n};\n\nexport type DigitalOceanTarget = Target & {\n\treadonly dropletId: number;\n\treadonly ipv4: string;\n\t/** Destroy the droplet via the DO API. */\n\tdestroy: () => Promise<void>;\n};\n\nexport class DigitalOceanError extends Error {\n\treadonly status: number;\n\treadonly body: unknown;\n\tconstructor(message: string, status: number, body: unknown) {\n\t\tsuper(message);\n\t\tthis.name = 'DigitalOceanError';\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t}\n}\n\n/**\n * fetch-backed default client. Talks JSON to `api.digitalocean.com/v2`.\n * Throws DigitalOceanError on non-2xx with the response body attached\n * so the caller can switch on `err.status`.\n */\nexport const createDigitalOceanClient = (\n\ttoken: string,\n\toptions: { baseUrl?: string; fetch?: typeof fetch } = {}\n): DigitalOceanClientLike => {\n\tconst base = options.baseUrl ?? DO_API_BASE;\n\tconst f = options.fetch ?? fetch;\n\treturn {\n\t\trequest: async <T>(\n\t\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\t\tpath: string,\n\t\t\tbody?: unknown\n\t\t): Promise<T> => {\n\t\t\tconst init: RequestInit = {\n\t\t\t\theaders: {\n\t\t\t\t\tauthorization: `Bearer ${token}`,\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t},\n\t\t\t\tmethod\n\t\t\t};\n\t\t\tif (body !== undefined) init.body = JSON.stringify(body);\n\t\t\tconst response = await f(`${base}${path}`, init);\n\t\t\tif (response.status === 204) return undefined as T;\n\t\t\tconst text = await response.text();\n\t\t\tconst parsed = text.length > 0 ? JSON.parse(text) : undefined;\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new DigitalOceanError(\n\t\t\t\t\t`DigitalOcean API ${method} ${path} failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tparsed\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn parsed as T;\n\t\t}\n\t};\n};\n\nconst resolveClient = (\n\toptions: Pick<DigitalOceanTargetOptions, 'client' | 'token'>\n): DigitalOceanClientLike => {\n\tif (options.client !== undefined) return options.client;\n\tif (options.token !== undefined && options.token.length > 0) {\n\t\treturn createDigitalOceanClient(options.token);\n\t}\n\tthrow new Error(\n\t\t'[deploy/digitalocean] either `token` or `client` must be provided'\n\t);\n};\n\nconst publicIpv4 = (droplet: DigitalOceanDroplet): string | undefined =>\n\tdroplet.networks.v4.find((net) => net.type === 'public')?.ip_address;\n\nconst defaultSleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms));\n\nconst defaultProbeSsh = async (host: string, port: number): Promise<boolean> => {\n\tconst PROBE_TIMEOUT_MS = 2_000;\n\treturn new Promise<boolean>((resolve) => {\n\t\tlet settled = false;\n\t\tconst settle = (value: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tresolve(value);\n\t\t};\n\t\tconst timer = setTimeout(() => settle(false), PROBE_TIMEOUT_MS);\n\t\tBun.connect({\n\t\t\thostname: host,\n\t\t\tport,\n\t\t\tsocket: {\n\t\t\t\tdata: () => {},\n\t\t\t\terror: () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tsettle(false);\n\t\t\t\t},\n\t\t\t\topen: (socket) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tsocket.end();\n\t\t\t\t\tsettle(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}).catch(() => {\n\t\t\tclearTimeout(timer);\n\t\t\tsettle(false);\n\t\t});\n\t});\n};\n\n/**\n * Find a droplet by name. Returns undefined if absent.\n * Throws if more than one droplet shares the name (drifted state).\n */\nexport const findDigitalOceanDroplet = async (\n\tclient: DigitalOceanClientLike,\n\tname: string\n): Promise<DigitalOceanDroplet | undefined> => {\n\t// DO's list endpoint supports `name=` exact-match filtering.\n\tconst body = await client.request<{ droplets: DigitalOceanDroplet[] }>(\n\t\t'GET',\n\t\t`/droplets?name=${encodeURIComponent(name)}`\n\t);\n\tconst matches = body.droplets.filter((droplet) => droplet.name === name);\n\tif (matches.length === 0) return undefined;\n\tif (matches.length > 1) {\n\t\tthrow new Error(\n\t\t\t`[deploy/digitalocean] multiple droplets named \"${name}\" (${matches\n\t\t\t\t.map((droplet) => droplet.id)\n\t\t\t\t.join(', ')}). Resolve manually before adopting.`\n\t\t);\n\t}\n\treturn matches[0];\n};\n\n/** List droplets, optionally filtered by tag. Useful for cleanup tasks. */\nexport const listDigitalOceanDroplets = async (options: {\n\ttoken?: string;\n\tclient?: DigitalOceanClientLike;\n\ttag?: string;\n}): Promise<DigitalOceanDroplet[]> => {\n\tconst client = resolveClient(options);\n\tconst path =\n\t\toptions.tag !== undefined\n\t\t\t? `/droplets?tag_name=${encodeURIComponent(options.tag)}`\n\t\t\t: '/droplets';\n\tconst body = await client.request<{ droplets: DigitalOceanDroplet[] }>(\n\t\t'GET',\n\t\tpath\n\t);\n\treturn body.droplets;\n};\n\n/** Destroy a droplet by id. No-op if already gone. */\nexport const destroyDigitalOceanDroplet = async (options: {\n\ttoken?: string;\n\tclient?: DigitalOceanClientLike;\n\tid: number;\n}): Promise<void> => {\n\tconst client = resolveClient(options);\n\ttry {\n\t\tawait client.request('DELETE', `/droplets/${options.id}`);\n\t} catch (error) {\n\t\tif (error instanceof DigitalOceanError && error.status === 404) {\n\t\t\treturn; // already destroyed — idempotent\n\t\t}\n\t\tthrow error;\n\t}\n};\n\n/**\n * Provision-or-reuse a DO droplet by name, wait for SSH, return a\n * Target. Idempotent: same name → same droplet.\n */\nexport const digitalOceanTarget = async (\n\toptions: DigitalOceanTargetOptions\n): Promise<DigitalOceanTarget> => {\n\tconst client = resolveClient(options);\n\tconst log = options.onLog ?? (() => {});\n\tconst probeSsh = options.probeSsh ?? defaultProbeSsh;\n\tconst sleep = options.sleep ?? defaultSleep;\n\tconst now = options.now ?? Date.now;\n\tconst pollMs = options.pollIntervalMs ?? 5_000;\n\tconst provisionTimeout = options.provisionTimeoutMs ?? 5 * 60_000;\n\tconst sshTimeout = options.sshReadinessTimeoutMs ?? 2 * 60_000;\n\tconst port = options.port ?? 22;\n\n\tconst existing = await findDigitalOceanDroplet(client, options.name);\n\tlet current: DigitalOceanDroplet;\n\tif (existing === undefined) {\n\t\tlog(`[do] creating droplet \"${options.name}\" in ${options.region}`);\n\t\tconst created = await client.request<{ droplet: DigitalOceanDroplet }>(\n\t\t\t'POST',\n\t\t\t'/droplets',\n\t\t\t{\n\t\t\t\tname: options.name,\n\t\t\t\tregion: options.region,\n\t\t\t\tsize: options.size,\n\t\t\t\timage: options.image,\n\t\t\t\tssh_keys: [...options.sshKeys],\n\t\t\t\t...(options.tags !== undefined ? { tags: [...options.tags] } : {}),\n\t\t\t\t...(options.userData !== undefined\n\t\t\t\t\t? { user_data: options.userData }\n\t\t\t\t\t: {}),\n\t\t\t\t...(options.vpcUuid !== undefined\n\t\t\t\t\t? { vpc_uuid: options.vpcUuid }\n\t\t\t\t\t: {}),\n\t\t\t\t...(options.ipv6 === true ? { ipv6: true } : {}),\n\t\t\t\t...(options.monitoring === true ? { monitoring: true } : {})\n\t\t\t}\n\t\t);\n\t\tcurrent = created.droplet;\n\t} else {\n\t\tlog(\n\t\t\t`[do] reusing droplet \"${options.name}\" (id ${existing.id}, status ${existing.status})`\n\t\t);\n\t\tcurrent = existing;\n\t}\n\n\t// Wait for status=active AND public IPv4 assigned.\n\tconst provisionStart = now();\n\tlet ipv4 = publicIpv4(current);\n\twhile (current.status !== 'active' || ipv4 === undefined) {\n\t\tif (now() - provisionStart > provisionTimeout) {\n\t\t\tthrow new Error(\n\t\t\t\t`[deploy/digitalocean] provision timeout after ${provisionTimeout}ms — droplet ${current.id} status \"${current.status}\", ipv4 ${ipv4 ?? '(unassigned)'}`\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollMs);\n\t\tconst refreshed: { droplet: DigitalOceanDroplet } = await client.request(\n\t\t\t'GET',\n\t\t\t`/droplets/${current.id}`\n\t\t);\n\t\tcurrent = refreshed.droplet;\n\t\tipv4 = publicIpv4(current);\n\t\tlog(`[do] poll: status=${current.status} ipv4=${ipv4 ?? '(none yet)'}`);\n\t}\n\tlog(`[do] droplet active at ${ipv4}`);\n\n\t// Wait for SSH readiness.\n\tconst sshStart = now();\n\twhile (!(await probeSsh(ipv4, port))) {\n\t\tif (now() - sshStart > sshTimeout) {\n\t\t\tthrow new Error(\n\t\t\t\t`[deploy/digitalocean] SSH readiness timeout after ${sshTimeout}ms — ${ipv4}:${port} did not accept connections`\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollMs);\n\t\tlog(`[do] waiting on ssh ${ipv4}:${port}`);\n\t}\n\tlog(`[do] ssh ready at ${ipv4}:${port}`);\n\n\tconst ssh = sshTarget({\n\t\thost: ipv4,\n\t\t...(options.user !== undefined ? { user: options.user } : {}),\n\t\t...(options.identity !== undefined ? { identity: options.identity } : {}),\n\t\t...(options.port !== undefined ? { port: options.port } : {})\n\t});\n\n\tconst dropletId = current.id;\n\tconst resolvedIpv4 = ipv4;\n\n\treturn {\n\t\tdescription: `digitalocean droplet \"${options.name}\" (${ssh.description})`,\n\t\tdropletId,\n\t\tipv4: resolvedIpv4,\n\t\tdestroy: () =>\n\t\t\tdestroyDigitalOceanDroplet({ client, id: dropletId }).then(() => {\n\t\t\t\tlog(`[do] destroyed droplet ${dropletId}`);\n\t\t\t}),\n\t\texec: ssh.exec,\n\t\tupload: ssh.upload,\n\t\t...(ssh.close !== undefined ? { close: ssh.close } : {})\n\t};\n};\n"
6
+ "/**\n * Shared \"cloud-provider Target\" plumbing used by the\n * provider-specific adapters (`./digitalocean`, `./hetzner`, future\n * `./linode`, `./vultr`, etc.).\n *\n * The provider supplies a small `CloudTargetHooks` bag that knows\n * the provider's:\n *\n * - find-by-name lookup\n * - create call (closure over create params)\n * - fetch-by-id (used to poll for `active`)\n * - destroy-by-id\n * - status + ipv4 + id extraction from the provider's Server shape\n * - readiness predicate (status reached the terminal \"running\" value)\n *\n * `createCloudTarget()` does the universal machinery: provision-or-\n * reuse, poll until ready + IPv4, wait for SSH probe, build\n * `sshTarget` against the IPv4, return the Target wrapped with\n * `{ id, ipv4, destroy() }`.\n *\n * The public adapter (e.g. `digitalOceanTarget`) is a 30-line facade\n * that wires its provider-specific bits and renames `id` → `dropletId`\n * on the way out.\n */\n\nimport type { Target } from './targets';\nimport { sshTarget } from './targets';\n\n/** Provider-specific hooks. Keep these pure of network IO timing — the helper schedules. */\nexport type CloudTargetHooks<Server> = {\n\t/** Find a server by name. Returns undefined if absent. */\n\tfindByName: (name: string) => Promise<Server | undefined>;\n\t/** Create the server. Closure over provider-specific create params. */\n\tcreate: () => Promise<Server>;\n\t/** Fetch a fresh copy of the server by id. Used to poll. */\n\tfetch: (id: number) => Promise<Server>;\n\t/** Destroy a server by id. 404 should be treated as idempotent success. */\n\tdestroy: (id: number) => Promise<void>;\n\t/** True when the server has reached its terminal \"running\" status. */\n\tisReady: (server: Server) => boolean;\n\t/** Extract the numeric id. */\n\tgetId: (server: Server) => number;\n\t/** Extract the public IPv4. Returns undefined while one is being assigned. */\n\tgetIpv4: (server: Server) => string | undefined;\n\t/** Extract the current status as a string (for log lines). */\n\tgetStatus: (server: Server) => string;\n};\n\nexport type CloudTargetOptions = {\n\t/** Provider's idempotency key (server name). */\n\tname: string;\n\t/** Region / location label — used in the \"creating\" log line. */\n\tregion: string;\n\n\t/** SSH login user. Default `'root'`. */\n\tuser?: string;\n\t/** SSH identity file. */\n\tidentity?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\n\t/** Default 5 min. */\n\tprovisionTimeoutMs?: number;\n\t/** Default 2 min. */\n\tsshReadinessTimeoutMs?: number;\n\t/** Default 5 s. */\n\tpollIntervalMs?: number;\n\n\t/** Called with status updates. */\n\tonLog?: (line: string) => void;\n\t/** Override SSH probe — tests skip real TCP IO. */\n\tprobeSsh?: (host: string, port: number) => Promise<boolean>;\n\t/** Override sleep — tests skip real waits. */\n\tsleep?: (ms: number) => Promise<void>;\n\t/** Override clock — tests inject deterministic timestamps. */\n\tnow?: () => number;\n\n\t/**\n\t * Short log prefix, e.g. `'[do]'` or `'[hetzner]'`. Threaded through\n\t * every log line so multi-provider deploys distinguish output.\n\t */\n\tlogPrefix: string;\n\t/**\n\t * Provider's word for the entity in log copy — `'droplet'` for DO,\n\t * `'server'` for Hetzner. Preserves provider-accurate output.\n\t */\n\tentityWord: string;\n\t/**\n\t * Build the Target's `description` field. Receives the resolved\n\t * IPv4 + the wrapped sshTarget description.\n\t */\n\tdescribeTarget: (sshDescription: string) => string;\n};\n\nexport type CloudTargetResult = {\n\tid: number;\n\tipv4: string;\n\tdescription: string;\n\texec: Target['exec'];\n\tupload: Target['upload'];\n\tclose?: Target['close'];\n\tdestroy: () => Promise<void>;\n};\n\nconst defaultSleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms));\n\nconst defaultProbeSsh = async (host: string, port: number): Promise<boolean> => {\n\tconst PROBE_TIMEOUT_MS = 2_000;\n\treturn new Promise<boolean>((resolve) => {\n\t\tlet settled = false;\n\t\tconst settle = (value: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tresolve(value);\n\t\t};\n\t\tconst timer = setTimeout(() => settle(false), PROBE_TIMEOUT_MS);\n\t\tBun.connect({\n\t\t\thostname: host,\n\t\t\tport,\n\t\t\tsocket: {\n\t\t\t\tdata: () => {},\n\t\t\t\terror: () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tsettle(false);\n\t\t\t\t},\n\t\t\t\topen: (socket) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tsocket.end();\n\t\t\t\t\tsettle(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}).catch(() => {\n\t\t\tclearTimeout(timer);\n\t\t\tsettle(false);\n\t\t});\n\t});\n};\n\n/**\n * The shared provision-or-reuse + wait-for-ready + wait-for-SSH\n * pipeline. Provider-specific adapters wire their `CloudTargetHooks`\n * + their option-shape mapping and return a typed result.\n */\nexport const createCloudTarget = async <Server>(\n\thooks: CloudTargetHooks<Server>,\n\toptions: CloudTargetOptions\n): Promise<CloudTargetResult> => {\n\tconst log = options.onLog ?? (() => {});\n\tconst probeSsh = options.probeSsh ?? defaultProbeSsh;\n\tconst sleep = options.sleep ?? defaultSleep;\n\tconst now = options.now ?? Date.now;\n\tconst pollMs = options.pollIntervalMs ?? 5_000;\n\tconst provisionTimeout = options.provisionTimeoutMs ?? 5 * 60_000;\n\tconst sshTimeout = options.sshReadinessTimeoutMs ?? 2 * 60_000;\n\tconst port = options.port ?? 22;\n\tconst prefix = options.logPrefix;\n\tconst noun = options.entityWord;\n\n\tconst existing = await hooks.findByName(options.name);\n\tlet current: Server;\n\tif (existing === undefined) {\n\t\tlog(`${prefix} creating ${noun} \"${options.name}\" in ${options.region}`);\n\t\tcurrent = await hooks.create();\n\t} else {\n\t\tlog(\n\t\t\t`${prefix} reusing ${noun} \"${options.name}\" (id ${hooks.getId(existing)}, status ${hooks.getStatus(existing)})`\n\t\t);\n\t\tcurrent = existing;\n\t}\n\n\t// Wait for status=ready AND public IPv4 assigned.\n\tconst provisionStart = now();\n\tlet ipv4 = hooks.getIpv4(current);\n\twhile (!hooks.isReady(current) || ipv4 === undefined) {\n\t\tif (now() - provisionStart > provisionTimeout) {\n\t\t\tthrow new Error(\n\t\t\t\t`${prefix} provision timeout after ${provisionTimeout}ms — ${noun} ${hooks.getId(current)} status \"${hooks.getStatus(current)}\", ipv4 ${ipv4 ?? '(unassigned)'}`\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollMs);\n\t\tcurrent = await hooks.fetch(hooks.getId(current));\n\t\tipv4 = hooks.getIpv4(current);\n\t\tlog(\n\t\t\t`${prefix} poll: status=${hooks.getStatus(current)} ipv4=${ipv4 ?? '(none yet)'}`\n\t\t);\n\t}\n\tlog(`${prefix} ${noun} ready at ${ipv4}`);\n\n\t// Wait for SSH readiness.\n\tconst sshStart = now();\n\twhile (!(await probeSsh(ipv4, port))) {\n\t\tif (now() - sshStart > sshTimeout) {\n\t\t\tthrow new Error(\n\t\t\t\t`${prefix} SSH readiness timeout after ${sshTimeout}ms — ${ipv4}:${port} did not accept connections`\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollMs);\n\t\tlog(`${prefix} waiting on ssh ${ipv4}:${port}`);\n\t}\n\tlog(`${prefix} ssh ready at ${ipv4}:${port}`);\n\n\tconst ssh = sshTarget({\n\t\thost: ipv4,\n\t\t...(options.user !== undefined ? { user: options.user } : {}),\n\t\t...(options.identity !== undefined ? { identity: options.identity } : {}),\n\t\t...(options.port !== undefined ? { port: options.port } : {})\n\t});\n\n\tconst id = hooks.getId(current);\n\tconst resolvedIpv4 = ipv4;\n\n\treturn {\n\t\tdescription: options.describeTarget(ssh.description),\n\t\tdestroy: () =>\n\t\t\thooks.destroy(id).then(() => {\n\t\t\t\tlog(`${prefix} destroyed ${noun} ${id}`);\n\t\t\t}),\n\t\texec: ssh.exec,\n\t\tid,\n\t\tipv4: resolvedIpv4,\n\t\tupload: ssh.upload,\n\t\t...(ssh.close !== undefined ? { close: ssh.close } : {})\n\t};\n};\n",
7
+ "/**\n * @absolutejs/deploy/digitalocean — provision-or-reuse Target adapter\n * for DigitalOcean droplets.\n *\n * What it does:\n *\n * 1. Looks up a droplet by `name`. If present and active, reuses it.\n * 2. If not present, creates it via the DO v2 API and waits for\n * `status === 'active'` with a public IPv4 assigned.\n * 3. Waits for SSH readiness (TCP connect on port 22 with backoff,\n * or a caller-supplied probe).\n * 4. Returns a Target that wraps sshTarget against the droplet's\n * public IPv4, plus `dropletId`, `ipv4`, and a `destroy()` helper.\n *\n * Idempotent by name — calling twice with the same name returns the\n * same droplet, no duplicates created. If multiple droplets share\n * the name, throws (the caller has drifted state to clean up).\n *\n * Narrow DigitalOceanClientLike interface keeps the dots-on-the-i\n * SDK out as a hard dep. Default client uses `fetch` against\n * `api.digitalocean.com`; pass your own for retry / observability.\n */\n\nimport type { Target } from './targets';\nimport { createCloudTarget, type CloudTargetHooks } from './cloudTarget';\n\nconst DO_API_BASE = 'https://api.digitalocean.com/v2';\n\n/**\n * Minimal subset of DO API calls we make. Lets callers BYO a client\n * with retry / observability / etc. (e.g. wrap got, undici, or a\n * tenant-scoped client that injects different tokens per call).\n */\nexport type DigitalOceanClientLike = {\n\trequest: <T = unknown>(\n\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\tpath: string,\n\t\tbody?: unknown\n\t) => Promise<T>;\n};\n\n/** A DigitalOcean droplet record, narrowed to what we inspect. */\nexport type DigitalOceanDroplet = {\n\tid: number;\n\tname: string;\n\tstatus: 'new' | 'active' | 'off' | 'archive';\n\tregion?: { slug: string };\n\tsize_slug?: string;\n\tnetworks: {\n\t\tv4: Array<{ ip_address: string; type: 'public' | 'private' }>;\n\t\tv6?: Array<{ ip_address: string; type: 'public' | 'private' }>;\n\t};\n\ttags?: string[];\n};\n\nexport type DigitalOceanTargetOptions = {\n\t/** API token (https://cloud.digitalocean.com/account/api/tokens). Required unless `client` is set. */\n\ttoken?: string;\n\t/** Custom client. Overrides token-built default. */\n\tclient?: DigitalOceanClientLike;\n\n\t// ── Droplet shape ────────────────────────────────────────────────\n\t/** Droplet name. Also the idempotency key. */\n\tname: string;\n\t/** Region slug — `'nyc3'`, `'sfo3'`, `'ams3'`, etc. */\n\tregion: string;\n\t/** Size slug — `'s-1vcpu-1gb'`, `'s-2vcpu-4gb'`, etc. */\n\tsize: string;\n\t/** Image slug, snapshot id, or backup id. e.g. `'ubuntu-22-04-x64'`. */\n\timage: string | number;\n\t/** SSH key fingerprints OR numeric ids. At least one required to ssh in. */\n\tsshKeys: ReadonlyArray<string | number>;\n\t/** Tags applied at creation. Useful for `listDroplets({ tag })`. */\n\ttags?: ReadonlyArray<string>;\n\t/** cloud-init user data — a shell script or YAML config. */\n\tuserData?: string;\n\t/** VPC UUID. Defaults to the account's default VPC for the region. */\n\tvpcUuid?: string;\n\t/** Enable IPv6. Default false. */\n\tipv6?: boolean;\n\t/** Enable monitoring agent. Default false. */\n\tmonitoring?: boolean;\n\n\t// ── SSH wrap ────────────────────────────────────────────────────\n\t/** SSH login user. Default `'root'`. */\n\tuser?: string;\n\t/** Path to SSH identity file forwarded to sshTarget. */\n\tidentity?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\n\t// ── Timing ──────────────────────────────────────────────────────\n\t/** Max time to wait for droplet `active` + IPv4. Default 5 min. */\n\tprovisionTimeoutMs?: number;\n\t/** Max time to wait for SSH probe to succeed. Default 2 min. */\n\tsshReadinessTimeoutMs?: number;\n\t/** Poll interval for provision + ssh probe. Default 5 s. */\n\tpollIntervalMs?: number;\n\n\t// ── Observability + injection points ───────────────────────────\n\t/** Called with status updates (one line each). Default: noop. */\n\tonLog?: (line: string) => void;\n\t/**\n\t * Override the SSH readiness probe. Default opens a TCP socket to\n\t * `host:port`. Tests pass a fake probe to skip real network IO.\n\t */\n\tprobeSsh?: (host: string, port: number) => Promise<boolean>;\n\t/**\n\t * Sleep used between polls. Default `setTimeout`-based. Tests can\n\t * pass a synchronous resolver to skip real waits.\n\t */\n\tsleep?: (ms: number) => Promise<void>;\n\t/** Wall clock. Defaults to `Date.now`. Tests can swap. */\n\tnow?: () => number;\n};\n\nexport type DigitalOceanTarget = Target & {\n\treadonly dropletId: number;\n\treadonly ipv4: string;\n\t/** Destroy the droplet via the DO API. */\n\tdestroy: () => Promise<void>;\n};\n\nexport class DigitalOceanError extends Error {\n\treadonly status: number;\n\treadonly body: unknown;\n\tconstructor(message: string, status: number, body: unknown) {\n\t\tsuper(message);\n\t\tthis.name = 'DigitalOceanError';\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t}\n}\n\n/**\n * fetch-backed default client. Talks JSON to `api.digitalocean.com/v2`.\n * Throws DigitalOceanError on non-2xx with the response body attached\n * so the caller can switch on `err.status`.\n */\nexport const createDigitalOceanClient = (\n\ttoken: string,\n\toptions: { baseUrl?: string; fetch?: typeof fetch } = {}\n): DigitalOceanClientLike => {\n\tconst base = options.baseUrl ?? DO_API_BASE;\n\tconst f = options.fetch ?? fetch;\n\treturn {\n\t\trequest: async <T>(\n\t\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\t\tpath: string,\n\t\t\tbody?: unknown\n\t\t): Promise<T> => {\n\t\t\tconst init: RequestInit = {\n\t\t\t\theaders: {\n\t\t\t\t\tauthorization: `Bearer ${token}`,\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t},\n\t\t\t\tmethod\n\t\t\t};\n\t\t\tif (body !== undefined) init.body = JSON.stringify(body);\n\t\t\tconst response = await f(`${base}${path}`, init);\n\t\t\tif (response.status === 204) return undefined as T;\n\t\t\tconst text = await response.text();\n\t\t\tconst parsed = text.length > 0 ? JSON.parse(text) : undefined;\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new DigitalOceanError(\n\t\t\t\t\t`DigitalOcean API ${method} ${path} failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tparsed\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn parsed as T;\n\t\t}\n\t};\n};\n\nconst resolveClient = (\n\toptions: Pick<DigitalOceanTargetOptions, 'client' | 'token'>\n): DigitalOceanClientLike => {\n\tif (options.client !== undefined) return options.client;\n\tif (options.token !== undefined && options.token.length > 0) {\n\t\treturn createDigitalOceanClient(options.token);\n\t}\n\tthrow new Error(\n\t\t'[deploy/digitalocean] either `token` or `client` must be provided'\n\t);\n};\n\nconst publicIpv4 = (droplet: DigitalOceanDroplet): string | undefined =>\n\tdroplet.networks.v4.find((net) => net.type === 'public')?.ip_address;\n\n/**\n * Find a droplet by name. Returns undefined if absent.\n * Throws if more than one droplet shares the name (drifted state).\n */\nexport const findDigitalOceanDroplet = async (\n\tclient: DigitalOceanClientLike,\n\tname: string\n): Promise<DigitalOceanDroplet | undefined> => {\n\t// DO's list endpoint supports `name=` exact-match filtering.\n\tconst body = await client.request<{ droplets: DigitalOceanDroplet[] }>(\n\t\t'GET',\n\t\t`/droplets?name=${encodeURIComponent(name)}`\n\t);\n\tconst matches = body.droplets.filter((droplet) => droplet.name === name);\n\tif (matches.length === 0) return undefined;\n\tif (matches.length > 1) {\n\t\tthrow new Error(\n\t\t\t`[deploy/digitalocean] multiple droplets named \"${name}\" (${matches\n\t\t\t\t.map((droplet) => droplet.id)\n\t\t\t\t.join(', ')}). Resolve manually before adopting.`\n\t\t);\n\t}\n\treturn matches[0];\n};\n\n/** List droplets, optionally filtered by tag. Useful for cleanup tasks. */\nexport const listDigitalOceanDroplets = async (options: {\n\ttoken?: string;\n\tclient?: DigitalOceanClientLike;\n\ttag?: string;\n}): Promise<DigitalOceanDroplet[]> => {\n\tconst client = resolveClient(options);\n\tconst path =\n\t\toptions.tag !== undefined\n\t\t\t? `/droplets?tag_name=${encodeURIComponent(options.tag)}`\n\t\t\t: '/droplets';\n\tconst body = await client.request<{ droplets: DigitalOceanDroplet[] }>(\n\t\t'GET',\n\t\tpath\n\t);\n\treturn body.droplets;\n};\n\n/** Destroy a droplet by id. No-op if already gone. */\nexport const destroyDigitalOceanDroplet = async (options: {\n\ttoken?: string;\n\tclient?: DigitalOceanClientLike;\n\tid: number;\n}): Promise<void> => {\n\tconst client = resolveClient(options);\n\ttry {\n\t\tawait client.request('DELETE', `/droplets/${options.id}`);\n\t} catch (error) {\n\t\tif (error instanceof DigitalOceanError && error.status === 404) {\n\t\t\treturn; // already destroyed — idempotent\n\t\t}\n\t\tthrow error;\n\t}\n};\n\n/**\n * Provision-or-reuse a DO droplet by name, wait for SSH, return a\n * Target. Idempotent: same name → same droplet.\n */\nexport const digitalOceanTarget = async (\n\toptions: DigitalOceanTargetOptions\n): Promise<DigitalOceanTarget> => {\n\tconst client = resolveClient(options);\n\n\tconst hooks: CloudTargetHooks<DigitalOceanDroplet> = {\n\t\tcreate: async () => {\n\t\t\tconst created = await client.request<{ droplet: DigitalOceanDroplet }>(\n\t\t\t\t'POST',\n\t\t\t\t'/droplets',\n\t\t\t\t{\n\t\t\t\t\tname: options.name,\n\t\t\t\t\tregion: options.region,\n\t\t\t\t\tsize: options.size,\n\t\t\t\t\timage: options.image,\n\t\t\t\t\tssh_keys: [...options.sshKeys],\n\t\t\t\t\t...(options.tags !== undefined\n\t\t\t\t\t\t? { tags: [...options.tags] }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(options.userData !== undefined\n\t\t\t\t\t\t? { user_data: options.userData }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(options.vpcUuid !== undefined\n\t\t\t\t\t\t? { vpc_uuid: options.vpcUuid }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(options.ipv6 === true ? { ipv6: true } : {}),\n\t\t\t\t\t...(options.monitoring === true ? { monitoring: true } : {})\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn created.droplet;\n\t\t},\n\t\tdestroy: (id) => destroyDigitalOceanDroplet({ client, id }),\n\t\tfetch: async (id) => {\n\t\t\tconst refreshed: { droplet: DigitalOceanDroplet } = await client.request(\n\t\t\t\t'GET',\n\t\t\t\t`/droplets/${id}`\n\t\t\t);\n\t\t\treturn refreshed.droplet;\n\t\t},\n\t\tfindByName: (name) => findDigitalOceanDroplet(client, name),\n\t\tgetId: (droplet) => droplet.id,\n\t\tgetIpv4: publicIpv4,\n\t\tgetStatus: (droplet) => droplet.status,\n\t\tisReady: (droplet) => droplet.status === 'active'\n\t};\n\n\tconst result = await createCloudTarget(hooks, {\n\t\tdescribeTarget: (sshDescription) =>\n\t\t\t`digitalocean droplet \"${options.name}\" (${sshDescription})`,\n\t\tentityWord: 'droplet',\n\t\tlogPrefix: '[do]',\n\t\tname: options.name,\n\t\tregion: options.region,\n\t\t...(options.user !== undefined ? { user: options.user } : {}),\n\t\t...(options.identity !== undefined ? { identity: options.identity } : {}),\n\t\t...(options.port !== undefined ? { port: options.port } : {}),\n\t\t...(options.provisionTimeoutMs !== undefined\n\t\t\t? { provisionTimeoutMs: options.provisionTimeoutMs }\n\t\t\t: {}),\n\t\t...(options.sshReadinessTimeoutMs !== undefined\n\t\t\t? { sshReadinessTimeoutMs: options.sshReadinessTimeoutMs }\n\t\t\t: {}),\n\t\t...(options.pollIntervalMs !== undefined\n\t\t\t? { pollIntervalMs: options.pollIntervalMs }\n\t\t\t: {}),\n\t\t...(options.onLog !== undefined ? { onLog: options.onLog } : {}),\n\t\t...(options.probeSsh !== undefined ? { probeSsh: options.probeSsh } : {}),\n\t\t...(options.sleep !== undefined ? { sleep: options.sleep } : {}),\n\t\t...(options.now !== undefined ? { now: options.now } : {})\n\t});\n\n\treturn {\n\t\tdescription: result.description,\n\t\tdestroy: result.destroy,\n\t\tdropletId: result.id,\n\t\texec: result.exec,\n\t\tipv4: result.ipv4,\n\t\tupload: result.upload,\n\t\t...(result.close !== undefined ? { close: result.close } : {})\n\t};\n};\n"
7
8
  ],
8
- "mappings": ";;AAuBA;AACA;AA+CA,IAAM,eAAe,OACpB,QACA,WACqB;AAAA,EACrB,IAAI,CAAC;AAAA,IAAQ,OAAO;AAAA,EACpB,MAAM,UAAU,IAAI;AAAA,EACpB,IAAI,SAAS;AAAA,EACb,IAAI,YAAY;AAAA,EAChB,MAAM,SAAS,OAAO,UAAU;AAAA,EAChC,IAAI;AAAA,IACH,OAAO,MAAM;AAAA,MACZ,QAAQ,MAAM,UAAU,MAAM,OAAO,KAAK;AAAA,MAC1C,IAAI;AAAA,QAAM;AAAA,MACV,MAAM,QAAQ,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAAA,MACpD,aAAa;AAAA,MACb,IAAI,CAAC;AAAA,QAAQ;AAAA,MACb,UAAU;AAAA,MACV,IAAI,UAAU,OAAO,QAAQ;AAAA,CAAI;AAAA,MACjC,OAAO,YAAY,IAAI;AAAA,QACtB,MAAM,OAAO,OAAO,MAAM,GAAG,OAAO,EAAE,QAAQ,OAAO,EAAE;AAAA,QACvD,IAAI,KAAK,SAAS;AA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cloud servers. Sibling to {@link digitalOceanTarget}; same
4
+ * shape, different API.
5
+ *
6
+ * What it does:
7
+ *
8
+ * 1. Looks up a server by `name`. If present and running, reuses it.
9
+ * 2. If not present, creates it via the Hetzner Cloud v1 API and
10
+ * waits for `status === 'running'` with a public IPv4 assigned.
11
+ * 3. Waits for SSH readiness (TCP connect on port 22 with backoff,
12
+ * or a caller-supplied probe).
13
+ * 4. Returns a Target that wraps sshTarget against the server's
14
+ * public IPv4, plus `serverId`, `ipv4`, and a `destroy()` helper.
15
+ *
16
+ * Idempotent by name — Hetzner enforces unique server names per
17
+ * project, so calling twice with the same name returns the same
18
+ * server.
19
+ *
20
+ * Narrow HetznerClientLike interface keeps the official `hcloud-js`
21
+ * SDK out as a hard dep. Default client uses `fetch` against
22
+ * `api.hetzner.cloud/v1`; pass your own for retry / observability.
23
+ */
24
+ import type { Target } from './targets';
25
+ /**
26
+ * Minimal subset of Hetzner Cloud API calls we make. Lets callers
27
+ * BYO a client with retry / observability / etc.
28
+ */
29
+ export type HetznerClientLike = {
30
+ request: <T = unknown>(method: 'GET' | 'POST' | 'DELETE', path: string, body?: unknown) => Promise<T>;
31
+ };
32
+ /** A Hetzner Cloud server, narrowed to what we inspect. */
33
+ export type HetznerServer = {
34
+ id: number;
35
+ name: string;
36
+ status: 'initializing' | 'starting' | 'running' | 'stopping' | 'off' | 'deleting' | 'migrating' | 'rebuilding' | 'unknown';
37
+ public_net: {
38
+ ipv4: {
39
+ id: number;
40
+ ip: string;
41
+ blocked: boolean;
42
+ dns_ptr?: string;
43
+ } | null;
44
+ ipv6: {
45
+ id: number;
46
+ ip: string;
47
+ blocked: boolean;
48
+ } | null;
49
+ };
50
+ server_type?: {
51
+ name: string;
52
+ };
53
+ datacenter?: {
54
+ location: {
55
+ name: string;
56
+ };
57
+ };
58
+ labels?: Record<string, string>;
59
+ };
60
+ export type HetznerTargetOptions = {
61
+ /** API token (https://docs.hetzner.cloud/#authentication). Required unless `client` is set. */
62
+ token?: string;
63
+ /** Custom client. Overrides token-built default. */
64
+ client?: HetznerClientLike;
65
+ /** Server name. Hetzner-unique per project; also our idempotency key. */
66
+ name: string;
67
+ /** Location slug — `'nbg1'`, `'fsn1'`, `'hel1'`, `'ash'`, `'hil'`. */
68
+ location: string;
69
+ /** Server type slug — `'cx22'`, `'cpx11'`, `'ccx13'`, etc. */
70
+ serverType: string;
71
+ /** Image slug or numeric id, e.g. `'ubuntu-22.04'`. */
72
+ image: string | number;
73
+ /** SSH key fingerprints, numeric ids, or names. At least one required. */
74
+ sshKeys: ReadonlyArray<string | number>;
75
+ /** Labels (Hetzner's key-value tags). */
76
+ labels?: Record<string, string>;
77
+ /** cloud-init user data — a shell script or YAML config. */
78
+ userData?: string;
79
+ /** Attach to a Cloud Network (by id). */
80
+ networkId?: number;
81
+ /** Disable IPv4 public addressing. Default: enabled. */
82
+ disablePublicIpv4?: boolean;
83
+ /** Disable IPv6 public addressing. Default: enabled. */
84
+ disablePublicIpv6?: boolean;
85
+ /** SSH login user. Default `'root'`. */
86
+ user?: string;
87
+ /** Path to SSH identity file forwarded to sshTarget. */
88
+ identity?: string;
89
+ /** SSH port. Default 22. */
90
+ port?: number;
91
+ /** Max time to wait for server `running` + IPv4. Default 5 min. */
92
+ provisionTimeoutMs?: number;
93
+ /** Max time to wait for SSH probe to succeed. Default 2 min. */
94
+ sshReadinessTimeoutMs?: number;
95
+ /** Poll interval for provision + ssh probe. Default 5 s. */
96
+ pollIntervalMs?: number;
97
+ /** Called with status updates (one line each). Default: noop. */
98
+ onLog?: (line: string) => void;
99
+ /**
100
+ * Override the SSH readiness probe. Default opens a TCP socket to
101
+ * `host:port`. Tests pass a fake probe to skip real network IO.
102
+ */
103
+ probeSsh?: (host: string, port: number) => Promise<boolean>;
104
+ /** Sleep used between polls. Tests can pass a synchronous resolver. */
105
+ sleep?: (ms: number) => Promise<void>;
106
+ /** Wall clock. Defaults to `Date.now`. Tests can swap. */
107
+ now?: () => number;
108
+ };
109
+ export type HetznerTarget = Target & {
110
+ readonly serverId: number;
111
+ readonly ipv4: string;
112
+ /** Destroy the server via the Hetzner API. */
113
+ destroy: () => Promise<void>;
114
+ };
115
+ export declare class HetznerError extends Error {
116
+ readonly status: number;
117
+ readonly body: unknown;
118
+ constructor(message: string, status: number, body: unknown);
119
+ }
120
+ /**
121
+ * fetch-backed default client. Talks JSON to `api.hetzner.cloud/v1`.
122
+ * Throws HetznerError on non-2xx with the response body attached so
123
+ * the caller can switch on `err.status`.
124
+ */
125
+ export declare const createHetznerClient: (token: string, options?: {
126
+ baseUrl?: string;
127
+ fetch?: typeof fetch;
128
+ }) => HetznerClientLike;
129
+ /**
130
+ * Find a server by name. Returns undefined if absent. Hetzner
131
+ * enforces unique server names per project, so duplicates aren't
132
+ * possible — but if the API ever returns >1 we still surface that
133
+ * loudly.
134
+ */
135
+ export declare const findHetznerServer: (client: HetznerClientLike, name: string) => Promise<HetznerServer | undefined>;
136
+ /** List servers, optionally filtered by label selector. */
137
+ export declare const listHetznerServers: (options: {
138
+ token?: string;
139
+ client?: HetznerClientLike;
140
+ /** Label selector, e.g. `'env=prod'` or `'env in (prod,staging)'`. */
141
+ labelSelector?: string;
142
+ }) => Promise<HetznerServer[]>;
143
+ /** Destroy a server by id. 404 treated as idempotent success. */
144
+ export declare const destroyHetznerServer: (options: {
145
+ token?: string;
146
+ client?: HetznerClientLike;
147
+ id: number;
148
+ }) => Promise<void>;
149
+ /**
150
+ * Provision-or-reuse a Hetzner Cloud server by name, wait for SSH,
151
+ * return a Target. Idempotent: same name → same server.
152
+ */
153
+ export declare const hetznerTarget: (options: HetznerTargetOptions) => Promise<HetznerTarget>;
@@ -0,0 +1,420 @@
1
+ // @bun
2
+ // src/targets.ts
3
+ import { mkdir } from "fs/promises";
4
+ import { join } from "path";
5
+ var decodeChunks = async (reader, onLine) => {
6
+ if (!reader)
7
+ return "";
8
+ const decoder = new TextDecoder;
9
+ let buffer = "";
10
+ let collected = "";
11
+ const stream = reader.getReader();
12
+ try {
13
+ while (true) {
14
+ const { done, value } = await stream.read();
15
+ if (done)
16
+ break;
17
+ const chunk = decoder.decode(value, { stream: true });
18
+ collected += chunk;
19
+ if (!onLine)
20
+ continue;
21
+ buffer += chunk;
22
+ let newline = buffer.indexOf(`
23
+ `);
24
+ while (newline !== -1) {
25
+ const line = buffer.slice(0, newline).replace(/\r$/, "");
26
+ if (line.length > 0)
27
+ onLine(line);
28
+ buffer = buffer.slice(newline + 1);
29
+ newline = buffer.indexOf(`
30
+ `);
31
+ }
32
+ }
33
+ const tail = decoder.decode();
34
+ collected += tail;
35
+ if (onLine && (buffer + tail).length > 0)
36
+ onLine((buffer + tail).replace(/\r$/, ""));
37
+ } finally {
38
+ stream.releaseLock();
39
+ }
40
+ return collected;
41
+ };
42
+ var runSpawn = async (argv, options) => {
43
+ const proc = Bun.spawn(argv, {
44
+ cwd: options.cwd,
45
+ env: options.env,
46
+ stderr: "pipe",
47
+ stdin: options.stdin === undefined ? "ignore" : "pipe",
48
+ stdout: "pipe"
49
+ });
50
+ if (options.stdin !== undefined && proc.stdin) {
51
+ const sink = proc.stdin;
52
+ const wrote = sink.write(options.stdin);
53
+ if (wrote && typeof wrote.then === "function") {
54
+ await wrote;
55
+ }
56
+ const ended = sink.end();
57
+ if (ended && typeof ended.then === "function") {
58
+ await ended;
59
+ }
60
+ }
61
+ const timeout = options.timeoutMs ?? 600000;
62
+ let timer;
63
+ if (timeout > 0) {
64
+ timer = setTimeout(() => {
65
+ try {
66
+ proc.kill();
67
+ } catch {}
68
+ }, timeout);
69
+ }
70
+ const stdoutPromise = decodeChunks(proc.stdout, options.onLog ? (line) => options.onLog(line, "stdout") : undefined);
71
+ const stderrPromise = decodeChunks(proc.stderr, options.onLog ? (line) => options.onLog(line, "stderr") : undefined);
72
+ const [stdout, stderr, exitCode] = await Promise.all([
73
+ stdoutPromise,
74
+ stderrPromise,
75
+ proc.exited
76
+ ]);
77
+ if (timer)
78
+ clearTimeout(timer);
79
+ return { exitCode: exitCode ?? -1, stderr, stdout };
80
+ };
81
+ var localTarget = (options) => {
82
+ const baseEnv = { ...options.env };
83
+ const ensureRoot = async () => {
84
+ await mkdir(options.root, { recursive: true });
85
+ };
86
+ return {
87
+ description: `local ${options.root}`,
88
+ exec: async (cmd, opts) => {
89
+ await ensureRoot();
90
+ return runSpawn(["sh", "-c", cmd], {
91
+ cwd: opts?.cwd ?? options.root,
92
+ env: { ...process.env, ...baseEnv, ...opts?.env ?? {} },
93
+ onLog: opts?.onLog,
94
+ stdin: opts?.stdin,
95
+ timeoutMs: opts?.timeoutMs
96
+ });
97
+ },
98
+ upload: async (localPath, remotePath, opts) => {
99
+ await ensureRoot();
100
+ const dest = remotePath.startsWith("/") ? remotePath : join(options.root, remotePath);
101
+ const argv = ["rsync", "-a"];
102
+ if (opts?.deleteOrphans)
103
+ argv.push("--delete");
104
+ for (const pattern of opts?.exclude ?? [])
105
+ argv.push("--exclude", pattern);
106
+ argv.push(localPath, dest);
107
+ const result = await runSpawn(argv, { timeoutMs: 600000 });
108
+ if (result.exitCode !== 0) {
109
+ throw new Error(`local upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);
110
+ }
111
+ }
112
+ };
113
+ };
114
+ var sshTargetString = (options) => {
115
+ const user = options.user ?? "root";
116
+ return `${user}@${options.host}`;
117
+ };
118
+ var sshBaseFlags = (options) => {
119
+ const flags = [];
120
+ if (options.port !== undefined && options.port !== 22)
121
+ flags.push("-p", String(options.port));
122
+ if (options.identity !== undefined)
123
+ flags.push("-i", options.identity);
124
+ flags.push("-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=accept-new");
125
+ for (const flag of options.sshFlags ?? [])
126
+ flags.push(flag);
127
+ return flags;
128
+ };
129
+ var shellQuote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
130
+ var buildRemoteCmd = (cmd, opts) => {
131
+ const env = opts?.env;
132
+ const envPrefix = env ? Object.entries(env).map(([k, v]) => `${k}=${shellQuote(v)}`).join(" ") + " " : "";
133
+ if (opts?.cwd) {
134
+ return `cd ${shellQuote(opts.cwd)} && ${envPrefix}${cmd}`;
135
+ }
136
+ return `${envPrefix}${cmd}`;
137
+ };
138
+ var sshTarget = (options) => {
139
+ const remote = sshTargetString(options);
140
+ const useRsync = options.rsync ?? true;
141
+ return {
142
+ description: `ssh ${remote}${options.port && options.port !== 22 ? `:${options.port}` : ""}`,
143
+ exec: async (cmd, opts) => {
144
+ const argv = ["ssh", ...sshBaseFlags(options)];
145
+ for (const name of options.forwardEnv ?? [])
146
+ argv.push("-o", `SendEnv=${name}`);
147
+ argv.push(remote, buildRemoteCmd(cmd, opts));
148
+ return runSpawn(argv, {
149
+ onLog: opts?.onLog,
150
+ stdin: opts?.stdin,
151
+ timeoutMs: opts?.timeoutMs
152
+ });
153
+ },
154
+ upload: async (localPath, remotePath, opts) => {
155
+ if (useRsync) {
156
+ const sshCmd = ["ssh", ...sshBaseFlags(options)].map((part) => part.includes(" ") ? `'${part}'` : part).join(" ");
157
+ const argv2 = ["rsync", "-az", "-e", sshCmd];
158
+ if (opts?.deleteOrphans)
159
+ argv2.push("--delete");
160
+ for (const pattern of opts?.exclude ?? [])
161
+ argv2.push("--exclude", pattern);
162
+ argv2.push(localPath, `${remote}:${remotePath}`);
163
+ const result2 = await runSpawn(argv2, { timeoutMs: 600000 });
164
+ if (result2.exitCode !== 0) {
165
+ throw new Error(`rsync upload failed (exit ${result2.exitCode}): ${result2.stderr || result2.stdout}`);
166
+ }
167
+ return;
168
+ }
169
+ const argv = ["scp", "-r", ...sshBaseFlags(options), localPath, `${remote}:${remotePath}`];
170
+ const result = await runSpawn(argv, { timeoutMs: 600000 });
171
+ if (result.exitCode !== 0) {
172
+ throw new Error(`scp upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);
173
+ }
174
+ }
175
+ };
176
+ };
177
+
178
+ // src/cloudTarget.ts
179
+ var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
180
+ var defaultProbeSsh = async (host, port) => {
181
+ const PROBE_TIMEOUT_MS = 2000;
182
+ return new Promise((resolve) => {
183
+ let settled = false;
184
+ const settle = (value) => {
185
+ if (settled)
186
+ return;
187
+ settled = true;
188
+ resolve(value);
189
+ };
190
+ const timer = setTimeout(() => settle(false), PROBE_TIMEOUT_MS);
191
+ Bun.connect({
192
+ hostname: host,
193
+ port,
194
+ socket: {
195
+ data: () => {},
196
+ error: () => {
197
+ clearTimeout(timer);
198
+ settle(false);
199
+ },
200
+ open: (socket) => {
201
+ clearTimeout(timer);
202
+ socket.end();
203
+ settle(true);
204
+ }
205
+ }
206
+ }).catch(() => {
207
+ clearTimeout(timer);
208
+ settle(false);
209
+ });
210
+ });
211
+ };
212
+ var createCloudTarget = async (hooks, options) => {
213
+ const log = options.onLog ?? (() => {});
214
+ const probeSsh = options.probeSsh ?? defaultProbeSsh;
215
+ const sleep = options.sleep ?? defaultSleep;
216
+ const now = options.now ?? Date.now;
217
+ const pollMs = options.pollIntervalMs ?? 5000;
218
+ const provisionTimeout = options.provisionTimeoutMs ?? 5 * 60000;
219
+ const sshTimeout = options.sshReadinessTimeoutMs ?? 2 * 60000;
220
+ const port = options.port ?? 22;
221
+ const prefix = options.logPrefix;
222
+ const noun = options.entityWord;
223
+ const existing = await hooks.findByName(options.name);
224
+ let current;
225
+ if (existing === undefined) {
226
+ log(`${prefix} creating ${noun} "${options.name}" in ${options.region}`);
227
+ current = await hooks.create();
228
+ } else {
229
+ log(`${prefix} reusing ${noun} "${options.name}" (id ${hooks.getId(existing)}, status ${hooks.getStatus(existing)})`);
230
+ current = existing;
231
+ }
232
+ const provisionStart = now();
233
+ let ipv4 = hooks.getIpv4(current);
234
+ while (!hooks.isReady(current) || ipv4 === undefined) {
235
+ if (now() - provisionStart > provisionTimeout) {
236
+ throw new Error(`${prefix} provision timeout after ${provisionTimeout}ms \u2014 ${noun} ${hooks.getId(current)} status "${hooks.getStatus(current)}", ipv4 ${ipv4 ?? "(unassigned)"}`);
237
+ }
238
+ await sleep(pollMs);
239
+ current = await hooks.fetch(hooks.getId(current));
240
+ ipv4 = hooks.getIpv4(current);
241
+ log(`${prefix} poll: status=${hooks.getStatus(current)} ipv4=${ipv4 ?? "(none yet)"}`);
242
+ }
243
+ log(`${prefix} ${noun} ready at ${ipv4}`);
244
+ const sshStart = now();
245
+ while (!await probeSsh(ipv4, port)) {
246
+ if (now() - sshStart > sshTimeout) {
247
+ throw new Error(`${prefix} SSH readiness timeout after ${sshTimeout}ms \u2014 ${ipv4}:${port} did not accept connections`);
248
+ }
249
+ await sleep(pollMs);
250
+ log(`${prefix} waiting on ssh ${ipv4}:${port}`);
251
+ }
252
+ log(`${prefix} ssh ready at ${ipv4}:${port}`);
253
+ const ssh = sshTarget({
254
+ host: ipv4,
255
+ ...options.user !== undefined ? { user: options.user } : {},
256
+ ...options.identity !== undefined ? { identity: options.identity } : {},
257
+ ...options.port !== undefined ? { port: options.port } : {}
258
+ });
259
+ const id = hooks.getId(current);
260
+ const resolvedIpv4 = ipv4;
261
+ return {
262
+ description: options.describeTarget(ssh.description),
263
+ destroy: () => hooks.destroy(id).then(() => {
264
+ log(`${prefix} destroyed ${noun} ${id}`);
265
+ }),
266
+ exec: ssh.exec,
267
+ id,
268
+ ipv4: resolvedIpv4,
269
+ upload: ssh.upload,
270
+ ...ssh.close !== undefined ? { close: ssh.close } : {}
271
+ };
272
+ };
273
+
274
+ // src/hetzner.ts
275
+ var HETZNER_API_BASE = "https://api.hetzner.cloud/v1";
276
+
277
+ class HetznerError extends Error {
278
+ status;
279
+ body;
280
+ constructor(message, status, body) {
281
+ super(message);
282
+ this.name = "HetznerError";
283
+ this.status = status;
284
+ this.body = body;
285
+ }
286
+ }
287
+ var createHetznerClient = (token, options = {}) => {
288
+ const base = options.baseUrl ?? HETZNER_API_BASE;
289
+ const f = options.fetch ?? fetch;
290
+ return {
291
+ request: async (method, path, body) => {
292
+ const init = {
293
+ headers: {
294
+ authorization: `Bearer ${token}`,
295
+ "content-type": "application/json"
296
+ },
297
+ method
298
+ };
299
+ if (body !== undefined)
300
+ init.body = JSON.stringify(body);
301
+ const response = await f(`${base}${path}`, init);
302
+ if (response.status === 204)
303
+ return;
304
+ const text = await response.text();
305
+ const parsed = text.length > 0 ? JSON.parse(text) : undefined;
306
+ if (!response.ok) {
307
+ throw new HetznerError(`Hetzner Cloud API ${method} ${path} failed: ${response.status} ${response.statusText}`, response.status, parsed);
308
+ }
309
+ return parsed;
310
+ }
311
+ };
312
+ };
313
+ var resolveClient = (options) => {
314
+ if (options.client !== undefined)
315
+ return options.client;
316
+ if (options.token !== undefined && options.token.length > 0) {
317
+ return createHetznerClient(options.token);
318
+ }
319
+ throw new Error("[deploy/hetzner] either `token` or `client` must be provided");
320
+ };
321
+ var publicIpv4 = (server) => server.public_net.ipv4?.ip;
322
+ var findHetznerServer = async (client, name) => {
323
+ const body = await client.request("GET", `/servers?name=${encodeURIComponent(name)}`);
324
+ const matches = body.servers.filter((server) => server.name === name);
325
+ if (matches.length === 0)
326
+ return;
327
+ if (matches.length > 1) {
328
+ throw new Error(`[deploy/hetzner] multiple servers named "${name}" (${matches.map((server) => server.id).join(", ")}). Hetzner shouldn't allow this \u2014 resolve manually.`);
329
+ }
330
+ return matches[0];
331
+ };
332
+ var listHetznerServers = async (options) => {
333
+ const client = resolveClient(options);
334
+ const path = options.labelSelector !== undefined ? `/servers?label_selector=${encodeURIComponent(options.labelSelector)}` : "/servers";
335
+ const body = await client.request("GET", path);
336
+ return body.servers;
337
+ };
338
+ var destroyHetznerServer = async (options) => {
339
+ const client = resolveClient(options);
340
+ try {
341
+ await client.request("DELETE", `/servers/${options.id}`);
342
+ } catch (error) {
343
+ if (error instanceof HetznerError && error.status === 404) {
344
+ return;
345
+ }
346
+ throw error;
347
+ }
348
+ };
349
+ var hetznerTarget = async (options) => {
350
+ const client = resolveClient(options);
351
+ const publicIpv4Enabled = options.disablePublicIpv4 !== true;
352
+ const publicIpv6Enabled = options.disablePublicIpv6 !== true;
353
+ const hooks = {
354
+ create: async () => {
355
+ const created = await client.request("POST", "/servers", {
356
+ name: options.name,
357
+ location: options.location,
358
+ server_type: options.serverType,
359
+ image: options.image,
360
+ ssh_keys: [...options.sshKeys],
361
+ start_after_create: true,
362
+ public_net: {
363
+ enable_ipv4: publicIpv4Enabled,
364
+ enable_ipv6: publicIpv6Enabled
365
+ },
366
+ ...options.labels !== undefined ? { labels: options.labels } : {},
367
+ ...options.userData !== undefined ? { user_data: options.userData } : {},
368
+ ...options.networkId !== undefined ? { networks: [options.networkId] } : {}
369
+ });
370
+ return created.server;
371
+ },
372
+ destroy: (id) => destroyHetznerServer({ client, id }),
373
+ fetch: async (id) => {
374
+ const refreshed = await client.request("GET", `/servers/${id}`);
375
+ return refreshed.server;
376
+ },
377
+ findByName: (name) => findHetznerServer(client, name),
378
+ getId: (server) => server.id,
379
+ getIpv4: publicIpv4,
380
+ getStatus: (server) => server.status,
381
+ isReady: (server) => server.status === "running"
382
+ };
383
+ const result = await createCloudTarget(hooks, {
384
+ describeTarget: (sshDescription) => `hetzner server "${options.name}" (${sshDescription})`,
385
+ entityWord: "server",
386
+ logPrefix: "[hetzner]",
387
+ name: options.name,
388
+ region: options.location,
389
+ ...options.user !== undefined ? { user: options.user } : {},
390
+ ...options.identity !== undefined ? { identity: options.identity } : {},
391
+ ...options.port !== undefined ? { port: options.port } : {},
392
+ ...options.provisionTimeoutMs !== undefined ? { provisionTimeoutMs: options.provisionTimeoutMs } : {},
393
+ ...options.sshReadinessTimeoutMs !== undefined ? { sshReadinessTimeoutMs: options.sshReadinessTimeoutMs } : {},
394
+ ...options.pollIntervalMs !== undefined ? { pollIntervalMs: options.pollIntervalMs } : {},
395
+ ...options.onLog !== undefined ? { onLog: options.onLog } : {},
396
+ ...options.probeSsh !== undefined ? { probeSsh: options.probeSsh } : {},
397
+ ...options.sleep !== undefined ? { sleep: options.sleep } : {},
398
+ ...options.now !== undefined ? { now: options.now } : {}
399
+ });
400
+ return {
401
+ description: result.description,
402
+ destroy: result.destroy,
403
+ exec: result.exec,
404
+ ipv4: result.ipv4,
405
+ serverId: result.id,
406
+ upload: result.upload,
407
+ ...result.close !== undefined ? { close: result.close } : {}
408
+ };
409
+ };
410
+ export {
411
+ listHetznerServers,
412
+ hetznerTarget,
413
+ findHetznerServer,
414
+ destroyHetznerServer,
415
+ createHetznerClient,
416
+ HetznerError
417
+ };
418
+
419
+ //# debugId=1016401F0A6B67CD64756E2164756E21
420
+ //# sourceMappingURL=hetzner.js.map
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/targets.ts", "../src/cloudTarget.ts", "../src/hetzner.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Target interface + bundled adapters (localTarget, sshTarget).\n *\n * A Target is the narrowest abstraction over \"a place I can deploy to\":\n *\n * - `exec(cmd, opts?)` — run a shell command, capture stdout/stderr/exitCode.\n * - `upload(localPath, remotePath, opts?)` — copy a local file or directory\n * to the target. Implementation is free to use whatever is fast (rsync,\n * scp, mv).\n * - `close?()` — optional teardown.\n *\n * Two adapters are bundled:\n *\n * - `localTarget` runs in a temp directory on the local filesystem. Useful\n * for tests and for \"deploy\" workflows that happen on the same host.\n * - `sshTarget` shells out to the system `ssh` and `rsync` binaries. No\n * `ssh2` npm dependency — the controller machine just needs `ssh` and\n * (optionally) `rsync` in PATH, which is universal on Mac/Linux/WSL.\n *\n * Provider-specific targets (Cloudflare Workers HTTP API, Fly Machines API,\n * AWS Fargate) don't fit \"exec + upload\" and ship as siblings later.\n */\n\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport type ExecOptions = {\n\t/** Working directory on the target. Default: target's root. */\n\tcwd?: string;\n\t/** Env vars to set for this command (merged onto target.env). */\n\tenv?: Record<string, string>;\n\t/** Hard kill after this many ms. Default 600_000 (10 min). 0 disables. */\n\ttimeoutMs?: number;\n\t/** Pipe stdout/stderr through here as it streams (lines, newline-stripped). */\n\tonLog?: (line: string, stream: 'stdout' | 'stderr') => void;\n\t/** Stdin payload — a string is written verbatim. */\n\tstdin?: string;\n};\n\nexport type ExecResult = {\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n};\n\nexport type UploadOptions = {\n\t/** Exclude paths matching these globs from a directory upload. */\n\texclude?: string[];\n\t/** When uploading a directory, delete remote files not present locally. */\n\tdeleteOrphans?: boolean;\n};\n\nexport type Target = {\n\t/** Human-readable description (e.g. \"ssh root@droplet-1.example.com\"). */\n\treadonly description: string;\n\texec: (cmd: string, opts?: ExecOptions) => Promise<ExecResult>;\n\tupload: (localPath: string, remotePath: string, opts?: UploadOptions) => Promise<void>;\n\tclose?: () => Promise<void>;\n};\n\n// -----------------------------------------------------------------------------\n// localTarget\n// -----------------------------------------------------------------------------\n\nexport type LocalTargetOptions = {\n\t/** Root directory the target operates in. Created if missing. */\n\troot: string;\n\t/** Env merged into every exec. */\n\tenv?: Record<string, string>;\n};\n\nconst decodeChunks = async (\n\treader: ReadableStream<Uint8Array> | null,\n\tonLine: ((line: string) => void) | undefined,\n): Promise<string> => {\n\tif (!reader) return '';\n\tconst decoder = new TextDecoder();\n\tlet buffer = '';\n\tlet collected = '';\n\tconst stream = reader.getReader();\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await stream.read();\n\t\t\tif (done) break;\n\t\t\tconst chunk = decoder.decode(value, { stream: true });\n\t\t\tcollected += chunk;\n\t\t\tif (!onLine) continue;\n\t\t\tbuffer += chunk;\n\t\t\tlet newline = buffer.indexOf('\\n');\n\t\t\twhile (newline !== -1) {\n\t\t\t\tconst line = buffer.slice(0, newline).replace(/\\r$/, '');\n\t\t\t\tif (line.length > 0) onLine(line);\n\t\t\t\tbuffer = buffer.slice(newline + 1);\n\t\t\t\tnewline = buffer.indexOf('\\n');\n\t\t\t}\n\t\t}\n\t\tconst tail = decoder.decode();\n\t\tcollected += tail;\n\t\tif (onLine && (buffer + tail).length > 0) onLine((buffer + tail).replace(/\\r$/, ''));\n\t} finally {\n\t\tstream.releaseLock();\n\t}\n\treturn collected;\n};\n\nconst runSpawn = async (\n\targv: string[],\n\toptions: {\n\t\tcwd?: string;\n\t\tenv?: Record<string, string>;\n\t\ttimeoutMs?: number;\n\t\tonLog?: ExecOptions['onLog'];\n\t\tstdin?: string;\n\t},\n): Promise<ExecResult> => {\n\tconst proc = Bun.spawn(argv, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tstderr: 'pipe',\n\t\tstdin: options.stdin === undefined ? 'ignore' : 'pipe',\n\t\tstdout: 'pipe',\n\t});\n\n\tif (options.stdin !== undefined && proc.stdin) {\n\t\t// Bun.spawn returns a FileSink for piped stdin — `write` + `end`, not a\n\t\t// WritableStream. (We use a permissive cast because @types/bun's\n\t\t// Subprocess.stdin discriminant flips based on the stdin generic.)\n\t\tconst sink = proc.stdin as unknown as {\n\t\t\twrite: (chunk: string | Uint8Array) => number | Promise<number>;\n\t\t\tend: () => void | Promise<void>;\n\t\t};\n\t\tconst wrote = sink.write(options.stdin);\n\t\tif (wrote && typeof (wrote as Promise<number>).then === 'function') {\n\t\t\tawait wrote;\n\t\t}\n\t\tconst ended = sink.end();\n\t\tif (ended && typeof (ended as Promise<void>).then === 'function') {\n\t\t\tawait ended;\n\t\t}\n\t}\n\n\tconst timeout = options.timeoutMs ?? 600_000;\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tif (timeout > 0) {\n\t\ttimer = setTimeout(() => {\n\t\t\ttry { proc.kill(); } catch { /* already gone */ }\n\t\t}, timeout);\n\t}\n\n\tconst stdoutPromise = decodeChunks(\n\t\tproc.stdout as unknown as ReadableStream<Uint8Array>,\n\t\toptions.onLog ? (line) => options.onLog!(line, 'stdout') : undefined,\n\t);\n\tconst stderrPromise = decodeChunks(\n\t\tproc.stderr as unknown as ReadableStream<Uint8Array>,\n\t\toptions.onLog ? (line) => options.onLog!(line, 'stderr') : undefined,\n\t);\n\n\tconst [stdout, stderr, exitCode] = await Promise.all([\n\t\tstdoutPromise,\n\t\tstderrPromise,\n\t\tproc.exited,\n\t]);\n\tif (timer) clearTimeout(timer);\n\n\treturn { exitCode: exitCode ?? -1, stderr, stdout };\n};\n\nexport const localTarget = (options: LocalTargetOptions): Target => {\n\tconst baseEnv = { ...options.env };\n\tconst ensureRoot = async () => { await mkdir(options.root, { recursive: true }); };\n\n\treturn {\n\t\tdescription: `local ${options.root}`,\n\t\texec: async (cmd, opts) => {\n\t\t\tawait ensureRoot();\n\t\t\treturn runSpawn(['sh', '-c', cmd], {\n\t\t\t\tcwd: opts?.cwd ?? options.root,\n\t\t\t\tenv: { ...process.env, ...baseEnv, ...(opts?.env ?? {}) } as Record<string, string>,\n\t\t\t\tonLog: opts?.onLog,\n\t\t\t\tstdin: opts?.stdin,\n\t\t\t\ttimeoutMs: opts?.timeoutMs,\n\t\t\t});\n\t\t},\n\t\tupload: async (localPath, remotePath, opts) => {\n\t\t\tawait ensureRoot();\n\t\t\tconst dest = remotePath.startsWith('/') ? remotePath : join(options.root, remotePath);\n\t\t\tconst argv = ['rsync', '-a'];\n\t\t\tif (opts?.deleteOrphans) argv.push('--delete');\n\t\t\tfor (const pattern of opts?.exclude ?? []) argv.push('--exclude', pattern);\n\t\t\t// rsync semantics: a trailing slash on the source copies *contents*; without it the dir itself is nested.\n\t\t\targv.push(localPath, dest);\n\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`local upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t}\n\t\t},\n\t};\n};\n\n// -----------------------------------------------------------------------------\n// sshTarget\n// -----------------------------------------------------------------------------\n\nexport type SshTargetOptions = {\n\t/** Hostname or IP of the remote. */\n\thost: string;\n\t/** Login user. Default `root`. */\n\tuser?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\t/** Path to SSH identity file. Default: ssh's own search. */\n\tidentity?: string;\n\t/** Extra flags appended to every `ssh` invocation. */\n\tsshFlags?: string[];\n\t/**\n\t * Use rsync for `upload`. Default true. When false, falls back to `scp`\n\t * which is universal but doesn't support delete / exclude.\n\t */\n\trsync?: boolean;\n\t/**\n\t * Env vars to forward via `ssh -o SendEnv=...`. Most remote sshd configs\n\t * accept only `LANG` and `LC_*` by default; for app env vars use the\n\t * step `env` option instead, which prepends `KEY=value` to the command.\n\t */\n\tforwardEnv?: string[];\n};\n\nconst sshTargetString = (options: SshTargetOptions): string => {\n\tconst user = options.user ?? 'root';\n\treturn `${user}@${options.host}`;\n};\n\nconst sshBaseFlags = (options: SshTargetOptions): string[] => {\n\tconst flags: string[] = [];\n\tif (options.port !== undefined && options.port !== 22) flags.push('-p', String(options.port));\n\tif (options.identity !== undefined) flags.push('-i', options.identity);\n\t// Never get stuck on a host-key prompt; treat unknown hosts as a fatal config issue rather than a UX detour.\n\tflags.push('-o', 'BatchMode=yes', '-o', 'StrictHostKeyChecking=accept-new');\n\tfor (const flag of options.sshFlags ?? []) flags.push(flag);\n\treturn flags;\n};\n\nconst shellQuote = (value: string): string => `'${value.replace(/'/g, `'\\\\''`)}'`;\n\nconst buildRemoteCmd = (cmd: string, opts: ExecOptions | undefined): string => {\n\tconst env = opts?.env;\n\tconst envPrefix = env\n\t\t? Object.entries(env).map(([k, v]) => `${k}=${shellQuote(v)}`).join(' ') + ' '\n\t\t: '';\n\tif (opts?.cwd) {\n\t\treturn `cd ${shellQuote(opts.cwd)} && ${envPrefix}${cmd}`;\n\t}\n\treturn `${envPrefix}${cmd}`;\n};\n\nexport const sshTarget = (options: SshTargetOptions): Target => {\n\tconst remote = sshTargetString(options);\n\tconst useRsync = options.rsync ?? true;\n\n\treturn {\n\t\tdescription: `ssh ${remote}${options.port && options.port !== 22 ? `:${options.port}` : ''}`,\n\t\texec: async (cmd, opts) => {\n\t\t\tconst argv = ['ssh', ...sshBaseFlags(options)];\n\t\t\tfor (const name of options.forwardEnv ?? []) argv.push('-o', `SendEnv=${name}`);\n\t\t\targv.push(remote, buildRemoteCmd(cmd, opts));\n\t\t\treturn runSpawn(argv, {\n\t\t\t\tonLog: opts?.onLog,\n\t\t\t\tstdin: opts?.stdin,\n\t\t\t\ttimeoutMs: opts?.timeoutMs,\n\t\t\t});\n\t\t},\n\t\tupload: async (localPath, remotePath, opts) => {\n\t\t\tif (useRsync) {\n\t\t\t\tconst sshCmd = ['ssh', ...sshBaseFlags(options)].map((part) => part.includes(' ') ? `'${part}'` : part).join(' ');\n\t\t\t\tconst argv = ['rsync', '-az', '-e', sshCmd];\n\t\t\t\tif (opts?.deleteOrphans) argv.push('--delete');\n\t\t\t\tfor (const pattern of opts?.exclude ?? []) argv.push('--exclude', pattern);\n\t\t\t\targv.push(localPath, `${remote}:${remotePath}`);\n\t\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\t\tif (result.exitCode !== 0) {\n\t\t\t\t\tthrow new Error(`rsync upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// scp fallback — no exclude, no delete. We still need -r to copy directories.\n\t\t\tconst argv = ['scp', '-r', ...sshBaseFlags(options), localPath, `${remote}:${remotePath}`];\n\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`scp upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t}\n\t\t},\n\t};\n};\n",
6
+ "/**\n * Shared \"cloud-provider Target\" plumbing used by the\n * provider-specific adapters (`./digitalocean`, `./hetzner`, future\n * `./linode`, `./vultr`, etc.).\n *\n * The provider supplies a small `CloudTargetHooks` bag that knows\n * the provider's:\n *\n * - find-by-name lookup\n * - create call (closure over create params)\n * - fetch-by-id (used to poll for `active`)\n * - destroy-by-id\n * - status + ipv4 + id extraction from the provider's Server shape\n * - readiness predicate (status reached the terminal \"running\" value)\n *\n * `createCloudTarget()` does the universal machinery: provision-or-\n * reuse, poll until ready + IPv4, wait for SSH probe, build\n * `sshTarget` against the IPv4, return the Target wrapped with\n * `{ id, ipv4, destroy() }`.\n *\n * The public adapter (e.g. `digitalOceanTarget`) is a 30-line facade\n * that wires its provider-specific bits and renames `id` → `dropletId`\n * on the way out.\n */\n\nimport type { Target } from './targets';\nimport { sshTarget } from './targets';\n\n/** Provider-specific hooks. Keep these pure of network IO timing — the helper schedules. */\nexport type CloudTargetHooks<Server> = {\n\t/** Find a server by name. Returns undefined if absent. */\n\tfindByName: (name: string) => Promise<Server | undefined>;\n\t/** Create the server. Closure over provider-specific create params. */\n\tcreate: () => Promise<Server>;\n\t/** Fetch a fresh copy of the server by id. Used to poll. */\n\tfetch: (id: number) => Promise<Server>;\n\t/** Destroy a server by id. 404 should be treated as idempotent success. */\n\tdestroy: (id: number) => Promise<void>;\n\t/** True when the server has reached its terminal \"running\" status. */\n\tisReady: (server: Server) => boolean;\n\t/** Extract the numeric id. */\n\tgetId: (server: Server) => number;\n\t/** Extract the public IPv4. Returns undefined while one is being assigned. */\n\tgetIpv4: (server: Server) => string | undefined;\n\t/** Extract the current status as a string (for log lines). */\n\tgetStatus: (server: Server) => string;\n};\n\nexport type CloudTargetOptions = {\n\t/** Provider's idempotency key (server name). */\n\tname: string;\n\t/** Region / location label — used in the \"creating\" log line. */\n\tregion: string;\n\n\t/** SSH login user. Default `'root'`. */\n\tuser?: string;\n\t/** SSH identity file. */\n\tidentity?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\n\t/** Default 5 min. */\n\tprovisionTimeoutMs?: number;\n\t/** Default 2 min. */\n\tsshReadinessTimeoutMs?: number;\n\t/** Default 5 s. */\n\tpollIntervalMs?: number;\n\n\t/** Called with status updates. */\n\tonLog?: (line: string) => void;\n\t/** Override SSH probe — tests skip real TCP IO. */\n\tprobeSsh?: (host: string, port: number) => Promise<boolean>;\n\t/** Override sleep — tests skip real waits. */\n\tsleep?: (ms: number) => Promise<void>;\n\t/** Override clock — tests inject deterministic timestamps. */\n\tnow?: () => number;\n\n\t/**\n\t * Short log prefix, e.g. `'[do]'` or `'[hetzner]'`. Threaded through\n\t * every log line so multi-provider deploys distinguish output.\n\t */\n\tlogPrefix: string;\n\t/**\n\t * Provider's word for the entity in log copy — `'droplet'` for DO,\n\t * `'server'` for Hetzner. Preserves provider-accurate output.\n\t */\n\tentityWord: string;\n\t/**\n\t * Build the Target's `description` field. Receives the resolved\n\t * IPv4 + the wrapped sshTarget description.\n\t */\n\tdescribeTarget: (sshDescription: string) => string;\n};\n\nexport type CloudTargetResult = {\n\tid: number;\n\tipv4: string;\n\tdescription: string;\n\texec: Target['exec'];\n\tupload: Target['upload'];\n\tclose?: Target['close'];\n\tdestroy: () => Promise<void>;\n};\n\nconst defaultSleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms));\n\nconst defaultProbeSsh = async (host: string, port: number): Promise<boolean> => {\n\tconst PROBE_TIMEOUT_MS = 2_000;\n\treturn new Promise<boolean>((resolve) => {\n\t\tlet settled = false;\n\t\tconst settle = (value: boolean) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tresolve(value);\n\t\t};\n\t\tconst timer = setTimeout(() => settle(false), PROBE_TIMEOUT_MS);\n\t\tBun.connect({\n\t\t\thostname: host,\n\t\t\tport,\n\t\t\tsocket: {\n\t\t\t\tdata: () => {},\n\t\t\t\terror: () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tsettle(false);\n\t\t\t\t},\n\t\t\t\topen: (socket) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tsocket.end();\n\t\t\t\t\tsettle(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}).catch(() => {\n\t\t\tclearTimeout(timer);\n\t\t\tsettle(false);\n\t\t});\n\t});\n};\n\n/**\n * The shared provision-or-reuse + wait-for-ready + wait-for-SSH\n * pipeline. Provider-specific adapters wire their `CloudTargetHooks`\n * + their option-shape mapping and return a typed result.\n */\nexport const createCloudTarget = async <Server>(\n\thooks: CloudTargetHooks<Server>,\n\toptions: CloudTargetOptions\n): Promise<CloudTargetResult> => {\n\tconst log = options.onLog ?? (() => {});\n\tconst probeSsh = options.probeSsh ?? defaultProbeSsh;\n\tconst sleep = options.sleep ?? defaultSleep;\n\tconst now = options.now ?? Date.now;\n\tconst pollMs = options.pollIntervalMs ?? 5_000;\n\tconst provisionTimeout = options.provisionTimeoutMs ?? 5 * 60_000;\n\tconst sshTimeout = options.sshReadinessTimeoutMs ?? 2 * 60_000;\n\tconst port = options.port ?? 22;\n\tconst prefix = options.logPrefix;\n\tconst noun = options.entityWord;\n\n\tconst existing = await hooks.findByName(options.name);\n\tlet current: Server;\n\tif (existing === undefined) {\n\t\tlog(`${prefix} creating ${noun} \"${options.name}\" in ${options.region}`);\n\t\tcurrent = await hooks.create();\n\t} else {\n\t\tlog(\n\t\t\t`${prefix} reusing ${noun} \"${options.name}\" (id ${hooks.getId(existing)}, status ${hooks.getStatus(existing)})`\n\t\t);\n\t\tcurrent = existing;\n\t}\n\n\t// Wait for status=ready AND public IPv4 assigned.\n\tconst provisionStart = now();\n\tlet ipv4 = hooks.getIpv4(current);\n\twhile (!hooks.isReady(current) || ipv4 === undefined) {\n\t\tif (now() - provisionStart > provisionTimeout) {\n\t\t\tthrow new Error(\n\t\t\t\t`${prefix} provision timeout after ${provisionTimeout}ms — ${noun} ${hooks.getId(current)} status \"${hooks.getStatus(current)}\", ipv4 ${ipv4 ?? '(unassigned)'}`\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollMs);\n\t\tcurrent = await hooks.fetch(hooks.getId(current));\n\t\tipv4 = hooks.getIpv4(current);\n\t\tlog(\n\t\t\t`${prefix} poll: status=${hooks.getStatus(current)} ipv4=${ipv4 ?? '(none yet)'}`\n\t\t);\n\t}\n\tlog(`${prefix} ${noun} ready at ${ipv4}`);\n\n\t// Wait for SSH readiness.\n\tconst sshStart = now();\n\twhile (!(await probeSsh(ipv4, port))) {\n\t\tif (now() - sshStart > sshTimeout) {\n\t\t\tthrow new Error(\n\t\t\t\t`${prefix} SSH readiness timeout after ${sshTimeout}ms — ${ipv4}:${port} did not accept connections`\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollMs);\n\t\tlog(`${prefix} waiting on ssh ${ipv4}:${port}`);\n\t}\n\tlog(`${prefix} ssh ready at ${ipv4}:${port}`);\n\n\tconst ssh = sshTarget({\n\t\thost: ipv4,\n\t\t...(options.user !== undefined ? { user: options.user } : {}),\n\t\t...(options.identity !== undefined ? { identity: options.identity } : {}),\n\t\t...(options.port !== undefined ? { port: options.port } : {})\n\t});\n\n\tconst id = hooks.getId(current);\n\tconst resolvedIpv4 = ipv4;\n\n\treturn {\n\t\tdescription: options.describeTarget(ssh.description),\n\t\tdestroy: () =>\n\t\t\thooks.destroy(id).then(() => {\n\t\t\t\tlog(`${prefix} destroyed ${noun} ${id}`);\n\t\t\t}),\n\t\texec: ssh.exec,\n\t\tid,\n\t\tipv4: resolvedIpv4,\n\t\tupload: ssh.upload,\n\t\t...(ssh.close !== undefined ? { close: ssh.close } : {})\n\t};\n};\n",
7
+ "/**\n * @absolutejs/deploy/hetzner — provision-or-reuse Target adapter for\n * Hetzner Cloud servers. Sibling to {@link digitalOceanTarget}; same\n * shape, different API.\n *\n * What it does:\n *\n * 1. Looks up a server by `name`. If present and running, reuses it.\n * 2. If not present, creates it via the Hetzner Cloud v1 API and\n * waits for `status === 'running'` with a public IPv4 assigned.\n * 3. Waits for SSH readiness (TCP connect on port 22 with backoff,\n * or a caller-supplied probe).\n * 4. Returns a Target that wraps sshTarget against the server's\n * public IPv4, plus `serverId`, `ipv4`, and a `destroy()` helper.\n *\n * Idempotent by name — Hetzner enforces unique server names per\n * project, so calling twice with the same name returns the same\n * server.\n *\n * Narrow HetznerClientLike interface keeps the official `hcloud-js`\n * SDK out as a hard dep. Default client uses `fetch` against\n * `api.hetzner.cloud/v1`; pass your own for retry / observability.\n */\n\nimport type { Target } from './targets';\nimport { createCloudTarget, type CloudTargetHooks } from './cloudTarget';\n\nconst HETZNER_API_BASE = 'https://api.hetzner.cloud/v1';\n\n/**\n * Minimal subset of Hetzner Cloud API calls we make. Lets callers\n * BYO a client with retry / observability / etc.\n */\nexport type HetznerClientLike = {\n\trequest: <T = unknown>(\n\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\tpath: string,\n\t\tbody?: unknown\n\t) => Promise<T>;\n};\n\n/** A Hetzner Cloud server, narrowed to what we inspect. */\nexport type HetznerServer = {\n\tid: number;\n\tname: string;\n\tstatus:\n\t\t| 'initializing'\n\t\t| 'starting'\n\t\t| 'running'\n\t\t| 'stopping'\n\t\t| 'off'\n\t\t| 'deleting'\n\t\t| 'migrating'\n\t\t| 'rebuilding'\n\t\t| 'unknown';\n\tpublic_net: {\n\t\tipv4: { id: number; ip: string; blocked: boolean; dns_ptr?: string } | null;\n\t\tipv6: { id: number; ip: string; blocked: boolean } | null;\n\t};\n\tserver_type?: { name: string };\n\tdatacenter?: { location: { name: string } };\n\tlabels?: Record<string, string>;\n};\n\nexport type HetznerTargetOptions = {\n\t/** API token (https://docs.hetzner.cloud/#authentication). Required unless `client` is set. */\n\ttoken?: string;\n\t/** Custom client. Overrides token-built default. */\n\tclient?: HetznerClientLike;\n\n\t// ── Server shape ─────────────────────────────────────────────────\n\t/** Server name. Hetzner-unique per project; also our idempotency key. */\n\tname: string;\n\t/** Location slug — `'nbg1'`, `'fsn1'`, `'hel1'`, `'ash'`, `'hil'`. */\n\tlocation: string;\n\t/** Server type slug — `'cx22'`, `'cpx11'`, `'ccx13'`, etc. */\n\tserverType: string;\n\t/** Image slug or numeric id, e.g. `'ubuntu-22.04'`. */\n\timage: string | number;\n\t/** SSH key fingerprints, numeric ids, or names. At least one required. */\n\tsshKeys: ReadonlyArray<string | number>;\n\t/** Labels (Hetzner's key-value tags). */\n\tlabels?: Record<string, string>;\n\t/** cloud-init user data — a shell script or YAML config. */\n\tuserData?: string;\n\t/** Attach to a Cloud Network (by id). */\n\tnetworkId?: number;\n\t/** Disable IPv4 public addressing. Default: enabled. */\n\tdisablePublicIpv4?: boolean;\n\t/** Disable IPv6 public addressing. Default: enabled. */\n\tdisablePublicIpv6?: boolean;\n\n\t// ── SSH wrap ────────────────────────────────────────────────────\n\t/** SSH login user. Default `'root'`. */\n\tuser?: string;\n\t/** Path to SSH identity file forwarded to sshTarget. */\n\tidentity?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\n\t// ── Timing ──────────────────────────────────────────────────────\n\t/** Max time to wait for server `running` + IPv4. Default 5 min. */\n\tprovisionTimeoutMs?: number;\n\t/** Max time to wait for SSH probe to succeed. Default 2 min. */\n\tsshReadinessTimeoutMs?: number;\n\t/** Poll interval for provision + ssh probe. Default 5 s. */\n\tpollIntervalMs?: number;\n\n\t// ── Observability + injection points ───────────────────────────\n\t/** Called with status updates (one line each). Default: noop. */\n\tonLog?: (line: string) => void;\n\t/**\n\t * Override the SSH readiness probe. Default opens a TCP socket to\n\t * `host:port`. Tests pass a fake probe to skip real network IO.\n\t */\n\tprobeSsh?: (host: string, port: number) => Promise<boolean>;\n\t/** Sleep used between polls. Tests can pass a synchronous resolver. */\n\tsleep?: (ms: number) => Promise<void>;\n\t/** Wall clock. Defaults to `Date.now`. Tests can swap. */\n\tnow?: () => number;\n};\n\nexport type HetznerTarget = Target & {\n\treadonly serverId: number;\n\treadonly ipv4: string;\n\t/** Destroy the server via the Hetzner API. */\n\tdestroy: () => Promise<void>;\n};\n\nexport class HetznerError extends Error {\n\treadonly status: number;\n\treadonly body: unknown;\n\tconstructor(message: string, status: number, body: unknown) {\n\t\tsuper(message);\n\t\tthis.name = 'HetznerError';\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t}\n}\n\n/**\n * fetch-backed default client. Talks JSON to `api.hetzner.cloud/v1`.\n * Throws HetznerError on non-2xx with the response body attached so\n * the caller can switch on `err.status`.\n */\nexport const createHetznerClient = (\n\ttoken: string,\n\toptions: { baseUrl?: string; fetch?: typeof fetch } = {}\n): HetznerClientLike => {\n\tconst base = options.baseUrl ?? HETZNER_API_BASE;\n\tconst f = options.fetch ?? fetch;\n\treturn {\n\t\trequest: async <T>(\n\t\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\t\tpath: string,\n\t\t\tbody?: unknown\n\t\t): Promise<T> => {\n\t\t\tconst init: RequestInit = {\n\t\t\t\theaders: {\n\t\t\t\t\tauthorization: `Bearer ${token}`,\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t},\n\t\t\t\tmethod\n\t\t\t};\n\t\t\tif (body !== undefined) init.body = JSON.stringify(body);\n\t\t\tconst response = await f(`${base}${path}`, init);\n\t\t\tif (response.status === 204) return undefined as T;\n\t\t\tconst text = await response.text();\n\t\t\tconst parsed = text.length > 0 ? JSON.parse(text) : undefined;\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new HetznerError(\n\t\t\t\t\t`Hetzner Cloud API ${method} ${path} failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tparsed\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn parsed as T;\n\t\t}\n\t};\n};\n\nconst resolveClient = (\n\toptions: Pick<HetznerTargetOptions, 'client' | 'token'>\n): HetznerClientLike => {\n\tif (options.client !== undefined) return options.client;\n\tif (options.token !== undefined && options.token.length > 0) {\n\t\treturn createHetznerClient(options.token);\n\t}\n\tthrow new Error(\n\t\t'[deploy/hetzner] either `token` or `client` must be provided'\n\t);\n};\n\nconst publicIpv4 = (server: HetznerServer): string | undefined =>\n\tserver.public_net.ipv4?.ip;\n\n/**\n * Find a server by name. Returns undefined if absent. Hetzner\n * enforces unique server names per project, so duplicates aren't\n * possible — but if the API ever returns >1 we still surface that\n * loudly.\n */\nexport const findHetznerServer = async (\n\tclient: HetznerClientLike,\n\tname: string\n): Promise<HetznerServer | undefined> => {\n\tconst body = await client.request<{ servers: HetznerServer[] }>(\n\t\t'GET',\n\t\t`/servers?name=${encodeURIComponent(name)}`\n\t);\n\tconst matches = body.servers.filter((server) => server.name === name);\n\tif (matches.length === 0) return undefined;\n\tif (matches.length > 1) {\n\t\tthrow new Error(\n\t\t\t`[deploy/hetzner] multiple servers named \"${name}\" (${matches\n\t\t\t\t.map((server) => server.id)\n\t\t\t\t.join(', ')}). Hetzner shouldn't allow this — resolve manually.`\n\t\t);\n\t}\n\treturn matches[0];\n};\n\n/** List servers, optionally filtered by label selector. */\nexport const listHetznerServers = async (options: {\n\ttoken?: string;\n\tclient?: HetznerClientLike;\n\t/** Label selector, e.g. `'env=prod'` or `'env in (prod,staging)'`. */\n\tlabelSelector?: string;\n}): Promise<HetznerServer[]> => {\n\tconst client = resolveClient(options);\n\tconst path =\n\t\toptions.labelSelector !== undefined\n\t\t\t? `/servers?label_selector=${encodeURIComponent(options.labelSelector)}`\n\t\t\t: '/servers';\n\tconst body = await client.request<{ servers: HetznerServer[] }>('GET', path);\n\treturn body.servers;\n};\n\n/** Destroy a server by id. 404 treated as idempotent success. */\nexport const destroyHetznerServer = async (options: {\n\ttoken?: string;\n\tclient?: HetznerClientLike;\n\tid: number;\n}): Promise<void> => {\n\tconst client = resolveClient(options);\n\ttry {\n\t\tawait client.request('DELETE', `/servers/${options.id}`);\n\t} catch (error) {\n\t\tif (error instanceof HetznerError && error.status === 404) {\n\t\t\treturn; // already destroyed — idempotent\n\t\t}\n\t\tthrow error;\n\t}\n};\n\n/**\n * Provision-or-reuse a Hetzner Cloud server by name, wait for SSH,\n * return a Target. Idempotent: same name → same server.\n */\nexport const hetznerTarget = async (\n\toptions: HetznerTargetOptions\n): Promise<HetznerTarget> => {\n\tconst client = resolveClient(options);\n\tconst publicIpv4Enabled = options.disablePublicIpv4 !== true;\n\tconst publicIpv6Enabled = options.disablePublicIpv6 !== true;\n\n\tconst hooks: CloudTargetHooks<HetznerServer> = {\n\t\tcreate: async () => {\n\t\t\tconst created = await client.request<{ server: HetznerServer }>(\n\t\t\t\t'POST',\n\t\t\t\t'/servers',\n\t\t\t\t{\n\t\t\t\t\tname: options.name,\n\t\t\t\t\tlocation: options.location,\n\t\t\t\t\tserver_type: options.serverType,\n\t\t\t\t\timage: options.image,\n\t\t\t\t\tssh_keys: [...options.sshKeys],\n\t\t\t\t\tstart_after_create: true,\n\t\t\t\t\tpublic_net: {\n\t\t\t\t\t\tenable_ipv4: publicIpv4Enabled,\n\t\t\t\t\t\tenable_ipv6: publicIpv6Enabled\n\t\t\t\t\t},\n\t\t\t\t\t...(options.labels !== undefined\n\t\t\t\t\t\t? { labels: options.labels }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(options.userData !== undefined\n\t\t\t\t\t\t? { user_data: options.userData }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(options.networkId !== undefined\n\t\t\t\t\t\t? { networks: [options.networkId] }\n\t\t\t\t\t\t: {})\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn created.server;\n\t\t},\n\t\tdestroy: (id) => destroyHetznerServer({ client, id }),\n\t\tfetch: async (id) => {\n\t\t\tconst refreshed: { server: HetznerServer } = await client.request(\n\t\t\t\t'GET',\n\t\t\t\t`/servers/${id}`\n\t\t\t);\n\t\t\treturn refreshed.server;\n\t\t},\n\t\tfindByName: (name) => findHetznerServer(client, name),\n\t\tgetId: (server) => server.id,\n\t\tgetIpv4: publicIpv4,\n\t\tgetStatus: (server) => server.status,\n\t\tisReady: (server) => server.status === 'running'\n\t};\n\n\tconst result = await createCloudTarget(hooks, {\n\t\tdescribeTarget: (sshDescription) =>\n\t\t\t`hetzner server \"${options.name}\" (${sshDescription})`,\n\t\tentityWord: 'server',\n\t\tlogPrefix: '[hetzner]',\n\t\tname: options.name,\n\t\tregion: options.location,\n\t\t...(options.user !== undefined ? { user: options.user } : {}),\n\t\t...(options.identity !== undefined ? { identity: options.identity } : {}),\n\t\t...(options.port !== undefined ? { port: options.port } : {}),\n\t\t...(options.provisionTimeoutMs !== undefined\n\t\t\t? { provisionTimeoutMs: options.provisionTimeoutMs }\n\t\t\t: {}),\n\t\t...(options.sshReadinessTimeoutMs !== undefined\n\t\t\t? { sshReadinessTimeoutMs: options.sshReadinessTimeoutMs }\n\t\t\t: {}),\n\t\t...(options.pollIntervalMs !== undefined\n\t\t\t? { pollIntervalMs: options.pollIntervalMs }\n\t\t\t: {}),\n\t\t...(options.onLog !== undefined ? { onLog: options.onLog } : {}),\n\t\t...(options.probeSsh !== undefined ? { probeSsh: options.probeSsh } : {}),\n\t\t...(options.sleep !== undefined ? { sleep: options.sleep } : {}),\n\t\t...(options.now !== undefined ? { now: options.now } : {})\n\t});\n\n\treturn {\n\t\tdescription: result.description,\n\t\tdestroy: result.destroy,\n\t\texec: result.exec,\n\t\tipv4: result.ipv4,\n\t\tserverId: result.id,\n\t\tupload: result.upload,\n\t\t...(result.close !== undefined ? { close: result.close } : {})\n\t};\n};\n"
8
+ ],
9
+ "mappings": ";;AAuBA;AACA;AA+CA,IAAM,eAAe,OACpB,QACA,WACqB;AAAA,EACrB,IAAI,CAAC;AAAA,IAAQ,OAAO;AAAA,EACpB,MAAM,UAAU,IAAI;AAAA,EACpB,IAAI,SAAS;AAAA,EACb,IAAI,YAAY;AAAA,EAChB,MAAM,SAAS,OAAO,UAAU;AAAA,EAChC,IAAI;AAAA,IACH,OAAO,MAAM;AAAA,MACZ,QAAQ,MAAM,UAAU,MAAM,OAAO,KAAK;AAAA,MAC1C,IAAI;AAAA,QAAM;AAAA,MACV,MAAM,QAAQ,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAAA,MACpD,aAAa;AAAA,MACb,IAAI,CAAC;AAAA,QAAQ;AAAA,MACb,UAAU;AAAA,MACV,IAAI,UAAU,OAAO,QAAQ;AAAA,CAAI;AAAA,MACjC,OAAO,YAAY,IAAI;AAAA,QACtB,MAAM,OAAO,OAAO,MAAM,GAAG,OAAO,EAAE,QAAQ,OAAO,EAAE;AAAA,QACvD,IAAI,KAAK,SAAS;AAAA,UAAG,OAAO,IAAI;AAAA,QAChC,SAAS,OAAO,MAAM,UAAU,CAAC;AAAA,QACjC,UAAU,OAAO,QAAQ;AAAA,CAAI;A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AAU,YAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,OAC1D,QAAQ,QAAQ,YAAY,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC;AAAA,EACzD,CAAC;AAAA,EAED,OAAO;AAAA,IACN,aAAa,OAAO;AAAA,IACpB,SAAS,OAAO;AAAA,IAChB,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,UAAU,OAAO;AAAA,IACjB,QAAQ,OAAO;AAAA,OACX,OAAO,UAAU,YAAY,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;AAAA,EAC7D;AAAA;",
10
+ "debugId": "1016401F0A6B67CD64756E2164756E21",
11
+ "names": []
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/deploy",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Generic Bun-project deploy pipeline. A Target (localTarget / sshTarget) is anywhere you can exec + upload — DigitalOcean droplets, Linode, Hetzner, Vultr, your own boxes. Bundled pipeline: prepare → upload → install → build → link → restart → verify. Atomic symlink swap, release history, prune, hooks. SSH shells out to system ssh/rsync — zero ssh2 deps.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,7 @@
26
26
  "release"
27
27
  ],
28
28
  "scripts": {
29
- "build": "rm -rf dist && bun build src/index.ts src/digitalocean.ts --outdir dist --sourcemap --target=bun && tsc --project tsconfig.build.json",
29
+ "build": "rm -rf dist && bun build src/index.ts src/digitalocean.ts src/hetzner.ts --outdir dist --sourcemap --target=bun && tsc --project tsconfig.build.json",
30
30
  "test": "bun test tests/",
31
31
  "typecheck": "tsc --noEmit",
32
32
  "format": "prettier --write \"./**/*.{ts,json,md}\"",
@@ -51,6 +51,11 @@
51
51
  "types": "./dist/digitalocean.d.ts",
52
52
  "import": "./dist/digitalocean.js",
53
53
  "default": "./dist/digitalocean.js"
54
+ },
55
+ "./hetzner": {
56
+ "types": "./dist/hetzner.d.ts",
57
+ "import": "./dist/hetzner.js",
58
+ "default": "./dist/hetzner.js"
54
59
  }
55
60
  },
56
61
  "files": ["dist", "README.md"]