diff --git a/manifest.json b/manifest.json index c732936..2036903 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian42-brat", "name": "Obsidian42 - BRAT", - "version": "0.3", + "version": "0.4", "minAppVersion": "0.9.12", "description": "Easily install a beta version of a plugin for testing.", "author": "TfTHacker", diff --git a/package.json b/package.json index 7d4933c..ff4d532 100644 --- a/package.json +++ b/package.json @@ -15,11 +15,11 @@ "url": "git://github.com/TfTHacker/obsidian42-brat.git" }, "devDependencies": { - "@types/node": "^16.9.1", - "@typescript-eslint/eslint-plugin": "^4.31.1", - "@typescript-eslint/parser": "^4.31.1", + "@types/node": "^16.10.3", + "@typescript-eslint/eslint-plugin": "^4.33.0", + "@typescript-eslint/parser": "^4.33.0", "eslint": "^7.32.0", - "obsidian": "^0.12.16", + "obsidian": "^0.12.17", "tslib": "^2.3.1", "typescript": "^4.4.3" }, diff --git a/src/AddNewPluginModal.ts b/src/AddNewPluginModal.ts index 2a698a8..ad5b2b0 100644 --- a/src/AddNewPluginModal.ts +++ b/src/AddNewPluginModal.ts @@ -24,7 +24,7 @@ export default class AddNewPluginModal extends Modal { if (this.address === "") return; const scrubbedAddress = this.address.replace("https://github.com/",""); if (await existBetaPluginInList(this.plugin, scrubbedAddress)) { - new Notice(`BRAT\nThis plugin is already in the list for beta testing`, 20000); + new Notice(`BRAT\nThis plugin is already in the list for beta testing`, 10000); return; } const result = await this.betaPlugins.addPlugin(scrubbedAddress); @@ -76,12 +76,9 @@ export default class AddNewPluginModal extends Modal { } async onClose(): Promise { - console.log('close',this.openSettingsTabAfterwards) if(this.openSettingsTabAfterwards) { - //@ts-ignore - await this.plugin.app.setting.open(); - //@ts-ignore - await this.plugin.app.setting.openTabById("obsidian42-brat"); + await (this.plugin as any).app.setting.open(); + await (this.plugin as any).app.setting.openTabById("obsidian42-brat"); } } diff --git a/src/BetaPlugins.ts b/src/BetaPlugins.ts index 01bde85..0416f02 100644 --- a/src/BetaPlugins.ts +++ b/src/BetaPlugins.ts @@ -44,7 +44,7 @@ export default class BetaPlugins { * @return {Promise} the manifest file if found, or null if its incomplete */ async validateRepository(repositoryPath: string, getBetaManifest = false, reportIsues = false): Promise { - const noticeTimeout = 60000; + const noticeTimeout = 10000; const manifestJson = await grabManifestJsonFromRepository(repositoryPath, !getBetaManifest); if (!manifestJson) { // this is a plugin with a manifest json, try to see if there is a beta version if (reportIsues) new Notice(`BRAT\n${repositoryPath}\nThis does not seem to be an obsidian plugin, as there is no manifest.json file.`, noticeTimeout); @@ -111,24 +111,34 @@ export default class BetaPlugins { */ async addPlugin(repositoryPath: string, updatePluginFiles = false, seeIfUpdatedOnly = false, reportIfNotUpdted = false): Promise { const manifestJson = await this.validateRepository(repositoryPath, false, true); - const noticeTimeout = 60000; + const noticeTimeout = 10000; if (manifestJson === null) return false; const betaManifestJson = await this.validateRepository(repositoryPath, true, false); const primaryManifest: PluginManifest = betaManifestJson ? betaManifestJson : manifestJson; // if there is a beta manifest, use that + if(!primaryManifest.hasOwnProperty('version')) { + new Notice(`BRAT\n${repositoryPath}\nThe manifest file in the root directory of the repository does not have a version number in the file. This plugin cannot be installed.`, noticeTimeout); + return false; + } + const releaseFiles = await this.getAllReleaseFiles(repositoryPath, primaryManifest) - if (releaseFiles.mainJs === "Not Found") { - new Notice(`BRAT\n${repositoryPath}\nThe release is not complete and cannot be download. main.js is missing from the release`, noticeTimeout); + if (releaseFiles.mainJs === null) { + new Notice(`BRAT\n${repositoryPath}\nThe release is not complete and cannot be download. main.js is missing from the Release`, noticeTimeout); return false; } - if (releaseFiles.manifest === "Not Found") { - new Notice(`BRAT\n${repositoryPath}\nThe release is not complete and cannot be download. manifest.json is missing from the release`, noticeTimeout); + if (releaseFiles.manifest === null) { + new Notice(`BRAT\n${repositoryPath}\nThe release is not complete and cannot be download. manifest.json is missing from the Release`, noticeTimeout); return false; } const remoteManifestJSON = JSON.parse(releaseFiles.manifest); + if(!remoteManifestJSON.hasOwnProperty('version')) { + new Notice(`BRAT\n${repositoryPath}\nThe manifest file in the Release does not have a version number in the file. This plugin cannot be installed`, noticeTimeout); + return false; + } + if (updatePluginFiles === false) { await this.writeReleaseFilesToPluginFolder(remoteManifestJSON.id, releaseFiles); await addBetaPluginToList(this.plugin, repositoryPath); @@ -201,7 +211,7 @@ export default class BetaPlugins { * @return {Promise} */ async checkForUpdatesAndInstallUpdates(showInfo = false, onlyCheckDontUpdate = false): Promise { - if (showInfo) new Notice(`BRAT\nChecking for plugin updates STARTED`, 30000); + if (showInfo) new Notice(`BRAT\nChecking for plugin updates STARTED`, 10000); for (const bp of this.plugin.settings.pluginList) { await this.updatePlugin(bp, onlyCheckDontUpdate); } diff --git a/src/githubUtils.ts b/src/githubUtils.ts index fec90a2..5d5e3d1 100644 --- a/src/githubUtils.ts +++ b/src/githubUtils.ts @@ -14,7 +14,7 @@ const GITHUB_RAW_USERCONTENT_PATH = "https://raw.githubusercontent.com/"; export const grabReleaseFileFromRepository = async (repository: string, version: string, fileName: string): Promise => { try { const download = await request({ url: `https://github.com/${repository}/releases/download/${version}/${fileName}` }); - return (download === "Not Found" ? null : download); + return ( ( download === "Not Found" || download === `{"error":"Not Found"}`) ? null : download); } catch (error) { console.log("error in grabReleaseFileFromRepository", error) }