@cardelli/ambit 0.1.0 → 0.1.2

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.
@@ -12,6 +12,35 @@ import { fileExists } from "../../lib/cli.js";
12
12
  // Constants
13
13
  // =============================================================================
14
14
  const ROUTER_APP_PREFIX = "ambit-";
15
+ // =============================================================================
16
+ // Deploy Error
17
+ // =============================================================================
18
+ /**
19
+ * Thrown when a `fly deploy` command fails. Carries the raw stderr so callers
20
+ * can surface it through `out` (respecting JSON mode) instead of printing
21
+ * directly.
22
+ */
23
+ export class FlyDeployError extends Error {
24
+ /** Last meaningful line from flyctl stderr. */
25
+ detail;
26
+ constructor(app, stderr) {
27
+ const detail = extractErrorDetail(stderr);
28
+ super(`Deploy Failed for '${app}'`);
29
+ this.name = "FlyDeployError";
30
+ this.detail = detail;
31
+ }
32
+ }
33
+ /**
34
+ * Pull the last non-empty, non-decoration line from fly stderr.
35
+ * Fly often prints progress lines then the actual error at the end.
36
+ */
37
+ const extractErrorDetail = (stderr) => {
38
+ const lines = stderr
39
+ .split("\n")
40
+ .map((l) => l.replace(/\x1b\[[0-9;]*m/g, "").trim())
41
+ .filter((l) => l.length > 0 && !l.startsWith("-->") && l !== "Error");
42
+ return lines[lines.length - 1] ?? "unknown error";
43
+ };
15
44
  export const getSizeConfig = (size) => {
16
45
  switch (size) {
17
46
  case "shared-cpu-1x":
@@ -226,8 +255,7 @@ export const createFlyProvider = () => {
226
255
  }
227
256
  const result = await runCommand(args);
228
257
  if (!result.success) {
229
- console.error(result.stderr);
230
- return die(`Deploy Failed for '${app}'`);
258
+ throw new FlyDeployError(app, result.stderr);
231
259
  }
232
260
  },
233
261
  async listIps(app) {
@@ -306,8 +334,7 @@ export const createFlyProvider = () => {
306
334
  }
307
335
  const result = await runCommand(args);
308
336
  if (!result.success) {
309
- console.error(result.stderr);
310
- return die(`Deploy Failed for '${app}'`);
337
+ throw new FlyDeployError(app, result.stderr);
311
338
  }
312
339
  },
313
340
  async listCerts(app) {
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/config.ts"],"names":[],"mappings":"AAOA,OAAO,yBAAyB,CAAC;AAKjC,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MACvB,CAAC;AAEzB,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,MAKjD,CAAC;AAMF,eAAO,MAAM,YAAY,QAAO,MAG/B,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/src/schemas/config.ts"],"names":[],"mappings":"AAOA,OAAO,yBAAyB,CAAC;AAKjC,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAAgC,CAAC;AAEhF,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,MAKjD,CAAC;AAMF,eAAO,MAAM,YAAY,QAAO,MAG/B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardelli/ambit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Tailscale subnet router manager for Fly.io custom networks",
5
5
  "license": "MIT",
6
6
  "module": "./esm/src/providers/fly.js",
@@ -38,6 +38,9 @@
38
38
  "./src/discovery": {
39
39
  "import": "./esm/src/discovery.js"
40
40
  },
41
+ "./src/guard": {
42
+ "import": "./esm/src/guard.js"
43
+ },
41
44
  "./src/resolve": {
42
45
  "import": "./esm/src/resolve.js"
43
46
  }