Skip to content

refactor(cli): clean up spinners, branch lookup, file command and large conditionals - #1158

Merged
andrii-bodnar merged 17 commits into
mainfrom
code-refactoring
Oct 30, 2026
Merged

andrii-bodnar merged 17 commits into
mainfrom
code-refactoring

Conversation

@bhdnb

@bhdnb bhdnb commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Refactoring pass over src-next, plus the fixes it surfaced.

Changes

  • Spinners: spinner-wrapped operations in init, login, browser auth, branch clone/merge, distribution release and bundle build now use withSpinner. A failure prints one spinner line with the full error instead of a generic line followed by the error.
  • Branch lookup: status, auto-translate and file resolve --branch through BranchService, and the private normalizeBranch copies are removed.
  • Download: the download sources --reviewed path is extracted into its own methods.
  • Auto-translate: the --file / --directory lookups are extracted into methods.
  • File command:
    • the repeated project-file lookup is pulled into findProjectFile
    • the existing-file update on upload moves into updateExistingFile
    • the string-based and manager-access checks run once for source and translation download
    • upload helpers no longer pass Bun.file around
  • Service signatures: FileService.updateProjectFile and TranslationService.importProjectTranslation(StringsBased) take their optional request fields as an object (ProjectFileUpdate, ImportTranslationOptions) instead of long runs of positional undefineds. The import progress callback stays a separate parameter, as in importXliffTranslation.
  • Shared helpers:
    • changedFileSettings decides which context/excluded languages a file update sends, shared by file upload and upload sources
    • isStringsBasedProject and FILE_MANAGEMENT_UNAVAILABLE replace 12 copies of the project-type check and 5 copies of the message
    • sameLanguageSet moves to lib/utils/array.ts as sameItems
    • getCommonPath moves to lib/utils/path.ts
    • resolveContextPath is removed, since it only forwarded to replaceFileDependentPlaceholders
    • leading-slash ternaries use toProjectPath
  • String command: StringService.isStringsBasedProject is removed; string loads the project through ProjectService like the other commands.
  • Types:
    • fixed the tsc errors from nullable API client fields
    • Awaited<ReturnType<GetXService>> / ReturnType<GetOutput> in signatures are replaced with the service classes and Output

User-visible fixes

  • --branch feature/x now works in status, auto-translate and file. Crowdin stores the branch as feature.x, which the old lookups didn't match. In file:
    • list showed branch-prefixed paths
    • upload tried to create a duplicate instead of updating
    • download, delete and translation upload/download reported the file as missing
  • --engine-id and --ai-prompt reject non-integer values such as abc or 1.5 as usage errors (exit 2). Before, they were silently dropped or sent to the API.
  • file upload --parser-version rejects non-numeric values such as 2x instead of parseInt silently reading them as 2.
  • Browser authorization now shows the "port in use" and "timed out" hints. Before, they were hidden behind "Brow
  • A missing branch in status and auto-translate now reports the shared `Project doesn't contain the ''
  • string list, add and edit --verbose show the "Fetching project info" spinner in text output, like the other commands.

Testing

  • E2E: the string snapshots are updated for the project spinner.

@bhdnb bhdnb self-assigned this Oct 27, 2026
@bhdnb bhdnb added the bug label Oct 27, 2026
@bhdnb
bhdnb marked this pull request as draft October 27, 2026 19:23
@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.21429% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.14%. Comparing base (cb2d12d) to head (8c45576).

Files with missing lines Patch % Lines
src-next/cli/commands/login/LoginCommand.ts 18.19% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1158      +/-   ##
==========================================
+ Coverage   93.71%   94.14%   +0.44%     
==========================================
  Files         159      161       +2     
  Lines       13104    13079      -25     
==========================================
+ Hits        12279    12312      +33     
+ Misses        825      767      -58     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bhdnb bhdnb changed the title refactor(cli): clean up spinners, branch lookup and large conditionals refactor(cli): clean up spinners, branch lookup, file command and large conditionals Oct 28, 2026
@bhdnb
bhdnb marked this pull request as ready for review October 29, 2026 15:49
@bhdnb
bhdnb requested a review from andrii-bodnar October 29, 2026 15:49
@andrii-bodnar
andrii-bodnar merged commit 3c85a44 into main Oct 30, 2026
13 checks passed
@andrii-bodnar
andrii-bodnar deleted the code-refactoring branch October 30, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants