Skip to content

Commit de63544

Browse files
committed
Apply changesets and update CHANGELOG [skip ci]
1 parent dbd0b2f commit de63544

File tree

1 file changed

+71
-71
lines changed

1 file changed

+71
-71
lines changed

lib/README.md

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Git Json Resolver Semver <img src="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png" style="height: 40px"/>
1+
# git-json-resolver-semver <img src="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png" style="height: 40px"/>
22

33
[![test](https://github.com/react18-tools/git-json-resolver-semver/actions/workflows/test.yml/badge.svg)](https://github.com/react18-tools/git-json-resolver-semver/actions/workflows/test.yml)
44
[![Maintainability](https://qlty.sh/gh/react18-tools/projects/git-json-resolver-semver/maintainability.svg)](https://qlty.sh/gh/react18-tools/projects/git-json-resolver-semver)
@@ -7,25 +7,27 @@
77
[![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/git-json-resolver-semver.svg)](https://www.npmjs.com/package/git-json-resolver-semver)
88
![npm bundle size](https://img.shields.io/bundlephobia/minzip/git-json-resolver-semver)
99

10-
Git Json Resolver Semver is a comprehensive library designed to unlock the full potential of React 18 server components. It provides customizable loading animation components and a fullscreen loader container, seamlessly integrating with React and Next.js.
10+
**Semver-aware plugin for [`git-json-resolver`](https://github.com/react18-tools/git-json-resolver)** — resolve JSON version conflicts (e.g., `package.json`) via semantic-version strategies.
1111

12-
✅ Fully Treeshakable (import from `git-json-resolver-semver/client/loader-container`)
12+
**Strategies (this release):**
1313

14-
✅ Fully TypeScript Supported
14+
- `semver-max` → pick the higher version
15+
- `semver-min` → pick the lower version
16+
- `semver-ours` → prefer ours if valid, else (optionally) prefer valid theirs
17+
- `semver-theirs` → prefer theirs if valid, else (optionally) prefer valid ours
1518

16-
✅ Leverages the power of React 18 Server components
19+
---
1720

18-
✅ Compatible with all React 18 build systems/tools/frameworks
21+
## ✨ Features
1922

20-
✅ Documented with [Typedoc](https://react18-tools.github.io/git-json-resolver-semver) ([Docs](https://react18-tools.github.io/git-json-resolver-semver))
23+
- Avoid manual conflict resolution in `package.json`
24+
- Small & tree-shakable (0 runtime dependencies)
25+
- Works with **direct import** or **dynamic plugin loading**
26+
- TypeScript types included
2127

22-
✅ Examples for Next.js, and Vite
28+
> <img src="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png" style="height: 20px"/> Star the repo if it saved your merge. And and also share it with your friends.
2329
24-
> <img src="https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png" style="height: 20px"/> Star [this repository](https://github.com/react18-tools/git-json-resolver-semver) and share it with your friends.
25-
26-
## Getting Started
27-
28-
### Installation
30+
## 📦 Install
2931

3032
```bash
3133
pnpm add git-json-resolver-semver
@@ -43,86 +45,83 @@ npm install git-json-resolver-semver
4345
yarn add git-json-resolver-semver
4446
```
4547

46-
## Want Lite Version? [![npm bundle size](https://img.shields.io/bundlephobia/minzip/git-json-resolver-semver-lite)](https://www.npmjs.com/package/git-json-resolver-semver-lite) [![Version](https://img.shields.io/npm/v/git-json-resolver-semver-lite.svg?colorB=green)](https://www.npmjs.com/package/git-json-resolver-semver-lite) [![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/git-json-resolver-semver-lite.svg)](https://www.npmjs.com/package/git-json-resolver-semver-lite)
47-
48-
```bash
49-
pnpm add git-json-resolver-semver-lite
50-
```
51-
52-
**or**
48+
Peer dependencies:
5349

5450
```bash
55-
npm install git-json-resolver-semver-lite
51+
pnpm install git-json-resolver
5652
```
5753

58-
**or**
54+
---
5955

60-
```bash
61-
yarn add git-json-resolver-semver-lite
62-
```
56+
## 🚀 Usage
6357

64-
> You need `r18gs` as a peer-dependency
58+
### 1. Direct Import
6559

66-
### Import Styles
60+
```ts
61+
import { semverMax } from "git-json-resolver-semver";
62+
import { resolveConflicts } from "git-json-resolver";
6763

68-
You can import styles globally or within specific components.
69-
70-
```css
71-
/* globals.css */
72-
@import "git-json-resolver-semver/dist";
64+
await resolveConflicts({
65+
customStrategies: {
66+
"semver-max": semverMax,
67+
},
68+
rules: {
69+
"dependencies.react": ["semver-max"],
70+
"devDependencies.vitest": ["semver-min"],
71+
},
72+
});
7373
```
7474

75-
```tsx
76-
// layout.tsx
77-
import "git-json-resolver-semver/dist/index.css";
78-
```
75+
### 2. Dynamic Loading
7976

80-
For selective imports:
81-
82-
```css
83-
/* globals.css */
84-
@import "git-json-resolver-semver/dist/client"; /** required if you are using LoaderContainer */
85-
@import "git-json-resolver-semver/dist/server/bars/bars1";
77+
```json
78+
{
79+
"plugins": ["git-json-resolver-semver"],
80+
"rules": {
81+
"dependencies.react": ["semver-max"],
82+
"devDependencies.vitest": ["semver-min"]
83+
}
84+
}
8685
```
8786

88-
### Usage
87+
**_or_** TypeScript Config
8988

90-
Using loaders is straightforward.
89+
```ts
90+
// git-json-resolver.config.ts
91+
import type { Config } from "git-json-resolver";
9192

92-
```tsx
93-
import { Bars1 } from "git-json-resolver-semver/dist/server/bars/bars1";
93+
const config: Config = {
94+
plugins: ["git-json-resolver-semver"],
95+
rules: {
96+
"dependencies.react": ["semver-max"],
97+
"devDependencies.vitest": ["semver-min"],
98+
},
99+
};
94100

95-
export default function MyComponent() {
96-
return someCondition ? <Bars1 /> : <>Something else...</>;
97-
}
101+
export default config;
98102
```
99103

100-
For detailed API and options, refer to [the API documentation](https://react18-tools.github.io/git-json-resolver-semver).
104+
---
101105

102-
**Using LoaderContainer**
106+
## ⚙️ Behavior notes
103107

104-
`LoaderContainer` is a fullscreen component. You can add this component directly in your layout and then use `useLoader` hook to toggle its visibility.
108+
- **strict** mode (default) accepts only `x.y.z`. Set non-strict to allow prereleases/ranges.
109+
- **preferValid** (default) returns the valid side when the other is invalid.
110+
- **fallback** controls behavior when neither side is valid (`ours` | `theirs` | `continue` | `error`).
105111

106-
```tsx
107-
// layout.tsx
108-
<LoaderContainer />
109-
...
110-
```
112+
## ⚙️ Strategies
111113

112-
```tsx
113-
// some other page or component
114-
import { useLoader } from "git-json-resolver-semver/dist/hooks";
115-
116-
export default MyComponent() {
117-
const { setLoading } = useLoader();
118-
useCallback(()=>{
119-
setLoading(true);
120-
...do some work
121-
setLoading(false);
122-
}, [])
123-
...
124-
}
125-
```
114+
| Strategy | Behavior | Example (`ours` vs `theirs`) | Result |
115+
| --------------- | --------------------------------------------------------------------- | ---------------------------- | ------- |
116+
| `semver-max` | Picks the higher valid semver | `1.2.3` vs `1.3.0` | `1.3.0` |
117+
| `semver-min` | Picks the lower valid semver | `2.0.0` vs `2.1.0` | `2.0.0` |
118+
| `semver-ours` | Picks `ours` if valid semver, else apply `preferValid` / `fallback` | `1.2.3` vs `banana` | `1.2.3` |
119+
| `semver-theirs` | Picks `theirs` if valid semver, else apply `preferValid` / `fallback` | `foo` vs `2.0.0` | `2.0.0` |
120+
121+
## 🙏 Acknowledgments
122+
123+
- [`git-json-resolver`](https://github.com/...) for the plugin system
124+
- [`compare-versions`](https://github.com/omichelsen/compare-versions) for lightweight semver checks
126125

127126
## License
128127

@@ -133,3 +132,4 @@ This library is licensed under the MPL-2.0 open-source license.
133132
<hr />
134133

135134
<p align="center" style="text-align:center">with 💖 by <a href="https://mayank-chaudhari.vercel.app" target="_blank">Mayank Kumar Chaudhari</a></p>
135+
```

0 commit comments

Comments
 (0)