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

@puya/fh

v1.0.5

Published

folder-hash is a cli tool that generates a hash for a folder, based on the files in it.

Readme

Puya Folder Hash Utility

@puya/fh is a tool that creates a hash for a directory based on the sub-directories/files located in it.

Related article

Story

As developers we all remember the troubles of building/transfering files from a published folder in a dev machine to a folder in a production server.

No matter how sharp we track the files we change during developement so that only copy them to production server not the whole published folder, we are all ended up creating a zip file, transfer it to production server, extract it there in the root of a website and free ourselves.

The slow transfer is painful, but the result is right at target (no errors - God willing -, all old files are replaced by their new updated version).

The issue resolved, but we always asked ourselves at the end of the day, couldn't be there a tool by which we could copy/transfer only the changed files, not the whole publish folder?

@puya/fh was created to help answering exactly this need.

Description

@puya/fh has two main features:

  • Generating a json file for a folder based on its content.
  • Comparing two json files and generate a change list.

The generated json for a given directory can be used to ...

  • compare the directory with another directory
  • produce a report based on the differences between two directories
  • create a batch file to copy missing file/folders
  • copy the changes directly.
  • compress changes into a single zip file

With these capabilities at hand, the problem described in Story section can be easily resolved.

  1. We generate a json for our application folder in the production server.
  2. Bring the json to our dev machine.
  3. Compare the json with our local folder and create a compressed file out of the changes
  4. Transfer the compressed file to production.
  5. Extract it there at the root of our app.

We can now transfer only the changed files to the production server.

Install

npm i @puya/fh -g

Usage

CLI

Base usage:

fh [command] [args] [options]

command:

  • hash: generates json file for a folder based on its content.
  • diff: checks the differences between two folders
  • apply: copies the differences between two folders to a target directory.

[args] depend on `[command].

[options]:

  • -ed or --exclude-dirs: specify a comma separated list of excluded folders that should be ignored.
  • -ef or --exclude-files: specify a comma separated list of excluded files that should be ignored.
  • -id or --include-dirs: specify a comma separated list of included folders that should not be ignored.
  • -if or --include-files: specify a comma separated list of excluded files that should not be ignored.
  • -q or -quiet: quiet mode (do not show output messages in console)
  • -ns or --no-sort: do not sort folder/files
  • -dbm or --debug-mode: debug mode
  • -dp or --deep: show deep details

Other args:

  • -? or --help: show help
  • -v or --version: show the tool version number

Notes:

  • include lists have more priority over exclude lists.
  • If an exclude/include list starts with comma, the list will be added to the default exclude/include list, otherwise it will replace it.
  • For each file it generates an md5 hash.
  • For sub-directories, it generates the md5 based on the content of a sub-directory.

Using @puya/fh in CLI is described in details a little furthur.

Development

import { FolderUtil } from "@puya/fh";

const json = FolderUtil.getHash(dir);

console.log(json.hash);

CLI Usage

hash

Args:

  • -d or --dir: path of directory for which hash should be generated (could be an absolute or relative path).
  • -o or --output: path/name of generated json file.

example 1: create hash for current directory

fh

example 2: create hash for /publish folder in current directory

fh hash -d ./publish

example 3: create hash for /publish folder as hash.json

fh hash -d ./publish -o hash.json

example 4: create hash for /publish folder in current directory, do not sort file/folders

fh hash -d ./publish -ns

example 5: create hash for /publish folder in current directory, quiet mode.

fh hash -d ./publish -q

diff

Args:

  • -f or --from: (relative/absolute) path of from or source folder (the folder we are comparing to) or (relative/absolute) path of its json.
  • -t or --to: (relative/absolute) path of to or destination folder (the folder we are comparing) or (relative/absolute) path of its json.
  • -rf or --relative-from: a path for from folder that will be used in generated batch or apply command (copying files/folders) for source file/dirs.
  • -rt or --relative-to: a path for to folder that will be used in generated batch or apply command (copying files/folders) for destination file/dirs.
  • -k or --kind: kind of operation to be performed on detected changes.
    • cmd: generate a windows .bat file to copy changes.
    • bash: generate a linux .sh file to copy changes.
    • report: report or show changes.

example 1: compare ./dev to ./prod directories, report changes

fh diff -f ./dev -t ./prod

example 2: compare dev.json to prod.json hash files, report changes

fh diff -f dev.json -t prod.json

example 3: compare ./dev to prod.json, report changes

fh diff -f ./dev -t prod.json

example 4: compare ./dev to ./prod directories, generate cmd batch file

fh diff -f ./dev -t ./prod -k cmd

example 5: compare ./dev to ./prod directories, generate bash file named ch20250512.sh

fh diff -f ./dev -t ./prod -k bash -o ch20250512.sh

example 6: compare ./dev to prod.json, generate cmd batch file named ch20250512.bat relative to ./publish dir

fh diff -f ./dev -t prod.json -rt ./publish -k cmd -o ch20250512.bat

apply

Args: arguments are the same as those used in diff command.

example 1: compare ./dev to ./prod directories, apply changes from './dev' into './prod'.

    fh apply -f ./dev -t ./prod

example 2: compare ./dev to prod.json, copy into -rt

    fh apply -f ./dev -t ./prod -rt ./publish

example 3: create zip archive out of changes

    fh apply -f ./dev -t ./prod -c

Included/Excluded files/folders

There are a default list of files and folders that @puya/fh ignores them by default.

default excluded folders

  • node_modules
  • .git
  • tests
  • tests
  • packages
  • wwwroot
  • coverage
  • .vscode
  • .idea
  • build
  • publish
  • .vs

Excluded files:

  • thumbs.db
  • package.json
  • packages.config
  • .env
  • .gitignore
  • .ds_store
  • *.log
  • *.test.js
  • *.spec.js
  • *.bak
  • *.tmp
  • sync.bat
  • sync.sh

These lists can be customized through cli arguments.