runFixCommand runs the fix command on specified or all workflows
(workflowIDs []string, write bool, verbose bool, workflowDir string, disabledCodemodIDs []string)
| 113 | |
| 114 | // runFixCommand runs the fix command on specified or all workflows |
| 115 | func runFixCommand(workflowIDs []string, write bool, verbose bool, workflowDir string, disabledCodemodIDs []string) error { |
| 116 | fixLog.Printf("Running fix command: workflowIDs=%v, write=%v, verbose=%v, workflowDir=%s, disabledCodemodIDs=%v", workflowIDs, write, verbose, workflowDir, disabledCodemodIDs) |
| 117 | |
| 118 | // Set up workflow directory (using default if not specified) |
| 119 | if workflowDir == "" { |
| 120 | workflowDir = constants.GetWorkflowDir() |
| 121 | fixLog.Printf("Using default workflow directory: %s", workflowDir) |
| 122 | } else { |
| 123 | workflowDir = filepath.Clean(workflowDir) |
| 124 | fixLog.Printf("Using custom workflow directory: %s", workflowDir) |
| 125 | } |
| 126 | |
| 127 | // Get workflow files to process |
| 128 | var files []string |
| 129 | var err error |
| 130 | |
| 131 | if len(workflowIDs) > 0 { |
| 132 | // Process specific workflows |
| 133 | for _, workflowID := range workflowIDs { |
| 134 | file, err := resolveWorkflowFileInDir(workflowID, verbose, workflowDir) |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | files = append(files, file) |
| 139 | } |
| 140 | } else { |
| 141 | // Process all workflows in the workflow directory |
| 142 | files, err = getMarkdownWorkflowFiles(workflowDir) |
| 143 | if err != nil { |
| 144 | return err |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if len(files) == 0 { |
| 149 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No workflow files found.")) |
| 150 | return nil |
| 151 | } |
| 152 | |
| 153 | // Load all codemods |
| 154 | codemods, err := GetCodemods(disabledCodemodIDs) |
| 155 | if err != nil { |
| 156 | return err |
| 157 | } |
| 158 | fixLog.Printf("Loaded %d codemods", len(codemods)) |
| 159 | |
| 160 | // Process each file |
| 161 | var totalFixed int |
| 162 | var totalFiles int |
| 163 | var workflowsNeedingFixes []workflowFixInfo |
| 164 | |
| 165 | for _, file := range files { |
| 166 | fixLog.Printf("Processing file: %s", file) |
| 167 | |
| 168 | fixed, appliedFixes, err := processWorkflowFileWithInfo(file, codemods, write, verbose) |
| 169 | if err != nil { |
| 170 | fmt.Fprintf(os.Stderr, "%s\n", console.FormatErrorMessage(fmt.Sprintf("Error processing %s: %v", filepath.Base(file), err))) |
| 171 | continue |
| 172 | } |
no test coverage detected