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

autofiles

v1.0.1

Published

This script is used to automate file creation by using templates.

Readme

Autofiles

This library supports automation of file creation in your project. It's highly configurable so that you can adjust it to your needs.

The core functionality is reacting to the creation of files or folders in a specified location by creating files using templates. As of v0.2.1, the only dynamic value in a template is name, which will be replaced by the name of the created file or folder. More features get added dependent on interest of users.

Installation

The installation can be made locally at project level. This has the advantage that every developer automatically installs the dependency when running npm install and can use it right away (when config and template files are committed).

npm install -D autofiles

If you prefer to install this dependency globally on your machine, you can do this using the following command. One usecase for this is, when you want to use this library without adding anything to the project itself. You probably want to gitignore the according config and template files if you do it this way.

npm install -g autofiles

Configuration

The configuration file has to be named autofiles.json and located in the root directory of the project. Its content has to be an array of configuration entries. The content of such an entry is defined by the following interface:

interface IConfigEntry {
  // Path from source directory to the folder to watch.
  directory: string;
  // Whether the creation of folders or files should be watched.
  folder: boolean;
  // If true, subdirectories of the defined directory get watched as well.
  includeSubdirs?: boolean;
  // If defined, an entry file with this name will be created and updated.
  entryFile?: string;
  // List of files to create.
  files: IFile[];
}

interface IFile {
  // Name of the file.
  filename: string;
  // Path from source directory to template txt file.
  pathToTemplate: string;
}

Every file object contains a filename and pathToTemplate property. The filename is a string which is going to be the resulting name of the file. $(name) in the string gets replaced by the name of the created folder or file, which triggered this creation. The pathToTemplate is the path from the project root directory to a .txt file. $(name) in this file gets replaced as well.

Here's an example:

// autofiles.json
[
  {
    "directory": "src/ui/components",
    "folder": true,
    "includeSubdirs": false,
    "entryFile": "index.ts",
    "files": [
      {
        "filename": "index.ts",
        "pathToTemplate": "autofiles/component/index.txt"
      },
      {
        "filename": "$(name).tsx",
        "pathToTemplate": "autofiles/component/main.txt"
      },
      {
        "filename": "$(name).stories.tsx",
        "pathToTemplate": "autofiles/component/stories.txt"
      }
    ]
  }
]

This example configuration takes action on newly created folders inside the src/ui/components directory. Nothing happens on creating subfolders. An entry file (index.ts) gets maintained on every change made. It exports everything that is exported from the index.ts files inside every component.

For this configuration to work, a couple template files need to be created. These files need to be located as it's defined in the pathToTemplate property of every file in the config.

Run script

npx autofiles