Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 10, 2025

Summary

Implements a comprehensive cleanup function to remove any packages installed by use-m in the global npm context/folder. This addresses issue #24 by providing both programmatic and CLI interfaces for cleaning up globally installed packages.

Changes

✨ New Features

  • use.cleanup() function: Programmatically remove all globally installed packages
  • CLI cleanup command: Easy command-line interface via use-m cleanup
  • Multi-environment support: Works with both Node.js/npm and Bun environments
  • Smart detection: Automatically detects environment and skips cleanup for browser/Deno (no global packages)

🔧 Implementation Details

  • Scans global npm/bun directories for packages matching use-m alias pattern (package-name-v-version)
  • Uses npm uninstall -g for npm environment
  • Uses bun remove -g for Bun environment
  • Returns detailed results including cleaned packages, errors, and environment info
  • Handles edge cases like missing directories and permission errors

📚 Documentation

  • Added comprehensive documentation section in README
  • Includes both programmatic and CLI usage examples
  • Clear explanation of return values and error handling

🧪 Testing

  • Added comprehensive test suite for cleanup functionality
  • Tests environment detection, error handling, and edge cases
  • Tests pass with 15-second timeout to accommodate real package operations

Test Plan

  • Test use.cleanup() function returns proper structure
  • Test environment detection (npm/bun/browser)
  • Test empty directory handling
  • Test CLI command functionality
  • Test documentation accuracy
  • Manual testing with real package installations

Resolves #24

🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #24
@konard konard self-assigned this Sep 10, 2025
konard and others added 2 commits September 10, 2025 07:38
- Add use.cleanup() function to programmatically remove all globally installed packages
- Support both Node.js/npm and Bun environments
- Add CLI cleanup command for easy command-line usage
- Include comprehensive tests for cleanup functionality
- Update documentation with usage examples and CLI command reference

Resolves #24

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@konard konard changed the title [WIP] cleanup function Implement cleanup function to remove globally installed packages Sep 10, 2025
@konard konard marked this pull request as ready for review September 10, 2025 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cleanup function

2 participants