mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-03 08:35:29 +02:00
08af9de190
* Started revisions support * More rev changes * More rev changes * More revs changes * Fixed deletion algorithm * More tests and moved updated time to separate field * Display info when restoring note * Better handling of existing notes * wip * Further improvements and fixed tests * Better handling of changes created via sync * Enable chokidar again * Testing special case * Further improved logic to handle notes that existed before the revision service * Added tests * Better handling of encrypted revisions * Improved handling of deleted note revisions by moving logic to collectRevision * Improved handling of old notes by moving logic to collectRevision() * Handle case when deleting revisions while one is still encrypted * UI tweaks * Added revision service to mobile app * Fixed config screens on mobile and desktop * Enabled revisions on CLI app
84 lines
2.7 KiB
JavaScript
84 lines
2.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Use njstrace to find out what Node.js might be spending time on
|
|
// var njstrace = require('njstrace').inject();
|
|
|
|
// Make it possible to require("/lib/...") without specifying full path
|
|
require('app-module-path').addPath(__dirname);
|
|
|
|
const compareVersion = require('compare-version');
|
|
const nodeVersion = process && process.versions && process.versions.node ? process.versions.node : '0.0.0';
|
|
if (compareVersion(nodeVersion, '8.0.0') < 0) {
|
|
console.error('Joplin requires Node 8+. Detected version ' + nodeVersion);
|
|
process.exit(1);
|
|
}
|
|
|
|
const { app } = require('./app.js');
|
|
const Folder = require('lib/models/Folder.js');
|
|
const Resource = require('lib/models/Resource.js');
|
|
const BaseItem = require('lib/models/BaseItem.js');
|
|
const Note = require('lib/models/Note.js');
|
|
const Tag = require('lib/models/Tag.js');
|
|
const NoteTag = require('lib/models/NoteTag.js');
|
|
const MasterKey = require('lib/models/MasterKey');
|
|
const Setting = require('lib/models/Setting.js');
|
|
const Revision = require('lib/models/Revision.js');
|
|
const { Logger } = require('lib/logger.js');
|
|
const { FsDriverNode } = require('lib/fs-driver-node.js');
|
|
const { shimInit } = require('lib/shim-init-node.js');
|
|
const { _ } = require('lib/locale.js');
|
|
const { FileApiDriverLocal } = require('lib/file-api-driver-local.js');
|
|
const EncryptionService = require('lib/services/EncryptionService');
|
|
|
|
const fsDriver = new FsDriverNode();
|
|
Logger.fsDriver_ = fsDriver;
|
|
Resource.fsDriver_ = fsDriver;
|
|
EncryptionService.fsDriver_ = fsDriver;
|
|
FileApiDriverLocal.fsDriver_ = fsDriver;
|
|
|
|
// That's not good, but it's to avoid circular dependency issues
|
|
// in the BaseItem class.
|
|
BaseItem.loadClass('Note', Note);
|
|
BaseItem.loadClass('Folder', Folder);
|
|
BaseItem.loadClass('Resource', Resource);
|
|
BaseItem.loadClass('Tag', Tag);
|
|
BaseItem.loadClass('NoteTag', NoteTag);
|
|
BaseItem.loadClass('MasterKey', MasterKey);
|
|
BaseItem.loadClass('Revision', Revision);
|
|
|
|
Setting.setConstant('appId', 'net.cozic.joplin-cli');
|
|
Setting.setConstant('appType', 'cli');
|
|
|
|
shimInit();
|
|
|
|
const application = app();
|
|
|
|
if (process.platform === "win32") {
|
|
var rl = require("readline").createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout
|
|
});
|
|
|
|
rl.on("SIGINT", function () {
|
|
process.emit("SIGINT");
|
|
});
|
|
}
|
|
|
|
process.stdout.on('error', function( err ) {
|
|
// https://stackoverflow.com/questions/12329816/error-write-epipe-when-piping-node-output-to-head#15884508
|
|
if (err.code == "EPIPE") {
|
|
process.exit(0);
|
|
}
|
|
});
|
|
|
|
application.start(process.argv).catch((error) => {
|
|
if (error.code == 'flagError') {
|
|
console.error(error.message);
|
|
console.error(_('Type `joplin help` for usage information.'));
|
|
} else {
|
|
console.error(_('Fatal error:'));
|
|
console.error(error);
|
|
}
|
|
|
|
process.exit(1);
|
|
}); |