nport 2.0.4 → 2.0.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 ADDED
@@ -0,0 +1,175 @@
1
+ # Changelog
2
+
3
+ All notable changes to NPort will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.0.6] - 2026-01-13
9
+
10
+ ### Added
11
+ - 🔧 **Backend URL Configuration**: Full control over backend server
12
+ - `--backend` / `-b` flag for temporary backend override
13
+ - `--set-backend` command to save backend URL permanently
14
+ - `NPORT_BACKEND_URL` environment variable support
15
+ - Saved backend configuration persists across sessions
16
+ - Priority system: CLI flag > Saved config > Env var > Default
17
+ - 🗂️ **Unified Configuration System**: All settings in one place
18
+ - New centralized `config-manager.js` module
19
+ - All preferences stored in `~/.nport/config.json`
20
+ - Automatic migration from old format (v2.0.5)
21
+ - Easy to read and manually edit JSON format
22
+ - 🌐 **New Default Backend**: Updated to `api.nport.link`
23
+ - Professional domain structure
24
+ - Better branding alignment
25
+ - Shorter and easier to remember
26
+
27
+ ### Changed
28
+ - 📝 **Language Configuration**: Now uses unified config system
29
+ - Language setting moved from `~/.nport/lang` to `~/.nport/config.json`
30
+ - Automatic migration from old file format
31
+ - Consistent configuration approach across all settings
32
+ - 📚 **Documentation Updates**: Complete overhaul
33
+ - Updated `README.md` with backend configuration options
34
+ - New `CLIENT_SETUP.md` focused on npm installation and backend setup
35
+ - Comprehensive backend URL documentation
36
+ - Clear priority order explanation
37
+
38
+ ### Improved
39
+ - 🎯 **Consistency**: Unified approach to all configuration
40
+ - Backend URL and language now use same storage system
41
+ - Single config file for all preferences
42
+ - Cleaner architecture and code organization
43
+ - 💾 **Configuration File Structure**:
44
+ ```json
45
+ {
46
+ "backendUrl": "https://api.nport.link",
47
+ "language": "en"
48
+ }
49
+ ```
50
+
51
+ ### Migration
52
+ - Automatic migration from v2.0.5 configuration files
53
+ - Old `~/.nport/lang` file automatically migrated to `config.json`
54
+ - No manual steps required
55
+ - Old files removed after successful migration
56
+
57
+ ## [2.0.5] - 2026-01-13
58
+
59
+ ### Added
60
+ - 🌍 **Multilingual Support**: Full internationalization with English and Vietnamese
61
+ - Interactive language selection on first run
62
+ - `--language` / `-l` flag to change language anytime
63
+ - Language preference saved to `~/.nport/lang`
64
+ - 🎨 **Enhanced UI**: Complete redesign with better visual hierarchy
65
+ - New header design with Vietnamese pride
66
+ - Improved connection status messages
67
+ - Better formatted output with consistent spacing
68
+ - Language change hint in goodbye message
69
+ - 📂 **Modular Architecture**: Refactored codebase into organized modules
70
+ - Split code into `/src` directory with clear separation of concerns
71
+ - Better maintainability and testability
72
+ - Modules: config, state, args, binary, api, version, ui, tunnel, lang, analytics
73
+ - ✅ **Version Command**: Added `-v` / `--version` flag
74
+ - Shows current version
75
+ - Checks for updates automatically
76
+ - Displays update instructions if available
77
+ - 📝 **Configuration Directory**: Organized config files under `~/.nport/`
78
+ - Language preference: `~/.nport/lang`
79
+ - Analytics ID: `~/.nport/analytics-id`
80
+
81
+ ### Changed
82
+ - 🎯 **Improved Console Output**: Better formatting and spacing throughout
83
+ - Connection messages now properly indented
84
+ - Time remaining display updated
85
+ - Footer redesigned with clearer calls-to-action
86
+ - 🔧 **Better Argument Parsing**: Enhanced CLI argument handling
87
+ - Support for multiple language flag formats
88
+ - Interactive prompt when using `--language` without value
89
+ - 📚 **Updated Documentation**: Complete README overhaul
90
+ - Added multilingual feature documentation
91
+ - New CLI options table
92
+ - Project structure documentation
93
+ - Cleaner examples and better organization
94
+
95
+ ### Fixed
96
+ - 🐛 **Terminal Compatibility**: Removed problematic emoji flags
97
+ - Vietnamese flag emoji replaced with text
98
+ - Better compatibility across different terminals
99
+
100
+ ## [2.0.4] - Previous Release
101
+
102
+ ### Features
103
+ - Basic tunnel functionality
104
+ - Custom subdomain support
105
+ - Cloudflare integration
106
+ - Auto-cleanup on exit
107
+ - 4-hour tunnel timeout
108
+
109
+ ---
110
+
111
+ ## Version Upgrade Guide
112
+
113
+ ### From 2.0.5 to 2.0.6
114
+
115
+ ```bash
116
+ npm install -g nport@latest
117
+ ```
118
+
119
+ **New Features to Try:**
120
+
121
+ 1. **Set Your Backend Permanently**
122
+ ```bash
123
+ nport --set-backend https://api.nport.link
124
+ ```
125
+
126
+ 2. **Use Custom Backend Temporarily**
127
+ ```bash
128
+ nport 3000 -b https://your-backend.com
129
+ ```
130
+
131
+ 3. **Check Current Configuration**
132
+ ```bash
133
+ cat ~/.nport/config.json
134
+ ```
135
+
136
+ 4. **Use Environment Variable**
137
+ ```bash
138
+ export NPORT_BACKEND_URL=https://your-backend.com
139
+ nport 3000
140
+ ```
141
+
142
+ **Breaking Changes:** None - fully backward compatible!
143
+
144
+ **Migration:** Your language preference from v2.0.5 will be automatically migrated to the new unified config format.
145
+
146
+ ### From 2.0.4 to 2.0.5
147
+
148
+ ```bash
149
+ npm install -g nport@latest
150
+ ```
151
+
152
+ **New Features to Try:**
153
+
154
+ 1. **Change Language**
155
+ ```bash
156
+ nport --language
157
+ ```
158
+
159
+ 2. **Check Version**
160
+ ```bash
161
+ nport -v
162
+ ```
163
+
164
+ 3. **Direct Language Selection**
165
+ ```bash
166
+ nport 3000 -l vi # Vietnamese
167
+ nport 3000 -l en # English
168
+ ```
169
+
170
+ **Breaking Changes:** None - fully backward compatible!
171
+
172
+ ---
173
+
174
+ Made with ❤️ in Vietnam by [Nick Pham](https://github.com/tuanngocptn)
175
+
package/README.md CHANGED
@@ -29,6 +29,7 @@ Perfect for:
29
29
  - 📡 **WebSocket Support**: Full WebSocket and Server-Sent Events support
30
30
  - 🎯 **No Configuration**: Works out of the box
31
31
  - 💻 **Cross-Platform**: Windows, macOS, and Linux support
32
+ - 🗣️ **Multilingual**: English and Vietnamese UI support
32
33
  - 🆓 **100% Free**: No accounts, no limits, no paywalls
33
34
  - 🔓 **Open Source**: MIT licensed
34
35
 
@@ -61,18 +62,29 @@ nport 3000
61
62
 
62
63
  Output:
63
64
  ```
64
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
65
- NPort - Free & Open Source ngrok Alternative
66
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
67
- 🌐 Website: https://nport.link
68
- 📦 NPM: https://www.npmjs.com/package/nport
69
- 💻 GitHub: https://github.com/tuanngocptn/nport
70
- ☕ Support: https://buymeacoffee.com/tuanngocptn
71
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
72
-
73
- 🚀 Starting Tunnel for port 3000...
74
- ✔ Tunnel created!
75
- 🌍 Public URL: https://user-1234.nport.link
65
+ ╭────────────────────────────────────────────────────────╮
66
+ N P O R T ⚡️ Free & Open Source from Vietnam │
67
+ ╰────────────────────────────────────────────────────────╯
68
+
69
+ Creating tunnel for port 3000...
70
+ 🚀 WE LIVE BABY!
71
+
72
+ 👉 https://user-1234.nport.link 👈
73
+
74
+ ───────────────────────────────────────────────────────
75
+
76
+ ⏱️ Time: 4h remaining
77
+
78
+ ✔ [1/2] Connection established...
79
+ ✔ [2/2] Compression enabled...
80
+
81
+ ───────────────────────────────────────────────────────
82
+
83
+ 🔥 KEEP THE VIBE ALIVE?
84
+ (Made with ❤️ in Vietnam)
85
+
86
+ ⭐️ Drop a Star: https://github.com/tuanngocptn/nport
87
+ ☕️ Buy Coffee: https://buymeacoffee.com/tuanngocptn
76
88
  ```
77
89
 
78
90
  ### Custom Subdomain
@@ -146,7 +158,89 @@ nport <port> [options]
146
158
  |--------|-------|-------------|---------|
147
159
  | `<port>` | - | Local port to tunnel (default: 8080) | `nport 3000` |
148
160
  | `--subdomain` | `-s` | Custom subdomain | `nport 3000 -s myapp` |
149
- | `-s=value` | - | Alternative format | `nport 3000 -s=myapp` |
161
+ | `--backend` | `-b` | Custom backend URL (temporary) | `nport 3000 -b https://your-backend.com` |
162
+ | `--set-backend` | - | Save backend URL permanently | `nport --set-backend https://your-backend.com` |
163
+ | `--language` | `-l` | Set language (en/vi) or prompt | `nport 3000 -l vi` |
164
+ | `--version` | `-v` | Show version information | `nport -v` |
165
+
166
+ ### Language Options
167
+
168
+ NPort supports multiple languages with automatic detection on first run.
169
+
170
+ ```bash
171
+ # Set language directly
172
+ nport 3000 --language en # English
173
+ nport 3000 -l vi # Vietnamese
174
+
175
+ # Open language selection menu
176
+ nport --language # Interactive prompt
177
+ nport -l # Interactive prompt
178
+ ```
179
+
180
+ On first run or when using `--language` without a value, you'll see an interactive language picker. Your choice is automatically saved for future sessions.
181
+
182
+ ### Backend URL Options
183
+
184
+ NPort uses a default backend at `https://api.nport.link`, but you can use your own backend server.
185
+
186
+ #### Temporary Backend (One-time Use)
187
+
188
+ Use a custom backend for just the current session:
189
+
190
+ ```bash
191
+ # Use custom backend via CLI flag
192
+ nport 3000 --backend https://your-backend.com
193
+ nport 3000 -b https://your-backend.com
194
+
195
+ # Use custom backend via environment variable
196
+ export NPORT_BACKEND_URL=https://your-backend.com
197
+ nport 3000
198
+
199
+ # Combine with other options
200
+ nport 3000 -s myapp -b https://your-backend.com
201
+ ```
202
+
203
+ #### Persistent Backend (Saved Configuration)
204
+
205
+ Save a backend URL to use automatically in all future sessions:
206
+
207
+ ```bash
208
+ # Save backend URL permanently
209
+ nport --set-backend https://your-backend.com
210
+
211
+ # Now all future commands will use this backend
212
+ nport 3000 # Uses saved backend
213
+ nport 3000 -s myapp # Uses saved backend
214
+
215
+ # Clear saved backend (return to default)
216
+ nport --set-backend
217
+
218
+ # Override saved backend temporarily
219
+ nport 3000 -b https://different-backend.com
220
+ ```
221
+
222
+ **Configuration Priority:**
223
+ 1. CLI flag (`--backend` or `-b`) - Highest priority
224
+ 2. Saved config (`--set-backend`)
225
+ 3. Environment variable (`NPORT_BACKEND_URL`)
226
+ 4. Default (`https://api.nport.link`) - Lowest priority
227
+
228
+ **Configuration Storage:**
229
+ Your backend preference is saved in `~/.nport/config.json`
230
+
231
+ This is useful if you want to:
232
+ - **Self-host**: Run your own NPort backend (see [server/](server/) directory)
233
+ - **Development**: Test against a local backend
234
+ - **Custom domains**: Use your own domain for tunnel URLs
235
+ - **Enterprise**: Use a company-hosted backend server
236
+
237
+ ### Version Information
238
+
239
+ ```bash
240
+ # Check current version and updates
241
+ nport -v
242
+ nport --version
243
+ ```
150
244
 
151
245
  ## 🔧 How It Works
152
246
 
@@ -162,12 +256,36 @@ Internet → Cloudflare Edge → Cloudflare Tunnel → Your localhost:3000
162
256
  (https://myapp.nport.link)
163
257
  ```
164
258
 
259
+ ## 🏗️ Project Structure
260
+
261
+ NPort uses a modular architecture for better maintainability:
262
+
263
+ ```
264
+ nport/
265
+ ├── index.js # Main entry point
266
+ ├── src/
267
+ │ ├── analytics.js # Analytics tracking
268
+ │ ├── api.js # Backend API client
269
+ │ ├── args.js # CLI argument parser
270
+ │ ├── binary.js # Cloudflared binary manager
271
+ │ ├── bin-manager.js # Binary download/installation
272
+ │ ├── config.js # Configuration constants
273
+ │ ├── lang.js # Multilingual support
274
+ │ ├── state.js # Application state
275
+ │ ├── tunnel.js # Tunnel orchestration
276
+ │ ├── ui.js # User interface display
277
+ │ └── version.js # Version management
278
+ └── bin/
279
+ └── cloudflared # Cloudflare tunnel binary
280
+ ```
281
+
165
282
  ## 🛡️ Security
166
283
 
167
284
  - **HTTPS by default**: All tunnels use SSL/TLS encryption
168
285
  - **Cloudflare protection**: DDoS protection and security features
169
286
  - **Automatic cleanup**: Tunnels are removed when you stop the process
170
287
  - **No data logging**: We don't store or log your traffic
288
+ - **Privacy**: Anonymous analytics (can be disabled with `NPORT_ANALYTICS=false`)
171
289
 
172
290
  ## 🆚 Comparison with ngrok
173
291
 
@@ -177,9 +295,10 @@ Internet → Cloudflare Edge → Cloudflare Tunnel → Your localhost:3000
177
295
  | Custom subdomains | ✅ Always | ❌ Paid only |
178
296
  | HTTPS | ✅ Always | ✅ |
179
297
  | Account required | ❌ No | ✅ Yes |
180
- | Time limits | ❌ None | ⚠️ Free tier limited |
298
+ | Time limits | ❌ None (4h auto-cleanup) | ⚠️ Free tier limited |
181
299
  | Open source | ✅ MIT | ❌ Proprietary |
182
300
  | Global network | ✅ Cloudflare | ✅ ngrok Edge |
301
+ | Multilingual | ✅ EN/VI | ❌ English only |
183
302
 
184
303
  ## 🧹 Cleanup
185
304
 
@@ -193,6 +312,8 @@ The cleanup process:
193
312
  2. ✅ Removes Cloudflare Tunnel
194
313
  3. ✅ Stops cloudflared process
195
314
 
315
+ Tunnels also auto-cleanup after **4 hours** to prevent resource waste.
316
+
196
317
  ## 🐛 Troubleshooting
197
318
 
198
319
  ### Binary not found
@@ -222,6 +343,24 @@ nport 3000 -s myapp-v2
222
343
 
223
344
  The `ERR Cannot determine default origin certificate path` warning is harmless and can be ignored. It appears because cloudflared checks for certificate-based authentication (we use token-based instead).
224
345
 
346
+ ### Change language
347
+
348
+ To change your language preference:
349
+ ```bash
350
+ nport --language
351
+ # or
352
+ nport -l
353
+ ```
354
+
355
+ Then select your preferred language from the menu.
356
+
357
+ ## 🌍 Supported Languages
358
+
359
+ - 🇺🇸 **English** (`en`) - Default
360
+ - 🇻🇳 **Vietnamese** (`vi`) - Tiếng Việt
361
+
362
+ Want to add your language? Contributions are welcome! Check out `src/lang.js` to see how easy it is to add translations.
363
+
225
364
  ## 🤝 Contributing
226
365
 
227
366
  Contributions are welcome! Please feel free to submit a Pull Request.
@@ -232,6 +371,24 @@ Contributions are welcome! Please feel free to submit a Pull Request.
232
371
  4. Push to the branch (`git push origin feature/amazing-feature`)
233
372
  5. Open a Pull Request
234
373
 
374
+ ### Adding a New Language
375
+
376
+ To add a new language:
377
+
378
+ 1. Open `src/lang.js`
379
+ 2. Add your language code to `availableLanguages` array
380
+ 3. Add translations to the `TRANSLATIONS` object
381
+ 4. Submit a PR!
382
+
383
+ Example:
384
+ ```javascript
385
+ const TRANSLATIONS = {
386
+ en: { /* English translations */ },
387
+ vi: { /* Vietnamese translations */ },
388
+ es: { /* Your Spanish translations */ },
389
+ };
390
+ ```
391
+
235
392
  ## 💖 Support
236
393
 
237
394
  If you find NPort useful, please consider supporting the project:
@@ -240,6 +397,7 @@ If you find NPort useful, please consider supporting the project:
240
397
  - ☕ [Buy me a coffee](https://buymeacoffee.com/tuanngocptn)
241
398
  - 💬 Share with your friends and colleagues
242
399
  - 🐛 [Report bugs](https://github.com/tuanngocptn/nport/issues)
400
+ - 🌍 [Add translations](https://github.com/tuanngocptn/nport/blob/main/src/lang.js)
243
401
 
244
402
  ## 📄 License
245
403
 
@@ -247,7 +405,7 @@ If you find NPort useful, please consider supporting the project:
247
405
 
248
406
  ## 🙏 Credits
249
407
 
250
- - Created by [Nick Pham](https://github.com/tuanngocptn) 🇻🇳
408
+ - Created by [Nick Pham](https://github.com/tuanngocptn) from Vietnam
251
409
  - Powered by [Cloudflare Tunnels](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/)
252
410
  - Inspired by [ngrok](https://ngrok.com) and [localtunnel](https://github.com/localtunnel/localtunnel)
253
411
 
@@ -260,4 +418,4 @@ If you find NPort useful, please consider supporting the project:
260
418
 
261
419
  ---
262
420
 
263
- Made with ❤️ by [Nick Pham](https://github.com/tuanngocptn)
421
+ Made with ❤️ in Vietnam by [Nick Pham](https://github.com/tuanngocptn)