Skip to content

Enable JSON log output for lint:version-consistency npm script #987

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

Test-ActionVersionConsistency.ps1 already supports -Format Json -OutputPath parameters with full JSON serialization via Export-ConsistencyReport, but the npm script lint:version-consistency does not pass these flags. No JSON log file is written to logs/ during normal npm run lint:version-consistency execution.

Current Behavior

Running npm run lint:version-consistency produces only console table output. No file is created in logs/. The script has the capability but it is unused.

Current npm script:

pwsh -NoProfile -Command "./scripts/security/Test-ActionVersionConsistency.ps1 -FailOnMismatch"

Expected Behavior

Running npm run lint:version-consistency writes logs/action-version-consistency-results.json containing violations, summary counts, and scan metadata in JSON format — consistent with other security scripts like Test-DependencyPinning.ps1 and Test-WorkflowPermissions.ps1.

Root Cause

The npm script in package.json invokes the script with only -FailOnMismatch and does not pass -Format Json -OutputPath.

Files Requiring Changes

File Change
package.json Add -Format Json -OutputPath logs/action-version-consistency-results.json to the lint:version-consistency script

Reproduction Steps

  1. Run npm run lint:version-consistency.
  2. Check logs/ for an action-version-consistency* file — none exists.
  3. Run pwsh -NoProfile -Command "./scripts/security/Test-ActionVersionConsistency.ps1 -FailOnMismatch -Format Json -OutputPath logs/action-version-consistency-results.json" — JSON file is created.

Fix Guidance

Update the npm script in package.json:

"lint:version-consistency": "pwsh -NoProfile -Command \"./scripts/security/Test-ActionVersionConsistency.ps1 -FailOnMismatch -Format Json -OutputPath logs/action-version-consistency-results.json\""

Note: When -Format Json is used, the console output switches to JSON format. If table console output is preferred alongside the JSON file, a separate -JsonLogPath parameter would need to be added to the script (but that is a separate enhancement — for this issue, the JSON file output is the priority).

Unit Testing and Code Coverage Requirements

No new Pester tests required — the script's JSON output is already tested via existing tests for -Format Json -OutputPath. Manual verification: run npm run lint:version-consistency and confirm the JSON file is created.


RPI Framework Starter Prompts

Research Phase

Select Task Researcher from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Research JSON log output for Test-ActionVersionConsistency.ps1. Investigate: (1) The script's existing -Format and -OutputPath parameters — read scripts/security/Test-ActionVersionConsistency.ps1 and find the Export-ConsistencyReport function to understand JSON serialization. (2) How other security scripts pass format/output params via npm scripts — examine lint:dependency-pinning and lint:permissions in package.json. (3) The current npm script and what parameters it passes. (4) Existing Pester test coverage in scripts/tests/security/Test-ActionVersionConsistency.Tests.ps1 for JSON output handling. (5) Whether using -Format Json changes the console output behavior (table vs JSON). (6) The JSON schema produced by Export-ConsistencyReport when -Format Json is used.

Plan Phase

Select Task Planner from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Plan enabling JSON log output for the lint:version-consistency npm script using the research document. The plan should cover: (1) Updating the npm script in package.json to add -Format Json -OutputPath logs/action-version-consistency-results.json. (2) Verifying the JSON file is created with expected schema (violations array, summary, metadata). (3) Confirming existing Pester tests still pass. (4) Validating via npm run lint:version-consistency end-to-end.

Implement Phase

Select Task Implementor from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Implement JSON log output for lint:version-consistency. Steps: (1) Update package.json to add -Format Json -OutputPath logs/action-version-consistency-results.json to the existing command. (2) Run npm run lint:version-consistency and verify logs/action-version-consistency-results.json is created. (3) Inspect the JSON file to confirm it contains violations array, summary counts, and scan metadata. (4) Run npm run test:ps -- -TestPath "scripts/tests/security/" to verify no test regressions.

Review Phase

Select Task Reviewer from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:

Review the lint:version-consistency npm script change. Verify: (1) Only package.json was modified. (2) The -Format Json -OutputPath flags match the pattern used by lint:dependency-pinning and lint:permissions. (3) The JSON output file path follows the logs/-results.json naming convention. (4) The npm command string is properly escaped with PowerShell quoting. (5) Running npm run lint:version-consistency produces the expected JSON file. (6) npm run test:ps passes with no regressions.


References

  • package.jsonlint:version-consistency script
  • scripts/security/Test-ActionVersionConsistency.ps1-Format and -OutputPath params, Export-ConsistencyReport function
  • scripts/security/Test-DependencyPinning.ps1 — reference pattern for security script JSON output via npm
  • scripts/security/Test-WorkflowPermissions.ps1 — reference pattern for security script JSON output via npm

Metadata

Metadata

Labels

good first issueGood for newcomersscriptsPowerShell, Bash, or Python scriptssecuritySecurity-related changes or concerns

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions