extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Update single-disk-eject extension

Open LostViking09 opened this issue 2 months ago • 5 comments

Description

Added Windows functionality, with the help of https://www.uwe-sieber.de/drivetools_e.html (bundled) and some PowerShell scripts.

Removed unused Linux-specific lines.

Screencast

Checklist

LostViking09 avatar Dec 05 '25 00:12 LostViking09

Thank you for your contribution! :tada:

🔔 @johndturn you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

📋 Quick checkout commands
BRANCH="ext/single-disk-eject"
FORK_URL="https://github.com/LostViking09/raycast-extensions.git"
EXTENSION_NAME="single-disk-eject"
REPO_NAME="raycast-extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

Due to our current reduced availability, the initial review may take up to 10-15 business days.

raycastbot avatar Dec 05 '25 00:12 raycastbot

Greptile Summary

This PR adds Windows support to the Single Disk Eject extension through a C# helper class and PowerShell script, while removing obsolete Linux support code. The implementation uses secure methods (execFile instead of exec, modern CIM over legacy WMI) and properly handles device ejection via Windows PnP APIs.

Key Changes:

  • Added Windows platform support with C# device ejection helper (USBEjector.cs)
  • Created PowerShell script (eject.ps1) to orchestrate the ejection process
  • Updated utils.ts to support Windows alongside macOS
  • Updated package.json to add Windows to supported platforms
  • Updated dev dependencies (React, Prettier)
  • Added @raycast/utils as a dependency

Minor Issue:

  • Changelog uses feature name instead of semantic versioning format for the new entry

Confidence Score: 4/5

  • This PR is safe to merge with minor formatting fix needed in the changelog.
  • The implementation is solid with secure command execution practices (execFile vs exec), proper Windows device API usage, and good error handling. The C# and PowerShell code is well-structured. The only issue is a minor changelog formatting violation that doesn't affect functionality. The platform support addition is correct, and dependency updates are appropriate.
  • CHANGELOG.md needs semantic version format instead of feature name for the new entry

Important Files Changed

Filename Overview
extensions/single-disk-eject/CHANGELOG.md Changelog updated with new Windows support, but the entry uses feature name [Windows Support] instead of semantic version (e.g., [1.2.0]). The {PR_MERGE_DATE} placeholder is correct, but the version format violates the project's changelog convention.
extensions/single-disk-eject/src/utils.ts Windows eject functionality properly implemented with safe command execution using execFile (prevents command injection). Code properly handles drive letter extraction, uses CIM (more modern than WMI), and includes proper error handling with helpful error messages.
extensions/single-disk-eject/assets/eject.ps1 PowerShell script for Windows ejection looks well-structured with proper error handling, uses CIM instead of legacy WMI, and correctly loads the C# helper class. No security concerns identified.
extensions/single-disk-eject/assets/USBEjector.cs C# helper class uses proper Windows device API calls (cfgmgr32.dll) to safely eject USB drives. Correctly navigates PnP device tree, includes veto type handling, and provides descriptive error messages for failed eject operations.
extensions/single-disk-eject/package.json Updated correctly: Windows platform added, @raycast/utils dependency added, dev dependencies updated appropriately (React version, prettier). No issues found.

greptile-apps[bot] avatar Dec 05 '25 11:12 greptile-apps[bot]

yeah we aren't going to merge a exe - too hard to verify automatically. Isn't it possible to do it with just some powershell?

mathieudutour avatar Dec 08 '25 07:12 mathieudutour

There are ways to do this in powershell, but the one that is actually a safe eject, not just an unmount, works differently than the taskbar applet, and often tells the user the drive is still in use.

I completely understand you don't want to merge this third-party tool. Will look into alternative solutions, maybe I can find some solution that has good UX.

LostViking09 avatar Dec 08 '25 10:12 LostViking09

This pull request has been automatically marked as stale because it did not have any recent activity.

It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

raycastbot avatar Dec 23 '25 10:12 raycastbot

Finally! I found a solution: using a C# helper as an interface for the Windows API. Powershell compiles it on the fly, works like a charm and still transparent for code review and security reasons.

I have also migrated to using wmic as it is somewhat faster than the previous powershell implementation.

LostViking09 avatar Jan 03 '26 12:01 LostViking09

Weird, the Store does not seem to be updated with this update. Changelog only shows the latest bugfix, and the plugin shows up as MacOS only 0.0

LostViking09 avatar Jan 13 '26 22:01 LostViking09

Triggered a new publish to see if it helps 🙂

pernielsentikaer avatar Jan 28 '26 08:01 pernielsentikaer

@LostViking09 it looks like there is an error with the package(lock) file, can you maybe update it in a PR?

You can see the error here: https://github.com/raycast/extensions/actions/runs/21431223204/job/61710804178

pernielsentikaer avatar Jan 28 '26 08:01 pernielsentikaer