@nora-link/client 1.0.4 → 1.0.5

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 (3) hide show
  1. package/dist/cli.js +23 -25
  2. package/package.json +1 -1
  3. package/src/cli.ts +23 -25
package/dist/cli.js CHANGED
@@ -11,8 +11,8 @@ commander_1.program
11
11
  .usage('[OPTIONS]...')
12
12
  .option('-d, --debug', 'output extra debugging', false)
13
13
  .option('-n, --non-secure', 'don\'t use secure connection', false)
14
- .option('-l, --log', `min log level to display. Options: ${logger_1.LOG_LEVEL.join(',')}`, (value, previous) => {
15
- const v = value.toLowerCase();
14
+ .option('-l, --log <log-level>', `min log level to display. Options: ${logger_1.LOG_LEVEL.join(',')}`, (value, previous) => {
15
+ const v = value?.toLowerCase();
16
16
  if (logger_1.LOG_LEVEL.includes(v)) {
17
17
  return v;
18
18
  }
@@ -25,29 +25,27 @@ commander_1.program
25
25
  .addHelpText('afterAll', 'To tunnel an ip to the subdomain `test`, you can use `-f test|192.168.1.130`')
26
26
  .parse();
27
27
  const options = commander_1.program.opts();
28
- let tunnels = [];
29
- if (Array.isArray(options.forward)) {
30
- tunnels = options.forward
31
- .filter((v) => typeof v === 'string')
32
- .map(v => {
33
- const [segment, labelOrUrl, urlPart] = v.split('|');
34
- let toUrl;
35
- const label = urlPart ? labelOrUrl : segment;
36
- const url = urlPart ?? labelOrUrl;
37
- if (/^https?:\/\//.test(url)) {
38
- toUrl = url;
39
- }
40
- else if (url.startsWith(':')) {
41
- //only port specified
42
- const port = +url.split(':')[1];
43
- toUrl = `http://127.0.0.1:${port}`;
44
- }
45
- else {
46
- toUrl = `http://${url}`;
47
- }
48
- return { remotePath: segment, localUrl: toUrl, label };
49
- });
50
- }
28
+ const forward = Array.isArray(options.forward) ? options.forward : [options.forward];
29
+ const tunnels = forward
30
+ .filter((v) => typeof v === 'string')
31
+ .map(v => {
32
+ const [segment, labelOrUrl, urlPart] = v.split('|');
33
+ let toUrl;
34
+ const label = urlPart ? labelOrUrl : segment;
35
+ const url = urlPart ?? labelOrUrl;
36
+ if (/^https?:\/\//.test(url)) {
37
+ toUrl = url;
38
+ }
39
+ else if (url.startsWith(':')) {
40
+ //only port specified
41
+ const port = +url.split(':')[1];
42
+ toUrl = `http://127.0.0.1:${port}`;
43
+ }
44
+ else {
45
+ toUrl = `http://${url}`;
46
+ }
47
+ return { remotePath: segment, localUrl: toUrl, label };
48
+ });
51
49
  new client_1.Client({
52
50
  agent: `${name}@${version}`,
53
51
  hostname: options.host,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nora-link/client",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "noralink.eu client",
5
5
  "bin": {
6
6
  "noralink": "dist/cli.js"
package/src/cli.ts CHANGED
@@ -12,8 +12,8 @@ program
12
12
  .usage('[OPTIONS]...')
13
13
  .option('-d, --debug', 'output extra debugging', false)
14
14
  .option('-n, --non-secure', 'don\'t use secure connection', false)
15
- .option<LogLevel>('-l, --log', `min log level to display. Options: ${LOG_LEVEL.join(',')}`, (value, previous) => {
16
- const v = value.toLowerCase() as LogLevel;
15
+ .option<LogLevel>('-l, --log <log-level>', `min log level to display. Options: ${LOG_LEVEL.join(',')}`, (value, previous) => {
16
+ const v = value?.toLowerCase() as LogLevel;
17
17
  if (LOG_LEVEL.includes(v)) {
18
18
  return v;
19
19
  }
@@ -28,30 +28,28 @@ program
28
28
 
29
29
  const options = program.opts();
30
30
 
31
- let tunnels: ClientConnectionOptions['tunnels'] = [];
32
- if (Array.isArray(options.forward)) {
33
- tunnels = options.forward
34
- .filter((v): v is string => typeof v === 'string')
35
- .map(v => {
36
- const [segment, labelOrUrl, urlPart] = v.split('|');
37
- let toUrl: string;
38
-
39
- const label = urlPart ? labelOrUrl : segment;
40
- const url = urlPart ?? labelOrUrl;
41
-
42
- if (/^https?:\/\//.test(url)) {
43
- toUrl = url;
44
- } else if (url.startsWith(':')) {
45
- //only port specified
46
- const port = +url.split(':')[1];
47
- toUrl = `http://127.0.0.1:${port}`;
48
- } else {
49
- toUrl = `http://${url}`;
50
- }
31
+ const forward = Array.isArray(options.forward) ? options.forward : [options.forward];
32
+ const tunnels: ClientConnectionOptions['tunnels'] = forward
33
+ .filter((v): v is string => typeof v === 'string')
34
+ .map(v => {
35
+ const [segment, labelOrUrl, urlPart] = v.split('|');
36
+ let toUrl: string;
37
+
38
+ const label = urlPart ? labelOrUrl : segment;
39
+ const url = urlPart ?? labelOrUrl;
40
+
41
+ if (/^https?:\/\//.test(url)) {
42
+ toUrl = url;
43
+ } else if (url.startsWith(':')) {
44
+ //only port specified
45
+ const port = +url.split(':')[1];
46
+ toUrl = `http://127.0.0.1:${port}`;
47
+ } else {
48
+ toUrl = `http://${url}`;
49
+ }
51
50
 
52
- return { remotePath: segment, localUrl: toUrl, label };
53
- });
54
- }
51
+ return { remotePath: segment, localUrl: toUrl, label };
52
+ });
55
53
 
56
54
  new Client({
57
55
  agent: `${name}@${version}`,