Skip to content

feat: add search, update, catalog and remove commands#2

Open
dongguacute wants to merge 3 commits intoLittleSound:mainfrom
dongguacute:main
Open

feat: add search, update, catalog and remove commands#2
dongguacute wants to merge 3 commits intoLittleSound:mainfrom
dongguacute:main

Conversation

@dongguacute
Copy link

Summary

This PR adds four new commands to enhance the package management experience:

  • nai search - Search npm registry for packages
  • nai update - Batch update dependencies to latest versions
  • nai catalog - Browse and manage catalog versions
  • nai remove - Remove packages from dependencies

Changes

New Files

File Description
src/npm.ts npm registry API utilities (search, versions, outdated check)

Modified Files

File Changes
src/cli.ts Added search, update, catalog commands with interactive UI
README.md Documented new commands and usage examples

Features

🔍 nai search (alias: nai s)

Search npm registry interactively:

nai search react
nai s "ui framework"
  • Searches npm registry using the official search API
  • Displays package name, version, and description
  • Select a package from results to install directly

📦 nai update (alias: nai up)

Check and update outdated packages:

nai update              # Check all packages for updates
nai update react lodash # Update specific packages
nai update -i           # Interactive mode - select packages to update
  • Automatically detects outdated dependencies
  • Respects catalog references - updates catalog entries when needed
  • Interactive multi-select for choosing which packages to update
  • Colorful summary showing old → new versions

🗂️ nai catalog

Browse catalogs and change dependency versions:

nai catalog        # Interactive catalog browser
nai catalog --list # List all catalogs with dep counts
  • View all catalogs and their dependencies
  • Select packages within a catalog
  • Fetch available versions from npm
  • Choose new version from a list of recent releases
  • Updates catalog entries and runs install automatically

🗑️ nai remove (alias: nai rm)

Remove packages from dependencies:

nai remove              # Interactive - select packages to remove
nai remove react lodash # Remove specific packages
nai rm axios --clean-catalog # Also remove unused catalog entries
  • Shows all dependencies across workspace packages
  • Multi-select packages to remove
  • Indicates which packages and dep types are affected
  • Optional catalog cleanup with --clean-catalog
  • Updates all relevant package.json files

Technical Details

src/npm.ts

New module providing npm registry interactions:

  • searchNpm(query, options) - Search npm registry
  • getPackageVersions(packageName) - Fetch all available versions
  • checkOutdated(deps, options) - Compare current versions with latest

UI/UX

All new commands follow the existing design patterns:

  • Uses @clack/prompts for consistent interactive UI
  • Colorful output with ansis
  • Spinner feedback during network operations
  • Summary confirmation before making changes

Test Plan

  • [✅] Existing tests pass (100 tests)
  • [✅] Build succeeds
  • [✅] Manual test: nai search react
  • [✅] Manual test: nai update in a project with outdated deps
  • [✅] Manual test: nai catalog in a monorepo with catalogs
  • [✅] Manual test: nai remove to uninstall packages

(以上就是具体描述,让AI总结的,指令我都试了一遍正常的,基本就是完善了一下基础功能,希望能够合并,谢谢)

dongguacute and others added 3 commits March 12, 2026 02:46
Added a new command to remove packages from dependencies, including options for catalog cleanup. Updated provider interfaces and implementations for bun, pnpm, and yarn to support the new removal feature. Enhanced type definitions and added tests for the new functionality.
Added new commands to the CLI for searching npm packages and updating dependencies. The `search` command allows users to find packages interactively, while the `update` command checks for outdated packages and facilitates their updates. Updated the README to reflect these new features and provided usage examples.
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.

1 participant