@aspruyt/xfg 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +1 -2
  2. package/dist/cli/index.d.ts +1 -2
  3. package/dist/cli/index.js +0 -1
  4. package/dist/cli/program.js +7 -2
  5. package/dist/cli/{settings/results-collector.d.ts → results-collector.d.ts} +1 -1
  6. package/dist/cli/{settings/results-collector.js → results-collector.js} +2 -1
  7. package/dist/cli/settings-report-builder.d.ts +1 -3
  8. package/dist/cli/sync-command.d.ts +2 -24
  9. package/dist/cli/sync-command.js +295 -301
  10. package/dist/cli/types.d.ts +60 -40
  11. package/dist/cli/types.js +1 -12
  12. package/dist/config/errors.d.ts +9 -0
  13. package/dist/config/errors.js +11 -0
  14. package/dist/config/file-reference-resolver.d.ts +2 -1
  15. package/dist/config/file-reference-resolver.js +10 -8
  16. package/dist/config/formatter.d.ts +3 -2
  17. package/dist/config/index.d.ts +4 -6
  18. package/dist/config/index.js +4 -8
  19. package/dist/config/loader.js +4 -2
  20. package/dist/config/merge.d.ts +0 -9
  21. package/dist/config/merge.js +2 -7
  22. package/dist/config/normalizer.d.ts +4 -0
  23. package/dist/config/normalizer.js +61 -110
  24. package/dist/config/types.d.ts +15 -19
  25. package/dist/config/types.js +1 -1
  26. package/dist/config/validator.d.ts +0 -4
  27. package/dist/config/validator.js +286 -363
  28. package/dist/config/validators/file-validator.d.ts +2 -8
  29. package/dist/config/validators/file-validator.js +6 -17
  30. package/dist/config/validators/index.d.ts +3 -3
  31. package/dist/config/validators/index.js +3 -3
  32. package/dist/config/validators/repo-settings-validator.d.ts +0 -6
  33. package/dist/config/validators/repo-settings-validator.js +9 -9
  34. package/dist/config/validators/ruleset-validator.d.ts +0 -14
  35. package/dist/config/validators/ruleset-validator.js +28 -28
  36. package/dist/lifecycle/ado-migration-source.js +2 -1
  37. package/dist/lifecycle/github-lifecycle-provider.d.ts +6 -5
  38. package/dist/lifecycle/github-lifecycle-provider.js +79 -90
  39. package/dist/lifecycle/index.d.ts +2 -6
  40. package/dist/lifecycle/index.js +0 -4
  41. package/dist/lifecycle/lifecycle-formatter.d.ts +2 -1
  42. package/dist/lifecycle/lifecycle-formatter.js +4 -0
  43. package/dist/lifecycle/lifecycle-helpers.d.ts +3 -2
  44. package/dist/lifecycle/repo-lifecycle-manager.js +4 -11
  45. package/dist/lifecycle/types.d.ts +0 -8
  46. package/dist/output/github-summary.d.ts +5 -0
  47. package/dist/output/github-summary.js +9 -2
  48. package/dist/output/index.d.ts +2 -2
  49. package/dist/output/index.js +1 -1
  50. package/dist/output/lifecycle-report.js +5 -23
  51. package/dist/output/settings-report.d.ts +14 -3
  52. package/dist/output/settings-report.js +137 -197
  53. package/dist/output/summary-utils.d.ts +1 -1
  54. package/dist/output/summary-utils.js +2 -1
  55. package/dist/output/sync-report.js +5 -8
  56. package/dist/output/unified-summary.d.ts +2 -1
  57. package/dist/output/unified-summary.js +71 -133
  58. package/dist/settings/base-processor.d.ts +67 -0
  59. package/dist/settings/base-processor.js +91 -0
  60. package/dist/settings/index.d.ts +4 -3
  61. package/dist/settings/index.js +3 -3
  62. package/dist/settings/labels/converter.d.ts +2 -1
  63. package/dist/settings/labels/github-labels-strategy.d.ts +9 -18
  64. package/dist/settings/labels/github-labels-strategy.js +17 -73
  65. package/dist/settings/labels/index.d.ts +2 -6
  66. package/dist/settings/labels/index.js +1 -9
  67. package/dist/settings/labels/processor.d.ts +6 -30
  68. package/dist/settings/labels/processor.js +62 -152
  69. package/dist/settings/labels/types.d.ts +5 -8
  70. package/dist/settings/repo-settings/formatter.d.ts +2 -2
  71. package/dist/settings/repo-settings/formatter.js +6 -6
  72. package/dist/settings/repo-settings/github-repo-settings-strategy.d.ts +11 -12
  73. package/dist/settings/repo-settings/github-repo-settings-strategy.js +32 -79
  74. package/dist/settings/repo-settings/index.d.ts +2 -5
  75. package/dist/settings/repo-settings/index.js +1 -9
  76. package/dist/settings/repo-settings/processor.d.ts +6 -27
  77. package/dist/settings/repo-settings/processor.js +51 -104
  78. package/dist/settings/repo-settings/types.d.ts +7 -9
  79. package/dist/settings/rulesets/diff-algorithm.d.ts +0 -4
  80. package/dist/settings/rulesets/diff-algorithm.js +1 -10
  81. package/dist/settings/rulesets/diff.d.ts +1 -1
  82. package/dist/settings/rulesets/diff.js +2 -21
  83. package/dist/settings/rulesets/formatter.d.ts +1 -3
  84. package/dist/settings/rulesets/formatter.js +1 -8
  85. package/dist/settings/rulesets/github-ruleset-strategy.d.ts +11 -51
  86. package/dist/settings/rulesets/github-ruleset-strategy.js +24 -85
  87. package/dist/settings/rulesets/index.d.ts +3 -6
  88. package/dist/settings/rulesets/index.js +5 -9
  89. package/dist/settings/rulesets/processor.d.ts +8 -33
  90. package/dist/settings/rulesets/processor.js +58 -151
  91. package/dist/settings/rulesets/types.d.ts +35 -6
  92. package/dist/shared/command-executor.d.ts +2 -22
  93. package/dist/shared/command-executor.js +8 -7
  94. package/dist/shared/env.d.ts +0 -8
  95. package/dist/shared/env.js +14 -70
  96. package/dist/shared/file-status.d.ts +2 -0
  97. package/dist/shared/file-status.js +13 -0
  98. package/dist/shared/gh-api-utils.d.ts +46 -0
  99. package/dist/shared/gh-api-utils.js +107 -0
  100. package/dist/shared/index.d.ts +5 -5
  101. package/dist/shared/index.js +3 -3
  102. package/dist/shared/interpolation-engine.d.ts +31 -0
  103. package/dist/shared/interpolation-engine.js +50 -0
  104. package/dist/shared/logger.d.ts +3 -7
  105. package/dist/shared/logger.js +4 -1
  106. package/dist/shared/repo-detector.d.ts +17 -2
  107. package/dist/shared/repo-detector.js +27 -0
  108. package/dist/shared/retry-utils.d.ts +9 -17
  109. package/dist/shared/retry-utils.js +22 -28
  110. package/dist/shared/sanitize-utils.d.ts +0 -7
  111. package/dist/shared/sanitize-utils.js +0 -7
  112. package/dist/shared/shell-utils.d.ts +1 -0
  113. package/dist/shared/shell-utils.js +3 -0
  114. package/dist/shared/string-utils.d.ts +4 -0
  115. package/dist/shared/string-utils.js +6 -0
  116. package/dist/shared/type-guards.d.ts +17 -0
  117. package/dist/shared/type-guards.js +26 -0
  118. package/dist/shared/workspace-utils.d.ts +0 -4
  119. package/dist/shared/workspace-utils.js +0 -4
  120. package/dist/{sync → shared}/xfg-template.d.ts +3 -2
  121. package/dist/{sync → shared}/xfg-template.js +13 -54
  122. package/dist/sync/auth-options-builder.d.ts +4 -5
  123. package/dist/sync/auth-options-builder.js +15 -26
  124. package/dist/sync/branch-manager.d.ts +5 -0
  125. package/dist/sync/branch-manager.js +12 -10
  126. package/dist/sync/commit-push-manager.d.ts +1 -1
  127. package/dist/sync/commit-push-manager.js +22 -18
  128. package/dist/sync/diff-utils.d.ts +4 -9
  129. package/dist/sync/diff-utils.js +2 -19
  130. package/dist/sync/file-sync-orchestrator.js +9 -8
  131. package/dist/sync/file-writer.d.ts +2 -1
  132. package/dist/sync/file-writer.js +3 -6
  133. package/dist/sync/index.d.ts +2 -15
  134. package/dist/sync/index.js +0 -19
  135. package/dist/sync/manifest-manager.d.ts +4 -0
  136. package/dist/sync/manifest-manager.js +5 -1
  137. package/dist/sync/manifest.d.ts +10 -41
  138. package/dist/sync/manifest.js +11 -56
  139. package/dist/sync/pr-merge-handler.d.ts +2 -6
  140. package/dist/sync/pr-merge-handler.js +6 -3
  141. package/dist/sync/repository-processor.d.ts +1 -2
  142. package/dist/sync/repository-processor.js +20 -12
  143. package/dist/sync/repository-session.js +5 -14
  144. package/dist/sync/sync-workflow.js +31 -38
  145. package/dist/sync/types.d.ts +43 -178
  146. package/dist/vcs/authenticated-git-ops.d.ts +27 -70
  147. package/dist/vcs/authenticated-git-ops.js +70 -96
  148. package/dist/vcs/azure-pr-strategy.d.ts +6 -4
  149. package/dist/vcs/azure-pr-strategy.js +34 -82
  150. package/dist/vcs/branch-utils.d.ts +6 -0
  151. package/dist/vcs/branch-utils.js +29 -0
  152. package/dist/vcs/commit-strategy-selector.d.ts +5 -0
  153. package/dist/vcs/commit-strategy-selector.js +10 -0
  154. package/dist/vcs/git-commit-strategy.js +1 -2
  155. package/dist/vcs/git-ops.d.ts +15 -59
  156. package/dist/vcs/git-ops.js +46 -110
  157. package/dist/vcs/github-app-token-manager.d.ts +0 -6
  158. package/dist/vcs/github-app-token-manager.js +5 -12
  159. package/dist/vcs/github-pr-strategy.d.ts +5 -5
  160. package/dist/vcs/github-pr-strategy.js +44 -122
  161. package/dist/vcs/gitlab-pr-strategy.d.ts +6 -4
  162. package/dist/vcs/gitlab-pr-strategy.js +39 -87
  163. package/dist/vcs/graphql-commit-strategy.d.ts +3 -4
  164. package/dist/vcs/graphql-commit-strategy.js +31 -63
  165. package/dist/vcs/index.d.ts +3 -16
  166. package/dist/vcs/index.js +2 -33
  167. package/dist/vcs/pr-creator.d.ts +9 -9
  168. package/dist/vcs/pr-creator.js +11 -10
  169. package/dist/vcs/pr-strategy-factory.d.ts +5 -0
  170. package/dist/vcs/pr-strategy-factory.js +17 -0
  171. package/dist/vcs/pr-strategy.d.ts +13 -26
  172. package/dist/vcs/pr-strategy.js +20 -25
  173. package/dist/vcs/types.d.ts +87 -21
  174. package/package.json +2 -1
@@ -1,28 +1,18 @@
1
1
  import type { FileContent, RepoConfig } from "../config/types.js";
2
2
  import type { RepoInfo } from "../shared/repo-detector.js";
3
- import type { IAuthenticatedGitOps, GitAuthOptions } from "../vcs/authenticated-git-ops.js";
3
+ import type { ILocalGitOps, IGitOps, GitAuthOptions } from "../vcs/authenticated-git-ops.js";
4
4
  import type { GitOpsOptions } from "../vcs/git-ops.js";
5
5
  import type { DiffStats } from "./diff-utils.js";
6
6
  import type { ILogger } from "../shared/logger.js";
7
7
  import type { XfgManifest } from "./manifest.js";
8
8
  import type { ICommandExecutor } from "../shared/command-executor.js";
9
9
  import type { FileAction } from "../vcs/pr-creator.js";
10
- /**
11
- * Factory function type for creating IAuthenticatedGitOps instances.
12
- * Allows dependency injection for testing.
13
- */
14
- export type GitOpsFactory = (options: GitOpsOptions, auth?: GitAuthOptions) => IAuthenticatedGitOps;
15
- /**
16
- * Result of processing a single file
17
- */
10
+ export type GitOpsFactory = (options: GitOpsOptions, auth?: GitAuthOptions, retries?: number) => IGitOps;
18
11
  export interface FileWriteResult {
19
12
  fileName: string;
20
13
  content: string | null;
21
14
  action: "create" | "update" | "delete" | "skip";
22
15
  }
23
- /**
24
- * Context for file writing operations
25
- */
26
16
  export interface FileWriteContext {
27
17
  repoInfo: RepoInfo;
28
18
  baseBranch: string;
@@ -30,72 +20,38 @@ export interface FileWriteContext {
30
20
  dryRun: boolean;
31
21
  noDelete: boolean;
32
22
  configId: string;
23
+ /** True when using GraphQL commit strategy (GitHub App) which cannot set file modes */
24
+ isGraphQLCommitMode?: boolean;
33
25
  }
34
- /**
35
- * Dependencies for FileWriter
36
- */
37
26
  export interface FileWriterDeps {
38
- gitOps: IAuthenticatedGitOps;
27
+ gitOps: ILocalGitOps;
39
28
  log: ILogger;
40
29
  }
41
- /**
42
- * Result of writing all files
43
- */
44
30
  export interface FileWriteAllResult {
45
31
  fileChanges: Map<string, FileWriteResult>;
46
32
  diffStats: DiffStats;
47
33
  }
48
- /**
49
- * Interface for file writing operations
50
- */
51
34
  export interface IFileWriter {
52
- /**
53
- * Write all files from config to repository
54
- */
55
35
  writeFiles(files: FileContent[], ctx: FileWriteContext, deps: FileWriterDeps): Promise<FileWriteAllResult>;
56
36
  }
57
- /**
58
- * Result of processing orphans
59
- */
60
37
  export interface OrphanProcessResult {
61
38
  manifest: XfgManifest;
62
39
  filesToDelete: string[];
63
40
  }
64
- /**
65
- * Options for orphan deletion
66
- */
67
41
  export interface OrphanDeleteOptions {
68
42
  dryRun: boolean;
69
43
  noDelete: boolean;
70
44
  }
71
- /**
72
- * Dependencies for orphan deletion
73
- */
74
45
  export interface OrphanDeleteDeps {
75
- gitOps: IAuthenticatedGitOps;
46
+ gitOps: ILocalGitOps;
76
47
  log: ILogger;
77
48
  fileChanges: Map<string, FileWriteResult>;
78
49
  }
79
- /**
80
- * Interface for manifest management operations
81
- */
82
50
  export interface IManifestManager {
83
- /**
84
- * Process manifest to find orphaned files
85
- */
86
51
  processOrphans(workDir: string, configId: string, filesWithDeleteOrphaned: Map<string, boolean | undefined>): OrphanProcessResult;
87
- /**
88
- * Delete orphaned files
89
- */
90
52
  deleteOrphans(filesToDelete: string[], options: OrphanDeleteOptions, deps: OrphanDeleteDeps): Promise<void>;
91
- /**
92
- * Save updated manifest
93
- */
94
53
  saveUpdatedManifest(workDir: string, manifest: XfgManifest, existingManifest: XfgManifest | null, dryRun: boolean, fileChanges: Map<string, FileWriteResult>): void;
95
54
  }
96
- /**
97
- * Options for branch setup
98
- */
99
55
  export interface BranchSetupOptions {
100
56
  repoInfo: RepoInfo;
101
57
  branchName: string;
@@ -105,81 +61,40 @@ export interface BranchSetupOptions {
105
61
  dryRun: boolean;
106
62
  retries: number;
107
63
  token?: string;
108
- gitOps: IAuthenticatedGitOps;
109
- log: ILogger;
64
+ gitOps: IGitOps;
110
65
  executor: ICommandExecutor;
111
66
  }
112
- /**
113
- * Interface for branch management operations
114
- */
115
67
  export interface IBranchManager {
116
- /**
117
- * Setup branch for sync (close existing PR, create fresh branch)
118
- */
119
68
  setupBranch(options: BranchSetupOptions): Promise<void>;
120
69
  }
121
- /**
122
- * Result of resolving authentication for a repository
123
- */
124
- export interface AuthResult {
125
- /** Installation token or PAT */
70
+ export type AuthResult = {
71
+ ok: true;
126
72
  token?: string;
127
- /** Auth options for git operations */
128
73
  authOptions?: GitAuthOptions;
129
- /** If set, caller should return this result (e.g., no installation found) */
130
- skipResult?: {
131
- success: boolean;
132
- repoName: string;
133
- message: string;
134
- skipped?: boolean;
135
- };
136
- }
137
- /**
138
- * Interface for building authentication options
139
- */
74
+ } | {
75
+ ok: false;
76
+ skipResult: ProcessorResult;
77
+ };
140
78
  export interface IAuthOptionsBuilder {
141
- /**
142
- * Resolve authentication for a repository.
143
- * Returns token and auth options, or a skip result if repo should be skipped.
144
- */
145
- resolve(repoInfo: RepoInfo, repoName: string): Promise<AuthResult>;
79
+ resolve(repoInfo: RepoInfo, repoName: string, preResolvedToken?: string): Promise<AuthResult>;
146
80
  }
147
- /**
148
- * Options for setting up a repository session
149
- */
150
81
  export interface SessionOptions {
151
82
  workDir: string;
152
83
  dryRun: boolean;
153
84
  retries: number;
154
85
  authOptions?: GitAuthOptions;
155
86
  }
156
- /**
157
- * Context returned from session setup
158
- */
159
87
  export interface SessionContext {
160
- /** Authenticated git operations */
161
- gitOps: IAuthenticatedGitOps;
162
- /** Default branch name */
88
+ gitOps: IGitOps;
163
89
  baseBranch: string;
164
- /** Cleanup function - call in finally block */
165
90
  cleanup: () => void;
166
91
  }
167
- /**
168
- * Interface for managing repository workspace lifecycle
169
- */
170
92
  export interface IRepositorySession {
171
- /**
172
- * Setup repository workspace: clean, clone, detect default branch.
173
- * Returns context with gitOps and cleanup function.
174
- */
175
93
  setup(repoInfo: RepoInfo, options: SessionOptions): Promise<SessionContext>;
176
94
  }
177
- /**
178
- * Options for commit and push operations
179
- */
180
95
  export interface CommitPushOptions {
181
96
  repoInfo: RepoInfo;
182
- gitOps: IAuthenticatedGitOps;
97
+ gitOps: IGitOps;
183
98
  workDir: string;
184
99
  fileChanges: Map<string, FileWriteResult>;
185
100
  commitMessage: string;
@@ -190,34 +105,19 @@ export interface CommitPushOptions {
190
105
  token?: string;
191
106
  executor: ICommandExecutor;
192
107
  }
193
- /**
194
- * Result of commit and push operation
195
- */
196
- export interface CommitPushResult {
197
- /** Whether commit/push succeeded */
198
- success: boolean;
199
- /** If failed, contains error result to return */
200
- errorResult?: {
201
- success: boolean;
202
- repoName: string;
203
- message: string;
204
- };
205
- /** If success but no changes, indicates skip */
206
- skipped?: boolean;
207
- }
208
- /**
209
- * Interface for commit and push operations
210
- */
108
+ export type CommitPushResult = {
109
+ success: true;
110
+ skipped?: false;
111
+ } | {
112
+ success: true;
113
+ skipped: true;
114
+ } | {
115
+ success: false;
116
+ errorResult: ProcessorResult;
117
+ };
211
118
  export interface ICommitPushManager {
212
- /**
213
- * Stage, commit, and push changes.
214
- * Handles dry-run mode and branch protection errors.
215
- */
216
- commitAndPush(options: CommitPushOptions, repoName: string): Promise<CommitPushResult>;
119
+ commitAndPush(options: CommitPushOptions): Promise<CommitPushResult>;
217
120
  }
218
- /**
219
- * Options for repository processing
220
- */
221
121
  export interface ProcessorOptions {
222
122
  branchName: string;
223
123
  workDir: string;
@@ -227,17 +127,15 @@ export interface ProcessorOptions {
227
127
  executor?: ICommandExecutor;
228
128
  prTemplate?: string;
229
129
  noDelete?: boolean;
130
+ /** Pre-resolved GitHub token — avoids duplicate resolution in AuthOptionsBuilder */
131
+ token?: string;
132
+ /** True when using GraphQL commit strategy (GitHub App) which cannot set file modes */
133
+ isGraphQLCommitMode?: boolean;
230
134
  }
231
- /**
232
- * Detail of a single file change for reporting
233
- */
234
135
  export interface FileChangeDetail {
235
136
  path: string;
236
137
  action: "create" | "update" | "delete";
237
138
  }
238
- /**
239
- * Result of repository processing
240
- */
241
139
  export interface ProcessorResult {
242
140
  success: boolean;
243
141
  repoName: string;
@@ -252,33 +150,18 @@ export interface ProcessorResult {
252
150
  diffStats?: DiffStats;
253
151
  fileChanges?: FileChangeDetail[];
254
152
  }
255
- /**
256
- * Interface for repository processing operations
257
- */
258
153
  export interface IRepositoryProcessor {
259
154
  process(repoConfig: RepoConfig, repoInfo: RepoInfo, options: ProcessorOptions): Promise<ProcessorResult>;
260
155
  }
261
- /**
262
- * Result of file synchronization
263
- */
264
156
  export interface FileSyncResult {
265
157
  fileChanges: Map<string, FileWriteResult>;
266
158
  diffStats: DiffStats;
267
159
  changedFiles: FileAction[];
268
160
  hasChanges: boolean;
269
161
  }
270
- /**
271
- * Interface for file synchronization orchestration
272
- */
273
162
  export interface IFileSyncOrchestrator {
274
- /**
275
- * Write files, handle orphans, update manifest, return change summary.
276
- */
277
163
  sync(repoConfig: RepoConfig, repoInfo: RepoInfo, session: SessionContext, options: ProcessorOptions): Promise<FileSyncResult>;
278
164
  }
279
- /**
280
- * Options for PR creation and merge
281
- */
282
165
  export interface PRHandlerOptions {
283
166
  branchName: string;
284
167
  baseBranch: string;
@@ -289,48 +172,30 @@ export interface PRHandlerOptions {
289
172
  token?: string;
290
173
  executor: ICommandExecutor;
291
174
  }
292
- /**
293
- * Interface for PR creation and merge handling
294
- */
175
+ export interface CreateAndMergeInput {
176
+ repoInfo: RepoInfo;
177
+ repoConfig: RepoConfig;
178
+ options: PRHandlerOptions;
179
+ changedFiles: FileAction[];
180
+ repoName: string;
181
+ diffStats?: DiffStats;
182
+ fileChanges?: FileChangeDetail[];
183
+ }
295
184
  export interface IPRMergeHandler {
296
- /**
297
- * Create PR and optionally merge based on repo config.
298
- * Returns ProcessorResult with PR URL and merge status.
299
- */
300
- createAndMerge(repoInfo: RepoInfo, repoConfig: RepoConfig, options: PRHandlerOptions, changedFiles: FileAction[], repoName: string, diffStats?: DiffStats, fileChanges?: FileChangeDetail[]): Promise<ProcessorResult>;
185
+ createAndMerge(input: CreateAndMergeInput): Promise<ProcessorResult>;
301
186
  }
302
- /**
303
- * Result of executing work within a sync workflow
304
- */
305
187
  export interface WorkResult {
306
- /** File changes to commit */
307
188
  fileChanges: Map<string, FileWriteResult>;
308
- /** Changed files for PR body */
309
189
  changedFiles: FileAction[];
310
- /** Diff statistics for reporting */
311
190
  diffStats?: DiffStats;
312
- /** Human-readable commit message */
313
191
  commitMessage: string;
314
- /** File change details for result reporting */
315
192
  fileChangeDetails: FileChangeDetail[];
316
193
  }
317
- /**
318
- * Strategy for executing work within the sync workflow.
319
- * Implementations define what changes to make (files vs manifest).
320
- */
194
+ /** Defines what changes to make within the sync workflow. Return null if no changes. */
321
195
  export interface IWorkStrategy {
322
- /**
323
- * Execute work and return changes to commit.
324
- * Return null if no changes detected (workflow will skip).
325
- */
326
196
  execute(repoConfig: RepoConfig, repoInfo: RepoInfo, session: SessionContext, options: ProcessorOptions): Promise<WorkResult | null>;
327
197
  }
328
- /**
329
- * Orchestrates the common sync workflow steps.
330
- */
198
+ /** Orchestrates: auth → session → branch → work → commit → PR */
331
199
  export interface ISyncWorkflow {
332
- /**
333
- * Execute workflow: auth → session → branch → work → commit → PR
334
- */
335
200
  execute(repoConfig: RepoConfig, repoInfo: RepoInfo, options: ProcessorOptions, workStrategy: IWorkStrategy): Promise<ProcessorResult>;
336
201
  }
@@ -1,40 +1,28 @@
1
- import { GitOps } from "./git-ops.js";
1
+ import type { ICommandExecutor } from "../shared/command-executor.js";
2
+ import type { GitAuthOptions, ILocalGitOps, IGitOps } from "./types.js";
3
+ export type { GitAuthOptions, ILocalGitOps, INetworkGitOps, IGitOps, } from "./types.js";
2
4
  /**
3
- * Options for authenticated git operations.
4
- */
5
- export interface GitAuthOptions {
6
- /** Access token for authentication */
7
- token: string;
8
- /** Git host (e.g., "github.com", "github.mycompany.com") */
9
- host: string;
10
- /** Repository owner */
11
- owner: string;
12
- /** Repository name */
13
- repo: string;
14
- }
15
- /**
16
- * Interface for authenticated git operations.
17
- * Enables proper mocking in tests without relying on class inheritance.
5
+ * Adds authentication to network git operations and delegates local ops.
6
+ *
7
+ * When auth options are provided, clone uses an embedded token URL which sets
8
+ * the remote origin. Subsequent operations (fetch, push, getDefaultBranch)
9
+ * reuse that authenticated remote URL — no extra auth setup per operation.
18
10
  */
19
- export interface IAuthenticatedGitOps {
20
- clone(gitUrl: string): Promise<void>;
21
- fetch(options?: {
22
- prune?: boolean;
23
- }): Promise<void>;
24
- push(branchName: string, options?: {
25
- force?: boolean;
26
- }): Promise<void>;
27
- getDefaultBranch(): Promise<{
28
- branch: string;
29
- method: string;
30
- }>;
31
- lsRemote(branchName: string, options?: {
32
- skipRetry?: boolean;
33
- }): Promise<string>;
34
- pushRefspec(refspec: string, options?: {
35
- delete?: boolean;
36
- }): Promise<void>;
37
- fetchBranch(branchName: string): Promise<void>;
11
+ export declare class AuthenticatedGitOps implements IGitOps {
12
+ private readonly localOps;
13
+ private readonly executor;
14
+ private readonly workDir;
15
+ private readonly retries;
16
+ private readonly auth?;
17
+ private readonly log?;
18
+ constructor(localOps: ILocalGitOps, executor: ICommandExecutor, workDir: string, retries: number, auth?: GitAuthOptions | undefined, log?: {
19
+ debug(msg: string): void;
20
+ } | undefined);
21
+ private execWithRetry;
22
+ /**
23
+ * Build the authenticated remote URL.
24
+ */
25
+ private getAuthenticatedUrl;
38
26
  cleanWorkspace(): void;
39
27
  createBranch(branchName: string): Promise<void>;
40
28
  writeFile(fileName: string, content: string): void;
@@ -48,28 +36,10 @@ export interface IAuthenticatedGitOps {
48
36
  fileExists(fileName: string): boolean;
49
37
  deleteFile(fileName: string): void;
50
38
  commit(message: string): Promise<boolean>;
51
- }
52
- /**
53
- * Wrapper around GitOps that adds authentication to network operations.
54
- *
55
- * When auth options are provided, network operations (clone, fetch, push,
56
- * getDefaultBranch) use `-c url.insteadOf` to override credentials per-command.
57
- * This allows different tokens for different repos without global git config.
58
- *
59
- * Local operations (commit, writeFile, etc.) pass through unchanged.
60
- */
61
- export declare class AuthenticatedGitOps implements IAuthenticatedGitOps {
62
- private gitOps;
63
- private auth?;
64
- private executor;
65
- private workDir;
66
- private retries;
67
- constructor(gitOps: GitOps, auth?: GitAuthOptions);
68
- private execWithRetry;
69
- /**
70
- * Build the authenticated remote URL.
71
- */
72
- private getAuthenticatedUrl;
39
+ getDefaultBranchLocal(): Promise<{
40
+ branch: string;
41
+ method: string;
42
+ }>;
73
43
  clone(gitUrl: string): Promise<void>;
74
44
  fetch(options?: {
75
45
  prune?: boolean;
@@ -103,17 +73,4 @@ export declare class AuthenticatedGitOps implements IAuthenticatedGitOps {
103
73
  * Used by GraphQLCommitStrategy to update local refs.
104
74
  */
105
75
  fetchBranch(branchName: string): Promise<void>;
106
- cleanWorkspace(): void;
107
- createBranch(branchName: string): Promise<void>;
108
- writeFile(fileName: string, content: string): void;
109
- setExecutable(fileName: string): Promise<void>;
110
- getFileContent(fileName: string): string | null;
111
- wouldChange(fileName: string, content: string): boolean;
112
- hasChanges(): Promise<boolean>;
113
- getChangedFiles(): Promise<string[]>;
114
- hasStagedChanges(): Promise<boolean>;
115
- fileExistsOnBranch(fileName: string, branch: string): Promise<boolean>;
116
- fileExists(fileName: string): boolean;
117
- deleteFile(fileName: string): void;
118
- commit(message: string): Promise<boolean>;
119
76
  }