tiro-notes 0.27.28 → 0.27.32
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 +61 -16
- package/package.json +2 -2
- package/server/server.js +1 -1
- package/shared.helpers.build.js +2 -2
package/cli.js
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const isDev = false
|
|
2
|
+
|
|
3
|
+
// const isDev = false
|
|
4
|
+
const isDev = process.env.ISDEV
|
|
4
5
|
|
|
5
6
|
const tHelpers = isDev ? require('../shared.helpers.js') : require(`./shared.helpers.build.js`);
|
|
6
7
|
|
|
8
|
+
|
|
9
|
+
// CLI HELP MANUAL
|
|
10
|
+
const outputHelp = () => {
|
|
11
|
+
var p = require('./package.json');
|
|
12
|
+
const tiroHelpString = `
|
|
13
|
+
VERSION:
|
|
14
|
+
===
|
|
15
|
+
${p.name.toUpperCase()} v.${p.version} ${isDev ? '(**dev**)' : ''}
|
|
16
|
+
|
|
17
|
+
DESCRIPTION:
|
|
18
|
+
===
|
|
19
|
+
${p.description}
|
|
20
|
+
|
|
21
|
+
ARGS:
|
|
22
|
+
====
|
|
23
|
+
|
|
24
|
+
--https/-s : enable https ssl with self signed certificate (boolean, false by default)
|
|
25
|
+
--port/-p : port to use (number, 3023 by default)
|
|
26
|
+
--tunnel/-t : uses autossh to "publish" the app on the web, requires a server you can access with ssh and autossh installed on that device. (ex:npx tiro-notes@latest -t REMOTE_USER@REMOTE_URL:REMOTE_PORT)
|
|
27
|
+
--help/-h : help
|
|
28
|
+
|
|
29
|
+
EXAMPLES:
|
|
30
|
+
====
|
|
31
|
+
- npx tiro-notes
|
|
32
|
+
- npx tiro-notes --tunnel ubuntu@myserver.com:3023 --port 3033 --https true
|
|
33
|
+
- npx tiro-notes -t ubuntu@myserver.com:3023 -p 3033 -s true
|
|
34
|
+
`;
|
|
35
|
+
console.log(tiroHelpString);
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
7
39
|
// open frontend on default browser
|
|
8
40
|
const openInBrowser = (url) => {
|
|
9
41
|
var start = (process.platform == 'darwin'? 'open': process.platform == 'win32'? 'start': 'xdg-open');
|
|
@@ -15,17 +47,20 @@ function getCliArgs () {
|
|
|
15
47
|
var args = process.argv;
|
|
16
48
|
var argsObj = {
|
|
17
49
|
port: 3023,
|
|
50
|
+
https: false,
|
|
51
|
+
help: false,
|
|
18
52
|
tunnel: {
|
|
19
53
|
enabled: false,
|
|
20
54
|
},
|
|
21
55
|
}
|
|
22
56
|
for (var i = 0; i < args.length; i++) {
|
|
23
57
|
if (i % 2 !== 0) continue
|
|
24
|
-
console.log(i);
|
|
25
58
|
var argName = args[i];
|
|
26
59
|
var argVal = args[i+1];
|
|
27
60
|
argName = argName.replace('--', '').replace('-','')
|
|
28
61
|
if (argName === 'p' || argName === 'port') argsObj.port = parseInt(argVal);
|
|
62
|
+
if (argName === 's' || argName === 'https') argsObj.https = true
|
|
63
|
+
if (argName === 'h' || argName === 'help') argsObj.help = true
|
|
29
64
|
if (argName === 't' || argName === 'tunnel') {
|
|
30
65
|
const argsArr = argVal.split(':')
|
|
31
66
|
if (argsArr.length > 1) {
|
|
@@ -43,7 +78,10 @@ function startTiroServer (argsObj, cb) {
|
|
|
43
78
|
|
|
44
79
|
// start tiro server, detect success message and get server params
|
|
45
80
|
tHelpers.execCmd('node', [`${__dirname}/server/server.js`], {
|
|
46
|
-
env: {
|
|
81
|
+
env: {
|
|
82
|
+
TIRO_PORT: argsObj.port,
|
|
83
|
+
TIRO_HTTPS: argsObj.https
|
|
84
|
+
},
|
|
47
85
|
logName: 'tiroServer',
|
|
48
86
|
onLog: str => {
|
|
49
87
|
tHelpers.checkAndGetTiroConfig(str, {platform: 'cli', cb})
|
|
@@ -83,28 +121,35 @@ function main () {
|
|
|
83
121
|
|
|
84
122
|
var argsObj = getCliArgs();
|
|
85
123
|
|
|
86
|
-
|
|
124
|
+
if (argsObj.help) {
|
|
87
125
|
|
|
88
|
-
|
|
89
|
-
const protocol = c.https ? 'https' : 'http'
|
|
90
|
-
const port = c.port
|
|
126
|
+
outputHelp();
|
|
91
127
|
|
|
92
|
-
|
|
93
|
-
openInBrowser(`${protocol}://localhost:${port}`);
|
|
128
|
+
} else {
|
|
94
129
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
130
|
+
startTiroServer(argsObj, (configServerObj) => {
|
|
131
|
+
|
|
132
|
+
const c = configServerObj
|
|
133
|
+
const protocol = c.https ? 'https' : 'http'
|
|
134
|
+
const port = c.port
|
|
135
|
+
|
|
136
|
+
// open in browser
|
|
137
|
+
openInBrowser(`${protocol}://localhost:${port}`);
|
|
138
|
+
|
|
139
|
+
// start tunnel with autossh if asked
|
|
140
|
+
startSshTunnel(argsObj);
|
|
141
|
+
|
|
142
|
+
})
|
|
143
|
+
}
|
|
99
144
|
}
|
|
100
145
|
|
|
101
146
|
const test = () => {
|
|
102
|
-
|
|
103
147
|
var argsObj = getCliArgs();
|
|
104
148
|
startSshTunnel(argsObj);
|
|
105
149
|
}
|
|
106
150
|
|
|
107
151
|
|
|
108
152
|
// start everything
|
|
109
|
-
isDev ? test() : main();
|
|
153
|
+
// isDev ? test() : main();
|
|
154
|
+
isDev ? main() : main();
|
|
110
155
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiro-notes",
|
|
3
|
-
"version": "0.27.
|
|
4
|
-
"description": "Tiro Notes
|
|
3
|
+
"version": "0.27.32",
|
|
4
|
+
"description": "Tiro Notes CLI to start Tiro Notes from the command line!",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean-previous-build": "rm -r node-build",
|
|
7
7
|
"export-cli-module": "cp -r ../../build node-build; cp cli.js node-build/; cp package.json node-build/; ",
|