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

verify-build

v1.2.0

Published

validate given file system, usually used for validating build artifacts

Downloads

20

Readme

verify-build

This package verifies your build files via pattern/schemas. Verify build will fail on the first use case where it does not match the schema provided and reports an error.

Installation:

npm install verify-build

Usage

You need to specify the path to a configuration file that contains the schemas as modules.

verify-build --config ./build-files-schema.js

Writing schema configuration file

Here is a basic sample configuration that verify build script expects. Note it starts with modules array and some global check configurations.

{
    checkNonEmptyFiles: false,
    logLevel: 'info'
    modules: [
        JSFiles,
        CSSFiles,
        images,
        fonts,
    ]
}

logLevel accepts two values ('info' and 'error'). Choose error when you want to trace where error occured. For detailed logging use info.

modules is a array of small independent module that define their own set of path, schemas. Lets explore a sample module

module.exports = {
    _name: "js bundles",
    desc: "Javascipt bundle for dev and prod",
    cwd: "../build/js/",
    checkFolderCount: 1,
    checkFileCount: 2,
    filesSchema: [
        {
            fileName: "bundles.js"
        },
        {
            fileName: "vendor.js"
        },
        {
            folderName: "minified",
            checkFileCount: 2,
            filesSchema: [
                {
                    fileName: "bundles.min.js",
                    checkEmpty: true
                },
                {
                    fileName: "vendor.min.js"
                }
            ]
        }
    ]
};

Here is the details about the above configuration

| keys | description | | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | _name | Name of the module | | desc | Description of the module. This is optional ans is used for understanding purpose | | cwd | You must provide cwd parameter to indicate the root for module files. | | checkFolderCount | Optional config if you wish to check folder count in the cwd. This checks if there are exact no of folders exist in the build. | | checkFileCount | Optional and similar to checkFolderCount but this checks for number of files. Note: you may apply this check at any folder level schema. | | filesSchema | filesSchema is a representation of nested folder structure where you can define child schemas using the same filesSchema representation. | | fileName | fileName is the name of the file to be checked used inside a filesSchema | | folderName | This key is used for finding folder path and determining if the schema is for a folder | | checkEmpty | checkEmpty checks if file is not blank. Its not required in case of contentMatch key is provided. |

Repeating a similar schema check for muiltiple folders in a directory

folderIterator key helps to repeat the same schema check for number of items in the folderIterator key.

    filesSchema: [
        {
            isFolder: true,
            folderIterator: ["folderNameA", "folderNameB", "folderNameC" ]
            filesSchema: [
                {
                    fileName: "bundles.min.js"
                },
                {
                    fileName: "vendor.min.js"
                }
            ]
        }
    ]

fileIterator key helps to repeat the same schema check for multiple files in the same folder.

filesSchema: [
    {
        fileIterator: ["jquery.js", "lodash.js", "underscore.js", "asf.t"],
        checkEmpty: true
    }
];

Checking content of a file

For checking content inside a file, use contentMatch key. You can specify a string or a custom function which can return a boolean value. A sample usage is given below.


    /**
     *  Custom function to do content matching
     *  It should return a boolean value
     */
    const checkDataJSON = (schema, fileContent) => {
        // verify fileContent based on schema and additional logic
    }

    ....

    filesSchema: [
        {
            {
                fileName: "bundles.min.js",
                contentMatch: "#ad46dgsksjdf7df45lks9dsn48ng"
            },
            {
                fileName: "data.json",
                contentMatch: checkDataJSON
            },

        }
    ]

Change log

Major change logs can be found here

| version | description | | ------- | -------------------------------------------- | | 1.2.0 | Optimizations and bug fixes for faster check | | 1.0.1 | Child is born |