@aspruyt/xfg 2.1.0 → 2.1.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.
- package/dist/repository-processor.js +23 -5
- package/package.json +2 -2
|
@@ -102,6 +102,9 @@ export class RepositoryProcessor {
|
|
|
102
102
|
// Edge cases (repos with unusual git attributes on config files) are essentially nonexistent.
|
|
103
103
|
const changedFiles = [];
|
|
104
104
|
const diffStats = createDiffStats();
|
|
105
|
+
// Track pre-write actions for non-dry-run mode (issue #252)
|
|
106
|
+
// We need to know if a file was created vs updated BEFORE writing it
|
|
107
|
+
const preWriteActions = new Map();
|
|
105
108
|
for (const file of repoConfig.files) {
|
|
106
109
|
const filePath = join(workDir, file.fileName);
|
|
107
110
|
const fileExistsLocal = existsSync(filePath);
|
|
@@ -148,7 +151,8 @@ export class RepositoryProcessor {
|
|
|
148
151
|
this.log.fileDiff(file.fileName, status, diffLines);
|
|
149
152
|
}
|
|
150
153
|
else {
|
|
151
|
-
// Write the file
|
|
154
|
+
// Write the file and store pre-write action for stats calculation
|
|
155
|
+
preWriteActions.set(file.fileName, action);
|
|
152
156
|
this.gitOps.writeFile(file.fileName, fileContent);
|
|
153
157
|
}
|
|
154
158
|
}
|
|
@@ -241,10 +245,9 @@ export class RepositoryProcessor {
|
|
|
241
245
|
if (!gitChangedFiles.has(file.fileName)) {
|
|
242
246
|
continue; // File didn't actually change
|
|
243
247
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
: "create";
|
|
248
|
+
// Use pre-write action (issue #252) - we stored whether file existed
|
|
249
|
+
// BEFORE writing, which is the correct basis for create vs update
|
|
250
|
+
const action = preWriteActions.get(file.fileName) ?? "update";
|
|
248
251
|
changedFiles.push({ fileName: file.fileName, action });
|
|
249
252
|
}
|
|
250
253
|
// Add any other files from git status that aren't already tracked
|
|
@@ -260,6 +263,21 @@ export class RepositoryProcessor {
|
|
|
260
263
|
: "create";
|
|
261
264
|
changedFiles.push({ fileName: gitFile, action });
|
|
262
265
|
}
|
|
266
|
+
// Calculate diff stats from changedFiles (issue #252)
|
|
267
|
+
for (const file of changedFiles) {
|
|
268
|
+
switch (file.action) {
|
|
269
|
+
case "create":
|
|
270
|
+
incrementDiffStats(diffStats, "NEW");
|
|
271
|
+
break;
|
|
272
|
+
case "update":
|
|
273
|
+
incrementDiffStats(diffStats, "MODIFIED");
|
|
274
|
+
break;
|
|
275
|
+
case "delete":
|
|
276
|
+
incrementDiffStats(diffStats, "DELETED");
|
|
277
|
+
break;
|
|
278
|
+
// "skip" files are not counted in stats
|
|
279
|
+
}
|
|
280
|
+
}
|
|
263
281
|
}
|
|
264
282
|
}
|
|
265
283
|
if (!hasChanges) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aspruyt/xfg",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "CLI tool to sync JSON, JSON5, YAML, or text configuration files across multiple Git repositories via pull requests or direct push",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"yaml": "^2.4.5"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@types/node": "^
|
|
61
|
+
"@types/node": "^24.0.0",
|
|
62
62
|
"c8": "^10.1.3",
|
|
63
63
|
"tsx": "^4.15.0",
|
|
64
64
|
"typescript": "^5.4.5"
|