venfork 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 cabljac
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,514 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/cabljac/venfork/refs/heads/main/assets/logo.svg" alt="Venfork Logo" width="200" />
3
+ </p>
4
+
5
+ # 🔧 Venfork
6
+
7
+ [![CI](https://github.com/cabljac/venfork/actions/workflows/ci.yml/badge.svg)](https://github.com/cabljac/venfork/actions/workflows/ci.yml)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ Create and manage private mirrors of public GitHub repositories for vendor development workflows.
11
+
12
+ ## What is Venfork?
13
+
14
+ Venfork helps contractors and vendors who need to work on private forks of public repositories. It creates a **three-repository workflow**:
15
+
16
+ 1. **Private Mirror** (`yourname/project-vendor` or `org/project-vendor`) - Where your team works internally
17
+ 2. **Public Fork** (`yourname/project` or `org/project`) - Staging area for contributions to upstream
18
+ 3. **Upstream** (`original/project`) - The original repository
19
+
20
+ > **Note:** Repos can be created under your personal account or under an organization using the `--org` flag.
21
+
22
+ ### Why Three Repositories?
23
+
24
+ **The Key Insight:**
25
+ > "The private mirror is completely disconnected from the public fork, allowing teams to experiment freely before presenting work to the client"
26
+
27
+ The private mirror is:
28
+ - ✅ Completely disconnected from the public fork
29
+ - ✅ Safe space to experiment, iterate, and refine work
30
+ - ✅ All internal PRs, reviews, and experiments stay private
31
+ - ✅ Only visible to your team
32
+
33
+ When you run `venfork stage`, your work becomes visible on the public fork and ready for PR to upstream.
34
+
35
+ ## Prerequisites
36
+
37
+ Before using Venfork, ensure you have:
38
+
39
+ - **Node.js 18+** or **Bun** (for running the CLI)
40
+ - **GitHub CLI (`gh`)** installed and authenticated
41
+ ```bash
42
+ # Install gh (macOS)
43
+ brew install gh
44
+
45
+ # Authenticate
46
+ gh auth login
47
+ ```
48
+ - **Git** configured with SSH keys for GitHub
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ # Install globally with npm
54
+ npm install -g venfork
55
+
56
+ # Or with Bun
57
+ bun install -g venfork
58
+
59
+ # Or use with npx (no installation needed)
60
+ npx venfork setup <repo-url>
61
+ ```
62
+
63
+ ## Quick Start
64
+
65
+ ```bash
66
+ # 1a. One-time setup (first team member, personal account)
67
+ venfork setup git@github.com:awesome/project.git
68
+
69
+ # Or for organization repos
70
+ venfork setup git@github.com:awesome/project.git --org my-company
71
+
72
+ # 1b. Clone existing setup (other team members)
73
+ venfork clone git@github.com:yourname/project-vendor.git
74
+
75
+ cd project-vendor
76
+
77
+ # 2. Work privately
78
+ git checkout -b feature/new-thing
79
+ # ... experiment, iterate, refine ...
80
+ git push origin feature/new-thing
81
+ # Still private! Create internal PR for team review
82
+
83
+ # 3. Stage for upstream (after internal approval)
84
+ venfork stage feature/new-thing
85
+ # NOW visible on public fork
86
+ # Create PR: public fork → upstream
87
+ ```
88
+
89
+ ## Commands
90
+
91
+ ### `venfork setup <upstream-url> [name] [--org <organization>]`
92
+
93
+ Creates the complete vendor workflow setup:
94
+
95
+ **What it creates:**
96
+ - **Private mirror** (`yourname/project-vendor` or `org/project-vendor`) - For internal work
97
+ - **Public fork** (`yourname/project` or `org/project`) - For staging to upstream
98
+ - **Local clone** with three remotes configured:
99
+ - `origin` → private mirror (default push/pull)
100
+ - `public` → public fork (for staging)
101
+ - `upstream` → original repo (read-only, push disabled)
102
+
103
+ **Arguments:**
104
+ - `upstream-url` - GitHub repository URL (SSH or HTTPS)
105
+ - `name` - (Optional) Name for private vendor repo (default: `{repo}-vendor`)
106
+ - `--org <organization>` - (Optional) Create repos under organization instead of personal account
107
+
108
+ **Examples:**
109
+ ```bash
110
+ # Personal account (default)
111
+ venfork setup git@github.com:vercel/next.js.git
112
+ # Creates: yourname/next.js-vendor (private), yourname/next.js (public fork)
113
+
114
+ venfork setup https://github.com/vuejs/vue.git vue-internal
115
+ # Creates: yourname/vue-internal (private), yourname/vue (public fork)
116
+
117
+ # Organization account
118
+ venfork setup git@github.com:client/awesome-project.git --org acme-corp
119
+ # Creates: acme-corp/awesome-project-vendor (private), acme-corp/awesome-project (public fork)
120
+
121
+ venfork setup git@github.com:client/project.git internal-mirror --org my-company
122
+ # Creates: my-company/internal-mirror (private), my-company/project (public fork)
123
+ ```
124
+
125
+ ### `venfork clone <vendor-repo-url>`
126
+
127
+ Clone an existing vendor setup and automatically configure all remotes.
128
+
129
+ **What it does:**
130
+ - Clones the private vendor repository
131
+ - Auto-detects the public fork (by stripping `-vendor` suffix)
132
+ - Auto-detects the upstream repository (from public fork's parent)
133
+ - Configures all three remotes (origin, public, upstream)
134
+ - Disables push to upstream (read-only)
135
+
136
+ **Use this when:**
137
+ - A teammate has already run `venfork setup`
138
+ - You need to clone an existing vendor setup
139
+ - You want automatic remote configuration
140
+
141
+ **Arguments:**
142
+ - `vendor-repo-url` - GitHub URL of the private vendor repository (SSH or HTTPS)
143
+
144
+ **Examples:**
145
+ ```bash
146
+ # Clone existing vendor setup (personal account)
147
+ venfork clone git@github.com:yourname/project-vendor.git
148
+ # Auto-detects: public fork at yourname/project
149
+ # Auto-detects: upstream from public fork's parent
150
+
151
+ # Clone organization vendor setup
152
+ venfork clone git@github.com:acme-corp/awesome-project-vendor.git
153
+ # Auto-detects: public fork at acme-corp/awesome-project
154
+ # Auto-detects: upstream from public fork's parent
155
+ ```
156
+
157
+ **Interactive prompts:**
158
+ - If public fork cannot be auto-detected, you'll be prompted for the URL
159
+ - If upstream cannot be auto-detected (no parent), you'll be prompted for the URL
160
+
161
+ ### `venfork sync [branch]`
162
+
163
+ Update the default branches of your private mirror and public fork to match upstream.
164
+
165
+ **Arguments:**
166
+ - `branch` - (Optional) Upstream branch to sync (default: auto-detected, usually `main` or `master`)
167
+
168
+ **Examples:**
169
+ ```bash
170
+ venfork sync # Sync default branches with upstream
171
+ venfork sync develop # Sync develop branch with upstream/develop
172
+ ```
173
+
174
+ **What it does:**
175
+ 1. Fetches latest changes from all remotes (upstream, origin, public)
176
+ 2. Checks for divergent commits (warns if found to prevent data loss)
177
+ 3. Force pushes upstream's default branch to origin and public
178
+ 4. **Does not affect your current working branch or feature branches**
179
+
180
+ **Important:**
181
+ - This keeps your default branches (main/master) in sync with upstream
182
+ - Your current work on feature branches is completely unaffected
183
+ - If divergent commits are detected, sync will abort to prevent data loss
184
+
185
+ ### `venfork status`
186
+
187
+ Check the current repository setup and configuration.
188
+
189
+ **What it shows:**
190
+ - Current branch
191
+ - All configured git remotes (fetch and push URLs)
192
+ - Setup completion status (✓/✗ for origin, public, upstream)
193
+ - Next steps if setup is incomplete
194
+
195
+ **Examples:**
196
+ ```bash
197
+ venfork status
198
+ ```
199
+
200
+ **Use this command to:**
201
+ - Verify your venfork setup is complete
202
+ - Debug remote configuration issues
203
+ - Check which remotes are configured
204
+ - See your current branch
205
+
206
+ ### `venfork stage <branch>`
207
+
208
+ Push a branch to the public fork, making it visible and ready for PR to upstream.
209
+
210
+ **⚠️ Important:** This is when your work becomes visible to the client!
211
+
212
+ **Arguments:**
213
+ - `branch` - Branch name to stage
214
+
215
+ **Examples:**
216
+ ```bash
217
+ venfork stage feature-auth
218
+ venfork stage bugfix/issue-123
219
+ ```
220
+
221
+ **What it does:**
222
+ 1. Verifies branch exists
223
+ 2. Shows staging details and confirmation
224
+ 3. Pushes to public fork
225
+ 4. Provides PR creation link
226
+
227
+ ## Environment Variables
228
+
229
+ ### `VENFORK_ORG`
230
+
231
+ Set a default organization for all venfork commands. This avoids having to type `--org` every time.
232
+
233
+ **Priority order:**
234
+ 1. `--org` flag (highest priority - always overrides)
235
+ 2. `VENFORK_ORG` environment variable
236
+ 3. Personal account (prompts for confirmation)
237
+
238
+ **Usage:**
239
+
240
+ ```bash
241
+ # Set in your shell profile (~/.zshrc, ~/.bashrc, etc.)
242
+ export VENFORK_ORG=my-company
243
+
244
+ # Now all commands use this org by default
245
+ venfork setup git@github.com:client/project.git
246
+ # Creates: my-company/project-vendor (private), my-company/project (public fork)
247
+
248
+ # Override with --org flag when needed
249
+ venfork setup git@github.com:other-client/app.git --org different-org
250
+ # Creates: different-org/app-vendor (private), different-org/app (public fork)
251
+ ```
252
+
253
+ **Safety feature:**
254
+ If neither `--org` nor `VENFORK_ORG` is set, venfork will prompt for confirmation before creating repos under your personal account. This prevents accidental personal repo creation when working as a vendor/contractor.
255
+
256
+ ```bash
257
+ # Without VENFORK_ORG or --org
258
+ venfork setup git@github.com:client/project.git
259
+
260
+ # Output:
261
+ # ⚠️ No organization specified
262
+ # Repos will be created under your personal account (username: yourname)
263
+ # Continue with personal account? (y/N)
264
+ ```
265
+
266
+ ## Complete Workflow
267
+
268
+ ### Initial Setup
269
+
270
+ ```bash
271
+ # Clone and configure the repos (personal account)
272
+ venfork setup git@github.com:client/awesome-project.git
273
+
274
+ # Or for organization
275
+ venfork setup git@github.com:client/awesome-project.git --org acme-corp
276
+
277
+ # Navigate to private mirror
278
+ cd awesome-project-vendor
279
+
280
+ # Check setup status
281
+ venfork status
282
+
283
+ # Or verify remotes manually
284
+ git remote -v
285
+ # With personal account:
286
+ # origin git@github.com:you/awesome-project-vendor.git (private)
287
+ # public git@github.com:you/awesome-project.git (public fork)
288
+ # upstream git@github.com:client/awesome-project.git (read-only)
289
+
290
+ # With organization:
291
+ # origin git@github.com:acme-corp/awesome-project-vendor.git (private)
292
+ # public git@github.com:acme-corp/awesome-project.git (public fork)
293
+ # upstream git@github.com:client/awesome-project.git (read-only)
294
+ ```
295
+
296
+ ### Daily Development
297
+
298
+ ```bash
299
+ # Sync default branches with upstream (optional, keeps main up-to-date)
300
+ venfork sync
301
+
302
+ # Create feature branch
303
+ git checkout -b feature/user-auth
304
+
305
+ # Make changes, commit
306
+ git add .
307
+ git commit -m "Add user authentication"
308
+
309
+ # Push to private mirror
310
+ git push origin feature/user-auth
311
+
312
+ # Create PR in private repo for team review
313
+ # Review happens internally, invisible to client
314
+ ```
315
+
316
+ ### Internal Review Process
317
+
318
+ ```bash
319
+ # Team reviews PR in private repo
320
+ # Experiment, iterate, refine approach
321
+ # All feedback and changes stay private
322
+
323
+ # Once approved internally, merge to main
324
+ git checkout main
325
+ git merge feature/user-auth
326
+ git push origin main
327
+ ```
328
+
329
+ ### Staging for Upstream
330
+
331
+ ```bash
332
+ # When ready to contribute back
333
+ venfork stage feature/user-auth
334
+
335
+ # Output shows:
336
+ # ✓ Branch staged to public fork
337
+ # 🔗 Create PR: https://github.com/client/awesome-project/compare/...
338
+
339
+ # NOW visible to client
340
+ # Create PR from public fork → upstream
341
+ ```
342
+
343
+ ## Repository Structure
344
+
345
+ ```
346
+ ┌─────────────────────────────────────────────┐
347
+ │ Upstream (client/project) │
348
+ │ • Original repository │
349
+ │ • Read-only for you │
350
+ └──────────────────┬──────────────────────────┘
351
+
352
+ │ fork
353
+
354
+ ┌─────────────────────────────────────────────┐
355
+ │ Public Fork (you/project or org/project) │
356
+ │ • Visible to everyone │
357
+ │ • Staging area for PRs │
358
+ │ • Only pushed to via `venfork stage` │
359
+ └──────────────────┬──────────────────────────┘
360
+
361
+ │ mirror (disconnected)
362
+
363
+ ┌─────────────────────────────────────────────┐
364
+ │ Private Mirror (you/project-vendor) │
365
+ │ (or org/project-vendor) │
366
+ │ • Only visible to your team │
367
+ │ • Safe space to experiment & iterate │
368
+ │ • Internal PRs and reviews │
369
+ │ • Your daily work happens here │
370
+ └─────────────────────────────────────────────┘
371
+ ```
372
+
373
+ ## Configuration
374
+
375
+ ### Git Remotes
376
+
377
+ After `venfork setup`, your local repository has three remotes:
378
+
379
+ | Remote | URL | Purpose |
380
+ |--------|-----|---------|
381
+ | `origin` | `you/project-vendor` (or `org/project-vendor`) | Private work (default) |
382
+ | `public` | `you/project` (or `org/project`) | Stage for upstream |
383
+ | `upstream` | `original/project` | Sync with latest |
384
+
385
+ **Note:** When using `--org`, all repos are created under the specified organization.
386
+
387
+ ### Default Behavior
388
+
389
+ - `git push` → Pushes to `origin` (private mirror)
390
+ - `git pull` → Pulls from `origin` (private mirror)
391
+ - `venfork sync` → Updates default branches of `origin` and `public` to match `upstream`
392
+ - `venfork stage` → Pushes to `public`
393
+
394
+ ## Troubleshooting
395
+
396
+ ### Check Your Setup
397
+
398
+ If you encounter issues, run `venfork status` first to check:
399
+ - Whether you're in a git repository
400
+ - Which remotes are configured
401
+ - If setup is complete
402
+
403
+ ### "GitHub CLI is not authenticated"
404
+
405
+ Run `gh auth login` and follow the prompts to authenticate.
406
+
407
+ ### "Not in a git repository"
408
+
409
+ Make sure you're inside the cloned vendor repository directory. Run `venfork status` to verify.
410
+
411
+ ### "Remote not found" (origin/public/upstream)
412
+
413
+ This means `venfork setup` wasn't run or didn't complete successfully.
414
+ - Run `venfork status` to see which remotes are missing
415
+ - Re-run `venfork setup` if needed
416
+
417
+ ### Divergent Commits Warning
418
+
419
+ If `venfork sync` detects commits on your default branch that aren't in upstream:
420
+ 1. This suggests work was committed directly to main/master (not recommended)
421
+ 2. Sync will abort to prevent losing these commits
422
+ 3. To preserve: manually rebase or cherry-pick them to a feature branch
423
+ 4. To force sync anyway: `git push origin upstream/main:main -f` (loses commits)
424
+
425
+ ### Branch Already Exists on Public Fork
426
+
427
+ If you've staged a branch before and need to update it:
428
+
429
+ ```bash
430
+ git push public feature-branch --force
431
+ ```
432
+
433
+ ## Development
434
+
435
+ ```bash
436
+ # Install dependencies (npm or bun)
437
+ npm install
438
+ # or
439
+ bun install
440
+
441
+ # Run tests
442
+ npm test
443
+ # or
444
+ bun test
445
+
446
+ # Run tests in watch mode
447
+ npm run test:watch
448
+ # or
449
+ bun run test:watch
450
+
451
+ # Run tests with coverage
452
+ npm run test:coverage
453
+ # or
454
+ bun run test:coverage
455
+
456
+ # Run in development mode
457
+ npm run dev setup --help
458
+ # or
459
+ bun run dev setup --help
460
+
461
+ # Build
462
+ npm run build
463
+ # or
464
+ bun run build
465
+
466
+ # Link for local testing
467
+ npm link
468
+ # or
469
+ bun link
470
+
471
+ # Format code
472
+ npm run format
473
+
474
+ # Lint code
475
+ npm run lint
476
+
477
+ # Check and fix all issues
478
+ npm run check
479
+ ```
480
+
481
+ ## Tech Stack
482
+
483
+ - **Runtime:** Node.js 18+ (or Bun for faster development)
484
+ - **Language:** TypeScript (strict mode)
485
+ - **Shell Execution:** execa
486
+ - **CLI Framework:** @clack/prompts
487
+ - **Code Quality:** Biome
488
+
489
+ ## License
490
+
491
+ MIT
492
+
493
+ ## Contributing
494
+
495
+ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) to get started.
496
+
497
+ Key steps:
498
+ 1. Fork and clone the repository
499
+ 2. Install dependencies: `bun install`
500
+ 3. Make your changes and add tests
501
+ 4. Run checks: `bun run check && bun test`
502
+ 5. Add a changeset: `bun run changeset`
503
+ 6. Submit a pull request
504
+
505
+ ## Support
506
+
507
+ If you encounter any issues or have questions:
508
+ 1. Check the [Troubleshooting](#troubleshooting) section
509
+ 2. Open an issue on GitHub
510
+ 3. Ensure you have the latest version installed
511
+
512
+ ---
513
+
514
+ Built with ❤️ for teams who need private vendor workflows
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
+ <svg fill="#22c55e" width="800px" height="800px" viewBox="0 0 36 36" version="1.1" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>forking-line</title>
4
+ <path d="M18.37,21.71,10.3,16.88a1,1,0,0,1-.47-.83V6.27l2.24,3A1,1,0,0,0,13.66,8l-4-5.33A1,1,0,0,0,8,2.69L4,8a1,1,0,0,0,.2,1.4,1,1,0,0,0,.6.2,1,1,0,0,0,.8-.39l2.23-3v9.78A3,3,0,0,0,9.28,18.6l8.06,4.82A1.37,1.37,0,0,1,18,24.59v8.83a1,1,0,0,0,2,0V24.59A3.37,3.37,0,0,0,18.37,21.71Z"/><path d="M31.66,8l-4-5.33a1,1,0,0,0-1.59,0L22,8a1,1,0,0,0,.2,1.4,1,1,0,0,0,.6.2,1,1,0,0,0,.8-.39l2.32-3.07v9.89a1,1,0,0,1-.47.83l-.11.08-4.87,3.88a5.52,5.52,0,0,1,1.11,1.68l5-4a3,3,0,0,0,1.38-2.51V6.38l2.15,2.85A1,1,0,1,0,31.66,8Z"/>
5
+ <rect x="0" y="0" width="36" height="36" fill-opacity="0"/>
6
+ </svg>