Skip to content

refactor: enhance locale extraction process with async handling and i…#1013

Merged
umeshmore45 merged 8 commits intodevfrom
feat/sitecore-locales-env
Mar 31, 2026
Merged

refactor: enhance locale extraction process with async handling and i…#1013
umeshmore45 merged 8 commits intodevfrom
feat/sitecore-locales-env

Conversation

@umeshmore45
Copy link
Copy Markdown
Contributor

…mproved error logging

  • Replaced synchronous file reading with asynchronous methods for better performance.
  • Introduced concurrency control to optimize the processing of multiple files.
  • Added regex matching for language extraction and improved directory skipping logic.
  • Enhanced logging for progress tracking and error handling during file operations.

…mproved error logging

- Replaced synchronous file reading with asynchronous methods for better performance.
- Introduced concurrency control to optimize the processing of multiple files.
- Added regex matching for language extraction and improved directory skipping logic.
- Enhanced logging for progress tracking and error handling during file operations.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors extractLocales in the Sitecore migration library to use asynchronous filesystem APIs, add bounded concurrency for file processing, and improve logging while extracting locale values from data.json exports.

Changes:

  • Replaced sync directory/file IO with async (fs.promises) and introduced a 3-phase pipeline (collect paths → extract → process concurrently).
  • Added a fast-path regex-based locale extraction by reading only the first 128 KiB of each data.json, with a JSON-parse fallback.
  • Expanded directory skipping and added progress/error logging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Updated regex patterns to improve the efficiency of language extraction from metadata blocks.
- Introduced a fast-path strategy to locate the language key within a limited slice of the JSON structure, enhancing performance.
- Maintained fallback to full JSON parsing for compatibility with various file formats.
…es.js

- Added checks for null or invalid directory and file path inputs to prevent runtime errors.
- Enhanced logging for invalid inputs to aid in debugging.
- Ensured that the locale extraction process gracefully handles empty or non-array paths.
…es.js

- Improved error logging to provide more informative messages when reading directories and files.
- Added optional chaining to safely access properties of directory entries.
- Introduced a limit variable for concurrency control to ensure robust processing of file paths.
vikrantraut
vikrantraut previously approved these changes Mar 27, 2026
…ocales.js

- Updated input validation to use optional chaining for safer property access.
- Improved handling of potential null or empty directory and file path scenarios.
- Ensured robust processing by checking the length of paths with optional chaining.
…ocales.js

- Updated input validation to use optional chaining for safer property access.
- Improved handling of potential null or empty directory and file path scenarios.
- Ensured robust processing by checking the length of paths with optional chaining.
@umeshmore45 umeshmore45 merged commit 80f8ece into dev Mar 31, 2026
9 checks passed
@umeshmore45 umeshmore45 deleted the feat/sitecore-locales-env branch March 31, 2026 12:51
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.

5 participants