Skip to content

Commit e2abb6e

Browse files
committed
RELEASING: Releasing 2 package(s)
Releases: [email protected] @repo/[email protected]
1 parent bf22f19 commit e2abb6e

File tree

12 files changed

+191
-154
lines changed

12 files changed

+191
-154
lines changed

.changeset/cuddly-pens-guess.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

.changeset/green-falcons-fly.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

.changeset/quick-buses-decide.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

.changeset/restore-command.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

.changeset/social-rats-look.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

.changeset/warm-rocks-clap.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/CHANGELOG.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,162 @@
11
# git-json-resolver
22

3+
## 1.0.0
4+
5+
### Major Changes
6+
7+
- 7e959e6: # 🚨 Breaking Change: Array Merge Strategy
8+
9+
**Arrays are no longer merged element-by-element** under the default `merge` strategy.
10+
11+
## What Changed
12+
- Only **plain objects** are merged by default
13+
- Arrays now require explicit strategies: `concat`, `unique`, or custom resolvers
14+
15+
## Why This Change
16+
17+
Previous array merging was unpredictable when arrays had:
18+
- Different lengths
19+
- Different semantic meanings
20+
- Mixed data types
21+
22+
## Migration Guide
23+
24+
```ts
25+
// Before (automatic array merging)
26+
rules: [{ pattern: "*", strategy: "merge" }];
27+
28+
// After (explicit array handling)
29+
rules: [
30+
{ pattern: "dependencies", strategy: "concat" },
31+
{ pattern: "scripts", strategy: "ours" },
32+
{ pattern: "*", strategy: "merge" }, // objects only
33+
];
34+
```
35+
36+
This ensures **predictable and safe** conflict resolution.
37+
38+
### Minor Changes
39+
40+
- Add `concat` and `unique` array merge strategies
41+
- **`concat`**: Concatenate arrays from both sides (applies only if both are arrays)
42+
- **`unique`**: Merge arrays and remove duplicates (applies only if both are arrays)
43+
44+
These strategies provide explicit control over array merging behavior for better conflict resolution.
45+
46+
- 50f0ee1: # 📁 Configurable Backup Path
47+
48+
## New Feature
49+
50+
**Backup file location is now fully configurable** for enhanced flexibility.
51+
52+
## Usage
53+
54+
```ts
55+
import { resolveConflicts } from "git-json-resolver";
56+
57+
resolveConflicts({
58+
filePath: "package.json",
59+
backupPath: "./backups/package.json.backup", // Custom backup location
60+
rules: [
61+
/* your rules */
62+
],
63+
});
64+
```
65+
66+
## Benefits
67+
- **Custom backup directories** for better organization
68+
- **Integration with existing backup strategies**
69+
- **Compliance with project structure requirements**
70+
71+
- e3f85e9: # 🔄 CLI Restore Command
72+
73+
## New CLI Feature
74+
75+
**Restore backup files** with a dedicated command for quick recovery.
76+
77+
## Usage
78+
79+
```bash
80+
# Restore specific backup
81+
npx git-json-resolver restore package.json.backup
82+
83+
# Restore all backups in directory
84+
npx git-json-resolver restore --all
85+
86+
# Restore with confirmation prompt
87+
npx git-json-resolver restore --interactive
88+
```
89+
90+
## Benefits
91+
- **Quick recovery** from failed merges
92+
- **Batch restore operations** for multiple files
93+
- **Interactive mode** for safer restoration
94+
- **Seamless CI/CD integration** for rollback scenarios
95+
96+
- 58df9b2: # ⚡ Pattern Negation Support
97+
98+
## New Matcher Feature
99+
100+
**Pattern negation with `!` prefix** for the default `basicMatcher`.
101+
102+
## Usage
103+
104+
```ts
105+
import { resolveConflicts } from "git-json-resolver";
106+
107+
resolveConflicts({
108+
filePath: "package.json",
109+
rules: [
110+
{ pattern: "dependencies.*", strategy: "ours" },
111+
{ pattern: "!dependencies.react", strategy: "theirs" }, // Negation
112+
{ pattern: "scripts.*", strategy: "merge" },
113+
{ pattern: "!scripts.test", strategy: "manual" }, // Exception
114+
],
115+
});
116+
```
117+
118+
## Benefits
119+
- **Fine-grained control** over merge strategies
120+
- **Exception handling** within broader patterns
121+
- **Intuitive syntax** familiar from gitignore patterns
122+
- **Enhanced rule flexibility** for complex scenarios
123+
124+
### Patch Changes
125+
126+
- 973fc14: # 🔧 Code Refactoring
127+
128+
## Normalizer Simplification
129+
- **Streamlined normalizer logic** for better maintainability
130+
- **Moved file handling utilities** to dedicated utils module
131+
- **Improved separation of concerns** between components
132+
133+
## Benefits
134+
- Cleaner, more focused code structure
135+
- Enhanced testability and debugging
136+
- Better code reusability across modules
137+
138+
- f9d3ea8: # 🚀 Quality & Performance Improvements
139+
140+
## Enhanced Error Handling
141+
- **More descriptive error messages** with context
142+
- **Graceful fallbacks** for edge cases
143+
- **Better error recovery** mechanisms
144+
145+
## Expanded Test Coverage
146+
- **Additional unit tests** for critical paths
147+
- **Edge case validation** scenarios
148+
- **Performance regression tests**
149+
150+
## Performance Enhancements
151+
- **Optimized pattern matching** algorithms
152+
- **Reduced memory footprint** for large files
153+
- **Faster conflict resolution** processing
154+
155+
## Benefits
156+
- More reliable conflict resolution
157+
- Better debugging experience
158+
- Improved performance for large repositories
159+
3160
## 0.1.8
4161

5162
### Patch Changes

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "git-json-resolver",
33
"author": "Mayank Kumar Chaudhari (https://mayank-chaudhari.vercel.app)",
44
"private": false,
5-
"version": "0.1.8",
5+
"version": "1.0.0",
66
"description": "A rules-based JSON conflict resolver that parses Git conflict markers, reconstructs ours/theirs, and merges with deterministic strategies — beyond line-based merges.",
77
"license": "MPL-2.0",
88
"main": "./dist/index.js",

lib/src/merger.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ export const BuiltInStrategies = {
123123

124124
return { status: StrategyStatus.CONTINUE, reason: "Unmergeable type" };
125125
},
126+
127+
concat: <TContext>({ ours, theirs, path }: MergeArgs<TContext>): StrategyResult => {
128+
if (Array.isArray(ours) && Array.isArray(theirs)) {
129+
return { status: StrategyStatus.OK, value: [...ours, ...theirs] };
130+
}
131+
return { status: StrategyStatus.CONTINUE, reason: `Cannot concat at ${path}` };
132+
},
133+
134+
unique: <TContext>({ ours, theirs, path }: MergeArgs<TContext>): StrategyResult => {
135+
if (Array.isArray(ours) && Array.isArray(theirs)) {
136+
return { status: StrategyStatus.OK, value: [...new Set([...ours, ...theirs])] };
137+
}
138+
return { status: StrategyStatus.CONTINUE, reason: `Cannot concat at ${path}` };
139+
},
126140
} as const;
127141

128142
/**

lib/src/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { Matcher } from "./matcher";
1414
* | `drop` | Remove the field entirely (always). |
1515
* | `non-empty` | Prefer non-empty value: `ours` > `theirs` > `base`; fallback to undefined. |
1616
* | `update` | Update with "theirs" if field exists in "ours"; drop if missing in "ours". |
17+
* | `concat` | Concatenate arrays from both sides (applies only if both are arrays). |
18+
* | `unique` | Merge arrays and remove duplicates (applies only if both are arrays). |
1719
*/
1820
export type InbuiltMergeStrategies =
1921
| "merge"
@@ -23,7 +25,9 @@ export type InbuiltMergeStrategies =
2325
| "skip"
2426
| "drop"
2527
| "non-empty"
26-
| "update";
28+
| "update"
29+
| "concat"
30+
| "unique";
2731

2832
/**
2933
* Status codes returned by strategy functions.

0 commit comments

Comments
 (0)