@absolutejs/deploy 0.12.0 → 0.14.0
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 +52 -0
- package/dist/cloudflare.js +34 -1
- package/dist/cloudflare.js.map +2 -2
- package/dist/digitalocean.js +34 -1
- package/dist/digitalocean.js.map +2 -2
- package/dist/digitaloceanDns.js +34 -1
- package/dist/digitaloceanDns.js.map +2 -2
- package/dist/digitaloceanInfrastructure.d.ts +26 -0
- package/dist/digitaloceanInfrastructure.js +543 -0
- package/dist/digitaloceanInfrastructure.js.map +13 -0
- package/dist/dns.js +34 -1
- package/dist/dns.js.map +2 -2
- package/dist/env.js +34 -1
- package/dist/env.js.map +2 -2
- package/dist/gcp.d.ts +23 -0
- package/dist/gcp.js +10474 -0
- package/dist/gcp.js.map +90 -0
- package/dist/hetzner.js +34 -1
- package/dist/hetzner.js.map +2 -2
- package/dist/hetznerDns.js +34 -1
- package/dist/hetznerDns.js.map +2 -2
- package/dist/index.js +34 -1
- package/dist/index.js.map +2 -2
- package/dist/infrastructure.d.ts +35 -0
- package/dist/infrastructure.js +4 -0
- package/dist/infrastructure.js.map +9 -0
- package/dist/linode.js +34 -1
- package/dist/linode.js.map +2 -2
- package/dist/preview.js +34 -1
- package/dist/preview.js.map +2 -2
- package/dist/route53.js +34 -1
- package/dist/route53.js.map +2 -2
- package/dist/tls.d.ts +11 -0
- package/dist/tls.js +44 -4
- package/dist/tls.js.map +3 -3
- package/dist/vultr.js +34 -1
- package/dist/vultr.js.map +2 -2
- package/package.json +20 -2
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
12
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
20
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
for (let key of __getOwnPropNames(mod))
|
|
23
|
+
if (!__hasOwnProp.call(to, key))
|
|
24
|
+
__defProp(to, key, {
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
26
|
+
enumerable: true
|
|
27
|
+
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __require = import.meta.require;
|
|
34
|
+
|
|
35
|
+
// src/targets.ts
|
|
36
|
+
import { mkdir } from "fs/promises";
|
|
37
|
+
import { join } from "path";
|
|
38
|
+
var decodeChunks = async (reader, onLine) => {
|
|
39
|
+
if (!reader)
|
|
40
|
+
return "";
|
|
41
|
+
const decoder = new TextDecoder;
|
|
42
|
+
let buffer = "";
|
|
43
|
+
let collected = "";
|
|
44
|
+
const stream = reader.getReader();
|
|
45
|
+
try {
|
|
46
|
+
while (true) {
|
|
47
|
+
const { done, value } = await stream.read();
|
|
48
|
+
if (done)
|
|
49
|
+
break;
|
|
50
|
+
const chunk = decoder.decode(value, { stream: true });
|
|
51
|
+
collected += chunk;
|
|
52
|
+
if (!onLine)
|
|
53
|
+
continue;
|
|
54
|
+
buffer += chunk;
|
|
55
|
+
let newline = buffer.indexOf(`
|
|
56
|
+
`);
|
|
57
|
+
while (newline !== -1) {
|
|
58
|
+
const line = buffer.slice(0, newline).replace(/\r$/, "");
|
|
59
|
+
if (line.length > 0)
|
|
60
|
+
onLine(line);
|
|
61
|
+
buffer = buffer.slice(newline + 1);
|
|
62
|
+
newline = buffer.indexOf(`
|
|
63
|
+
`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const tail = decoder.decode();
|
|
67
|
+
collected += tail;
|
|
68
|
+
if (onLine && (buffer + tail).length > 0)
|
|
69
|
+
onLine((buffer + tail).replace(/\r$/, ""));
|
|
70
|
+
} finally {
|
|
71
|
+
stream.releaseLock();
|
|
72
|
+
}
|
|
73
|
+
return collected;
|
|
74
|
+
};
|
|
75
|
+
var runSpawn = async (argv, options) => {
|
|
76
|
+
const proc = Bun.spawn(argv, {
|
|
77
|
+
cwd: options.cwd,
|
|
78
|
+
env: options.env,
|
|
79
|
+
stderr: "pipe",
|
|
80
|
+
stdin: options.stdin === undefined ? "ignore" : "pipe",
|
|
81
|
+
stdout: "pipe"
|
|
82
|
+
});
|
|
83
|
+
if (options.stdin !== undefined && proc.stdin) {
|
|
84
|
+
const sink = proc.stdin;
|
|
85
|
+
const wrote = sink.write(options.stdin);
|
|
86
|
+
if (wrote && typeof wrote.then === "function") {
|
|
87
|
+
await wrote;
|
|
88
|
+
}
|
|
89
|
+
const ended = sink.end();
|
|
90
|
+
if (ended && typeof ended.then === "function") {
|
|
91
|
+
await ended;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const timeout = options.timeoutMs ?? 600000;
|
|
95
|
+
let timer;
|
|
96
|
+
if (timeout > 0) {
|
|
97
|
+
timer = setTimeout(() => {
|
|
98
|
+
try {
|
|
99
|
+
proc.kill();
|
|
100
|
+
} catch {}
|
|
101
|
+
}, timeout);
|
|
102
|
+
}
|
|
103
|
+
const stdoutPromise = decodeChunks(proc.stdout, options.onLog ? (line) => options.onLog(line, "stdout") : undefined);
|
|
104
|
+
const stderrPromise = decodeChunks(proc.stderr, options.onLog ? (line) => options.onLog(line, "stderr") : undefined);
|
|
105
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
106
|
+
stdoutPromise,
|
|
107
|
+
stderrPromise,
|
|
108
|
+
proc.exited
|
|
109
|
+
]);
|
|
110
|
+
if (timer)
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
return { exitCode: exitCode ?? -1, stderr, stdout };
|
|
113
|
+
};
|
|
114
|
+
var localTarget = (options) => {
|
|
115
|
+
const baseEnv = { ...options.env };
|
|
116
|
+
const ensureRoot = async () => {
|
|
117
|
+
await mkdir(options.root, { recursive: true });
|
|
118
|
+
};
|
|
119
|
+
return {
|
|
120
|
+
description: `local ${options.root}`,
|
|
121
|
+
exec: async (cmd, opts) => {
|
|
122
|
+
await ensureRoot();
|
|
123
|
+
return runSpawn(["sh", "-c", cmd], {
|
|
124
|
+
cwd: opts?.cwd ?? options.root,
|
|
125
|
+
env: { ...process.env, ...baseEnv, ...opts?.env ?? {} },
|
|
126
|
+
onLog: opts?.onLog,
|
|
127
|
+
stdin: opts?.stdin,
|
|
128
|
+
timeoutMs: opts?.timeoutMs
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
upload: async (localPath, remotePath, opts) => {
|
|
132
|
+
await ensureRoot();
|
|
133
|
+
const dest = remotePath.startsWith("/") ? remotePath : join(options.root, remotePath);
|
|
134
|
+
const argv = ["rsync", "-a"];
|
|
135
|
+
if (opts?.deleteOrphans)
|
|
136
|
+
argv.push("--delete");
|
|
137
|
+
for (const pattern of opts?.exclude ?? [])
|
|
138
|
+
argv.push("--exclude", pattern);
|
|
139
|
+
argv.push(localPath, dest);
|
|
140
|
+
const result = await runSpawn(argv, { timeoutMs: 600000 });
|
|
141
|
+
if (result.exitCode !== 0) {
|
|
142
|
+
throw new Error(`local upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
var sshTargetString = (options) => {
|
|
148
|
+
const user = options.user ?? "root";
|
|
149
|
+
return `${user}@${options.host}`;
|
|
150
|
+
};
|
|
151
|
+
var sshBaseFlags = (options) => {
|
|
152
|
+
const flags = [];
|
|
153
|
+
if (options.port !== undefined && options.port !== 22)
|
|
154
|
+
flags.push("-p", String(options.port));
|
|
155
|
+
if (options.identity !== undefined)
|
|
156
|
+
flags.push("-i", options.identity);
|
|
157
|
+
flags.push("-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=accept-new");
|
|
158
|
+
for (const flag of options.sshFlags ?? [])
|
|
159
|
+
flags.push(flag);
|
|
160
|
+
return flags;
|
|
161
|
+
};
|
|
162
|
+
var shellQuote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
163
|
+
var buildRemoteCmd = (cmd, opts) => {
|
|
164
|
+
const env = opts?.env;
|
|
165
|
+
const envPrefix = env ? Object.entries(env).map(([k, v]) => `${k}=${shellQuote(v)}`).join(" ") + " " : "";
|
|
166
|
+
if (opts?.cwd) {
|
|
167
|
+
return `cd ${shellQuote(opts.cwd)} && ${envPrefix}${cmd}`;
|
|
168
|
+
}
|
|
169
|
+
return `${envPrefix}${cmd}`;
|
|
170
|
+
};
|
|
171
|
+
var sshTarget = (options) => {
|
|
172
|
+
const remote = sshTargetString(options);
|
|
173
|
+
const useRsync = options.rsync ?? true;
|
|
174
|
+
return {
|
|
175
|
+
description: `ssh ${remote}${options.port && options.port !== 22 ? `:${options.port}` : ""}`,
|
|
176
|
+
exec: async (cmd, opts) => {
|
|
177
|
+
const argv = ["ssh", ...sshBaseFlags(options)];
|
|
178
|
+
for (const name of options.forwardEnv ?? [])
|
|
179
|
+
argv.push("-o", `SendEnv=${name}`);
|
|
180
|
+
argv.push(remote, buildRemoteCmd(cmd, opts));
|
|
181
|
+
return runSpawn(argv, {
|
|
182
|
+
onLog: opts?.onLog,
|
|
183
|
+
stdin: opts?.stdin,
|
|
184
|
+
timeoutMs: opts?.timeoutMs
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
upload: async (localPath, remotePath, opts) => {
|
|
188
|
+
if (useRsync) {
|
|
189
|
+
const sshCmd = ["ssh", ...sshBaseFlags(options)].map((part) => part.includes(" ") ? `'${part}'` : part).join(" ");
|
|
190
|
+
const argv2 = ["rsync", "-az", "-e", sshCmd];
|
|
191
|
+
if (opts?.deleteOrphans)
|
|
192
|
+
argv2.push("--delete");
|
|
193
|
+
for (const pattern of opts?.exclude ?? [])
|
|
194
|
+
argv2.push("--exclude", pattern);
|
|
195
|
+
argv2.push(localPath, `${remote}:${remotePath}`);
|
|
196
|
+
const result2 = await runSpawn(argv2, { timeoutMs: 600000 });
|
|
197
|
+
if (result2.exitCode !== 0) {
|
|
198
|
+
throw new Error(`rsync upload failed (exit ${result2.exitCode}): ${result2.stderr || result2.stdout}`);
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const argv = ["scp", "-r", ...sshBaseFlags(options), localPath, `${remote}:${remotePath}`];
|
|
203
|
+
const result = await runSpawn(argv, { timeoutMs: 600000 });
|
|
204
|
+
if (result.exitCode !== 0) {
|
|
205
|
+
throw new Error(`scp upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/cloudTarget.ts
|
|
212
|
+
var defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
213
|
+
var defaultProbeSsh = async (host, port) => {
|
|
214
|
+
const PROBE_TIMEOUT_MS = 2000;
|
|
215
|
+
return new Promise((resolve) => {
|
|
216
|
+
let settled = false;
|
|
217
|
+
const settle = (value) => {
|
|
218
|
+
if (settled)
|
|
219
|
+
return;
|
|
220
|
+
settled = true;
|
|
221
|
+
resolve(value);
|
|
222
|
+
};
|
|
223
|
+
const timer = setTimeout(() => settle(false), PROBE_TIMEOUT_MS);
|
|
224
|
+
Bun.connect({
|
|
225
|
+
hostname: host,
|
|
226
|
+
port,
|
|
227
|
+
socket: {
|
|
228
|
+
data: () => {},
|
|
229
|
+
error: () => {
|
|
230
|
+
clearTimeout(timer);
|
|
231
|
+
settle(false);
|
|
232
|
+
},
|
|
233
|
+
open: (socket) => {
|
|
234
|
+
clearTimeout(timer);
|
|
235
|
+
socket.end();
|
|
236
|
+
settle(true);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}).catch(() => {
|
|
240
|
+
clearTimeout(timer);
|
|
241
|
+
settle(false);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
var createCloudTarget = async (hooks, options) => {
|
|
246
|
+
const log = options.onLog ?? (() => {});
|
|
247
|
+
const probeSsh = options.probeSsh ?? defaultProbeSsh;
|
|
248
|
+
const sleep = options.sleep ?? defaultSleep;
|
|
249
|
+
const now = options.now ?? Date.now;
|
|
250
|
+
const pollMs = options.pollIntervalMs ?? 5000;
|
|
251
|
+
const provisionTimeout = options.provisionTimeoutMs ?? 5 * 60000;
|
|
252
|
+
const sshTimeout = options.sshReadinessTimeoutMs ?? 2 * 60000;
|
|
253
|
+
const port = options.port ?? 22;
|
|
254
|
+
const prefix = options.logPrefix;
|
|
255
|
+
const noun = options.entityWord;
|
|
256
|
+
const existing = await hooks.findByName(options.name);
|
|
257
|
+
let current;
|
|
258
|
+
if (existing === undefined) {
|
|
259
|
+
log(`${prefix} creating ${noun} "${options.name}" in ${options.region}`);
|
|
260
|
+
current = await hooks.create();
|
|
261
|
+
} else {
|
|
262
|
+
log(`${prefix} reusing ${noun} "${options.name}" (id ${hooks.getId(existing)}, status ${hooks.getStatus(existing)})`);
|
|
263
|
+
current = existing;
|
|
264
|
+
}
|
|
265
|
+
const provisionStart = now();
|
|
266
|
+
let ipv4 = hooks.getIpv4(current);
|
|
267
|
+
while (!hooks.isReady(current) || ipv4 === undefined) {
|
|
268
|
+
if (now() - provisionStart > provisionTimeout) {
|
|
269
|
+
throw new Error(`${prefix} provision timeout after ${provisionTimeout}ms \u2014 ${noun} ${hooks.getId(current)} status "${hooks.getStatus(current)}", ipv4 ${ipv4 ?? "(unassigned)"}`);
|
|
270
|
+
}
|
|
271
|
+
await sleep(pollMs);
|
|
272
|
+
current = await hooks.fetch(hooks.getId(current));
|
|
273
|
+
ipv4 = hooks.getIpv4(current);
|
|
274
|
+
log(`${prefix} poll: status=${hooks.getStatus(current)} ipv4=${ipv4 ?? "(none yet)"}`);
|
|
275
|
+
}
|
|
276
|
+
log(`${prefix} ${noun} ready at ${ipv4}`);
|
|
277
|
+
const sshStart = now();
|
|
278
|
+
while (!await probeSsh(ipv4, port)) {
|
|
279
|
+
if (now() - sshStart > sshTimeout) {
|
|
280
|
+
throw new Error(`${prefix} SSH readiness timeout after ${sshTimeout}ms \u2014 ${ipv4}:${port} did not accept connections`);
|
|
281
|
+
}
|
|
282
|
+
await sleep(pollMs);
|
|
283
|
+
log(`${prefix} waiting on ssh ${ipv4}:${port}`);
|
|
284
|
+
}
|
|
285
|
+
log(`${prefix} ssh ready at ${ipv4}:${port}`);
|
|
286
|
+
const ssh = sshTarget({
|
|
287
|
+
host: ipv4,
|
|
288
|
+
...options.user !== undefined ? { user: options.user } : {},
|
|
289
|
+
...options.identity !== undefined ? { identity: options.identity } : {},
|
|
290
|
+
...options.port !== undefined ? { port: options.port } : {}
|
|
291
|
+
});
|
|
292
|
+
const id = hooks.getId(current);
|
|
293
|
+
const resolvedIpv4 = ipv4;
|
|
294
|
+
return {
|
|
295
|
+
description: options.describeTarget(ssh.description),
|
|
296
|
+
destroy: () => hooks.destroy(id).then(() => {
|
|
297
|
+
log(`${prefix} destroyed ${noun} ${id}`);
|
|
298
|
+
}),
|
|
299
|
+
exec: ssh.exec,
|
|
300
|
+
id,
|
|
301
|
+
ipv4: resolvedIpv4,
|
|
302
|
+
upload: ssh.upload,
|
|
303
|
+
...ssh.close !== undefined ? { close: ssh.close } : {}
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// src/digitalocean.ts
|
|
308
|
+
var DO_API_BASE = "https://api.digitalocean.com/v2";
|
|
309
|
+
|
|
310
|
+
class DigitalOceanError extends Error {
|
|
311
|
+
status;
|
|
312
|
+
body;
|
|
313
|
+
constructor(message, status, body) {
|
|
314
|
+
super(message);
|
|
315
|
+
this.name = "DigitalOceanError";
|
|
316
|
+
this.status = status;
|
|
317
|
+
this.body = body;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
var createDigitalOceanClient = (token, options = {}) => {
|
|
321
|
+
const base = options.baseUrl ?? DO_API_BASE;
|
|
322
|
+
const f = options.fetch ?? fetch;
|
|
323
|
+
return {
|
|
324
|
+
request: async (method, path, body) => {
|
|
325
|
+
const init = {
|
|
326
|
+
headers: {
|
|
327
|
+
authorization: `Bearer ${token}`,
|
|
328
|
+
"content-type": "application/json"
|
|
329
|
+
},
|
|
330
|
+
method
|
|
331
|
+
};
|
|
332
|
+
if (body !== undefined)
|
|
333
|
+
init.body = JSON.stringify(body);
|
|
334
|
+
const response = await f(`${base}${path}`, init);
|
|
335
|
+
if (response.status === 204)
|
|
336
|
+
return;
|
|
337
|
+
const text = await response.text();
|
|
338
|
+
const parsed = text.length > 0 ? JSON.parse(text) : undefined;
|
|
339
|
+
if (!response.ok) {
|
|
340
|
+
throw new DigitalOceanError(`DigitalOcean API ${method} ${path} failed: ${response.status} ${response.statusText}`, response.status, parsed);
|
|
341
|
+
}
|
|
342
|
+
return parsed;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
var resolveClient = (options) => {
|
|
347
|
+
if (options.client !== undefined)
|
|
348
|
+
return options.client;
|
|
349
|
+
if (options.token !== undefined && options.token.length > 0) {
|
|
350
|
+
return createDigitalOceanClient(options.token);
|
|
351
|
+
}
|
|
352
|
+
throw new Error("[deploy/digitalocean] either `token` or `client` must be provided");
|
|
353
|
+
};
|
|
354
|
+
var publicIpv4 = (droplet) => droplet.networks.v4.find((net) => net.type === "public")?.ip_address;
|
|
355
|
+
var findDigitalOceanDroplet = async (client, name) => {
|
|
356
|
+
const body = await client.request("GET", `/droplets?name=${encodeURIComponent(name)}`);
|
|
357
|
+
const matches = body.droplets.filter((droplet) => droplet.name === name);
|
|
358
|
+
if (matches.length === 0)
|
|
359
|
+
return;
|
|
360
|
+
if (matches.length > 1) {
|
|
361
|
+
throw new Error(`[deploy/digitalocean] multiple droplets named "${name}" (${matches.map((droplet) => droplet.id).join(", ")}). Resolve manually before adopting.`);
|
|
362
|
+
}
|
|
363
|
+
return matches[0];
|
|
364
|
+
};
|
|
365
|
+
var listDigitalOceanDroplets = async (options) => {
|
|
366
|
+
const client = resolveClient(options);
|
|
367
|
+
const path = options.tag !== undefined ? `/droplets?tag_name=${encodeURIComponent(options.tag)}` : "/droplets";
|
|
368
|
+
const body = await client.request("GET", path);
|
|
369
|
+
return body.droplets;
|
|
370
|
+
};
|
|
371
|
+
var destroyDigitalOceanDroplet = async (options) => {
|
|
372
|
+
const client = resolveClient(options);
|
|
373
|
+
try {
|
|
374
|
+
await client.request("DELETE", `/droplets/${options.id}`);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
if (error instanceof DigitalOceanError && error.status === 404) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
throw error;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
var digitalOceanTarget = async (options) => {
|
|
383
|
+
const client = resolveClient(options);
|
|
384
|
+
const hooks = {
|
|
385
|
+
create: async () => {
|
|
386
|
+
const created = await client.request("POST", "/droplets", {
|
|
387
|
+
name: options.name,
|
|
388
|
+
region: options.region,
|
|
389
|
+
size: options.size,
|
|
390
|
+
image: options.image,
|
|
391
|
+
ssh_keys: [...options.sshKeys],
|
|
392
|
+
...options.tags !== undefined ? { tags: [...options.tags] } : {},
|
|
393
|
+
...options.userData !== undefined ? { user_data: options.userData } : {},
|
|
394
|
+
...options.vpcUuid !== undefined ? { vpc_uuid: options.vpcUuid } : {},
|
|
395
|
+
...options.ipv6 === true ? { ipv6: true } : {},
|
|
396
|
+
...options.monitoring === true ? { monitoring: true } : {}
|
|
397
|
+
});
|
|
398
|
+
return created.droplet;
|
|
399
|
+
},
|
|
400
|
+
destroy: (id) => destroyDigitalOceanDroplet({ client, id }),
|
|
401
|
+
fetch: async (id) => {
|
|
402
|
+
const refreshed = await client.request("GET", `/droplets/${id}`);
|
|
403
|
+
return refreshed.droplet;
|
|
404
|
+
},
|
|
405
|
+
findByName: (name) => findDigitalOceanDroplet(client, name),
|
|
406
|
+
getId: (droplet) => droplet.id,
|
|
407
|
+
getIpv4: publicIpv4,
|
|
408
|
+
getStatus: (droplet) => droplet.status,
|
|
409
|
+
isReady: (droplet) => droplet.status === "active"
|
|
410
|
+
};
|
|
411
|
+
const result = await createCloudTarget(hooks, {
|
|
412
|
+
describeTarget: (sshDescription) => `digitalocean droplet "${options.name}" (${sshDescription})`,
|
|
413
|
+
entityWord: "droplet",
|
|
414
|
+
logPrefix: "[do]",
|
|
415
|
+
name: options.name,
|
|
416
|
+
region: options.region,
|
|
417
|
+
...options.user !== undefined ? { user: options.user } : {},
|
|
418
|
+
...options.identity !== undefined ? { identity: options.identity } : {},
|
|
419
|
+
...options.port !== undefined ? { port: options.port } : {},
|
|
420
|
+
...options.provisionTimeoutMs !== undefined ? { provisionTimeoutMs: options.provisionTimeoutMs } : {},
|
|
421
|
+
...options.sshReadinessTimeoutMs !== undefined ? { sshReadinessTimeoutMs: options.sshReadinessTimeoutMs } : {},
|
|
422
|
+
...options.pollIntervalMs !== undefined ? { pollIntervalMs: options.pollIntervalMs } : {},
|
|
423
|
+
...options.onLog !== undefined ? { onLog: options.onLog } : {},
|
|
424
|
+
...options.probeSsh !== undefined ? { probeSsh: options.probeSsh } : {},
|
|
425
|
+
...options.sleep !== undefined ? { sleep: options.sleep } : {},
|
|
426
|
+
...options.now !== undefined ? { now: options.now } : {}
|
|
427
|
+
});
|
|
428
|
+
return {
|
|
429
|
+
description: result.description,
|
|
430
|
+
destroy: result.destroy,
|
|
431
|
+
dropletId: result.id,
|
|
432
|
+
exec: result.exec,
|
|
433
|
+
ipv4: result.ipv4,
|
|
434
|
+
upload: result.upload,
|
|
435
|
+
...result.close !== undefined ? { close: result.close } : {}
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// src/digitaloceanInfrastructure.ts
|
|
440
|
+
var resolveClient2 = (options) => {
|
|
441
|
+
if (options.client)
|
|
442
|
+
return options.client;
|
|
443
|
+
if (options.token)
|
|
444
|
+
return createDigitalOceanClient(options.token);
|
|
445
|
+
throw new Error("[deploy/digitalocean] either `token` or `client` must be provided");
|
|
446
|
+
};
|
|
447
|
+
var address = (droplet, type) => droplet.networks.v4.find((network) => network.type === type)?.ip_address;
|
|
448
|
+
var stateFor = (status) => {
|
|
449
|
+
if (status === "active")
|
|
450
|
+
return "ready";
|
|
451
|
+
if (status === "new")
|
|
452
|
+
return "pending";
|
|
453
|
+
return "terminated";
|
|
454
|
+
};
|
|
455
|
+
var parseNodeId = (id) => {
|
|
456
|
+
const match = /^digitalocean:([1-9][0-9]*)$/.exec(id);
|
|
457
|
+
if (!match?.[1])
|
|
458
|
+
throw new Error("[deploy/digitalocean] invalid infrastructure node id");
|
|
459
|
+
return Number(match[1]);
|
|
460
|
+
};
|
|
461
|
+
var createDigitalOceanInfrastructureProvider = (options) => {
|
|
462
|
+
if (options.regions.length === 0)
|
|
463
|
+
throw new Error("[deploy/digitalocean] at least one fleet region is required");
|
|
464
|
+
if (!options.tag)
|
|
465
|
+
throw new Error("[deploy/digitalocean] a fleet tag is required");
|
|
466
|
+
const client = resolveClient2(options);
|
|
467
|
+
const configuredRegions = new Map(options.regions.map((region) => [region.region, region]));
|
|
468
|
+
const normalize = (droplet) => {
|
|
469
|
+
const publicIpv42 = address(droplet, "public");
|
|
470
|
+
const privateIpv4 = address(droplet, "private");
|
|
471
|
+
const agentHost = options.agent?.preferPrivateNetwork ? privateIpv4 ?? publicIpv42 : publicIpv42 ?? privateIpv4;
|
|
472
|
+
return {
|
|
473
|
+
id: `digitalocean:${droplet.id}`,
|
|
474
|
+
label: droplet.name,
|
|
475
|
+
provider: "digitalocean",
|
|
476
|
+
region: droplet.region?.slug ?? "unknown",
|
|
477
|
+
state: stateFor(droplet.status),
|
|
478
|
+
...publicIpv42 ? { publicIpv4: publicIpv42 } : {},
|
|
479
|
+
...privateIpv4 ? { privateIpv4 } : {},
|
|
480
|
+
...options.agent && agentHost ? {
|
|
481
|
+
agent: {
|
|
482
|
+
url: `${options.agent.protocol ?? "http"}://${agentHost}:${options.agent.port ?? 8081}/`,
|
|
483
|
+
...options.agent.audience ? { audience: options.agent.audience } : {}
|
|
484
|
+
}
|
|
485
|
+
} : {}
|
|
486
|
+
};
|
|
487
|
+
};
|
|
488
|
+
const list = () => listDigitalOceanDroplets({ client, tag: options.tag });
|
|
489
|
+
return {
|
|
490
|
+
capabilities: {
|
|
491
|
+
cloudInit: true,
|
|
492
|
+
idempotentProvisioning: true,
|
|
493
|
+
privateNetworking: true,
|
|
494
|
+
regionalPlacement: true,
|
|
495
|
+
regions: [...configuredRegions.keys()]
|
|
496
|
+
},
|
|
497
|
+
getNode: async (id) => {
|
|
498
|
+
const result = await client.request("GET", `/droplets/${parseNodeId(id)}`);
|
|
499
|
+
return normalize(result.droplet);
|
|
500
|
+
},
|
|
501
|
+
listNodes: async () => (await list()).map(normalize),
|
|
502
|
+
name: "digitalocean",
|
|
503
|
+
provisionNode: async (input) => {
|
|
504
|
+
const existing = await findDigitalOceanDroplet(client, input.name);
|
|
505
|
+
if (existing)
|
|
506
|
+
return normalize(existing);
|
|
507
|
+
const droplets = await list();
|
|
508
|
+
const eligible = input.region ? options.regions.filter((region2) => region2.region === input.region) : [...options.regions];
|
|
509
|
+
if (eligible.length === 0)
|
|
510
|
+
throw new Error(`[deploy/digitalocean] region ${input.region} is not configured`);
|
|
511
|
+
const counts = new Map(eligible.map((region2) => [region2.region, 0]));
|
|
512
|
+
for (const droplet of droplets) {
|
|
513
|
+
const region2 = droplet.region?.slug;
|
|
514
|
+
if (region2 && counts.has(region2))
|
|
515
|
+
counts.set(region2, (counts.get(region2) ?? 0) + 1);
|
|
516
|
+
}
|
|
517
|
+
const regionName = [...counts].sort((left, right) => left[1] - right[1] || left[0].localeCompare(right[0]))[0]?.[0];
|
|
518
|
+
const region = regionName ? configuredRegions.get(regionName) : undefined;
|
|
519
|
+
if (!region)
|
|
520
|
+
throw new Error("[deploy/digitalocean] no configured fleet region is available");
|
|
521
|
+
const result = await client.request("POST", "/droplets", {
|
|
522
|
+
image: region.image,
|
|
523
|
+
name: input.name,
|
|
524
|
+
region: region.region,
|
|
525
|
+
size: region.size,
|
|
526
|
+
ssh_keys: [...region.sshKeys],
|
|
527
|
+
tags: [options.tag],
|
|
528
|
+
...region.userData ? { user_data: region.userData } : {},
|
|
529
|
+
...region.vpcUuid ? { vpc_uuid: region.vpcUuid } : {},
|
|
530
|
+
...region.ipv6 ? { ipv6: true } : {},
|
|
531
|
+
...region.monitoring ? { monitoring: true } : {}
|
|
532
|
+
});
|
|
533
|
+
return normalize(result.droplet);
|
|
534
|
+
},
|
|
535
|
+
terminateNode: async (id) => destroyDigitalOceanDroplet({ client, id: parseNodeId(id) })
|
|
536
|
+
};
|
|
537
|
+
};
|
|
538
|
+
export {
|
|
539
|
+
createDigitalOceanInfrastructureProvider
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
//# debugId=9C7FA211BB249E1164756E2164756E21
|
|
543
|
+
//# sourceMappingURL=digitaloceanInfrastructure.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/targets.ts", "../src/cloudTarget.ts", "../src/digitalocean.ts", "../src/digitaloceanInfrastructure.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, Id = number> = {\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: Id) => Promise<Server>;\n\t/** Destroy a server by id. 404 should be treated as idempotent success. */\n\tdestroy: (id: Id) => Promise<void>;\n\t/** True when the server has reached its terminal \"running\" status. */\n\tisReady: (server: Server) => boolean;\n\t/** Extract the provider-assigned id (number for DO/Hetzner/Linode, string for Vultr). */\n\tgetId: (server: Server) => Id;\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<Id = number> = {\n\tid: Id;\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, Id = number>(\n\thooks: CloudTargetHooks<Server, Id>,\n\toptions: CloudTargetOptions\n): Promise<CloudTargetResult<Id>> => {\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' | 'PUT' | 'PATCH' | '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' | 'PUT' | 'PATCH' | '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",
|
|
8
|
+
"/** Fleet lifecycle adapter built on the canonical DigitalOcean client. */\nimport {\n createDigitalOceanClient,\n destroyDigitalOceanDroplet,\n findDigitalOceanDroplet,\n listDigitalOceanDroplets,\n type DigitalOceanClientLike,\n type DigitalOceanDroplet,\n} from \"./digitalocean\";\nimport type {\n InfrastructureNode,\n InfrastructureNodeState,\n InfrastructureProvider,\n} from \"./infrastructure\";\n\nexport type DigitalOceanFleetRegion = {\n image: string | number;\n ipv6?: boolean;\n monitoring?: boolean;\n region: string;\n size: string;\n sshKeys: ReadonlyArray<string | number>;\n userData?: string;\n vpcUuid?: string;\n};\n\nexport type DigitalOceanInfrastructureProviderOptions = {\n agent?: {\n audience?: string;\n port?: number;\n preferPrivateNetwork?: boolean;\n protocol?: \"http\" | \"https\";\n };\n client?: DigitalOceanClientLike;\n regions: readonly DigitalOceanFleetRegion[];\n tag: string;\n token?: string;\n};\n\nconst resolveClient = (options: DigitalOceanInfrastructureProviderOptions) => {\n if (options.client) return options.client;\n if (options.token) return createDigitalOceanClient(options.token);\n\n throw new Error(\n \"[deploy/digitalocean] either `token` or `client` must be provided\",\n );\n};\n\nconst address = (droplet: DigitalOceanDroplet, type: \"private\" | \"public\") =>\n droplet.networks.v4.find((network) => network.type === type)?.ip_address;\n\nconst stateFor = (\n status: DigitalOceanDroplet[\"status\"],\n): InfrastructureNodeState => {\n if (status === \"active\") return \"ready\";\n if (status === \"new\") return \"pending\";\n\n return \"terminated\";\n};\n\nconst parseNodeId = (id: string) => {\n const match = /^digitalocean:([1-9][0-9]*)$/.exec(id);\n if (!match?.[1])\n throw new Error(\"[deploy/digitalocean] invalid infrastructure node id\");\n\n return Number(match[1]);\n};\n\nexport const createDigitalOceanInfrastructureProvider = (\n options: DigitalOceanInfrastructureProviderOptions,\n): InfrastructureProvider => {\n if (options.regions.length === 0)\n throw new Error(\n \"[deploy/digitalocean] at least one fleet region is required\",\n );\n if (!options.tag)\n throw new Error(\"[deploy/digitalocean] a fleet tag is required\");\n const client = resolveClient(options);\n const configuredRegions = new Map(\n options.regions.map((region) => [region.region, region]),\n );\n\n const normalize = (droplet: DigitalOceanDroplet): InfrastructureNode => {\n const publicIpv4 = address(droplet, \"public\");\n const privateIpv4 = address(droplet, \"private\");\n const agentHost = options.agent?.preferPrivateNetwork\n ? (privateIpv4 ?? publicIpv4)\n : (publicIpv4 ?? privateIpv4);\n\n return {\n id: `digitalocean:${droplet.id}`,\n label: droplet.name,\n provider: \"digitalocean\",\n region: droplet.region?.slug ?? \"unknown\",\n state: stateFor(droplet.status),\n ...(publicIpv4 ? { publicIpv4 } : {}),\n ...(privateIpv4 ? { privateIpv4 } : {}),\n ...(options.agent && agentHost\n ? {\n agent: {\n url: `${options.agent.protocol ?? \"http\"}://${agentHost}:${options.agent.port ?? 8081}/`,\n ...(options.agent.audience\n ? { audience: options.agent.audience }\n : {}),\n },\n }\n : {}),\n };\n };\n\n const list = () =>\n listDigitalOceanDroplets({ client, tag: options.tag });\n\n return {\n capabilities: {\n cloudInit: true,\n idempotentProvisioning: true,\n privateNetworking: true,\n regionalPlacement: true,\n regions: [...configuredRegions.keys()],\n },\n getNode: async (id) => {\n const result = await client.request<{ droplet: DigitalOceanDroplet }>(\n \"GET\",\n `/droplets/${parseNodeId(id)}`,\n );\n\n return normalize(result.droplet);\n },\n listNodes: async () => (await list()).map(normalize),\n name: \"digitalocean\",\n provisionNode: async (input) => {\n const existing = await findDigitalOceanDroplet(client, input.name);\n if (existing) return normalize(existing);\n const droplets = await list();\n const eligible = input.region\n ? options.regions.filter((region) => region.region === input.region)\n : [...options.regions];\n if (eligible.length === 0)\n throw new Error(\n `[deploy/digitalocean] region ${input.region} is not configured`,\n );\n const counts = new Map(\n eligible.map((region) => [region.region, 0]),\n );\n for (const droplet of droplets) {\n const region = droplet.region?.slug;\n if (region && counts.has(region))\n counts.set(region, (counts.get(region) ?? 0) + 1);\n }\n const regionName = [...counts].sort(\n (left, right) =>\n left[1] - right[1] || left[0].localeCompare(right[0]),\n )[0]?.[0];\n const region = regionName ? configuredRegions.get(regionName) : undefined;\n if (!region)\n throw new Error(\n \"[deploy/digitalocean] no configured fleet region is available\",\n );\n const result = await client.request<{ droplet: DigitalOceanDroplet }>(\n \"POST\",\n \"/droplets\",\n {\n image: region.image,\n name: input.name,\n region: region.region,\n size: region.size,\n ssh_keys: [...region.sshKeys],\n tags: [options.tag],\n ...(region.userData ? { user_data: region.userData } : {}),\n ...(region.vpcUuid ? { vpc_uuid: region.vpcUuid } : {}),\n ...(region.ipv6 ? { ipv6: true } : {}),\n ...(region.monitoring ? { monitoring: true } : {}),\n },\n );\n\n return normalize(result.droplet);\n },\n terminateNode: async (id) =>\n destroyDigitalOceanDroplet({ client, id: parseNodeId(id) }),\n };\n};\n"
|
|
9
|
+
],
|
|
10
|
+
"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,Q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