Skip to content

Commit 49166a6

Browse files
committed
upgrade deps && docs [skip ci]
1 parent 50e3ea6 commit 49166a6

File tree

6 files changed

+214
-13
lines changed

6 files changed

+214
-13
lines changed

MIGRATION.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ If you're using dynamic plugin loading, **no changes are needed**:
2929
#### 2. Direct Import Usage
3030

3131
**Before (v0.0.2):**
32+
3233
```ts
3334
import plugin, { semverMax } from "git-json-resolver-semver";
3435
import { resolveConflicts } from "git-json-resolver";
3536

3637
// Plugin configuration (old way)
3738
await plugin.init?.({
3839
strict: false,
39-
fallback: "ours"
40+
fallback: "ours",
4041
});
4142

4243
await resolveConflicts({
@@ -50,14 +51,15 @@ await resolveConflicts({
5051
```
5152

5253
**After (v1.0.0):**
54+
5355
```ts
5456
import createSemverPlugin, { semverMax, init } from "git-json-resolver-semver";
5557
import { resolveConflicts } from "git-json-resolver";
5658

5759
// Option 1: Use factory function with config
5860
const plugin = createSemverPlugin({
5961
strict: false,
60-
fallback: "ours"
62+
fallback: "ours",
6163
});
6264

6365
await resolveConflicts({
@@ -70,7 +72,7 @@ await resolveConflicts({
7072
// Option 2: Use global init (for backward compatibility)
7173
init({
7274
strict: false,
73-
fallback: "ours"
75+
fallback: "ours",
7476
});
7577

7678
await resolveConflicts({
@@ -91,8 +93,8 @@ The plugin now uses `validateStrict` from compare-versions and properly handles
9193

9294
```ts
9395
// Now properly handles these cases:
94-
"^1.2.3" // Strips ^ prefix before validation
95-
"1.2.3-beta.1" // Handled based on strict mode setting
96+
"^1.2.3"; // Strips ^ prefix before validation
97+
"1.2.3-beta.1"; // Handled based on strict mode setting
9698
```
9799

98100
#### Factory Pattern Benefits
@@ -116,10 +118,13 @@ All configuration options remain the same:
116118
### Troubleshooting
117119

118120
**Error: "Cannot read property 'strategies' of undefined"**
121+
119122
- You're likely importing the old way. Use `createSemverPlugin()` or individual strategy exports.
120123

121124
**Error: "plugin.init is not a function"**
125+
122126
- Use the new `init` named export instead of `plugin.init`.
123127

124128
**Semver validation behaving differently**
125-
- The new validation is more accurate. Check if your versions need the `strict: false` option.
129+
130+
- The new validation is more accurate. Check if your versions need the `strict: false` option.

docs/index.md

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,24 @@ pnpm install git-json-resolver
6464
### 1. Direct Import
6565

6666
```ts
67-
import { semverMax } from "git-json-resolver-semver";
67+
import createSemverPlugin, { semverMax } from "git-json-resolver-semver";
6868
import { resolveConflicts } from "git-json-resolver";
6969

70+
// Option 1: Use factory function with custom config
71+
const plugin = createSemverPlugin({
72+
strict: false,
73+
fallback: "ours",
74+
});
75+
76+
await resolveConflicts({
77+
customStrategies: plugin.strategies,
78+
rules: {
79+
"dependencies.react": ["semver-max"],
80+
"devDependencies.vitest": ["semver-min"],
81+
},
82+
});
83+
84+
// Option 2: Use individual strategy exports - not scoped @see migration guide for more details
7085
await resolveConflicts({
7186
customStrategies: {
7287
"semver-max": semverMax,
@@ -109,11 +124,39 @@ export default config;
109124

110125
---
111126

112-
## ⚙️ Behavior notes
127+
## ⚙️ Configuration
128+
129+
### Factory Pattern (Recommended)
130+
131+
```ts
132+
import createSemverPlugin from "git-json-resolver-semver";
133+
134+
const plugin = createSemverPlugin({
135+
strict: true, // Use validateStrict for exact semver only
136+
preferValid: true, // Prefer valid semver when only one side is valid
137+
fallback: "continue", // Behavior when both sides invalid
138+
preferRange: false, // Future: merge into semver ranges
139+
workspacePattern: "", // Pattern for workspace rules
140+
});
141+
```
142+
143+
### Global Configuration
144+
145+
```ts
146+
import { init } from "git-json-resolver-semver";
147+
148+
init({
149+
strict: false, // Allow prereleases and ranges
150+
fallback: "ours",
151+
});
152+
```
153+
154+
### Behavior Notes
113155

114-
- **strict** mode (default) accepts only `x.y.z`. Set non-strict to allow prereleases/ranges.
115-
- **preferValid** (default) returns the valid side when the other is invalid.
116-
- **fallback** controls behavior when neither side is valid (`ours` | `theirs` | `continue` | `error`).
156+
- **strict** mode uses `validateStrict` - only accepts `x.y.z` format
157+
- **preferValid** returns the valid side when the other is invalid
158+
- **fallback** controls behavior when neither side is valid
159+
- Version prefixes like `^1.2.3` are automatically handled
117160

118161
## ⚙️ Strategies
119162

@@ -142,5 +185,5 @@ This library is licensed under the MPL-2.0 open-source license.
142185
143186
## Modules
144187
145-
- [index](index.md)
188+
- [index](index/README.md)
146189
- [index.test](index.test.md)

docs/index/-internal-.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
layout: default
3+
title: Internal
4+
parent: Index
5+
nav_order: 4
6+
---
7+
8+
# \<internal\>
9+
10+
## Interfaces
11+
12+
### SemverPluginConfig
13+
14+
Defined in: [index.ts:27](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L27)
15+
16+
#### Properties
17+
18+
##### fallback?
19+
20+
> `optional` **fallback**: `"ours"` \| `"theirs"` \| `"continue"` \| `"error"`
21+
22+
Defined in: [index.ts:29](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L29)
23+
24+
##### preferRange?
25+
26+
> `optional` **preferRange**: `boolean`
27+
28+
Defined in: [index.ts:31](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L31)
29+
30+
##### preferValid?
31+
32+
> `optional` **preferValid**: `boolean`
33+
34+
Defined in: [index.ts:30](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L30)
35+
36+
##### strict?
37+
38+
> `optional` **strict**: `boolean`
39+
40+
Defined in: [index.ts:28](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L28)
41+
42+
##### workspacePattern?
43+
44+
> `optional` **workspacePattern**: `string`
45+
46+
Defined in: [index.ts:32](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L32)

docs/index/README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
layout: default
3+
title: README
4+
parent: Index
5+
nav_order: 5
6+
---
7+
8+
# index
9+
10+
## Modules
11+
12+
- [\<internal\>](-internal-.md)
13+
14+
## Variables
15+
16+
### semverMax
17+
18+
> `const` **semverMax**: `StrategyFn`\<`unknown`\>
19+
20+
Defined in: [index.ts:153](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L153)
21+
22+
---
23+
24+
### semverMin
25+
26+
> `const` **semverMin**: `StrategyFn`\<`unknown`\>
27+
28+
Defined in: [index.ts:154](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L154)
29+
30+
---
31+
32+
### semverOurs
33+
34+
> `const` **semverOurs**: `StrategyFn`\<`unknown`\>
35+
36+
Defined in: [index.ts:155](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L155)
37+
38+
---
39+
40+
### semverTheirs
41+
42+
> `const` **semverTheirs**: `StrategyFn`\<`unknown`\>
43+
44+
Defined in: [index.ts:156](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L156)
45+
46+
## Functions
47+
48+
### createSemverPlugin()
49+
50+
> **createSemverPlugin**(`pluginConfig`: [`SemverPluginConfig`](-internal-.md#semverpluginconfig)): `StrategyPlugin`
51+
52+
Defined in: [index.ts:62](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L62)
53+
54+
Creates semver-aware strategies for `git-json-resolver`.
55+
56+
## Strategies
57+
58+
| Strategy | Behavior | Example (`ours` vs `theirs`) | Result |
59+
| --------------- | --------------------------------------------------------------------- | ---------------------------- | ------- |
60+
| `semver-max` | Picks the higher valid semver | `1.2.3` vs `1.3.0` | `1.3.0` |
61+
| `semver-min` | Picks the lower valid semver | `2.0.0` vs `2.1.0` | `2.0.0` |
62+
| `semver-ours` | Picks `ours` if valid semver, else apply `preferValid` / `fallback` | `1.2.3` vs `banana` | `1.2.3` |
63+
| `semver-theirs` | Picks `theirs` if valid semver, else apply `preferValid` / `fallback` | `foo` vs `2.0.0` | `2.0.0` |
64+
65+
Configuration options (`pluginConfig`):
66+
67+
- `strict` → use validateStrict - https://github.com/omichelsen/compare-versions?tab=readme-ov-file#validate-version-numbers-strict
68+
- `fallback` → behavior when both invalid (`ours` | `theirs` | `continue` | `error`)
69+
- `preferValid` → if only one side is valid semver, take it
70+
- `preferRange` → merge into semver range (future)
71+
- `workspacePattern` → pattern for workspace rules (e.g. `workspaces:*`)
72+
73+
#### Parameters
74+
75+
##### pluginConfig
76+
77+
[`SemverPluginConfig`](-internal-.md#semverpluginconfig) = `defaultConfig`
78+
79+
#### Returns
80+
81+
`StrategyPlugin`
82+
83+
---
84+
85+
### init()
86+
87+
> **init**(`config`: [`SemverPluginConfig`](-internal-.md#semverpluginconfig)): `void`
88+
89+
Defined in: [index.ts:158](https://github.com/react18-tools/git-json-resolver-semver/blob/50e3ea62d91488fe5a6f02d1c59f11b20e40d81f/lib/src/index.ts#L158)
90+
91+
#### Parameters
92+
93+
##### config
94+
95+
[`SemverPluginConfig`](-internal-.md#semverpluginconfig)
96+
97+
#### Returns
98+
99+
`void`

docs/index/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: default
3+
title: Index
4+
nav_order: 3
5+
has_children: true
6+
---
7+
8+
# Index

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
"next@>=15.0.0 <15.2.3": ">=15.2.3"
4343
}
4444
}
45-
}
45+
}

0 commit comments

Comments
 (0)