patchy-cli 0.0.3 → 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 +136 -44
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,98 +1,188 @@
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
- 1. Clone repo `~/target-1`
8
- 2. Make some edits (the patches!)
9
- 3. Create a repo for your patches → `~/my-patches`
10
- 3. `patchy generate --repo ~/target-1` → Creates `~/my-patches/patches/*.diff`
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.
11
8
 
12
- Then reapply your changes later with:
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.
13
10
 
14
- 5. `patchy apply --repo ~/target-1` → `~/target-1` (patches applied)
11
+ ## What is Patchy?
15
12
 
13
+ Patchy helps you **generate** and **apply** `.diff` patches for a git repo you've cloned on your machine.
16
14
 
17
- ### `patches/` folder structure
15
+ It's opinionated and has [conventions](#patch-file-layout) about how the `.diff` files are stored.
18
16
 
19
- Patch files are stored in the same folder structure as the target repo:
17
+ ## Example
20
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))
30
+ ```json5
31
+ {
32
+ "repo_url": "https://github.com/octocat/spoon-knife",
33
+ "patches_dir": "./patches/",
34
+ "clones_dir": "./clones/",
35
+ "repo_dir": "spoon-knife",
36
+ "ref": "main"
37
+ }
21
38
  ```
22
- ~/target-1/
23
- └── path/in/repo/existingFile.txt
24
- ```
39
+
40
+ `patchy init` also creates an empty `./patches` folder and clones the spoon-knife repo into `./clones`:
25
41
 
26
42
  ```
27
- my-patch-repo/
43
+ ./
28
44
  ├── patches/
29
- ├── path/in/repo/existingFile.txt.diff
30
- │ └── path/in/repo/newFile.txt
45
+ ├── clones/
46
+ │ └── spoon-knife/
47
+ │ └── path/to/existingFile.txt
31
48
  └── patchy.json
32
49
  ```
33
50
 
34
- - **Edits** are stored as `.diff` files e.g. `existingFile.txt.diff`.
35
- - **New files** are stored as regular files e.g. `newFile.txt`.
51
+ ### Make changes to the cloned repo
36
52
 
37
- ### `patchy.json`
53
+ We can now make changes directly in the cloned spoon-knife repo:
38
54
 
39
- ```jsonc
40
- {
41
- // Git URL to clone from.
42
- "repo_url": "https://github.com/example/repo.git", // Override: --repo-url | env: PATCHY_REPO_URL
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
+ ```
43
59
 
44
- // Path to repo you're generating patches from or applying patches to.
45
- "repo_dir": "~/repos/repo", // Override: --repo-dir | env: PATCHY_REPO_DIR
60
+ ### Generate patches:
46
61
 
47
- // Directory containing patch files.
48
- "patches_dir": "./patches/", // Override: --patches-dir | env: PATCHY_PATCHES_DIR
62
+ To generate the patches for the changes run `patchy generate`:
49
63
 
50
- // Parent directory for cloning repos. You can easily clone more repos here from repo_url.
51
- "clones_dir": "./clones/", // Override: --clones-dir | env: PATCHY_CLONES_DIR
52
64
 
53
- // Git ref to checkout (branch, tag, SHA).
54
- "ref": "main" // Override: --ref | env: PATCHY_REF
55
- }
56
65
  ```
66
+ ./
67
+ ├── clones/
68
+ │ └── spoon-knife/
69
+ │ ├── path/to/existingFile.txt
70
+ │ └── path/to/newFile.txt
71
+ ├── patches/
72
+ │ ├── path/to/existingFile.txt.diff
73
+ │ └── path/to/newFile.txt
74
+ └── patchy.json
75
+ ```
76
+ - **Edits** are stored as `.diff` files e.g. `existingFile.txt.diff`.
77
+ - **New files** are copied as regular files e.g. `newFile.txt` (easier to inspect and edit directly).
57
78
 
58
- Precedence: CLI flags > Environment variables > `patchy.json`
79
+ ### Reapplying patches:
59
80
 
60
- ## Getting started
81
+ Reset the current upstream repo `patchy repo reset main`, which will reset everything to `main`:
61
82
 
62
- ### Installation
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
+ ```
93
+
94
+ Apply the patches back to the cloned repo with: `patchy apply`
63
95
 
64
- ```sh
65
- curl -fsSL https://raw.githubusercontent.com/richardgill/patchy/main/install | bash
96
+ ```
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
66
106
  ```
67
107
 
68
- Or via npm:
108
+ ## Getting started
69
109
 
70
- **Install script (recommended):**
110
+ ### Installation
71
111
 
72
112
  ```sh
73
113
  curl -fsSL https://raw.githubusercontent.com/richardgill/patchy/main/install | bash
114
+ # follow instructions
115
+ patchy
74
116
  ```
75
117
 
76
- **Via npm:**
118
+ Or via npm:
119
+
77
120
 
78
121
  ```sh
79
122
  npm install -g patchy-cli
123
+ patchy-cli
80
124
  ```
81
125
 
82
126
  Or use directly without installing:
83
127
 
84
128
  ```sh
85
- npx patchy-cli --version
129
+ npx patchy-cli@latest
86
130
  ```
87
131
 
88
- ### Initialize patchy
132
+ ### Initialize Patchy
89
133
 
90
- Run this command to initialize patchy in your project:
134
+ Run this command to initialize Patchy in your project folder:
91
135
 
92
136
  ```sh
93
137
  patchy init
94
138
  ```
95
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
+
96
186
  ## Commands
97
187
 
98
188
  ### `patchy generate`
@@ -103,6 +193,8 @@ Generate `.diff` files and new files into `./patches/` based on current `git dif
103
193
  patchy generate [--repo-dir] [--patches-dir] [--dry-run]
104
194
  ```
105
195
 
196
+ Note: `patchy generate` is destructive and will remove any unneeded files in your `./patches/` folder.
197
+
106
198
  ### `patchy apply`
107
199
 
108
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",
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",
64
- "patchy-cli-linux-arm64": "0.0.3",
65
- "patchy-cli-darwin-x64": "0.0.3",
66
- "patchy-cli-darwin-arm64": "0.0.3",
67
- "patchy-cli-windows-x64": "0.0.3"
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"