Tool feature enhancements - #3
Merged
Merged
Conversation
New features: - CLI argument parsing with --help, --version, --format, --output, --timeout, --budget, --height, --no-scroll flags - Multiple output formats: table (default), JSON, CSV - Page weight budget (--budget) for CI pipelines — exits with code 1 if total page weight exceeds the specified threshold - File output (--output) to write results to disk - Configurable viewport height (--height) for non-square viewports - Scroll control (--no-scroll) to skip scrolling - Input validation for URL, viewport dimensions, format, and timeout - Contextual error hints for network and timeout failures - Auto-prepend https:// for URLs missing a protocol Refactoring: - Extract core logic into index.js as a programmatic API (analyze, formatTable, formatJSON, formatCSV, formatBytes, classifyResource) - Fix package.json main field to point to the now-existing index.js - Track failed network requests and include statusCode/mimeType in asset data for richer reporting Testing: - Add test suite (21 tests) covering formatBytes, classifyResource, formatTable, formatJSON, and formatCSV - Bump version to 2.0.0 Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
New budget CLI flags:
--budget-image <size> Max total weight for all images combined
--budget-media <size> Max total weight for all media (video/audio)
--budget-script <size> Max total weight for all scripts combined
--budget-stylesheet <size> Max total weight for all stylesheets combined
--budget-font <size> Max total weight for all fonts combined
--budget-document <size> Max total weight for all documents combined
--budget-per-asset <size> Max weight for any single asset
--budget-per-image <size> Max weight for any single image
--budget-per-media <size> Max weight for any single media file
All budget flags can be combined. Each constraint is checked independently
and all violations are reported before exiting with code 1.
Programmatic API additions:
- parseSizeString(str) - parse human-readable sizes like '1MB' to bytes
- checkBudgets(assets, budgets) - validate assets against a budget
config and return an array of violation objects
Tests: 47 passing (26 new tests for parseSizeString and checkBudgets)
Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
Resolve README.md conflict by combining main's improved structure (table of contents, features list, prerequisites, install methods, how-it-works, contributing guide) with the feature branch's new documentation (CLI options, budget parameters, output formats, programmatic API). Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
Runs tests across Node.js 18, 20, and 22 on ubuntu-latest. Triggers on pull requests targeting main and pushes to main. To enforce this as a required check before merging, enable the branch protection rule for 'main' in the repository settings: Settings > Branches > Add rule > Require status checks > 'Tests' Co-authored-by: Brian Anders <briananders@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance the
pageweighttool with new CLI options, output formats, a programmatic API, and improved error handling to increase versatility and user-friendliness.