@gw-tools/gw 0.22.0-beta.1 → 0.25.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/README.md +35 -0
- package/install.js +50 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -771,6 +771,41 @@ gw install-shell --remove
|
|
|
771
771
|
|
|
772
772
|
The `--remove` flag cleans up both the new eval-based format and any legacy file-based installations.
|
|
773
773
|
|
|
774
|
+
#### Migrating from File-Based Integration
|
|
775
|
+
|
|
776
|
+
If you previously used `gw install-shell` (before v0.22), you had file-based integration:
|
|
777
|
+
|
|
778
|
+
- `~/.gw/shell/integration.zsh` (or `.bash`)
|
|
779
|
+
- A source line in your shell config
|
|
780
|
+
|
|
781
|
+
To migrate to the new eval-based approach:
|
|
782
|
+
|
|
783
|
+
1. Remove old integration:
|
|
784
|
+
|
|
785
|
+
```bash
|
|
786
|
+
gw install-shell --remove
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
2. Add new integration to your shell config:
|
|
790
|
+
|
|
791
|
+
```bash
|
|
792
|
+
# Zsh (~/.zshrc)
|
|
793
|
+
eval "$(gw install-shell)"
|
|
794
|
+
|
|
795
|
+
# Bash (~/.bashrc)
|
|
796
|
+
eval "$(gw install-shell)"
|
|
797
|
+
|
|
798
|
+
# Fish (~/.config/fish/config.fish)
|
|
799
|
+
gw install-shell | source
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
3. Restart your terminal or source your config:
|
|
803
|
+
```bash
|
|
804
|
+
source ~/.zshrc # or ~/.bashrc
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
**Why the change?** The eval-based approach ensures shell integration stays up-to-date automatically when gw is updated, without requiring manual reinstallation.
|
|
808
|
+
|
|
774
809
|
### root
|
|
775
810
|
|
|
776
811
|
Get the root directory of the current git repository. For git worktrees, returns the parent directory containing all worktrees.
|
package/install.js
CHANGED
|
@@ -197,13 +197,61 @@ function installShellIntegration() {
|
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
// Check if already present
|
|
200
|
+
// Check if already present or needs migration
|
|
201
201
|
if (fsExists(configFile)) {
|
|
202
|
-
|
|
202
|
+
let content = fsRead(configFile, 'utf8');
|
|
203
|
+
|
|
204
|
+
// Check if new eval-based integration is already present
|
|
203
205
|
if (content.includes('gw install-shell')) {
|
|
204
206
|
console.log('✓ Shell integration already configured!');
|
|
205
207
|
return;
|
|
206
208
|
}
|
|
209
|
+
|
|
210
|
+
// Check for old source-based integration and migrate
|
|
211
|
+
const hasOldSource = content.includes('source ~/.gw/shell/integration') ||
|
|
212
|
+
content.includes('source "$HOME/.gw/shell/integration');
|
|
213
|
+
if (hasOldSource) {
|
|
214
|
+
console.log(' Migrating from legacy file-based integration...');
|
|
215
|
+
|
|
216
|
+
// Remove old comment and source lines
|
|
217
|
+
const lines = content.split('\n');
|
|
218
|
+
const filtered = [];
|
|
219
|
+
let skipNext = false;
|
|
220
|
+
|
|
221
|
+
for (const line of lines) {
|
|
222
|
+
// Skip old comment line
|
|
223
|
+
if (line.includes('# gw-tools shell integration') && !line.includes('eval')) {
|
|
224
|
+
skipNext = true;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
// Skip old source line
|
|
228
|
+
if (skipNext && line.includes('source') && line.includes('.gw/shell/integration')) {
|
|
229
|
+
skipNext = false;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
skipNext = false;
|
|
233
|
+
filtered.push(line);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
content = filtered.join('\n');
|
|
237
|
+
fsWrite(configFile, content);
|
|
238
|
+
|
|
239
|
+
// Remove old integration files
|
|
240
|
+
const legacyFiles = [
|
|
241
|
+
join(home, '.gw', 'shell', 'integration.zsh'),
|
|
242
|
+
join(home, '.gw', 'shell', 'integration.bash'),
|
|
243
|
+
];
|
|
244
|
+
for (const file of legacyFiles) {
|
|
245
|
+
if (fsExists(file)) {
|
|
246
|
+
try {
|
|
247
|
+
require('fs').unlinkSync(file);
|
|
248
|
+
console.log(` Removed legacy file: ${file}`);
|
|
249
|
+
} catch {
|
|
250
|
+
// Ignore removal errors
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
207
255
|
}
|
|
208
256
|
|
|
209
257
|
// Append eval line
|