Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions cmd/commands/mockery/mockery.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ import (
)

var (
jobsNum int
dry bool
gitMod bool
dry bool
gitMod bool
)

var mockeryCmd = &cobra.Command{
Use: "mockery [config-files...]",
Short: "Run mockery with base and package-specific configurations",
Long: `Run mockery by merging .mockery.base.yml with .mockery.pkg.yml files.
Long: `Run mockery by merging all .mockery.pkg.yml files into a single invocation.

This command will:
1. Load base configuration from .mockery.base.yml
2. Search for all .mockery.pkg.yml files (or use provided list)
3. Merge base config with package config (package takes precedence)
4. Generate temporary config files and execute mockery concurrently
5. Report failures without stopping execution
6. Clean up temporary files and exit with code 1 if any failed
3. Merge all package configs into a single unified config
4. Execute mockery once for all packages
5. Clean up temporary files and exit with code 1 if failed

Examples:
# Run mockery for all .mockery.pkg.yml files found in project
Expand All @@ -34,9 +32,6 @@ Examples:
# Run mockery for specific package config files
draft mockery services/user/.mockery.pkg.yml services/auth/.mockery.pkg.yml

# Run with custom concurrent job limit (default: 5)
draft mockery --jobs-num 5

# Dry run - validate configs without executing mockery
draft mockery --dry

Expand All @@ -46,15 +41,14 @@ Examples:
}

func init() {
mockeryCmd.Flags().IntVarP(&jobsNum, "jobs-num", "j", 5, "Number of concurrent mockery jobs to run")
mockeryCmd.Flags().BoolVar(&dry, "dry", false, "Dry run - validate and prepare configs without executing mockery")
mockeryCmd.Flags().BoolVar(&gitMod, "git-mod", false, "Only run mockery for packages with modified files (compares HEAD with main branch)")
}

func run(cmd *cobra.Command, args []string) {
common.ChDir(cmd)

if err := mockery.New(cmd.Context(), args, jobsNum, dry, gitMod).Exec(); err != nil {
if err := mockery.New(cmd.Context(), args, dry, gitMod).Exec(); err != nil {
log.Exitf(1, "Failed to run mockery: %v", err)
}

Expand Down
Loading