diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c0fad4..3275b82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 0.8.2 + +### New + +- A new setting controls if a beta plugin is auto-enabled after installation. This means after it is installed, it will be enabled in settings. This reduces the additional step of manually enabling a plugin after installation. This setting is now enabled by default. +- chore: update all dependencies. + # 0.8.1 ### New diff --git a/manifest.json b/manifest.json index 88a6e5b..5d14fb9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian42-brat", "name": "BRAT", - "version": "0.8.1", + "version": "0.8.2", "minAppVersion": "1.4.16", "description": "Easily install a beta version of a plugin for testing.", "author": "TfTHacker", diff --git a/package.json b/package.json index ca92c68..8ddf588 100644 --- a/package.json +++ b/package.json @@ -21,28 +21,28 @@ "devDependencies": { "typescript": "5.3.3", "tslib": "^2.6.2", - "@types/node": "^20.10.4", - "@typescript-eslint/eslint-plugin": "^6.13.2", - "@typescript-eslint/parser": "^6.13.2", - "@typescript-eslint/utils": "^6.13.2", + "@types/node": "^20.10.5", + "@typescript-eslint/eslint-plugin": "^6.15.0", + "@typescript-eslint/parser": "^6.15.0", + "@typescript-eslint/utils": "^6.15.0", "builtin-modules": "3.3.0", - "esbuild": "0.19.9", - "eslint": "^8.55.0", - "eslint-config-prettier": "^9.0.0", + "esbuild": "0.19.10", + "eslint": "^8.56.0", + "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-css": "^0.8.1", "eslint-plugin-eslint-comments": "^3.2.0", - "eslint-plugin-import": "^2.29.0", - "eslint-plugin-jsonc": "^2.10.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-jsonc": "^2.11.2", "eslint-plugin-mdx": "^3.0.0", "eslint-plugin-only-warn": "^1.1.0", - "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-prettier": "^5.1.0", "eslint-plugin-tsdoc": "^0.2.17", - "eslint-plugin-yml": "^1.10.0", + "eslint-plugin-yml": "^1.11.0", "@html-eslint/eslint-plugin": "^0.22.0", "@html-eslint/parser": "^0.22.0", "husky": "^8.0.3", - "jsdom": "^23.0.0", + "jsdom": "^23.0.1", "lint-staged": "^15.2.0", "prettier": "^3.1.1", "remark-preset-lint-consistent": "^5.1.2", @@ -50,7 +50,7 @@ "remark-preset-lint-recommended": "^6.1.3", "remark-preset-prettier": "^2.0.1", "ts-node": "^10.9.2", - "typedoc": "^0.25.3", + "typedoc": "^0.25.4", "@types/obsidian-typings": "github:Fevol/obsidian-typings", "obsidian": "1.4.11" }, diff --git a/src/features/BetaPlugins.ts b/src/features/BetaPlugins.ts index 6d3bf2a..7de5c33 100644 --- a/src/features/BetaPlugins.ts +++ b/src/features/BetaPlugins.ts @@ -138,7 +138,7 @@ export default class BetaPlugins { 'manifest.json', this.plugin.settings.debuggingMode ) - : '', + : '', styles: await grabReleaseFileFromRepository( repositoryPath, version, @@ -223,15 +223,16 @@ export default class BetaPlugins { 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.`; await this.plugin.log(msg, true); - toastMessage(this.plugin, `${msg}`, noticeTimeout); + toastMessage(this.plugin, msg, noticeTimeout); return false; } if (!Object.hasOwn(primaryManifest, '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.`; + 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.`; await this.plugin.log(msg, true); - toastMessage(this.plugin, `${msg}`, noticeTimeout); + toastMessage(this.plugin, msg, noticeTimeout); return false; } @@ -240,13 +241,14 @@ export default class BetaPlugins { if (!requireApiVersion(primaryManifest.minAppVersion)) { const msg = `Plugin: ${repositoryPath}\n\n` + - `The manifest${usingBetaManifest ? '-beta' : '' + `The manifest${ + usingBetaManifest ? '-beta' : '' }.json for this plugin indicates that the Obsidian ` + `version of the app needs to be ${primaryManifest.minAppVersion}, ` + `but this installation of Obsidian is ${apiVersion}. \n\nYou will need to update your ` + `Obsidian to use this plugin or contact the plugin developer for more information.`; await this.plugin.log(msg, true); - toastMessage(this.plugin, `${msg}`, 30); + toastMessage(this.plugin, msg, 30); return false; } } @@ -273,7 +275,7 @@ export default class BetaPlugins { if (rFiles.mainJs === null) { const msg = `${repositoryPath}\nThe release is not complete and cannot be download. main.js is missing from the Release`; await this.plugin.log(msg, true); - toastMessage(this.plugin, `${msg}`, noticeTimeout); + toastMessage(this.plugin, msg, noticeTimeout); return null; } return rFiles; @@ -287,7 +289,9 @@ export default class BetaPlugins { addBetaPluginToList(this.plugin, repositoryPath, specifyVersion); if (enableAfterInstall) { const { plugins } = this.plugin.app; - const pluginTargetFolderPath = normalizePath(plugins.getPluginFolder() + '/' + primaryManifest.id); + const pluginTargetFolderPath = normalizePath( + plugins.getPluginFolder() + '/' + primaryManifest.id + ); await plugins.loadManifest(pluginTargetFolderPath); await plugins.enablePlugin(primaryManifest.id); } @@ -305,7 +309,7 @@ export default class BetaPlugins { const versionText = specifyVersion === '' ? '' : ` (version: ${specifyVersion})`; let msg = `${repositoryPath}${versionText}\nThe plugin has been registered with BRAT.`; if (!enableAfterInstall) { - msg += " You may still need to enable it the Community Plugin List."; + msg += ' You may still need to enable it the Community Plugin List.'; } await this.plugin.log(msg, true); toastMessage(this.plugin, msg, noticeTimeout); @@ -368,7 +372,7 @@ export default class BetaPlugins { const msg = `There is an update available for ${primaryManifest.id} from version ${localManifestJson.version} to ${primaryManifest.version}. `; await this.plugin.log( msg + - `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, + `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, true ); toastMessage(this.plugin, msg, 30, () => { @@ -385,7 +389,7 @@ export default class BetaPlugins { const msg = `${primaryManifest.id}\nPlugin has been updated from version ${localManifestJson.version} to ${primaryManifest.version}. `; await this.plugin.log( msg + - `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, + `[Release Info](https://github.com/${repositoryPath}/releases/tag/${primaryManifest.version})`, true ); toastMessage(this.plugin, msg, 30, () => { @@ -516,12 +520,12 @@ export default class BetaPlugins { (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) + ) : manifests.filter( - (manifest) => - !enabledPlugins.find((pluginName) => manifest.id === pluginName.id) - ); + (manifest) => + !enabledPlugins.find((pluginName) => manifest.id === pluginName.id) + ); } } diff --git a/src/features/themes.ts b/src/features/themes.ts index a4b0067..7915c51 100644 --- a/src/features/themes.ts +++ b/src/features/themes.ts @@ -92,7 +92,7 @@ export const themeSave = async ( } void plugin.log(msg + `[Theme Info](https://github.com/${cssGithubRepository})`, false); - toastMessage(plugin, `${msg}`, 20, (): void => { + toastMessage(plugin, msg, 20, (): void => { window.open(`https://github.com/${cssGithubRepository}`); }); return true; @@ -159,7 +159,7 @@ export const themeDelete = (plugin: ThePlugin, cssGithubRepository: string): voi void plugin.saveSettings(); const msg = `Removed ${cssGithubRepository} from BRAT themes list and will no longer be updated. However, the theme files still exist in the vault. To remove them, go into Settings > Appearance and remove the theme.`; void plugin.log(msg, true); - toastMessage(plugin, `${msg}`); + toastMessage(plugin, msg); }; /** diff --git a/src/ui/AddNewPluginModal.ts b/src/ui/AddNewPluginModal.ts index 2ed361a..36adb92 100644 --- a/src/ui/AddNewPluginModal.ts +++ b/src/ui/AddNewPluginModal.ts @@ -50,7 +50,9 @@ export default class AddNewPluginModal extends Modal { false, false, false, - this.version + this.version, + false, + this.enableAfterInstall ); if (result) { this.close(); @@ -94,19 +96,23 @@ export default class AddNewPluginModal extends Modal { } formEl.createDiv('modal-button-container', (buttonContainerEl) => { - buttonContainerEl.createEl("label", { - cls: "mod-checkbox" - }, (labelEl) => { - const checkboxEl = labelEl.createEl("input", { - attr: { tabindex: -1 }, - type: "checkbox" - }); - checkboxEl.checked = this.enableAfterInstall; - checkboxEl.addEventListener("click", () => { - this.enableAfterInstall = checkboxEl.checked; - }); - labelEl.appendText('Enable after installing the plugin'); - }); + buttonContainerEl.createEl( + 'label', + { + cls: 'mod-checkbox', + }, + (labelEl) => { + const checkboxEl = labelEl.createEl('input', { + attr: { tabindex: -1 }, + type: 'checkbox', + }); + checkboxEl.checked = this.enableAfterInstall; + checkboxEl.addEventListener('click', () => { + this.enableAfterInstall = checkboxEl.checked; + }); + labelEl.appendText('Enable after installing the plugin'); + } + ); buttonContainerEl .createEl('button', { attr: { type: 'button' }, text: 'Never mind' }) diff --git a/src/ui/SettingsTab.ts b/src/ui/SettingsTab.ts index c14a79e..7ddcdcf 100644 --- a/src/ui/SettingsTab.ts +++ b/src/ui/SettingsTab.ts @@ -31,27 +31,27 @@ export class BratSettingsTab extends PluginSettingTab { containerEl.empty(); new Setting(containerEl) - .setName('Auto-update plugins at startup') + .setName('Auto-enable plugins after installation') .setDesc( - 'If enabled all beta plugins will be checked for updates each time Obsidian starts. Note: this does not update frozen version plugins.' + 'If enabled beta plugins will be automatically enabled after installtion by default. Note: you can toggle this on and off for each plugin in the "Add Plugin" form.' ) .addToggle((cb: ToggleComponent) => { - cb.setValue(this.plugin.settings.updateAtStartup); + cb.setValue(this.plugin.settings.enableAfterInstall); cb.onChange(async (value: boolean) => { - this.plugin.settings.updateAtStartup = value; + this.plugin.settings.enableAfterInstall = value; await this.plugin.saveSettings(); }); }); new Setting(containerEl) - .setName('Auto-enable plugins after installation') + .setName('Auto-update plugins at startup') .setDesc( - 'If enabled beta plugins will be automatically enabled after installtion by default. Note: you can toggle this on and off for each plugin in the "Add Plugin" form.' + 'If enabled all beta plugins will be checked for updates each time Obsidian starts. Note: this does not update frozen version plugins.' ) .addToggle((cb: ToggleComponent) => { - cb.setValue(this.plugin.settings.enableAfterInstall); + cb.setValue(this.plugin.settings.updateAtStartup); cb.onChange(async (value: boolean) => { - this.plugin.settings.enableAfterInstall = value; + this.plugin.settings.updateAtStartup = value; await this.plugin.saveSettings(); }); });