-
Notifications
You must be signed in to change notification settings - Fork 662
feat: add --dry-run flag for CLI run command #1421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add --dry-run flag for CLI run command #1421
Conversation
- add --dry-run flag to preview translation tasks without execution - show detailed file analysis: source/target strings, changes breakdown - display summary with total strings to translate - skip authentication and API initialization in dry-run mode - support all existing filter flags (--target-locale, --bucket, --file, --key) this feature allows users to: - preview which files would be translated - see how many strings would be affected - estimate potential costs before running actual translation - verify configuration without making changes
There was a problem hiding this 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 adds a --dry-run flag to the CLI run command, allowing users to preview translation tasks before execution. The implementation intelligently skips authentication, API initialization, and actual translation while providing detailed analysis of what would be translated.
Key Changes:
- Added
--dry-runflag to preview translation operations without execution - Implemented comprehensive file analysis showing source/target string counts and change breakdowns
- Conditionally skip authentication and localization provider initialization in dry-run mode
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/cli/src/cli/cmd/run/_types.ts | Added dryRun boolean flag to the schema with default value false |
| packages/cli/src/cli/cmd/run/index.ts | Added --dry-run option and branching logic to invoke dry-run mode instead of execution/frozen checks |
| packages/cli/src/cli/cmd/run/setup.ts | Modified setup tasks to skip localization provider selection, authentication, validation, and initialization when dryRun flag is enabled |
| packages/cli/src/cli/cmd/run/dry-run.ts | New module implementing dry-run analysis with detailed file-by-file breakdown and summary of translation requirements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // If dry-run mode is enabled, skip execution and show preview | ||
| if (ctx.flags.dryRun) { | ||
| await dryRun(ctx); | ||
| await renderSpacer(); |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch mode (line 178) may not work correctly when combined with --dry-run since ctx.localizer will be null in dry-run mode. The watch mode's triggerRetranslation function calls execute() which requires a valid localizer. Consider adding a check like if (ctx.flags.dryRun && ctx.flags.watch) to either prevent this combination or document the expected behavior.
| } catch (error: any) { | ||
| results.push({ | ||
| task: assignedTask, | ||
| sourceCount: 0, | ||
| targetCount: 0, | ||
| added: 0, | ||
| updated: 0, | ||
| renamed: 0, | ||
| removed: 0, | ||
| toTranslate: 0, | ||
| }); | ||
| } |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors are silently caught and converted to zero-value results, making it difficult to distinguish between a file with no translations and a file that failed to load. Consider logging the error or showing a warning in the output to help users identify configuration or file access issues. For example: console.warn(chalk.yellow(\⚠ Failed to analyze ${assignedTask.bucketPathPattern}: ${error.message}`))`
| const displayPath = result.task.bucketPathPattern.replace( | ||
| "[locale]", | ||
| result.task.targetLocale, | ||
| ); |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable displayPath.
| const displayPath = result.task.bucketPathPattern.replace( | |
| "[locale]", | |
| result.task.targetLocale, | |
| ); |
|
@SouravVerma-art please resolve comments |
|
@SouravVerma-art please go through the comments and resolve them |
|
Hey @SouravVerma-art! Just checking in - are you still working on this PR? We noticed there are some comments that may need addressing. If you need more time, no problem! Just let us know. If we don't hear back within a week, we'll close this to keep the repo tidy, but you can always reopen when ready. |
this feature allows users to: