devtunnel-cli 3.0.44 ā 3.1.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/README.md +152 -141
- package/package.json +89 -85
- package/src/core/RUN.js +64 -64
- package/src/core/index.js +374 -374
- package/src/core/proxy-server.js +105 -105
- package/src/core/setup-cloudflared.js +427 -427
- package/src/core/start.js +2 -2
- package/src/core/static-server.js +109 -109
- package/src/utils/folder-picker.js +140 -140
- package/src/utils/pages/index.html +1 -1
- package/src/utils/postinstall-global-check.cjs +15 -0
- package/src/utils/tunnel-helpers.js +35 -35
package/README.md
CHANGED
|
@@ -1,141 +1,152 @@
|
|
|
1
|
-
# DevTunnel-CLI š
|
|
2
|
-
|
|
3
|
-
**Share your local dev servers worldwide - Zero config tunnel for any framework**
|
|
4
|
-
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://github.com/maiz-an/DevTunnel-CLI)
|
|
7
|
-
[](https://www.npmjs.com/package/devtunnel-cli)
|
|
8
|
-
|
|
9
|
-
š **Website:** [devtunnel-cli.vercel.app](https://devtunnel-cli.vercel.app) | š¦ **npm:** [devtunnel-cli](https://www.npmjs.com/package/devtunnel-cli) | š» **GitHub:** [maiz-an/DevTunnel-CLI](https://github.com/maiz-an/DevTunnel-CLI)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
# DevTunnel-CLI š
|
|
2
|
+
|
|
3
|
+
**Share your local dev servers worldwide - Zero config tunnel for any framework**
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/maiz-an/DevTunnel-CLI)
|
|
7
|
+
[](https://www.npmjs.com/package/devtunnel-cli)
|
|
8
|
+
|
|
9
|
+
š **Website:** [devtunnel-cli.vercel.app](https://devtunnel-cli.vercel.app) | š¦ **npm:** [devtunnel-cli](https://www.npmjs.com/package/devtunnel-cli) | š» **GitHub:** [maiz-an/DevTunnel-CLI](https://github.com/maiz-an/DevTunnel-CLI)
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
| Platform | Command |
|
|
14
|
+
| -------- | ------- |
|
|
15
|
+
| **Windows** | `winget install devtunnel-cli` |
|
|
16
|
+
| **macOS** | `brew install devtunnel-cli` |
|
|
17
|
+
| **Linux** | `sudo apt install devtunnel-cli` |
|
|
18
|
+
| **npm** | `npm i -g devtunnel-cli` |
|
|
19
|
+
|
|
20
|
+
Windows, macOS, and Linux: same style ā **standalone binary**, no Node required.
|
|
21
|
+
**Linux (first time only):** run once `curl -fsSL https://raw.githubusercontent.com/maiz-an/DevTunnel-CLI/main/scripts/install.sh | sudo sh` to add our APT repo, then use the command above. npm requires Node.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## šÆ Purpose & Scope
|
|
26
|
+
|
|
27
|
+
DevTunnel-CLI is designed for **DEVELOPMENT**, **TESTING**, **DEMOS**, and **WEBHOOK DEBUGGING**. It provides fast, frictionless access to your local dev servers from anywhere.
|
|
28
|
+
|
|
29
|
+
DevTunnel-CLI is built for developers who need instant public URLs to share work-in-progress, test on mobile devices, demo features to clients, or debug webhooks from third-party services.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ā” Quick Start
|
|
34
|
+
|
|
35
|
+
### Step-by-Step Guide
|
|
36
|
+
|
|
37
|
+
**1. Install DevTunnel (one-time setup):**
|
|
38
|
+
Use **Windows** (winget), **macOS** (brew), **Linux** (apt), or **npm** ā see the [Install](#install) table above.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm i -g devtunnel-cli
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**2. Navigate to your project directory:**
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
cd your-project
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**3. Have your app running (in one terminal):**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm run dev
|
|
54
|
+
# OR php artisan serve (Laravel)
|
|
55
|
+
# OR XAMPP / Live Server (PHP/HTML)
|
|
56
|
+
# HTML: optional ā DevTunnel can start a built-in server
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**4. Run DevTunnel (in another terminal, same directory):**
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cd your-project # Same directory as your project
|
|
63
|
+
devtunnel-cli # Auto-detects project type and port!
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**That's it!** DevTunnel auto-detects Node, Laravel, HTML, and PHP/XAMPP projects.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## ⨠Features
|
|
71
|
+
|
|
72
|
+
- š¤ **Fully Automatic** - Cloudflare bundled, no installation needed
|
|
73
|
+
- šÆ **Zero Config** - No project changes needed
|
|
74
|
+
- š **Smart Proxy** - Bypasses Vite/React restrictions
|
|
75
|
+
- š **Cross-Platform** - Windows, macOS, Linux
|
|
76
|
+
- š **Any Framework** - Node, React, Laravel, plain HTML, PHP/XAMPP
|
|
77
|
+
- š **HTML** - Default port 5500; built-in static server if none running
|
|
78
|
+
- š **PHP/XAMPP** - Port 80; supports htdocs subfolders (e.g. <http://localhost/YourProject/>)
|
|
79
|
+
- š **Multi-Service** - Cloudflare, Ngrok, LocalTunnel fallback
|
|
80
|
+
- š **Multiple Ports** - DevTunnel-CLI supports multiple ports; auto-detects or lets you choose
|
|
81
|
+
- š¹ **Streaming Support** - Handles video/audio files
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## š” How to Use
|
|
86
|
+
|
|
87
|
+
**Important:** Run `devtunnel-cli` from the same directory as your project!
|
|
88
|
+
|
|
89
|
+
1. **Install DevTunnel** (one-time): use winget, brew, apt, or [npm](#install) above.
|
|
90
|
+
2. **Go to your project**: `cd your-project` (Node, Laravel, HTML, or XAMPP folder)
|
|
91
|
+
3. **Have your app running**: `npm run dev`, `php artisan serve`, or XAMPP. For HTML, optional ā DevTunnel can serve it.
|
|
92
|
+
4. **Open a new terminal** in the same project directory
|
|
93
|
+
5. **Run DevTunnel**: `devtunnel-cli` (auto-detects project type and port!)
|
|
94
|
+
6. **Get your public URL** and share it! š
|
|
95
|
+
|
|
96
|
+
**Example (Node):**
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Terminal 1
|
|
100
|
+
cd my-react-app
|
|
101
|
+
npm run dev
|
|
102
|
+
|
|
103
|
+
# Terminal 2 - same directory
|
|
104
|
+
cd my-react-app
|
|
105
|
+
devtunnel-cli
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Works with:** Vite, React, Next.js, Express, NestJS, Laravel, plain HTML, PHP/XAMPP, and any HTTP/HTTPS server.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## š Documentation
|
|
113
|
+
|
|
114
|
+
- [Features](docs/FEATURES.md)
|
|
115
|
+
- [Troubleshooting](docs/TROUBLESHOOTING.md)
|
|
116
|
+
- [Contributing](docs/CONTRIBUTING.md)
|
|
117
|
+
- [License](docs/LICENSE)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## š ļø Requirements
|
|
122
|
+
|
|
123
|
+
- **Windows / macOS / Linux (OS install):** No Node required ā standalone binary.
|
|
124
|
+
- **npm install:** Node.js 16+ ([nodejs.org](https://nodejs.org)).
|
|
125
|
+
- Internet connection and your dev server running.
|
|
126
|
+
|
|
127
|
+
Cloudflare is automatically bundled on first run.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## š License
|
|
132
|
+
|
|
133
|
+
MIT License - see [LICENSE](docs/LICENSE)
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
**Latest on [npm](https://www.npmjs.com/package/devtunnel-cli)** | Made with ā¤ļø for developers worldwide
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## š Search keywords
|
|
142
|
+
|
|
143
|
+
Find this project as: **DevTunnel**, **devtunnel**, **dev-tunnel**, **Dev-Tunnel**, **DevTunnel-CLI**, **devtunnel-cli**, **dev-tunnel-cli**, **Dev-Tunnel-CLI**. npm (install here): [devtunnel-cli](https://www.npmjs.com/package/devtunnel-cli) Ā· Docs: [devtunnel-cli.vercel.app](https://devtunnel-cli.vercel.app) Ā· GitHub: [maiz-an/DevTunnel-CLI](https://github.com/maiz-an/DevTunnel-CLI).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## š¦ Links
|
|
148
|
+
|
|
149
|
+
- **Website**: [devtunnel-cli.vercel.app](https://devtunnel-cli.vercel.app)
|
|
150
|
+
- **npm**: [devtunnel-cli](https://www.npmjs.com/package/devtunnel-cli)
|
|
151
|
+
- **GitHub**: [maiz-an/DevTunnel-CLI](https://github.com/maiz-an/DevTunnel-CLI)
|
|
152
|
+
- **Issues**: [GitHub Issues](https://github.com/maiz-an/DevTunnel-CLI/issues)
|
package/package.json
CHANGED
|
@@ -1,86 +1,90 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "devtunnel-cli",
|
|
3
|
-
"version": "3.0
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "DevTunnel-CLI ā fast, zero-config tool to share local servers for development, testing, demos, and webhook debugging. npm i -g devtunnel-cli.",
|
|
6
|
-
"main": "src/core/start.js",
|
|
7
|
-
"files": [
|
|
8
|
-
"README.md",
|
|
9
|
-
"src"
|
|
10
|
-
],
|
|
11
|
-
"bin": {
|
|
12
|
-
"devtunnel-cli": "src/core/RUN.js"
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"start": "node src/core/RUN.js",
|
|
16
|
-
"dev": "node src/core/RUN.js",
|
|
17
|
-
"run": "node src/core/RUN.js",
|
|
18
|
-
"tunnel": "node src/core/index.js",
|
|
19
|
-
"sync-version": "node sync-version.js",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "devtunnel-cli",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "DevTunnel-CLI ā fast, zero-config tool to share local servers for development, testing, demos, and webhook debugging. npm i -g devtunnel-cli.",
|
|
6
|
+
"main": "src/core/start.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"README.md",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"devtunnel-cli": "src/core/RUN.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "node src/core/RUN.js",
|
|
16
|
+
"dev": "node src/core/RUN.js",
|
|
17
|
+
"run": "node src/core/RUN.js",
|
|
18
|
+
"tunnel": "node src/core/index.js",
|
|
19
|
+
"sync-version": "node sync-version.js",
|
|
20
|
+
"build:standalone": "node scripts/build-standalone.js",
|
|
21
|
+
"test": "node -e \"console.log('ok')\"",
|
|
22
|
+
"prepublishOnly": "npm test",
|
|
23
|
+
"postinstall": "node src/utils/postinstall-global-check.cjs"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"DevTunnel-CLI",
|
|
27
|
+
"DevTunnel",
|
|
28
|
+
"devtunnel",
|
|
29
|
+
"dev-tunnel",
|
|
30
|
+
"Dev-Tunnel",
|
|
31
|
+
"devtunnel-cli",
|
|
32
|
+
"dev-tunnel-cli",
|
|
33
|
+
"Dev-Tunnel-CLI",
|
|
34
|
+
"multiple ports",
|
|
35
|
+
"dev tunnel",
|
|
36
|
+
"localhost tunnel",
|
|
37
|
+
"cloudflare tunnel",
|
|
38
|
+
"ngrok alternative",
|
|
39
|
+
"ngrok",
|
|
40
|
+
"localtunnel",
|
|
41
|
+
"dev-server",
|
|
42
|
+
"share localhost",
|
|
43
|
+
"public-url",
|
|
44
|
+
"port forwarding",
|
|
45
|
+
"local development",
|
|
46
|
+
"vite tunnel",
|
|
47
|
+
"react dev server",
|
|
48
|
+
"nextjs tunnel",
|
|
49
|
+
"nestjs",
|
|
50
|
+
"express",
|
|
51
|
+
"laravel",
|
|
52
|
+
"php",
|
|
53
|
+
"html",
|
|
54
|
+
"backend",
|
|
55
|
+
"frontend",
|
|
56
|
+
"proxy",
|
|
57
|
+
"development tools",
|
|
58
|
+
"web development",
|
|
59
|
+
"tunnel service",
|
|
60
|
+
"local server sharing",
|
|
61
|
+
"dev server proxy",
|
|
62
|
+
"cloudflare tunnel cli",
|
|
63
|
+
"ngrok alternative free",
|
|
64
|
+
"zero config tunnel",
|
|
65
|
+
"development",
|
|
66
|
+
"localhost"
|
|
67
|
+
],
|
|
68
|
+
"author": "maiz",
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"preferGlobal": true,
|
|
71
|
+
"repository": {
|
|
72
|
+
"type": "git",
|
|
73
|
+
"url": "git+https://github.com/maiz-an/DevTunnel-CLI.git"
|
|
74
|
+
},
|
|
75
|
+
"bugs": {
|
|
76
|
+
"url": "https://github.com/maiz-an/DevTunnel-CLI/issues"
|
|
77
|
+
},
|
|
78
|
+
"homepage": "https://devtunnel-cli.vercel.app",
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=16.0.0"
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"http-proxy": "^1.18.1",
|
|
84
|
+
"localtunnel": "^2.0.2",
|
|
85
|
+
"prompts": "^2.4.2"
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@yao-pkg/pkg": "^5.15.0"
|
|
89
|
+
}
|
|
86
90
|
}
|
package/src/core/RUN.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// Universal Node.js Launcher - Works on ALL platforms!
|
|
4
|
-
import { spawn } from "child_process";
|
|
5
|
-
import { readFileSync, existsSync } from "fs";
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
import { dirname, join } from "path";
|
|
8
|
-
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = dirname(__filename);
|
|
11
|
-
|
|
12
|
-
// Version flags: devtunnel-cli --version, -v, or --v
|
|
13
|
-
const args = process.argv.slice(2);
|
|
14
|
-
const showVersion = args.some((a) => a === "--version" || a === "-v" || a === "--v");
|
|
15
|
-
if (showVersion) {
|
|
16
|
-
try {
|
|
17
|
-
const pkgPath = join(dirname(dirname(__dirname)), "package.json");
|
|
18
|
-
const version = existsSync(pkgPath)
|
|
19
|
-
? JSON.parse(readFileSync(pkgPath, "utf8")).version
|
|
20
|
-
: "?.?.?";
|
|
21
|
-
console.log(version);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
console.log("?.?.?");
|
|
24
|
-
}
|
|
25
|
-
process.exit(0);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const originalEmitWarning = process.emitWarning;
|
|
29
|
-
process.emitWarning = function(warning, ...args) {
|
|
30
|
-
if (typeof warning === 'string' && warning.includes('util._extend')) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
return originalEmitWarning.call(this, warning, ...args);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
process.stdout.write('\x1B[2J\x1B[0f');
|
|
37
|
-
console.clear();
|
|
38
|
-
|
|
39
|
-
const startPath = join(__dirname, "start.js");
|
|
40
|
-
const child = spawn("node", [startPath], {
|
|
41
|
-
stdio: "inherit",
|
|
42
|
-
shell: false
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
child.on("error", (error) => {
|
|
46
|
-
console.error("ā Error starting app:", error.message);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
child.on("close", (code) => {
|
|
51
|
-
if (code !== 0) {
|
|
52
|
-
console.log(`\nā ļø Process exited with code ${code}`);
|
|
53
|
-
}
|
|
54
|
-
process.exit(code || 0);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Handle Ctrl+C
|
|
58
|
-
process.on("SIGINT", () => {
|
|
59
|
-
child.kill("SIGINT");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
process.on("SIGTERM", () => {
|
|
63
|
-
child.kill("SIGTERM");
|
|
64
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Universal Node.js Launcher - Works on ALL platforms!
|
|
4
|
+
import { spawn } from "child_process";
|
|
5
|
+
import { readFileSync, existsSync } from "fs";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
import { dirname, join } from "path";
|
|
8
|
+
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
|
|
12
|
+
// Version flags: devtunnel-cli --version, -v, or --v
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const showVersion = args.some((a) => a === "--version" || a === "-v" || a === "--v");
|
|
15
|
+
if (showVersion) {
|
|
16
|
+
try {
|
|
17
|
+
const pkgPath = join(dirname(dirname(__dirname)), "package.json");
|
|
18
|
+
const version = existsSync(pkgPath)
|
|
19
|
+
? JSON.parse(readFileSync(pkgPath, "utf8")).version
|
|
20
|
+
: "?.?.?";
|
|
21
|
+
console.log(version);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.log("?.?.?");
|
|
24
|
+
}
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const originalEmitWarning = process.emitWarning;
|
|
29
|
+
process.emitWarning = function(warning, ...args) {
|
|
30
|
+
if (typeof warning === 'string' && warning.includes('util._extend')) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
return originalEmitWarning.call(this, warning, ...args);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
process.stdout.write('\x1B[2J\x1B[0f');
|
|
37
|
+
console.clear();
|
|
38
|
+
|
|
39
|
+
const startPath = join(__dirname, "start.js");
|
|
40
|
+
const child = spawn("node", [startPath], {
|
|
41
|
+
stdio: "inherit",
|
|
42
|
+
shell: false
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
child.on("error", (error) => {
|
|
46
|
+
console.error("ā Error starting app:", error.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
child.on("close", (code) => {
|
|
51
|
+
if (code !== 0) {
|
|
52
|
+
console.log(`\nā ļø Process exited with code ${code}`);
|
|
53
|
+
}
|
|
54
|
+
process.exit(code || 0);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Handle Ctrl+C
|
|
58
|
+
process.on("SIGINT", () => {
|
|
59
|
+
child.kill("SIGINT");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
process.on("SIGTERM", () => {
|
|
63
|
+
child.kill("SIGTERM");
|
|
64
|
+
});
|