@silver886/mcp-proxy 0.2.0 → 0.2.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.
Files changed (40) hide show
  1. package/README.md +0 -8
  2. package/node_modules/cloudflared/LICENSE +21 -0
  3. package/node_modules/cloudflared/README.md +156 -0
  4. package/node_modules/cloudflared/bin/cloudflared +0 -0
  5. package/node_modules/cloudflared/lib/cloudflared.js +10 -0
  6. package/node_modules/cloudflared/lib/constants.js +58 -0
  7. package/node_modules/cloudflared/lib/error.js +32 -0
  8. package/node_modules/cloudflared/lib/handler.js +117 -0
  9. package/node_modules/cloudflared/lib/index.js +126 -0
  10. package/node_modules/cloudflared/lib/install.js +155 -0
  11. package/node_modules/cloudflared/lib/lib.d.ts +236 -0
  12. package/node_modules/cloudflared/lib/lib.js +45 -0
  13. package/node_modules/cloudflared/lib/regex.js +52 -0
  14. package/node_modules/cloudflared/lib/service.js +229 -0
  15. package/node_modules/cloudflared/lib/tunnel.js +164 -0
  16. package/node_modules/cloudflared/lib/types.js +16 -0
  17. package/node_modules/cloudflared/package.json +59 -0
  18. package/node_modules/cloudflared/scripts/postinstall.mjs +10 -0
  19. package/node_modules/eventsource-parser/LICENSE +21 -0
  20. package/node_modules/eventsource-parser/README.md +126 -0
  21. package/node_modules/eventsource-parser/dist/index.cjs +166 -0
  22. package/node_modules/eventsource-parser/dist/index.cjs.map +1 -0
  23. package/node_modules/eventsource-parser/dist/index.d.cts +146 -0
  24. package/node_modules/eventsource-parser/dist/index.d.ts +146 -0
  25. package/node_modules/eventsource-parser/dist/index.js +166 -0
  26. package/node_modules/eventsource-parser/dist/index.js.map +1 -0
  27. package/node_modules/eventsource-parser/dist/stream.cjs +28 -0
  28. package/node_modules/eventsource-parser/dist/stream.cjs.map +1 -0
  29. package/node_modules/eventsource-parser/dist/stream.d.cts +121 -0
  30. package/node_modules/eventsource-parser/dist/stream.d.ts +121 -0
  31. package/node_modules/eventsource-parser/dist/stream.js +29 -0
  32. package/node_modules/eventsource-parser/dist/stream.js.map +1 -0
  33. package/node_modules/eventsource-parser/package.json +92 -0
  34. package/node_modules/eventsource-parser/src/errors.ts +44 -0
  35. package/node_modules/eventsource-parser/src/index.ts +3 -0
  36. package/node_modules/eventsource-parser/src/parse.ts +395 -0
  37. package/node_modules/eventsource-parser/src/stream.ts +88 -0
  38. package/node_modules/eventsource-parser/src/types.ts +97 -0
  39. package/node_modules/eventsource-parser/stream.js +2 -0
  40. package/package.json +2 -1
package/README.md CHANGED
@@ -213,11 +213,3 @@ object.
213
213
  | `-32003` | `PROCESS_EXITED` | MCP server child process died |
214
214
  | `-32004` | `PROCESS_NOT_RUNNING` | Child process isn't running |
215
215
  | `-32005` | `REQUEST_TIMEOUT` | MCP server didn't respond in time |
216
-
217
- ## Development
218
-
219
- ```bash
220
- pnpm install
221
- pnpm run build
222
- pnpm publish --access public --no-git-checks
223
- ```
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 JacobLinCool
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,156 @@
1
+ # cloudflared
2
+
3
+ A Node.js package that allows you to easily create HTTPS tunnels using Cloudflare's `cloudflared` command-line tool. It provides a typed API for creating tunnels and managing the `cloudflared` binary installation.
4
+
5
+ > This tool will automatically install the [latest version of `cloudflared`](https://github.com/cloudflare/cloudflared/releases/latest) (or `CLOUDFLARED_VERSION` env var if exists) at the first time.
6
+ > Then, it just passes down the command to `cloudflared`.
7
+
8
+ ## Installation
9
+
10
+ You can install this package using your favorite package manager:
11
+
12
+ ### PNPM
13
+
14
+ ```sh
15
+ pnpm i -g cloudflared
16
+ ```
17
+
18
+ ### NPM
19
+
20
+ ```sh
21
+ npm i -g cloudflared
22
+ ```
23
+
24
+ ### Yarn
25
+
26
+ ```sh
27
+ yarn global add cloudflared
28
+ ```
29
+
30
+ > If `CLOUDFLARED_VERSION` env var is set, it will install the specified version of `cloudflared`, otherwise it will install the latest version.
31
+
32
+ ## CLI Usage
33
+
34
+ You can use the `cloudflared` command-line tool to create HTTPS tunnels. You can find the usage of `cloudflared` [here](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-useful-commands/).
35
+
36
+ In addition to the standard `cloudflared` commands, this package also provides an extra subcommand: `cloudflared bin`. You can use it to manage the `cloudflared` binary version.
37
+
38
+ ```sh
39
+ ❯ cloudflared bin --help
40
+ cloudflared bin : Prints the path to the binary
41
+ cloudflared bin remove : Removes the binary
42
+ cloudflared bin install [version] : Installs the binary
43
+ cloudflared bin list : Lists 30 latest releases
44
+ cloudflared bin help : Prints this help message
45
+ Examples:
46
+ cloudflared bin install : Installs the latest version of cloudflared
47
+ cloudflared bin install 2023.4.1 : Installs cloudflared 2023.4.1
48
+ You can find releases at https://github.com/cloudflare/cloudflared/releases
49
+ ```
50
+
51
+ ## Library Usage
52
+
53
+ You can also use it as a library in your TypeScript / JavaScript projects.
54
+
55
+ ### Binary Path & Install
56
+
57
+ You can get the path of the `cloudflared` binary and install it using the `bin` and `install` functions, respectively.
58
+
59
+ ```js
60
+ import { bin, install } from "cloudflared";
61
+ import fs from "node:fs";
62
+ import { spawn } from "node:child_process";
63
+
64
+ if (!fs.existsSync(bin)) {
65
+ // install cloudflared binary
66
+ await install(bin);
67
+ }
68
+
69
+ // run cloudflared
70
+ spawn(bin, ["--version"], { stdio: "inherit" });
71
+ ```
72
+
73
+ - `bin`: The path of the binary.
74
+ - `install`: A function that installs the binary to the given path.
75
+
76
+ ### Tunnel
77
+
78
+ Checkout [`examples/tunnel.js`](examples/tunnel.js).
79
+
80
+ `Tunnel` is inherited from `EventEmitter`, so you can listen to the events it emits, checkout [`examples/events.mjs`](examples/events.mjs).
81
+
82
+ ```js
83
+ import { Tunnel } from "cloudflared";
84
+
85
+ console.log("Cloudflared Tunnel Example.");
86
+ main();
87
+
88
+ async function main() {
89
+ // run: cloudflared tunnel --hello-world
90
+ const tunnel = Tunnel.quick();
91
+
92
+ // show the url
93
+ const url = new Promise((resolve) => tunnel.once("url", resolve));
94
+ console.log("LINK:", await url);
95
+
96
+ // wait for connection to be established
97
+ const conn = new Promise((resolve) => tunnel.once("connected", resolve));
98
+ console.log("CONN:", await conn);
99
+
100
+ // stop the tunnel after 15 seconds
101
+ setTimeout(tunnel.stop, 15_000);
102
+
103
+ tunnel.on("exit", (code) => {
104
+ console.log("tunnel process exited with code", code);
105
+ });
106
+ }
107
+ ```
108
+
109
+ ```sh
110
+ ❯ node examples/tunnel.js
111
+ Cloudflared Tunnel Example.
112
+ LINK: https://mailto-davis-wilderness-facts.trycloudflare.com
113
+ CONN: {
114
+ id: 'df1b8330-44ea-4ecb-bb93-8a32400f6d1c',
115
+ ip: '198.41.200.193',
116
+ location: 'tpe01'
117
+ }
118
+ tunnel process exited with code 0
119
+ ```
120
+
121
+ ### Service
122
+
123
+ Checkout [`examples/service.js`](examples/service.js).
124
+
125
+ ```js
126
+ import { service } from "cloudflared";
127
+
128
+ console.log("Cloudflared Service Example.");
129
+ main();
130
+
131
+ async function main() {
132
+ if (service.exists()) {
133
+ console.log("Service is running.");
134
+ const current = service.current();
135
+ for (const { service, hostname } of current.config.ingress) {
136
+ console.log(` - ${service} -> ${hostname}`);
137
+ }
138
+ console.log("metrics server:", current.metrics);
139
+ } else {
140
+ console.log("Service is not running.");
141
+ }
142
+ }
143
+ ```
144
+
145
+ ```sh
146
+ ❯ node examples/service.js
147
+ Cloudflared Service Example.
148
+ Service is running.
149
+ - http://localhost:12345 -> sub.example.com
150
+ - http_status:404 -> undefined
151
+ metrics server: 127.0.0.1:49177/metrics
152
+ ```
153
+
154
+ NOTICE: On linux, service can only be installed and uninstalled by root.
155
+
156
+ Run service test on linux: `sudo -E env "PATH=$PATH" pnpm test`
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var import_error = require("./error.js");
4
+ var import_index = require("./index.js");
5
+ (0, import_index.main)().catch((err) => {
6
+ if (err instanceof import_error.UnsupportedError) {
7
+ console.error(err.message);
8
+ process.exit(1);
9
+ }
10
+ });
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var constants_exports = {};
30
+ __export(constants_exports, {
31
+ CLOUDFLARED_VERSION: () => CLOUDFLARED_VERSION,
32
+ DEFAULT_CLOUDFLARED_BIN: () => DEFAULT_CLOUDFLARED_BIN,
33
+ RELEASE_BASE: () => RELEASE_BASE,
34
+ bin: () => bin,
35
+ use: () => use
36
+ });
37
+ module.exports = __toCommonJS(constants_exports);
38
+ var import_node_path = __toESM(require("node:path"));
39
+ const DEFAULT_CLOUDFLARED_BIN = import_node_path.default.join(
40
+ __dirname,
41
+ "..",
42
+ "bin",
43
+ process.platform === "win32" ? "cloudflared.exe" : "cloudflared"
44
+ );
45
+ let bin = process.env.CLOUDFLARED_BIN || DEFAULT_CLOUDFLARED_BIN;
46
+ function use(executable) {
47
+ bin = executable;
48
+ }
49
+ const CLOUDFLARED_VERSION = process.env.CLOUDFLARED_VERSION || "latest";
50
+ const RELEASE_BASE = "https://github.com/cloudflare/cloudflared/releases/";
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ CLOUDFLARED_VERSION,
54
+ DEFAULT_CLOUDFLARED_BIN,
55
+ RELEASE_BASE,
56
+ bin,
57
+ use
58
+ });
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var error_exports = {};
20
+ __export(error_exports, {
21
+ UnsupportedError: () => UnsupportedError
22
+ });
23
+ module.exports = __toCommonJS(error_exports);
24
+ class UnsupportedError extends Error {
25
+ constructor(message) {
26
+ super(message);
27
+ }
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ UnsupportedError
32
+ });
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var handler_exports = {};
20
+ __export(handler_exports, {
21
+ ConfigHandler: () => ConfigHandler,
22
+ ConnectionHandler: () => ConnectionHandler,
23
+ TryCloudflareHandler: () => TryCloudflareHandler
24
+ });
25
+ module.exports = __toCommonJS(handler_exports);
26
+ var import_node_stream = require("node:stream");
27
+ var import_regex = require("./regex");
28
+ class ConnectionHandler {
29
+ constructor(tunnel) {
30
+ this.connections = [];
31
+ this.connected_handler = (output, tunnel) => {
32
+ const conn_match = output.match(import_regex.conn_regex);
33
+ const ip_match = output.match(import_regex.ip_regex);
34
+ const location_match = output.match(import_regex.location_regex);
35
+ const index_match = output.match(import_regex.index_regex);
36
+ if (conn_match && ip_match && location_match && index_match) {
37
+ const connection = {
38
+ id: conn_match[1],
39
+ ip: ip_match[1],
40
+ location: location_match[1]
41
+ };
42
+ this.connections[Number(index_match[1])] = connection;
43
+ tunnel.emit("connected", connection);
44
+ }
45
+ };
46
+ this.disconnected_handler = (output, tunnel) => {
47
+ const index_match = output.includes("terminated") ? output.match(import_regex.index_regex) : null;
48
+ if (index_match) {
49
+ const index = Number(index_match[1]);
50
+ if (this.connections[index]) {
51
+ tunnel.emit("disconnected", this.connections[index]);
52
+ this.connections[index] = void 0;
53
+ }
54
+ }
55
+ };
56
+ tunnel.addHandler(this.connected_handler.bind(this));
57
+ tunnel.addHandler(this.disconnected_handler.bind(this));
58
+ }
59
+ }
60
+ class TryCloudflareHandler {
61
+ constructor(tunnel) {
62
+ this.url_handler = (output, tunnel) => {
63
+ const url_match = output.match(/https:\/\/([a-z0-9-]+)\.trycloudflare\.com/);
64
+ if (url_match) {
65
+ tunnel.emit("url", url_match[0]);
66
+ }
67
+ };
68
+ tunnel.addHandler(this.url_handler.bind(this));
69
+ }
70
+ }
71
+ class ConfigHandler extends import_node_stream.EventEmitter {
72
+ constructor(tunnel) {
73
+ super();
74
+ this.config_handler = (output, tunnel) => {
75
+ const config_match = output.match(/\bconfig="(.+?)" version=(\d+)/);
76
+ if (config_match) {
77
+ try {
78
+ const config_str = config_match[1].replace(/\\"/g, '"');
79
+ const config = JSON.parse(config_str);
80
+ const version = parseInt(config_match[2], 10);
81
+ this.emit("config", {
82
+ config,
83
+ version
84
+ });
85
+ if (config && typeof config === "object" && "ingress" in config && Array.isArray(config.ingress)) {
86
+ for (const ingress of config.ingress) {
87
+ if ("hostname" in ingress) {
88
+ tunnel.emit("url", ingress.hostname);
89
+ }
90
+ }
91
+ }
92
+ } catch (error) {
93
+ this.emit("error", new Error(`Failed to parse config: ${error}`));
94
+ }
95
+ }
96
+ };
97
+ tunnel.addHandler(this.config_handler.bind(this));
98
+ }
99
+ on(event, listener) {
100
+ return super.on(event, listener);
101
+ }
102
+ once(event, listener) {
103
+ return super.once(event, listener);
104
+ }
105
+ off(event, listener) {
106
+ return super.off(event, listener);
107
+ }
108
+ emit(event, ...args) {
109
+ return super.emit(event, ...args);
110
+ }
111
+ }
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ ConfigHandler,
115
+ ConnectionHandler,
116
+ TryCloudflareHandler
117
+ });
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ main: () => main
32
+ });
33
+ module.exports = __toCommonJS(src_exports);
34
+ var import_node_fs = __toESM(require("node:fs"));
35
+ var import_node_https = __toESM(require("node:https"));
36
+ var import_node_child_process = require("node:child_process");
37
+ var import_lib = require("./lib.js");
38
+ var import_constants = require("./constants.js");
39
+ async function main() {
40
+ const args = process.argv.slice(2);
41
+ if (args[0] === "bin") {
42
+ if (!args[1]) {
43
+ console.log(import_lib.bin);
44
+ return;
45
+ }
46
+ if (args[1] === "remove") {
47
+ import_node_fs.default.unlinkSync(import_lib.bin);
48
+ console.log("Removed cloudflared");
49
+ return;
50
+ }
51
+ if (args[1] === "install") {
52
+ const version = args[2] || import_constants.CLOUDFLARED_VERSION;
53
+ if (version !== "latest") {
54
+ console.log(`Installing cloudflared ${args[2]}`);
55
+ console.log(await (0, import_lib.install)(import_lib.bin, args[2]));
56
+ } else {
57
+ console.log("Installing latest version of cloudflared");
58
+ await (0, import_lib.install)(import_lib.bin, version);
59
+ }
60
+ return;
61
+ }
62
+ if (args[1] === "list") {
63
+ import_node_https.default.get(
64
+ {
65
+ hostname: "api.github.com",
66
+ path: "/repos/cloudflare/cloudflared/releases",
67
+ headers: {
68
+ "user-agent": "node-cloudflared"
69
+ }
70
+ },
71
+ (res) => {
72
+ let data = "";
73
+ res.on("data", (chunk) => {
74
+ data += chunk;
75
+ });
76
+ res.on("end", () => {
77
+ const releases = JSON.parse(data);
78
+ for (const release of releases) {
79
+ console.log(
80
+ `${release.tag_name.padEnd(10)} (${release.published_at}) [${release.html_url}]`
81
+ );
82
+ }
83
+ });
84
+ }
85
+ );
86
+ return;
87
+ }
88
+ if (args[1] === "help" || args[1] === "--help" || args[1] === "-h") {
89
+ console.log(`cloudflared bin : Prints the path to the binary`);
90
+ console.log(`cloudflared bin remove : Removes the binary`);
91
+ console.log(`cloudflared bin install [version] : Installs the binary`);
92
+ console.log(`cloudflared bin list : Lists 30 latest releases`);
93
+ console.log(`cloudflared bin help : Prints this help message`);
94
+ console.log(`Examples:`);
95
+ console.log(
96
+ `cloudflared bin install : Installs the latest version of cloudflared`
97
+ );
98
+ console.log(`cloudflared bin install 2023.4.1 : Installs cloudflared 2023.4.1`);
99
+ console.log(
100
+ `You can find releases at https://github.com/cloudflare/cloudflared/releases`
101
+ );
102
+ return;
103
+ }
104
+ }
105
+ if (!import_node_fs.default.existsSync(import_lib.bin)) {
106
+ console.log("Installed cloudflared to " + await (0, import_lib.install)(import_lib.bin));
107
+ }
108
+ const sub = (0, import_node_child_process.spawn)(import_lib.bin, args, { stdio: "inherit" });
109
+ sub.on("exit", (code) => {
110
+ if (typeof code === "number") {
111
+ process.exit(code);
112
+ } else {
113
+ process.exit(1);
114
+ }
115
+ });
116
+ const signals = ["SIGINT", "SIGTERM", "SIGQUIT"];
117
+ for (const signal of signals) {
118
+ process.on(signal, () => {
119
+ sub.kill(signal);
120
+ });
121
+ }
122
+ }
123
+ // Annotate the CommonJS export names for ESM import in node:
124
+ 0 && (module.exports = {
125
+ main
126
+ });