Skip to content

feat(report): support --report for single export commands#3

Merged
alexey1312 merged 2 commits intomainfrom
feat/report-single-export
Feb 25, 2026
Merged

feat(report): support --report for single export commands#3
alexey1312 merged 2 commits intomainfrom
feat/report-single-export

Conversation

@alexey1312
Copy link
Collaborator

Summary

  • Extend --report flag support from batch-only to all export commands (colors, icons, images, typography)
  • Add ExportReport type and parseSingleReport() for single-command structured JSON reports
  • Harden parseReportFile() with granular error handling, type-guarded format discrimination, and defensive null checks
  • Reuse BatchConfigStats in ExportReport to eliminate type duplication

Test plan

  • 77 unit tests pass (6 new edge-case tests added)
  • ESLint, Prettier, TSC, actionlint all pass
  • E2E: verify --report flag is injected for colors/icons/images/typography commands
  • E2E: verify single export report JSON is parsed and report_json output is populated
  • E2E: verify batch mode continues to work unchanged

🤖 Generated with Claude Code

alexey1312 and others added 2 commits February 25, 2026 10:22
Extend --report flag injection from batch-only to all export commands
(colors, icons, images, typography). Parse both BatchReport and
ExportReport formats via structural discrimination in parseReportFile().

Closes #2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ests

Break monolithic try/catch in parseReportFile into separate stages
(file read, JSON parse, format discrimination) with core.warning at
each level. Strengthen report format discrimination with type guards
(Array.isArray, typeof checks). Add defensive null guard for stats in
parseSingleReport. Reuse BatchConfigStats in ExportReport type. Fix
misleading "Report file not found" warning message. Add 6 new tests
covering edge cases: unrecognized format, discriminator precedence,
single-report error truncation, null error on failure, multi-stat
summation, and custom report path for single exports.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @alexey1312, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the action's reporting capabilities by extending the --report flag functionality to include all individual export commands. This allows users to obtain structured JSON reports for single exports, providing more detailed and programmatic insights into their asset generation processes. The changes also include robust parsing logic to correctly interpret both batch and single export report formats, improving the reliability and usability of the reporting feature.

Highlights

  • Extended Report Flag Support: The --report flag, previously limited to batch mode, now supports all single export commands: colors, icons, images, and typography.
  • New Export Report Type and Parsing: Introduced an ExportReport type and a dedicated parseSingleReport() function to handle structured JSON reports generated by single export commands.
  • Enhanced Report File Parsing Robustness: The parseReportFile() function has been hardened with granular error handling, type-guarded discrimination between batch and single export report formats, and defensive null checks for improved reliability.
  • Type Reusability: The BatchConfigStats type is now reused within the new ExportReport interface, eliminating type duplication.
  • Updated Action Metadata: The action.yml file has been updated to reflect the broader applicability of the report input and report_json output, removing previous 'batch mode only' descriptions.
Changelog
  • action.yml
    • Updated the description for the report input to remove the 'batch mode' limitation.
    • Updated the description for the report_json output to remove the 'batch mode only' limitation.
  • src/index.test.ts
    • Modified the test for --report injection to now include single export commands.
    • Added new tests to verify custom report paths for single export commands.
    • Added tests to ensure --report is not injected for non-export commands like fetch or download.
    • Added tests to confirm auto-injection of --report for all export commands.
    • Introduced new tests for parseReportFile to handle single export reports with assets, errors, zero stats, unrecognized JSON structures, and long error messages.
    • Added a test to ensure batch parsing is preferred when a report contains both batch and single export indicators.
    • Added a test for handling single export failures with null errors.
    • Added a test to correctly sum all stat fields in a single export report.
  • src/index.ts
    • Imported the new ExportReport type.
    • Defined REPORT_COMMANDS constant to list all commands supporting structured JSON reports.
    • Modified buildCommand to inject the --report flag for any command listed in REPORT_COMMANDS.
    • Refactored parseReportFile to include error handling for file reading and JSON parsing, and to discriminate between BatchReport and ExportReport structures.
    • Extracted batch report parsing logic into a new parseBatchReport function.
    • Implemented a new parseSingleReport function to process single export reports, calculating assets exported, validated, and failed counts.
    • Updated the run function to use the REPORT_COMMANDS constant when determining whether to parse a structured report, and improved error logging for report file reading.
  • src/types.ts
    • Updated the reportJson output description to remove the 'batch mode only' restriction.
    • Defined SingleExportCommand type.
    • Introduced ExportReport interface to represent structured reports from single export commands, reusing BatchConfigStats.
    • Added AssetManifest and AssetManifestFile interfaces for future use.
Activity
  • The author has added 6 new edge-case unit tests, bringing the total to 77 passing tests.
  • All static analysis checks (ESLint, Prettier, TSC, actionlint) are passing.
  • E2E tests are planned to verify --report flag injection, single export report parsing, and continued batch mode functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request extends the --report functionality to single export commands, which was previously only available for batch mode. This is achieved by introducing a new ExportReport type and a parser for this new report format. The main report parsing logic in parseReportFile has been refactored to be more robust, with better error handling and logic to discriminate between batch and single command reports. The changes are well-tested with new unit tests covering various scenarios for the new functionality. My review found one minor inconsistency in a type definition, for which I've provided a suggestion.

duration: number;
success: boolean;
error: string | null;
stats: BatchConfigStats;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The stats property is defined as non-nullable (BatchConfigStats), but the implementation in src/index.ts handles cases where it might be null or undefined. For example, parseReportFile checks report.stats != null, and parseSingleReport uses a nullish coalescing operator (report.stats ?? ...).

To make the type definition consistent with the implementation, stats should be nullable. This also aligns with the BatchConfigReport type where stats is already defined as BatchConfigStats | null.

Suggested change
stats: BatchConfigStats;
stats: BatchConfigStats | null;

@alexey1312 alexey1312 merged commit ddeb308 into main Feb 25, 2026
7 checks passed
@alexey1312 alexey1312 deleted the feat/report-single-export branch February 25, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant