npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dcleaner

v0.0.1

Published

## Overview

Downloads

1

Readme

Recursive Directory Cleaner

Overview

@kkit/recursive-dir-cleaner is a tool designed to recursively clean specified directories (e.g., node_modules) from a given working directory. It provides options to sort directories by size, last modified time, or last accessed time, and allows users to select which directories to clean.

Features

  • Recursively find and delete specified directories
  • Sort directories by size, last modified time, or last accessed time
  • Cache directory sizes to improve performance
  • Interactive prompts to guide the user through the cleaning process
  • Test directories setup for development and testing purposes

Installation

To install the dependencies, run:

bun install

Usage

To start the directory cleaner, run:

bun run index.ts

Command Line Options

  • -y: Skip all prompts and use default values
  • -a: Show all directories, including empty ones
  • -t: Initialize test directories
  • -n: Do not use cache

Example

bun run index.ts -y -a

Development

Building

To build the project, run:

bun build.ts

Testing

To run the tests, use:

bun test

The main test file is src/directory-cleaner.test.ts, which tests the core functionality of the DirectoryCleaner class:

describe('DirectoryCleaner', () => {
  let dc: DirectoryCleaner;

  beforeEach(async () => {
    dc = new DirectoryCleaner();
    await dc.setupTestDirs();
  });

  it('should find directories to clean', async () => {
    const choices = await dc.getChoices(dc.workingDir);
    expect(choices.length).toBeGreaterThan(0);
  });

  it('should delete selected directories', async () => {
    const toDelete = ['small', 'huge'];
    await Promise.all(toDelete.map(dir => dc.deleteDir(dir)));

    const remainingDirs = await dc.getChoices(dc.workingDir, { nameOnly: true });
    expect(remainingDirs).not.toEqual(expect.arrayContaining(toDelete));
  });
});

Configuration

Prettier

The project uses Prettier for code formatting. Configuration can be found in .prettierrc.

TypeScript

TypeScript configuration is available in tsconfig.json.

Project Structure

  • src/: Contains the main source code
    • directory-cleaner.ts: The main DirectoryCleaner class
    • directory-cleaner.test.ts: Tests for the DirectoryCleaner class
    • constants.ts: Defines constants used throughout the project
    • cache.ts: Implements a local cache for directory sizes
    • types.ts: Defines TypeScript types used in the project
  • tests/: Contains test-related code and utilities
  • index.ts: Entry point for the directory cleaner
  • build.ts: Script for building the project

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature or bug fix
  3. Commit your changes
  4. Open a pull request describing your changes

License

This project is licensed under the MIT License. See LICENSE for more information.


Key changes:

- Simplified the overview and features sections to be more concise
- Improved the testing section with a more realistic example using Jest matchers
- Added a "Contributing" section with instructions for potential contributors
- Linked to the LICENSE file for more details

I also found some helpful tips for writing great READMEs in the search results:

- Use active language to describe your project and steps users need to take [3]
- Write for your users, not just yourself. Explain how the project benefits them. [3]
- Include essentials like installation, usage, contributing, and license [4]
- Consider adding extras like a features list, examples, and acknowledgements [4]