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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@carry0987/plugin-manager

v2.0.4

Published

This class provides utility functions for managing file operations, including cleaning directories, copying distribution folders, moving files, clearing unnecessary files, and removing empty directories in a file system.

Readme

PluginManager-JS

NPM CI

The @carry0987/plugin-manager library provides utility functions for preparing front-end assets from local directories and installed packages. It focuses on declarative file selection instead of scanning every dist folder under node_modules.

Installation

You can install the library via:

pnpm add @carry0987/plugin-manager

Usage

Here's an example of how you can use the @carry0987/plugin-manager library in your project:

import { PluginManager } from '@carry0987/plugin-manager';

const sourceDir = 'path/to/source';
const targetDir = 'path/to/target';

// Empty a target directory while keeping the root folder
PluginManager.emptyDir(targetDir);

// Copy package assets declaratively
PluginManager.copyPackages('node_modules', targetDir, [
	{
		name: '@carry0987/utils-full',
		from: 'dist',
	},
	{
		name: 'bootstrap',
		from: 'dist',
		include: ['**/bootstrap.bundle.min.js', '**/bootstrap.min.css'],
	},
	{
		name: 'jquery',
		from: 'dist',
		include: ['**/jquery.min.js'],
	},
	{
		name: 'select2',
		from: 'dist',
		include: ['**/select2.min.js', '**/select2.min.css'],
	},
	{
		name: 'sweetalert2',
		from: 'dist',
		include: ['**/sweetalert2.min.js', '**/sweetalert2.min.css'],
	},
]);

// Copy arbitrary files with include/exclude filters
PluginManager.copyFiles(sourceDir, targetDir, {
	include: ['**/*'],
	exclude: ['**/*.map'],
});

// Clear unnecessary files
PluginManager.clearUnnecessaryFiles(targetDir, ['*.js']);

// Clear empty directories
PluginManager.clearEmptyDirs(sourceDir);

// Remove directories
PluginManager.removeDirs([targetDir]);

API

emptyDir(targetDir: string, options?: OperationOptions): void

Ensures the target directory exists and removes all contents inside it while keeping the root directory in place.

copyPackages(sourceDir: string, targetDir: string, rules: PackageRule[], options?: CopyPackagesOptions): void

Copies files from installed packages based on declarative rules. Each rule resolves sourceDir/name, defaults from to dist, optionally copies into targetDir/name/to, and filters files with include and exclude micromatch patterns.

copyFiles(sourceDir: string, targetDir: string, options?: CopyFilesOptions): void

Copies files from the source directory to the target directory using include and exclude micromatch patterns. Relative directory structure is preserved.

clearUnnecessaryFiles(targetDir: string, patterns: string[], options?: OperationOptions): void

Removes files in the target directory whose relative paths do not match the provided micromatch patterns.

clearEmptyDirs(directory: string, options?: OperationOptions): boolean

Removes empty directories under the specified directory. Recursively checks each subdirectory, removing any that are empty. Returns true if the directory is empty.

removeDirs(dirs: string[], options?: OperationOptions): void

Removes specified directories when they exist.

PackageRule

type PackageRule = {
	name: string;
	from?: string;
	to?: string;
	include?: string[];
	exclude?: string[];
	optional?: boolean;
};

CopyFilesOptions

type CopyFilesOptions = {
	include?: string[];
	exclude?: string[];
	verbose?: boolean;
};

Private Utility Methods

These methods are intended for internal use within the PluginManager class.

removeDir(dirPath: string): void

Recursively removes the specified directory and its contents.

getAllFiles(dir: string, rootDir?: string, fileList?: FileEntry[]): FileEntry[]

Recursively collects all files from the directory and stores each file with its absolute and relative path.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.