@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.
- package/esm/lib/cli.d.ts.map +1 -1
- package/esm/lib/cli.js +7 -11
- package/esm/lib/command.d.ts.map +1 -1
- package/esm/lib/command.js +45 -40
- package/esm/src/cli/commands/create.js +18 -5
- package/esm/src/cli/commands/deploy.js +137 -77
- package/esm/src/cli/commands/destroy.js +19 -7
- package/esm/src/cli/commands/doctor.js +7 -7
- package/esm/src/cli/commands/list.js +13 -6
- package/esm/src/cli/commands/status.js +98 -94
- package/esm/src/cli/mod.js +1 -1
- package/esm/src/credentials.d.ts +13 -4
- package/esm/src/credentials.d.ts.map +1 -1
- package/esm/src/credentials.js +26 -9
- package/esm/src/guard.d.ts +6 -0
- package/esm/src/guard.d.ts.map +1 -1
- package/esm/src/guard.js +183 -0
- package/esm/src/providers/fly.d.ts +10 -0
- package/esm/src/providers/fly.d.ts.map +1 -1
- package/esm/src/providers/fly.js +31 -4
- package/esm/src/schemas/config.d.ts.map +1 -1
- package/package.json +4 -1
package/esm/src/providers/fly.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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,
|
|
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.
|
|
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
|
}
|