mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
API migration to remove deprecated calls
This commit is contained in:
parent
d343ff0d23
commit
eaab82551f
48
db/migrations/0213__migrate_scripts.js
Normal file
48
db/migrations/0213__migrate_scripts.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
module.exports = () => {
|
||||||
|
const beccaLoader = require("../../src/becca/becca_loader");
|
||||||
|
const becca = require("../../src/becca/becca");
|
||||||
|
const cls = require("../../src/services/cls");
|
||||||
|
const log = require("../../src/services/log");
|
||||||
|
|
||||||
|
cls.init(() => {
|
||||||
|
beccaLoader.load();
|
||||||
|
|
||||||
|
for (const note of Object.values(becca.notes)) {
|
||||||
|
try {
|
||||||
|
if (!note.isJavaScript()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!note.mime?.endsWith('env=frontend') && !note.mime?.endsWith('env=backend')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const origContent = note.getContent().toString();
|
||||||
|
const fixedContent = origContent
|
||||||
|
.replaceAll("runOnServer", "runOnBackend")
|
||||||
|
.replaceAll("api.refreshTree()", "")
|
||||||
|
.replaceAll("addTextToActiveTabEditor", "addTextToActiveContextEditor")
|
||||||
|
.replaceAll("getActiveTabNote", "getActiveContextNote")
|
||||||
|
.replaceAll("getActiveTabTextEditor", "getActiveContextTextEditor")
|
||||||
|
.replaceAll("getActiveTabNotePath", "getActiveContextNotePath")
|
||||||
|
.replaceAll("getDateNote", "getDayNote")
|
||||||
|
.replaceAll("utils.unescapeHtml", "unescapeHtml")
|
||||||
|
.replaceAll("sortNotesByTitle", "sortNotes")
|
||||||
|
.replaceAll("CollapsibleWidget", "RightPanelWidget")
|
||||||
|
.replaceAll("TabAwareWidget", "NoteContextAwareWidget")
|
||||||
|
.replaceAll("TabCachingWidget", "NoteContextAwareWidget")
|
||||||
|
.replaceAll("NoteContextCachingWidget", "NoteContextAwareWidget");
|
||||||
|
|
||||||
|
if (origContent !== fixedContent) {
|
||||||
|
log.info(`Replacing legacy API calls for note '${note.noteId}'`);
|
||||||
|
|
||||||
|
note.saveNoteRevision();
|
||||||
|
note.setContent(fixedContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
log.error(`Error during migration to 213 for note '${note.noteId}': ${e.message} ${e.stack}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
@ -4,7 +4,7 @@ const build = require('./build');
|
|||||||
const packageJson = require('../../package');
|
const packageJson = require('../../package');
|
||||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||||
|
|
||||||
const APP_DB_VERSION = 212;
|
const APP_DB_VERSION = 213;
|
||||||
const SYNC_VERSION = 29;
|
const SYNC_VERSION = 29;
|
||||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user