@aspruyt/xfg 4.0.5 → 5.0.1

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 (75) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/program.d.ts +3 -0
  3. package/dist/cli/program.js +18 -13
  4. package/dist/cli/sync-command.js +63 -39
  5. package/dist/cli/sync-report-builder.js +7 -4
  6. package/dist/cli/types.d.ts +1 -0
  7. package/dist/config/formatter.js +14 -9
  8. package/dist/config/merge.d.ts +2 -4
  9. package/dist/config/merge.js +15 -67
  10. package/dist/config/validator.js +2 -9
  11. package/dist/lifecycle/repo-lifecycle-factory.js +0 -4
  12. package/dist/output/github-summary.d.ts +3 -2
  13. package/dist/output/github-summary.js +1 -7
  14. package/dist/output/lifecycle-report.js +7 -14
  15. package/dist/output/sync-report.d.ts +2 -19
  16. package/dist/output/sync-report.js +16 -28
  17. package/dist/output/types.d.ts +19 -0
  18. package/dist/output/types.js +1 -0
  19. package/dist/output/unified-summary.d.ts +2 -1
  20. package/dist/output/unified-summary.js +4 -1
  21. package/dist/settings/base-processor.d.ts +3 -1
  22. package/dist/settings/base-processor.js +9 -5
  23. package/dist/settings/index.d.ts +1 -1
  24. package/dist/settings/labels/diff.d.ts +2 -1
  25. package/dist/settings/labels/formatter.js +2 -4
  26. package/dist/settings/labels/github-labels-strategy.js +2 -1
  27. package/dist/settings/labels/processor.js +0 -1
  28. package/dist/settings/repo-settings/github-repo-settings-strategy.js +2 -1
  29. package/dist/settings/rulesets/diff-algorithm.js +0 -1
  30. package/dist/settings/rulesets/diff.d.ts +2 -1
  31. package/dist/settings/rulesets/diff.js +37 -21
  32. package/dist/settings/rulesets/formatter.js +44 -38
  33. package/dist/settings/rulesets/github-ruleset-strategy.js +2 -1
  34. package/dist/settings/rulesets/processor.js +0 -1
  35. package/dist/shared/gh-api-utils.d.ts +8 -7
  36. package/dist/shared/gh-api-utils.js +2 -16
  37. package/dist/shared/interpolation-engine.d.ts +3 -0
  38. package/dist/shared/interpolation-engine.js +0 -3
  39. package/dist/shared/json-utils.d.ts +6 -0
  40. package/dist/shared/json-utils.js +16 -0
  41. package/dist/shared/repo-detector.js +0 -4
  42. package/dist/shared/xfg-template.d.ts +3 -0
  43. package/dist/shared/xfg-template.js +0 -20
  44. package/dist/sync/auth-options-builder.js +7 -1
  45. package/dist/sync/branch-manager.d.ts +1 -1
  46. package/dist/sync/commit-message.d.ts +1 -1
  47. package/dist/sync/commit-push-manager.d.ts +1 -1
  48. package/dist/sync/commit-push-manager.js +2 -2
  49. package/dist/sync/diff-utils.d.ts +15 -2
  50. package/dist/sync/diff-utils.js +50 -14
  51. package/dist/sync/file-sync-orchestrator.js +2 -4
  52. package/dist/sync/file-sync-strategy.js +11 -4
  53. package/dist/sync/file-writer.js +9 -4
  54. package/dist/sync/index.d.ts +2 -1
  55. package/dist/sync/index.js +1 -0
  56. package/dist/sync/manifest-manager.d.ts +1 -1
  57. package/dist/sync/manifest-manager.js +20 -6
  58. package/dist/sync/pr-merge-handler.js +6 -1
  59. package/dist/sync/repository-processor.js +8 -1
  60. package/dist/sync/types.d.ts +5 -4
  61. package/dist/vcs/authenticated-git-ops.d.ts +9 -1
  62. package/dist/vcs/authenticated-git-ops.js +7 -14
  63. package/dist/vcs/git-ops.js +29 -12
  64. package/dist/vcs/github-pr-strategy.js +6 -1
  65. package/dist/vcs/gitlab-pr-strategy.js +7 -2
  66. package/dist/vcs/graphql-commit-strategy.js +2 -1
  67. package/dist/vcs/index.d.ts +1 -0
  68. package/dist/vcs/index.js +2 -0
  69. package/dist/vcs/pr-creator.d.ts +5 -1
  70. package/dist/vcs/pr-creator.js +4 -4
  71. package/package.json +1 -1
  72. package/dist/output/index.d.ts +0 -5
  73. package/dist/output/index.js +0 -10
  74. package/dist/shared/index.d.ts +0 -15
  75. package/dist/shared/index.js +0 -30
@@ -5,7 +5,7 @@ import { assertGitLabRepo } from "../shared/repo-detector.js";
5
5
  import { BasePRStrategy } from "./pr-strategy.js";
6
6
  import { withRetry, isPermanentError } from "../shared/retry-utils.js";
7
7
  import { getStderr } from "../shared/command-executor.js";
8
- import { parseApiJson } from "../shared/gh-api-utils.js";
8
+ import { parseApiJson } from "../shared/json-utils.js";
9
9
  import { sanitizeCredentials } from "../shared/sanitize-utils.js";
10
10
  import { toErrorMessage, safeCleanup } from "../shared/type-guards.js";
11
11
  import { NO_OP_DEBUG_LOG } from "../shared/logger.js";
@@ -146,7 +146,12 @@ export class GitLabPRStrategy extends BasePRStrategy {
146
146
  assertGitLabRepo(repoInfo, "GitLab PR strategy");
147
147
  const repoFlag = this.getRepoFlag(repoInfo);
148
148
  const descFile = join(workDir, this.bodyFilePath);
149
- writeFileSync(descFile, body, "utf-8");
149
+ try {
150
+ writeFileSync(descFile, body, "utf-8");
151
+ }
152
+ catch (err) {
153
+ throw new SyncError(`Failed to write PR description to ${descFile}: ${toErrorMessage(err)}`);
154
+ }
150
155
  // glab mr create with description from file
151
156
  const command = `glab mr create --source-branch ${escapeShellArg(branchName)} --target-branch ${escapeShellArg(baseBranch)} --title ${escapeShellArg(title)} --description "$(cat ${escapeShellArg(descFile)})" --yes -R ${escapeShellArg(repoFlag)}`;
152
157
  try {
@@ -2,7 +2,8 @@ import { isGitHubRepo } from "../shared/repo-detector.js";
2
2
  import { escapeShellArg } from "../shared/shell-utils.js";
3
3
  import { withRetry, CORE_PERMANENT_ERROR_PATTERNS, DEFAULT_PERMANENT_ERROR_PATTERNS, } from "../shared/retry-utils.js";
4
4
  import { toErrorMessage } from "../shared/type-guards.js";
5
- import { parseApiJson, buildTokenEnv } from "../shared/gh-api-utils.js";
5
+ import { parseApiJson } from "../shared/json-utils.js";
6
+ import { buildTokenEnv } from "../shared/gh-api-utils.js";
6
7
  import { ValidationError, GraphQLApiError } from "../shared/errors.js";
7
8
  /**
8
9
  * Maximum payload size for GitHub GraphQL API (50MB).
@@ -2,3 +2,4 @@ export type { PRMergeConfig, FileChange, FileAction, IGitOps, ILocalGitOps, INet
2
2
  export type { GitOpsOptions } from "./git-ops.js";
3
3
  export { getCommitStrategy, createTokenManager, } from "./commit-strategy-selector.js";
4
4
  export { getPRStrategy } from "./pr-strategy-factory.js";
5
+ export { createPR, mergePR } from "./pr-creator.js";
package/dist/vcs/index.js CHANGED
@@ -2,3 +2,5 @@
2
2
  export { getCommitStrategy, createTokenManager, } from "./commit-strategy-selector.js";
3
3
  // PR strategy factory
4
4
  export { getPRStrategy } from "./pr-strategy-factory.js";
5
+ // PR creation and merge
6
+ export { createPR, mergePR } from "./pr-creator.js";
@@ -1,6 +1,6 @@
1
1
  import { RepoInfo } from "../shared/repo-detector.js";
2
2
  import type { IPRStrategyLogger } from "./pr-strategy.js";
3
- import type { FileAction, MergeResult, PRMergeConfig, PRResult } from "./types.js";
3
+ import type { FileAction, IPRStrategy, MergeResult, PRMergeConfig, PRResult } from "./types.js";
4
4
  import { ICommandExecutor } from "../shared/command-executor.js";
5
5
  export type { FileAction };
6
6
  interface PROptions {
@@ -22,6 +22,8 @@ interface PROptions {
22
22
  labels?: string[];
23
23
  /** Optional logger for PR strategy debug/warn/info messages */
24
24
  log?: IPRStrategyLogger;
25
+ /** Pre-constructed PR strategy to reuse (avoids redundant instantiation) */
26
+ strategy?: IPRStrategy;
25
27
  }
26
28
  export type { PRResult } from "./types.js";
27
29
  /**
@@ -53,5 +55,7 @@ interface MergePROptions {
53
55
  token?: string;
54
56
  /** Optional logger for PR strategy debug/warn/info messages */
55
57
  log?: IPRStrategyLogger;
58
+ /** Pre-constructed PR strategy to reuse (avoids redundant instantiation) */
59
+ strategy?: IPRStrategy;
56
60
  }
57
61
  export declare function mergePR(options: MergePROptions): Promise<MergeResult>;
@@ -106,8 +106,8 @@ export async function createPR(options) {
106
106
  };
107
107
  }
108
108
  // Get the appropriate strategy and execute via workflow executor
109
- const strategy = getPRStrategy(repoInfo, executor, log);
110
- const workflow = new PRWorkflowExecutor(strategy);
109
+ const resolvedStrategy = options.strategy ?? getPRStrategy(repoInfo, executor, log);
110
+ const workflow = new PRWorkflowExecutor(resolvedStrategy);
111
111
  return workflow.execute({
112
112
  repoInfo,
113
113
  title,
@@ -135,8 +135,8 @@ export async function mergePR(options) {
135
135
  };
136
136
  }
137
137
  // Get the appropriate strategy and execute merge
138
- const strategy = getPRStrategy(repoInfo, executor, log);
139
- return strategy.merge({
138
+ const resolvedStrategy = options.strategy ?? getPRStrategy(repoInfo, executor, log);
139
+ return resolvedStrategy.merge({
140
140
  prUrl,
141
141
  repoInfo,
142
142
  config: mergeConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspruyt/xfg",
3
- "version": "4.0.5",
3
+ "version": "5.0.1",
4
4
  "description": "Manage files, settings, and repositories across GitHub, Azure DevOps, and GitLab — declaratively, from a single YAML config",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,5 +0,0 @@
1
- export { formatSyncReportCLI, formatSyncReportMarkdown, writeSyncReportSummary, type SyncReport, type RepoFileChanges, type ReportFileChange, } from "./sync-report.js";
2
- export { formatSettingsReportCLI, formatSettingsReportMarkdown, writeSettingsReportSummary, type SettingsReport, type RepoChanges, type RulesetChange, type SettingChange, } from "./settings-report.js";
3
- export { formatUnifiedSummaryMarkdown, writeUnifiedSummary, } from "./unified-summary.js";
4
- export { formatSummary, shouldWriteSummary, writeSummary, type MergeOutcome, type FileChanges, type RulesetPlanDetail, type RepoSettingsPlanDetail, type RepoResult, type SummaryData, } from "./github-summary.js";
5
- export { getMergeOutcome, toFileChanges, buildRepoResult, buildErrorResult, } from "./summary-utils.js";
@@ -1,10 +0,0 @@
1
- // Sync report (repo-grouped file changes)
2
- export { formatSyncReportCLI, formatSyncReportMarkdown, writeSyncReportSummary, } from "./sync-report.js";
3
- // Settings report (repo-grouped settings changes)
4
- export { formatSettingsReportCLI, formatSettingsReportMarkdown, writeSettingsReportSummary, } from "./settings-report.js";
5
- // Unified summary (lifecycle + sync + settings in one diff block)
6
- export { formatUnifiedSummaryMarkdown, writeUnifiedSummary, } from "./unified-summary.js";
7
- // GitHub Actions summary
8
- export { formatSummary, shouldWriteSummary, writeSummary, } from "./github-summary.js";
9
- // Summary utilities
10
- export { getMergeOutcome, toFileChanges, buildRepoResult, buildErrorResult, } from "./summary-utils.js";
@@ -1,15 +0,0 @@
1
- export { Logger, NO_OP_DEBUG_LOG, type ILogger, type DebugLog, type DebugWarnLog, type DebugInfoLog, type DebugInfoWarnLog, } from "./logger.js";
2
- export { withRetry, isPermanentError, isTransientError, DEFAULT_PERMANENT_ERROR_PATTERNS, } from "./retry-utils.js";
3
- export { ShellCommandExecutor, type ICommandExecutor, } from "./command-executor.js";
4
- export { escapeShellArg, escapeRegExp } from "./shell-utils.js";
5
- export { sanitizeCredentials } from "./sanitize-utils.js";
6
- export { interpolateEnvVars, interpolateContent, type EnvInterpolationOptions, } from "./env.js";
7
- export { generateWorkspaceName } from "./workspace-utils.js";
8
- export { detectRepoType, parseGitUrl, getRepoDisplayName, isGitHubRepo, isAzureDevOpsRepo, isGitLabRepo, type RepoInfo, type GitHubRepoInfo, type AzureDevOpsRepoInfo, type GitLabRepoInfo, } from "./repo-detector.js";
9
- export { ValidationError, GraphQLApiError, SyncError, LifecycleError, } from "./errors.js";
10
- export { formatStatusBadge, type FileStatus } from "./file-status.js";
11
- export { GhApiClient, getHostnameFlag, buildTokenEnv, resolveGitHubToken, isHttp404Error, parseApiJson, type GhApiOptions, } from "./gh-api-utils.js";
12
- export { interpolateString, interpolateValue, type InterpolationConfig, } from "./interpolation-engine.js";
13
- export { camelToSnake } from "./string-utils.js";
14
- export { isPlainObject, toErrorMessage, safeCleanup } from "./type-guards.js";
15
- export { interpolateXfgContent, type XfgTemplateContext, } from "./xfg-template.js";
@@ -1,30 +0,0 @@
1
- // Logging
2
- export { Logger, NO_OP_DEBUG_LOG, } from "./logger.js";
3
- // Retry utilities
4
- export { withRetry, isPermanentError, isTransientError, DEFAULT_PERMANENT_ERROR_PATTERNS, } from "./retry-utils.js";
5
- // Command execution
6
- export { ShellCommandExecutor, } from "./command-executor.js";
7
- // Shell utilities
8
- export { escapeShellArg, escapeRegExp } from "./shell-utils.js";
9
- // Sanitization
10
- export { sanitizeCredentials } from "./sanitize-utils.js";
11
- // Environment
12
- export { interpolateEnvVars, interpolateContent, } from "./env.js";
13
- // Workspace utilities
14
- export { generateWorkspaceName } from "./workspace-utils.js";
15
- // Repository detection
16
- export { detectRepoType, parseGitUrl, getRepoDisplayName, isGitHubRepo, isAzureDevOpsRepo, isGitLabRepo, } from "./repo-detector.js";
17
- // Errors
18
- export { ValidationError, GraphQLApiError, SyncError, LifecycleError, } from "./errors.js";
19
- // File status
20
- export { formatStatusBadge } from "./file-status.js";
21
- // GitHub API utilities
22
- export { GhApiClient, getHostnameFlag, buildTokenEnv, resolveGitHubToken, isHttp404Error, parseApiJson, } from "./gh-api-utils.js";
23
- // Interpolation engine
24
- export { interpolateString, interpolateValue, } from "./interpolation-engine.js";
25
- // String utilities
26
- export { camelToSnake } from "./string-utils.js";
27
- // Type guards
28
- export { isPlainObject, toErrorMessage, safeCleanup } from "./type-guards.js";
29
- // XFG templating
30
- export { interpolateXfgContent, } from "./xfg-template.js";