@gw-tools/gw 0.12.15 → 0.12.17

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 +120 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -39,6 +39,10 @@ A command-line tool for managing git worktrees, built with Deno.
39
39
  - [Options](#options-3)
40
40
  - [Examples](#examples-5)
41
41
  - [When to Use](#when-to-use)
42
+ - [show-init](#show-init)
43
+ - [Options](#options-6)
44
+ - [Examples](#examples-8)
45
+ - [When to Use](#when-to-use-1)
42
46
  - [sync](#sync)
43
47
  - [Arguments](#arguments-2)
44
48
  - [Options](#options-4)
@@ -98,6 +102,55 @@ gw add feat-another-feature
98
102
  gw cd feat-another-feature
99
103
  ```
100
104
 
105
+ ## Initial Setup: Secrets in the Default Branch
106
+
107
+ **Important:** Before using `gw add` with auto-copy, ensure your secrets and environment files exist in your `defaultBranch` worktree (typically `main`). This worktree is the **source** from which files are copied to new worktrees.
108
+
109
+ ### First-Time Setup Flow
110
+
111
+ ```bash
112
+ # 1. Set up your bare repository structure
113
+ git clone --bare https://github.com/user/repo.git repo.git
114
+ cd repo.git
115
+
116
+ # 2. Create the main worktree (your defaultBranch)
117
+ git worktree add main main
118
+
119
+ # 3. Set up secrets in the main worktree FIRST
120
+ cd main
121
+ cp .env.example .env # Create your environment file
122
+ # Edit .env with your actual secrets, API keys, etc.
123
+ mkdir -p secrets/
124
+ # Add any other secret files your project needs
125
+
126
+ # 4. Initialize gw with auto-copy configuration
127
+ gw init --auto-copy-files .env,secrets/
128
+
129
+ # 5. Now create feature worktrees - files are copied automatically from main
130
+ cd ..
131
+ gw add feat-new-feature
132
+ # .env and secrets/ are automatically copied from main to feat-new-feature
133
+ ```
134
+
135
+ ### Why This Matters
136
+
137
+ - **`gw add`** copies files **from** your `defaultBranch` worktree **to** the new worktree
138
+ - **`gw sync`** also uses `defaultBranch` as the source (unless `--from` is specified)
139
+ - **Auto-clean** will **never** remove the `defaultBranch` worktree, ensuring your source files are always available
140
+ - If secrets don't exist in `defaultBranch`, they won't be copied to new worktrees
141
+
142
+ ### Keeping Secrets Updated
143
+
144
+ When you update secrets in your `defaultBranch` worktree, sync them to existing worktrees:
145
+
146
+ ```bash
147
+ # Sync all autoCopyFiles to an existing worktree
148
+ gw sync feat-existing-branch
149
+
150
+ # Or sync specific files
151
+ gw sync feat-existing-branch .env
152
+ ```
153
+
101
154
  ## Features
102
155
 
103
156
  - **Quick navigation**: Navigate to worktrees instantly with smart partial matching (`gw cd feat` finds `feat-branch`)
@@ -490,6 +543,7 @@ gw init [options]
490
543
 
491
544
  #### Options
492
545
 
546
+ - `-i, --interactive`: Interactively prompt for configuration options
493
547
  - `--root <path>`: Specify the git repository root path (optional, auto-detects if not provided)
494
548
  - `--default-source <name>`: Set the default source worktree (default: "main")
495
549
  - `--auto-copy-files <files>`: Comma-separated list of files to auto-copy when creating worktrees with `gw add`
@@ -502,6 +556,9 @@ gw init [options]
502
556
  #### Examples
503
557
 
504
558
  ```bash
559
+ # Interactive mode - prompts for all configuration options
560
+ gw init --interactive
561
+
505
562
  # Initialize with auto-detected root
506
563
  gw init
507
564
 
@@ -557,8 +614,9 @@ gw init --auto-clean --auto-copy-files .env --post-add "pnpm install"
557
614
  ```
558
615
 
559
616
  **How it works:**
560
- - Runs automatically on `gw add` and `gw list` commands
617
+ - Runs automatically on `gw add` and `gw list` commands (in the background, non-blocking)
561
618
  - Only runs once per 24 hours (cooldown)
619
+ - **Never removes the `defaultBranch` worktree** - it's protected as the source for file syncing
562
620
  - Removes worktrees older than `cleanThreshold` with:
563
621
  - No uncommitted changes
564
622
  - No staged files
@@ -579,6 +637,67 @@ Use `gw init` to:
579
637
 
580
638
  The config file is created at `.gw/config.json` at the git root, so it's shared across all worktrees.
581
639
 
640
+ ### show-init
641
+
642
+ Generate a `gw init` command that matches your current configuration. This is useful for documentation or recreating the same configuration in another repository.
643
+
644
+ ```bash
645
+ gw show-init [options]
646
+ ```
647
+
648
+ #### Options
649
+
650
+ - `-h, --help`: Show help message
651
+
652
+ #### Examples
653
+
654
+ ```bash
655
+ # Show the init command for current config
656
+ gw show-init
657
+
658
+ # Copy the command to clipboard (macOS)
659
+ gw show-init | pbcopy
660
+
661
+ # Copy the command to clipboard (Linux with xclip)
662
+ gw show-init | xclip -selection clipboard
663
+
664
+ # Save to a file
665
+ gw show-init > init-command.txt
666
+
667
+ # Add to your documentation
668
+ echo "## Setup\n\n\`\`\`bash\n$(gw show-init)\n\`\`\`" >> README.md
669
+ ```
670
+
671
+ #### Output Example
672
+
673
+ If your `.gw/config.json` contains:
674
+ ```json
675
+ {
676
+ "root": "/Users/username/Workspace/repo.git",
677
+ "defaultBranch": "main",
678
+ "autoCopyFiles": [".env", "secrets/"],
679
+ "hooks": {
680
+ "add": {
681
+ "post": ["pnpm install"]
682
+ }
683
+ },
684
+ "cleanThreshold": 7
685
+ }
686
+ ```
687
+
688
+ Then `gw show-init` will output:
689
+ ```bash
690
+ gw init --root /Users/username/Workspace/repo.git --auto-copy-files .env,secrets/ --post-add 'pnpm install'
691
+ ```
692
+
693
+ #### When to Use
694
+
695
+ Use `gw show-init` to:
696
+ - Document your setup in README files or team wikis
697
+ - Share configuration commands with team members
698
+ - Recreate the same configuration in another repository
699
+ - Verify your current configuration settings as a single command
700
+
582
701
  ### sync
583
702
 
584
703
  Sync files and directories between worktrees, preserving directory structure.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gw-tools/gw",
3
- "version": "0.12.15",
3
+ "version": "0.12.17",
4
4
  "description": "A command-line tool for managing git worktrees - copy files between worktrees with ease",
5
5
  "keywords": [
6
6
  "git",