From 41f994193c438342f1e6830a8711e096cb40e234 Mon Sep 17 00:00:00 2001 From: CK <69121180+TfTHacker@users.noreply.github.com> Date: Fri, 19 Nov 2021 07:34:05 +0100 Subject: [PATCH] 0.5.9 Themes release --- manifest-beta.json | 2 +- manifest.json | 2 +- src/features/BetaPlugins.ts | 42 ++++++++++++++++++------------------- src/features/themes.ts | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/manifest-beta.json b/manifest-beta.json index f2f8acd..fc73ce5 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian42-brat", "name": "Obsidian42 - BRAT", - "version": "0.5.8", + "version": "0.5.9", "minAppVersion": "0.9.12", "description": "Easily install a beta version of a plugin for testing.", "author": "TfTHacker", diff --git a/manifest.json b/manifest.json index ced7b76..fc73ce5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian42-brat", "name": "Obsidian42 - BRAT", - "version": "0.5.6", + "version": "0.5.9", "minAppVersion": "0.9.12", "description": "Easily install a beta version of a plugin for testing.", "author": "TfTHacker", diff --git a/src/features/BetaPlugins.ts b/src/features/BetaPlugins.ts index be890d4..84ba333 100644 --- a/src/features/BetaPlugins.ts +++ b/src/features/BetaPlugins.ts @@ -115,28 +115,28 @@ export default class BetaPlugins { const noticeTimeout = 10000; let primaryManifest = await this.validateRepository(repositoryPath, true, false); // attempt to get manifest-beta.json const usingBetaManifest: boolean = primaryManifest ? true : false; - if(usingBetaManifest===false) + if (usingBetaManifest === false) primaryManifest = await this.validateRepository(repositoryPath, false, true); // attempt to get manifest.json - if(primaryManifest===null) { + if (primaryManifest === null) { const msg = `${repositoryPath}\nA manifest.json or manifest-beta.json file does not exist in the root directory of the repository. This plugin cannot be installed.`; this.plugin.log(msg, true); new Notice(`BRAT\n${msg}`, noticeTimeout); return false; } - - if(!primaryManifest.hasOwnProperty('version')) { + + if (!primaryManifest.hasOwnProperty('version')) { const msg = `${repositoryPath}\nThe manifest${usingBetaManifest ? "-beta" : ""}.json file in the root directory of the repository does not have a version number in the file. This plugin cannot be installed.`; this.plugin.log(msg, true); new Notice(`BRAT\n${msg}`, noticeTimeout); return false; } - const getRelease = async ()=>{ + const getRelease = async () => { const rFiles = await this.getAllReleaseFiles(repositoryPath, primaryManifest, usingBetaManifest); - if(usingBetaManifest || rFiles.manifest === null) //if beta, use that manifest, or if there is no manifest in release, use the primaryManifest + if (usingBetaManifest || rFiles.manifest === null) //if beta, use that manifest, or if there is no manifest in release, use the primaryManifest rFiles.manifest = JSON.stringify(primaryManifest); - + if (rFiles.mainJs === null) { const msg = `${repositoryPath}\nThe release is not complete and cannot be download. main.js is missing from the Release`; this.plugin.log(msg, true); @@ -148,7 +148,7 @@ export default class BetaPlugins { if (updatePluginFiles === false) { const releaseFiles = await getRelease(); - if (releaseFiles===null) return; + if (releaseFiles === null) return; await this.writeReleaseFilesToPluginFolder(primaryManifest.id, releaseFiles); await addBetaPluginToList(this.plugin, repositoryPath); //@ts-ignore @@ -173,25 +173,25 @@ export default class BetaPlugins { const localManifestJSON = await JSON.parse(localManifestContents); if (localManifestJSON.version !== primaryManifest.version) { //manifest files are not the same, do an update const releaseFiles = await getRelease(); - if (releaseFiles===null) return; + if (releaseFiles === null) return; if (seeIfUpdatedOnly) { // dont update, just report it const msg = `There is an update available for ${primaryManifest.id} from version ${localManifestJSON.version} to ${primaryManifest.version}. `; - this.plugin.log(msg + `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, false); - const newNotice: Notice = new Notice(`BRAT\n${msg}\n(Click for info)`,30000); + this.plugin.log(msg + `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, false); + const newNotice: Notice = new Notice(`BRAT\n${msg}\n(Click for info)`, 30000); //@ts-ignore - newNotice.noticeEl.onclick = async () => { window.open(`https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version}`) }; + newNotice.noticeEl.oncontextmenu = async () => { window.open(`https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version}`) }; } else { await this.writeReleaseFilesToPluginFolder(primaryManifest.id, releaseFiles); //@ts-ignore await this.plugin.app.plugins.loadManifests(); //@ts-ignore - if(this.plugin.app.plugins.plugins[primaryManifest.id]?.manifest) await this.reloadPlugin(primaryManifest.id); //reload if enabled + if (this.plugin.app.plugins.plugins[primaryManifest.id]?.manifest) await this.reloadPlugin(primaryManifest.id); //reload if enabled const msg = `${primaryManifest.id}\nPlugin has been updated from version ${localManifestJSON.version} to ${primaryManifest.version}. `; - this.plugin.log(msg + `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, false); - const newNotice: Notice = new Notice(`BRAT\n${msg}\n(Click for info)`,30000); + this.plugin.log(msg + `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, false); + const newNotice: Notice = new Notice(`BRAT\n${msg}\n(Click for info)`, 30000); //@ts-ignore - newNotice.noticeEl.onclick = async () => { window.open(`https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version}`) }; + newNotice.noticeEl.oncontextmenu = async (e) => { window.open(`https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version}`) }; } } else if (reportIfNotUpdted) new Notice(`BRAT\nNo update available for ${repositoryPath}`, 3000); @@ -274,14 +274,14 @@ export default class BetaPlugins { * * @return {PluginManifest[]} manifests of plugins */ - getEnabledDisabledPlugins( enabled: boolean): PluginManifest[] { + getEnabledDisabledPlugins(enabled: boolean): PluginManifest[] { // @ts-ignore const pl = this.plugin.app.plugins; const manifests: PluginManifest[] = Object.values(pl.manifests); // @ts-ignore - const enabledPlugins: PluginManifest[] = Object.values(pl.plugins).map(p=>p.manifest); - return enabled ? - manifests.filter(manifest => enabledPlugins.find(pluginName=> manifest.id===pluginName.id)) : - manifests.filter(manifest => !enabledPlugins.find(pluginName=> manifest.id===pluginName.id)); + const enabledPlugins: PluginManifest[] = Object.values(pl.plugins).map(p => p.manifest); + return enabled ? + manifests.filter(manifest => enabledPlugins.find(pluginName => manifest.id === pluginName.id)) : + manifests.filter(manifest => !enabledPlugins.find(pluginName => manifest.id === pluginName.id)); } } \ No newline at end of file diff --git a/src/features/themes.ts b/src/features/themes.ts index b0fb6b2..442e6e8 100644 --- a/src/features/themes.ts +++ b/src/features/themes.ts @@ -37,7 +37,7 @@ export const themeInstallTheme = async (plugin: ThePlugin, cssGithubRepository: plugin.log(msg + `[Theme Info](https://github.com/${cssGithubRepository})`, false); const newNotice: Notice = new Notice(`BRAT\n${msg}\n(Click for info)`, 10000); //@ts-ignore - newNotice.noticeEl.onclick = async () => { window.open(`https://github.com/${cssGithubRepository}`) }; + newNotice.noticeEl.oncontextmenu = async () => { window.open(`https://github.com/${cssGithubRepository}`) }; setTimeout(() => { // @ts-ignore plugin.app.customCss.setTheme(cssFileName);