tiro-notes 0.27.25 → 0.27.28
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 +26 -20
- package/package.json +1 -1
- package/shared.helpers.build.js +5 -4
package/cli.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//const
|
|
3
|
-
const
|
|
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) => {
|
|
@@ -52,31 +54,28 @@ function startTiroServer (argsObj, cb) {
|
|
|
52
54
|
const startSshTunnel = (argsObj) => {
|
|
53
55
|
if (argsObj.tunnel.enabled) {
|
|
54
56
|
// kill previous autossh processes
|
|
55
|
-
let cb1 = true
|
|
56
57
|
let cb2 = true
|
|
58
|
+
let cb1 = true
|
|
57
59
|
tHelpers.execCmd('killall', [`autossh`], {
|
|
58
|
-
logName:'tunnel 1',
|
|
59
|
-
onLog:
|
|
60
|
-
if (!
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
tHelpers.execCmd('autossh', [
|
|
64
|
-
logName:'tunnel 2',
|
|
60
|
+
logName:'tunnel 1/3',
|
|
61
|
+
onLog: () => {
|
|
62
|
+
if (!cb2) return
|
|
63
|
+
cb2 = false
|
|
64
|
+
// check if autossh is working
|
|
65
|
+
tHelpers.execCmd('autossh', [`-V`], {
|
|
66
|
+
logName:'tunnel 2/3',
|
|
65
67
|
onLog: str => {
|
|
66
|
-
if (!
|
|
67
|
-
|
|
68
|
+
if (!cb1) return
|
|
69
|
+
cb1 = false
|
|
70
|
+
// start autossh finally
|
|
68
71
|
tHelpers.execCmd('autossh',['-M','20000','-N', argsObj.tunnel.remoteUrl,'-R', `${argsObj.tunnel.remotePort}:localhost:${argsObj.port}`,'-C'], {
|
|
69
|
-
logName:'tunnel 3'
|
|
72
|
+
logName:'tunnel 3/3'
|
|
70
73
|
})
|
|
71
74
|
}
|
|
72
75
|
})
|
|
73
|
-
|
|
74
76
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// check if autossh is working
|
|
79
|
-
|
|
77
|
+
})
|
|
78
|
+
}
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
// Main script
|
|
@@ -99,6 +98,13 @@ function main () {
|
|
|
99
98
|
})
|
|
100
99
|
}
|
|
101
100
|
|
|
101
|
+
const test = () => {
|
|
102
|
+
|
|
103
|
+
var argsObj = getCliArgs();
|
|
104
|
+
startSshTunnel(argsObj);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
102
108
|
// start everything
|
|
103
|
-
main();
|
|
109
|
+
isDev ? test() : main();
|
|
104
110
|
|
package/package.json
CHANGED
package/shared.helpers.build.js
CHANGED
|
@@ -45,10 +45,10 @@ const execCmd = (cmd, params, p) => {
|
|
|
45
45
|
if (!p) p = {}
|
|
46
46
|
if (!p.env) p.env = {}
|
|
47
47
|
if (!p.platform) p.platform = false
|
|
48
|
-
|
|
48
|
+
p.logName = !p.logName ? '' : `${p.logName} `
|
|
49
49
|
const log = whichLog(p);
|
|
50
50
|
|
|
51
|
-
log(`ExecCMD ${JSON.stringify({cmd, params, p})}`);
|
|
51
|
+
log(`[${p.logName}] === ExecCMD ${JSON.stringify({cmd, params, p})}`);
|
|
52
52
|
|
|
53
53
|
let child
|
|
54
54
|
let spawn = require( 'child_process' ).spawn;
|
|
@@ -62,9 +62,10 @@ const execCmd = (cmd, params, p) => {
|
|
|
62
62
|
});
|
|
63
63
|
child.stderr.on( 'data', data => {
|
|
64
64
|
const str = `[${p.logName} ${cmd} ERROR!] : ${data}`;
|
|
65
|
-
log( str );
|
|
65
|
+
console.log( str );
|
|
66
|
+
if (p && p.onLog) p.onLog(str)
|
|
66
67
|
});
|
|
67
|
-
|
|
68
|
+
if (p && p.onDone) p.onDone()
|
|
68
69
|
return child;
|
|
69
70
|
}
|
|
70
71
|
|