Skip to content

refactor(cli): Convert sync to pull/push subcommands#9

Merged
tarasyarema merged 4 commits intomainfrom
sync-export-refactor
Feb 4, 2026
Merged

refactor(cli): Convert sync to pull/push subcommands#9
tarasyarema merged 4 commits intomainfrom
sync-export-refactor

Conversation

@desplega-bot
Copy link
Contributor

Summary

  • Replace sync --pull/--push flags with sync pull and sync push subcommands for clearer CLI semantics
  • Add --id option to pull/push single tests by UUID
  • Add --app-config-id option to filter tests during pull by app configuration
  • Require --all or --id for push operations to prevent accidental bulk uploads
  • Add deprecation warning to export command, recommending sync pull --id instead
  • Update API client to support app_config_id parameter in listTests()

Migration Guide

Old Command New Command
qa-use test sync qa-use test sync pull
qa-use test sync --pull qa-use test sync pull
qa-use test sync --push qa-use test sync push --all
qa-use test export <id> qa-use test sync pull --id <id>

Test plan

  • sync pull pulls all tests
  • sync pull --id <uuid> pulls a single test
  • sync pull --app-config-id <id> filters tests by app config
  • sync push without --id or --all shows error message
  • sync push --all pushes all tests
  • sync push --id <uuid> pushes a single test
  • export command shows deprecation warning

Breaking changes

The sync command now uses subcommands instead of flags. Users need to update their scripts to use the new syntax.


Generated with Claude Code

- Replace `sync --pull`/`--push` flags with `sync pull` and `sync push` subcommands
- Add `--id` option to pull/push single tests
- Add `--app-config-id` option to filter tests by app config during pull
- Require `--all` or `--id` for push to prevent accidental bulk operations
- Add deprecation warning to `export` command (use `sync pull --id` instead)
- Update API client to support app_config_id parameter in listTests()

BREAKING CHANGE: The sync command now uses subcommands instead of flags.
  - `qa-use test sync` or `sync --pull` → `qa-use test sync pull`
  - `qa-use test sync --push` → `qa-use test sync push --all`

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qa-use-mcp Ready Ready Preview, Comment Feb 4, 2026 11:51am

Request Review

Copy link
Contributor

@tarasyarema tarasyarema left a comment

Choose a reason for hiding this comment

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

Plz add unit tests for the changes

Add comprehensive tests for the new sync pull/push subcommand structure:
- Test command structure (pull and push subcommands exist)
- Test all options for pull: --id, --app-config-id, --dry-run, --force
- Test all options for push: --id, --all, --dry-run, --force
- Test option parsing (required arguments vs boolean flags)
- Test subcommand hierarchy (sync -> pull/push)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tarasyarema
Copy link
Contributor

@desplega-bot did you check my comment above, and make sure CI passes...

Remove unused `mock` and `spyOn` imports to fix linter error.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@desplega-bot
Copy link
Contributor Author

@tarasyarema Yes! I reviewed your comment requesting unit tests, and unit tests were added in a previous commit.

The CI was failing due to a linting error - unused imports (mock, spyOn) in sync.test.ts. I've just pushed a fix (commit 6543601) that removes the unused imports.

The unit tests for the sync command changes are comprehensive:

  • 31 tests covering command structure, options, and the updateLocalVersionHash function
  • All lint and unit tests pass locally

CI should be green on the next run.

@tarasyarema
Copy link
Contributor

@desplega-bot I think you did not push the refactor #9 (comment) right?

Create a reusable toSafeFilename utility in src/utils/strings.ts
that converts test names to safe filename slugs by:
- Lowercasing the string
- Replacing non-alphanumeric characters with hyphens
- Removing leading/trailing hyphens

Update all 4 locations that had this duplicated pattern:
- sync.ts dry-run preview
- sync.ts pullFromCloud function
- sync.ts writeTestsFromContent function
- export.ts test export loop

Add unit tests for the new utility function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@desplega-bot
Copy link
Contributor Author

Apologies for the oversight! I've now pushed the refactor commit (c70c49c) that extracts the toSafeFilename utility function to src/utils/strings.ts and updates all 4 locations that had the duplicated pattern. I've also added unit tests for the new utility.

Copy link
Contributor

@tarasyarema tarasyarema left a comment

Choose a reason for hiding this comment

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

Nice, can you also check if there are other places where the same heuristic was used, and change it?

@desplega-bot
Copy link
Contributor Author

@tarasyarema I've done a comprehensive search of the entire codebase for any other occurrences of the same heuristic pattern.

Pattern searched:

.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, '')

Results:
The PR has already addressed all locations where this heuristic was used. The only remaining occurrence of the pattern is in the new toSafeFilename utility function itself (src/utils/strings.ts:10-11), which is the correct centralized location.

Files updated in this PR:

  1. src/cli/commands/test/sync.ts - 3 locations (dry-run preview, pullFromCloud, writeTestsFromContent)
  2. src/cli/commands/test/export.ts - 1 location (test export loop)

Additional verification:

  • Searched for toLowerCase().*replace combinations - no other matches
  • Searched for safeName, safeFilename, slug patterns - all now use toSafeFilename
  • Searched for unnamed-test fallback - only in the new utility
  • Checked lib/ directory - no similar patterns found

No other places in the codebase use this heuristic pattern. The refactor is complete!

@tarasyarema tarasyarema merged commit 0ad24b3 into main Feb 4, 2026
4 checks passed
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.

2 participants