@forceuser/git-profile-switcher 0.1.4
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 +96 -0
- package/bin/gip.mjs +25 -0
- package/dist/runtime/app/index.js +677 -0
- package/dist/runtime/cli/completion.js +142 -0
- package/dist/runtime/cli/help.js +288 -0
- package/dist/runtime/cli/parse.js +41 -0
- package/dist/runtime/cli/prompts.js +389 -0
- package/dist/runtime/config/paths.js +39 -0
- package/dist/runtime/git/config.js +188 -0
- package/dist/runtime/profiles/repository.js +183 -0
- package/dist/runtime/profiles/transfer.js +111 -0
- package/dist/runtime/profiles/types.js +23 -0
- package/dist/runtime/prompt/status.js +103 -0
- package/dist/runtime/shell/integration.js +254 -0
- package/dist/runtime/tui/index.js +604 -0
- package/package.json +105 -0
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Git Profile Switcher
|
|
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`.
|
|
5
|
+
|
|
6
|
+
It keeps profile metadata in app data, writes generated profile config files, and manages
|
|
7
|
+
one clearly marked block in your global `~/.gitconfig`.
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```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
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Common Commands
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
gip profile:add
|
|
25
|
+
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
|
|
29
|
+
gip use work
|
|
30
|
+
gip use work --global
|
|
31
|
+
gip now work
|
|
32
|
+
gip now --clear
|
|
33
|
+
gip clear
|
|
34
|
+
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
|
|
41
|
+
gip tui
|
|
42
|
+
gip install:shell zsh
|
|
43
|
+
gip install:prompt zsh
|
|
44
|
+
gip install:prompt zsh --format profile
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Development
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install
|
|
51
|
+
npm run verify
|
|
52
|
+
npm run verify:publish
|
|
53
|
+
```
|
|
54
|
+
|
|
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`.
|
|
57
|
+
|
|
58
|
+
## Publication
|
|
59
|
+
|
|
60
|
+
The package builds to `dist/` and publishes only `bin/`, `dist/runtime/`, `README.md`,
|
|
61
|
+
and `package.json`.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm run build
|
|
65
|
+
npm run smoke:package
|
|
66
|
+
npm run verify:publish
|
|
67
|
+
```
|
|
68
|
+
|
|
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).
|
|
71
|
+
|
|
72
|
+
## Shell Prompt
|
|
73
|
+
|
|
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:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
gip prompt
|
|
79
|
+
gip prompt --json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Use `gip profile:color` to color the managed profile segment in installed shell prompts.
|
|
83
|
+
|
|
84
|
+
## Storage
|
|
85
|
+
|
|
86
|
+
Default app data lives at:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
~/.config/git-profile-switcher/
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Generated Git config snippets live under:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
~/.config/git-profile-switcher/gitconfigs/
|
|
96
|
+
```
|
package/bin/gip.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
8
|
+
const builtRuntime = join(root, "dist", "runtime", "app", "index.js");
|
|
9
|
+
if (existsSync(builtRuntime)) {
|
|
10
|
+
await import(`file://${builtRuntime}`);
|
|
11
|
+
} else {
|
|
12
|
+
const runtime = join(root, "runtime", "app", "index.ts");
|
|
13
|
+
const result = spawnSync(
|
|
14
|
+
process.execPath,
|
|
15
|
+
["--conditions=gip-source", "--experimental-strip-types", runtime, ...process.argv.slice(2)],
|
|
16
|
+
{ stdio: "inherit" },
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if (result.error) {
|
|
20
|
+
console.error(result.error.message);
|
|
21
|
+
process.exitCode = 1;
|
|
22
|
+
} else {
|
|
23
|
+
process.exitCode = result.status ?? 0;
|
|
24
|
+
}
|
|
25
|
+
}
|