@lifelessrasel/devtunnel-cli 1.0.0 → 1.0.1

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 (2) hide show
  1. package/bin/devtunnel.js +45 -3
  2. package/package.json +2 -1
package/bin/devtunnel.js CHANGED
@@ -5,20 +5,61 @@ const WebSocket = require('ws');
5
5
  const axios = require('axios');
6
6
  const program = new Command();
7
7
 
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const os = require('os');
11
+ const inquirer = require('inquirer');
12
+
13
+ const CONFIG_DIR = path.join(os.homedir(), '.devtunnel');
14
+ const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
15
+
16
+ function saveConfig(config) {
17
+ if (!fs.existsSync(CONFIG_DIR)) {
18
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
19
+ }
20
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
21
+ }
22
+
23
+ function loadConfig() {
24
+ if (fs.existsSync(CONFIG_FILE)) {
25
+ return JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
26
+ }
27
+ return {};
28
+ }
29
+
8
30
  program
9
31
  .name('devtunnel')
10
32
  .description('Expose your local server to the internet')
11
- .version('1.0.0');
33
+ .version('1.0.1');
34
+
35
+ program.command('login')
36
+ .description('Login with your API Key')
37
+ .action(async () => {
38
+ const answers = await inquirer.prompt([
39
+ {
40
+ type: 'password',
41
+ name: 'apiKey',
42
+ message: 'Enter your API Key:',
43
+ mask: '*'
44
+ }
45
+ ]);
46
+
47
+ const config = loadConfig();
48
+ config.apiKey = answers.apiKey;
49
+ saveConfig(config);
50
+ console.log('✅ API Key saved successfully!');
51
+ });
12
52
 
13
53
  program.command('start')
14
54
  .description('Start a tunnel')
15
55
  .option('-p, --port <number>', 'Local port to expose', '3000')
16
56
  .option('-s, --subdomain <string>', 'Requested subdomain')
17
- .option('--server <string>', 'Tunnel server URL', 'ws://localhost:8000')
57
+ .option('--server <string>', 'Tunnel server URL', 'wss://tunnel.mohammadrasel.com')
18
58
  .action(async (options) => {
19
59
  const localPort = options.port;
20
60
  const serverUrl = options.server;
21
61
  const requestedSubdomain = options.subdomain;
62
+ const config = loadConfig();
22
63
 
23
64
  console.log(`Connecting to ${serverUrl} requesting subdomain: ${requestedSubdomain || '(random)'}...`);
24
65
 
@@ -28,7 +69,8 @@ program.command('start')
28
69
  console.log('Connected to Tunnel Server.');
29
70
  ws.send(JSON.stringify({
30
71
  type: 'register',
31
- subdomain: requestedSubdomain
72
+ subdomain: requestedSubdomain,
73
+ apiKey: config.apiKey
32
74
  }));
33
75
  });
34
76
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.0",
6
+ "version": "1.0.1",
7
7
  "description": "A specialized tunneling tool to expose local servers to the internet via DevTunnel.net",
8
8
  "main": "bin/devtunnel.js",
9
9
  "scripts": {
@@ -26,6 +26,7 @@
26
26
  "dependencies": {
27
27
  "axios": "^1.13.2",
28
28
  "commander": "^14.0.2",
29
+ "inquirer": "^8.2.7",
29
30
  "ws": "^8.19.0"
30
31
  },
31
32
  "repository": {