-
Notifications
You must be signed in to change notification settings - Fork 3
/
dbg.js
47 lines (41 loc) · 1.17 KB
/
dbg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict'
const { dialog } = require('electron')
const archiver = require('archiver')
const fs = require('fs')
const path = require('path')
const users = require('./users.js')
const loc = require('./loc.js')
function xport(log) {
const t = (new Date()).toISOString()
const n = `troubleshooting-desktop-app-${t.replace(/[/:\\*&^%$#@!()]/g, "_")}.zip`
dialog.showSaveDialog({
title: "Troubleshooting files",
defaultPath: n,
buttonLabel: "Export",
})
.then(f => {
if(!f.filePath) return
const o = fs.createWriteStream(f.filePath)
const zip = archiver('zip')
zip.on("warning", w => console.log(w))
zip.on("error", err => console.error(err))
zip.pipe(o)
const logfile = path.join(loc.db(), log.getName())
zip.file(logfile, { name: log.getName() })
const userinfo = users.info()
zip.append(JSON.stringify(userinfo, null, 2), {
name: "userinfo.json",
})
userinfo.forEach(ui => {
const n = "User-" + ui.id
const userlog = path.join(loc.db(), n)
zip.file(userlog, { name: n })
})
zip.directory(loc.db(), "all")
zip.finalize()
})
.catch(e => console.error(e))
}
module.exports = {
xport,
}