A command-line interface (CLI) Pokedex application built with TypeScript and Node.js. This application functions as a REPL (Read-Eval-Print Loop) that allows users to interact with the PokeAPI to explore locations, discover Pokemon, and attempt to catch them to build their own Pokedex.
- Interactive REPL: A continuous shell environment for entering commands.
- Location Exploration: Browse through location areas in the Pokemon world with pagination.
- Pokemon Discovery: Explore specific areas to see which Pokemon can be found there.
- Catching Mechanics: Attempt to catch Pokemon using a probability-based system determined by the Pokemon's base experience.
- Pokedex Management: View a list of caught Pokemon and inspect their detailed statistics (height, weight, stats, types).
- Caching: Implements an internal caching system to minimize API requests and improve performance.
- Node.js (v18+ recommended)
- npm
-
Clone the repository:
git clone <repository-url> cd pokedex
-
Install dependencies:
npm install
To compile and run the application in a single step:
npm run devOnce the REPL is running (Pokedex >), you can use the following commands:
| Command | Description | Usage |
|---|---|---|
help |
Displays a help message with all available commands. | help |
map |
Displays the next 20 location areas in the Pokemon world. | map |
mapb |
Displays the previous 20 location areas. | mapb |
explore |
Lists all Pokemon available in a specific location area. | explore <location_name> |
catch |
Attempts to catch a specific Pokemon. Success is based on difficulty. | catch <pokemon_name> |
inspect |
Displays details (stats, type, height, weight) of a caught Pokemon. | inspect <pokemon_name> |
pokedex |
Lists all Pokemon currently in your Pokedex. | pokedex |
exit |
Exits the application. | exit |
The project uses Vitest for testing. The suite includes unit tests for input sanitization and the caching mechanism.
To run the tests:
npm testsrc/main.ts: Entry point of the applicationsrc/repl.ts: Handles the Read-Eval-Print Loop logic and input sanitizationsrc/commands/: Contains the logic for individual commands (catch, explore, map, etc.)src/pokeapi.ts: Handles interactions with the PokeAPIsrc/pokecache.ts: Implements the caching class with a reaping interval to clear old datasrc/state.ts: Manages the application state (REPL instance, Pokedex data, pagination URLs)