@schmock/cli 2.3.0 → 2.4.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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/bin.js +455 -91
- package/dist/cli.d.ts +50 -13
- package/dist/cli.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +456 -91
- package/package.json +21 -4
- package/dist/cli.js +0 -351
package/dist/cli.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Server } from "node:http";
|
|
2
|
+
import type * as Schmock from "@schmock/core";
|
|
2
3
|
export interface CliOptions {
|
|
3
4
|
spec: string;
|
|
4
5
|
port?: number;
|
|
@@ -10,28 +11,64 @@ export interface CliOptions {
|
|
|
10
11
|
errors?: boolean;
|
|
11
12
|
watch?: boolean;
|
|
12
13
|
admin?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Bearer token required by every `/schmock-admin/*` request (`--admin-token`).
|
|
16
|
+
* When `admin` is on and this is omitted, a random token is minted once and
|
|
17
|
+
* surfaced on {@link CliServer.adminToken}.
|
|
18
|
+
*/
|
|
19
|
+
adminToken?: string;
|
|
20
|
+
/**
|
|
21
|
+
* How many requests the mock retains for `GET /schmock-admin/history`
|
|
22
|
+
* (`--admin-history-limit`, default 500). Ignored — history is disabled
|
|
23
|
+
* entirely — when `admin` is off.
|
|
24
|
+
*/
|
|
25
|
+
adminHistoryLimit?: number;
|
|
26
|
+
/** Validate the spec against the OpenAPI schema at startup (`--strict`). */
|
|
27
|
+
strict?: boolean;
|
|
28
|
+
/** Resolve `$ref`s outside the spec document (`--refs-external`). */
|
|
29
|
+
refsExternal?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Hosts an `http(s)` `$ref` may target (`--refs-allow-http`). Supplying this
|
|
32
|
+
* also enables http resolution, which still requires `refsExternal`.
|
|
33
|
+
*/
|
|
34
|
+
refsAllowHttp?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* How long {@link CliServer.close} waits for in-flight requests before the
|
|
37
|
+
* remaining sockets are destroyed (default 5000 ms). A half-sent request
|
|
38
|
+
* never completes on its own, so without a bound the close would hang.
|
|
39
|
+
*/
|
|
40
|
+
shutdownGraceMs?: number;
|
|
13
41
|
}
|
|
14
42
|
export interface CliServer {
|
|
15
43
|
server: Server;
|
|
16
44
|
port: number;
|
|
17
45
|
hostname: string;
|
|
18
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The bearer token this server requires on `/schmock-admin/*`. Present only
|
|
48
|
+
* when admin is enabled; supply it as `Authorization: Bearer <token>`.
|
|
49
|
+
*/
|
|
50
|
+
adminToken?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Stop watching, stop accepting, and settle once the socket is released —
|
|
53
|
+
* within {@link CliOptions.shutdownGraceMs}. Memoized: every call observes
|
|
54
|
+
* the same shutdown, so closing twice is safe and resolves twice.
|
|
55
|
+
*/
|
|
56
|
+
close(): Promise<void>;
|
|
19
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Read a `--seed` manifest.
|
|
60
|
+
*
|
|
61
|
+
* Every entry shape is checked explicitly and anything unrecognised throws:
|
|
62
|
+
* silently dropping a malformed entry used to start a server whose collections
|
|
63
|
+
* were quietly empty. File entries resolve relative to the manifest rather than
|
|
64
|
+
* the process CWD, and may not escape the manifest directory.
|
|
65
|
+
*/
|
|
66
|
+
export declare function loadSeedFile(seedPath: string): Schmock.SeedConfig;
|
|
20
67
|
export declare function createCliServer(options: CliOptions): Promise<CliServer>;
|
|
68
|
+
/** Loopback binds are `127.0.0.0/8`, `::1` and `localhost`; everything else is reachable off-box. */
|
|
69
|
+
export declare function isLoopbackHost(hostname: string): boolean;
|
|
21
70
|
export declare function parseCliArgs(args: string[]): CliOptions & {
|
|
22
71
|
help: boolean;
|
|
23
72
|
};
|
|
24
|
-
export interface WatchHandle {
|
|
25
|
-
close(): void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Prepare a replacement before closing the live server, then bind it to the
|
|
29
|
-
* same port. Invalid spec changes therefore leave the current server online.
|
|
30
|
-
*/
|
|
31
|
-
export declare function reloadServer(current: CliServer, options: CliOptions): Promise<CliServer>;
|
|
32
|
-
/**
|
|
33
|
-
* Watch a spec file and hot-reload the server on changes.
|
|
34
|
-
*/
|
|
35
|
-
export declare function startWatch(specPath: string, options: CliOptions, getCurrentServer: () => CliServer, onReload: (server: CliServer) => void): WatchHandle;
|
|
36
73
|
export declare function run(args: string[]): Promise<void>;
|
|
37
74
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,WAAW,CAAC;AAWxD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAgB9C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qEAAqE;IACrE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AA6ID;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAwCjE;AA4jBD,wBAAsB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAsB7E;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CASxD;AAqED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CA2D3E;AAwKD,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAyFvD"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|