tiro-notes 0.27.26 → 0.27.29

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/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
- //const tHelpers = require('../shared.helpers.js'); // for dev purposes
3
- const tHelpers = require(`./shared.helpers.build.js`);
2
+ //const isDev = true
3
+ const isDev = false
4
+
5
+ const tHelpers = isDev ? require('../shared.helpers.js') : require(`./shared.helpers.build.js`);
4
6
 
5
7
  // open frontend on default browser
6
8
  const openInBrowser = (url) => {
@@ -13,6 +15,7 @@ function getCliArgs () {
13
15
  var args = process.argv;
14
16
  var argsObj = {
15
17
  port: 3023,
18
+ https: false,
16
19
  tunnel: {
17
20
  enabled: false,
18
21
  },
@@ -24,6 +27,7 @@ function getCliArgs () {
24
27
  var argVal = args[i+1];
25
28
  argName = argName.replace('--', '').replace('-','')
26
29
  if (argName === 'p' || argName === 'port') argsObj.port = parseInt(argVal);
30
+ if (argName === 's' || argName === 'https') argsObj.https = true
27
31
  if (argName === 't' || argName === 'tunnel') {
28
32
  const argsArr = argVal.split(':')
29
33
  if (argsArr.length > 1) {
@@ -41,7 +45,10 @@ function startTiroServer (argsObj, cb) {
41
45
 
42
46
  // start tiro server, detect success message and get server params
43
47
  tHelpers.execCmd('node', [`${__dirname}/server/server.js`], {
44
- env: { TIRO_PORT: argsObj.port },
48
+ env: {
49
+ TIRO_PORT: argsObj.port,
50
+ TIRO_HTTPS: argsObj.https
51
+ },
45
52
  logName: 'tiroServer',
46
53
  onLog: str => {
47
54
  tHelpers.checkAndGetTiroConfig(str, {platform: 'cli', cb})
@@ -52,23 +59,22 @@ function startTiroServer (argsObj, cb) {
52
59
  const startSshTunnel = (argsObj) => {
53
60
  if (argsObj.tunnel.enabled) {
54
61
  // kill previous autossh processes
55
- let cb1 = true
56
62
  let cb2 = true
63
+ let cb1 = true
57
64
  tHelpers.execCmd('killall', [`autossh`], {
58
- logName:'tunnel 1',
59
- onLog: str => {
60
- if (!cb1) return
61
- cb1 = false
62
-
65
+ logName:'tunnel 1/3',
66
+ onLog: () => {
67
+ if (!cb2) return
68
+ cb2 = false
63
69
  // check if autossh is working
64
- tHelpers.execCmd('autossh', [`--help`], {
65
- logName:'tunnel 2',
70
+ tHelpers.execCmd('autossh', [`-V`], {
71
+ logName:'tunnel 2/3',
66
72
  onLog: str => {
67
- if (!cb2) return
68
- cb2 = false
73
+ if (!cb1) return
74
+ cb1 = false
69
75
  // start autossh finally
70
76
  tHelpers.execCmd('autossh',['-M','20000','-N', argsObj.tunnel.remoteUrl,'-R', `${argsObj.tunnel.remotePort}:localhost:${argsObj.port}`,'-C'], {
71
- logName:'tunnel 3'
77
+ logName:'tunnel 3/3'
72
78
  })
73
79
  }
74
80
  })
@@ -97,6 +103,13 @@ function main () {
97
103
  })
98
104
  }
99
105
 
106
+ const test = () => {
107
+
108
+ var argsObj = getCliArgs();
109
+ startSshTunnel(argsObj);
110
+ }
111
+
112
+
100
113
  // start everything
101
- main();
114
+ isDev ? test() : main();
102
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiro-notes",
3
- "version": "0.27.26",
3
+ "version": "0.27.29",
4
4
  "description": "Tiro Notes for CLI",
5
5
  "scripts": {
6
6
  "clean-previous-build": "rm -r node-build",