@absolutejs/deploy 0.20.1 → 0.21.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/dist/digitaloceanEphemeralInfrastructure.d.ts +20 -0
- package/dist/digitaloceanEphemeralInfrastructure.js +610 -0
- package/dist/digitaloceanEphemeralInfrastructure.js.map +13 -0
- package/dist/ephemeralInfrastructure.d.ts +37 -0
- package/dist/ephemeralInfrastructure.js +4 -0
- package/dist/ephemeralInfrastructure.js.map +9 -0
- package/dist/index.js +7 -2
- package/dist/index.js.map +3 -3
- package/dist/releaseArtifact.js +7 -2
- package/dist/releaseArtifact.js.map +3 -3
- package/package.json +12 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type DigitalOceanClientLike } from "./digitalocean";
|
|
2
|
+
import type { EphemeralInfrastructureProvider } from "./ephemeralInfrastructure";
|
|
3
|
+
export type DigitalOceanVolume = {
|
|
4
|
+
droplet_ids: number[];
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
region: {
|
|
8
|
+
slug: string;
|
|
9
|
+
};
|
|
10
|
+
size_gigabytes: number;
|
|
11
|
+
};
|
|
12
|
+
export type DigitalOceanEphemeralInfrastructureOptions = {
|
|
13
|
+
client?: DigitalOceanClientLike;
|
|
14
|
+
cleanupPollIntervalMs?: number;
|
|
15
|
+
cleanupTimeoutMs?: number;
|
|
16
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
17
|
+
tag: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const createDigitalOceanEphemeralInfrastructureProvider: (options: DigitalOceanEphemeralInfrastructureOptions) => EphemeralInfrastructureProvider;
|
|
@@ -0,0 +1,610 @@
|
|
|
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/digitaloceanEphemeralInfrastructure.ts
|
|
440
|
+
var DEFAULT_CLEANUP_POLL_INTERVAL_MS = 2000;
|
|
441
|
+
var DEFAULT_CLEANUP_TIMEOUT_MS = 120000;
|
|
442
|
+
var MINIMUM_VOLUME_GIB = 1;
|
|
443
|
+
var SAFE_RESOURCE_NAME = /^[a-z0-9][a-z0-9-]{0,62}$/;
|
|
444
|
+
var resolveClient2 = (options) => {
|
|
445
|
+
if (options.client)
|
|
446
|
+
return options.client;
|
|
447
|
+
if (options.token)
|
|
448
|
+
return createDigitalOceanClient(options.token);
|
|
449
|
+
throw new Error("[deploy/digitalocean-ephemeral] either `token` or `client` must be provided");
|
|
450
|
+
};
|
|
451
|
+
var parseDropletId = (id) => {
|
|
452
|
+
const match = /^digitalocean:droplet:([1-9][0-9]*)$/.exec(id);
|
|
453
|
+
if (!match?.[1])
|
|
454
|
+
throw new Error("[deploy/digitalocean-ephemeral] invalid droplet id");
|
|
455
|
+
return Number(match[1]);
|
|
456
|
+
};
|
|
457
|
+
var parseVolumeId = (id) => {
|
|
458
|
+
const match = /^digitalocean:volume:([0-9a-f-]{36})$/.exec(id);
|
|
459
|
+
if (!match?.[1])
|
|
460
|
+
throw new Error("[deploy/digitalocean-ephemeral] invalid volume id");
|
|
461
|
+
return match[1];
|
|
462
|
+
};
|
|
463
|
+
var privateIpv4 = (droplet) => droplet.networks.v4.find(({ type }) => type === "private")?.ip_address;
|
|
464
|
+
var publicIpv42 = (droplet) => droplet.networks.v4.find(({ type }) => type === "public")?.ip_address;
|
|
465
|
+
var normalize = (droplet, volume) => {
|
|
466
|
+
const privateAddress = privateIpv4(droplet);
|
|
467
|
+
const publicAddress = publicIpv42(droplet);
|
|
468
|
+
return {
|
|
469
|
+
node: {
|
|
470
|
+
id: `digitalocean:droplet:${droplet.id}`,
|
|
471
|
+
label: droplet.name,
|
|
472
|
+
provider: "digitalocean",
|
|
473
|
+
region: droplet.region?.slug ?? "unknown",
|
|
474
|
+
state: droplet.status === "active" ? "ready" : droplet.status === "new" ? "pending" : "terminated",
|
|
475
|
+
...privateAddress ? { privateIpv4: privateAddress } : {},
|
|
476
|
+
...publicAddress ? { publicIpv4: publicAddress } : {}
|
|
477
|
+
},
|
|
478
|
+
volume: {
|
|
479
|
+
encryptedAtRest: true,
|
|
480
|
+
id: `digitalocean:volume:${volume.id}`,
|
|
481
|
+
label: volume.name,
|
|
482
|
+
region: volume.region.slug,
|
|
483
|
+
sizeGiB: volume.size_gigabytes
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
var findVolume = async (client, name) => {
|
|
488
|
+
const result = await client.request("GET", `/volumes?name=${encodeURIComponent(name)}`);
|
|
489
|
+
const matches = result.volumes.filter((volume) => volume.name === name);
|
|
490
|
+
if (matches.length > 1)
|
|
491
|
+
throw new Error(`[deploy/digitalocean-ephemeral] multiple volumes named "${name}"`);
|
|
492
|
+
return matches[0];
|
|
493
|
+
};
|
|
494
|
+
var absent = async (operation) => {
|
|
495
|
+
try {
|
|
496
|
+
await operation();
|
|
497
|
+
return false;
|
|
498
|
+
} catch (error) {
|
|
499
|
+
if (error instanceof DigitalOceanError && error.status === 404)
|
|
500
|
+
return true;
|
|
501
|
+
throw error;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
var validateRequest = (request) => {
|
|
505
|
+
if (!SAFE_RESOURCE_NAME.test(request.name))
|
|
506
|
+
throw new Error("[deploy/digitalocean-ephemeral] invalid resource name");
|
|
507
|
+
if (!request.idempotencyKey)
|
|
508
|
+
throw new Error("[deploy/digitalocean-ephemeral] idempotency key is required");
|
|
509
|
+
if (!request.vpcUuid)
|
|
510
|
+
throw new Error("[deploy/digitalocean-ephemeral] VPC UUID is required");
|
|
511
|
+
if (request.sshKeys.length === 0)
|
|
512
|
+
throw new Error("[deploy/digitalocean-ephemeral] at least one SSH key is required");
|
|
513
|
+
if (!Number.isSafeInteger(request.volumeGiB) || request.volumeGiB < MINIMUM_VOLUME_GIB)
|
|
514
|
+
throw new Error("[deploy/digitalocean-ephemeral] invalid volume size");
|
|
515
|
+
};
|
|
516
|
+
var createDigitalOceanEphemeralInfrastructureProvider = (options) => {
|
|
517
|
+
if (!options.tag)
|
|
518
|
+
throw new Error("[deploy/digitalocean-ephemeral] a resource tag is required");
|
|
519
|
+
const client = resolveClient2(options);
|
|
520
|
+
const sleep = options.sleep ?? ((milliseconds) => Bun.sleep(milliseconds));
|
|
521
|
+
const pollIntervalMs = options.cleanupPollIntervalMs ?? DEFAULT_CLEANUP_POLL_INTERVAL_MS;
|
|
522
|
+
const cleanupTimeoutMs = options.cleanupTimeoutMs ?? DEFAULT_CLEANUP_TIMEOUT_MS;
|
|
523
|
+
const inspectAbsence = async (resources) => {
|
|
524
|
+
const dropletId = parseDropletId(resources.node.id);
|
|
525
|
+
const volumeId = parseVolumeId(resources.volume.id);
|
|
526
|
+
const [dropletAbsent, volumeAbsent] = await Promise.all([
|
|
527
|
+
absent(() => client.request("GET", `/droplets/${dropletId}`)),
|
|
528
|
+
absent(() => client.request("GET", `/volumes/${volumeId}`))
|
|
529
|
+
]);
|
|
530
|
+
return { dropletAbsent, volumeAbsent };
|
|
531
|
+
};
|
|
532
|
+
const waitUntil = async (predicate, label) => {
|
|
533
|
+
const deadline = Date.now() + cleanupTimeoutMs;
|
|
534
|
+
while (!await predicate()) {
|
|
535
|
+
if (Date.now() >= deadline)
|
|
536
|
+
throw new Error(`[deploy/digitalocean-ephemeral] timed out waiting for ${label}`);
|
|
537
|
+
await sleep(pollIntervalMs);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
return {
|
|
541
|
+
cleanup: async (resources) => {
|
|
542
|
+
const dropletId = parseDropletId(resources.node.id);
|
|
543
|
+
const volumeId = parseVolumeId(resources.volume.id);
|
|
544
|
+
if (!(await inspectAbsence(resources)).dropletAbsent)
|
|
545
|
+
await client.request("DELETE", `/droplets/${dropletId}`);
|
|
546
|
+
await waitUntil(async () => (await inspectAbsence(resources)).dropletAbsent, "droplet deletion");
|
|
547
|
+
if (!(await inspectAbsence(resources)).volumeAbsent)
|
|
548
|
+
await client.request("DELETE", `/volumes/${volumeId}`);
|
|
549
|
+
await waitUntil(async () => (await inspectAbsence(resources)).volumeAbsent, "volume deletion");
|
|
550
|
+
return inspectAbsence(resources);
|
|
551
|
+
},
|
|
552
|
+
inspectAbsence,
|
|
553
|
+
name: "digitalocean",
|
|
554
|
+
provision: async (request) => {
|
|
555
|
+
validateRequest(request);
|
|
556
|
+
const volumeName = `${request.name}-checkpoint`;
|
|
557
|
+
let volume = await findVolume(client, volumeName);
|
|
558
|
+
const createdVolume = !volume;
|
|
559
|
+
if (!volume) {
|
|
560
|
+
const result = await client.request("POST", "/volumes", {
|
|
561
|
+
description: `Ephemeral ${request.name} checkpoint volume`,
|
|
562
|
+
filesystem_label: "criu-checkpoint",
|
|
563
|
+
filesystem_type: "ext4",
|
|
564
|
+
name: volumeName,
|
|
565
|
+
region: request.region,
|
|
566
|
+
size_gigabytes: request.volumeGiB,
|
|
567
|
+
tags: [options.tag]
|
|
568
|
+
});
|
|
569
|
+
volume = result.volume;
|
|
570
|
+
}
|
|
571
|
+
if (volume.region.slug !== request.region || volume.size_gigabytes !== request.volumeGiB)
|
|
572
|
+
throw new Error("[deploy/digitalocean-ephemeral] existing volume does not match the requested topology");
|
|
573
|
+
try {
|
|
574
|
+
let droplet = await findDigitalOceanDroplet(client, request.name);
|
|
575
|
+
if (!droplet) {
|
|
576
|
+
const result = await client.request("POST", "/droplets", {
|
|
577
|
+
backups: false,
|
|
578
|
+
image: request.image,
|
|
579
|
+
ipv6: false,
|
|
580
|
+
monitoring: true,
|
|
581
|
+
name: request.name,
|
|
582
|
+
region: request.region,
|
|
583
|
+
size: request.size,
|
|
584
|
+
ssh_keys: [...request.sshKeys],
|
|
585
|
+
tags: [options.tag],
|
|
586
|
+
user_data: request.userData,
|
|
587
|
+
volumes: [volume.id],
|
|
588
|
+
vpc_uuid: request.vpcUuid
|
|
589
|
+
});
|
|
590
|
+
droplet = result.droplet;
|
|
591
|
+
}
|
|
592
|
+
if (droplet.region?.slug !== request.region || droplet.size_slug && droplet.size_slug !== request.size)
|
|
593
|
+
throw new Error("[deploy/digitalocean-ephemeral] existing droplet does not match the requested topology");
|
|
594
|
+
if (volume.droplet_ids.length > 0 && !volume.droplet_ids.includes(droplet.id))
|
|
595
|
+
throw new Error("[deploy/digitalocean-ephemeral] checkpoint volume is attached to another droplet");
|
|
596
|
+
return normalize(droplet, volume);
|
|
597
|
+
} catch (error) {
|
|
598
|
+
if (createdVolume)
|
|
599
|
+
await client.request("DELETE", `/volumes/${volume.id}`);
|
|
600
|
+
throw error;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
export {
|
|
606
|
+
createDigitalOceanEphemeralInfrastructureProvider
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
//# debugId=B8BFAC3CF04D69D764756E2164756E21
|
|
610
|
+
//# sourceMappingURL=digitaloceanEphemeralInfrastructure.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/targets.ts", "../src/cloudTarget.ts", "../src/digitalocean.ts", "../src/digitaloceanEphemeralInfrastructure.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
|
+
"import {\n createDigitalOceanClient,\n DigitalOceanError,\n findDigitalOceanDroplet,\n type DigitalOceanClientLike,\n type DigitalOceanDroplet,\n} from \"./digitalocean\";\nimport type {\n EphemeralInfrastructureAbsence,\n EphemeralInfrastructureProvider,\n EphemeralInfrastructureResources,\n ProvisionEphemeralInfrastructure,\n} from \"./ephemeralInfrastructure\";\n\nexport type DigitalOceanVolume = {\n droplet_ids: number[];\n id: string;\n name: string;\n region: { slug: string };\n size_gigabytes: number;\n};\n\nexport type DigitalOceanEphemeralInfrastructureOptions = {\n client?: DigitalOceanClientLike;\n cleanupPollIntervalMs?: number;\n cleanupTimeoutMs?: number;\n sleep?: (milliseconds: number) => Promise<void>;\n tag: string;\n token?: string;\n};\n\nconst DEFAULT_CLEANUP_POLL_INTERVAL_MS = 2_000;\nconst DEFAULT_CLEANUP_TIMEOUT_MS = 120_000;\nconst MINIMUM_VOLUME_GIB = 1;\nconst SAFE_RESOURCE_NAME = /^[a-z0-9][a-z0-9-]{0,62}$/;\n\nconst resolveClient = (options: DigitalOceanEphemeralInfrastructureOptions) => {\n if (options.client) return options.client;\n if (options.token) return createDigitalOceanClient(options.token);\n\n throw new Error(\n \"[deploy/digitalocean-ephemeral] either `token` or `client` must be provided\",\n );\n};\n\nconst parseDropletId = (id: string) => {\n const match = /^digitalocean:droplet:([1-9][0-9]*)$/.exec(id);\n if (!match?.[1])\n throw new Error(\"[deploy/digitalocean-ephemeral] invalid droplet id\");\n\n return Number(match[1]);\n};\n\nconst parseVolumeId = (id: string) => {\n const match = /^digitalocean:volume:([0-9a-f-]{36})$/.exec(id);\n if (!match?.[1])\n throw new Error(\"[deploy/digitalocean-ephemeral] invalid volume id\");\n\n return match[1];\n};\n\nconst privateIpv4 = (droplet: DigitalOceanDroplet) =>\n droplet.networks.v4.find(({ type }) => type === \"private\")?.ip_address;\n\nconst publicIpv4 = (droplet: DigitalOceanDroplet) =>\n droplet.networks.v4.find(({ type }) => type === \"public\")?.ip_address;\n\nconst normalize = (\n droplet: DigitalOceanDroplet,\n volume: DigitalOceanVolume,\n): EphemeralInfrastructureResources => {\n const privateAddress = privateIpv4(droplet);\n const publicAddress = publicIpv4(droplet);\n\n return {\n node: {\n id: `digitalocean:droplet:${droplet.id}`,\n label: droplet.name,\n provider: \"digitalocean\",\n region: droplet.region?.slug ?? \"unknown\",\n state:\n droplet.status === \"active\"\n ? \"ready\"\n : droplet.status === \"new\"\n ? \"pending\"\n : \"terminated\",\n ...(privateAddress ? { privateIpv4: privateAddress } : {}),\n ...(publicAddress ? { publicIpv4: publicAddress } : {}),\n },\n volume: {\n encryptedAtRest: true,\n id: `digitalocean:volume:${volume.id}`,\n label: volume.name,\n region: volume.region.slug,\n sizeGiB: volume.size_gigabytes,\n },\n };\n};\n\nconst findVolume = async (client: DigitalOceanClientLike, name: string) => {\n const result = await client.request<{ volumes: DigitalOceanVolume[] }>(\n \"GET\",\n `/volumes?name=${encodeURIComponent(name)}`,\n );\n const matches = result.volumes.filter((volume) => volume.name === name);\n if (matches.length > 1)\n throw new Error(\n `[deploy/digitalocean-ephemeral] multiple volumes named \"${name}\"`,\n );\n\n return matches[0];\n};\n\nconst absent = async (operation: () => Promise<unknown>): Promise<boolean> => {\n try {\n await operation();\n return false;\n } catch (error) {\n if (error instanceof DigitalOceanError && error.status === 404) return true;\n throw error;\n }\n};\n\nconst validateRequest = (request: ProvisionEphemeralInfrastructure) => {\n if (!SAFE_RESOURCE_NAME.test(request.name))\n throw new Error(\"[deploy/digitalocean-ephemeral] invalid resource name\");\n if (!request.idempotencyKey)\n throw new Error(\n \"[deploy/digitalocean-ephemeral] idempotency key is required\",\n );\n if (!request.vpcUuid)\n throw new Error(\"[deploy/digitalocean-ephemeral] VPC UUID is required\");\n if (request.sshKeys.length === 0)\n throw new Error(\n \"[deploy/digitalocean-ephemeral] at least one SSH key is required\",\n );\n if (\n !Number.isSafeInteger(request.volumeGiB) ||\n request.volumeGiB < MINIMUM_VOLUME_GIB\n )\n throw new Error(\"[deploy/digitalocean-ephemeral] invalid volume size\");\n};\n\nexport const createDigitalOceanEphemeralInfrastructureProvider = (\n options: DigitalOceanEphemeralInfrastructureOptions,\n): EphemeralInfrastructureProvider => {\n if (!options.tag)\n throw new Error(\n \"[deploy/digitalocean-ephemeral] a resource tag is required\",\n );\n const client = resolveClient(options);\n const sleep = options.sleep ?? ((milliseconds) => Bun.sleep(milliseconds));\n const pollIntervalMs =\n options.cleanupPollIntervalMs ?? DEFAULT_CLEANUP_POLL_INTERVAL_MS;\n const cleanupTimeoutMs =\n options.cleanupTimeoutMs ?? DEFAULT_CLEANUP_TIMEOUT_MS;\n\n const inspectAbsence = async (\n resources: EphemeralInfrastructureResources,\n ): Promise<EphemeralInfrastructureAbsence> => {\n const dropletId = parseDropletId(resources.node.id);\n const volumeId = parseVolumeId(resources.volume.id);\n const [dropletAbsent, volumeAbsent] = await Promise.all([\n absent(() => client.request(\"GET\", `/droplets/${dropletId}`)),\n absent(() => client.request(\"GET\", `/volumes/${volumeId}`)),\n ]);\n\n return { dropletAbsent, volumeAbsent };\n };\n\n const waitUntil = async (\n predicate: () => Promise<boolean>,\n label: string,\n ) => {\n const deadline = Date.now() + cleanupTimeoutMs;\n while (!(await predicate())) {\n if (Date.now() >= deadline)\n throw new Error(\n `[deploy/digitalocean-ephemeral] timed out waiting for ${label}`,\n );\n await sleep(pollIntervalMs);\n }\n };\n\n return {\n cleanup: async (resources) => {\n const dropletId = parseDropletId(resources.node.id);\n const volumeId = parseVolumeId(resources.volume.id);\n if (!(await inspectAbsence(resources)).dropletAbsent)\n await client.request(\"DELETE\", `/droplets/${dropletId}`);\n await waitUntil(\n async () => (await inspectAbsence(resources)).dropletAbsent,\n \"droplet deletion\",\n );\n if (!(await inspectAbsence(resources)).volumeAbsent)\n await client.request(\"DELETE\", `/volumes/${volumeId}`);\n await waitUntil(\n async () => (await inspectAbsence(resources)).volumeAbsent,\n \"volume deletion\",\n );\n\n return inspectAbsence(resources);\n },\n inspectAbsence,\n name: \"digitalocean\",\n provision: async (request) => {\n validateRequest(request);\n const volumeName = `${request.name}-checkpoint`;\n let volume = await findVolume(client, volumeName);\n const createdVolume = !volume;\n if (!volume) {\n const result = await client.request<{ volume: DigitalOceanVolume }>(\n \"POST\",\n \"/volumes\",\n {\n description: `Ephemeral ${request.name} checkpoint volume`,\n filesystem_label: \"criu-checkpoint\",\n filesystem_type: \"ext4\",\n name: volumeName,\n region: request.region,\n size_gigabytes: request.volumeGiB,\n tags: [options.tag],\n },\n );\n volume = result.volume;\n }\n if (\n volume.region.slug !== request.region ||\n volume.size_gigabytes !== request.volumeGiB\n )\n throw new Error(\n \"[deploy/digitalocean-ephemeral] existing volume does not match the requested topology\",\n );\n\n try {\n let droplet = await findDigitalOceanDroplet(client, request.name);\n if (!droplet) {\n const result = await client.request<{ droplet: DigitalOceanDroplet }>(\n \"POST\",\n \"/droplets\",\n {\n backups: false,\n image: request.image,\n ipv6: false,\n monitoring: true,\n name: request.name,\n region: request.region,\n size: request.size,\n ssh_keys: [...request.sshKeys],\n tags: [options.tag],\n user_data: request.userData,\n volumes: [volume.id],\n vpc_uuid: request.vpcUuid,\n },\n );\n droplet = result.droplet;\n }\n if (\n droplet.region?.slug !== request.region ||\n (droplet.size_slug && droplet.size_slug !== request.size)\n )\n throw new Error(\n \"[deploy/digitalocean-ephemeral] existing droplet does not match the requested topology\",\n );\n if (\n volume.droplet_ids.length > 0 &&\n !volume.droplet_ids.includes(droplet.id)\n )\n throw new Error(\n \"[deploy/digitalocean-ephemeral] checkpoint volume is attached to another droplet\",\n );\n\n return normalize(droplet, volume);\n } catch (error) {\n if (createdVolume)\n await client.request(\"DELETE\", `/volumes/${volume.id}`);\n throw error;\n }\n },\n };\n};\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";;;;;;;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AAAA,QACA,IACE,QAAQ,QAAQ,SAAS,QAAQ,UAChC,QAAQ,aAAa,QAAQ,cAAc,QAAQ;AAAA,UAEpD,MAAM,IAAI,MACR,wFACF;AAAA,QACF,IACE,OAAO,YAAY,SAAS,KAC5B,CAAC,OAAO,YAAY,SAAS,QAAQ,EAAE;AAAA,UAEvC,MAAM,IAAI,MACR,kFACF;AAAA,QAEF,OAAO,UAAU,SAAS,MAAM;AAAA,QAChC,OAAO,OAAO;AAAA,QACd,IAAI;AAAA,UACF,MAAM,OAAO,QAAQ,UAAU,YAAY,OAAO,IAAI;AAAA,QACxD,MAAM;AAAA;AAAA;AAAA,EAGZ;AAAA;",
|
|
11
|
+
"debugId": "B8BFAC3CF04D69D764756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { InfrastructureNode } from "./infrastructure";
|
|
2
|
+
/** A short-lived compute and storage allocation with independently observable cleanup. */
|
|
3
|
+
export type EphemeralInfrastructureResources = {
|
|
4
|
+
node: InfrastructureNode;
|
|
5
|
+
volume: {
|
|
6
|
+
encryptedAtRest: true;
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
region: string;
|
|
10
|
+
sizeGiB: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type ProvisionEphemeralInfrastructure = {
|
|
14
|
+
idempotencyKey: string;
|
|
15
|
+
image: string | number;
|
|
16
|
+
name: string;
|
|
17
|
+
region: string;
|
|
18
|
+
size: string;
|
|
19
|
+
sshKeys: ReadonlyArray<string | number>;
|
|
20
|
+
userData: string;
|
|
21
|
+
volumeGiB: number;
|
|
22
|
+
vpcUuid: string;
|
|
23
|
+
};
|
|
24
|
+
export type EphemeralInfrastructureAbsence = {
|
|
25
|
+
dropletAbsent: boolean;
|
|
26
|
+
volumeAbsent: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Provider-owned lifecycle for isolated experiments. It deliberately contains
|
|
30
|
+
* no remote-command primitive: the provisioned image decides what can run.
|
|
31
|
+
*/
|
|
32
|
+
export type EphemeralInfrastructureProvider = {
|
|
33
|
+
cleanup: (resources: EphemeralInfrastructureResources) => Promise<EphemeralInfrastructureAbsence>;
|
|
34
|
+
inspectAbsence: (resources: EphemeralInfrastructureResources) => Promise<EphemeralInfrastructureAbsence>;
|
|
35
|
+
name: string;
|
|
36
|
+
provision: (request: ProvisionEphemeralInfrastructure) => Promise<EphemeralInfrastructureResources>;
|
|
37
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -112,9 +112,13 @@ var receiveReleaseArtifact = async (options) => {
|
|
|
112
112
|
await mkdir(path.dirname(options.destination), { recursive: true });
|
|
113
113
|
const writer = Bun.file(options.destination).writer();
|
|
114
114
|
const hasher = new Bun.CryptoHasher("sha256");
|
|
115
|
+
const reader = options.stream.getReader();
|
|
115
116
|
let bytes = 0;
|
|
116
117
|
try {
|
|
117
|
-
|
|
118
|
+
while (true) {
|
|
119
|
+
const { done, value: chunk } = await reader.read();
|
|
120
|
+
if (done)
|
|
121
|
+
break;
|
|
118
122
|
bytes += chunk.byteLength;
|
|
119
123
|
if (bytes > options.expectedBytes || bytes > maxBytes)
|
|
120
124
|
throw new ReleaseArtifactError("Release artifact exceeds its declared size");
|
|
@@ -125,6 +129,7 @@ var receiveReleaseArtifact = async (options) => {
|
|
|
125
129
|
await rm(options.destination, { force: true });
|
|
126
130
|
throw error;
|
|
127
131
|
} finally {
|
|
132
|
+
reader.releaseLock();
|
|
128
133
|
await writer.end();
|
|
129
134
|
}
|
|
130
135
|
if (bytes !== options.expectedBytes || hasher.digest("hex") !== options.expectedSha256) {
|
|
@@ -861,5 +866,5 @@ export {
|
|
|
861
866
|
EdgeIngressValidationError
|
|
862
867
|
};
|
|
863
868
|
|
|
864
|
-
//# debugId=
|
|
869
|
+
//# debugId=BC2DAC4B8EA4FAB664756E2164756E21
|
|
865
870
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/releaseArtifact.ts", "../src/edgeIngress.ts", "../src/targets.ts", "../src/processManagers.ts", "../src/deployer.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { mkdir, mkdtemp, rm, stat } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\n\nconst DEFAULT_MAX_BYTES = 2_147_483_648;\nconst ERROR_DETAIL_LIMIT = 500;\nconst SAFE_RELEASE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\n\nexport type ReleaseArtifactMetadata = {\n bytes: number;\n releaseId: string;\n sha256: string;\n};\n\nexport type CreatedReleaseArtifact = {\n dispose: () => Promise<void>;\n file: Bun.BunFile;\n metadata: ReleaseArtifactMetadata;\n path: string;\n};\n\nexport class ReleaseArtifactError extends Error {}\n\nconst run = async (command: string[]) => {\n const process = Bun.spawn(command, { stderr: \"pipe\", stdout: \"pipe\" });\n const [exitCode, stderr, stdout] = await Promise.all([\n process.exited,\n new Response(process.stderr).text(),\n new Response(process.stdout).text(),\n ]);\n if (exitCode !== 0)\n throw new ReleaseArtifactError(\n `${command[0]} failed (${exitCode}): ${stderr.slice(0, ERROR_DETAIL_LIMIT)}`,\n );\n\n return stdout;\n};\n\nconst assertReleaseId = (value: string) => {\n if (!SAFE_RELEASE_ID.test(value))\n throw new ReleaseArtifactError(\"Release id is invalid\");\n\n return value;\n};\n\nconst assertExclude = (value: string) => {\n if (\n value.length === 0 ||\n value.startsWith(\"-\") ||\n value.startsWith(\"/\") ||\n value.split(\"/\").some((part) => part === \"..\") ||\n /[\\0\\r\\n]/.test(value)\n )\n throw new ReleaseArtifactError(`Invalid release exclusion: ${value}`);\n\n return value.replace(/^\\.\\//, \"\");\n};\n\nconst sha256File = async (file: Blob) => {\n const hasher = new Bun.CryptoHasher(\"sha256\");\n for await (const chunk of file.stream()) hasher.update(chunk);\n\n return hasher.digest(\"hex\");\n};\n\nexport const createReleaseArtifact = async (options: {\n exclude?: string[];\n releaseId?: string;\n sourceRoot: string;\n temporaryRoot?: string;\n}): Promise<CreatedReleaseArtifact> => {\n const releaseId = assertReleaseId(options.releaseId ?? crypto.randomUUID());\n const source = path.resolve(options.sourceRoot);\n const sourceStats = await stat(source).catch(() => null);\n if (!sourceStats?.isDirectory())\n throw new ReleaseArtifactError(\"Release source root is not a directory\");\n if (!(await Bun.file(path.join(source, \"package.json\")).exists()))\n throw new ReleaseArtifactError(\"Release source has no package.json\");\n const temporary = await mkdtemp(\n path.join(options.temporaryRoot ?? tmpdir(), \"absolutejs-release-\"),\n );\n const archivePath = path.join(temporary, `${releaseId}.tgz`);\n try {\n await run([\n \"tar\",\n \"-czf\",\n archivePath,\n ...(options.exclude ?? []).map(\n (value) => `--exclude=./${assertExclude(value)}`,\n ),\n \"-C\",\n source,\n \".\",\n ]);\n const file = Bun.file(archivePath);\n\n return {\n dispose: () => rm(temporary, { force: true, recursive: true }),\n file,\n metadata: {\n bytes: file.size,\n releaseId,\n sha256: await sha256File(file),\n },\n path: archivePath,\n };\n } catch (error) {\n await rm(temporary, { force: true, recursive: true });\n throw error;\n }\n};\n\nexport const receiveReleaseArtifact = async (options: {\n destination: string;\n expectedBytes: number;\n expectedSha256: string;\n maxBytes?: number;\n stream: ReadableStream<Uint8Array>;\n}) => {\n const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n if (\n !Number.isSafeInteger(options.expectedBytes) ||\n options.expectedBytes < 1 ||\n options.expectedBytes > maxBytes ||\n !/^[a-f0-9]{64}$/.test(options.expectedSha256)\n )\n throw new ReleaseArtifactError(\"Release artifact metadata is invalid\");\n await mkdir(path.dirname(options.destination), { recursive: true });\n const writer = Bun.file(options.destination).writer();\n const hasher = new Bun.CryptoHasher(\"sha256\");\n let bytes = 0;\n try {\n
|
|
5
|
+
"import { mkdir, mkdtemp, rm, stat } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\n\nconst DEFAULT_MAX_BYTES = 2_147_483_648;\nconst ERROR_DETAIL_LIMIT = 500;\nconst SAFE_RELEASE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\n\nexport type ReleaseArtifactMetadata = {\n bytes: number;\n releaseId: string;\n sha256: string;\n};\n\nexport type CreatedReleaseArtifact = {\n dispose: () => Promise<void>;\n file: Bun.BunFile;\n metadata: ReleaseArtifactMetadata;\n path: string;\n};\n\nexport class ReleaseArtifactError extends Error {}\n\nconst run = async (command: string[]) => {\n const process = Bun.spawn(command, { stderr: \"pipe\", stdout: \"pipe\" });\n const [exitCode, stderr, stdout] = await Promise.all([\n process.exited,\n new Response(process.stderr).text(),\n new Response(process.stdout).text(),\n ]);\n if (exitCode !== 0)\n throw new ReleaseArtifactError(\n `${command[0]} failed (${exitCode}): ${stderr.slice(0, ERROR_DETAIL_LIMIT)}`,\n );\n\n return stdout;\n};\n\nconst assertReleaseId = (value: string) => {\n if (!SAFE_RELEASE_ID.test(value))\n throw new ReleaseArtifactError(\"Release id is invalid\");\n\n return value;\n};\n\nconst assertExclude = (value: string) => {\n if (\n value.length === 0 ||\n value.startsWith(\"-\") ||\n value.startsWith(\"/\") ||\n value.split(\"/\").some((part) => part === \"..\") ||\n /[\\0\\r\\n]/.test(value)\n )\n throw new ReleaseArtifactError(`Invalid release exclusion: ${value}`);\n\n return value.replace(/^\\.\\//, \"\");\n};\n\nconst sha256File = async (file: Blob) => {\n const hasher = new Bun.CryptoHasher(\"sha256\");\n for await (const chunk of file.stream()) hasher.update(chunk);\n\n return hasher.digest(\"hex\");\n};\n\nexport const createReleaseArtifact = async (options: {\n exclude?: string[];\n releaseId?: string;\n sourceRoot: string;\n temporaryRoot?: string;\n}): Promise<CreatedReleaseArtifact> => {\n const releaseId = assertReleaseId(options.releaseId ?? crypto.randomUUID());\n const source = path.resolve(options.sourceRoot);\n const sourceStats = await stat(source).catch(() => null);\n if (!sourceStats?.isDirectory())\n throw new ReleaseArtifactError(\"Release source root is not a directory\");\n if (!(await Bun.file(path.join(source, \"package.json\")).exists()))\n throw new ReleaseArtifactError(\"Release source has no package.json\");\n const temporary = await mkdtemp(\n path.join(options.temporaryRoot ?? tmpdir(), \"absolutejs-release-\"),\n );\n const archivePath = path.join(temporary, `${releaseId}.tgz`);\n try {\n await run([\n \"tar\",\n \"-czf\",\n archivePath,\n ...(options.exclude ?? []).map(\n (value) => `--exclude=./${assertExclude(value)}`,\n ),\n \"-C\",\n source,\n \".\",\n ]);\n const file = Bun.file(archivePath);\n\n return {\n dispose: () => rm(temporary, { force: true, recursive: true }),\n file,\n metadata: {\n bytes: file.size,\n releaseId,\n sha256: await sha256File(file),\n },\n path: archivePath,\n };\n } catch (error) {\n await rm(temporary, { force: true, recursive: true });\n throw error;\n }\n};\n\nexport const receiveReleaseArtifact = async (options: {\n destination: string;\n expectedBytes: number;\n expectedSha256: string;\n maxBytes?: number;\n stream: ReadableStream<Uint8Array>;\n}) => {\n const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n if (\n !Number.isSafeInteger(options.expectedBytes) ||\n options.expectedBytes < 1 ||\n options.expectedBytes > maxBytes ||\n !/^[a-f0-9]{64}$/.test(options.expectedSha256)\n )\n throw new ReleaseArtifactError(\"Release artifact metadata is invalid\");\n await mkdir(path.dirname(options.destination), { recursive: true });\n const writer = Bun.file(options.destination).writer();\n const hasher = new Bun.CryptoHasher(\"sha256\");\n const reader = options.stream.getReader();\n let bytes = 0;\n try {\n while (true) {\n const { done, value: chunk } = await reader.read();\n if (done) break;\n bytes += chunk.byteLength;\n if (bytes > options.expectedBytes || bytes > maxBytes)\n throw new ReleaseArtifactError(\n \"Release artifact exceeds its declared size\",\n );\n hasher.update(chunk);\n writer.write(chunk);\n }\n } catch (error) {\n await rm(options.destination, { force: true });\n throw error;\n } finally {\n reader.releaseLock();\n await writer.end();\n }\n if (\n bytes !== options.expectedBytes ||\n hasher.digest(\"hex\") !== options.expectedSha256\n ) {\n await rm(options.destination, { force: true });\n throw new ReleaseArtifactError(\n \"Release artifact integrity verification failed\",\n );\n }\n\n return { bytes, sha256: options.expectedSha256 };\n};\n\nexport const extractReleaseArtifact = async (options: {\n archivePath: string;\n destination: string;\n}) => {\n const [names, verbose] = await Promise.all([\n run([\"tar\", \"-tzf\", options.archivePath]),\n run([\"tar\", \"-tvzf\", options.archivePath]),\n ]);\n const unsafePath = names\n .split(\"\\n\")\n .filter(Boolean)\n .some(\n (entry) =>\n entry.startsWith(\"/\") || entry.split(\"/\").some((part) => part === \"..\"),\n );\n const unsafeType = verbose\n .split(\"\\n\")\n .filter(Boolean)\n .some((entry) => entry[0] !== \"-\" && entry[0] !== \"d\");\n if (unsafePath || unsafeType)\n throw new ReleaseArtifactError(\"Release artifact contains an unsafe entry\");\n await rm(options.destination, { force: true, recursive: true });\n await mkdir(options.destination, { recursive: true });\n await run([\n \"tar\",\n \"-xzf\",\n options.archivePath,\n \"--no-same-owner\",\n \"--no-same-permissions\",\n \"-C\",\n options.destination,\n ]);\n if (\n !(await Bun.file(path.join(options.destination, \"package.json\")).exists())\n )\n throw new ReleaseArtifactError(\"Release artifact has no package.json\");\n\n return { extracted: true } as const;\n};\n",
|
|
6
6
|
"/** Provider-neutral lifecycle for a global ingress in front of regional edge pools. */\n\nexport type EdgeIngressProtocol = \"tcp\" | \"http\" | \"https\";\n\nexport type EdgeIngressBackend = {\n /** Provider-native regional pool id (for example a DO regional LB UUID or GCP group self-link). */\n resourceId: string;\n region: string;\n /** Lower values are preferred during regional failover. */\n priority?: number;\n};\n\nexport type EdgeIngressSpec = {\n backends: readonly EdgeIngressBackend[];\n healthCheck: {\n path?: string;\n port: number;\n protocol: EdgeIngressProtocol;\n };\n idempotencyKey: string;\n listener: {\n port: number;\n protocol: EdgeIngressProtocol;\n targetPort: number;\n tlsPassthrough?: boolean;\n };\n name: string;\n};\n\nexport type EdgeIngressState = \"provisioning\" | \"ready\" | \"degraded\";\n\nexport type EdgeIngress = {\n addresses: string[];\n backends: EdgeIngressBackend[];\n id: string;\n name: string;\n provider: string;\n state: EdgeIngressState;\n};\n\nexport type EdgeIngressCapabilities = {\n automaticHealthFailover: boolean;\n global: boolean;\n tlsPassthrough: boolean;\n};\n\nexport type EdgeIngressProvider = {\n capabilities: EdgeIngressCapabilities;\n getIngress: (name: string) => Promise<EdgeIngress | null>;\n name: string;\n reconcileIngress: (spec: EdgeIngressSpec) => Promise<EdgeIngress>;\n removeIngress: (name: string, idempotencyKey: string) => Promise<void>;\n};\n\nconst validPort = (port: number) =>\n Number.isInteger(port) && port >= 1 && port <= 65_535;\n\nexport class EdgeIngressValidationError extends Error {}\n\nexport const validateEdgeIngressSpec = (spec: EdgeIngressSpec) => {\n if (!/^[a-z]([-a-z0-9]*[a-z0-9])?$/.test(spec.name))\n throw new EdgeIngressValidationError(\"Invalid edge ingress name\");\n if (spec.backends.length === 0)\n throw new EdgeIngressValidationError(\n \"Edge ingress requires at least one regional backend\",\n );\n if (!validPort(spec.listener.port) || !validPort(spec.listener.targetPort))\n throw new EdgeIngressValidationError(\"Invalid edge ingress listener port\");\n if (!validPort(spec.healthCheck.port))\n throw new EdgeIngressValidationError(\"Invalid edge ingress health port\");\n const resources = new Set<string>();\n for (const backend of spec.backends) {\n if (!backend.resourceId || !backend.region)\n throw new EdgeIngressValidationError(\"Invalid edge ingress backend\");\n if (resources.has(backend.resourceId))\n throw new EdgeIngressValidationError(\"Duplicate edge ingress backend\");\n resources.add(backend.resourceId);\n }\n if (\n spec.listener.tlsPassthrough &&\n spec.listener.protocol !== \"https\" &&\n spec.listener.protocol !== \"tcp\"\n )\n throw new EdgeIngressValidationError(\n \"TLS passthrough requires an HTTPS or TCP listener\",\n );\n\n return spec;\n};\n\nexport const normalizedEdgeIngressBackends = (\n backends: readonly EdgeIngressBackend[],\n) =>\n [...backends].sort(\n (left, right) =>\n (left.priority ?? Number.MAX_SAFE_INTEGER) -\n (right.priority ?? Number.MAX_SAFE_INTEGER) ||\n left.region.localeCompare(right.region) ||\n left.resourceId.localeCompare(right.resourceId),\n );\n",
|
|
7
7
|
"/**\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",
|
|
8
8
|
"/**\n * ProcessManager — the abstraction that turns \"files are on the target\" into\n * \"the app is running.\" Two strategies ship: `bareManager` (nohup, lowest\n * dependency) and `systemdManager` (templated unit file, the way production\n * VMs should run).\n *\n * Callers can supply their own — anything that implements `start` / `stop` /\n * `reload` / `status` against a `Target` works. PM2, supervisord, runit,\n * @absolutejs/runtime all fit if someone writes the adapter.\n */\n\nimport type { Target } from './targets';\n\nexport type ProcessManagerContext = {\n\t/** Absolute path on the target to the active release dir (the symlink target). */\n\tcurrentPath: string;\n\t/** Absolute path on the target to the new release dir we just uploaded. */\n\treleasePath: string;\n\t/** Release id (timestamped). */\n\treleaseId: string;\n\t/** App name — supplied via deployer config; used for unit names, pid files, etc. */\n\tappName: string;\n\t/** Optional env to set on the process. */\n\tenv: Record<string, string>;\n\t/** Log sink for any commands the manager runs. */\n\tonLog?: (line: string, stream: 'stdout' | 'stderr') => void;\n};\n\nexport type ProcessManager = {\n\t/** Bring the new release up. Called after the `current` symlink has been swapped. */\n\treload: (target: Target, ctx: ProcessManagerContext) => Promise<void>;\n\t/** Stop the running process. */\n\tstop?: (target: Target, ctx: ProcessManagerContext) => Promise<void>;\n\t/** Return current status (best-effort; used by callers for diagnostics). */\n\tstatus?: (target: Target, ctx: ProcessManagerContext) => Promise<'running' | 'stopped' | 'unknown'>;\n};\n\n// -----------------------------------------------------------------------------\n// bareManager — nohup background + pid file\n// -----------------------------------------------------------------------------\n\nexport type BareManagerOptions = {\n\t/** Command to run. Default `bun run start`. */\n\tcommand?: string;\n\t/** Log files inside the app's data dir (default: alongside pid). */\n\tlogFileBaseName?: string;\n};\n\nconst pidPath = (appName: string) => `/var/lib/${appName}/${appName}.pid`;\nconst logDir = (appName: string) => `/var/log/${appName}`;\n\nexport const bareManager = (options: BareManagerOptions = {}): ProcessManager => {\n\tconst command = options.command ?? 'bun run start';\n\tconst logBase = options.logFileBaseName ?? 'app';\n\n\tconst envPrefix = (env: Record<string, string>) =>\n\t\tObject.entries(env).map(([k, v]) => `${k}='${v.replace(/'/g, `'\\\\''`)}'`).join(' ');\n\n\tconst startCmd = (ctx: ProcessManagerContext): string => {\n\t\tconst env = envPrefix(ctx.env);\n\t\tconst pid = pidPath(ctx.appName);\n\t\tconst out = `${logDir(ctx.appName)}/${logBase}.out.log`;\n\t\tconst err = `${logDir(ctx.appName)}/${logBase}.err.log`;\n\t\treturn `\nmkdir -p $(dirname ${pid}) ${logDir(ctx.appName)} &&\ncd ${ctx.currentPath} &&\nnohup env ${env} sh -c '${command.replace(/'/g, `'\\\\''`)}' >> ${out} 2>> ${err} &\necho $! > ${pid}\n`.trim();\n\t};\n\n\tconst stopCmd = (ctx: ProcessManagerContext): string => `\nPID=$(cat ${pidPath(ctx.appName)} 2>/dev/null || true);\nif [ -n \"$PID\" ] && kill -0 \"$PID\" 2>/dev/null; then\n kill \"$PID\" 2>/dev/null || true;\n for i in 1 2 3 4 5; do\n if ! kill -0 \"$PID\" 2>/dev/null; then break; fi;\n sleep 1;\n done;\n kill -9 \"$PID\" 2>/dev/null || true;\nfi\nrm -f ${pidPath(ctx.appName)}\n`.trim();\n\n\treturn {\n\t\treload: async (target, ctx) => {\n\t\t\tconst stop = await target.exec(stopCmd(ctx), { onLog: ctx.onLog, timeoutMs: 30_000 });\n\t\t\tif (stop.exitCode !== 0) {\n\t\t\t\tthrow new Error(`bareManager.stop failed (exit ${stop.exitCode}): ${stop.stderr}`);\n\t\t\t}\n\t\t\tconst start = await target.exec(startCmd(ctx), { onLog: ctx.onLog, timeoutMs: 30_000 });\n\t\t\tif (start.exitCode !== 0) {\n\t\t\t\tthrow new Error(`bareManager.start failed (exit ${start.exitCode}): ${start.stderr}`);\n\t\t\t}\n\t\t},\n\t\tstatus: async (target, ctx) => {\n\t\t\tconst result = await target.exec(\n\t\t\t\t`PID=$(cat ${pidPath(ctx.appName)} 2>/dev/null || true); if [ -n \"$PID\" ] && kill -0 \"$PID\" 2>/dev/null; then echo running; else echo stopped; fi`,\n\t\t\t\t{ timeoutMs: 5_000 },\n\t\t\t);\n\t\t\tconst out = result.stdout.trim();\n\t\t\tif (out === 'running') return 'running';\n\t\t\tif (out === 'stopped') return 'stopped';\n\t\t\treturn 'unknown';\n\t\t},\n\t\tstop: async (target, ctx) => {\n\t\t\tconst result = await target.exec(stopCmd(ctx), { onLog: ctx.onLog, timeoutMs: 30_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`bareManager.stop failed (exit ${result.exitCode}): ${result.stderr}`);\n\t\t\t}\n\t\t},\n\t};\n};\n\n// -----------------------------------------------------------------------------\n// systemdManager — generates a unit file pointing at current/, restarts via systemctl\n// -----------------------------------------------------------------------------\n\nexport type SystemdManagerOptions = {\n\t/** Unit file name (defaults to `${appName}.service`). */\n\tunitName?: string;\n\t/** ExecStart command. Default `/usr/local/bin/bun run start`. */\n\texecStart?: string;\n\t/** User to run as. Default the deploy user. */\n\tuser?: string;\n\t/** Group. Default the deploy user. */\n\tgroup?: string;\n\t/** Restart policy. Default `always`. */\n\trestart?: 'always' | 'on-failure' | 'no';\n\t/** systemctl path. Default `systemctl`. */\n\tsystemctl?: string;\n\t/** Unit file directory. Default `/etc/systemd/system`. */\n\tunitDir?: string;\n};\n\nconst renderSystemdUnit = (\n\tctx: ProcessManagerContext,\n\toptions: SystemdManagerOptions,\n): string => {\n\tconst user = options.user ?? 'deploy';\n\tconst group = options.group ?? user;\n\tconst execStart = options.execStart ?? '/usr/local/bin/bun run start';\n\tconst restart = options.restart ?? 'always';\n\tconst envLines = Object.entries(ctx.env)\n\t\t.map(([k, v]) => `Environment=${k}=${v.replace(/\"/g, '\\\\\"')}`)\n\t\t.join('\\n');\n\treturn `[Unit]\nDescription=${ctx.appName} (managed by @absolutejs/deploy)\nAfter=network.target\n\n[Service]\nType=simple\nWorkingDirectory=${ctx.currentPath}\nExecStart=${execStart}\nRestart=${restart}\nRestartSec=2\nUser=${user}\nGroup=${group}\n${envLines}\nStandardOutput=append:/var/log/${ctx.appName}/app.out.log\nStandardError=append:/var/log/${ctx.appName}/app.err.log\n\n[Install]\nWantedBy=multi-user.target\n`;\n};\n\nexport const systemdManager = (options: SystemdManagerOptions = {}): ProcessManager => {\n\tconst systemctl = options.systemctl ?? 'systemctl';\n\tconst unitDir = options.unitDir ?? '/etc/systemd/system';\n\tconst unitName = (ctx: ProcessManagerContext) => options.unitName ?? `${ctx.appName}.service`;\n\n\treturn {\n\t\treload: async (target, ctx) => {\n\t\t\tconst unit = renderSystemdUnit(ctx, options);\n\t\t\tconst name = unitName(ctx);\n\t\t\t// Write the unit via a heredoc executed by the remote shell. tee/cat work but\n\t\t\t// stdin is the cleanest path that doesn't reveal unit text in `ps`.\n\t\t\tconst writeUnit = await target.exec(\n\t\t\t\t`mkdir -p /var/log/${ctx.appName} && cat > ${unitDir}/${name}`,\n\t\t\t\t{ onLog: ctx.onLog, stdin: unit, timeoutMs: 30_000 },\n\t\t\t);\n\t\t\tif (writeUnit.exitCode !== 0) {\n\t\t\t\tthrow new Error(`systemdManager: writing unit failed (exit ${writeUnit.exitCode}): ${writeUnit.stderr}`);\n\t\t\t}\n\t\t\tconst reload = await target.exec(`${systemctl} daemon-reload`, { onLog: ctx.onLog, timeoutMs: 15_000 });\n\t\t\tif (reload.exitCode !== 0) {\n\t\t\t\tthrow new Error(`systemdManager: daemon-reload failed (exit ${reload.exitCode}): ${reload.stderr}`);\n\t\t\t}\n\t\t\tconst enable = await target.exec(`${systemctl} enable ${name}`, { onLog: ctx.onLog, timeoutMs: 15_000 });\n\t\t\tif (enable.exitCode !== 0) {\n\t\t\t\tthrow new Error(`systemdManager: enable failed (exit ${enable.exitCode}): ${enable.stderr}`);\n\t\t\t}\n\t\t\tconst restart = await target.exec(`${systemctl} restart ${name}`, { onLog: ctx.onLog, timeoutMs: 60_000 });\n\t\t\tif (restart.exitCode !== 0) {\n\t\t\t\tthrow new Error(`systemdManager: restart failed (exit ${restart.exitCode}): ${restart.stderr}`);\n\t\t\t}\n\t\t},\n\t\tstatus: async (target, ctx) => {\n\t\t\tconst result = await target.exec(`${systemctl} is-active ${unitName(ctx)} || true`, { timeoutMs: 10_000 });\n\t\t\tconst out = result.stdout.trim();\n\t\t\tif (out === 'active') return 'running';\n\t\t\tif (out === 'inactive' || out === 'failed') return 'stopped';\n\t\t\treturn 'unknown';\n\t\t},\n\t\tstop: async (target, ctx) => {\n\t\t\tconst result = await target.exec(`${systemctl} stop ${unitName(ctx)}`, { onLog: ctx.onLog, timeoutMs: 30_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`systemdManager: stop failed (exit ${result.exitCode}): ${result.stderr}`);\n\t\t\t}\n\t\t},\n\t};\n};\n",
|
|
9
9
|
"/**\n * createDeployer — drives a step pipeline against a Target.\n *\n * The default pipeline (`defaultBunPipeline`) is the right thing for a Bun\n * project on a Linux host: prepare → upload → install → build → link →\n * restart → verify. Callers can replace steps wholesale or splice their own\n * in via `steps: [...]`.\n *\n * Release model: every `deploy()` creates a fresh timestamped directory\n * under `<root>/releases/`, uploads into it, then atomically swaps the\n * `<root>/current` symlink. `rollback(id)` re-points the symlink and\n * reloads the process manager — no re-upload, no re-build, just a fast\n * switch.\n */\n\nimport type { ProcessManager, ProcessManagerContext } from './processManagers';\nimport { bareManager } from './processManagers';\nimport type { ExecResult, Target } from './targets';\n\nexport type Source = {\n\t/** Local directory to copy. */\n\tkind: 'directory';\n\troot: string;\n\t/** Globs excluded from upload. Defaults to common dev artifacts. */\n\texclude?: string[];\n};\n\nexport type VerifySpec =\n\t| { kind: 'http'; url: string; retries?: number; intervalMs?: number; expectStatus?: number }\n\t| { kind: 'tcp'; host: string; port: number; retries?: number; intervalMs?: number }\n\t| { kind: 'custom'; check: (ctx: DeployContext) => Promise<boolean> };\n\nexport type ReleaseAnnotations = {\n\t/** Git commit SHA being deployed (40-char hex; truncated forms accepted). */\n\tcommitSha?: string;\n\t/** Git ref (e.g. `refs/heads/main`, `v1.2.3`). */\n\tref?: string;\n\t/** Commit message (or any human-readable description). */\n\tmessage?: string;\n\t/** Committer / deployer identity. */\n\tauthor?: string;\n\t/** Arbitrary tags for downstream filtering (status pages, audits). */\n\ttags?: Record<string, string>;\n};\n\nexport type DeployContext = {\n\ttarget: Target;\n\tsource: Source;\n\treleaseId: string;\n\treleasePath: string;\n\tcurrentPath: string;\n\tappName: string;\n\tenv: Record<string, string>;\n\thooks: ResolvedHooks;\n\tprocessManager: ProcessManager;\n\tverify: VerifySpec | null;\n\tannotations: ReleaseAnnotations;\n\t/** Optional cancellation signal shared with custom steps and verify hooks. */\n\tsignal?: AbortSignal;\n\t/** When `true`, steps log what they WOULD do via hooks.onLog and do not mutate the target. */\n\tdryRun: boolean;\n};\n\nexport type DeployStep = {\n\tname: string;\n\trun: (ctx: DeployContext) => Promise<void>;\n};\n\nexport type DeployHooks = {\n\tonStepStart?: (step: { name: string; releaseId: string }) => void | Promise<void>;\n\tonStepEnd?: (step: { name: string; releaseId: string; durationMs: number }) => void | Promise<void>;\n\tonLog?: (line: string, stream: 'stdout' | 'stderr', step: string) => void;\n\tonError?: (error: { step: string; releaseId: string; error: Error }) => void | Promise<void>;\n};\n\ntype ResolvedHooks = Required<{\n\t[K in keyof DeployHooks]: NonNullable<DeployHooks[K]>;\n}>;\n\nexport type DeployOptions = {\n\t/** Cancel before the next pipeline step; custom steps may observe it directly. */\n\tsignal?: AbortSignal;\n\t/** Per-release annotations stored alongside the release dir as `.deploy-meta.json`. */\n\tannotations?: ReleaseAnnotations;\n\t/**\n\t * When `true`, the deploy plan is logged but no mutation happens on the\n\t * target — steps still call `target.exec` only via `cmd === 'echo'`-style\n\t * dry-run probes. Use this from `gh actions` to verify pipeline shape\n\t * before flipping a real `current` symlink.\n\t */\n\tdryRun?: boolean;\n\t/**\n\t * Resume a previously-failed release. The deployer reads the release's\n\t * `.deploy-meta.json`, finds the step that died, and starts from there.\n\t * Steps that completed successfully are skipped. Use this when a deploy\n\t * fails on `verify` (e.g. health-check timeout) but the release is\n\t * otherwise intact on disk.\n\t */\n\tresumeReleaseId?: string;\n};\n\nexport type DeployerOptions = {\n\ttarget: Target;\n\tsource: Source;\n\t/** App name; used by ProcessManagers for unit names, pid files, log paths. Required. */\n\tappName: string;\n\t/** Where deploys live on the target. Default `/srv/<appName>`. */\n\trootPath?: string;\n\t/** Steps in order. Default: `defaultBunPipeline()`. */\n\tsteps?: DeployStep[];\n\t/** Env merged into install / build / start. */\n\tenv?: Record<string, string>;\n\t/** Process manager. Default `bareManager()`. */\n\tprocessManager?: ProcessManager;\n\t/** How to verify the deploy is up. Default null (skip verify). */\n\tverify?: VerifySpec | null;\n\thooks?: DeployHooks;\n\t/** Override `Date.now` for deterministic release ids in tests. */\n\tclock?: () => number;\n};\n\nexport type ReleaseRecord = {\n\treleaseId: string;\n\tannotations: ReleaseAnnotations;\n\tstatus: 'in-progress' | 'completed' | 'failed';\n\tfailedStep?: string;\n\tcompletedSteps: string[];\n\tstartedAt: number;\n\tendedAt?: number;\n};\n\nexport type DeployResult = {\n\treleaseId: string;\n\treleasePath: string;\n\tcurrentPath: string;\n\tdurationMs: number;\n\tsteps: { name: string; durationMs: number; skipped?: boolean }[];\n\tannotations: ReleaseAnnotations;\n};\n\nexport type Deployer = {\n\tdeploy: (options?: DeployOptions) => Promise<DeployResult>;\n\trollback: (releaseId: string) => Promise<DeployResult>;\n\t/** Stop the active release through the configured process manager. */\n\tstop: () => Promise<void>;\n\t/** Best-effort active process status from the configured process manager. */\n\tstatus: () => Promise<'running' | 'stopped' | 'unknown'>;\n\tlistReleases: () => Promise<string[]>;\n\t/** Read the deploy meta for a specific release (or null if missing). */\n\treadReleaseMeta: (releaseId: string) => Promise<ReleaseRecord | null>;\n\tprune: (options: { keep: number }) => Promise<{ removed: string[] }>;\n\tdispose: () => Promise<void>;\n};\n\nconst DEFAULT_EXCLUDES = ['node_modules', 'dist', 'build', '.git', '.DS_Store', '*.log'];\n\nconst noopHooks: ResolvedHooks = {\n\tonError: () => {},\n\tonLog: () => {},\n\tonStepEnd: () => {},\n\tonStepStart: () => {},\n};\n\nconst resolveHooks = (hooks?: DeployHooks): ResolvedHooks => ({\n\tonError: hooks?.onError ?? noopHooks.onError,\n\tonLog: hooks?.onLog ?? noopHooks.onLog,\n\tonStepEnd: hooks?.onStepEnd ?? noopHooks.onStepEnd,\n\tonStepStart: hooks?.onStepStart ?? noopHooks.onStepStart,\n});\n\nconst makeReleaseId = (clock: () => number): string => {\n\tconst t = clock();\n\tconst date = new Date(t);\n\tconst pad = (n: number, w = 2) => n.toString().padStart(w, '0');\n\treturn `${date.getUTCFullYear()}${pad(date.getUTCMonth() + 1)}${pad(date.getUTCDate())}-${pad(date.getUTCHours())}${pad(date.getUTCMinutes())}${pad(date.getUTCSeconds())}`;\n};\n\nconst requireSuccess = (label: string, result: ExecResult) => {\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(`${label} failed (exit ${result.exitCode}): ${result.stderr || result.stdout || '(no output)'}`);\n\t}\n};\n\n// -----------------------------------------------------------------------------\n// Default Bun pipeline steps\n// -----------------------------------------------------------------------------\n\nexport const defaultBunPipeline = (): DeployStep[] => [\n\t{\n\t\tname: 'prepare',\n\t\trun: async (ctx) => {\n\t\t\tconst result = await ctx.target.exec(\n\t\t\t\t`mkdir -p ${ctx.releasePath}`,\n\t\t\t\t{ onLog: (line, stream) => ctx.hooks.onLog(line, stream, 'prepare') },\n\t\t\t);\n\t\t\trequireSuccess('prepare: mkdir', result);\n\t\t},\n\t},\n\t{\n\t\tname: 'upload',\n\t\trun: async (ctx) => {\n\t\t\tif (ctx.source.kind !== 'directory') {\n\t\t\t\tthrow new Error(`Unsupported source kind: ${(ctx.source as { kind: string }).kind}`);\n\t\t\t}\n\t\t\t// Trailing slash on source = copy contents, not the dir itself.\n\t\t\tconst localPath = ctx.source.root.endsWith('/') ? ctx.source.root : `${ctx.source.root}/`;\n\t\t\tawait ctx.target.upload(localPath, ctx.releasePath, {\n\t\t\t\texclude: ctx.source.exclude ?? DEFAULT_EXCLUDES,\n\t\t\t});\n\t\t},\n\t},\n\t{\n\t\tname: 'install',\n\t\trun: async (ctx) => {\n\t\t\tconst result = await ctx.target.exec(\n\t\t\t\t`bun install --production`,\n\t\t\t\t{\n\t\t\t\t\tcwd: ctx.releasePath,\n\t\t\t\t\tenv: ctx.env,\n\t\t\t\t\tonLog: (line, stream) => ctx.hooks.onLog(line, stream, 'install'),\n\t\t\t\t\ttimeoutMs: 600_000,\n\t\t\t\t},\n\t\t\t);\n\t\t\trequireSuccess('install', result);\n\t\t},\n\t},\n\t{\n\t\tname: 'build',\n\t\trun: async (ctx) => {\n\t\t\t// Run only if the project declares a `build` script. Detect by reading package.json on the remote.\n\t\t\tconst probe = await ctx.target.exec(\n\t\t\t\t`grep -E '\"build\"\\\\s*:' package.json || true`,\n\t\t\t\t{ cwd: ctx.releasePath, timeoutMs: 10_000 },\n\t\t\t);\n\t\t\tif (!probe.stdout.includes('\"build\"')) return;\n\t\t\tconst result = await ctx.target.exec(\n\t\t\t\t`bun run build`,\n\t\t\t\t{\n\t\t\t\t\tcwd: ctx.releasePath,\n\t\t\t\t\tenv: ctx.env,\n\t\t\t\t\tonLog: (line, stream) => ctx.hooks.onLog(line, stream, 'build'),\n\t\t\t\t\ttimeoutMs: 600_000,\n\t\t\t\t},\n\t\t\t);\n\t\t\trequireSuccess('build', result);\n\t\t},\n\t},\n\t{\n\t\tname: 'link',\n\t\trun: async (ctx) => {\n\t\t\t// Atomic-ish symlink swap: write a NEW symlink to a temp name, then rename onto current.\n\t\t\tconst tmpLink = `${ctx.currentPath}.next`;\n\t\t\tconst result = await ctx.target.exec(\n\t\t\t\t`ln -sfn ${ctx.releasePath} ${tmpLink} && mv -Tf ${tmpLink} ${ctx.currentPath}`,\n\t\t\t\t{ onLog: (line, stream) => ctx.hooks.onLog(line, stream, 'link'), timeoutMs: 10_000 },\n\t\t\t);\n\t\t\trequireSuccess('link', result);\n\t\t},\n\t},\n\t{\n\t\tname: 'restart',\n\t\trun: async (ctx) => {\n\t\t\tawait ctx.processManager.reload(ctx.target, {\n\t\t\t\tappName: ctx.appName,\n\t\t\t\tcurrentPath: ctx.currentPath,\n\t\t\t\tenv: ctx.env,\n\t\t\t\tonLog: (line, stream) => ctx.hooks.onLog(line, stream, 'restart'),\n\t\t\t\treleaseId: ctx.releaseId,\n\t\t\t\treleasePath: ctx.releasePath,\n\t\t\t});\n\t\t},\n\t},\n\t{\n\t\tname: 'verify',\n\t\trun: async (ctx) => {\n\t\t\tif (!ctx.verify) return;\n\t\t\tawait runVerify(ctx);\n\t\t},\n\t},\n];\n\nconst runVerify = async (ctx: DeployContext): Promise<void> => {\n\tconst spec = ctx.verify!;\n\tif (spec.kind === 'custom') {\n\t\tconst ok = await spec.check(ctx);\n\t\tif (!ok) throw new Error('verify: custom check returned false');\n\t\treturn;\n\t}\n\tif (spec.kind === 'http') {\n\t\tconst retries = spec.retries ?? 30;\n\t\tconst intervalMs = spec.intervalMs ?? 1_000;\n\t\tconst expectStatus = spec.expectStatus ?? 200;\n\t\tfor (let attempt = 0; attempt <= retries; attempt++) {\n\t\t\tconst probe = await ctx.target.exec(\n\t\t\t\t`curl -s -o /dev/null -w '%{http_code}' --max-time 5 ${spec.url}`,\n\t\t\t\t{ timeoutMs: 10_000 },\n\t\t\t);\n\t\t\tconst code = Number(probe.stdout.trim());\n\t\t\tif (code === expectStatus) return;\n\t\t\tif (attempt < retries) await new Promise((resolve) => setTimeout(resolve, intervalMs));\n\t\t}\n\t\tthrow new Error(`verify: HTTP ${spec.url} did not return ${expectStatus} after ${retries} retries`);\n\t}\n\t// tcp\n\tconst retries = spec.retries ?? 30;\n\tconst intervalMs = spec.intervalMs ?? 1_000;\n\tfor (let attempt = 0; attempt <= retries; attempt++) {\n\t\tconst probe = await ctx.target.exec(\n\t\t\t`bash -c 'cat < /dev/tcp/${spec.host}/${spec.port}' 2>/dev/null && echo open || echo closed`,\n\t\t\t{ timeoutMs: 10_000 },\n\t\t);\n\t\tif (probe.stdout.includes('open')) return;\n\t\tif (attempt < retries) await new Promise((resolve) => setTimeout(resolve, intervalMs));\n\t}\n\tthrow new Error(`verify: TCP ${spec.host}:${spec.port} not open after ${retries} retries`);\n};\n\n// -----------------------------------------------------------------------------\n// Deployer\n// -----------------------------------------------------------------------------\n\nexport const createDeployer = (options: DeployerOptions): Deployer => {\n\tconst clock = options.clock ?? Date.now;\n\tconst hooks = resolveHooks(options.hooks);\n\tconst rootPath = options.rootPath ?? `/srv/${options.appName}`;\n\tconst currentPath = `${rootPath}/current`;\n\tconst releasesPath = `${rootPath}/releases`;\n\tconst env: Record<string, string> = { NODE_ENV: 'production', ...options.env };\n\tconst processManager = options.processManager ?? bareManager();\n\tconst verify = options.verify === undefined ? null : options.verify;\n\tlet disposed = false;\n\n\tconst buildCtx = (\n\t\treleaseId: string,\n\t\topts: { annotations: ReleaseAnnotations; dryRun: boolean; signal?: AbortSignal },\n\t): DeployContext => ({\n\t\tannotations: opts.annotations,\n\t\tappName: options.appName,\n\t\tcurrentPath,\n\t\tdryRun: opts.dryRun,\n\t\tenv,\n\t\thooks,\n\t\tprocessManager,\n\t\tsignal: opts.signal,\n\t\treleaseId,\n\t\treleasePath: `${releasesPath}/${releaseId}`,\n\t\tsource: options.source,\n\t\ttarget: options.target,\n\t\tverify,\n\t});\n\n\tconst metaPath = (releaseId: string) => `${releasesPath}/${releaseId}/.deploy-meta.json`;\n\n\tconst writeMeta = async (releaseId: string, record: ReleaseRecord): Promise<void> => {\n\t\tconst json = JSON.stringify(record);\n\t\t// Use stdin to avoid quoting hassles + so the JSON doesn't appear in `ps`.\n\t\tconst result = await options.target.exec(`cat > ${metaPath(releaseId)}`, {\n\t\t\tstdin: json,\n\t\t\ttimeoutMs: 10_000,\n\t\t});\n\t\tif (result.exitCode !== 0) {\n\t\t\t// Non-fatal — the deploy doesn't depend on the meta file for success.\n\t\t\tconsole.warn(`[deploy] writeMeta(${releaseId}) failed: ${result.stderr || result.stdout}`);\n\t\t}\n\t};\n\n\tconst readMeta = async (releaseId: string): Promise<ReleaseRecord | null> => {\n\t\tconst result = await options.target.exec(`cat ${metaPath(releaseId)} 2>/dev/null || true`, {\n\t\t\ttimeoutMs: 10_000,\n\t\t});\n\t\tconst text = result.stdout.trim();\n\t\tif (text.length === 0) return null;\n\t\ttry {\n\t\t\treturn JSON.parse(text) as ReleaseRecord;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t};\n\n\tconst cleanOrphanedSymlink = async (): Promise<void> => {\n\t\t// A prior deploy that crashed between `ln -sfn ... current.next` and\n\t\t// `mv -Tf current.next current` leaves `current.next` dangling. Clean\n\t\t// it so the next link step's `mv -Tf` is unambiguous.\n\t\tawait options.target.exec(`rm -f ${currentPath}.next`, { timeoutMs: 5_000 });\n\t};\n\n\tconst runSteps = async (\n\t\tsteps: DeployStep[],\n\t\treleaseId: string,\n\t\trunOpts: {\n\t\t\tannotations: ReleaseAnnotations;\n\t\t\tdryRun: boolean;\n\t\t\talreadyCompleted: string[];\n\t\t\tsignal?: AbortSignal;\n\t\t},\n\t): Promise<DeployResult> => {\n\t\tconst ctx = buildCtx(releaseId, {\n\t\t\tannotations: runOpts.annotations,\n\t\t\tdryRun: runOpts.dryRun,\n\t\t\tsignal: runOpts.signal,\n\t\t});\n\t\tconst stepDurations: { name: string; durationMs: number; skipped?: boolean }[] = [];\n\t\tconst startedAt = clock();\n\t\tconst completedSteps: string[] = [...runOpts.alreadyCompleted];\n\n\t\tconst record: ReleaseRecord = {\n\t\t\tannotations: runOpts.annotations,\n\t\t\tcompletedSteps,\n\t\t\treleaseId,\n\t\t\tstartedAt,\n\t\t\tstatus: 'in-progress',\n\t\t};\n\t\t// Write the meta-record as soon as the release directory exists, which\n\t\t// `prepare` sets up. Until then we have nowhere to put it.\n\n\t\tfor (const step of steps) {\n\t\t\tctx.signal?.throwIfAborted();\n\t\t\tif (completedSteps.includes(step.name) && step.name !== 'verify') {\n\t\t\t\t// Resume: skip steps already done. (Always re-run verify so a\n\t\t\t\t// healthy probe is recorded post-resume.)\n\t\t\t\tstepDurations.push({ durationMs: 0, name: step.name, skipped: true });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst stepStartedAt = clock();\n\t\t\tawait hooks.onStepStart({ name: step.name, releaseId });\n\n\t\t\tif (runOpts.dryRun) {\n\t\t\t\thooks.onLog(`[dry-run] would run: ${step.name}`, 'stdout', step.name);\n\t\t\t\tstepDurations.push({ durationMs: 0, name: step.name, skipped: true });\n\t\t\t\tawait hooks.onStepEnd({ durationMs: 0, name: step.name, releaseId });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tawait step.run(ctx);\n\t\t\t\tctx.signal?.throwIfAborted();\n\t\t\t} catch (error) {\n\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\trecord.status = 'failed';\n\t\t\t\trecord.failedStep = step.name;\n\t\t\t\trecord.endedAt = clock();\n\t\t\t\t// Best-effort meta write so resume() works later.\n\t\t\t\tawait writeMeta(releaseId, record);\n\t\t\t\tawait hooks.onError({ error: err, releaseId, step: step.name });\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tconst durationMs = clock() - stepStartedAt;\n\t\t\tstepDurations.push({ durationMs, name: step.name });\n\t\t\tcompletedSteps.push(step.name);\n\t\t\tawait hooks.onStepEnd({ durationMs, name: step.name, releaseId });\n\n\t\t\t// After `prepare` (the first step that creates the dir), persist meta.\n\t\t\tif (step.name === 'prepare') {\n\t\t\t\tawait writeMeta(releaseId, record);\n\t\t\t}\n\t\t}\n\n\t\trecord.status = 'completed';\n\t\trecord.endedAt = clock();\n\t\tif (!runOpts.dryRun) await writeMeta(releaseId, record);\n\n\t\treturn {\n\t\t\tannotations: runOpts.annotations,\n\t\t\tcurrentPath,\n\t\t\tdurationMs: clock() - startedAt,\n\t\t\treleaseId,\n\t\t\treleasePath: ctx.releasePath,\n\t\t\tsteps: stepDurations,\n\t\t};\n\t};\n\n\tconst ensureRoot = async () => {\n\t\tconst result = await options.target.exec(`mkdir -p ${releasesPath}`, { timeoutMs: 10_000 });\n\t\trequireSuccess('ensureRoot', result);\n\t};\n\tconst activeProcessContext = (): ProcessManagerContext => ({\n\t\tappName: options.appName,\n\t\tcurrentPath,\n\t\tenv,\n\t\treleaseId: 'current',\n\t\treleasePath: currentPath,\n\t});\n\n\treturn {\n\t\tdeploy: async (deployOpts: DeployOptions = {}) => {\n\t\t\tif (disposed) throw new Error('Deployer is disposed');\n\t\t\tawait ensureRoot();\n\t\t\tawait cleanOrphanedSymlink();\n\n\t\t\tconst annotations = deployOpts.annotations ?? {};\n\t\t\tconst dryRun = deployOpts.dryRun ?? false;\n\n\t\t\tif (deployOpts.resumeReleaseId !== undefined) {\n\t\t\t\tconst prior = await readMeta(deployOpts.resumeReleaseId);\n\t\t\t\tif (!prior) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`resume: no .deploy-meta.json for release ${deployOpts.resumeReleaseId}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (prior.status === 'completed') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`resume: release ${deployOpts.resumeReleaseId} already completed`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn runSteps(options.steps ?? defaultBunPipeline(), deployOpts.resumeReleaseId, {\n\t\t\t\t\talreadyCompleted: prior.completedSteps,\n\t\t\t\t\tannotations: prior.annotations ?? annotations,\n\t\t\t\t\tdryRun,\n\t\t\t\t\tsignal: deployOpts.signal,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst releaseId = makeReleaseId(clock);\n\t\t\treturn runSteps(options.steps ?? defaultBunPipeline(), releaseId, {\n\t\t\t\talreadyCompleted: [],\n\t\t\t\tannotations,\n\t\t\t\tdryRun,\n\t\t\t\tsignal: deployOpts.signal,\n\t\t\t});\n\t\t},\n\t\tdispose: async () => {\n\t\t\tdisposed = true;\n\t\t\tif (options.target.close) await options.target.close();\n\t\t},\n\t\tlistReleases: async () => {\n\t\t\tawait ensureRoot();\n\t\t\tconst result = await options.target.exec(\n\t\t\t\t`ls -1 ${releasesPath} 2>/dev/null || true`,\n\t\t\t\t{ timeoutMs: 10_000 },\n\t\t\t);\n\t\t\treturn result.stdout\n\t\t\t\t.split('\\n')\n\t\t\t\t.map((line) => line.trim())\n\t\t\t\t.filter((line) => line.length > 0)\n\t\t\t\t.sort();\n\t\t},\n\t\tprune: async ({ keep }) => {\n\t\t\tif (disposed) throw new Error('Deployer is disposed');\n\t\t\tconst all = await (async () => {\n\t\t\t\tconst result = await options.target.exec(\n\t\t\t\t\t`ls -1 ${releasesPath} 2>/dev/null || true`,\n\t\t\t\t\t{ timeoutMs: 10_000 },\n\t\t\t\t);\n\t\t\t\treturn result.stdout\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map((line) => line.trim())\n\t\t\t\t\t.filter((line) => line.length > 0)\n\t\t\t\t\t.sort();\n\t\t\t})();\n\t\t\tif (all.length <= keep) return { removed: [] };\n\t\t\tconst removed = all.slice(0, all.length - keep);\n\t\t\tfor (const releaseId of removed) {\n\t\t\t\tawait options.target.exec(`rm -rf ${releasesPath}/${releaseId}`, { timeoutMs: 60_000 });\n\t\t\t}\n\t\t\treturn { removed };\n\t\t},\n\t\treadReleaseMeta: readMeta,\n\t\trollback: async (releaseId) => {\n\t\t\tif (disposed) throw new Error('Deployer is disposed');\n\t\t\tawait ensureRoot();\n\t\t\tawait cleanOrphanedSymlink();\n\t\t\tconst exists = await options.target.exec(\n\t\t\t\t`test -d ${releasesPath}/${releaseId} && echo ok || echo missing`,\n\t\t\t\t{ timeoutMs: 5_000 },\n\t\t\t);\n\t\t\tif (!exists.stdout.includes('ok')) {\n\t\t\t\tthrow new Error(`rollback: release ${releaseId} not found at ${releasesPath}/${releaseId}`);\n\t\t\t}\n\t\t\t// Rollback steps: re-link + restart (no upload, no install, no build).\n\t\t\tconst rollbackSteps: DeployStep[] = defaultBunPipeline().filter((step) =>\n\t\t\t\tstep.name === 'link' || step.name === 'restart' || step.name === 'verify',\n\t\t\t);\n\t\t\tconst prior = await readMeta(releaseId);\n\t\t\treturn runSteps(rollbackSteps, releaseId, {\n\t\t\t\talreadyCompleted: [],\n\t\t\t\tannotations: prior?.annotations ?? {},\n\t\t\t\tdryRun: false,\n\t\t\t});\n\t\t},\n\t\tstatus: async () => {\n\t\t\tif (disposed) throw new Error('Deployer is disposed');\n\t\t\tif (!processManager.status) return 'unknown';\n\t\t\treturn processManager.status(options.target, activeProcessContext());\n\t\t},\n\t\tstop: async () => {\n\t\t\tif (disposed) throw new Error('Deployer is disposed');\n\t\t\tif (!processManager.stop) {\n\t\t\t\tthrow new Error('Process manager does not support stop');\n\t\t\t}\n\t\t\tawait processManager.stop(options.target, activeProcessContext());\n\t\t},\n\t};\n};\n"
|
|
10
10
|
],
|
|
11
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA,IAAM,oBAAoB;AAC1B,IAAM,qBAAqB;AAC3B,IAAM,kBAAkB;AAAA;AAejB,MAAM,6BAA6B,MAAM;AAAC;AAEjD,IAAM,MAAM,OAAO,YAAsB;AAAA,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AAM,sBAAsB;AAAA,MACpD,IAAI,CAAC,eAAe;AAAA,QAAQ,OAAO;AAAA,MACnC,OAAO,eAAe,OAAO,QAAQ,QAAQ,qBAAqB,CAAC;AAAA;AAAA,IAEpE,MAAM,YAAY;AAAA,MACjB,IAAI;AAAA,QAAU,MAAM,IAAI,MAAM,sBAAsB;AAAA,MACpD,IAAI,CAAC,eAAe,MAAM;AAAA,QACzB,MAAM,IAAI,MAAM,uCAAuC;AAAA,MACxD;AAAA,MACA,MAAM,eAAe,KAAK,QAAQ,QAAQ,qBAAqB,CAAC;AAAA;AAAA,EAElE;AAAA;",
|
|
12
|
+
"debugId": "BC2DAC4B8EA4FAB664756E2164756E21",
|
|
13
13
|
"names": []
|
|
14
14
|
}
|
package/dist/releaseArtifact.js
CHANGED
|
@@ -112,9 +112,13 @@ var receiveReleaseArtifact = async (options) => {
|
|
|
112
112
|
await mkdir(path.dirname(options.destination), { recursive: true });
|
|
113
113
|
const writer = Bun.file(options.destination).writer();
|
|
114
114
|
const hasher = new Bun.CryptoHasher("sha256");
|
|
115
|
+
const reader = options.stream.getReader();
|
|
115
116
|
let bytes = 0;
|
|
116
117
|
try {
|
|
117
|
-
|
|
118
|
+
while (true) {
|
|
119
|
+
const { done, value: chunk } = await reader.read();
|
|
120
|
+
if (done)
|
|
121
|
+
break;
|
|
118
122
|
bytes += chunk.byteLength;
|
|
119
123
|
if (bytes > options.expectedBytes || bytes > maxBytes)
|
|
120
124
|
throw new ReleaseArtifactError("Release artifact exceeds its declared size");
|
|
@@ -125,6 +129,7 @@ var receiveReleaseArtifact = async (options) => {
|
|
|
125
129
|
await rm(options.destination, { force: true });
|
|
126
130
|
throw error;
|
|
127
131
|
} finally {
|
|
132
|
+
reader.releaseLock();
|
|
128
133
|
await writer.end();
|
|
129
134
|
}
|
|
130
135
|
if (bytes !== options.expectedBytes || hasher.digest("hex") !== options.expectedSha256) {
|
|
@@ -166,5 +171,5 @@ export {
|
|
|
166
171
|
ReleaseArtifactError
|
|
167
172
|
};
|
|
168
173
|
|
|
169
|
-
//# debugId=
|
|
174
|
+
//# debugId=7AC624D04445253564756E2164756E21
|
|
170
175
|
//# sourceMappingURL=releaseArtifact.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/releaseArtifact.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { mkdir, mkdtemp, rm, stat } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\n\nconst DEFAULT_MAX_BYTES = 2_147_483_648;\nconst ERROR_DETAIL_LIMIT = 500;\nconst SAFE_RELEASE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\n\nexport type ReleaseArtifactMetadata = {\n bytes: number;\n releaseId: string;\n sha256: string;\n};\n\nexport type CreatedReleaseArtifact = {\n dispose: () => Promise<void>;\n file: Bun.BunFile;\n metadata: ReleaseArtifactMetadata;\n path: string;\n};\n\nexport class ReleaseArtifactError extends Error {}\n\nconst run = async (command: string[]) => {\n const process = Bun.spawn(command, { stderr: \"pipe\", stdout: \"pipe\" });\n const [exitCode, stderr, stdout] = await Promise.all([\n process.exited,\n new Response(process.stderr).text(),\n new Response(process.stdout).text(),\n ]);\n if (exitCode !== 0)\n throw new ReleaseArtifactError(\n `${command[0]} failed (${exitCode}): ${stderr.slice(0, ERROR_DETAIL_LIMIT)}`,\n );\n\n return stdout;\n};\n\nconst assertReleaseId = (value: string) => {\n if (!SAFE_RELEASE_ID.test(value))\n throw new ReleaseArtifactError(\"Release id is invalid\");\n\n return value;\n};\n\nconst assertExclude = (value: string) => {\n if (\n value.length === 0 ||\n value.startsWith(\"-\") ||\n value.startsWith(\"/\") ||\n value.split(\"/\").some((part) => part === \"..\") ||\n /[\\0\\r\\n]/.test(value)\n )\n throw new ReleaseArtifactError(`Invalid release exclusion: ${value}`);\n\n return value.replace(/^\\.\\//, \"\");\n};\n\nconst sha256File = async (file: Blob) => {\n const hasher = new Bun.CryptoHasher(\"sha256\");\n for await (const chunk of file.stream()) hasher.update(chunk);\n\n return hasher.digest(\"hex\");\n};\n\nexport const createReleaseArtifact = async (options: {\n exclude?: string[];\n releaseId?: string;\n sourceRoot: string;\n temporaryRoot?: string;\n}): Promise<CreatedReleaseArtifact> => {\n const releaseId = assertReleaseId(options.releaseId ?? crypto.randomUUID());\n const source = path.resolve(options.sourceRoot);\n const sourceStats = await stat(source).catch(() => null);\n if (!sourceStats?.isDirectory())\n throw new ReleaseArtifactError(\"Release source root is not a directory\");\n if (!(await Bun.file(path.join(source, \"package.json\")).exists()))\n throw new ReleaseArtifactError(\"Release source has no package.json\");\n const temporary = await mkdtemp(\n path.join(options.temporaryRoot ?? tmpdir(), \"absolutejs-release-\"),\n );\n const archivePath = path.join(temporary, `${releaseId}.tgz`);\n try {\n await run([\n \"tar\",\n \"-czf\",\n archivePath,\n ...(options.exclude ?? []).map(\n (value) => `--exclude=./${assertExclude(value)}`,\n ),\n \"-C\",\n source,\n \".\",\n ]);\n const file = Bun.file(archivePath);\n\n return {\n dispose: () => rm(temporary, { force: true, recursive: true }),\n file,\n metadata: {\n bytes: file.size,\n releaseId,\n sha256: await sha256File(file),\n },\n path: archivePath,\n };\n } catch (error) {\n await rm(temporary, { force: true, recursive: true });\n throw error;\n }\n};\n\nexport const receiveReleaseArtifact = async (options: {\n destination: string;\n expectedBytes: number;\n expectedSha256: string;\n maxBytes?: number;\n stream: ReadableStream<Uint8Array>;\n}) => {\n const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n if (\n !Number.isSafeInteger(options.expectedBytes) ||\n options.expectedBytes < 1 ||\n options.expectedBytes > maxBytes ||\n !/^[a-f0-9]{64}$/.test(options.expectedSha256)\n )\n throw new ReleaseArtifactError(\"Release artifact metadata is invalid\");\n await mkdir(path.dirname(options.destination), { recursive: true });\n const writer = Bun.file(options.destination).writer();\n const hasher = new Bun.CryptoHasher(\"sha256\");\n let bytes = 0;\n try {\n
|
|
5
|
+
"import { mkdir, mkdtemp, rm, stat } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\n\nconst DEFAULT_MAX_BYTES = 2_147_483_648;\nconst ERROR_DETAIL_LIMIT = 500;\nconst SAFE_RELEASE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;\n\nexport type ReleaseArtifactMetadata = {\n bytes: number;\n releaseId: string;\n sha256: string;\n};\n\nexport type CreatedReleaseArtifact = {\n dispose: () => Promise<void>;\n file: Bun.BunFile;\n metadata: ReleaseArtifactMetadata;\n path: string;\n};\n\nexport class ReleaseArtifactError extends Error {}\n\nconst run = async (command: string[]) => {\n const process = Bun.spawn(command, { stderr: \"pipe\", stdout: \"pipe\" });\n const [exitCode, stderr, stdout] = await Promise.all([\n process.exited,\n new Response(process.stderr).text(),\n new Response(process.stdout).text(),\n ]);\n if (exitCode !== 0)\n throw new ReleaseArtifactError(\n `${command[0]} failed (${exitCode}): ${stderr.slice(0, ERROR_DETAIL_LIMIT)}`,\n );\n\n return stdout;\n};\n\nconst assertReleaseId = (value: string) => {\n if (!SAFE_RELEASE_ID.test(value))\n throw new ReleaseArtifactError(\"Release id is invalid\");\n\n return value;\n};\n\nconst assertExclude = (value: string) => {\n if (\n value.length === 0 ||\n value.startsWith(\"-\") ||\n value.startsWith(\"/\") ||\n value.split(\"/\").some((part) => part === \"..\") ||\n /[\\0\\r\\n]/.test(value)\n )\n throw new ReleaseArtifactError(`Invalid release exclusion: ${value}`);\n\n return value.replace(/^\\.\\//, \"\");\n};\n\nconst sha256File = async (file: Blob) => {\n const hasher = new Bun.CryptoHasher(\"sha256\");\n for await (const chunk of file.stream()) hasher.update(chunk);\n\n return hasher.digest(\"hex\");\n};\n\nexport const createReleaseArtifact = async (options: {\n exclude?: string[];\n releaseId?: string;\n sourceRoot: string;\n temporaryRoot?: string;\n}): Promise<CreatedReleaseArtifact> => {\n const releaseId = assertReleaseId(options.releaseId ?? crypto.randomUUID());\n const source = path.resolve(options.sourceRoot);\n const sourceStats = await stat(source).catch(() => null);\n if (!sourceStats?.isDirectory())\n throw new ReleaseArtifactError(\"Release source root is not a directory\");\n if (!(await Bun.file(path.join(source, \"package.json\")).exists()))\n throw new ReleaseArtifactError(\"Release source has no package.json\");\n const temporary = await mkdtemp(\n path.join(options.temporaryRoot ?? tmpdir(), \"absolutejs-release-\"),\n );\n const archivePath = path.join(temporary, `${releaseId}.tgz`);\n try {\n await run([\n \"tar\",\n \"-czf\",\n archivePath,\n ...(options.exclude ?? []).map(\n (value) => `--exclude=./${assertExclude(value)}`,\n ),\n \"-C\",\n source,\n \".\",\n ]);\n const file = Bun.file(archivePath);\n\n return {\n dispose: () => rm(temporary, { force: true, recursive: true }),\n file,\n metadata: {\n bytes: file.size,\n releaseId,\n sha256: await sha256File(file),\n },\n path: archivePath,\n };\n } catch (error) {\n await rm(temporary, { force: true, recursive: true });\n throw error;\n }\n};\n\nexport const receiveReleaseArtifact = async (options: {\n destination: string;\n expectedBytes: number;\n expectedSha256: string;\n maxBytes?: number;\n stream: ReadableStream<Uint8Array>;\n}) => {\n const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n if (\n !Number.isSafeInteger(options.expectedBytes) ||\n options.expectedBytes < 1 ||\n options.expectedBytes > maxBytes ||\n !/^[a-f0-9]{64}$/.test(options.expectedSha256)\n )\n throw new ReleaseArtifactError(\"Release artifact metadata is invalid\");\n await mkdir(path.dirname(options.destination), { recursive: true });\n const writer = Bun.file(options.destination).writer();\n const hasher = new Bun.CryptoHasher(\"sha256\");\n const reader = options.stream.getReader();\n let bytes = 0;\n try {\n while (true) {\n const { done, value: chunk } = await reader.read();\n if (done) break;\n bytes += chunk.byteLength;\n if (bytes > options.expectedBytes || bytes > maxBytes)\n throw new ReleaseArtifactError(\n \"Release artifact exceeds its declared size\",\n );\n hasher.update(chunk);\n writer.write(chunk);\n }\n } catch (error) {\n await rm(options.destination, { force: true });\n throw error;\n } finally {\n reader.releaseLock();\n await writer.end();\n }\n if (\n bytes !== options.expectedBytes ||\n hasher.digest(\"hex\") !== options.expectedSha256\n ) {\n await rm(options.destination, { force: true });\n throw new ReleaseArtifactError(\n \"Release artifact integrity verification failed\",\n );\n }\n\n return { bytes, sha256: options.expectedSha256 };\n};\n\nexport const extractReleaseArtifact = async (options: {\n archivePath: string;\n destination: string;\n}) => {\n const [names, verbose] = await Promise.all([\n run([\"tar\", \"-tzf\", options.archivePath]),\n run([\"tar\", \"-tvzf\", options.archivePath]),\n ]);\n const unsafePath = names\n .split(\"\\n\")\n .filter(Boolean)\n .some(\n (entry) =>\n entry.startsWith(\"/\") || entry.split(\"/\").some((part) => part === \"..\"),\n );\n const unsafeType = verbose\n .split(\"\\n\")\n .filter(Boolean)\n .some((entry) => entry[0] !== \"-\" && entry[0] !== \"d\");\n if (unsafePath || unsafeType)\n throw new ReleaseArtifactError(\"Release artifact contains an unsafe entry\");\n await rm(options.destination, { force: true, recursive: true });\n await mkdir(options.destination, { recursive: true });\n await run([\n \"tar\",\n \"-xzf\",\n options.archivePath,\n \"--no-same-owner\",\n \"--no-same-permissions\",\n \"-C\",\n options.destination,\n ]);\n if (\n !(await Bun.file(path.join(options.destination, \"package.json\")).exists())\n )\n throw new ReleaseArtifactError(\"Release artifact has no package.json\");\n\n return { extracted: true } as const;\n};\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAEA,IAAM,oBAAoB;AAC1B,IAAM,qBAAqB;AAC3B,IAAM,kBAAkB;AAAA;AAejB,MAAM,6BAA6B,MAAM;AAAC;AAEjD,IAAM,MAAM,OAAO,YAAsB;AAAA,EACvC,MAAM,UAAU,IAAI,MAAM,SAAS,EAAE,QAAQ,QAAQ,QAAQ,OAAO,CAAC;AAAA,EACrE,OAAO,UAAU,QAAQ,UAAU,MAAM,QAAQ,IAAI;AAAA,IACnD,QAAQ;AAAA,IACR,IAAI,SAAS,QAAQ,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",
|
|
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",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"release"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "rm -rf dist && bun build src/index.ts src/releaseArtifact.ts src/infrastructure.ts src/edgeIngress.ts src/digitalocean.ts src/digitaloceanInfrastructure.ts src/digitaloceanIngress.ts src/gcp.ts src/gcpIngress.ts src/hetzner.ts src/hetznerInfrastructure.ts src/linode.ts src/linodeInfrastructure.ts src/vultr.ts src/vultrInfrastructure.ts src/dns.ts src/cloudflare.ts src/digitaloceanDns.ts src/hetznerDns.ts src/route53.ts src/tls.ts src/env.ts src/preview.ts src/managedPreview.ts --outdir dist --root src --sourcemap --target=bun && tsc --project tsconfig.build.json",
|
|
33
|
+
"build": "rm -rf dist && bun build src/index.ts src/releaseArtifact.ts src/infrastructure.ts src/ephemeralInfrastructure.ts src/edgeIngress.ts src/digitalocean.ts src/digitaloceanInfrastructure.ts src/digitaloceanEphemeralInfrastructure.ts src/digitaloceanIngress.ts src/gcp.ts src/gcpIngress.ts src/hetzner.ts src/hetznerInfrastructure.ts src/linode.ts src/linodeInfrastructure.ts src/vultr.ts src/vultrInfrastructure.ts src/dns.ts src/cloudflare.ts src/digitaloceanDns.ts src/hetznerDns.ts src/route53.ts src/tls.ts src/env.ts src/preview.ts src/managedPreview.ts --outdir dist --root src --sourcemap --target=bun && tsc --project tsconfig.build.json",
|
|
34
34
|
"test": "bun test tests/",
|
|
35
35
|
"typecheck": "tsc --noEmit",
|
|
36
36
|
"format": "prettier --write \"./**/*.{ts,json,md}\"",
|
|
@@ -66,6 +66,16 @@
|
|
|
66
66
|
"import": "./dist/infrastructure.js",
|
|
67
67
|
"default": "./dist/infrastructure.js"
|
|
68
68
|
},
|
|
69
|
+
"./ephemeral-infrastructure": {
|
|
70
|
+
"types": "./dist/ephemeralInfrastructure.d.ts",
|
|
71
|
+
"import": "./dist/ephemeralInfrastructure.js",
|
|
72
|
+
"default": "./dist/ephemeralInfrastructure.js"
|
|
73
|
+
},
|
|
74
|
+
"./digitalocean-ephemeral-infrastructure": {
|
|
75
|
+
"types": "./dist/digitaloceanEphemeralInfrastructure.d.ts",
|
|
76
|
+
"import": "./dist/digitaloceanEphemeralInfrastructure.js",
|
|
77
|
+
"default": "./dist/digitaloceanEphemeralInfrastructure.js"
|
|
78
|
+
},
|
|
69
79
|
"./edge-ingress": {
|
|
70
80
|
"types": "./dist/edgeIngress.d.ts",
|
|
71
81
|
"import": "./dist/edgeIngress.js",
|