@cdwr/fly-node 0.3.4 → 0.3.6
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/CHANGELOG.md +17 -0
- package/index.cjs +24 -15
- package/index.js +25 -16
- package/package.json +1 -1
- package/src/lib/schemas/certs-list-with-app.schema.d.ts +2 -2
- package/src/lib/schemas/certs-list.schema.d.ts +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## 0.3.6 (2026-11-23)
|
|
2
|
+
|
|
3
|
+
### 🐞 Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **fly-node:** an absolute config path is found by config show ([edbfd5c86](https://github.com/codeware-sthlm/cdwr/commit/edbfd5c86))
|
|
6
|
+
|
|
7
|
+
## 0.3.5 (2026-11-15)
|
|
8
|
+
|
|
9
|
+
### 🐞 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **fly-node:** await parse so nullOnError catches schema errors ([23f2ffb3](https://github.com/codeware-sthlm/cdwr/commit/23f2ffb3))
|
|
12
|
+
- **fly-node:** read certificate status from flyctl 0.5 certs list ([8ea5053f](https://github.com/codeware-sthlm/cdwr/commit/8ea5053f))
|
|
13
|
+
|
|
14
|
+
### ✅ Tests
|
|
15
|
+
|
|
16
|
+
- **fly-node:** list a real certificate in the cli integration test ([522353c6](https://github.com/codeware-sthlm/cdwr/commit/522353c6))
|
|
17
|
+
|
|
1
18
|
## 0.3.4 (2026-11-15)
|
|
2
19
|
|
|
3
20
|
### 🐞 Bug Fixes
|
package/index.cjs
CHANGED
|
@@ -613,7 +613,7 @@ var SpawnError = class extends Error {
|
|
|
613
613
|
}
|
|
614
614
|
};
|
|
615
615
|
function spawn(command, args, options) {
|
|
616
|
-
return new Promise((
|
|
616
|
+
return new Promise((resolve2, reject) => {
|
|
617
617
|
const { streamToConsole, ...spawnOptions } = options || {};
|
|
618
618
|
const process2 = (0, import_child_process2.spawn)(command, args, {
|
|
619
619
|
...spawnOptions,
|
|
@@ -637,7 +637,7 @@ function spawn(command, args, options) {
|
|
|
637
637
|
const stdout = Buffer.concat(stdoutChunks).toString();
|
|
638
638
|
const stderr = Buffer.concat(stderrChunks).toString();
|
|
639
639
|
if (code === 0) {
|
|
640
|
-
|
|
640
|
+
resolve2({ stdout, stderr });
|
|
641
641
|
} else {
|
|
642
642
|
const lines = stderr.replace(/\r?\n$/, "").split(/\r?\n/);
|
|
643
643
|
const message = streamToConsole && lines.length > STREAMED_STDERR_TAIL_LINES ? `Process exited with code ${code}
|
|
@@ -654,7 +654,7 @@ Error: ${stderr}`;
|
|
|
654
654
|
// libs/shared/util/misc/src/lib/spawn-pty.ts
|
|
655
655
|
var import_node_pty_prebuilt_multiarch = require("@homebridge/node-pty-prebuilt-multiarch");
|
|
656
656
|
function spawnPty(command, args, options) {
|
|
657
|
-
return new Promise((
|
|
657
|
+
return new Promise((resolve2, reject) => {
|
|
658
658
|
const ptyData = [];
|
|
659
659
|
const ptyProcess = (0, import_node_pty_prebuilt_multiarch.spawn)(command, args, {
|
|
660
660
|
cwd: process.cwd(),
|
|
@@ -674,7 +674,7 @@ function spawnPty(command, args, options) {
|
|
|
674
674
|
ptyProcess.onExit(({ exitCode }) => {
|
|
675
675
|
const output = ptyData.join("");
|
|
676
676
|
if (exitCode === 0) {
|
|
677
|
-
|
|
677
|
+
resolve2(output);
|
|
678
678
|
} else {
|
|
679
679
|
reject(
|
|
680
680
|
new Error(`Process exited with code ${exitCode}
|
|
@@ -823,16 +823,25 @@ var CertsListFlyResponseElementSchema = import_zod17.z.object({
|
|
|
823
823
|
hostname: import_zod17.z.string(),
|
|
824
824
|
clientStatus: import_zod17.z.string()
|
|
825
825
|
});
|
|
826
|
+
var withClientStatus = (schema) => import_zod17.z.preprocess((data) => {
|
|
827
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
828
|
+
return data;
|
|
829
|
+
}
|
|
830
|
+
const { status, ...rest } = data;
|
|
831
|
+
return status === void 0 ? rest : { ...rest, clientStatus: status };
|
|
832
|
+
}, schema);
|
|
826
833
|
var CertsListTransformedResponseSchema = import_zod17.z.array(
|
|
827
|
-
withCamelCase(CertsListFlyResponseElementSchema)
|
|
834
|
+
withCamelCase(withClientStatus(CertsListFlyResponseElementSchema))
|
|
828
835
|
);
|
|
829
836
|
|
|
830
837
|
// packages/fly-node/src/lib/schemas/certs-list-with-app.schema.ts
|
|
831
838
|
var CertsListWithAppTransformedResponseSchema = import_zod19.z.array(
|
|
832
839
|
withCamelCase(
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
840
|
+
withClientStatus(
|
|
841
|
+
CertsListFlyResponseElementSchema.extend({
|
|
842
|
+
app: import_zod19.z.string()
|
|
843
|
+
})
|
|
844
|
+
)
|
|
836
845
|
)
|
|
837
846
|
);
|
|
838
847
|
|
|
@@ -1752,7 +1761,7 @@ ${error}`);
|
|
|
1752
1761
|
args.push(options?.app || "--generate-name");
|
|
1753
1762
|
args.push("--org", options?.org || this._config.org || "personal");
|
|
1754
1763
|
args.push("--json");
|
|
1755
|
-
return AppsCreateTransformedResponseSchema.parseAsync(
|
|
1764
|
+
return await AppsCreateTransformedResponseSchema.parseAsync(
|
|
1756
1765
|
await this.execFly(args)
|
|
1757
1766
|
);
|
|
1758
1767
|
}
|
|
@@ -2132,7 +2141,7 @@ ${error}`);
|
|
|
2132
2141
|
return;
|
|
2133
2142
|
}
|
|
2134
2143
|
await new Promise(
|
|
2135
|
-
(
|
|
2144
|
+
(resolve2) => setTimeout(resolve2, MACHINE_STATE_INTERVAL_MS)
|
|
2136
2145
|
);
|
|
2137
2146
|
}
|
|
2138
2147
|
throw new Error(
|
|
@@ -2157,7 +2166,7 @@ ${error}`);
|
|
|
2157
2166
|
async fetchAllApps(onError) {
|
|
2158
2167
|
const args = ["apps", "list", "--json"];
|
|
2159
2168
|
try {
|
|
2160
|
-
return AppsListTransformedResponseSchema.parseAsync(
|
|
2169
|
+
return await AppsListTransformedResponseSchema.parseAsync(
|
|
2161
2170
|
await this.execFly(args)
|
|
2162
2171
|
);
|
|
2163
2172
|
} catch (error) {
|
|
@@ -2268,7 +2277,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2268
2277
|
args.push(...this.getAppOrConfigArgs(options));
|
|
2269
2278
|
args.push("--json");
|
|
2270
2279
|
try {
|
|
2271
|
-
return CertsListTransformedResponseSchema.parseAsync(
|
|
2280
|
+
return await CertsListTransformedResponseSchema.parseAsync(
|
|
2272
2281
|
await this.execFly(args)
|
|
2273
2282
|
);
|
|
2274
2283
|
} catch (error) {
|
|
@@ -2283,7 +2292,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2283
2292
|
args.push(...this.getAppOrConfigArgs(options));
|
|
2284
2293
|
args.push("--json");
|
|
2285
2294
|
try {
|
|
2286
|
-
return SecretsListTransformedResponseSchema.parseAsync(
|
|
2295
|
+
return await SecretsListTransformedResponseSchema.parseAsync(
|
|
2287
2296
|
await this.execFly(args)
|
|
2288
2297
|
);
|
|
2289
2298
|
} catch (error) {
|
|
@@ -2308,7 +2317,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2308
2317
|
async showConfig(onError, options) {
|
|
2309
2318
|
const normalized = this.normalizeOptions(options);
|
|
2310
2319
|
const config = normalized.config || this.instanceConfig;
|
|
2311
|
-
if (config && !(0, import_fs.existsSync)((0, import_path.
|
|
2320
|
+
if (config && !(0, import_fs.existsSync)((0, import_path.resolve)((0, import_process.cwd)(), config))) {
|
|
2312
2321
|
throw new Error(`Config file '${config}' does not exist`);
|
|
2313
2322
|
}
|
|
2314
2323
|
const args = ["config", "show"];
|
|
@@ -2405,7 +2414,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2405
2414
|
this.logger.info(
|
|
2406
2415
|
`Transient Fly error (${cause}), retrying in ${delay / 1e3}s (attempt ${attempt + 1} of ${TRANSIENT_RETRY_DELAYS_MS.length + 1}): ${toLogCmd}`
|
|
2407
2416
|
);
|
|
2408
|
-
await new Promise((
|
|
2417
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
2409
2418
|
continue;
|
|
2410
2419
|
}
|
|
2411
2420
|
if (onError === "throwOnError") {
|
package/index.js
CHANGED
|
@@ -527,7 +527,7 @@ var HOSTNAME_CHECK_FIELDS = `
|
|
|
527
527
|
|
|
528
528
|
// packages/fly-node/src/lib/fly.class.ts
|
|
529
529
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
530
|
-
import { dirname, join } from "path";
|
|
530
|
+
import { dirname, join, resolve } from "path";
|
|
531
531
|
import { cwd } from "process";
|
|
532
532
|
|
|
533
533
|
// libs/shared/util/misc/src/lib/docker-build.ts
|
|
@@ -569,7 +569,7 @@ var SpawnError = class extends Error {
|
|
|
569
569
|
}
|
|
570
570
|
};
|
|
571
571
|
function spawn(command, args, options) {
|
|
572
|
-
return new Promise((
|
|
572
|
+
return new Promise((resolve2, reject) => {
|
|
573
573
|
const { streamToConsole, ...spawnOptions } = options || {};
|
|
574
574
|
const process2 = cpSpawn(command, args, {
|
|
575
575
|
...spawnOptions,
|
|
@@ -593,7 +593,7 @@ function spawn(command, args, options) {
|
|
|
593
593
|
const stdout = Buffer.concat(stdoutChunks).toString();
|
|
594
594
|
const stderr = Buffer.concat(stderrChunks).toString();
|
|
595
595
|
if (code === 0) {
|
|
596
|
-
|
|
596
|
+
resolve2({ stdout, stderr });
|
|
597
597
|
} else {
|
|
598
598
|
const lines = stderr.replace(/\r?\n$/, "").split(/\r?\n/);
|
|
599
599
|
const message = streamToConsole && lines.length > STREAMED_STDERR_TAIL_LINES ? `Process exited with code ${code}
|
|
@@ -610,7 +610,7 @@ Error: ${stderr}`;
|
|
|
610
610
|
// libs/shared/util/misc/src/lib/spawn-pty.ts
|
|
611
611
|
import { spawn as spawn2 } from "@homebridge/node-pty-prebuilt-multiarch";
|
|
612
612
|
function spawnPty(command, args, options) {
|
|
613
|
-
return new Promise((
|
|
613
|
+
return new Promise((resolve2, reject) => {
|
|
614
614
|
const ptyData = [];
|
|
615
615
|
const ptyProcess = spawn2(command, args, {
|
|
616
616
|
cwd: process.cwd(),
|
|
@@ -630,7 +630,7 @@ function spawnPty(command, args, options) {
|
|
|
630
630
|
ptyProcess.onExit(({ exitCode }) => {
|
|
631
631
|
const output = ptyData.join("");
|
|
632
632
|
if (exitCode === 0) {
|
|
633
|
-
|
|
633
|
+
resolve2(output);
|
|
634
634
|
} else {
|
|
635
635
|
reject(
|
|
636
636
|
new Error(`Process exited with code ${exitCode}
|
|
@@ -779,16 +779,25 @@ var CertsListFlyResponseElementSchema = z14.object({
|
|
|
779
779
|
hostname: z14.string(),
|
|
780
780
|
clientStatus: z14.string()
|
|
781
781
|
});
|
|
782
|
+
var withClientStatus = (schema) => z14.preprocess((data) => {
|
|
783
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
784
|
+
return data;
|
|
785
|
+
}
|
|
786
|
+
const { status, ...rest } = data;
|
|
787
|
+
return status === void 0 ? rest : { ...rest, clientStatus: status };
|
|
788
|
+
}, schema);
|
|
782
789
|
var CertsListTransformedResponseSchema = z14.array(
|
|
783
|
-
withCamelCase(CertsListFlyResponseElementSchema)
|
|
790
|
+
withCamelCase(withClientStatus(CertsListFlyResponseElementSchema))
|
|
784
791
|
);
|
|
785
792
|
|
|
786
793
|
// packages/fly-node/src/lib/schemas/certs-list-with-app.schema.ts
|
|
787
794
|
var CertsListWithAppTransformedResponseSchema = z15.array(
|
|
788
795
|
withCamelCase(
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
796
|
+
withClientStatus(
|
|
797
|
+
CertsListFlyResponseElementSchema.extend({
|
|
798
|
+
app: z15.string()
|
|
799
|
+
})
|
|
800
|
+
)
|
|
792
801
|
)
|
|
793
802
|
);
|
|
794
803
|
|
|
@@ -1708,7 +1717,7 @@ ${error}`);
|
|
|
1708
1717
|
args.push(options?.app || "--generate-name");
|
|
1709
1718
|
args.push("--org", options?.org || this._config.org || "personal");
|
|
1710
1719
|
args.push("--json");
|
|
1711
|
-
return AppsCreateTransformedResponseSchema.parseAsync(
|
|
1720
|
+
return await AppsCreateTransformedResponseSchema.parseAsync(
|
|
1712
1721
|
await this.execFly(args)
|
|
1713
1722
|
);
|
|
1714
1723
|
}
|
|
@@ -2088,7 +2097,7 @@ ${error}`);
|
|
|
2088
2097
|
return;
|
|
2089
2098
|
}
|
|
2090
2099
|
await new Promise(
|
|
2091
|
-
(
|
|
2100
|
+
(resolve2) => setTimeout(resolve2, MACHINE_STATE_INTERVAL_MS)
|
|
2092
2101
|
);
|
|
2093
2102
|
}
|
|
2094
2103
|
throw new Error(
|
|
@@ -2113,7 +2122,7 @@ ${error}`);
|
|
|
2113
2122
|
async fetchAllApps(onError) {
|
|
2114
2123
|
const args = ["apps", "list", "--json"];
|
|
2115
2124
|
try {
|
|
2116
|
-
return AppsListTransformedResponseSchema.parseAsync(
|
|
2125
|
+
return await AppsListTransformedResponseSchema.parseAsync(
|
|
2117
2126
|
await this.execFly(args)
|
|
2118
2127
|
);
|
|
2119
2128
|
} catch (error) {
|
|
@@ -2224,7 +2233,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2224
2233
|
args.push(...this.getAppOrConfigArgs(options));
|
|
2225
2234
|
args.push("--json");
|
|
2226
2235
|
try {
|
|
2227
|
-
return CertsListTransformedResponseSchema.parseAsync(
|
|
2236
|
+
return await CertsListTransformedResponseSchema.parseAsync(
|
|
2228
2237
|
await this.execFly(args)
|
|
2229
2238
|
);
|
|
2230
2239
|
} catch (error) {
|
|
@@ -2239,7 +2248,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2239
2248
|
args.push(...this.getAppOrConfigArgs(options));
|
|
2240
2249
|
args.push("--json");
|
|
2241
2250
|
try {
|
|
2242
|
-
return SecretsListTransformedResponseSchema.parseAsync(
|
|
2251
|
+
return await SecretsListTransformedResponseSchema.parseAsync(
|
|
2243
2252
|
await this.execFly(args)
|
|
2244
2253
|
);
|
|
2245
2254
|
} catch (error) {
|
|
@@ -2264,7 +2273,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2264
2273
|
async showConfig(onError, options) {
|
|
2265
2274
|
const normalized = this.normalizeOptions(options);
|
|
2266
2275
|
const config = normalized.config || this.instanceConfig;
|
|
2267
|
-
if (config && !existsSync(
|
|
2276
|
+
if (config && !existsSync(resolve(cwd(), config))) {
|
|
2268
2277
|
throw new Error(`Config file '${config}' does not exist`);
|
|
2269
2278
|
}
|
|
2270
2279
|
const args = ["config", "show"];
|
|
@@ -2361,7 +2370,7 @@ ${JSON.stringify(response, null, 2)}`);
|
|
|
2361
2370
|
this.logger.info(
|
|
2362
2371
|
`Transient Fly error (${cause}), retrying in ${delay / 1e3}s (attempt ${attempt + 1} of ${TRANSIENT_RETRY_DELAYS_MS.length + 1}): ${toLogCmd}`
|
|
2363
2372
|
);
|
|
2364
|
-
await new Promise((
|
|
2373
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
2365
2374
|
continue;
|
|
2366
2375
|
}
|
|
2367
2376
|
if (onError === "throwOnError") {
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* certs list response extended with application name
|
|
4
4
|
*/
|
|
5
|
-
export declare const CertsListWithAppTransformedResponseSchema: z.ZodArray<z.ZodPreprocess<z.ZodObject<{
|
|
5
|
+
export declare const CertsListWithAppTransformedResponseSchema: z.ZodArray<z.ZodPreprocess<z.ZodPreprocess<z.ZodObject<{
|
|
6
6
|
createdAt: z.ZodString;
|
|
7
7
|
hostname: z.ZodString;
|
|
8
8
|
clientStatus: z.ZodString;
|
|
9
9
|
app: z.ZodString;
|
|
10
|
-
}, z.core.$strip>, unknown>>;
|
|
10
|
+
}, z.core.$strip>, unknown>, unknown>>;
|
|
@@ -11,6 +11,14 @@ export declare const CertsListFlyResponseElementSchema: z.ZodObject<{
|
|
|
11
11
|
hostname: z.ZodString;
|
|
12
12
|
clientStatus: z.ZodString;
|
|
13
13
|
}, z.core.$strip>;
|
|
14
|
+
/**
|
|
15
|
+
* A Zod preprocessor which reads the certificate state from `status`
|
|
16
|
+
* (flyctl 0.5 and later) or `clientStatus` (older flyctl),
|
|
17
|
+
* so the schema always gets one `clientStatus`.
|
|
18
|
+
*
|
|
19
|
+
* Expects camelCased keys, so wrap it in `withCamelCase`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const withClientStatus: <T extends z.ZodType>(schema: T) => z.ZodPreprocess<T, unknown>;
|
|
14
22
|
/**
|
|
15
23
|
* Transformed certs list response schema
|
|
16
24
|
*
|
|
@@ -18,8 +26,8 @@ export declare const CertsListFlyResponseElementSchema: z.ZodObject<{
|
|
|
18
26
|
* fly certs list --app [name] --json
|
|
19
27
|
* ```
|
|
20
28
|
*/
|
|
21
|
-
export declare const CertsListTransformedResponseSchema: z.ZodArray<z.ZodPreprocess<z.ZodObject<{
|
|
29
|
+
export declare const CertsListTransformedResponseSchema: z.ZodArray<z.ZodPreprocess<z.ZodPreprocess<z.ZodObject<{
|
|
22
30
|
createdAt: z.ZodString;
|
|
23
31
|
hostname: z.ZodString;
|
|
24
32
|
clientStatus: z.ZodString;
|
|
25
|
-
}, z.core.$strip>, unknown>>;
|
|
33
|
+
}, z.core.$strip>, unknown>, unknown>>;
|