@savaryna/git-add-account 0.0.1-beta.3 → 1.0.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 +27 -14
- package/helpers/prompts.js +1 -1
- package/index.js +7 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,45 +1,58 @@
|
|
|
1
1
|
# @savaryna/add-git-account
|
|
2
2
|
|
|
3
|
-
🔐 A small CLI app that allows you to easily add multiple GIT accounts on one machine. It switches between accounts automatically.
|
|
3
|
+
🔐 A small CLI app that allows you to easily add multiple GIT accounts on one machine. It switches between accounts automatically based on the workspace (directory) you are in.
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
Run the command
|
|
7
|
+
Run the command direcly:
|
|
8
8
|
```shell
|
|
9
9
|
npx @savaryna/git-add-account
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
or if you want to install it globally:
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm i -g @savaryna/git-add-account
|
|
16
|
+
|
|
17
|
+
# now you can run it by invoking
|
|
18
|
+
git-add-account
|
|
19
|
+
|
|
20
|
+
# or
|
|
21
|
+
gaa
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
After going through all the steps:
|
|
13
25
|
|
|
14
26
|
```shell
|
|
15
|
-
Need to install the following packages:
|
|
16
|
-
@savaryna/git-add-account
|
|
17
|
-
Ok to proceed? (y)
|
|
18
27
|
✔ Name to use for this account: … Example Name
|
|
19
28
|
✔ Email to use for this account: … example@email.com
|
|
20
29
|
✔ Workspace to use for this account: … /Users/savaryna/code/email
|
|
21
30
|
✔ Name to use for SSH keys: … email_example_name
|
|
22
31
|
Enter passphrase (empty for no passphrase):
|
|
23
32
|
Enter same passphrase again:
|
|
24
|
-
✔
|
|
33
|
+
✔ Do you want to sign your work? … no / yes
|
|
25
34
|
|
|
26
|
-
Your public SSH key is: ssh-ed25519
|
|
35
|
+
Your public SSH key is: ssh-ed25519 AAAAC3NlZ...DITJheGo example@email.com
|
|
27
36
|
You can also find it here: /Users/savaryna/.ssh/git_email_example_name.pub
|
|
28
37
|
Add it to your favorite GIT provider and enjoy!
|
|
29
38
|
|
|
30
|
-
✨ Done. Thanks for using git-add-account!
|
|
39
|
+
✨ Done. Thanks for using @savaryna/git-add-account!
|
|
31
40
|
```
|
|
32
41
|
|
|
33
|
-
|
|
42
|
+
You will be presented with your public SSH key so you can copy, and add it to your GIT provider. For example GitHub[^1]:
|
|
34
43
|
|
|
35
|
-
1. Go to your account [settings/keys](https://github.com/settings/keys)
|
|
44
|
+
1. Go to your account [settings / keys](https://github.com/settings/keys)
|
|
36
45
|
2. Click on `New SSH key`
|
|
37
|
-
3. Give it
|
|
38
|
-
4.
|
|
39
|
-
|
|
46
|
+
3. Give it any title
|
|
47
|
+
4. Choose `Authentication Key` for key type
|
|
48
|
+
4. Paste in the public SSH key copied earlier in the key field
|
|
49
|
+
5. Repeat steps 2 - 4 to add a `Signing Key` key type, if you chose to sign your work (Commits, Tags, Pushes)[^2]
|
|
40
50
|
6. Done! Now you can go to the workspace you chose for the account `/Users/savaryna/code/email` in this example, and all the GIT
|
|
41
51
|
commands issued from this and children directories will automatically use the correct account.
|
|
42
52
|
|
|
43
53
|
## License
|
|
44
54
|
|
|
45
55
|
MIT – See [LICENSE](LICENSE) file.
|
|
56
|
+
|
|
57
|
+
[^1]: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?tool=webui
|
|
58
|
+
[^2]: https://docs.github.com/en/authentication/managing-commit-signature-verification
|
package/helpers/prompts.js
CHANGED
|
@@ -2,7 +2,7 @@ const prompts = require('prompts');
|
|
|
2
2
|
|
|
3
3
|
const exit = (code = 0, reason = null) => {
|
|
4
4
|
console.log(reason ? `\n${reason}\n` : '');
|
|
5
|
-
console.log(`${code ? '😵 Exited.' : '✨ Done.'} Thanks for using git-add-account!\n`);
|
|
5
|
+
console.log(`${code ? '😵 Exited.' : '✨ Done.'} Thanks for using @savaryna/git-add-account!\n`);
|
|
6
6
|
process.exit(code);
|
|
7
7
|
};
|
|
8
8
|
|
package/index.js
CHANGED
|
@@ -117,19 +117,21 @@ async function main() {
|
|
|
117
117
|
// Set default ssh command
|
|
118
118
|
await exec(`git config --file ${workspaceGitConfigPath} core.sshCommand "ssh -i ${sshKeyPath}"`);
|
|
119
119
|
|
|
120
|
-
const {
|
|
120
|
+
const { signYourWork } = await prompts({
|
|
121
121
|
type: 'toggle',
|
|
122
|
-
name: '
|
|
123
|
-
message: '
|
|
122
|
+
name: 'signYourWork',
|
|
123
|
+
message: 'Do you want to sign your work?',
|
|
124
124
|
initial: true,
|
|
125
125
|
active: 'yes',
|
|
126
126
|
inactive: 'no',
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
// Enable
|
|
130
|
-
if (
|
|
129
|
+
// Enable signing
|
|
130
|
+
if (signYourWork) {
|
|
131
131
|
await exec(`git config --file ${workspaceGitConfigPath} gpg.format ssh`);
|
|
132
132
|
await exec(`git config --file ${workspaceGitConfigPath} commit.gpgsign true`);
|
|
133
|
+
await exec(`git config --file ${workspaceGitConfigPath} push.gpgsign if-asked`);
|
|
134
|
+
await exec(`git config --file ${workspaceGitConfigPath} tag.gpgsign true`);
|
|
133
135
|
await exec(`git config --file ${workspaceGitConfigPath} user.signingkey ${sshKeyPath}`);
|
|
134
136
|
}
|
|
135
137
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savaryna/git-add-account",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "🔐 A small CLI app that allows you to easily add multiple GIT accounts on one machine. It switches between accounts automatically.",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "🔐 A small CLI app that allows you to easily add multiple GIT accounts on one machine. It switches between accounts automatically based on the workspace (directory) you are in.",
|
|
5
5
|
"homepage": "https://github.com/savaryna/git-add-account#readme",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"add",
|