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

file-versioner

v1.1.0

Published

Version files and Update Links in the project

Downloads

163

Readme

File Versioner

Overview

File Versioner is a Node.js package that allows you to version your CSS, JS, or other specified files and update their associated links in HTML, PHP, or any other files containing these tags.

Installation

npm install file-versioner

Usage

Create a file-versioner.json file at the root of your project with the following structure:

{
  "folders": [
    {
      "folder": "path/to/your/folder",
      "filePath": ["path/to/your/file1.html", "path/to/your/file2.html"],
      "length": 8
    },
    {
      "folder": "path/to/another/folder",
      "filePath": "path/to/your/file.html",
      "updateInFile": false
    }
  ],
  "updateInFile": true,
  "filePath": ["path/to/default/file1.html", "path/to/default/file2.html"],
  "length": 6
}

Configuration

  • folders: An array of objects specifying the folders to process.
  • folder: The path to the folder containing files to versionize.
  • updateInFile: (Optional) Boolean indicating whether to update links in files. Defaults to updateInFile from the root level, or false if not specified.
  • filePath: (Optional) Path(s) to the file to update links. If not provided, filePath from the root level will be used.
  • length: (Optional) Length of the version string. If not provided, length from the root level will be used. Defaults to 6 if not specified.
  • filePath: Default path(s) to the file to update links.
  • updateInFile: (Optional) Default boolean indicating whether to update links in files. Defaults to false if not provided.
  • length: (Optional) Default length of the version string. Defaults to 6 if not provided.

Note

When the length parameter is set to 0, the filename will be generated without a version. This is useful for cases where versioning is no longer required.

Example file-versioner.json

{
    "folders": [
        {
            "folder": "public/assets"
        },
        {
            "folder": "public/images",
            "filePath": ["app/index.php", "app/another-file.php"],
        }
    ],
    "updateInFile": true,
    "filePath": "index.html",
    "length": 8
}

Running file-versioner

After setting up file-versioner.json, run the following command in your project directory:

npx file-versioner

Behavior

The file-versioner command will:

  • Rename each file in the folder with a version string appended to its name.
  • Optionally update links to these files in the specified filePath.

Author

Muneeb

Contact

For support or inquiries, please reach out to me at [email protected].

Contributing

Contributions, issues, and feature requests are welcome !

License

This project is licensed under the MIT License.