gitshift 1.0.5 → 1.0.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/LICENSE +15 -0
- package/README.md +70 -0
- package/package.json +9 -3
- package/src/commands/add.js +78 -67
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Akash Lakade
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# GitShift CLI
|
|
2
|
+
|
|
3
|
+
GitShift CLI helps you create, manage, and switch between GitHub identity profiles from the terminal. It stores profiles locally, updates your global Git config, and can generate SSH keys for each profile when needed.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g gitshift
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run it locally from the project:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install
|
|
15
|
+
npm start -- --help
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
GitShift expects the following tools to be available on your machine:
|
|
21
|
+
|
|
22
|
+
- `git`
|
|
23
|
+
- `ssh`
|
|
24
|
+
- `ssh-keygen` for automatic SSH key generation
|
|
25
|
+
- `gh` is recommended and checked by `gitshift doctor`
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
gitshift --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Commands
|
|
34
|
+
|
|
35
|
+
- `gitshift add` - Create a new local profile. Prompts for profile name, GitHub username, email, and whether to generate an SSH key.
|
|
36
|
+
- `gitshift list` - Show all saved profiles.
|
|
37
|
+
- `gitshift current` - Display the active profile.
|
|
38
|
+
- `gitshift use <profile>` - Switch to a saved profile and update global Git user name and email.
|
|
39
|
+
- `gitshift remove <profile>` - Delete a saved profile.
|
|
40
|
+
- `gitshift doctor` - Check whether Git, SSH, and GitHub CLI are installed.
|
|
41
|
+
|
|
42
|
+
## Example Workflow
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
gitshift add
|
|
46
|
+
gitshift list
|
|
47
|
+
gitshift use personal
|
|
48
|
+
gitshift current
|
|
49
|
+
gitshift doctor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
When you create a profile and choose SSH generation, GitShift creates a key under your home directory in `.ssh` using the pattern `gitshift-<profile-name>`.
|
|
53
|
+
|
|
54
|
+
## How It Works
|
|
55
|
+
|
|
56
|
+
Profiles are saved locally on your machine using the app's configuration store. Switching profiles updates your global Git identity with:
|
|
57
|
+
|
|
58
|
+
- `user.name`
|
|
59
|
+
- `user.email`
|
|
60
|
+
|
|
61
|
+
## Notes
|
|
62
|
+
|
|
63
|
+
- Profile names must be unique.
|
|
64
|
+
- `gitshift use <profile>` only switches to profiles that already exist locally.
|
|
65
|
+
- If SSH key generation fails, make sure OpenSSH is installed and available in your shell.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
ISC
|
|
70
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitshift",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "GitHub Account Switcher CLI",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"bin": {
|
|
@@ -11,8 +11,14 @@
|
|
|
11
11
|
"start": "node src/server.js",
|
|
12
12
|
"doctor": "node src/server.js doctor"
|
|
13
13
|
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
|
|
14
|
+
"keywords": [
|
|
15
|
+
"git",
|
|
16
|
+
"github",
|
|
17
|
+
"cli",
|
|
18
|
+
"ssh",
|
|
19
|
+
"account-switcher"
|
|
20
|
+
],
|
|
21
|
+
"author": "Akash Lakade",
|
|
16
22
|
"license": "ISC",
|
|
17
23
|
"type": "module",
|
|
18
24
|
"dependencies": {
|
package/src/commands/add.js
CHANGED
|
@@ -20,80 +20,91 @@ import {
|
|
|
20
20
|
} from "../utils/logger.js";
|
|
21
21
|
|
|
22
22
|
export async function addCommand() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (getProfile(name)) {
|
|
28
|
-
error(
|
|
29
|
-
`Profile "${name}" already exists`
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
process.exitCode = 1;
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const username = await input({
|
|
37
|
-
message: "GitHub Username",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const email = await input({
|
|
41
|
-
message: "Email",
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const createSSH = await confirm({
|
|
45
|
-
message:
|
|
46
|
-
"Generate SSH key automatically?",
|
|
47
|
-
default: true,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
let sshKey = null;
|
|
51
|
-
|
|
52
|
-
if (createSSH) {
|
|
53
|
-
const spinner = ora(
|
|
54
|
-
"Generating SSH key..."
|
|
55
|
-
).start();
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
sshKey = await generateSSHKey(
|
|
59
|
-
name,
|
|
60
|
-
email
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
spinner.succeed(
|
|
64
|
-
"SSH key generated"
|
|
65
|
-
);
|
|
66
|
-
} catch (err) {
|
|
67
|
-
spinner.fail(
|
|
68
|
-
"Unable to generate SSH key"
|
|
69
|
-
);
|
|
23
|
+
try {
|
|
24
|
+
const name = await input({
|
|
25
|
+
message: "Profile Name",
|
|
26
|
+
});
|
|
70
27
|
|
|
28
|
+
if (getProfile(name)) {
|
|
71
29
|
error(
|
|
72
|
-
"
|
|
30
|
+
`Profile "${name}" already exists`
|
|
73
31
|
);
|
|
74
32
|
|
|
75
|
-
if (
|
|
76
|
-
err &&
|
|
77
|
-
typeof err === "object" &&
|
|
78
|
-
"shortMessage" in err &&
|
|
79
|
-
err.shortMessage
|
|
80
|
-
) {
|
|
81
|
-
error(String(err.shortMessage));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
33
|
process.exitCode = 1;
|
|
85
34
|
return;
|
|
86
35
|
}
|
|
87
|
-
}
|
|
88
36
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
37
|
+
const username = await input({
|
|
38
|
+
message: "GitHub Username",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const email = await input({
|
|
42
|
+
message: "Email",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const createSSH = await confirm({
|
|
46
|
+
message:
|
|
47
|
+
"Generate SSH key automatically?",
|
|
48
|
+
default: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
let sshKey = null;
|
|
52
|
+
|
|
53
|
+
if (createSSH) {
|
|
54
|
+
const spinner = ora(
|
|
55
|
+
"Generating SSH key..."
|
|
56
|
+
).start();
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
sshKey = await generateSSHKey(
|
|
60
|
+
name,
|
|
61
|
+
email
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
spinner.succeed(
|
|
65
|
+
"SSH key generated"
|
|
66
|
+
);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
spinner.fail(
|
|
69
|
+
"Unable to generate SSH key"
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
error(
|
|
73
|
+
"Could not create SSH key. Ensure OpenSSH is installed and available."
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
if (
|
|
77
|
+
err &&
|
|
78
|
+
typeof err === "object" &&
|
|
79
|
+
"shortMessage" in err &&
|
|
80
|
+
err.shortMessage
|
|
81
|
+
) {
|
|
82
|
+
error(String(err.shortMessage));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
saveProfile({
|
|
91
|
+
name,
|
|
92
|
+
username,
|
|
93
|
+
email,
|
|
94
|
+
sshKey,
|
|
95
|
+
});
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
success(
|
|
98
|
+
`Profile "${name}" saved locally`
|
|
99
|
+
);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (err && err.name === "ExitPromptError") {
|
|
102
|
+
// User canceled the prompt (Ctrl+C / SIGINT). Exit gracefully.
|
|
103
|
+
process.exitCode = 0;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
error(String(err));
|
|
108
|
+
process.exitCode = 1;
|
|
109
|
+
}
|
|
99
110
|
}
|