patchy-cli 0.0.3-pr.153.9ad372b → 0.0.4-pr.154.e427e8f

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.
Files changed (2) hide show
  1. package/README.md +114 -41
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,42 +1,66 @@
1
- # patchy
1
+ # Patchy
2
2
 
3
- An opinionated command-line tool for managing Git patch workflows.
3
+ A CLI for generating and applying patches to git repositories.
4
4
 
5
- ## How it works
5
+ ## Patches vs forks
6
6
 
7
- Patchy helps you manage `.diff` patches for a repository you want to modify.
7
+ A traditional fork means maintaining a separate repository or long-lived branch. Over time, your history diverges from upstream, which can make updates painful.
8
8
 
9
- `patchy.json` (see [full config reference](#patchyjson) below)
9
+ With patches, you store changes as `.diff` files alongside the upstream repo. You can inspect them, edit them, and apply them to a fresh clone of the repo.
10
+
11
+ ## What is Patchy?
12
+
13
+ Patchy helps you **generate** and **apply** `.diff` patches for a git repo you've cloned on your machine.
14
+
15
+ It's opinionated and has [conventions](#patch-file-layout) about how the `.diff` files are stored.
16
+
17
+ ## Example
18
+
19
+ Starting a patch-based fork of https://github.com/octocat/spoon-knife.
20
+
21
+ ### Setup Patchy
22
+
23
+ Create a folder for the fork: `mkdir spoon-knife-fork && cd spoon-knife-fork`
24
+
25
+ - [Install Patchy](#install)
26
+ - Run `patchy init`
27
+ - press enter to select all the default options
28
+
29
+ `patchy init` creates your config: `./patchy.json` ([full reference](#patchyjson))
10
30
  ```json5
11
31
  {
12
32
  "repo_url": "https://github.com/octocat/spoon-knife",
13
33
  "patches_dir": "./patches/",
14
34
  "clones_dir": "./clones/",
15
35
  "repo_dir": "spoon-knife",
36
+ "ref": "main"
16
37
  }
17
38
  ```
18
39
 
19
- Initialize Patchy with:
20
- ```bash
21
- patchy init
22
- ```
23
-
24
- You can `patchy repo clone` the repo into `./clones/` to complete the setup.
25
-
26
- Now you'll have
40
+ `patchy init` also creates an empty `./patches` folder and clones the spoon-knife repo into `./clones`:
27
41
 
28
42
  ```
29
43
  ./
30
44
  ├── patches/
31
45
  ├── clones/
32
46
  │ └── spoon-knife/
33
- ├── path/to/existingFile.txt
47
+ └── path/to/existingFile.txt
34
48
  └── patchy.json
35
49
  ```
36
50
 
37
- Now you can make changes directly to `./clones/spoon-knife`
51
+ ### Make changes to the cloned repo
52
+
53
+ We can now make changes directly in the cloned spoon-knife repo:
54
+
55
+ ```bash
56
+ echo "edit existing file" >> clones/spoon-knife/path/to/existingFile.txt
57
+ echo "new file" > clones/spoon-knife/path/to/newFile.txt
58
+ ```
59
+
60
+ ### Generate patches:
61
+
62
+ To generate the patches for the changes run `patchy generate`:
38
63
 
39
- And generate patches with `patchy generate`
40
64
 
41
65
  ```
42
66
  ./
@@ -49,36 +73,37 @@ And generate patches with `patchy generate`
49
73
  │ └── path/to/newFile.txt
50
74
  └── patchy.json
51
75
  ```
52
-
53
76
  - **Edits** are stored as `.diff` files e.g. `existingFile.txt.diff`.
54
- - **New files** are copied as regular files e.g. `newFile.txt`.
55
-
56
- You can reapply your changes later with:
77
+ - **New files** are copied as regular files e.g. `newFile.txt` (easier to inspect and edit directly).
57
78
 
58
- `patchy apply`
79
+ ### Reapplying patches:
59
80
 
60
- ### `patchy.json`
81
+ Reset the current upstream repo `patchy repo reset main`, which will reset everything to `main`:
61
82
 
62
- ```jsonc
63
- {
64
- // Git URL to clone from.
65
- "repo_url": "https://github.com/example/repo.git", // Override: --repo-url | env: PATCHY_REPO_URL
66
-
67
- // Path to repo you're generating patches from or applying patches to.
68
- "repo_dir": "~/repos/repo", // Override: --repo-dir | env: PATCHY_REPO_DIR
69
-
70
- // Directory containing patch files.
71
- "patches_dir": "./patches/", // Override: --patches-dir | env: PATCHY_PATCHES_DIR
83
+ ```
84
+ ./
85
+ ├── clones/
86
+ │ └── spoon-knife/ <<< reset
87
+ │ ├── path/to/existingFile.txt
88
+ ├── patches/
89
+ │ ├── path/to/existingFile.txt.diff
90
+ │ └── path/to/newFile.txt
91
+ └── patchy.json
92
+ ```
72
93
 
73
- // Parent directory for cloning repos. You can easily clone more repos here from repo_url.
74
- "clones_dir": "./clones/", // Override: --clones-dir | env: PATCHY_CLONES_DIR
94
+ Apply the patches back to the cloned repo with: `patchy apply`
75
95
 
76
- // Git ref to checkout (branch, tag, SHA).
77
- "ref": "main" // Override: --ref | env: PATCHY_REF
78
- }
79
96
  ```
80
-
81
- Precedence: CLI flags > Environment variables > `patchy.json`
97
+ ./
98
+ ├── clones/
99
+ │ └── spoon-knife/
100
+ │ ├── path/to/existingFile.txt (modified)
101
+ │ └── path/to/newFile.txt (added)
102
+ ├── patches/
103
+ │ ├── path/to/existingFile.txt.diff
104
+ │ └── path/to/newFile.txt
105
+ └── patchy.json
106
+ ```
82
107
 
83
108
  ## Getting started
84
109
 
@@ -104,14 +129,60 @@ Or use directly without installing:
104
129
  npx patchy-cli@latest
105
130
  ```
106
131
 
107
- ### Initialize patchy
132
+ ### Initialize Patchy
108
133
 
109
- Run this command to initialize patchy in your project:
134
+ Run this command to initialize Patchy in your project folder:
110
135
 
111
136
  ```sh
112
137
  patchy init
113
138
  ```
114
139
 
140
+ ## `patchy.json` reference
141
+
142
+ ```jsonc
143
+ {
144
+ // Git URL to clone from.
145
+ "repo_url": "https://github.com/example/repo.git", // Override: --repo-url | env: PATCHY_REPO_URL
146
+
147
+ // Path to repo you're generating patches from or applying patches to.
148
+ "repo_dir": "~/repos/repo", // Override: --repo-dir | env: PATCHY_REPO_DIR
149
+
150
+ // Directory containing patch files.
151
+ "patches_dir": "./patches/", // Override: --patches-dir | env: PATCHY_PATCHES_DIR
152
+
153
+ // Parent directory for cloning repos. You can easily clone more repos here from repo_url.
154
+ "clones_dir": "./clones/", // Override: --clones-dir | env: PATCHY_CLONES_DIR
155
+
156
+ // Git ref to checkout (branch, tag, SHA).
157
+ "ref": "main" // Override: --ref | env: PATCHY_REF
158
+ }
159
+ ```
160
+ Precedence: CLI flags > Environment variables > `patchy.json`
161
+
162
+ `patchy.json` use jsonc, so comments are allowed.
163
+
164
+ ## Patch file layout
165
+
166
+ The `patches/` directory (customizable via [`patches_dir`](#patchyjson)) uses the same folder structure as `repo_dir`:
167
+
168
+ ```
169
+ ./
170
+ ├── patches/
171
+ │ ├── path/to/existingFile.txt.diff
172
+ │ └── path/to/newFile.txt
173
+ ├── clones/
174
+ │ └── repo-clone-1/
175
+ │ ├── path/to/existingFile.txt (modified)
176
+ │ └── path/to/newFile.txt (added)
177
+ └── patchy.json
178
+ ```
179
+
180
+ **Two types of patch files:**
181
+ - **`.diff` files** — For modified existing files (generated via `git diff HEAD`)
182
+ - **Plain files** — For newly added files (copied verbatim for easier inspection and editing)
183
+
184
+ `patchy generate` automatically removes stale files in `patches/` that no longer correspond to changes in `repo_dir`.
185
+
115
186
  ## Commands
116
187
 
117
188
  ### `patchy generate`
@@ -122,6 +193,8 @@ Generate `.diff` files and new files into `./patches/` based on current `git dif
122
193
  patchy generate [--repo-dir] [--patches-dir] [--dry-run]
123
194
  ```
124
195
 
196
+ Note: `patchy generate` is destructive and will remove any unneeded files in your `./patches/` folder.
197
+
125
198
  ### `patchy apply`
126
199
 
127
200
  Apply patch files from `patches/` into `repo_dir`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchy-cli",
3
- "version": "0.0.3-pr.153.9ad372b",
3
+ "version": "0.0.4-pr.154.e427e8f",
4
4
  "description": "A CLI tool for managing Git patch workflows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -60,11 +60,11 @@
60
60
  "url": "https://github.com/richardgill/patchy"
61
61
  },
62
62
  "optionalDependencies": {
63
- "patchy-cli-linux-x64": "0.0.3-pr.153.9ad372b",
64
- "patchy-cli-linux-arm64": "0.0.3-pr.153.9ad372b",
65
- "patchy-cli-darwin-x64": "0.0.3-pr.153.9ad372b",
66
- "patchy-cli-darwin-arm64": "0.0.3-pr.153.9ad372b",
67
- "patchy-cli-windows-x64": "0.0.3-pr.153.9ad372b"
63
+ "patchy-cli-linux-x64": "0.0.4-pr.154.e427e8f",
64
+ "patchy-cli-linux-arm64": "0.0.4-pr.154.e427e8f",
65
+ "patchy-cli-darwin-x64": "0.0.4-pr.154.e427e8f",
66
+ "patchy-cli-darwin-arm64": "0.0.4-pr.154.e427e8f",
67
+ "patchy-cli-windows-x64": "0.0.4-pr.154.e427e8f"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public"