node package manager

size-matters

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?