@forceuser/git-profile-switcher 0.1.6 → 0.1.7

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 CHANGED
@@ -1,96 +1,177 @@
1
1
  # Git Profile Switcher
2
2
 
3
- `gip` is a small local-first CLI/TUI for managing multiple Git identities and applying
4
- them automatically per directory with Git `includeIf`.
3
+ `gip` helps you use the right Git identity in the right directory.
5
4
 
6
- It keeps profile metadata in app data, writes generated profile config files, and manages
7
- one clearly marked block in your global `~/.gitconfig`.
5
+ It stores named profiles, writes Git `includeIf` rules for directory-based switching,
6
+ and can show the active profile in your shell prompt.
8
7
 
9
- ## Quick Start
8
+ ## Install
10
9
 
11
10
  ```bash
12
- npm test
13
- npm run dev -- profile:add
14
- npm run dev -- profile:add work --user-name "Work Name" --user-email work@example.com
15
- npm run dev -- use
16
- npm run dev -- use work
17
- npm run dev -- prompt
18
- npm run dev -- prompt --format profile
11
+ npm install -g @forceuser/git-profile-switcher
19
12
  ```
20
13
 
21
- ## Common Commands
14
+ After installation, the CLI is available as both:
22
15
 
23
16
  ```bash
24
- gip profile:add
17
+ gip --help
18
+ git-profile-switcher --help
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ Create your profiles:
24
+
25
+ ```bash
26
+ gip profile:add personal
25
27
  gip profile:add work --user-name "Work Name" --user-email work@example.com
26
- gip profile:list
27
- gip profile:color work cyan
28
- gip use
28
+ ```
29
+
30
+ Use a profile in the current directory:
31
+
32
+ ```bash
33
+ cd ~/Projects/work-app
29
34
  gip use work
30
- gip use work --global
31
- gip now work
32
- gip now --clear
35
+ ```
36
+
37
+ From now on, Git uses that profile in this directory and its Git repositories.
38
+
39
+ Check what Git identity is active:
40
+
41
+ ```bash
42
+ gip doctor
43
+ ```
44
+
45
+ ## Daily Use
46
+
47
+ Pick from your saved profiles:
48
+
49
+ ```bash
50
+ gip use
51
+ ```
52
+
53
+ Set a global fallback identity:
54
+
55
+ ```bash
56
+ gip use personal --global
57
+ ```
58
+
59
+ Clear the current directory rule:
60
+
61
+ ```bash
33
62
  gip clear
63
+ ```
64
+
65
+ Clear the global fallback identity:
66
+
67
+ ```bash
34
68
  gip clear --global
35
- gip rule:add ~/Developer/Work
36
- gip rule:add work ~/Developer/Work
37
- gip rule:list
38
- gip apply
39
- gip doctor
40
- gip prompt --format profile
69
+ ```
70
+
71
+ Open the terminal UI:
72
+
73
+ ```bash
41
74
  gip tui
75
+ ```
76
+
77
+ ## Session-Only Identity
78
+
79
+ Use `now` when you want a profile only in the current terminal session:
80
+
81
+ ```bash
42
82
  gip install:shell zsh
43
- gip install:prompt zsh
44
- gip install:prompt zsh --format profile
83
+ source ~/.zshrc
84
+
85
+ gip now work
86
+ gip now --clear
45
87
  ```
46
88
 
47
- ## Development
89
+ Without shell integration, use:
48
90
 
49
91
  ```bash
50
- npm install
51
- npm run verify
52
- npm run verify:publish
92
+ eval "$(gip now work --exports)"
53
93
  ```
54
94
 
55
- `npm install` runs the local Husky setup when the checkout has a `.git` directory.
56
- Pre-commit runs `lint-staged`; pre-push runs `npm run verify`.
95
+ ## Shell Prompt
96
+
97
+ Install prompt integration to show the active profile in your prompt:
57
98
 
58
- ## Publication
99
+ ```bash
100
+ gip install:prompt zsh
101
+ source ~/.zshrc
102
+ ```
59
103
 
60
- The package builds to `dist/` and publishes only `bin/`, `dist/runtime/`, `README.md`,
61
- and `package.json`.
104
+ Choose prompt colors per profile:
62
105
 
63
106
  ```bash
64
- npm run build
65
- npm run smoke:package
66
- npm run verify:publish
107
+ gip profile:color work cyan
67
108
  ```
68
109
 
69
- GitHub Actions publishes to the public npm registry from SemVer tags or GitHub releases.
70
- See [Release With GitHub Actions](./docs/operations/release-with-github-actions.md).
110
+ Install completion, session wrapper, and prompt integration together:
71
111
 
72
- ## Shell Prompt
112
+ ```bash
113
+ gip install:all zsh
114
+ ```
115
+
116
+ Supported shells: `zsh`, `bash`, and `fish`.
117
+
118
+ ## Move To A New Machine
73
119
 
74
- After installing prompt integration, your shell prompt can show the effective Git identity
75
- for the current directory. The prompt command itself is intentionally plain:
120
+ Export profiles:
76
121
 
77
122
  ```bash
78
- gip prompt
79
- gip prompt --json
123
+ gip export
80
124
  ```
81
125
 
82
- Use `gip profile:color` to color the managed profile segment in installed shell prompts.
126
+ Import profiles on another machine:
83
127
 
84
- ## Storage
128
+ ```bash
129
+ gip import
130
+ ```
85
131
 
86
- Default app data lives at:
132
+ By default, both commands use:
133
+
134
+ ```text
135
+ ~/gip-profiles.json
136
+ ```
137
+
138
+ Directory rules are machine-specific, so `gip` skips them by default. Include them only
139
+ when you explicitly want to migrate the same directory mappings:
140
+
141
+ ```bash
142
+ gip export --rules
143
+ gip import --rules
144
+ ```
145
+
146
+ ## Where Data Lives
147
+
148
+ Profile metadata:
87
149
 
88
150
  ```text
89
151
  ~/.config/git-profile-switcher/
90
152
  ```
91
153
 
92
- Generated Git config snippets live under:
154
+ Generated Git config snippets:
93
155
 
94
156
  ```text
95
157
  ~/.config/git-profile-switcher/gitconfigs/
96
158
  ```
159
+
160
+ `gip` manages one marked block in your global Git config and leaves unrelated content
161
+ alone.
162
+
163
+ ## Useful Commands
164
+
165
+ ```bash
166
+ gip profile:list
167
+ gip profile:remove work
168
+ gip rule:list
169
+ gip rule:add work ~/Projects/work-app
170
+ gip rule:remove <rule-id>
171
+ gip paths
172
+ gip prompt
173
+ gip help <command>
174
+ ```
175
+
176
+ For development and release notes, see
177
+ [Development](https://github.com/forceuser/git-profile-switcher/blob/main/docs/development.md).
@@ -241,7 +241,7 @@ export async function main(args = process.argv.slice(2)) {
241
241
  }
242
242
  if (command === "export") {
243
243
  const data = await repository.read();
244
- const exportData = hasFlag(parsed, "profiles-only") ? { ...data, rules: [] } : data;
244
+ const exportData = hasFlag(parsed, "rules") ? data : { ...data, rules: [] };
245
245
  const bundle = createProfileExportBundle(exportData);
246
246
  const outputPath = getStringFlag(parsed, "output") ??
247
247
  parsed.positionals[0] ??
@@ -266,7 +266,7 @@ export async function main(args = process.argv.slice(2)) {
266
266
  }
267
267
  const resolvedInputPath = resolve(inputPath);
268
268
  const incoming = parseProfileImportBundle(JSON.parse(await readFile(resolvedInputPath, "utf8")));
269
- const importData = hasFlag(parsed, "profiles-only") ? { ...incoming, rules: [] } : incoming;
269
+ const importData = hasFlag(parsed, "rules") ? incoming : { ...incoming, rules: [] };
270
270
  const current = await repository.read();
271
271
  const next = hasFlag(parsed, "replace")
272
272
  ? importData
@@ -102,25 +102,25 @@ export const COMMANDS = [
102
102
  },
103
103
  {
104
104
  name: "export",
105
- summary: "Export profiles and directory rules for migration.",
106
- usage: "gip export [--output <path>] [--profiles-only]\n gip export <path>",
107
- completionFlags: ["--output", "--profiles-only", "--help"],
105
+ summary: "Export profiles for migration, optionally with directory rules.",
106
+ usage: "gip export [--output <path>] [--rules]\n gip export <path>",
107
+ completionFlags: ["--output", "--rules", "--help"],
108
108
  examples: [
109
109
  "gip export",
110
- "gip export --profiles-only",
110
+ "gip export --rules",
111
111
  "gip export --output ./gip-profiles.backup.json",
112
112
  "gip export ./gip.json",
113
113
  ],
114
114
  },
115
115
  {
116
116
  name: "import",
117
- summary: "Import profiles and directory rules from a migration file.",
118
- usage: "gip import [--input <path>] [--replace] [--profiles-only] [--no-apply]\n gip import <path>",
119
- completionFlags: ["--input", "--replace", "--profiles-only", "--no-apply", "--help"],
117
+ summary: "Import profiles from a migration file, optionally with directory rules.",
118
+ usage: "gip import [--input <path>] [--replace] [--rules] [--no-apply]\n gip import <path>",
119
+ completionFlags: ["--input", "--replace", "--rules", "--no-apply", "--help"],
120
120
  examples: [
121
121
  "gip import",
122
122
  "gip import --input ./gip-profiles.backup.json",
123
- "gip import --profiles-only",
123
+ "gip import --rules",
124
124
  "gip import ./gip.json --replace",
125
125
  "gip import ./gip.json --no-apply",
126
126
  ],
@@ -131,8 +131,8 @@ async function diagnosticsMenu(context) {
131
131
  }
132
132
  async function migrationMenu(context) {
133
133
  return await runMenu(context, "Import and export", [
134
- { label: "Export profiles and rules", run: () => exportProfiles(context) },
135
- { label: "Import profiles and rules", run: () => importProfiles(context) },
134
+ { label: "Export profiles", run: () => exportProfiles(context) },
135
+ { label: "Import profiles", run: () => importProfiles(context) },
136
136
  { label: "Back", run: async () => "back" },
137
137
  ]);
138
138
  }
@@ -472,8 +472,8 @@ async function selectPromptFormat(context) {
472
472
  }
473
473
  async function selectTransferScope(context, prompt) {
474
474
  const scopes = [
475
- "profiles-and-rules",
476
475
  "profiles-only",
476
+ "profiles-and-rules",
477
477
  ];
478
478
  const scope = await context.prompts.selectOne({
479
479
  prompt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forceuser/git-profile-switcher",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "private": false,
5
5
  "description": "CLI and TUI for automatic per-directory Git user identity switching.",
6
6
  "keywords": [