Skip to content

Conversation

yuya-takeyama
Copy link
Owner

@yuya-takeyama yuya-takeyama commented Aug 3, 2025

Summary

  • Added --result-json-file option to output sync results as JSON
  • Distinguish between create and update actions based on file reason
  • Support for both dry-run and actual execution modes

Motivation

Closes #2

This feature enables CI/CD pipelines to programmatically determine which files have changed during sync operations. The JSON output can be used to:

  • Trigger CloudFront cache invalidation for changed files only
  • Generate deployment reports
  • Make automated deployment decisions

Changes

  1. New CLI option: --result-json-file <path>
  2. JSON output structure:
    • changes: Array of file change details
    • summary: Statistics (created, updated, deleted, failed)
  3. Action types: Properly distinguish between create and update based on the sync reason

JSON Output Format

Create/Update Operations

{
  "action": "create",
  "source": "/path/to/local/file.txt",
  "target": "s3://bucket/prefix/file.txt"
}

Delete Operations

{
  "action": "delete",
  "target": "s3://bucket/prefix/file.txt"
}

Complete Example

{
  "changes": [
    {
      "action": "create",
      "source": "/Users/yuya/project/file1.txt",
      "target": "s3://my-bucket/prefix/file1.txt"
    },
    {
      "action": "update",
      "source": "/Users/yuya/project/file2.txt",
      "target": "s3://my-bucket/prefix/file2.txt"
    },
    {
      "action": "delete",
      "target": "s3://my-bucket/prefix/old-file.txt"
    }
  ],
  "summary": {
    "total_files": 3,
    "created": 1,
    "updated": 1,
    "deleted": 1,
    "failed": 0
  }
}

Breaking Changes

⚠️ This PR includes breaking changes to the JSON output format:

  1. Changed from from/to to source/target pattern
  2. Delete operations now only have target field (no source)
  3. Removed unused skip field from summary

This structure provides clearer semantics and enables future extensibility for S3-to-local and S3-to-S3 sync operations.

Test Plan

  • Test dry-run mode with JSON output
  • Test actual sync with JSON output
  • Verify create vs update distinction
  • Test with various sync scenarios (create, update, delete)
  • Verify JSON file is created with proper permissions (0644)
  • Test error handling and failed operations in JSON output

🤖 Generated with Claude Code

- Added new CLI flag to output sync results to a JSON file
- Structured output includes file changes and summary statistics
- Distinguish between create and update actions based on file reason
- Support for both dry-run and actual execution modes
- Useful for CI/CD pipelines to determine changed files

Closes #2
- Removed skip field from Summary struct
- Removed ActionSkip handling in both dry-run and execution modes
- Updated README to reflect that only create, update, and delete actions are supported
- Skip action was never actually used since planner only returns items that need action
…ibility

BREAKING CHANGE: JSON output structure has changed
- Replaced path, local_path, s3_key, bucket fields with from and to
- from: absolute source path (e.g., /path/to/file or s3://bucket/key)
- to: absolute destination path (empty string for deletions)
- This enables consistent output for future S3-to-local and S3-to-S3 operations
BREAKING CHANGE: JSON output structure has changed again
- Replaced from/to with source/target pattern
- create/update: source (local path) and target (S3 path)
- delete: only target (S3 path to delete), no source field
- This provides clearer semantics for each action type
@yuya-takeyama yuya-takeyama marked this pull request as ready for review August 3, 2025 14:14
@yuya-takeyama yuya-takeyama merged commit 2d12640 into main Aug 3, 2025
1 check passed
@yuya-takeyama yuya-takeyama deleted the yuya-takeyama/feat/result-json-file branch August 3, 2025 14:14
@yuya-takeyama-tagpr yuya-takeyama-tagpr bot mentioned this pull request Aug 3, 2025
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.

Feature: Add --result-json-file option for programmatic result processing
1 participant