@nora-link/client 1.0.4 → 1.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.
Files changed (3) hide show
  1. package/dist/cli.js +17 -12
  2. package/package.json +1 -1
  3. package/src/cli.ts +17 -13
package/dist/cli.js CHANGED
@@ -11,14 +11,14 @@ 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
  }
19
19
  return previous;
20
20
  }, 'info')
21
- .requiredOption('-f, --forward <subdomain|label|url>', 'Tunnel subdomain to local url. Label is optional')
21
+ .requiredOption('-f, --forward <subdomain|label|url...>', 'Tunnel subdomain to local url. Label is optional')
22
22
  .requiredOption('-k, --key <api-key>', 'Api Key')
23
23
  .requiredOption('-h, --host <hostname>', 'Server host name', 'noralink.eu')
24
24
  .addHelpText('afterAll', 'To tunnel a local port to the subdomain `test`, you can use `-f test|:3000`')
@@ -48,12 +48,17 @@ if (Array.isArray(options.forward)) {
48
48
  return { remotePath: segment, localUrl: toUrl, label };
49
49
  });
50
50
  }
51
- new client_1.Client({
52
- agent: `${name}@${version}`,
53
- hostname: options.host,
54
- secure: !options.nonSecure,
55
- tunnels,
56
- apiKey: options.key,
57
- logger: (0, logger_1.createConsoleLogger)(options.log),
58
- }).handle$
59
- .subscribe();
51
+ if (!tunnels.length) {
52
+ console.info('no valid tunnels specified');
53
+ process.exit(1);
54
+ }
55
+ else {
56
+ new client_1.Client({
57
+ agent: `${name}@${version}`,
58
+ hostname: options.host,
59
+ secure: !options.nonSecure,
60
+ tunnels,
61
+ apiKey: options.key,
62
+ logger: (0, logger_1.createConsoleLogger)(options.log),
63
+ }).handle$.subscribe();
64
+ }
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.6",
4
4
  "description": "noralink.eu client",
5
5
  "bin": {
6
6
  "noralink": "dist/cli.js"
package/src/cli.ts CHANGED
@@ -12,14 +12,14 @@ 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
  }
20
20
  return previous;
21
21
  }, 'info')
22
- .requiredOption('-f, --forward <subdomain|label|url>', 'Tunnel subdomain to local url. Label is optional')
22
+ .requiredOption('-f, --forward <subdomain|label|url...>', 'Tunnel subdomain to local url. Label is optional')
23
23
  .requiredOption('-k, --key <api-key>', 'Api Key')
24
24
  .requiredOption('-h, --host <hostname>', 'Server host name', 'noralink.eu')
25
25
  .addHelpText('afterAll', 'To tunnel a local port to the subdomain `test`, you can use `-f test|:3000`')
@@ -53,13 +53,17 @@ if (Array.isArray(options.forward)) {
53
53
  });
54
54
  }
55
55
 
56
- new Client({
57
- agent: `${name}@${version}`,
58
- hostname: options.host,
59
- secure: !options.nonSecure,
60
- tunnels,
61
- apiKey: options.key,
62
- logger: createConsoleLogger(options.log),
63
- }).handle$
64
- .subscribe();
65
-
56
+ if (!tunnels.length) {
57
+ console.info('no valid tunnels specified');
58
+ process.exit(1);
59
+ }
60
+ else {
61
+ new Client({
62
+ agent: `${name}@${version}`,
63
+ hostname: options.host,
64
+ secure: !options.nonSecure,
65
+ tunnels,
66
+ apiKey: options.key,
67
+ logger: createConsoleLogger(options.log),
68
+ }).handle$.subscribe();
69
+ }