diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a04319..4288ffe 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,26 @@ # Change Log -## 1.0.0 :- +## v1.0.0 -- Enables **Clear Cache** command of **Drush** to used in **Drupal** projects, Only works on **Linux/Mac** OS. +- Added support for the **Clear Cache** command of **Drush** in **Drupal** projects. This feature is available only for **Linux/Mac** OS. -## 1.1.0 :- +## v1.1.0 -- Enables **Clear Cache** command's support for **DDEV** drupal project environment. +- Added support for the **Clear Cache** command in **DDEV** Drupal project environment. - Fixed minor issues and added comments. -- Removed extension from **Preview**. +- Removed extension from the **Preview**. - Updated the **Readme** file. -## 1.2.0 :- +## v1.2.0 -- Now displays more details about site in tooltip. -- Action button will be not visible if **Drush** not found. -- Updated output messages for end users. +- Enhanced tooltip to display more details about the site. +- Added logic to hide the action button if **Drush** is not found. +- Improved output messages for end users. - Fixed minor issues and removed debugging code. - Updated the **Readme** file. + +## v1.3.0 + +- Adds support for **drush v12**. +- Fixes the issues reported in [#1](https://github.com/vinugawade/ur-cache-cleaner/issues/1) by [@elgandoz](https://github.com/elgandoz). +- Refactors the code for better maintainability and readability. diff --git a/README.md b/README.md index 7a7b058..835b081 100755 --- a/README.md +++ b/README.md @@ -8,14 +8,26 @@ ## Features ✨ -**UR Cache Cleaner** is a VS Code extension which helps you to **Clear Cache** of your **Drupal** project with single click of a **Button** without switching to **Admin Panel** or **Terminal**. Only build for **Linux/Mac** OS. +**UR Cache Cleaner** is a powerful VS Code extension designed specifically for drupal projects. It offers the following features: -### Shortcut keys +- **Cache Clearing:** With just a single click of a button, you can easily clear the cache of your drupal project without the need to switch to the admin panel or terminal. -- Mac :- **⇧+⌘+C ⇧+⌘+R** -- Linux :- **Ctrl+Shift+C Ctrl+Shift+R** +- **Efficiency:** UR Cache Cleaner streamlines the cache clearing process, saving you time and effort by eliminating the need to navigate through different panels or tools. -For example if you open **Drupal project**, Then you can see the **Clear Cache** button at the left side of **Status Bar** : +- **User-Friendly Interface:** The extension provides a clean and intuitive interface, making it easy for users to navigate and utilize its features. + +- **Linux/Mac OS Support:** UR Cache Cleaner is specially built to cater to Linux and Mac OS users, ensuring optimal performance on these platforms. + +Experience the convenience and efficiency of **UR Cache Cleaner** in managing cache clearing for your drupal projects. Upgrade your workflow and enhance productivity with this powerful VS Code extension. + +--- + +### Shortcut keys ✨ + +- Mac: **⇧+⌘+C ⇧+⌘+R** +- Linux: **Ctrl+Shift+C Ctrl+Shift+R** + +When you open a Drupal project, you will find the "Clear Cache" button located on the left side of the Status Bar. ![Clear Your Cache](assets/images/feature.gif) @@ -23,15 +35,15 @@ For example if you open **Drupal project**, Then you can see the **Clear Cache** ## Requirements ✨ -- Install [Drush Launcher](https://github.com/drush-ops/drush-launcher) on your system. +To utilize UR Cache Cleaner, please ensure you have installed [Drush Launcher](https://github.com/drush-ops/drush-launcher) on your system. --- ## Known Issues ✨ -- Not build for windows OS. +Please note that UR Cache Cleaner is not currently compatible with Windows OS. We apologize for any inconvenience this may cause. -Feel free to add any issues under our [repository](https://github.com/vinugawade/ur-cache-cleaner/issues). +We encourage you to report any issues you encounter on our [repository](https://github.com/vinugawade/ur-cache-cleaner/issues). Your feedback and contributions are highly appreciated. --- @@ -43,31 +55,39 @@ See [CHANGELOG.md](CHANGELOG.md). ## Release Notes ✨ -### 1.0.0 +### v1.0.0 + +- Introduces the **Clear Cache** command of **Drush** for use in Drupal projects. This feature is currently supported only on **Linux/Mac OS**. -- Enables **Clear Cache** command of **Drush** to used in **Drupal** projects, Only works on **Linux/Mac** OS. +### v1.1.0 -### 1.1.0 +- Adds support for the **Clear Cache** command in **DDEV** Drupal project environments. +- Fixes minor issues and adds comments for improved clarity. -- Enables **Clear Cache** command's support for **DDEV** drupal project environment. -- Fixed minor issues and added comments. +### v1.2.0 -### 1.2.0 +- Enhances the tooltip to display additional site details. +- Addresses minor issues for improved performance. -- Now displays more details about site in tooltip. -- Fixed minor issues. +### v1.3.0 + +- Adds support for **drush v12**. +- Fixes the issues reported in [#1](https://github.com/vinugawade/ur-cache-cleaner/issues/1) by [@elgandoz](https://github.com/elgandoz). +- Refactors the code for better maintainability and readability. --- ## Contributors ✨ -Feel free to contribute in our [repository](https://github.com/vinugawade/ur-cache-cleaner). +We welcome contributions to our [repository](https://github.com/vinugawade/ur-cache-cleaner). Feel free to contribute and help make **UR Cache Cleaner** even better. --- ## Maintainer ✨ -Built with 💛 by [Vinay Gawade](https://github.com/vinugawade). +**UR Cache Cleaner** is built with 💛 by [Vinay Gawade](https://github.com/vinugawade). + +Your support and feedback are valuable in maintaining and improving the extension. logo logo @@ -79,13 +99,12 @@ Built with 💛 by [Vinay Gawade](https://github.com/vinugawade). ## Credits ✨ -- Logo generated by [DesignEvo](https://www.designevo.com) free logo designer. -- Icons added by [glyphter](https://glyphter.com/) free icon font pack. +The logo for **UR Cache Cleaner** was generated using the free logo designer [DesignEvo](https://www.designevo.com), while the icons were provided by [glyphter](https://glyphter.com/), a free icon font pack. --- -## License +## License ✨ -Check [here](LICENSE). +Please refer to the [LICENSE](LICENSE) file for details on the licensing of **UR Cache Cleaner**. ![LICENSE](https://img.shields.io/github/license/vinugawade/ur-cache-cleaner?style=flat-square) diff --git a/package-lock.json b/package-lock.json index e1eb822..7648be7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ur-cache-cleaner", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ur-cache-cleaner", - "version": "1.2.0", + "version": "1.3.0", "license": "GNU General Public License", "dependencies": { "command-exists": "^1.2.9" diff --git a/package.json b/package.json index 39a2828..0aa2165 100755 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "url": "https://github.com/vinugawade/ur-cache-cleaner.git" }, "license": "GNU General Public License", - "version": "1.2.0", + "version": "1.3.0", "engines": { "vscode": "^1.72.0" }, @@ -83,11 +83,11 @@ } ], "keybindings": [ - { - "command": "ur-cache-cleaner.drushClearCache", - "key": "ctrl+shift+c ctrl+shift+r", - "mac": "cmd+shift+c cmd+shift+r" - } + { + "command": "ur-cache-cleaner.drushClearCache", + "key": "ctrl+shift+c ctrl+shift+r", + "mac": "cmd+shift+c cmd+shift+r" + } ] }, "scripts": { diff --git a/src/commands/check_cmd.js b/src/commands/check_cmd.js index 4b0c964..39273cc 100755 --- a/src/commands/check_cmd.js +++ b/src/commands/check_cmd.js @@ -1,14 +1,14 @@ const commandExists = require('command-exists').sync; /** - * @param {object} cmd + * Checks if a command exists. + * @param {object} cmd - The command object. + * @returns {boolean|string} - Returns true if the command exists, or an error message if it doesn't. */ exports.command = (cmd) => { - var result; if (commandExists(cmd.name)) { - result = true; + return true; } else { - result = `${cmd.title} launcher is not installed, Please install it globally on your system.`; + return "Drush launcher is not installed. Please install it globally on your system."; } - return result; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/commands/drush/cmd.js b/src/commands/drush/cmd.js index 4b3fff8..5a0f52a 100755 --- a/src/commands/drush/cmd.js +++ b/src/commands/drush/cmd.js @@ -6,68 +6,55 @@ const fs = require('fs'); const title = "Drush"; const name = "drush"; const root = vscode.workspace.rootPath; -const status = name + ' status --root=' + root; const successMsg = "Cache rebuild completed."; -var cacheRebuild = "drush > /dev/null"; + +let cacheRebuild = checkDdevEnv() ? 'ddev drush cr' : `${root}/vendor/bin/${name} cr`; +let status = checkDdevEnv() ? 'ddev drush status' : `${root}/vendor/bin/${name} status`; /** - * @param {object} extStatusBarItem - * @param {string} drupalVersion - * @param {string} drushVersion + * Clears the cache and updates the status bar item. + * @param {object} extStatusBarItem - The extension status bar item. + * @param {string} drupalVersion - The Drupal version. + * @param {string} drushVersion - The Drush version. */ function clearCache(extStatusBarItem, drupalVersion, drushVersion) { - - // Modify command if it's running in ddev environment. - cacheRebuild = checkDdevEnv(cacheRebuild); - cmdRunner.exec(cacheRebuild, (exps, stdout, stderr) => { if (stderr) { - // Show success output & update values of status bar button. let output = stderr.trim(); if (output.includes('[success]')) { vscode.window.showInformationMessage(successMsg); } else { - vscode.window.showErrorMessage(`${title} error: ` + stderr); + vscode.window.showErrorMessage(`${title} error: ${stderr}`); } - extStatusBarItem.text = `$(clear-cache) Clear Cache`; - extStatusBarItem.tooltip = `Drupal ${drupalVersion} (${title} ${drushVersion})`; } if (exps) { - // Show exception & update values of status bar button. vscode.window.showErrorMessage('Exception: ' + exps); - extStatusBarItem.text = `$(clear-cache) Clear Cache`; - extStatusBarItem.tooltip = `Drupal ${drupalVersion} (${title} ${drushVersion})`; } if (stdout) { - // Show output & update values of status bar button. vscode.window.showInformationMessage('stdout: ' + stdout); - extStatusBarItem.text = `$(clear-cache) Clear Cache`; - extStatusBarItem.tooltip = `Drupal ${drupalVersion} (${title} ${drushVersion})`; } + + // Update the status bar item with cache clear information. + extStatusBarItem.text = `$(clear-cache) Clear Cache`; + extStatusBarItem.tooltip = `Drupal ${drupalVersion} (${title} ${drushVersion})`; }); } /** - * @param {string} cacheRebuildCmd + * Checks if the workspace is running in ddev environment. + * @returns {boolean} - Returns true if ddev environment is detected, false otherwise. */ -function checkDdevEnv(cacheRebuildCmd) { - // Check .ddev directory exist or not in workspace. - var ddev_config = root + '/.ddev' - if (fs.existsSync(ddev_config)) { - cacheRebuildCmd = `ddev ` + name + ` cr`; - } else { - cacheRebuildCmd = name + ' cr --root=' + root; - } - return cacheRebuildCmd; +function checkDdevEnv() { + return fs.existsSync(`${root}/.ddev`); } module.exports = { - title, - name, - root, - status, - clearCache, - checkDdevEnv -} \ No newline at end of file + title, // Drupal site title + name, // Drush command name + root, // Workspace root path + status, // Drush command status + clearCache, // Function to clear the cache + checkDdevEnv // Function to check if ddev environment is detected +}; \ No newline at end of file diff --git a/src/extension.js b/src/extension.js index 370269e..fdee6a8 100755 --- a/src/extension.js +++ b/src/extension.js @@ -6,10 +6,10 @@ const check = require('./commands/check_cmd'); var drupalVersion, drushVersion; /** - * @param {vscode.ExtensionContext} context + * Activate the extension when the VS Code instance starts. + * @param {vscode.ExtensionContext} context - The extension context. */ function activate(context) { - // Create a new status bar item that we can now manage. const extStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100); const result = check.command(drush); @@ -18,17 +18,20 @@ function activate(context) { // Assign values of status bar button. const extDrushButtonId = 'ur-cache-cleaner.drushClearCache'; extStatusBarItem.command = extDrushButtonId; - extStatusBarItem.name = `drush-clear-cache`; + extStatusBarItem.name = 'drush-clear-cache'; cmdRunner.exec(drush.status, (exps, stdout, stderr) => { + if (stderr) { // Show command error. - vscode.window.showErrorMessage(`${drush.title} error: ` + stderr); + vscode.window.showErrorMessage(`${drush.title} error: ${stderr}`); } + if (exps) { // Show command exception. - vscode.window.showErrorMessage(`${drush.title} ` + exps); + vscode.window.showErrorMessage(`${drush.title} ${exps}`); } + if (stdout && !exps && !stderr) { // Extract the version of Drupal and Drush from the output of the status command. const drupal_expression = /Drupal version\s+:\s(([0-9]\.*){1,})/g; @@ -36,7 +39,7 @@ function activate(context) { drupalVersion = drupal_expression.exec(stdout)[1]; drushVersion = drush_expression.exec(stdout)[1]; - extStatusBarItem.text = `$(clear-cache) Clear Cache`; + extStatusBarItem.text = '$(clear-cache) Clear Cache'; extStatusBarItem.tooltip = `Drupal ${drupalVersion} (${drush.title} ${drushVersion})`; extStatusBarItem.show(); } @@ -44,8 +47,8 @@ function activate(context) { const disposable = vscode.commands.registerCommand(extDrushButtonId, function () { // Change text while clearing cache. - extStatusBarItem.text = `$(sync~spin) Clearing Cache`; - extStatusBarItem.tooltip = `Working on...`; + extStatusBarItem.text = '$(sync~spin) Clearing Cache'; + extStatusBarItem.tooltip = 'Working on...'; // Execute clear cache command. drush.clearCache(extStatusBarItem, drupalVersion, drushVersion); }); @@ -56,13 +59,14 @@ function activate(context) { // Show command not found error message. vscode.window.showErrorMessage(result); } - } -// This method is called when your extension is deactivated +/** + * Deactivates the extension. + */ function deactivate() { } module.exports = { activate, deactivate -} +}; \ No newline at end of file