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

size-matters

v0.3.1

Published

Analyze files to measure negative impacts on file size over time.

Downloads

12

Readme

README

What is this repository for?

  • size-matters is a node js app that can be used to measure negative impacts on file size over time. File size thresholds can be set to fail a build when any files become too large.

How do I get set up?

  • Install
    • Local - npm i -D size-matters or yarn add -D size-matters
    • Global - npm i -g size-matters or yarn global add size-matters
    • Required (As Administrator) - npm i -g windows-build-tools or yarn global add windows-build-tools
  • Configuration
    • See example.config.json
  • Dependencies
    • See package.json
  • Database configuration
    • The database backing the app is SQLite3.
    • The database is specified in the config json.
    • If the database doesn't exist then a database initialization script is automatically run to create the database in the specified location.
    • The database initialization script can be found in ./src/schema/initialize-database.sql.
  • Run tests
    • npm test or yarn test

Usage

Because of the async operations used for reading/writing files it was decided that piping data from one operation to the next would be a clean approach. This also gives the opportunity to run individual operations.

Here are some commands to help get started.

  • Help
    • node ./node_modules/size-matters --help or node ./node_modules/size-matters -h
  • Config
    • The config is always piped to the next process. See the example config in the source for setting up a config.
    • node ./node_modules/size-matters -c path/to/config.json
  • Gather Stats on your directory
    • node ./node_modules/size-matters -c path/to/config.json -a gatherStats
  • Analyze file sizes
    • node ./node_modules/size-matters -c path/to/config.json -a fileSize
  • Generate report (requires data piped from -a fileSize)
    • node ./node_modules/size-matters -c path/to/config.json -a fileSize | node ./node_modules/size-matters -a generateReport

Configuration

  • The config file must be json.
  • project - project related properties
    • name - name used to store the project in the database.
    • path - path to be analyzed.
  • database - properties to configure the database.
    • fullPath - absolute path to the database. If the database does not exist then one will be created for the specified file path.
  • analyze - analysis related properties.
    • rootPath - the root path is joined to the project.path and is required. This helps identify the project in the database and also allows for multiple directories to be tracked separately per project.
    • ignoreOutdatedFiles (optional) - if set to true, files that weren't found the last time gatherStats was run will not be analyzed and will not appear on report output.
    • fileSize - properties to configure the file size analysis.
      • threshold - properties to set thresholds for file sizes. Reports will reflect whether a change had a minor positive or negative impact based on these settings.
        • minor - integer that defines a "minor" change in file size.
        • moderate - integer that defines a "moderate" change in file size.
        • major - integer that defines a "major" change in file size.
        • unacceptable - integer that defines a "unacceptable" change in file size. An exception is thrown if a file size increases beyond this threshold. The unacceptable file size does not necessarily have to be smaller than "major".
    • maxHistory - integer that defines the maximum number of records to analyze. A record is created for every time gatherStats is run.
    • include - string or array of glob patterns to identify what file types should be analyzed. This only affects gatherStats. Use in combination with ignoreOutdatedFiles to prevent generateReport from reporting on files that do not match the glob patterns.
    • ignore (optional) - string or array of glob patterns to not include in an analysis.
  • reporting - properties to configure reporting
    • path - absolute or relative output path for reports.
    • chart - properties to configure the chart output of each individual file analysis.
      • width - CSS property for the width of the charts.
      • height - CSS property for the height of the charts.

Contribution guidelines

  • Writing tests
    • Jest is the test runner.
  • Code review
  • Guidelines
    • Use airbnb eslint rules

Who do I talk to?