4.2 KiB
4.2 KiB
Implementation Plan
-
1. Extend environment configuration to support operation mode
- Add OPERATION_MODE environment variable loading and validation in config/environment.js
- Set default operation mode to "update" for backward compatibility
- Validate operation mode is either "update" or "rollback"
- Update .env.example file with new OPERATION_MODE variable
- Requirements: 2.1, 2.2, 9.4, 9.5
-
2. Add rollback price calculation utilities
- Create validateRollbackEligibility function in utils/price.js to check if variant has valid compare-at price
- Create prepareRollbackUpdate function in utils/price.js to prepare rollback price update objects
- Add unit tests for rollback price utility functions
- Requirements: 6.1, 6.2, 6.3, 6.4
-
3. Extend product service with rollback validation methods
- Add validateProductsForRollback method to services/product.js to filter products eligible for rollback
- Implement logic to skip products/variants without compare-at prices
- Add logging for validation warnings when products cannot be rolled back
- Write unit tests for rollback validation methods
- Requirements: 1.7, 6.1, 6.4, 6.5
-
4. Implement core rollback functionality in product service
- Add rollbackVariantPrice method to services/product.js to update individual variant prices
- Implement rollbackProductPrices method to orchestrate batch rollback operations
- Add processProductForRollback method to handle individual product rollback processing
- Use existing GraphQL mutation infrastructure for price updates
- Requirements: 1.4, 1.5, 1.6, 5.1, 5.2, 5.3
-
5. Extend logging utilities for rollback operations
- Add logRollbackStart method to utils/logger.js to log rollback operation initialization
- Add logRollbackUpdate method to utils/logger.js to log successful rollback operations
- Add logRollbackSummary method to utils/logger.js for rollback completion summaries
- Ensure rollback logs are distinguished from price update logs in Progress.md
- Requirements: 3.1, 3.3, 3.5, 7.1, 7.2, 7.3, 8.3
-
6. Implement rollback workflow in main application
- Add operation mode detection logic to src/index.js based on configuration
- Create fetchAndValidateProductsForRollback method in main application class
- Create rollbackPrices method to execute rollback operations
- Create displayRollbackSummary method for rollback-specific result display
- Requirements: 8.1, 8.2, 8.4, 8.5, 9.1, 9.2, 9.3
-
7. Integrate dual operation mode routing
- Modify main application run method to route between update and rollback workflows
- Ensure both operation modes use the same error handling and infrastructure
- Maintain backward compatibility when operation mode is not specified
- Add operation mode indication in console output and logging
- Requirements: 9.1, 9.2, 9.3, 9.4, 9.5
-
8. Add comprehensive error handling for rollback operations
- Implement graceful handling of products without compare-at prices
- Add retry logic for rollback API operations using existing patterns
- Ensure rollback errors are properly logged and don't stop processing of other products
- Add rollback-specific error analysis in completion summaries
- Requirements: 4.1, 4.2, 4.3, 4.4, 4.5
-
9. Update package.json scripts for rollback mode
- Add npm script for running rollback operations
- Update existing scripts to maintain backward compatibility
- Add script documentation for both operation modes
- Requirements: 8.1, 8.2
-
10. Create comprehensive tests for rollback functionality
- Write unit tests for all new rollback utility functions
- Write integration tests for rollback product service methods
- Write end-to-end tests for complete rollback workflow
- Test dual operation mode functionality and backward compatibility
- Requirements: All requirements - comprehensive testing coverage
-
11. Update documentation and examples
- Update .env.example with OPERATION_MODE variable and usage examples
- Add rollback operation examples and usage instructions
- Update any existing documentation to reflect dual operation mode capability
- Requirements: 2.1, 8.4, 9.4