mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
chore: removing unnecessary console.logs and changing binary location
This commit is contained in:
parent
ab8e543de0
commit
8878725234
5 changed files with 11 additions and 35 deletions
|
|
@ -7,6 +7,10 @@ Once the library is published in Obsidian Official Community Repository: just he
|
|||
|
||||
Note: Please note that this plugin is in early phase. Basic functionality should work just fine but I do not take any responsibility for potential data loss and damage to your Vault.
|
||||
|
||||
On the first try plugin will download better_sqlite3.node binary to run database locally. This is due to the Obsidian restrictions to bundle everything in the `main.js`. The whole process of generating it is public and you can check it in the GitHub workflows.
|
||||
|
||||
The plugin creates database file in configuration folder `.obsidian` named `sqlseal.db`.
|
||||
|
||||
### Manual Instalation
|
||||
To manually install the package, open [Releases](https://github.com/h-sphere/sql-seal/releases) and download .zip of the last one. Unzip it in your vault under `.obsidian/Plugins/sqlseal`.
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ export class SealFileSync {
|
|||
if (!(file instanceof TFile)) {
|
||||
return
|
||||
}
|
||||
console.log('Modified', file)
|
||||
const frontmatter = await extractFrontmatterFromFile(file)
|
||||
|
||||
if (this.hasNewColumns(frontmatter)) {
|
||||
|
|
@ -55,7 +54,6 @@ export class SealFileSync {
|
|||
if (!(file instanceof TFile)) {
|
||||
return
|
||||
}
|
||||
console.log('File created', file.path)
|
||||
const frontmatter = await extractFrontmatterFromFile(file)
|
||||
|
||||
|
||||
|
|
@ -82,7 +80,6 @@ export class SealFileSync {
|
|||
return
|
||||
}
|
||||
|
||||
console.log('File deleted', file.path)
|
||||
await this.sqlSeal.db.deleteData('files', [{ id: file.path }])
|
||||
this.sqlSeal.observer.fireObservers('table:files')
|
||||
|
||||
|
|
@ -95,7 +92,6 @@ export class SealFileSync {
|
|||
return
|
||||
}
|
||||
|
||||
console.log('File renamed', file.path)
|
||||
// deleting old one and adding new one
|
||||
await this.sqlSeal.db.deleteData('files', [{ id: oldPath }])
|
||||
|
||||
|
|
@ -127,11 +123,6 @@ export class SealFileSync {
|
|||
}
|
||||
|
||||
async getFileTags(file: TFile) {
|
||||
|
||||
// Get fresh tag
|
||||
console.log('FILE', file)
|
||||
|
||||
|
||||
return (this.app.metadataCache.getFileCache(file)?.tags || [])
|
||||
.map(t => t.tag)
|
||||
.map(t => ({ tag: t, fileId: file.path }))
|
||||
|
|
@ -160,7 +151,6 @@ export class SealFileSync {
|
|||
const currentFields = Object.keys(this.currentSchema)
|
||||
const newFields = Object.keys(newFrontmatter).filter(f => !currentFields.includes(f))
|
||||
|
||||
console.log('current fields', currentFields, Object.keys(newFrontmatter))
|
||||
return newFields.length > 0
|
||||
}
|
||||
}
|
||||
|
|
@ -84,23 +84,17 @@ export class SqlSealDatabase {
|
|||
const dbPath = path.resolve(this.app.vault.adapter.basePath, this.app.vault.configDir, "plugins/sqlseal/better_sqlite3.node")
|
||||
// check if file "better_sqlite3.node" exists in the plugin folder, if not, download it from github release
|
||||
if (!fs.existsSync(dbPath)) {
|
||||
console.log('BETTER SQL DOES NOT EXIST, DOWNLOADING FROM GITHUB RELEASE')
|
||||
const url = 'https://github.com/kulak-at/tag-test/releases/download/0.1/better_sqlite3.node' // my github release url
|
||||
|
||||
// use node native request to fetch data
|
||||
console.log('PATH TO WRITE', dbPath)
|
||||
const url = 'https://github.com/h-sphere/sql-seal/releases/download/0.2.0/better_sqlite3.node' // my github release url
|
||||
|
||||
await fetchBlobData(url, dbPath)
|
||||
}
|
||||
console.log('FETCHED')
|
||||
|
||||
await delay(1000) // Making sure everything is in order: ;
|
||||
await delay(500)
|
||||
|
||||
//@ts-ignore
|
||||
const defaultDbPath = path.resolve(this.app.vault.adapter.basePath, this.app.vault.configDir, "obsidian.db")
|
||||
const defaultDbPath = path.resolve(this.app.vault.adapter.basePath, this.app.vault.configDir, "sqlseal.db")
|
||||
this.db = new Database(defaultDbPath, { verbose: this.verbose ? console.log : undefined })
|
||||
|
||||
console.log('Connected to database', this.db)
|
||||
this.isConnected = true
|
||||
this.connectingPromiseResolve()
|
||||
}
|
||||
|
|
@ -143,7 +137,7 @@ export class SqlSealDatabase {
|
|||
try {
|
||||
update.run(data)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -159,7 +153,7 @@ export class SqlSealDatabase {
|
|||
try {
|
||||
deleteStmt.run(data)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -181,7 +175,7 @@ export class SqlSealDatabase {
|
|||
})
|
||||
insert.run(data)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -230,7 +224,7 @@ export class SqlSealDatabase {
|
|||
try {
|
||||
insert.run(data)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -241,7 +235,6 @@ export class SqlSealDatabase {
|
|||
async defineDatabaseFromUrl(unprefixedName: string, url: string, prefix: string, reloadData: boolean = false) {
|
||||
const name = prefixedIfNotGlobal(unprefixedName, [], prefix) // FIXME: should we pass global tables here too?
|
||||
if (this.savedDatabases[name]) {
|
||||
console.log('Database Exists', name)
|
||||
if (reloadData) {
|
||||
await this.loadDataForDatabaseFromUrl(name, url)
|
||||
}
|
||||
|
|
@ -249,7 +242,6 @@ export class SqlSealDatabase {
|
|||
}
|
||||
const file = this.app.vault.getFileByPath(url)
|
||||
if (!file) {
|
||||
console.log('File not found')
|
||||
return name
|
||||
}
|
||||
const data = await this.app.vault.cachedRead(file)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ export class SqlSeal {
|
|||
private observeAllFileChanges() {
|
||||
// Use fs to observe file changes
|
||||
this.app.vault.on('modify', async (file) => {
|
||||
console.log('Firing observers for file:', file.path)
|
||||
this.observer.fireObservers('file:' + file.path)
|
||||
})
|
||||
}
|
||||
|
|
@ -67,7 +66,6 @@ export class SqlSeal {
|
|||
const url = match[2];
|
||||
const prefixedName = await this.db.defineDatabaseFromUrl(name, url, prefix)
|
||||
this.observer.registerObserver(`file:${url}`, async () => {
|
||||
console.log('File was changes and we need to update related table: ', name)
|
||||
// Update table
|
||||
await this.db.defineDatabaseFromUrl(name, url, prefix, true)
|
||||
|
||||
|
|
@ -94,11 +92,6 @@ export class SqlSeal {
|
|||
// Register observer for each table
|
||||
tables.forEach(table => {
|
||||
const observer = async () => {
|
||||
console.log('Table was changes and we need to update related select: ', table)
|
||||
|
||||
// FIXME: check if element is still in the DOM.
|
||||
console.log(el, el.isShown(), el.isConnected)
|
||||
|
||||
if (!el.isConnected) {
|
||||
// Unregistering using the context id
|
||||
this.observer.unregisterObserversByTag(ctx.docId)
|
||||
|
|
@ -120,7 +113,6 @@ export class SqlSeal {
|
|||
displayInfo(el, 'Cannot access frontmatter properties in Live Preview Mode. Switch to Reading Mode to see the results.')
|
||||
} else {
|
||||
displayError(el, e)
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export const fetchBlobData = async (url: string, filePath: string) => {
|
|||
if (statusCode === 301 || statusCode === 302) {
|
||||
// Handle redirect
|
||||
const redirectUrl = response.headers.location;
|
||||
console.log(`Redirected to: ${redirectUrl}`);
|
||||
if (!redirectUrl) {
|
||||
reject('Redirect URL not found')
|
||||
return;
|
||||
|
|
@ -36,7 +35,6 @@ export const fetchBlobData = async (url: string, filePath: string) => {
|
|||
response.pipe(fileStream);
|
||||
|
||||
fileStream.on('finish', () => {
|
||||
console.log(`Blob data saved to ${filePath}`);
|
||||
resolve()
|
||||
fileStream.close()
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue