cloudron 5.14.1 → 5.14.2
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/package.json +1 -1
- package/src/actions.js +5 -13
- package/src/line-stream.js +0 -30
package/package.json
CHANGED
package/src/actions.js
CHANGED
|
@@ -7,7 +7,6 @@ const assert = require('assert'),
|
|
|
7
7
|
{ EventSource } = require('eventsource'),
|
|
8
8
|
fs = require('fs'),
|
|
9
9
|
https = require('https'),
|
|
10
|
-
LineStream = require('./line-stream.js'),
|
|
11
10
|
manifestFormat = require('cloudron-manifestformat'),
|
|
12
11
|
os = require('os'),
|
|
13
12
|
path = require('path'),
|
|
@@ -966,19 +965,12 @@ async function logs(localOptions, cmd) {
|
|
|
966
965
|
} else {
|
|
967
966
|
const url = `${apiPath}?access_token=${token}&lines=${lines}&format=json`;
|
|
968
967
|
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
if (response.status !== 200) return exit(`Failed to get logs: ${requestError(response)}`);
|
|
972
|
-
});
|
|
973
|
-
req.on('error', (error) => exit(`Pipe error: ${error.message}`));
|
|
974
|
-
|
|
975
|
-
const lineStream = new LineStream();
|
|
976
|
-
lineStream
|
|
977
|
-
.on('line', (line) => { logPrinter(JSON.parse(line)); } )
|
|
978
|
-
.on('error', (error) => exit(`JSON parse error: ${error.message}`))
|
|
979
|
-
.on('end', process.exit);
|
|
968
|
+
const response = await superagent.get(url, { rejectUnauthorized }).ok(() => true);
|
|
969
|
+
if (response.status !== 200) return exit(`Failed to get logs: ${requestError(response)}`);
|
|
980
970
|
|
|
981
|
-
|
|
971
|
+
for (const line of response.body.toString('utf8').trim().split('\n')) {
|
|
972
|
+
logPrinter(JSON.parse(line));
|
|
973
|
+
}
|
|
982
974
|
}
|
|
983
975
|
}
|
|
984
976
|
|
package/src/line-stream.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { Transform } = require('stream');
|
|
4
|
-
|
|
5
|
-
class LineStream extends Transform {
|
|
6
|
-
constructor(options) {
|
|
7
|
-
super();
|
|
8
|
-
this._buffer = '';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
_transform(chunk, encoding, callback) {
|
|
12
|
-
this._buffer += chunk.toString('utf8');
|
|
13
|
-
|
|
14
|
-
const lines = this._buffer.split('\n');
|
|
15
|
-
this._buffer = lines.pop(); // maybe incomplete line
|
|
16
|
-
|
|
17
|
-
for (const line of lines) {
|
|
18
|
-
this.emit('line', line);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
callback();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_flush(callback) {
|
|
25
|
-
if (this._buffer) this.emit('line', this.buff_bufferer);
|
|
26
|
-
callback();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
exports = module.exports = LineStream;
|