Skip to content

Commit 24f11c4

Browse files
bpodburton-pCopilot
authored
Feature/npm package updates (#9)
* Adding next steps and index fix * Adds more docs * Update index.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Burton Podczerwinski <befreestudios@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4f11708 commit 24f11c4

File tree

4 files changed

+184
-25
lines changed

4 files changed

+184
-25
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2025-04-28
9+
10+
### Added
11+
12+
- Initial public release
13+
- Interactive setup wizard for configuring git contexts
14+
- Multiple context support (personal, work, client projects, etc.)
15+
- Path-based pattern matching using Git's conditional includes
16+
- Configuration management with automatic `.gitconfig.d` directory creation
17+
- Backup functionality for existing git configurations
18+
- CLI commands: setup, add, remove, list, apply
19+
20+
[1.0.0]: https://github.com/befreestudios-io/git-context-switcher/releases/tag/v1.0.0

README.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,41 @@ Switch between git contexts easily for different environments (personal, work, c
1010
## Features
1111

1212
### Interactive Setup Wizard
13+
1314
- Guides you through creating multiple context-specific configurations
1415
- Automatically organizes the configs in your global .gitconfig file
1516

1617
### Multiple Context Support
18+
1719
- Supports any number of different contexts (personal, work, client1, client2, etc.)
1820
- Each context gets its own configuration file
1921

2022
### Path-Based Pattern Matching
23+
2124
- Uses git's conditional includes based on repository paths
2225
- Automatically applies the right identity based on where your repositories are located
2326

2427
### Configuration Management
28+
2529
- Creates a `.gitconfig.d` directory to organize your context-specific configs
2630
- Backs up your existing configuration before making changes
2731
- Handles existing conditional includes safely
2832

2933
## Installation
3034

31-
### Local Installation
35+
### NPM (Recommended)
36+
37+
The easiest way to install Git Context Switcher:
38+
39+
```bash
40+
# Install globally for command-line use
41+
npm install -g git-context-switcher
42+
43+
# After installation, you can use the command from anywhere
44+
git-context --version
45+
```
46+
47+
### Local Development Installation
3248

3349
```bash
3450
# Clone the repository
@@ -45,12 +61,6 @@ chmod +x index.js
4561
npm link
4662
```
4763

48-
### Global Installation (from npm)
49-
50-
```bash
51-
npm install -g git-context-switcher
52-
```
53-
5464
## Usage
5565

5666
### Setup Wizard
@@ -62,6 +72,7 @@ git-context setup
6272
```
6373

6474
The wizard will:
75+
6576
1. Create a `.gitconfig.d` directory in your home folder
6677
2. Back up your existing git config
6778
3. Guide you through setting up multiple contexts
@@ -98,15 +109,19 @@ git-context apply
98109
Git Context Switcher uses Git's [conditional includes](https://git-scm.com/docs/git-config#_conditional_includes) feature to apply different configurations based on the repository path.
99110

100111
For example, if you have:
112+
101113
- Personal projects in `~/personal/`
102114
- Work projects in `~/work/`
103115

104116
The tool will create:
117+
105118
1. A `.gitconfig.d` directory with separate config files:
119+
106120
- `.gitconfig.d/personal.gitconfig`
107121
- `.gitconfig.d/work.gitconfig`
108122

109123
2. Add these conditional includes to your main `.gitconfig`:
124+
110125
```
111126
[includeIf "gitdir:~/personal/**"]
112127
path = ~/.gitconfig.d/personal.gitconfig
@@ -117,6 +132,9 @@ The tool will create:
117132

118133
When you work in different repositories, Git automatically applies the correct configuration based on the repository path.
119134

135+
## Versioning
136+
137+
Git Context Switcher follows [Semantic Versioning](https://semver.org/). For the versions available, see the [tags on this repository](https://github.com/befreestudios-io/git-context-switcher/tags) or check the [CHANGELOG.md](CHANGELOG.md) file.
120138

121139
## License
122140

@@ -136,4 +154,4 @@ Please make sure your code follows the existing style and passes all tests.
136154

137155
## Security
138156

139-
For security issues, please see our [Security Policy](SECURITY.md).
157+
For security issues, please see our [Security Policy](SECURITY.md).

index.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,55 @@
11
#!/usr/bin/env node
22

3-
import { program } from 'commander';
4-
import { createGitContextSwitcher } from './lib/gitContextSwitcher.js';
5-
3+
import { program } from "commander";
4+
import { createGitContextSwitcher } from "./lib/gitContextSwitcher.js";
5+
import { readFileSync } from "fs";
6+
import { dirname, join } from "path";
7+
import { fileURLToPath } from "url";
8+
9+
const __dirname = dirname(fileURLToPath(import.meta.url));
10+
let packageJson;
11+
try {
12+
const packageContent = readFileSync(join(__dirname, "package.json"), "utf8");
13+
packageJson = JSON.parse(packageContent);
14+
} catch (error) {
15+
console.error("Error reading or parsing package.json:", error.message);
16+
process.exit(1);
17+
}
618
const switcher = createGitContextSwitcher();
719

820
program
9-
.name('git-context-switcher')
10-
.description('A tool to manage multiple git context configurations')
11-
.version('1.0.0');
21+
.name("git-context-switcher")
22+
.description("A tool to manage multiple git context configurations")
23+
.version(packageJson.version);
1224

1325
program
14-
.command('setup')
15-
.description('Run the interactive setup wizard')
26+
.command("setup")
27+
.description("Run the interactive setup wizard")
1628
.action(() => switcher.runSetupWizard());
1729

1830
program
19-
.command('list')
20-
.description('List all configured contexts')
31+
.command("list")
32+
.description("List all configured contexts")
2133
.action(() => switcher.listContexts());
2234

2335
program
24-
.command('add')
25-
.description('Add a new context')
36+
.command("add")
37+
.description("Add a new context")
2638
.action(() => switcher.addContext());
2739

2840
program
29-
.command('remove')
30-
.description('Remove an existing context')
41+
.command("remove")
42+
.description("Remove an existing context")
3143
.action(() => switcher.removeContext());
3244

3345
program
34-
.command('apply')
35-
.description('Apply configuration based on current directory')
46+
.command("apply")
47+
.description("Apply configuration based on current directory")
3648
.action(() => switcher.applyContext());
3749

3850
program.parse(process.argv);
3951

4052
// Show help if no command provided
4153
if (!process.argv.slice(2).length) {
4254
program.outputHelp();
43-
}
55+
}

next-steps.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Git Context Switcher - Next Steps
2+
3+
## Project Overview
4+
5+
Git Context Switcher is a tool that helps users switch between different Git configurations (personal, work, client projects, etc.) using Git's conditional includes feature. It creates and manages separate config files in the `.gitconfig.d` directory and updates the main `.gitconfig` with appropriate conditional includes.
6+
7+
## Current Status
8+
9+
- Version 1.0.0 published to npm
10+
- Basic functionality implemented
11+
- File system operations working properly
12+
- Tests are in place
13+
14+
## Next Steps
15+
16+
### High Priority
17+
18+
1. **Complete FileSystem service improvements**
19+
20+
- Finish error handling improvements in the `_ensureTestDirectories` method
21+
- Add better error messaging for permission issues
22+
- Implement file locking for concurrent operations
23+
24+
2. **Documentation Enhancement**
25+
26+
- Update README with more detailed examples
27+
- Add troubleshooting section
28+
- Document all available commands and options
29+
30+
3. **Testing**
31+
- Increase test coverage (aim for >80%)
32+
- Add more integration tests
33+
- Add tests for edge cases around file permissions
34+
35+
### Medium Priority
36+
37+
1. **Feature Enhancements** (v1.1.0)
38+
39+
- Add support for automatic context detection based on repository URL
40+
- Implement context templates for quick setup
41+
- Add ability to export/import contexts for sharing
42+
43+
2. **Performance Improvements** (v1.2.0)
44+
45+
- Optimize file operations for large git config files
46+
- Implement caching for frequently accessed configs
47+
48+
3. **User Experience** (v1.3.0)
49+
- Improve CLI output with better formatting and colors
50+
- Add interactive mode for context setup
51+
- Implement context validation
52+
53+
### Low Priority
54+
55+
1. **Platform Specific Enhancements** (v1.4.0)
56+
57+
- Add specific handling for Windows paths
58+
- Create installation scripts for different platforms
59+
60+
2. **Integration** (v1.5.0)
61+
- Create hooks for popular IDEs and editors
62+
- Add integration with other Git tools
63+
64+
## Version Planning
65+
66+
### Semantic Versioning Guidelines
67+
68+
- **MAJOR (X.0.0)**: Breaking changes that are not backward compatible
69+
- **MINOR (0.X.0)**: New features that are backward compatible
70+
- **PATCH (0.0.X)**: Bug fixes and minor improvements that are backward compatible
71+
72+
### Release Planning
73+
74+
1. **v1.0.x Patches**:
75+
76+
- Bug fixes
77+
- Documentation improvements
78+
- Minor optimizations
79+
80+
2. **v1.1.0 - v1.5.0**:
81+
82+
- Feature additions as outlined above
83+
- Each feature set should be released as a minor version increment
84+
85+
3. **v2.0.0 (Future)**:
86+
- Consider for any breaking changes to the API or CLI interface
87+
- Major architectural improvements
88+
89+
### Release Process
90+
91+
1. Update version in package.json
92+
2. Update CHANGELOG.md with changes
93+
3. Create git tag for the version
94+
4. Push to GitHub
95+
5. Publish to npm
96+
97+
## Notes
98+
99+
- Remember to follow security best practices when dealing with potentially sensitive git config data
100+
- Keep the validation of path safety as a top priority
101+
- Consider backward compatibility when making changes
102+
103+
## Implementation Decisions
104+
105+
- Continue using fs-extra for file operations due to its promise support and enhanced API
106+
- Maintain ES modules pattern for better future compatibility
107+
- Keep the configuration format simple and compatible with Git's native format
108+
109+
Last updated: April 28, 2025

0 commit comments

Comments
 (0)