2023-12-20 21:08:07 +02:00
|
|
|
import BaseCommand from './base-command';
|
2017-11-21 20:48:50 +02:00
|
|
|
const { app } = require('./app.js');
|
2023-12-20 21:08:07 +02:00
|
|
|
import Setting from '@joplin/lib/models/Setting';
|
|
|
|
import ReportService from '@joplin/lib/services/ReportService';
|
|
|
|
import * as fs from 'fs-extra';
|
2017-11-21 20:48:50 +02:00
|
|
|
|
|
|
|
class Command extends BaseCommand {
|
2023-12-20 21:08:07 +02:00
|
|
|
public override usage() {
|
2017-11-21 20:48:50 +02:00
|
|
|
return 'export-sync-status';
|
|
|
|
}
|
|
|
|
|
2023-12-20 21:08:07 +02:00
|
|
|
public override description() {
|
2017-11-21 20:48:50 +02:00
|
|
|
return 'Export sync status';
|
|
|
|
}
|
|
|
|
|
2023-12-20 21:08:07 +02:00
|
|
|
public override hidden() {
|
2017-11-21 20:48:50 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-12-20 21:08:07 +02:00
|
|
|
public override async action() {
|
2017-11-21 20:48:50 +02:00
|
|
|
const service = new ReportService();
|
2023-12-20 21:08:07 +02:00
|
|
|
const csv = await service.basicItemList({ format: 'csv' }) as string;
|
2019-09-19 23:51:18 +02:00
|
|
|
const filePath = `${Setting.value('profileDir')}/syncReport-${new Date().getTime()}.csv`;
|
2017-11-21 20:48:50 +02:00
|
|
|
await fs.writeFileSync(filePath, csv);
|
2019-09-19 23:51:18 +02:00
|
|
|
this.stdout(`Sync status exported to ${filePath}`);
|
2017-11-21 20:48:50 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
app()
|
|
|
|
.gui()
|
|
|
|
.showConsole();
|
|
|
|
app()
|
|
|
|
.gui()
|
|
|
|
.maximizeConsole();
|
2017-11-21 20:48:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
module.exports = Command;
|