@aspruyt/xfg 5.0.1 → 5.1.0

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.
@@ -7,9 +7,9 @@ export declare function getFileStatus(exists: boolean, changed: boolean): FileSt
7
7
  */
8
8
  export declare function formatDiffLine(line: string): string;
9
9
  /**
10
- * Check if a file is a structured data file (JSON, JSON5, YAML, YML).
10
+ * Check if a file is likely binary based on its extension.
11
11
  */
12
- export declare function isStructuredDataFile(fileName: string): boolean;
12
+ export declare function isBinaryFile(fileName: string): boolean;
13
13
  /**
14
14
  * Compute a unified diff between old and new content.
15
15
  * Returns raw diff lines (no ANSI formatting).
@@ -17,11 +17,52 @@ export function formatDiffLine(line) {
17
17
  return chalk.cyan(line);
18
18
  return line;
19
19
  }
20
+ const BINARY_EXTENSIONS = new Set([
21
+ ".png",
22
+ ".jpg",
23
+ ".jpeg",
24
+ ".gif",
25
+ ".bmp",
26
+ ".ico",
27
+ ".webp",
28
+ ".svg",
29
+ ".woff",
30
+ ".woff2",
31
+ ".ttf",
32
+ ".eot",
33
+ ".otf",
34
+ ".pdf",
35
+ ".zip",
36
+ ".tar",
37
+ ".gz",
38
+ ".bz2",
39
+ ".7z",
40
+ ".rar",
41
+ ".exe",
42
+ ".dll",
43
+ ".so",
44
+ ".dylib",
45
+ ".bin",
46
+ ".dat",
47
+ ".db",
48
+ ".sqlite",
49
+ ".jar",
50
+ ".class",
51
+ ".pyc",
52
+ ".wasm",
53
+ ".mp3",
54
+ ".mp4",
55
+ ".wav",
56
+ ".avi",
57
+ ".mov",
58
+ ".mkv",
59
+ ]);
20
60
  /**
21
- * Check if a file is a structured data file (JSON, JSON5, YAML, YML).
61
+ * Check if a file is likely binary based on its extension.
22
62
  */
23
- export function isStructuredDataFile(fileName) {
24
- return /\.(json|json5|ya?ml)$/i.test(fileName);
63
+ export function isBinaryFile(fileName) {
64
+ const ext = fileName.slice(fileName.lastIndexOf(".")).toLowerCase();
65
+ return BINARY_EXTENSIONS.has(ext);
25
66
  }
26
67
  /**
27
68
  * Compute a unified diff between old and new content.
@@ -2,7 +2,7 @@ import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { convertContentToString } from "../config/formatter.js";
4
4
  import { interpolateXfgContent } from "../shared/xfg-template.js";
5
- import { getFileStatus, generateDiff, createDiffStats, incrementDiffStats, computeUnifiedDiff, isStructuredDataFile, } from "./diff-utils.js";
5
+ import { getFileStatus, generateDiff, createDiffStats, incrementDiffStats, computeUnifiedDiff, isBinaryFile, } from "./diff-utils.js";
6
6
  /**
7
7
  * Determines if a file should be marked as executable.
8
8
  * .sh files are auto-executable unless explicit executable: false is set.
@@ -70,8 +70,8 @@ export class FileWriter {
70
70
  content: fileContent,
71
71
  action,
72
72
  };
73
- // Compute raw diff lines for structured data files (all modes)
74
- if (isStructuredDataFile(file.fileName)) {
73
+ // Compute raw diff lines for text files (all modes)
74
+ if (!isBinaryFile(file.fileName)) {
75
75
  writeResult.diffLines = computeUnifiedDiff(existingContent, fileContent);
76
76
  }
77
77
  fileChanges.set(file.fileName, writeResult);
@@ -1,4 +1,4 @@
1
1
  export type { DiffStats } from "./diff-utils.js";
2
- export { computeUnifiedDiff, isStructuredDataFile, formatDiffLine, } from "./diff-utils.js";
2
+ export { computeUnifiedDiff, isBinaryFile, formatDiffLine, } from "./diff-utils.js";
3
3
  export type { FileChangeDetail, GitOpsFactory, IAuthOptionsBuilder, IBranchManager, ICommitPushManager, IFileSyncOrchestrator, IPRMergeHandler, IRepositoryProcessor, IRepositorySession, IWorkStrategy, ProcessorResult, SessionContext, WorkResult, } from "./types.js";
4
4
  export { RepositoryProcessor } from "./repository-processor.js";
@@ -1,2 +1,2 @@
1
- export { computeUnifiedDiff, isStructuredDataFile, formatDiffLine, } from "./diff-utils.js";
1
+ export { computeUnifiedDiff, isBinaryFile, formatDiffLine, } from "./diff-utils.js";
2
2
  export { RepositoryProcessor } from "./repository-processor.js";
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { loadManifest, saveManifest, updateManifest, MANIFEST_FILENAME, } from "./manifest.js";
4
- import { computeUnifiedDiff, isStructuredDataFile } from "./diff-utils.js";
4
+ import { computeUnifiedDiff, isBinaryFile } from "./diff-utils.js";
5
5
  /**
6
6
  * Handles manifest loading, saving, and orphan detection.
7
7
  */
@@ -35,7 +35,7 @@ export class ManifestManager {
35
35
  content: null,
36
36
  action: "delete",
37
37
  };
38
- if (isStructuredDataFile(fileName)) {
38
+ if (!isBinaryFile(fileName)) {
39
39
  const existingContent = gitOps.getFileContent(fileName);
40
40
  if (existingContent !== null) {
41
41
  writeResult.diffLines = computeUnifiedDiff(existingContent, null);
package/package.json CHANGED
@@ -1,12 +1,21 @@
1
1
  {
2
2
  "name": "@aspruyt/xfg",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
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",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
7
13
  "bin": {
8
14
  "xfg": "./dist/cli.js"
9
15
  },
16
+ "sideEffects": [
17
+ "./dist/cli.js"
18
+ ],
10
19
  "files": [
11
20
  "dist",
12
21
  "PR.md"
@@ -57,6 +66,9 @@
57
66
  ],
58
67
  "author": "Anthony Spruyt",
59
68
  "license": "MIT",
69
+ "funding": {
70
+ "url": "https://github.com/sponsors/anthony-spruyt"
71
+ },
60
72
  "dependencies": {
61
73
  "chalk": "^5.3.0",
62
74
  "commander": "^14.0.2",