@absolutejs/deploy 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -3
- package/dist/cloudTarget.d.ts +8 -8
- package/dist/digitalocean.d.ts +1 -1
- package/dist/digitalocean.js.map +3 -3
- package/dist/digitaloceanDns.d.ts +22 -0
- package/dist/digitaloceanDns.js +526 -0
- package/dist/digitaloceanDns.js.map +13 -0
- package/dist/env.d.ts +112 -0
- package/dist/env.js +203 -0
- package/dist/env.js.map +10 -0
- package/dist/hetzner.js.map +2 -2
- package/dist/hetznerDns.d.ts +43 -0
- package/dist/hetznerDns.js +169 -0
- package/dist/hetznerDns.js.map +10 -0
- package/dist/linode.d.ts +99 -0
- package/dist/linode.js +428 -0
- package/dist/linode.js.map +12 -0
- package/dist/vultr.d.ts +95 -0
- package/dist/vultr.js +420 -0
- package/dist/vultr.js.map +12 -0
- package/package.json +27 -2
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @absolutejs/deploy/env — push environment-variable files to remote
|
|
3
|
+
* targets and fan-out secret rotations across the fleet.
|
|
4
|
+
*
|
|
5
|
+
* Composes with `@absolutejs/secrets`: that library handles the
|
|
6
|
+
* in-process side (resolve, rotate, redact, in-process listeners);
|
|
7
|
+
* this module handles the deploy-side (push values to remote env
|
|
8
|
+
* files, atomic swap, conditional service reload).
|
|
9
|
+
*
|
|
10
|
+
* Narrow `SecretSource` interface — `@absolutejs/secrets`'
|
|
11
|
+
* `SecretBroker` satisfies it structurally without a hard dep
|
|
12
|
+
* either direction.
|
|
13
|
+
*
|
|
14
|
+
* Standard format: a remote env file at
|
|
15
|
+
* `/etc/<appName>.env` (or wherever you choose) that systemd reads
|
|
16
|
+
* via `EnvironmentFile=`, Docker reads via `--env-file`, and most
|
|
17
|
+
* shell start scripts source. One `KEY=value` per line, no
|
|
18
|
+
* newlines inside values.
|
|
19
|
+
*/
|
|
20
|
+
import type { Target } from './targets';
|
|
21
|
+
/**
|
|
22
|
+
* Minimal interface this module needs to read secret values. The
|
|
23
|
+
* `SecretBroker` from `@absolutejs/secrets` satisfies it structurally;
|
|
24
|
+
* any other implementation (a Map, an AWS Secrets Manager client
|
|
25
|
+
* wrapper, etc.) works as long as it exposes `resolve(name)`.
|
|
26
|
+
*/
|
|
27
|
+
export type SecretSource = {
|
|
28
|
+
resolve: (name: string) => Promise<{
|
|
29
|
+
value: string;
|
|
30
|
+
fingerprint?: string;
|
|
31
|
+
} | null>;
|
|
32
|
+
};
|
|
33
|
+
export declare const serializeEnvFile: (values: Record<string, string>) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Parse a remote env file's contents. Ignores blank lines and `#`
|
|
36
|
+
* comments. Lines that don't match `KEY=VALUE` throw — the deploy
|
|
37
|
+
* primitive owns the file, so unknown content is loud, not silent.
|
|
38
|
+
*/
|
|
39
|
+
export declare const parseEnvFile: (text: string) => Record<string, string>;
|
|
40
|
+
export type EnvDeployment = {
|
|
41
|
+
/** The cloud Target whose remote filesystem we write to. */
|
|
42
|
+
target: Target;
|
|
43
|
+
/** Remote path for the env file (e.g. `/etc/myapp.env`). */
|
|
44
|
+
remotePath: string;
|
|
45
|
+
/**
|
|
46
|
+
* Names of secrets this deployment consumes from the SecretSource.
|
|
47
|
+
* Each name is resolved before the file is written.
|
|
48
|
+
*/
|
|
49
|
+
secretNames?: ReadonlyArray<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Non-secret env vars to merge in (NODE_ENV, PORT, LOG_LEVEL).
|
|
52
|
+
* If an `extras` key collides with a `secretNames` entry, throws —
|
|
53
|
+
* silent overrides are worse than a loud rejection.
|
|
54
|
+
*/
|
|
55
|
+
extras?: Record<string, string>;
|
|
56
|
+
/** chmod for the file. Default `'600'`. */
|
|
57
|
+
mode?: string;
|
|
58
|
+
/** chown for the file. Default unchanged. */
|
|
59
|
+
owner?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Command to run after the file changes. Skipped when the diff is
|
|
62
|
+
* empty — bouncing a service for an identical file is the wrong
|
|
63
|
+
* default.
|
|
64
|
+
*/
|
|
65
|
+
reload?: string;
|
|
66
|
+
};
|
|
67
|
+
export type EnvSyncResult = {
|
|
68
|
+
/** Keys present in the new spec but not the existing file. */
|
|
69
|
+
added: string[];
|
|
70
|
+
/** Keys whose values changed (fingerprints, NOT plaintext, for safety). */
|
|
71
|
+
changed: string[];
|
|
72
|
+
/** Keys removed from the spec (still in the existing file). */
|
|
73
|
+
removed: string[];
|
|
74
|
+
/** Keys whose values matched — file wasn't rewritten for these. */
|
|
75
|
+
unchanged: string[];
|
|
76
|
+
/** True iff `deployment.reload` was invoked. */
|
|
77
|
+
reloaded: boolean;
|
|
78
|
+
/** True iff the file content changed (atomic-write happened). */
|
|
79
|
+
wrote: boolean;
|
|
80
|
+
/** Remote path that was synced. */
|
|
81
|
+
remotePath: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Push an env file to a single target. Atomic: write to a `.new`
|
|
85
|
+
* tempfile, chmod / chown, then `mv` into place. Diffs the merged
|
|
86
|
+
* values against the existing file content and skips the
|
|
87
|
+
* write+reload when nothing changed.
|
|
88
|
+
*/
|
|
89
|
+
export declare const syncEnvToTarget: (deployment: EnvDeployment, values: Record<string, string>) => Promise<EnvSyncResult>;
|
|
90
|
+
export type DeploymentSyncResult = {
|
|
91
|
+
deployment: EnvDeployment;
|
|
92
|
+
result?: EnvSyncResult;
|
|
93
|
+
error?: Error;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Fan-out push: for each deployment, resolve its `secretNames` via
|
|
97
|
+
* the source, merge with `extras`, and push to the target. Resolves
|
|
98
|
+
* are fresh every call — so calling this again after
|
|
99
|
+
* `broker.rotate(name)` propagates the new value to every
|
|
100
|
+
* deployment that uses it.
|
|
101
|
+
*
|
|
102
|
+
* Best-effort across the fan-out: a per-target failure is captured
|
|
103
|
+
* in the result, but doesn't stop the rest. Operator inspects the
|
|
104
|
+
* returned array, fixes the broken target, re-runs.
|
|
105
|
+
*/
|
|
106
|
+
export declare const syncSecretsToDeployments: (source: SecretSource, deployments: ReadonlyArray<EnvDeployment>) => Promise<DeploymentSyncResult[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Returns just the deployments that use a given secret name. Useful
|
|
109
|
+
* for "rotate one secret and propagate ONLY to the consumers" —
|
|
110
|
+
* `syncSecretsToDeployments(source, deploymentsUsing(name, deployments))`.
|
|
111
|
+
*/
|
|
112
|
+
export declare const deploymentsUsing: (name: string, deployments: ReadonlyArray<EnvDeployment>) => EnvDeployment[];
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/env.ts
|
|
3
|
+
var KEY_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
|
|
4
|
+
var NEEDS_QUOTING = /[\s"'`$\\#&|;<>(){}*?!]/;
|
|
5
|
+
var validateKey = (key) => {
|
|
6
|
+
if (!KEY_PATTERN.test(key)) {
|
|
7
|
+
throw new Error(`[deploy/env] invalid env key "${key}" \u2014 must match /^[A-Z_][A-Z0-9_]*$/`);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var serializeLine = (key, value) => {
|
|
11
|
+
validateKey(key);
|
|
12
|
+
if (value.includes(`
|
|
13
|
+
`) || value.includes("\r")) {
|
|
14
|
+
throw new Error(`[deploy/env] value for "${key}" contains a newline \u2014 env files cannot represent multi-line values. Use a separate file path for multi-line secrets.`);
|
|
15
|
+
}
|
|
16
|
+
if (NEEDS_QUOTING.test(value) || value.startsWith("=") || value === "") {
|
|
17
|
+
const escaped = value.replaceAll("\\", "\\\\").replaceAll('"', "\\\"");
|
|
18
|
+
return `${key}="${escaped}"`;
|
|
19
|
+
}
|
|
20
|
+
return `${key}=${value}`;
|
|
21
|
+
};
|
|
22
|
+
var serializeEnvFile = (values) => {
|
|
23
|
+
const lines = [];
|
|
24
|
+
for (const key of Object.keys(values).sort()) {
|
|
25
|
+
const value = values[key];
|
|
26
|
+
if (value === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
lines.push(serializeLine(key, value));
|
|
29
|
+
}
|
|
30
|
+
return `${lines.join(`
|
|
31
|
+
`)}
|
|
32
|
+
`;
|
|
33
|
+
};
|
|
34
|
+
var unquoteValue = (raw) => {
|
|
35
|
+
if (raw.length >= 2 && raw.startsWith('"') && raw.endsWith('"')) {
|
|
36
|
+
const inner = raw.slice(1, -1);
|
|
37
|
+
return inner.replaceAll("\\\"", '"').replaceAll("\\\\", "\\");
|
|
38
|
+
}
|
|
39
|
+
if (raw.length >= 2 && raw.startsWith("'") && raw.endsWith("'")) {
|
|
40
|
+
return raw.slice(1, -1);
|
|
41
|
+
}
|
|
42
|
+
return raw;
|
|
43
|
+
};
|
|
44
|
+
var parseEnvFile = (text) => {
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const rawLine of text.split(`
|
|
47
|
+
`)) {
|
|
48
|
+
const line = rawLine.trim();
|
|
49
|
+
if (line.length === 0 || line.startsWith("#"))
|
|
50
|
+
continue;
|
|
51
|
+
const eq = line.indexOf("=");
|
|
52
|
+
if (eq <= 0) {
|
|
53
|
+
throw new Error(`[deploy/env] malformed env line: "${rawLine}"`);
|
|
54
|
+
}
|
|
55
|
+
const key = line.slice(0, eq).trim();
|
|
56
|
+
const value = unquoteValue(line.slice(eq + 1).trim());
|
|
57
|
+
validateKey(key);
|
|
58
|
+
result[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
var shellQuote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
63
|
+
var tryReadRemoteFile = async (target, remotePath) => {
|
|
64
|
+
const result = await target.exec(`if [ -f ${shellQuote(remotePath)} ]; then cat ${shellQuote(remotePath)}; else echo __ABS_DEPLOY_ENV_ABSENT__; fi`);
|
|
65
|
+
if (result.exitCode !== 0) {
|
|
66
|
+
throw new Error(`[deploy/env] failed to read ${remotePath}: exit ${result.exitCode}: ${result.stderr || result.stdout}`);
|
|
67
|
+
}
|
|
68
|
+
if (result.stdout.trim() === "__ABS_DEPLOY_ENV_ABSENT__")
|
|
69
|
+
return;
|
|
70
|
+
return result.stdout;
|
|
71
|
+
};
|
|
72
|
+
var mergeValues = (deployment, resolved) => {
|
|
73
|
+
const out = {};
|
|
74
|
+
for (const [key, value] of Object.entries(deployment.extras ?? {})) {
|
|
75
|
+
validateKey(key);
|
|
76
|
+
out[key] = value;
|
|
77
|
+
}
|
|
78
|
+
for (const [key, value] of Object.entries(resolved)) {
|
|
79
|
+
if (out[key] !== undefined) {
|
|
80
|
+
throw new Error(`[deploy/env] "${key}" defined in BOTH extras and secretNames for ${deployment.remotePath} \u2014 remove one`);
|
|
81
|
+
}
|
|
82
|
+
out[key] = value;
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
};
|
|
86
|
+
var diffEnv = (previous, next) => {
|
|
87
|
+
const added = [];
|
|
88
|
+
const changed = [];
|
|
89
|
+
const removed = [];
|
|
90
|
+
const unchanged = [];
|
|
91
|
+
const allKeys = new Set([...Object.keys(previous), ...Object.keys(next)]);
|
|
92
|
+
for (const key of [...allKeys].sort()) {
|
|
93
|
+
const prev = previous[key];
|
|
94
|
+
const curr = next[key];
|
|
95
|
+
if (curr === undefined)
|
|
96
|
+
removed.push(key);
|
|
97
|
+
else if (prev === undefined)
|
|
98
|
+
added.push(key);
|
|
99
|
+
else if (prev === curr)
|
|
100
|
+
unchanged.push(key);
|
|
101
|
+
else
|
|
102
|
+
changed.push(key);
|
|
103
|
+
}
|
|
104
|
+
return { added, changed, removed, unchanged };
|
|
105
|
+
};
|
|
106
|
+
var writeRemoteFileAtomically = async (target, remotePath, contents, mode, owner) => {
|
|
107
|
+
const tempPath = `${remotePath}.new.${Math.floor(Date.now() / 1000)}`;
|
|
108
|
+
const dir = remotePath.split("/").slice(0, -1).join("/") || "/";
|
|
109
|
+
const mkdir = await target.exec(`mkdir -p ${shellQuote(dir)}`);
|
|
110
|
+
if (mkdir.exitCode !== 0) {
|
|
111
|
+
throw new Error(`[deploy/env] mkdir ${dir} failed: ${mkdir.stderr || mkdir.stdout}`);
|
|
112
|
+
}
|
|
113
|
+
const writeResult = await target.exec(`cat > ${shellQuote(tempPath)}`, {
|
|
114
|
+
stdin: contents
|
|
115
|
+
});
|
|
116
|
+
if (writeResult.exitCode !== 0) {
|
|
117
|
+
throw new Error(`[deploy/env] write to ${tempPath} failed: ${writeResult.stderr || writeResult.stdout}`);
|
|
118
|
+
}
|
|
119
|
+
const chmod = await target.exec(`chmod ${shellQuote(mode)} ${shellQuote(tempPath)}`);
|
|
120
|
+
if (chmod.exitCode !== 0) {
|
|
121
|
+
throw new Error(`[deploy/env] chmod failed: ${chmod.stderr || chmod.stdout}`);
|
|
122
|
+
}
|
|
123
|
+
if (owner !== undefined) {
|
|
124
|
+
const chown = await target.exec(`chown ${shellQuote(owner)} ${shellQuote(tempPath)}`);
|
|
125
|
+
if (chown.exitCode !== 0) {
|
|
126
|
+
throw new Error(`[deploy/env] chown failed: ${chown.stderr || chown.stdout}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const mv = await target.exec(`mv ${shellQuote(tempPath)} ${shellQuote(remotePath)}`);
|
|
130
|
+
if (mv.exitCode !== 0) {
|
|
131
|
+
throw new Error(`[deploy/env] mv failed: ${mv.stderr || mv.stdout}`);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var syncEnvToTarget = async (deployment, values) => {
|
|
135
|
+
const mode = deployment.mode ?? "600";
|
|
136
|
+
const merged = mergeValues(deployment, values);
|
|
137
|
+
const previousText = await tryReadRemoteFile(deployment.target, deployment.remotePath);
|
|
138
|
+
const previous = previousText === undefined ? {} : parseEnvFile(previousText);
|
|
139
|
+
const diff = diffEnv(previous, merged);
|
|
140
|
+
const changed = diff.added.length + diff.changed.length + diff.removed.length;
|
|
141
|
+
if (changed === 0) {
|
|
142
|
+
return {
|
|
143
|
+
...diff,
|
|
144
|
+
reloaded: false,
|
|
145
|
+
remotePath: deployment.remotePath,
|
|
146
|
+
wrote: false
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const nextText = serializeEnvFile(merged);
|
|
150
|
+
await writeRemoteFileAtomically(deployment.target, deployment.remotePath, nextText, mode, deployment.owner);
|
|
151
|
+
let reloaded = false;
|
|
152
|
+
if (deployment.reload !== undefined) {
|
|
153
|
+
const reload = await deployment.target.exec(deployment.reload);
|
|
154
|
+
if (reload.exitCode !== 0) {
|
|
155
|
+
throw new Error(`[deploy/env] reload command failed: ${reload.stderr || reload.stdout}`);
|
|
156
|
+
}
|
|
157
|
+
reloaded = true;
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
...diff,
|
|
161
|
+
reloaded,
|
|
162
|
+
remotePath: deployment.remotePath,
|
|
163
|
+
wrote: true
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
var resolveSecrets = async (source, names) => {
|
|
167
|
+
const out = {};
|
|
168
|
+
for (const name of names) {
|
|
169
|
+
const resolved = await source.resolve(name);
|
|
170
|
+
if (resolved === null) {
|
|
171
|
+
throw new Error(`[deploy/env] secret "${name}" not found in source`);
|
|
172
|
+
}
|
|
173
|
+
out[name] = resolved.value;
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
};
|
|
177
|
+
var syncSecretsToDeployments = async (source, deployments) => {
|
|
178
|
+
const results = [];
|
|
179
|
+
for (const deployment of deployments) {
|
|
180
|
+
try {
|
|
181
|
+
const resolved = await resolveSecrets(source, deployment.secretNames ?? []);
|
|
182
|
+
const result = await syncEnvToTarget(deployment, resolved);
|
|
183
|
+
results.push({ deployment, result });
|
|
184
|
+
} catch (error) {
|
|
185
|
+
results.push({
|
|
186
|
+
deployment,
|
|
187
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return results;
|
|
192
|
+
};
|
|
193
|
+
var deploymentsUsing = (name, deployments) => deployments.filter((d) => (d.secretNames ?? []).includes(name));
|
|
194
|
+
export {
|
|
195
|
+
syncSecretsToDeployments,
|
|
196
|
+
syncEnvToTarget,
|
|
197
|
+
serializeEnvFile,
|
|
198
|
+
parseEnvFile,
|
|
199
|
+
deploymentsUsing
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
//# debugId=61C727D3C5F9CC6864756E2164756E21
|
|
203
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/env.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @absolutejs/deploy/env — push environment-variable files to remote\n * targets and fan-out secret rotations across the fleet.\n *\n * Composes with `@absolutejs/secrets`: that library handles the\n * in-process side (resolve, rotate, redact, in-process listeners);\n * this module handles the deploy-side (push values to remote env\n * files, atomic swap, conditional service reload).\n *\n * Narrow `SecretSource` interface — `@absolutejs/secrets`'\n * `SecretBroker` satisfies it structurally without a hard dep\n * either direction.\n *\n * Standard format: a remote env file at\n * `/etc/<appName>.env` (or wherever you choose) that systemd reads\n * via `EnvironmentFile=`, Docker reads via `--env-file`, and most\n * shell start scripts source. One `KEY=value` per line, no\n * newlines inside values.\n */\n\nimport type { Target } from './targets';\n\n// =============================================================================\n// SecretSource — narrow interface @absolutejs/secrets' broker satisfies\n// =============================================================================\n\n/**\n * Minimal interface this module needs to read secret values. The\n * `SecretBroker` from `@absolutejs/secrets` satisfies it structurally;\n * any other implementation (a Map, an AWS Secrets Manager client\n * wrapper, etc.) works as long as it exposes `resolve(name)`.\n */\nexport type SecretSource = {\n\tresolve: (\n\t\tname: string\n\t) => Promise<{ value: string; fingerprint?: string } | null>;\n};\n\n// =============================================================================\n// Env-file (de)serialization\n// =============================================================================\n\nconst KEY_PATTERN = /^[A-Z_][A-Z0-9_]*$/;\nconst NEEDS_QUOTING = /[\\s\"'`$\\\\#&|;<>(){}*?!]/;\n\nconst validateKey = (key: string): void => {\n\tif (!KEY_PATTERN.test(key)) {\n\t\tthrow new Error(\n\t\t\t`[deploy/env] invalid env key \"${key}\" — must match /^[A-Z_][A-Z0-9_]*$/`\n\t\t);\n\t}\n};\n\nconst serializeLine = (key: string, value: string): string => {\n\tvalidateKey(key);\n\tif (value.includes('\\n') || value.includes('\\r')) {\n\t\tthrow new Error(\n\t\t\t`[deploy/env] value for \"${key}\" contains a newline — env files cannot represent multi-line values. Use a separate file path for multi-line secrets.`\n\t\t);\n\t}\n\tif (NEEDS_QUOTING.test(value) || value.startsWith('=') || value === '') {\n\t\tconst escaped = value.replaceAll('\\\\', '\\\\\\\\').replaceAll('\"', '\\\\\"');\n\t\treturn `${key}=\"${escaped}\"`;\n\t}\n\treturn `${key}=${value}`;\n};\n\nexport const serializeEnvFile = (values: Record<string, string>): string => {\n\tconst lines: string[] = [];\n\tfor (const key of Object.keys(values).sort()) {\n\t\tconst value = values[key];\n\t\tif (value === undefined) continue;\n\t\tlines.push(serializeLine(key, value));\n\t}\n\treturn `${lines.join('\\n')}\\n`;\n};\n\nconst unquoteValue = (raw: string): string => {\n\tif (\n\t\traw.length >= 2 &&\n\t\traw.startsWith('\"') &&\n\t\traw.endsWith('\"')\n\t) {\n\t\tconst inner = raw.slice(1, -1);\n\t\treturn inner.replaceAll('\\\\\"', '\"').replaceAll('\\\\\\\\', '\\\\');\n\t}\n\tif (\n\t\traw.length >= 2 &&\n\t\traw.startsWith(\"'\") &&\n\t\traw.endsWith(\"'\")\n\t) {\n\t\treturn raw.slice(1, -1);\n\t}\n\treturn raw;\n};\n\n/**\n * Parse a remote env file's contents. Ignores blank lines and `#`\n * comments. Lines that don't match `KEY=VALUE` throw — the deploy\n * primitive owns the file, so unknown content is loud, not silent.\n */\nexport const parseEnvFile = (text: string): Record<string, string> => {\n\tconst result: Record<string, string> = {};\n\tfor (const rawLine of text.split('\\n')) {\n\t\tconst line = rawLine.trim();\n\t\tif (line.length === 0 || line.startsWith('#')) continue;\n\t\tconst eq = line.indexOf('=');\n\t\tif (eq <= 0) {\n\t\t\tthrow new Error(`[deploy/env] malformed env line: \"${rawLine}\"`);\n\t\t}\n\t\tconst key = line.slice(0, eq).trim();\n\t\tconst value = unquoteValue(line.slice(eq + 1).trim());\n\t\tvalidateKey(key);\n\t\tresult[key] = value;\n\t}\n\treturn result;\n};\n\n// =============================================================================\n// Deployment spec + sync primitive\n// =============================================================================\n\nexport type EnvDeployment = {\n\t/** The cloud Target whose remote filesystem we write to. */\n\ttarget: Target;\n\t/** Remote path for the env file (e.g. `/etc/myapp.env`). */\n\tremotePath: string;\n\t/**\n\t * Names of secrets this deployment consumes from the SecretSource.\n\t * Each name is resolved before the file is written.\n\t */\n\tsecretNames?: ReadonlyArray<string>;\n\t/**\n\t * Non-secret env vars to merge in (NODE_ENV, PORT, LOG_LEVEL).\n\t * If an `extras` key collides with a `secretNames` entry, throws —\n\t * silent overrides are worse than a loud rejection.\n\t */\n\textras?: Record<string, string>;\n\t/** chmod for the file. Default `'600'`. */\n\tmode?: string;\n\t/** chown for the file. Default unchanged. */\n\towner?: string;\n\t/**\n\t * Command to run after the file changes. Skipped when the diff is\n\t * empty — bouncing a service for an identical file is the wrong\n\t * default.\n\t */\n\treload?: string;\n};\n\nexport type EnvSyncResult = {\n\t/** Keys present in the new spec but not the existing file. */\n\tadded: string[];\n\t/** Keys whose values changed (fingerprints, NOT plaintext, for safety). */\n\tchanged: string[];\n\t/** Keys removed from the spec (still in the existing file). */\n\tremoved: string[];\n\t/** Keys whose values matched — file wasn't rewritten for these. */\n\tunchanged: string[];\n\t/** True iff `deployment.reload` was invoked. */\n\treloaded: boolean;\n\t/** True iff the file content changed (atomic-write happened). */\n\twrote: boolean;\n\t/** Remote path that was synced. */\n\tremotePath: string;\n};\n\nconst shellQuote = (value: string): string =>\n\t`'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n\nconst tryReadRemoteFile = async (\n\ttarget: Target,\n\tremotePath: string\n): Promise<string | undefined> => {\n\tconst result = await target.exec(\n\t\t`if [ -f ${shellQuote(remotePath)} ]; then cat ${shellQuote(remotePath)}; else echo __ABS_DEPLOY_ENV_ABSENT__; fi`\n\t);\n\tif (result.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`[deploy/env] failed to read ${remotePath}: exit ${result.exitCode}: ${result.stderr || result.stdout}`\n\t\t);\n\t}\n\tif (result.stdout.trim() === '__ABS_DEPLOY_ENV_ABSENT__') return undefined;\n\treturn result.stdout;\n};\n\nconst mergeValues = (\n\tdeployment: EnvDeployment,\n\tresolved: Record<string, string>\n): Record<string, string> => {\n\tconst out: Record<string, string> = {};\n\tfor (const [key, value] of Object.entries(deployment.extras ?? {})) {\n\t\tvalidateKey(key);\n\t\tout[key] = value;\n\t}\n\tfor (const [key, value] of Object.entries(resolved)) {\n\t\tif (out[key] !== undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`[deploy/env] \"${key}\" defined in BOTH extras and secretNames for ${deployment.remotePath} — remove one`\n\t\t\t);\n\t\t}\n\t\tout[key] = value;\n\t}\n\treturn out;\n};\n\nconst diffEnv = (\n\tprevious: Record<string, string>,\n\tnext: Record<string, string>\n): Pick<EnvSyncResult, 'added' | 'changed' | 'removed' | 'unchanged'> => {\n\tconst added: string[] = [];\n\tconst changed: string[] = [];\n\tconst removed: string[] = [];\n\tconst unchanged: string[] = [];\n\tconst allKeys = new Set([...Object.keys(previous), ...Object.keys(next)]);\n\tfor (const key of [...allKeys].sort()) {\n\t\tconst prev = previous[key];\n\t\tconst curr = next[key];\n\t\tif (curr === undefined) removed.push(key);\n\t\telse if (prev === undefined) added.push(key);\n\t\telse if (prev === curr) unchanged.push(key);\n\t\telse changed.push(key);\n\t}\n\treturn { added, changed, removed, unchanged };\n};\n\nconst writeRemoteFileAtomically = async (\n\ttarget: Target,\n\tremotePath: string,\n\tcontents: string,\n\tmode: string,\n\towner?: string\n): Promise<void> => {\n\tconst tempPath = `${remotePath}.new.${Math.floor(Date.now() / 1000)}`;\n\tconst dir = remotePath.split('/').slice(0, -1).join('/') || '/';\n\tconst mkdir = await target.exec(`mkdir -p ${shellQuote(dir)}`);\n\tif (mkdir.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`[deploy/env] mkdir ${dir} failed: ${mkdir.stderr || mkdir.stdout}`\n\t\t);\n\t}\n\t// Write via stdin redirect — no shell escaping of the env file content.\n\tconst writeResult = await target.exec(`cat > ${shellQuote(tempPath)}`, {\n\t\tstdin: contents\n\t});\n\tif (writeResult.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`[deploy/env] write to ${tempPath} failed: ${writeResult.stderr || writeResult.stdout}`\n\t\t);\n\t}\n\tconst chmod = await target.exec(\n\t\t`chmod ${shellQuote(mode)} ${shellQuote(tempPath)}`\n\t);\n\tif (chmod.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`[deploy/env] chmod failed: ${chmod.stderr || chmod.stdout}`\n\t\t);\n\t}\n\tif (owner !== undefined) {\n\t\tconst chown = await target.exec(\n\t\t\t`chown ${shellQuote(owner)} ${shellQuote(tempPath)}`\n\t\t);\n\t\tif (chown.exitCode !== 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`[deploy/env] chown failed: ${chown.stderr || chown.stdout}`\n\t\t\t);\n\t\t}\n\t}\n\tconst mv = await target.exec(\n\t\t`mv ${shellQuote(tempPath)} ${shellQuote(remotePath)}`\n\t);\n\tif (mv.exitCode !== 0) {\n\t\tthrow new Error(`[deploy/env] mv failed: ${mv.stderr || mv.stdout}`);\n\t}\n};\n\n/**\n * Push an env file to a single target. Atomic: write to a `.new`\n * tempfile, chmod / chown, then `mv` into place. Diffs the merged\n * values against the existing file content and skips the\n * write+reload when nothing changed.\n */\nexport const syncEnvToTarget = async (\n\tdeployment: EnvDeployment,\n\tvalues: Record<string, string>\n): Promise<EnvSyncResult> => {\n\tconst mode = deployment.mode ?? '600';\n\tconst merged = mergeValues(deployment, values);\n\tconst previousText = await tryReadRemoteFile(\n\t\tdeployment.target,\n\t\tdeployment.remotePath\n\t);\n\tconst previous = previousText === undefined ? {} : parseEnvFile(previousText);\n\tconst diff = diffEnv(previous, merged);\n\tconst changed = diff.added.length + diff.changed.length + diff.removed.length;\n\n\tif (changed === 0) {\n\t\treturn {\n\t\t\t...diff,\n\t\t\treloaded: false,\n\t\t\tremotePath: deployment.remotePath,\n\t\t\twrote: false\n\t\t};\n\t}\n\n\tconst nextText = serializeEnvFile(merged);\n\tawait writeRemoteFileAtomically(\n\t\tdeployment.target,\n\t\tdeployment.remotePath,\n\t\tnextText,\n\t\tmode,\n\t\tdeployment.owner\n\t);\n\n\tlet reloaded = false;\n\tif (deployment.reload !== undefined) {\n\t\tconst reload = await deployment.target.exec(deployment.reload);\n\t\tif (reload.exitCode !== 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`[deploy/env] reload command failed: ${reload.stderr || reload.stdout}`\n\t\t\t);\n\t\t}\n\t\treloaded = true;\n\t}\n\n\treturn {\n\t\t...diff,\n\t\treloaded,\n\t\tremotePath: deployment.remotePath,\n\t\twrote: true\n\t};\n};\n\n// =============================================================================\n// Multi-target fan-out via a SecretSource\n// =============================================================================\n\nconst resolveSecrets = async (\n\tsource: SecretSource,\n\tnames: ReadonlyArray<string>\n): Promise<Record<string, string>> => {\n\tconst out: Record<string, string> = {};\n\tfor (const name of names) {\n\t\tconst resolved = await source.resolve(name);\n\t\tif (resolved === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`[deploy/env] secret \"${name}\" not found in source`\n\t\t\t);\n\t\t}\n\t\tout[name] = resolved.value;\n\t}\n\treturn out;\n};\n\nexport type DeploymentSyncResult = {\n\tdeployment: EnvDeployment;\n\tresult?: EnvSyncResult;\n\terror?: Error;\n};\n\n/**\n * Fan-out push: for each deployment, resolve its `secretNames` via\n * the source, merge with `extras`, and push to the target. Resolves\n * are fresh every call — so calling this again after\n * `broker.rotate(name)` propagates the new value to every\n * deployment that uses it.\n *\n * Best-effort across the fan-out: a per-target failure is captured\n * in the result, but doesn't stop the rest. Operator inspects the\n * returned array, fixes the broken target, re-runs.\n */\nexport const syncSecretsToDeployments = async (\n\tsource: SecretSource,\n\tdeployments: ReadonlyArray<EnvDeployment>\n): Promise<DeploymentSyncResult[]> => {\n\tconst results: DeploymentSyncResult[] = [];\n\tfor (const deployment of deployments) {\n\t\ttry {\n\t\t\tconst resolved = await resolveSecrets(\n\t\t\t\tsource,\n\t\t\t\tdeployment.secretNames ?? []\n\t\t\t);\n\t\t\tconst result = await syncEnvToTarget(deployment, resolved);\n\t\t\tresults.push({ deployment, result });\n\t\t} catch (error) {\n\t\t\tresults.push({\n\t\t\t\tdeployment,\n\t\t\t\terror: error instanceof Error ? error : new Error(String(error))\n\t\t\t});\n\t\t}\n\t}\n\treturn results;\n};\n\n/**\n * Returns just the deployments that use a given secret name. Useful\n * for \"rotate one secret and propagate ONLY to the consumers\" —\n * `syncSecretsToDeployments(source, deploymentsUsing(name, deployments))`.\n */\nexport const deploymentsUsing = (\n\tname: string,\n\tdeployments: ReadonlyArray<EnvDeployment>\n): EnvDeployment[] =>\n\tdeployments.filter((d) => (d.secretNames ?? []).includes(name));\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AA0CA,IAAM,cAAc;AACpB,IAAM,gBAAgB;AAEtB,IAAM,cAAc,CAAC,QAAsB;AAAA,EAC1C,IAAI,CAAC,YAAY,KAAK,GAAG,GAAG;AAAA,IAC3B,MAAM,IAAI,MACT,iCAAiC,6CAClC;AAAA,EACD;AAAA;AAGD,IAAM,gBAAgB,CAAC,KAAa,UAA0B;AAAA,EAC7D,YAAY,GAAG;AAAA,EACf,IAAI,MAAM,SAAS;AAAA,CAAI,KAAK,MAAM,SAAS,IAAI,GAAG;AAAA,IACjD,MAAM,IAAI,MACT,2BAA2B,+HAC5B;AAAA,EACD;AAAA,EACA,IAAI,cAAc,KAAK,KAAK,KAAK,MAAM,WAAW,GAAG,KAA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
|
"sources": ["../src/targets.ts", "../src/cloudTarget.ts", "../src/hetzner.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Target interface + bundled adapters (localTarget, sshTarget).\n *\n * A Target is the narrowest abstraction over \"a place I can deploy to\":\n *\n * - `exec(cmd, opts?)` — run a shell command, capture stdout/stderr/exitCode.\n * - `upload(localPath, remotePath, opts?)` — copy a local file or directory\n * to the target. Implementation is free to use whatever is fast (rsync,\n * scp, mv).\n * - `close?()` — optional teardown.\n *\n * Two adapters are bundled:\n *\n * - `localTarget` runs in a temp directory on the local filesystem. Useful\n * for tests and for \"deploy\" workflows that happen on the same host.\n * - `sshTarget` shells out to the system `ssh` and `rsync` binaries. No\n * `ssh2` npm dependency — the controller machine just needs `ssh` and\n * (optionally) `rsync` in PATH, which is universal on Mac/Linux/WSL.\n *\n * Provider-specific targets (Cloudflare Workers HTTP API, Fly Machines API,\n * AWS Fargate) don't fit \"exec + upload\" and ship as siblings later.\n */\n\nimport { mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport type ExecOptions = {\n\t/** Working directory on the target. Default: target's root. */\n\tcwd?: string;\n\t/** Env vars to set for this command (merged onto target.env). */\n\tenv?: Record<string, string>;\n\t/** Hard kill after this many ms. Default 600_000 (10 min). 0 disables. */\n\ttimeoutMs?: number;\n\t/** Pipe stdout/stderr through here as it streams (lines, newline-stripped). */\n\tonLog?: (line: string, stream: 'stdout' | 'stderr') => void;\n\t/** Stdin payload — a string is written verbatim. */\n\tstdin?: string;\n};\n\nexport type ExecResult = {\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n};\n\nexport type UploadOptions = {\n\t/** Exclude paths matching these globs from a directory upload. */\n\texclude?: string[];\n\t/** When uploading a directory, delete remote files not present locally. */\n\tdeleteOrphans?: boolean;\n};\n\nexport type Target = {\n\t/** Human-readable description (e.g. \"ssh root@droplet-1.example.com\"). */\n\treadonly description: string;\n\texec: (cmd: string, opts?: ExecOptions) => Promise<ExecResult>;\n\tupload: (localPath: string, remotePath: string, opts?: UploadOptions) => Promise<void>;\n\tclose?: () => Promise<void>;\n};\n\n// -----------------------------------------------------------------------------\n// localTarget\n// -----------------------------------------------------------------------------\n\nexport type LocalTargetOptions = {\n\t/** Root directory the target operates in. Created if missing. */\n\troot: string;\n\t/** Env merged into every exec. */\n\tenv?: Record<string, string>;\n};\n\nconst decodeChunks = async (\n\treader: ReadableStream<Uint8Array> | null,\n\tonLine: ((line: string) => void) | undefined,\n): Promise<string> => {\n\tif (!reader) return '';\n\tconst decoder = new TextDecoder();\n\tlet buffer = '';\n\tlet collected = '';\n\tconst stream = reader.getReader();\n\ttry {\n\t\twhile (true) {\n\t\t\tconst { done, value } = await stream.read();\n\t\t\tif (done) break;\n\t\t\tconst chunk = decoder.decode(value, { stream: true });\n\t\t\tcollected += chunk;\n\t\t\tif (!onLine) continue;\n\t\t\tbuffer += chunk;\n\t\t\tlet newline = buffer.indexOf('\\n');\n\t\t\twhile (newline !== -1) {\n\t\t\t\tconst line = buffer.slice(0, newline).replace(/\\r$/, '');\n\t\t\t\tif (line.length > 0) onLine(line);\n\t\t\t\tbuffer = buffer.slice(newline + 1);\n\t\t\t\tnewline = buffer.indexOf('\\n');\n\t\t\t}\n\t\t}\n\t\tconst tail = decoder.decode();\n\t\tcollected += tail;\n\t\tif (onLine && (buffer + tail).length > 0) onLine((buffer + tail).replace(/\\r$/, ''));\n\t} finally {\n\t\tstream.releaseLock();\n\t}\n\treturn collected;\n};\n\nconst runSpawn = async (\n\targv: string[],\n\toptions: {\n\t\tcwd?: string;\n\t\tenv?: Record<string, string>;\n\t\ttimeoutMs?: number;\n\t\tonLog?: ExecOptions['onLog'];\n\t\tstdin?: string;\n\t},\n): Promise<ExecResult> => {\n\tconst proc = Bun.spawn(argv, {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tstderr: 'pipe',\n\t\tstdin: options.stdin === undefined ? 'ignore' : 'pipe',\n\t\tstdout: 'pipe',\n\t});\n\n\tif (options.stdin !== undefined && proc.stdin) {\n\t\t// Bun.spawn returns a FileSink for piped stdin — `write` + `end`, not a\n\t\t// WritableStream. (We use a permissive cast because @types/bun's\n\t\t// Subprocess.stdin discriminant flips based on the stdin generic.)\n\t\tconst sink = proc.stdin as unknown as {\n\t\t\twrite: (chunk: string | Uint8Array) => number | Promise<number>;\n\t\t\tend: () => void | Promise<void>;\n\t\t};\n\t\tconst wrote = sink.write(options.stdin);\n\t\tif (wrote && typeof (wrote as Promise<number>).then === 'function') {\n\t\t\tawait wrote;\n\t\t}\n\t\tconst ended = sink.end();\n\t\tif (ended && typeof (ended as Promise<void>).then === 'function') {\n\t\t\tawait ended;\n\t\t}\n\t}\n\n\tconst timeout = options.timeoutMs ?? 600_000;\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tif (timeout > 0) {\n\t\ttimer = setTimeout(() => {\n\t\t\ttry { proc.kill(); } catch { /* already gone */ }\n\t\t}, timeout);\n\t}\n\n\tconst stdoutPromise = decodeChunks(\n\t\tproc.stdout as unknown as ReadableStream<Uint8Array>,\n\t\toptions.onLog ? (line) => options.onLog!(line, 'stdout') : undefined,\n\t);\n\tconst stderrPromise = decodeChunks(\n\t\tproc.stderr as unknown as ReadableStream<Uint8Array>,\n\t\toptions.onLog ? (line) => options.onLog!(line, 'stderr') : undefined,\n\t);\n\n\tconst [stdout, stderr, exitCode] = await Promise.all([\n\t\tstdoutPromise,\n\t\tstderrPromise,\n\t\tproc.exited,\n\t]);\n\tif (timer) clearTimeout(timer);\n\n\treturn { exitCode: exitCode ?? -1, stderr, stdout };\n};\n\nexport const localTarget = (options: LocalTargetOptions): Target => {\n\tconst baseEnv = { ...options.env };\n\tconst ensureRoot = async () => { await mkdir(options.root, { recursive: true }); };\n\n\treturn {\n\t\tdescription: `local ${options.root}`,\n\t\texec: async (cmd, opts) => {\n\t\t\tawait ensureRoot();\n\t\t\treturn runSpawn(['sh', '-c', cmd], {\n\t\t\t\tcwd: opts?.cwd ?? options.root,\n\t\t\t\tenv: { ...process.env, ...baseEnv, ...(opts?.env ?? {}) } as Record<string, string>,\n\t\t\t\tonLog: opts?.onLog,\n\t\t\t\tstdin: opts?.stdin,\n\t\t\t\ttimeoutMs: opts?.timeoutMs,\n\t\t\t});\n\t\t},\n\t\tupload: async (localPath, remotePath, opts) => {\n\t\t\tawait ensureRoot();\n\t\t\tconst dest = remotePath.startsWith('/') ? remotePath : join(options.root, remotePath);\n\t\t\tconst argv = ['rsync', '-a'];\n\t\t\tif (opts?.deleteOrphans) argv.push('--delete');\n\t\t\tfor (const pattern of opts?.exclude ?? []) argv.push('--exclude', pattern);\n\t\t\t// rsync semantics: a trailing slash on the source copies *contents*; without it the dir itself is nested.\n\t\t\targv.push(localPath, dest);\n\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`local upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t}\n\t\t},\n\t};\n};\n\n// -----------------------------------------------------------------------------\n// sshTarget\n// -----------------------------------------------------------------------------\n\nexport type SshTargetOptions = {\n\t/** Hostname or IP of the remote. */\n\thost: string;\n\t/** Login user. Default `root`. */\n\tuser?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\t/** Path to SSH identity file. Default: ssh's own search. */\n\tidentity?: string;\n\t/** Extra flags appended to every `ssh` invocation. */\n\tsshFlags?: string[];\n\t/**\n\t * Use rsync for `upload`. Default true. When false, falls back to `scp`\n\t * which is universal but doesn't support delete / exclude.\n\t */\n\trsync?: boolean;\n\t/**\n\t * Env vars to forward via `ssh -o SendEnv=...`. Most remote sshd configs\n\t * accept only `LANG` and `LC_*` by default; for app env vars use the\n\t * step `env` option instead, which prepends `KEY=value` to the command.\n\t */\n\tforwardEnv?: string[];\n};\n\nconst sshTargetString = (options: SshTargetOptions): string => {\n\tconst user = options.user ?? 'root';\n\treturn `${user}@${options.host}`;\n};\n\nconst sshBaseFlags = (options: SshTargetOptions): string[] => {\n\tconst flags: string[] = [];\n\tif (options.port !== undefined && options.port !== 22) flags.push('-p', String(options.port));\n\tif (options.identity !== undefined) flags.push('-i', options.identity);\n\t// Never get stuck on a host-key prompt; treat unknown hosts as a fatal config issue rather than a UX detour.\n\tflags.push('-o', 'BatchMode=yes', '-o', 'StrictHostKeyChecking=accept-new');\n\tfor (const flag of options.sshFlags ?? []) flags.push(flag);\n\treturn flags;\n};\n\nconst shellQuote = (value: string): string => `'${value.replace(/'/g, `'\\\\''`)}'`;\n\nconst buildRemoteCmd = (cmd: string, opts: ExecOptions | undefined): string => {\n\tconst env = opts?.env;\n\tconst envPrefix = env\n\t\t? Object.entries(env).map(([k, v]) => `${k}=${shellQuote(v)}`).join(' ') + ' '\n\t\t: '';\n\tif (opts?.cwd) {\n\t\treturn `cd ${shellQuote(opts.cwd)} && ${envPrefix}${cmd}`;\n\t}\n\treturn `${envPrefix}${cmd}`;\n};\n\nexport const sshTarget = (options: SshTargetOptions): Target => {\n\tconst remote = sshTargetString(options);\n\tconst useRsync = options.rsync ?? true;\n\n\treturn {\n\t\tdescription: `ssh ${remote}${options.port && options.port !== 22 ? `:${options.port}` : ''}`,\n\t\texec: async (cmd, opts) => {\n\t\t\tconst argv = ['ssh', ...sshBaseFlags(options)];\n\t\t\tfor (const name of options.forwardEnv ?? []) argv.push('-o', `SendEnv=${name}`);\n\t\t\targv.push(remote, buildRemoteCmd(cmd, opts));\n\t\t\treturn runSpawn(argv, {\n\t\t\t\tonLog: opts?.onLog,\n\t\t\t\tstdin: opts?.stdin,\n\t\t\t\ttimeoutMs: opts?.timeoutMs,\n\t\t\t});\n\t\t},\n\t\tupload: async (localPath, remotePath, opts) => {\n\t\t\tif (useRsync) {\n\t\t\t\tconst sshCmd = ['ssh', ...sshBaseFlags(options)].map((part) => part.includes(' ') ? `'${part}'` : part).join(' ');\n\t\t\t\tconst argv = ['rsync', '-az', '-e', sshCmd];\n\t\t\t\tif (opts?.deleteOrphans) argv.push('--delete');\n\t\t\t\tfor (const pattern of opts?.exclude ?? []) argv.push('--exclude', pattern);\n\t\t\t\targv.push(localPath, `${remote}:${remotePath}`);\n\t\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\t\tif (result.exitCode !== 0) {\n\t\t\t\t\tthrow new Error(`rsync upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// scp fallback — no exclude, no delete. We still need -r to copy directories.\n\t\t\tconst argv = ['scp', '-r', ...sshBaseFlags(options), localPath, `${remote}:${remotePath}`];\n\t\t\tconst result = await runSpawn(argv, { timeoutMs: 600_000 });\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\tthrow new Error(`scp upload failed (exit ${result.exitCode}): ${result.stderr || result.stdout}`);\n\t\t\t}\n\t\t},\n\t};\n};\n",
|
|
6
|
-
"/**\n * Shared \"cloud-provider Target\" plumbing used by the\n * provider-specific adapters (`./digitalocean`, `./hetzner`, future\n * `./linode`, `./vultr`, etc.).\n *\n * The provider supplies a small `CloudTargetHooks` bag that knows\n * the provider's:\n *\n * - find-by-name lookup\n * - create call (closure over create params)\n * - fetch-by-id (used to poll for `active`)\n * - destroy-by-id\n * - status + ipv4 + id extraction from the provider's Server shape\n * - readiness predicate (status reached the terminal \"running\" value)\n *\n * `createCloudTarget()` does the universal machinery: provision-or-\n * reuse, poll until ready + IPv4, wait for SSH probe, build\n * `sshTarget` against the IPv4, return the Target wrapped with\n * `{ id, ipv4, destroy() }`.\n *\n * The public adapter (e.g. `digitalOceanTarget`) is a 30-line facade\n * that wires its provider-specific bits and renames `id` → `dropletId`\n * on the way out.\n */\n\nimport type { Target } from './targets';\nimport { sshTarget } from './targets';\n\n/** Provider-specific hooks. Keep these pure of network IO timing — the helper schedules. */\nexport type CloudTargetHooks<Server> = {\n\t/** Find a server by name. Returns undefined if absent. */\n\tfindByName: (name: string) => Promise<Server | undefined>;\n\t/** Create the server. Closure over provider-specific create params. */\n\tcreate: () => Promise<Server>;\n\t/** Fetch a fresh copy of the server by id. Used to poll. */\n\tfetch: (id:
|
|
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
7
|
"/**\n * @absolutejs/deploy/hetzner — provision-or-reuse Target adapter for\n * Hetzner Cloud servers. Sibling to {@link digitalOceanTarget}; same\n * shape, different API.\n *\n * What it does:\n *\n * 1. Looks up a server by `name`. If present and running, reuses it.\n * 2. If not present, creates it via the Hetzner Cloud v1 API and\n * waits for `status === 'running'` with a public IPv4 assigned.\n * 3. Waits for SSH readiness (TCP connect on port 22 with backoff,\n * or a caller-supplied probe).\n * 4. Returns a Target that wraps sshTarget against the server's\n * public IPv4, plus `serverId`, `ipv4`, and a `destroy()` helper.\n *\n * Idempotent by name — Hetzner enforces unique server names per\n * project, so calling twice with the same name returns the same\n * server.\n *\n * Narrow HetznerClientLike interface keeps the official `hcloud-js`\n * SDK out as a hard dep. Default client uses `fetch` against\n * `api.hetzner.cloud/v1`; pass your own for retry / observability.\n */\n\nimport type { Target } from './targets';\nimport { createCloudTarget, type CloudTargetHooks } from './cloudTarget';\n\nconst HETZNER_API_BASE = 'https://api.hetzner.cloud/v1';\n\n/**\n * Minimal subset of Hetzner Cloud API calls we make. Lets callers\n * BYO a client with retry / observability / etc.\n */\nexport type HetznerClientLike = {\n\trequest: <T = unknown>(\n\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\tpath: string,\n\t\tbody?: unknown\n\t) => Promise<T>;\n};\n\n/** A Hetzner Cloud server, narrowed to what we inspect. */\nexport type HetznerServer = {\n\tid: number;\n\tname: string;\n\tstatus:\n\t\t| 'initializing'\n\t\t| 'starting'\n\t\t| 'running'\n\t\t| 'stopping'\n\t\t| 'off'\n\t\t| 'deleting'\n\t\t| 'migrating'\n\t\t| 'rebuilding'\n\t\t| 'unknown';\n\tpublic_net: {\n\t\tipv4: { id: number; ip: string; blocked: boolean; dns_ptr?: string } | null;\n\t\tipv6: { id: number; ip: string; blocked: boolean } | null;\n\t};\n\tserver_type?: { name: string };\n\tdatacenter?: { location: { name: string } };\n\tlabels?: Record<string, string>;\n};\n\nexport type HetznerTargetOptions = {\n\t/** API token (https://docs.hetzner.cloud/#authentication). Required unless `client` is set. */\n\ttoken?: string;\n\t/** Custom client. Overrides token-built default. */\n\tclient?: HetznerClientLike;\n\n\t// ── Server shape ─────────────────────────────────────────────────\n\t/** Server name. Hetzner-unique per project; also our idempotency key. */\n\tname: string;\n\t/** Location slug — `'nbg1'`, `'fsn1'`, `'hel1'`, `'ash'`, `'hil'`. */\n\tlocation: string;\n\t/** Server type slug — `'cx22'`, `'cpx11'`, `'ccx13'`, etc. */\n\tserverType: string;\n\t/** Image slug or numeric id, e.g. `'ubuntu-22.04'`. */\n\timage: string | number;\n\t/** SSH key fingerprints, numeric ids, or names. At least one required. */\n\tsshKeys: ReadonlyArray<string | number>;\n\t/** Labels (Hetzner's key-value tags). */\n\tlabels?: Record<string, string>;\n\t/** cloud-init user data — a shell script or YAML config. */\n\tuserData?: string;\n\t/** Attach to a Cloud Network (by id). */\n\tnetworkId?: number;\n\t/** Disable IPv4 public addressing. Default: enabled. */\n\tdisablePublicIpv4?: boolean;\n\t/** Disable IPv6 public addressing. Default: enabled. */\n\tdisablePublicIpv6?: boolean;\n\n\t// ── SSH wrap ────────────────────────────────────────────────────\n\t/** SSH login user. Default `'root'`. */\n\tuser?: string;\n\t/** Path to SSH identity file forwarded to sshTarget. */\n\tidentity?: string;\n\t/** SSH port. Default 22. */\n\tport?: number;\n\n\t// ── Timing ──────────────────────────────────────────────────────\n\t/** Max time to wait for server `running` + IPv4. Default 5 min. */\n\tprovisionTimeoutMs?: number;\n\t/** Max time to wait for SSH probe to succeed. Default 2 min. */\n\tsshReadinessTimeoutMs?: number;\n\t/** Poll interval for provision + ssh probe. Default 5 s. */\n\tpollIntervalMs?: number;\n\n\t// ── Observability + injection points ───────────────────────────\n\t/** Called with status updates (one line each). Default: noop. */\n\tonLog?: (line: string) => void;\n\t/**\n\t * Override the SSH readiness probe. Default opens a TCP socket to\n\t * `host:port`. Tests pass a fake probe to skip real network IO.\n\t */\n\tprobeSsh?: (host: string, port: number) => Promise<boolean>;\n\t/** Sleep used between polls. Tests can pass a synchronous resolver. */\n\tsleep?: (ms: number) => Promise<void>;\n\t/** Wall clock. Defaults to `Date.now`. Tests can swap. */\n\tnow?: () => number;\n};\n\nexport type HetznerTarget = Target & {\n\treadonly serverId: number;\n\treadonly ipv4: string;\n\t/** Destroy the server via the Hetzner API. */\n\tdestroy: () => Promise<void>;\n};\n\nexport class HetznerError extends Error {\n\treadonly status: number;\n\treadonly body: unknown;\n\tconstructor(message: string, status: number, body: unknown) {\n\t\tsuper(message);\n\t\tthis.name = 'HetznerError';\n\t\tthis.status = status;\n\t\tthis.body = body;\n\t}\n}\n\n/**\n * fetch-backed default client. Talks JSON to `api.hetzner.cloud/v1`.\n * Throws HetznerError on non-2xx with the response body attached so\n * the caller can switch on `err.status`.\n */\nexport const createHetznerClient = (\n\ttoken: string,\n\toptions: { baseUrl?: string; fetch?: typeof fetch } = {}\n): HetznerClientLike => {\n\tconst base = options.baseUrl ?? HETZNER_API_BASE;\n\tconst f = options.fetch ?? fetch;\n\treturn {\n\t\trequest: async <T>(\n\t\t\tmethod: 'GET' | 'POST' | 'DELETE',\n\t\t\tpath: string,\n\t\t\tbody?: unknown\n\t\t): Promise<T> => {\n\t\t\tconst init: RequestInit = {\n\t\t\t\theaders: {\n\t\t\t\t\tauthorization: `Bearer ${token}`,\n\t\t\t\t\t'content-type': 'application/json'\n\t\t\t\t},\n\t\t\t\tmethod\n\t\t\t};\n\t\t\tif (body !== undefined) init.body = JSON.stringify(body);\n\t\t\tconst response = await f(`${base}${path}`, init);\n\t\t\tif (response.status === 204) return undefined as T;\n\t\t\tconst text = await response.text();\n\t\t\tconst parsed = text.length > 0 ? JSON.parse(text) : undefined;\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new HetznerError(\n\t\t\t\t\t`Hetzner Cloud API ${method} ${path} failed: ${response.status} ${response.statusText}`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tparsed\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn parsed as T;\n\t\t}\n\t};\n};\n\nconst resolveClient = (\n\toptions: Pick<HetznerTargetOptions, 'client' | 'token'>\n): HetznerClientLike => {\n\tif (options.client !== undefined) return options.client;\n\tif (options.token !== undefined && options.token.length > 0) {\n\t\treturn createHetznerClient(options.token);\n\t}\n\tthrow new Error(\n\t\t'[deploy/hetzner] either `token` or `client` must be provided'\n\t);\n};\n\nconst publicIpv4 = (server: HetznerServer): string | undefined =>\n\tserver.public_net.ipv4?.ip;\n\n/**\n * Find a server by name. Returns undefined if absent. Hetzner\n * enforces unique server names per project, so duplicates aren't\n * possible — but if the API ever returns >1 we still surface that\n * loudly.\n */\nexport const findHetznerServer = async (\n\tclient: HetznerClientLike,\n\tname: string\n): Promise<HetznerServer | undefined> => {\n\tconst body = await client.request<{ servers: HetznerServer[] }>(\n\t\t'GET',\n\t\t`/servers?name=${encodeURIComponent(name)}`\n\t);\n\tconst matches = body.servers.filter((server) => server.name === name);\n\tif (matches.length === 0) return undefined;\n\tif (matches.length > 1) {\n\t\tthrow new Error(\n\t\t\t`[deploy/hetzner] multiple servers named \"${name}\" (${matches\n\t\t\t\t.map((server) => server.id)\n\t\t\t\t.join(', ')}). Hetzner shouldn't allow this — resolve manually.`\n\t\t);\n\t}\n\treturn matches[0];\n};\n\n/** List servers, optionally filtered by label selector. */\nexport const listHetznerServers = async (options: {\n\ttoken?: string;\n\tclient?: HetznerClientLike;\n\t/** Label selector, e.g. `'env=prod'` or `'env in (prod,staging)'`. */\n\tlabelSelector?: string;\n}): Promise<HetznerServer[]> => {\n\tconst client = resolveClient(options);\n\tconst path =\n\t\toptions.labelSelector !== undefined\n\t\t\t? `/servers?label_selector=${encodeURIComponent(options.labelSelector)}`\n\t\t\t: '/servers';\n\tconst body = await client.request<{ servers: HetznerServer[] }>('GET', path);\n\treturn body.servers;\n};\n\n/** Destroy a server by id. 404 treated as idempotent success. */\nexport const destroyHetznerServer = async (options: {\n\ttoken?: string;\n\tclient?: HetznerClientLike;\n\tid: number;\n}): Promise<void> => {\n\tconst client = resolveClient(options);\n\ttry {\n\t\tawait client.request('DELETE', `/servers/${options.id}`);\n\t} catch (error) {\n\t\tif (error instanceof HetznerError && error.status === 404) {\n\t\t\treturn; // already destroyed — idempotent\n\t\t}\n\t\tthrow error;\n\t}\n};\n\n/**\n * Provision-or-reuse a Hetzner Cloud server by name, wait for SSH,\n * return a Target. Idempotent: same name → same server.\n */\nexport const hetznerTarget = async (\n\toptions: HetznerTargetOptions\n): Promise<HetznerTarget> => {\n\tconst client = resolveClient(options);\n\tconst publicIpv4Enabled = options.disablePublicIpv4 !== true;\n\tconst publicIpv6Enabled = options.disablePublicIpv6 !== true;\n\n\tconst hooks: CloudTargetHooks<HetznerServer> = {\n\t\tcreate: async () => {\n\t\t\tconst created = await client.request<{ server: HetznerServer }>(\n\t\t\t\t'POST',\n\t\t\t\t'/servers',\n\t\t\t\t{\n\t\t\t\t\tname: options.name,\n\t\t\t\t\tlocation: options.location,\n\t\t\t\t\tserver_type: options.serverType,\n\t\t\t\t\timage: options.image,\n\t\t\t\t\tssh_keys: [...options.sshKeys],\n\t\t\t\t\tstart_after_create: true,\n\t\t\t\t\tpublic_net: {\n\t\t\t\t\t\tenable_ipv4: publicIpv4Enabled,\n\t\t\t\t\t\tenable_ipv6: publicIpv6Enabled\n\t\t\t\t\t},\n\t\t\t\t\t...(options.labels !== undefined\n\t\t\t\t\t\t? { labels: options.labels }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(options.userData !== undefined\n\t\t\t\t\t\t? { user_data: options.userData }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\t...(options.networkId !== undefined\n\t\t\t\t\t\t? { networks: [options.networkId] }\n\t\t\t\t\t\t: {})\n\t\t\t\t}\n\t\t\t);\n\t\t\treturn created.server;\n\t\t},\n\t\tdestroy: (id) => destroyHetznerServer({ client, id }),\n\t\tfetch: async (id) => {\n\t\t\tconst refreshed: { server: HetznerServer } = await client.request(\n\t\t\t\t'GET',\n\t\t\t\t`/servers/${id}`\n\t\t\t);\n\t\t\treturn refreshed.server;\n\t\t},\n\t\tfindByName: (name) => findHetznerServer(client, name),\n\t\tgetId: (server) => server.id,\n\t\tgetIpv4: publicIpv4,\n\t\tgetStatus: (server) => server.status,\n\t\tisReady: (server) => server.status === 'running'\n\t};\n\n\tconst result = await createCloudTarget(hooks, {\n\t\tdescribeTarget: (sshDescription) =>\n\t\t\t`hetzner server \"${options.name}\" (${sshDescription})`,\n\t\tentityWord: 'server',\n\t\tlogPrefix: '[hetzner]',\n\t\tname: options.name,\n\t\tregion: options.location,\n\t\t...(options.user !== undefined ? { user: options.user } : {}),\n\t\t...(options.identity !== undefined ? { identity: options.identity } : {}),\n\t\t...(options.port !== undefined ? { port: options.port } : {}),\n\t\t...(options.provisionTimeoutMs !== undefined\n\t\t\t? { provisionTimeoutMs: options.provisionTimeoutMs }\n\t\t\t: {}),\n\t\t...(options.sshReadinessTimeoutMs !== undefined\n\t\t\t? { sshReadinessTimeoutMs: options.sshReadinessTimeoutMs }\n\t\t\t: {}),\n\t\t...(options.pollIntervalMs !== undefined\n\t\t\t? { pollIntervalMs: options.pollIntervalMs }\n\t\t\t: {}),\n\t\t...(options.onLog !== undefined ? { onLog: options.onLog } : {}),\n\t\t...(options.probeSsh !== undefined ? { probeSsh: options.probeSsh } : {}),\n\t\t...(options.sleep !== undefined ? { sleep: options.sleep } : {}),\n\t\t...(options.now !== undefined ? { now: options.now } : {})\n\t});\n\n\treturn {\n\t\tdescription: result.description,\n\t\tdestroy: result.destroy,\n\t\texec: result.exec,\n\t\tipv4: result.ipv4,\n\t\tserverId: result.id,\n\t\tupload: result.upload,\n\t\t...(result.close !== undefined ? { close: result.close } : {})\n\t};\n};\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;AAuBA;AACA;AA+CA,IAAM,eAAe,OACpB,QACA,WACqB;AAAA,EACrB,IAAI,CAAC;AAAA,IAAQ,OAAO;AAAA,EACpB,MAAM,UAAU,IAAI;AAAA,EACpB,IAAI,SAAS;AAAA,EACb,IAAI,YAAY;AAAA,EAChB,MAAM,SAAS,OAAO,UAAU;AAAA,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U,QAAQ,SAAS,IAAI,CAAC;AAAA,OACnE,QAAQ,SAAS,YAAY,EAAE,MAAM,QAAQ,KAAK,IAAI,CAAC;AAAA,OACvD,QAAQ,uBAAuB,YAChC,EAAE,oBAAoB,QAAQ,mBAAmB,IACjD,CAAC;AAAA,OACA,QAAQ,0BAA0B,YACnC,EAAE,uBAAuB,QAAQ,sBAAsB,IACvD,CAAC;AAAA,OACA,QAAQ,mBAAmB,YAC5B,EAAE,gBAAgB,QAAQ,eAAe,IACzC,CAAC;AAAA,OACA,QAAQ,UAAU,YAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,OAC1D,QAAQ,aAAa,YAAY,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,OACnE,QAAQ,UAAU,YAAY,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,OAC1D,QAAQ,QAAQ,YAAY,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC;AAAA,EACzD,CAAC;AAAA,EAED,OAAO;AAAA,IACN,aAAa,OAAO;AAAA,IACpB,SAAS,OAAO;AAAA,IAChB,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,UAAU,OAAO;AAAA,IACjB,QAAQ,OAAO;AAAA,OACX,OAAO,UAAU,YAAY,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;AAAA,EAC7D;AAAA;",
|
|
10
10
|
"debugId": "1016401F0A6B67CD64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @absolutejs/deploy/hetzner-dns — Hetzner DNS implementing the
|
|
3
|
+
* {@link DnsProvider} contract from `./dns`.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: Hetzner DNS is a SEPARATE service from Hetzner Cloud (compute).
|
|
6
|
+
* - Compute API: https://api.hetzner.cloud/v1, token = Bearer
|
|
7
|
+
* - DNS API: https://dns.hetzner.com/api/v1, token = Auth-API-Token header
|
|
8
|
+
*
|
|
9
|
+
* Different auth header AND different base URL — get them confused
|
|
10
|
+
* and every request fails. We use a separate client type +
|
|
11
|
+
* `createHetznerDnsClient` factory to keep them distinct.
|
|
12
|
+
*
|
|
13
|
+
* Scope: one provider instance is bound to one zone (referenced by
|
|
14
|
+
* `zoneId`). DNS record names in Hetzner are FQDN-style for the
|
|
15
|
+
* apex (`'@'`) and relative for subdomains (`'api'` not
|
|
16
|
+
* `'api.example.com'`).
|
|
17
|
+
*/
|
|
18
|
+
import type { DnsProvider } from './dns';
|
|
19
|
+
export type HetznerDnsClientLike = {
|
|
20
|
+
request: <T = unknown>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', path: string, body?: unknown) => Promise<T>;
|
|
21
|
+
};
|
|
22
|
+
export declare class HetznerDnsError extends Error {
|
|
23
|
+
readonly status: number;
|
|
24
|
+
readonly body: unknown;
|
|
25
|
+
constructor(message: string, status: number, body: unknown);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* fetch-backed default client. Uses Hetzner DNS's `Auth-API-Token`
|
|
29
|
+
* header — NOT the Bearer-style auth used by Hetzner Cloud compute.
|
|
30
|
+
*/
|
|
31
|
+
export declare const createHetznerDnsClient: (token: string, options?: {
|
|
32
|
+
baseUrl?: string;
|
|
33
|
+
fetch?: typeof fetch;
|
|
34
|
+
}) => HetznerDnsClientLike;
|
|
35
|
+
export type HetznerDnsProviderOptions = {
|
|
36
|
+
token?: string;
|
|
37
|
+
client?: HetznerDnsClientLike;
|
|
38
|
+
/** Hetzner DNS zone id (UUID-shaped). */
|
|
39
|
+
zoneId: string;
|
|
40
|
+
/** Optional zone name for log + record-name conversion. */
|
|
41
|
+
zoneName?: string;
|
|
42
|
+
};
|
|
43
|
+
export declare const hetznerDnsProvider: (options: HetznerDnsProviderOptions) => DnsProvider;
|