@@ -94,8 +94,24 @@ func processDependent(ctx context.Context, dependentName string, dependent workf
94
94
95
95
logger .Printf ("Location %s does not exist for dependent %s" , location , dependentName )
96
96
97
- // Ask user if they want to clone the repository
98
- if ! interactivity .SimpleConfirm ("Would you like to clone the repository?" , true ) {
97
+ // Ask user if they want to clone the repository to the specified location
98
+ prompt := fmt .Sprintf ("Would you like to clone the repository to %s?" , location )
99
+ if ! interactivity .SimpleConfirm (prompt , true ) {
100
+ logger .Printf ("\n 🚫 Repository clone declined." )
101
+ logger .Printf ("💡 You can override the dependent location by creating a local workflow configuration file." )
102
+
103
+ // Ask if they want to create workflow.local.yaml for local overrides
104
+ localWorkflowPath := filepath .Join (projectDir , ".speakeasy" , "workflow.local.yaml" )
105
+ prompt := fmt .Sprintf ("Would you like to create %s to customize dependent locations?" , localWorkflowPath )
106
+ if interactivity .SimpleConfirm (prompt , true ) {
107
+ if err := CreateWorkflowLocalFile (projectDir ); err != nil {
108
+ logger .Printf ("❌ Failed to create workflow.local.yaml: %v" , err )
109
+ } else {
110
+ logger .Printf ("✅ Created %s" , localWorkflowPath )
111
+ logger .Printf ("📝 You can now uncomment and modify the dependents section to set custom locations." )
112
+ }
113
+ }
114
+
99
115
return fmt .Errorf ("location %s does not exist and user declined to clone" , location )
100
116
}
101
117
@@ -174,3 +190,59 @@ func runSpeakeasyFromLocation(ctx context.Context, location, command, flagsStrin
174
190
175
191
return cmd .Run ()
176
192
}
193
+
194
+ func CreateWorkflowLocalFile (workflowDir string ) error {
195
+ workflowPath := filepath .Join (workflowDir , ".speakeasy" , "workflow.yaml" )
196
+ localWorkflowPath := filepath .Join (workflowDir , ".speakeasy" , "workflow.local.yaml" )
197
+
198
+ if _ , err := os .Stat (workflowPath ); os .IsNotExist (err ) {
199
+ return fmt .Errorf ("workflow.yaml file not found at %s" , workflowPath )
200
+ }
201
+
202
+ if _ , err := os .Stat (localWorkflowPath ); err == nil {
203
+ return fmt .Errorf ("workflow.local.yaml already exists at %s" , localWorkflowPath )
204
+ }
205
+
206
+ workflowContent , err := os .ReadFile (workflowPath )
207
+ if err != nil {
208
+ return fmt .Errorf ("failed to read workflow.yaml: %w" , err )
209
+ }
210
+
211
+ commentedContent := commentOutYAMLContent (string (workflowContent ))
212
+
213
+ instructions := `# Local Workflow Configuration Override File
214
+ #
215
+ # This file allows you to override any field from workflow.yaml for local development.
216
+ # Uncomment and modify any section below to override the corresponding values.
217
+ #
218
+ # Only uncomment the specific fields (and their parent keys) that you want to override - you don't need to
219
+ # uncomment entire sections if you only want to change one value.
220
+ #
221
+ # Example: To override just the speakeasyVersion, uncomment only that line:
222
+ # speakeasyVersion: "1.234.0"
223
+
224
+ `
225
+
226
+ finalContent := instructions + commentedContent
227
+
228
+ if err := os .WriteFile (localWorkflowPath , []byte (finalContent ), 0644 ); err != nil {
229
+ return fmt .Errorf ("failed to write workflow.local.yaml: %w" , err )
230
+ }
231
+
232
+ return nil
233
+ }
234
+
235
+ func commentOutYAMLContent (content string ) string {
236
+ lines := strings .Split (content , "\n " )
237
+ var commentedLines []string
238
+
239
+ for _ , line := range lines {
240
+ if strings .TrimSpace (line ) == "" {
241
+ commentedLines = append (commentedLines , line )
242
+ } else {
243
+ commentedLines = append (commentedLines , "# " + line )
244
+ }
245
+ }
246
+
247
+ return strings .Join (commentedLines , "\n " )
248
+ }
0 commit comments